Mercurial > snowl
annotate extension/modules/feed.js @ 139:8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Mon, 07 Jul 2008 01:22:44 -0700 |
parents | 58b04d16257c |
children | 510dc9c6647d |
rev | line source |
---|---|
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
1 EXPORTED_SYMBOLS = ["SnowlFeed"]; |
14 | 2 |
3 const Cc = Components.classes; | |
4 const Ci = Components.interfaces; | |
5 const Cr = Components.results; | |
6 const Cu = Components.utils; | |
7 | |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
8 // modules that come with Firefox |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
9 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
130
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
10 Cu.import("resource://gre/modules/ISO8601DateUtils.jsm"); |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
11 |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
12 // modules that should come with Firefox |
114 | 13 Cu.import("resource://snowl/modules/log4moz.js"); |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
14 Cu.import("resource://snowl/modules/Observers.js"); |
114 | 15 Cu.import("resource://snowl/modules/URI.js"); |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
16 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
17 // Snowl-specific modules |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
18 Cu.import("resource://snowl/modules/datastore.js"); |
114 | 19 Cu.import("resource://snowl/modules/source.js"); |
20 | |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
21 // FIXME: factor this out into a common file. |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
22 const PART_TYPE_CONTENT = 1; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
23 const PART_TYPE_SUMMARY = 2; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
24 |
113
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
25 // nsIFeedTextConstruct::type to media type mappings. |
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
26 const mediaTypes = { html: "text/html", |
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
27 xhtml: "application/xhtml+xml", |
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
28 text: "text/plain" }; |
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
29 |
118 | 30 /** |
31 * Convert a string to an array of character codes. | |
32 * | |
33 * @param string {string} the string to convert | |
34 * @returns {array} the array of character codes | |
35 */ | |
36 function stringToArray(string) { | |
37 var array = []; | |
38 for (let i = 0; i < string.length; i++) | |
39 array.push(string.charCodeAt(i)); | |
40 return array; | |
41 } | |
42 | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
43 function SnowlFeed(aID, aName, aMachineURI, aHumanURI, aLastRefreshed, aImportance) { |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
44 // Call the superclass's constructor to initialize the new instance. |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
45 SnowlSource.call(this, aID, aName, aMachineURI, aHumanURI, aLastRefreshed, aImportance); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
46 } |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
47 |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
48 SnowlFeed.prototype = { |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
49 __proto__: SnowlSource.prototype, |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
50 |
115
9556a63bfbda
make all snowl feeds share a logger
Myk Melez <myk@mozilla.org>
parents:
114
diff
changeset
|
51 _log: Log4Moz.Service.getLogger("Snowl.Feed"), |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
52 |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
53 // If we prompt the user to authenticate, and the user asks us to remember |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
54 // their password, we store the nsIAuthInformation in this property until |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
55 // the request succeeds, at which point we store it with the login manager. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
56 _authInfo: null, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
57 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
58 // Observer Service |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
59 get _obsSvc() { |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
60 let obsSvc = Cc["@mozilla.org/observer-service;1"]. |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
61 getService(Ci.nsIObserverService); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
62 this.__defineGetter__("_obsSvc", function() { return obsSvc }); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
63 return this._obsSvc; |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
64 }, |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
65 |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
66 // nsISupports |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
67 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
68 QueryInterface: XPCOMUtils.generateQI([Ci.nsIAuthPrompt2]), |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
69 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
70 // nsIInterfaceRequestor |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
71 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
72 getInterface: function(iid) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
73 return this.QueryInterface(iid); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
74 }, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
75 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
76 // nsIAuthPrompt2 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
77 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
78 _logins: null, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
79 _loginIndex: 0, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
80 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
81 promptAuth: function(channel, level, authInfo) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
82 // Check saved logins before prompting the user. We get them |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
83 // from the login manager and try each in turn until one of them works |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
84 // or we run out of them. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
85 if (!this._logins) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
86 let lm = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
87 // XXX Should we be using channel.URI.prePath in case the old URI |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
88 // redirects us to a new one at a different hostname? |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
89 this._logins = lm.findLogins({}, this.machineURI.prePath, null, authInfo.realm); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
90 } |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
91 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
92 let login = this._logins[this._loginIndex]; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
93 if (login) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
94 authInfo.username = login.username; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
95 authInfo.password = login.password; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
96 ++this._loginIndex; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
97 return true; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
98 } |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
99 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
100 // If we've made it this far, none of the saved logins worked, so we prompt |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
101 // the user to provide one. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
102 let args = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
103 args.AppendElement({ wrappedJSObject: this }); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
104 args.AppendElement(authInfo); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
105 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
106 // |result| is how the dialog passes information back to us. It sets two |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
107 // properties on the object: |proceed|, which we return from this function, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
108 // and which determines whether or not authentication can proceed using |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
109 // the values entered by the user; and |remember|, which determines whether |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
110 // or not we save the user's login with the login manager once the request |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
111 // succeeds. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
112 let result = {}; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
113 args.AppendElement({ wrappedJSObject: result }); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
114 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
115 let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
116 ww.openWindow(null, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
117 // XXX Should we use commonDialog.xul? |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
118 "chrome://snowl/content/login.xul", |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
119 null, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
120 "chrome,centerscreen,dialog,modal", |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
121 args); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
122 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
123 if (result.remember) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
124 this._authInfo = authInfo; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
125 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
126 return result.proceed; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
127 }, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
128 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
129 asyncPromptAuth: function() { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
130 throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
131 }, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
132 |
116 | 133 refresh: function() { |
14 | 134 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); |
135 | |
136 request.QueryInterface(Ci.nsIDOMEventTarget); | |
137 let t = this; | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
138 request.addEventListener("load", function(e) { t.onRefreshLoad(e) }, false); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
139 request.addEventListener("error", function(e) { t.onRefreshError(e) }, false); |
14 | 140 |
141 request.QueryInterface(Ci.nsIXMLHttpRequest); | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
142 |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
143 // The feed processor is going to parse the XML, so override the MIME type |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
144 // in order to turn off parsing by XMLHttpRequest itself. |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
145 request.overrideMimeType("text/plain"); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
146 |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
147 request.open("GET", this.machineURI.spec, true); |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
148 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
149 // Register a listener for notification callbacks so we handle authentication. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
150 request.channel.notificationCallbacks = this; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
151 |
14 | 152 request.send(null); |
153 }, | |
154 | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
155 onRefreshLoad: function(aEvent) { |
14 | 156 let request = aEvent.target; |
157 | |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
158 // If the request failed, let the error handler handle it. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
159 // XXX Do we need this? Don't such failures call the error handler directly? |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
160 if (request.status < 200 || request.status > 299) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
161 this.onRefreshError(aEvent); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
162 return; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
163 } |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
164 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
165 // XXX What's the right way to handle this? |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
166 if (request.responseText.length == 0) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
167 this.onRefreshError(aEvent); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
168 return; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
169 } |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
170 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
171 // _authInfo only gets set if we prompted the user to authenticate |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
172 // and the user checked the "remember password" box. Since we're here, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
173 // it means the request succeeded, so we save the login. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
174 if (this._authInfo) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
175 this._saveLogin(); |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
176 |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
177 let parser = Cc["@mozilla.org/feed-processor;1"]. |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
178 createInstance(Ci.nsIFeedProcessor); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
179 parser.listener = { t: this, handleResult: function(r) { this.t.onRefreshResult(r) } }; |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
180 parser.parseFromString(request.responseText, request.channel.URI); |
14 | 181 }, |
182 | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
183 onRefreshError: function(aEvent) { |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
184 let request = aEvent.target; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
185 this._log.error("onRefreshError: " + request.status + " (" + request.statusText + ")"); |
14 | 186 }, |
187 | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
188 onRefreshResult: function(aResult) { |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
189 Observers.notify(this, "snowl:subscribe:get:start", null); |
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
190 |
14 | 191 // Now that we know we successfully downloaded the feed and obtained |
192 // a result from it, update the "last refreshed" timestamp. | |
117
31fedd0b1466
refactor resetLastRefreshed into a lastRefreshed getter
Myk Melez <myk@mozilla.org>
parents:
116
diff
changeset
|
193 this.lastRefreshed = new Date(); |
14 | 194 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
195 let feed = aResult.doc.QueryInterface(Components.interfaces.nsIFeed); |
14 | 196 |
118 | 197 let currentMessageIDs = []; |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
198 let messagesChanged = false; |
14 | 199 |
200 SnowlDatastore.dbConnection.beginTransaction(); | |
201 try { | |
202 for (let i = 0; i < feed.items.length; i++) { | |
203 let entry = feed.items.queryElementAt(i, Ci.nsIFeedEntry); | |
204 //entry.QueryInterface(Ci.nsIFeedContainer); | |
205 | |
206 // Figure out the ID for the entry, then check if the entry has already | |
207 // been retrieved. If we can't figure out the entry's ID, then we skip | |
208 // the entry, since its ID is the only way for us to know whether or not | |
209 // it has already been retrieved. | |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
210 let externalID; |
14 | 211 try { |
118 | 212 externalID = entry.id || this._generateID(entry); |
14 | 213 } |
214 catch(ex) { | |
118 | 215 this._log.warn("couldn't retrieve a message: " + ex); |
14 | 216 continue; |
217 } | |
218 | |
118 | 219 let internalID = this._getInternalIDForExternalID(externalID); |
220 if (internalID) | |
221 continue; | |
14 | 222 |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
223 messagesChanged = true; |
118 | 224 this._log.info(this.name + " adding message " + externalID); |
132
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
225 internalID = this._addMessage(feed, entry, externalID); |
118 | 226 currentMessageIDs.push(internalID); |
14 | 227 } |
228 | |
229 // Update the current flag. | |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
230 // XXX Should this affect whether or not messages have changed? |
14 | 231 SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages SET current = 0 WHERE sourceID = " + this.id); |
118 | 232 SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages SET current = 1 WHERE id IN (" + currentMessageIDs.join(", ") + ")"); |
14 | 233 |
234 SnowlDatastore.dbConnection.commitTransaction(); | |
235 } | |
236 catch(ex) { | |
237 SnowlDatastore.dbConnection.rollbackTransaction(); | |
238 throw ex; | |
239 } | |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
240 |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
241 if (messagesChanged) |
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
242 this._obsSvc.notifyObservers(null, "messages:changed", null); |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
243 |
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
244 Observers.notify(this, "snowl:subscribe:get:end", null); |
14 | 245 }, |
246 | |
247 /** | |
248 * Add a message to the datastore for the given feed entry. | |
249 * | |
132
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
250 * @param aFeed {nsIFeed} the feed |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
251 * @param aEntry {nsIFeedEntry} the entry |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
252 * @param aExternalID {string} the external ID of the entry |
14 | 253 */ |
132
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
254 _addMessage: function(aFeed, aEntry, aExternalID) { |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
255 // Determine the author. |
14 | 256 let author = null; |
257 if (aEntry.authors.length > 0) { | |
258 let firstAuthor = aEntry.authors.queryElementAt(0, Ci.nsIFeedPerson); | |
132
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
259 if (firstAuthor.name) |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
260 author = firstAuthor.name; |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
261 else if (firstAuthor.email) |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
262 author = firstAuthor.email; |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
263 } |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
264 if (!author && aFeed.authors.length > 0) { |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
265 let firstAuthor = aFeed.authors.queryElementAt(0, Ci.nsIFeedPerson); |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
266 if (firstAuthor.name) |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
267 author = firstAuthor.name; |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
268 else if (firstAuthor.email) |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
269 author = firstAuthor.email; |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
270 } |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
271 if (!author && aFeed.title) { |
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
272 author = aFeed.title.plainText(); |
14 | 273 } |
274 | |
130
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
275 // Pick a timestamp, which is one of (by priority, high to low): |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
276 // 1. when the entry was last updated; |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
277 // 2. when the entry was published; |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
278 // 3. the Dublin Core timestamp associated with the entry; |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
279 // XXX Should we separately record when we added the entry so that the user |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
280 // can sort in the "order received" and view "when received" separately from |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
281 // "when published/updated"? |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
282 let timestamp = aEntry.updated ? new Date(aEntry.updated) : |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
283 aEntry.published ? new Date(aEntry.published) : |
7d13369f7d01
use the updated timestamp if available, otherwise the published timestamp, and finally the dc:date, which the feed parser appears to always provide (if necessary, it gives the time downloaded)
Myk Melez <myk@mozilla.org>
parents:
121
diff
changeset
|
284 ISO8601DateUtils.parse(aEntry.get("dc:date")); |
14 | 285 |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
286 // FIXME: handle titles that contain markup or are missing. |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
287 let messageID = this.addSimpleMessage(this.id, aExternalID, |
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
288 aEntry.title.text, author, |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
289 timestamp, aEntry.link); |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
290 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
291 // Add parts |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
292 if (aEntry.content) { |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
293 this.addPart(messageID, PART_TYPE_CONTENT, aEntry.content.text, |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
294 (aEntry.content.base ? aEntry.content.base.spec : null), |
113
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
295 aEntry.content.lang, mediaTypes[aEntry.content.type]); |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
296 } |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
297 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
298 if (aEntry.summary) { |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
299 this.addPart(messageID, PART_TYPE_SUMMARY, aEntry.summary.text, |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
300 (aEntry.summary.base ? aEntry.summary.base.spec : null), |
113
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
301 aEntry.summary.lang, mediaTypes[aEntry.summary.type]); |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
302 } |
14 | 303 |
304 // Add metadata. | |
305 let fields = aEntry.QueryInterface(Ci.nsIFeedContainer). | |
306 fields.QueryInterface(Ci.nsIPropertyBag).enumerator; | |
307 while (fields.hasMoreElements()) { | |
308 let field = fields.getNext().QueryInterface(Ci.nsIProperty); | |
309 | |
310 if (field.name == "authors") { | |
311 let values = field.value.QueryInterface(Ci.nsIArray).enumerate(); | |
312 while (values.hasMoreElements()) { | |
313 let value = values.getNext().QueryInterface(Ci.nsIFeedPerson); | |
314 // FIXME: store people records in a separate table with individual | |
315 // columns for each person attribute (i.e. name, email, url)? | |
118 | 316 this._addMetadatum(messageID, |
317 "atom:author", | |
318 value.name && value.email ? value.name + "<" + value.email + ">" | |
319 : value.name ? value.name : value.email); | |
14 | 320 } |
321 } | |
322 | |
323 else if (field.name == "links") { | |
324 let values = field.value.QueryInterface(Ci.nsIArray).enumerate(); | |
325 while (values.hasMoreElements()) { | |
326 let value = values.getNext().QueryInterface(Ci.nsIPropertyBag2); | |
327 // FIXME: store link records in a separate table with individual | |
328 // colums for each link attribute (i.e. href, type, rel, title)? | |
118 | 329 this._addMetadatum(messageID, |
330 "atom:link_" + value.get("rel"), | |
331 value.get("href")); | |
14 | 332 } |
333 } | |
334 | |
335 // For some reason, the values of certain simple fields (like RSS2 guid) | |
336 // are property bags containing the value instead of the value itself. | |
337 // For those, we need to unwrap the extra layer. This strange behavior | |
338 // has been filed as bug 427907. | |
339 else if (typeof field.value == "object") { | |
340 if (field.value instanceof Ci.nsIPropertyBag2) { | |
341 let value = field.value.QueryInterface(Ci.nsIPropertyBag2).get(field.name); | |
118 | 342 this._addMetadatum(messageID, field.name, value); |
14 | 343 } |
344 else if (field.value instanceof Ci.nsIArray) { | |
345 let values = field.value.QueryInterface(Ci.nsIArray).enumerate(); | |
346 while (values.hasMoreElements()) { | |
347 let value = values.getNext().QueryInterface(Ci.nsIPropertyBag2); | |
118 | 348 this._addMetadatum(messageID, field.name, value.get(field.name)); |
14 | 349 } |
350 } | |
351 } | |
352 | |
353 else | |
118 | 354 this._addMetadatum(messageID, field.name, field.value); |
14 | 355 } |
356 | |
357 return messageID; | |
358 }, | |
359 | |
360 /** | |
361 * Given an entry, generate an ID for it based on a hash of its link, | |
362 * published, and title attributes. Useful for uniquely identifying entries | |
363 * that don't provide their own IDs. | |
364 * | |
365 * @param entry {nsIFeedEntry} the entry for which to generate an ID | |
366 * @returns {string} an ID for the entry | |
367 */ | |
118 | 368 _generateID: function(entry) { |
14 | 369 let hasher = Cc["@mozilla.org/security/hash;1"]. |
370 createInstance(Ci.nsICryptoHash); | |
371 hasher.init(Ci.nsICryptoHash.SHA1); | |
118 | 372 let identity = stringToArray(entry.link.spec + entry.published + entry.title.text); |
14 | 373 hasher.update(identity, identity.length); |
374 return "urn:" + hasher.finish(true); | |
375 }, | |
376 | |
377 // FIXME: Make the rest of this stuff be part of a superclass from which | |
378 // this class is derived. | |
379 | |
380 /** | |
381 * Get the internal ID of the message with the given external ID. | |
382 * | |
383 * @param aExternalID {string} | |
384 * the external ID of the message | |
385 * | |
386 * @returns {number} | |
387 * the internal ID of the message, or undefined if the message | |
388 * doesn't exist | |
389 */ | |
118 | 390 _getInternalIDForExternalID: function(aExternalID) { |
14 | 391 return SnowlDatastore.selectInternalIDForExternalID(aExternalID); |
392 }, | |
393 | |
394 /** | |
395 * Add a message with a single part to the datastore. | |
396 * | |
397 * @param aSourceID {integer} the record ID of the message source | |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
398 * @param aExternalID {string} the external ID of the message |
14 | 399 * @param aSubject {string} the title of the message |
400 * @param aAuthor {string} the author of the message | |
401 * @param aTimestamp {Date} the date/time at which the message was sent | |
402 * @param aLink {nsIURI} a link to the content of the message, | |
403 * if the content is hosted on a server | |
404 * | |
405 * @returns {integer} the internal ID of the newly-created message | |
406 */ | |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
407 addSimpleMessage: function(aSourceID, aExternalID, aSubject, aAuthor, |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
408 aTimestamp, aLink) { |
14 | 409 // Convert the timestamp to milliseconds-since-epoch, which is how we store |
410 // it in the datastore. | |
411 let timestamp = aTimestamp ? aTimestamp.getTime() : null; | |
412 | |
413 // Convert the link to its string spec, which is how we store it | |
414 // in the datastore. | |
415 let link = aLink ? aLink.spec : null; | |
416 | |
417 let messageID = | |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
418 SnowlDatastore.insertMessage(aSourceID, aExternalID, aSubject, aAuthor, |
14 | 419 timestamp, link); |
420 | |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
421 return messageID; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
422 }, |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
423 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
424 get _addPartStatement() { |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
425 let statement = SnowlDatastore.createStatement( |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
426 "INSERT INTO parts(messageID, partType, content, baseURI, languageCode, mediaType) \ |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
427 VALUES (:messageID, :partType, :content, :baseURI, :languageCode, :mediaType)" |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
428 ); |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
429 this.__defineGetter__("_addPartStatement", function() { return statement }); |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
430 return this._addPartStatement; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
431 }, |
14 | 432 |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
433 addPart: function(aMessageID, aPartType, aContent, aBaseURI, aLanguageCode, |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
434 aMediaType) { |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
435 this._addPartStatement.params.messageID = aMessageID; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
436 this._addPartStatement.params.partType = aPartType; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
437 this._addPartStatement.params.content = aContent; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
438 this._addPartStatement.params.baseURI = aBaseURI; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
439 this._addPartStatement.params.languageCode = aLanguageCode; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
440 this._addPartStatement.params.mediaType = aMediaType; |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
441 this._addPartStatement.execute(); |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
442 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
443 return SnowlDatastore.dbConnection.lastInsertRowID; |
14 | 444 }, |
445 | |
118 | 446 _addMetadatum: function(aMessageID, aAttributeName, aValue) { |
14 | 447 // FIXME: speed this up by caching the list of known attributes. |
448 let attributeID = SnowlDatastore.selectAttributeID(aAttributeName) | |
449 || SnowlDatastore.insertAttribute(aAttributeName); | |
450 SnowlDatastore.insertMetadatum(aMessageID, attributeID, aValue); | |
451 }, | |
452 | |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
453 subscribe: function(callback) { |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
454 Observers.notify(this, "snowl:subscribe:connect:start", null); |
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
455 |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
456 this._subscribeCallback = callback; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
457 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
458 this._log.info("subscribing to " + this.name + " <" + this.machineURI.spec + ">"); |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
459 |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
460 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
461 |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
462 request = request.QueryInterface(Ci.nsIDOMEventTarget); |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
463 |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
464 let t = this; |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
465 request.addEventListener("load", function(e) { t.onSubscribeLoad(e) }, false); |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
466 request.addEventListener("error", function(e) { t.onSubscribeError(e) }, false); |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
467 |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
468 request = request.QueryInterface(Ci.nsIXMLHttpRequest); |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
104
diff
changeset
|
469 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
470 // The feed processor is going to parse the XML, so override the MIME type |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
104
diff
changeset
|
471 // in order to turn off parsing by XMLHttpRequest itself. |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
104
diff
changeset
|
472 request.overrideMimeType("text/plain"); |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
104
diff
changeset
|
473 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
474 request.open("GET", this.machineURI.spec, true); |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
475 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
476 // Register a listener for notification callbacks so we handle authentication. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
477 request.channel.notificationCallbacks = this; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
478 |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
479 request.send(null); |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
480 }, |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
481 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
482 onSubscribeLoad: function(aEvent) { |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
483 let request = aEvent.target; |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
484 |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
485 // If the request failed, let the error handler handle it. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
486 // XXX Do we need this? Don't such failures call the error handler directly? |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
487 if (request.status < 200 || request.status > 299) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
488 this.onSubscribeError(aEvent); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
489 return; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
490 } |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
491 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
492 // XXX What's the right way to handle this? |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
493 if (request.responseText.length == 0) { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
494 this.onRefreshError(aEvent); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
495 return; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
496 } |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
497 |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
498 Observers.notify(this, "snowl:subscribe:connect:end", request.status); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
499 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
500 // _authInfo only gets set if we prompted the user to authenticate |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
501 // and the user checked the "remember password" box. Since we're here, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
502 // it means the request succeeded, so we save the login. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
503 if (this._authInfo) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
504 this._saveLogin(); |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
505 |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
506 let parser = Cc["@mozilla.org/feed-processor;1"]. |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
507 createInstance(Ci.nsIFeedProcessor); |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
508 parser.listener = { t: this, handleResult: function(r) { this.t.onSubscribeResult(r) } }; |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
509 parser.parseFromString(request.responseText, request.channel.URI); |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
510 }, |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
511 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
512 onSubscribeError: function(aEvent) { |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
513 let request = aEvent.target; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
514 this._log.error("onSubscribeError: " + request.status + " (" + request.statusText + ")"); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
515 Observers.notify(this, "snowl:subscribe:connect:end", request.status); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
516 if (this._subscribeCallback) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
517 this._subscribeCallback(); |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
518 }, |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
519 |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
520 onSubscribeResult: function(aResult) { |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
521 try { |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
522 let feed = aResult.doc.QueryInterface(Components.interfaces.nsIFeed); |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
523 |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
524 // Extract the name (if we don't already have one) and human URI from the feed. |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
525 if (!this.name) |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
526 this.name = feed.title.plainText(); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
527 this.humanURI = feed.link; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
528 |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
529 // Add the source to the database. |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
530 let statement = |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
531 SnowlDatastore.createStatement("INSERT INTO sources (name, machineURI, humanURI) " + |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
532 "VALUES (:name, :machineURI, :humanURI)"); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
533 try { |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
534 statement.params.name = this.name; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
535 statement.params.machineURI = this.machineURI.spec; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
536 statement.params.humanURI = this.humanURI.spec; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
537 statement.step(); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
538 } |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
539 finally { |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
540 statement.reset(); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
541 } |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
542 |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
543 // Extract the ID of the source from the newly-created database record. |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
544 this.id = SnowlDatastore.dbConnection.lastInsertRowID; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
545 |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
546 // Let observers know about the new source. |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
547 this._obsSvc.notifyObservers(null, "sources:changed", null); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
548 |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
549 // Refresh the feed to import all its items. |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
550 this.onRefreshResult(aResult); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
551 } |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
552 catch(ex) { |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
553 dump("error on subscribe result: " + ex + "\n"); |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
554 } |
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
555 finally { |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
556 if (this._subscribeCallback) |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
557 this._subscribeCallback(); |
112
754441ddeaa3
combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents:
108
diff
changeset
|
558 } |
139
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
559 }, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
560 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
561 _saveLogin: function() { |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
562 let lm = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
563 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
564 // Create a new login with the auth information we obtained from the user. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
565 let LoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
566 Ci.nsILoginInfo, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
567 "init"); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
568 // XXX Should we be using channel.URI.prePath in case the old URI |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
569 // redirects us to a new one at a different hostname? |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
570 let newLogin = new LoginInfo(this.machineURI.prePath, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
571 null, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
572 this._authInfo.realm, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
573 this._authInfo.username, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
574 this._authInfo.password, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
575 "", |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
576 ""); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
577 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
578 // Get existing logins that have the same hostname and realm. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
579 let logins = lm.findLogins({}, this.machineURI.prePath, null, this._authInfo.realm); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
580 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
581 // Try to figure out if we should replace one of the existing logins. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
582 // If there's only one existing login, we replace it. Otherwise, if |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
583 // there's a login with the same username, we replace that. Otherwise, |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
584 // we add the new login instead of replacing an existing one. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
585 let oldLogin; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
586 if (logins.length == 1) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
587 oldLogin = logins[0]; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
588 else if (logins.length > 1) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
589 oldLogin = logins.filter(function(v) v.username == this._authInfo.username)[0]; |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
590 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
591 if (oldLogin) |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
592 lm.modifyLogin(oldLogin, newLogin); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
593 else |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
594 lm.addLogin(newLogin); |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
595 |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
596 // Now that we've saved the login, we don't need the auth info anymore. |
8763c90ce556
better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents:
138
diff
changeset
|
597 this._authInfo = null; |
76
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
598 } |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
599 |
1cbd4c5a511b
link the source name to the human URI if available; add a new SnowlFeedSubscriber object that can handle subscribing to feeds from various interfaces and which sets the human URI if available; make the OPML importer use the new SnowlFeedSubscriber object
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
600 }; |