summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-09-12 20:24:05 (UTC)
committer zautrix <zautrix>2004-09-12 20:24:05 (UTC)
commit7fcde3393eb2150fd96f7899056ec11d0fd2931e (patch) (side-by-side diff)
treed46619e939b655b33df280f16c30b5e675be7450 /libkcal
parent5b434dd78f71bcea5e6067fc8ae0faaaea313f9d (diff)
downloadkdepimpi-7fcde3393eb2150fd96f7899056ec11d0fd2931e.zip
kdepimpi-7fcde3393eb2150fd96f7899056ec11d0fd2931e.tar.gz
kdepimpi-7fcde3393eb2150fd96f7899056ec11d0fd2931e.tar.bz2
writing gammurc added
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp97
-rw-r--r--libkcal/phoneformat.h2
2 files changed, 94 insertions, 5 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 178a63e..99d6a06 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -20,25 +20,25 @@
*/
#include <qdatetime.h>
#include <qstring.h>
#include <qapplication.h>
#include <qptrlist.h>
#include <qregexp.h>
#include <qmessagebox.h>
#include <qclipboard.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qtextcodec.h>
-#include <qxml.h>
+#include <qdir.h>
#include <qlabel.h>
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include "calendar.h"
#include "alarm.h"
#include "recurrence.h"
#include "calendarlocal.h"
@@ -75,27 +75,116 @@ public:
}
return datestr + timestr;
}
};
PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
{
mProfileName = profileName;
- mDevice = device;
- mConnection = connection;
- mModel = model;
+
+ QString fileName = QDir::homeDirPath() +"/.gammurc";
+ //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();
+ }
}
PhoneFormat::~PhoneFormat()
{
}
#if 0
int PhoneFormat::initDevice(GSM_StateMachine *s)
{
GSM_ReadConfig(NULL, &s->Config[0], 0);
s->ConfigNum = 1;
GSM_Config *cfg = &s->Config[0];
if ( ! mConnection.isEmpty() ) {
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 8286098..2d1ff79 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -43,19 +43,19 @@ class PhoneFormat : public QObject {
bool load( Calendar * ,Calendar * );
bool save( Calendar * );
bool fromString( Calendar *, const QString & );
QString toString( Calendar * );
static ulong getCsum( const QStringList & );
static ulong getCsumTodo( Todo* to );
static ulong getCsumEvent( Event* ev );
private:
void copyEvent( Event* to, Event* from );
void copyTodo( Todo* to, Todo* from );
//int initDevice(GSM_StateMachine *s);
- QString mProfileName, mDevice, mConnection, mModel;
+ QString mProfileName;
void afterSave( Incidence* );
};
}
#endif