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,157 +1,169 @@
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
7############################################################################# 7#############################################################################
8 8
9 MAKEFILE =Makefile 9 MAKEFILE =Makefile
10 QMAKE =qmake 10 QMAKE =qmake
11DEL_FILE = rm -f 11DEL_FILE = rm -f
12CHK_DIR_EXISTS= test -d 12CHK_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 \
19 sub-libkdepim \ 20 sub-libkdepim \
20 sub-kabc \ 21 sub-kabc \
21 sub-korganizer \ 22 sub-korganizer \
22 sub-kaddressbook \ 23 sub-kaddressbook \
23 sub-kabc-plugins-file \ 24 sub-kabc-plugins-file \
24 sub-kabc-plugins-dir 25 sub-kabc-plugins-dir
25 26
26first: all 27first: all
27 28
28all: Makefile $(SUBTARGETS) 29all: Makefile $(SUBTARGETS)
29 30
30gammu/emb/common/$(MAKEFILE): 31gammu/emb/common/$(MAKEFILE):
31 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" 32 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
32 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE) 33 cd gammu/emb/common && $(QMAKE) common.pro -o $(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)
39sub-libical: libical/$(MAKEFILE) FORCE 46sub-libical: libical/$(MAKEFILE) FORCE
40 cd libical && $(MAKE) -f $(MAKEFILE) 47 cd libical && $(MAKE) -f $(MAKEFILE)
41 48
42libkcal/$(MAKEFILE): 49libkcal/$(MAKEFILE):
43 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" 50 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
44 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE) 51 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE)
45sub-libkcal: libkcal/$(MAKEFILE) FORCE 52sub-libkcal: libkcal/$(MAKEFILE) FORCE
46 cd libkcal && $(MAKE) -f $(MAKEFILE) 53 cd libkcal && $(MAKE) -f $(MAKEFILE)
47 54
48microkde/$(MAKEFILE): 55microkde/$(MAKEFILE):
49 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" 56 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
50 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE) 57 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE)
51sub-microkde: microkde/$(MAKEFILE) FORCE 58sub-microkde: microkde/$(MAKEFILE) FORCE
52 cd microkde && $(MAKE) -f $(MAKEFILE) 59 cd microkde && $(MAKE) -f $(MAKEFILE)
53 60
54libkdepim/$(MAKEFILE): 61libkdepim/$(MAKEFILE):
55 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" 62 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
56 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE) 63 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE)
57sub-libkdepim: libkdepim/$(MAKEFILE) FORCE 64sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
58 cd libkdepim && $(MAKE) -f $(MAKEFILE) 65 cd libkdepim && $(MAKE) -f $(MAKEFILE)
59 66
60kabc/$(MAKEFILE): 67kabc/$(MAKEFILE):
61 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" 68 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
62 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE) 69 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE)
63sub-kabc: kabc/$(MAKEFILE) FORCE 70sub-kabc: kabc/$(MAKEFILE) FORCE
64 cd kabc && $(MAKE) -f $(MAKEFILE) 71 cd kabc && $(MAKE) -f $(MAKEFILE)
65 72
66korganizer/$(MAKEFILE): 73korganizer/$(MAKEFILE):
67 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" 74 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
68 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE) 75 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE)
69sub-korganizer: korganizer/$(MAKEFILE) FORCE 76sub-korganizer: korganizer/$(MAKEFILE) FORCE
70 cd korganizer && $(MAKE) -f $(MAKEFILE) 77 cd korganizer && $(MAKE) -f $(MAKEFILE)
71 78
72kaddressbook/$(MAKEFILE): 79kaddressbook/$(MAKEFILE):
73 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" 80 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
74 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE) 81 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE)
75sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE 82sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
76 cd kaddressbook && $(MAKE) -f $(MAKEFILE) 83 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
77 84
78kabc/plugins/file/$(MAKEFILE): 85kabc/plugins/file/$(MAKEFILE):
79 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" 86 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
80 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE) 87 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
81sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE 88sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
82 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) 89 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
83 90
84kabc/plugins/dir/$(MAKEFILE): 91kabc/plugins/dir/$(MAKEFILE):
85 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" 92 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
86 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE) 93 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE)
87sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE 94sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
88 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) 95 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
89 96
90Makefile: kopi-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf 97Makefile: kopi-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf
91 $(QMAKE) -o Makefile kopi-desktop.pro 98 $(QMAKE) -o Makefile kopi-desktop.pro
92qmake: qmake_all 99qmake: 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
101 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 109 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
102 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 110 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
103 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 111 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
104 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 112 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
105 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 113 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
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
112 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true 121 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
113 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true 122 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
114 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true 123 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
115 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true 124 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
116 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true 125 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
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
123 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 133 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
124 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 134 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
125 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 135 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
126 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 136 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
127 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 137 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
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
134 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true 145 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
135 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true 146 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
136 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true 147 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
137 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true 148 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
138 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true 149 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
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
145 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 157 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
146 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 158 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
147 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 159 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
148 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 160 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
149 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 161 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
150 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 162 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
151 163
152install: install_subdirs 164install: install_subdirs
153 165
154uninstall: uninstall_subdirs 166uninstall: uninstall_subdirs
155 167
156FORCE: 168FORCE:
157 169
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
@@ -54,456 +54,459 @@ void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entr
54 *Location= -1; 54 *Location= -1;
55 for (i = 0; i < entry->EntriesNum; i++) { 55 for (i = 0; i < entry->EntriesNum; i++) {
56 switch (entry->Entries[i].EntryType) { 56 switch (entry->Entries[i].EntryType) {
57 case CAL_START_DATETIME : 57 case CAL_START_DATETIME :
58 if (*Time == -1) *Time = i; 58 if (*Time == -1) *Time = i;
59 break; 59 break;
60 case CAL_END_DATETIME : 60 case CAL_END_DATETIME :
61 if (*EndTime == -1) *EndTime = i; 61 if (*EndTime == -1) *EndTime = i;
62 break; 62 break;
63 case CAL_ALARM_DATETIME : 63 case CAL_ALARM_DATETIME :
64 case CAL_SILENT_ALARM_DATETIME: 64 case CAL_SILENT_ALARM_DATETIME:
65 if (*Alarm == -1) *Alarm = i; 65 if (*Alarm == -1) *Alarm = i;
66 break; 66 break;
67 case CAL_RECURRANCE: 67 case CAL_RECURRANCE:
68 if (*Recurrance == -1) *Recurrance = i; 68 if (*Recurrance == -1) *Recurrance = i;
69 break; 69 break;
70 case CAL_TEXT: 70 case CAL_TEXT:
71 if (*Text == -1) *Text = i; 71 if (*Text == -1) *Text = i;
72 break; 72 break;
73 case CAL_PHONE: 73 case CAL_PHONE:
74 if (*Phone == -1) *Phone = i; 74 if (*Phone == -1) *Phone = i;
75 break; 75 break;
76 case CAL_LOCATION: 76 case CAL_LOCATION:
77 if (*Location == -1) *Location = i; 77 if (*Location == -1) *Location = i;
78 break; 78 break;
79 default: 79 default:
80 break; 80 break;
81 } 81 }
82 } 82 }
83} 83}
84 84
85GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) 85GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version)
86{ 86{
87 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; 87 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location;
88 char buffer[2000]; 88 char buffer[2000];
89 89
90 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); 90 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
91 91
92 if (header) { 92 if (header) {
93 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); 93 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
94 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); 94 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
95 } 95 }
96 *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); 96 *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10);
97 97
98 if (Version == Nokia_VCalendar) { 98 if (Version == Nokia_VCalendar) {
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) {
119 buffer[0] = 0; 119 buffer[0] = 0;
120 buffer[1] = 0; 120 buffer[1] = 0;
121 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); 121 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
122 if (Text != -1) { 122 if (Text != -1) {
123 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); 123 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
124 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); 124 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
125 } 125 }
126 SaveVCALText(Buffer, Length, buffer, "SUMMARY"); 126 SaveVCALText(Buffer, Length, buffer, "SUMMARY");
127 } else { 127 } else {
128 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 128 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
129 } 129 }
130 if (note->Type == GSM_CAL_MEETING && Location != -1) { 130 if (note->Type == GSM_CAL_MEETING && Location != -1) {
131 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); 131 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
132 } 132 }
133 133
134 if (Time == -1) return ERR_UNKNOWN; 134 if (Time == -1) return ERR_UNKNOWN;
135 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 135 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
136 136
137 if (EndTime != -1) { 137 if (EndTime != -1) {
138 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 138 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
139 } 139 }
140 140
141 if (Alarm != -1) { 141 if (Alarm != -1) {
142 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 142 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
143 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 143 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
144 } else { 144 } else {
145 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 145 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
146 } 146 }
147 } 147 }
148 148
149 /* Birthday is known to be recurranced */ 149 /* Birthday is known to be recurranced */
150 if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { 150 if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) {
151 switch(note->Entries[Recurrance].Number/24) { 151 switch(note->Entries[Recurrance].Number/24) {
152 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; 152 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break;
153 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; 153 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break;
154 case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; 154 case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break;
155 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; 155 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break;
156 } 156 }
157 } 157 }
158 } else if (Version == Siemens_VCalendar) { 158 } else if (Version == Siemens_VCalendar) {
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
176 if (Time == -1) return ERR_UNKNOWN; 176 if (Time == -1) return ERR_UNKNOWN;
177 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 177 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
178 178
179 if (Alarm != -1) { 179 if (Alarm != -1) {
180 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 180 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
181 } 181 }
182 182
183 if (Recurrance != -1) { 183 if (Recurrance != -1) {
184 switch(note->Entries[Recurrance].Number/24) { 184 switch(note->Entries[Recurrance].Number/24) {
185 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; 185 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break;
186 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; 186 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break;
187 case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; 187 case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break;
188 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; 188 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break;
189 } 189 }
190 } 190 }
191 191
192 if (note->Type == GSM_CAL_CALL) { 192 if (note->Type == GSM_CAL_CALL) {
193 buffer[0] = 0; 193 buffer[0] = 0;
194 buffer[1] = 0; 194 buffer[1] = 0;
195 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); 195 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
196 if (Text != -1) { 196 if (Text != -1) {
197 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); 197 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
198 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); 198 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
199 } 199 }
200 SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); 200 SaveVCALText(Buffer, Length, buffer, "DESCRIPTION");
201 } else { 201 } else {
202 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); 202 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION");
203 } 203 }
204 } else if (Version == SonyEricsson_VCalendar) { 204 } else if (Version == SonyEricsson_VCalendar) {
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
228 if (Time == -1) return ERR_UNKNOWN; 228 if (Time == -1) return ERR_UNKNOWN;
229 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 229 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
230 230
231 if (EndTime != -1) { 231 if (EndTime != -1) {
232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
233 } 233 }
234 234
235 if (Alarm != -1) { 235 if (Alarm != -1) {
236 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 236 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
237 } 237 }
238 238
239 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 239 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
240 240
241 if (Location != -1) { 241 if (Location != -1) {
242 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); 242 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
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
249 return ERR_NONE; 250 return ERR_NONE;
250} 251}
251 252
252void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) 253void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone)
253{ 254{
254 int i; 255 int i;
255 256
256 *Text = -1; 257 *Text = -1;
257 *EndTime= -1; 258 *EndTime= -1;
258 *Alarm = -1; 259 *Alarm = -1;
259 *Completed= -1; 260 *Completed= -1;
260 *Phone = -1; 261 *Phone = -1;
261 for (i = 0; i < entry->EntriesNum; i++) { 262 for (i = 0; i < entry->EntriesNum; i++) {
262 switch (entry->Entries[i].EntryType) { 263 switch (entry->Entries[i].EntryType) {
263 case TODO_END_DATETIME : 264 case TODO_END_DATETIME :
264 if (*EndTime == -1) *EndTime = i; 265 if (*EndTime == -1) *EndTime = i;
265 break; 266 break;
266 case TODO_ALARM_DATETIME : 267 case TODO_ALARM_DATETIME :
267 case TODO_SILENT_ALARM_DATETIME: 268 case TODO_SILENT_ALARM_DATETIME:
268 if (*Alarm == -1) *Alarm = i; 269 if (*Alarm == -1) *Alarm = i;
269 break; 270 break;
270 case TODO_TEXT: 271 case TODO_TEXT:
271 if (*Text == -1) *Text = i; 272 if (*Text == -1) *Text = i;
272 break; 273 break;
273 case TODO_COMPLETED: 274 case TODO_COMPLETED:
274 if (*Completed == -1) *Completed = i; 275 if (*Completed == -1) *Completed = i;
275 break; 276 break;
276 case TODO_PHONE: 277 case TODO_PHONE:
277 if (*Phone == -1) *Phone = i; 278 if (*Phone == -1) *Phone = i;
278 break; 279 break;
279 default: 280 default:
280 break; 281 break;
281 } 282 }
282 } 283 }
283} 284}
284 285
285GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) 286GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version)
286{ 287{
287 int Text, Alarm, Completed, EndTime, Phone; 288 int Text, Alarm, Completed, EndTime, Phone;
288 289
289 GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); 290 GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone);
290 291
291 if (header) { 292 if (header) {
292 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); 293 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
293 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); 294 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
294 } 295 }
295 296
296 *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); 297 *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10);
297 298
298 if (Version == Nokia_VToDo) { 299 if (Version == Nokia_VToDo) {
299 if (Text == -1) return ERR_UNKNOWN; 300 if (Text == -1) return ERR_UNKNOWN;
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) {
315 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DUE"); 316 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DUE");
316 } 317 }
317 318
318 if (Alarm != -1) { 319 if (Alarm != -1) {
319 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 320 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
320 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 321 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
321 } else { 322 } else {
322 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 323 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
323 } 324 }
324 } 325 }
325 } else if (Version == SonyEricsson_VToDo) { 326 } else if (Version == SonyEricsson_VToDo) {
326 if (Text == -1) return ERR_UNKNOWN; 327 if (Text == -1) return ERR_UNKNOWN;
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
341 if (Alarm != -1) { 342 if (Alarm != -1) {
342 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 343 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
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) {
349 *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); 351 *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
350 } 352 }
351 return ERR_NONE; 353 return ERR_NONE;
352} 354}
353 355
354GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) 356GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer)
355{ 357{
356 unsigned char Line[2000],Buff[2000]; 358 unsigned char Line[2000],Buff[2000];
357 int Level = 0; 359 int Level = 0;
358 360
359 Calendar->EntriesNum = 0; 361 Calendar->EntriesNum = 0;
360 ToDo->EntriesNum = 0; 362 ToDo->EntriesNum = 0;
361 363
362 while (1) { 364 while (1) {
363 MyGetLine(Buffer, Pos, Line, strlen(Buffer)); 365 MyGetLine(Buffer, Pos, Line, strlen(Buffer));
364 if (strlen(Line) == 0) break; 366 if (strlen(Line) == 0) break;
365 switch (Level) { 367 switch (Level) {
366 case 0: 368 case 0:
367 if (strstr(Line,"BEGIN:VEVENT")) { 369 if (strstr(Line,"BEGIN:VEVENT")) {
368 Calendar->Type = GSM_CAL_MEMO; 370 Calendar->Type = GSM_CAL_MEMO;
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;
376 case 1: /* Calendar note */ 378 case 1: /* Calendar note */
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;
394 Calendar->EntriesNum++; 397 Calendar->EntriesNum++;
395 } 398 }
396 if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { 399 if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) {
397 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 400 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
398 Calendar->Entries[Calendar->EntriesNum].Number = 7*24; 401 Calendar->Entries[Calendar->EntriesNum].Number = 7*24;
399 Calendar->EntriesNum++; 402 Calendar->EntriesNum++;
400 } 403 }
401 if (strstr(Line,"RRULE:W2")) { 404 if (strstr(Line,"RRULE:W2")) {
402 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 405 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
403 Calendar->Entries[Calendar->EntriesNum].Number = 14*24; 406 Calendar->Entries[Calendar->EntriesNum].Number = 14*24;
404 Calendar->EntriesNum++; 407 Calendar->EntriesNum++;
405 } 408 }
406 if (strstr(Line,"RRULE:MD1")) { 409 if (strstr(Line,"RRULE:MD1")) {
407 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 410 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
408 Calendar->Entries[Calendar->EntriesNum].Number = 30*24; 411 Calendar->Entries[Calendar->EntriesNum].Number = 30*24;
409 Calendar->EntriesNum++; 412 Calendar->EntriesNum++;
410 } 413 }
411 if (strstr(Line,"RRULE:YD1")) { 414 if (strstr(Line,"RRULE:YD1")) {
412 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 415 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
413 Calendar->Entries[Calendar->EntriesNum].Number = 365*24; 416 Calendar->Entries[Calendar->EntriesNum].Number = 365*24;
414 Calendar->EntriesNum++; 417 Calendar->EntriesNum++;
415 } 418 }
416 if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { 419 if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) {
417 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; 420 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT;
418 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); 421 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
419 Calendar->EntriesNum++; 422 Calendar->EntriesNum++;
420 } 423 }
421 if (ReadVCALText(Line, "LOCATION", Buff)) { 424 if (ReadVCALText(Line, "LOCATION", Buff)) {
422 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; 425 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION;
423 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); 426 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
424 Calendar->EntriesNum++; 427 Calendar->EntriesNum++;
425 } 428 }
426 if (ReadVCALText(Line, "DTSTART", Buff)) { 429 if (ReadVCALText(Line, "DTSTART", Buff)) {
427 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; 430 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME;
428 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 431 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
429 Calendar->EntriesNum++; 432 Calendar->EntriesNum++;
430 } 433 }
431 if (ReadVCALText(Line, "DTEND", Buff)) { 434 if (ReadVCALText(Line, "DTEND", Buff)) {
432 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; 435 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME;
433 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 436 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
434 Calendar->EntriesNum++; 437 Calendar->EntriesNum++;
435 } 438 }
436 if (ReadVCALText(Line, "DALARM", Buff)) { 439 if (ReadVCALText(Line, "DALARM", Buff)) {
437 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; 440 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME;
438 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 441 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
439 Calendar->EntriesNum++; 442 Calendar->EntriesNum++;
440 } 443 }
441 if (ReadVCALText(Line, "AALARM", Buff)) { 444 if (ReadVCALText(Line, "AALARM", Buff)) {
442 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; 445 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME;
443 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 446 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
444 Calendar->EntriesNum++; 447 Calendar->EntriesNum++;
445 } 448 }
446 break; 449 break;
447 case 2: /* ToDo note */ 450 case 2: /* ToDo note */
448 if (strstr(Line,"END:VTODO")) { 451 if (strstr(Line,"END:VTODO")) {
449 if (ToDo->EntriesNum == 0) return ERR_EMPTY; 452 if (ToDo->EntriesNum == 0) return ERR_EMPTY;
450 return ERR_NONE; 453 return ERR_NONE;
451 } 454 }
452 if (ReadVCALText(Line, "DUE", Buff)) { 455 if (ReadVCALText(Line, "DUE", Buff)) {
453 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; 456 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME;
454 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 457 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
455 ToDo->EntriesNum++; 458 ToDo->EntriesNum++;
456 } 459 }
457 if (ReadVCALText(Line, "DALARM", Buff)) { 460 if (ReadVCALText(Line, "DALARM", Buff)) {
458 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; 461 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
459 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 462 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
460 ToDo->EntriesNum++; 463 ToDo->EntriesNum++;
461 } 464 }
462 if (ReadVCALText(Line, "AALARM", Buff)) { 465 if (ReadVCALText(Line, "AALARM", Buff)) {
463 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; 466 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME;
464 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 467 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
465 ToDo->EntriesNum++; 468 ToDo->EntriesNum++;
466 } 469 }
467 if (ReadVCALText(Line, "SUMMARY", Buff)) { 470 if (ReadVCALText(Line, "SUMMARY", Buff)) {
468 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; 471 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT;
469 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); 472 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff);
470 ToDo->EntriesNum++; 473 ToDo->EntriesNum++;
471 } 474 }
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++;
488 } 491 }
489 break; 492 break;
490 } 493 }
491 } 494 }
492 495
493 if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; 496 if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY;
494 return ERR_NONE; 497 return ERR_NONE;
495} 498}
496 499
497GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) 500GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note)
498{ 501{
499 *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); 502 *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10);
500 *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); 503 *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10);
501 SaveVCALText(Buffer, Length, Note->Text, "BODY"); 504 SaveVCALText(Buffer, Length, Note->Text, "BODY");
502 *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); 505 *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10);
503 506
504 return ERR_NONE; 507 return ERR_NONE;
505} 508}
506 509
507/* How should editor hadle tabs in this file? Add editor commands here. 510/* How should editor hadle tabs in this file? Add editor commands here.
508 * vim: noexpandtab sw=8 ts=8 sts=8: 511 * vim: noexpandtab sw=8 ts=8 sts=8:
509 */ 512 */
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
@@ -1830,97 +1830,97 @@ void CalendarView::writeLocale()
1830 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1830 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1831 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1831 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1832 KOPrefs::instance()->mDaylightsavingStart, 1832 KOPrefs::instance()->mDaylightsavingStart,
1833 KOPrefs::instance()->mDaylightsavingEnd ); 1833 KOPrefs::instance()->mDaylightsavingEnd );
1834 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1834 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1835} 1835}
1836void CalendarView::updateConfig() 1836void CalendarView::updateConfig()
1837{ 1837{
1838 writeLocale(); 1838 writeLocale();
1839 if ( KOPrefs::instance()->mUseAppColors ) 1839 if ( KOPrefs::instance()->mUseAppColors )
1840 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1840 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1841 emit configChanged(); 1841 emit configChanged();
1842 mTodoList->updateConfig(); 1842 mTodoList->updateConfig();
1843 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1843 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1844 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1844 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1845 // To make the "fill window" configurations work 1845 // To make the "fill window" configurations work
1846 //mViewManager->raiseCurrentView(); 1846 //mViewManager->raiseCurrentView();
1847} 1847}
1848 1848
1849 1849
1850void CalendarView::eventChanged(Event *event) 1850void CalendarView::eventChanged(Event *event)
1851{ 1851{
1852 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1852 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1853 //updateUnmanagedViews(); 1853 //updateUnmanagedViews();
1854} 1854}
1855 1855
1856void CalendarView::eventAdded(Event *event) 1856void CalendarView::eventAdded(Event *event)
1857{ 1857{
1858 changeEventDisplay(event,KOGlobals::EVENTADDED); 1858 changeEventDisplay(event,KOGlobals::EVENTADDED);
1859} 1859}
1860 1860
1861void CalendarView::eventToBeDeleted(Event *) 1861void CalendarView::eventToBeDeleted(Event *)
1862{ 1862{
1863 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1863 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1864} 1864}
1865 1865
1866void CalendarView::eventDeleted() 1866void CalendarView::eventDeleted()
1867{ 1867{
1868 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1868 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1869} 1869}
1870void CalendarView::changeTodoDisplay(Todo *which, int action) 1870void CalendarView::changeTodoDisplay(Todo *which, int action)
1871{ 1871{
1872 changeIncidenceDisplay((Incidence *)which, action); 1872 changeIncidenceDisplay((Incidence *)which, action);
1873 mDateNavigator->updateView(); 1873 mDateNavigator->updateView();
1874 //mDialogManager->updateSearchDialog(); 1874 //mDialogManager->updateSearchDialog();
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}
1882 1882
1883void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1883void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1884{ 1884{
1885 updateUnmanagedViews(); 1885 updateUnmanagedViews();
1886 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1886 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1887 if ( action == KOGlobals::EVENTDELETED ) { //delete 1887 if ( action == KOGlobals::EVENTDELETED ) { //delete
1888 mCalendar->checkAlarmForIncidence( 0, true ); 1888 mCalendar->checkAlarmForIncidence( 0, true );
1889 if ( mEventViewerDialog ) 1889 if ( mEventViewerDialog )
1890 mEventViewerDialog->hide(); 1890 mEventViewerDialog->hide();
1891 } 1891 }
1892 else 1892 else
1893 mCalendar->checkAlarmForIncidence( which , false ); 1893 mCalendar->checkAlarmForIncidence( which , false );
1894} 1894}
1895 1895
1896// most of the changeEventDisplays() right now just call the view's 1896// most of the changeEventDisplays() right now just call the view's
1897// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1897// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1898void CalendarView::changeEventDisplay(Event *which, int action) 1898void CalendarView::changeEventDisplay(Event *which, int action)
1899{ 1899{
1900 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1900 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1901 changeIncidenceDisplay((Incidence *)which, action); 1901 changeIncidenceDisplay((Incidence *)which, action);
1902 mDateNavigator->updateView(); 1902 mDateNavigator->updateView();
1903 //mDialogManager->updateSearchDialog(); 1903 //mDialogManager->updateSearchDialog();
1904 1904
1905 if (which) { 1905 if (which) {
1906 // If there is an event view visible update the display 1906 // If there is an event view visible update the display
1907 mViewManager->currentView()->changeEventDisplay(which,action); 1907 mViewManager->currentView()->changeEventDisplay(which,action);
1908 // TODO: check, if update needed 1908 // TODO: check, if update needed
1909 // if (which->getTodoStatus()) { 1909 // if (which->getTodoStatus()) {
1910 mTodoList->updateView(); 1910 mTodoList->updateView();
1911 // } 1911 // }
1912 } else { 1912 } else {
1913 mViewManager->currentView()->updateView(); 1913 mViewManager->currentView()->updateView();
1914 } 1914 }
1915} 1915}
1916 1916
1917 1917
1918void CalendarView::updateTodoViews() 1918void CalendarView::updateTodoViews()
1919{ 1919{
1920 1920
1921 mTodoList->updateView(); 1921 mTodoList->updateView();
1922 mViewManager->currentView()->updateView(); 1922 mViewManager->currentView()->updateView();
1923 1923
1924} 1924}
1925 1925
1926 1926
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 9fdcd2f..543db86 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,70 +1,69 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = _obj/ 4OBJECTS_DIR = _obj/
5MOC_DIR = _moc 5MOC_DIR = _moc
6DESTDIR= ../bin 6DESTDIR= ../bin
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim 10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
11#../qtcompat 11#../qtcompat
12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC 14#KORG_NOPRINTER KORG_NOKABC
15DEFINES += KORG_NOLVALTERNATION 15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION 16DEFINES += DESKTOP_VERSION
17unix : { 17unix : {
18LIBS += ../bin/libmicrokdepim.so 18LIBS += ../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
26LIBS += -lldap 25LIBS += -lldap
27OBJECTS_DIR = obj/unix 26OBJECTS_DIR = obj/unix
28MOC_DIR = moc/unix 27MOC_DIR = moc/unix
29} 28}
30win32: { 29win32: {
31DEFINES += _WIN32_ 30DEFINES += _WIN32_
32LIBS += ../bin/microkdepim.lib 31LIBS += ../bin/microkdepim.lib
33LIBS += ../bin/microkcal.lib 32LIBS += ../bin/microkcal.lib
34LIBS += ../bin/microkde.lib 33LIBS += ../bin/microkde.lib
35LIBS += ../bin/microkabc.lib 34LIBS += ../bin/microkabc.lib
36LIBS += ../libical/lib/ical.lib 35LIBS += ../libical/lib/ical.lib
37LIBS += ../libical/lib/icalss.lib 36LIBS += ../libical/lib/icalss.lib
38#LIBS += atls.lib 37#LIBS += atls.lib
39LIBS += mfc71u.lib 38LIBS += mfc71u.lib
40QMAKE_LINK += /NODEFAULTLIB:LIBC 39QMAKE_LINK += /NODEFAULTLIB:LIBC
41#QMAKE_LINK += /NODEFAULTLIB:MSVCRT 40#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
42#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib 41#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
43OBJECTS_DIR = obj/win 42OBJECTS_DIR = obj/win
44MOC_DIR = moc/win 43MOC_DIR = moc/win
45} 44}
46 45
47 46
48INTERFACES = kofilterview_base.ui 47INTERFACES = kofilterview_base.ui
49# filteredit_base.ui 48# filteredit_base.ui
50 49
51# kdateedit.h \ 50# kdateedit.h \
52 51
53HEADERS = \ 52HEADERS = \
54 filteredit_base.h \ 53 filteredit_base.h \
55 alarmclient.h \ 54 alarmclient.h \
56 calendarview.h \ 55 calendarview.h \
57 customlistviewitem.h \ 56 customlistviewitem.h \
58 datenavigator.h \ 57 datenavigator.h \
59 docprefs.h \ 58 docprefs.h \
60 filtereditdialog.h \ 59 filtereditdialog.h \
61 incomingdialog.h \ 60 incomingdialog.h \
62 incomingdialog_base.h \ 61 incomingdialog_base.h \
63 interfaces/korganizer/baseview.h \ 62 interfaces/korganizer/baseview.h \
64 interfaces/korganizer/calendarviewbase.h \ 63 interfaces/korganizer/calendarviewbase.h \
65 journalentry.h \ 64 journalentry.h \
66 kdatenavigator.h \ 65 kdatenavigator.h \
67 koagenda.h \ 66 koagenda.h \
68 koagendaitem.h \ 67 koagendaitem.h \
69 koagendaview.h \ 68 koagendaview.h \
70 kocounterdialog.h \ 69 kocounterdialog.h \
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index d9bda64..56c9801 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -489,96 +489,101 @@ QStringList Incidence::secrecyList()
489} 489}
490 490
491 491
492QPtrList<Alarm> Incidence::alarms() const 492QPtrList<Alarm> Incidence::alarms() const
493{ 493{
494 return mAlarms; 494 return mAlarms;
495} 495}
496 496
497Alarm* Incidence::newAlarm() 497Alarm* Incidence::newAlarm()
498{ 498{
499 Alarm* alarm = new Alarm(this); 499 Alarm* alarm = new Alarm(this);
500 mAlarms.append(alarm); 500 mAlarms.append(alarm);
501// updated(); 501// updated();
502 return alarm; 502 return alarm;
503} 503}
504 504
505void Incidence::addAlarm(Alarm *alarm) 505void Incidence::addAlarm(Alarm *alarm)
506{ 506{
507 mAlarms.append(alarm); 507 mAlarms.append(alarm);
508 updated(); 508 updated();
509} 509}
510 510
511void Incidence::removeAlarm(Alarm *alarm) 511void Incidence::removeAlarm(Alarm *alarm)
512{ 512{
513 mAlarms.removeRef(alarm); 513 mAlarms.removeRef(alarm);
514 updated(); 514 updated();
515} 515}
516 516
517void Incidence::clearAlarms() 517void Incidence::clearAlarms()
518{ 518{
519 mAlarms.clear(); 519 mAlarms.clear();
520 updated(); 520 updated();
521} 521}
522 522
523bool Incidence::isAlarmEnabled() const 523bool Incidence::isAlarmEnabled() const
524{ 524{
525 Alarm* alarm; 525 Alarm* alarm;
526 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 526 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
527 if (alarm->enabled()) 527 if (alarm->enabled())
528 return true; 528 return true;
529 } 529 }
530 return false; 530 return false;
531} 531}
532 532
533Recurrence *Incidence::recurrence() const 533Recurrence *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{
540 if (mReadOnly) return; 545 if (mReadOnly) return;
541 mLocation = location; 546 mLocation = location;
542 updated(); 547 updated();
543} 548}
544 549
545QString Incidence::location() const 550QString Incidence::location() const
546{ 551{
547 return mLocation; 552 return mLocation;
548} 553}
549 554
550ushort Incidence::doesRecur() const 555ushort Incidence::doesRecur() const
551{ 556{
552 if ( mRecurrence ) return mRecurrence->doesRecur(); 557 if ( mRecurrence ) return mRecurrence->doesRecur();
553 else return Recurrence::rNone; 558 else return Recurrence::rNone;
554} 559}
555 560
556QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 561QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
557{ 562{
558 QDateTime incidenceStart = dt; 563 QDateTime incidenceStart = dt;
559 *ok = false; 564 *ok = false;
560 if ( doesRecur() ) { 565 if ( doesRecur() ) {
561 bool last; 566 bool last;
562 recurrence()->getPreviousDateTime( incidenceStart , &last ); 567 recurrence()->getPreviousDateTime( incidenceStart , &last );
563 int count = 0; 568 int count = 0;
564 if ( !last ) { 569 if ( !last ) {
565 while ( !last ) { 570 while ( !last ) {
566 ++count; 571 ++count;
567 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 572 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
568 if ( recursOn( incidenceStart.date() ) ) { 573 if ( recursOn( incidenceStart.date() ) ) {
569 last = true; // exit while llop 574 last = true; // exit while llop
570 } else { 575 } else {
571 if ( last ) { // no alarm on last recurrence 576 if ( last ) { // no alarm on last recurrence
572 return QDateTime (); 577 return QDateTime ();
573 } 578 }
574 int year = incidenceStart.date().year(); 579 int year = incidenceStart.date().year();
575 // workaround for bug in recurrence 580 // workaround for bug in recurrence
576 if ( count == 100 || year < 1980 || year > 5000 ) { 581 if ( count == 100 || year < 1980 || year > 5000 ) {
577 return QDateTime (); 582 return QDateTime ();
578 } 583 }
579 incidenceStart = incidenceStart.addSecs( 1 ); 584 incidenceStart = incidenceStart.addSecs( 1 );
580 } 585 }
581 } 586 }
582 } else { 587 } else {
583 return QDateTime (); 588 return QDateTime ();
584 } 589 }
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index d1972cb..7dc6f10 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -200,97 +200,97 @@ class Incidence : public IncidenceBase
200 QPtrList<Attachment> attachments(const QString& mime) const; 200 QPtrList<Attachment> attachments(const QString& mime) const;
201 201
202 /** sets the event's status the value specified. See the enumeration 202 /** sets the event's status the value specified. See the enumeration
203 * above for possible values. */ 203 * above for possible values. */
204 void setSecrecy(int); 204 void setSecrecy(int);
205 /** return the event's secrecy. */ 205 /** return the event's secrecy. */
206 int secrecy() const; 206 int secrecy() const;
207 /** return the event's secrecy in string format. */ 207 /** return the event's secrecy in string format. */
208 QString secrecyStr() const; 208 QString secrecyStr() const;
209 /** return list of all availbale secrecy classes */ 209 /** return list of all availbale secrecy classes */
210 static QStringList secrecyList(); 210 static QStringList secrecyList();
211 /** return human-readable name of secrecy class */ 211 /** return human-readable name of secrecy class */
212 static QString secrecyName(int); 212 static QString secrecyName(int);
213 213
214 /** returns TRUE if the date specified is one on which the event will 214 /** returns TRUE if the date specified is one on which the event will
215 * recur. */ 215 * recur. */
216 bool recursOn(const QDate &qd) const; 216 bool recursOn(const QDate &qd) const;
217 217
218 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 218 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
219 219
220 /** set resources used, such as Office, Car, etc. */ 220 /** set resources used, such as Office, Car, etc. */
221 void setResources(const QStringList &resources); 221 void setResources(const QStringList &resources);
222 /** return list of current resources */ 222 /** return list of current resources */
223 QStringList resources() const; 223 QStringList resources() const;
224 224
225 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 225 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
226 void setPriority(int priority); 226 void setPriority(int priority);
227 /** get the event's priority */ 227 /** get the event's priority */
228 int priority() const; 228 int priority() const;
229 229
230 /** All alarms that are associated with this incidence */ 230 /** All alarms that are associated with this incidence */
231 QPtrList<Alarm> alarms() const; 231 QPtrList<Alarm> alarms() const;
232 /** Create a new alarm which is associated with this incidence */ 232 /** Create a new alarm which is associated with this incidence */
233 Alarm* newAlarm(); 233 Alarm* newAlarm();
234 /** Add an alarm which is associated with this incidence */ 234 /** Add an alarm which is associated with this incidence */
235 void addAlarm(Alarm*); 235 void addAlarm(Alarm*);
236 /** Remove an alarm that is associated with this incidence */ 236 /** Remove an alarm that is associated with this incidence */
237 void removeAlarm(Alarm*); 237 void removeAlarm(Alarm*);
238 /** Remove all alarms that are associated with this incidence */ 238 /** Remove all alarms that are associated with this incidence */
239 void clearAlarms(); 239 void clearAlarms();
240 /** return whether any alarm associated with this incidence is enabled */ 240 /** return whether any alarm associated with this incidence is enabled */
241 bool isAlarmEnabled() const; 241 bool isAlarmEnabled() const;
242 242
243 /** 243 /**
244 Return the recurrence rule associated with this incidence. If there is 244 Return the recurrence rule associated with this incidence. If there is
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 */
252 ushort doesRecur() const; 252 ushort doesRecur() const;
253 253
254 /** set the event's/todo's location. Do _not_ use it with journal */ 254 /** set the event's/todo's location. Do _not_ use it with journal */
255 void setLocation(const QString &location); 255 void setLocation(const QString &location);
256 /** return the event's/todo's location. Do _not_ use it with journal */ 256 /** return the event's/todo's location. Do _not_ use it with journal */
257 QString location() const; 257 QString location() const;
258 /** returns TRUE or FALSE depending on whether the todo has a start date */ 258 /** returns TRUE or FALSE depending on whether the todo has a start date */
259 bool hasStartDate() const; 259 bool hasStartDate() const;
260 /** sets the event's hasStartDate value. */ 260 /** sets the event's hasStartDate value. */
261 void setHasStartDate(bool f); 261 void setHasStartDate(bool f);
262 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 262 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
263 bool cancelled() const; 263 bool cancelled() const;
264 void setCancelled( bool b ); 264 void setCancelled( bool b );
265 265
266protected: 266protected:
267 QPtrList<Alarm> mAlarms; 267 QPtrList<Alarm> mAlarms;
268 private: 268 private:
269 int mRevision; 269 int mRevision;
270 bool mCancelled; 270 bool mCancelled;
271 271
272 // base components of jounal, event and todo 272 // base components of jounal, event and todo
273 QDateTime mCreated; 273 QDateTime mCreated;
274 QString mDescription; 274 QString mDescription;
275 QString mSummary; 275 QString mSummary;
276 QStringList mCategories; 276 QStringList mCategories;
277 Incidence *mRelatedTo; 277 Incidence *mRelatedTo;
278 QString mRelatedToUid; 278 QString mRelatedToUid;
279 QPtrList<Incidence> mRelations; 279 QPtrList<Incidence> mRelations;
280 DateList mExDates; 280 DateList mExDates;
281 QPtrList<Attachment> mAttachments; 281 QPtrList<Attachment> mAttachments;
282 QStringList mResources; 282 QStringList mResources;
283 bool mHasStartDate; // if todo has associated start date 283 bool mHasStartDate; // if todo has associated start date
284 284
285 int mSecrecy; 285 int mSecrecy;
286 int mPriority; // 1 = highest, 2 = less, etc. 286 int mPriority; // 1 = highest, 2 = less, etc.
287 287
288 //QPtrList<Alarm> mAlarms; 288 //QPtrList<Alarm> mAlarms;
289 Recurrence *mRecurrence; 289 Recurrence *mRecurrence;
290 290
291 QString mLocation; 291 QString mLocation;
292}; 292};
293 293
294bool operator==( const Incidence&, const Incidence& ); 294bool operator==( const Incidence&, const Incidence& );
295 295
296} 296}
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 1769b37..0bc9125 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,662 +1,168 @@
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
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
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 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "phoneformat.h" 44#include "phoneformat.h"
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;
512 QString timestr; 58 QString timestr;
513 int offset = KGlobal::locale()->localTimeOffset( dti ); 59 int offset = KGlobal::locale()->localTimeOffset( dti );
514 QDateTime dt; 60 QDateTime dt;
515 if (useTZ) 61 if (useTZ)
516 dt = dti.addSecs ( -(offset*60)); 62 dt = dti.addSecs ( -(offset*60));
517 else 63 else
518 dt = dti; 64 dt = dti;
519 if(dt.date().isValid()){ 65 if(dt.date().isValid()){
520 const QDate& date = dt.date(); 66 const QDate& date = dt.date();
521 datestr.sprintf("%04d%02d%02d", 67 datestr.sprintf("%04d%02d%02d",
522 date.year(), date.month(), date.day()); 68 date.year(), date.month(), date.day());
523 } 69 }
524 if(dt.time().isValid()){ 70 if(dt.time().isValid()){
525 const QTime& time = dt.time(); 71 const QTime& time = dt.time();
526 timestr.sprintf("T%02d%02d%02d", 72 timestr.sprintf("T%02d%02d%02d",
527 time.hour(), time.minute(), time.second()); 73 time.hour(), time.minute(), time.second());
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{
581 mProfileName = profileName; 85 mProfileName = profileName;
582 mDevice = device; 86 mDevice = device;
583 mConnection = connection; 87 mConnection = connection;
584 mModel = model; 88 mModel = model;
585} 89}
586 90
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);
593 s->ConfigNum = 1; 98 s->ConfigNum = 1;
594 GSM_Config *cfg = &s->Config[0]; 99 GSM_Config *cfg = &s->Config[0];
595 if ( ! mConnection.isEmpty() ) { 100 if ( ! mConnection.isEmpty() ) {
596 cfg->Connection = strdup(mConnection.latin1()); 101 cfg->Connection = strdup(mConnection.latin1());
597 cfg->DefaultConnection = false; 102 cfg->DefaultConnection = false;
598 qDebug("Connection set %s ", cfg->Connection ); 103 qDebug("Connection set %s ", cfg->Connection );
599 104
600 } 105 }
601 if ( ! mDevice.isEmpty() ) { 106 if ( ! mDevice.isEmpty() ) {
602 cfg->Device = strdup(mDevice.latin1()); 107 cfg->Device = strdup(mDevice.latin1());
603 cfg->DefaultDevice = false; 108 cfg->DefaultDevice = false;
604 qDebug("Device set %s ", cfg->Device); 109 qDebug("Device set %s ", cfg->Device);
605 110
606 } 111 }
607 if ( ! mModel.isEmpty() ) { 112 if ( ! mModel.isEmpty() ) {
608 strcpy(cfg->Model,mModel.latin1() ); 113 strcpy(cfg->Model,mModel.latin1() );
609 cfg->DefaultModel = false; 114 cfg->DefaultModel = false;
610 qDebug("Model set %s ",cfg->Model ); 115 qDebug("Model set %s ",cfg->Model );
611 } 116 }
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;
618 if ( todo->hasDueDate() ) 124 if ( todo->hasDueDate() )
619 attList << PhoneParser::dtToString ( todo->dtDue() ); 125 attList << PhoneParser::dtToString ( todo->dtDue() );
620 attList << todo->summary(); 126 attList << todo->summary();
621 QString completedString = "no"; 127 QString completedString = "no";
622 if ( todo->isCompleted() ) 128 if ( todo->isCompleted() )
623 completedString = "yes"; 129 completedString = "yes";
624 attList << completedString; 130 attList << completedString;
625 attList << QString::number( todo->priority() ); 131 attList << QString::number( todo->priority() );
626 QString alarmString = "na"; 132 QString alarmString = "na";
627 Alarm *alarm; 133 Alarm *alarm;
628 if ( todo->alarms().count() > 0 ) { 134 if ( todo->alarms().count() > 0 ) {
629 alarm = todo->alarms().first(); 135 alarm = todo->alarms().first();
630 if ( alarm->enabled() ) { 136 if ( alarm->enabled() ) {
631 alarmString = QString::number(alarm->startOffset().asSeconds() ); 137 alarmString = QString::number(alarm->startOffset().asSeconds() );
632 } 138 }
633 } 139 }
634 attList << alarmString; 140 attList << alarmString;
635 attList << todo->categoriesStr(); 141 attList << todo->categoriesStr();
636 attList << todo->secrecyStr(); 142 attList << todo->secrecyStr();
637 return PhoneFormat::getCsum(attList ); 143 return PhoneFormat::getCsum(attList );
638 144
639} 145}
640ulong PhoneFormat::getCsumEvent( Event* event ) 146ulong PhoneFormat::getCsumEvent( Event* event )
641{ 147{
642 QStringList attList; 148 QStringList attList;
643 attList << PhoneParser::dtToString ( event->dtStart() ); 149 attList << PhoneParser::dtToString ( event->dtStart() );
644 attList << PhoneParser::dtToString ( event->dtEnd() ); 150 attList << PhoneParser::dtToString ( event->dtEnd() );
645 attList << event->summary(); 151 attList << event->summary();
646 attList << event->location(); 152 attList << event->location();
647 QString alarmString = "na"; 153 QString alarmString = "na";
648 Alarm *alarm; 154 Alarm *alarm;
649 if ( event->alarms().count() > 0 ) { 155 if ( event->alarms().count() > 0 ) {
650 alarm = event->alarms().first(); 156 alarm = event->alarms().first();
651 if ( alarm->enabled() ) { 157 if ( alarm->enabled() ) {
652 alarmString = QString::number( alarm->startOffset().asSeconds() ); 158 alarmString = QString::number( alarm->startOffset().asSeconds() );
653 } 159 }
654 } 160 }
655 attList << alarmString; 161 attList << alarmString;
656 Recurrence* rec = event->recurrence(); 162 Recurrence* rec = event->recurrence();
657 QStringList list; 163 QStringList list;
658 bool writeEndDate = false; 164 bool writeEndDate = false;
659 switch ( rec->doesRecur() ) 165 switch ( rec->doesRecur() )
660 { 166 {
661 case Recurrence::rDaily: // 0 167 case Recurrence::rDaily: // 0
662 list.append( "0" ); 168 list.append( "0" );
@@ -726,966 +232,350 @@ ulong PhoneFormat::getCsumEvent( Event* event )
726 list.append( "0" ); 232 list.append( "0" );
727 list.append( "20991231T000000" ); 233 list.append( "20991231T000000" );
728 break; 234 break;
729 } 235 }
730 if ( writeEndDate ) { 236 if ( writeEndDate ) {
731 237
732 if ( rec->endDate().isValid() ) { // 15 + 16 238 if ( rec->endDate().isValid() ) { // 15 + 16
733 list.append( "1" ); 239 list.append( "1" );
734 list.append( PhoneParser::dtToString( rec->endDate()) ); 240 list.append( PhoneParser::dtToString( rec->endDate()) );
735 } else { 241 } else {
736 list.append( "0" ); 242 list.append( "0" );
737 list.append( "20991231T000000" ); 243 list.append( "20991231T000000" );
738 } 244 }
739 245
740 } 246 }
741 attList << list.join(""); 247 attList << list.join("");
742 attList << event->categoriesStr(); 248 attList << event->categoriesStr();
743 attList << event->secrecyStr(); 249 attList << event->secrecyStr();
744 return PhoneFormat::getCsum(attList ); 250 return PhoneFormat::getCsum(attList );
745} 251}
746ulong PhoneFormat::getCsum( const QStringList & attList) 252ulong PhoneFormat::getCsum( const QStringList & attList)
747{ 253{
748 int max = attList.count() -1; 254 int max = attList.count() -1;
749 ulong cSum = 0; 255 ulong cSum = 0;
750 int j,k,i; 256 int j,k,i;
751 int add; 257 int add;
752 for ( i = 1; i < max ; ++i ) { 258 for ( i = 1; i < max ; ++i ) {
753 QString s = attList[i]; 259 QString s = attList[i];
754 if ( ! s.isEmpty() ){ 260 if ( ! s.isEmpty() ){
755 j = s.length(); 261 j = s.length();
756 for ( k = 0; k < j; ++k ) { 262 for ( k = 0; k < j; ++k ) {
757 int mul = k +1; 263 int mul = k +1;
758 add = s[k].unicode (); 264 add = s[k].unicode ();
759 if ( k < 16 ) 265 if ( k < 16 )
760 mul = mul * mul; 266 mul = mul * mul;
761 add = add * mul *i*i*i; 267 add = add * mul *i*i*i;
762 cSum += add; 268 cSum += add;
763 } 269 }
764 } 270 }
765 } 271 }
766 return cSum; 272 return cSum;
767 273
768} 274}
769//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 275//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
770#include <stdlib.h> 276#include <stdlib.h>
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;
879 inc->removeID( mProfileName ); 436 inc->removeID( mProfileName );
880 if ( inc->type() == "Event") 437 if ( inc->type() == "Event")
881 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 438 csum = PhoneFormat::getCsumEvent( (Event*) inc );
882 else 439 else
883 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 440 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
884 inc->setCsum( mProfileName, QString::number( csum )); 441 inc->setCsum( mProfileName, QString::number( csum ));
885 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 442 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
886 443
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;
899 int h = status.sizeHint().height()+20 ; 450 int h = status.sizeHint().height()+20 ;
900 int dw = QApplication::desktop()->width(); 451 int dw = QApplication::desktop()->width();
901 int dh = QApplication::desktop()->height(); 452 int dh = QApplication::desktop()->height();
902 status.setCaption(i18n("Writing to phone...") ); 453 status.setCaption(i18n("Writing to phone...") );
903 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 454 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
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) ){
1136 qDebug("error reloading calendar "); 502 qDebug("error reloading 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();
1153 QString cSum = ev->getCsum(mProfileName); 519 QString cSum = ev->getCsum(mProfileName);
1154 ev1 = er1.first(); 520 ev1 = er1.first();
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 }
1161 ev1 = er1.next(); 528 ev1 = er1.next();
1162 } 529 }
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
1173 to = tl.first(); 539 to = tl.first();
1174 procCount = 0; 540 procCount = 0;
1175 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 541 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
1176 Todo* to1 ; 542 Todo* to1 ;
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);
1184 Todo* to1 = tl1.first(); 549 Todo* to1 = tl1.first();
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 }
1191 to1 = tl1.next(); 557 to1 = tl1.next();
1192 } 558 }
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
1684QString PhoneFormat::toString( Calendar * ) 574QString PhoneFormat::toString( Calendar * )
1685{ 575{
1686 return QString::null; 576 return QString::null;
1687} 577}
1688bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 578bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
1689{ 579{
1690 return false; 580 return false;
1691} 581}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2c2e51c..8286098 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,67 +1,61 @@
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) 2003 Cornelius Schumacher <schumacher@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
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
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/**
36 This class implements the calendar format used by Phone. 34 This class implements the calendar format used by Phone.
37*/ 35*/
38 class Event; 36 class Event;
39 class Todo; 37 class Todo;
40class PhoneFormat : public QObject { 38class PhoneFormat : public QObject {
41 public: 39 public:
42 /** Create new iCalendar format. */ 40 /** Create new iCalendar format. */
43 PhoneFormat(QString profileName, QString device,QString connection, QString model); 41 PhoneFormat(QString profileName, QString device,QString connection, QString model);
44 virtual ~PhoneFormat(); 42 virtual ~PhoneFormat();
45 43
46 bool load( Calendar * ,Calendar * ); 44 bool load( Calendar * ,Calendar * );
47 bool save( Calendar * ); 45 bool save( Calendar * );
48 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
49 QString toString( Calendar * ); 47 QString toString( Calendar * );
50 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
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};
64 58
65} 59}
66 60
67#endif 61#endif
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 0ebd7d1..4727a7a 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -9,100 +9,103 @@
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qfile.h> 29#include <qfile.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36 36
37#include "vcc.h" 37#include "vcc.h"
38#include "vobject.h" 38#include "vobject.h"
39 39
40#include "vcaldrag.h" 40#include "vcaldrag.h"
41#include "calendar.h" 41#include "calendar.h"
42 42
43#include "vcalformat.h" 43#include "vcalformat.h"
44 44
45using namespace KCal; 45using namespace KCal;
46 46
47VCalFormat::VCalFormat() 47VCalFormat::VCalFormat()
48{ 48{
49 mCalendar = 0; 49 mCalendar = 0;
50 useLocalTime = false; 50 useLocalTime = false;
51} 51}
52 52
53VCalFormat::~VCalFormat() 53VCalFormat::~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;
64 67
65 VObject *vcal = 0; 68 VObject *vcal = 0;
66 69
67 // this is not necessarily only 1 vcal. Could be many vcals, or include 70 // this is not necessarily only 1 vcal. Could be many vcals, or include
68 // a vcard... 71 // a vcard...
69 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); 72 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data()));
70 73
71 if (!vcal) { 74 if (!vcal) {
72 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 75 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
73 return FALSE; 76 return FALSE;
74 } 77 }
75 78
76 // any other top-level calendar stuff should be added/initialized here 79 // any other top-level calendar stuff should be added/initialized here
77 80
78 // put all vobjects into their proper places 81 // put all vobjects into their proper places
79 populate(vcal); 82 populate(vcal);
80 83
81 // clean up from vcal API stuff 84 // clean up from vcal API stuff
82 cleanVObjects(vcal); 85 cleanVObjects(vcal);
83 cleanStrTbl(); 86 cleanStrTbl();
84 87
85 return true; 88 return true;
86} 89}
87 90
88 91
89bool VCalFormat::save(Calendar *calendar, const QString &fileName) 92bool VCalFormat::save(Calendar *calendar, const QString &fileName)
90{ 93{
91 mCalendar = calendar; 94 mCalendar = calendar;
92 95
93 QString tmpStr; 96 QString tmpStr;
94 VObject *vcal, *vo; 97 VObject *vcal, *vo;
95 98
96 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; 99 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl;
97 100
98 vcal = newVObject(VCCalProp); 101 vcal = newVObject(VCCalProp);
99 102
100 // addPropValue(vcal,VCLocationProp, "0.0"); 103 // addPropValue(vcal,VCLocationProp, "0.0");
101 addPropValue(vcal,VCProdIdProp, productId()); 104 addPropValue(vcal,VCProdIdProp, productId());
102 tmpStr = mCalendar->getTimeZoneStr(); 105 tmpStr = mCalendar->getTimeZoneStr();
103 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 106 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
104 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 107 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
105 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 108 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
106 109
107 // TODO STUFF 110 // TODO STUFF
108 QPtrList<Todo> todoList = mCalendar->rawTodos(); 111 QPtrList<Todo> todoList = mCalendar->rawTodos();
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index 848be78..5bef7ed 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -2,110 +2,111 @@
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@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
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef _VCALFORMAT_H 22#ifndef _VCALFORMAT_H
23#define _VCALFORMAT_H 23#define _VCALFORMAT_H
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#define _VCAL_VERSION "1.0" 27#define _VCAL_VERSION "1.0"
28 28
29class VObject; 29class VObject;
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the vCalendar format. It provides methods for 34 This class implements the vCalendar format. It provides methods for
35 loading/saving/converting vCalendar format data into the internal KOrganizer 35 loading/saving/converting vCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 36 representation as Calendar and Events.
37 37
38 @short vCalendar format implementation 38 @short vCalendar format implementation
39*/ 39*/
40class VCalFormat : public CalFormat { 40class VCalFormat : public CalFormat {
41 public: 41 public:
42 VCalFormat(); 42 VCalFormat();
43 virtual ~VCalFormat(); 43 virtual ~VCalFormat();
44 44
45 /** loads a calendar on disk in vCalendar format into the current calendar. 45 /** loads a calendar on disk in vCalendar format into the current calendar.
46 * any information already present is lost. Returns TRUE if successful, 46 * any information already present is lost. Returns TRUE if successful,
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.
59 */ 59 */
60 bool fromString( Calendar *, const QString & ); 60 bool fromString( Calendar *, const QString & );
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 );
67 68
68 protected: 69 protected:
69 /** translates a VObject of the TODO type into a Event */ 70 /** translates a VObject of the TODO type into a Event */
70 Todo *VTodoToEvent(VObject *vtodo); 71 Todo *VTodoToEvent(VObject *vtodo);
71 /** translates a VObject into a Event and returns a pointer to it. */ 72 /** translates a VObject into a Event and returns a pointer to it. */
72 Event *VEventToEvent(VObject *vevent); 73 Event *VEventToEvent(VObject *vevent);
73 /** translate a Event into a VTodo-type VObject and return pointer */ 74 /** translate a Event into a VTodo-type VObject and return pointer */
74 VObject *eventToVTodo(const Todo *anEvent); 75 VObject *eventToVTodo(const Todo *anEvent);
75 /** translate a Event into a VObject and returns a pointer to it. */ 76 /** translate a Event into a VObject and returns a pointer to it. */
76 VObject* eventToVEvent(const Event *anEvent); 77 VObject* eventToVEvent(const Event *anEvent);
77 78
78 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ 79 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
79 QString qDateToISO(const QDate &); 80 QString qDateToISO(const QDate &);
80 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ 81 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */
81 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); 82 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE);
82 /** takes a string in the format YYYYMMDDTHHMMSS and returns a 83 /** takes a string in the format YYYYMMDDTHHMMSS and returns a
83 * valid QDateTime. */ 84 * valid QDateTime. */
84 QDateTime ISOToQDateTime(const QString & dtStr); 85 QDateTime ISOToQDateTime(const QString & dtStr);
85 /** takes a string in the format YYYYMMDD and returns a 86 /** takes a string in the format YYYYMMDD and returns a
86 * valid QDate. */ 87 * valid QDate. */
87 QDate ISOToQDate(const QString & dtStr); 88 QDate ISOToQDate(const QString & dtStr);
88 /** takes a vCalendar tree of VObjects, and puts all of them that have 89 /** takes a vCalendar tree of VObjects, and puts all of them that have
89 * the "event" property into the dictionary, todos in the todo-list, etc. */ 90 * the "event" property into the dictionary, todos in the todo-list, etc. */
90 void populate(VObject *vcal); 91 void populate(VObject *vcal);
91 92
92 /** takes a number 0 - 6 and returns the two letter string of that day, 93 /** takes a number 0 - 6 and returns the two letter string of that day,
93 * i.e. MO, TU, WE, etc. */ 94 * i.e. MO, TU, WE, etc. */
94 const char *dayFromNum(int day); 95 const char *dayFromNum(int day);
95 /** the reverse of the above function. */ 96 /** the reverse of the above function. */
96 int numFromDay(const QString &day); 97 int numFromDay(const QString &day);
97 98
98 Attendee::PartStat readStatus(const char *s) const; 99 Attendee::PartStat readStatus(const char *s) const;
99 QCString writeStatus(Attendee::PartStat status) const; 100 QCString writeStatus(Attendee::PartStat status) const;
100 101
101 private: 102 private:
102 Calendar *mCalendar; 103 Calendar *mCalendar;
103 bool useLocalTime; 104 bool useLocalTime;
104 105
105 QPtrList<Event> mEventsRelate; // events with relations 106 QPtrList<Event> mEventsRelate; // events with relations
106 QPtrList<Todo> mTodosRelate; // todos with relations 107 QPtrList<Todo> mTodosRelate; // todos with relations
107}; 108};
108 109
109} 110}
110 111
111#endif 112#endif