Bug 340949: alarm off by default, registration cleanup
This commit is contained in:
Родитель
62995fd5a2
Коммит
ef5f439089
|
@ -47,7 +47,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
DIRS = public
|
||||
MODULE = wcap
|
||||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
EXTRA_SCRIPTS = \
|
||||
calWcapUtils.js \
|
||||
calWcapRequest.js \
|
||||
calWcapErrors.js \
|
||||
|
@ -55,6 +55,9 @@ EXTRA_PP_COMPONENTS = \
|
|||
calWcapCalendarItems.js \
|
||||
calWcapCalendar.js \
|
||||
calWcapCachedCalendar.js \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
calWcapCalendarModule.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -69,5 +72,16 @@ else # ifdef wcap_logging
|
|||
DEFINES += -DLOG_LEVEL=0
|
||||
endif # ifdef wcap_logging
|
||||
|
||||
# installing EXTRA_SCRIPTS into js/
|
||||
|
||||
# using NSINSTALL to make directory: no mtime to preserve:
|
||||
libs:: $(EXTRA_SCRIPTS)
|
||||
if test ! -d $(FINAL_TARGET)/js; then $(NSINSTALL) -D $(FINAL_TARGET)/js; fi
|
||||
$(INSTALL) $^ $(FINAL_TARGET)/js
|
||||
|
||||
# using SYSINSTALL (i.e. NSINSTALL in copy mode):
|
||||
install:: $(EXTRA_SCRIPTS)
|
||||
$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -363,6 +363,12 @@ calWcapCachedCalendar.prototype = {
|
|||
} );
|
||||
},
|
||||
|
||||
syncChangesTo:
|
||||
function( destCal, itemFilter, dtFrom, iListener )
|
||||
{
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getStampFile:
|
||||
function()
|
||||
{
|
||||
|
@ -443,7 +449,9 @@ calWcapCachedCalendar.prototype = {
|
|||
|
||||
// first sync in changes from remote, then get items from locally:
|
||||
remoteCal.syncChangesTo(
|
||||
localCal, dtFrom,
|
||||
localCal,
|
||||
Components.interfaces.calICalendar.ITEM_FILTER_ALL_ITEMS,
|
||||
dtFrom,
|
||||
{ // calIOperationListener:
|
||||
onOperationComplete:
|
||||
function( calendar, status, opType, id, detail )
|
||||
|
|
|
@ -56,6 +56,7 @@ function calWcapCalendar( calId, session ) {
|
|||
this.wrappedJSObject = this;
|
||||
this.m_calId = calId;
|
||||
this.m_session = session;
|
||||
this.m_bSuppressAlarms = SUPPRESS_ALARMS;
|
||||
}
|
||||
calWcapCalendar.prototype = {
|
||||
m_ifaces: [ Components.interfaces.calIWcapCalendar,
|
||||
|
|
|
@ -191,29 +191,33 @@ calWcapCalendar.prototype.getRecurrenceParams = function(
|
|||
}
|
||||
};
|
||||
|
||||
const XPROP_OP_ADD = 0;
|
||||
const XPROP_OP_REPLACE = 1;
|
||||
const XPROP_OP_DELETE = 2;
|
||||
// xxx todo:
|
||||
// currently unused, because of problems storing X- properties at recurring
|
||||
// events: X-NSCP-OPERATION-REPLACE, -DELETE do not work.
|
||||
|
||||
function makeXPropertyUrl( name, op, value )
|
||||
{
|
||||
var url = ("&" + name);
|
||||
switch (op) {
|
||||
case XPROP_OP_ADD:
|
||||
url += "=X-NSCP-ORIGINAL-OPERATION=X-NSCP-WCAP-PROPERTY-ADD";
|
||||
break;
|
||||
case XPROP_OP_REPLACE:
|
||||
url += "=X-NSCP-ORIGINAL-OPERATION=X-NSCP-WCAP-PROPERTY-REPLACE";
|
||||
break;
|
||||
case XPROP_OP_DELETE:
|
||||
url += "=X-NSCP-ORIGINAL-OPERATION=X-NSCP-WCAP-PROPERTY-DELETE";
|
||||
break;
|
||||
}
|
||||
url += "^";
|
||||
if (value)
|
||||
url += value;
|
||||
return url;
|
||||
}
|
||||
// const XPROP_OP_ADD = 0;
|
||||
// const XPROP_OP_REPLACE = 1;
|
||||
// const XPROP_OP_DELETE = 2;
|
||||
|
||||
// function makeXPropertyUrl( name, op, value )
|
||||
// {
|
||||
// var url = ("&" + name);
|
||||
// switch (op) {
|
||||
// case XPROP_OP_ADD:
|
||||
// url += "=X-NSCP-ORIGINAL-OPERATION=X-NSCP-WCAP-PROPERTY-ADD";
|
||||
// break;
|
||||
// case XPROP_OP_REPLACE:
|
||||
// url += "=X-NSCP-ORIGINAL-OPERATION=X-NSCP-WCAP-PROPERTY-REPLACE";
|
||||
// break;
|
||||
// case XPROP_OP_DELETE:
|
||||
// url += "=X-NSCP-ORIGINAL-OPERATION=X-NSCP-WCAP-PROPERTY-DELETE";
|
||||
// break;
|
||||
// }
|
||||
// url += "^";
|
||||
// if (value)
|
||||
// url += value;
|
||||
// return url;
|
||||
// }
|
||||
|
||||
calWcapCalendar.prototype.getStoreUrl = function( item, oldItem )
|
||||
{
|
||||
|
@ -1070,6 +1074,38 @@ calWcapCalendar.prototype.getItems_resp = function(
|
|||
}
|
||||
};
|
||||
|
||||
function getItemFilterUrlPortions( itemFilter )
|
||||
{
|
||||
var url = "";
|
||||
switch (itemFilter &
|
||||
Components.interfaces.calICalendar.ITEM_FILTER_TYPE_ALL) {
|
||||
case Components.interfaces.calICalendar.ITEM_FILTER_TYPE_TODO:
|
||||
url += "&component-type=todo"; break;
|
||||
case Components.interfaces.calICalendar.ITEM_FILTER_TYPE_EVENT:
|
||||
url += "&component-type=event"; break;
|
||||
}
|
||||
|
||||
const calIWcapCalendar = Components.interfaces.calIWcapCalendar;
|
||||
var compstate = "";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REPLY_DECLINED)
|
||||
compstate += ";REPLY-DECLINED";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REPLY_ACCEPTED)
|
||||
compstate += ";REPLY-ACCEPTED";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_COMPLETED)
|
||||
compstate += ";REQUEST-COMPLETED";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_NEEDS_ACTION)
|
||||
compstate += ";REQUEST-NEEDS-ACTION";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_NEEDSNOACTION)
|
||||
compstate += ";REQUEST-NEEDSNOACTION";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_PENDING)
|
||||
compstate += ";REQUEST-PENDING";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_WAITFORREPLY)
|
||||
compstate += ";REQUEST-WAITFORREPLY";
|
||||
if (compstate.length > 0)
|
||||
url += ("&compstate=" + compstate.substr(1));
|
||||
return url;
|
||||
}
|
||||
|
||||
calWcapCalendar.prototype.getItems = function(
|
||||
itemFilter, maxResult, rangeStart, rangeEnd, iListener )
|
||||
{
|
||||
|
@ -1094,32 +1130,8 @@ calWcapCalendar.prototype.getItems = function(
|
|||
"&fmt-out=text%2Fcalendar&calid=" +
|
||||
encodeURIComponent(this.calId));
|
||||
|
||||
switch (itemFilter &
|
||||
Components.interfaces.calICalendar.ITEM_FILTER_TYPE_ALL) {
|
||||
case Components.interfaces.calICalendar.ITEM_FILTER_TYPE_TODO:
|
||||
url += "&component-type=todo"; break;
|
||||
case Components.interfaces.calICalendar.ITEM_FILTER_TYPE_EVENT:
|
||||
url += "&component-type=event"; break;
|
||||
}
|
||||
|
||||
const calIWcapCalendar = Components.interfaces.calIWcapCalendar;
|
||||
var compstate = "";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REPLY_DECLINED)
|
||||
compstate += ";REPLY-DECLINED";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REPLY_ACCEPTED)
|
||||
compstate += ";REPLY-ACCEPTED";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_COMPLETED)
|
||||
compstate += ";REQUEST-COMPLETED";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_NEEDS_ACTION)
|
||||
compstate += ";REQUEST-NEEDS-ACTION";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_NEEDSNOACTION)
|
||||
compstate += ";REQUEST-NEEDSNOACTION";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_PENDING)
|
||||
compstate += ";REQUEST-PENDING";
|
||||
if (itemFilter & calIWcapCalendar.ITEM_FILTER_REQUEST_WAITFORREPLY)
|
||||
compstate += ";REQUEST-WAITFORREPLY";
|
||||
if (compstate.length > 0)
|
||||
url += ("&compstate=" + compstate.substr(1));
|
||||
// setting component-type, compstate filters:
|
||||
url += getItemFilterUrlPortions(itemFilter);
|
||||
|
||||
if (maxResult > 0)
|
||||
url += ("&maxResult=" + maxResult);
|
||||
|
@ -1188,6 +1200,7 @@ SyncState.prototype = {
|
|||
};
|
||||
|
||||
function FinishListener( opType, syncState ) {
|
||||
this.wrappedJSObject = this;
|
||||
this.m_opType = opType;
|
||||
this.m_syncState = syncState;
|
||||
}
|
||||
|
@ -1236,7 +1249,7 @@ calWcapCalendar.prototype.syncChangesTo_resp = function(
|
|||
};
|
||||
|
||||
calWcapCalendar.prototype.syncChangesTo = function(
|
||||
destCal, dtFrom, iListener )
|
||||
destCal, itemFilter, dtFrom, iListener )
|
||||
{
|
||||
// this.ensureOnline();
|
||||
if (dtFrom != null) {
|
||||
|
@ -1248,10 +1261,20 @@ calWcapCalendar.prototype.syncChangesTo = function(
|
|||
dtFrom = this.session.getServerTime(dtFrom);
|
||||
}
|
||||
var zdtFrom = getIcalUTC(dtFrom);
|
||||
this.log( "syncChangesTo(): dtFrom=" + zdtFrom );
|
||||
this.log( "syncChangesTo():\n\titemFilter=" + itemFilter +
|
||||
"\n\tdtFrom=" + zdtFrom );
|
||||
|
||||
var calObserver = null;
|
||||
try {
|
||||
calObserver = iListener.QueryInterface(
|
||||
Components.interfaces.calIObserver );
|
||||
}
|
||||
catch (exc) {
|
||||
}
|
||||
|
||||
try {
|
||||
// new stamp for this sync:
|
||||
var now = getTime();
|
||||
var now = getTime(); // xxx todo: not exact
|
||||
var this_ = this;
|
||||
const SYNC = Components.interfaces.calIWcapCalendar.SYNC;
|
||||
|
||||
|
@ -1294,23 +1317,29 @@ calWcapCalendar.prototype.syncChangesTo = function(
|
|||
url += ("&relativealarm=1&compressed=1&recurring=1" +
|
||||
"&fmt-out=text%2Fcalendar&calid=" +
|
||||
encodeURIComponent(this.calId));
|
||||
url += getItemFilterUrlPortions(itemFilter);
|
||||
this.session.issueAsyncRequest(
|
||||
url, stringToIcal,
|
||||
function( wcapResponse ) {
|
||||
this_.syncChangesTo_resp(
|
||||
wcapResponse, syncState, iListener,
|
||||
function( item ) {
|
||||
syncState.acquire();
|
||||
this_.log( "adding " + item.id );
|
||||
// xxx todo: verify whether exceptions have been
|
||||
// written
|
||||
destCal.addItem( item, addItemListener );
|
||||
this_.log( "new item: " + item.id );
|
||||
if (destCal) {
|
||||
syncState.acquire();
|
||||
// xxx todo: verify whether exceptions have been
|
||||
// written
|
||||
destCal.addItem( item, addItemListener );
|
||||
}
|
||||
if (calObserver)
|
||||
calObserver.onAddItem( item );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
var modifiedItems = [];
|
||||
this.log( "syncChangesTo(): getting last modifications." );
|
||||
|
||||
this.log( "syncChangesTo(): getting last modifications..." );
|
||||
var modifyItemListener = new FinishListener(
|
||||
Components.interfaces.calIOperationListener.MODIFY, syncState );
|
||||
var params = ("&relativealarm=1&compressed=1&recurring=1&calid=" +
|
||||
|
@ -1318,7 +1347,8 @@ calWcapCalendar.prototype.syncChangesTo = function(
|
|||
params += ("&fmt-out=text%2Fcalendar&dtstart=" + zdtFrom);
|
||||
syncState.acquire();
|
||||
this.session.issueAsyncRequest(
|
||||
this.session.getCommandUrl("fetchcomponents_by_lastmod")+params,
|
||||
this.session.getCommandUrl("fetchcomponents_by_lastmod") +
|
||||
params + getItemFilterUrlPortions(itemFilter),
|
||||
stringToIcal,
|
||||
function( wcapResponse ) {
|
||||
this_.syncChangesTo_resp(
|
||||
|
@ -1327,27 +1357,40 @@ calWcapCalendar.prototype.syncChangesTo = function(
|
|||
var dtCreated = item.getProperty("CREATED");
|
||||
var bAdd = (dtCreated == null ||
|
||||
dtCreated.compare(dtFrom) >= 0);
|
||||
syncState.acquire();
|
||||
modifiedItems.push( item.id );
|
||||
if (bAdd) {
|
||||
// xxx todo: verify whether exceptions
|
||||
// have been written
|
||||
this_.log( "adding " + item.id );
|
||||
destCal.addItem( item, addItemListener );
|
||||
this_.log( "new item: " + item.id );
|
||||
if (destCal) {
|
||||
syncState.acquire();
|
||||
destCal.addItem( item, addItemListener );
|
||||
}
|
||||
if (calObserver)
|
||||
calObserver.onAddItem( item );
|
||||
}
|
||||
else {
|
||||
this_.log( "modifying " + item.id );
|
||||
destCal.modifyItem( item, null,
|
||||
modifyItemListener );
|
||||
this_.log( "modified item: " + item.id );
|
||||
if (destCal) {
|
||||
syncState.acquire();
|
||||
destCal.modifyItem( item, null,
|
||||
modifyItemListener );
|
||||
}
|
||||
if (calObserver)
|
||||
calObserver.onModifyItem( item, null );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
this.log( "syncChangesTo(): getting deleted items." );
|
||||
|
||||
this.log( "syncChangesTo(): getting deleted items..." );
|
||||
var deleteItemListener = new FinishListener(
|
||||
Components.interfaces.calIOperationListener.DELETE, syncState );
|
||||
syncState.acquire();
|
||||
this.session.issueAsyncRequest(
|
||||
this.session.getCommandUrl("fetch_deletedcomponents") + params,
|
||||
this.session.getCommandUrl("fetch_deletedcomponents") + params +
|
||||
getItemFilterUrlPortions( itemFilter & // only component-type
|
||||
Components.interfaces.calICalendar
|
||||
.ITEM_FILTER_TYPE_ALL ),
|
||||
stringToIcal,
|
||||
function( wcapResponse ) {
|
||||
this_.syncChangesTo_resp(
|
||||
|
@ -1362,10 +1405,15 @@ calWcapCalendar.prototype.syncChangesTo = function(
|
|||
return;
|
||||
}
|
||||
}
|
||||
syncState.acquire();
|
||||
if (item.parentItem == item) {
|
||||
this_.log( "deleting " + item.id );
|
||||
destCal.deleteItem( item, deleteItemListener );
|
||||
this_.log( "deleted item: " + item.id );
|
||||
if (destCal) {
|
||||
syncState.acquire();
|
||||
destCal.deleteItem( item,
|
||||
deleteItemListener );
|
||||
}
|
||||
if (calObserver)
|
||||
calObserver.onDeleteItem( item );
|
||||
}
|
||||
else {
|
||||
// modify parent instead of
|
||||
|
@ -1373,9 +1421,14 @@ calWcapCalendar.prototype.syncChangesTo = function(
|
|||
var parent = item.parentItem.clone();
|
||||
parent.recurrenceInfo.removeOccurrenceAt(
|
||||
item.recurrenceId );
|
||||
this_.log( "modifying " + parent.id );
|
||||
destCal.modifyItem( parent, item,
|
||||
deleteItemListener );
|
||||
this_.log( "modified parent: " + parent.id );
|
||||
if (destCal) {
|
||||
syncState.acquire();
|
||||
destCal.modifyItem( parent, item,
|
||||
deleteItemListener );
|
||||
}
|
||||
if (calObserver)
|
||||
calObserver.onModifyItem( parent, item );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -37,6 +37,132 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//
|
||||
// init code for globals, prefs:
|
||||
//
|
||||
|
||||
// ctors:
|
||||
var CalEvent;
|
||||
var CalTodo;
|
||||
var CalDateTime;
|
||||
var XmlHttpRequest;
|
||||
|
||||
// some string resources:
|
||||
var g_privateItemTitle;
|
||||
var g_confidentialItemTitle;
|
||||
var g_busyItemTitle;
|
||||
var g_busyPhantomItemUuidPrefix;
|
||||
|
||||
// global preferences:
|
||||
// caching: off|memory|storage:
|
||||
var CACHE = "off";
|
||||
// denotes where to host local storage calendar(s)
|
||||
var CACHE_DIR = null;
|
||||
|
||||
// logging:
|
||||
#expand var LOG_LEVEL = __LOG_LEVEL__;
|
||||
var LOG_TIMEZONE = null;
|
||||
var LOG_FILE_STREAM = null;
|
||||
|
||||
// whether alarms are by default turned on/off:
|
||||
var SUPPRESS_ALARMS = true;
|
||||
|
||||
function initWcapProvider()
|
||||
{
|
||||
try {
|
||||
// ctors:
|
||||
CalEvent = new Components.Constructor(
|
||||
"@mozilla.org/calendar/event;1", "calIEvent" );
|
||||
CalTodo = new Components.Constructor(
|
||||
"@mozilla.org/calendar/todo;1", "calITodo" );
|
||||
CalDateTime = new Components.Constructor(
|
||||
"@mozilla.org/calendar/datetime;1", "calIDateTime" );
|
||||
XmlHttpRequest = new Components.Constructor(
|
||||
"@mozilla.org/xmlextras/xmlhttprequest;1", "nsIXMLHttpRequest" );
|
||||
|
||||
// some string resources:
|
||||
g_privateItemTitle = getWcapBundle().GetStringFromName(
|
||||
"privateItem.title.text");
|
||||
g_confidentialItemTitle = getWcapBundle().GetStringFromName(
|
||||
"confidentialItem.title.text");
|
||||
g_busyItemTitle = getWcapBundle().GetStringFromName(
|
||||
"busyItem.title.text");
|
||||
g_busyPhantomItemUuidPrefix = ("PHANTOM_uuid" + getTime().icalString);
|
||||
|
||||
LOG_TIMEZONE = getPref("calendar.timezone.local", null);
|
||||
|
||||
var logLevel = getPref("calendar.wcap.log_level", null);
|
||||
if (logLevel == null) { // log_level pref undefined:
|
||||
if (getPref("calendar.debug.log", false))
|
||||
logLevel = 1; // at least basic logging when calendar.debug.log
|
||||
}
|
||||
if (logLevel > LOG_LEVEL) {
|
||||
LOG_LEVEL = logLevel;
|
||||
}
|
||||
|
||||
if (LOG_LEVEL > 0) {
|
||||
var logFileName = getPref("calendar.wcap.log_file", null);
|
||||
if (logFileName != null) {
|
||||
// set up file:
|
||||
var logFile =
|
||||
Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
logFile.initWithPath( logFileName );
|
||||
// create output stream:
|
||||
var logFileStream = Components.classes[
|
||||
"@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
logFileStream.init(
|
||||
logFile,
|
||||
0x02 /* PR_WRONLY */ |
|
||||
0x08 /* PR_CREATE_FILE */ |
|
||||
0x10 /* PR_APPEND */,
|
||||
0700 /* read, write, execute/search by owner */,
|
||||
0 /* unused */ );
|
||||
LOG_FILE_STREAM = logFileStream;
|
||||
}
|
||||
logMessage( "init sequence",
|
||||
"################################# NEW LOG " +
|
||||
"#################################" );
|
||||
}
|
||||
|
||||
SUPPRESS_ALARMS = getPref("calendar.wcap.suppress_alarms", true);
|
||||
if (SUPPRESS_ALARMS)
|
||||
logMessage( "calendar.wcap.suppress_alarms", SUPPRESS_ALARMS );
|
||||
|
||||
// init cache dir directory:
|
||||
CACHE = getPref("calendar.wcap.cache", "off");
|
||||
logMessage( "calendar.wcap.cache", CACHE );
|
||||
if (CACHE == "storage") {
|
||||
var cacheDir = null;
|
||||
var sCacheDir = getPref("calendar.wcap.cache_dir", null);
|
||||
if (sCacheDir != null) {
|
||||
cacheDir = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
cacheDir.initWithPath( sCacheDir );
|
||||
}
|
||||
else { // not found: default to wcap/ directory in profile
|
||||
var dirService = Components.classes[
|
||||
"@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
cacheDir = dirService.get(
|
||||
"ProfD", Components.interfaces.nsILocalFile );
|
||||
cacheDir.append( "wcap" );
|
||||
}
|
||||
CACHE_DIR = cacheDir;
|
||||
logMessage( "calendar.wcap.cache_dir", CACHE_DIR.path );
|
||||
if (!CACHE_DIR.exists()) {
|
||||
CACHE_DIR.create(
|
||||
Components.interfaces.nsIFile.DIRECTORY_TYPE,
|
||||
0700 /* read, write, execute/search by owner */ );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (exc) {
|
||||
logMessage( "error in init sequence", exc );
|
||||
}
|
||||
}
|
||||
|
||||
var calWcapCalendarModule = {
|
||||
|
||||
WcapCalendarInfo: {
|
||||
|
@ -73,10 +199,8 @@ var calWcapCalendarModule = {
|
|||
function( compMgr, cid, iid )
|
||||
{
|
||||
if (!this.m_scriptsLoaded) {
|
||||
this.m_scriptsLoaded = true;
|
||||
// load scripts:
|
||||
const scripts = [ "calWcapUtils.js" /* has the main init code */,
|
||||
"calWcapErrors.js",
|
||||
// loading extra scripts from ../js:
|
||||
const scripts = [ "calWcapUtils.js", "calWcapErrors.js",
|
||||
"calWcapRequest.js", "calWcapSession.js",
|
||||
"calWcapCalendar.js", "calWcapCalendarItems.js",
|
||||
"calWcapCachedCalendar.js" ];
|
||||
|
@ -86,12 +210,16 @@ var calWcapCalendarModule = {
|
|||
var ioService =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var baseDir = __LOCATION__.parent.parent;
|
||||
baseDir.append("js");
|
||||
for each ( var script in scripts ) {
|
||||
var scriptFile = __LOCATION__.parent.clone();
|
||||
var scriptFile = baseDir.clone();
|
||||
scriptFile.append(script);
|
||||
scriptLoader.loadSubScript(
|
||||
ioService.newFileURI(scriptFile).spec, null );
|
||||
}
|
||||
initWcapProvider();
|
||||
this.m_scriptsLoaded = true;
|
||||
}
|
||||
|
||||
if (!cid.equals( calWcapCalendar.prototype.classID ))
|
||||
|
|
|
@ -337,105 +337,3 @@ function syncExec( func )
|
|||
// proxy.run();
|
||||
// }
|
||||
|
||||
|
||||
//
|
||||
// init code for globals, prefs:
|
||||
//
|
||||
|
||||
// ctors:
|
||||
var CalEvent = new Components.Constructor(
|
||||
"@mozilla.org/calendar/event;1", "calIEvent" );
|
||||
var CalTodo = new Components.Constructor(
|
||||
"@mozilla.org/calendar/todo;1", "calITodo" );
|
||||
var CalDateTime = new Components.Constructor(
|
||||
"@mozilla.org/calendar/datetime;1", "calIDateTime" );
|
||||
var XmlHttpRequest = new Components.Constructor(
|
||||
"@mozilla.org/xmlextras/xmlhttprequest;1", "nsIXMLHttpRequest" );
|
||||
|
||||
// global preferences:
|
||||
|
||||
// caching: off|memory|storage:
|
||||
var CACHE = "off";
|
||||
// denotes where to host local storage calendar(s)
|
||||
var CACHE_DIR = null;
|
||||
|
||||
// logging:
|
||||
#expand var LOG_LEVEL = __LOG_LEVEL__;
|
||||
var LOG_TIMEZONE = getPref("calendar.timezone.local", null);
|
||||
var LOG_FILE_STREAM = null;
|
||||
|
||||
try {
|
||||
var logLevel = getPref("calendar.wcap.log_level", null);
|
||||
if (logLevel == null) { // log_level pref undefined:
|
||||
if (getPref("calendar.debug.log", false))
|
||||
logLevel = 1; // at least basic logging when calendar.debug.log
|
||||
}
|
||||
if (logLevel > LOG_LEVEL) {
|
||||
LOG_LEVEL = logLevel;
|
||||
}
|
||||
|
||||
if (LOG_LEVEL > 0) {
|
||||
var logFileName = getPref("calendar.wcap.log_file", null);
|
||||
if (logFileName != null) {
|
||||
// set up file:
|
||||
var logFile = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
logFile.initWithPath( logFileName );
|
||||
// create output stream:
|
||||
var logFileStream = Components.classes[
|
||||
"@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
logFileStream.init(
|
||||
logFile,
|
||||
0x02 /* PR_WRONLY */ |
|
||||
0x08 /* PR_CREATE_FILE */ |
|
||||
0x10 /* PR_APPEND */,
|
||||
0700 /* read, write, execute/search by owner */,
|
||||
0 /* unused */ );
|
||||
LOG_FILE_STREAM = logFileStream;
|
||||
}
|
||||
logMessage( "init sequence",
|
||||
"################################# NEW LOG " +
|
||||
"#################################" );
|
||||
}
|
||||
|
||||
// init cache dir directory:
|
||||
CACHE = getPref("calendar.wcap.cache", "off" /* xxx todo */ );
|
||||
logMessage( "calendar.wcap.cache", CACHE );
|
||||
if (CACHE == "storage") {
|
||||
var cacheDir = null;
|
||||
var sCacheDir = getPref("calendar.wcap.cache_dir", null);
|
||||
if (sCacheDir != null) {
|
||||
cacheDir = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
cacheDir.initWithPath( sCacheDir );
|
||||
}
|
||||
else { // not found: default to wcap/ directory in profile
|
||||
var dirService = Components.classes[
|
||||
"@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
cacheDir = dirService.get(
|
||||
"ProfD", Components.interfaces.nsILocalFile );
|
||||
cacheDir.append( "wcap" );
|
||||
}
|
||||
CACHE_DIR = cacheDir;
|
||||
logMessage( "calendar.wcap.cache_dir", CACHE_DIR.path );
|
||||
if (!CACHE_DIR.exists()) {
|
||||
CACHE_DIR.create( Components.interfaces.nsIFile.DIRECTORY_TYPE,
|
||||
0700 /* read, write, execute/search by owner */ );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (exc) {
|
||||
logMessage( "error in init sequence", exc );
|
||||
}
|
||||
|
||||
// some string resources:
|
||||
var g_privateItemTitle = getWcapBundle().GetStringFromName(
|
||||
"privateItem.title.text");
|
||||
var g_confidentialItemTitle = getWcapBundle().GetStringFromName(
|
||||
"confidentialItem.title.text");
|
||||
var g_busyItemTitle = getWcapBundle().GetStringFromName(
|
||||
"busyItem.title.text");
|
||||
var g_busyPhantomItemUuidPrefix = ("PHANTOM_uuid" + getTime().icalString);
|
||||
|
||||
|
|
|
@ -95,6 +95,17 @@ interface calIWcapCalendar : calICalendar
|
|||
|
||||
/* xxx todo: additional filters sensible for calICalendar, too?
|
||||
claiming bits 24-30 for now.
|
||||
|
||||
Those bits are somehow handled special now:
|
||||
If at least one of the below is set, then
|
||||
that filter bit(s) are active.
|
||||
If none of the below is set, then those compstate
|
||||
filters are not taken into account at all.
|
||||
So there is no need to OR all of the below together
|
||||
(ITEM_FILTER_ALL_ITEMS does not cover these bits) if you
|
||||
don't care about the REQUEST/REPLY states.
|
||||
|
||||
xxx todo: ITEM_FILTER_CLASS_OCCURRENCES is not filter, rename?
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -158,13 +169,18 @@ interface calIWcapCalendar : calICalendar
|
|||
* The passed <code>iListener</code> receives a
|
||||
* <code>SYNC</code> with timestamp as detail.
|
||||
*
|
||||
* @param destCal destination calendar to write changes to
|
||||
* @param destCal destination calendar to write changes to (may be null)
|
||||
* @param itemFilter ITEM_FILTER flags OR-ed together,
|
||||
* ITEM_FILTER_CLASS_OCCURRENCES not allowed
|
||||
* @param dtFrom start time to sync changes from,
|
||||
* if null all items are synced in
|
||||
* @param iListener operation listener for SYNC operation
|
||||
* (may optionally implemented calIObserver to receive
|
||||
* onAddItem(), onModifyItem() or onDeleteItem() calls)
|
||||
*/
|
||||
void syncChangesTo(
|
||||
in calICalendar destCal,
|
||||
in unsigned long itemFilter,
|
||||
in calIDateTime dtFrom,
|
||||
in calIOperationListener iListener );
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче