Bug 340949: fixing calId encoded into url, alarms/ tunneling X- props, support for TRANSP

This commit is contained in:
daniel.boelzle%sun.com 2006-10-19 11:41:36 +00:00
Родитель e2a92a13ae
Коммит 3431aeecd7
3 изменённых файлов: 62 добавлений и 34 удалений

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

@ -384,10 +384,21 @@ calWcapCalendar.prototype.storeItem = function( item, oldItem, receiverFunc )
// xxx todo: sentBy sentUID fields in cs: missing in cal api
}
// xxx todo: force exclusion from free-busy calc for PRIVATE items
// until user can check this on/off in UI:
var strTransp = null;
if (item.hasProperty("TRANSP"))
strTransp = item.getProperty("TRANSP");
switch (strTransp) {
case "TRANSPARENT":
url += "&transparent=1";
break;
case "OPAQUE":
url += "&transparent=0";
break;
default:
url += ("&transparent=" +
(((icsClass == "PRIVATE") || bIsAllDay) ? "1" : "0"));
break;
}
url += ("&isAllDay=" + (bIsAllDay ? "1" : "0"));
@ -504,7 +515,22 @@ calWcapCalendar.prototype.storeItem = function( item, oldItem, receiverFunc )
url + "&fmt-out=text%2Fcalendar", stringToIcal, receiverFunc );
};
calWcapCalendar.prototype.adoptItem_resp = function( wcapResponse, listener )
calWcapCalendar.prototype.tunnelXProps = function( destItem, srcItem )
{
var enum = srcItem.propertyEnumerator;
while (enum.hasMoreElements()) {
var prop = enum.getNext().QueryInterface(
Components.interfaces.nsIProperty);
var name = prop.name;
if (name.indexOf("X-MOZ-") == 0) {
this.log( "tunneling " + name );
destItem.setProperty(name, prop.value);
}
}
};
calWcapCalendar.prototype.adoptItem_resp = function(
wcapResponse, newItem_, listener )
{
var item = null;
try {
@ -513,12 +539,14 @@ calWcapCalendar.prototype.adoptItem_resp = function( wcapResponse, listener )
var items = this.parseItems(
icalRootComp,
Components.interfaces.calICalendar.ITEM_FILTER_ALL_ITEMS,
0, null, null );
0, null, null, true /* bLeaveMutable */ );
if (items.length < 1)
throw new Components.Exception("empty VCALENDAR returned!");
if (items.length > 1)
this.notifyError( "unexpected number of items: " + items.length );
item = items[0];
this.tunnelXProps(item, newItem_);
item.makeImmutable();
this.log( "item.id=" + item.id );
if (listener != null) {
@ -560,7 +588,7 @@ calWcapCalendar.prototype.adoptItem = function( item, listener )
this.storeItem(
item, oldItem,
function( wcapResponse ) {
this_.adoptItem_resp( wcapResponse, listener );
this_.adoptItem_resp( wcapResponse, item, listener );
} );
}
catch (exc) {
@ -581,7 +609,7 @@ calWcapCalendar.prototype.addItem = function( item, listener )
};
calWcapCalendar.prototype.modifyItem_resp = function(
wcapResponse, oldItem, listener )
wcapResponse, newItem_, oldItem, listener )
{
var item = null;
try {
@ -590,12 +618,14 @@ calWcapCalendar.prototype.modifyItem_resp = function(
var items = this.parseItems(
icalRootComp,
Components.interfaces.calICalendar.ITEM_FILTER_ALL_ITEMS,
0, null, null );
0, null, null, true /* bLeaveMutable */ );
if (items.length < 1)
throw new Components.Exception("empty VCALENDAR returned!");
if (items.length > 1)
this.notifyError( "unexpected number of items: " + items.length );
item = items[0];
this.tunnelXProps(item, newItem_);
item.makeImmutable();
if (listener != null) {
listener.onOperationComplete(
@ -629,7 +659,7 @@ calWcapCalendar.prototype.modifyItem = function( newItem, oldItem, listener )
this.storeItem(
newItem, oldItem,
function( wcapResponse ) {
this_.modifyItem_resp( wcapResponse, oldItem, listener );
this_.modifyItem_resp(wcapResponse, newItem, oldItem, listener);
} );
}
catch (exc) {
@ -715,7 +745,8 @@ calWcapCalendar.prototype.deleteItem = function( item, listener )
};
calWcapCalendar.prototype.parseItems = function(
icalRootComp, itemFilter, maxResult, rangeStart, rangeEnd )
icalRootComp, itemFilter, maxResult, rangeStart, rangeEnd,
bLeaveMutable )
{
var unexpandedItems = [];
var uid2parent = {};
@ -889,6 +920,7 @@ calWcapCalendar.prototype.parseItems = function(
++i )
{
var item = unexpandedItems[i];
if (!bLeaveMutable)
item.makeImmutable();
if (item.recurrenceInfo != null &&
(itemFilter & Components.interfaces.calICalendar
@ -1287,7 +1319,7 @@ calWcapCalendar.prototype.syncChangesTo = function(
try {
var this_ = this;
// new stamp for this sync:
var now = getTime(); // xxx todo: not exact
var now = getTime();
var syncState = new SyncState(
// finishFunc:
@ -1329,7 +1361,7 @@ calWcapCalendar.prototype.syncChangesTo = function(
var params = ("&relativealarm=1&compressed=1&recurring=1&calid=" +
encodeURIComponent(this.calId));
params += ("&fmt-out=text%2Fcalendar&dtstart=" + zdtFrom);
params += ("&dtend=" + getIcalUTC(now));
params += ("&dtend=" + getIcalUTC( this.session.getServerTime(now) ));
syncState.acquire();
this.session.issueAsyncRequest(

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

@ -79,7 +79,7 @@ var LOG_TIMEZONE = null;
var LOG_FILE_STREAM = null;
// whether alarms are by default turned on/off:
var SUPPRESS_ALARMS = true;
var SUPPRESS_ALARMS = false;
function initWcapProvider()
{
@ -145,8 +145,7 @@ function initWcapProvider()
"#################################" );
}
SUPPRESS_ALARMS = getPref("calendar.wcap.suppress_alarms", true);
if (SUPPRESS_ALARMS)
SUPPRESS_ALARMS = getPref("calendar.wcap.suppress_alarms", false);
logMessage( "calendar.wcap.suppress_alarms", SUPPRESS_ALARMS );
// init cache dir directory:

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

@ -336,13 +336,7 @@ calWcapSession.prototype = {
}
}
// xxx todo: realm names must not have a
// trailing slash
var sessionUri = this_.uri.clone();
var spec = sessionUri.spec;
if (spec[spec.length - 1] == '/')
spec = spec.substr(0, spec.length - 1);
sessionUri.spec = spec;
sessionUri.userPass = "";
if (sessionUri.scheme.toLowerCase() != "https" &&
sessionUri.port == -1 /* no port specified */)
@ -415,8 +409,12 @@ calWcapSession.prototype = {
Components.classes["@mozilla.org/passwordmanager;1"]
.getService(Components.interfaces.nsIPasswordManager);
// xxx todo: pw host names must not have a trailing slash
var pwHost = sessionUri.spec;
if (pwHost[pwHost.length - 1] == '/')
pwHost = pwHost.substr(0, pwHost.length - 1);
this.log( "looking in pw db for: " + pwHost );
var enumerator = passwordManager.enumerator;
this.log( "looking in pw db for: " + sessionUri.spec );
while (enumerator.hasMoreElements()) {
var pwEntry = enumerator.getNext().QueryInterface(
Components.interfaces.nsIPassword );
@ -424,7 +422,7 @@ calWcapSession.prototype = {
this.log( "pw entry:\n\thost=" + pwEntry.host +
"\n\tuser=" + pwEntry.user );
}
if (pwEntry.host == sessionUri.spec) {
if (pwEntry.host == pwHost) {
// found an entry matching URI:
outUser.value = pwEntry.user;
outPW.value = pwEntry.password;
@ -433,22 +431,21 @@ calWcapSession.prototype = {
}
if (outPW.value) {
this.log( "password entry found for host " + sessionUri.spec +
this.log( "password entry found for host " + pwHost +
"\nuser is " + outUser.value );
this.assureSecureLogin(sessionUri);
this.login_( sessionUri, outUser.value, outPW.value );
}
else
this.log( "no password entry found for " + sessionUri.spec );
this.log( "no password entry found for " + pwHost );
if (!this.m_sessionId) {
var loginText = this.getServerInfo(sessionUri);
if (outPW.value) {
// login failed before, so try to remove from pw db:
try {
passwordManager.removeUser( sessionUri.spec,
outUser.value );
this.log( "removed from pw db: " + sessionUri.spec );
passwordManager.removeUser( pwHost, outUser.value );
this.log( "removed from pw db: " + pwHost );
}
catch (exc) {
this.logError( "error removing from pw db: " + exc );
@ -481,9 +478,9 @@ calWcapSession.prototype = {
}
if (savePW.value) {
try { // save pw under session uri:
passwordManager.addUser( sessionUri.spec,
passwordManager.addUser( pwHost,
outUser.value, outPW.value );
this.log( "added to pw db: " + sessionUri.spec );
this.log( "added to pw db: " + pwHost );
}
catch (exc) {
this.logError( "error adding pw to db: " + exc );