annotate modules/feed.js @ 382:8460f746207e default tip

remove extraneous log statement
author Myk Melez <myk@mozilla.org>
date Sat, 08 Nov 2008 10:38:57 -0800
parents 6916b17a0536 2116e44e4c17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
308
553ceeb3507b factor out PART_TYPE_* constants
Myk Melez <myk@mozilla.org>
parents: 287
diff changeset
37 let EXPORTED_SYMBOLS = ["SnowlFeed"];
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
38
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
39 const Cc = Components.classes;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
40 const Ci = Components.interfaces;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
41 const Cr = Components.results;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
42 const Cu = Components.utils;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
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
308
553ceeb3507b factor out PART_TYPE_* constants
Myk Melez <myk@mozilla.org>
parents: 287
diff changeset
48 // modules that are generic
114
5669c7260ce3 import stuff first
Myk Melez <myk@mozilla.org>
parents: 113
diff changeset
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
5669c7260ce3 import stuff first
Myk Melez <myk@mozilla.org>
parents: 113
diff changeset
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
271
54b59324bd71 update the stream view when messages get added
Myk Melez <myk@mozilla.org>
parents: 260
diff changeset
53 // modules that are Snowl-specific
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
54 Cu.import("resource://snowl/modules/datastore.js");
114
5669c7260ce3 import stuff first
Myk Melez <myk@mozilla.org>
parents: 113
diff changeset
55 Cu.import("resource://snowl/modules/source.js");
357
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
56 Cu.import("resource://snowl/modules/target.js");
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
57 Cu.import("resource://snowl/modules/identity.js");
282
76ee747a1dba add messages progressively to the stream view rather than rebuilding the view each time
Myk Melez <myk@mozilla.org>
parents: 271
diff changeset
58 Cu.import("resource://snowl/modules/message.js");
287
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
59 Cu.import("resource://snowl/modules/utils.js");
239
2116e44e4c17 Added a simple, tentative source type registration API to SnowlService. Rather than coupling SnowlService to specific source types by importing their JS modules in service.js, we now have the source types register with SnowlService upon import by calling a new method, SnowlService.addSourceType(). This makes it easy for third parties to add new source types without having to modify Snowl's source code.
Atul Varma <varmaa@toolness.com>
parents: 229
diff changeset
60 Cu.import("resource://snowl/modules/service.js");
114
5669c7260ce3 import stuff first
Myk Melez <myk@mozilla.org>
parents: 113
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
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
67 /**
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
68 * Convert a string to an array of character codes.
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
69 *
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
70 * @param string {string} the string to convert
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
71 * @returns {array} the array of character codes
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
72 */
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
73 function stringToArray(string) {
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
74 var array = [];
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
75 for (let i = 0; i < string.length; i++)
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
76 array.push(string.charCodeAt(i));
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
77 return array;
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
78 }
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
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
ce534ed8a39e make refreshing twitter work
Myk Melez <myk@mozilla.org>
parents: 192
diff changeset
86 constructor: SnowlFeed,
ce534ed8a39e make refreshing twitter work
Myk Melez <myk@mozilla.org>
parents: 192
diff changeset
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
357
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
97
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
98 //**************************************************************************//
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
99 // Class Composition Goo
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
100
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
101 _classes: [SnowlSource],
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
102
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
103 implements: function(cls) {
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
104 return (this._classes.indexOf(cls) != -1);
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
105 },
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
106
357
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
107
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
108 //**************************************************************************//
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
109 // XPCOM Interface Goo
1db123f46ed7 add some glue to let sources be queried to see if they are also targets
Myk Melez <myk@mozilla.org>
parents: 355
diff changeset
110
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
111 // 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
112
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 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
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 // 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
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 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
118 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
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
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // 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
122
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
123 _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
124 _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
125
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
126 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
127 // 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
128 // 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
129 // 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
130 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
131 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
132 // 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
133 // 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
134 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
135 }
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 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
138 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
139 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
140 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
141 ++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
142 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
143 }
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // 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
146 // 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
147 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
148 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
149 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
150
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // |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
152 // 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
153 // 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
154 // 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
155 // 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
156 // 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
157 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
158 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
159
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 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
161 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
162 // 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
163 "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
164 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
165 "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
166 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
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 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
169 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
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 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
172 },
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
173
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
174 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
175 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
176 },
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
177
116
cb8bbdf99268 getNewMessages -> refresh
Myk Melez <myk@mozilla.org>
parents: 115
diff changeset
178 refresh: function() {
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
179 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
180
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
181 request.QueryInterface(Ci.nsIDOMEventTarget);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
182 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
183 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
184 request.addEventListener("error", function(e) { t.onRefreshError(e) }, false);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
185
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
186 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
187
754441ddeaa3 combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents: 108
diff changeset
188 // 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
189 // 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
190 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
191
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
192 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
193
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
194 // 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
195 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
196
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
197 request.send(null);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
198 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
199
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
200 onRefreshLoad: function(aEvent) {
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
201 let request = aEvent.target;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
202
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
203 // 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
204 // 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
205 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
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
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
210 // 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
211 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
212 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
213 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
214 }
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
215
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
216 // _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
217 // 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
218 // 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
219 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
220 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
221
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 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
223 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
224 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
225 parser.parseFromString(request.responseText, request.channel.URI);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
226 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
227
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
228 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
229 let request = aEvent.target;
144
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
230
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
231 // 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
232 let statusText = "";
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
233 try {
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
234 statusText = request.statusText;
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
235 }
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
236 catch(ex) {}
239
2116e44e4c17 Added a simple, tentative source type registration API to SnowlService. Rather than coupling SnowlService to specific source types by importing their JS modules in service.js, we now have the source types register with SnowlService upon import by calling a new method, SnowlService.addSourceType(). This makes it easy for third parties to add new source types without having to modify Snowl's source code.
Atul Varma <varmaa@toolness.com>
parents: 229
diff changeset
237
144
510dc9c6647d catch exceptions sometimes thrown when retrieving XMLHttpRequest::statusText
Myk Melez <myk@mozilla.org>
parents: 139
diff changeset
238 this._log.error("onRefreshError: " + request.status + " (" + statusText + ")");
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
239 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
240
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
241 onRefreshResult: function(aResult) {
318
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
242 // FIXME: Make this be "snowl:refresh:start" or move it into the subscribing
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
243 // caller so it makes sense that it's called "snowl:subscribe:get:start",
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
244 // since this method also gets called during periodically on feeds to which
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
245 // the user is already subscribed.
137
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
246 Observers.notify(this, "snowl:subscribe:get:start", null);
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
247
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
248 // Now that we know we successfully downloaded the feed and obtained
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
249 // 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
250 this.lastRefreshed = new Date();
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
251
318
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
252 // FIXME: handle the case where this throws |aResult.doc is null|
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
253 // because the feed processor couldn't parse the feed file
0856399a6a9e comment about two things that need fixing in SnowlFeed::onRefreshResult
Myk Melez <myk@mozilla.org>
parents: 308
diff changeset
254 // (f.e. because its content isn't a valid 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
255 let feed = aResult.doc.QueryInterface(Components.interfaces.nsIFeed);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
256
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
257 let currentMessageIDs = [];
121
110b9b8aed1f only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents: 118
diff changeset
258 let messagesChanged = false;
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
259
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
260 SnowlDatastore.dbConnection.beginTransaction();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
261 try {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
262 for (let i = 0; i < feed.items.length; i++) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
263 let entry = feed.items.queryElementAt(i, Ci.nsIFeedEntry);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
264 //entry.QueryInterface(Ci.nsIFeedContainer);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
265
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
266 // Figure out the ID for the entry, then check if the entry has already
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
267 // been retrieved. If we can't figure out the entry's ID, then we skip
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
268 // the entry, since its ID is the only way for us to know whether or not
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
269 // it has already been retrieved.
84
915e41848f6d rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents: 76
diff changeset
270 let externalID;
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
271 try {
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
272 externalID = entry.id || this._generateID(entry);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
273 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
274 catch(ex) {
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
275 this._log.warn("couldn't retrieve a message: " + ex);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
276 continue;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
277 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
278
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
279 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
280 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
281 currentMessageIDs.push(internalID);
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
282 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
283 }
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
284
121
110b9b8aed1f only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents: 118
diff changeset
285 messagesChanged = true;
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
286 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
287 internalID = this._addMessage(feed, entry, externalID, this.lastRefreshed);
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
288 currentMessageIDs.push(internalID);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
289 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
290
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
291 // 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
292 // XXX Should this affect whether or not messages have changed?
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
293 SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages SET current = 0 WHERE sourceID = " + this.id);
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
294 SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages SET current = 1 WHERE id IN (" + currentMessageIDs.join(", ") + ")");
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
295
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
296 SnowlDatastore.dbConnection.commitTransaction();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
297 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
298 catch(ex) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
299 SnowlDatastore.dbConnection.rollbackTransaction();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
300 throw ex;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
301 }
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
302
121
110b9b8aed1f only notify observers that messages have changed if they have
Myk Melez <myk@mozilla.org>
parents: 118
diff changeset
303 if (messagesChanged)
358
c00b3db58dcf add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents: 357
diff changeset
304 Observers.notify(null, "snowl:messages:changed", null);
137
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
305
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
306 Observers.notify(this, "snowl:subscribe:get:end", null);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
307 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
308
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
309 /**
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
310 * Add a message to the datastore for the given feed entry.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
311 *
132
8f3137f7cc0a employ gymnastics to come up with a reasonable author string
Myk Melez <myk@mozilla.org>
parents: 130
diff changeset
312 * @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
313 * @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
314 * @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
315 * @param aReceived {Date} when the message was received
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
316 */
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
317 _addMessage: function(aFeed, aEntry, aExternalID, aReceived) {
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
318 let authorID = null;
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
319 let authors = (aEntry.authors.length > 0) ? aEntry.authors
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
320 : (aFeed.authors.length > 0) ? aFeed.authors
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
321 : null;
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
322 if (authors && authors.length > 0) {
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
323 let author = authors.queryElementAt(0, Ci.nsIFeedPerson);
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
324 // The external ID for an author is her email address, if provided
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
325 // (many feeds don't); otherwise it's her name. For the name, on the
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
326 // other hand, we use the name, if provided, but fall back to the
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
327 // email address if a name is not provided (which it probably was).
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
328 let externalID = author.email || author.name;
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
329 let name = author.name || author.email;
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
330
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
331 // Get an existing identity or create a new one. Creating an identity
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
332 // automatically creates a person record with the provided name.
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
333 identity = SnowlIdentity.get(this.id, externalID) ||
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
334 SnowlIdentity.create(this.id, externalID, name);
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
335 authorID = identity.personID;
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
336 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
337
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
338 // 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
339 // 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
340 // 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
341 // 3. the Dublin Core timestamp associated with the entry;
287
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
342 let timestamp = aEntry.updated ? new Date(aEntry.updated)
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
343 : aEntry.published ? new Date(aEntry.published)
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
344 : aEntry.get("dc:date") ? ISO8601DateUtils.parse(aEntry.get("dc:date"))
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
345 : null;
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
346
85
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
347 // FIXME: handle titles that contain markup or are missing.
84
915e41848f6d rename universalID to externalID
Myk Melez <myk@mozilla.org>
parents: 76
diff changeset
348 let messageID = this.addSimpleMessage(this.id, aExternalID,
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
349 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
350 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
351
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
352 // 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
353 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
354 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
355 (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
356 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
357 }
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
358
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
359 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
360 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
361 (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
362 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
363 }
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
364
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
365 // Add metadata.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
366 let fields = aEntry.QueryInterface(Ci.nsIFeedContainer).
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
367 fields.QueryInterface(Ci.nsIPropertyBag).enumerator;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
368 while (fields.hasMoreElements()) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
369 let field = fields.getNext().QueryInterface(Ci.nsIProperty);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
370
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
371 // FIXME: create people records for these.
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
372 if (field.name == "authors") {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
373 let values = field.value.QueryInterface(Ci.nsIArray).enumerate();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
374 while (values.hasMoreElements()) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
375 let value = values.getNext().QueryInterface(Ci.nsIFeedPerson);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
376 // FIXME: store people records in a separate table with individual
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
377 // columns for each person attribute (i.e. name, email, url)?
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
378 this._addMetadatum(messageID,
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
379 "atom:author",
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
380 value.name && value.email ? value.name + "<" + value.email + ">"
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
381 : value.name ? value.name : value.email);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
382 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
383 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
384
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
385 else if (field.name == "links") {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
386 let values = field.value.QueryInterface(Ci.nsIArray).enumerate();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
387 while (values.hasMoreElements()) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
388 let value = values.getNext().QueryInterface(Ci.nsIPropertyBag2);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
389 // FIXME: store link records in a separate table with individual
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
390 // colums for each link attribute (i.e. href, type, rel, title)?
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
391 this._addMetadatum(messageID,
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
392 "atom:link_" + value.get("rel"),
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
393 value.get("href"));
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
394 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
395 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
396
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
397 // For some reason, the values of certain simple fields (like RSS2 guid)
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
398 // are property bags containing the value instead of the value itself.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
399 // For those, we need to unwrap the extra layer. This strange behavior
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
400 // has been filed as bug 427907.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
401 else if (typeof field.value == "object") {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
402 if (field.value instanceof Ci.nsIPropertyBag2) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
403 let value = field.value.QueryInterface(Ci.nsIPropertyBag2).get(field.name);
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
404 this._addMetadatum(messageID, field.name, value);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
405 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
406 else if (field.value instanceof Ci.nsIArray) {
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
407 let values = field.value.QueryInterface(Ci.nsIArray).enumerate();
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
408 while (values.hasMoreElements()) {
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
409 // FIXME: values might not always have this interface.
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
410 let value = values.getNext().QueryInterface(Ci.nsIPropertyBag2);
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
411 this._addMetadatum(messageID, field.name, value.get(field.name));
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
412 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
413 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
414 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
415
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
416 else
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
417 this._addMetadatum(messageID, field.name, field.value);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
418 }
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
419
282
76ee747a1dba add messages progressively to the stream view rather than rebuilding the view each time
Myk Melez <myk@mozilla.org>
parents: 271
diff changeset
420 Observers.notify(SnowlMessage.get(messageID), "snowl:message:added", null);
76ee747a1dba add messages progressively to the stream view rather than rebuilding the view each time
Myk Melez <myk@mozilla.org>
parents: 271
diff changeset
421
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
422 return messageID;
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
423 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
424
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
425 /**
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
426 * Given an entry, generate an ID for it based on a hash of its link,
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
427 * published, and title attributes. Useful for uniquely identifying entries
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
428 * that don't provide their own IDs.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
429 *
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
430 * @param entry {nsIFeedEntry} the entry for which to generate an ID
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
431 * @returns {string} an ID for the entry
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
432 */
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
433 _generateID: function(entry) {
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
434 let hasher = Cc["@mozilla.org/security/hash;1"].
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
435 createInstance(Ci.nsICryptoHash);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
436 hasher.init(Ci.nsICryptoHash.SHA1);
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
437 let identity = stringToArray(entry.link.spec + entry.published + entry.title.text);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
438 hasher.update(identity, identity.length);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
439 return "urn:" + hasher.finish(true);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
440 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
441
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
442 // FIXME: Make the rest of this stuff be part of a superclass from which
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
443 // this class is derived.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
444
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
445 /**
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
446 * Get the internal ID of the message with the given external ID.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
447 *
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
448 * @param aExternalID {string}
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
449 * the external ID of the message
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
450 *
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
451 * @returns {number}
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
452 * the internal ID of the message, or undefined if the message
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
453 * doesn't exist
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
454 */
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
455 _getInternalIDForExternalID: function(aExternalID) {
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
456 return SnowlDatastore.selectInternalIDForExternalID(aExternalID);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
457 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
458
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
459 /**
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
460 * Add a message with a single part to the datastore.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
461 *
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
462 * @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
463 * @param aExternalID {string} the external ID of the message
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
464 * @param aSubject {string} the title of the message
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
465 * @param aAuthorID {string} the author of the message
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
466 * @param aTimestamp {Date} the date/time at which the message was sent
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
467 * @param aLink {nsIURI} a link to the content of the message,
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
468 * if the content is hosted on a server
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
469 *
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
470 * @returns {integer} the internal ID of the newly-created message
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
471 */
164
e3bdf5b26748 basic support for people
Myk Melez <myk@mozilla.org>
parents: 144
diff changeset
472 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
473 aTimestamp, aReceived, aLink) {
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
474 let messageID =
287
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
475 SnowlDatastore.insertMessage(aSourceID,
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
476 aExternalID,
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
477 aSubject,
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
478 aAuthorID,
355
e9d7087abad1 implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents: 330
diff changeset
479 SnowlDateUtils.jsToJulianDate(aTimestamp),
e9d7087abad1 implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents: 330
diff changeset
480 SnowlDateUtils.jsToJulianDate(aReceived),
287
113312a23f53 use julian dates for the lastRefreshed values, push date conversion up the stack (away from the core database access routines), and make the datastore code migrate from a version 4 to a version 5 schema (storing julian instead of JS dates)
Myk Melez <myk@mozilla.org>
parents: 282
diff changeset
481 aLink ? aLink.spec : null);
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
482
85
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
483 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
484 },
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
485
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
486 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
487 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
488 "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
489 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
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 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
492 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
493 },
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
494
85
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
495 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
496 aMediaType) {
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
497 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
498 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
499 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
500 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
501 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
502 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
503 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
504
f5161c834622 store summaries in addition to content and display them in the river view
Myk Melez <myk@mozilla.org>
parents: 84
diff changeset
505 return SnowlDatastore.dbConnection.lastInsertRowID;
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
506 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
507
118
3c16d71594e5 some code cleanup
Myk Melez <myk@mozilla.org>
parents: 117
diff changeset
508 _addMetadatum: function(aMessageID, aAttributeName, aValue) {
14
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
509 // FIXME: speed this up by caching the list of known attributes.
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
510 let attributeID = SnowlDatastore.selectAttributeID(aAttributeName)
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
511 || SnowlDatastore.insertAttribute(aAttributeName);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
512 SnowlDatastore.insertMetadatum(aMessageID, attributeID, aValue);
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
513 },
74f775701774 refresh sources once per hour
Myk Melez <myk@mozilla.org>
parents:
diff changeset
514
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
515 subscribe: function(callback) {
137
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
516 Observers.notify(this, "snowl:subscribe:connect:start", null);
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
517
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
518 this._subscribeCallback = callback;
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
519
112
754441ddeaa3 combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents: 108
diff changeset
520 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
521
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
522 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
523
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
524 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
525
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
526 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
527 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
528 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
529
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
530 request = request.QueryInterface(Ci.nsIXMLHttpRequest);
106
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 104
diff changeset
531
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
532 // 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
533 // 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
534 request.overrideMimeType("text/plain");
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 104
diff changeset
535
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
536 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
537
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // 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
539 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
540
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
541 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
542 },
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
543
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
544 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
545 let request = aEvent.target;
137
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
546
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
547 // 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
548 // 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
549 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
550 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
551 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
552 }
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
553
112
754441ddeaa3 combine the SnowlFeed and SnowlFeedSubscriber objects, and make it inherit from SnowlSource; also, remove the obsolete SnowlFeedClient
Myk Melez <myk@mozilla.org>
parents: 108
diff changeset
554 // 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
555 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
556 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
557 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
558 }
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
559
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
560 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
561
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // _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
563 // 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
564 // 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
565 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
566 this._saveLogin();
137
447ad38415f8 show subscription progress in subscribe dialog
Myk Melez <myk@mozilla.org>
parents: 132
diff changeset
567
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
568 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
569 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
570 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
571 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
572 },
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
573
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
574 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
575 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
576 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
577 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
578 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
579 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
580 },
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
581
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
582 onSubscribeResult: function(aResult) {
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
583 try {
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
584 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
585
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
586 // 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
587 if (!this.name)
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
588 this.name = feed.title.plainText();
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
589 this.humanURI = feed.link;
205
ce534ed8a39e make refreshing twitter work
Myk Melez <myk@mozilla.org>
parents: 192
diff changeset
590
ce534ed8a39e make refreshing twitter work
Myk Melez <myk@mozilla.org>
parents: 192
diff changeset
591 this.persist();
ce534ed8a39e make refreshing twitter work
Myk Melez <myk@mozilla.org>
parents: 192
diff changeset
592
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
593 // Let observers know about the new source.
358
c00b3db58dcf add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents: 357
diff changeset
594 Observers.notify(null, "snowl:sources:changed", null);
205
ce534ed8a39e make refreshing twitter work
Myk Melez <myk@mozilla.org>
parents: 192
diff changeset
595
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
596 // 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
597 this.onRefreshResult(aResult);
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
598 }
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
599 catch(ex) {
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
600 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
601 }
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
602 finally {
138
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
603 if (this._subscribeCallback)
58b04d16257c integrate subscription UI into a single page
Myk Melez <myk@mozilla.org>
parents: 137
diff changeset
604 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
605 }
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
606 },
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 _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
609 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
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 // 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
612 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
613 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
614 "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
615 // 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
616 // 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
617 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
618 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
619 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
620 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
621 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
622 "",
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // 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
626 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
627
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, 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 // 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
629 // 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
630 // 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
631 // 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
632 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
633 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
634 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
635 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
636 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
637
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
638 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
639 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
640 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
641 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
642
8763c90ce556 better support for feeds that require authentication; we now display a custom authentication dialog that hopefully makes more sense when it appears out of the blue; we also use it when subscribing the user to the feed, and it includes UI for the user to request that their credentials be remembered; finally, we use remembered credentials automatically across sessions instead of prompting at least once per session
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
643 // 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
644 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
645 }
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
646
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
647 };
239
2116e44e4c17 Added a simple, tentative source type registration API to SnowlService. Rather than coupling SnowlService to specific source types by importing their JS modules in service.js, we now have the source types register with SnowlService upon import by calling a new method, SnowlService.addSourceType(). This makes it easy for third parties to add new source types without having to modify Snowl's source code.
Atul Varma <varmaa@toolness.com>
parents: 229
diff changeset
648
380
6916b17a0536 Automated merge with http://hg.toolness.com/snowl/
Myk Melez <myk@mozilla.org>
parents: 358
diff changeset
649 SnowlService.addAccountType(SnowlFeed);