/usr/lib/thunderbird-addons/extensions/{e2fda1a4-762b-4020-b5ad-a41df1933103}/calendar-js/calWcapCalendar.js is in xul-ext-lightning 1:24.4.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://calendar/modules/calUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function calWcapCalendar(/*optional*/session, /*optional*/calProps) {
this.initProviderBase();
this.m_session = session;
this.m_calProps = calProps;
}
const calWcapCalendarClassID = Components.ID("{cf4d93e5-af79-451a-95f3-109055b32ef0}");
const calWcapCalendarInterfaces = [
calIWcapCalendar,
calICalendar,
Components.interfaces.calISchedulingSupport,
Components.interfaces.calIChangeLog,
Components.interfaces.calICalendarProvider,
];
calWcapCalendar.prototype = {
__proto__: cal.ProviderBase.prototype,
classID: calWcapCalendarClassID,
QueryInterface: XPCOMUtils.generateQI(calWcapCalendarInterfaces),
classInfo: XPCOMUtils.generateCI({
classID: calWcapCalendarClassID,
contractID: "@mozilla.org/calendar/calendar;1?type=wcap",
classDescription: "Sun Java System Calendar Server WCAP Provider",
interfaces: calWcapCalendarInterfaces
}),
toString: function calWcapCalendar_toString() {
var str = this.session.toString();
if (this.m_calId) {
str += (", calId=" + this.calId);
} else {
str += ", default calendar";
}
return str;
},
notifyError_: function calWcapCalendar_notifyError_(err, msg, context) {
var rc = getResultCode(err);
switch (rc) {
case calIWcapErrors.WCAP_COMPONENT_NOT_FOUND:
case NS_ERROR_OFFLINE:
return;
default:
msg = errorToString(err);
log("error: " + msg, context);
break;
}
this.__proto__.__proto__.notifyError.apply(
this,
err instanceof Components.interfaces.nsIException
? [err.result, err.message]
: [(isNaN(err) ? Components.results.NS_ERROR_FAILURE : err), msg]);
},
notifyError: function calWcapCalendar_notifyError(err, msg) {
this.notifyError_(err, msg, this);
},
// calICalendarProvider:
get prefChromeOverlay() {
return null;
},
// displayName attribute already part of calIWcapCalendar
createCalendar: function calWcapCalendar_createCalendar(name, url, listener) {
throw NS_ERROR_NOT_IMPLEMENTED;
},
deleteCalendar: function calWcapCalendar_deleteCalendar(calendar, listener) {
throw NS_ERROR_NOT_IMPLEMENTED;
},
getCalendar: function calWcapCalendar_getCalendar(url) {
throw NS_ERROR_NOT_IMPLEMENTED;
},
// calICalendar:
get name() {
var name = this.getProperty("name");
if (!name) {
name = this.displayName;
}
return name;
},
set name(aValue) {
return this.setProperty("name", aValue);
},
get type() {
return "wcap";
},
m_uri: null,
get uri() {
return this.m_uri;
},
set uri(thatUri) {
this.m_uri = thatUri.clone();
var path = thatUri.path;
var qmPos = path.indexOf("?");
if (qmPos != -1) {
var pos = path.indexOf("?calid=", qmPos);
if (pos != -1) {
var start = (pos + "?calid=".length);
var end = path.indexOf("&", start);
this.m_calId = decodeURIComponent(
path.substring(start, end == -1 ? path.length : end));
}
}
return this.uri;
},
getProperty: function calWcapCalendar_getProperty(aName) {
switch (aName) {
case "cache.supported":
return true;
case "timezones.provider":
return ((this.m_session && this.session.isLoggedIn) ? this.session : null);
case "organizerId":
return this.ownerId;
case "organizerCN":
return this.getCalendarProperties("X-S1CS-CALPROPS-COMMON-NAME");
case "itip.disableRevisionChecks":
return true;
case "capabilities.timezones.floating.supported":
case "capabilities.timezones.UTC.supported":
case "capabilities.attachments.supported":
case "capabilities.alarms.popup.supported": // CS cannot store X-props reliably
// (thus writing X-MOZ stamps etc is not possible).
// Popup alarms not available no matter what; wtf.
return false;
case "capabilities.alarms.actionValues":
return ["EMAIL"];
case "capabilities.alarms.maxCount":
return 1;
}
var value = this.__proto__.__proto__.getProperty.apply(this, arguments);
switch (aName) {
case "readOnly":
if (value === null) {
// tweak readOnly default to true for non-owned calendars,
// all secondary calendars to readOnly unless we're logged in
value = (this.m_session && this.session.isLoggedIn
? !this.isOwnedCalendar
: !this.isDefaultCalendar);
}
break;
case "calendar-main-in-composite":
if (value === null && !this.isDefaultCalendar) {
// tweak in-composite to false for secondary calendars:
value = false;
}
break;
}
return value;
},
setProperty: function calWcapCalendar_setProperty(aName, aValue) {
switch (aName) {
case "disabled":
if (this.isDefaultCalendar) {
// disabling/enabling the default calendar will enable/disable all calendars
// belonging to the same session:
for each (let calendar in this.session.getRegisteredCalendars()) {
if (!calendar.isDefaultCalendar) {
calendar.setProperty("disabled", aValue);
}
}
}
// fallthru intended
default:
this.__proto__.__proto__.setProperty.apply(this, arguments);
break;
}
},
notifyObservers: function calWcapCalendar_notifyObservers(func, args) {
if (g_bShutdown) {
return;
}
this.observers.notify(func, args);
},
// xxx todo: batch currently not used
startBatch: function calWcapCalendar_startBatch() {
this.notifyObservers("onStartBatch");
},
endBatch: function calWcapCalendar_endBatch() {
this.notifyObservers("onEndBatch");
},
get canRefresh() {
return true;
},
refresh: function calWcapCalendar_refresh() {
log("refresh.", this);
// invalidate cached results:
delete this.m_cachedResults;
// notify about refreshed calendar:
this.notifyObservers("onLoad", [this]);
},
issueNetworkRequest: function calWcapCalendar_issueNetworkRequest(
request, respFunc, dataConvFunc, wcapCommand, params, accessRights) {
var this_ = this;
// - bootstrap problem: no cal_props, no access check, no default calId
// - assure being logged in, thus the default cal_props are available
// - every subscribed calendar will come along with cal_props
return this.session.getSessionId(
request,
function getSessionId_resp(err, sessionId) {
try {
if (err) {
throw err;
}
this_.assureAccess(accessRights);
params += ("&calid=" + encodeURIComponent(this_.calId));
this_.session.issueNetworkRequest(request, respFunc, dataConvFunc, wcapCommand, params);
} catch (exc) {
request.execSubRespFunc(respFunc, exc);
}
});
},
// calIWcapCalendar:
m_session: null,
get session() {
if (!this.m_session) {
this.m_session = getWcapSessionFor(this);
}
return this.m_session;
},
m_calId: null,
get calId() {
return (this.m_calId || this.session.defaultCalId);
},
get ownerId() {
var ar = this.getCalendarProperties("X-NSCP-CALPROPS-PRIMARY-OWNER");
if (ar.length == 0) {
var calId = this.calId;
log("cannot determine primary owner of calendar " + calId, this);
// fallback to calId prefix:
var nColon = calId.indexOf(":");
if (nColon >= 0)
calId = calId.substring(0, nColon);
return calId;
}
return ar[0];
},
get description() {
var ar = this.getCalendarProperties("X-NSCP-CALPROPS-DESCRIPTION");
if (ar.length == 0) {
// fallback to display name:
return this.displayName;
}
return ar[0];
},
get displayName() {
var ar = this.getCalendarProperties("X-NSCP-CALPROPS-NAME");
if (ar.length == 0) {
// fallback to common name:
ar = this.getCalendarProperties("X-S1CS-CALPROPS-COMMON-NAME");
if (ar.length == 0) {
ar = [this.calId];
}
}
return ar[0];
},
get isOwnedCalendar() {
if (this.isDefaultCalendar) {
return true; // default calendar is owned
}
return (this.ownerId == this.session.userId);
},
get isDefaultCalendar() {
return !this.m_calId;
},
m_calProps: null,
getCalendarProperties: function calWcapCalendar_getCalendarProperties(propName, out_count) {
if (!this.m_calProps) {
log("soft error: no calprops available, most possibly not logged in.", this);
}
var ret = filterXmlNodes(propName, this.m_calProps);
if (out_count) {
out_count.value = ret.length;
}
return ret;
},
get defaultTimezone() {
var tzid = this.getCalendarProperties("X-NSCP-CALPROPS-TZID");
if (tzid.length > 0) { // first try server-configured tz:
return tzid[0];
} else {
logWarning("defaultTimezone: cannot get X-NSCP-CALPROPS-TZID!", this);
// try to use local one if supported:
let tzid = cal.getTimezoneService().defaultTimezone.tzid;
return (this.session.getTimezone(tzid) ? tzid : "UTC");
}
},
getAlignedTzid: function calWcapCalendar_getAlignedTzid(tz) {
var tzid = tz.tzid;
// check whether it is one cs supports:
if (tz.isFloating || !this.session.getTimezone(tzid)) {
log("not a supported timezone: " + tzid);
// bug 435436:
// xxx todo: we could further on search for a matching region,
// e.g. CET (in TZNAME), but for now stick to
// user's default if not supported directly
var ret = this.defaultTimezone;
// use calendar's default:
log(tzid + " not supported, falling back to default: " + ret, this);
return ret;
}
return tzid;
},
checkAccess: function calWcapCalendar_checkAccess(accessControlBits) {
// xxx todo: take real acl into account
// for now, optimistically assuming that everybody has full access, server will check:
var granted = calIWcapCalendar.AC_FULL;
if (this.getProperty("readOnly")) {
granted &= ~(calIWcapCalendar.AC_COMP_WRITE |
calIWcapCalendar.AC_PROP_WRITE);
}
// check whether every bit fits:
return ((accessControlBits & granted) == accessControlBits);
},
assureAccess: function calWcapCalendar_assureAccess(accessControlBits) {
if (!this.checkAccess(accessControlBits & (calIWcapCalendar.AC_COMP_WRITE |
calIWcapCalendar.AC_PROP_WRITE))) {
// throw different error code for read-only:
throw new Components.Exception(errorToString(calIErrors.CAL_IS_READONLY),
calIErrors.CAL_IS_READONLY);
}
if (!this.checkAccess(accessControlBits)) {
throw new Components.Exception(errorToString(calIWcapErrors.WCAP_ACCESS_DENIED_TO_CALENDAR),
calIWcapErrors.WCAP_ACCESS_DENIED_TO_CALENDAR);
// xxx todo: throwing different error here, no
// calIErrors.CAL_IS_READONLY anymore
}
},
defineAccessControl: function calWcapCalendar_defineAccessControl(userId, accessControlBits) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
resetAccessControl: function calWcapCalendar_resetAccessControl(userId) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
getAccessControlDefinitions: function calWcapCalendar_getAccessControlDefinitions(out_count, out_users,
out_accessControlBits) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}
};
|