mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Added ability to inform observers about errors
This commit is contained in:
parent
b20e0b65f2
commit
efab7689e1
@ -309,7 +309,7 @@ oeICalContainerImpl::AddCalendars( PRUint32 serverCount, const char **servers )
|
||||
#ifdef ICAL_DEBUG
|
||||
printf( "oeICalContainerImpl::AddCalendars( %d, [Array] )\n", serverCount );
|
||||
#endif
|
||||
nsresult rv;
|
||||
nsresult rv=NS_OK;
|
||||
for( unsigned int i=0; i<serverCount; i++ ) {
|
||||
rv = AddCalendar( servers[i] );
|
||||
if( NS_FAILED( rv ) )
|
||||
@ -1441,6 +1441,9 @@ void oeICalContainerFilter::UpdateAllFilters( PRInt32 icaltype )
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP oeICalContainerFilter::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
///////////////////////////////////////////////////
|
||||
// FilterDateTime
|
||||
//////////////////////////////////////////////////
|
||||
|
@ -1693,9 +1693,7 @@ bool oeICalEventImpl::ParseIcalComponent( icalcomponent *comp )
|
||||
tmpstr = icalproperty_get_uid( prop );
|
||||
SetId( tmpstr );
|
||||
} else {
|
||||
#ifdef ICAL_DEBUG
|
||||
printf( "oeICalEventImpl::ParseIcalComponent() failed: UID not found!\n" );
|
||||
#endif
|
||||
ReportError( oeIICal::ICAL_ERROR_PROBLEM, 0, "oeICalEventImpl::ParseIcalComponent() failed: UID not found!\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2629,6 +2627,12 @@ icalcomponent* oeICalEventImpl::AsIcalComponent()
|
||||
return newcalendar;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP oeICalEventImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
|
||||
if( m_calendar )
|
||||
m_calendar->ReportError( severity, errorid, errorstring );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
@ -1473,7 +1473,7 @@ oeICalImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinm
|
||||
eventArray->GetElementAt( i, getter_AddRefs( tmpcomp ) );
|
||||
oeIICalEvent* tmpevent = tmpcomp;
|
||||
bool isbeginning;
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
|
||||
bool isallday = next.is_date;
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
||||
@ -2052,6 +2052,47 @@ oeICalImpl::GetAllTodos(nsISimpleEnumerator **resultList )
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP oeICalImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
|
||||
|
||||
if( severity >= ICAL_ERROR_PROBLEM ) {
|
||||
#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;
|
||||
}
|
||||
|
||||
/*************************************************************************************************************/
|
||||
/*************************************************************************************************************/
|
||||
/*************************************************************************************************************/
|
||||
@ -2509,4 +2550,7 @@ NS_IMETHODIMP oeICalFilter::GetDuration(PRBool *is_negative, PRUint16 *weeks, PR
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP oeICalFilter::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -150,6 +150,8 @@ interface oeIICalEvent : nsISupports
|
||||
void addContact(in nsIAbCard contact);
|
||||
void removeContact(in nsIAbCard contact);
|
||||
void removeContacts();
|
||||
|
||||
void reportError( in short severity, in unsigned long errorid, in string errorstring );
|
||||
};
|
||||
|
||||
[scriptable, uuid(f95df40e-0d5f-49ec-9ba8-4b88d3eb53e0)]
|
||||
@ -180,6 +182,7 @@ interface oeIICalObserver : nsISupports
|
||||
void onModifyItem( in oeIICalEvent e, in oeIICalEvent olde );
|
||||
void onDeleteItem( in oeIICalEvent e);
|
||||
void onAlarm( in oeIICalEventDisplay e);
|
||||
void onError( in short severity, in unsigned long errorid, in string errorstring );
|
||||
};
|
||||
|
||||
[scriptable, uuid(7a4fd625-69a8-4008-932e-cccc227b402c)]
|
||||
@ -192,11 +195,17 @@ interface oeIICalTodoObserver : nsISupports
|
||||
void onModifyItem( in oeIICalTodo e, in oeIICalTodo olde );
|
||||
void onDeleteItem( in oeIICalTodo e);
|
||||
void onAlarm( in oeIICalTodo e);
|
||||
void onError( in short severity, in unsigned long errorid, in string errorstring );
|
||||
};
|
||||
|
||||
[scriptable, uuid(981ab93d-ad51-45bb-a4a2-e158c2cfdeb4)]
|
||||
interface oeIICal : nsISupports
|
||||
{
|
||||
const long ICAL_ERROR_DEBUG = 0;
|
||||
const long ICAL_ERROR_WARN = 1;
|
||||
const long ICAL_ERROR_PROBLEM = 1;
|
||||
const long ICAL_ERROR_CRITICAL = 1;
|
||||
|
||||
void Test();
|
||||
|
||||
attribute boolean batchMode;
|
||||
@ -227,6 +236,7 @@ interface oeIICal : nsISupports
|
||||
nsISimpleEnumerator getAllTodos();
|
||||
|
||||
void resetFilter();
|
||||
void reportError( in short severity, in unsigned long errorid, in string errorstring );
|
||||
};
|
||||
|
||||
[scriptable, uuid(c89ec938-f690-4f62-a4b3-11e962ba2314)]
|
||||
|
@ -87,6 +87,7 @@
|
||||
onModifyItem : function( calendarEvent, originalEvent ) {},
|
||||
onDeleteItem : function( calendarEvent ) {},
|
||||
onAlarm : function( calendarEvent ) {},
|
||||
onError : function() {},
|
||||
};
|
||||
|
||||
These methods are now called synchronously, if you add an event the onAddItem
|
||||
@ -684,6 +685,7 @@ CalendarAlarmObserver.prototype.onLoad = function( calendarEvent ){}
|
||||
CalendarAlarmObserver.prototype.onAddItem = function( calendarEvent ){}
|
||||
CalendarAlarmObserver.prototype.onModifyItem = function( calendarEvent, originalEvent ){}
|
||||
CalendarAlarmObserver.prototype.onDeleteItem = function( calendarEvent ){}
|
||||
CalendarAlarmObserver.prototype.onError = function(){}
|
||||
|
||||
CalendarAlarmObserver.prototype.onAlarm = function calAlarm_onAlarm( calendarEvent )
|
||||
{
|
||||
|
@ -200,6 +200,9 @@ function CalendarWindow( )
|
||||
onAlarm : function( calendarEvent )
|
||||
{
|
||||
|
||||
},
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -282,9 +282,11 @@ function testAdd( )
|
||||
|
||||
onDeleteItem : function( calendarEvent )
|
||||
{
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
var ds = new CalendarEventDataSource( calendarObserver, "/tmp/" );
|
||||
@ -332,6 +334,10 @@ function testAddDelete( owner )
|
||||
{
|
||||
testAddDeleteObject.deletedEvent = calendarEvent;
|
||||
testAddDeleteObject.done = true;
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -473,6 +479,10 @@ function testModify( owner )
|
||||
{
|
||||
testModifyObject.deletedEvent = calendarEvent;
|
||||
testModifyObject.done = true;
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@ -697,6 +707,10 @@ function testAlarm( owner )
|
||||
}
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -846,6 +860,10 @@ function testGetDay( owner )
|
||||
{
|
||||
testGetDayObject.deletedEvent = calendarEvent;
|
||||
--testGetDayObject.done;
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@ -1068,6 +1086,10 @@ function testGetById( owner )
|
||||
{
|
||||
testGetByIdObject.deletedEvent = calendarEvent;
|
||||
testGetByIdObject.done = true;
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -181,6 +181,9 @@ var unifinderEventDataSourceObserver =
|
||||
onAlarm : function( calendarEvent )
|
||||
{
|
||||
|
||||
},
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -94,6 +94,10 @@ var unifinderToDoDataSourceObserver =
|
||||
onAlarm : function( calendarToDo )
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
onError : function()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user