-rw-r--r-- | libkcal/libkcal.pro | 2 | ||||
-rw-r--r-- | libkcal/libkcalE.pro | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 117 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 1 |
4 files changed, 5 insertions, 117 deletions
diff --git a/libkcal/libkcal.pro b/libkcal/libkcal.pro index 7a0bd22..171c726 100644 --- a/libkcal/libkcal.pro +++ b/libkcal/libkcal.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkcal | 3 | TARGET = microkcal |
4 | 4 | ||
5 | include( ../variables.pri ) | 5 | include( ../variables.pri ) |
6 | 6 | ||
7 | INCLUDEPATH += ../microkde versit ../microkde/kdecore | 7 | INCLUDEPATH += ../libkdepim ../microkde versit ../microkde/kdecore |
8 | #../qtcompat | 8 | #../qtcompat |
9 | INCLUDEPATH += ../libical/src/libical | 9 | INCLUDEPATH += ../libical/src/libical |
10 | INCLUDEPATH += ../libical/src/libicalss | 10 | INCLUDEPATH += ../libical/src/libicalss |
11 | DESTDIR = ../bin | 11 | DESTDIR = ../bin |
12 | DEFINES += DESKTOP_VERSION | 12 | DEFINES += DESKTOP_VERSION |
13 | unix: { | 13 | unix: { |
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro index e379b95..e42dc9c 100644 --- a/libkcal/libkcalE.pro +++ b/libkcal/libkcalE.pro | |||
@@ -1,11 +1,11 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = komicrokcal | 3 | TARGET = komicrokcal |
4 | 4 | ||
5 | INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include | 5 | INCLUDEPATH += ../libkdepim ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include |
6 | INCLUDEPATH += ../libical/src/libical | 6 | INCLUDEPATH += ../libical/src/libical |
7 | INCLUDEPATH += ../libical/src/libicalss | 7 | INCLUDEPATH += ../libical/src/libicalss |
8 | OBJECTS_DIR = obj/$(PLATFORM) | 8 | OBJECTS_DIR = obj/$(PLATFORM) |
9 | MOC_DIR = moc/$(PLATFORM) | 9 | MOC_DIR = moc/$(PLATFORM) |
10 | DESTDIR = $(QPEDIR)/lib | 10 | DESTDIR = $(QPEDIR)/lib |
11 | LIBS += ../libical/lib/$(PLATFORM)/libical.a | 11 | LIBS += ../libical/lib/$(PLATFORM)/libical.a |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index b2a62b1..c39413e 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -33,12 +33,13 @@ | |||
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <phoneaccess.h> | ||
39 | 40 | ||
40 | #include "calendar.h" | 41 | #include "calendar.h" |
41 | #include "alarm.h" | 42 | #include "alarm.h" |
42 | #include "recurrence.h" | 43 | #include "recurrence.h" |
43 | #include "calendarlocal.h" | 44 | #include "calendarlocal.h" |
44 | 45 | ||
@@ -81,117 +82,19 @@ public: | |||
81 | 82 | ||
82 | 83 | ||
83 | 84 | ||
84 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
85 | { | 86 | { |
86 | mProfileName = profileName; | 87 | mProfileName = profileName; |
87 | writeConfig( device, connection, model ); | 88 | PhoneAccess::writeConfig( device, connection, model ); |
88 | } | 89 | } |
89 | 90 | ||
90 | PhoneFormat::~PhoneFormat() | 91 | PhoneFormat::~PhoneFormat() |
91 | { | 92 | { |
92 | } | 93 | } |
93 | void PhoneFormat::writeConfig( QString device, QString connection, QString model ) | ||
94 | { | ||
95 | #ifdef _WIN32_ | ||
96 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; | ||
97 | #else | ||
98 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | ||
99 | #endif | ||
100 | //qDebug("save %d ", load ); | ||
101 | QString content; | ||
102 | bool write = false; | ||
103 | bool addPort = true, addConnection = true, addModel = true; | ||
104 | QFile file( fileName ); | ||
105 | if ( QFile::exists( fileName) ) { | ||
106 | if (!file.open( IO_ReadOnly ) ) { | ||
107 | qDebug("Error: cannot open %s ", fileName.latin1() ); | ||
108 | return; | ||
109 | } | ||
110 | QString line; | ||
111 | while ( file.readLine( line, 1024 ) > 0 ) { | ||
112 | //qDebug("*%s* ", line.latin1() ); | ||
113 | if ( line.left(7 ) == "[gammu]" ) { | ||
114 | ; | ||
115 | } else | ||
116 | if ( line.left(4 ) == "port" ) { | ||
117 | if ( line == "port = " + device+"\n" ) { | ||
118 | content += line ; | ||
119 | addPort = false; | ||
120 | //qDebug("port found" ); | ||
121 | } | ||
122 | |||
123 | } else if ( line.left(5 ) == "model" ) { | ||
124 | if ( line == "model = " + model +"\n") { | ||
125 | content += line ; | ||
126 | addModel = false; | ||
127 | //qDebug("model found" ); | ||
128 | } | ||
129 | |||
130 | } else if ( line.left( 10 ) == "connection" ) { | ||
131 | if ( line == "connection = " + connection +"\n") { | ||
132 | addConnection = false; | ||
133 | content += line ; | ||
134 | //qDebug("con found" ); | ||
135 | } | ||
136 | |||
137 | } else { | ||
138 | content += line ; | ||
139 | } | ||
140 | } | ||
141 | file.close(); | ||
142 | } else { | ||
143 | if ( ! connection.isEmpty() ) { | ||
144 | addConnection = true; | ||
145 | } | ||
146 | if ( ! device.isEmpty() ) { | ||
147 | addPort = true; | ||
148 | 94 | ||
149 | } | ||
150 | if ( ! model.isEmpty() ) { | ||
151 | addModel = true; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | if ( addConnection ) { | ||
156 | if ( ! write ) | ||
157 | content += "[gammu]\n"; | ||
158 | write = true; | ||
159 | content += "connection = "; | ||
160 | content += connection; | ||
161 | content += "\n"; | ||
162 | } | ||
163 | if ( addPort ) { | ||
164 | if ( ! write ) | ||
165 | content += "[gammu]\n"; | ||
166 | write = true; | ||
167 | content += "port = "; | ||
168 | content += device; | ||
169 | content += "\n"; | ||
170 | |||
171 | } | ||
172 | if ( addModel ) { | ||
173 | if ( ! write ) | ||
174 | content += "[gammu]\n"; | ||
175 | write = true; | ||
176 | content += "model = "; | ||
177 | content += model; | ||
178 | content += "\n"; | ||
179 | } | ||
180 | if ( write ) { | ||
181 | if (!file.open( IO_WriteOnly ) ) { | ||
182 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | ||
183 | return; | ||
184 | } | ||
185 | qDebug("Writing file %s ", fileName.latin1() ); | ||
186 | QTextStream ts( &file ); | ||
187 | ts << content ; | ||
188 | file.close(); | ||
189 | } | ||
190 | |||
191 | } | ||
192 | #if 0 | 95 | #if 0 |
193 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 96 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
194 | { | 97 | { |
195 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 98 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
196 | s->ConfigNum = 1; | 99 | s->ConfigNum = 1; |
197 | GSM_Config *cfg = &s->Config[0]; | 100 | GSM_Config *cfg = &s->Config[0]; |
@@ -587,27 +490,13 @@ bool PhoneFormat::writeToPhone( Calendar * calendar) | |||
587 | #endif | 490 | #endif |
588 | 491 | ||
589 | VCalFormat vfsave; | 492 | VCalFormat vfsave; |
590 | vfsave.setLocalTime ( true ); | 493 | vfsave.setLocalTime ( true ); |
591 | if ( ! vfsave.save( calendar, fileName ) ) | 494 | if ( ! vfsave.save( calendar, fileName ) ) |
592 | return false; | 495 | return false; |
593 | // 4 call kammu | 496 | return PhoneAccess::writeToPhone( fileName ); |
594 | #ifdef DESKTOP_VERSION | ||
595 | QString command ="./kammu --restore " + fileName ; | ||
596 | #else | ||
597 | QString command ="kammu --restore " + fileName ; | ||
598 | #endif | ||
599 | int ret; | ||
600 | while ( (ret = system ( command.latin1())) != 0 ) { | ||
601 | qDebug("Error S::command returned %d. asking users", ret); | ||
602 | int retval = KMessageBox::warningContinueCancel(0, | ||
603 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); | ||
604 | if ( retval != KMessageBox::Continue ) | ||
605 | return false; | ||
606 | } | ||
607 | return true; | ||
608 | } | 497 | } |
609 | bool PhoneFormat::save( Calendar *calendar) | 498 | bool PhoneFormat::save( Calendar *calendar) |
610 | { | 499 | { |
611 | QLabel status ( i18n(" Opening device ..."), 0 ); | 500 | QLabel status ( i18n(" Opening device ..."), 0 ); |
612 | int w = status.sizeHint().width()+20 ; | 501 | int w = status.sizeHint().width()+20 ; |
613 | if ( w < 200 ) w = 230; | 502 | if ( w < 200 ) w = 230; |
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 61e8160..001fd81 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -45,13 +45,12 @@ class PhoneFormat : public QObject { | |||
45 | bool save( Calendar * ); | 45 | bool save( Calendar * ); |
46 | bool fromString( Calendar *, const QString & ); | 46 | bool fromString( Calendar *, const QString & ); |
47 | QString toString( Calendar * ); | 47 | QString toString( Calendar * ); |
48 | static ulong getCsum( const QStringList & ); | 48 | static ulong getCsum( const QStringList & ); |
49 | static ulong getCsumTodo( Todo* to ); | 49 | static ulong getCsumTodo( Todo* to ); |
50 | static ulong getCsumEvent( Event* ev ); | 50 | static ulong getCsumEvent( Event* ev ); |
51 | static void writeConfig( QString device,QString connection, QString model ); | ||
52 | static bool writeToPhone( Calendar * ); | 51 | static bool writeToPhone( Calendar * ); |
53 | private: | 52 | private: |
54 | void copyEvent( Event* to, Event* from ); | 53 | void copyEvent( Event* to, Event* from ); |
55 | void copyTodo( Todo* to, Todo* from ); | 54 | void copyTodo( Todo* to, Todo* from ); |
56 | //int initDevice(GSM_StateMachine *s); | 55 | //int initDevice(GSM_StateMachine *s); |
57 | QString mProfileName; | 56 | QString mProfileName; |