-rw-r--r-- | libkcal/phoneformat.cpp | 7 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 3555dc6..281434e 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -275,51 +275,49 @@ ulong PhoneFormat::getCsum( const QStringList & attList) | |||
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 |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool 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("tmp", "phonefile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/phonefile.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | QString command; | 298 | QString command; |
299 | int ret = PhoneAccess::readFromPhone( fileName ); | 299 | if ( ! PhoneAccess::readFromPhone( fileName )) { |
300 | if ( ret != 0 ) { | ||
301 | qDebug("Error::command returned %d", ret); | ||
302 | return false; | 300 | return false; |
303 | } | 301 | } |
304 | VCalFormat vfload; | 302 | VCalFormat vfload; |
305 | vfload.setLocalTime ( true ); | 303 | vfload.setLocalTime ( true ); |
306 | qDebug("loading file ..."); | 304 | qDebug("loading file ..."); |
307 | 305 | ||
308 | if ( ! vfload.load( calendar, fileName ) ) | 306 | if ( ! vfload.load( calendar, fileName ) ) |
309 | return false; | 307 | return false; |
310 | QPtrList<Event> er = calendar->rawEvents(); | 308 | QPtrList<Event> er = calendar->rawEvents(); |
311 | Event* ev = er.first(); | 309 | Event* ev = er.first(); |
312 | qDebug("reading events... "); | 310 | qDebug("reading events... "); |
313 | while ( ev ) { | 311 | while ( ev ) { |
314 | QStringList cat = ev->categories(); | 312 | QStringList cat = ev->categories(); |
315 | if ( cat.contains( "MeetingDEF" )) { | 313 | if ( cat.contains( "MeetingDEF" )) { |
316 | ev->setCategories( QStringList() ); | 314 | ev->setCategories( QStringList() ); |
317 | } | 315 | } |
318 | int id = ev->pilotId(); | 316 | int id = ev->pilotId(); |
319 | Event *event; | 317 | Event *event; |
320 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 318 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
321 | if ( event ) { | 319 | if ( event ) { |
322 | event = (Event*)event->clone(); | 320 | event = (Event*)event->clone(); |
323 | copyEvent( event, ev ); | 321 | copyEvent( event, ev ); |
324 | calendar->deleteEvent( ev ); | 322 | calendar->deleteEvent( ev ); |
325 | calendar->addEvent( event); | 323 | calendar->addEvent( event); |
@@ -466,50 +464,53 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) | |||
466 | void PhoneFormat::afterSave( Incidence* inc) | 464 | void PhoneFormat::afterSave( Incidence* inc) |
467 | { | 465 | { |
468 | uint csum; | 466 | uint csum; |
469 | inc->removeID( mProfileName ); | 467 | inc->removeID( mProfileName ); |
470 | if ( inc->type() == "Event") | 468 | if ( inc->type() == "Event") |
471 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 469 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
472 | else | 470 | else |
473 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 471 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
474 | inc->setCsum( mProfileName, QString::number( csum )); | 472 | inc->setCsum( mProfileName, QString::number( csum )); |
475 | 473 | ||
476 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
477 | 475 | ||
478 | } | 476 | } |
479 | 477 | ||
480 | bool PhoneFormat::writeToPhone( Calendar * calendar) | 478 | bool PhoneFormat::writeToPhone( Calendar * calendar) |
481 | { | 479 | { |
482 | #ifdef _WIN32_ | 480 | #ifdef _WIN32_ |
483 | QString fileName = locateLocal("tmp", "tempfile.vcs"); | 481 | QString fileName = locateLocal("tmp", "tempfile.vcs"); |
484 | #else | 482 | #else |
485 | QString fileName = "/tmp/kdepimtemp.vcs"; | 483 | QString fileName = "/tmp/kdepimtemp.vcs"; |
486 | #endif | 484 | #endif |
487 | 485 | ||
488 | VCalFormat vfsave; | 486 | VCalFormat vfsave; |
489 | vfsave.setLocalTime ( true ); | 487 | vfsave.setLocalTime ( true ); |
488 | QString id = calendar->timeZoneId(); | ||
489 | calendar->setLocalTime(); | ||
490 | if ( ! vfsave.save( calendar, fileName ) ) | 490 | if ( ! vfsave.save( calendar, fileName ) ) |
491 | return false; | 491 | return false; |
492 | calendar->setTimeZoneId( id ); | ||
492 | return PhoneAccess::writeToPhone( fileName ); | 493 | return PhoneAccess::writeToPhone( fileName ); |
493 | } | 494 | } |
494 | bool PhoneFormat::save( Calendar *calendar) | 495 | bool PhoneFormat::save( Calendar *calendar) |
495 | { | 496 | { |
496 | QLabel status ( i18n(" Opening device ..."), 0 ); | 497 | QLabel status ( i18n(" Opening device ..."), 0 ); |
497 | int w = status.sizeHint().width()+20 ; | 498 | int w = status.sizeHint().width()+20 ; |
498 | if ( w < 200 ) w = 230; | 499 | if ( w < 200 ) w = 230; |
499 | int h = status.sizeHint().height()+20 ; | 500 | int h = status.sizeHint().height()+20 ; |
500 | int dw = QApplication::desktop()->width(); | 501 | int dw = QApplication::desktop()->width(); |
501 | int dh = QApplication::desktop()->height(); | 502 | int dh = QApplication::desktop()->height(); |
502 | status.setCaption(i18n("Writing to phone...") ); | 503 | status.setCaption(i18n("Writing to phone...") ); |
503 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 504 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
504 | status.show(); | 505 | status.show(); |
505 | status.raise(); | 506 | status.raise(); |
506 | qApp->processEvents(); | 507 | qApp->processEvents(); |
507 | QString message; | 508 | QString message; |
508 | 509 | ||
509 | // 1 remove events which should be deleted | 510 | // 1 remove events which should be deleted |
510 | QPtrList<Event> er = calendar->rawEvents(); | 511 | QPtrList<Event> er = calendar->rawEvents(); |
511 | Event* ev = er.first(); | 512 | Event* ev = er.first(); |
512 | while ( ev ) { | 513 | while ( ev ) { |
513 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 514 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
514 | calendar->deleteEvent( ev ); | 515 | calendar->deleteEvent( ev ); |
515 | } else { | 516 | } else { |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 5fafa1f..8298aa6 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -142,32 +142,32 @@ bool PhoneAccess::writeToPhone( QString fileName) | |||
142 | int ret; | 142 | int ret; |
143 | while ( (ret = system ( command.latin1())) != 0 ) { | 143 | while ( (ret = system ( command.latin1())) != 0 ) { |
144 | qDebug("Error S::command returned %d.", ret); | 144 | qDebug("Error S::command returned %d.", ret); |
145 | int retval = KMessageBox::warningContinueCancel(0, | 145 | int retval = KMessageBox::warningContinueCancel(0, |
146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); |
147 | if ( retval != KMessageBox::Continue ) | 147 | if ( retval != KMessageBox::Continue ) |
148 | return false; | 148 | return false; |
149 | } | 149 | } |
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | bool PhoneAccess::readFromPhone( QString fileName) | 152 | bool PhoneAccess::readFromPhone( QString fileName) |
153 | { | 153 | { |
154 | 154 | ||
155 | #ifdef DESKTOP_VERSION | 155 | #ifdef DESKTOP_VERSION |
156 | #ifdef _WIN32_ | 156 | #ifdef _WIN32_ |
157 | QString command ="kammu --backup " + fileName + " -yes" ; | 157 | QString command ="kammu --backup " + fileName + " -yes" ; |
158 | #else | 158 | #else |
159 | QString command ="./kammu --backup " + fileName + " -yes" ; | 159 | QString command ="./kammu --backup " + fileName + " -yes" ; |
160 | #endif | 160 | #endif |
161 | #else | 161 | #else |
162 | QString command ="kammu --backup " + fileName + " -yes" ; | 162 | QString command ="kammu --backup " + fileName + " -yes" ; |
163 | #endif | 163 | #endif |
164 | int ret; | 164 | int ret; |
165 | while ( (ret = system ( command.latin1())) != 0 ) { | 165 | while ( (ret = system ( command.latin1())) != 0 ) { |
166 | qDebug("Error S::command returned %d.", ret); | 166 | qDebug("Error reading from phone:Command returned %d", ret); |
167 | int retval = KMessageBox::warningContinueCancel(0, | 167 | int retval = KMessageBox::warningContinueCancel(0, |
168 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 168 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); |
169 | if ( retval != KMessageBox::Continue ) | 169 | if ( retval != KMessageBox::Continue ) |
170 | return false; | 170 | return false; |
171 | } | 171 | } |
172 | return true; | 172 | return true; |
173 | } | 173 | } |