summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp23
-rw-r--r--libkcal/alarm.cpp16
-rw-r--r--libkcal/alarm.h2
-rw-r--r--libkcal/phoneformat.cpp58
4 files changed, 63 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index cfd9290..d5d31e2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1115,58 +1115,73 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1115 } else { 1115 } else {
1116 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1116 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1117 ++addedEventR; 1117 ++addedEventR;
1118 inL->setLastModified( modifiedCalendar ); 1118 inL->setLastModified( modifiedCalendar );
1119 remote->addIncidence( inL->clone() ); 1119 remote->addIncidence( inL->clone() );
1120 } 1120 }
1121 } 1121 }
1122 } 1122 }
1123 } 1123 }
1124 } 1124 }
1125 inL = el.next(); 1125 inL = el.next();
1126 } 1126 }
1127 int delFut = 0;
1127 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1128 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1128 er = remote->rawIncidences(); 1129 er = remote->rawIncidences();
1129 inR = er.first(); 1130 inR = er.first();
1130 QDateTime dt; 1131 QDateTime dt;
1131 QDateTime cur = QDateTime::currentDateTime(); 1132 QDateTime cur = QDateTime::currentDateTime();
1132 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); 1133 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 );
1133 while ( inR ) { 1134 while ( inR ) {
1134 if ( inR->type() == "Todo" ) { 1135 if ( inR->type() == "Todo" ) {
1135 Todo * t = (Todo*)inR; 1136 Todo * t = (Todo*)inR;
1136 if ( t->hasDueDate() ) 1137 if ( t->hasDueDate() )
1137 dt = t->dtDue(); 1138 dt = t->dtDue();
1138 else 1139 else
1139 dt = cur.addSecs( 62 ); 1140 dt = cur.addSecs( 62 );
1140 } 1141 }
1141 else dt = inR->dtStart(); 1142 else if (inR->type() == "Event" ) {
1142 if ( dt < cur || dt > end ) 1143 bool ok;
1144 dt = inR->getNextOccurence( cur, &ok );
1145 if ( !ok )
1146 dt = cur.addSecs( -62 );
1147 }
1148 else
1149 dt = inR->dtStart();
1150 if ( dt < cur || dt > end ) {
1143 remote->deleteIncidence( inR ); 1151 remote->deleteIncidence( inR );
1152 ++delFut;
1153 }
1144 inR = er.next(); 1154 inR = er.next();
1145 } 1155 }
1146 } 1156 }
1147 bar.hide(); 1157 bar.hide();
1148 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1158 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1149 eventLSync->setReadOnly( false ); 1159 eventLSync->setReadOnly( false );
1150 eventLSync->setDtStart( mLastCalendarSync ); 1160 eventLSync->setDtStart( mLastCalendarSync );
1151 eventRSync->setDtStart( mLastCalendarSync ); 1161 eventRSync->setDtStart( mLastCalendarSync );
1152 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1162 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1153 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1163 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1154 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1164 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1155 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1165 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1156 eventLSync->setReadOnly( true ); 1166 eventLSync->setReadOnly( true );
1157 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1167 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1158 remote->addEvent( eventRSync ); 1168 remote->addEvent( eventRSync );
1159 QString mes; 1169 QString mes;
1160 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1170 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1171 QString delmess;
1172 if ( delFut ) {
1173 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1174 mes += delmess;
1175 }
1161 if ( KOPrefs::instance()->mShowSyncSummary ) { 1176 if ( KOPrefs::instance()->mShowSyncSummary ) {
1162 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1177 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1163 } 1178 }
1164 qDebug( mes ); 1179 qDebug( mes );
1165 mCalendar->checkAlarmForIncidence( 0, true ); 1180 mCalendar->checkAlarmForIncidence( 0, true );
1166 return syncOK; 1181 return syncOK;
1167} 1182}
1168 1183
1169void CalendarView::setSyncDevice( QString s ) 1184void CalendarView::setSyncDevice( QString s )
1170{ 1185{
1171 mCurrentSyncDevice= s; 1186 mCurrentSyncDevice= s;
1172} 1187}
@@ -1236,30 +1251,28 @@ void CalendarView::syncExternal( int mode )
1236 } else 1251 } else
1237 return; 1252 return;
1238 if ( loadSuccess ) { 1253 if ( loadSuccess ) {
1239 getEventViewerDialog()->setSyncMode( true ); 1254 getEventViewerDialog()->setSyncMode( true );
1240 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1255 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1241 getEventViewerDialog()->setSyncMode( false ); 1256 getEventViewerDialog()->setSyncMode( false );
1242 qApp->processEvents(); 1257 qApp->processEvents();
1243 if ( syncOK ) { 1258 if ( syncOK ) {
1244 if ( KOPrefs::instance()->mWriteBackFile ) 1259 if ( KOPrefs::instance()->mWriteBackFile )
1245 { 1260 {
1246 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1261 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1247 Incidence* inc = iL.first(); 1262 Incidence* inc = iL.first();
1248 /* obsolete
1249 while ( inc ) { 1263 while ( inc ) {
1250 inc->setZaurusStat( inc->revision () ); 1264 inc->removeID(mCurrentSyncDevice);
1251 inc = iL.next(); 1265 inc = iL.next();
1252 } 1266 }
1253 */
1254#ifndef DESKTOP_VERSION 1267#ifndef DESKTOP_VERSION
1255 if ( sharpFormat ) 1268 if ( sharpFormat )
1256 sharpFormat->save(calendar); 1269 sharpFormat->save(calendar);
1257#endif 1270#endif
1258 if ( phoneFormat ) 1271 if ( phoneFormat )
1259 phoneFormat->save(calendar); 1272 phoneFormat->save(calendar);
1260 iL = calendar->rawIncidences(); 1273 iL = calendar->rawIncidences();
1261 inc = iL.first(); 1274 inc = iL.first();
1262 Incidence* loc; 1275 Incidence* loc;
1263 while ( inc ) { 1276 while ( inc ) {
1264 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1277 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1265 loc = mCalendar->incidence(inc->uid() ); 1278 loc = mCalendar->incidence(inc->uid() );
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 07812c2..29e6205 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -291,24 +291,40 @@ void Alarm::setText(const QString &text)
291QString Alarm::text() const 291QString Alarm::text() const
292{ 292{
293 return (mType == Display) ? mDescription : QString::null; 293 return (mType == Display) ? mDescription : QString::null;
294} 294}
295 295
296void Alarm::setTime(const QDateTime &alarmTime) 296void Alarm::setTime(const QDateTime &alarmTime)
297{ 297{
298 mAlarmTime = alarmTime; 298 mAlarmTime = alarmTime;
299 mHasTime = true; 299 mHasTime = true;
300 300
301 mParent->updated(); 301 mParent->updated();
302} 302}
303int Alarm::offset()
304{
305 if ( hasTime() ) {
306 if (mParent->type()=="Todo") {
307 Todo *t = static_cast<Todo*>(mParent);
308 return t->dtDue().secsTo( mAlarmTime ) ;
309 } else
310 return mParent->dtStart().secsTo( mAlarmTime ) ;
311 }
312 else
313 {
314 return mOffset.asSeconds();
315 }
316
317}
318
303 319
304QDateTime Alarm::time() const 320QDateTime Alarm::time() const
305{ 321{
306 if ( hasTime() ) 322 if ( hasTime() )
307 return mAlarmTime; 323 return mAlarmTime;
308 else 324 else
309 { 325 {
310 if (mParent->type()=="Todo") { 326 if (mParent->type()=="Todo") {
311 Todo *t = static_cast<Todo*>(mParent); 327 Todo *t = static_cast<Todo*>(mParent);
312 return mOffset.end( t->dtDue() ); 328 return mOffset.end( t->dtDue() );
313 } else if (mEndOffset) { 329 } else if (mEndOffset) {
314 return mOffset.end( mParent->dtEnd() ); 330 return mOffset.end( mParent->dtEnd() );
diff --git a/libkcal/alarm.h b/libkcal/alarm.h
index ae2eca3..682b626 100644
--- a/libkcal/alarm.h
+++ b/libkcal/alarm.h
@@ -49,25 +49,25 @@ class Alarm : public CustomProperties
49 /** Compare this alarm with another one. */ 49 /** Compare this alarm with another one. */
50 bool operator==(const Alarm &) const; 50 bool operator==(const Alarm &) const;
51 bool operator!=(const Alarm &a) const { return !operator==(a); } 51 bool operator!=(const Alarm &a) const { return !operator==(a); }
52 52
53 /** Set the type of the alarm. 53 /** Set the type of the alarm.
54 If the specified type is different from the current type of the alarm, 54 If the specified type is different from the current type of the alarm,
55 the alarm's type-specific properties are initialised to null. 55 the alarm's type-specific properties are initialised to null.
56 @param type type of alarm. 56 @param type type of alarm.
57 */ 57 */
58 void setType(Type type); 58 void setType(Type type);
59 /** Return the type of the alarm */ 59 /** Return the type of the alarm */
60 Type type() const; 60 Type type() const;
61 61 int offset();
62 /** Set the alarm to be a display alarm. 62 /** Set the alarm to be a display alarm.
63 @param text text to display when the alarm is triggered. 63 @param text text to display when the alarm is triggered.
64 */ 64 */
65 void setDisplayAlarm(const QString &text); 65 void setDisplayAlarm(const QString &text);
66 /** Set the text to be displayed when the alarm is triggered. 66 /** Set the text to be displayed when the alarm is triggered.
67 Ignored if the alarm is not a display alarm. 67 Ignored if the alarm is not a display alarm.
68 */ 68 */
69 void setText(const QString &text); 69 void setText(const QString &text);
70 /** Return the text string that displays when the alarm is triggered. */ 70 /** Return the text string that displays when the alarm is triggered. */
71 QString text() const; 71 QString text() const;
72 72
73 /** Set the alarm to be an audio alarm. 73 /** Set the alarm to be an audio alarm.
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 6d0da5c..178a63e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -129,46 +129,46 @@ ulong PhoneFormat::getCsumTodo( Todo* todo )
129 if ( todo->isCompleted() ) 129 if ( todo->isCompleted() )
130 completedString = "yes"; 130 completedString = "yes";
131 attList << completedString; 131 attList << completedString;
132 int prio = todo->priority(); 132 int prio = todo->priority();
133 if( prio == 2 ) prio = 1; 133 if( prio == 2 ) prio = 1;
134 if (prio == 4 ) prio = 5 ; 134 if (prio == 4 ) prio = 5 ;
135 attList << QString::number( prio ); 135 attList << QString::number( prio );
136 QString alarmString = "na"; 136 QString alarmString = "na";
137 Alarm *alarm; 137 Alarm *alarm;
138 if ( todo->alarms().count() > 0 ) { 138 if ( todo->alarms().count() > 0 ) {
139 alarm = todo->alarms().first(); 139 alarm = todo->alarms().first();
140 if ( alarm->enabled() ) { 140 if ( alarm->enabled() ) {
141 alarmString = QString::number(alarm->startOffset().asSeconds() ); 141 alarmString = QString::number(alarm->offset() );
142 } 142 }
143 } 143 }
144 attList << alarmString; 144 attList << alarmString;
145 attList << todo->categoriesStr(); 145 attList << todo->categoriesStr();
146 attList << todo->secrecyStr(); 146 attList << todo->secrecyStr();
147 return PhoneFormat::getCsum(attList ); 147 return PhoneFormat::getCsum(attList );
148 148
149} 149}
150ulong PhoneFormat::getCsumEvent( Event* event ) 150ulong PhoneFormat::getCsumEvent( Event* event )
151{ 151{
152 QStringList attList; 152 QStringList attList;
153 attList << PhoneParser::dtToString ( event->dtStart() ); 153 attList << PhoneParser::dtToString ( event->dtStart() );
154 attList << PhoneParser::dtToString ( event->dtEnd() ); 154 attList << PhoneParser::dtToString ( event->dtEnd() );
155 attList << event->summary(); 155 attList << event->summary();
156 attList << event->location(); 156 attList << event->location();
157 QString alarmString = "na"; 157 QString alarmString = "na";
158 Alarm *alarm; 158 Alarm *alarm;
159 if ( event->alarms().count() > 0 ) { 159 if ( event->alarms().count() > 0 ) {
160 alarm = event->alarms().first(); 160 alarm = event->alarms().first();
161 if ( alarm->enabled() ) { 161 if ( alarm->enabled() ) {
162 alarmString = QString::number( alarm->startOffset().asSeconds() ); 162 alarmString = QString::number( alarm->offset() );
163 } 163 }
164 } 164 }
165 attList << alarmString; 165 attList << alarmString;
166 Recurrence* rec = event->recurrence(); 166 Recurrence* rec = event->recurrence();
167 QStringList list; 167 QStringList list;
168 bool writeEndDate = false; 168 bool writeEndDate = false;
169 switch ( rec->doesRecur() ) 169 switch ( rec->doesRecur() )
170 { 170 {
171 case Recurrence::rDaily: // 0 171 case Recurrence::rDaily: // 0
172 list.append( "0" ); 172 list.append( "0" );
173 list.append( QString::number( rec->frequency() ));//12 173 list.append( QString::number( rec->frequency() ));//12
174 list.append( "0" ); 174 list.append( "0" );
@@ -268,49 +268,48 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
268 for ( k = 0; k < j; ++k ) { 268 for ( k = 0; k < j; ++k ) {
269 int mul = k +1; 269 int mul = k +1;
270 add = s[k].unicode (); 270 add = s[k].unicode ();
271 if ( k < 16 ) 271 if ( k < 16 )
272 mul = mul * mul; 272 mul = mul * mul;
273 int ii = i+1; 273 int ii = i+1;
274 add = add * mul *ii*ii*ii; 274 add = add * mul *ii*ii*ii;
275 cSum += add; 275 cSum += add;
276 } 276 }
277 } 277 }
278 278
279 } 279 }
280 QString dump = attList.join(","); 280 //QString dump = attList.join(",");
281 qDebug("csum: %d %s", cSum,dump.latin1()); 281 //qDebug("csum: %d %s", cSum,dump.latin1());
282 282
283 return cSum; 283 return cSum;
284 284
285} 285}
286//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 286//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
287#include <stdlib.h> 287#include <stdlib.h>
288#define DEBUGMODE false 288#define DEBUGMODE false
289bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 289bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
290{ 290{
291 291
292 QString fileName; 292 QString fileName;
293#ifdef _WIN32_ 293#ifdef _WIN32_
294 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 294 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
295#else 295#else
296 fileName = "/tmp/kdepimtemp.vcs"; 296 fileName = "/tmp/kdepimtemp.vcs";
297#endif 297#endif
298 QString command ="./kammu --backup " + fileName + " -yes" ; 298 QString command ="./kammu --backup " + fileName + " -yes" ;
299 int ret = system ( command.latin1() ); 299 int ret = system ( command.latin1() );
300 if ( ret != 0 ) { 300 if ( ret != 0 ) {
301 qDebug("Error::command returned %d", ret); 301 qDebug("Error::command returned %d", ret);
302 return false; 302 return false;
303 } 303 }
304 qDebug("Command returned %d", ret);
305 VCalFormat vfload; 304 VCalFormat vfload;
306 vfload.setLocalTime ( true ); 305 vfload.setLocalTime ( true );
307 qDebug("loading file ..."); 306 qDebug("loading file ...");
308 307
309 if ( ! vfload.load( calendar, fileName ) ) 308 if ( ! vfload.load( calendar, fileName ) )
310 return false; 309 return false;
311 QPtrList<Event> er = calendar->rawEvents(); 310 QPtrList<Event> er = calendar->rawEvents();
312 Event* ev = er.first(); 311 Event* ev = er.first();
313 qDebug("reading events... "); 312 qDebug("reading events... ");
314 while ( ev ) { 313 while ( ev ) {
315 QStringList cat = ev->categories(); 314 QStringList cat = ev->categories();
316 if ( cat.contains( "MeetingDEF" )) { 315 if ( cat.contains( "MeetingDEF" )) {
@@ -339,25 +338,25 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
339 QPtrList<Todo> tr = calendar->rawTodos(); 338 QPtrList<Todo> tr = calendar->rawTodos();
340 Todo* ev = tr.first(); 339 Todo* ev = tr.first();
341 while ( ev ) { 340 while ( ev ) {
342 341
343 QStringList cat = ev->categories(); 342 QStringList cat = ev->categories();
344 if ( cat.contains( "MeetingDEF" )) { 343 if ( cat.contains( "MeetingDEF" )) {
345 ev->setCategories( QStringList() ); 344 ev->setCategories( QStringList() );
346 } 345 }
347 int id = ev->pilotId(); 346 int id = ev->pilotId();
348 Todo *event; 347 Todo *event;
349 event = existingCal->todo( mProfileName ,QString::number( id ) ); 348 event = existingCal->todo( mProfileName ,QString::number( id ) );
350 if ( event ) { 349 if ( event ) {
351 qDebug("copy todo %s ", event->summary().latin1()); 350 //qDebug("copy todo %s ", event->summary().latin1());
352 351
353 event = (Todo*)event->clone(); 352 event = (Todo*)event->clone();
354 copyTodo( event, ev ); 353 copyTodo( event, ev );
355 calendar->deleteTodo( ev ); 354 calendar->deleteTodo( ev );
356 calendar->addTodo( event); 355 calendar->addTodo( event);
357 } 356 }
358 else 357 else
359 event = ev; 358 event = ev;
360 uint cSum; 359 uint cSum;
361 cSum = PhoneFormat::getCsumTodo( event ); 360 cSum = PhoneFormat::getCsumTodo( event );
362 event->setCsum( mProfileName, QString::number( cSum )); 361 event->setCsum( mProfileName, QString::number( cSum ));
363 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 362 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
@@ -371,33 +370,35 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
371{ 370{
372 if ( from->dtStart().isValid() ) 371 if ( from->dtStart().isValid() )
373 to->setDtStart( from->dtStart() ); 372 to->setDtStart( from->dtStart() );
374 if ( from->dtEnd().isValid() ) 373 if ( from->dtEnd().isValid() )
375 to->setDtEnd( from->dtEnd() ); 374 to->setDtEnd( from->dtEnd() );
376 if ( !from->location().isEmpty() ) 375 if ( !from->location().isEmpty() )
377 to->setLocation( from->location() ); 376 to->setLocation( from->location() );
378 if ( !from->description().isEmpty() ) 377 if ( !from->description().isEmpty() )
379 to->setDescription( from->description() ); 378 to->setDescription( from->description() );
380 if ( !from->summary().isEmpty() ) 379 if ( !from->summary().isEmpty() )
381 to->setSummary( from->summary() ); 380 to->setSummary( from->summary() );
382 381
383 QPtrListIterator<Alarm> it( from->alarms() ); 382 if ( from->alarms().count() ) {
384 if ( it.current() )
385 to->clearAlarms(); 383 to->clearAlarms();
386 const Alarm *a; 384 Alarm *a = from->alarms().first();
387 while( (a = it.current()) ) { 385 Alarm *b = to->newAlarm( );
388 Alarm *b = new Alarm( *a ); 386 b->setEnabled( a->enabled() );
389 b->setParent( to ); 387 if ( a->hasStartOffset() ) {
390 to->addAlarm( b ); 388 b->setStartOffset( a->startOffset() );
391 ++it; 389 }
390 if ( a->hasTime() )
391 b->setTime( a->time() );
392
392 } 393 }
393 QStringList cat = to->categories(); 394 QStringList cat = to->categories();
394 QStringList catFrom = from->categories(); 395 QStringList catFrom = from->categories();
395 QString nCat; 396 QString nCat;
396 int iii; 397 int iii;
397 for ( iii = 0; iii < catFrom.count();++iii ) { 398 for ( iii = 0; iii < catFrom.count();++iii ) {
398 nCat = catFrom[iii]; 399 nCat = catFrom[iii];
399 if ( !nCat.isEmpty() ) 400 if ( !nCat.isEmpty() )
400 if ( !cat.contains( nCat )) { 401 if ( !cat.contains( nCat )) {
401 cat << nCat; 402 cat << nCat;
402 } 403 }
403 } 404 }
@@ -411,34 +412,35 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
411{ 412{
412 if ( from->dtStart().isValid() ) 413 if ( from->dtStart().isValid() )
413 to->setDtStart( from->dtStart() ); 414 to->setDtStart( from->dtStart() );
414 if ( from->dtDue().isValid() ) 415 if ( from->dtDue().isValid() )
415 to->setDtDue( from->dtDue() ); 416 to->setDtDue( from->dtDue() );
416 if ( !from->location().isEmpty() ) 417 if ( !from->location().isEmpty() )
417 to->setLocation( from->location() ); 418 to->setLocation( from->location() );
418 if ( !from->description().isEmpty() ) 419 if ( !from->description().isEmpty() )
419 to->setDescription( from->description() ); 420 to->setDescription( from->description() );
420 if ( !from->summary().isEmpty() ) 421 if ( !from->summary().isEmpty() )
421 to->setSummary( from->summary() ); 422 to->setSummary( from->summary() );
422 423
423 QPtrListIterator<Alarm> it( from->alarms() ); 424 if ( from->alarms().count() ) {
424 if ( it.current() )
425 to->clearAlarms(); 425 to->clearAlarms();
426 const Alarm *a; 426 Alarm *a = from->alarms().first();
427 while( (a = it.current()) ) { 427 Alarm *b = to->newAlarm( );
428 Alarm *b = new Alarm( *a ); 428 b->setEnabled( a->enabled() );
429 b->setParent( to ); 429 if ( a->hasStartOffset() )
430 to->addAlarm( b ); 430 b->setStartOffset( a->startOffset() );
431 ++it; 431 if ( a->hasTime() )
432 b->setTime( a->time() );
432 } 433 }
434
433 QStringList cat = to->categories(); 435 QStringList cat = to->categories();
434 QStringList catFrom = from->categories(); 436 QStringList catFrom = from->categories();
435 QString nCat; 437 QString nCat;
436 int iii; 438 int iii;
437 for ( iii = 0; iii < catFrom.count();++iii ) { 439 for ( iii = 0; iii < catFrom.count();++iii ) {
438 nCat = catFrom[iii]; 440 nCat = catFrom[iii];
439 if ( !nCat.isEmpty() ) 441 if ( !nCat.isEmpty() )
440 if ( !cat.contains( nCat )) { 442 if ( !cat.contains( nCat )) {
441 cat << nCat; 443 cat << nCat;
442 } 444 }
443 } 445 }
444 to->setCategories( cat ); 446 to->setCategories( cat );
@@ -524,28 +526,25 @@ bool PhoneFormat::save( Calendar *calendar)
524 if ( ! vfsave.save( calendar, fileName ) ) 526 if ( ! vfsave.save( calendar, fileName ) )
525 return false; 527 return false;
526 // 4 call kammu 528 // 4 call kammu
527 QString command ="./kammu --restore " + fileName ; 529 QString command ="./kammu --restore " + fileName ;
528 int ret; 530 int ret;
529 while ( (ret = system ( command.latin1())) != 0 ) { 531 while ( (ret = system ( command.latin1())) != 0 ) {
530 qDebug("Error S::command returned %d. asking users", ret); 532 qDebug("Error S::command returned %d. asking users", ret);
531 int retval = KMessageBox::warningContinueCancel(0, 533 int retval = KMessageBox::warningContinueCancel(0,
532 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); 534 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
533 if ( retval != KMessageBox::Continue ) 535 if ( retval != KMessageBox::Continue )
534 return false; 536 return false;
535 } 537 }
536 if ( ret != 0 ) { 538
537 qDebug("Error S::command returned %d", ret);
538 return false;
539 }
540 // 5 reread data 539 // 5 reread data
541 message = i18n(" Rereading all data ... "); 540 message = i18n(" Rereading all data ... ");
542 status.setText ( message ); 541 status.setText ( message );
543 qApp->processEvents(); 542 qApp->processEvents();
544 CalendarLocal* calendarTemp = new CalendarLocal(); 543 CalendarLocal* calendarTemp = new CalendarLocal();
545 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 544 calendarTemp->setTimeZoneId( calendar->timeZoneId());
546 if ( ! load( calendarTemp,calendar) ){ 545 if ( ! load( calendarTemp,calendar) ){
547 qDebug("error reloading calendar "); 546 qDebug("error reloading calendar ");
548 delete calendarTemp; 547 delete calendarTemp;
549 return false; 548 return false;
550 } 549 }
551 // 6 compare data 550 // 6 compare data
@@ -570,59 +569,58 @@ bool PhoneFormat::save( Calendar *calendar)
570 while ( ev1 ) { 569 while ( ev1 ) {
571 if ( ev1->getCsum( mProfileName ) == cSum ) { 570 if ( ev1->getCsum( mProfileName ) == cSum ) {
572 er1.remove( ev1 ); 571 er1.remove( ev1 );
573 afterSave( ev ); 572 afterSave( ev );
574 ev->setID(mProfileName, ev1->getID(mProfileName) ); 573 ev->setID(mProfileName, ev1->getID(mProfileName) );
575 //qDebug("Event found on phone for %s ", ev->summary().latin1()); 574 //qDebug("Event found on phone for %s ", ev->summary().latin1());
576 575
577 break; 576 break;
578 } 577 }
579 ev1 = er1.next(); 578 ev1 = er1.next();
580 } 579 }
581 if ( ! ev1 ) { 580 if ( ! ev1 ) {
582 ev->removeID(mProfileName); 581 // ev->removeID(mProfileName);
583 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 582 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
584 } 583 }
585 584
586 585
587 ev = er.next(); 586 ev = er.next();
588 } 587 }
589 //algo 6 compare todo 588 //algo 6 compare todo
590 tl = calendar->rawTodos(); 589 tl = calendar->rawTodos();
591 to = tl.first(); 590 to = tl.first();
592 procCount = 0; 591 procCount = 0;
593 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 592 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
594 Todo* to1 ; 593 Todo* to1 ;
595 message = i18n(" Comparing todo # "); 594 message = i18n(" Comparing todo # ");
596 while ( to ) { 595 while ( to ) {
597 qDebug("todo2 %d ", procCount);
598 status.setText ( message + QString::number ( ++procCount ) ); 596 status.setText ( message + QString::number ( ++procCount ) );
599 qApp->processEvents(); 597 qApp->processEvents();
600 uint csum; 598 uint csum;
601 csum = PhoneFormat::getCsumTodo( to ); 599 csum = PhoneFormat::getCsumTodo( to );
602 QString cSum = QString::number( csum ); 600 QString cSum = QString::number( csum );
603 //to->setCsum( mProfileName, cSum ); 601 //to->setCsum( mProfileName, cSum );
604 qDebug("Todo cSum %s ", cSum.latin1()); 602 //qDebug("Todo cSum %s ", cSum.latin1());
605 Todo* to1 = tl1.first(); 603 Todo* to1 = tl1.first();
606 while ( to1 ) { 604 while ( to1 ) {
607 if ( to1->getCsum( mProfileName ) == cSum ) { 605 if ( to1->getCsum( mProfileName ) == cSum ) {
608 tl1.remove( to1 ); 606 tl1.remove( to1 );
609 afterSave( to ); 607 afterSave( to );
610 to->setID(mProfileName, to1->getID(mProfileName) ); 608 to->setID(mProfileName, to1->getID(mProfileName) );
611 break; 609 break;
612 } 610 }
613 to1 = tl1.next(); 611 to1 = tl1.next();
614 } 612 }
615 if ( ! to1 ) { 613 if ( ! to1 ) {
616 to->removeID(mProfileName); 614 //to->removeID(mProfileName);
617 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 615 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
618 } 616 }
619 617
620 to = tl.next(); 618 to = tl.next();
621 } 619 }
622 delete calendarTemp; 620 delete calendarTemp;
623 return true; 621 return true;
624 622
625 623
626 624
627} 625}
628 626