continuing calItemBase/calEvent fixes. not part of the build.

This commit is contained in:
vladimir%pobox.com 2004-11-19 00:59:49 +00:00
Родитель 7c98ff6077
Коммит 6cf034315c
4 изменённых файлов: 62 добавлений и 2 удалений

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

@ -1,5 +1,7 @@
function calEvent() {
this.wrappedJSObject = this;
this.initItemBase();
this.initEvent();
}
calEvent.prototype = {
@ -10,13 +12,18 @@ calEvent.prototype = {
!aIID.equals(Components.interfaces.calIItemBase) &&
!aIID.equals(Components.interfaces.calIEvent))
{
dump ("calEvent QI failed to " + aIID + "\n");
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
initEvent: function () {
this.mStartDate = createCalDateTime();
this.mEndDate = createCalDateTime();
this.mStampDate = createCalDateTime();
},
clone: function () {
var m = new calEvent();
this.cloneItemBaseInto(m);

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

@ -45,6 +45,8 @@
//
function calEvent() {
this.wrappedJSObject = this;
this.initItemBase();
this.initEvent();
}
calEvent.prototype = {
@ -55,13 +57,18 @@ calEvent.prototype = {
!aIID.equals(Components.interfaces.calIItemBase) &&
!aIID.equals(Components.interfaces.calIEvent))
{
dump ("calEvent QI failed to " + aIID + "\n");
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
initEvent: function () {
this.mStartDate = createCalDateTime();
this.mEndDate = createCalDateTime();
this.mStampDate = createCalDateTime();
},
clone: function () {
var m = new calEvent();
this.cloneItemBaseInto(m);

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

@ -30,6 +30,18 @@ calItemBase.prototype = {
},
initItemBase: function () {
this.mCreationDate = createCalDateTime();
this.mAlarmTime = createCalDateTime();
this.mRecurrenceInfo = null;
this.mAttachments = null;
this.mContacts = null;
this.mProperties = null;
},
cloneItemBaseInto: function (m) {
m.mImmutable = false;
@ -107,3 +119,14 @@ calItemOccurrence.prototype = {
next: null,
previous: null
};
function createCalDateTime() {
const kCdtClass = Components.classes["@mozilla.org/calendar/datetime;1"];
const kCdtInterface = Components.interfaces.calIDateTime;
return kCdtClass.createInstance(kCdtInterface);
}

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

@ -71,6 +71,18 @@ calItemBase.prototype = {
this.mImmutable = true;
},
// initialize this class's members
initItemBase: function () {
this.mCreationDate = createCalDateTime();
this.mAlarmTime = createCalDateTime();
// fix me
this.mRecurrenceInfo = null;
this.mAttachments = null;
this.mContacts = null;
this.mProperties = null;
},
// for subclasses to use; copies the ItemBase's values
// into m
cloneItemBaseInto: function (m) {
@ -149,3 +161,14 @@ calItemOccurrence.prototype = {
next: null,
previous: null
};
//
// helper functions
//
function createCalDateTime() {
const kCdtClass = Components.classes["@mozilla.org/calendar/datetime;1"];
const kCdtInterface = Components.interfaces.calIDateTime;
return kCdtClass.createInstance(kCdtInterface);
}