-rw-r--r-- | libkcal/phoneformat.cpp | 68 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 |
2 files changed, 44 insertions, 26 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 29c1ae6..b2a62b1 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -86,4 +86,15 @@ PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, | |||
86 | mProfileName = profileName; | 86 | mProfileName = profileName; |
87 | 87 | writeConfig( device, connection, model ); | |
88 | } | ||
89 | |||
90 | PhoneFormat::~PhoneFormat() | ||
91 | { | ||
92 | } | ||
93 | void PhoneFormat::writeConfig( QString device, QString connection, QString model ) | ||
94 | { | ||
95 | #ifdef _WIN32_ | ||
96 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; | ||
97 | #else | ||
88 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | 98 | QString fileName = QDir::homeDirPath() +"/.gammurc"; |
99 | #endif | ||
89 | //qDebug("save %d ", load ); | 100 | //qDebug("save %d ", load ); |
@@ -178,6 +189,3 @@ PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, | |||
178 | } | 189 | } |
179 | } | ||
180 | 190 | ||
181 | PhoneFormat::~PhoneFormat() | ||
182 | { | ||
183 | } | 191 | } |
@@ -571,2 +579,31 @@ void PhoneFormat::afterSave( Incidence* inc) | |||
571 | } | 579 | } |
580 | |||
581 | bool PhoneFormat::writeToPhone( Calendar * calendar) | ||
582 | { | ||
583 | #ifdef _WIN32_ | ||
584 | QString fileName = locateLocal("tmp", "tempfile.vcs"); | ||
585 | #else | ||
586 | QString fileName = "/tmp/kdepimtemp.vcs"; | ||
587 | #endif | ||
588 | |||
589 | VCalFormat vfsave; | ||
590 | vfsave.setLocalTime ( true ); | ||
591 | if ( ! vfsave.save( calendar, fileName ) ) | ||
592 | return false; | ||
593 | // 4 call kammu | ||
594 | #ifdef DESKTOP_VERSION | ||
595 | QString command ="./kammu --restore " + fileName ; | ||
596 | #else | ||
597 | QString command ="kammu --restore " + fileName ; | ||
598 | #endif | ||
599 | int ret; | ||
600 | while ( (ret = system ( command.latin1())) != 0 ) { | ||
601 | qDebug("Error S::command returned %d. asking users", ret); | ||
602 | int retval = KMessageBox::warningContinueCancel(0, | ||
603 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); | ||
604 | if ( retval != KMessageBox::Continue ) | ||
605 | return false; | ||
606 | } | ||
607 | return true; | ||
608 | } | ||
572 | bool PhoneFormat::save( Calendar *calendar) | 609 | bool PhoneFormat::save( Calendar *calendar) |
@@ -585,7 +622,2 @@ bool PhoneFormat::save( Calendar *calendar) | |||
585 | QString message; | 622 | QString message; |
586 | #ifdef _WIN32_ | ||
587 | QString fileName = locateLocal("tmp", "tempfile.vcs"); | ||
588 | #else | ||
589 | QString fileName = "/tmp/kdepimtemp.vcs"; | ||
590 | #endif | ||
591 | 623 | ||
@@ -616,20 +648,4 @@ bool PhoneFormat::save( Calendar *calendar) | |||
616 | // 3 save file | 648 | // 3 save file |
617 | VCalFormat vfsave; | 649 | if ( !writeToPhone( calendar ) ) |
618 | vfsave.setLocalTime ( true ); | ||
619 | if ( ! vfsave.save( calendar, fileName ) ) | ||
620 | return false; | 650 | return false; |
621 | // 4 call kammu | ||
622 | #ifdef DESKTOP_VERSION | ||
623 | QString command ="./kammu --restore " + fileName ; | ||
624 | #else | ||
625 | QString command ="kammu --restore " + fileName ; | ||
626 | #endif | ||
627 | int ret; | ||
628 | while ( (ret = system ( command.latin1())) != 0 ) { | ||
629 | qDebug("Error S::command returned %d. asking users", ret); | ||
630 | int retval = KMessageBox::warningContinueCancel(0, | ||
631 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); | ||
632 | if ( retval != KMessageBox::Continue ) | ||
633 | return false; | ||
634 | } | ||
635 | 651 | ||
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 2d1ff79..61e8160 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -50,2 +50,4 @@ class PhoneFormat : public QObject { | |||
50 | static ulong getCsumEvent( Event* ev ); | 50 | static ulong getCsumEvent( Event* ev ); |
51 | static void writeConfig( QString device,QString connection, QString model ); | ||
52 | static bool writeToPhone( Calendar * ); | ||
51 | private: | 53 | private: |