author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkdepim/phoneaccess.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | libkdepim/phoneaccess.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 89db22b..0ea73f5 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -17,21 +17,22 @@ | |||
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <QDesktopWidget> |
26 | #include <q3ptrlist.h> | ||
26 | #include <qregexp.h> | 27 | #include <qregexp.h> |
27 | #include <qfile.h> | 28 | #include <qfile.h> |
28 | #include <qlabel.h> | 29 | #include <qlabel.h> |
29 | #include <qtextstream.h> | 30 | #include <q3textstream.h> |
30 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
31 | #include <qdir.h> | 32 | #include <qdir.h> |
32 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
33 | #include <stdlib.h> | 34 | #include <stdlib.h> |
34 | #include "phoneaccess.h" | 35 | #include "phoneaccess.h" |
35 | 36 | ||
36 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) | 37 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) |
37 | { | 38 | { |
@@ -41,22 +42,24 @@ void PhoneAccess::writeConfig( QString device, QString connection, QString model | |||
41 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | 42 | QString fileName = QDir::homeDirPath() +"/.gammurc"; |
42 | #endif | 43 | #endif |
43 | //qDebug("save %d ", load ); | 44 | //qDebug("save %d ", load ); |
44 | QString content = "[gammu]\n";; | 45 | QString content = "[gammu]\n";; |
45 | bool write = false; | 46 | bool write = false; |
46 | bool addPort = true, addConnection = true, addModel = true; | 47 | bool addPort = true, addConnection = true, addModel = true; |
47 | QFile file( fileName ); | 48 | QFile file( fileName ); |
48 | if ( QFile::exists( fileName) ) { | 49 | if ( QFile::exists( fileName) ) { |
49 | if (!file.open( IO_ReadOnly ) ) { | 50 | if (!file.open( QIODevice::ReadOnly ) ) { |
50 | qDebug("Error: cannot open %s ", fileName.latin1() ); | 51 | qDebug("Error: cannot open %s ", fileName.latin1() ); |
51 | return; | 52 | return; |
52 | } | 53 | } |
53 | QString line; | 54 | QString line; |
54 | while ( file.readLine( line, 1024 ) > 0 ) { | 55 | char tmp[1024]; |
56 | while ( file.readLine( tmp, 1024 ) > 0 ) { | ||
57 | line = tmp; | ||
55 | //qDebug("*%s* ", line.latin1() ); | 58 | //qDebug("*%s* ", line.latin1() ); |
56 | if ( line.left(7 ) == "[gammu]" ) { | 59 | if ( line.left(7 ) == "[gammu]" ) { |
57 | ; | 60 | ; |
58 | } else | 61 | } else |
59 | if ( line.left(4 ) == "port" ) { | 62 | if ( line.left(4 ) == "port" ) { |
60 | if ( line == "port = " + device+"\n" ) { | 63 | if ( line == "port = " + device+"\n" ) { |
61 | content += line ; | 64 | content += line ; |
62 | addPort = false; | 65 | addPort = false; |
@@ -110,22 +113,22 @@ void PhoneAccess::writeConfig( QString device, QString connection, QString model | |||
110 | } | 113 | } |
111 | if ( addModel ) { | 114 | if ( addModel ) { |
112 | write = true; | 115 | write = true; |
113 | content += "model = "; | 116 | content += "model = "; |
114 | content += model; | 117 | content += model; |
115 | content += "\n"; | 118 | content += "\n"; |
116 | } | 119 | } |
117 | if ( write ) { | 120 | if ( write ) { |
118 | if (!file.open( IO_WriteOnly ) ) { | 121 | if (!file.open( QIODevice::WriteOnly ) ) { |
119 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | 122 | qDebug("Error: cannot write file %s ", fileName.latin1() ); |
120 | return; | 123 | return; |
121 | } | 124 | } |
122 | qDebug("Writing file %s ", fileName.latin1() ); | 125 | qDebug("Writing file %s ", fileName.latin1() ); |
123 | QTextStream ts( &file ); | 126 | Q3TextStream ts( &file ); |
124 | ts << content ; | 127 | ts << content ; |
125 | file.close(); | 128 | file.close(); |
126 | } | 129 | } |
127 | 130 | ||
128 | } | 131 | } |
129 | 132 | ||
130 | 133 | ||
131 | bool PhoneAccess::writeToPhone( QString fileName) | 134 | bool PhoneAccess::writeToPhone( QString fileName) |