mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
continuing cal provider fixes. not part of the build.
This commit is contained in:
parent
6cf034315c
commit
3ed5153e77
50
calendar/providers/Makefile.in
Normal file
50
calendar/providers/Makefile.in
Normal file
@ -0,0 +1,50 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Oracle Corporation code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Oracle Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Vladimir Vukicevic <vladimir.vukicevic@oracle.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
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = calprovs
|
||||
MODULE_NAME = calProviderModule
|
||||
|
||||
DIRS = memory storage
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -68,23 +68,14 @@ calMemoryCalendar.prototype = {
|
||||
// nsICalendar interface
|
||||
//
|
||||
|
||||
mBatchMode: false,
|
||||
// attribute boolean batchMode;
|
||||
get batchMode() { return this.mBatchMode; },
|
||||
set batchMode(aBatchMode) {
|
||||
this.mBatchMode = aBatchMode;
|
||||
},
|
||||
|
||||
// attribute nsIURI uri;
|
||||
get uri() { return false; },
|
||||
get uri() { return ""; },
|
||||
set uri(aURI) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
|
||||
// attribute boolean suppressAlarms;
|
||||
get suppressAlarms() { return false; },
|
||||
set suppressAlarms(aSuppressAlarms) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
|
||||
// XXX what happens when we add an observer that already exists with a different filter?
|
||||
// we can add them separately, but when we remove, we'll remove all instances
|
||||
// void addObserver( in calIObserver observer, in unsigned long aItemFilter );
|
||||
addObserver: function (aObserver, aItemFilter) {
|
||||
for (var i = 0; i < this.mObservers.length; i++) {
|
||||
@ -112,6 +103,7 @@ calMemoryCalendar.prototype = {
|
||||
addItem: function (aItem, aListener) {
|
||||
if (aItem.id == null) {
|
||||
// is this an error? Or should we generate an IID?
|
||||
aItem.id = "uuid:" + (new Date()).getTime();
|
||||
}
|
||||
if (this.mItems[aItem.id] != null) {
|
||||
// is this an error?
|
||||
@ -193,22 +185,35 @@ calMemoryCalendar.prototype = {
|
||||
|
||||
// void getItem( in string id, in calIOperationListener aListener );
|
||||
getItem: function (aId, aListener) {
|
||||
if (!aListener)
|
||||
return;
|
||||
|
||||
if (aId == null ||
|
||||
this.mItems[aId] == null)
|
||||
{
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (Components.results.NS_ERROR_FAILURE,
|
||||
aId,
|
||||
aListener.GET,
|
||||
"ID doesn't exist for getItem");
|
||||
aListener.onGetComplete(Components.results.NS_ERROR_FAILURE,
|
||||
null,
|
||||
"IID doesn't exist for getItem", 0, []);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (Components.results.NS_OK,
|
||||
aId,
|
||||
aListener.GET,
|
||||
this.mItems[aId]);
|
||||
var item = this.mItems[aId];
|
||||
var iid = null;
|
||||
|
||||
if (item.QueryInterface(Components.interfaces.calIEvent)) {
|
||||
iid = Components.interfaces.calIEvent;
|
||||
} else if (item.QueryInterface(Components.interfaces.calITodo)) {
|
||||
iid = Components.interfaces.calITodo;
|
||||
} else {
|
||||
aListener.onGetComplete(Components.results.NS_ERROR_FAILURE,
|
||||
null,
|
||||
"Can't deduce item type based on QI", 0, []);
|
||||
return;
|
||||
}
|
||||
|
||||
aListener.onGetComplete(Components.results.NS_OK,
|
||||
iid,
|
||||
null, 1, [item]);
|
||||
},
|
||||
|
||||
// void getItems( in nsIIDRef aItemType, in unsigned long aItemFilter,
|
||||
@ -260,10 +265,7 @@ calMemoryCalendar.prototype = {
|
||||
}
|
||||
|
||||
// determine whether any endpoint falls within the range
|
||||
if ((itemStartTime >= startTime && itemEndTime <= endTime) ||
|
||||
(itemStartTime <= startTime && itemEndTime > startTime) ||
|
||||
(itemStartTime <= endTime && itemEndTime >= endTime))
|
||||
{
|
||||
if (itemStartTime <= endTime && itemEndTime >= startTime) {
|
||||
itemsFound.push(item);
|
||||
}
|
||||
|
||||
@ -276,14 +278,10 @@ calMemoryCalendar.prototype = {
|
||||
aListener.onGetComplete (Components.results.NS_OK,
|
||||
aItemType,
|
||||
null,
|
||||
itemsFound.length,
|
||||
itemsFound);
|
||||
},
|
||||
|
||||
// void reportError( in unsigned long errorid, in AUTF8String aMessage );
|
||||
reportError: function (aErrorId, aMessage)
|
||||
{
|
||||
},
|
||||
|
||||
//
|
||||
// Helper functions
|
||||
//
|
||||
|
@ -86,7 +86,8 @@ const TODO_PERCENT_COMPLETE = TODO_COLUMN_COUNTER++;
|
||||
function newDateTime(aPRTime) {
|
||||
var t = Components.classes[kCalDateTimeContractID]
|
||||
.createInstance(kCalDateTimeIID);
|
||||
t.utcTime = aPRTime;
|
||||
t.isUtc = true;
|
||||
t.nativeTime = aPRTime;
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -137,14 +138,6 @@ calStorageCalendar.prototype = {
|
||||
// nsICalendar interface
|
||||
//
|
||||
|
||||
mBatchMode: false,
|
||||
// attribute boolean batchMode;
|
||||
get batchMode() { return this.mBatchMode; },
|
||||
set batchMode(aBatchMode) {
|
||||
this.mBatchMode = aBatchMode;
|
||||
|
||||
},
|
||||
|
||||
mURI: null,
|
||||
// attribute nsIURI uri;
|
||||
get uri() { return this.mURI; },
|
||||
@ -171,8 +164,6 @@ calStorageCalendar.prototype = {
|
||||
get suppressAlarms() { return false; },
|
||||
set suppressAlarms(aSuppressAlarms) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
|
||||
// XXX what happens when we add an observer that already exists with a different filter?
|
||||
// we can add them separately, but when we remove, we'll remove all instances
|
||||
// void addObserver( in calIObserver observer, in unsigned long aItemFilter );
|
||||
addObserver: function (aObserver, aItemFilter) {
|
||||
for (var i = 0; i < this.mObservers.length; i++) {
|
||||
@ -200,6 +191,7 @@ calStorageCalendar.prototype = {
|
||||
addItem: function (aItem, aListener) {
|
||||
if (aItem.id == null) {
|
||||
// is this an error? Or should we generate an IID?
|
||||
aItem.id = "uuid:" + (new Date()).getTime();
|
||||
}
|
||||
if (this.mItems[aItem.id] != null) {
|
||||
// is this an error?
|
||||
@ -282,7 +274,8 @@ calStorageCalendar.prototype = {
|
||||
}
|
||||
|
||||
// is this item an event?
|
||||
var event = aItem.QueryInterface(kCalEventIID);
|
||||
var item = getItemByHash (aId);
|
||||
var event = item.QueryInterface(kCalEventIID);
|
||||
if (event) {
|
||||
deleteEvent (aId);
|
||||
} else {
|
||||
@ -293,8 +286,8 @@ calStorageCalendar.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
// notify observers XXX
|
||||
//observeDeleteItem(deletedItem);
|
||||
// notify observers
|
||||
observeDeleteItem(item);
|
||||
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (Components.results.NS_OK,
|
||||
@ -309,18 +302,27 @@ calStorageCalendar.prototype = {
|
||||
if (!aListener)
|
||||
return;
|
||||
|
||||
// XXX what do we load from? this thing is horribly underspecified
|
||||
var item = getItemByHash (aId);
|
||||
if (item) {
|
||||
aListener.onOperationComplete (Components.results.NS_OK,
|
||||
aId,
|
||||
aListener.GET,
|
||||
item);
|
||||
var item_iid = null;
|
||||
if (item.QueryInterface (kCalEventIID)) {
|
||||
item_iid = kCalEventIID;
|
||||
} else if (item.QueryInterface (kCalTodoIID)) {
|
||||
item_iid = kCalTodoIID;
|
||||
} else {
|
||||
aListener.onGetComplete(Components.results.NS_ERROR_FAILURE,
|
||||
null,
|
||||
"Unknown IID type", 0, []);
|
||||
return;
|
||||
}
|
||||
|
||||
aListener.onGetComplete(Components.results.NS_OK,
|
||||
item_iid,
|
||||
null, 1, [item]);
|
||||
} else {
|
||||
aListener.onOperationComplete (Components.results.NS_ERROR_FAILURE,
|
||||
aId,
|
||||
aListener.GET,
|
||||
"ID not found");
|
||||
aListener.onGetComplete (Components.results.NS_ERROR_FAILURE,
|
||||
null,
|
||||
"ID not found", 0, []);
|
||||
}
|
||||
},
|
||||
|
||||
@ -362,14 +364,10 @@ calStorageCalendar.prototype = {
|
||||
aListener.onGetComplete (Components.results.NS_OK,
|
||||
aItemType,
|
||||
null,
|
||||
itemsFound.length,
|
||||
itemsFound);
|
||||
},
|
||||
|
||||
// void reportError( in unsigned long errorid, in AUTF8String aMessage );
|
||||
reportError: function (aErrorId, aMessage)
|
||||
{
|
||||
},
|
||||
|
||||
//
|
||||
// Helper functions
|
||||
//
|
||||
@ -445,9 +443,9 @@ calStorageCalendar.prototype = {
|
||||
|
||||
mSelectEventByHash = mDB.createStatement ("SELECT * FROM cal_events WHERE hashid = ? LIMIT 1");
|
||||
mSelectEventByOid = mDB.createStatement ("SELECT * FROM cal_events WHERE oid = ? LIMIT 1");
|
||||
// this needs to have the range bound like this: start, end, start, start, end, end
|
||||
mSelectEventsByRange = mDB.createStatement ("SELECT * FROM cal_events WHERE (time_start >= ? AND time_end <= ?) OR (time_start <= ? AND time_end > ?) OR (time_start <= ? AND time_end <= ?)");
|
||||
mSelectEventsByRangeAndLimit = mDB.createStatement ("SELECT * FROM cal_events WHERE (time_start >= ? AND time_end <= ?) OR (time_start <= ? AND time_end > ?) OR (time_start <= ? AND time_end <= ?) LIMIT ?");
|
||||
// this needs to have the range bound like this: start, end
|
||||
mSelectEventsByRange = mDB.createStatement ("SELECT * FROM cal_events WHERE (time_end >= ? AND time_start <= ?)");
|
||||
mSelectEventsByRangeAndLimit = mDB.createStatement ("SELECT * FROM cal_events WHERE (time_end >= ? AND time_start <= ?) LIMIT ?");
|
||||
mDeleteEventByHash = mDB.createStatement ("DELETE FROM cal_events WHERE hashid = ?");
|
||||
qs = "?"; for (var i = 1; i < EV_COLUMN_COUNTER; i++) qs += ",?";
|
||||
mInsertEvent = mDB.createStatement ("INSERT INTO cal_events VALUES (" + qs + ")");
|
||||
|
Loading…
Reference in New Issue
Block a user