Mercurial > snowl
annotate modules/feed.js @ 260:f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Mon, 25 Aug 2008 17:33:13 -0700 |
parents | 842cc8be67d2 |
children | 54b59324bd71 |
rev | line source |
---|---|
229
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
1 /* ***** BEGIN LICENSE BLOCK ***** |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
3 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
4 * The contents of this file are subject to the Mozilla Public License Version |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
5 * 1.1 (the "License"); you may not use this file except in compliance with |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
6 * the License. You may obtain a copy of the License at |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
7 * http://www.mozilla.org/MPL/ |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
8 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
9 * Software distributed under the License is distributed on an "AS IS" basis, |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
11 * for the specific language governing rights and limitations under the |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
12 * License. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
13 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
14 * The Original Code is Snowl. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
15 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
16 * The Initial Developer of the Original Code is Mozilla. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
17 * Portions created by the Initial Developer are Copyright (C) 2008 |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
18 * the Initial Developer. All Rights Reserved. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
19 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
20 * Contributor(s): |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
21 * Myk Melez <myk@mozilla.org> |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
22 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
23 * Alternatively, the contents of this file may be used under the terms of |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
24 * either the GNU General Public License Version 2 or later (the "GPL"), or |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
26 * in which case the provisions of the GPL or the LGPL are applicable instead |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
27 * of those above. If you wish to allow use of your version of this file only |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
28 * under the terms of either the GPL or the LGPL, and not to allow others to |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
29 * use your version of this file under the terms of the MPL, indicate your |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
30 * decision by deleting the provisions above and replace them with the notice |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
31 * and other provisions required by the GPL or the LGPL. If you do not delete |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
32 * the provisions above, a recipient may use your version of this file under |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
33 * the terms of any one of the MPL, the GPL or the LGPL. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
34 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
35 * ***** END LICENSE BLOCK ***** */ |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
36 |
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
|
37 EXPORTED_SYMBOLS = ["SnowlFeed"]; |
14 | 38 |
39 const Cc = Components.classes; | |
40 const Ci = Components.interfaces; | |
41 const Cr = Components.results; | |
42 const Cu = Components.utils; | |
43 | |
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
|
44 // 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
|
45 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
|
46 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
|
47 |
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
|
48 // modules that should come with Firefox |
114 | 49 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
|
50 Cu.import("resource://snowl/modules/Observers.js"); |
114 | 51 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
|
52 |
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 // 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
|
54 Cu.import("resource://snowl/modules/datastore.js"); |
114 | 55 Cu.import("resource://snowl/modules/source.js"); |
164 | 56 Cu.import("resource://snowl/modules/identity.js"); |
114 | 57 |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
58 // 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
|
59 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
|
60 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
|
61 |
113
f633d4f1fefa
make mediaTypes a constant rather than a property of the SnowlFeed object
Myk Melez <myk@mozilla.org>
parents:
112
diff
changeset
|
62 // 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
|
63 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
|
64 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
|
65 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
|
66 |
118 | 67 /** |
68 * Convert a string to an array of character codes. | |
69 * | |
70 * @param string {string} the string to convert | |
71 * @returns {array} the array of character codes | |
72 */ | |
73 function stringToArray(string) { | |
74 var array = []; | |
75 for (let i = 0; i < string.length; i++) | |
76 array.push(string.charCodeAt(i)); | |
77 return array; | |
78 } | |
79 | |
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
|
80 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
|
81 // 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
|
82 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
|
83 } |
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
|
84 |
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
|
85 SnowlFeed.prototype = { |
205 | 86 constructor: SnowlFeed, |
87 | |
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
|
88 __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
|
89 |
115
9556a63bfbda
make all snowl feeds share a logger
Myk Melez <myk@mozilla.org>
parents:
114
diff
changeset
|
90 _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
|
91 |
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
|
92 // 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
|
93 // 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
|
94 // 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
|
95 _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
|
96 |
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
|
97 // 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 }, |
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
|
104 |
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
|
105 // 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
|
106 |
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 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
|
108 |
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 // 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
|
110 |
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 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
|
112 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
|
113 }, |
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 // 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
|
116 |
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 _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
|
118 _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
|
119 |
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 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
|
121 // 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
|
122 // 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
|
123 // 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
|
124 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
|
125 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
|
126 // 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
|
127 // 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
|
128 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
|
129 } |
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 |
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 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
|
132 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
|
133 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
|
134 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
|
135 ++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
|
136 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
|
137 } |
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
|
138 |
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
|
139 // 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
|
140 // 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
|
141 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
|
142 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
|
143 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
|
144 |
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
|
145 // |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
|
146 // 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
|
147 // 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
|
148 // 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
|
149 // 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
|
150 // 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
|
151 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
|
152 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
|
153 |
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
|
154 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
|
155 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
|
156 // 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
|
157 "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
|
158 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
|
159 "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
|
160 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
|
161 |
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 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
|
163 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
|
164 |
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
|
165 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
|
166 }, |
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 |
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 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
|
169 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
|
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 |
116 | 172 refresh: function() { |
14 | 173 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); |
174 | |
175 request.QueryInterface(Ci.nsIDOMEventTarget); | |
176 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
|
177 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
|
178 request.addEventListener("error", function(e) { t.onRefreshError(e) }, false); |
14 | 179 |
180 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
|
181 |
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
|
182 // 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
|
183 // 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
|
184 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
|
185 |
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
|
186 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
|
187 |
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
|
188 // 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
|
189 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
|
190 |
14 | 191 request.send(null); |
192 }, | |
193 | |
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
|
194 onRefreshLoad: function(aEvent) { |
14 | 195 let request = aEvent.target; |
196 | |
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
|
197 // 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
|
198 // 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
|
199 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
|
200 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
|
201 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
|
202 } |
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
|
203 |
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
|
204 // 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
|
205 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
|
206 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
|
207 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
|
208 } |
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
|
209 |
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
|
210 // _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
|
211 // 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
|
212 // 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
|
213 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
|
214 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
|
215 |
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
|
216 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
|
217 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
|
218 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
|
219 parser.parseFromString(request.responseText, request.channel.URI); |
14 | 220 }, |
221 | |
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
|
222 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
|
223 let request = aEvent.target; |
144
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
224 |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
225 // Sometimes an attempt to retrieve status text throws NS_ERROR_NOT_AVAILABLE |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
226 let statusText = ""; |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
227 try { |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
228 statusText = request.statusText; |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
229 } |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
230 catch(ex) {} |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
231 |
510dc9c6647d
catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents:
139
diff
changeset
|
232 this._log.error("onRefreshError: " + request.status + " (" + statusText + ")"); |
14 | 233 }, |
234 | |
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
|
235 onRefreshResult: function(aResult) { |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
236 Observers.notify(this, "snowl:subscribe:get:start", null); |
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
237 |
14 | 238 // Now that we know we successfully downloaded the feed and obtained |
239 // 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
|
240 this.lastRefreshed = new Date(); |
14 | 241 |
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
|
242 let feed = aResult.doc.QueryInterface(Components.interfaces.nsIFeed); |
14 | 243 |
118 | 244 let currentMessageIDs = []; |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
245 let messagesChanged = false; |
14 | 246 |
247 SnowlDatastore.dbConnection.beginTransaction(); | |
248 try { | |
249 for (let i = 0; i < feed.items.length; i++) { | |
250 let entry = feed.items.queryElementAt(i, Ci.nsIFeedEntry); | |
251 //entry.QueryInterface(Ci.nsIFeedContainer); | |
252 | |
253 // Figure out the ID for the entry, then check if the entry has already | |
254 // been retrieved. If we can't figure out the entry's ID, then we skip | |
255 // the entry, since its ID is the only way for us to know whether or not | |
256 // it has already been retrieved. | |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
257 let externalID; |
14 | 258 try { |
118 | 259 externalID = entry.id || this._generateID(entry); |
14 | 260 } |
261 catch(ex) { | |
118 | 262 this._log.warn("couldn't retrieve a message: " + ex); |
14 | 263 continue; |
264 } | |
265 | |
118 | 266 let internalID = this._getInternalIDForExternalID(externalID); |
192
da18f7de05d6
fix the bug where we don't set 'current' correctly for most messages
Myk Melez <myk@mozilla.org>
parents:
164
diff
changeset
|
267 if (internalID) { |
da18f7de05d6
fix the bug where we don't set 'current' correctly for most messages
Myk Melez <myk@mozilla.org>
parents:
164
diff
changeset
|
268 currentMessageIDs.push(internalID); |
118 | 269 continue; |
192
da18f7de05d6
fix the bug where we don't set 'current' correctly for most messages
Myk Melez <myk@mozilla.org>
parents:
164
diff
changeset
|
270 } |
14 | 271 |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
272 messagesChanged = true; |
118 | 273 this._log.info(this.name + " adding message " + externalID); |
260
f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
Myk Melez <myk@mozilla.org>
parents:
256
diff
changeset
|
274 internalID = this._addMessage(feed, entry, externalID, this.lastRefreshed); |
118 | 275 currentMessageIDs.push(internalID); |
14 | 276 } |
277 | |
278 // 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
|
279 // XXX Should this affect whether or not messages have changed? |
14 | 280 SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages SET current = 0 WHERE sourceID = " + this.id); |
118 | 281 SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages SET current = 1 WHERE id IN (" + currentMessageIDs.join(", ") + ")"); |
14 | 282 |
283 SnowlDatastore.dbConnection.commitTransaction(); | |
284 } | |
285 catch(ex) { | |
286 SnowlDatastore.dbConnection.rollbackTransaction(); | |
287 throw ex; | |
288 } | |
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
|
289 |
121
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
290 if (messagesChanged) |
110b9b8aed1f
only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents:
118
diff
changeset
|
291 this._obsSvc.notifyObservers(null, "messages:changed", null); |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
292 |
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
293 Observers.notify(this, "snowl:subscribe:get:end", null); |
14 | 294 }, |
295 | |
296 /** | |
297 * Add a message to the datastore for the given feed entry. | |
298 * | |
132
8f3137f7cc0a
employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents:
130
diff
changeset
|
299 * @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
|
300 * @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
|
301 * @param aExternalID {string} the external ID of the entry |
260
f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
Myk Melez <myk@mozilla.org>
parents:
256
diff
changeset
|
302 * @param aReceived {Date} when the message was received |
14 | 303 */ |
260
f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
Myk Melez <myk@mozilla.org>
parents:
256
diff
changeset
|
304 _addMessage: function(aFeed, aEntry, aExternalID, aReceived) { |
164 | 305 let authorID = null; |
306 let authors = (aEntry.authors.length > 0) ? aEntry.authors | |
307 : (aFeed.authors.length > 0) ? aFeed.authors | |
308 : null; | |
309 if (authors && authors.length > 0) { | |
310 let author = authors.queryElementAt(0, Ci.nsIFeedPerson); | |
311 // The external ID for an author is her email address, if provided | |
312 // (many feeds don't); otherwise it's her name. For the name, on the | |
313 // other hand, we use the name, if provided, but fall back to the | |
314 // email address if a name is not provided (which it probably was). | |
315 let externalID = author.email || author.name; | |
316 let name = author.name || author.email; | |
317 | |
318 // Get an existing identity or create a new one. Creating an identity | |
319 // automatically creates a person record with the provided name. | |
320 identity = SnowlIdentity.get(this.id, externalID) || | |
321 SnowlIdentity.create(this.id, externalID, name); | |
322 authorID = identity.personID; | |
14 | 323 } |
324 | |
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
|
325 // 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
|
326 // 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
|
327 // 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
|
328 // 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
|
329 // 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
|
330 // 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
|
331 // "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
|
332 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
|
333 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
|
334 ISO8601DateUtils.parse(aEntry.get("dc:date")); |
14 | 335 |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
336 // FIXME: handle titles that contain markup or are missing. |
84
915e41848f6d
rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents:
76
diff
changeset
|
337 let messageID = this.addSimpleMessage(this.id, aExternalID, |
164 | 338 aEntry.title.text, authorID, |
260
f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
Myk Melez <myk@mozilla.org>
parents:
256
diff
changeset
|
339 timestamp, aReceived, aEntry.link); |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
340 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
341 // 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
|
342 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
|
343 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
|
344 (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
|
345 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
|
346 } |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
347 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
348 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
|
349 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
|
350 (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
|
351 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
|
352 } |
14 | 353 |
354 // Add metadata. | |
355 let fields = aEntry.QueryInterface(Ci.nsIFeedContainer). | |
356 fields.QueryInterface(Ci.nsIPropertyBag).enumerator; | |
357 while (fields.hasMoreElements()) { | |
358 let field = fields.getNext().QueryInterface(Ci.nsIProperty); | |
359 | |
164 | 360 // FIXME: create people records for these. |
14 | 361 if (field.name == "authors") { |
362 let values = field.value.QueryInterface(Ci.nsIArray).enumerate(); | |
363 while (values.hasMoreElements()) { | |
364 let value = values.getNext().QueryInterface(Ci.nsIFeedPerson); | |
365 // FIXME: store people records in a separate table with individual | |
366 // columns for each person attribute (i.e. name, email, url)? | |
118 | 367 this._addMetadatum(messageID, |
368 "atom:author", | |
369 value.name && value.email ? value.name + "<" + value.email + ">" | |
370 : value.name ? value.name : value.email); | |
14 | 371 } |
372 } | |
373 | |
374 else if (field.name == "links") { | |
375 let values = field.value.QueryInterface(Ci.nsIArray).enumerate(); | |
376 while (values.hasMoreElements()) { | |
377 let value = values.getNext().QueryInterface(Ci.nsIPropertyBag2); | |
378 // FIXME: store link records in a separate table with individual | |
379 // colums for each link attribute (i.e. href, type, rel, title)? | |
118 | 380 this._addMetadatum(messageID, |
381 "atom:link_" + value.get("rel"), | |
382 value.get("href")); | |
14 | 383 } |
384 } | |
385 | |
386 // For some reason, the values of certain simple fields (like RSS2 guid) | |
387 // are property bags containing the value instead of the value itself. | |
388 // For those, we need to unwrap the extra layer. This strange behavior | |
389 // has been filed as bug 427907. | |
390 else if (typeof field.value == "object") { | |
391 if (field.value instanceof Ci.nsIPropertyBag2) { | |
392 let value = field.value.QueryInterface(Ci.nsIPropertyBag2).get(field.name); | |
118 | 393 this._addMetadatum(messageID, field.name, value); |
14 | 394 } |
395 else if (field.value instanceof Ci.nsIArray) { | |
396 let values = field.value.QueryInterface(Ci.nsIArray).enumerate(); | |
397 while (values.hasMoreElements()) { | |
164 | 398 // FIXME: values might not always have this interface. |
14 | 399 let value = values.getNext().QueryInterface(Ci.nsIPropertyBag2); |
118 | 400 this._addMetadatum(messageID, field.name, value.get(field.name)); |
14 | 401 } |
402 } | |
403 } | |
404 | |
405 else | |
118 | 406 this._addMetadatum(messageID, field.name, field.value); |
14 | 407 } |
408 | |
409 return messageID; | |
410 }, | |
411 | |
412 /** | |
413 * Given an entry, generate an ID for it based on a hash of its link, | |
414 * published, and title attributes. Useful for uniquely identifying entries | |
415 * that don't provide their own IDs. | |
416 * | |
417 * @param entry {nsIFeedEntry} the entry for which to generate an ID | |
418 * @returns {string} an ID for the entry | |
419 */ | |
118 | 420 _generateID: function(entry) { |
14 | 421 let hasher = Cc["@mozilla.org/security/hash;1"]. |
422 createInstance(Ci.nsICryptoHash); | |
423 hasher.init(Ci.nsICryptoHash.SHA1); | |
118 | 424 let identity = stringToArray(entry.link.spec + entry.published + entry.title.text); |
14 | 425 hasher.update(identity, identity.length); |
426 return "urn:" + hasher.finish(true); | |
427 }, | |
428 | |
429 // FIXME: Make the rest of this stuff be part of a superclass from which | |
430 // this class is derived. | |
431 | |
432 /** | |
433 * Get the internal ID of the message with the given external ID. | |
434 * | |
435 * @param aExternalID {string} | |
436 * the external ID of the message | |
437 * | |
438 * @returns {number} | |
439 * the internal ID of the message, or undefined if the message | |
440 * doesn't exist | |
441 */ | |
118 | 442 _getInternalIDForExternalID: function(aExternalID) { |
14 | 443 return SnowlDatastore.selectInternalIDForExternalID(aExternalID); |
444 }, | |
445 | |
446 /** | |
447 * Add a message with a single part to the datastore. | |
448 * | |
449 * @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
|
450 * @param aExternalID {string} the external ID of the message |
14 | 451 * @param aSubject {string} the title of the message |
164 | 452 * @param aAuthorID {string} the author of the message |
14 | 453 * @param aTimestamp {Date} the date/time at which the message was sent |
454 * @param aLink {nsIURI} a link to the content of the message, | |
455 * if the content is hosted on a server | |
456 * | |
457 * @returns {integer} the internal ID of the newly-created message | |
458 */ | |
164 | 459 addSimpleMessage: function(aSourceID, aExternalID, aSubject, aAuthorID, |
260
f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
Myk Melez <myk@mozilla.org>
parents:
256
diff
changeset
|
460 aTimestamp, aReceived, aLink) { |
14 | 461 // Convert the link to its string spec, which is how we store it |
462 // in the datastore. | |
463 let link = aLink ? aLink.spec : null; | |
464 | |
465 let messageID = | |
164 | 466 SnowlDatastore.insertMessage(aSourceID, aExternalID, aSubject, aAuthorID, |
260
f88055405aee
make all messages received in the same refresh have the same received datetime, and support multiple sort properties when sorting a collection
Myk Melez <myk@mozilla.org>
parents:
256
diff
changeset
|
467 aTimestamp, aReceived, link); |
14 | 468 |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
469 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
|
470 }, |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
471 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
472 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
|
473 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
|
474 "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
|
475 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
|
476 ); |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
477 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
|
478 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
|
479 }, |
14 | 480 |
85
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
481 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
|
482 aMediaType) { |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 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
|
487 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
|
488 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
|
489 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
|
490 |
f5161c834622
store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents:
84
diff
changeset
|
491 return SnowlDatastore.dbConnection.lastInsertRowID; |
14 | 492 }, |
493 | |
118 | 494 _addMetadatum: function(aMessageID, aAttributeName, aValue) { |
14 | 495 // FIXME: speed this up by caching the list of known attributes. |
496 let attributeID = SnowlDatastore.selectAttributeID(aAttributeName) | |
497 || SnowlDatastore.insertAttribute(aAttributeName); | |
498 SnowlDatastore.insertMetadatum(aMessageID, attributeID, aValue); | |
499 }, | |
500 | |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
501 subscribe: function(callback) { |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
502 Observers.notify(this, "snowl:subscribe:connect:start", null); |
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
503 |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
504 this._subscribeCallback = callback; |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
505 |
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
|
506 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
|
507 |
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
|
508 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
|
509 |
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 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
|
511 |
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 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
|
513 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
|
514 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
|
515 |
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
|
516 request = request.QueryInterface(Ci.nsIXMLHttpRequest); |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
104
diff
changeset
|
517 |
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 // 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
|
519 // 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
|
520 request.overrideMimeType("text/plain"); |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
104
diff
changeset
|
521 |
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
|
522 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
|
523 |
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
|
524 // 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
|
525 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
|
526 |
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
|
527 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
|
528 }, |
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
|
529 |
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
|
530 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
|
531 let request = aEvent.target; |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
532 |
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
|
533 // 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
|
534 // 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
|
535 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
|
536 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
|
537 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
|
538 } |
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
|
539 |
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
|
540 // 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
|
541 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
|
542 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
|
543 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
|
544 } |
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
|
545 |
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
|
546 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
|
547 |
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
|
548 // _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
|
549 // 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
|
550 // 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
|
551 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
|
552 this._saveLogin(); |
137
447ad38415f8
show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents:
132
diff
changeset
|
553 |
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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 }, |
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
|
559 |
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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 }, |
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
|
567 |
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
|
568 onSubscribeResult: function(aResult) { |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
569 try { |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
570 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
|
571 |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
572 // 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
|
573 if (!this.name) |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
574 this.name = feed.title.plainText(); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
575 this.humanURI = feed.link; |
205 | 576 |
577 this.persist(); | |
578 | |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
579 // Let observers know about the new source. |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
580 this._obsSvc.notifyObservers(null, "sources:changed", null); |
205 | 581 |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
582 // 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
|
583 this.onRefreshResult(aResult); |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
584 } |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
585 catch(ex) { |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
586 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
|
587 } |
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
|
588 finally { |
138
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
589 if (this._subscribeCallback) |
58b04d16257c
integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents:
137
diff
changeset
|
590 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
|
591 } |
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
|
592 }, |
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 |
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 _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
|
595 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
|
596 |
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 // 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
|
598 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
|
599 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
|
600 "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
|
601 // 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
|
602 // 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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 "", |
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
|
609 ""); |
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
|
610 |
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
|
611 // 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
|
612 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
|
613 |
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
|
614 // 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
|
615 // 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
|
616 // 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
|
617 // 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 |
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
|
624 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
|
625 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
|
626 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
|
627 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
|
628 |
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
|
629 // 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
|
630 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
|
631 } |
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
|
632 |
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
|
633 }; |