summaryrefslogtreecommitdiffabout
path: root/libkdepim/phoneaccess.cpp
Unidiff
Diffstat (limited to 'libkdepim/phoneaccess.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/phoneaccess.cpp15
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
@@ -13,54 +13,57 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
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
36void PhoneAccess::writeConfig( QString device, QString connection, QString model ) 37void PhoneAccess::writeConfig( QString device, QString connection, QString model )
37{ 38{
38#ifdef _WIN32_ 39#ifdef _WIN32_
39 QString fileName = qApp->applicationDirPath () +"\\gammurc"; 40 QString fileName = qApp->applicationDirPath () +"\\gammurc";
40#else 41#else
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;
63 //qDebug("port found" ); 66 //qDebug("port found" );
64 } 67 }
65 68
66 } else if ( line.left(5 ) == "model" ) { 69 } else if ( line.left(5 ) == "model" ) {
@@ -106,30 +109,30 @@ void PhoneAccess::writeConfig( QString device, QString connection, QString model
106 content += "port = "; 109 content += "port = ";
107 content += device; 110 content += device;
108 content += "\n"; 111 content += "\n";
109 112
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
131bool PhoneAccess::writeToPhone( QString fileName) 134bool PhoneAccess::writeToPhone( QString fileName)
132{ 135{
133 136
134#ifdef DESKTOP_VERSION 137#ifdef DESKTOP_VERSION
135#ifdef _WIN32_ 138#ifdef _WIN32_