MozillaZine

Fx2 external rss reader subscription is broken - a fix

Discussion of bugs in Mozilla Firefox
alta88
 
Posts: 972
Joined: January 28th, 2006, 3:08 pm

Post Posted October 28th, 2006, 2:59 pm

The Fx2 feed subscription implementation is rather broken. How it was released in this state is a topic for another time.. Fx will subscribe to an external feed reader by issuing the following eg.
Code: Select all
"C:\PROGRA~1\MOZILLA\THUNDE~1.0\THUNDE~1.EXE" "http://www.yoursite.com/rss"
to the (win) OS. Needless to say, only readers that take one argument in that format will subscribe. Tb is not one of them, nor are several others. There are bugs about this, for what that's worth.

Anyway, I've put together some code to fix this. In the Fx install directory \components, this code in Feedconverter.js starting at line 313

Code: Select all
   case "client":
      var clientApp =
        prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
//@line 373 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/FeedConverter.js"
      var ss =
          Cc["@mozilla.org/browser/shell-service;1"].
          getService(Ci.nsIShellService_MOZILLA_1_8_BRANCH);
      ss.openApplicationWithURI(clientApp, spec);
      break;


can be replaced with: (the const vars can go up top with the rest)

[edit: updated 30-Dec-2006]

Code: Select all
case "client":
   const PREF_SELECTED_APP_ARGS = "browser.feeds.handlers.application.args";
   const PREF_SELECTED_APP_URIPREFIX = "browser.feeds.handlers.application.uriPrefix";
   var clientApp = prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
   var feedhandlerArgs = safeGetCharPref(PREF_SELECTED_APP_ARGS).split(" "); //get all args words delimitted by space into array
   var uriPrefix = safeGetCharPref(PREF_SELECTED_APP_URIPREFIX);

   var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
   file.initWithPath(clientApp.persistentDescriptor);
   var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
   process.init(file);

   if (uriPrefix) spec = uriPrefix + spec;
   if (feedhandlerArgs) {
      var args = feedhandlerArgs;
      args[args.length] = spec; // add uri as last arg at the end
   }
   else
      var args = [spec];

   process.run(false, args, args.length);
//   debug("FeedConverter.js: ", (clientApp.persistentDescriptor + " " + args));

   break;

The following prefs are used to accept arguments, and a uri prefix, as required by the external app. The example below is the Tb requirement, for both a new instance of Tb as well as adding a feed to an already running instance. The prefs can be added to pref.js or (better) user.js or as strings in about:config (easiest).
Code: Select all
user_pref("browser.feeds.handlers.application.args","-mail");
user_pref("browser.feeds.handlers.application.uriPrefix","feed:");

For GreatNews, eg.
Code: Select all
user_pref("browser.feeds.handlers.application.uriPrefix","/feed:");

Comments on the code accepted gladly, but it WFM (winxp, haven't booted into Suse yet) and should not cause console errors. Note that if Fx is running with -no-remote, you can't communicate with a running Tb; it will always give an 'already running' message.
Last edited by alta88 on December 30th, 2006, 3:52 pm, edited 1 time in total.

SPL
 
Posts: 3
Joined: May 20th, 2005, 4:10 am

Post Posted November 8th, 2006, 6:48 am

Thanks for the code. It worked for me. Feeds are now automatically added to Thunderbird when clicking on the Feed icon.

Using FF 2.0 and Thunderbird 1.5.0.7 on Windows XP SP2

Steve

Mahtte0

User avatar
 
Posts: 4
Joined: May 22nd, 2006, 3:25 am

Post Posted November 9th, 2006, 2:30 am

Hi. I've tested your patch under Xubuntu 6.10, but it doesn't work

I'm using program versions downloaded from www.mozillaitalia.it. What happens is that Thunderbird gets the focus, or starts if it's closed, but doesn't get the subscription. Probably, the different versions of Tb (for Win or for Linux) use a different argument to subscribe the feed, but I'm not able to create a patch myself, or modify yours, so, please, help me

An idea: can this patch be implemented as an extension?
Every man of ambition has to fight his century with its own weapons. What this century worships is wealth. The God of this century is wealth.

O.Wilde "An Ideal Husband, act 2"

alta88
 
Posts: 972
Joined: January 28th, 2006, 3:08 pm

Post Posted November 9th, 2006, 11:19 am

Mahtte0 wrote:Hi. I've tested your patch under Xubuntu 6.10, but it doesn't work

I'm using program versions downloaded from www.mozillaitalia.it. What happens is that Thunderbird gets the focus, or starts if it's closed, but doesn't get the subscription. Probably, the different versions of Tb (for Win or for Linux) use a different argument to subscribe the feed, but I'm not able to create a patch myself, or modify yours, so, please, help me

An idea: can this patch be implemented as an extension?


this patch will only change how Fx starts the external reader. i have run into numerous occasions like you describe under winxp - the problem is with the actual subscription code in Tb. usually, restarting a running Tb will make subscribing work again. i've also seen rdf file corruption, or incomplete removal of feeds. you may want to manually check feeds.rdf and feeditems.rdf for a feed that won't work. if you issue the command at the prompt, passing those args, and Tb starts/gets focus and doesn't subscribe, then the problem is within Tb. i don't believe the args are different in 'nix, but if so, the patch lets you change them as you like.

also, i think Tb3 has different handling than 1.5 or 2.0b1, but it's unpublished as far as i know (unless you want to go .cvs diving). another thing to check is network.protocol handlers for feed within Fx; these have no meaning in win but are used in mac/'nix i believe, don't know the precedence of starting apps that Fx thinks are feed:, whether in Feedconverter.js or elsewhere.

rss in Tb is in a sad state. there are bugs for all these issues, just no attention.

an extension is a bit beyond what i can do right now, but anyone is free to take the code and wrap it up.

in boca al lupo ;)

Mahtte0

User avatar
 
Posts: 4
Joined: May 22nd, 2006, 3:25 am

Post Posted November 13th, 2006, 6:51 am

I'm sorry for having given a faulty news, but the patch works perfectly also under GNU/Linux and TB 1.5.0.8

I didn't modify properly the second string, having left the "/" in front of "feed:"

Thanks again
Every man of ambition has to fight his century with its own weapons. What this century worships is wealth. The God of this century is wealth.

O.Wilde "An Ideal Husband, act 2"

trishacupra
 
Posts: 76
Joined: September 14th, 2006, 3:55 am

Post Posted December 18th, 2006, 3:24 am

Thanks, thanks, and more thanks. Your fix has worked for me, and will save me so much time and effort. Now it works as expected.

pompy
 
Posts: 18
Joined: December 14th, 2006, 11:17 am

Post Posted December 25th, 2006, 9:46 pm

Awesome! Just implemented the new code, it works! yayy thankss.

alta88
 
Posts: 972
Joined: January 28th, 2006, 3:08 pm

Post Posted December 30th, 2006, 4:00 pm

due to how args are passed to the winOS by nsIProcess, an arg string with spaces (multiple args) would fail. updated to fix that. note that for Tb, the -mail arg must be the last in the string, eg
Code: Select all
user_pref("browser.feeds.handlers.application.args","-P myprofile -mail");

pompy
 
Posts: 18
Joined: December 14th, 2006, 11:17 am

Post Posted December 30th, 2006, 4:43 pm

alta88, what exactly did you fix again?
Because the code you had when you first started this thread I implemented, and it's working fine ...

Hope to hear from you to clear it up! Thanks.

alta88
 
Posts: 972
Joined: January 28th, 2006, 3:08 pm

Post Posted December 30th, 2006, 5:57 pm

it was only to to have Fx pass multiple args to the winOS without enclosing them in double quotes if the arg string had spaces. if you didn't have multiple args then it will continue to work. if you did, then it should now work..

Stebs
 
Posts: 504
Joined: June 3rd, 2004, 5:49 am
Location: Luxembourg

Post Posted January 12th, 2007, 8:12 am

Tested this a while ago (with TB 1.5) and it didn't work for me.
Now, tested it again with TB 2.0 Nightly this time and still can't get it to work. :(

After subscribing (for example this Feed: http://weblogs.mozillazine.org/rumblingedge/atom.xml), I see the text of the Feed (garbled, without line-break and with all html Tags etc.) in the right lower Message Pane, regardless if I'm in my own Inbox or the correct News and Feeds folder.
about:config displays correctly:
browser.feeds.handlers.application.args -mail
browser.feeds.handlers.application.uriPrefix feed:

Extract from FeedConverter.js:

Code: Select all
    var handler = safeGetCharPref(PREF_SELECTED_ACTION, "bookmarks");
    if (handler == "ask" || handler == "reader")                               
      handler = safeGetCharPref(PREF_SELECTED_READER, "bookmarks");             

    switch (handler) {
// Modified: http://forums.mozillazine.org/viewtopic.php?t=480357
//
//    case "client":
//      var clientApp =
//        prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
////@line 393 "/cygdrive/c/builds/tinderbox/Fx-Mozilla1.8-release/WINNT_5.2_Depend/mozilla/browser/components/feeds/src/FeedConverter.js"
//      var ss =
//          Cc["@mozilla.org/browser/shell-service;1"].
//          getService(Ci.nsIShellService_MOZILLA_1_8_BRANCH);
//      ss.openApplicationWithURI(clientApp, spec);
//      break;

//NEW:
case "client":
   const PREF_SELECTED_APP_ARGS = "browser.feeds.handlers.application.args";
   const PREF_SELECTED_APP_URIPREFIX = "browser.feeds.handlers.application.uriPrefix";
   var clientApp = prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
   var feedhandlerArgs = safeGetCharPref(PREF_SELECTED_APP_ARGS).split(" "); //get all args words delimitted by space into array
   var uriPrefix = safeGetCharPref(PREF_SELECTED_APP_URIPREFIX);

   var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
   file.initWithPath(clientApp.persistentDescriptor);
   var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
   process.init(file);

   if (uriPrefix) spec = uriPrefix + spec;
   if (feedhandlerArgs) {
      var args = feedhandlerArgs;
      args[args.length] = spec; // add uri as last arg at the end
   }
   else
      var args = [spec];

   process.run(false, args, args.length);
//   debug("FeedConverter.js: ", (clientApp.persistentDescriptor + " " + args));

   break;
//END NEW
   
    default:
      // "web" should have been handled elsewhere
      LOG("unexpected handler: " + handler);


What goes wrong?

alta88
 
Posts: 972
Joined: January 28th, 2006, 3:08 pm

Post Posted January 12th, 2007, 9:37 am

RSS is not well supported in Tb so it could be a number of things. For example, due to bug 365192, one cannot be guaranteed to subscribe unless Tb has just been restarted (if then).

However, this feed worked for me. Those prefs need to go in Fx about:config, not Tb. In your Tb profile's News folder, you may want to check feeds.rdf for that feed to see if the entry there is corrupted, and carefully remove just that item; edit/save the file with Tb closed. You can also check for console errors, make sure both JS and XML errors are on (use Console 2).

You can add this function to Feedconverter.js to see a console message anytime an external feed is initiated from Fx, and uncomment the debug line.

Code: Select all
function debug(aScript, aMsg) { Components.classes["@mozilla.org/consoleservice;1"]
                  .getService(Components.interfaces.nsIConsoleService)
                  .logStringMessage(aScript + aMsg);
};

Stebs
 
Posts: 504
Joined: June 3rd, 2004, 5:49 am
Location: Luxembourg

Post Posted January 12th, 2007, 10:35 am

alta88 wrote:RSS is not well supported in Tb so it could be a number of things. For example, due to bug 365192, one cannot be guaranteed to subscribe unless Tb has just been restarted (if then).
Tried it both: with Tb still open and also Tb closed so it was opened upon subscription.
(And now also closed it and reopened it before subscription)

Those prefs need to go in Fx about:config, not Tb.
Sure, got at least that right ;)
In your Tb profile's News folder, you may want to check feeds.rdf for that feed to see if the entry there is corrupted, and carefully remove just that item; edit/save the file with Tb closed. You can also check for console errors, make sure both JS and XML errors are on (use Console 2).
Got indeed at lot of Feeds in there and my Profile is quite old, so I just went ahead and created a new Profile just for testing.
So now I did test with a Profile that has just a new and empty "News & Blogs" Account.

But still was not able to subscribe to the Feed, the Folder in Tb remains empty (apart Trash)
Got some Error in Tb Console, but only when Tb was already opened upon subcription:
Code: Select all
Error: [Exception... "'Failure' when calling method: [nsICommandLineHandler::handle]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "<unknown>"  data: no]

You can add this function to Feedconverter.js to see a console message anytime an external feed is initiated from Fx, and uncomment the debug line.

Code: Select all
function debug(aScript, aMsg) { Components.classes["@mozilla.org/consoleservice;1"]
                  .getService(Components.interfaces.nsIConsoleService)
                  .logStringMessage(aScript + aMsg);
};
Did that, found no relevant error message in Fx (but did until now not install Console2, should I still do that?)

alta88
 
Posts: 972
Joined: January 28th, 2006, 3:08 pm

Post Posted January 12th, 2007, 11:34 am

Stebs wrote:But still was not able to subscribe to the Feed, the Folder in Tb remains empty (apart Trash)
Got some Error in Tb Console, but only when Tb was already opened upon subcription:
Code: Select all
Error: [Exception... "'Failure' when calling method: [nsICommandLineHandler::handle]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "<unknown>"  data: no]


well that's the problem, Tb can't parse (or even handle cleanly) the args. in my Fx console the string i have is (you don't need Console2 it's just nicer esp with ConsoleFilter).
Code: Select all
FeedConverter.js: C:\PROGRA~1\MOZILLA\THUNDE~1.0\THUNDE~1.EXE -mail,feed:http://weblogs.mozillazine.org/rumblingedge/atom.xml


i'd make sure you don't have any nulls or extraneous stuff in the args, otherwise i don't know why Tb throws that error.

trishacupra
 
Posts: 76
Joined: September 14th, 2006, 3:55 am

Post Posted January 16th, 2007, 3:56 am

Thanks so much - again. For some reason it stopped working for me - I'm guessing it was the FF update. But I just followed your directions and it works fantastic again. It's such a pain to add feeds manually to TB, and this is such a convenience. Funny how FF needs fixing to do this, which should happen by default.

Return to Firefox Bugs


Who is online

Users browsing this forum: No registered users and 1 guest