This commit is contained in:
mikep%oeone.com 2001-12-20 22:16:08 +00:00
Родитель 30dfb0a96f
Коммит 04c3315aa3
9 изменённых файлов: 2232 добавлений и 1251 удалений

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

@ -37,10 +37,7 @@
#include <unistd.h>
#include <oeIICal.h>
#include <oeICalImpl.h>
#include <oeICalEventImpl.h>
#include <nsIServiceManager.h>
//#include <nsXPIDLString.h>
main()
{
@ -82,7 +79,7 @@ main()
return -2;
}
mysample->SetServer( "/home/mostafah/calendar" );
mysample->SetServer( "/tmp/.oecalendar" );
rv = mysample->Test();
if ( rv != NS_OK )

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

@ -0,0 +1,172 @@
/*
* 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 OEone Corporation.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by OEone Corporation are Copyright (C) 2001
* OEone Corporation. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini (mostafah@oeone.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.
*
*
*/
#include <unistd.h>
#include "oeDateTimeImpl.h"
#include "nsMemory.h"
#include "stdlib.h"
icaltimetype ConvertFromPrtime( PRTime indate );
/* Implementation file */
NS_IMPL_ISUPPORTS1(oeDateTimeImpl, oeIDateTime)
nsresult
NS_NewDateTime( oeIDateTime** inst )
{
NS_PRECONDITION(inst != nsnull, "null ptr");
if (! inst)
return NS_ERROR_NULL_POINTER;
*inst = new oeDateTimeImpl();
if (! *inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*inst);
return NS_OK;
}
oeDateTimeImpl::oeDateTimeImpl()
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
m_datetime = icaltime_null_time();
}
oeDateTimeImpl::~oeDateTimeImpl()
{
/* destructor code */
}
/* attribute short year; */
NS_IMETHODIMP oeDateTimeImpl::GetYear(PRInt16 *retval)
{
*retval = m_datetime.year;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetYear(PRInt16 newval)
{
m_datetime.year = newval;
return NS_OK;
}
/* attribute short month; */
NS_IMETHODIMP oeDateTimeImpl::GetMonth(PRInt16 *retval)
{
*retval = m_datetime.month - 1;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetMonth(PRInt16 newval)
{
m_datetime.month = newval + 1;
if( m_datetime.month < 1 || m_datetime.month > 12 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
/* attribute short day; */
NS_IMETHODIMP oeDateTimeImpl::GetDay(PRInt16 *retval)
{
*retval = m_datetime.day;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetDay(PRInt16 newval)
{
m_datetime.day = newval;
if( newval < 1 || newval > 31 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
/* attribute short hour; */
NS_IMETHODIMP oeDateTimeImpl::GetHour(PRInt16 *retval)
{
*retval = m_datetime.hour;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetHour(PRInt16 newval)
{
m_datetime.hour = newval;
if( newval < 0 || newval > 23 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
/* attribute short minute; */
NS_IMETHODIMP oeDateTimeImpl::GetMinute(PRInt16 *retval)
{
*retval = m_datetime.minute;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetMinute(PRInt16 newval)
{
m_datetime.minute = newval;
if( newval < 0 || newval > 59 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::GetTime(PRTime *retval)
{
unsigned long long result = icaltime_as_timet( m_datetime );
*retval = result*1000;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::ToString(char **retval)
{
char tmp[20];
sprintf( tmp, "%04d/%02d/%02d %02d:%02d:%02d" , m_datetime.year, m_datetime.month, m_datetime.day, m_datetime.hour, m_datetime.minute, 0 );
*retval= (char*) nsMemory::Clone( tmp, strlen(tmp)+1);
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetTime( PRUint64 ms )
{
m_datetime = ConvertFromPrtime( ms );
return NS_OK;
}
void oeDateTimeImpl::AdjustToWeekday( short weekday ) {
short currentday = icaltime_day_of_week( m_datetime );
while( currentday != weekday ) {
m_datetime.day++;
m_datetime = icaltime_normalize( m_datetime );
currentday = icaltime_day_of_week( m_datetime );
}
}

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

@ -0,0 +1,63 @@
/*
* 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 OEone Corporation.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by OEone Corporation are Copyright (C) 2001
* OEone Corporation. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini (mostafah@oeone.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.
*
*
*/
#ifndef __OE_DATETIMEIMPL_H__
#define __OE_DATETIMEIMPL_H__
#include "oeIICal.h"
extern "C" {
#include "ical.h"
}
#define OE_DATETIME_CID \
{ 0x78b5b255, 0x7450, 0x47c0, { 0xba, 0x16, 0x0a, 0x6e, 0x7e, 0x80, 0x6e, 0x5d } }
#define OE_DATETIME_CONTRACTID "@mozilla.org/oedatetime;1"
class oeDateTimeImpl : public oeIDateTime
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIDATETIME
oeDateTimeImpl();
virtual ~oeDateTimeImpl();
void AdjustToWeekday( short weekday );
/* additional members */
struct icaltimetype m_datetime;
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -35,6 +35,12 @@
* ***** END LICENSE BLOCK ***** */
#include "oeIICal.h"
#include "oeDateTimeImpl.h"
#include "nsISimpleEnumerator.h"
#include "nsISupportsPrimitives.h"
#include "nsSupportsPrimitives.h"
#include <vector>
extern "C" {
#include "ical.h"
}
@ -44,6 +50,25 @@ extern "C" {
#define OE_ICALEVENT_CONTRACTID "@mozilla.org/icalevent;1"
class NS_COM
oeDateEnumerator : public nsISimpleEnumerator
{
public:
oeDateEnumerator();
virtual ~oeDateEnumerator();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
NS_IMETHOD AddDate( PRTime date );
private:
PRUint32 mCurrentIndex;
vector<PRTime> mIdVector;
};
/* oeIcalEvent Header file */
class oeICalEventImpl : public oeIICalEvent
@ -51,10 +76,41 @@ class oeICalEventImpl : public oeIICalEvent
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
icalcomponent *vcalendar;
oeICalEventImpl();
virtual ~oeICalEventImpl();
/* additional members */
void oeICalEventImpl::ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
NS_IMETHODIMP SetId( PRUint32 newid );
icaltimetype GetNextAlarmTime( icaltimetype begin );
private:
unsigned long m_id;
unsigned long m_syncid;
char *m_title;
char *m_description;
char *m_location;
char *m_category;
bool m_isprivate;
bool m_allday;
bool m_hasalarm;
unsigned long m_alarmlength;
char *m_alarmunits;
char *m_alarmemail;
char *m_inviteemail;
short m_recurtype;
unsigned long m_recurinterval;
bool m_recur;
bool m_recurforever;
char *m_recurunits;
short m_recurweekdays;
short m_recurweeknumber;
oeDateTimeImpl *m_start;
oeDateTimeImpl *m_end;
oeDateTimeImpl *m_recurend;
icaltimetype m_lastalarmack;
vector<PRTime> m_exceptiondates;
icaltimetype GetNextRecurrence( icaltimetype begin );
icaltimetype oeICalEventImpl::CalculateAlarmTime( icaltimetype date );
bool IsExcepted( PRTime date );
};

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

@ -36,6 +36,7 @@
#include "oeICalImpl.h"
#include "oeICalEventImpl.h"
#include "oeDateTimeImpl.h"
#include "oeICalStartupHandler.h"
#include "nsIGenericFactory.h"
@ -44,6 +45,7 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalImpl);
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalEventImpl);
NS_GENERIC_FACTORY_CONSTRUCTOR(oeDateTimeImpl);
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalStartupHandler);
static nsModuleComponentInfo pModuleInfo[] =
@ -58,6 +60,11 @@ static nsModuleComponentInfo pModuleInfo[] =
OE_ICALEVENT_CONTRACTID,
oeICalEventImplConstructor,
},
{ "ICal DateTime",
OE_DATETIME_CID,
OE_DATETIME_CONTRACTID,
oeDateTimeImplConstructor,
},
{
"Calendar Startup Handler",
OE_ICALSTARTUPHANDLER_CID,
@ -68,5 +75,5 @@ static nsModuleComponentInfo pModuleInfo[] =
}
};
NS_IMPL_NSGETMODULE(oeICalModule, pModuleInfo)
NS_IMPL_NSGETMODULE("ICal Component", pModuleInfo)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -35,12 +35,82 @@
* ***** END LICENSE BLOCK ***** */
#include "oeIICal.h"
#include <vector>
#include "nsITimer.h"
#define OE_ICAL_CID \
{ 0x0a8c5de7, 0x0d19, 0x4b95, { 0x82, 0xf4, 0xe0, 0xaf, 0x92, 0x45, 0x32, 0x27 } }
#define OE_ICAL_CONTRACTID "@mozilla.org/ical;1"
class EventList {
public:
oeIICalEvent* event;
EventList* next;
EventList() {
event = NULL;
next = NULL;
}
~EventList() {
if( event )
event->Release();
if( next )
delete next;
}
void Add( oeIICalEvent* e) {
if( !event ) {
event = e;
} else {
if( !next ) {
next = new EventList();
}
next->Add( e );
}
}
oeIICalEvent* GetEventById( PRUint32 id ) {
if( !event )
return NULL;
PRUint32 eid=0;
event->GetId( &eid );
if( eid == id )
return event;
if( next )
return next->GetEventById( id );
return NULL;
}
void Remove( PRUint32 id ) {
if( !event )
return;
PRUint32 eid=0;
event->GetId( &eid );
if( eid == id ) {
event->Release();
if( next ) {
event = next->event;
EventList *tmp = next;
next = next->next;
tmp->next = NULL;
tmp->event = NULL;
delete tmp;
} else {
event = NULL;
}
} else {
if( next )
next->Remove( id );
}
}
/* int Count() {
int result=0;
if( !event )
return 0;
result++;
if( next )
result += next->Count();
return result;
}*/
};
class oeICalImpl : public oeIICal
{
public:
@ -68,4 +138,11 @@ class oeICalImpl : public oeIICal
* commented out (because this macro already defines them.)
*/
NS_DECL_OEIICAL
void SetupAlarmManager();
private:
vector<oeIICalObserver*> m_observerlist;
bool m_batchMode;
EventList m_eventlist;
nsITimer *m_alarmtimer;
char serveraddr[200];
};

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

@ -35,6 +35,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsISimpleEnumerator;
/**
* The uuid is a unique number identifying the interface normally
@ -49,58 +50,97 @@
*
*/
[scriptable, uuid(db180127-cc56-40c6-a8ef-7e329e1c4142)]
interface oeIDateTime : nsISupports
{
attribute short year;
attribute short month;
attribute short day;
attribute short hour;
attribute short minute;
PRTime getTime();
void setTime( in unsigned long long ms );
string toString();
};
[scriptable, uuid(89c5cd5a-af2d-45e6-83c7-2f2420a13626)]
interface oeIICalEvent : nsISupports
{
attribute unsigned long Id;
attribute string Title;
attribute string Description;
attribute string Location;
attribute string Category;
attribute boolean PrivateEvent;
attribute boolean AllDay;
attribute boolean Alarm;
// attribute boolean AlarmWentOff;
attribute unsigned long AlarmLength;
attribute string AlarmEmailAddress;
attribute string InviteEmailAddress;
attribute string SnoozeTime;
attribute short RecurType;
attribute unsigned long RecurInterval;
attribute string RepeatUnits;
attribute boolean RepeatForever;
void SetStartDate( in short year, in short month, in short day, in short hour, in short min);
void SetEndDate( in short year, in short month, in short day, in short hour, in short min);
void SetRecurInfo( in short type, in unsigned long interval, in short endyear, in short endmonth, in short endday);
string GetNextRecurrence( in short year, in short month, in short day );
string GetRecurEndDate();
string GetStartDate();
string GetEndDate();
// void SetAlarm(in short year, in short month, in short day, in short hour, in short min);
readonly attribute oeIDateTime start;
readonly attribute oeIDateTime end;
readonly attribute unsigned long id;
attribute string title;
attribute string description;
attribute string location;
attribute string category;
attribute boolean privateEvent;
attribute unsigned long syncId;
attribute boolean allDay;
attribute boolean alarm;
attribute string alarmUnits;
attribute unsigned long alarmLength;
attribute string alarmEmailAddress;
attribute string inviteEmailAddress;
attribute unsigned long recurInterval;
readonly attribute oeIDateTime recurEnd;
attribute boolean recur;
attribute string recurUnits;
attribute boolean recurForever;
attribute short recurWeekdays;
attribute short recurWeekNumber;
attribute PRTime lastAlarmAck;
boolean getNextRecurrence( in PRTime begin, out PRTime result);
string getIcalString();
void parseIcalString(in string icalstr);
void addException( in PRTime exdate );
nsISimpleEnumerator getExceptions();
// PRTime calculateAlarmTime();
};
[scriptable, uuid(b8584baa-1507-40d4-b542-5a2758e1c86d)]
interface oeIICalObserver : nsISupports
{
void onStartBatch();
void onEndBatch();
void onLoad();
void onAddItem( in oeIICalEvent e);
void onModifyItem( in oeIICalEvent e, in oeIICalEvent olde );
void onDeleteItem( in oeIICalEvent e);
void onAlarm( in oeIICalEvent e);
};
[scriptable, uuid(981ab93d-ad51-45bb-a4a2-e158c2cfdeb4)]
interface oeIICal : nsISupports
{
void Test();
long AddEvent( in oeIICalEvent icalevent );
void DeleteEvent( in long id );
oeIICalEvent FetchEvent( in long id );
void SnoozeEvent( in long id );
string SearchAlarm( in short year, in short month, in short day,
in short hour, in short min );
string SearchEvent( in short styear, in short stmonth, in short stday,
in short sthour, in short stmin,
in short endyear, in short endmonth, in short endday,
in short endhour, in short endmin );
void SetServer( in string str );
long UpdateEvent( in oeIICalEvent icalevent );
string SearchForEvent( in string sqlstr );
attribute boolean batchMode;
void setServer( in string str );
void addObserver( in oeIICalObserver observer );
long addEvent( in oeIICalEvent icalevent );
long modifyEvent( in oeIICalEvent icalevent );
void deleteEvent( in long id );
oeIICalEvent fetchEvent( in long id );
nsISimpleEnumerator searchBySQL( in string sqlstr );
nsISimpleEnumerator getAllEvents();
nsISimpleEnumerator getEventsForMonth(in PRTime date, out nsISimpleEnumerator datelist );
nsISimpleEnumerator getEventsForWeek(in PRTime date, out nsISimpleEnumerator datelist );
nsISimpleEnumerator getEventsForDay(in PRTime date, out nsISimpleEnumerator datelist );
nsISimpleEnumerator getEventsForRange(in PRTime begindate, in PRTime enddate, out nsISimpleEnumerator datelist );
nsISimpleEnumerator getNextNEvents(in PRTime begindate, in long count, out nsISimpleEnumerator datelist );
// nsISimpleEnumerator searchAlarm( in short year, in short month, in short day,
// in short hour, in short min );
// void AckAlarm( in oeIICalEvent icalevent );
};
%{ C++
extern nsresult
NS_NewICal(oeIICal** inst);
extern nsresult
NS_NewICalEvent(oeIICalEvent** inst);
extern nsresult
NS_NewDateTime(oeIDateTime** inst);
%}