author | zautrix <zautrix> | 2005-11-25 20:49:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 20:49:16 (UTC) |
commit | 2468bddcb380d8621d5bb49b69b3492d90562d93 (patch) (unidiff) | |
tree | c310f4fff5e476087e8406614e57a7f258f1b14f | |
parent | 7a439999b9fa2bd7ad76e195cdf95bf5211952cb (diff) | |
download | kdepimpi-2468bddcb380d8621d5bb49b69b3492d90562d93.zip kdepimpi-2468bddcb380d8621d5bb49b69b3492d90562d93.tar.gz kdepimpi-2468bddcb380d8621d5bb49b69b3492d90562d93.tar.bz2 |
sync
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 25 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 5 |
5 files changed, 29 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 307027a..e45240a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1647,25 +1647,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1647 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1647 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1648 | eventRSync->setDtStart( mLastCalendarSync ); | 1648 | eventRSync->setDtStart( mLastCalendarSync ); |
1649 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1649 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1650 | eventRSync->setCategories( i18n("SyncEvent") ); | 1650 | eventRSync->setCategories( i18n("SyncEvent") ); |
1651 | } | 1651 | } |
1652 | } | 1652 | } |
1653 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1653 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1654 | fullDateRange = true; | 1654 | fullDateRange = true; |
1655 | 1655 | ||
1656 | if ( ! fullDateRange ) { | 1656 | if ( ! fullDateRange ) { |
1657 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1657 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1658 | 1658 | ||
1659 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1659 | qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1660 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1660 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1661 | fullDateRange = true; | 1661 | fullDateRange = true; |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | if ( mSyncManager->syncWithDesktop() ) { | 1664 | if ( mSyncManager->syncWithDesktop() ) { |
1665 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1665 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1666 | } | 1666 | } |
1667 | if ( fullDateRange ) | 1667 | if ( fullDateRange ) |
1668 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1668 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1669 | else | 1669 | else |
1670 | mLastCalendarSync = eventLSync->dtStart(); | 1670 | mLastCalendarSync = eventLSync->dtStart(); |
1671 | // for resyncing if own file has changed | 1671 | // for resyncing if own file has changed |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 0a94914..66836a1 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -307,24 +307,25 @@ public: | |||
307 | */ | 307 | */ |
308 | void setLoadedProductId( const QString & ); | 308 | void setLoadedProductId( const QString & ); |
309 | /** | 309 | /** |
310 | Return product id taken from file that has been loaded. Returns | 310 | Return product id taken from file that has been loaded. Returns |
311 | QString::null, if no calendar has been loaded. | 311 | QString::null, if no calendar has been loaded. |
312 | */ | 312 | */ |
313 | QString loadedProductId(); | 313 | QString loadedProductId(); |
314 | int defaultCalendar(); | 314 | int defaultCalendar(); |
315 | void setDontDeleteIncidencesOnClose (); | 315 | void setDontDeleteIncidencesOnClose (); |
316 | public slots: | 316 | public slots: |
317 | void setDefaultCalendar( int ); | 317 | void setDefaultCalendar( int ); |
318 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 318 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
319 | virtual void setAllCalendarEnabled( bool enable ) = 0; | ||
319 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 320 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
320 | virtual void setReadOnly( int id, bool enable ) = 0; | 321 | virtual void setReadOnly( int id, bool enable ) = 0; |
321 | virtual void setDefaultCalendarEnabledOnly() = 0; | 322 | virtual void setDefaultCalendarEnabledOnly() = 0; |
322 | virtual void setCalendarRemove( int id ) = 0; | 323 | virtual void setCalendarRemove( int id ) = 0; |
323 | virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0; | 324 | virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0; |
324 | 325 | ||
325 | signals: | 326 | signals: |
326 | void calendarChanged(); | 327 | void calendarChanged(); |
327 | void calendarSaved(); | 328 | void calendarSaved(); |
328 | void calendarLoaded(); | 329 | void calendarLoaded(); |
329 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 330 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
330 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 331 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 45e3128..2a57724 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -181,41 +181,51 @@ void CalendarLocal::setSyncEventsEnabled() | |||
181 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 181 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
182 | ev->setCalEnabled( true ); | 182 | ev->setCalEnabled( true ); |
183 | ev = mEventList.next(); | 183 | ev = mEventList.next(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | void CalendarLocal::setSyncEventsReadOnly() | 186 | void CalendarLocal::setSyncEventsReadOnly() |
187 | { | 187 | { |
188 | Event * ev; | 188 | Event * ev; |
189 | ev = mEventList.first(); | 189 | ev = mEventList.first(); |
190 | while ( ev ) { | 190 | while ( ev ) { |
191 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { | 191 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { |
192 | ev->setReadOnly( true ); | 192 | ev->setReadOnly( true ); |
193 | ev->setCalID( 1 ); | ||
194 | } | 193 | } |
195 | ev = mEventList.next(); | 194 | ev = mEventList.next(); |
196 | } | 195 | } |
197 | } | 196 | } |
197 | |||
198 | void CalendarLocal::addCalendar( Calendar* cal ) | 198 | void CalendarLocal::addCalendar( Calendar* cal ) |
199 | { | 199 | { |
200 | cal->setDontDeleteIncidencesOnClose(); | 200 | cal->setDontDeleteIncidencesOnClose(); |
201 | setSyncEventsEnabled(); | ||
201 | { | 202 | { |
202 | QPtrList<Event> EventList = cal->rawEvents(); | 203 | QPtrList<Event> EventList = cal->rawEvents(); |
204 | QPtrList<Event> el; | ||
203 | Event * ev = EventList.first(); | 205 | Event * ev = EventList.first(); |
204 | while ( ev ) { | 206 | while ( ev ) { |
207 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { | ||
208 | Event * se = event( ev->uid() ); | ||
209 | if ( se ) | ||
210 | el.append( se ); | ||
211 | } | ||
205 | ev->unRegisterObserver( cal ); | 212 | ev->unRegisterObserver( cal ); |
206 | ev->registerObserver( this ); | 213 | ev->registerObserver( this ); |
207 | mEventList.append( ev ); | 214 | mEventList.append( ev ); |
208 | ev = EventList.next(); | 215 | ev = EventList.next(); |
209 | } | 216 | } |
217 | for ( ev = el.first(); ev; ev = el.next() ) { | ||
218 | deleteIncidence ( ev ); | ||
219 | } | ||
210 | } | 220 | } |
211 | { | 221 | { |
212 | 222 | ||
213 | QPtrList<Todo> TodoList = cal->rawTodos(); | 223 | QPtrList<Todo> TodoList = cal->rawTodos(); |
214 | Todo * ev = TodoList.first(); | 224 | Todo * ev = TodoList.first(); |
215 | while ( ev ) { | 225 | while ( ev ) { |
216 | QString rel = ev->relatedToUid(); | 226 | QString rel = ev->relatedToUid(); |
217 | if ( !rel.isEmpty() ){ | 227 | if ( !rel.isEmpty() ){ |
218 | ev->setRelatedTo ( 0 ); | 228 | ev->setRelatedTo ( 0 ); |
219 | ev->setRelatedToUid( rel ); | 229 | ev->setRelatedToUid( rel ); |
220 | } | 230 | } |
221 | ev = TodoList.next(); | 231 | ev = TodoList.next(); |
@@ -994,24 +1004,37 @@ void CalendarLocal::setCalendarRemove( int id ) | |||
994 | Journal * ev = JournalList.first(); | 1004 | Journal * ev = JournalList.first(); |
995 | while ( ev ) { | 1005 | while ( ev ) { |
996 | if ( ev->calID() == id ) | 1006 | if ( ev->calID() == id ) |
997 | deleteJournal( ev ); | 1007 | deleteJournal( ev ); |
998 | ev = JournalList.next(); | 1008 | ev = JournalList.next(); |
999 | } | 1009 | } |
1000 | } | 1010 | } |
1001 | 1011 | ||
1002 | clearUndo(0); | 1012 | clearUndo(0); |
1003 | 1013 | ||
1004 | } | 1014 | } |
1005 | 1015 | ||
1016 | void CalendarLocal::setAllCalendarEnabled( bool enable ) | ||
1017 | { | ||
1018 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
1019 | it->setCalEnabled( enable ); | ||
1020 | |||
1021 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | ||
1022 | it->setCalEnabled( enable ); | ||
1023 | |||
1024 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | ||
1025 | it->setCalEnabled( enable ); | ||
1026 | |||
1027 | |||
1028 | } | ||
1006 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 1029 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
1007 | { | 1030 | { |
1008 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1031 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1009 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1032 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1010 | 1033 | ||
1011 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1034 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1012 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1035 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1013 | 1036 | ||
1014 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1037 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1015 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1038 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1016 | 1039 | ||
1017 | } | 1040 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index eb7bf34..b70f0c9 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -185,24 +185,25 @@ class CalendarLocal : public Calendar | |||
185 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 185 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
186 | bool inclusive = false ); | 186 | bool inclusive = false ); |
187 | Todo *todo( QString, QString ); | 187 | Todo *todo( QString, QString ); |
188 | Event *event( QString, QString ); | 188 | Event *event( QString, QString ); |
189 | void getIncidenceCount( int calId, int& events, int & todos, int & journals); | 189 | void getIncidenceCount( int calId, int& events, int & todos, int & journals); |
190 | 190 | ||
191 | public slots: | 191 | public slots: |
192 | void setCalendarEnabled( int id, bool enable ); | 192 | void setCalendarEnabled( int id, bool enable ); |
193 | void setAlarmEnabled( int id, bool enable ); | 193 | void setAlarmEnabled( int id, bool enable ); |
194 | void setReadOnly( int id, bool enable ); | 194 | void setReadOnly( int id, bool enable ); |
195 | void setDefaultCalendarEnabledOnly(); | 195 | void setDefaultCalendarEnabledOnly(); |
196 | void setCalendarRemove( int id ); | 196 | void setCalendarRemove( int id ); |
197 | void setAllCalendarEnabled( bool enable ); | ||
197 | 198 | ||
198 | protected: | 199 | protected: |
199 | 200 | ||
200 | // Event* mNextAlarmEvent; | 201 | // Event* mNextAlarmEvent; |
201 | QString mNextSummary; | 202 | QString mNextSummary; |
202 | QString mNextAlarmEventDateTimeString; | 203 | QString mNextAlarmEventDateTimeString; |
203 | QString mLastAlarmNotificationString; | 204 | QString mLastAlarmNotificationString; |
204 | QDateTime mNextAlarmEventDateTime; | 205 | QDateTime mNextAlarmEventDateTime; |
205 | QDateTime mNextAlarmDateTime; | 206 | QDateTime mNextAlarmDateTime; |
206 | void reInitAlarmSettings(); | 207 | void reInitAlarmSettings(); |
207 | 208 | ||
208 | /** Notification function of IncidenceBase::Observer. */ | 209 | /** Notification function of IncidenceBase::Observer. */ |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 795cd30..d2cb71b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1131,43 +1131,42 @@ void KSyncManager::syncPi() | |||
1131 | mPisyncFinished = true; | 1131 | mPisyncFinished = true; |
1132 | return; | 1132 | return; |
1133 | } | 1133 | } |
1134 | bool ok; | 1134 | bool ok; |
1135 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1135 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1136 | if ( ! ok ) { | 1136 | if ( ! ok ) { |
1137 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1137 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1138 | mPisyncFinished = true; | 1138 | mPisyncFinished = true; |
1139 | return; | 1139 | return; |
1140 | } | 1140 | } |
1141 | mCurrentResourceLocal = ""; | 1141 | mCurrentResourceLocal = ""; |
1142 | mCurrentResourceRemote = ""; | 1142 | mCurrentResourceRemote = ""; |
1143 | qDebug ( "KSM: sync pi %d",mSpecificResources.count() ); | ||
1144 | if ( mSpecificResources.count() ) { | 1143 | if ( mSpecificResources.count() ) { |
1145 | int lastSyncRes = mSpecificResources.count()/2; | 1144 | int lastSyncRes = mSpecificResources.count()/2; |
1146 | int ccc = mSpecificResources.count()-1; | 1145 | int ccc = mSpecificResources.count()-1; |
1147 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { | 1146 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { |
1148 | --ccc; | 1147 | --ccc; |
1149 | --lastSyncRes; | 1148 | --lastSyncRes; |
1150 | qDebug ( "KSM: sync pi %d",ccc ); | 1149 | //qDebug ( "KSM: sync pi %d",ccc ); |
1151 | } | 1150 | } |
1152 | int startLocal = 0; | 1151 | int startLocal = 0; |
1153 | int startRemote = mSpecificResources.count()/2; | 1152 | int startRemote = mSpecificResources.count()/2; |
1154 | emit multiResourceSyncStart( true ); | 1153 | emit multiResourceSyncStart( true ); |
1155 | while ( startLocal < mSpecificResources.count()/2 ) { | 1154 | while ( startLocal < mSpecificResources.count()/2 ) { |
1156 | if ( startLocal+1 >= lastSyncRes ) | 1155 | if ( startLocal+1 >= lastSyncRes ) |
1157 | emit multiResourceSyncStart( false ); | 1156 | emit multiResourceSyncStart( false ); |
1158 | mPisyncFinished = false; | 1157 | mPisyncFinished = false; |
1159 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | 1158 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; |
1160 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | 1159 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; |
1161 | qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1160 | //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1162 | if ( !mCurrentResourceRemote.isEmpty() ) { | 1161 | if ( !mCurrentResourceRemote.isEmpty() ) { |
1163 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1162 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1164 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1163 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1165 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1164 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1166 | commandSocket->readFile( syncFileName() ); | 1165 | commandSocket->readFile( syncFileName() ); |
1167 | while ( !mPisyncFinished ) { | 1166 | while ( !mPisyncFinished ) { |
1168 | //qDebug("waiting "); | 1167 | //qDebug("waiting "); |
1169 | qApp->processEvents(); | 1168 | qApp->processEvents(); |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | ++startRemote; | 1171 | ++startRemote; |
1173 | ++startLocal; | 1172 | ++startLocal; |