-rw-r--r-- | korganizer/calendarview.cpp | 76 | ||||
-rw-r--r-- | korganizer/calendarview.h | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 27 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 | ||||
-rw-r--r-- | libkcal/calendar.h | 2 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 14 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 2 |
8 files changed, 87 insertions, 43 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cfc6b10..9160e1d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -841,88 +841,114 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b break; default: // SYNC_PREF_TAKE_BOTH not implemented break; } return 0; } Event* CalendarView::getLastSyncEvent() { Event* lse; //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); - lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); + lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); if (!lse) { lse = new Event(); - lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); - lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); + lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); + QString sum = ""; + if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) + sum = "E: "; + lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); mCalendar->addEvent( lse ); } return lse; } -void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) +void CalendarView::setupExternSyncProfiles() { - if ( ! lastSync ) - return; - if ( toDelete->zaurusId() < 0 ) + Event* lse; + mExternLastSyncEvent.clear(); + int i; + for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { + lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); + if ( lse ) + mExternLastSyncEvent.append( lse ); + else + qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); + } + +} +// we check, if the to delete event has a id for a profile +// if yes, we set this id in the profile to delete +void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) +{ + if ( ! lastSync.count() == 0 ) return; if ( toDelete->type() == "Journal" ) return; - QString des = lastSync->description(); - QString pref = "e"; - if ( toDelete->type() == "Todo" ) - pref = "t"; - des += pref+ QString::number ( toDelete->zaurusId() ) + ","; - lastSync->setReadOnly( false ); - lastSync->setDescription( des ); - lastSync->setReadOnly( true ); + + Event* eve = lastSync.first(); + + while ( eve ) { + int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name + if ( id >= 0 ) { + QString des = eve->description(); + QString pref = "e"; + if ( toDelete->type() == "Todo" ) + pref = "t"; + des += pref+ QString::number ( id ) + ","; + eve->setReadOnly( false ); + eve->setDescription( des ); + eve->setReadOnly( true ); + } + eve = lastSync.next(); + } } bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) { bool syncOK = true; int addedEvent = 0; int addedEventR = 0; int deletedEventR = 0; int deletedEventL = 0; int changedLocal = 0; int changedRemote = 0; //QPtrList<Event> el = local->rawEvents(); Event* eventR; QString uid; int take; Event* eventL; Event* eventRSync; Event* eventLSync; - Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); - Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); + QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); + QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; mLastCalendarSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastCalendarSync;; - eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); + eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); if ( eventR ) { eventRSync = (Event*) eventR->clone(); remote->deleteEvent(eventR ); } else { fullDateRange = true; eventRSync = new Event(); eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); - eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); + eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); eventRSync->setDtStart( mLastCalendarSync ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); eventRSync->setCategories( i18n("SyncEvent") ); } eventLSync = getLastSyncEvent(); if ( eventLSync->dtStart() == mLastCalendarSync ) fullDateRange = true; if ( ! fullDateRange ) { if ( eventLSync->dtStart() != eventRSync->dtStart() ) { // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); @@ -956,25 +982,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); int modulo = (er.count()/10)+1; int incCounter = 0; while ( inR ) { if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inR->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; qApp->processEvents(); if ( !skipIncidence ) { inL = local->incidence( uid ); if ( inL ) { // maybe conflict - same uid in both calendars int maxrev = inL->revision(); if ( maxrev < inR->revision() ) maxrev = inR->revision(); if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { //qDebug("take %d %s ", take, inL->summary().latin1()); if ( take == 3 ) @@ -1006,25 +1032,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int ++deletedEventR; } else { inR->setLastModified( modifiedCalendar ); local->addIncidence( inR->clone() ); ++addedEvent; } } else { if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { inR->setLastModified( modifiedCalendar ); local->addIncidence( inR->clone() ); ++addedEvent; } else { - checkSharpEvent(eventRSyncSharp, inR); + checkExternSyncEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); ++deletedEventR; } } } } inR = er.next(); } QPtrList<Incidence> el = local->rawIncidences(); inL = el.first(); modulo = (el.count()/10)+1; bar.setCaption (i18n("Add / remove events") ); @@ -1033,46 +1059,46 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int incCounter = 0; while ( inL ) { qApp->processEvents(); if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inL->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) skipIncidence = true; if ( !skipIncidence ) { inR = remote->incidence( uid ); if ( ! inR ) { if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( inL->zaurusId() >= 0 && mode != 4 ) { local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { inL->setZaurusId( -1 ); ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } } } else { if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { - checkSharpEvent(eventLSyncSharp, inL); + checkExternSyncEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } } } } } @@ -1333,25 +1359,25 @@ bool CalendarView::importQtopia( const QString &categories, #endif } void CalendarView::setSyncEventsReadOnly() { Event * ev; QPtrList<Event> eL = mCalendar->rawEvents(); ev = eL.first(); while ( ev ) { - if ( ev->uid().left(21) == QString("last-syncEvent-device") ) + if ( ev->uid().left(15) == QString("last-syncEvent-") ) ev->setReadOnly( true ); ev = eL.next(); } } bool CalendarView::openCalendar(QString filename, bool merge) { if (filename.isEmpty()) { return false; } if (!QFile::exists(filename)) { @@ -1797,25 +1823,25 @@ void CalendarView::eventToBeDeleted(Event *) void CalendarView::eventDeleted() { changeEventDisplay(0,KOGlobals::EVENTDELETED); } void CalendarView::changeTodoDisplay(Todo *which, int action) { changeIncidenceDisplay((Incidence *)which, action); } void CalendarView::checkZaurusId( int id, bool todo ) { if ( id >= 0 ) { - Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); + Incidence* lse = mCalendar->event( "last-syncEvent-Sharp-DTM"); if ( lse ) { QString des = lse->description(); QString pref = "e"; if ( todo ) pref = "t"; des += pref+ QString::number ( id ) + ","; lse->setReadOnly( false ); lse->setDescription( des ); lse->setReadOnly( true ); } } } diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 8aa5e1c..557554f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -104,24 +104,25 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser QWidgetStack *viewStack(); QWidget *leftFrame(); NavigatorBar *navigatorBar(); DateNavigator *dateNavigator(); KDateNavigator *dateNavigatorWidget(); void addView(KOrg::BaseView *); void showView(KOrg::BaseView *); KOEventViewerDialog* getEventViewerDialog(); Incidence *currentSelection(); + void setupExternSyncProfiles(); signals: /** This todo has been modified */ void todoModified(Todo *, int); /** when change is made to options dialog, the topwidget will catch this * and emit this signal which notifies all widgets which have registered * for notification to update their settings. */ void configChanged(); /** emitted when the topwidget is closing down, so that any attached child windows can also close. */ void closingDown(); @@ -472,25 +473,25 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser private: AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); QDateTime loadedFileVersion; - void checkSharpEvent( Event* lastSync, Incidence* toDelete ); + void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); void checkZaurusId( int id, bool todo = false ); int mGlobalSyncMode; QString mCurrentSyncDevice; QString mCurrentSyncName; KOBeamPrefs* beamDialog; void init(); int mDatePickerMode; bool mFlagEditDescription; QDateTime mLastCalendarSync; void createPrinter(); void calendarModified( bool, Calendar * ); @@ -525,25 +526,25 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser KODialogManager *mDialogManager; // Calendar filters QPtrList<CalFilter> mFilters; // various housekeeping variables. bool mModified; // flag indicating if calendar is modified bool mReadOnly; // flag indicating if calendar is read-only QDate mSaveSingleDate; Incidence *mSelectedIncidence; Incidence *mMoveIncidence; - + QPtrList<Event> mExternLastSyncEvent; KOTodoView *mTodoList; KOEventEditor * mEventEditor; KOTodoEditor * mTodoEditor; KOEventViewerDialog * mEventViewerDialog; void keyPressEvent ( QKeyEvent *e) ; //QMap<Incidence*,KOIncidenceEditor*> mDialogList; }; class CalendarViewVisitor : public Incidence::Visitor { public: diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 3ba5ab2..f3231ff 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -168,49 +168,50 @@ KOPrefs::KOPrefs() : addItemFont("MonthView Font",&mMonthViewFont); addItemFont("AgendaView Font",&mAgendaViewFont); addItemFont("MarcusBains Font",&mMarcusBainsFont); addItemFont("TimeLabels Font",&mTimeLabelsFont); addItemFont("TodoView Font",&mTodoViewFont); addItemFont("ListView Font",&mListViewFont); addItemFont("DateNavigator Font",&mDateNavigatorFont); addItemFont("EditBox Font",&mEditBoxFont); addItemFont("JournalView Font",&mJornalViewFont); addItemFont("WhatsNextView Font",&mWhatsNextFont); addItemFont("EventView Font",&mEventViewFont); - KPrefs::setCurrentGroup("SyncProfiles"); - addItemString("LocalMachineName",&mLocalMachineName, "undefined"); - addItemStringList("SyncProfileNames",&mSyncProfileNames); +// KPrefs::setCurrentGroup("SyncProfiles"); +// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); +// addItemStringList("SyncProfileNames",&mSyncProfileNames); +// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); KPrefs::setCurrentGroup("RemoteSyncing"); - addItemBool("UsePasswd",&mUsePassWd,false); - addItemBool("WriteBackFile",&mWriteBackFile,true); - addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); - addItemBool("AskForPreferences",&mAskForPreferences,true); - addItemBool("ShowSyncSummary",&mShowSyncSummary,true); +// addItemBool("UsePasswd",&mUsePassWd,false); +// addItemBool("WriteBackFile",&mWriteBackFile,true); +// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); +// addItemBool("AskForPreferences",&mAskForPreferences,true); +// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); addItemBool("ShowSyncEvents",&mShowSyncEvents,false); addItemInt("LastSyncTime",&mLastSyncTime,0); addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif - addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); - addItemString("RemoteUser",&mRemoteUser, "zaurus"); - addItemString("RemotePassWd",&mRemotePassWd, ""); - addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); - addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); +// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); +// addItemString("RemoteUser",&mRemoteUser, "zaurus"); +// addItemString("RemotePassWd",&mRemotePassWd, ""); +// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); +// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); KPrefs::setCurrentGroup("LoadSaveFileNames"); addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); KPrefs::setCurrentGroup("Locale"); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index fe044e6..424fa98 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -206,24 +206,25 @@ class KOPrefs : public KPimPrefs bool mWriteBackExistingOnly; QString mRemoteIP; QString mRemoteUser; QString mRemotePassWd; QString mRemoteFile; QString mLocalTempFile; int mLastSyncTime; int mSyncAlgoPrefs; int mRingSyncAlgoPrefs; QStringList mSyncProfileNames; + QStringList mExternSyncProfiles; QString mLocalMachineName; void setCategoryColor(QString cat,const QColor & color); QColor *categoryColor(QString cat); QString mArchiveFile; QString mHtmlExportFile; bool mHtmlWithSave; QStringList mSelectedPlugins; QString mLastImportFile; QString mLastVcalFile; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 44b1264..6020a46 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -827,39 +827,42 @@ void MainWindow::fillSyncMenu() prof << i18n("Sharp_DTM"); prof << i18n("Local_file"); prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); + config.writeEntry("ExternSyncProfiles","Sharp_DTM"); config.sync(); delete temp; } + KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); KOPrefs::instance()->mSyncProfileNames = prof; int i; for ( i = 0; i < prof.count(); ++i ) { syncMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) syncMenu->insertSeparator(); } QDir app_dir; if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { syncMenu->setItemEnabled( false , 1000 ); } + mView->setupExternSyncProfiles(); } int MainWindow::ringSync() { int syncedProfiles = 0; int i; QTime timer; KConfig config ( locateLocal( "config","syncprofilesrc" ) ); QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; KSyncProfile* temp = new KSyncProfile (); KOPrefs::instance()->mAskForPreferences = false; for ( i = 0; i < syncProfileNames.count(); ++i ) { diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 7d23619..df5bbcf 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -66,25 +66,25 @@ public: Calendar(const QString &timeZoneId); virtual ~Calendar(); void deleteIncidence(Incidence *in); /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; /** Sync changes in memory to persistant storage. */ virtual void save() = 0; - + virtual QPtrList<Event> getExternLastSyncEvents() = 0; virtual bool isSaving() { return false; } /** Return the owner of the calendar's full name. */ const QString &getOwner() const; /** Set the owner of the calendar. Should be owner's full name. */ void setOwner( const QString &os ); /** Return the email address of the calendar owner. diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3c572f0..09ce9f0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -213,24 +213,37 @@ QPtrList<Todo> CalendarLocal::rawTodos() return mTodoList; } Todo *CalendarLocal::todo( int id ) { Todo *todo; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->zaurusId() == id ) return todo; } return 0; } +QPtrList<Event> CalendarLocal::getExternLastSyncEvents() +{ + QPtrList<Event> el; + Event *todo; + for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { + if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) + if ( todo->summary().left(3) == "E: " ) + el.append( todo ); + } + + return el; + +} Event *CalendarLocal::event( int id ) { Event *todo; for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { if ( todo->zaurusId() == id ) return todo; } return 0; } Todo *CalendarLocal::todo( const QString &uid ) { Todo *todo; @@ -311,25 +324,24 @@ QString CalendarLocal:: getAlarmNotification() Alarm* alarm = mNextAlarmIncidence->alarms().first(); if ( alarm->type() == Alarm::Procedure ) { ret = "proc_alarm" + alarm->programFile()+"+++"; } else { ret = "audio_alarm" +alarm->audioFile() +"+++"; } ret += "cal_alarm"+ mNextSummary.left( 25 ); if ( mNextSummary.length() > 25 ) ret += "\n" + mNextSummary.mid(25, 25 ); ret+= "\n"+mNextAlarmEventDateTimeString; return ret; } - void CalendarLocal::registerAlarm() { mLastAlarmNotificationString = getAlarmNotification(); // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); // #ifndef DESKTOP_VERSION // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); // #endif } void CalendarLocal::deRegisterAlarm() { if ( mLastAlarmNotificationString.isNull() ) diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a2e50e3..3257198 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -76,25 +76,25 @@ class CalendarLocal : public Calendar Deletes an event from this calendar. */ void deleteEvent( Event *event ); /** Retrieves an event on the basis of the unique string ID. */ Event *event( const QString &uid ); /** Return unfiltered list of all events in calendar. */ QPtrList<Event> rawEvents(); - + QPtrList<Event> getExternLastSyncEvents(); /** Add a todo to the todolist. */ bool addTodo( Todo *todo ); bool addTodoNoDup( Todo *todo ); /** Remove a todo from the todolist. */ void deleteTodo( Todo * ); /** Searches todolist for an event with this unique string identifier, returns a pointer or null. |