2001-11-07 20:29:04 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2001-11-07 19:18:46 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2001-11-07 20:29:04 +00:00
|
|
|
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* OEone Corporation.
|
2001-11-07 20:29:04 +00:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
2001-11-07 20:29:04 +00:00
|
|
|
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
|
2004-04-06 18:49:40 +00:00
|
|
|
* Cristian Tapus <cristian_tapus@yahoo.com>
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2001-11-07 20:29:04 +00:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2003-10-24 20:40:32 +00:00
|
|
|
|
|
|
|
/* This file implements an XPCOM object which represents a calendar object. It is a container
|
|
|
|
of events and prepares responses for queries made upon the calendar in whole. The task of reading from
|
|
|
|
and writing to the calendar data storage is currently performed by this object */
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2001-11-22 19:15:20 +00:00
|
|
|
#ifndef WIN32
|
2001-11-07 19:18:46 +00:00
|
|
|
#include <unistd.h>
|
2001-11-22 19:15:20 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
#define __cplusplus__ 1
|
|
|
|
|
|
|
|
#include "oeICalImpl.h"
|
|
|
|
#include "oeICalEventImpl.h"
|
|
|
|
#include "nsMemory.h"
|
2001-12-20 22:16:08 +00:00
|
|
|
#include "stdlib.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsISimpleEnumerator.h"
|
2002-04-11 20:35:04 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsNetCID.h"
|
2002-04-12 16:25:27 +00:00
|
|
|
#include "nsEscape.h"
|
2002-05-22 14:01:38 +00:00
|
|
|
#include "nsISupportsArray.h"
|
2002-09-06 15:41:48 +00:00
|
|
|
#include "nsXPCOM.h"
|
2002-09-09 15:29:16 +00:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2003-06-18 20:11:58 +00:00
|
|
|
#include "nsIWindowMediator.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMWindowInternal.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMElement.h"
|
2003-08-01 18:46:23 +00:00
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefService.h"
|
2003-06-18 20:11:58 +00:00
|
|
|
|
2002-09-09 15:29:16 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "icalss.h"
|
|
|
|
}
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
icaltimetype ConvertFromPrtime( PRTime indate );
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime ConvertToPrtime ( icaltimetype indate );
|
2002-03-14 16:42:41 +00:00
|
|
|
void AlarmTimerCallback(nsITimer *aTimer, void *aClosure);
|
2003-05-15 14:15:30 +00:00
|
|
|
void GenerateUUID(char *output);
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
icalcomponent* icalcomponent_fetch( icalcomponent* parent,const char* uid )
|
|
|
|
{
|
|
|
|
icalcomponent *inner;
|
|
|
|
icalproperty *prop;
|
|
|
|
const char *this_uid;
|
|
|
|
|
|
|
|
for(inner = icalcomponent_get_first_component( parent , ICAL_ANY_COMPONENT );
|
|
|
|
inner != 0;
|
|
|
|
inner = icalcomponent_get_next_component( parent , ICAL_ANY_COMPONENT ) ){
|
|
|
|
|
|
|
|
prop = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
|
|
|
|
if ( prop ) {
|
|
|
|
this_uid = icalproperty_get_uid( prop );
|
|
|
|
|
|
|
|
if(this_uid==0){
|
|
|
|
icalerror_warn("icalcomponent_fetch found a component with no UID");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(uid,this_uid)==0){
|
|
|
|
return inner;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
icalerror_warn("icalcomponent_fetch found a component with no UID");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2004-04-06 18:49:40 +00:00
|
|
|
/*
|
|
|
|
* This function adds the first component of the child component to the
|
|
|
|
* first component of the parent icalfileset (which is a icalfileset_impl)
|
|
|
|
*
|
|
|
|
* This is used in the following member functions: AddEvent, ModifyEvent,
|
|
|
|
* AddTodo, ModifyTodo
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
icalerrorenum icalfileset_add_first_to_first_component(icalfileset *parent,
|
|
|
|
icalcomponent* child)
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf("icalfileset_add_first_to_first_component()::\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct icalfileset_impl* impl = (struct icalfileset_impl*)parent;
|
|
|
|
|
|
|
|
icalerror_check_arg_re((parent!=0),"parent", ICAL_BADARG_ERROR);
|
|
|
|
icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
|
|
|
|
|
|
|
|
// get the first component of the child which is either a vevent or a vtodo
|
|
|
|
icalcomponent* vfirst = icalcomponent_get_first_component(child, ICAL_VEVENT_COMPONENT);
|
|
|
|
if (vfirst==0) {
|
|
|
|
vfirst = icalcomponent_get_first_component(child, ICAL_VTODO_COMPONENT);
|
|
|
|
}
|
|
|
|
if (vfirst==0) return ICAL_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
// extract the first (presumably) vcalendar component of the parent stream
|
|
|
|
struct icalfileset_impl* firstc = (struct icalfileset_impl*)icalfileset_get_first_component(impl);
|
|
|
|
|
|
|
|
icalcomponent_kind kind_firstc;
|
|
|
|
|
|
|
|
if (firstc!=0)
|
|
|
|
kind_firstc = icalcomponent_isa (firstc);
|
|
|
|
else
|
|
|
|
// the check below will fail due to firstc==0
|
|
|
|
kind_firstc = ICAL_VCALENDAR_COMPONENT;
|
|
|
|
|
|
|
|
if ( (firstc==0) || (kind_firstc != ICAL_VCALENDAR_COMPONENT) ) {
|
|
|
|
// if parent stream is empty or first component is not a VCALENDAR
|
|
|
|
// then create a new vcalendar component
|
|
|
|
firstc = (struct icalfileset_impl*)icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
|
|
|
|
|
|
|
|
if (firstc==0) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf("icalfileset_add_first_to_first_component():: firstc is still NULL\n");
|
|
|
|
#endif
|
|
|
|
return ICAL_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add component to parent stream
|
|
|
|
icalfileset_add_component(parent, firstc);
|
|
|
|
} else {
|
|
|
|
// I need to remove the version and the prodid
|
|
|
|
|
|
|
|
//version
|
|
|
|
icalproperty *prop = icalcomponent_get_first_property(firstc, ICAL_VERSION_PROPERTY );
|
|
|
|
icalcomponent_remove_property( firstc, prop );
|
|
|
|
|
|
|
|
//prodid
|
|
|
|
prop = icalcomponent_get_first_property( firstc, ICAL_PRODID_PROPERTY );
|
|
|
|
icalcomponent_remove_property( firstc, prop );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//version
|
|
|
|
icalproperty *prop = icalproperty_new_version( ICALEVENT_VERSION );
|
|
|
|
icalcomponent_add_property( firstc, prop );
|
|
|
|
|
|
|
|
//prodid
|
|
|
|
prop = icalproperty_new_prodid( ICALEVENT_PRODID );
|
|
|
|
icalcomponent_add_property( firstc, prop );
|
|
|
|
|
|
|
|
// get the timezone component if any
|
|
|
|
icalcomponent* timezone = icalcomponent_get_first_component(child, ICAL_VTIMEZONE_COMPONENT);
|
|
|
|
|
|
|
|
// we know that we have at most one timezone component inside the child component
|
|
|
|
if (timezone!=0) icalcomponent_add_component(firstc, timezone);
|
|
|
|
|
|
|
|
// add first component of child into the first component of stream
|
|
|
|
icalcomponent_add_component(firstc, vfirst);
|
|
|
|
|
|
|
|
icalfileset_mark(parent);
|
|
|
|
|
|
|
|
return ICAL_NO_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
oeEventEnumerator::oeEventEnumerator( )
|
|
|
|
:
|
|
|
|
mCurrentIndex( 0 )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
NS_NewISupportsArray(getter_AddRefs(mEventVector));
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oeEventEnumerator::~oeEventEnumerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(oeEventEnumerator, nsISimpleEnumerator)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
oeEventEnumerator::HasMoreElements(PRBool *result)
|
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 count = 0;
|
|
|
|
mEventVector->Count(&count);
|
|
|
|
if( mCurrentIndex >= count )
|
2001-12-20 22:16:08 +00:00
|
|
|
{
|
|
|
|
*result = PR_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-08-22 14:44:01 +00:00
|
|
|
|
2002-05-22 14:01:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeEventEnumerator::GetNext(nsISupports **_retval)
|
|
|
|
{
|
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 count = 0;
|
|
|
|
mEventVector->Count(&count);
|
|
|
|
if( mCurrentIndex >= count )
|
2002-05-22 14:01:38 +00:00
|
|
|
{
|
|
|
|
*_retval = nsnull;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
nsCOMPtr<nsISupports> event;
|
|
|
|
mEventVector->QueryElementAt( mCurrentIndex, NS_GET_IID(nsISupports), getter_AddRefs(event));
|
2002-06-21 17:16:30 +00:00
|
|
|
*_retval = event;
|
2003-02-14 21:14:42 +00:00
|
|
|
NS_ADDREF( *_retval );
|
2002-05-22 14:01:38 +00:00
|
|
|
++mCurrentIndex;
|
|
|
|
}
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-06-21 17:16:30 +00:00
|
|
|
oeEventEnumerator::AddEvent( nsISupports* event)
|
2001-12-20 22:16:08 +00:00
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 count = 0;
|
|
|
|
mEventVector->Count( &count );
|
|
|
|
mEventVector->InsertElementAt( event, count );
|
2001-12-20 22:16:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* date enumerator */
|
|
|
|
oeDateEnumerator::oeDateEnumerator( )
|
|
|
|
:
|
|
|
|
mCurrentIndex( 0 )
|
|
|
|
{
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
oeDateEnumerator::~oeDateEnumerator()
|
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
for( int i=0; i<mDateVector.Count(); i++ ) {
|
|
|
|
PRTime *timeptr = (PRTime*)(mDateVector[i]);
|
|
|
|
delete timeptr;
|
|
|
|
}
|
|
|
|
mDateVector.Clear();
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(oeDateEnumerator, nsISimpleEnumerator)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
oeDateEnumerator::HasMoreElements(PRBool *result)
|
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
if( mCurrentIndex >= mDateVector.Count() )
|
2001-12-20 22:16:08 +00:00
|
|
|
{
|
|
|
|
*result = PR_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-24 21:01:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeDateEnumerator::GetNext(nsISupports **_retval)
|
|
|
|
{
|
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
if( mCurrentIndex >= mDateVector.Count() )
|
2001-12-24 21:01:42 +00:00
|
|
|
{
|
|
|
|
*_retval = nsnull;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISupportsPRTime> nsPRTime = do_CreateInstance( NS_SUPPORTS_PRTIME_CONTRACTID , &rv);
|
|
|
|
if( NS_FAILED( rv ) ) {
|
2002-01-04 19:27:45 +00:00
|
|
|
*_retval = nsnull;
|
2001-12-24 21:01:42 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
nsISupportsPRTime* date;
|
|
|
|
rv = nsPRTime->QueryInterface(NS_GET_IID(nsISupportsPRTime), (void **)&date);
|
|
|
|
if( NS_FAILED( rv ) ) {
|
2002-01-04 19:27:45 +00:00
|
|
|
*_retval = nsnull;
|
2001-12-24 21:01:42 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
date->SetData( *(PRTime *)(mDateVector[ mCurrentIndex ]) );
|
2001-12-24 21:01:42 +00:00
|
|
|
*_retval = date;
|
|
|
|
++mCurrentIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
oeDateEnumerator::AddDate(PRTime date)
|
|
|
|
{
|
2003-02-14 18:05:46 +00:00
|
|
|
PRTime *newdate = new PRTime;
|
2004-09-21 18:56:45 +00:00
|
|
|
if (!newdate)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2003-02-14 18:05:46 +00:00
|
|
|
*newdate = date;
|
|
|
|
mDateVector.AppendElement( newdate );
|
2001-12-20 22:16:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// ICal Factory
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewICal( oeIICal** inst )
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(inst != nsnull, "null ptr");
|
|
|
|
if (! inst)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*inst = new oeICalImpl();
|
|
|
|
if (! *inst)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(*inst);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
oeICalImpl::oeICalImpl()
|
|
|
|
{
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::oeICalImpl()\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_batchMode = false;
|
2004-09-01 20:11:06 +00:00
|
|
|
m_suppressAlarms = false;
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-03-22 23:04:40 +00:00
|
|
|
m_alarmtimer = nsnull;
|
2002-06-25 13:50:39 +00:00
|
|
|
|
|
|
|
m_filter = new oeICalFilter();
|
|
|
|
NS_ADDREF( m_filter );
|
2003-02-14 18:05:46 +00:00
|
|
|
|
|
|
|
NS_NewISupportsArray(getter_AddRefs(m_observerlist));
|
|
|
|
NS_NewISupportsArray(getter_AddRefs(m_todoobserverlist));
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oeICalImpl::~oeICalImpl()
|
|
|
|
{
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::~oeICalImpl()\n" );
|
|
|
|
#endif
|
2004-09-01 20:11:06 +00:00
|
|
|
CancelAlarmTimer();
|
2002-06-25 13:50:39 +00:00
|
|
|
|
|
|
|
NS_RELEASE( m_filter );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NS_IMPL_ISUPPORTS1 expands to a simple implementation of the nsISupports
|
|
|
|
* interface. This includes a proper implementation of AddRef, Release,
|
|
|
|
* and QueryInterface. If this class supported more interfaces than just
|
|
|
|
* nsISupports,
|
|
|
|
* you could use NS_IMPL_ADDREF() and NS_IMPL_RELEASE() to take care of the
|
|
|
|
* simple stuff, but you would have to create QueryInterface on your own.
|
|
|
|
* nsSampleFactory.cpp is an example of this approach.
|
|
|
|
* Notice that the second parameter to the macro is the static IID accessor
|
|
|
|
* method, and NOT the #defined IID.
|
|
|
|
*/
|
2003-09-07 21:37:51 +00:00
|
|
|
NS_IMPL_ISUPPORTS1(oeICalImpl, oeIICal)
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
nsVoidArray *oeICalImpl::GetEventList()
|
2002-08-22 14:44:01 +00:00
|
|
|
{
|
|
|
|
return &m_eventlist;
|
|
|
|
}
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Test
|
|
|
|
*
|
|
|
|
* DESCRIPTION: An exported XPCOM function used by the tester program to make sure
|
|
|
|
* all main internal functions are working properly
|
|
|
|
* PARAMETERS:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* RETURN
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::Test(void)
|
|
|
|
{
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test()\n" );
|
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2001-11-07 19:18:46 +00:00
|
|
|
icalcomponent *icalcalendar,*icalevent;
|
|
|
|
struct icaltimetype start, end;
|
|
|
|
char uidstr[10]="900000000";
|
2001-12-20 22:16:08 +00:00
|
|
|
char icalrawcalendarstr[] = "BEGIN:VCALENDAR\n\
|
|
|
|
BEGIN:VEVENT\n\
|
|
|
|
END:VEVENT\n\
|
|
|
|
END:VCALENDAR\n\
|
|
|
|
";
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2004-11-08 18:23:03 +00:00
|
|
|
printf( "oeICalImpl::Test() failed: Cannot open stream: %s!\n", m_serveraddr.get() );
|
2002-03-01 22:07:45 +00:00
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
icalcalendar = icalparser_parse_string(icalrawcalendarstr);
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !icalcalendar ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: Cannot create VCALENDAR!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2003-03-24 18:57:57 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
icalevent = icalcomponent_get_first_component(icalcalendar,ICAL_VEVENT_COMPONENT);
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !icalevent ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: VEVENT not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
icalproperty *uid = icalproperty_new_uid( uidstr );
|
|
|
|
icalcomponent_add_property( icalevent, uid );
|
|
|
|
|
|
|
|
icalproperty *title = icalproperty_new_summary( "Lunch time" );
|
|
|
|
icalcomponent_add_property( icalevent, title );
|
|
|
|
|
|
|
|
icalproperty *description = icalproperty_new_description( "Will be out for one hour" );
|
|
|
|
icalcomponent_add_property( icalevent, description );
|
|
|
|
|
|
|
|
icalproperty *location = icalproperty_new_location( "Restaurant" );
|
|
|
|
icalcomponent_add_property( icalevent, location );
|
|
|
|
|
|
|
|
icalproperty *category = icalproperty_new_categories( "Personal" );
|
|
|
|
icalcomponent_add_property( icalevent, category );
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
icalproperty *classp = icalproperty_new_class( ICAL_CLASS_PRIVATE );
|
2001-11-07 19:18:46 +00:00
|
|
|
icalcomponent_add_property( icalevent, classp );
|
|
|
|
|
|
|
|
start.year = 2001; start.month = 8; start.day = 15;
|
|
|
|
start.hour = 12; start.minute = 24; start.second = 0;
|
|
|
|
start.is_utc = false; start.is_date = false;
|
|
|
|
|
|
|
|
end.year = 2001; end.month = 8; end.day = 15;
|
|
|
|
end.hour = 13; end.minute = 24; end.second = 0;
|
|
|
|
end.is_utc = false; end.is_date = false;
|
|
|
|
|
|
|
|
icalproperty *dtstart = icalproperty_new_dtstart( start );
|
|
|
|
icalproperty *dtend = icalproperty_new_dtend( end );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, dtstart );
|
|
|
|
icalcomponent_add_property( icalevent, dtend );
|
|
|
|
//
|
|
|
|
icalproperty *xprop = icalproperty_new_x( "TRUE" );
|
|
|
|
icalparameter *xpar = icalparameter_new_member( "AllDay" ); //NOTE: new_member is used because new_x didn't work
|
|
|
|
// Better to be changed to new_x when problem is solved
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "FALSE" );
|
|
|
|
xpar = icalparameter_new_member( "Alarm" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "FALSE" );
|
|
|
|
xpar = icalparameter_new_member( "AlarmWentOff" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "5" );
|
|
|
|
xpar = icalparameter_new_member( "AlarmLength" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "mostafah@oeone.com" );
|
|
|
|
xpar = icalparameter_new_member( "AlarmEmailAddres" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "mostafah@oeone.com" );
|
|
|
|
xpar = icalparameter_new_member( "InviteEmailAddres" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "5" );
|
|
|
|
xpar = icalparameter_new_member( "SnoozeTime" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "0" );
|
|
|
|
xpar = icalparameter_new_member( "RecurType" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "0" );
|
|
|
|
xpar = icalparameter_new_member( "RecurInterval" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "days" );
|
|
|
|
xpar = icalparameter_new_member( "RepeatUnits" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
xprop = icalproperty_new_x( "FALSE" );
|
|
|
|
xpar = icalparameter_new_member( "RepeatForever" );
|
|
|
|
|
|
|
|
icalproperty_add_parameter( xprop, xpar );
|
|
|
|
|
|
|
|
icalcomponent_add_property( icalevent, xprop );
|
|
|
|
//
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
struct icaltriggertype trig;
|
|
|
|
icalcomponent *valarm = icalcomponent_new_valarm();
|
|
|
|
trig.time.year = trig.time.month = trig.time.day = trig.time.hour = trig.time.minute = trig.time.second = 0;
|
|
|
|
trig.duration.is_neg = true;
|
|
|
|
trig.duration.days = trig.duration.weeks = trig.duration.hours = trig.duration.seconds = 0;
|
|
|
|
trig.duration.minutes = 1;
|
|
|
|
xprop = icalproperty_new_trigger( trig );
|
|
|
|
icalcomponent_add_property( valarm, xprop );
|
|
|
|
icalcomponent_add_component( icalevent, valarm );
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
icalfileset_add_component(stream,icalcalendar);
|
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2002-05-01 14:11:30 +00:00
|
|
|
printf( "oeICalImpl::Test() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-04-18 16:32:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("Appended Event\n");
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
icalcomponent *fetchedcal = icalfileset_fetch( stream, uidstr );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !fetchedcal ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: Cannot fetch event!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
icalcomponent *fetchedevent = icalcomponent_get_first_component( fetchedcal,ICAL_VEVENT_COMPONENT);
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !fetchedevent ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: VEVENT not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("Fetched Event\n");
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
icalproperty *tmpprop;
|
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_UID_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: UID not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-01-08 14:56:59 +00:00
|
|
|
printf("id: %s\n", icalproperty_get_uid( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_SUMMARY_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: SUMMARY not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-01-08 14:56:59 +00:00
|
|
|
printf("Title: %s\n", icalproperty_get_summary( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_CATEGORIES_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: CATEGORIES not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-01-08 14:56:59 +00:00
|
|
|
printf("Category: %s\n", icalproperty_get_categories( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_DESCRIPTION_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: DESCRIPTION not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-01-08 14:56:59 +00:00
|
|
|
printf("Description: %s\n", icalproperty_get_description( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_LOCATION_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: LOCATION not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-01-08 14:56:59 +00:00
|
|
|
printf("Location: %s\n", icalproperty_get_location( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_CLASS_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: CLASS not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-01-08 14:56:59 +00:00
|
|
|
printf("Class: %s\n", (icalproperty_get_class( tmpprop ) == ICAL_CLASS_PUBLIC) ? "PUBLIC" : "PRIVATE" );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_DTSTART_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: DTSTART not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
start = icalproperty_get_dtstart( tmpprop );
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("Start: %d-%d-%d %d:%d\n", start.year, start.month, start.day, start.hour, start.minute );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_DTEND_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: DTEND not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
end = icalproperty_get_dtstart( tmpprop );
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("End: %d-%d-%d %d:%d\n", end.year, end.month, end.day, end.hour, end.minute );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
//
|
|
|
|
for( tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_X_PROPERTY );
|
|
|
|
tmpprop != 0 ;
|
|
|
|
tmpprop = icalcomponent_get_next_property( fetchedevent, ICAL_X_PROPERTY ) ) {
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-04-04 22:41:14 +00:00
|
|
|
icalparameter *tmppar = icalproperty_get_first_parameter( tmpprop, ICAL_MEMBER_PARAMETER );
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("%s: %s\n", icalparameter_get_member( tmppar ), icalproperty_get_value_as_string( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
icalcomponent *newcomp = icalcomponent_new_clone( fetchedcal );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !newcomp ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: Cannot clone event!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2003-03-24 18:57:57 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
icalcomponent *newevent = icalcomponent_get_first_component( newcomp, ICAL_VEVENT_COMPONENT );
|
2003-03-24 18:57:57 +00:00
|
|
|
if ( !newevent ) {
|
2002-03-01 22:07:45 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: VEVENT not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
tmpprop = icalcomponent_get_first_property( newevent, ICAL_SUMMARY_PROPERTY );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !tmpprop ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: SUMMARY not found!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
icalproperty_set_summary( tmpprop, "LUNCH AND LEARN TIME" );
|
|
|
|
// icalfileset_modify( stream, fetchedcal, newcomp );
|
|
|
|
icalfileset_remove_component( stream, fetchedcal );
|
|
|
|
icalfileset_add_component( stream, newcomp );
|
|
|
|
icalcomponent_free( fetchedcal );
|
|
|
|
//
|
|
|
|
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("Event updated\n");
|
2002-01-08 14:56:59 +00:00
|
|
|
printf( "New Title: %s\n", icalproperty_get_summary( tmpprop ) );
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
fetchedcal = icalfileset_fetch( stream, uidstr );
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !fetchedcal ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::Test() failed: Cannot fetch event!\n" );
|
|
|
|
#endif
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
icalfileset_remove_component( stream, fetchedcal );
|
|
|
|
|
2002-01-08 15:20:47 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-11-07 19:18:46 +00:00
|
|
|
printf("Removed Event\n");
|
2002-01-08 15:20:47 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2002-05-01 14:11:30 +00:00
|
|
|
printf( "oeICalImpl::Test() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-04-18 16:32:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
icalfileset_free(stream);
|
2003-03-24 18:57:57 +00:00
|
|
|
return NS_OK;
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-11-08 18:23:03 +00:00
|
|
|
oeICalImpl::SetServer( const nsACString &aServer ) {
|
2001-11-07 19:18:46 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2004-11-08 18:23:03 +00:00
|
|
|
printf( "oeICalImpl::SetServer(%s)\n", PromiseFlatCString(aServer).get() );
|
2001-11-07 19:18:46 +00:00
|
|
|
#endif
|
2002-04-11 20:35:04 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
if( StringBeginsWith(aServer, NS_LITERAL_CSTRING("file:///") ) ) {
|
2002-04-11 20:35:04 +00:00
|
|
|
nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
|
|
|
|
nsCString filePath;
|
2004-11-08 18:23:03 +00:00
|
|
|
url->SetSpec( aServer );
|
2002-04-11 20:35:04 +00:00
|
|
|
url->GetFilePath( filePath );
|
2004-11-08 18:23:03 +00:00
|
|
|
m_serveraddr = filePath;
|
|
|
|
NS_UnescapeURL( m_serveraddr );
|
2002-04-11 20:35:04 +00:00
|
|
|
} else
|
2004-11-08 18:23:03 +00:00
|
|
|
m_serveraddr = aServer;
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-12-05 14:03:48 +00:00
|
|
|
//UGLY HACK TO ADD DEPENDANCY TO stat() in libc. ( -lc didn't work )
|
|
|
|
int dummy=0;
|
|
|
|
if( dummy )
|
|
|
|
stat(NULL,NULL);
|
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2004-11-08 18:23:03 +00:00
|
|
|
printf( "oeICalImpl::SetServer() failed: Cannot open stream: %s!\n", m_serveraddr.get() );
|
2002-03-01 22:07:45 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-04-04 00:19:44 +00:00
|
|
|
nsresult rv;
|
|
|
|
icalcomponent *vcalendar;
|
2002-06-26 18:45:19 +00:00
|
|
|
icalcomponent *vevent,*vtodo;
|
2002-04-04 00:19:44 +00:00
|
|
|
oeICalEventImpl *icalevent;
|
2002-06-26 18:45:19 +00:00
|
|
|
oeICalTodoImpl *icaltodo;
|
2002-04-04 00:19:44 +00:00
|
|
|
for( vcalendar = icalfileset_get_first_component( stream );
|
|
|
|
vcalendar != 0;
|
|
|
|
vcalendar = icalfileset_get_next_component( stream ) ) {
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-04-04 00:19:44 +00:00
|
|
|
for( vevent = icalcomponent_get_first_component( vcalendar, ICAL_VEVENT_COMPONENT );
|
|
|
|
vevent != 0;
|
|
|
|
vevent = icalcomponent_get_next_component( vcalendar, ICAL_VEVENT_COMPONENT ) ) {
|
|
|
|
|
|
|
|
if( NS_FAILED( rv = NS_NewICalEvent((oeIICalEvent**) &icalevent ))) {
|
|
|
|
return rv;
|
|
|
|
}
|
2002-04-08 21:40:09 +00:00
|
|
|
if( icalevent->ParseIcalComponent( vevent ) ) {
|
2004-10-28 15:18:12 +00:00
|
|
|
m_eventlist.AppendElement( icalevent );
|
2002-08-22 14:44:01 +00:00
|
|
|
icalevent->SetParent( this );
|
2002-04-08 21:40:09 +00:00
|
|
|
} else {
|
|
|
|
icalevent->Release();
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2002-06-26 18:45:19 +00:00
|
|
|
for( vtodo = icalcomponent_get_first_component( vcalendar, ICAL_VTODO_COMPONENT );
|
|
|
|
vtodo != 0;
|
|
|
|
vtodo = icalcomponent_get_next_component( vcalendar, ICAL_VTODO_COMPONENT ) ) {
|
|
|
|
|
|
|
|
if( NS_FAILED( rv = NS_NewICalTodo((oeIICalTodo**) &icaltodo ))) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if( icaltodo->ParseIcalComponent( vtodo ) ) {
|
|
|
|
m_todolist.Add( icaltodo );
|
2002-08-22 14:44:01 +00:00
|
|
|
icaltodo->SetParent( this );
|
2002-06-26 18:45:19 +00:00
|
|
|
} else {
|
|
|
|
icaltodo->Release();
|
|
|
|
}
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
icalfileset_free(stream);
|
|
|
|
|
2002-07-03 16:18:36 +00:00
|
|
|
unsigned int i;
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count(&observercount);
|
|
|
|
for( i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnLoad();
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetServer() : WARNING Call to observer's onLoad() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2003-02-14 18:05:46 +00:00
|
|
|
m_todoobserverlist->Count(&observercount);
|
|
|
|
for( i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalTodoObserver>observer;
|
|
|
|
m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnLoad();
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetServer() : WARNING Call to observer's onLoad() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetupAlarmManager();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-08-22 14:44:01 +00:00
|
|
|
NS_IMETHODIMP
|
2004-11-08 18:23:03 +00:00
|
|
|
oeICalImpl::GetServer( nsACString &aServer ) {
|
2002-08-22 14:44:01 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::GetServer()\n" );
|
|
|
|
#endif
|
2004-11-08 18:23:03 +00:00
|
|
|
aServer = m_serveraddr;
|
2002-08-22 14:44:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
/* attribute boolean batchMode; */
|
|
|
|
NS_IMETHODIMP oeICalImpl::GetBatchMode(PRBool *aBatchMode)
|
|
|
|
{
|
|
|
|
*aBatchMode = m_batchMode;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalImpl::SetBatchMode(PRBool aBatchMode)
|
|
|
|
{
|
|
|
|
bool newBatchMode = aBatchMode;
|
|
|
|
|
|
|
|
if( m_batchMode != newBatchMode )
|
|
|
|
{
|
|
|
|
m_batchMode = aBatchMode;
|
2002-03-01 22:07:45 +00:00
|
|
|
|
|
|
|
// if batch mode changed to off, call set up alarm mamnager
|
|
|
|
|
|
|
|
if( !m_batchMode )
|
|
|
|
{
|
|
|
|
SetupAlarmManager();
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-03-01 22:07:45 +00:00
|
|
|
// tell observers about the change
|
|
|
|
|
2002-08-22 14:44:01 +00:00
|
|
|
//The container will take care of this for now
|
|
|
|
/*
|
2002-07-03 16:18:36 +00:00
|
|
|
unsigned int i;
|
|
|
|
for( i=0; i<m_observerlist.size(); i++ )
|
2001-12-20 22:16:08 +00:00
|
|
|
{
|
2002-06-27 16:51:51 +00:00
|
|
|
if( m_batchMode ) {
|
|
|
|
nsresult rv;
|
|
|
|
rv = m_observerlist[i]->OnStartBatch();
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onStartBatch() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsresult rv;
|
|
|
|
rv = m_observerlist[i]->OnEndBatch();
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onEndBatch() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2002-06-27 18:00:42 +00:00
|
|
|
for( i=0; i<m_todoobserverlist.size(); i++ )
|
2002-06-27 16:51:51 +00:00
|
|
|
{
|
|
|
|
if( m_batchMode ) {
|
|
|
|
nsresult rv;
|
|
|
|
rv = m_todoobserverlist[i]->OnStartBatch();
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onStartBatch() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsresult rv;
|
|
|
|
rv = m_todoobserverlist[i]->OnEndBatch();
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onEndBatch() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-08-22 14:44:01 +00:00
|
|
|
}*/
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
2004-09-01 20:11:06 +00:00
|
|
|
/* attribute boolean suppressAlarms; */
|
|
|
|
NS_IMETHODIMP oeICalImpl::GetSuppressAlarms(PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
*aRetVal = m_suppressAlarms;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalImpl::SetSuppressAlarms(PRBool aNewVal)
|
|
|
|
{
|
|
|
|
if( m_suppressAlarms ) {
|
|
|
|
if( !aNewVal ) {
|
|
|
|
m_suppressAlarms = PR_FALSE;
|
|
|
|
SetupAlarmManager();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if( aNewVal ) {
|
|
|
|
m_suppressAlarms = PR_TRUE;
|
|
|
|
CancelAlarmTimer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* AddEvent
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Adds an event
|
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
* icalcalendar - The XPCOM component representing an event
|
|
|
|
* retid - Place to store the returned id
|
|
|
|
*
|
|
|
|
* RETURN
|
|
|
|
* None
|
|
|
|
*/
|
2002-04-04 22:41:14 +00:00
|
|
|
NS_IMETHODIMP oeICalImpl::AddEvent(oeIICalEvent *icalevent,char **retid)
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
2001-12-20 22:16:08 +00:00
|
|
|
printf( "oeICalImpl::AddEvent()\n" );
|
2001-11-07 19:18:46 +00:00
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2003-05-15 14:15:30 +00:00
|
|
|
icalcomponent *vcalendar;
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::AddEvent() failed: Cannot open stream: %s!\n", serveraddr );
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-04 22:41:14 +00:00
|
|
|
((oeICalEventImpl *)icalevent)->GetId( retid );
|
2002-03-01 22:07:45 +00:00
|
|
|
|
2002-04-04 22:41:14 +00:00
|
|
|
if( *retid == nsnull ) {
|
2003-05-15 14:15:30 +00:00
|
|
|
char uidstr[40];
|
|
|
|
GenerateUUID( uidstr );
|
2002-04-04 22:41:14 +00:00
|
|
|
((oeICalEventImpl *)icalevent)->SetId( uidstr );
|
|
|
|
((oeICalEventImpl *)icalevent)->GetId( retid );
|
2002-03-01 22:07:45 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
|
2004-04-06 18:49:40 +00:00
|
|
|
icalfileset_add_first_to_first_component( stream, vcalendar );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-04-06 18:49:40 +00:00
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
2002-04-18 16:32:23 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-05-01 14:11:30 +00:00
|
|
|
printf( "oeICalImpl::AddEvent() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-04-18 16:32:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
icalfileset_free( stream );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
icalevent->AddRef();
|
2004-10-28 15:18:12 +00:00
|
|
|
m_eventlist.AppendElement( icalevent );
|
2002-08-22 14:44:01 +00:00
|
|
|
((oeICalEventImpl *)icalevent)->SetParent( this );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count(&observercount);
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnAddItem( icalevent );
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::AddEvent() : WARNING Call to observer's onAddItem() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetupAlarmManager();
|
2001-11-07 19:18:46 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2001-12-20 22:16:08 +00:00
|
|
|
* ModifyEvent
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION: Updates an event
|
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
* icalcalendar - The XPCOM component representing an event
|
|
|
|
* retid - Place to store the returned id
|
|
|
|
*
|
|
|
|
* RETURN
|
|
|
|
* None
|
|
|
|
*/
|
2002-04-04 22:41:14 +00:00
|
|
|
NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, char **retid)
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
2001-12-20 22:16:08 +00:00
|
|
|
printf( "oeICalImpl::ModifyEvent()\n" );
|
2001-11-07 19:18:46 +00:00
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2001-12-20 22:16:08 +00:00
|
|
|
icalcomponent *vcalendar;
|
2003-08-15 18:08:48 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
//This might be a TODO object. If so then call the appropriate function.
|
|
|
|
nsCOMPtr<oeIICalTodo> icaltodo;
|
|
|
|
rv = icalevent->QueryInterface(NS_GET_IID(oeIICalTodo), (void **)&icaltodo);
|
|
|
|
if( NS_SUCCEEDED( rv ) ) {
|
|
|
|
return ModifyTodo( icaltodo, retid );
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::ModifyEvent() failed: Cannot open stream: %s!\n", serveraddr );
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-05-22 14:01:38 +00:00
|
|
|
icalevent->GetId( retid );
|
2002-04-04 22:41:14 +00:00
|
|
|
if( *retid == nsnull ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::ModifyEvent() - Invalid Id.\n" );
|
|
|
|
#endif
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
icalcomponent *fetchedvcal = icalfileset_fetch( stream, *retid );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-03-01 22:07:45 +00:00
|
|
|
oeICalEventImpl *oldevent=nsnull;
|
2002-04-18 16:32:23 +00:00
|
|
|
if( fetchedvcal ) {
|
|
|
|
icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, *retid );
|
|
|
|
if( fetchedvevent ) {
|
|
|
|
icalcomponent_remove_component( fetchedvcal, fetchedvevent );
|
|
|
|
if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
|
|
|
|
icalfileset_remove_component( stream, fetchedvcal );
|
|
|
|
icalcomponent_free( fetchedvcal );
|
|
|
|
}
|
|
|
|
if( NS_FAILED( rv = NS_NewICalEvent((oeIICalEvent**) &oldevent ))) {
|
|
|
|
nsMemory::Free( *retid );
|
|
|
|
*retid = nsnull;
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
oldevent->ParseIcalComponent( fetchedvevent );
|
|
|
|
icalcomponent_free( fetchedvevent );
|
|
|
|
} else {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::ModifyEvent() - WARNING Event not found.\n" );
|
|
|
|
#endif
|
2002-04-04 22:41:14 +00:00
|
|
|
nsMemory::Free( *retid );
|
|
|
|
*retid = nsnull;
|
2002-03-01 22:07:45 +00:00
|
|
|
icalfileset_free(stream);
|
2002-04-18 16:32:23 +00:00
|
|
|
return NS_OK;
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2002-03-01 22:07:45 +00:00
|
|
|
} else {
|
2002-04-18 16:32:23 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::ModifyEvent() - WARNING Event not found.\n" );
|
|
|
|
#endif
|
2002-04-04 22:41:14 +00:00
|
|
|
nsMemory::Free( *retid );
|
|
|
|
*retid = nsnull;
|
2002-03-01 22:07:45 +00:00
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
2004-02-12 22:42:32 +00:00
|
|
|
//Update Last-Modified
|
|
|
|
icalevent->UpdateLastModified();
|
2003-06-18 15:22:16 +00:00
|
|
|
|
2004-02-12 22:42:32 +00:00
|
|
|
vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
|
2004-04-06 18:49:40 +00:00
|
|
|
icalfileset_add_first_to_first_component( stream, vcalendar );
|
|
|
|
|
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
2002-04-18 16:32:23 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-05-01 14:11:30 +00:00
|
|
|
printf( "oeICalImpl::ModifyEvent() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-04-18 16:32:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
icalfileset_free(stream);
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count(&observercount);
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
|
|
|
rv = observer->OnModifyItem( icalevent, oldevent );
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::ModifyEvent() : WARNING Call to observer's onModifyItem() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oldevent->Release();
|
|
|
|
|
|
|
|
SetupAlarmManager();
|
2001-11-07 19:18:46 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* FetchEvent
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Fetches an event
|
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
* ev - Place to store the XPCOM representation of the fetched event
|
|
|
|
* id - Id of the event to fetch
|
|
|
|
*
|
|
|
|
* RETURN
|
|
|
|
* None
|
|
|
|
*/
|
2002-04-04 22:41:14 +00:00
|
|
|
NS_IMETHODIMP oeICalImpl::FetchEvent( const char *id, oeIICalEvent **ev)
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "oeICalImpl::FetchEvent()\n" );
|
2001-11-07 19:18:46 +00:00
|
|
|
#endif
|
2002-06-17 12:42:24 +00:00
|
|
|
|
|
|
|
if( id == nsnull ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::FetchEvent() - Invalid Id.\n" );
|
|
|
|
#endif
|
|
|
|
*ev = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
*ev = nsnull; //initialize to null
|
|
|
|
|
|
|
|
oeIICalEvent *event;
|
|
|
|
for (PRInt32 i = 0 ; i < m_eventlist.Count(); ++i) {
|
|
|
|
event = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
|
|
|
|
// XXX Evil cast
|
|
|
|
if (event && ((oeICalEventImpl *)event)->matchId(id)) {
|
|
|
|
*ev = event;
|
|
|
|
NS_ADDREF(*ev);
|
|
|
|
break;
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2001-12-20 22:16:08 +00:00
|
|
|
* DeleteEvent
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
2001-12-20 22:16:08 +00:00
|
|
|
* DESCRIPTION: Deletes an event
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS:
|
2001-12-20 22:16:08 +00:00
|
|
|
* id - Id of the event to delete
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* RETURN
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2002-04-04 22:41:14 +00:00
|
|
|
oeICalImpl::DeleteEvent( const char *id )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
2002-04-04 22:41:14 +00:00
|
|
|
printf( "oeICalImpl::DeleteEvent( %s )\n", id );
|
2001-11-07 19:18:46 +00:00
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-03-01 22:07:45 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::DeleteEvent() failed: Cannot open stream: %s!\n", serveraddr );
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-04 22:41:14 +00:00
|
|
|
if( id == nsnull ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::DeleteEvent() - Invalid Id.\n" );
|
|
|
|
#endif
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
icalcomponent *fetchedvcal = icalfileset_fetch( stream, id );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
if( !fetchedvcal ) {
|
2001-12-20 22:16:08 +00:00
|
|
|
icalfileset_free(stream);
|
2002-04-18 16:32:23 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::DeleteEvent() - WARNING Event not found.\n" );
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, id );
|
|
|
|
|
|
|
|
if( !fetchedvevent ) {
|
|
|
|
icalfileset_free(stream);
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::DeleteEvent() - WARNING Event not found.\n" );
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
icalcomponent_remove_component( fetchedvcal, fetchedvevent );
|
|
|
|
icalcomponent_free( fetchedvevent );
|
|
|
|
if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
|
|
|
|
icalfileset_remove_component( stream, fetchedvcal );
|
|
|
|
icalcomponent_free( fetchedvcal );
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-04-18 16:32:23 +00:00
|
|
|
icalfileset_mark( stream ); //Make sure stream is marked as dirty
|
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2002-06-21 17:16:30 +00:00
|
|
|
printf( "oeICalImpl::DeleteEvent() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-04-18 16:32:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
icalfileset_free(stream);
|
|
|
|
|
|
|
|
oeIICalEvent *icalevent;
|
|
|
|
FetchEvent( id , &icalevent );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
m_eventlist.RemoveElement(icalevent);
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count(&observercount);
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnDeleteItem( icalevent );
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::DeleteEvent() : WARNING Call to observer's onDeleteItem() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
icalevent->Release();
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
SetupAlarmManager();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
/**
|
|
|
|
* recurCompareFunc
|
|
|
|
*
|
|
|
|
* helper for GetAllEvents, compares two events by either the next recurrance,
|
|
|
|
* or the previous if no next
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
recurCompareFunc(const void* aElement1, const void* aElement2, void* aData)
|
|
|
|
{
|
|
|
|
oeICalEventImpl* event1 = (oeICalEventImpl *)aElement1;
|
|
|
|
oeICalEventImpl* event2 = (oeICalEventImpl *)aElement2;
|
|
|
|
icaltimetype* now = (icaltimetype *)aData;
|
|
|
|
|
|
|
|
icaltimetype time1 = event1->GetNextRecurrence(*now, nsnull);
|
|
|
|
if (icaltime_is_null_time(time1)) {
|
|
|
|
time1 = event1->GetPreviousOccurrence(*now);
|
|
|
|
}
|
|
|
|
|
|
|
|
icaltimetype time2 = event2->GetNextRecurrence(*now, nsnull);
|
|
|
|
if (icaltime_is_null_time(time2)) {
|
|
|
|
time2 = event2->GetPreviousOccurrence(*now);
|
|
|
|
}
|
|
|
|
return icaltime_compare(time1, time2);
|
|
|
|
}
|
|
|
|
|
2004-10-06 15:20:08 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* GetAllEvents
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Returns a list of all the events in this calendar in an enumerator.
|
|
|
|
* The events are sorted based on the order of their next occurence if they recur in
|
|
|
|
* the future or their last occurence in the past otherwise.
|
|
|
|
* Here's a presentation of the sort criteria using the time axis:
|
|
|
|
* -----(Last occurence of Event1)---(Last occurence of Event2)----(Now)----(Next occurence of Event3)---->
|
|
|
|
* (Note that Event1 and Event2 will not recur in the future.)
|
|
|
|
*/
|
2002-05-22 14:01:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::GetAllEvents()\n" );
|
|
|
|
#endif
|
2002-08-22 14:44:01 +00:00
|
|
|
|
2004-10-06 15:20:08 +00:00
|
|
|
//Create a new enumerator to be returned
|
2004-07-22 20:07:03 +00:00
|
|
|
oeEventEnumerator *eventEnum = new oeEventEnumerator();
|
|
|
|
if (!eventEnum)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-05-22 14:01:38 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
nsVoidArray eventlist;
|
|
|
|
eventlist = m_eventlist;
|
2002-05-22 14:01:38 +00:00
|
|
|
|
2004-10-06 15:20:08 +00:00
|
|
|
//Calculate the present time in milliseconds
|
|
|
|
PRTime nowinms = PR_Now();
|
2002-05-22 14:01:38 +00:00
|
|
|
PRInt64 usecpermsec;
|
|
|
|
LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
|
2004-10-06 15:20:08 +00:00
|
|
|
LL_DIV( nowinms, nowinms, usecpermsec );
|
2002-05-22 14:01:38 +00:00
|
|
|
|
2004-10-06 15:20:08 +00:00
|
|
|
struct icaltimetype now = ConvertFromPrtime( nowinms );
|
|
|
|
struct icaltimetype checkdate = now;
|
|
|
|
//use Now-1 so we ensure we consider Now in the calculation
|
2002-05-22 14:01:38 +00:00
|
|
|
icaltime_adjust( &now, 0, 0, 0, -1 );
|
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
// Sort the eventlist
|
|
|
|
eventlist.Sort(recurCompareFunc, &now);
|
2002-05-22 14:01:38 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
PRUint32 num2;
|
|
|
|
num2 = eventlist.Count();
|
|
|
|
for (PRUint32 j = 0; j < num2; ++j) {
|
|
|
|
eventEnum->AddEvent((oeICalEventImpl *)(eventlist[j]));
|
|
|
|
}
|
2004-10-06 15:20:08 +00:00
|
|
|
|
2004-07-22 20:07:03 +00:00
|
|
|
*resultList = eventEnum;
|
2004-10-06 15:20:08 +00:00
|
|
|
// bump ref count
|
2004-07-22 20:07:03 +00:00
|
|
|
NS_ADDREF(*resultList);
|
2002-08-22 14:44:01 +00:00
|
|
|
return NS_OK;
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-12-06 20:31:20 +00:00
|
|
|
oeICalImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **eventlist ) {
|
2001-11-07 19:18:46 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2001-12-20 22:16:08 +00:00
|
|
|
printf( "oeICalImpl::GetEventsForMonth()\n" );
|
|
|
|
#endif
|
|
|
|
struct icaltimetype checkdate = ConvertFromPrtime( datems );
|
|
|
|
checkdate.day = 1;
|
|
|
|
checkdate.hour = 0;
|
|
|
|
checkdate.minute = 0;
|
|
|
|
checkdate.second = 0;
|
|
|
|
icaltime_adjust( &checkdate, 0, 0 , 0, -1 );
|
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "CHECKDATE: %s\n" , icaltime_as_ctime( checkdate ) );
|
|
|
|
#endif
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime checkdateinms = ConvertToPrtime( checkdate );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
struct icaltimetype checkenddate = ConvertFromPrtime( datems );
|
|
|
|
checkenddate.month++;
|
|
|
|
checkenddate.day = 1;
|
|
|
|
checkenddate.hour = 0;
|
|
|
|
checkenddate.minute = 0;
|
|
|
|
checkenddate.second = 0;
|
|
|
|
checkenddate = icaltime_normalize( checkenddate );
|
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "CHECKENDDATE: %s\n" , icaltime_as_ctime( checkenddate ) );
|
|
|
|
#endif
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime checkenddateinms = ConvertToPrtime( checkenddate );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-12-06 20:31:20 +00:00
|
|
|
return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-12-06 20:31:20 +00:00
|
|
|
oeICalImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **eventlist ) {
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::GetEventsForWeek()\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct icaltimetype checkdate = ConvertFromPrtime( datems );
|
|
|
|
checkdate.hour = 0;
|
|
|
|
checkdate.minute = 0;
|
|
|
|
checkdate.second = 0;
|
|
|
|
icaltime_adjust( &checkdate, 0, 0 , 0, -1 );
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime checkdateinms = ConvertToPrtime( checkdate );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
struct icaltimetype checkenddate = ConvertFromPrtime( datems );
|
|
|
|
checkenddate.hour = 0;
|
|
|
|
checkenddate.minute = 0;
|
|
|
|
checkenddate.second = 0;
|
|
|
|
icaltime_adjust( &checkenddate, 7, 0 , 0, 0 );
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime checkenddateinms = ConvertToPrtime( checkenddate );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-12-06 20:31:20 +00:00
|
|
|
return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-12-06 20:31:20 +00:00
|
|
|
oeICalImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **eventlist ) {
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::GetEventsForDay()\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct icaltimetype checkdate = ConvertFromPrtime( datems );
|
|
|
|
checkdate.hour = 0;
|
|
|
|
checkdate.minute = 0;
|
|
|
|
checkdate.second = 0;
|
|
|
|
icaltime_adjust( &checkdate, 0, 0, 0, -1 );
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime checkdateinms = ConvertToPrtime( checkdate );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
struct icaltimetype checkenddate = ConvertFromPrtime( datems );
|
|
|
|
checkenddate.hour = 0;
|
|
|
|
checkenddate.minute = 0;
|
|
|
|
checkenddate.second = 0;
|
|
|
|
icaltime_adjust( &checkenddate, 1, 0, 0, 0 );
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime checkenddateinms = ConvertToPrtime( checkenddate );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
2002-12-06 20:31:20 +00:00
|
|
|
return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
|
2002-10-22 17:33:05 +00:00
|
|
|
}
|
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
|
|
|
|
class eventOccurence {
|
|
|
|
public:
|
|
|
|
PRTime start;
|
|
|
|
nsCOMPtr<oeIICalEvent> event;
|
|
|
|
bool isbeginning;
|
|
|
|
bool isallday;
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
occurCompareFunc(const void* aElement1, const void* aElement2, void* aData)
|
|
|
|
{
|
|
|
|
eventOccurence* occur1 = (eventOccurence *)aElement1;
|
|
|
|
eventOccurence* occur2 = (eventOccurence *)aElement2;
|
|
|
|
|
|
|
|
return (occur1->start - occur2->start);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-22 14:01:38 +00:00
|
|
|
NS_IMETHODIMP
|
2004-10-28 15:18:12 +00:00
|
|
|
oeICalImpl::GetEventsForRange(PRTime aBeginDate, PRTime aEndDate, nsISimpleEnumerator **aResult)
|
|
|
|
{
|
2002-05-22 14:01:38 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "oeICalImpl::GetEventsForRange()\n" );
|
|
|
|
#endif
|
|
|
|
|
2004-07-22 20:07:03 +00:00
|
|
|
oeEventEnumerator *eventEnum = new oeEventEnumerator();
|
|
|
|
if (!eventEnum)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-10-28 15:18:12 +00:00
|
|
|
*aResult = eventEnum;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
|
|
|
|
struct icaltimetype checkdate = ConvertFromPrtime(aBeginDate);
|
|
|
|
icaltime_adjust(&checkdate, 0, 0, 0, -1);
|
|
|
|
struct icaltimetype checkenddate = ConvertFromPrtime(aEndDate);
|
|
|
|
|
|
|
|
nsVoidArray occurList;
|
|
|
|
oeIICalEvent *tmpevent;
|
2004-10-28 20:37:21 +00:00
|
|
|
PRInt32 i;
|
|
|
|
for (i = 0 ; i < m_eventlist.Count(); ++i) {
|
2004-10-28 15:18:12 +00:00
|
|
|
tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
|
|
|
|
struct icaltimetype check = checkdate;
|
|
|
|
bool isbeginning;
|
|
|
|
check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
|
|
|
|
while (!icaltime_is_null_time(check) && (icaltime_compare(check, checkenddate) < 0)) {
|
|
|
|
eventOccurence *occur = new eventOccurence();
|
|
|
|
if (!occur) {
|
|
|
|
// I whish i knew a better way to do this cleanup stuff..
|
2004-10-28 20:41:59 +00:00
|
|
|
for (PRInt32 j = 0 ; j < occurList.Count(); ++j) {
|
|
|
|
eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[j]);
|
2004-10-28 15:18:12 +00:00
|
|
|
delete occur;
|
2002-05-22 14:01:38 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-05-22 14:01:38 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
occur->start = ConvertToPrtime(check);
|
|
|
|
occur->event = tmpevent;
|
|
|
|
occur->isbeginning = isbeginning;
|
|
|
|
occur->isallday = check.is_date;
|
|
|
|
occurList.AppendElement(occur);
|
|
|
|
check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
|
2002-05-22 14:01:38 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
}
|
|
|
|
occurList.Sort(occurCompareFunc, nsnull);
|
|
|
|
|
2004-10-28 20:37:21 +00:00
|
|
|
for (i = 0 ; i < occurList.Count(); ++i) {
|
2004-10-28 15:18:12 +00:00
|
|
|
eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[i]);
|
|
|
|
tmpevent = NS_STATIC_CAST(oeIICalEvent*, occur->event);
|
|
|
|
((oeICalEventImpl *)tmpevent)->
|
|
|
|
ChopAndAddEventToEnum(ConvertFromPrtime(occur->start), aResult,
|
|
|
|
occur->isallday, occur->isbeginning );
|
|
|
|
delete occur;
|
|
|
|
}
|
2002-05-22 14:01:38 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-05-08 21:13:44 +00:00
|
|
|
|
2002-05-22 14:01:38 +00:00
|
|
|
NS_IMETHODIMP
|
2004-10-28 15:18:12 +00:00
|
|
|
oeICalImpl::GetFirstEventsForRange(PRTime aBeginDate, PRTime aEndDate, nsISimpleEnumerator **aResult)
|
|
|
|
{
|
2002-08-27 19:51:23 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-05-22 14:01:38 +00:00
|
|
|
printf( "oeICalImpl::GetFirstEventsForRange()\n" );
|
|
|
|
#endif
|
2004-07-22 20:07:03 +00:00
|
|
|
oeEventEnumerator *eventEnum = new oeEventEnumerator();
|
|
|
|
if (!eventEnum)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-10-28 15:18:12 +00:00
|
|
|
*aResult = eventEnum;
|
|
|
|
NS_ADDREF(*aResult);
|
2002-05-22 14:01:38 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> eventArray;
|
|
|
|
NS_NewISupportsArray(getter_AddRefs(eventArray));
|
|
|
|
if (eventArray == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
oeIICalEvent *event;
|
2004-10-28 20:41:59 +00:00
|
|
|
PRInt32 i;
|
|
|
|
for (i = 0 ; i < m_eventlist.Count(); ++i) {
|
2004-10-28 15:18:12 +00:00
|
|
|
event = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
|
|
|
|
eventArray->AppendElement(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct icaltimetype checkdate = ConvertFromPrtime(aBeginDate);
|
|
|
|
icaltime_adjust(&checkdate, 0, 0, 0, -1);
|
|
|
|
|
|
|
|
struct icaltimetype checkenddate = ConvertFromPrtime(aEndDate);
|
|
|
|
|
|
|
|
nsVoidArray occurList;
|
|
|
|
oeIICalEvent *tmpevent;
|
2004-10-28 20:41:59 +00:00
|
|
|
for (i = 0 ; i < m_eventlist.Count(); ++i) {
|
2004-10-28 15:18:12 +00:00
|
|
|
tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
|
|
|
|
struct icaltimetype check = checkdate;
|
|
|
|
bool isbeginning;
|
|
|
|
check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
|
|
|
|
if (!icaltime_is_null_time(check) && (icaltime_compare(check, checkenddate) < 0)) {
|
|
|
|
eventOccurence *occur = new eventOccurence();
|
|
|
|
if (!occur) {
|
|
|
|
// I whish i knew a better way to do this cleanup stuff..
|
|
|
|
for (PRInt32 j = 0 ; i < occurList.Count(); ++j) {
|
|
|
|
eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[j]);
|
|
|
|
delete occur;
|
2002-05-22 14:01:38 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-05-22 14:01:38 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
occur->start = ConvertToPrtime(check);
|
|
|
|
occur->event = tmpevent;
|
|
|
|
occur->isbeginning = isbeginning;
|
|
|
|
occur->isallday = check.is_date;
|
|
|
|
occurList.AppendElement(occur);
|
|
|
|
check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
|
2002-05-22 14:01:38 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
}
|
|
|
|
occurList.Sort(occurCompareFunc, nsnull);
|
|
|
|
|
2004-10-28 20:41:59 +00:00
|
|
|
for (i = 0 ; i < occurList.Count(); ++i) {
|
2004-10-28 15:18:12 +00:00
|
|
|
eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[i]);
|
|
|
|
tmpevent = NS_STATIC_CAST(oeIICalEvent*, occur->event);
|
|
|
|
((oeICalEventImpl *)tmpevent)->
|
|
|
|
ChopAndAddEventToEnum(ConvertFromPrtime(occur->start), aResult,
|
|
|
|
occur->isallday, occur->isbeginning );
|
|
|
|
delete occur;
|
|
|
|
}
|
2002-05-22 14:01:38 +00:00
|
|
|
|
2002-08-22 14:44:01 +00:00
|
|
|
return NS_OK;
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
|
2002-04-17 22:03:27 +00:00
|
|
|
icaltimetype oeICalImpl::GetNextEvent( icaltimetype starting ) {
|
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "oeICalImpl::GetNextEvent()\n" );
|
|
|
|
#endif
|
|
|
|
icaltimetype soonest = icaltime_null_time();
|
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
oeIICalEvent *tmpevent;
|
|
|
|
for (PRInt32 i = 0 ; i < m_eventlist.Count(); ++i) {
|
|
|
|
tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
|
|
|
|
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( starting, nsnull );
|
|
|
|
next.is_date = false;
|
|
|
|
if( !icaltime_is_null_time( next ) && ( icaltime_is_null_time( soonest ) || (icaltime_compare( soonest, next ) > 0) ) ) {
|
|
|
|
soonest = next;
|
2002-04-17 22:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return soonest;
|
|
|
|
}
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
NS_IMETHODIMP
|
2002-12-06 20:31:20 +00:00
|
|
|
oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **eventlist ) {
|
2001-12-20 22:16:08 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-04-17 22:03:27 +00:00
|
|
|
printf( "oeICalImpl::GetNextNEvents( %d )\n", maxcount );
|
2001-12-20 22:16:08 +00:00
|
|
|
#endif
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2004-07-22 20:07:03 +00:00
|
|
|
oeEventEnumerator *eventEnum = new oeEventEnumerator();
|
|
|
|
if (!eventEnum)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
*eventlist = eventEnum;
|
|
|
|
NS_ADDREF(*eventlist);
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
struct icaltimetype checkdate = ConvertFromPrtime( datems );
|
|
|
|
icaltime_adjust( &checkdate, 0, 0, 0, -1 );
|
|
|
|
|
2002-05-08 20:43:05 +00:00
|
|
|
int count = 0;
|
|
|
|
icaltimetype nextcheckdate;
|
|
|
|
do {
|
|
|
|
nextcheckdate = GetNextEvent( checkdate );
|
|
|
|
if( !icaltime_is_null_time( nextcheckdate )) {
|
2004-10-28 15:18:12 +00:00
|
|
|
oeIICalEvent *tmpevent;
|
|
|
|
for (PRInt32 i = 0 ; (count < maxcount) && (i < m_eventlist.Count()); ++i) {
|
|
|
|
bool isbeginning,isallday;
|
|
|
|
tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
|
|
|
|
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
|
|
|
|
isallday = next.is_date;
|
|
|
|
next.is_date = false;
|
|
|
|
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
|
|
|
((oeICalEventImpl *)tmpevent)->ChopAndAddEventToEnum( nextcheckdate, eventlist, isallday, isbeginning );
|
|
|
|
count++;
|
2002-05-08 20:43:05 +00:00
|
|
|
}
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2002-05-08 20:43:05 +00:00
|
|
|
checkdate = nextcheckdate;
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2002-05-08 20:43:05 +00:00
|
|
|
} while ( !icaltime_is_null_time( nextcheckdate ) && (count < maxcount) );
|
2001-12-20 22:16:08 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-02-26 18:30:04 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
int gObservercount=0;
|
|
|
|
#endif
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::AddObserver(oeIICalObserver *observer)
|
|
|
|
{
|
2002-10-22 17:33:05 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
2003-02-26 18:30:04 +00:00
|
|
|
gObservercount++;
|
|
|
|
printf( "oeICalImpl::AddObserver(): %d\n", gObservercount );
|
2001-12-20 22:16:08 +00:00
|
|
|
#endif
|
|
|
|
if( observer ) {
|
|
|
|
observer->AddRef();
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count( &observercount );
|
|
|
|
m_observerlist->InsertElementAt( observer, observercount );
|
2002-08-22 14:44:01 +00:00
|
|
|
// observer->OnLoad();
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-04-17 22:03:27 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::RemoveObserver(oeIICalObserver *observer)
|
|
|
|
{
|
2002-10-22 17:33:05 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
2003-02-26 18:30:04 +00:00
|
|
|
gObservercount--;
|
|
|
|
printf( "oeICalImpl::RemoveObserver(): %d\n", gObservercount );
|
2002-04-17 22:03:27 +00:00
|
|
|
#endif
|
|
|
|
if( observer ) {
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>tmpobserver;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(tmpobserver));
|
|
|
|
if( observer == tmpobserver ) {
|
|
|
|
m_observerlist->RemoveElementAt( i );
|
|
|
|
observer->Release();
|
2002-04-17 22:03:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-06-27 16:51:51 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::AddTodoObserver(oeIICalTodoObserver *observer)
|
|
|
|
{
|
2002-10-22 17:33:05 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
2002-06-27 16:51:51 +00:00
|
|
|
printf( "oeICalImpl::AddTodoObserver()\n" );
|
|
|
|
#endif
|
|
|
|
if( observer ) {
|
|
|
|
observer->AddRef();
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_todoobserverlist->Count( &observercount );
|
|
|
|
m_todoobserverlist->InsertElementAt( observer, observercount );
|
2002-08-22 14:44:01 +00:00
|
|
|
// observer->OnLoad();
|
2002-06-27 16:51:51 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::RemoveTodoObserver(oeIICalTodoObserver *observer)
|
|
|
|
{
|
2002-10-22 17:33:05 +00:00
|
|
|
#ifdef ICAL_DEBUG_ALL
|
2002-06-27 16:51:51 +00:00
|
|
|
printf( "oeICalImpl::RemoveTodoObserver()\n" );
|
|
|
|
#endif
|
|
|
|
if( observer ) {
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_todoobserverlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
2003-10-08 04:09:12 +00:00
|
|
|
nsCOMPtr<oeIICalTodoObserver>tmpobserver;
|
2003-02-14 18:05:46 +00:00
|
|
|
m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(tmpobserver));
|
|
|
|
if( observer == tmpobserver ) {
|
|
|
|
m_todoobserverlist->RemoveElementAt( i );
|
|
|
|
observer->Release();
|
2002-06-27 16:51:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
void AlarmTimerCallback(nsITimer *aTimer, void *aClosure)
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "AlarmTimerCallback\n" );
|
|
|
|
#endif
|
|
|
|
oeICalImpl *icallib = (oeICalImpl *)aClosure;
|
|
|
|
icallib->SetupAlarmManager();
|
|
|
|
}
|
|
|
|
|
2003-06-18 20:11:58 +00:00
|
|
|
NS_IMETHODIMP UpdateCalendarIcon( PRBool hasAlarm )
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator =
|
|
|
|
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
|
|
|
static PRBool lastTimeHadAlarm = false;
|
|
|
|
|
|
|
|
if( lastTimeHadAlarm == hasAlarm )
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
lastTimeHadAlarm = hasAlarm;
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
|
|
|
|
|
|
// why use DOM window enumerator instead of XUL window...????
|
|
|
|
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator))))
|
|
|
|
{
|
|
|
|
PRBool more;
|
|
|
|
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
|
|
|
|
while(more)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> nextWindow = nsnull;
|
|
|
|
windowEnumerator->GetNext(getter_AddRefs(nextWindow));
|
|
|
|
nsCOMPtr<nsIDOMWindowInternal> domWindow(do_QueryInterface(nextWindow));
|
|
|
|
|
2004-06-18 21:54:48 +00:00
|
|
|
if( domWindow ) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
|
|
domWindow->GetDocument(getter_AddRefs(domDocument));
|
|
|
|
|
|
|
|
if(domDocument)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> domElement;
|
|
|
|
domDocument->GetElementById(NS_LITERAL_STRING("mini-cal"), getter_AddRefs(domElement));
|
|
|
|
|
|
|
|
if (domElement) {
|
|
|
|
if ( hasAlarm ) {
|
|
|
|
domElement->SetAttribute(NS_LITERAL_STRING("BiffState"), NS_LITERAL_STRING("Alarm"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
domElement->RemoveAttribute(NS_LITERAL_STRING("BiffState"));
|
|
|
|
}
|
2003-06-18 20:11:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
void oeICalImpl::SetupAlarmManager() {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::SetupAlarmManager()\n" );
|
|
|
|
#endif
|
2004-09-01 20:11:06 +00:00
|
|
|
if( m_suppressAlarms )
|
|
|
|
return;
|
2002-03-01 22:07:45 +00:00
|
|
|
if( m_batchMode )
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::SetupAlarmManager() - defering alarms while in batch mode\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-08-01 18:46:23 +00:00
|
|
|
static icaltimetype lastcheck = icaltime_null_time();
|
|
|
|
|
2003-06-18 20:11:58 +00:00
|
|
|
UpdateCalendarIcon( false );
|
|
|
|
|
2002-01-07 18:23:31 +00:00
|
|
|
PRTime todayinms = PR_Now();
|
|
|
|
PRInt64 usecpermsec;
|
|
|
|
LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
|
|
|
|
LL_DIV( todayinms, todayinms, usecpermsec );
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
icaltimetype now = ConvertFromPrtime( todayinms );
|
|
|
|
|
|
|
|
icaltimetype nextalarm = icaltime_null_time();
|
2003-08-01 18:46:23 +00:00
|
|
|
|
|
|
|
int processmissed = -1; // -1 means the value has not been read from the preferences. 0 or 1 are valid values.
|
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
oeICalEventImpl *event;
|
|
|
|
for (PRInt32 i = 0 ; i < m_eventlist.Count(); ++i) {
|
|
|
|
event = NS_STATIC_CAST(oeICalEventImpl*, m_eventlist[i]);
|
|
|
|
icaltimetype begin=icaltime_null_time();
|
|
|
|
begin.year = 1970; begin.month=1; begin.day=1;
|
|
|
|
icaltimetype alarmtime = begin;
|
|
|
|
do {
|
|
|
|
alarmtime = event->GetNextAlarmTime( alarmtime );
|
|
|
|
if( icaltime_is_null_time( alarmtime ) )
|
|
|
|
break;
|
|
|
|
if( icaltime_compare( alarmtime, now ) <= 0 ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "ALARM WENT OFF: %s\n", icaltime_as_ical_string( alarmtime ) );
|
|
|
|
#endif
|
2003-08-01 18:46:23 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
nsresult rv;
|
|
|
|
if( processmissed == -1 ) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
|
|
|
if ( NS_SUCCEEDED(rv) && prefBranch ) {
|
|
|
|
rv = prefBranch->GetBoolPref("calendar.alarms.showmissed", &processmissed);
|
|
|
|
} else {
|
|
|
|
processmissed = true; //if anything goes wrong just consider the default setting
|
2003-08-01 18:46:23 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
}
|
2003-08-01 18:46:23 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
if( !processmissed ) {
|
|
|
|
time_t timediff = icaltime_as_timet( now ) - icaltime_as_timet( alarmtime );
|
|
|
|
if( timediff > 30 ) //if alarmtime is older than 30 seconds it won't be processed.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateCalendarIcon( true );
|
2003-06-18 20:11:58 +00:00
|
|
|
|
2004-10-28 15:18:12 +00:00
|
|
|
oeIICalEventDisplay* eventDisplay;
|
|
|
|
rv = NS_NewICalEventDisplay( event, &eventDisplay );
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetupAlarmManager() : WARNING Cannot create oeIICalEventDisplay instance: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
icaltimetype eventtime = event->CalculateEventTime( alarmtime );
|
|
|
|
eventDisplay->SetDisplayDate( ConvertToPrtime( eventtime ) );
|
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
|
|
|
rv = observer->OnAlarm( eventDisplay );
|
2002-09-06 15:23:00 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
2004-10-28 15:18:12 +00:00
|
|
|
printf( "oeICalImpl::SetupAlarmManager() : WARNING Call to observer's onAlarm() unsuccessful: %x\n", rv );
|
2002-09-06 15:23:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2004-10-28 15:18:12 +00:00
|
|
|
NS_RELEASE( eventDisplay );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if( icaltime_is_null_time( nextalarm ) )
|
|
|
|
nextalarm = alarmtime;
|
|
|
|
else if( icaltime_compare( nextalarm, alarmtime ) > 0 )
|
|
|
|
nextalarm = alarmtime;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ( 1 );
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2003-08-01 18:46:23 +00:00
|
|
|
|
2003-08-15 18:08:48 +00:00
|
|
|
TodoList *tmptodolistptr = &m_todolist;
|
|
|
|
while( tmptodolistptr ) {
|
|
|
|
oeIICalTodo *todo = tmptodolistptr->todo;
|
|
|
|
if( todo ) {
|
|
|
|
oeICalEventImpl *event = ((oeICalTodoImpl *)todo)->GetBaseEvent();
|
|
|
|
icaltimetype begin=icaltime_null_time();
|
|
|
|
begin.year = 1970; begin.month=1; begin.day=1;
|
|
|
|
icaltimetype alarmtime = begin;
|
|
|
|
do {
|
|
|
|
alarmtime = event->GetNextAlarmTime( alarmtime );
|
|
|
|
if( icaltime_is_null_time( alarmtime ) )
|
|
|
|
break;
|
|
|
|
if( icaltime_compare( alarmtime, now ) <= 0 ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "ALARM WENT OFF: %s\n", icaltime_as_ical_string( alarmtime ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
if( processmissed == -1 ) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
|
|
|
if ( NS_SUCCEEDED(rv) && prefBranch ) {
|
|
|
|
rv = prefBranch->GetBoolPref("calendar.alarms.showmissed", &processmissed);
|
|
|
|
} else {
|
|
|
|
processmissed = true; //if anything goes wrong just consider the default setting
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !processmissed ) {
|
|
|
|
time_t timediff = icaltime_as_timet( now ) - icaltime_as_timet( alarmtime );
|
|
|
|
if( timediff > 30 ) //if alarmtime is older than 30 seconds it won't be processed.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateCalendarIcon( true );
|
|
|
|
|
|
|
|
oeIICalEventDisplay* eventDisplay;
|
|
|
|
rv = NS_NewICalEventDisplay( todo, &eventDisplay );
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetupAlarmManager() : WARNING Cannot create oeIICalEventDisplay instance: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
icaltimetype eventtime = event->CalculateEventTime( alarmtime );
|
|
|
|
eventDisplay->SetDisplayDate( ConvertToPrtime( eventtime ) );
|
|
|
|
PRUint32 observercount;
|
|
|
|
//Here we should be using the todo observer list but nothing implements
|
|
|
|
//alarm handling for todos yet so we'll just use the one for events
|
|
|
|
m_observerlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
|
|
|
rv = observer->OnAlarm( eventDisplay );
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::SetupAlarmManager() : WARNING Call to observer's onAlarm() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
NS_RELEASE( eventDisplay );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if( icaltime_is_null_time( nextalarm ) )
|
|
|
|
nextalarm = alarmtime;
|
|
|
|
else if( icaltime_compare( nextalarm, alarmtime ) > 0 )
|
|
|
|
nextalarm = alarmtime;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ( 1 );
|
|
|
|
}
|
|
|
|
tmptodolistptr = tmptodolistptr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-01 18:46:23 +00:00
|
|
|
lastcheck = now;
|
|
|
|
|
2004-09-01 20:11:06 +00:00
|
|
|
CancelAlarmTimer(); //cancel the current alarm timer if any
|
|
|
|
|
2001-12-20 22:16:08 +00:00
|
|
|
if( !icaltime_is_null_time( nextalarm ) ) {
|
2002-09-06 15:23:00 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
2002-07-10 14:03:53 +00:00
|
|
|
printf( "NEXT ALARM IS: %s\n", icaltime_as_ical_string( nextalarm ) );
|
2002-09-06 15:23:00 +00:00
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
time_t timediff = icaltime_as_timet( nextalarm ) - icaltime_as_timet( now );
|
2002-03-22 23:04:40 +00:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsITimer> alarmtimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
|
|
|
alarmtimer->QueryInterface(NS_GET_IID(nsITimer), (void **)&m_alarmtimer);
|
|
|
|
if( NS_FAILED( rv ) )
|
|
|
|
m_alarmtimer = nsnull;
|
|
|
|
else
|
2002-09-09 15:29:16 +00:00
|
|
|
#ifdef NS_INIT_REFCNT //A temporary way of keeping backward compatibility with Mozilla 1.0 source compile
|
2002-06-11 20:47:04 +00:00
|
|
|
m_alarmtimer->Init( AlarmTimerCallback, this, timediff*1000, PR_TRUE, NS_TYPE_ONE_SHOT );
|
2002-09-09 15:29:16 +00:00
|
|
|
#else
|
|
|
|
m_alarmtimer->InitWithFuncCallback( AlarmTimerCallback, this, timediff*1000, nsITimer::TYPE_ONE_SHOT );
|
|
|
|
#endif
|
2001-12-20 22:16:08 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
2002-06-21 17:16:30 +00:00
|
|
|
|
2004-09-01 20:11:06 +00:00
|
|
|
void oeICalImpl::CancelAlarmTimer() {
|
|
|
|
if( m_alarmtimer ) {
|
|
|
|
PRUint32 delay = 0;
|
|
|
|
#ifdef NS_INIT_REFCNT //A temporary way of keeping backward compatibility with Mozilla 1.0 source compile
|
|
|
|
delay = m_alarmtimer->GetDelay();
|
|
|
|
#else
|
|
|
|
m_alarmtimer->GetDelay( &delay );
|
|
|
|
#endif
|
|
|
|
if ( delay != 0 )
|
|
|
|
m_alarmtimer->Cancel();
|
|
|
|
m_alarmtimer->Release();
|
|
|
|
m_alarmtimer = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-21 17:16:30 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* AddTodo
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Adds a TODO component
|
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
* icaltodo - The XPCOM component representing a TODO
|
|
|
|
* retid - Place to store the returned id
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP oeICalImpl::AddTodo(oeIICalTodo *icaltodo,char **retid)
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::AddTodo()\n" );
|
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2003-05-15 14:15:30 +00:00
|
|
|
icalcomponent *vcalendar;
|
2002-06-21 17:16:30 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-06-21 17:16:30 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::AddTodo() failed: Cannot open stream: %s!\n", serveraddr );
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
((oeICalTodoImpl *)icaltodo)->GetId( retid );
|
|
|
|
|
|
|
|
if( *retid == nsnull ) {
|
2003-05-15 14:15:30 +00:00
|
|
|
char uidstr[40];
|
|
|
|
GenerateUUID( uidstr );
|
2002-06-21 17:16:30 +00:00
|
|
|
|
|
|
|
((oeICalTodoImpl *)icaltodo)->SetId( uidstr );
|
|
|
|
((oeICalTodoImpl *)icaltodo)->GetId( retid );
|
|
|
|
}
|
|
|
|
|
|
|
|
vcalendar = ((oeICalTodoImpl *)icaltodo)->AsIcalComponent();
|
|
|
|
|
2004-04-06 18:49:40 +00:00
|
|
|
icalfileset_add_first_to_first_component( stream, vcalendar );
|
2002-06-21 17:16:30 +00:00
|
|
|
|
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::AddTodo() : WARNING icalfileset_commit() unsuccessful\n" );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
icalfileset_free( stream );
|
|
|
|
|
|
|
|
icaltodo->AddRef();
|
|
|
|
m_todolist.Add( icaltodo );
|
2002-08-22 14:44:01 +00:00
|
|
|
((oeICalTodoImpl *)icaltodo)->SetParent( this );
|
2002-06-21 17:16:30 +00:00
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_todoobserverlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalTodoObserver>observer;
|
|
|
|
m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnAddItem( icaltodo );
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::AddTodo() : WARNING Call to observer's onAddItem() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-21 17:16:30 +00:00
|
|
|
}
|
|
|
|
|
2003-08-15 18:08:48 +00:00
|
|
|
SetupAlarmManager();
|
2002-06-21 17:16:30 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::DeleteTodo( const char *id )
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::DeleteTodo( %s )\n", id );
|
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2002-06-21 17:16:30 +00:00
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-06-21 17:16:30 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::DeleteTodo() failed: Cannot open stream: %s!\n", serveraddr );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( id == nsnull ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::DeleteTodo() - Invalid Id.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
icalcomponent *fetchedvcal = icalfileset_fetch( stream, id );
|
|
|
|
|
|
|
|
if( !fetchedvcal ) {
|
|
|
|
icalfileset_free(stream);
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::DeleteTodo() - WARNING Event not found.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, id );
|
|
|
|
|
|
|
|
if( !fetchedvevent ) {
|
|
|
|
icalfileset_free(stream);
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::DeleteTodo() - WARNING Event not found.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
icalcomponent_remove_component( fetchedvcal, fetchedvevent );
|
|
|
|
icalcomponent_free( fetchedvevent );
|
|
|
|
if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
|
|
|
|
icalfileset_remove_component( stream, fetchedvcal );
|
|
|
|
icalcomponent_free( fetchedvcal );
|
|
|
|
}
|
|
|
|
|
|
|
|
icalfileset_mark( stream ); //Make sure stream is marked as dirty
|
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::DeleteTodo() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
icalfileset_free(stream);
|
|
|
|
|
|
|
|
oeIICalTodo *icalevent;
|
|
|
|
FetchTodo( id , &icalevent );
|
|
|
|
|
|
|
|
m_todolist.Remove( id );
|
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_todoobserverlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalTodoObserver>observer;
|
|
|
|
m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnDeleteItem( icalevent );
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::DeleteTodo() : WARNING Call to observer's onDeleteItem() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-21 17:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
icalevent->Release();
|
|
|
|
|
2003-08-15 18:08:48 +00:00
|
|
|
SetupAlarmManager();
|
2002-06-21 17:16:30 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalImpl::FetchTodo( const char *id, oeIICalTodo **ev)
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "oeICalImpl::FetchTodo()\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( id == nsnull ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::FetchTodo() - Invalid Id.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
*ev = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
oeIICalTodo* event = m_todolist.GetTodoById( id );
|
|
|
|
if( event != nsnull ) {
|
|
|
|
event->AddRef();
|
|
|
|
}
|
|
|
|
*ev = event;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalImpl::ModifyTodo(oeIICalTodo *icalevent, char **retid)
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::ModifyTodo()\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
2002-07-10 14:03:53 +00:00
|
|
|
icalset *stream;
|
2002-06-21 17:16:30 +00:00
|
|
|
icalcomponent *vcalendar;
|
|
|
|
|
2004-11-08 18:23:03 +00:00
|
|
|
stream = icalfileset_new(m_serveraddr.get());
|
2002-06-21 17:16:30 +00:00
|
|
|
if ( !stream ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::ModifyTodo() failed: Cannot open stream: %s!\n", serveraddr );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
icalevent->GetId( retid );
|
|
|
|
if( *retid == nsnull ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::ModifyTodo() - Invalid Id.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
icalcomponent *fetchedvcal = icalfileset_fetch( stream, *retid );
|
|
|
|
|
|
|
|
oeICalTodoImpl *oldevent=nsnull;
|
|
|
|
if( fetchedvcal ) {
|
|
|
|
icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, *retid );
|
|
|
|
if( fetchedvevent ) {
|
|
|
|
icalcomponent_remove_component( fetchedvcal, fetchedvevent );
|
|
|
|
if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
|
|
|
|
icalfileset_remove_component( stream, fetchedvcal );
|
|
|
|
icalcomponent_free( fetchedvcal );
|
|
|
|
}
|
|
|
|
nsresult rv;
|
|
|
|
if( NS_FAILED( rv = NS_NewICalTodo((oeIICalTodo**) &oldevent ))) {
|
|
|
|
nsMemory::Free( *retid );
|
|
|
|
*retid = nsnull;
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
oldevent->ParseIcalComponent( fetchedvevent );
|
|
|
|
icalcomponent_free( fetchedvevent );
|
|
|
|
} else {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::ModifyTodo() - WARNING Event not found.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
nsMemory::Free( *retid );
|
|
|
|
*retid = nsnull;
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::ModifyTodo() - WARNING Event not found.\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
nsMemory::Free( *retid );
|
|
|
|
*retid = nsnull;
|
|
|
|
icalfileset_free(stream);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-02-12 22:42:32 +00:00
|
|
|
//Update Last-Modified
|
|
|
|
icalevent->UpdateLastModified();
|
|
|
|
|
2002-06-21 17:16:30 +00:00
|
|
|
vcalendar = ((oeICalTodoImpl *)icalevent)->AsIcalComponent();
|
2004-04-06 18:49:40 +00:00
|
|
|
|
|
|
|
icalfileset_add_first_to_first_component( stream, vcalendar );
|
|
|
|
|
2002-06-21 17:16:30 +00:00
|
|
|
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
2003-08-15 18:08:48 +00:00
|
|
|
printf( "oeICalImpl::ModifyTodo() : WARNING icalfileset_commit() unsuccessful\n" );
|
2002-06-21 17:16:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
icalfileset_free(stream);
|
|
|
|
|
2003-02-14 18:05:46 +00:00
|
|
|
PRUint32 observercount;
|
|
|
|
m_todoobserverlist->Count( &observercount );
|
|
|
|
for( unsigned int i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalTodoObserver>observer;
|
|
|
|
m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
|
2002-06-27 16:51:51 +00:00
|
|
|
nsresult rv;
|
2003-02-14 18:05:46 +00:00
|
|
|
rv = observer->OnModifyItem( icalevent, oldevent );
|
2002-06-27 16:51:51 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::ModifyTodo() : WARNING Call to observer's onModifyItem() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-21 17:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oldevent->Release();
|
|
|
|
|
2003-08-15 18:08:48 +00:00
|
|
|
SetupAlarmManager();
|
2002-06-21 17:16:30 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
oeICalImpl::GetAllTodos(nsISimpleEnumerator **resultList )
|
|
|
|
{
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::GetAllTodos()\n" );
|
|
|
|
#endif
|
2002-08-22 14:44:01 +00:00
|
|
|
|
2004-07-26 13:50:22 +00:00
|
|
|
oeEventEnumerator *todoEnum = new oeEventEnumerator();
|
|
|
|
if (!todoEnum)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
*resultList = todoEnum;
|
|
|
|
NS_ADDREF(*resultList);
|
2002-06-25 13:50:39 +00:00
|
|
|
|
|
|
|
TodoList *tmplistptr = &m_todolist;
|
|
|
|
while( tmplistptr ) {
|
|
|
|
if( tmplistptr->todo ) {
|
|
|
|
if( SatisfiesFilter( tmplistptr->todo ) )
|
|
|
|
todoEnum->AddEvent( tmplistptr->todo );
|
|
|
|
}
|
|
|
|
tmplistptr = tmplistptr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
// bump ref count
|
2002-08-22 14:44:01 +00:00
|
|
|
// return todoEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)resultList);
|
|
|
|
return NS_OK;
|
2002-06-25 13:50:39 +00:00
|
|
|
}
|
|
|
|
|
2003-06-04 20:42:44 +00:00
|
|
|
NS_IMETHODIMP oeICalImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
|
|
|
|
|
2003-06-26 18:24:44 +00:00
|
|
|
if( severity >= oeIICalError::CAL_PROBLEM ) {
|
2003-06-04 20:42:44 +00:00
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::ReportError(%d,%x) : %s\n", severity, errorid, errorstring );
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
#ifdef ICAL_DEBUG_ALL
|
|
|
|
printf( "oeICalImpl::ReportError(%d,%x) : %s\n", severity, errorid, errorstring );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
PRUint32 observercount;
|
|
|
|
m_observerlist->Count(&observercount);
|
|
|
|
for( i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalObserver>observer;
|
|
|
|
m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
|
|
|
|
nsresult rv;
|
|
|
|
rv = observer->OnError( severity, errorid, errorstring );
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::ReportError() : WARNING Call to observer's onError() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
m_todoobserverlist->Count(&observercount);
|
|
|
|
for( i=0; i<observercount; i++ ) {
|
|
|
|
nsCOMPtr<oeIICalTodoObserver>observer;
|
|
|
|
m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
|
|
|
|
nsresult rv;
|
|
|
|
rv = observer->OnError( severity, errorid, errorstring );
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
printf( "oeICalImpl::ReportError() : WARNING Call to observer's onError() unsuccessful: %x\n", rv );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
/*************************************************************************************************************/
|
|
|
|
/*************************************************************************************************************/
|
|
|
|
/*************************************************************************************************************/
|
|
|
|
/* Filter stuff here */
|
|
|
|
/*************************************************************************************************************/
|
|
|
|
/*************************************************************************************************************/
|
|
|
|
|
|
|
|
bool oeICalImpl::SatisfiesFilter( oeIICalTodo *comp )
|
|
|
|
{
|
|
|
|
bool result=false;
|
|
|
|
if( m_filter && m_filter->m_completed ) {
|
|
|
|
if( icaltime_is_null_time( m_filter->m_completed->m_datetime ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
oeDateTimeImpl *completed;
|
|
|
|
nsresult rv;
|
|
|
|
rv = comp->GetCompleted( (oeIDateTime **)&completed );
|
|
|
|
if( NS_FAILED( rv ) ) {
|
|
|
|
#ifdef ICAL_DEBUG
|
|
|
|
printf( "oeICalImpl::SatisfiesFilter() : WARNING GetCompleted() unsuccessful\n" );
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if( icaltime_is_null_time( completed->m_datetime ) )
|
|
|
|
result = true;
|
|
|
|
if( icaltime_compare( completed->m_datetime , m_filter->m_completed->m_datetime ) > 0 )
|
|
|
|
result = true;
|
|
|
|
NS_RELEASE( completed );
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalImpl::GetFilter( oeIICalTodo **retval )
|
|
|
|
{
|
|
|
|
*retval = m_filter;
|
|
|
|
NS_ADDREF(*retval);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalImpl::ResetFilter()
|
|
|
|
{
|
|
|
|
if( m_filter && m_filter->m_completed )
|
|
|
|
m_filter->m_completed->m_datetime = icaltime_null_time();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(oeICalFilter, oeIICalTodo)
|
|
|
|
|
|
|
|
oeICalFilter::oeICalFilter()
|
|
|
|
{
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_completed ))) {
|
|
|
|
m_completed = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
oeICalFilter::~oeICalFilter()
|
|
|
|
{
|
|
|
|
if( m_completed )
|
|
|
|
m_completed->Release();
|
|
|
|
}
|
|
|
|
|
2003-08-15 18:08:48 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetType(Componenttype *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetId(char **aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetId(const char *aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-10 21:24:08 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetTitle(nsACString& aRetVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-10 21:24:08 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetTitle(const nsACString& aNewVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetDescription(nsACString& aRetVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetDescription(const nsACString& aNewVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetLocation(nsACString& aRetVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetLocation(const nsACString& aNewVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetCategories(nsACString& aRetVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetCategories(const nsACString& aNewVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetUrl(nsACString& aRetVal)
|
2002-06-26 14:39:21 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:15:49 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetUrl(const nsACString& aNewVal)
|
2002-06-26 14:39:21 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetPrivateEvent(PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetPrivateEvent(PRBool aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-09 14:21:56 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetMethod(eventMethodProperty *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetMethod(eventMethodProperty aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetStatus(eventStatusProperty *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetStatus(eventStatusProperty aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetPriority(PRInt16 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetPriority(PRInt16 aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetSyncId(char * *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetSyncId(const char * aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetAllDay(PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetAllDay(PRBool aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetAlarm(PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetAlarm(PRBool aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetAlarmUnits(char * *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetAlarmUnits(const char * aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetAlarmLength(PRUint32 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetAlarmLength(PRUint32 aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetAlarmEmailAddress(char * *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetAlarmEmailAddress(const char * aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetInviteEmailAddress(char * *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetInviteEmailAddress(const char * aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurInterval(PRUint32 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecurInterval(PRUint32 aNewVal )
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-12-05 18:10:57 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurCount(PRUint32 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecurCount(PRUint32 aNewVal )
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurUnits(char **aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecurUnits(const char * aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecur(PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecur(PRBool aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurForever(PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecurForever(PRBool aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-02-12 22:42:32 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetLastModified(PRTime *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP oeICalFilter::UpdateLastModified()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetLastAlarmAck(PRTime *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetLastAlarmAck(PRTime aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetNextRecurrence( PRTime begin, PRTime *retval, PRBool *isvalid ) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetPreviousOccurrence( PRTime beforethis, PRTime *retval, PRBool *isvalid ) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetStart(oeIDateTime * *start)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetEnd(oeIDateTime * *end)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-09 14:21:56 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetStamp(oeIDateTime * *stamp)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-06-25 13:50:39 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurEnd(oeIDateTime * *recurend)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurWeekdays(PRInt16 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecurWeekdays(PRInt16 aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetRecurWeekNumber(PRInt16 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetRecurWeekNumber(PRInt16 aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-15 17:31:40 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetIcalString(nsACString& aRetVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-15 17:31:40 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::ParseIcalString(const nsACString& aNewVal, PRBool *aRetVal)
|
2002-06-25 13:50:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::AddException( PRTime exdate )
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::RemoveAllExceptions()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetExceptions(nsISimpleEnumerator **datelist )
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetSnoozeTime( PRTime snoozetime )
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::Clone( oeIICalEvent **ev )
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetDue(oeIDateTime * *due)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetCompleted(oeIDateTime * *completed)
|
|
|
|
{
|
|
|
|
*completed = m_completed;
|
|
|
|
NS_ADDREF(*completed);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetPercent(PRInt16 *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::SetPercent(PRInt16 aNewVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2002-07-03 16:18:36 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::AddAttachment(nsIMsgAttachment *attachment)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::RemoveAttachment(nsIMsgAttachment *attachment)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::RemoveAttachments()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetAttachmentsArray(nsISupportsArray * *aAttachmentsArray)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-07-11 13:33:42 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::AddContact(nsIAbCard *contact)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::RemoveContact(nsIAbCard *contact)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::RemoveContacts()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetContactsArray(nsISupportsArray * *aContactsArray)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-07-26 13:50:22 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetParent( oeIICal *parent)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-08-22 14:44:01 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::GetParent( oeIICal **parent)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetTodoIcalString(nsACString& aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::ParseTodoIcalString(const nsACString& aNewVal, PRBool *aRetVal)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2002-10-21 16:03:26 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetDuration(PRBool is_negative, PRUint16 weeks, PRUint16 days, PRUint16 hours, PRUint16 minutes, PRUint16 seconds)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetDuration(PRBool *is_negative, PRUint16 *weeks, PRUint16 *days, PRUint16 *hours, PRUint16 *minutes, PRUint16 *seconds)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-06-04 20:42:44 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2002-08-22 14:44:01 +00:00
|
|
|
|
2003-08-22 13:27:20 +00:00
|
|
|
NS_IMETHODIMP oeICalFilter::SetParameter( const char *name, const char *value ) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP oeICalFilter::GetParameter( const char *name, char **value ) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|