summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-30 07:47:56 (UTC)
committer zautrix <zautrix>2004-08-30 07:47:56 (UTC)
commitb36bcd92b643c87ee5e2bfc39076ea56abf4c7d2 (patch) (unidiff)
tree99223dd8edf0e00a4f060610ea0642f915cf4703
parent78f44f13835e3fa501997f485b505b193bd474f5 (diff)
downloadkdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.zip
kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.tar.gz
kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.tar.bz2
Changes in gammu connection
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile16
-rw-r--r--gammu/emb/common/service/gsmcal.c85
-rw-r--r--kdepim-desktop.pro6
-rw-r--r--kopi-desktop.pro6
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/korganizer.pro1
-rw-r--r--libkcal/incidence.cpp5
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/phoneformat.cpp1464
-rw-r--r--libkcal/phoneformat.h14
-rw-r--r--libkcal/vcalformat.cpp5
-rw-r--r--libkcal/vcalformat.h5
12 files changed, 259 insertions, 1352 deletions
diff --git a/Makefile b/Makefile
index ac314b9..f21e524 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1############################################################################# 1#############################################################################
2# Makefile for building: kopi-desktop 2# Makefile for building: kopi-desktop
3# Generated by qmake (1.07a) (Qt 3.3.1) on: Sun Aug 29 13:39:55 2004 3# Generated by qmake (1.07a) (Qt 3.3.1) on: Sun Aug 29 18:50:00 2004
4# Project: kopi-desktop.pro 4# Project: kopi-desktop.pro
5# Template: subdirs 5# Template: subdirs
6# Command: $(QMAKE) -o Makefile kopi-desktop.pro 6# Command: $(QMAKE) -o Makefile kopi-desktop.pro
@@ -13,6 +13,7 @@ CHK_DIR_EXISTS= test -d
13MKDIR = mkdir -p 13MKDIR = mkdir -p
14 SUBTARGETS = \ 14 SUBTARGETS = \
15 sub-gammu-emb-common \ 15 sub-gammu-emb-common \
16 sub-gammu-emb-gammu \
16 sub-libical \ 17 sub-libical \
17 sub-libkcal \ 18 sub-libkcal \
18 sub-microkde \ 19 sub-microkde \
@@ -33,6 +34,12 @@ gammu/emb/common/$(MAKEFILE):
33sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE 34sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
34 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) 35 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
35 36
37gammu/emb/gammu/$(MAKEFILE):
38 @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
39 cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE)
40sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
41 cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
42
36libical/$(MAKEFILE): 43libical/$(MAKEFILE):
37 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" 44 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
38 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE) 45 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE)
@@ -93,8 +100,9 @@ qmake: qmake_all
93 @$(QMAKE) -o Makefile kopi-desktop.pro 100 @$(QMAKE) -o Makefile kopi-desktop.pro
94 101
95all: $(SUBTARGETS) 102all: $(SUBTARGETS)
96qmake_all: gammu/emb/common/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) 103qmake_all: gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE)
97 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 104 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
105 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
98 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 106 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
99 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 107 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
100 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 108 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
@@ -106,6 +114,7 @@ qmake_all: gammu/emb/common/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE)
106 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 114 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
107clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE 115clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
108 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true 116 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
117 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
109 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true 118 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
110 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true 119 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
111 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true 120 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
@@ -117,6 +126,7 @@ clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
117 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true 126 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
118uninstall_subdirs: qmake_all FORCE 127uninstall_subdirs: qmake_all FORCE
119 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 128 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
129 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
120 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 130 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
121 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 131 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
122 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 132 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
@@ -128,6 +138,7 @@ uninstall_subdirs: qmake_all FORCE
128 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 138 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
129install_subdirs: qmake_all FORCE 139install_subdirs: qmake_all FORCE
130 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true 140 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
141 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
131 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true 142 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
132 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true 143 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
133 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true 144 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
@@ -139,6 +150,7 @@ install_subdirs: qmake_all FORCE
139 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true 150 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
140distclean: qmake_all FORCE 151distclean: qmake_all FORCE
141 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 152 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
153 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
142 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 154 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
143 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 155 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
144 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 156 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c
index 950e35e..598292c 100644
--- a/gammu/emb/common/service/gsmcal.c
+++ b/gammu/emb/common/service/gsmcal.c
@@ -99,20 +99,20 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note
99 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 99 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
100 switch (note->Type) { 100 switch (note->Type) {
101 case GSM_CAL_REMINDER: 101 case GSM_CAL_REMINDER:
102 *Length+=sprintf(Buffer+(*Length), "REMINDER%c%c",13,10); 102 *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10);
103 break; 103 break;
104 case GSM_CAL_MEMO: 104 case GSM_CAL_MEMO:
105 *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); 105 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
106 break; 106 break;
107 case GSM_CAL_CALL: 107 case GSM_CAL_CALL:
108 *Length+=sprintf(Buffer+(*Length), "PHONE CALL%c%c",13,10); 108 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
109 break; 109 break;
110 case GSM_CAL_BIRTHDAY: 110 case GSM_CAL_BIRTHDAY:
111 *Length+=sprintf(Buffer+(*Length), "SPECIAL OCCASION%c%c",13,10); 111 *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10);
112 break; 112 break;
113 case GSM_CAL_MEETING: 113 case GSM_CAL_MEETING:
114 default: 114 default:
115 *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); 115 *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10);
116 break; 116 break;
117 } 117 }
118 if (note->Type == GSM_CAL_CALL) { 118 if (note->Type == GSM_CAL_CALL) {
@@ -159,17 +159,17 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note
159 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 159 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
160 switch (note->Type) { 160 switch (note->Type) {
161 case GSM_CAL_MEETING: 161 case GSM_CAL_MEETING:
162 *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); 162 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
163 break; 163 break;
164 case GSM_CAL_CALL: 164 case GSM_CAL_CALL:
165 *Length+=sprintf(Buffer+(*Length), "PHONE CALL%c%c",13,10); 165 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
166 break; 166 break;
167 case GSM_CAL_BIRTHDAY: 167 case GSM_CAL_BIRTHDAY:
168 *Length+=sprintf(Buffer+(*Length), "ANNIVERSARY%c%c",13,10); 168 *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10);
169 break; 169 break;
170 case GSM_CAL_MEMO: 170 case GSM_CAL_MEMO:
171 default: 171 default:
172 *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); 172 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
173 break; 173 break;
174 } 174 }
175 175
@@ -205,23 +205,23 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note
205 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 205 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
206 switch (note->Type) { 206 switch (note->Type) {
207 case GSM_CAL_MEETING: 207 case GSM_CAL_MEETING:
208 *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); 208 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
209 break; 209 break;
210 case GSM_CAL_REMINDER: 210 case GSM_CAL_REMINDER:
211 *Length+=sprintf(Buffer+(*Length), "DATE%c%c",13,10); 211 *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10);
212 break; 212 break;
213 case GSM_CAL_TRAVEL: 213 case GSM_CAL_TRAVEL:
214 *Length+=sprintf(Buffer+(*Length), "TRAVEL%c%c",13,10); 214 *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10);
215 break; 215 break;
216 case GSM_CAL_VACATION: 216 case GSM_CAL_VACATION:
217 *Length+=sprintf(Buffer+(*Length), "VACATION%c%c",13,10); 217 *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10);
218 break; 218 break;
219 case GSM_CAL_BIRTHDAY: 219 case GSM_CAL_BIRTHDAY:
220 *Length+=sprintf(Buffer+(*Length), "ANNIVERSARY%c%c",13,10); 220 *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10);
221 break; 221 break;
222 case GSM_CAL_MEMO: 222 case GSM_CAL_MEMO:
223 default: 223 default:
224 *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); 224 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
225 break; 225 break;
226 } 226 }
227 227
@@ -243,6 +243,7 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note
243 } 243 }
244 } 244 }
245 245
246 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
246 *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); 247 *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10);
247 if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); 248 if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
248 249
@@ -300,15 +301,15 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h
300 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 301 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
301 302
302 if (Completed == -1) { 303 if (Completed == -1) {
303 *Length+=sprintf(Buffer+(*Length), "STATUS:NEEDS ACTION%c%c",13,10); 304 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
304 } else { 305 } else {
305 *Length+=sprintf(Buffer+(*Length), "STATUS:COMPLETED%c%c",13,10); 306 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
306 } 307 }
307 308
308 switch (note->Priority) { 309 switch (note->Priority) {
309 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; 310 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
310 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:2%c%c",13,10); break; 311 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
311 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; 312 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
312 } 313 }
313 314
314 if (EndTime != -1) { 315 if (EndTime != -1) {
@@ -327,14 +328,14 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h
327 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 328 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
328 329
329 if (Completed == -1) { 330 if (Completed == -1) {
330 *Length+=sprintf(Buffer+(*Length), "STATUS:NEEDS ACTION%c%c",13,10); 331 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
331 } else { 332 } else {
332 *Length+=sprintf(Buffer+(*Length), "STATUS:COMPLETED%c%c",13,10); 333 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
333 } 334 }
334 335
335 switch (note->Priority) { 336 switch (note->Priority) {
336 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; 337 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
337 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:2%c%c",13,10); break; 338 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
338 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; 339 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
339 } 340 }
340 341
@@ -343,6 +344,7 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h
343 } 344 }
344 } 345 }
345 346
347 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
346 *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); 348 *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10);
347 349
348 if (header) { 350 if (header) {
@@ -369,7 +371,7 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda
369 Level = 1; 371 Level = 1;
370 } 372 }
371 if (strstr(Line,"BEGIN:VTODO")) { 373 if (strstr(Line,"BEGIN:VTODO")) {
372 ToDo->Priority = GSM_Priority_Low; 374 ToDo->Priority = GSM_Priority_Medium;
373 Level = 2; 375 Level = 2;
374 } 376 }
375 break; 377 break;
@@ -377,17 +379,18 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda
377 if (strstr(Line,"END:VEVENT")) { 379 if (strstr(Line,"END:VEVENT")) {
378 if (Calendar->EntriesNum == 0) return ERR_EMPTY; 380 if (Calendar->EntriesNum == 0) return ERR_EMPTY;
379 return ERR_NONE; 381 return ERR_NONE;
380 } 382 }
381 if (strstr(Line,"CATEGORIES:REMINDER")) Calendar->Type = GSM_CAL_REMINDER; 383 Calendar->Type = GSM_CAL_MEETING;
382 if (strstr(Line,"CATEGORIES:DATE")) Calendar->Type = GSM_CAL_REMINDER;//SE 384 if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER;
383 if (strstr(Line,"CATEGORIES:TRAVEL")) Calendar->Type = GSM_CAL_TRAVEL; //SE 385 if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE
384 if (strstr(Line,"CATEGORIES:VACATION")) Calendar->Type = GSM_CAL_VACATION;//SE 386 if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE
385 if (strstr(Line,"CATEGORIES:MISCELLANEOUS")) Calendar->Type = GSM_CAL_MEMO; 387 if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE
386 if (strstr(Line,"CATEGORIES:PHONE CALL")) Calendar->Type = GSM_CAL_CALL; 388 if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO;
387 if (strstr(Line,"CATEGORIES:SPECIAL OCCASION")) Calendar->Type = GSM_CAL_BIRTHDAY; 389 if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL;
388 if (strstr(Line,"CATEGORIES:ANNIVERSARY")) Calendar->Type = GSM_CAL_BIRTHDAY; 390 if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY;
389 if (strstr(Line,"CATEGORIES:MEETING")) Calendar->Type = GSM_CAL_MEETING; 391 if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY;
390 if (strstr(Line,"CATEGORIES:APPOINTMENT")) Calendar->Type = GSM_CAL_MEETING; 392 if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING;
393 if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING;
391 if (strstr(Line,"RRULE:D1")) { 394 if (strstr(Line,"RRULE:D1")) {
392 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 395 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
393 Calendar->Entries[Calendar->EntriesNum].Number = 1*24; 396 Calendar->Entries[Calendar->EntriesNum].Number = 1*24;
@@ -472,16 +475,16 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda
472 if (ReadVCALText(Line, "PRIORITY", Buff)) { 475 if (ReadVCALText(Line, "PRIORITY", Buff)) {
473 if (ToDoVer == SonyEricsson_VToDo) { 476 if (ToDoVer == SonyEricsson_VToDo) {
474 ToDo->Priority = GSM_Priority_Low; 477 ToDo->Priority = GSM_Priority_Low;
475 if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium; 478 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
476 if (atoi(DecodeUnicodeString(Buff))==1) ToDo->Priority = GSM_Priority_High; 479 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
477 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); 480 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff));
478 } else if (ToDoVer == Nokia_VToDo) { 481 } else if (ToDoVer == Nokia_VToDo) {
479 ToDo->Priority = GSM_Priority_Low; 482 ToDo->Priority = GSM_Priority_Low;
480 if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium; 483 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
481 if (atoi(DecodeUnicodeString(Buff))==3) ToDo->Priority = GSM_Priority_High; 484 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
482 } 485 }
483 } 486 }
484 if (strstr(Line,"STATUS:COMPLETED")) { 487 if (strstr(Line,"PERCENT-COMPLETE:100")) {
485 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; 488 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED;
486 ToDo->Entries[ToDo->EntriesNum].Number = 1; 489 ToDo->Entries[ToDo->EntriesNum].Number = 1;
487 ToDo->EntriesNum++; 490 ToDo->EntriesNum++;
diff --git a/kdepim-desktop.pro b/kdepim-desktop.pro
new file mode 100644
index 0000000..7a3a96e
--- a/dev/null
+++ b/kdepim-desktop.pro
@@ -0,0 +1,6 @@
1
2
3TEMPLATE = subdirs
4SUBDIRS = gammu/emb/common gammu/emb/gammu libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir
5#kalarmd
6
diff --git a/kopi-desktop.pro b/kopi-desktop.pro
deleted file mode 100644
index 69c874f..0000000
--- a/kopi-desktop.pro
+++ b/dev/null
@@ -1,6 +0,0 @@
1
2
3TEMPLATE = subdirs
4SUBDIRS = gammu/emb/common libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir
5#kalarmd
6
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 7444bad..db07713 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1875,7 +1875,7 @@ void CalendarView::changeTodoDisplay(Todo *which, int action)
1875 1875
1876 if (which) { 1876 if (which) {
1877 mViewManager->currentView()->updateView(); 1877 mViewManager->currentView()->updateView();
1878 mTodoList->updateView(); 1878 //mTodoList->updateView();
1879 } 1879 }
1880 1880
1881} 1881}
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 9fdcd2f..543db86 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -19,7 +19,6 @@ LIBS += ../bin/libmicrokdepim.so
19LIBS += ../bin/libmicrokcal.so 19LIBS += ../bin/libmicrokcal.so
20LIBS += ../bin/libmicrokde.so 20LIBS += ../bin/libmicrokde.so
21LIBS += ../bin/libmicrokabc.so 21LIBS += ../bin/libmicrokabc.so
22LIBS += ../bin/libmicrogammu.so
23LIBS += -lbluetooth 22LIBS += -lbluetooth
24LIBS += -lsdp 23LIBS += -lsdp
25 24
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index d9bda64..56c9801 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -534,6 +534,11 @@ Recurrence *Incidence::recurrence() const
534{ 534{
535 return mRecurrence; 535 return mRecurrence;
536} 536}
537void Incidence::setRecurrence( Recurrence * r)
538{
539 delete mRecurrence;
540 mRecurrence = r;
541}
537 542
538void Incidence::setLocation(const QString &location) 543void Incidence::setLocation(const QString &location)
539{ 544{
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index d1972cb..7dc6f10 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -245,7 +245,7 @@ class Incidence : public IncidenceBase
245 none, returns an appropriate (non-0) object. 245 none, returns an appropriate (non-0) object.
246 */ 246 */
247 Recurrence *recurrence() const; 247 Recurrence *recurrence() const;
248 248 void setRecurrence(Recurrence * r);
249 /** 249 /**
250 Forward to Recurrence::doesRecur(). 250 Forward to Recurrence::doesRecur().
251 */ 251 */
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 1769b37..0bc9125 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,7 +1,7 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
@@ -45,467 +45,13 @@
45#include "syncdefines.h" 45#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48
49class PhoneParser : public QObject 48class PhoneParser : public QObject
50{ 49{
51public: 50public:
52 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { 51 PhoneParser( ) {
53 ; 52 ;
54 } 53 }
55 bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) 54
56 {
57
58 int id = ToDo->Location;
59 Todo *todo;
60 todo = existingCalendar->todo( mProfileName ,QString::number( id ) );
61 if (todo )
62 todo = (Todo *)todo->clone();
63 else
64 todo = new Todo;
65 todo->setID( mProfileName,QString::number( id ) );
66 todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
67 int priority;
68 switch (ToDo->Priority) {
69 case GSM_Priority_Low : priority = 5; break;
70 case GSM_Priority_Medium : priority = 3; break;
71 case GSM_Priority_High : priority = 1; break;
72 default :priority = 3 ;break;
73 }
74 todo->setPriority( priority );
75 GSM_Phone_Functions*Phone;
76 Phone=s->Phone.Functions;
77 int j;
78 GSM_DateTime* dtp;
79 bool alarm = false;
80 QDateTime alarmDt;
81 GSM_Category Category;
82 int error;
83 for (j=0;j<ToDo->EntriesNum;j++) {
84
85 //qDebug(" for todo %d",ToDo->Location );
86 switch (ToDo->Entries[j].EntryType) {
87 case TODO_END_DATETIME:
88 dtp = &ToDo->Entries[j].Date ;
89 todo->setDtDue (fromGSM ( dtp ));
90 break;
91 case TODO_COMPLETED:
92 if ( ToDo->Entries[j].Number == 1 ) {
93 todo->setCompleted( true );
94 }
95 else {
96 todo->setCompleted( false );
97 }
98 break;
99 case TODO_ALARM_DATETIME:
100 dtp = &ToDo->Entries[j].Date ;
101 alarm = true;
102 alarmDt = fromGSM ( dtp );
103 break;
104 case TODO_SILENT_ALARM_DATETIME:
105 dtp = &ToDo->Entries[j].Date ;
106 alarm = true;
107 alarmDt = fromGSM ( dtp );
108 break;
109 case TODO_TEXT:
110 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text ));
111 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text )));
112 break;
113 case TODO_PRIVATE:
114 if ( ToDo->Entries[j].Number == 1 )
115 todo->setSecrecy( Incidence::SecrecyPrivate );
116 else
117 todo->setSecrecy( Incidence::SecrecyPublic );
118 break;
119 case TODO_CATEGORY:
120 Category.Location = ToDo->Entries[j].Number;
121 Category.Type = Category_ToDo;
122 error=Phone->GetCategory(s, &Category);
123 if (error == ERR_NONE) {
124 QStringList cat = todo->categories();
125 QString nCat = QString ( (const char*)Category.Name );
126 if ( !nCat.isEmpty() )
127 if ( !cat.contains( nCat )) {
128 cat << nCat;
129 todo->setCategories( cat );
130 }
131 }
132 break;
133 case TODO_CONTACTID:
134#if 0
135 // not supported
136 entry.Location = ToDo->Entries[j].Number;
137 entry.MemoryType = MEM_ME;
138 error=Phone->GetMemory(s, &entry);
139 if (error == ERR_NONE) {
140 name = GSM_PhonebookGetEntryName(&entry);
141 if (name != NULL) {
142 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
143 } else {
144 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
145 }
146 } else {
147 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
148 }
149#endif
150 break;
151 case TODO_PHONE:
152#if 0
153 // not supported
154 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
155#endif
156 break;
157 }
158 }
159 QString alarmString = "na";
160 if ( alarm ) {
161 Alarm *alarm;
162 if ( todo->alarms().count() > 0 )
163 alarm = todo->alarms().first();
164 else {
165 alarm = new Alarm( todo );
166 todo->addAlarm( alarm );
167 }
168 alarm->setType( Alarm::Audio );
169 alarm->setEnabled( true );
170 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
171 alarm->setStartOffset( -alarmOffset );
172 alarmString = QString::number( alarmOffset );
173 } else {
174 Alarm *alarm;
175 if ( todo->alarms().count() > 0 ) {
176 alarm = todo->alarms().first();
177 alarm->setType( Alarm::Audio );
178 alarm->setStartOffset( -60*15 );
179 alarm->setEnabled( false );
180 }
181 }
182 // csum *****************************************
183 uint cSum;
184 cSum = PhoneFormat::getCsumTodo( todo );
185 todo->setCsum( mProfileName, QString::number( cSum ));
186 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
187 mCalendar->addTodo( todo);
188
189 return true;
190 }
191 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
192 {
193
194 int id = Note->Location;
195 Event *event;
196 event = existingCalendar->event( mProfileName ,QString::number( id ) );
197 if ( event )
198 event = (Event*)event->clone();
199 else
200 event = new Event;
201 event->setID( mProfileName,QString::number( id ) );
202 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
203
204
205 int i = 0;
206 bool repeating = false;
207 int repeat_dayofweek = -1;
208 int repeat_day = -1;
209 int repeat_weekofmonth = -1;
210 int repeat_month = -1;
211 int repeat_frequency = -1;
212 int rec_type = -1;
213 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
214 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
215 GSM_DateTime* dtp;
216 bool alarm = false;
217 QDateTime alarmDt;
218 repeat_startdate.Day= 0;
219 repeat_stopdate.Day = 0;
220 for (i=0;i<Note->EntriesNum;i++) {
221
222 //qDebug(" for ev");
223 switch (Note->Entries[i].EntryType) {
224 case CAL_START_DATETIME:
225 dtp = &Note->Entries[i].Date ;
226 if ( dtp->Hour > 24 ) {
227 event->setFloats( true );
228 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
229 } else {
230 event->setDtStart (fromGSM ( dtp ));
231
232 }
233 //Note->Entries[i].Date.Hour = 5;
234 break;
235 case CAL_END_DATETIME:
236 dtp = &Note->Entries[i].Date ;
237 if ( dtp->Hour > 24 ) {
238 event->setFloats( true );
239 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
240 } else {
241 event->setDtEnd (fromGSM ( dtp ));
242 }
243 break;
244 case CAL_ALARM_DATETIME:
245 dtp = &Note->Entries[i].Date ;
246 alarm = true;
247 alarmDt = fromGSM ( dtp );
248 break;
249 case CAL_SILENT_ALARM_DATETIME:
250 dtp = &Note->Entries[i].Date ;
251 alarm = true;
252 alarmDt = fromGSM ( dtp );
253 break;
254 case CAL_RECURRANCE:
255 rec_type = Note->Entries[i].Number;
256 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
257 break;
258 case CAL_TEXT:
259 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) );
260 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text )));
261 break;
262 case CAL_LOCATION:
263 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) ));
264 break;
265 case CAL_PHONE:
266 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
267 break;
268 case CAL_PRIVATE:
269 if ( Note->Entries[i].Number == 1 )
270 event->setSecrecy( Incidence::SecrecyPrivate );
271 else
272 event->setSecrecy( Incidence::SecrecyPublic );
273
274 break;
275 case CAL_CONTACTID:
276#if 0
277 entry.Location = Note->Entries[i].Number;
278 entry.MemoryType = MEM_ME;
279 error=Phone->GetMemory(&s, &entry);
280 if (error == ERR_NONE) {
281 name = GSM_PhonebookGetEntryName(&entry);
282 if (name != NULL) {
283 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
284 } else {
285 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
286 }
287 } else {
288 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
289 }
290#endif
291 break;
292 case CAL_REPEAT_DAYOFWEEK:
293 repeat_dayofweek = Note->Entries[i].Number;
294 repeating = true;
295 break;
296 case CAL_REPEAT_DAY:
297 repeat_day = Note->Entries[i].Number;
298 repeating = true;
299 break;
300 case CAL_REPEAT_WEEKOFMONTH:
301 repeat_weekofmonth = Note->Entries[i].Number;
302 repeating = true;
303 break;
304 case CAL_REPEAT_MONTH:
305 repeat_month = Note->Entries[i].Number;
306 repeating = true;
307 break;
308 case CAL_REPEAT_FREQUENCY:
309 repeat_frequency = Note->Entries[i].Number;
310 repeating = true;
311 break;
312 case CAL_REPEAT_STARTDATE:
313 repeat_startdate = Note->Entries[i].Date;
314 repeating = true;
315 break;
316 case CAL_REPEAT_STOPDATE:
317 repeat_stopdate = Note->Entries[i].Date;
318 repeating = true;
319 break;
320 }
321 }
322#if 0
323 event->setDescription( attList[4] );
324 bool repeating = false;
325 int repeat_dayofweek = -1;
326 int repeat_day = -1;
327 int repeat_weekofmonth = -1;
328 int repeat_month = -1;
329 int repeat_frequency = -1;
330 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
331 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
332
333#endif
334
335 QString recurString = "no";
336 if ( repeating && repeat_frequency != -1) {
337 recurString = "y";
338 if ( repeat_dayofweek >= 0 )
339 recurString += "dow" + QString::number (repeat_dayofweek);
340 if ( repeat_day >= 0 )
341 recurString += "d" + QString::number (repeat_day);
342 if ( repeat_weekofmonth >= 0 )
343 recurString += "w" + QString::number (repeat_weekofmonth);
344 if ( repeat_month >= 0 )
345 recurString += "m" + QString::number ( repeat_month );
346 if ( repeat_frequency >= 0 )
347 recurString += "f" + QString::number (repeat_frequency );
348
349 int rtype = 0;
350 // qDebug("recurs ");
351 QDate startDate, endDate;
352 if ( repeat_startdate.Day > 0 ) {
353 startDate = datefromGSM ( &repeat_startdate );
354 event->setDtStart(QDateTime ( startDate, event->dtStart().time()));
355 } else {
356 startDate = event->dtStart().date();
357 }
358 int freq = repeat_frequency;
359 bool hasEndDate = false;
360 if ( repeat_stopdate.Day > 0 ) {
361 endDate = datefromGSM ( &repeat_stopdate );
362 hasEndDate = true;
363 }
364
365 uint weekDaysNum = repeat_dayofweek ;
366 // 1 == monday, 7 == sunday
367 QBitArray weekDays( 7 );
368 int i;
369 int bb = 1;
370 for( i = 1; i <= 7; ++i ) {
371 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
372 bb = 2 << (i-1);
373 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
374 }
375 // qDebug("next ");
376 int pos = 0;
377 Recurrence *r = event->recurrence();
378 /*
379 0 daily;
380 1 weekly;x
381 2 monthpos;x
382 3 monthlyday;
383 4 rYearlyMont
384 bool repeating = false;
385 int repeat_dayofweek = -1;
386 int repeat_day = -1;
387 int repeat_weekofmonth = -1;
388 int repeat_month = -1;
389 int repeat_frequency = -1;
390 */
391 int dayOfWeek = startDate.dayOfWeek();
392 if ( repeat_weekofmonth >= 0 ) {
393 rtype = 2; // ************************ 2 MonthlyPos
394 pos = repeat_weekofmonth;
395 if ( repeat_dayofweek >= 0 )
396 dayOfWeek = repeat_dayofweek;
397 if (repeat_month > 0) {
398 if ( repeat_month != event->dtStart().date().month() ) {
399 QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() );
400 event->setDtStart(QDateTime ( date , event->dtStart().time()) );
401 }
402 if ( freq == 1 )
403 freq = 12;
404 }
405 } else if ( repeat_dayofweek >= 0 ) {
406 rtype = 1;// ************************ 1 Weekly
407 } else if ( repeat_day >= 0 ) {
408 if ( repeat_month > 0) {
409 rtype = 4;
410 } else {
411 rtype = 3;
412 }
413 } else {
414 rtype = 0 ;
415 }
416
417 if ( rtype == 0 ) {
418 if ( hasEndDate ) r->setDaily( freq, endDate );
419 else r->setDaily( freq, -1 );
420 } else if ( rtype == 1 ) {
421 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
422 else r->setWeekly( freq, weekDays, -1 );
423 } else if ( rtype == 3 ) {
424 if ( hasEndDate )
425 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
426 else
427 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
428 r->addMonthlyDay( startDate.day() );
429 } else if ( rtype == 2 ) {
430 if ( hasEndDate )
431 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
432 else
433 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
434 QBitArray days( 7 );
435 days.fill( false );
436 days.setBit( dayOfWeek - 1 );
437 r->addMonthlyPos( pos, days );
438 } else if ( rtype == 4 ) {
439 if ( hasEndDate )
440 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
441 else
442 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
443 r->addYearlyNum( startDate.month() );
444 }
445 } else {
446 event->recurrence()->unsetRecurs();
447 }
448
449 QStringList cat = event->categories();
450 QString nCat = getCategory( Note );
451
452 if ( !nCat.isEmpty() )
453 if ( !cat.contains( nCat )) {
454 cat << nCat;
455 event->setCategories( cat );
456 }
457
458 if ( alarm ) {
459 Alarm *alarm;
460 if ( event->alarms().count() > 0 )
461 alarm = event->alarms().first();
462 else {
463 alarm = new Alarm( event );
464 event->addAlarm( alarm );
465 }
466 alarm->setType( Alarm::Audio );
467 alarm->setEnabled( true );
468 int alarmOffset = alarmDt.secsTo( event->dtStart() );
469 alarm->setStartOffset( -alarmOffset );
470 } else {
471 Alarm *alarm;
472 if ( event->alarms().count() > 0 ) {
473 alarm = event->alarms().first();
474 alarm->setType( Alarm::Audio );
475 alarm->setStartOffset( -60*15 );
476 alarm->setEnabled( false );
477 }
478 }
479 // csum *****************************************
480
481 uint cSum;
482 cSum = PhoneFormat::getCsumEvent( event );
483 event->setCsum( mProfileName, QString::number( cSum ));
484 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
485 mCalendar->addEvent( event);
486
487 return true;
488 }
489
490
491 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = false ) {
492 QDateTime dt;
493 int y,m,t,h,min,sec;
494 y = dtp->Year;
495 m = dtp->Month;
496 t = dtp->Day;
497 h = dtp->Hour;
498 min = dtp->Minute;
499 sec = dtp->Second;
500 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
501 // dtp->Timezone: offset in hours
502 int offset = KGlobal::locale()->localTimeOffset( dt );
503 if ( useTz )
504 dt = dt.addSecs ( offset*60);
505 return dt;
506
507 }
508
509 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 55 static QString dtToString( const QDateTime& dti, bool useTZ = false )
510 { 56 {
511 QString datestr; 57 QString datestr;
@@ -528,53 +74,11 @@ public:
528 } 74 }
529 return datestr + timestr; 75 return datestr + timestr;
530 } 76 }
531 QDate datefromGSM ( GSM_DateTime*dtp ) {
532 return QDate ( dtp->Year, dtp->Month, dtp->Day );
533 }
534 QString getCategory( GSM_CalendarEntry*Note)
535 {
536 QString CATEGORY;
537 switch (Note->Type) {
538 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
539 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
540 //case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
541 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
542 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
543 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
544 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
545 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
546 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
547 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
548 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
549 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
550 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
551 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
552 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
553 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
554 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
555 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
556 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
557 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
558 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
559 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
560 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
561 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
562 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
563 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
564 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
565 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
566 default : CATEGORY = QString("");
567 }
568 77
569 return CATEGORY;
570 }
571 78
572protected:
573private:
574 Calendar *mCalendar;
575 QString mProfileName ;
576}; 79};
577 80
81
578 82
579PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 83PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
580{ 84{
@@ -587,6 +91,7 @@ PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection,
587PhoneFormat::~PhoneFormat() 91PhoneFormat::~PhoneFormat()
588{ 92{
589} 93}
94#if 0
590int PhoneFormat::initDevice(GSM_StateMachine *s) 95int PhoneFormat::initDevice(GSM_StateMachine *s)
591{ 96{
592 GSM_ReadConfig(NULL, &s->Config[0], 0); 97 GSM_ReadConfig(NULL, &s->Config[0], 0);
@@ -612,6 +117,7 @@ int PhoneFormat::initDevice(GSM_StateMachine *s)
612 int error=GSM_InitConnection(s,3); 117 int error=GSM_InitConnection(s,3);
613 return error; 118 return error;
614} 119}
120#endif
615ulong PhoneFormat::getCsumTodo( Todo* todo ) 121ulong PhoneFormat::getCsumTodo( Todo* todo )
616{ 122{
617 QStringList attList; 123 QStringList attList;
@@ -771,108 +277,159 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
771#define DEBUGMODE false 277#define DEBUGMODE false
772bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 278bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
773{ 279{
774 GSM_StateMachines;
775 qDebug(" load ");
776 s.opened = false;
777 s.msg = NULL;
778 s.ConfigNum = 0;
779 QLabel status ( i18n("Opening device ..."), 0 );
780 int w = status.sizeHint().width()+20 ;
781 if ( w < 200 ) w = 230;
782 int h = status.sizeHint().height()+20 ;
783 int dw = QApplication::desktop()->width();
784 int dh = QApplication::desktop()->height();
785 status.setCaption(i18n("Reading phone...") );
786 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
787 status.show();
788 status.raise();
789 qApp->processEvents();
790 280
791 int error=initDevice(&s); 281 QString fileName;
792 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 282#ifdef _WIN32_
793 if ( error != ERR_NONE ) 283 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
284#else
285 fileName = "/tmp/kdepimtemp.vcs";
286#endif
287 QString command ="./kammu --backup " + fileName + " -yes";
288 int ret = system ( command.latin1() );
289 if ( ret != 0 )
794 return false; 290 return false;
795 GSM_Phone_Functions*Phone; 291 VCalFormat vfload;
796 GSM_CalendarEntrynote; 292 vfload.setLocalTime ( true );
797 bool start = true; 293 if ( ! vfload.load( calendar, fileName ) )
798 Phone=s.Phone.Functions; 294 return false;
799 bool gshutdown = false; 295 QPtrList<Event> er = calendar->rawEvents();
800 PhoneParser handler( calendar, mProfileName ); 296 Event* ev = er.first();
801 int ccc = 0; 297 while ( ev ) {
802 QString message = i18n(" Reading event # "); 298 int id = ev->pilotId();
803 int procCount = 0; 299 Event *event;
804 qDebug("Debug: only 10 calender items are downloaded "); 300 event = existingCal->event( mProfileName ,QString::number( id ) );
805 while (!gshutdown && ccc++ < 10) { 301 if ( event ) {
806 status.setText ( message + QString::number ( ++procCount ) ); 302 event = (Event*)event->clone();
807 qApp->processEvents(); 303 copyEvent( event, ev );
808 qDebug("readEvent %d ", ccc); 304 calendar->deleteEvent( ev );
809 error=Phone->GetNextCalendar(&s,&note,start); 305 calendar->addEvent( event);
810 if (error == ERR_EMPTY) break; 306 }
811 start = false; 307 else
812 handler.readEvent( existingCal, &note ); 308 event = ev;
813 qDebug("Org loc %d ",note.Location); 309 uint cSum;
814 //note.Location = 0; 310 cSum = PhoneFormat::getCsumEvent( event );
815 error=Phone->SetCalendar(&s,&note); 311 event->setCsum( mProfileName, QString::number( cSum ));
816 qDebug("new loc %d ",note.Location); 312 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
313 event->setID( mProfileName,QString::number( id ) );
314 ev = er.next();
315 }
316 {
317 QPtrList<Todo> tr = calendar->rawTodos();
318 Todo* ev = tr.first();
319 while ( ev ) {
320
321 QStringList cat = ev->categories();
322 if ( cat.contains( "MeetingDEF" )) {
323 ev->setCategories( QStringList() );
324 }
325 int id = ev->pilotId();
326 Todo *event;
327 event = existingCal->todo( mProfileName ,QString::number( id ) );
328 if ( event ) {
329 event = (Todo*)event->clone();
330 copyTodo( event, ev );
331 calendar->deleteTodo( ev );
332 calendar->addTodo( event);
333 }
334 else
335 event = ev;
336 uint cSum;
337 cSum = PhoneFormat::getCsumTodo( event );
338 event->setCsum( mProfileName, QString::number( cSum ));
339 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
340 event->setID( mProfileName,QString::number( id ) );
341 ev = tr.next();
342 }
817 } 343 }
818
819 start = true;
820 GSM_ToDoEntry ToDo;
821 ccc = 0;
822 message = i18n(" Reading todo # ");
823 procCount = 0;
824 while (!gshutdown && ccc++ < 10) {
825 status.setText ( message + QString::number ( ++procCount ) );
826 qApp->processEvents();
827 error = Phone->GetNextToDo(&s, &ToDo, start);
828 if (error == ERR_EMPTY) break;
829 start = false;
830 qDebug("ReadTodo %d ", ccc);
831 handler.readTodo( existingCal, &ToDo, &s);
832
833 }
834
835 error=GSM_TerminateConnection(&s);
836
837 return true; 344 return true;
838} 345}
839#include <qcstring.h> 346void PhoneFormat::copyEvent( Event* to, Event* from )
840void PhoneFormat::event2GSM( Calendar *cal,Event* ev, GSM_CalendarEntry*Note )
841{ 347{
842 QString eText = vfconverter.eventToString( ev, cal ); 348 if ( from->dtStart().isValid() )
843 int pos = 0; 349 to->setDtStart( from->dtStart() );
844 GSM_ToDoEntry dummy; 350 if ( from->dtEnd().isValid() )
845 qDebug( "Convert event"); 351 to->setDtEnd( from->dtEnd() );
846 QByteArray ba; 352 if ( !from->location().isEmpty() )
847 QDataStream s ( ba, IO_WriteOnly ); 353 to->setLocation( from->location() );
848 s << eText.utf8(); 354 if ( !from->description().isEmpty() )
849 GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); 355 to->setDescription( from->description() );
850 qDebug( "Convert event done"); 356 if ( !from->summary().isEmpty() )
851 Note->Location = 0; 357 to->setSummary( from->summary() );
852 QString loc = ev->getID(mProfileName); 358
853 if ( !loc.isEmpty() ){ 359 QPtrListIterator<Alarm> it( from->alarms() );
854 Note->Location = loc.toInt(); 360 to->clearAlarms();
361 const Alarm *a;
362 while( (a = it.current()) ) {
363 Alarm *b = new Alarm( *a );
364 b->setParent( to );
365 to->addAlarm( b );
366 ++it;
367 }
368 QStringList cat = to->categories();
369 QStringList catFrom = from->categories();
370 QString nCat;
371 int iii;
372 for ( iii = 0; iii < catFrom.count();++iii ) {
373 nCat = catFrom[iii];
374 if ( !nCat.isEmpty() )
375 if ( !cat.contains( nCat )) {
376 cat << nCat;
377 }
855 } 378 }
379 to->setCategories( cat );
380 Recurrence * r = new Recurrence( *from->recurrence(),to);
381 to->setRecurrence( r ) ;
382
856 383
857} 384}
858void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) 385void PhoneFormat::copyTodo( Todo* to, Todo* from )
859{ 386{
860 qDebug( "Convert todo1"); 387 if ( from->dtStart().isValid() )
861 QString tText = vfconverter.todoToString( todo, cal ); 388 to->setDtStart( from->dtStart() );
862 int pos = 0; 389 if ( from->dtDue().isValid() )
863 GSM_CalendarEntry dummy; 390 to->setDtDue( from->dtDue() );
864 QByteArray ba; 391 if ( !from->location().isEmpty() )
865 QDataStream s ( ba, IO_WriteOnly ); 392 to->setLocation( from->location() );
866 s << tText.utf8(); 393 if ( !from->description().isEmpty() )
867 GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); 394 to->setDescription( from->description() );
868 qDebug( "Convert todo done "); 395 if ( !from->summary().isEmpty() )
869 gsmTodo->Location = 0; 396 to->setSummary( from->summary() );
870 QString loc = todo->getID(mProfileName); 397
871 if ( !loc.isEmpty() ){ 398 QPtrListIterator<Alarm> it( from->alarms() );
872 gsmTodo->Location = loc.toInt(); 399 to->clearAlarms();
400 const Alarm *a;
401 while( (a = it.current()) ) {
402 Alarm *b = new Alarm( *a );
403 b->setParent( to );
404 to->addAlarm( b );
405 ++it;
406 }
407 QStringList cat = to->categories();
408 QStringList catFrom = from->categories();
409 QString nCat;
410 int iii;
411 for ( iii = 0; iii < catFrom.count();++iii ) {
412 nCat = catFrom[iii];
413 if ( !nCat.isEmpty() )
414 if ( !cat.contains( nCat )) {
415 cat << nCat;
416 }
873 } 417 }
874 418 to->setCategories( cat );
419 if ( from->isCompleted() ) {
420 to->setCompleted( true );
421 if( from->completed().isValid() )
422 to->setCompleted( from->completed() );
423 } else {
424 // set percentcomplete only, if to->isCompleted()
425 if ( to->isCompleted() )
426 to->setPercentComplete(from->percentComplete());
427 }
428 to->setPriority(from->priority());
429
875} 430}
431#include <qcstring.h>
432
876void PhoneFormat::afterSave( Incidence* inc) 433void PhoneFormat::afterSave( Incidence* inc)
877{ 434{
878 uint csum; 435 uint csum;
@@ -887,12 +444,6 @@ void PhoneFormat::afterSave( Incidence* inc)
887} 444}
888bool PhoneFormat::save( Calendar *calendar) 445bool PhoneFormat::save( Calendar *calendar)
889{ 446{
890
891 GSM_StateMachines;
892 qDebug(" save ");
893 s.opened = false;
894 s.msg = NULL;
895 s.ConfigNum = 0;
896 QLabel status ( i18n(" Opening device ..."), 0 ); 447 QLabel status ( i18n(" Opening device ..."), 0 );
897 int w = status.sizeHint().width()+20 ; 448 int w = status.sizeHint().width()+20 ;
898 if ( w < 200 ) w = 230; 449 if ( w < 200 ) w = 230;
@@ -904,232 +455,47 @@ bool PhoneFormat::save( Calendar *calendar)
904 status.show(); 455 status.show();
905 status.raise(); 456 status.raise();
906 qApp->processEvents(); 457 qApp->processEvents();
907 458 QString message;
908 int error=initDevice(&s);
909 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
910 if ( error != ERR_NONE )
911 return false;
912 GSM_Phone_Functions*Phone;
913 GSM_CalendarEntryNote;
914 bool start = true;
915 Phone=s.Phone.Functions;
916 bool gshutdown = false;
917 QPtrList<Event> er = calendar->rawEvents();
918 Event* ev = er.first();
919 QString message = i18n(" Deleting event # ");
920 int procCount = 0;
921 int diffProc = 0;
922 bool setPossible = true;
923#ifdef _WIN32_ 459#ifdef _WIN32_
924 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 460 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
925#else 461#else
926 QString fileName = "/tmp/kdepimtemp.vcs"; 462 QString fileName = "/tmp/kdepimtemp.vcs";
927#endif 463#endif
928 //algo 1 delete event
929 while ( ev ) {
930 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
931
932 status.setText ( message + QString::number ( ++procCount ) );
933 qApp->processEvents();
934 qDebug("del event1 %d ", procCount);
935 //event2GSM( calendar, ev, &Note );
936 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
937 464
938 QString loc = ev->getID(mProfileName); 465 // 1 remove events which should be deleted
939 if ( !loc.isEmpty() ){ 466 QPtrList<Event> er = calendar->rawEvents();
940 Note.Location = loc.toInt(); 467 Event* ev = er.first();
941 } else { 468 while ( ev ) {
942 qDebug("error: loc is empty "); 469 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
943 } 470 calendar->deleteEvent( ev );
944 error = Phone->DeleteCalendar(&s, &Note); 471 } else {
945 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
946 qDebug(" e error delete1 planB %d ", error);
947 break;
948 }
949 }
950 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
951 // we have to do this later after deleting
952
953 }
954 else { // change existing
955 472
956 QString loc = ev->getID(mProfileName); 473 }
957 if ( !loc.isEmpty() ){
958 Note.Location = loc.toInt();
959 } else {
960 qDebug("error3: loc is empty ");
961 }
962 error = Phone->DeleteCalendar(&s, &Note);
963 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
964 qDebug(" e error delete2 planB %d ", error);
965 break;
966 }
967 ev->removeID( mProfileName );
968 }
969 }
970 ev = er.next(); 474 ev = er.next();
971 } 475 }
972 //algo 1 delete todo 476 // 2 remove todos which should be deleted
973 GSM_ToDoEntry ToDoEntry;
974 QPtrList<Todo> tl = calendar->rawTodos(); 477 QPtrList<Todo> tl = calendar->rawTodos();
975 Todo* to = tl.first(); 478 Todo* to = tl.first();
976 message = i18n(" Deleting todo # ");
977 procCount = 0;
978 while ( to ) { 479 while ( to ) {
979 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 480 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
980 qDebug("todo3 %d ", procCount); 481 calendar->deleteTodo( to );
981 status.setText ( message + QString::number ( ++procCount ) );
982 qApp->processEvents();
983 qDebug("todo5 %d ", procCount);
984 // todo2GSM( calendar, to, &ToDoEntry );
985 QString loc = to->getID(mProfileName);
986 if ( !loc.isEmpty() ){
987 ToDoEntry.Location = loc.toInt();
988 } else {
989 qDebug("error2: loc is empty ");
990 }
991 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
992 error=Phone->DeleteToDo(&s,&ToDoEntry);
993 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
994 qDebug("delete planB %d ", error);
995 }
996 }
997 else if ( to->getID(mProfileName).isEmpty() ) { // add new
998 ;
999 }
1000 else { // change existing
1001 error=Phone->DeleteToDo(&s,&ToDoEntry);
1002 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1003 qDebug("set planB %d ", error);
1004 }
1005 to->removeID( mProfileName );
1006 }
1007 } 482 }
1008 to = tl.next(); 483 to = tl.next();
1009 } 484 }
1010 //algo 2 add event 485 // 3 save file
1011 ev = er.first(); 486 VCalFormat vfsave;
1012 QString filec; 487 vfsave.setLocalTime ( true );
1013 message = i18n(" Preparing event # "); 488 if ( ! vfsave.save( calendar, fileName ) )
1014 procCount = 0;
1015 while ( ev ) {
1016 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1017 if ( ev->getID(mProfileName).isEmpty() ) {
1018 status.setText ( message + QString::number ( ++procCount ) );
1019 qApp->processEvents();
1020 filec += vfconverter.eventToString( ev, calendar )+ "\n";
1021 afterSave ( ev );
1022
1023 }
1024 }
1025 ev = er.next();
1026 }
1027 //algo 2 add todo
1028 to = tl.first();
1029 procCount = 0;
1030 message = i18n(" Preparing todo # ");
1031 while ( to ) {
1032 qDebug("todo2 %d ", procCount);
1033 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1034 qDebug("todo4 %d ", procCount);
1035 if ( to->getID(mProfileName).isEmpty() ) {
1036 status.setText ( message + QString::number ( ++procCount ) );
1037 qApp->processEvents();
1038 filec += vfconverter.todoToString( to, calendar )+ "\n";
1039 afterSave ( to );
1040 }
1041 }
1042 to = tl.next();
1043 }
1044 if ( filec.isEmpty() ) {
1045 qDebug("Nothing to write back.Finished. ");
1046 error=GSM_TerminateConnection(&s);
1047 return true;
1048 }
1049 //algo 3 saving file
1050 message = i18n(" Saving temp file ... ");
1051 status.setText ( message );
1052 qApp->processEvents();
1053 QFile file( fileName );
1054 if (!file.open( IO_WriteOnly ) ) {
1055 qDebug("error open file ");
1056 error=GSM_TerminateConnection(&s);
1057 return false; 489 return false;
1058 } 490 // 4 call kammu
1059 QTextStream ts( &file ); 491 QString command ="./kammu --restore " + fileName ;
1060 ts.setCodec( QTextCodec::codecForName("utf8") ); 492 int ret = system ( command.latin1() );
1061 ts << filec ; 493 if ( ret != 0 )
1062 file.close(); 494 return false;
1063 495 // 5 reread data
1064
1065 message = i18n(" Parsing temp file ... ");
1066 status.setText ( message );
1067 qApp->processEvents();
1068 GSM_Backup Backup;
1069 error=GSM_ReadBackupFile( (char*) fileName.latin1() ,&Backup);
1070 qDebug("Read file result %d ",error );
1071 //algo 4 writing event
1072 int max, i;
1073 procCount = 0;
1074 message = i18n(" Writing event # ");
1075 if (Backup.Calendar[0] != NULL) {
1076 max = 0;
1077 while (Backup.Calendar[max]!=NULL) max++;
1078
1079 GSM_DateTime*dtp;
1080
1081 for (i=0;i<max;i++) {
1082 status.setText ( message + QString::number ( ++procCount ) );
1083 qApp->processEvents();
1084 Note = *Backup.Calendar[i];
1085
1086#if 0
1087 int j;
1088 for (j=0;j<Note.EntriesNum;j++) {
1089 //qDebug(" for ev");
1090 switch (Note.Entries[j].EntryType) {
1091 case CAL_START_DATETIME:
1092 //Note->Entries[i].Date.Hour = 5;
1093 dtp = &Note.Entries[j].Date;
1094 qDebug("start event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second );
1095 break;
1096 case CAL_END_DATETIME:
1097 dtp = &Note.Entries[j].Date;
1098 qDebug("end event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second );
1099 break;
1100 }
1101 }
1102 int type = Note.Type;
1103 qDebug(" event type %d - %d %d - %d %d %d",type, GSM_CAL_CALL , GSM_CAL_MEETING ,GSM_CAL_BIRTHDAY, GSM_CAL_MEMO ,GSM_CAL_ALARM );
1104#endif
1105
1106 Note.Type = GSM_CAL_MEETING;
1107 // pending: fix in gammu GSM_ReadBackupFile the type settings
1108 int loc = Note.Location;
1109 Note.Location = 0;
1110 error=Phone->AddCalendar(&s,&Note);
1111 qDebug("add event %d %d %d", error, Note.Location, loc );
1112 }
1113 }
1114 //algo 4 writing todo
1115 procCount = 0;
1116 message = i18n(" Writing todo # ");
1117 if (Backup.ToDo[0] != NULL) {
1118 max = 0;
1119 while (Backup.ToDo[max]!=NULL) max++;
1120 for (i=0;i<max;i++) {
1121 status.setText ( message + QString::number ( ++procCount ) );
1122 qApp->processEvents();
1123 ToDoEntry = *Backup.ToDo[i];
1124 error = Phone->AddToDo(&s,&ToDoEntry);
1125 qDebug("add todo %d ", error);
1126 }
1127 }
1128 //algo 5 reread
1129 message = i18n(" Rereading all data ... "); 496 message = i18n(" Rereading all data ... ");
1130 status.setText ( message ); 497 status.setText ( message );
1131 qApp->processEvents(); 498 qApp->processEvents();
1132 error=GSM_TerminateConnection(&s);
1133 CalendarLocal* calendarTemp = new CalendarLocal(); 499 CalendarLocal* calendarTemp = new CalendarLocal();
1134 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 500 calendarTemp->setTimeZoneId( calendar->timeZoneId());
1135 if ( ! load( calendarTemp,calendar) ){ 501 if ( ! load( calendarTemp,calendar) ){
@@ -1137,16 +503,16 @@ bool PhoneFormat::save( Calendar *calendar)
1137 delete calendarTemp; 503 delete calendarTemp;
1138 return false; 504 return false;
1139 } 505 }
506 // 6 compare data
1140 507
1141 508//algo 6 compare event
1142 //algo 6 compare event 509 er = calendar->rawEvents();
1143 ev = er.first(); 510 ev = er.first();
1144 message = i18n(" Comparing event # "); 511 message = i18n(" Comparing event # ");
1145 QPtrList<Event> er1 = calendarTemp->rawEvents(); 512 QPtrList<Event> er1 = calendarTemp->rawEvents();
1146 Event* ev1; 513 Event* ev1;
1147 procCount = 0; 514 int procCount = 0;
1148 while ( ev ) { 515 while ( ev ) {
1149 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) {
1150 qDebug("event new ID "); 516 qDebug("event new ID ");
1151 status.setText ( message + QString::number ( ++procCount ) ); 517 status.setText ( message + QString::number ( ++procCount ) );
1152 qApp->processEvents(); 518 qApp->processEvents();
@@ -1155,6 +521,7 @@ bool PhoneFormat::save( Calendar *calendar)
1155 while ( ev1 ) { 521 while ( ev1 ) {
1156 if ( ev1->getCsum( mProfileName ) == cSum ) { 522 if ( ev1->getCsum( mProfileName ) == cSum ) {
1157 er1.remove( ev1 ); 523 er1.remove( ev1 );
524 afterSave( ev );
1158 ev->setID(mProfileName, ev1->getID(mProfileName) ); 525 ev->setID(mProfileName, ev1->getID(mProfileName) );
1159 break; 526 break;
1160 } 527 }
@@ -1163,10 +530,9 @@ bool PhoneFormat::save( Calendar *calendar)
1163 if ( ! ev1 ) { 530 if ( ! ev1 ) {
1164 ev->removeID(mProfileName); 531 ev->removeID(mProfileName);
1165 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 532 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
1166 qDebug("Probably writing back of events not supported ");
1167 } 533 }
1168 534
1169 } 535
1170 ev = er.next(); 536 ev = er.next();
1171 } 537 }
1172 //algo 6 compare todo 538 //algo 6 compare todo
@@ -1177,7 +543,6 @@ bool PhoneFormat::save( Calendar *calendar)
1177 message = i18n(" Comparing todo # "); 543 message = i18n(" Comparing todo # ");
1178 while ( to ) { 544 while ( to ) {
1179 qDebug("todo2 %d ", procCount); 545 qDebug("todo2 %d ", procCount);
1180 if ( to->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) {
1181 status.setText ( message + QString::number ( ++procCount ) ); 546 status.setText ( message + QString::number ( ++procCount ) );
1182 qApp->processEvents(); 547 qApp->processEvents();
1183 QString cSum = to->getCsum(mProfileName); 548 QString cSum = to->getCsum(mProfileName);
@@ -1185,6 +550,7 @@ bool PhoneFormat::save( Calendar *calendar)
1185 while ( to1 ) { 550 while ( to1 ) {
1186 if ( to1->getCsum( mProfileName ) == cSum ) { 551 if ( to1->getCsum( mProfileName ) == cSum ) {
1187 tl1.remove( to1 ); 552 tl1.remove( to1 );
553 afterSave( to );
1188 to->setID(mProfileName, to1->getID(mProfileName) ); 554 to->setID(mProfileName, to1->getID(mProfileName) );
1189 break; 555 break;
1190 } 556 }
@@ -1193,491 +559,15 @@ bool PhoneFormat::save( Calendar *calendar)
1193 if ( ! to1 ) { 559 if ( ! to1 ) {
1194 to->removeID(mProfileName); 560 to->removeID(mProfileName);
1195 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 561 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
1196 qDebug("Probably writing back of todos not supported ");
1197 } 562 }
1198 } 563
1199 to = tl.next(); 564 to = tl.next();
1200 } 565 }
1201 delete calendarTemp; 566 delete calendarTemp;
1202 return true; 567 return true;
1203 // *******************************************************************
1204 // *******************************************************************
1205 // *******************************************************************
1206#if 0
1207 while ( ev && ! planB) {
1208 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
1209
1210 status.setText ( message + QString::number ( ++procCount ) );
1211 qApp->processEvents();
1212 qDebug("event1 %d ", procCount);
1213 event2GSM( calendar, ev, &Note );
1214 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1215 error = Phone->DeleteCalendar(&s, &Note);
1216 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1217 planB = true;
1218 qDebug(" e delete1 planB %d ", error);
1219 break;
1220 }
1221 }
1222 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
1223 // we have to do this later after deleting
1224
1225 }
1226 else { // change existing
1227 if ( setPossible ) {
1228 error = Phone->SetCalendar(&s, &Note);
1229 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1230 setPossible = false;
1231 ++diffProc;
1232 qDebug("Set cal not supported %d ", error);
1233 break;
1234 }
1235 }
1236 if ( ! setPossible) {
1237 ++diffProc;
1238 error = Phone->DeleteCalendar(&s, &Note);
1239 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1240 planB = true;
1241 qDebug(" e delete2 planB %d ", error);
1242 break;
1243 }
1244 ev->removeID( mProfileName );
1245 }
1246 qDebug("Change Calendar. Location %d status: %d",Note.Location, error );
1247 }
1248 }
1249 ev = er.next();
1250 }
1251 ev = er.first();
1252 // pending get empty slots
1253 int loc = 0;
1254 procCount -= diffProc;
1255 while ( ev && ! planB) {
1256 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1257 qDebug("event2 %d ", procCount);
1258 if ( ev->getID(mProfileName).isEmpty() ) {
1259 status.setText ( message + QString::number ( ++procCount ) );
1260 qApp->processEvents();
1261 //int newID ;//= pending
1262 //ev->setID(mProfileName, QString::number( newID ));
1263 event2GSM( calendar, ev, &Note );
1264 ++loc;
1265 Note.Location = loc;
1266 error = Phone->AddCalendar(&s, &Note);
1267 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1268 planB = true;
1269 qDebug(" e add planB %d ", error);
1270 break;
1271 }
1272 ev->setID( mProfileName, QString::number( Note.Location ) );
1273 qDebug("New Calendar. Location %d stat %d %d",Note.Location ,error, ERR_UNKNOWN);
1274 afterSave( ev );
1275 } else {
1276 afterSave( ev ); // setting temp sync stat for changed items
1277 }
1278 }
1279 ev = er.next();
1280 }
1281 568
1282 569
1283 if ( planB ) {
1284 qDebug("delete all calendar...");
1285 status.setText ( i18n("Deleting all calendar..."));
1286 qApp->processEvents();
1287 error=Phone->DeleteAllCalendar(&s);
1288 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1289 message = i18n(" Deleting event # ");
1290 procCount = 0;
1291 while (1) {
1292 status.setText ( message + QString::number ( ++procCount ) );
1293 qApp->processEvents();
1294 qDebug("deleting event ... %d", procCount);
1295 error = Phone->GetNextCalendar(&s,&Note,true);
1296 if (error != ERR_NONE) break;
1297 error = Phone->DeleteCalendar(&s,&Note);
1298 }
1299 qDebug("deleting calendar ... finished");
1300 } else {
1301 status.setText ( i18n("All calendar deleted!"));
1302 qDebug("all cal deleted");
1303 }
1304 bool planC = false;
1305 ev = er.first();
1306 procCount = 0;
1307 message = i18n(" Writing event # ");
1308 while ( ev && ! planC) {
1309 status.setText ( message + QString::number ( ++procCount ) );
1310 qApp->processEvents();
1311 event2GSM( calendar, ev, &Note );
1312 Note.Location = procCount;
1313 error=Phone->AddCalendar(&s,&Note);
1314 if (error != ERR_NONE ) {
1315 // we have currently no planC :-(
1316 // planC = true;
1317 //qDebug("add planC %d ", error);
1318 //break;
1319 // we remove the ID such that this todo is not deleted after next sync
1320 ev->removeID(mProfileName);
1321 ev->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1322 qDebug("error :cal adding loc %d planB stat %d ", Note.Location ,error);
1323 } else {
1324 qDebug("cal adding loc %d planB stat %d ", Note.Location ,error);
1325 ev->setID(mProfileName, QString::number( Note.Location ));
1326 afterSave( ev );
1327 }
1328 ev = er.next();
1329 }
1330 if ( planC ) {
1331 qDebug("writing cal went wrong...");
1332 570
1333 // we have currently no planC :-(
1334 }
1335 }
1336 GSM_ToDoEntry ToDoEntry;
1337 QPtrList<Todo> tl = calendar->rawTodos();
1338 Todo* to = tl.first();
1339
1340 message = i18n(" Processing todo # ");
1341 procCount = 0;
1342 planB = false;
1343 while ( to && ! planB ) {
1344 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1345 qDebug("todo3 %d ", procCount);
1346 status.setText ( message + QString::number ( ++procCount ) );
1347 qApp->processEvents();
1348 qDebug("todo5 %d ", procCount);
1349 todo2GSM( calendar, to, &ToDoEntry );
1350 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1351 error=Phone->DeleteToDo(&s,&ToDoEntry);
1352 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1353 planB = true;
1354 qDebug("delete planB %d ", error);
1355 }
1356 }
1357 else if ( to->getID(mProfileName).isEmpty() ) { // add new
1358 ;
1359 }
1360 else { // change existing
1361 error=Phone->SetToDo(&s,&ToDoEntry);
1362 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1363 planB = true;
1364 qDebug("set planB %d ", error);
1365 }
1366 qDebug("Old Todo. Location %d %d",ToDoEntry.Location , error );
1367 }
1368 }
1369 to = tl.next();
1370 }
1371
1372 // pending get empty slots
1373 to = tl.first();
1374 while ( to && ! planB ) {
1375 qDebug("todo2 %d ", procCount);
1376 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1377 qDebug("todo4 %d ", procCount);
1378 if ( to->getID(mProfileName).isEmpty() ) {
1379 status.setText ( message + QString::number ( ++procCount ) );
1380 qApp->processEvents();
1381 //int newID ;//= pending
1382 //to->setID(mProfileName, QString::number( newID ));
1383 todo2GSM( calendar,to, &ToDoEntry );
1384 ToDoEntry.Location = 0;
1385 error=Phone->AddToDo(&s,&ToDoEntry);
1386 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1387 planB = true;
1388 qDebug("new planB %d ", error);
1389 }
1390 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1391 afterSave( to );
1392 qDebug("New Todo. Location %d %d",ToDoEntry.Location, error );
1393 } else {
1394 afterSave( to );
1395 }
1396 }
1397 to = tl.next();
1398 }
1399 if ( planB ) {
1400 qDebug("delete all ...");
1401 error=Phone->DeleteAllToDo(&s);
1402 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1403 while (1) {
1404 qDebug("deleting todo ...");
1405 error = Phone->GetNextToDo(&s,&ToDoEntry,true);
1406 if (error != ERR_NONE) break;
1407 error = Phone->DeleteToDo(&s,&ToDoEntry);
1408 }
1409 qDebug("deleting todo ... finished");
1410 } else {
1411 qDebug("all todo deleted");
1412 }
1413 bool planC = false;
1414 to = tl.first();
1415 while ( to && ! planC ) {
1416 todo2GSM( calendar,to, &ToDoEntry );
1417 ToDoEntry.Location = 0;
1418 error=Phone->AddToDo(&s,&ToDoEntry);
1419 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1420 // we have currently no planC :-(
1421 // planC = true;
1422 //qDebug("add planC %d ", error);
1423 //break;
1424 // we remove the ID such that this todo is not deleted after next sync
1425 to->removeID(mProfileName);
1426 to->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1427 } else {
1428 qDebug("adding %d planB %d ", ToDoEntry.Location ,error);
1429 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1430 afterSave( to );
1431 }
1432 to = tl.next();
1433 }
1434 if ( planC ) {
1435 // we have currently no planC :-(
1436 }
1437 }
1438 return true;
1439#endif
1440}
1441QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ )
1442{
1443 QString datestr;
1444 QString timestr;
1445 int offset = KGlobal::locale()->localTimeOffset( dti );
1446 QDateTime dt;
1447 if (useTZ)
1448 dt = dti.addSecs ( -(offset*60));
1449 else
1450 dt = dti;
1451 if(dt.date().isValid()){
1452 const QDate& date = dt.date();
1453 datestr.sprintf("%04d%02d%02d",
1454 date.year(), date.month(), date.day());
1455 }
1456 if(dt.time().isValid()){
1457 const QTime& time = dt.time();
1458 timestr.sprintf("T%02d%02d%02d",
1459 time.hour(), time.minute(), time.second());
1460 }
1461 return datestr + timestr;
1462}
1463QString PhoneFormat::getEventString( Event* event )
1464{
1465#if 0
1466 QStringList list;
1467 list.append( QString::number(event->zaurusId() ) );
1468 list.append( event->categories().join(",") );
1469 if ( !event->summary().isEmpty() )
1470 list.append( event->summary() );
1471 else
1472 list.append("" );
1473 if ( !event->location().isEmpty() )
1474 list.append( event->location() );
1475 else
1476 list.append("" );
1477 if ( !event->description().isEmpty() )
1478 list.append( event->description() );
1479 else
1480 list.append( "" );
1481 if ( event->doesFloat () ) {
1482 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
1483 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
1484 list.append( "1" );
1485
1486 }
1487 else {
1488 list.append( dtToString( event->dtStart()) );
1489 list.append( dtToString( event->dtEnd()) ); //6
1490 list.append( "0" );
1491 }
1492 bool noAlarm = true;
1493 if ( event->alarms().count() > 0 ) {
1494 Alarm * al = event->alarms().first();
1495 if ( al->enabled() ) {
1496 noAlarm = false;
1497 list.append( "0" ); // yes, 0 == alarm
1498 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
1499 if ( al->type() == Alarm::Audio )
1500 list.append( "1" ); // type audio
1501 else
1502 list.append( "0" ); // type silent
1503 }
1504 }
1505 if ( noAlarm ) {
1506 list.append( "1" ); // yes, 1 == no alarm
1507 list.append( "0" ); // no alarm offset
1508 list.append( "1" ); // type
1509 }
1510 // next is: 11
1511 // next is: 11-16 are recurrence
1512 Recurrence* rec = event->recurrence();
1513
1514 bool writeEndDate = false;
1515 switch ( rec->doesRecur() )
1516 {
1517 case Recurrence::rDaily: // 0
1518 list.append( "0" );
1519 list.append( QString::number( rec->frequency() ));//12
1520 list.append( "0" );
1521 list.append( "0" );
1522 writeEndDate = true;
1523 break;
1524 case Recurrence::rWeekly:// 1
1525 list.append( "1" );
1526 list.append( QString::number( rec->frequency()) );//12
1527 list.append( "0" );
1528 {
1529 int days = 0;
1530 QBitArray weekDays = rec->days();
1531 int i;
1532 for( i = 1; i <= 7; ++i ) {
1533 if ( weekDays[i-1] ) {
1534 days += 1 << (i-1);
1535 }
1536 }
1537 list.append( QString::number( days ) );
1538 }
1539 //pending weekdays
1540 writeEndDate = true;
1541
1542 break;
1543 case Recurrence::rMonthlyPos:// 2
1544 list.append( "2" );
1545 list.append( QString::number( rec->frequency()) );//12
1546
1547 writeEndDate = true;
1548 {
1549 int count = 1;
1550 QPtrList<Recurrence::rMonthPos> rmp;
1551 rmp = rec->monthPositions();
1552 if ( rmp.first()->negative )
1553 count = 5 - rmp.first()->rPos - 1;
1554 else
1555 count = rmp.first()->rPos - 1;
1556 list.append( QString::number( count ) );
1557
1558 }
1559
1560 list.append( "0" );
1561 break;
1562 case Recurrence::rMonthlyDay:// 3
1563 list.append( "3" );
1564 list.append( QString::number( rec->frequency()) );//12
1565 list.append( "0" );
1566 list.append( "0" );
1567 writeEndDate = true;
1568 break;
1569 case Recurrence::rYearlyMonth://4
1570 list.append( "4" );
1571 list.append( QString::number( rec->frequency()) );//12
1572 list.append( "0" );
1573 list.append( "0" );
1574 writeEndDate = true;
1575 break;
1576
1577 default:
1578 list.append( "255" );
1579 list.append( QString() );
1580 list.append( "0" );
1581 list.append( QString() );
1582 list.append( "0" );
1583 list.append( "20991231T000000" );
1584 break;
1585 }
1586 if ( writeEndDate ) {
1587
1588 if ( rec->endDate().isValid() ) { // 15 + 16
1589 list.append( "1" );
1590 list.append( dtToString( rec->endDate()) );
1591 } else {
1592 list.append( "0" );
1593 list.append( "20991231T000000" );
1594 }
1595
1596 }
1597 if ( event->doesFloat () ) {
1598 list.append( dtToString( event->dtStart(), false ).left( 8 ));
1599 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
1600
1601 }
1602 else {
1603 list.append( QString() );
1604 list.append( QString() );
1605
1606 }
1607 if (event->dtStart().date() == event->dtEnd().date() )
1608 list.append( "0" );
1609 else
1610 list.append( "1" );
1611
1612
1613 for(QStringList::Iterator it=list.begin();
1614 it!=list.end(); ++it){
1615 QString& s = (*it);
1616 s.replace(QRegExp("\""), "\"\"");
1617 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
1618 s.prepend('\"');
1619 s.append('\"');
1620 } else if(s.isEmpty() && !s.isNull()){
1621 s = "\"\"";
1622 }
1623 }
1624 return list.join(",");
1625#endif
1626 return QString();
1627
1628}
1629QString PhoneFormat::getTodoString( Todo* todo )
1630{
1631#if 0
1632 QStringList list;
1633 list.append( QString::number( todo->zaurusId() ) );
1634 list.append( todo->categories().join(",") );
1635
1636 if ( todo->hasStartDate() ) {
1637 list.append( dtToString( todo->dtStart()) );
1638 } else
1639 list.append( QString() );
1640
1641 if ( todo->hasDueDate() ) {
1642 QTime tim;
1643 if ( todo->doesFloat()) {
1644 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
1645 } else {
1646 list.append( dtToString(todo->dtDue() ) );
1647 }
1648 } else
1649 list.append( QString() );
1650
1651 if ( todo->isCompleted() ) {
1652 list.append( dtToString( todo->completed()) );
1653 list.append( "0" ); // yes 0 == completed
1654 } else {
1655 list.append( dtToString( todo->completed()) );
1656 list.append( "1" );
1657 }
1658 list.append( QString::number( todo->priority() ));
1659 if( ! todo->summary().isEmpty() )
1660 list.append( todo->summary() );
1661 else
1662 list.append( "" );
1663 if (! todo->description().isEmpty() )
1664 list.append( todo->description() );
1665 else
1666 list.append( "" );
1667 for(QStringList::Iterator it=list.begin();
1668 it!=list.end(); ++it){
1669 QString& s = (*it);
1670 s.replace(QRegExp("\""), "\"\"");
1671 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
1672 s.prepend('\"');
1673 s.append('\"');
1674 } else if(s.isEmpty() && !s.isNull()){
1675 s = "\"\"";
1676 }
1677 }
1678 return list.join(",");
1679#endif
1680 return QString();
1681} 571}
1682 572
1683 573
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2c2e51c..8286098 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -27,9 +27,7 @@
27 27
28#include "vcalformat.h" 28#include "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30extern "C" { 30
31#include "../gammu/emb/common/gammu.h"
32}
33namespace KCal { 31namespace KCal {
34 32
35/** 33/**
@@ -51,13 +49,9 @@ class PhoneFormat : public QObject {
51 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
52 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
53 private: 51 private:
54 VCalFormat vfconverter; 52 void copyEvent( Event* to, Event* from );
55 void event2GSM( Calendar *, Event* ev, GSM_CalendarEntry*Note ); 53 void copyTodo( Todo* to, Todo* from );
56 void todo2GSM( Calendar *, Todo* ev, GSM_ToDoEntry *ToDo ); 54 //int initDevice(GSM_StateMachine *s);
57 int initDevice(GSM_StateMachine *s);
58 QString getEventString( Event* );
59 QString getTodoString( Todo* );
60 QString dtToGSM( const QDateTime& dt, bool useTZ = true );
61 QString mProfileName, mDevice, mConnection, mModel; 55 QString mProfileName, mDevice, mConnection, mModel;
62 void afterSave( Incidence* ); 56 void afterSave( Incidence* );
63}; 57};
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 0ebd7d1..4727a7a 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -54,10 +54,13 @@ VCalFormat::~VCalFormat()
54{ 54{
55} 55}
56 56
57void VCalFormat::setLocalTime ( bool b )
58{
59 useLocalTime = b;
60}
57bool VCalFormat::load(Calendar *calendar, const QString &fileName) 61bool VCalFormat::load(Calendar *calendar, const QString &fileName)
58{ 62{
59 mCalendar = calendar; 63 mCalendar = calendar;
60
61 clearException(); 64 clearException();
62 65
63 kdDebug(5800) << "VCalFormat::load() " << fileName << endl; 66 kdDebug(5800) << "VCalFormat::load() " << fileName << endl;
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index 848be78..5bef7ed 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -47,12 +47,12 @@ class VCalFormat : public CalFormat {
47 * else returns FALSE. 47 * else returns FALSE.
48 * @param fileName the name of the calendar on disk. 48 * @param fileName the name of the calendar on disk.
49 */ 49 */
50 bool load(Calendar *,const QString &fileName); 50 bool load(Calendar *,const QString &fileName );
51 /** writes out the calendar to disk in vCalendar format. Returns true if 51 /** writes out the calendar to disk in vCalendar format. Returns true if
52 * successful and false on error. 52 * successful and false on error.
53 * @param fileName the name of the file 53 * @param fileName the name of the file
54 */ 54 */
55 bool save(Calendar *,const QString &fileName); 55 bool save(Calendar *,const QString &fileName );
56 56
57 /** 57 /**
58 Parse string and populate calendar with that information. 58 Parse string and populate calendar with that information.
@@ -61,6 +61,7 @@ class VCalFormat : public CalFormat {
61 /** 61 /**
62 Return calendar information as string. 62 Return calendar information as string.
63 */ 63 */
64 void setLocalTime ( bool );
64 QString toString( Calendar * ); 65 QString toString( Calendar * );
65 QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); 66 QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true );
66 QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); 67 QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true );