summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kpimglobalprefs.cpp7
-rw-r--r--libkdepim/kpimglobalprefs.h3
-rw-r--r--libkdepim/libkdepim.pro6
-rw-r--r--libkdepim/libkdepimE.pro6
-rw-r--r--libkdepim/phoneaccess.cpp153
-rw-r--r--libkdepim/phoneaccess.h42
6 files changed, 213 insertions, 4 deletions
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index b2b7663..b71e18d 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -99,6 +99,13 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
99 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); 99 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
100 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); 100 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
101 101
102
103 KPrefs::setCurrentGroup( "PhoneAccess" );
104 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
105 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
106 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
107
108
102} 109}
103 110
104void KPimGlobalPrefs::setGlobalConfig() 111void KPimGlobalPrefs::setGlobalConfig()
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
index 84ba689..f6b6628 100644
--- a/libkdepim/kpimglobalprefs.h
+++ b/libkdepim/kpimglobalprefs.h
@@ -129,6 +129,9 @@ class KPimGlobalPrefs : public KPrefs
129 QString mSipOtherMessage; 129 QString mSipOtherMessage;
130 QString mSipOtherMessageParameters; 130 QString mSipOtherMessageParameters;
131 131
132 QString mEx2PhoneDevice;
133 QString mEx2PhoneConnection;
134 QString mEx2PhoneModel;
132 135
133}; 136};
134 137
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index eac19ea..84af7ad 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -35,7 +35,8 @@ HEADERS = \
35 ksyncprofile.h \ 35 ksyncprofile.h \
36 ksyncprefsdialog.h \ 36 ksyncprefsdialog.h \
37 kcmconfigs/kcmkdepimconfig.h \ 37 kcmconfigs/kcmkdepimconfig.h \
38 kcmconfigs/kdepimconfigwidget.h 38 kcmconfigs/kdepimconfigwidget.h \
39 phoneaccess.h
39 40
40SOURCES = \ 41SOURCES = \
41 categoryeditdialog.cpp \ 42 categoryeditdialog.cpp \
@@ -54,6 +55,7 @@ SOURCES = \
54 ksyncprofile.cpp \ 55 ksyncprofile.cpp \
55 ksyncprefsdialog.cpp \ 56 ksyncprefsdialog.cpp \
56 kcmconfigs/kcmkdepimconfig.cpp \ 57 kcmconfigs/kcmkdepimconfig.cpp \
57 kcmconfigs/kdepimconfigwidget.cpp 58 kcmconfigs/kdepimconfigwidget.cpp \
59 phoneaccess.cpp
58 60
59 61
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
index 156e247..f3db68e 100644
--- a/libkdepim/libkdepimE.pro
+++ b/libkdepim/libkdepimE.pro
@@ -29,7 +29,8 @@ HEADERS = \
29 ksyncprofile.h \ 29 ksyncprofile.h \
30 ksyncprefsdialog.h \ 30 ksyncprefsdialog.h \
31 kcmconfigs/kcmkdepimconfig.h \ 31 kcmconfigs/kcmkdepimconfig.h \
32 kcmconfigs/kdepimconfigwidget.h 32 kcmconfigs/kdepimconfigwidget.h \
33 phoneaccess.h
33 34
34 35
35 36
@@ -50,6 +51,7 @@ SOURCES = \
50 ksyncprofile.cpp \ 51 ksyncprofile.cpp \
51 ksyncprefsdialog.cpp \ 52 ksyncprefsdialog.cpp \
52 kcmconfigs/kcmkdepimconfig.cpp \ 53 kcmconfigs/kcmkdepimconfig.cpp \
53 kcmconfigs/kdepimconfigwidget.cpp 54 kcmconfigs/kdepimconfigwidget.cpp \
55 phoneaccess.cpp
54 56
55 57
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
new file mode 100644
index 0000000..c0bd6cc
--- a/dev/null
+++ b/libkdepim/phoneaccess.cpp
@@ -0,0 +1,153 @@
1/*
2 This file is part of libkdepim.
3
4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
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
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22
23#include <qstring.h>
24#include <qapplication.h>
25#include <qptrlist.h>
26#include <qregexp.h>
27#include <qfile.h>
28#include <qtextstream.h>
29#include <qtextcodec.h>
30#include <qdir.h>
31#include <kmessagebox.h>
32#include <stdlib.h>
33#include "phoneaccess.h"
34
35void PhoneAccess::writeConfig( QString device, QString connection, QString model )
36{
37#ifdef _WIN32_
38 QString fileName = qApp->applicationDirPath () +"\\gammurc";
39#else
40 QString fileName = QDir::homeDirPath() +"/.gammurc";
41#endif
42 //qDebug("save %d ", load );
43 QString content;
44 bool write = false;
45 bool addPort = true, addConnection = true, addModel = true;
46 QFile file( fileName );
47 if ( QFile::exists( fileName) ) {
48 if (!file.open( IO_ReadOnly ) ) {
49 qDebug("Error: cannot open %s ", fileName.latin1() );
50 return;
51 }
52 QString line;
53 while ( file.readLine( line, 1024 ) > 0 ) {
54 //qDebug("*%s* ", line.latin1() );
55 if ( line.left(7 ) == "[gammu]" ) {
56 ;
57 } else
58 if ( line.left(4 ) == "port" ) {
59 if ( line == "port = " + device+"\n" ) {
60 content += line ;
61 addPort = false;
62 //qDebug("port found" );
63 }
64
65 } else if ( line.left(5 ) == "model" ) {
66 if ( line == "model = " + model +"\n") {
67 content += line ;
68 addModel = false;
69 //qDebug("model found" );
70 }
71
72 } else if ( line.left( 10 ) == "connection" ) {
73 if ( line == "connection = " + connection +"\n") {
74 addConnection = false;
75 content += line ;
76 //qDebug("con found" );
77 }
78
79 } else {
80 content += line ;
81 }
82 }
83 file.close();
84 } else {
85 if ( ! connection.isEmpty() ) {
86 addConnection = true;
87 }
88 if ( ! device.isEmpty() ) {
89 addPort = true;
90
91 }
92 if ( ! model.isEmpty() ) {
93 addModel = true;
94 }
95 }
96
97 if ( addConnection ) {
98 if ( ! write )
99 content += "[gammu]\n";
100 write = true;
101 content += "connection = ";
102 content += connection;
103 content += "\n";
104 }
105 if ( addPort ) {
106 if ( ! write )
107 content += "[gammu]\n";
108 write = true;
109 content += "port = ";
110 content += device;
111 content += "\n";
112
113 }
114 if ( addModel ) {
115 if ( ! write )
116 content += "[gammu]\n";
117 write = true;
118 content += "model = ";
119 content += model;
120 content += "\n";
121 }
122 if ( write ) {
123 if (!file.open( IO_WriteOnly ) ) {
124 qDebug("Error: cannot write file %s ", fileName.latin1() );
125 return;
126 }
127 qDebug("Writing file %s ", fileName.latin1() );
128 QTextStream ts( &file );
129 ts << content ;
130 file.close();
131 }
132
133}
134
135
136bool PhoneAccess::writeToPhone( QString fileName)
137{
138
139#ifdef DESKTOP_VERSION
140 QString command ="./kammu --restore " + fileName ;
141#else
142 QString command ="kammu --restore " + fileName ;
143#endif
144 int ret;
145 while ( (ret = system ( command.latin1())) != 0 ) {
146 qDebug("Error S::command returned %d. asking users", ret);
147 int retval = KMessageBox::warningContinueCancel(0,
148 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
149 if ( retval != KMessageBox::Continue )
150 return false;
151 }
152 return true;
153}
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h
new file mode 100644
index 0000000..b7c4732
--- a/dev/null
+++ b/libkdepim/phoneaccess.h
@@ -0,0 +1,42 @@
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
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
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21#ifndef PHONEACCESS_H
22#define PHONEACCESS_H
23
24#include <qstring.h>
25
26
27
28/**
29 This class implements the calendar format used by Phone.
30*/
31
32class PhoneAccess : public QObject {
33 public:
34
35 static void writeConfig( QString device,QString connection, QString model );
36 static bool writeToPhone( QString fileName );
37
38};
39
40
41
42#endif