More work on multiple types of calendars.

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

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

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

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

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

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

@ -117,7 +117,6 @@ public:
bool matchId( const char *id );
icaltimetype GetNextRecurrence( icaltimetype begin, bool *isbeginning );
icaltimetype GetPreviousOccurrence( icaltimetype beforethis );
NS_IMETHODIMP SetParent( oeIICal *parent );
icaltimetype CalculateEventTime( icaltimetype alarmtime );
void ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
bool isallday, bool isbeginning );
@ -166,7 +165,7 @@ private:
icaldurationtype GetLength();
nsCOMPtr<nsISupportsArray> m_attachments;
nsCOMPtr<nsISupportsArray> m_contacts;
oeIICal *m_calendar;
nsCOMPtr<oeIICal> m_calendar;
};
/*******************************************************************************************/

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

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

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

@ -127,11 +127,6 @@ oeICalTodoImpl::~oeICalTodoImpl()
mEvent->Release();
}
NS_IMETHODIMP oeICalTodoImpl::SetParent( oeIICal *calendar )
{
return mEvent->SetParent( calendar );
}
bool oeICalTodoImpl::matchId( const char *id ) {
return mEvent->matchId( id );
}

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

@ -69,7 +69,6 @@ public:
icalcomponent *AsIcalComponent();
NS_IMETHOD Clone(oeIICalTodo **_retval);
bool matchId( const char *id );
NS_IMETHODIMP SetParent( oeIICal *parent );
oeICalEventImpl *GetBaseEvent();
private:
int m_percent;

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

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

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

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