diff options
author | Mark Tully <markjtully@gmail.com> | 2012-03-24 03:01:08 +0530 |
---|---|---|
committer | Manish Sinha <manishsinha@ubuntu.com> | 2012-03-24 03:01:08 +0530 |
commit | 348758c1a655c027d8e8d526b698ee6e60692dc9 (patch) | |
tree | 2f2fa81ab04e6866f0084c885545c7fbc2a95f59 /thunderbird | |
parent | 89e99c55c831248b41f637845435739bcb335d14 (diff) | |
parent | 62160f20a21f266faf51643ec64213e339230527 (diff) |
Added Thunderbird datasource
Diffstat (limited to 'thunderbird')
-rw-r--r-- | thunderbird/Makefile.am | 13 | ||||
-rw-r--r-- | thunderbird/README | 10 | ||||
-rw-r--r-- | thunderbird/extension/Makefile.am | 40 | ||||
-rw-r--r-- | thunderbird/extension/chrome.manifest | 5 | ||||
-rw-r--r-- | thunderbird/extension/chrome/content/event.js | 85 | ||||
-rw-r--r-- | thunderbird/extension/chrome/content/module.js | 62 | ||||
-rw-r--r-- | thunderbird/extension/chrome/content/zeitgeist.png | bin | 0 -> 1631 bytes | |||
-rw-r--r-- | thunderbird/extension/chrome/content/zeitgeist.xul | 7 | ||||
-rw-r--r-- | thunderbird/extension/defaults/preferences/prefs.js | 2 | ||||
-rw-r--r-- | thunderbird/extension/install.rdf | 28 | ||||
-rw-r--r-- | thunderbird/extension/license.txt | 166 |
11 files changed, 418 insertions, 0 deletions
diff --git a/thunderbird/Makefile.am b/thunderbird/Makefile.am new file mode 100644 index 0000000..00b37f2 --- /dev/null +++ b/thunderbird/Makefile.am @@ -0,0 +1,13 @@ +SUBDIRS = extension + +# identifier for the TB profile in which 'make install' installs this extension +TARGET_PROFILE = *default* + +local-install: all + $(MAKE) -C extension $@ + cp xpcom-thunderbird\@zeitgeist-project.com.xpi ~/.thunderbird/$(TARGET_PROFILE)/extensions/ + +local-uninstall: + $(MAKE) -C extension $@ + -rm -rf ~/.thunderbird/$(TARGET_PROFILE)/extensions/xpcom-thunderbird\@zeitgeist-project.com.xpi + diff --git a/thunderbird/README b/thunderbird/README new file mode 100644 index 0000000..572bbe7 --- /dev/null +++ b/thunderbird/README @@ -0,0 +1,10 @@ +Links +===== + +Useful resources: + https://developer.mozilla.org/en/js-ctypes/Using_js-ctypes + +TODO +==== + * add events for attachments + * add events for calendar if thunderbird has lightning intalled diff --git a/thunderbird/extension/Makefile.am b/thunderbird/extension/Makefile.am new file mode 100644 index 0000000..b82e2de --- /dev/null +++ b/thunderbird/extension/Makefile.am @@ -0,0 +1,40 @@ +SUBDIRS = + +extensiondir = $(datadir)/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384} +EXTENSIONS_SYMLINK = $(extensiondir) + +xul_extdir = $(datadir)/xul-ext-zeitgeist +dist_xul_ext_DATA = \ + license.txt \ + chrome.manifest \ + install.rdf \ + $(NULL) + +contentdir = $(xul_extdir)/chrome/content +dist_content_DATA = \ + chrome/content/zeitgeist.xul \ + chrome/content/zeitgeist.png \ + chrome/content/event.js \ + chrome/content/module.js \ + $(NULL) + +prefsdir = $(xul_extdir)/defaults/preferences +dist_prefs_DATA = \ + defaults/preferences/prefs.js \ + $(NULL) + +install-exec-hook: + $(MKDIR_P) $(DESTDIR)$(extensiondir) + test -h "$(DESTDIR)$(EXTENSIONS_SYMLINK)" || $(LN_S) -f "$(DESTDIR)$(xul_extdir)" "$(DESTDIR)$(EXTENSIONS_SYMLINK)" + +# we want to allow also local install +EXTENSION_CONTENT = \ + $(dist_xul_ext_DATA) \ + defaults \ + chrome \ + $(NULL) + +local-install: all + zip -r ../xpcom-thunderbird@zeitgeist-project.com.xpi $(EXTENSION_CONTENT) + +local-uninstall: diff --git a/thunderbird/extension/chrome.manifest b/thunderbird/extension/chrome.manifest new file mode 100644 index 0000000..4d42dea --- /dev/null +++ b/thunderbird/extension/chrome.manifest @@ -0,0 +1,5 @@ +content zeitgeist chrome/content/ + +overlay chrome://messenger/content/messenger.xul chrome://zeitgeist/content/zeitgeist.xul + +locale zeitgeist en-US chrome/locale/en-US/ diff --git a/thunderbird/extension/chrome/content/event.js b/thunderbird/extension/chrome/content/event.js new file mode 100644 index 0000000..ee5a46c --- /dev/null +++ b/thunderbird/extension/chrome/content/event.js @@ -0,0 +1,85 @@ +var ZeitgeistNewMailListener = { + + init: function() { + var notificationService = Components.classes["@mozilla.org/messenger/msgnotificationservice;1"] + .getService(Components.interfaces.nsIMsgFolderNotificationService); + notificationService.addListener(this, notificationService.msgAdded); + }, + + msgAdded: function(aMsgHdr) { + + let folder = aMsgHdr.folder; + + // Only add to zeitgeist if the folder the message is in is flagged as an inbox ("0x00001000") + if (folder.flags & "0x00001000") { + + let hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"] + .getService(Components.interfaces.nsIMsgHeaderParser); + + let uri = folder.getUriForMsg(aMsgHdr); + let author = hdrParser.extractHeaderAddressName(aMsgHdr.mime2DecodedAuthor); + let address = hdrParser.extractHeaderAddressMailboxes(aMsgHdr.author); + let message_subject = aMsgHdr.mime2DecodedSubject + let account = aMsgHdr.folder.server.prettyName + + let subject = libzeitgeist.zeitgeist_subject_new_full( uri, + "http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email", + "http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MailboxDataObject", + "message/rfc822", + address, + author + " - " + message_subject, + "net"); + + let event = libzeitgeist.zeitgeist_event_new_full( "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ReceiveEvent", + "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#SystemNotification", + "application://thunderbird.desktop", + subject, + null); + + libzeitgeist.zeitgeist_event_set_origin( event, + account) + + libzeitgeist.zeitgeist_log_insert_events_no_reply(libzeitgeist.log, event, null); + + //Log event in Thunderbird's error console if logging pref is true + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + if (prefs.getBoolPref("extensions.zeitgeist.log")) { + zeitgeist.debug("Event added to zeitgeist:" + + "\n\t\tEvent interpretation: EVENT_INTERPRETATION.RECEIVE_EVENT" + + "\n\t\tEvent manifestation: EVENT_MANIFESTATION.SYSTEM_NOTIFICATION" + + "\n\t\tActor: application://thunderbird.desktop" + + "\n\t\tOrigin: " + account + + "\n\t\tSubject:\n\t\t\tSubject interpretation: MESSAGE.EMAIL" + + "\n\t\t\tSubject manifestation: MAILBOX_DATA_OBJECT" + + "\n\t\t\turl: " + uri + + "\n\t\t\tmimetype: message/rfc822" + + "\n\t\t\torigin: " + address + + "\n\t\t\ttitle: " + author + " - " + message_subject + + "\n\t\t\tstorage: net"); + } + } + }, +}; + +var zeitgeist = { + init: function() { + ZeitgeistNewMailListener.init(); + libzeitgeist.init(); + }, + + uninit: function() { + + libzeitgeist.shutdown(); + }, + + debug: function (aMessage) { + var consoleService = Components.classes["@mozilla.org/consoleservice;1"] + .getService(Components.interfaces.nsIConsoleService); + consoleService.logStringMessage("Zeitgeist Extension (" + new Date() + " ):\n\t" + aMessage); + window.dump("Zeitgeist Extension: (" + new Date() + " ):\n\t" + aMessage + "\n"); + } +}; + +window.addEventListener("load", function() {zeitgeist.init()}, false); +window.addEventListener("unload", function() {zeitgeist.uninit()}, false); diff --git a/thunderbird/extension/chrome/content/module.js b/thunderbird/extension/chrome/content/module.js new file mode 100644 index 0000000..ffd5ad2 --- /dev/null +++ b/thunderbird/extension/chrome/content/module.js @@ -0,0 +1,62 @@ +var libzeitgeist = { + + zeitgeistPath: "libzeitgeist-1.0.so.1", + + lib: null, + + init: function() { + + Components.utils.import("resource://gre/modules/ctypes.jsm"); + + this.lib = ctypes.open(this.zeitgeistPath); + + //Structures + this._ZeitgeistEvent = new ctypes.StructType("_ZeitgeistEvent"); + this._ZeitgeistSubject = new ctypes.StructType("_ZeitgeistSubject"); + this._ZeitgeistLog = new ctypes.StructType("_ZeitgeistLog"); + + //Methods + this.zeitgeist_event_new_full = this.lib.declare( "zeitgeist_event_new_full", + ctypes.default_abi, + ctypes.char.ptr, + ctypes.char.ptr, //interpretation + ctypes.char.ptr, //manifestation + ctypes.char.ptr, //actor + ctypes.char.ptr, //subject + ctypes.voidptr_t); + + this.zeitgeist_event_set_origin = this.lib.declare( "zeitgeist_event_set_origin", + ctypes.default_abi, + ctypes.voidptr_t, + ctypes.char.ptr, //event + ctypes.char.ptr); //origin + + this.zeitgeist_subject_new_full = this.lib.declare( "zeitgeist_subject_new_full", + ctypes.default_abi, + ctypes.char.ptr, + ctypes.char.ptr, //uri + ctypes.char.ptr, //interpretation + ctypes.char.ptr, //manfestation + ctypes.char.ptr, //mimetype + ctypes.char.ptr, //origin + ctypes.char.ptr, //text + ctypes.char.ptr); //storage + + this.zeitgeist_log_new = this.lib.declare( "zeitgeist_log_new", + ctypes.default_abi, + ctypes.char.ptr ); + + this.zeitgeist_log_insert_events_no_reply = this.lib.declare( "zeitgeist_log_insert_events_no_reply", + ctypes.default_abi, + ctypes.void_t.ptr, + ctypes.char.ptr, //log + ctypes.char.ptr, //event + ctypes.voidptr_t); + + this.log = libzeitgeist.zeitgeist_log_new(); + }, + + shutdown: function() { + this.lib.close(); + } +}; diff --git a/thunderbird/extension/chrome/content/zeitgeist.png b/thunderbird/extension/chrome/content/zeitgeist.png Binary files differnew file mode 100644 index 0000000..4ae18f0 --- /dev/null +++ b/thunderbird/extension/chrome/content/zeitgeist.png diff --git a/thunderbird/extension/chrome/content/zeitgeist.xul b/thunderbird/extension/chrome/content/zeitgeist.xul new file mode 100644 index 0000000..852c394 --- /dev/null +++ b/thunderbird/extension/chrome/content/zeitgeist.xul @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<overlay id="zeitgeist" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + + <script type="application/javascript" src="chrome://zeitgeist/content/module.js"></script> + <script type="application/javascript" src="chrome://zeitgeist/content/event.js"></script> + +</overlay> diff --git a/thunderbird/extension/defaults/preferences/prefs.js b/thunderbird/extension/defaults/preferences/prefs.js new file mode 100644 index 0000000..c314a60 --- /dev/null +++ b/thunderbird/extension/defaults/preferences/prefs.js @@ -0,0 +1,2 @@ +pref("extensions.zeitgeist.log" , false); + diff --git a/thunderbird/extension/install.rdf b/thunderbird/extension/install.rdf new file mode 100644 index 0000000..9b9c0e8 --- /dev/null +++ b/thunderbird/extension/install.rdf @@ -0,0 +1,28 @@ +<?xml version="1.0"?> + +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + + <Description about="urn:mozilla:install-manifest"> + <em:id>thunderbird@zeitgeist-project.com</em:id> + <em:version>0.2</em:version> + <em:type>2</em:type> + + <!-- Target Application this extension can install into, + with minimum and maximum supported versions. --> + <em:targetApplication> + <Description> + <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> + <em:minVersion>5.0</em:minVersion> + <em:maxVersion>17.*</em:maxVersion> + </Description> + </em:targetApplication> + + <!-- Front End MetaData --> + <em:name>Zeitgeist</em:name> + <em:description>Dataprovider for the zeitgeist framework</em:description> + <em:creator>Mark Tully</em:creator> + <em:homepageURL>http://launchpad.net/zeitgeist</em:homepageURL> + <em:iconURL>chrome://zeitgeist/content/zeitgeist.png</em:iconURL> + </Description> +</RDF> diff --git a/thunderbird/extension/license.txt b/thunderbird/extension/license.txt new file mode 100644 index 0000000..f463a23 --- /dev/null +++ b/thunderbird/extension/license.txt @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + |