author | zautrix <zautrix> | 2004-09-12 20:24:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 20:24:05 (UTC) |
commit | 7fcde3393eb2150fd96f7899056ec11d0fd2931e (patch) (unidiff) | |
tree | d46619e939b655b33df280f16c30b5e675be7450 /libkcal | |
parent | 5b434dd78f71bcea5e6067fc8ae0faaaea313f9d (diff) | |
download | kdepimpi-7fcde3393eb2150fd96f7899056ec11d0fd2931e.zip kdepimpi-7fcde3393eb2150fd96f7899056ec11d0fd2931e.tar.gz kdepimpi-7fcde3393eb2150fd96f7899056ec11d0fd2931e.tar.bz2 |
writing gammurc added
-rw-r--r-- | libkcal/phoneformat.cpp | 97 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 |
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 | |||
@@ -30,5 +30,5 @@ | |||
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qdir.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
@@ -85,7 +85,96 @@ PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, | |||
85 | { | 85 | { |
86 | mProfileName = profileName; | 86 | mProfileName = profileName; |
87 | mDevice = device; | 87 | |
88 | mConnection = connection; | 88 | QString fileName = QDir::homeDirPath() +"/.gammurc"; |
89 | mModel = model; | 89 | //qDebug("save %d ", load ); |
90 | QString content; | ||
91 | bool write = false; | ||
92 | bool addPort = true, addConnection = true, addModel = true; | ||
93 | QFile file( fileName ); | ||
94 | if ( QFile::exists( fileName) ) { | ||
95 | if (!file.open( IO_ReadOnly ) ) { | ||
96 | qDebug("Error: cannot open %s ", fileName.latin1() ); | ||
97 | return; | ||
98 | } | ||
99 | QString line; | ||
100 | while ( file.readLine( line, 1024 ) > 0 ) { | ||
101 | //qDebug("*%s* ", line.latin1() ); | ||
102 | if ( line.left(7 ) == "[gammu]" ) { | ||
103 | ; | ||
104 | } else | ||
105 | if ( line.left(4 ) == "port" ) { | ||
106 | if ( line == "port = " + device+"\n" ) { | ||
107 | content += line ; | ||
108 | addPort = false; | ||
109 | //qDebug("port found" ); | ||
110 | } | ||
111 | |||
112 | } else if ( line.left(5 ) == "model" ) { | ||
113 | if ( line == "model = " + model +"\n") { | ||
114 | content += line ; | ||
115 | addModel = false; | ||
116 | //qDebug("model found" ); | ||
117 | } | ||
118 | |||
119 | } else if ( line.left( 10 ) == "connection" ) { | ||
120 | if ( line == "connection = " + connection +"\n") { | ||
121 | addConnection = false; | ||
122 | content += line ; | ||
123 | //qDebug("con found" ); | ||
124 | } | ||
125 | |||
126 | } else { | ||
127 | content += line ; | ||
128 | } | ||
129 | } | ||
130 | file.close(); | ||
131 | } else { | ||
132 | if ( ! connection.isEmpty() ) { | ||
133 | addConnection = true; | ||
134 | } | ||
135 | if ( ! device.isEmpty() ) { | ||
136 | addPort = true; | ||
137 | |||
138 | } | ||
139 | if ( ! model.isEmpty() ) { | ||
140 | addModel = true; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | if ( addConnection ) { | ||
145 | if ( ! write ) | ||
146 | content += "[gammu]\n"; | ||
147 | write = true; | ||
148 | content += "connection = "; | ||
149 | content += connection; | ||
150 | content += "\n"; | ||
151 | } | ||
152 | if ( addPort ) { | ||
153 | if ( ! write ) | ||
154 | content += "[gammu]\n"; | ||
155 | write = true; | ||
156 | content += "port = "; | ||
157 | content += device; | ||
158 | content += "\n"; | ||
159 | |||
160 | } | ||
161 | if ( addModel ) { | ||
162 | if ( ! write ) | ||
163 | content += "[gammu]\n"; | ||
164 | write = true; | ||
165 | content += "model = "; | ||
166 | content += model; | ||
167 | content += "\n"; | ||
168 | } | ||
169 | if ( write ) { | ||
170 | if (!file.open( IO_WriteOnly ) ) { | ||
171 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | ||
172 | return; | ||
173 | } | ||
174 | qDebug("Writing file %s ", fileName.latin1() ); | ||
175 | QTextStream ts( &file ); | ||
176 | ts << content ; | ||
177 | file.close(); | ||
178 | } | ||
90 | } | 179 | } |
91 | 180 | ||
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 8286098..2d1ff79 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -53,5 +53,5 @@ class PhoneFormat : public QObject { | |||
53 | void copyTodo( Todo* to, Todo* from ); | 53 | void copyTodo( Todo* to, Todo* from ); |
54 | //int initDevice(GSM_StateMachine *s); | 54 | //int initDevice(GSM_StateMachine *s); |
55 | QString mProfileName, mDevice, mConnection, mModel; | 55 | QString mProfileName; |
56 | void afterSave( Incidence* ); | 56 | void afterSave( Incidence* ); |
57 | }; | 57 | }; |