first bits of new calendar interfaces

This commit is contained in:
vladimir%pobox.com 2004-10-26 21:27:59 +00:00
parent 842593b76f
commit 55000b6c93
5 changed files with 614 additions and 0 deletions

View File

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 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 ***** */
#include "calIItemBase.idl"
//
// calIEvent
//
// An interface for an event (analogous to a VEVENT)
//
[scriptable, uuid(5ab15c1c-e295-4d8e-a9a9-ba5bc848b59a)]
interface calIEvent : calIItemBase
{
const long CAL_EVENT_STATUS_TENTATIVE = 2;
const long CAL_EVENT_STATUS_CONFIRMED = 3;
// these attributes are marked readonly, as the calIDates are owned
// by the event; however, the actual caIDate objects are not read
// only and are intended to be manipulated to adjust dates.
readonly attribute calIDateTime startDate;
readonly attribute calIDateTime endDate;
readonly attribute calIDateTime stampDate; // ??
// all day event?
attribute boolean isAllDay;
};

View File

@ -0,0 +1,185 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 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 ***** */
interface nsIWriteablePropertyBag;
interface calICalendar;
interface calIDisplayItem;
//
// calIItemBase
//
// Base for Events, Todos, Journals, etc.
//
[scriptable, uuid(096b8cc5-113c-40fb-bc52-d64e3992980c)]
interface calIItemBase
{
// clone interface; returns this item, but with
// NULL id
// XXX nsICloneable?
calIItemBase clone();
// methods
const long CAL_METHOD_NONE = 0;
const long CAL_METHOD_PUBLISH = 1;
const long CAL_METHOD_REQUEST = 2;
// statuses, extended by each event/todo/journal subclass
const long CAL_ITEM_STATUS_NONE = 0;
const long CAL_ITEM_STATUS_CANCELLED = 1;
// the time when this item was created
attribute calIDateTime creationDate;
// last time any attribute was modified on this item, in UTC
readonly attribute PRTime lastModifiedTime;
// the calICalendar to which this event belongs
attribute calICalendar parent;
// the ID of this event
attribute AUTF8String id;
// event title
attribute AUTF8String title;
// event priority
attribute short priority;
attribute boolean isPrivate;
// event/status of the event (see consts above)
attribute long method;
attribute long status;
// ical interop; writing this means parsing
// the ical string into this event
attribute AUTF8String icalString;
//
// alarms
//
attribute boolean hasAlarm;
attribute calIDateTime alarmTime;
// rest of alarm properties (?)
void snoozeAlarm (in calIDateTime aSnoozeFor);
//
// recurrence
//
const long CAL_ITEM_RECUR_TYPE_NONE = 0;
const long CAL_ITEM_RECUR_TYPE_MINUTELY = 1;
const long CAL_ITEM_RECUR_TYPE_HOURLY = 2;
const long CAL_ITEM_RECUR_TYPE_DAILY = 3;
const long CAL_ITEM_RECUR_TYPE_MONTHLY = 4;
const long CAL_ITEM_RECUR_TYPE_YEARLY = 5;
attribute long recurType;
attribute calIDateTime recurEnd; // if null, then forever
// array of calIDateTime
readonly attribute nsISupportsArray recurrenceExceptions;
// rest of recurrence in properties (?)
// return the next display item for this event,
// where the start time is >= aStartTime
calIDisplayItem getNextOccurrence (in calIDateTime aStartTime);
// return the previous display item for this event,
// where the start time is < aStartTime
calIDisplayItem getPreviousOccurrence (in calIDateTime aStartTime);
// return array of calIDisplayItems, representing all
// occurances of this event between start and end.
nsISupportsArray getAllOccurrences (in calIDateTime aStartTime,
in calIDateTime aEndTime);
// attachments
// array of nsIMsgAttachment
readonly attribute nsISupportsArray attachments;
// contacts
// array of nsIAbCard
readonly attribute nsISupportsArray contacts;
//
// other properties come in through a property bag
//
// 'description' - description (string)
// 'location' - location (string)
// 'categories' - categories (string)
// 'syncId' - sync id (string)
// 'inviteEmailAddress' - string
// alarmLength/alarmUnits/alarmEmailAddress/lastAlarmAck
// recurInterval/recurCount/recurWeekdays/recurWeeknumber
// Ideally, /all/ of the properties on the event should
// be available via the property bag. (And maybe the
// nsIItemBase impl should be QI'able to
// nsIWritablePropertyBag also)
readonly attribute nsIWritablePropertyBag properties;
};
//
// calIItemOccurrence
//
// An item representing a specific instance of a possibly recurring item.
// XXX unclear how recurrence (& this) works for todo events with due dates.
//
[scriptable, uuid(b19f3d7e-e848-4139-af3e-505a8023568d)]
interface calIItemOccurrence
{
//
// The parent item for which this is the occurrence item for
//
readonly attribute calIItemBase item;
//
// The start and end times to display for this event instance
//
readonly attribute calIDateTime occurrenceStartDate;
readonly attribute calIDateTime occurrenceEndDate;
// same as item.getNextOccurrence(occurrenceEndDate)
readonly attribute calIItemOccurence next;
// same as item.getPreviousOccurence(occurrenceStartDate)
readonly attribute calIItemOccurence previous;
};

View File

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 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 ***** */
#include "calIItemBase.idl"
//
// calITodo
//
// An interface for a todo item (analogous to a VTODO)
//
[scriptable, uuid(522991f2-4928-4cd2-9a02-e3071c58cf1c)]
interface calITodo : calIItemBase
{
const long CAL_TODO_STATUS_NEEDSACTION = 4;
const long CAL_TODO_STATUS_COMPLETED = 5;
const long CAL_TODO_STATUS_INPROCESS = 6;
readonly attribute calIDateTime dueDate;
readonly attribute calIDateTime completedDate;
attribute short percentComplete;
};

View File

@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 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 ***** */
#include "nsHashPropertyBag.h"
#include "calItemBase.h"
NS_IMPL_ISUPPORTS1(calItemBase, calIItemBase);
/***
*** calItemBase impl
***/
calItemBase::calItemBase()
{
// do we need a ::Init method?
NS_NewHashPropertyBag(getter_AddRefs(mProperties));
}
/**
** calIItemBase interface
**/
// helpers for value types
#define VALUETYPE_ATTR_GETTER(mtype,name) \
NS_IMETHODIMP \
calItemBase::Get##name (mtype *_retval) { \
*_retval = m##name; \
return NS_OK; \
}
#define VALUETYPE_ATTR_SETTER(mtype,name) \
NS_IMETHODIMP \
calItemBase::Set##name (mtype aValue) { \
if (m##name != aValue) { \
m##name = aValue; \
mLastModified = PR_Now(); \
} \
return NS_OK;
}
#define VALUETYPE_ATTR(mtype,name) \
VALUETYPE_ATTR_GETTER(mtype,name) \
VALUETYPE_ATTR_SETTER(mtype,name)
// helpers for interface types
#define ISUPPORTS_ATTR_GETTER(mtype,name)
NS_IMETHODIMP
calItemBase::Get##name (mtype **_retval) { \
NS_IF_ADDREF (*_retval = m##name); \
return NS_OK; \
}
#define ISUPPORTS_ATTR_SETTER(mtype,name) \
NS_IMETHODIMP \
calItemBase::Set##name (mtype *aValue) { \
if (m##name != aValue) { \
m##name = aValue; \
mLastModified = PR_Now(); \
} \
return NS_OK;
}
#define ISUPPORTS_ATTR(mtype,name) \
ISUPPORTS_ATTR_GETTER(mtype,name) \
ISUPPORTS_ATTR_SETTER(mtype,name)
/*
* calIItemBase attributes
*/
// General attrs
ISUPPORTS_ATTR(calIDateTime, CreationDate);
VALUETYPE_ATTR_GETTER(PRTime, LastModifiedTime);
ISUPPORTS_ATTR(calICalendar, Parent);
VALUETYPE_ATTR(nsACString&, Id);
VALUETYPE_ATTR(nsACString&, Title);
VALUETYPE_ATTR(PRInt16, Priority);
VALUETYPE_ATTR(PRBool, IsPrivate);
VALUETYPE_ATTR(PRInt32, Method);
VALUETYPE_ATTR(PRInt32, Status);
// Alarm attrs
VALUETYPE_ATTR(PRBool, HasAlarm);
ISUPPORTS_ATTR(calIDateTime, AlarmTime);
// Recurrence attrs
VALUETYPE_ATTR(PRInt32, RecurType);
ISUPPORTS_ATTR(calIDateTime, RecurEnd);
ISUPPORTS_ATTR_GETTER(nsISupportsArray, RecurrenceExceptions);
// Attachments
ISUPPORTS_ATTR_GETTER(nsISupportsArray, Attachments);
// Contacts
ISUPPORTS_ATTR_GETTER(nsISupportsArray, Contacts);
// Properties
ISUPPORTS_ATTR_GETTER(nsIWritablePropertyBag, Properties);
/*
* calIItemBase methods
*/
NS_IMETHODIMP
calItemBase::Clone (calIItemBase **_retval)
{
}
NS_IMETHODIMP
calItemBase::SnoozeAlarm (calIDateTime *aSnoozeFor)
{
}
NS_IMETHODIMP
calItemBase::GetNextOccurrence (calIDateTime *aStartTime)
{
}
NS_IMETHODIMP
calItemBase::GetPreviousOccurrence (calIDateTime *aStartTime)
{
}
NS_IMETHODIMP
calItemBase::GetAllOccurrences (calIDateTime *aStartTime)
{
}
/***
*** calItemOccurrence impl
***/
NS_IMPL_ISUPPORTS1(calItemOccurrence, calIItemOccurrence);
calItemOccurrence::calItemOccurrence()
{
}
calItemOccurrence::calItemOccurrence(calIItemBase *aBaseItem,
calIDateTime *aStart,
calIDateTime *aEnd)
: mItem(aBaseItem), mOccurrenceStartDate(aStart), mOccurrenceEndDate(aEnd)
{
}
ISUPPORTS_ATTR_GETTER(calIItemBase, Item);
ISUPPORTS_ATTR_GETTER(calIDateTime, OccurrenceStartDate);
ISUPPORTS_ATTR_GETTER(calIDateTime, OccurrenceEndDate);

View File

@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 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 ***** */
#ifndef CALITEMBASE_H_
#define CALITEMBASE_H_
#include "nsCOMPtr.h"
#include "nsIPropertyBag.h"
#include "calIDateTime.h"
#include "calICalendar.h"
#include "calIItemBase.h"
class calItemBase : public calIItemBase, public nsIWritablePropertyBag
{
public:
calItemBase();
// nsISupports
NS_DECL_ISUPPORTS
// calIItemBase
NS_DECL_CALIITEMBASE
// nsIWritablePropertyBag interface
NS_DECL_NSIPROPERTYBAG
NS_DECL_NSIWRITABLEPROPERTYBAG
protected:
nsCOMPtr<calICalendar> mParent;
nsCOMPtr<calIDateTime> mCreationDate;
PRTime mLastModifiedTime;
nsCString mID;
nsCString mTitle;
PRInt16 mPriority;
PRBool mIsPrivate;
PRInt32 mMethod;
PRInt32 mStatus;
// alarm
PRBool mHasAlarm;
nsCOMPtr<calIDateTime> mAlarmTime;
// recurrence
PRInt32 mRecurType;
nsCOMPtr<calIDateTime> mRecurEnd;
nsCOMArray<calIDateTime> mRecurrenceExceptions;
// attachments
nsCOMArray<nsIMsgAttachment> mAttachments;
// contacts
nsCOMArray<nsIAbCard> mContacts;
// properties
nsCOMPtr<nsWritablePropertyBag> mProperties;
};
class calItemOccurrence : public class calIItemOccurrence
{
public:
calItemOccurrence();
calItemOccurrence(calIItemBase *aBaseItem,
calIDateTime *aStart,
calIDateTime *aEnd);
protected:
nsCOMPtr<calIItemBase> mItem;
nsCOMPtr<calIDateTime> mOccurrenceStartDate;
nsCOMPtr<calIDateTime> mOccurrenceEndDate;
};
#endif /* CALITEMBASE_H_ */