Thunderbird support?

24 views
Skip to first unread message

Marc Sherman

unread,
Mar 17, 2010, 9:51:42 PM3/17/10
to Autotrans
Would it be possible to make this plugin work in Thunderbird as well?

Thanks,
- Marc

Glenn

unread,
Mar 20, 2010, 6:57:21 AM3/20/10
to Autotrans
I haven't really worked with Thunderbird, but perhaps I'll find some
time to investigate this soon.

Marc Sherman

unread,
Apr 26, 2010, 10:50:31 AM4/26/10
to Autotrans


On Mar 20, 6:57 am, Glenn <glenn...@gmail.com> wrote:
> I haven't really worked with Thunderbird, but perhaps I'll find some
> time to investigate this soon.

I hacked up the 3.0 version of your plugin to work in thunderbird. The
big change I had to make was to remove use of the FUSE library for
prefs reading, because it doesn't exist in thunderbird. I extracted
all prefs access to a helper method, but I haven't actually
implemented it -- as it happens, I didn't need it because I don't
change any of your default prefs. I'm sure it's pretty easy to
implement in a firefox and thunderbird cross-platform way, though.

Note: I'm not at all a mozilla hacker -- I basically figured out what
I needed to do with google and the Error Console. So if there's any
egregious errors in my changes, please forgive me. :)

Here's the patch:

diff -u -r autotrans-3.0-fx/chrome/content/autotrans.js autotrans-3.0-
fx-and-tb/chrome/content/autotrans.js
--- autotrans-3.0-fx/chrome/content/autotrans.js 2010-02-28
06:46:48.000000000 -0500
+++ autotrans-3.0-fx-and-tb/chrome/content/autotrans.js 2010-04-26
09:29:14.000000000 -0400
@@ -36,7 +36,7 @@
* ***** END LICENSE BLOCK ***** */

var autotrans = {
- application: Components.classes["@mozilla.org/fuel/application;
1"].getService(Components.interfaces.fuelIApplication),
+ //application: Components.classes["@mozilla.org/fuel/application;
1"].getService(Components.interfaces.fuelIApplication),
prefService: Components.classes["@mozilla.org/preferences-service;
1"].getService(Components.interfaces.nsIPrefBranch),
jsonService: Components.classes["@mozilla.org/dom/json;
1"].createInstance(Components.interfaces.nsIJSON),

@@ -49,7 +49,7 @@
autotrans.initialized = true;

// Setup common libraries
- glennpow.debugging =
autotrans.application.prefs.getValue("extensions.autotrans.debug",
false);
+ glennpow.debugging =
autotrans.getPrefValue("extensions.autotrans.debug", false);
glennpow.logfile = "autotrans_log.txt";
glennpowAuthentication.hostname = "chrome://autotrans";
},
@@ -160,7 +160,7 @@
var url = daemon.url;

// Check that you haven't reached the max request attempts
- var maxAttempts =
autotrans.application.prefs.getValue("extensions.autotrans.attempts",
3);
+ var maxAttempts =
autotrans.getPrefValue("extensions.autotrans.attempts", 3);
if (attempt > maxAttempts) {
callback(false,
autotrans.strings.getString("extensions.autotrans.connection_failure"));
return;
@@ -185,7 +185,7 @@
}

// Timeout and retry request
- var maxTimeout =
autotrans.application.prefs.getValue("extensions.autotrans.timeout",
10000);
+ var maxTimeout =
autotrans.getPrefValue("extensions.autotrans.timeout", 10000);
var requestTimer = setTimeout(function() {

glennpow.log(autotrans.strings.getString("extensions.autotrans.timeout"));
request.abort();
@@ -348,7 +348,7 @@
},

addTorrentToDaemon: function(daemon, torrentURL, addPaused,
callback) {
- var sendMetaInfo =
autotrans.application.prefs.getValue("extensions.autotrans.metainfo",
false);
+ var sendMetaInfo =
autotrans.getPrefValue("extensions.autotrans.metainfo", false);

if (sendMetaInfo) {
try {
@@ -379,6 +379,11 @@

glennpow.log(autotrans.strings.getString("extensions.autotrans.retrieving_count")
+ ": " + daemon.url);
autotrans.ajaxToUrl(daemon,
autotrans.jsonService.encode({ method: "session-stats" }), callback);
},
+
+ getPrefValue: function(key, defaultvalue) {
+ // TODO implement this!
+ return defaultvalue;
+ },
};

window.addEventListener("load", function(e) { autotrans.onLoad(e); },
false);
diff -u -r autotrans-3.0-fx/chrome/content/ff-overlay.xul
autotrans-3.0-fx-and-tb/chrome/content/ff-overlay.xul
--- autotrans-3.0-fx/chrome/content/ff-overlay.xul 2010-02-18
10:10:34.000000000 -0500
+++ autotrans-3.0-fx-and-tb/chrome/content/ff-overlay.xul 2010-04-26
10:32:30.000000000 -0400
@@ -64,6 +64,19 @@
oncommand="autotransOverlay.onGotoTorrents(event)"/>
</menupopup>

+ <menupopup id="mailContext">
+ <menuseparator id="autotrans-context-separator" />
+ <menuitem id="autotrans-context-add"
label="&autotransContext.addTorrent.label;"
+ class="menuitem-iconic"
+ accesskey="&autotransContext.addTorrent.accesskey;"
+ image="chrome://autotrans/skin/autotrans-
statusicon.png"
+ insertafter="context-setp-properties"
+ oncommand="autotransOverlay.onAddTorrent(event)"/>
+ <menuitem id="autotrans-context-goto"
label="&autotransContext.gotoTorrents.label;"
+ insertafter="autotrans-context-add-as"
+ oncommand="autotransOverlay.onGotoTorrents(event)"/>
+ </menupopup>
+
<statusbar id="status-bar">
<menupopup id="statusContextMenu">
<!-- Dynamically create menuitems -->
diff -u -r autotrans-3.0-fx/chrome/content/overlay.js autotrans-3.0-fx-
and-tb/chrome/content/overlay.js
--- autotrans-3.0-fx/chrome/content/overlay.js 2010-02-18
10:04:00.000000000 -0500
+++ autotrans-3.0-fx-and-tb/chrome/content/overlay.js 2010-04-26
10:35:42.000000000 -0400
@@ -43,8 +43,15 @@
autotransOverlay.initialized = true;

autotrans.strings = document.getElementById("autotrans-strings");
+
+ if(document.getElementById("contentAreaContextMenu") != null) {
+
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing",
autotransOverlay.updateContentAreaContextMenu, false);
+ }
+
+ if(document.getElementById("mailContext") != null) {
+
document.getElementById("mailContext").addEventListener("popupshowing",
autotransOverlay.updateContentAreaContextMenu, false);
+ }

-
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing",
autotransOverlay.updateContentAreaContextMenu, false);

document.getElementById("statusContextMenu").addEventListener("popupshowing",
autotransOverlay.updateStatusContextMenu, false);

var prefObserver = {
@@ -78,21 +85,21 @@
},

updateState: function() {
- document.getElementById("autotrans-context-goto").hidden = !
autotrans.application.prefs.getValue("extensions.autotrans.gotomenu",
true);
+ document.getElementById("autotrans-context-goto").hidden = !
autotrans.getPrefValue("extensions.autotrans.gotomenu", true);

- if
(autotrans.application.prefs.getValue("extensions.autotrans.menuicon",
true)) {
+ if (autotrans.getPrefValue("extensions.autotrans.menuicon",
true)) {
document.getElementById("autotrans-context-
add").setAttribute("class", "menuitem-iconic");
} else {
document.getElementById("autotrans-context-
add").removeAttribute("class");
}

- document.getElementById("autotrans-status-
panel").setAttribute("collapsed", !
autotrans.application.prefs.getValue("extensions.autotrans.statusicon",
true));
+ document.getElementById("autotrans-status-
panel").setAttribute("collapsed", !
autotrans.getPrefValue("extensions.autotrans.statusicon", true));
},
}

prefObserver.register();
},
-
+
// Determine if menu item is visible
updateContentAreaContextMenu: function(event) {

autotransOverlay.showContextMenu(autotransOverlay.contextMenuVisible());
@@ -100,7 +107,7 @@

// Only show context menu item if selected file has torrent
extension or mime-type
contextMenuVisible: function() {
- if
(autotrans.application.prefs.getValue("extensions.autotrans.extfilter",
true)) {
+ if (autotrans.getPrefValue("extensions.autotrans.extfilter",
true)) {
var visible = false;
if (gContextMenu.onLink) {
// First check if it's a magnet link (TODO - this code may
not be sufficient. Awaiting transmission 1.80)
@@ -131,7 +138,7 @@
// Show/hide menu item
showContextMenu: function(visible) {
document.getElementById("autotrans-context-add").hidden = !
visible;
- document.getElementById("autotrans-context-separator").hidden = !
visible && !
autotrans.application.prefs.getValue("extensions.autotrans.gotomenu",
true);
+ document.getElementById("autotrans-context-separator").hidden = !
visible && !autotrans.getPrefValue("extensions.autotrans.gotomenu",
true);
},

// Update status-bar context menu
diff -u -r autotrans-3.0-fx/chrome.manifest autotrans-3.0-fx-and-tb/
chrome.manifest
--- autotrans-3.0-fx/chrome.manifest 2010-01-18 20:05:10.000000000
-0500
+++ autotrans-3.0-fx-and-tb/chrome.manifest 2010-04-26
08:35:24.000000000 -0400
@@ -1,4 +1,5 @@
content autotrans chrome/content/
skin autotrans classic/1.0 chrome/skin/
locale autotrans en-US chrome/locale/en-US/
-overlay chrome://browser/content/browser.xul chrome://autotrans/content/ff-overlay.xul
+overlay chrome://browser/content/browser.xul chrome://autotrans/content/ff-overlay.xul
application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+overlay chrome://messenger/content/messenger.xul
chrome://autotrans/content/ff-overlay.xul application={3550f703-
e582-4d05-9a08-453d09bdfdc6}
diff -u -r autotrans-3.0-fx/install.rdf autotrans-3.0-fx-and-tb/
install.rdf
--- autotrans-3.0-fx/install.rdf 2010-02-18 10:48:30.000000000 -0500
+++ autotrans-3.0-fx-and-tb/install.rdf 2010-04-26 08:32:48.000000000
-0400
@@ -17,5 +17,12 @@
<em:maxVersion>3.6.*</em:maxVersion>
</Description>
</em:targetApplication>
+ <em:targetApplication>
+ <Description>
+ <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> <!--
thunderbird -->
+ <em:minVersion>3.0</em:minVersion>
+ <em:maxVersion>3.0.*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
</Description>
</RDF>


--
Subscription settings: http://groups.google.com/group/autotrans-firefox/subscribe?hl=en
Reply all
Reply to author
Forward
0 new messages