conduit r1824 - in trunk: . conduit/modules conduit/modules/Firefox3Module
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1824 - in trunk: . conduit/modules conduit/modules/Firefox3Module
- Date: Tue, 20 Jan 2009 11:04:19 +0000 (UTC)
Author: jstowers
Date: Tue Jan 20 11:04:18 2009
New Revision: 1824
URL: http://svn.gnome.org/viewvc/conduit?rev=1824&view=rev
Log:
2009-01-21 John Stowers <john stowers gmail com>
* conduit/modules/Firefox3Module.py:
* conduit/modules/Firefox3Module/Firefox3Module.py:
* conduit/modules/Firefox3Module/Makefile.am:
* conduit/modules/Firefox3Module/config.glade:
* conduit/modules/Makefile.am:
* configure.ac: Add a more comprehensive firefox module
with support for multiple profiles.
Fixes #568372 (Andrew Stormont)
Added:
trunk/conduit/modules/Firefox3Module/
trunk/conduit/modules/Firefox3Module/Firefox3Module.py
trunk/conduit/modules/Firefox3Module/Makefile.am
trunk/conduit/modules/Firefox3Module/config.glade
Removed:
trunk/conduit/modules/Firefox3Module.py
Modified:
trunk/ChangeLog
trunk/conduit/modules/Makefile.am
trunk/configure.ac
Added: trunk/conduit/modules/Firefox3Module/Firefox3Module.py
==============================================================================
--- (empty file)
+++ trunk/conduit/modules/Firefox3Module/Firefox3Module.py Tue Jan 20 11:04:18 2009
@@ -0,0 +1,139 @@
+# Copyright 2009 - Andrew Stormont <andyjstormont googlemail com>
+
+import os
+from ConfigParser import ConfigParser
+import sqlite3
+import logging
+import conduit
+import conduit.dataproviders.DataProvider as DataProvider
+import conduit.utils as Utils
+from conduit.datatypes.Bookmark import Bookmark
+import conduit.Exceptions as Exceptions
+
+log = logging.getLogger("modules.Firefox3")
+
+MODULES = {
+ "Firefox3DataProviderSource" : { "type" : "dataprovider" },
+}
+
+class Firefox3DataProviderSource( DataProvider.DataSource ):
+ """
+ Firefox 3 Bookmarks datasource
+ """
+
+ _name_ = "Firefox 3 Bookmarks"
+ _description_ = "Syncronize your Firefox 3 Bookmarks"
+ _category_ = conduit.dataproviders.CATEGORY_MISC
+ _module_type_ = "source"
+ _out_type_ = "bookmark"
+ _icon_ = "applications-internet"
+ _configurable_ = True
+
+ # nasty constants
+ SYNCERROR = "Can't read Firefox 3 Bookmarks - please make sure Firefox is closed."
+ ( BOOKMARKS_ROOT, BOOKMARKS_MENU, BOOKMARKS_TOOLBAR ) = range( 1,4 )
+
+ def __init__( self ):
+ self.Bookmarks = []
+
+ self.FirefoxDir = os.path.expanduser( "~/.mozilla/firefox/" )
+ self.Cf = ConfigParser()
+ self.Cf.read( self.FirefoxDir + "profiles.ini" )
+ self.ProfilePath = self.Cf.get( "Profile0", "Path" ) # default
+ DataProvider.DataSource.__init__( self )
+
+ def refresh( self ):
+ # sqlite3 is not thread safe, so we cannot preserve connections in this class
+ Con = sqlite3.connect( self.FirefoxDir + self.ProfilePath + "/places.sqlite" )
+ try:
+ Cur = Con.execute( "select * from moz_bookmarks" )
+ except:
+ log.debug( self.SYNCERROR )
+ raise Exceptions.SyncronizeError( self.SYNCERROR )
+ for Line in Cur.fetchall():
+ ( bid, btype, fk, parent, position, title, keywordid, folder_type, dateadded, lastmodified ) = Line
+ if not fk:
+ # this bookmark has no url, that means it's a folder or something firefox specific
+ continue
+ else:
+ bookmark = Bookmark( title, self.get_bookmark_url_from_fk( fk ) )
+ bookmark.set_UID( bookmark.get_hash() )
+ self.Bookmarks.append( bookmark )
+ Con.close()
+ DataProvider.DataSource.refresh( self )
+
+ def get_all( self ):
+ DataProvider.DataSource.get_all( self )
+ retval = []
+ for bookmark in self.Bookmarks:
+ retval.append( bookmark.get_UID() )
+ return retval
+
+ def get( self, luid ):
+ DataProvider.DataSource.get( self, luid )
+ for bookmark in self.Bookmarks:
+ if bookmark.get_UID() == luid:
+ return bookmark
+
+ def get_bookmark_url_from_fk( self, fk ):
+ Con = sqlite3.connect( self.FirefoxDir + self.ProfilePath + "/places.sqlite" )
+ try:
+ Cur = Con.execute( "select * from moz_places" )
+ except:
+ log.debug( self.SYNCERROR )
+ raise Exceptions.SyncronizeError( self.SYNCERROR )
+ retval = None
+ for Line in Cur.fetchall():
+ ( bid, url, title, host, visits, hidden, typed, faviconid, frecency ) = Line
+ if bid == fk:
+ retval = url
+ break
+ Con.close()
+ return retval
+
+ def configure( self, window ):
+ # thanks to the evolution module for some of this
+ import gtk
+ tree = Utils.dataprovider_glade_get_widget(
+ __file__,
+ "config.glade",
+ "Firefox3ConfigDialog"
+ )
+
+ sourceComboBox = tree.get_widget("profileComboBox")
+ store = gtk.ListStore( str, str )
+ sourceComboBox.set_model(store)
+
+ cell = gtk.CellRendererText()
+ sourceComboBox.pack_start(cell, True)
+ sourceComboBox.add_attribute(cell, 'text', 0)
+ sourceComboBox.set_active(0)
+
+ for profilename, profilepath in self.get_profiles():
+ rowref = store.append( ( profilename, profilepath ) )
+ if profilepath == self.ProfilePath:
+ sourceComboBox.set_active_iter(rowref)
+
+ dlg = tree.get_widget("Firefox3ConfigDialog")
+
+ response = Utils.run_dialog (dlg, window)
+ if response == True:
+ self.ProfilePath = store.get_value(sourceComboBox.get_active_iter(), 1)
+ dlg.destroy()
+
+ def get_profiles( self ):
+ retval = []
+ for section in self.Cf.sections():
+ if section != "General":
+ retval.append( ( self.Cf.get( section, "Name" ), self.Cf.get( section, "Path" ) ) )
+ return retval
+
+ def get_configuration(self):
+ return { "ProfilePath" : self.ProfilePath }
+
+ def set_configuration(self, config):
+ self.ProfilePath = config.get( "ProfilePath", self.ProfilePath )
+
+ def get_UID( self ):
+ return "Firefox3Module"
+
Added: trunk/conduit/modules/Firefox3Module/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/conduit/modules/Firefox3Module/Makefile.am Tue Jan 20 11:04:18 2009
@@ -0,0 +1,8 @@
+conduit_handlersdir = $(libdir)/conduit/modules/Firefox3Module
+conduit_handlers_DATA = config.glade
+conduit_handlers_PYTHON = Firefox3Module.py
+
+EXTRA_DIST = config.glade
+
+clean-local:
+ rm -rf *.pyc *.pyo
Added: trunk/conduit/modules/Firefox3Module/config.glade
==============================================================================
--- (empty file)
+++ trunk/conduit/modules/Firefox3Module/config.glade Tue Jan 20 11:04:18 2009
@@ -0,0 +1,125 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkDialog" id="Firefox3ConfigDialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Firefox</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="default_width">250</property>
+ <property name="default_height">350</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox22">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">5</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox9">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="button24">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button25">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="comboboxbox">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">5</property>
+
+ <child>
+ <widget class="GtkLabel" id="profileLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Firefox Profile:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="profileComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
Modified: trunk/conduit/modules/Makefile.am
==============================================================================
--- trunk/conduit/modules/Makefile.am (original)
+++ trunk/conduit/modules/Makefile.am Tue Jan 20 11:04:18 2009
@@ -16,7 +16,8 @@
N800Module \
NetworkModule \
GConfModule \
- ZotoModule
+ ZotoModule \
+ Firefox3Module
conduit_handlersdir = $(libdir)/conduit/modules
conduit_handlers_PYTHON = \
@@ -25,8 +26,7 @@
ConverterModule.py \
PhotoConverterModule.py \
AudioVideoConverterModule.py \
- GoogleBookmarksModule.py \
- Firefox3Module.py
+ GoogleBookmarksModule.py
clean-local:
rm -rf *.pyc *.pyo
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Jan 20 11:04:18 2009
@@ -175,6 +175,7 @@
conduit/modules/NetworkModule/Makefile
conduit/modules/GConfModule/Makefile
conduit/modules/ZotoModule/Makefile
+conduit/modules/Firefox3Module/Makefile
data/Makefile
data/conduit.desktop.in
data/conduit-autostart.desktop.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]