bug 335462 - Queues up authentication requests to prevent multiple auth prompts. Patch by Bruno Browning <browning@uwalumni.com>, r=lilmatt, dmose

This commit is contained in:
mattwillis%gmail.com 2006-09-26 20:29:45 +00:00
Родитель 3d47173317
Коммит 3b17f6d9dc
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -24,6 +24,8 @@
* Dan Mosedale <dan.mosedale@oracle.com>
* Mike Shaver <mike.x.shaver@oracle.com>
* Gary van der Merwe <garyvdm@gmail.com>
* Bruno Browning <browning@uwalumni.com>
* Matthew Willis <lilmatt@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -88,6 +90,12 @@ function makeOccurrence(item, start, end)
const START_OF_TIME = -0x7fffffffffffffff;
const END_OF_TIME = 0x7fffffffffffffff;
// used by mAuthenticationStatus
const kCaldavNoAuthentication = 0;
const kCaldavFirstRequestSent = 1; // Queueing subsequent requests
const kCaldavFreshlyAuthenticated = 2; // Need to process queue
const kCaldavAuthenticated = 3; // Queue being processed or empty
calDavCalendar.prototype = {
//
// nsISupports interface
@ -146,6 +154,11 @@ calDavCalendar.prototype = {
this.mReadOnly = bool;
},
// attribute PRUInt8 mAuthenticationStatus;
mAuthenticationStatus: 0,
mPendingStartupRequests: Array(),
get canRefresh() {
// refresh() is currently not implemented, but we may want to change that
return false;
@ -619,6 +632,18 @@ calDavCalendar.prototype = {
LOG("reportInternal's onGetResult threw an"
+ " exception " + ex + "; ignoring");
}
// We have a result, so we must be authenticated
if (thisCalendar.mAuthenticationStatus == kCaldavFirstRequestSent) {
thisCalendar.mAthenticationStatus = kCaldavFreshlyAuthenticated;
}
if (thisCalendar.mAuthenticationStatus == kCaldavFreshlyAuthenticated) {
thisCalendar.mAuthenticationStatus = kCaldavAuthenticated;
for (var req in thisCalendar.mPendingStartupRequests) {
thisCalendar.getItems.apply(this, req.pop());
}
}
return;
};
@ -681,6 +706,15 @@ calDavCalendar.prototype = {
if (!aListener)
return;
if (this.mAuthenticationStatus == kCaldavFirstRequestSent) {
var req = new Array(aItemFilter, aCount, aRangeStart, aRangeEnd, aListener);
this.mPendingStartupRequests.push(req);
return;
}
if (this.mAuthenticationStatus == kCaldavNoAuthentication) {
this.mAuthenticationStatus = kCaldavFirstRequestSent;
}
// this is our basic report xml
var C = new Namespace("C", "urn:ietf:params:xml:ns:caldav");
var D = new Namespace("D", "DAV:");