[kupfer: 16/23] plugin.thunderbird: support AppLeafContentMixin and Icedove



commit 9431e364ff17030b2a25d4cffc4e997ff3245521
Author: Karol BÄ?dkowski <karol bedkowsk+gh gmail com>
Date:   Sun Dec 13 16:03:39 2009 +0100

    plugin.thunderbird: support AppLeafContentMixin and Icedove
    
    Add support for Icedove from Debian.
    Add searching for thunderbird home in various path.

 kupfer/plugin/thunderbird.py         |   13 +++++++------
 kupfer/plugin/thunderbird_support.py |   21 +++++++++++++++------
 2 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/kupfer/plugin/thunderbird.py b/kupfer/plugin/thunderbird.py
index 57aeaaf..d0fe731 100644
--- a/kupfer/plugin/thunderbird.py
+++ b/kupfer/plugin/thunderbird.py
@@ -14,7 +14,7 @@ from kupfer.plugin import thunderbird_support as support
 __kupfer_name__ = _("Thunderbird")
 __kupfer_sources__ = ("ContactsSource", )
 __kupfer_actions__ = ("NewMailAction", )
-__description__ = _("Thunderbird Contacts and Actions")
+__description__ = _("Thunderbird/Icedove Contacts and Actions")
 __version__ = "2009-12-13"
 __author__ = "Karol BÄ?dkowski <karol bedkowski gmail com>"
 
@@ -49,7 +49,8 @@ class ComposeMail(RunnableLeaf):
 		RunnableLeaf.__init__(self, name=_("Compose New Mail"))
 
 	def run(self):
-		utils.launch_commandline('thunderbird --compose')
+		if not utils.launch_commandline('thunderbird --compose'):
+			utils.launch_commandline('icedove --compose')
 
 	def get_description(self):
 		return _("Compose New Mail with Thunderbird")
@@ -68,7 +69,8 @@ class NewMailAction(Action):
 		if isinstance(leaf, UrlLeaf):
 			email = _get_email_from_url(email)
 
-		utils.launch_commandline("thunderbird --compose '%s'" % email)
+		if not utils.launch_commandline("thunderbird mailto:%s"; % email):
+			utils.launch_commandline("icedove mailto:%s"; % email)
 
 	def get_icon_name(self):
 		return "mail-message-new"
@@ -93,9 +95,8 @@ class NewMailAction(Action):
 		return False
 
 
-#AppLeafContentMixin
-class ContactsSource(Source, FilesystemWatchMixin):
-#	appleaf_content_id = 'thunderbird'
+class ContactsSource(AppLeafContentMixin, Source, FilesystemWatchMixin):
+	appleaf_content_id = ('thunderbird', 'icedove')
 
 	def __init__(self, name=_("Thundrbird Address Book")):
 		Source.__init__(self, name)
diff --git a/kupfer/plugin/thunderbird_support.py b/kupfer/plugin/thunderbird_support.py
index 2d5f1a0..85e8c43 100644
--- a/kupfer/plugin/thunderbird_support.py
+++ b/kupfer/plugin/thunderbird_support.py
@@ -19,9 +19,12 @@ Concept for mork parser from:
 	- mork.cs from GnomeDo by Pierre Ã?stlund
 '''
 
+THUNDERBIRD_HOME = map(os.path.expanduser, 
+		('~/.mozilla-thunderbird/', '~/.thunderbird'))
 
-THUNDERBIRD_HOME = '~/.thunderbird'
-THUNDERBIRD_PROFILES = os.path.join(THUNDERBIRD_HOME, 'profiles.ini')
+THUNDERBIRD_PROFILES = [ 
+		(thome, os.path.join(thome, 'profiles.ini'))
+		for thome in THUNDERBIRD_HOME ]
 ABOOK_FILE = 'abook.mab'
 
 
@@ -231,12 +234,18 @@ def _mork2contacts(tables):
 
 def get_addressbook_dir_file():
 	''' Get path to addressbook file from default profile. '''
-	profile_file = os.path.expanduser(THUNDERBIRD_PROFILES)
-	if not os.path.isfile(profile_file):
+	thunderbird_home, thunderbird_profile = None, None
+	for thome, tprofile in THUNDERBIRD_PROFILES:
+		if os.path.isfile(tprofile):
+			thunderbird_home = thome
+			thunderbird_profile = tprofile
+			break
+
+	if not thunderbird_home:
 		return None, None
 
 	config = RawConfigParser()
-	config.read(profile_file)
+	config.read(tprofile)
 	path = None
 	for section in config.sections():
 		if config.has_option(section, "Default") and \
@@ -248,7 +257,7 @@ def get_addressbook_dir_file():
 			path = config.get(section, "Path")
 
 	if path:
-		path = os.path.join(os.path.expanduser(THUNDERBIRD_HOME), path)
+		path = os.path.join(thunderbird_home, path)
 	return path, ABOOK_FILE
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]