summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 689618d..a7f7010 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -74,24 +74,25 @@
#include <libkcal/calfilter.h>
#include <libkcal/attendee.h>
#include <libkcal/dndfactory.h>
#include <libkcal/freebusy.h>
#include <libkcal/filestorage.h>
#include <libkcal/calendarresources.h>
#include <libkcal/qtopiaformat.h>
#include "../kalarmd/alarmdialog.h"
#ifndef DESKTOP_VERSION
#include <libkcal/sharpformat.h>
#endif
+#include <libkcal/phoneformat.h>
#ifndef KORG_NOMAIL
#include "komailclient.h"
#endif
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include "koeventeditor.h"
#include "kotodoeditor.h"
#include "koprefs.h"
@@ -1166,56 +1167,74 @@ bool CalendarView::syncCalendar(QString filename, int mode)
}
}
setModified( true );
}
delete storage;
delete calendar;
if ( syncOK )
updateView();
return syncOK;
}
void CalendarView::syncPhone()
{
- qDebug("CalendarView::syncPhone() ");
+ syncExternal( 1 );
}
-void CalendarView::syncSharp()
+void CalendarView::syncExternal( int mode )
{
-#ifndef DESKTOP_VERSION
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
//mCurrentSyncDevice = "sharp-DTM";
if ( KOPrefs::instance()->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
bool syncOK = false;
- SharpFormat sharpFormat;
- if ( sharpFormat.load( calendar, mCalendar ) ) {
+ boo loadSuccess = false;
+ PhoneFormat* phoneFormat = 0;
+#ifndef DESKTOP_VERSION
+ SharpFormat* sharpFormat = 0;
+ if ( mode == 0 ) { // sharp
+ sharpFormat = new SharpFormat () ;
+ loadSuccess = sharpFormat->load( calendar, mCalendar );
+
+ } else
+#endif
+ if ( mode == 1 ) { // phone
+ phoneFormat = new PhoneFormat ();
+ loadSuccess = phoneFormat->load( calendar, mCalendar );
+
+ } else
+ return;
+ if ( loadSuccess ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
qApp->processEvents();
if ( syncOK ) {
if ( KOPrefs::instance()->mWriteBackFile )
{
QPtrList<Incidence> iL = mCalendar->rawIncidences();
Incidence* inc = iL.first();
/* obsolete
while ( inc ) {
inc->setZaurusStat( inc->revision () );
inc = iL.next();
}
*/
- // pending: clean last sync event description
- sharpFormat.save(calendar);
+#ifndef DESKTOP_VERSION
+ if ( sharpFormat )
+ sharpFormat->save(calendar);
+#endif
+ if ( phoneFormat )
+ phoneFormat->save(calendar);
iL = calendar->rawIncidences();
inc = iL.first();
Incidence* loc;
while ( inc ) {
if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
loc = mCalendar->incidence(inc->uid() );
if ( loc ) {
loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
}
}
inc = iL.next();
@@ -1229,25 +1248,30 @@ void CalendarView::syncSharp()
}
}
setModified( true );
} else {
QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
question, i18n("Ok")) ;
}
delete calendar;
updateView();
return ;//syncOK;
-#endif
+
+}
+void CalendarView::syncSharp()
+{
+ syncExternal( 0 );
+
}
#include <kabc/stdaddressbook.h>
bool CalendarView::importBday()
{
KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
KABC::AddressBook::Iterator it;
int count = 0;
for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
++count;
}