From 07fa092b413b7cde1bd4fc797ce0b30adcb8668d Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 06 Oct 2004 00:33:20 +0000 Subject: export to phone added --- (limited to 'libkcal/phoneformat.cpp') diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 29c1ae6..b2a62b1 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -84,8 +84,19 @@ public: PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) { mProfileName = profileName; - + writeConfig( device, connection, model ); +} + +PhoneFormat::~PhoneFormat() +{ +} +void PhoneFormat::writeConfig( QString device, QString connection, QString model ) +{ +#ifdef _WIN32_ + QString fileName = qApp->applicationDirPath () +"\\gammurc"; +#else QString fileName = QDir::homeDirPath() +"/.gammurc"; +#endif //qDebug("save %d ", load ); QString content; bool write = false; @@ -176,10 +187,7 @@ PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, ts << content ; file.close(); } -} -PhoneFormat::~PhoneFormat() -{ } #if 0 int PhoneFormat::initDevice(GSM_StateMachine *s) @@ -569,6 +577,35 @@ void PhoneFormat::afterSave( Incidence* inc) inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } + +bool PhoneFormat::writeToPhone( Calendar * calendar) +{ +#ifdef _WIN32_ + QString fileName = locateLocal("tmp", "tempfile.vcs"); +#else + QString fileName = "/tmp/kdepimtemp.vcs"; +#endif + + VCalFormat vfsave; + vfsave.setLocalTime ( true ); + if ( ! vfsave.save( calendar, fileName ) ) + return false; + // 4 call kammu +#ifdef DESKTOP_VERSION + QString command ="./kammu --restore " + fileName ; +#else + QString command ="kammu --restore " + fileName ; +#endif + int ret; + while ( (ret = system ( command.latin1())) != 0 ) { + qDebug("Error S::command returned %d. asking users", ret); + int retval = KMessageBox::warningContinueCancel(0, + i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); + if ( retval != KMessageBox::Continue ) + return false; + } + return true; +} bool PhoneFormat::save( Calendar *calendar) { QLabel status ( i18n(" Opening device ..."), 0 ); @@ -583,11 +620,6 @@ bool PhoneFormat::save( Calendar *calendar) status.raise(); qApp->processEvents(); QString message; -#ifdef _WIN32_ - QString fileName = locateLocal("tmp", "tempfile.vcs"); -#else - QString fileName = "/tmp/kdepimtemp.vcs"; -#endif // 1 remove events which should be deleted QPtrList er = calendar->rawEvents(); @@ -614,24 +646,8 @@ bool PhoneFormat::save( Calendar *calendar) to = tl.next(); } // 3 save file - VCalFormat vfsave; - vfsave.setLocalTime ( true ); - if ( ! vfsave.save( calendar, fileName ) ) + if ( !writeToPhone( calendar ) ) return false; - // 4 call kammu -#ifdef DESKTOP_VERSION - QString command ="./kammu --restore " + fileName ; -#else - QString command ="kammu --restore " + fileName ; -#endif - int ret; - while ( (ret = system ( command.latin1())) != 0 ) { - qDebug("Error S::command returned %d. asking users", ret); - int retval = KMessageBox::warningContinueCancel(0, - i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); - if ( retval != KMessageBox::Continue ) - return false; - } // 5 reread data message = i18n(" Rereading all data ... "); -- cgit v0.9.0.2