unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/0000755000015700001700000000000012201153753021676 5ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/po/0000755000015700001700000000000012201153753022314 5ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/po/POTFILES.in0000644000015700001700000000015112201153510024055 0ustar pbuserpbgroup00000000000000[encoding: UTF-8] src/unity_firefoxbookmarks_daemon.py [type: gettext/ini]data/firefoxbookmarks.scope.in unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/po/unity-scope-firefoxbookmarks.pot0000644000015700001700000000231712201153510030662 0ustar pbuserpbgroup00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #: ../src/unity_firefoxbookmarks_daemon.py:35 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-02-25 13:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/unity_firefoxbookmarks_daemon.py:33 msgid "Search Bookmarks" msgstr "" #: ../src/unity_firefoxbookmarks_daemon.py:34 msgid "Sorry, there are no Bookmarks that match your search." msgstr "" #: ../src/unity_firefoxbookmarks_daemon.py:44 msgid "Bookmarks" msgstr "" #: ../data/firefoxbookmarks.scope.in.h:1 msgid "firefoxbookmarks;" msgstr "" #: ../data/firefoxbookmarks.scope.in.h:2 msgid "Firefoxbookmarks" msgstr "" #: ../data/firefoxbookmarks.scope.in.h:3 msgid "Find Firefoxbookmarks items" msgstr "" #: ../data/firefoxbookmarks.scope.in.h:4 msgid "Search Firefoxbookmarks" msgstr "" unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/MANIFEST.in0000644000015700001700000000007612201153510023426 0ustar pbuserpbgroup00000000000000include MANIFEST.in include src/* include data/* include po/* unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/0000755000015700001700000000000012201153753023040 5ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/fake-firefox.py0000755000015700001700000000010412201153510025745 0ustar pbuserpbgroup00000000000000#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys sys.exit(1) unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/__init__.py0000644000015700001700000000000012201153510025126 0ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/0000755000015700001700000000000012201153753023751 5ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_fail/0000755000015700001700000000000012201153753031330 5ustar pbuserpbgroup00000000000000././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_fail/mock_firefoxbookmarks_failunity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_fail/mock_firefox0000644000015700001700000000000612201153510033711 0ustar pbuserpbgroup00000000000000 unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_pass/0000755000015700001700000000000012201153753031363 5ustar pbuserpbgroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_pass/profile.default/unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_pass/profile.defa0000755000015700001700000000000012201153753033642 5ustar pbuserpbgroup00000000000000././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_pass/profile.default/places.sqliteunity-scope-firefoxbookmarks-0.1+13.10.20130809.1/tests/data/mock_firefoxbookmarks_pass/profile.defa0000644000015700001700000022000012201153510033625 0ustar pbuserpbgroup00000000000000SQLite format 3@ ~Q~-'   [ i f $/2~G%indexmoz_favicons_guid_uniqueindexmoz_faviconsCREATE UNIQUE INDEX moz_favicons_guid_uniqueindex ON moz_favicons (guid)vC!indexmoz_places_guid_uniqueindexmoz_placesCREATE UNIQUE INDEX moz_places_guid_uniqueindex ON moz_places (guid)I'!indexmoz_bookmarks_guid_uniqueindexmoz_bookmarksCREATE UNIQUE INDEX moz_bookmarks_guid_uniqueindex ON moz_bookmarks (guid)sA!indexmoz_places_url_uniqueindexmoz_placesCREATE UNIQUE INDEX moz_places_url_uniqueindex ON moz_places (url)~ G!!indexmoz_places_lastvisitdateindexmoz_placesCREATE INDEX moz_places_lastvisitdateindex ON moz_places (last_visit_date)m =! indexmoz_places_frecencyindexmoz_places CREATE INDEX moz_places_frecencyindex ON moz_places (frecency)j 7! indexmoz_places_visitcountmoz_places CREATE INDEX moz_places_visitcount ON moz_places (visit_count)e 5!indexmoz_places_hostindexmoz_places CREATE INDEX moz_places_hostindex ON moz_places (rev_host)m ;! indexmoz_places_faviconindexmoz_places CREATE INDEX moz_places_faviconindex ON moz_places (favicon_id)S'5indexmoz_bookmarks_itemlastmodifiedindexmoz_bookmarks CREATE INDEX moz_bookmarks_itemlastmodifiedindex ON moz_bookmarks (fk, lastModified)}?'!indexmoz_bookmarks_parentindexmoz_bookmarksCREATE INDEX moz_bookmarks_parentindex ON moz_bookmarks (parent, position)q;' indexmoz_bookmarks_itemindexmoz_bookmarksCREATE INDEX moz_bookmarks_itemindex ON moz_bookmarks (fk, type)K%%[tablesqlite_stat1sqlite_stat1CREATE TABLE sqlite_stat1(tbl,idx,stat)Q!!mtablemoz_placesmoz_placesCREATE TABLE moz_places ( id INTEGER PRIMARY KEY, url LONGVARCHAR, title LONGVARCHAR, rev_host LONGVARCHAR, visit_count INTEGER DEFAULT 0, hidden INTEGER DEFAULT 0 NOT NULL, typed INTEGER DEFAULT 0 NOT NULL, favicon_id INTEGER, frecency INTEGER DEFAULT -1 NOT NULL, last_visit_date INTEGER , guid TEXT)/%%!tablemoz_faviconsmoz_faviconsCREATE TABLE moz_favicons ( id INTEGER PRIMARY KEY, url LONGVARCHAR UNIQUE, data BLOB, mime_type VARCHAR(32), expiration LONG, guid TEXT)7K%indexsqlite_autoindex_moz_favicons_1moz_favicons''ctablemoz_bookmarksmoz_bookmarksCREATE TABLE moz_bookmarks ( id INTEGER PRIMARY KEY, type INTEGER, fk INTEGER DEFAULT NULL, parent INTEGER, position INTEGER, title LONGVARCHAR, keyword_id INTEGER, folder_type TEXT, dateAdded INTEGER, lastModified INTEGER, guid TEXT) 0 %Ubuntu2; # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from gi.repository import GLib, Gio from gi.repository import Unity import gettext import os import webbrowser import sqlite3 import hashlib APP_NAME = 'unity-scope-firefoxbookmarks' LOCAL_PATH = '/usr/share/locale/' gettext.bindtextdomain(APP_NAME, LOCAL_PATH) gettext.textdomain(APP_NAME) _ = gettext.gettext GROUP_NAME = 'com.canonical.Unity.Scope.Webhistory.Firefoxbookmarks' UNIQUE_PATH = '/com/canonical/unity/scope/webhistory/firefoxbookmarks' SEARCH_HINT = _('Search Bookmarks') NO_RESULTS_HINT = _('Sorry, there are no Bookmarks that match your search.') PROVIDER_CREDITS = _('') SVG_DIR = '/usr/share/icons/unity-icon-theme/places/svg/' PROVIDER_ICON = SVG_DIR + 'group-browserbookmarks.svg' DEFAULT_RESULT_ICON = SVG_DIR + 'group-browserbookmarks.svg' DEFAULT_RESULT_MIMETYPE = 'text/html' DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT FIREFOX_EXECUTABLE = '/usr/bin/firefox' BOOKMARKS_PATH = os.getenv("HOME") + "/.mozilla/firefox/" BOOKMARKS_QUERY = '''SELECT moz_bookmarks.title, moz_places.url, moz_favicons.url, '%s', '%s' FROM moz_bookmarks, moz_places, moz_favicons WHERE moz_places.id = moz_bookmarks.fk AND moz_places.favicon_id = moz_favicons.id AND moz_bookmarks.title is not null AND moz_places.favicon_id is not null AND moz_bookmarks.type = 1 AND (moz_bookmarks.title LIKE '%%%s%%' OR moz_places.url LIKE '%%%s%%') ORDER BY moz_bookmarks.lastModified;''' c1 = {'id': 'bookmarks', 'name': _('Bookmarks'), 'icon': SVG_DIR + 'group-installed.svg', 'renderer': Unity.CategoryRenderer.VERTICAL_TILE} CATEGORIES = [c1] FILTERS = [] EXTRA_METADATA = [] def get_bookmarks_from_firefox(path, search): ''' Gets a list of bookmarks from the user's firefox profiles ''' # Build Firefox's profile paths firefox_dbfiles = [] bookmarks = [] for folder in os.listdir(path): if '.' in folder: firefox_dbfiles.append(path + folder + "/places.sqlite") for dbfile in firefox_dbfiles: if os.path.exists(dbfile): try: filename = dbfile.replace('/places.sqlite', '') file_name, profile_name = os.path.splitext(filename) profile_name = profile_name[1:] sqlite_query = BOOKMARKS_QUERY % (profile_name, dbfile, search, search) conn = sqlite3.connect(dbfile) connection = conn.cursor() connection.execute(sqlite_query) profile_bookmarks = connection.fetchall() for bookmark in profile_bookmarks: bookmarks.append(bookmark) connection.close() except sqlite3.DatabaseError: pass return bookmarks def search(search, filters): ''' Search for help documents matching the search string ''' results = [] bookmarks = get_bookmarks_from_firefox(BOOKMARKS_PATH, search) for bookmark in bookmarks: # Stop Firefox's smart bookmark folders from showing up if not bookmark[1].find("place:") == -1: continue path = bookmark[4].replace('places.sqlite', 'thumbnails/') path = path.replace('.mozilla/', '.cache/mozilla/') icon = '%s%s.png' % (path, hashlib.md5(bookmark[1].encode()).hexdigest()) if not os.path.exists(icon): icon = None results.append({'uri': bookmark[1], 'icon': icon, 'category': 0, 'title': bookmark[0], 'user': GLib.Variant('s', bookmark[3])}) return results def activate(result, metadata, id): ''' Open the url in the default webbrowser Args: uri: The url to be opened ''' parameters = [FIREFOX_EXECUTABLE, result.uri] GLib.spawn_async(parameters) return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri=None) class Preview(Unity.ResultPreviewer): ''' Creates the preview for the result ''' def do_run(self): ''' Create a preview and return it ''' preview = Unity.GenericPreview.new(self.result.title, '', None) preview.props.subtitle = self.result.uri if os.path.exists(self.result.icon_hint): preview.props.image_source_uri = 'file://' + self.result.icon_hint else: preview.props.image = Gio.ThemedIcon.new('gtk-about') show_action = Unity.PreviewAction.new("show", _("Open"), None) preview.add_action(show_action) return preview # Classes below this point establish communication # with Unity, you probably shouldn't modify them. class MySearch(Unity.ScopeSearchBase): def __init__(self, search_context): super(MySearch, self).__init__() self.set_search_context(search_context) def do_run(self): ''' Adds results to the model ''' try: result_set = self.search_context.result_set for i in search(self.search_context.search_query, self.search_context.filter_state): if not 'uri' in i or not i['uri'] or i['uri'] == '': continue if not 'icon' in i or not i['icon'] or i['icon'] == '': i['icon'] = DEFAULT_RESULT_ICON if not 'mimetype' in i or not i['mimetype'] or i['mimetype'] == '': i['mimetype'] = DEFAULT_RESULT_MIMETYPE if not 'result_type' in i or not i['result_type'] or i['result_type'] == '': i['result_type'] = DEFAULT_RESULT_TYPE if not 'category' in i or not i['category'] or i['category'] == '': i['category'] = 0 if not 'title' in i or not i['title']: i['title'] = '' if not 'comment' in i or not i['comment']: i['comment'] = '' if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': i['dnd_uri'] = i['uri'] i['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS) result_set.add_result(**i) except Exception as error: print(error) class Scope(Unity.AbstractScope): def __init__(self): Unity.AbstractScope.__init__(self) def do_get_search_hint(self): return SEARCH_HINT def do_get_schema(self): ''' Adds specific metadata fields ''' schema = Unity.Schema.new() if EXTRA_METADATA: for m in EXTRA_METADATA: schema.add_field(m['id'], m['type'], m['field']) #FIXME should be REQUIRED for credits schema.add_field('provider_credits', 's', Unity.SchemaFieldType.OPTIONAL) return schema def do_get_categories(self): ''' Adds categories ''' cs = Unity.CategorySet.new() if CATEGORIES: for c in CATEGORIES: cat = Unity.Category.new(c['id'], c['name'], Gio.ThemedIcon.new(c['icon']), c['renderer']) cs.add(cat) return cs def do_get_filters(self): ''' Adds filters ''' fs = Unity.FilterSet.new() #if FILTERS: # return fs def do_get_group_name(self): return GROUP_NAME def do_get_unique_name(self): return UNIQUE_PATH def do_create_search_for_query(self, search_context): se = MySearch(search_context) return se def do_activate(self, result, metadata, id): return activate(result, metadata, id) def do_create_previewer(self, result, metadata): ''' Creates a preview when a resut is right-clicked ''' result_preview = Preview() result_preview.set_scope_result(result) result_preview.set_search_metadata(metadata) return result_preview def load_scope(): return Scope() unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/src/__init__.py0000644000015700001700000000000012201153510024553 0ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/setup.py0000644000015700001700000000166712201153510023411 0ustar pbuserpbgroup00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Setup file for firefoxbookmarks dash plugin ''' from distutils.core import setup from DistUtilsExtra.command import build_extra from DistUtilsExtra.command import build_i18n setup(name='unity-scope-firefoxbookmarks', version='0.1', author='Mark Tully', author_email='markjtully@gmail.com', url='http://launchpad.net/ubuntu-scopes', license='GNU General Public License (GPL)', data_files=[('share/dbus-1/services', ['data/unity-scope-firefoxbookmarks.service']), #('share/icons/unity-icon-theme/places/svg', ['data/icons/service-firefoxbookmarks.svg']), ('share/unity-scopes/firefoxbookmarks', ['src/unity_firefoxbookmarks_daemon.py']), ('share/unity-scopes/firefoxbookmarks', ['src/__init__.py']), ], cmdclass={'build': build_extra.build_extra, 'build_i18n': build_i18n.build_i18n, }) unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/setup.cfg0000644000015700001700000000022412201153510023504 0ustar pbuserpbgroup00000000000000[build] i18n=True [build_i18n] domain=unity-scope-firefoxbookmarks desktop_files=[('share/unity/scopes/web', ('data/firefoxbookmarks.scope.in',))] unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/data/0000755000015700001700000000000012201153753022607 5ustar pbuserpbgroup00000000000000unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/data/unity-scope-firefoxbookmarks.service0000644000015700001700000000025412201153510032011 0ustar pbuserpbgroup00000000000000[D-BUS Service] Name=com.canonical.Unity.Scope.Webhistory.Firefoxbookmarks Exec=/usr/bin/python3 /usr/share/unity-scopes/scope-runner-dbus.py -s web/firefoxbookmarks.scope unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/data/firefoxbookmarks.scope.in0000644000015700001700000000154412201153510027615 0ustar pbuserpbgroup00000000000000[Scope] DBusName=com.canonical.Unity.Scope.Webhistory.Firefoxbookmarks DBusPath=/com/canonical/unity/scope/webhistory/firefoxbookmarks Icon=/usr/share/icons/unity-icon-theme/places/svg/group-browserbookmarks.svg QueryBinary=firefox _Keywords=firefoxbookmarks;firefox;web;bookmarks; RequiredMetadata= OptionalMetadata= Loader=/usr/share/unity-scopes/firefoxbookmarks/unity_firefoxbookmarks_daemon.py Module=firefoxbookmarks.unity_firefoxbookmarks_daemon ModuleType=python3 RemoteContent=false Type=web _Name=Firefox Bookmarks _Description=This is an Ubuntu search plugin that enables information from Firefox to be searched and displayed in the Dash underneath the Web header. If you do not wish to search this content source, you can disable this search plugin. _SearchHint=Search Firefoxbookmarks [Desktop Entry] X-Ubuntu-Gettext-Domain=unity-scope-firefoxbookmarks unity-scope-firefoxbookmarks-0.1+13.10.20130809.1/data/icons/0000755000015700001700000000000012201153753023722 5ustar pbuserpbgroup00000000000000