diff --git a/calendar/libxpical/oeICalContainerImpl.cpp b/calendar/libxpical/oeICalContainerImpl.cpp index d6bacaf242d..e6d1b883c0a 100644 --- a/calendar/libxpical/oeICalContainerImpl.cpp +++ b/calendar/libxpical/oeICalContainerImpl.cpp @@ -44,6 +44,9 @@ extern "C" { extern icalarray *builtin_timezones; extern char *gDefaultTzidPrefix; } + +oeIICalContainer *gContainer=nsnull; + //icaltimetype ConvertFromPrtime( PRTime indate ); void icaltimezone_init_mozilla_zones (void) { @@ -187,6 +190,8 @@ oeICalContainerImpl::oeICalContainerImpl() m_filter->m_calendarArray = m_calendarArray; icaltimezone_init_mozilla_zones (); + + gContainer = this; } oeICalContainerImpl::~oeICalContainerImpl() @@ -201,6 +206,7 @@ oeICalContainerImpl::~oeICalContainerImpl() m_todoobserverArray = nsnull; NS_RELEASE( m_filter ); + gContainer = nsnull; } /** @@ -970,6 +976,25 @@ oeICalContainerImpl::GetAllTodos(nsISimpleEnumerator **resultList ) return NS_OK; } +NS_IMETHODIMP oeICalContainerImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) { + PRUint32 num; + unsigned int i; + m_observerArray->Count( &num ); + for ( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver ); + tmpobserver->OnError( severity, errorid, errorstring ); + } + + m_todoobserverArray->Count( &num ); + for ( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver ); + tmpobserver->OnError( severity, errorid, errorstring ); + } + return NS_OK; +} + /*************************************************************************************************************/ /*************************************************************************************************************/ /*************************************************************************************************************/ diff --git a/calendar/libxpical/oeICalEventImpl.cpp b/calendar/libxpical/oeICalEventImpl.cpp index 584c127d266..117e8a09d37 100644 --- a/calendar/libxpical/oeICalEventImpl.cpp +++ b/calendar/libxpical/oeICalEventImpl.cpp @@ -67,6 +67,8 @@ #define DEFAULT_ALARM_LENGTH 15 #define DEFAULT_RECUR_UNITS "weeks" +extern oeIICalContainer *gContainer; + char *EmptyReturn() { return (char*) nsMemory::Clone( "", 1 ); } @@ -288,6 +290,7 @@ oeICalEventImpl::oeICalEventImpl() SetSyncId( "" ); NS_NewISupportsArray(getter_AddRefs(m_attachments)); NS_NewISupportsArray(getter_AddRefs(m_contacts)); + m_calendar=nsnull; } oeICalEventImpl::~oeICalEventImpl() @@ -1693,8 +1696,12 @@ bool oeICalEventImpl::ParseIcalComponent( icalcomponent *comp ) tmpstr = icalproperty_get_uid( prop ); SetId( tmpstr ); } else { - ReportError( oeIICal::ICAL_ERROR_PROBLEM, 0, "oeICalEventImpl::ParseIcalComponent() failed: UID not found!\n" ); - return false; + ReportError( oeIICal::ICAL_ERROR_WARN, 0, "oeICalEventImpl::ParseIcalComponent() : Warning UID not found! Assigning new one." ); + char uidstr[40]; + GenerateUUID( uidstr ); + SetId( uidstr ); + prop = icalproperty_new_uid( uidstr ); + icalcomponent_add_property( vevent, prop ); } //method @@ -2628,8 +2635,11 @@ icalcomponent* oeICalEventImpl::AsIcalComponent() } NS_IMETHODIMP oeICalEventImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) { - if( m_calendar ) + if( m_calendar ) { m_calendar->ReportError( severity, errorid, errorstring ); + } else if( gContainer ) { + gContainer->ReportError( severity, errorid, errorstring ); + } return NS_OK; } diff --git a/calendar/libxpical/oeIICal.idl b/calendar/libxpical/oeIICal.idl index 0507cc7ffef..9bf77715d84 100644 --- a/calendar/libxpical/oeIICal.idl +++ b/calendar/libxpical/oeIICal.idl @@ -272,6 +272,7 @@ interface oeIICalContainer : nsISupports nsISimpleEnumerator getAllTodos(); void resetFilter(); + void reportError( in short severity, in unsigned long errorid, in string errorstring ); }; %{ C++ diff --git a/calendar/resources/content/calendar.xul b/calendar/resources/content/calendar.xul index 4c14f66a397..c46af419a6b 100644 --- a/calendar/resources/content/calendar.xul +++ b/calendar/resources/content/calendar.xul @@ -115,7 +115,7 @@ - + diff --git a/calendar/resources/content/importExport.js b/calendar/resources/content/importExport.js index ccd8ed59350..f6ee7740318 100644 --- a/calendar/resources/content/importExport.js +++ b/calendar/resources/content/importExport.js @@ -1280,3 +1280,29 @@ function getXmlDocument ( eventList ) } return xmlDocument; } + +function startImport() { + var ImportExportErrorHandler = { + errorreport : "", + onLoad : function() {}, + onStartBatch : function() {}, + onEndBatch : function() {}, + onAddItem : function( calendarEvent ) {}, + onModifyItem : function( calendarEvent, originalEvent ) {}, + onDeleteItem : function( calendarEvent, nextEvent ) {}, + onAlarm : function( calendarEvent ) {}, + onError : function( severity, errorid, errorstring ) + { + this.errorreport=this.errorreport+errorstring+"\n"; + }, + showErrors : function () { + if( this.errorreport != "" ) + alert( "Errors:\n"+this.errorreport ); + } + + } + gICalLib.addObserver( ImportExportErrorHandler ); + loadEventsFromFile(); + ImportExportErrorHandler.showErrors(); + gICalLib.removeObserver( ImportExportErrorHandler ); +}