summaryrefslogtreecommitdiffabout
path: root/libkcal/phoneformat.cpp
authorzautrix <zautrix>2004-10-06 16:20:25 (UTC)
committer zautrix <zautrix>2004-10-06 16:20:25 (UTC)
commit656636acfb8c607901c97c4f55129e29e1df9913 (patch) (side-by-side diff)
tree25efd61a6b691822a11f43719efcbf69ce7d5c25 /libkcal/phoneformat.cpp
parenta22de800110d8350a5200a994b041e47d51bf4c6 (diff)
downloadkdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.zip
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.gz
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.bz2
more fixes
Diffstat (limited to 'libkcal/phoneformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp117
1 files changed, 3 insertions, 114 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index b2a62b1..c39413e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -36,6 +36,7 @@
#include <klocale.h>
#include <kglobal.h>
#include <kmessagebox.h>
+#include <phoneaccess.h>
#include "calendar.h"
#include "alarm.h"
@@ -84,111 +85,13 @@ public:
PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
{
mProfileName = profileName;
- writeConfig( device, connection, model );
+ PhoneAccess::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;
- bool addPort = true, addConnection = true, addModel = true;
- QFile file( fileName );
- if ( QFile::exists( fileName) ) {
- if (!file.open( IO_ReadOnly ) ) {
- qDebug("Error: cannot open %s ", fileName.latin1() );
- return;
- }
- QString line;
- while ( file.readLine( line, 1024 ) > 0 ) {
- //qDebug("*%s* ", line.latin1() );
- if ( line.left(7 ) == "[gammu]" ) {
- ;
- } else
- if ( line.left(4 ) == "port" ) {
- if ( line == "port = " + device+"\n" ) {
- content += line ;
- addPort = false;
- //qDebug("port found" );
- }
-
- } else if ( line.left(5 ) == "model" ) {
- if ( line == "model = " + model +"\n") {
- content += line ;
- addModel = false;
- //qDebug("model found" );
- }
-
- } else if ( line.left( 10 ) == "connection" ) {
- if ( line == "connection = " + connection +"\n") {
- addConnection = false;
- content += line ;
- //qDebug("con found" );
- }
-
- } else {
- content += line ;
- }
- }
- file.close();
- } else {
- if ( ! connection.isEmpty() ) {
- addConnection = true;
- }
- if ( ! device.isEmpty() ) {
- addPort = true;
- }
- if ( ! model.isEmpty() ) {
- addModel = true;
- }
- }
-
- if ( addConnection ) {
- if ( ! write )
- content += "[gammu]\n";
- write = true;
- content += "connection = ";
- content += connection;
- content += "\n";
- }
- if ( addPort ) {
- if ( ! write )
- content += "[gammu]\n";
- write = true;
- content += "port = ";
- content += device;
- content += "\n";
-
- }
- if ( addModel ) {
- if ( ! write )
- content += "[gammu]\n";
- write = true;
- content += "model = ";
- content += model;
- content += "\n";
- }
- if ( write ) {
- if (!file.open( IO_WriteOnly ) ) {
- qDebug("Error: cannot write file %s ", fileName.latin1() );
- return;
- }
- qDebug("Writing file %s ", fileName.latin1() );
- QTextStream ts( &file );
- ts << content ;
- file.close();
- }
-
-}
#if 0
int PhoneFormat::initDevice(GSM_StateMachine *s)
{
@@ -590,21 +493,7 @@ bool PhoneFormat::writeToPhone( Calendar * calendar)
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;
+ return PhoneAccess::writeToPhone( fileName );
}
bool PhoneFormat::save( Calendar *calendar)
{