More work on multiple types of calendars.

bug 252603, r=mostafah
This commit is contained in:
mvl%exedo.nl 2004-07-26 13:50:22 +00:00
Родитель 8a324e7d9b
Коммит 98df5c7632
8 изменённых файлов: 86 добавлений и 686 удалений

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

@ -272,9 +272,9 @@ oeICalContainerImpl::~oeICalContainerImpl()
NS_IMPL_ISUPPORTS1(oeICalContainerImpl, oeIICalContainer)
NS_IMETHODIMP
oeICalContainerImpl::AddCalendar( const char *server ) {
oeICalContainerImpl::AddCalendar( const char *server, const char *type ) {
#ifdef ICAL_DEBUG
printf( "oeICalContainerImpl::AddCalendar(%s)\n", server );
printf( "oeICalContainerImpl::AddCalendar(%s, %s)\n", server, type );
#endif
nsresult rv;
@ -288,7 +288,14 @@ oeICalContainerImpl::AddCalendar( const char *server ) {
return NS_OK;
}
calendar = do_CreateInstance(OE_ICAL_CONTRACTID, &rv);
nsCAutoString contractid;
contractid.AssignLiteral("@mozilla.org/ical;1");
if (type && strlen(type)) {
contractid.AppendLiteral("?type=");
contractid.Append(type);
}
printf("\nContractID: %s\n\n",contractid.get());
calendar = do_CreateInstance(contractid.get(), &rv);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
@ -378,7 +385,7 @@ oeICalContainerImpl::AddCalendars( PRUint32 serverCount, const char **servers )
#endif
nsresult rv=NS_OK;
for( unsigned int i=0; i<serverCount; i++ ) {
rv = AddCalendar( servers[i] );
rv = AddCalendar( servers[i], "" );
if( NS_FAILED( rv ) )
break;
}
@ -472,7 +479,7 @@ NS_IMETHODIMP oeICalContainerImpl::AddEvent( oeIICalEvent *icalevent, const char
nsCOMPtr<oeIICal> calendar;
GetCalendar( server , getter_AddRefs(calendar) );
if( !calendar ) {
AddCalendar( server );
AddCalendar( server, "" );
GetCalendar( server , getter_AddRefs(calendar) );
if( !calendar ) {
#ifdef ICAL_DEBUG
@ -921,7 +928,7 @@ NS_IMETHODIMP oeICalContainerImpl::AddTodo(oeIICalTodo *icaltodo, const char *se
nsCOMPtr<oeIICal> calendar;
GetCalendar( server , getter_AddRefs(calendar) );
if( !calendar ) {
AddCalendar( server );
AddCalendar( server, "" );
GetCalendar( server , getter_AddRefs(calendar) );
if( !calendar ) {
#ifdef ICAL_DEBUG
@ -1501,6 +1508,11 @@ NS_IMETHODIMP oeICalContainerFilter::GetContactsArray(nsISupportsArray * *aConta
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP oeICalContainerFilter::SetParent( oeIICal *parent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP oeICalContainerFilter::GetParent( oeIICal **parent)
{
return NS_ERROR_NOT_IMPLEMENTED;
@ -1542,10 +1554,13 @@ void oeICalContainerFilter::UpdateAllFilters( PRInt32 icaltype )
nsCOMPtr<oeIICal> calendar;
m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
oeIICalTodo *filter;
//XXX comptr? getter_AddRefs?
calendar->GetFilter( &filter );
oeIDateTime *completed;
filter->GetCompleted( &completed );
completed->SetTime( completedvalue );
if (filter) {
oeIDateTime *completed;
filter->GetCompleted( &completed );
completed->SetTime( completedvalue );
}
}
break;

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

@ -369,7 +369,7 @@ oeICalEventImpl::~oeICalEventImpl()
NS_IMETHODIMP oeICalEventImpl::SetParent( oeIICal *calendar )
{
#ifdef ICAL_DEBUG
printf( "oeICalEventImpl::SetParent()\n" );
printf( "oeICalEventImpl::SetParent()\n");
#endif
m_calendar = calendar;
return NS_OK;
@ -378,7 +378,7 @@ NS_IMETHODIMP oeICalEventImpl::SetParent( oeIICal *calendar )
NS_IMETHODIMP oeICalEventImpl::GetParent( oeIICal **calendar )
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalEventImpl::GetParent()\n" );
printf( "oeICalEventImpl::GetParent()\n");
#endif
*calendar = m_calendar;
NS_ADDREF( *calendar );

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

@ -1,189 +0,0 @@
/* ***** 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 OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
* ArentJan Banck <ajbanck@planet.nl>
*
* 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 ***** */
/* Header file for oeICalEventImpl.cpp containing its CID and CONTRACTID.*/
#ifndef _OEICALEVENTIMPL_H_
#define _OEICALEVENTIMPL_H_
#include "oeIICal.h"
#include "oeDateTimeImpl.h"
#include "nsISimpleEnumerator.h"
#include "nsISupportsPrimitives.h"
#include "nsSupportsPrimitives.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsVoidArray.h"
extern "C" {
#include "ical.h"
}
#define OE_ICALEVENT_CID \
{ 0x31bda500, 0xee5e, 0x4a4a, { 0x9a, 0xb4, 0x7b, 0x4b, 0x3e, 0x87, 0x40, 0x05 } }
#define OE_ICALEVENT_CONTRACTID "@mozilla.org/icalevent;1"
#define ICALEVENT_VERSION "2.0"
#define ICALEVENT_PRODID "-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN"
/* event enumerator */
class
oeEventEnumerator : public nsISimpleEnumerator
{
public:
oeEventEnumerator();
virtual ~oeEventEnumerator();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
NS_IMETHOD AddEvent( nsISupports *event );
private:
PRUint32 mCurrentIndex;
nsCOMPtr<nsISupportsArray> mEventVector;
};
class
oeDateEnumerator : public nsISimpleEnumerator
{
public:
oeDateEnumerator();
virtual ~oeDateEnumerator();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
NS_IMETHOD AddDate( PRTime date );
private:
PRInt32 mCurrentIndex;
nsVoidArray mDateVector;
};
/* oeIcalEvent Header file */
class oeICalEventImpl : public oeIICalEvent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
oeICalEventImpl();
virtual ~oeICalEventImpl();
/* additional members */
bool ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
icaltimetype GetNextAlarmTime( icaltimetype begin );
bool matchId( const char *id );
icaltimetype GetNextRecurrence( icaltimetype begin, bool *isbeginning );
icaltimetype GetPreviousOccurrence( icaltimetype beforethis );
NS_IMETHODIMP SetParent( oeIICal *parent );
icaltimetype CalculateEventTime( icaltimetype alarmtime );
void ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
bool isallday, bool isbeginning );
void SetType( Componenttype type );
private:
Componenttype m_type;
char *m_id;
char *m_syncid;
nsCString m_title;
nsCString m_description;
nsCString m_location;
nsCString m_category;
nsCString m_url;
short m_priority;
eventMethodProperty m_method;
eventStatusProperty m_status;
bool m_isprivate;
bool m_allday;
bool m_hasalarm;
unsigned long m_alarmlength;
icalparameter_related m_alarmtriggerrelation;
char *m_alarmunits;
char *m_alarmemail;
char *m_inviteemail;
short m_recurtype;
unsigned long m_recurinterval;
unsigned long m_recurcount;
bool m_recur;
bool m_recurforever;
char *m_recurunits;
short m_recurweekdays;
short m_recurweeknumber;
icaldurationtype m_duration;
oeDateTimeImpl *m_start;
oeDateTimeImpl *m_end;
oeDateTimeImpl *m_stamp;
oeDateTimeImpl *m_recurend;
bool m_storeingmt;
icaltimetype m_lastalarmack;
icaltimetype m_lastmodified;
nsVoidArray m_exceptiondates;
nsVoidArray m_snoozetimes;
icaltimetype CalculateAlarmTime( icaltimetype date );
bool IsExcepted( PRTime date );
icaldurationtype GetLength();
nsCOMPtr<nsISupportsArray> m_attachments;
nsCOMPtr<nsISupportsArray> m_contacts;
oeIICal *m_calendar;
};
/*******************************************************************************************/
#define OE_ICALEVENTDISPLAY_CONTRACTID "@mozilla.org/icaleventdisplay;1"
class oeICalEventDisplayImpl : public oeIICalEventDisplay
{
public:
NS_DECL_ISUPPORTS
NS_FORWARD_OEIICALEVENT(mEvent->)
NS_DECL_OEIICALEVENTDISPLAY
oeICalEventDisplayImpl( oeIICalEvent *event );
virtual ~oeICalEventDisplayImpl();
private:
icaltimetype m_displaydate;
icaltimetype m_displaydateend;
nsCOMPtr<oeIICalEvent> mEvent;
};
#endif

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

@ -2285,14 +2285,11 @@ oeICalImpl::GetAllTodos(nsISimpleEnumerator **resultList )
printf( "oeICalImpl::GetAllTodos()\n" );
#endif
nsCOMPtr<oeEventEnumerator> todoEnum;
if( !*resultList ) {
todoEnum = new oeEventEnumerator();
if (!todoEnum)
return NS_ERROR_OUT_OF_MEMORY;
todoEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)resultList);
} else
todoEnum = (oeEventEnumerator *)*resultList;
oeEventEnumerator *todoEnum = new oeEventEnumerator();
if (!todoEnum)
return NS_ERROR_OUT_OF_MEMORY;
*resultList = todoEnum;
NS_ADDREF(*resultList);
TodoList *tmplistptr = &m_todolist;
while( tmplistptr ) {
@ -2796,6 +2793,11 @@ NS_IMETHODIMP oeICalFilter::GetContactsArray(nsISupportsArray * *aContactsArray)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP oeICalFilter::SetParent( oeIICal *parent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP oeICalFilter::GetParent( oeIICal **parent)
{
return NS_ERROR_NOT_IMPLEMENTED;

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

@ -1,381 +0,0 @@
/* ***** 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 Mozilla Calendar Code.
*
* The Initial Developer of the Original Code is
* Chris Charabaruk <ccharabaruk@meldstar.com>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Chris Charabaruk <ccharabaruk@meldstar.com>
* 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.
*
* ***** END LICENSE BLOCK ***** */
/* This file implements an XPCOM object which represents a calendar task(todo) object. It is a derivation
of the event object which adds fields exclusive to tasks.
*/
#ifndef WIN32
#include <unistd.h>
#endif
#include "oeICalEventImpl.h"
#include "oeICalTodoImpl.h"
#include "nsMemory.h"
#include "nsCOMPtr.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#define strcasecmp strcmp
#define RECUR_NONE 0
#define RECUR_DAILY 1
#define RECUR_WEEKLY 2
#define RECUR_MONTHLY_MDAY 3
#define RECUR_MONTHLY_WDAY 4
#define RECUR_YEARLY 5
/* Implementation file */
NS_IMPL_ISUPPORTS2(oeICalTodoImpl, oeIICalTodo, oeIICalEvent)
icaltimetype ConvertFromPrtime( PRTime indate );
PRTime ConvertToPrtime ( icaltimetype indate );
nsresult
NS_NewICalTodo( oeIICalTodo** inst )
{
NS_PRECONDITION(inst != nsnull, "null ptr");
if (! inst)
return NS_ERROR_NULL_POINTER;
*inst = new oeICalTodoImpl();
if (! *inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*inst);
return NS_OK;
}
oeICalTodoImpl::oeICalTodoImpl()
{
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::oeICalTodoImpl()\n" );
#endif
mEvent = new oeICalEventImpl();
NS_ADDREF( mEvent );
mEvent->SetType( XPICAL_VTODO_COMPONENT );
/* member initializers and constructor code */
nsresult rv;
if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_completed ))) {
m_completed = nsnull;
}
m_percent = 0;
//Some defaults are different for todos, apply them
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if ( NS_SUCCEEDED(rv) && prefBranch ) {
nsXPIDLCString tmpstr;
PRInt32 tmpint;
rv = prefBranch->GetIntPref("calendar.alarms.onfortodos", &tmpint);
if (NS_SUCCEEDED(rv))
SetAlarm( tmpint );
rv = prefBranch->GetIntPref("calendar.alarms.todoalarmlen", &tmpint);
if (NS_SUCCEEDED(rv))
SetAlarmLength( tmpint );
rv = prefBranch->GetCharPref("calendar.alarms.todoalarmunit", getter_Copies(tmpstr));
if (NS_SUCCEEDED(rv))
SetAlarmUnits( PromiseFlatCString( tmpstr ).get() );
}
}
oeICalTodoImpl::~oeICalTodoImpl()
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::~oeICalTodoImpl()\n");
#endif
/* destructor code */
if( m_completed )
m_completed->Release();
mEvent->Release();
}
NS_IMETHODIMP oeICalTodoImpl::SetParent( oeIICal *calendar )
{
return mEvent->SetParent( calendar );
}
bool oeICalTodoImpl::matchId( const char *id ) {
return mEvent->matchId( id );
}
/* readonly attribute oeIDateTime due; */
NS_IMETHODIMP oeICalTodoImpl::GetDue(oeIDateTime * *due)
{
return mEvent->GetEnd( due );
}
/* areadonly attribute oeIDateTime completed; */
NS_IMETHODIMP oeICalTodoImpl::GetCompleted(oeIDateTime * *completed)
{
*completed = m_completed;
NS_ADDREF(*completed);
return NS_OK;
}
/* attribute short percent; */
NS_IMETHODIMP oeICalTodoImpl::GetPercent(PRInt16 *aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "GetPercent() = " );
#endif
*aRetVal = m_percent;
#ifdef ICAL_DEBUG_ALL
printf( "%d\n", *aRetVal );
#endif
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::SetPercent(PRInt16 aNewVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "SetPercent( %d )\n", aNewVal );
#endif
m_percent = aNewVal;
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::Clone( oeIICalTodo **ev )
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::Clone()\n" );
#endif
nsresult rv;
oeICalTodoImpl *icaltodo =nsnull;
if( NS_FAILED( rv = NS_NewICalTodo( (oeIICalTodo**) &icaltodo ) ) ) {
return rv;
}
icalcomponent *vcalendar = AsIcalComponent();
if ( !vcalendar ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::Clone() failed!\n" );
#endif
icaltodo->Release();
return NS_OK;
}
icalcomponent *vtodo = icalcomponent_get_first_component( vcalendar, ICAL_VTODO_COMPONENT );
if( !(icaltodo->ParseIcalComponent( vtodo )) ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::Clone() failed.\n" );
#endif
icaltodo->Release();
return NS_OK;
}
*ev = icaltodo;
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::GetTodoIcalString(nsACString& aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::GetTodoIcalString() = " );
#endif
icalcomponent *vcalendar = AsIcalComponent();
if ( !vcalendar ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::GetTodoIcalString() failed!\n" );
#endif
return NS_OK;
}
char *str = icalcomponent_as_ical_string( vcalendar );
if( str ) {
aRetVal = str;
} else
aRetVal.Truncate();
icalcomponent_free( vcalendar );
#ifdef ICAL_DEBUG_ALL
printf( "\"%s\"\n", PromiseFlatCString( aRetVal ).get() );
#endif
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::ParseTodoIcalString(const nsACString& aNewVal, PRBool *aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::ParseTodoIcalString( %s )\n", PromiseFlatCString( aNewVal ).get() );
#endif
*aRetVal = false;
icalcomponent *comp = icalparser_parse_string( PromiseFlatCString( aNewVal ).get() );
if( comp ) {
if( ParseIcalComponent( comp ) )
*aRetVal = true;
icalcomponent_free( comp );
}
return NS_OK;
}
bool oeICalTodoImpl::ParseIcalComponent( icalcomponent *comp )
{
#ifdef ICAL_DEBUG_ALL
printf( "ParseIcalComponent()\n" );
#endif
icalcomponent *vtodo=nsnull;
icalcomponent_kind kind = icalcomponent_isa( comp );
if( kind == ICAL_VCALENDAR_COMPONENT )
vtodo = icalcomponent_get_first_component( comp , ICAL_VTODO_COMPONENT );
else if( kind == ICAL_VTODO_COMPONENT )
vtodo = comp;
if ( !vtodo ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::ParseIcalComponent() failed: vtodo is NULL!\n" );
#endif
return false;
}
//First parse all basic properties
((oeICalEventImpl *)mEvent)->ParseIcalComponent( vtodo );
//then go on with the extra properties
//percent
icalproperty *prop = icalcomponent_get_first_property( vtodo, ICAL_PERCENTCOMPLETE_PROPERTY );
if ( prop != 0) {
m_percent = icalproperty_get_percentcomplete( prop );
} else {
m_percent = 0;
}
//completed
prop = icalcomponent_get_first_property( vtodo, ICAL_COMPLETED_PROPERTY );
if (prop != 0) {
icaltimetype completed;
completed = icalproperty_get_completed( prop );
m_completed->m_datetime = completed;
} else {
m_completed->m_datetime = icaltime_null_time();
}
return true;
}
icalcomponent* oeICalTodoImpl::AsIcalComponent()
{
#ifdef ICAL_DEBUG_ALL
printf( "AsIcalComponent()\n" );
#endif
icalcomponent *newcalendar;
newcalendar = icalcomponent_new_vcalendar();
if ( !newcalendar ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::AsIcalComponent() failed: Cannot create VCALENDAR!\n" );
#endif
return nsnull;
}
icalcomponent *basevcal = ((oeICalEventImpl *)mEvent)->AsIcalComponent();
if ( !basevcal ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::AsIcalComponent() failed: Cannot create ical component from mEvent!\n" );
#endif
icalcomponent_free( newcalendar );
return nsnull;
}
//version
icalproperty *prop = icalproperty_new_version( ICALEVENT_VERSION );
icalcomponent_add_property( newcalendar, prop );
//prodid
prop = icalproperty_new_prodid( ICALEVENT_PRODID );
icalcomponent_add_property( newcalendar, prop );
icalcomponent *vtodo = icalcomponent_new_vtodo();
icalcomponent *vevent = icalcomponent_get_first_component( basevcal, ICAL_VEVENT_COMPONENT );
for( prop = icalcomponent_get_first_property( vevent, ICAL_ANY_PROPERTY );
prop != 0 ;
prop = icalcomponent_get_next_property( vevent, ICAL_ANY_PROPERTY ) ) {
icalproperty *newprop;
icalproperty_kind propkind = icalproperty_isa( prop );
if( propkind == ICAL_X_PROPERTY ) {
newprop = icalproperty_new_x( icalproperty_get_value_as_string( prop ) );
icalproperty_set_x_name( newprop, icalproperty_get_x_name( prop ));
icalparameter *oldpar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
icalparameter *newpar = icalparameter_new_member( icalparameter_get_member( oldpar ) );
icalproperty_add_parameter( newprop, newpar );
} else if( propkind == ICAL_DTEND_PROPERTY ) {
//Change DTEND to DUE
newprop = icalproperty_new_due( icalproperty_get_dtend( prop ) );
icalparameter *oldpar = icalproperty_get_first_parameter( prop, ICAL_TZID_PARAMETER );
if( oldpar ) {
icalparameter *newpar = icalparameter_new_tzid( icalparameter_get_tzid( oldpar ) );
icalproperty_add_parameter( newprop, newpar );
}
} else {
newprop = icalproperty_new_clone( prop );
}
icalcomponent_add_property( vtodo, newprop );
}
icalcomponent *nestedcomp;
for( nestedcomp = icalcomponent_get_first_component( vevent, ICAL_ANY_COMPONENT );
nestedcomp != 0 ;
nestedcomp = icalcomponent_get_next_component( vevent, ICAL_ANY_COMPONENT ) ) {
icalcomponent_add_component( vtodo, icalcomponent_new_clone(nestedcomp) );
}
icalcomponent_free( basevcal );
//percent
if( m_percent != 0) {
prop = icalproperty_new_percentcomplete( m_percent );
icalcomponent_add_property( vtodo, prop );
}
//completed
if( m_completed && !icaltime_is_null_time( m_completed->m_datetime ) ) {
prop = icalproperty_new_completed( m_completed->m_datetime );
icalcomponent_add_property( vtodo, prop );
}
//add event to newcalendar
icalcomponent_add_component( newcalendar, vtodo );
return newcalendar;
}
oeICalEventImpl *oeICalTodoImpl::GetBaseEvent() {
return mEvent;
}
/* End of implementation class template. */

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

@ -1,80 +0,0 @@
/* ***** 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 Mozilla Calendar Code.
*
* The Initial Developer of the Original Code is
* Chris Charabaruk <ccharabaruk@meldstar.com>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Chris Charabaruk <ccharabaruk@meldstar.com>
* 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.
*
* ***** END LICENSE BLOCK ***** */
/* Header file for oeICalTodoImpl.cpp containing its CID and CONTRACTID.*/
#ifndef _OEICALTODOIMPL_H_
#define _OEICALTODOIMPL_H_
#include "oeIICal.h"
#include "oeDateTimeImpl.h"
#include "nsISimpleEnumerator.h"
#include "nsISupportsPrimitives.h"
#include "nsSupportsPrimitives.h"
extern "C" {
#include "ical.h"
}
#define OE_ICALTODO_CID { 0x0c06905a, 0x1dd2, 0x11b2, { 0xba, 0x61, 0xc9, 0x5d, 0x84, 0x0b, 0x01, 0xef } }
#define OE_ICALTODO_CONTRACTID "@mozilla.org/icaltodo;1"
/* oeICalTodo Header file */
class oeICalTodoImpl : public oeIICalTodo
{
public:
NS_DECL_ISUPPORTS
NS_FORWARD_OEIICALEVENT(mEvent->)
NS_DECL_OEIICALTODO
oeICalTodoImpl();
virtual ~oeICalTodoImpl();
/* additional members */
bool ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
NS_IMETHOD Clone(oeIICalTodo **_retval);
bool matchId( const char *id );
NS_IMETHODIMP SetParent( oeIICal *parent );
oeICalEventImpl *GetBaseEvent();
private:
int m_percent;
oeDateTimeImpl *m_completed;
oeICalEventImpl *mEvent;
};
#endif

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

@ -104,7 +104,7 @@ interface oeIICalEvent : nsISupports
readonly attribute oeIDateTime start;
readonly attribute oeIDateTime end;
readonly attribute oeIDateTime stamp;
readonly attribute oeIICal parent;
attribute oeIICal parent;
readonly attribute Componenttype type;
readonly attribute PRTime lastModified;
@ -230,12 +230,17 @@ interface oeIICal : nsISupports
oeIICalEvent fetchEvent( in string id );
// nsISimpleEnumerator searchBySQL( in string sqlstr );
nsISimpleEnumerator getAllEvents();
nsISimpleEnumerator getEventsForMonth( in PRTime date );
nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
/**
* For all the getEvents* and get*EventForRange methods:
* Get events for a certain range. items are oeIICalEventDisplay
*/
nsISimpleEnumerator getEventsForMonth( in PRTime date );
nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
string addTodo( in oeIICalTodo icaltodo );
string modifyTodo( in oeIICalTodo icaltodo );
@ -253,7 +258,20 @@ interface oeIICalContainer : nsISupports
attribute boolean batchMode;
readonly attribute oeIICalTodo filter;
void addCalendar( in string server );
/**
* Add a calendar to the container.
* @param server
* a string indicating the server url
* @param type
* a string idicating which type of calendar to add.
* an object with contractid of @mozilla.org/ical;1?type=<type>
* will be created and added. The object should implement
* oeIICal.
* When empty, @mozilla.org/ical;1 will be used
*/
void addCalendar( in string server, in string type );
void removeCalendar( in string server );
oeIICal getCalendar( in string server );
void addCalendars( in unsigned long serverCount, [array, size_is(serverCount)] in string servers );
@ -265,13 +283,26 @@ interface oeIICalContainer : nsISupports
string modifyEvent( in oeIICalEvent icalevent );
void deleteEvent( in string id );
oeIICalEvent fetchEvent( in string id );
nsISimpleEnumerator getAllEvents();
nsISimpleEnumerator getEventsForMonth( in PRTime date );
nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getAllEvents();
/**
* For all the getEvents* and get*EventForRange methods:
* Get events for a certain range. items are oeIICalEventDisplay
*/
nsISimpleEnumerator getEventsForMonth( in PRTime date );
/**
* Get the events starting at the beginning of |date|
* until 7 days later
*/
nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
/**
* Get the first occurence of the events in the given time range
*/
nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
string addTodo( in oeIICalTodo icaltodo, in string server );
string modifyTodo( in oeIICalTodo icaltodo );

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

@ -401,7 +401,8 @@ calendarManager.prototype.addCalendar = function calMan_addCalendar( ThisCalenda
{
//dump( "\n CALENDAR MANANGER-> add calendar with path "+ThisCalendarObject.getAttribute( "http://home.netscape.com/NC-rdf#path"+"\n\n" ) );
gICalLib.addCalendar( ThisCalendarObject.getAttribute( "http://home.netscape.com/NC-rdf#path" ) );
gICalLib.addCalendar( ThisCalendarObject.getAttribute( "http://home.netscape.com/NC-rdf#path" ),
ThisCalendarObject.getAttribute( "http://home.netscape.com/NC-rdf#type" ));
//ThisCalendarObject.setAttribute( "http://home.netscape.com/NC-rdf#active", "true" );
@ -885,7 +886,8 @@ function switchCalendar( event )
{
window.setCursor( "wait" );
gICalLib.addCalendar( calendarNode.getAttribute( "http://home.netscape.com/NC-rdf#path" ) );
gICalLib.addCalendar( calendarNode.getAttribute( "http://home.netscape.com/NC-rdf#path" ),
calendarNode.getAttribute( "http://home.netscape.com/NC-rdf#type" ));
window.setCursor( "default" );