Fixed bug 166028: Should be able to import files without UIDs

This commit is contained in:
mostafah%oeone.com 2003-06-06 14:12:40 +00:00
Родитель 8774d1f2b9
Коммит 6e643dc60b
5 изменённых файлов: 66 добавлений и 4 удалений

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

@ -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; i<num; i++ ) {
oeIICalObserver* tmpobserver;
m_observerArray->GetElementAt( i, (nsISupports **)&tmpobserver );
tmpobserver->OnError( severity, errorid, errorstring );
}
m_todoobserverArray->Count( &num );
for ( i=0; i<num; i++ ) {
oeIICalTodoObserver* tmpobserver;
m_todoobserverArray->GetElementAt( i, (nsISupports **)&tmpobserver );
tmpobserver->OnError( severity, errorid, errorstring );
}
return NS_OK;
}
/*************************************************************************************************************/
/*************************************************************************************************************/
/*************************************************************************************************************/

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

@ -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;
}

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

@ -272,6 +272,7 @@ interface oeIICalContainer : nsISupports
nsISimpleEnumerator getAllTodos();
void resetFilter();
void reportError( in short severity, in unsigned long errorid, in string errorstring );
};
%{ C++

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

@ -115,7 +115,7 @@
<command id="month_view_command" oncommand="gCalendarWindow.switchToMonthView()" disabled="true"/>
<command id="multiweek_view_command" oncommand="gCalendarWindow.switchToMultiweekView()" disabled="false"/>
<command id="import_command" oncommand="loadEventsFromFile()"/>
<command id="import_command" oncommand="startImport()"/>
<command id="export_command" oncommand="saveEventsToFile()" disabled="true" disabledwhennoeventsselected="true"/>
<command id="refresh_remote_calendars" oncommand="gCalendarWindow.calendarManager.refreshAllRemoteCalendars()"/>

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

@ -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 );
}