author | zautrix <zautrix> | 2004-08-30 07:47:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-30 07:47:56 (UTC) |
commit | b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2 (patch) (unidiff) | |
tree | 99223dd8edf0e00a4f060610ea0642f915cf4703 | |
parent | 78f44f13835e3fa501997f485b505b193bd474f5 (diff) | |
download | kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.zip kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.tar.gz kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.tar.bz2 |
Changes in gammu connection
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 85 | ||||
-rw-r--r-- | kdepim-desktop.pro | 6 | ||||
-rw-r--r-- | kopi-desktop.pro | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/korganizer.pro | 1 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 5 | ||||
-rw-r--r-- | libkcal/incidence.h | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 1464 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 14 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 5 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 5 |
12 files changed, 259 insertions, 1352 deletions
@@ -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 |
11 | DEL_FILE = rm -f | 11 | DEL_FILE = rm -f |
12 | CHK_DIR_EXISTS= test -d | 12 | CHK_DIR_EXISTS= test -d |
13 | MKDIR = mkdir -p | 13 | MKDIR = 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 | ||
26 | first: all | 27 | first: all |
27 | 28 | ||
28 | all: Makefile $(SUBTARGETS) | 29 | all: Makefile $(SUBTARGETS) |
29 | 30 | ||
30 | gammu/emb/common/$(MAKEFILE): | 31 | gammu/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) |
33 | sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE | 34 | sub-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 | ||
37 | gammu/emb/gammu/$(MAKEFILE): | ||
38 | @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu" | ||
39 | cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE) | ||
40 | sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE | ||
41 | cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE) | ||
42 | |||
36 | libical/$(MAKEFILE): | 43 | libical/$(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) |
39 | sub-libical: libical/$(MAKEFILE) FORCE | 46 | sub-libical: libical/$(MAKEFILE) FORCE |
40 | cd libical && $(MAKE) -f $(MAKEFILE) | 47 | cd libical && $(MAKE) -f $(MAKEFILE) |
41 | 48 | ||
42 | libkcal/$(MAKEFILE): | 49 | libkcal/$(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) |
45 | sub-libkcal: libkcal/$(MAKEFILE) FORCE | 52 | sub-libkcal: libkcal/$(MAKEFILE) FORCE |
46 | cd libkcal && $(MAKE) -f $(MAKEFILE) | 53 | cd libkcal && $(MAKE) -f $(MAKEFILE) |
47 | 54 | ||
48 | microkde/$(MAKEFILE): | 55 | microkde/$(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) |
51 | sub-microkde: microkde/$(MAKEFILE) FORCE | 58 | sub-microkde: microkde/$(MAKEFILE) FORCE |
52 | cd microkde && $(MAKE) -f $(MAKEFILE) | 59 | cd microkde && $(MAKE) -f $(MAKEFILE) |
53 | 60 | ||
54 | libkdepim/$(MAKEFILE): | 61 | libkdepim/$(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) |
57 | sub-libkdepim: libkdepim/$(MAKEFILE) FORCE | 64 | sub-libkdepim: libkdepim/$(MAKEFILE) FORCE |
58 | cd libkdepim && $(MAKE) -f $(MAKEFILE) | 65 | cd libkdepim && $(MAKE) -f $(MAKEFILE) |
59 | 66 | ||
60 | kabc/$(MAKEFILE): | 67 | kabc/$(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) |
63 | sub-kabc: kabc/$(MAKEFILE) FORCE | 70 | sub-kabc: kabc/$(MAKEFILE) FORCE |
64 | cd kabc && $(MAKE) -f $(MAKEFILE) | 71 | cd kabc && $(MAKE) -f $(MAKEFILE) |
65 | 72 | ||
66 | korganizer/$(MAKEFILE): | 73 | korganizer/$(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) |
69 | sub-korganizer: korganizer/$(MAKEFILE) FORCE | 76 | sub-korganizer: korganizer/$(MAKEFILE) FORCE |
70 | cd korganizer && $(MAKE) -f $(MAKEFILE) | 77 | cd korganizer && $(MAKE) -f $(MAKEFILE) |
71 | 78 | ||
72 | kaddressbook/$(MAKEFILE): | 79 | kaddressbook/$(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) |
75 | sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE | 82 | sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE |
76 | cd kaddressbook && $(MAKE) -f $(MAKEFILE) | 83 | cd kaddressbook && $(MAKE) -f $(MAKEFILE) |
77 | 84 | ||
78 | kabc/plugins/file/$(MAKEFILE): | 85 | kabc/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) |
81 | sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE | 88 | sub-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 | ||
84 | kabc/plugins/dir/$(MAKEFILE): | 91 | kabc/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) |
87 | sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE | 94 | sub-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 | ||
90 | Makefile: kopi-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf | 97 | Makefile: kopi-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf |
91 | $(QMAKE) -o Makefile kopi-desktop.pro | 98 | $(QMAKE) -o Makefile kopi-desktop.pro |
92 | qmake: qmake_all | 99 | qmake: qmake_all |
93 | @$(QMAKE) -o Makefile kopi-desktop.pro | 100 | @$(QMAKE) -o Makefile kopi-desktop.pro |
94 | 101 | ||
95 | all: $(SUBTARGETS) | 102 | all: $(SUBTARGETS) |
96 | qmake_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) | 103 | qmake_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 |
107 | clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE | 115 | clean 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 |
118 | uninstall_subdirs: qmake_all FORCE | 127 | uninstall_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 |
129 | install_subdirs: qmake_all FORCE | 139 | install_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 |
140 | distclean: qmake_all FORCE | 151 | distclean: 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 | ||
152 | install: install_subdirs | 164 | install: install_subdirs |
153 | 165 | ||
154 | uninstall: uninstall_subdirs | 166 | uninstall: uninstall_subdirs |
155 | 167 | ||
156 | FORCE: | 168 | FORCE: |
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 | |||
@@ -1,509 +1,512 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | #include "gsmcal.h" | 5 | #include "gsmcal.h" |
6 | #include "gsmmisc.h" | 6 | #include "gsmmisc.h" |
7 | #include "../misc/coding/coding.h" | 7 | #include "../misc/coding/coding.h" |
8 | 8 | ||
9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) | 9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) |
10 | { | 10 | { |
11 | bool Past = true; | 11 | bool Past = true; |
12 | int i; | 12 | int i; |
13 | GSM_DateTimeDT; | 13 | GSM_DateTimeDT; |
14 | 14 | ||
15 | GSM_GetCurrentDateTime (&DT); | 15 | GSM_GetCurrentDateTime (&DT); |
16 | for (i = 0; i < note->EntriesNum; i++) { | 16 | for (i = 0; i < note->EntriesNum; i++) { |
17 | switch (note->Entries[i].EntryType) { | 17 | switch (note->Entries[i].EntryType) { |
18 | case CAL_RECURRANCE: | 18 | case CAL_RECURRANCE: |
19 | Past = false; | 19 | Past = false; |
20 | break; | 20 | break; |
21 | case CAL_START_DATETIME : | 21 | case CAL_START_DATETIME : |
22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; | 22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; |
23 | if (note->Entries[i].Date.Year == DT.Year && | 23 | if (note->Entries[i].Date.Year == DT.Year && |
24 | note->Entries[i].Date.Month > DT.Month) Past = false; | 24 | note->Entries[i].Date.Month > DT.Month) Past = false; |
25 | if (note->Entries[i].Date.Year == DT.Year && | 25 | if (note->Entries[i].Date.Year == DT.Year && |
26 | note->Entries[i].Date.Month == DT.Month && | 26 | note->Entries[i].Date.Month == DT.Month && |
27 | note->Entries[i].Date.Day > DT.Day) Past = false; | 27 | note->Entries[i].Date.Day > DT.Day) Past = false; |
28 | break; | 28 | break; |
29 | default: | 29 | default: |
30 | break; | 30 | break; |
31 | } | 31 | } |
32 | if (!Past) break; | 32 | if (!Past) break; |
33 | } | 33 | } |
34 | switch (note->Type) { | 34 | switch (note->Type) { |
35 | case GSM_CAL_BIRTHDAY: | 35 | case GSM_CAL_BIRTHDAY: |
36 | Past = false; | 36 | Past = false; |
37 | break; | 37 | break; |
38 | default: | 38 | default: |
39 | break; | 39 | break; |
40 | } | 40 | } |
41 | return Past; | 41 | return Past; |
42 | } | 42 | } |
43 | 43 | ||
44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) | 44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) |
45 | { | 45 | { |
46 | int i; | 46 | int i; |
47 | 47 | ||
48 | *Text = -1; | 48 | *Text = -1; |
49 | *Time = -1; | 49 | *Time = -1; |
50 | *Alarm = -1; | 50 | *Alarm = -1; |
51 | *Phone = -1; | 51 | *Phone = -1; |
52 | *Recurrance= -1; | 52 | *Recurrance= -1; |
53 | *EndTime= -1; | 53 | *EndTime= -1; |
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 | ||
85 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) | 85 | GSM_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, ¬e->Entries[Time].Date, "DTSTART"); | 135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
136 | 136 | ||
137 | if (EndTime != -1) { | 137 | if (EndTime != -1) { |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->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, ¬e->Entries[Alarm].Date, "DALARM"); | 143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
144 | } else { | 144 | } else { |
145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 145 | SaveVCALDateTime(Buffer, Length, ¬e->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, ¬e->Entries[Time].Date, "DTSTART"); | 177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
178 | 178 | ||
179 | if (Alarm != -1) { | 179 | if (Alarm != -1) { |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->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, ¬e->Entries[Time].Date, "DTSTART"); | 229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
230 | 230 | ||
231 | if (EndTime != -1) { | 231 | if (EndTime != -1) { |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
233 | } | 233 | } |
234 | 234 | ||
235 | if (Alarm != -1) { | 235 | if (Alarm != -1) { |
236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 236 | SaveVCALDateTime(Buffer, Length, ¬e->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 | ||
252 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) | 253 | void 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 | ||
285 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) | 286 | GSM_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, ¬e->Entries[EndTime].Date, "DUE"); | 316 | SaveVCALDateTime(Buffer, Length, ¬e->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, ¬e->Entries[Alarm].Date, "DALARM"); | 321 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
321 | } else { | 322 | } else { |
322 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 323 | SaveVCALDateTime(Buffer, Length, ¬e->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, ¬e->Entries[Alarm].Date, "AALARM"); | 343 | SaveVCALDateTime(Buffer, Length, ¬e->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 | ||
354 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) | 356 | GSM_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 | ||
497 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 500 | GSM_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 | |||
3 | TEMPLATE = subdirs | ||
4 | SUBDIRS = 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 | |||
3 | TEMPLATE = subdirs | ||
4 | SUBDIRS = 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 | |||
@@ -1494,769 +1494,769 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1494 | 1494 | ||
1495 | if ( km == KMessageBox::Cancel ) | 1495 | if ( km == KMessageBox::Cancel ) |
1496 | return false; | 1496 | return false; |
1497 | if ( km == KMessageBox::Yes ) | 1497 | if ( km == KMessageBox::Yes ) |
1498 | return true; | 1498 | return true; |
1499 | 1499 | ||
1500 | setSyncDevice("deleteaftersync" ); | 1500 | setSyncDevice("deleteaftersync" ); |
1501 | KOPrefs::instance()->mAskForPreferences = true; | 1501 | KOPrefs::instance()->mAskForPreferences = true; |
1502 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1502 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1503 | KOPrefs::instance()->mWriteBackFile = false; | 1503 | KOPrefs::instance()->mWriteBackFile = false; |
1504 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1504 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1505 | KOPrefs::instance()->mShowSyncSummary = false; | 1505 | KOPrefs::instance()->mShowSyncSummary = false; |
1506 | syncCalendar( fn, 3 ); | 1506 | syncCalendar( fn, 3 ); |
1507 | Event * e = getLastSyncEvent(); | 1507 | Event * e = getLastSyncEvent(); |
1508 | mCalendar->deleteEvent ( e ); | 1508 | mCalendar->deleteEvent ( e ); |
1509 | updateView(); | 1509 | updateView(); |
1510 | return true; | 1510 | return true; |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | bool CalendarView::saveCalendar( QString filename ) | 1513 | bool CalendarView::saveCalendar( QString filename ) |
1514 | { | 1514 | { |
1515 | 1515 | ||
1516 | // Store back all unsaved data into calendar object | 1516 | // Store back all unsaved data into calendar object |
1517 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1517 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1518 | if ( mViewManager->currentView() ) | 1518 | if ( mViewManager->currentView() ) |
1519 | mViewManager->currentView()->flushView(); | 1519 | mViewManager->currentView()->flushView(); |
1520 | 1520 | ||
1521 | //mStorage->setFileName( filename ); | 1521 | //mStorage->setFileName( filename ); |
1522 | 1522 | ||
1523 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1523 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1524 | mStorage->setFileName( filename ); | 1524 | mStorage->setFileName( filename ); |
1525 | bool success; | 1525 | bool success; |
1526 | success = mStorage->save(); | 1526 | success = mStorage->save(); |
1527 | if ( !success ) { | 1527 | if ( !success ) { |
1528 | return false; | 1528 | return false; |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | return true; | 1531 | return true; |
1532 | } | 1532 | } |
1533 | 1533 | ||
1534 | void CalendarView::closeCalendar() | 1534 | void CalendarView::closeCalendar() |
1535 | { | 1535 | { |
1536 | 1536 | ||
1537 | // child windows no longer valid | 1537 | // child windows no longer valid |
1538 | emit closingDown(); | 1538 | emit closingDown(); |
1539 | 1539 | ||
1540 | mCalendar->close(); | 1540 | mCalendar->close(); |
1541 | setModified(false); | 1541 | setModified(false); |
1542 | updateView(); | 1542 | updateView(); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void CalendarView::archiveCalendar() | 1545 | void CalendarView::archiveCalendar() |
1546 | { | 1546 | { |
1547 | mDialogManager->showArchiveDialog(); | 1547 | mDialogManager->showArchiveDialog(); |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | 1550 | ||
1551 | void CalendarView::readSettings() | 1551 | void CalendarView::readSettings() |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | 1554 | ||
1555 | // mViewManager->showAgendaView(); | 1555 | // mViewManager->showAgendaView(); |
1556 | QString str; | 1556 | QString str; |
1557 | //qDebug("CalendarView::readSettings() "); | 1557 | //qDebug("CalendarView::readSettings() "); |
1558 | // read settings from the KConfig, supplying reasonable | 1558 | // read settings from the KConfig, supplying reasonable |
1559 | // defaults where none are to be found | 1559 | // defaults where none are to be found |
1560 | KConfig *config = KOGlobals::config(); | 1560 | KConfig *config = KOGlobals::config(); |
1561 | #ifndef KORG_NOSPLITTER | 1561 | #ifndef KORG_NOSPLITTER |
1562 | config->setGroup("KOrganizer Geometry"); | 1562 | config->setGroup("KOrganizer Geometry"); |
1563 | 1563 | ||
1564 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1564 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1565 | if (sizes.count() != 2) { | 1565 | if (sizes.count() != 2) { |
1566 | sizes << mDateNavigator->minimumSizeHint().width(); | 1566 | sizes << mDateNavigator->minimumSizeHint().width(); |
1567 | sizes << 300; | 1567 | sizes << 300; |
1568 | } | 1568 | } |
1569 | mPanner->setSizes(sizes); | 1569 | mPanner->setSizes(sizes); |
1570 | 1570 | ||
1571 | sizes = config->readIntListEntry("Separator2"); | 1571 | sizes = config->readIntListEntry("Separator2"); |
1572 | if ( ( mResourceView && sizes.count() == 4 ) || | 1572 | if ( ( mResourceView && sizes.count() == 4 ) || |
1573 | ( !mResourceView && sizes.count() == 3 ) ) { | 1573 | ( !mResourceView && sizes.count() == 3 ) ) { |
1574 | mLeftSplitter->setSizes(sizes); | 1574 | mLeftSplitter->setSizes(sizes); |
1575 | } | 1575 | } |
1576 | #endif | 1576 | #endif |
1577 | globalFlagBlockAgenda = 1; | 1577 | globalFlagBlockAgenda = 1; |
1578 | mViewManager->showAgendaView(); | 1578 | mViewManager->showAgendaView(); |
1579 | //mViewManager->readSettings( config ); | 1579 | //mViewManager->readSettings( config ); |
1580 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1580 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1581 | readFilterSettings(config); | 1581 | readFilterSettings(config); |
1582 | config->setGroup( "Views" ); | 1582 | config->setGroup( "Views" ); |
1583 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1583 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1584 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1584 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1585 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1585 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1586 | else mNavigator->selectDates( dateCount ); | 1586 | else mNavigator->selectDates( dateCount ); |
1587 | // mViewManager->readSettings( config ); | 1587 | // mViewManager->readSettings( config ); |
1588 | updateConfig(); | 1588 | updateConfig(); |
1589 | globalFlagBlockAgenda = 2; | 1589 | globalFlagBlockAgenda = 2; |
1590 | mViewManager->readSettings( config ); | 1590 | mViewManager->readSettings( config ); |
1591 | #ifdef DESKTOP_VERSION | 1591 | #ifdef DESKTOP_VERSION |
1592 | config->setGroup("WidgetLayout"); | 1592 | config->setGroup("WidgetLayout"); |
1593 | QStringList list; | 1593 | QStringList list; |
1594 | list = config->readListEntry("MainLayout"); | 1594 | list = config->readListEntry("MainLayout"); |
1595 | int x,y,w,h; | 1595 | int x,y,w,h; |
1596 | if ( ! list.isEmpty() ) { | 1596 | if ( ! list.isEmpty() ) { |
1597 | x = list[0].toInt(); | 1597 | x = list[0].toInt(); |
1598 | y = list[1].toInt(); | 1598 | y = list[1].toInt(); |
1599 | w = list[2].toInt(); | 1599 | w = list[2].toInt(); |
1600 | h = list[3].toInt(); | 1600 | h = list[3].toInt(); |
1601 | topLevelWidget()->setGeometry(x,y,w,h); | 1601 | topLevelWidget()->setGeometry(x,y,w,h); |
1602 | 1602 | ||
1603 | } else { | 1603 | } else { |
1604 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1604 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1605 | } | 1605 | } |
1606 | list = config->readListEntry("EditEventLayout"); | 1606 | list = config->readListEntry("EditEventLayout"); |
1607 | if ( ! list.isEmpty() ) { | 1607 | if ( ! list.isEmpty() ) { |
1608 | x = list[0].toInt(); | 1608 | x = list[0].toInt(); |
1609 | y = list[1].toInt(); | 1609 | y = list[1].toInt(); |
1610 | w = list[2].toInt(); | 1610 | w = list[2].toInt(); |
1611 | h = list[3].toInt(); | 1611 | h = list[3].toInt(); |
1612 | mEventEditor->setGeometry(x,y,w,h); | 1612 | mEventEditor->setGeometry(x,y,w,h); |
1613 | 1613 | ||
1614 | } | 1614 | } |
1615 | list = config->readListEntry("EditTodoLayout"); | 1615 | list = config->readListEntry("EditTodoLayout"); |
1616 | if ( ! list.isEmpty() ) { | 1616 | if ( ! list.isEmpty() ) { |
1617 | x = list[0].toInt(); | 1617 | x = list[0].toInt(); |
1618 | y = list[1].toInt(); | 1618 | y = list[1].toInt(); |
1619 | w = list[2].toInt(); | 1619 | w = list[2].toInt(); |
1620 | h = list[3].toInt(); | 1620 | h = list[3].toInt(); |
1621 | mTodoEditor->setGeometry(x,y,w,h); | 1621 | mTodoEditor->setGeometry(x,y,w,h); |
1622 | 1622 | ||
1623 | } | 1623 | } |
1624 | list = config->readListEntry("ViewerLayout"); | 1624 | list = config->readListEntry("ViewerLayout"); |
1625 | if ( ! list.isEmpty() ) { | 1625 | if ( ! list.isEmpty() ) { |
1626 | x = list[0].toInt(); | 1626 | x = list[0].toInt(); |
1627 | y = list[1].toInt(); | 1627 | y = list[1].toInt(); |
1628 | w = list[2].toInt(); | 1628 | w = list[2].toInt(); |
1629 | h = list[3].toInt(); | 1629 | h = list[3].toInt(); |
1630 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1630 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1631 | } | 1631 | } |
1632 | #endif | 1632 | #endif |
1633 | 1633 | ||
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | 1636 | ||
1637 | void CalendarView::writeSettings() | 1637 | void CalendarView::writeSettings() |
1638 | { | 1638 | { |
1639 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1639 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1640 | 1640 | ||
1641 | KConfig *config = KOGlobals::config(); | 1641 | KConfig *config = KOGlobals::config(); |
1642 | 1642 | ||
1643 | #ifndef KORG_NOSPLITTER | 1643 | #ifndef KORG_NOSPLITTER |
1644 | config->setGroup("KOrganizer Geometry"); | 1644 | config->setGroup("KOrganizer Geometry"); |
1645 | 1645 | ||
1646 | QValueList<int> list = mPanner->sizes(); | 1646 | QValueList<int> list = mPanner->sizes(); |
1647 | config->writeEntry("Separator1",list); | 1647 | config->writeEntry("Separator1",list); |
1648 | 1648 | ||
1649 | list = mLeftSplitter->sizes(); | 1649 | list = mLeftSplitter->sizes(); |
1650 | config->writeEntry("Separator2",list); | 1650 | config->writeEntry("Separator2",list); |
1651 | #endif | 1651 | #endif |
1652 | 1652 | ||
1653 | mViewManager->writeSettings( config ); | 1653 | mViewManager->writeSettings( config ); |
1654 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1654 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1655 | mDialogManager->writeSettings( config ); | 1655 | mDialogManager->writeSettings( config ); |
1656 | //KOPrefs::instance()->usrWriteConfig(); | 1656 | //KOPrefs::instance()->usrWriteConfig(); |
1657 | KOPrefs::instance()->writeConfig(); | 1657 | KOPrefs::instance()->writeConfig(); |
1658 | 1658 | ||
1659 | writeFilterSettings(config); | 1659 | writeFilterSettings(config); |
1660 | 1660 | ||
1661 | config->setGroup( "Views" ); | 1661 | config->setGroup( "Views" ); |
1662 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1662 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1663 | 1663 | ||
1664 | #ifdef DESKTOP_VERSION | 1664 | #ifdef DESKTOP_VERSION |
1665 | config->setGroup("WidgetLayout"); | 1665 | config->setGroup("WidgetLayout"); |
1666 | QStringList list ;//= config->readListEntry("MainLayout"); | 1666 | QStringList list ;//= config->readListEntry("MainLayout"); |
1667 | int x,y,w,h; | 1667 | int x,y,w,h; |
1668 | QWidget* wid; | 1668 | QWidget* wid; |
1669 | wid = topLevelWidget(); | 1669 | wid = topLevelWidget(); |
1670 | x = wid->geometry().x(); | 1670 | x = wid->geometry().x(); |
1671 | y = wid->geometry().y(); | 1671 | y = wid->geometry().y(); |
1672 | w = wid->width(); | 1672 | w = wid->width(); |
1673 | h = wid->height(); | 1673 | h = wid->height(); |
1674 | list.clear(); | 1674 | list.clear(); |
1675 | list << QString::number( x ); | 1675 | list << QString::number( x ); |
1676 | list << QString::number( y ); | 1676 | list << QString::number( y ); |
1677 | list << QString::number( w ); | 1677 | list << QString::number( w ); |
1678 | list << QString::number( h ); | 1678 | list << QString::number( h ); |
1679 | config->writeEntry("MainLayout",list ); | 1679 | config->writeEntry("MainLayout",list ); |
1680 | 1680 | ||
1681 | wid = mEventEditor; | 1681 | wid = mEventEditor; |
1682 | x = wid->geometry().x(); | 1682 | x = wid->geometry().x(); |
1683 | y = wid->geometry().y(); | 1683 | y = wid->geometry().y(); |
1684 | w = wid->width(); | 1684 | w = wid->width(); |
1685 | h = wid->height(); | 1685 | h = wid->height(); |
1686 | list.clear(); | 1686 | list.clear(); |
1687 | list << QString::number( x ); | 1687 | list << QString::number( x ); |
1688 | list << QString::number( y ); | 1688 | list << QString::number( y ); |
1689 | list << QString::number( w ); | 1689 | list << QString::number( w ); |
1690 | list << QString::number( h ); | 1690 | list << QString::number( h ); |
1691 | config->writeEntry("EditEventLayout",list ); | 1691 | config->writeEntry("EditEventLayout",list ); |
1692 | 1692 | ||
1693 | wid = mTodoEditor; | 1693 | wid = mTodoEditor; |
1694 | x = wid->geometry().x(); | 1694 | x = wid->geometry().x(); |
1695 | y = wid->geometry().y(); | 1695 | y = wid->geometry().y(); |
1696 | w = wid->width(); | 1696 | w = wid->width(); |
1697 | h = wid->height(); | 1697 | h = wid->height(); |
1698 | list.clear(); | 1698 | list.clear(); |
1699 | list << QString::number( x ); | 1699 | list << QString::number( x ); |
1700 | list << QString::number( y ); | 1700 | list << QString::number( y ); |
1701 | list << QString::number( w ); | 1701 | list << QString::number( w ); |
1702 | list << QString::number( h ); | 1702 | list << QString::number( h ); |
1703 | config->writeEntry("EditTodoLayout",list ); | 1703 | config->writeEntry("EditTodoLayout",list ); |
1704 | wid = getEventViewerDialog(); | 1704 | wid = getEventViewerDialog(); |
1705 | x = wid->geometry().x(); | 1705 | x = wid->geometry().x(); |
1706 | y = wid->geometry().y(); | 1706 | y = wid->geometry().y(); |
1707 | w = wid->width(); | 1707 | w = wid->width(); |
1708 | h = wid->height(); | 1708 | h = wid->height(); |
1709 | list.clear(); | 1709 | list.clear(); |
1710 | list << QString::number( x ); | 1710 | list << QString::number( x ); |
1711 | list << QString::number( y ); | 1711 | list << QString::number( y ); |
1712 | list << QString::number( w ); | 1712 | list << QString::number( w ); |
1713 | list << QString::number( h ); | 1713 | list << QString::number( h ); |
1714 | config->writeEntry("ViewerLayout",list ); | 1714 | config->writeEntry("ViewerLayout",list ); |
1715 | wid = mDialogManager->getSearchDialog(); | 1715 | wid = mDialogManager->getSearchDialog(); |
1716 | if ( wid ) { | 1716 | if ( wid ) { |
1717 | x = wid->geometry().x(); | 1717 | x = wid->geometry().x(); |
1718 | y = wid->geometry().y(); | 1718 | y = wid->geometry().y(); |
1719 | w = wid->width(); | 1719 | w = wid->width(); |
1720 | h = wid->height(); | 1720 | h = wid->height(); |
1721 | list.clear(); | 1721 | list.clear(); |
1722 | list << QString::number( x ); | 1722 | list << QString::number( x ); |
1723 | list << QString::number( y ); | 1723 | list << QString::number( y ); |
1724 | list << QString::number( w ); | 1724 | list << QString::number( w ); |
1725 | list << QString::number( h ); | 1725 | list << QString::number( h ); |
1726 | config->writeEntry("SearchLayout",list ); | 1726 | config->writeEntry("SearchLayout",list ); |
1727 | } | 1727 | } |
1728 | #endif | 1728 | #endif |
1729 | 1729 | ||
1730 | 1730 | ||
1731 | config->sync(); | 1731 | config->sync(); |
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | void CalendarView::readFilterSettings(KConfig *config) | 1734 | void CalendarView::readFilterSettings(KConfig *config) |
1735 | { | 1735 | { |
1736 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1736 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1737 | 1737 | ||
1738 | mFilters.clear(); | 1738 | mFilters.clear(); |
1739 | 1739 | ||
1740 | config->setGroup("General"); | 1740 | config->setGroup("General"); |
1741 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1741 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1742 | 1742 | ||
1743 | QStringList::ConstIterator it = filterList.begin(); | 1743 | QStringList::ConstIterator it = filterList.begin(); |
1744 | QStringList::ConstIterator end = filterList.end(); | 1744 | QStringList::ConstIterator end = filterList.end(); |
1745 | while(it != end) { | 1745 | while(it != end) { |
1746 | // kdDebug() << " filter: " << (*it) << endl; | 1746 | // kdDebug() << " filter: " << (*it) << endl; |
1747 | 1747 | ||
1748 | CalFilter *filter; | 1748 | CalFilter *filter; |
1749 | filter = new CalFilter(*it); | 1749 | filter = new CalFilter(*it); |
1750 | config->setGroup("Filter_" + (*it)); | 1750 | config->setGroup("Filter_" + (*it)); |
1751 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1751 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1752 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1752 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1753 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1753 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1754 | mFilters.append(filter); | 1754 | mFilters.append(filter); |
1755 | 1755 | ||
1756 | ++it; | 1756 | ++it; |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | if (mFilters.count() == 0) { | 1759 | if (mFilters.count() == 0) { |
1760 | CalFilter *filter = new CalFilter(i18n("Default")); | 1760 | CalFilter *filter = new CalFilter(i18n("Default")); |
1761 | mFilters.append(filter); | 1761 | mFilters.append(filter); |
1762 | } | 1762 | } |
1763 | mFilterView->updateFilters(); | 1763 | mFilterView->updateFilters(); |
1764 | config->setGroup("FilterView"); | 1764 | config->setGroup("FilterView"); |
1765 | 1765 | ||
1766 | mFilterView->blockSignals(true); | 1766 | mFilterView->blockSignals(true); |
1767 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1767 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1768 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1768 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1769 | mFilterView->blockSignals(false); | 1769 | mFilterView->blockSignals(false); |
1770 | // We do it manually to avoid it being done twice by the above calls | 1770 | // We do it manually to avoid it being done twice by the above calls |
1771 | updateFilter(); | 1771 | updateFilter(); |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::writeFilterSettings(KConfig *config) | 1774 | void CalendarView::writeFilterSettings(KConfig *config) |
1775 | { | 1775 | { |
1776 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1776 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1777 | 1777 | ||
1778 | QStringList filterList; | 1778 | QStringList filterList; |
1779 | 1779 | ||
1780 | CalFilter *filter = mFilters.first(); | 1780 | CalFilter *filter = mFilters.first(); |
1781 | while(filter) { | 1781 | while(filter) { |
1782 | // kdDebug() << " fn: " << filter->name() << endl; | 1782 | // kdDebug() << " fn: " << filter->name() << endl; |
1783 | filterList << filter->name(); | 1783 | filterList << filter->name(); |
1784 | config->setGroup("Filter_" + filter->name()); | 1784 | config->setGroup("Filter_" + filter->name()); |
1785 | config->writeEntry("Criteria",filter->criteria()); | 1785 | config->writeEntry("Criteria",filter->criteria()); |
1786 | config->writeEntry("CategoryList",filter->categoryList()); | 1786 | config->writeEntry("CategoryList",filter->categoryList()); |
1787 | filter = mFilters.next(); | 1787 | filter = mFilters.next(); |
1788 | } | 1788 | } |
1789 | config->setGroup("General"); | 1789 | config->setGroup("General"); |
1790 | config->writeEntry("CalendarFilters",filterList); | 1790 | config->writeEntry("CalendarFilters",filterList); |
1791 | 1791 | ||
1792 | config->setGroup("FilterView"); | 1792 | config->setGroup("FilterView"); |
1793 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1793 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1794 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1794 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | 1797 | ||
1798 | void CalendarView::goToday() | 1798 | void CalendarView::goToday() |
1799 | { | 1799 | { |
1800 | mNavigator->selectToday(); | 1800 | mNavigator->selectToday(); |
1801 | } | 1801 | } |
1802 | 1802 | ||
1803 | void CalendarView::goNext() | 1803 | void CalendarView::goNext() |
1804 | { | 1804 | { |
1805 | mNavigator->selectNext(); | 1805 | mNavigator->selectNext(); |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | void CalendarView::goPrevious() | 1808 | void CalendarView::goPrevious() |
1809 | { | 1809 | { |
1810 | mNavigator->selectPrevious(); | 1810 | mNavigator->selectPrevious(); |
1811 | } | 1811 | } |
1812 | void CalendarView::goNextMonth() | 1812 | void CalendarView::goNextMonth() |
1813 | { | 1813 | { |
1814 | mNavigator->selectNextMonth(); | 1814 | mNavigator->selectNextMonth(); |
1815 | } | 1815 | } |
1816 | 1816 | ||
1817 | void CalendarView::goPreviousMonth() | 1817 | void CalendarView::goPreviousMonth() |
1818 | { | 1818 | { |
1819 | mNavigator->selectPreviousMonth(); | 1819 | mNavigator->selectPreviousMonth(); |
1820 | } | 1820 | } |
1821 | void CalendarView::writeLocale() | 1821 | void CalendarView::writeLocale() |
1822 | { | 1822 | { |
1823 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1823 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1824 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1824 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1825 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1825 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1826 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1826 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1827 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1827 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1828 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1828 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1829 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1829 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
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 | } |
1836 | void CalendarView::updateConfig() | 1836 | void 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 | ||
1850 | void CalendarView::eventChanged(Event *event) | 1850 | void CalendarView::eventChanged(Event *event) |
1851 | { | 1851 | { |
1852 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1852 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1853 | //updateUnmanagedViews(); | 1853 | //updateUnmanagedViews(); |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | void CalendarView::eventAdded(Event *event) | 1856 | void CalendarView::eventAdded(Event *event) |
1857 | { | 1857 | { |
1858 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1858 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | void CalendarView::eventToBeDeleted(Event *) | 1861 | void 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 | ||
1866 | void CalendarView::eventDeleted() | 1866 | void CalendarView::eventDeleted() |
1867 | { | 1867 | { |
1868 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1868 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1869 | } | 1869 | } |
1870 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1870 | void 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 | ||
1883 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1883 | void 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. |
1898 | void CalendarView::changeEventDisplay(Event *which, int action) | 1898 | void 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 | ||
1918 | void CalendarView::updateTodoViews() | 1918 | void 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 | ||
1927 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1927 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1928 | { | 1928 | { |
1929 | mTodoList->updateView(); | 1929 | mTodoList->updateView(); |
1930 | mViewManager->updateView(start, end); | 1930 | mViewManager->updateView(start, end); |
1931 | //mDateNavigator->updateView(); | 1931 | //mDateNavigator->updateView(); |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | void CalendarView::updateView() | 1934 | void CalendarView::updateView() |
1935 | { | 1935 | { |
1936 | DateList tmpList = mNavigator->selectedDates(); | 1936 | DateList tmpList = mNavigator->selectedDates(); |
1937 | 1937 | ||
1938 | // We assume that the navigator only selects consecutive days. | 1938 | // We assume that the navigator only selects consecutive days. |
1939 | updateView( tmpList.first(), tmpList.last() ); | 1939 | updateView( tmpList.first(), tmpList.last() ); |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | void CalendarView::updateUnmanagedViews() | 1942 | void CalendarView::updateUnmanagedViews() |
1943 | { | 1943 | { |
1944 | mDateNavigator->updateDayMatrix(); | 1944 | mDateNavigator->updateDayMatrix(); |
1945 | } | 1945 | } |
1946 | 1946 | ||
1947 | int CalendarView::msgItemDelete() | 1947 | int CalendarView::msgItemDelete() |
1948 | { | 1948 | { |
1949 | return KMessageBox::warningContinueCancel(this, | 1949 | return KMessageBox::warningContinueCancel(this, |
1950 | i18n("This item will be\npermanently deleted."), | 1950 | i18n("This item will be\npermanently deleted."), |
1951 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1951 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1952 | } | 1952 | } |
1953 | 1953 | ||
1954 | 1954 | ||
1955 | void CalendarView::edit_cut() | 1955 | void CalendarView::edit_cut() |
1956 | { | 1956 | { |
1957 | Event *anEvent=0; | 1957 | Event *anEvent=0; |
1958 | 1958 | ||
1959 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1959 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1960 | 1960 | ||
1961 | if (mViewManager->currentView()->isEventView()) { | 1961 | if (mViewManager->currentView()->isEventView()) { |
1962 | if ( incidence && incidence->type() == "Event" ) { | 1962 | if ( incidence && incidence->type() == "Event" ) { |
1963 | anEvent = static_cast<Event *>(incidence); | 1963 | anEvent = static_cast<Event *>(incidence); |
1964 | } | 1964 | } |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | if (!anEvent) { | 1967 | if (!anEvent) { |
1968 | KNotifyClient::beep(); | 1968 | KNotifyClient::beep(); |
1969 | return; | 1969 | return; |
1970 | } | 1970 | } |
1971 | DndFactory factory( mCalendar ); | 1971 | DndFactory factory( mCalendar ); |
1972 | factory.cutEvent(anEvent); | 1972 | factory.cutEvent(anEvent); |
1973 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 1973 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
1974 | } | 1974 | } |
1975 | 1975 | ||
1976 | void CalendarView::edit_copy() | 1976 | void CalendarView::edit_copy() |
1977 | { | 1977 | { |
1978 | Event *anEvent=0; | 1978 | Event *anEvent=0; |
1979 | 1979 | ||
1980 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1980 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1981 | 1981 | ||
1982 | if (mViewManager->currentView()->isEventView()) { | 1982 | if (mViewManager->currentView()->isEventView()) { |
1983 | if ( incidence && incidence->type() == "Event" ) { | 1983 | if ( incidence && incidence->type() == "Event" ) { |
1984 | anEvent = static_cast<Event *>(incidence); | 1984 | anEvent = static_cast<Event *>(incidence); |
1985 | } | 1985 | } |
1986 | } | 1986 | } |
1987 | 1987 | ||
1988 | if (!anEvent) { | 1988 | if (!anEvent) { |
1989 | KNotifyClient::beep(); | 1989 | KNotifyClient::beep(); |
1990 | return; | 1990 | return; |
1991 | } | 1991 | } |
1992 | DndFactory factory( mCalendar ); | 1992 | DndFactory factory( mCalendar ); |
1993 | factory.copyEvent(anEvent); | 1993 | factory.copyEvent(anEvent); |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | void CalendarView::edit_paste() | 1996 | void CalendarView::edit_paste() |
1997 | { | 1997 | { |
1998 | QDate date = mNavigator->selectedDates().first(); | 1998 | QDate date = mNavigator->selectedDates().first(); |
1999 | 1999 | ||
2000 | DndFactory factory( mCalendar ); | 2000 | DndFactory factory( mCalendar ); |
2001 | Event *pastedEvent = factory.pasteEvent( date ); | 2001 | Event *pastedEvent = factory.pasteEvent( date ); |
2002 | 2002 | ||
2003 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2003 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2004 | } | 2004 | } |
2005 | 2005 | ||
2006 | void CalendarView::edit_options() | 2006 | void CalendarView::edit_options() |
2007 | { | 2007 | { |
2008 | mDialogManager->showOptionsDialog(); | 2008 | mDialogManager->showOptionsDialog(); |
2009 | //writeSettings(); | 2009 | //writeSettings(); |
2010 | } | 2010 | } |
2011 | void CalendarView::edit_sync_options() | 2011 | void CalendarView::edit_sync_options() |
2012 | { | 2012 | { |
2013 | //mDialogManager->showSyncOptions(); | 2013 | //mDialogManager->showSyncOptions(); |
2014 | //KOPrefs::instance()->mSyncAlgoPrefs | 2014 | //KOPrefs::instance()->mSyncAlgoPrefs |
2015 | QDialog dia( this, "dia", true ); | 2015 | QDialog dia( this, "dia", true ); |
2016 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2016 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2017 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2017 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2018 | QVBoxLayout lay ( &dia ); | 2018 | QVBoxLayout lay ( &dia ); |
2019 | lay.setSpacing( 2 ); | 2019 | lay.setSpacing( 2 ); |
2020 | lay.setMargin( 3 ); | 2020 | lay.setMargin( 3 ); |
2021 | lay.addWidget(&gr); | 2021 | lay.addWidget(&gr); |
2022 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2022 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2023 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2023 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2024 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2024 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2025 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2025 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2026 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2026 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2027 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2027 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2028 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2028 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2029 | QPushButton pb ( "OK", &dia); | 2029 | QPushButton pb ( "OK", &dia); |
2030 | lay.addWidget( &pb ); | 2030 | lay.addWidget( &pb ); |
2031 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2031 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2032 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2032 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2033 | case 0: | 2033 | case 0: |
2034 | loc.setChecked( true); | 2034 | loc.setChecked( true); |
2035 | break; | 2035 | break; |
2036 | case 1: | 2036 | case 1: |
2037 | rem.setChecked( true ); | 2037 | rem.setChecked( true ); |
2038 | break; | 2038 | break; |
2039 | case 2: | 2039 | case 2: |
2040 | newest.setChecked( true); | 2040 | newest.setChecked( true); |
2041 | break; | 2041 | break; |
2042 | case 3: | 2042 | case 3: |
2043 | ask.setChecked( true); | 2043 | ask.setChecked( true); |
2044 | break; | 2044 | break; |
2045 | case 4: | 2045 | case 4: |
2046 | f_loc.setChecked( true); | 2046 | f_loc.setChecked( true); |
2047 | break; | 2047 | break; |
2048 | case 5: | 2048 | case 5: |
2049 | f_rem.setChecked( true); | 2049 | f_rem.setChecked( true); |
2050 | break; | 2050 | break; |
2051 | case 6: | 2051 | case 6: |
2052 | // both.setChecked( true); | 2052 | // both.setChecked( true); |
2053 | break; | 2053 | break; |
2054 | default: | 2054 | default: |
2055 | break; | 2055 | break; |
2056 | } | 2056 | } |
2057 | if ( dia.exec() ) { | 2057 | if ( dia.exec() ) { |
2058 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2058 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2059 | } | 2059 | } |
2060 | 2060 | ||
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void CalendarView::slotSelectPickerDate( QDate d) | 2063 | void CalendarView::slotSelectPickerDate( QDate d) |
2064 | { | 2064 | { |
2065 | mDateFrame->hide(); | 2065 | mDateFrame->hide(); |
2066 | if ( mDatePickerMode == 1 ) { | 2066 | if ( mDatePickerMode == 1 ) { |
2067 | mNavigator->slotDaySelect( d ); | 2067 | mNavigator->slotDaySelect( d ); |
2068 | } else if ( mDatePickerMode == 2 ) { | 2068 | } else if ( mDatePickerMode == 2 ) { |
2069 | if ( mMoveIncidence->type() == "Todo" ) { | 2069 | if ( mMoveIncidence->type() == "Todo" ) { |
2070 | Todo * to = (Todo *) mMoveIncidence; | 2070 | Todo * to = (Todo *) mMoveIncidence; |
2071 | QTime tim; | 2071 | QTime tim; |
2072 | if ( to->hasDueDate() ) | 2072 | if ( to->hasDueDate() ) |
2073 | tim = to->dtDue().time(); | 2073 | tim = to->dtDue().time(); |
2074 | else { | 2074 | else { |
2075 | tim = QTime ( 0,0,0 ); | 2075 | tim = QTime ( 0,0,0 ); |
2076 | to->setFloats( true ); | 2076 | to->setFloats( true ); |
2077 | to->setHasDueDate( true ); | 2077 | to->setHasDueDate( true ); |
2078 | } | 2078 | } |
2079 | QDateTime dt ( d,tim ); | 2079 | QDateTime dt ( d,tim ); |
2080 | to->setDtDue( dt ); | 2080 | to->setDtDue( dt ); |
2081 | todoChanged( to ); | 2081 | todoChanged( to ); |
2082 | } else { | 2082 | } else { |
2083 | QTime tim = mMoveIncidence->dtStart().time(); | 2083 | QTime tim = mMoveIncidence->dtStart().time(); |
2084 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2084 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2085 | QDateTime dt ( d,tim ); | 2085 | QDateTime dt ( d,tim ); |
2086 | mMoveIncidence->setDtStart( dt ); | 2086 | mMoveIncidence->setDtStart( dt ); |
2087 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2087 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2088 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2088 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2089 | } | 2089 | } |
2090 | 2090 | ||
2091 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2091 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2092 | } | 2092 | } |
2093 | } | 2093 | } |
2094 | 2094 | ||
2095 | void CalendarView::removeCategories() | 2095 | void CalendarView::removeCategories() |
2096 | { | 2096 | { |
2097 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2097 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2098 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2098 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2099 | QStringList catIncList; | 2099 | QStringList catIncList; |
2100 | QStringList newCatList; | 2100 | QStringList newCatList; |
2101 | Incidence* inc = incList.first(); | 2101 | Incidence* inc = incList.first(); |
2102 | int i; | 2102 | int i; |
2103 | int count = 0; | 2103 | int count = 0; |
2104 | while ( inc ) { | 2104 | while ( inc ) { |
2105 | newCatList.clear(); | 2105 | newCatList.clear(); |
2106 | catIncList = inc->categories() ; | 2106 | catIncList = inc->categories() ; |
2107 | for( i = 0; i< catIncList.count(); ++i ) { | 2107 | for( i = 0; i< catIncList.count(); ++i ) { |
2108 | if ( catList.contains (catIncList[i])) | 2108 | if ( catList.contains (catIncList[i])) |
2109 | newCatList.append( catIncList[i] ); | 2109 | newCatList.append( catIncList[i] ); |
2110 | } | 2110 | } |
2111 | newCatList.sort(); | 2111 | newCatList.sort(); |
2112 | inc->setCategories( newCatList.join(",") ); | 2112 | inc->setCategories( newCatList.join(",") ); |
2113 | inc = incList.next(); | 2113 | inc = incList.next(); |
2114 | } | 2114 | } |
2115 | } | 2115 | } |
2116 | 2116 | ||
2117 | int CalendarView::addCategories() | 2117 | int CalendarView::addCategories() |
2118 | { | 2118 | { |
2119 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2119 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2120 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2120 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2121 | QStringList catIncList; | 2121 | QStringList catIncList; |
2122 | Incidence* inc = incList.first(); | 2122 | Incidence* inc = incList.first(); |
2123 | int i; | 2123 | int i; |
2124 | int count = 0; | 2124 | int count = 0; |
2125 | while ( inc ) { | 2125 | while ( inc ) { |
2126 | catIncList = inc->categories() ; | 2126 | catIncList = inc->categories() ; |
2127 | for( i = 0; i< catIncList.count(); ++i ) { | 2127 | for( i = 0; i< catIncList.count(); ++i ) { |
2128 | if ( !catList.contains (catIncList[i])) { | 2128 | if ( !catList.contains (catIncList[i])) { |
2129 | catList.append( catIncList[i] ); | 2129 | catList.append( catIncList[i] ); |
2130 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2130 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2131 | ++count; | 2131 | ++count; |
2132 | } | 2132 | } |
2133 | } | 2133 | } |
2134 | inc = incList.next(); | 2134 | inc = incList.next(); |
2135 | } | 2135 | } |
2136 | catList.sort(); | 2136 | catList.sort(); |
2137 | KOPrefs::instance()->mCustomCategories = catList; | 2137 | KOPrefs::instance()->mCustomCategories = catList; |
2138 | return count; | 2138 | return count; |
2139 | } | 2139 | } |
2140 | 2140 | ||
2141 | void CalendarView::manageCategories() | 2141 | void CalendarView::manageCategories() |
2142 | { | 2142 | { |
2143 | KOCatPrefs* cp = new KOCatPrefs(); | 2143 | KOCatPrefs* cp = new KOCatPrefs(); |
2144 | cp->show(); | 2144 | cp->show(); |
2145 | int w =cp->sizeHint().width() ; | 2145 | int w =cp->sizeHint().width() ; |
2146 | int h = cp->sizeHint().height() ; | 2146 | int h = cp->sizeHint().height() ; |
2147 | int dw = QApplication::desktop()->width(); | 2147 | int dw = QApplication::desktop()->width(); |
2148 | int dh = QApplication::desktop()->height(); | 2148 | int dh = QApplication::desktop()->height(); |
2149 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2149 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2150 | if ( !cp->exec() ) { | 2150 | if ( !cp->exec() ) { |
2151 | delete cp; | 2151 | delete cp; |
2152 | return; | 2152 | return; |
2153 | } | 2153 | } |
2154 | int count = 0; | 2154 | int count = 0; |
2155 | if ( cp->addCat() ) { | 2155 | if ( cp->addCat() ) { |
2156 | count = addCategories(); | 2156 | count = addCategories(); |
2157 | if ( count ) { | 2157 | if ( count ) { |
2158 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2158 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2159 | writeSettings(); | 2159 | writeSettings(); |
2160 | } | 2160 | } |
2161 | } else { | 2161 | } else { |
2162 | removeCategories(); | 2162 | removeCategories(); |
2163 | updateView(); | 2163 | updateView(); |
2164 | } | 2164 | } |
2165 | delete cp; | 2165 | delete cp; |
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | void CalendarView::beamIncidence(Incidence * Inc) | 2168 | void CalendarView::beamIncidence(Incidence * Inc) |
2169 | { | 2169 | { |
2170 | QPtrList<Incidence> delSel ; | 2170 | QPtrList<Incidence> delSel ; |
2171 | delSel.append(Inc); | 2171 | delSel.append(Inc); |
2172 | beamIncidenceList( delSel ); | 2172 | beamIncidenceList( delSel ); |
2173 | } | 2173 | } |
2174 | void CalendarView::beamCalendar() | 2174 | void CalendarView::beamCalendar() |
2175 | { | 2175 | { |
2176 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2176 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2177 | //qDebug("beamCalendar() "); | 2177 | //qDebug("beamCalendar() "); |
2178 | beamIncidenceList( delSel ); | 2178 | beamIncidenceList( delSel ); |
2179 | } | 2179 | } |
2180 | void CalendarView::beamFilteredCalendar() | 2180 | void CalendarView::beamFilteredCalendar() |
2181 | { | 2181 | { |
2182 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2182 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2183 | //qDebug("beamFilteredCalendar() "); | 2183 | //qDebug("beamFilteredCalendar() "); |
2184 | beamIncidenceList( delSel ); | 2184 | beamIncidenceList( delSel ); |
2185 | } | 2185 | } |
2186 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2186 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2187 | { | 2187 | { |
2188 | if ( beamDialog->exec () == QDialog::Rejected ) | 2188 | if ( beamDialog->exec () == QDialog::Rejected ) |
2189 | return; | 2189 | return; |
2190 | 2190 | ||
2191 | QString fn = "/tmp/kopibeamfile"; | 2191 | QString fn = "/tmp/kopibeamfile"; |
2192 | QString mes; | 2192 | QString mes; |
2193 | bool createbup = true; | 2193 | bool createbup = true; |
2194 | if ( createbup ) { | 2194 | if ( createbup ) { |
2195 | QString description = "\n"; | 2195 | QString description = "\n"; |
2196 | CalendarLocal* cal = new CalendarLocal(); | 2196 | CalendarLocal* cal = new CalendarLocal(); |
2197 | if ( beamDialog->beamLocal() ) | 2197 | if ( beamDialog->beamLocal() ) |
2198 | cal->setLocalTime(); | 2198 | cal->setLocalTime(); |
2199 | else | 2199 | else |
2200 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2200 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2201 | Incidence *incidence = delSel.first(); | 2201 | Incidence *incidence = delSel.first(); |
2202 | bool addText = false; | 2202 | bool addText = false; |
2203 | if ( delSel.count() < 10 ) | 2203 | if ( delSel.count() < 10 ) |
2204 | addText = true; | 2204 | addText = true; |
2205 | else { | 2205 | else { |
2206 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2206 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2207 | } | 2207 | } |
2208 | while ( incidence ) { | 2208 | while ( incidence ) { |
2209 | Incidence *in = incidence->clone(); | 2209 | Incidence *in = incidence->clone(); |
2210 | if ( addText ) | 2210 | if ( addText ) |
2211 | description += in->summary() + "\n"; | 2211 | description += in->summary() + "\n"; |
2212 | cal->addIncidence( in ); | 2212 | cal->addIncidence( in ); |
2213 | incidence = delSel.next(); | 2213 | incidence = delSel.next(); |
2214 | } | 2214 | } |
2215 | if ( beamDialog->beamVcal() ) { | 2215 | if ( beamDialog->beamVcal() ) { |
2216 | fn += ".vcs"; | 2216 | fn += ".vcs"; |
2217 | FileStorage storage( cal, fn, new VCalFormat ); | 2217 | FileStorage storage( cal, fn, new VCalFormat ); |
2218 | storage.save(); | 2218 | storage.save(); |
2219 | } else { | 2219 | } else { |
2220 | fn += ".ics"; | 2220 | fn += ".ics"; |
2221 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2221 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2222 | storage.save(); | 2222 | storage.save(); |
2223 | } | 2223 | } |
2224 | delete cal; | 2224 | delete cal; |
2225 | mes = i18n("KO/Pi: Ready for beaming"); | 2225 | mes = i18n("KO/Pi: Ready for beaming"); |
2226 | setCaption(mes); | 2226 | setCaption(mes); |
2227 | 2227 | ||
2228 | #ifndef DESKTOP_VERSION | 2228 | #ifndef DESKTOP_VERSION |
2229 | Ir *ir = new Ir( this ); | 2229 | Ir *ir = new Ir( this ); |
2230 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2230 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2231 | ir->send( fn, description, "text/x-vCalendar" ); | 2231 | ir->send( fn, description, "text/x-vCalendar" ); |
2232 | #endif | 2232 | #endif |
2233 | } | 2233 | } |
2234 | } | 2234 | } |
2235 | void CalendarView::beamDone( Ir *ir ) | 2235 | void CalendarView::beamDone( Ir *ir ) |
2236 | { | 2236 | { |
2237 | #ifndef DESKTOP_VERSION | 2237 | #ifndef DESKTOP_VERSION |
2238 | delete ir; | 2238 | delete ir; |
2239 | #endif | 2239 | #endif |
2240 | } | 2240 | } |
2241 | 2241 | ||
2242 | void CalendarView::moveIncidence(Incidence * inc ) | 2242 | void CalendarView::moveIncidence(Incidence * inc ) |
2243 | { | 2243 | { |
2244 | if ( !inc ) return; | 2244 | if ( !inc ) return; |
2245 | // qDebug("showDatePickerForIncidence( ) "); | 2245 | // qDebug("showDatePickerForIncidence( ) "); |
2246 | if ( mDateFrame->isVisible() ) | 2246 | if ( mDateFrame->isVisible() ) |
2247 | mDateFrame->hide(); | 2247 | mDateFrame->hide(); |
2248 | else { | 2248 | else { |
2249 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2249 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2250 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2250 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2251 | int dw = QApplication::desktop()->width(); | 2251 | int dw = QApplication::desktop()->width(); |
2252 | int dh = QApplication::desktop()->height(); | 2252 | int dh = QApplication::desktop()->height(); |
2253 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2253 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2254 | mDateFrame->show(); | 2254 | mDateFrame->show(); |
2255 | } | 2255 | } |
2256 | mDatePickerMode = 2; | 2256 | mDatePickerMode = 2; |
2257 | mMoveIncidence = inc ; | 2257 | mMoveIncidence = inc ; |
2258 | QDate da; | 2258 | QDate da; |
2259 | if ( mMoveIncidence->type() == "Todo" ) { | 2259 | if ( mMoveIncidence->type() == "Todo" ) { |
2260 | Todo * to = (Todo *) mMoveIncidence; | 2260 | Todo * to = (Todo *) mMoveIncidence; |
2261 | if ( to->hasDueDate() ) | 2261 | if ( to->hasDueDate() ) |
2262 | da = to->dtDue().date(); | 2262 | da = to->dtDue().date(); |
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro index 9fdcd2f..543db86 100644 --- a/korganizer/korganizer.pro +++ b/korganizer/korganizer.pro | |||
@@ -1,193 +1,192 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | TARGET = kopi | 3 | TARGET = kopi |
4 | OBJECTS_DIR = _obj/ | 4 | OBJECTS_DIR = _obj/ |
5 | MOC_DIR = _moc | 5 | MOC_DIR = _moc |
6 | DESTDIR= ../bin | 6 | DESTDIR= ../bin |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim | 10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim |
11 | #../qtcompat | 11 | #../qtcompat |
12 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL | 12 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL |
13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER | 13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER |
14 | #KORG_NOPRINTER KORG_NOKABC | 14 | #KORG_NOPRINTER KORG_NOKABC |
15 | DEFINES += KORG_NOLVALTERNATION | 15 | DEFINES += KORG_NOLVALTERNATION |
16 | DEFINES += DESKTOP_VERSION | 16 | DEFINES += DESKTOP_VERSION |
17 | unix : { | 17 | unix : { |
18 | LIBS += ../bin/libmicrokdepim.so | 18 | LIBS += ../bin/libmicrokdepim.so |
19 | LIBS += ../bin/libmicrokcal.so | 19 | LIBS += ../bin/libmicrokcal.so |
20 | LIBS += ../bin/libmicrokde.so | 20 | LIBS += ../bin/libmicrokde.so |
21 | LIBS += ../bin/libmicrokabc.so | 21 | LIBS += ../bin/libmicrokabc.so |
22 | LIBS += ../bin/libmicrogammu.so | ||
23 | LIBS += -lbluetooth | 22 | LIBS += -lbluetooth |
24 | LIBS += -lsdp | 23 | LIBS += -lsdp |
25 | 24 | ||
26 | LIBS += -lldap | 25 | LIBS += -lldap |
27 | OBJECTS_DIR = obj/unix | 26 | OBJECTS_DIR = obj/unix |
28 | MOC_DIR = moc/unix | 27 | MOC_DIR = moc/unix |
29 | } | 28 | } |
30 | win32: { | 29 | win32: { |
31 | DEFINES += _WIN32_ | 30 | DEFINES += _WIN32_ |
32 | LIBS += ../bin/microkdepim.lib | 31 | LIBS += ../bin/microkdepim.lib |
33 | LIBS += ../bin/microkcal.lib | 32 | LIBS += ../bin/microkcal.lib |
34 | LIBS += ../bin/microkde.lib | 33 | LIBS += ../bin/microkde.lib |
35 | LIBS += ../bin/microkabc.lib | 34 | LIBS += ../bin/microkabc.lib |
36 | LIBS += ../libical/lib/ical.lib | 35 | LIBS += ../libical/lib/ical.lib |
37 | LIBS += ../libical/lib/icalss.lib | 36 | LIBS += ../libical/lib/icalss.lib |
38 | #LIBS += atls.lib | 37 | #LIBS += atls.lib |
39 | LIBS += mfc71u.lib | 38 | LIBS += mfc71u.lib |
40 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 39 | QMAKE_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 |
43 | OBJECTS_DIR = obj/win | 42 | OBJECTS_DIR = obj/win |
44 | MOC_DIR = moc/win | 43 | MOC_DIR = moc/win |
45 | } | 44 | } |
46 | 45 | ||
47 | 46 | ||
48 | INTERFACES = kofilterview_base.ui | 47 | INTERFACES = kofilterview_base.ui |
49 | # filteredit_base.ui | 48 | # filteredit_base.ui |
50 | 49 | ||
51 | # kdateedit.h \ | 50 | # kdateedit.h \ |
52 | 51 | ||
53 | HEADERS = \ | 52 | HEADERS = \ |
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 \ |
71 | kodaymatrix.h \ | 70 | kodaymatrix.h \ |
72 | kodialogmanager.h \ | 71 | kodialogmanager.h \ |
73 | koeditordetails.h \ | 72 | koeditordetails.h \ |
74 | koeditorgeneral.h \ | 73 | koeditorgeneral.h \ |
75 | koeditorgeneralevent.h \ | 74 | koeditorgeneralevent.h \ |
76 | koeditorgeneraltodo.h \ | 75 | koeditorgeneraltodo.h \ |
77 | koeditorrecurrence.h \ | 76 | koeditorrecurrence.h \ |
78 | koeventeditor.h \ | 77 | koeventeditor.h \ |
79 | koeventpopupmenu.h \ | 78 | koeventpopupmenu.h \ |
80 | koeventview.h \ | 79 | koeventview.h \ |
81 | koeventviewer.h \ | 80 | koeventviewer.h \ |
82 | koeventviewerdialog.h \ | 81 | koeventviewerdialog.h \ |
83 | kofilterview.h \ | 82 | kofilterview.h \ |
84 | koglobals.h \ | 83 | koglobals.h \ |
85 | koincidenceeditor.h \ | 84 | koincidenceeditor.h \ |
86 | kojournalview.h \ | 85 | kojournalview.h \ |
87 | kolistview.h \ | 86 | kolistview.h \ |
88 | kolocationbox.h \ | 87 | kolocationbox.h \ |
89 | komonthview.h \ | 88 | komonthview.h \ |
90 | koprefs.h \ | 89 | koprefs.h \ |
91 | koprefsdialog.h \ | 90 | koprefsdialog.h \ |
92 | kotimespanview.h \ | 91 | kotimespanview.h \ |
93 | kotodoeditor.h \ | 92 | kotodoeditor.h \ |
94 | kotodoview.h \ | 93 | kotodoview.h \ |
95 | kotodoviewitem.h \ | 94 | kotodoviewitem.h \ |
96 | koviewmanager.h \ | 95 | koviewmanager.h \ |
97 | kowhatsnextview.h \ | 96 | kowhatsnextview.h \ |
98 | ktimeedit.h \ | 97 | ktimeedit.h \ |
99 | lineview.h \ | 98 | lineview.h \ |
100 | mainwindow.h \ | 99 | mainwindow.h \ |
101 | navigatorbar.h \ | 100 | navigatorbar.h \ |
102 | outgoingdialog.h \ | 101 | outgoingdialog.h \ |
103 | outgoingdialog_base.h \ | 102 | outgoingdialog_base.h \ |
104 | publishdialog.h \ | 103 | publishdialog.h \ |
105 | publishdialog_base.h \ | 104 | publishdialog_base.h \ |
106 | savetemplatedialog.h \ | 105 | savetemplatedialog.h \ |
107 | searchdialog.h \ | 106 | searchdialog.h \ |
108 | simplealarmclient.h \ | 107 | simplealarmclient.h \ |
109 | statusdialog.h \ | 108 | statusdialog.h \ |
110 | timeline.h \ | 109 | timeline.h \ |
111 | timespanview.h \ | 110 | timespanview.h \ |
112 | version.h \ | 111 | version.h \ |
113 | ../kalarmd/alarmdialog.h \ | 112 | ../kalarmd/alarmdialog.h \ |
114 | 113 | ||
115 | 114 | ||
116 | SOURCES = \ | 115 | SOURCES = \ |
117 | filteredit_base.cpp \ | 116 | filteredit_base.cpp \ |
118 | calendarview.cpp \ | 117 | calendarview.cpp \ |
119 | datenavigator.cpp \ | 118 | datenavigator.cpp \ |
120 | docprefs.cpp \ | 119 | docprefs.cpp \ |
121 | filtereditdialog.cpp \ | 120 | filtereditdialog.cpp \ |
122 | incomingdialog.cpp \ | 121 | incomingdialog.cpp \ |
123 | incomingdialog_base.cpp \ | 122 | incomingdialog_base.cpp \ |
124 | journalentry.cpp \ | 123 | journalentry.cpp \ |
125 | kdatenavigator.cpp \ | 124 | kdatenavigator.cpp \ |
126 | koagenda.cpp \ | 125 | koagenda.cpp \ |
127 | koagendaitem.cpp \ | 126 | koagendaitem.cpp \ |
128 | koagendaview.cpp \ | 127 | koagendaview.cpp \ |
129 | kocounterdialog.cpp \ | 128 | kocounterdialog.cpp \ |
130 | kodaymatrix.cpp \ | 129 | kodaymatrix.cpp \ |
131 | kodialogmanager.cpp \ | 130 | kodialogmanager.cpp \ |
132 | koeditordetails.cpp \ | 131 | koeditordetails.cpp \ |
133 | koeditorgeneral.cpp \ | 132 | koeditorgeneral.cpp \ |
134 | koeditorgeneralevent.cpp \ | 133 | koeditorgeneralevent.cpp \ |
135 | koeditorgeneraltodo.cpp \ | 134 | koeditorgeneraltodo.cpp \ |
136 | koeditorrecurrence.cpp \ | 135 | koeditorrecurrence.cpp \ |
137 | koeventeditor.cpp \ | 136 | koeventeditor.cpp \ |
138 | koeventpopupmenu.cpp \ | 137 | koeventpopupmenu.cpp \ |
139 | koeventview.cpp \ | 138 | koeventview.cpp \ |
140 | koeventviewer.cpp \ | 139 | koeventviewer.cpp \ |
141 | koeventviewerdialog.cpp \ | 140 | koeventviewerdialog.cpp \ |
142 | kofilterview.cpp \ | 141 | kofilterview.cpp \ |
143 | koglobals.cpp \ | 142 | koglobals.cpp \ |
144 | koincidenceeditor.cpp \ | 143 | koincidenceeditor.cpp \ |
145 | kojournalview.cpp \ | 144 | kojournalview.cpp \ |
146 | kolistview.cpp \ | 145 | kolistview.cpp \ |
147 | kolocationbox.cpp \ | 146 | kolocationbox.cpp \ |
148 | komonthview.cpp \ | 147 | komonthview.cpp \ |
149 | koprefs.cpp \ | 148 | koprefs.cpp \ |
150 | koprefsdialog.cpp \ | 149 | koprefsdialog.cpp \ |
151 | kotimespanview.cpp \ | 150 | kotimespanview.cpp \ |
152 | kotodoeditor.cpp \ | 151 | kotodoeditor.cpp \ |
153 | kotodoview.cpp \ | 152 | kotodoview.cpp \ |
154 | kotodoviewitem.cpp \ | 153 | kotodoviewitem.cpp \ |
155 | koviewmanager.cpp \ | 154 | koviewmanager.cpp \ |
156 | kowhatsnextview.cpp \ | 155 | kowhatsnextview.cpp \ |
157 | ktimeedit.cpp \ | 156 | ktimeedit.cpp \ |
158 | lineview.cpp \ | 157 | lineview.cpp \ |
159 | main.cpp \ | 158 | main.cpp \ |
160 | mainwindow.cpp \ | 159 | mainwindow.cpp \ |
161 | navigatorbar.cpp \ | 160 | navigatorbar.cpp \ |
162 | outgoingdialog.cpp \ | 161 | outgoingdialog.cpp \ |
163 | outgoingdialog_base.cpp \ | 162 | outgoingdialog_base.cpp \ |
164 | publishdialog.cpp \ | 163 | publishdialog.cpp \ |
165 | publishdialog_base.cpp \ | 164 | publishdialog_base.cpp \ |
166 | savetemplatedialog.cpp \ | 165 | savetemplatedialog.cpp \ |
167 | searchdialog.cpp \ | 166 | searchdialog.cpp \ |
168 | simplealarmclient.cpp \ | 167 | simplealarmclient.cpp \ |
169 | statusdialog.cpp \ | 168 | statusdialog.cpp \ |
170 | timeline.cpp \ | 169 | timeline.cpp \ |
171 | timespanview.cpp \ | 170 | timespanview.cpp \ |
172 | ../kalarmd/alarmdialog.cpp | 171 | ../kalarmd/alarmdialog.cpp |
173 | 172 | ||
174 | HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h | 173 | HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h |
175 | INTERFACES += calprintdayconfig_base.ui \ | 174 | INTERFACES += calprintdayconfig_base.ui \ |
176 | calprintmonthconfig_base.ui \ | 175 | calprintmonthconfig_base.ui \ |
177 | calprinttodoconfig_base.ui \ | 176 | calprinttodoconfig_base.ui \ |
178 | calprintweekconfig_base.ui | 177 | calprintweekconfig_base.ui |
179 | SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp | 178 | SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp |
180 | 179 | ||
181 | 180 | ||
182 | 181 | ||
183 | win32: { | 182 | win32: { |
184 | HEADERS += ../outport/msoutl9.h \ | 183 | HEADERS += ../outport/msoutl9.h \ |
185 | koimportoldialog.h | 184 | koimportoldialog.h |
186 | 185 | ||
187 | 186 | ||
188 | SOURCES += ../outport/msoutl9.cpp \ | 187 | SOURCES += ../outport/msoutl9.cpp \ |
189 | koimportoldialog.cpp | 188 | koimportoldialog.cpp |
190 | 189 | ||
191 | 190 | ||
192 | } | 191 | } |
193 | 192 | ||
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index d9bda64..56c9801 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -153,442 +153,447 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | |||
153 | } else { | 153 | } else { |
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
157 | qDebug("recurrence is NOT equal "); | 157 | qDebug("recurrence is NOT equal "); |
158 | return false; | 158 | return false; |
159 | } | 159 | } |
160 | return | 160 | return |
161 | // i1.created() == i2.created() && | 161 | // i1.created() == i2.created() && |
162 | stringCompare( i1.description(), i2.description() ) && | 162 | stringCompare( i1.description(), i2.description() ) && |
163 | stringCompare( i1.summary(), i2.summary() ) && | 163 | stringCompare( i1.summary(), i2.summary() ) && |
164 | i1.categories() == i2.categories() && | 164 | i1.categories() == i2.categories() && |
165 | // no need to compare mRelatedTo | 165 | // no need to compare mRelatedTo |
166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
167 | // i1.relations() == i2.relations() && | 167 | // i1.relations() == i2.relations() && |
168 | i1.exDates() == i2.exDates() && | 168 | i1.exDates() == i2.exDates() && |
169 | i1.attachments() == i2.attachments() && | 169 | i1.attachments() == i2.attachments() && |
170 | i1.resources() == i2.resources() && | 170 | i1.resources() == i2.resources() && |
171 | i1.secrecy() == i2.secrecy() && | 171 | i1.secrecy() == i2.secrecy() && |
172 | i1.priority() == i2.priority() && | 172 | i1.priority() == i2.priority() && |
173 | stringCompare( i1.location(), i2.location() ); | 173 | stringCompare( i1.location(), i2.location() ); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void Incidence::recreate() | 177 | void Incidence::recreate() |
178 | { | 178 | { |
179 | setCreated(QDateTime::currentDateTime()); | 179 | setCreated(QDateTime::currentDateTime()); |
180 | 180 | ||
181 | setUid(CalFormat::createUniqueId()); | 181 | setUid(CalFormat::createUniqueId()); |
182 | 182 | ||
183 | setRevision(0); | 183 | setRevision(0); |
184 | 184 | ||
185 | setLastModified(QDateTime::currentDateTime()); | 185 | setLastModified(QDateTime::currentDateTime()); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Incidence::setReadOnly( bool readOnly ) | 188 | void Incidence::setReadOnly( bool readOnly ) |
189 | { | 189 | { |
190 | IncidenceBase::setReadOnly( readOnly ); | 190 | IncidenceBase::setReadOnly( readOnly ); |
191 | recurrence()->setRecurReadOnly( readOnly); | 191 | recurrence()->setRecurReadOnly( readOnly); |
192 | } | 192 | } |
193 | 193 | ||
194 | void Incidence::setCreated(QDateTime created) | 194 | void Incidence::setCreated(QDateTime created) |
195 | { | 195 | { |
196 | if (mReadOnly) return; | 196 | if (mReadOnly) return; |
197 | mCreated = getEvenTime(created); | 197 | mCreated = getEvenTime(created); |
198 | } | 198 | } |
199 | 199 | ||
200 | QDateTime Incidence::created() const | 200 | QDateTime Incidence::created() const |
201 | { | 201 | { |
202 | return mCreated; | 202 | return mCreated; |
203 | } | 203 | } |
204 | 204 | ||
205 | void Incidence::setRevision(int rev) | 205 | void Incidence::setRevision(int rev) |
206 | { | 206 | { |
207 | if (mReadOnly) return; | 207 | if (mReadOnly) return; |
208 | mRevision = rev; | 208 | mRevision = rev; |
209 | 209 | ||
210 | updated(); | 210 | updated(); |
211 | } | 211 | } |
212 | 212 | ||
213 | int Incidence::revision() const | 213 | int Incidence::revision() const |
214 | { | 214 | { |
215 | return mRevision; | 215 | return mRevision; |
216 | } | 216 | } |
217 | 217 | ||
218 | void Incidence::setDtStart(const QDateTime &dtStart) | 218 | void Incidence::setDtStart(const QDateTime &dtStart) |
219 | { | 219 | { |
220 | 220 | ||
221 | QDateTime dt = getEvenTime(dtStart); | 221 | QDateTime dt = getEvenTime(dtStart); |
222 | recurrence()->setRecurStart( dt); | 222 | recurrence()->setRecurStart( dt); |
223 | IncidenceBase::setDtStart( dt ); | 223 | IncidenceBase::setDtStart( dt ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void Incidence::setDescription(const QString &description) | 226 | void Incidence::setDescription(const QString &description) |
227 | { | 227 | { |
228 | if (mReadOnly) return; | 228 | if (mReadOnly) return; |
229 | mDescription = description; | 229 | mDescription = description; |
230 | updated(); | 230 | updated(); |
231 | } | 231 | } |
232 | 232 | ||
233 | QString Incidence::description() const | 233 | QString Incidence::description() const |
234 | { | 234 | { |
235 | return mDescription; | 235 | return mDescription; |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void Incidence::setSummary(const QString &summary) | 239 | void Incidence::setSummary(const QString &summary) |
240 | { | 240 | { |
241 | if (mReadOnly) return; | 241 | if (mReadOnly) return; |
242 | mSummary = summary; | 242 | mSummary = summary; |
243 | updated(); | 243 | updated(); |
244 | } | 244 | } |
245 | 245 | ||
246 | QString Incidence::summary() const | 246 | QString Incidence::summary() const |
247 | { | 247 | { |
248 | return mSummary; | 248 | return mSummary; |
249 | } | 249 | } |
250 | 250 | ||
251 | void Incidence::setCategories(const QStringList &categories) | 251 | void Incidence::setCategories(const QStringList &categories) |
252 | { | 252 | { |
253 | if (mReadOnly) return; | 253 | if (mReadOnly) return; |
254 | mCategories = categories; | 254 | mCategories = categories; |
255 | updated(); | 255 | updated(); |
256 | } | 256 | } |
257 | 257 | ||
258 | // TODO: remove setCategories(QString) function | 258 | // TODO: remove setCategories(QString) function |
259 | void Incidence::setCategories(const QString &catStr) | 259 | void Incidence::setCategories(const QString &catStr) |
260 | { | 260 | { |
261 | if (mReadOnly) return; | 261 | if (mReadOnly) return; |
262 | mCategories.clear(); | 262 | mCategories.clear(); |
263 | 263 | ||
264 | if (catStr.isEmpty()) return; | 264 | if (catStr.isEmpty()) return; |
265 | 265 | ||
266 | mCategories = QStringList::split(",",catStr); | 266 | mCategories = QStringList::split(",",catStr); |
267 | 267 | ||
268 | QStringList::Iterator it; | 268 | QStringList::Iterator it; |
269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
270 | *it = (*it).stripWhiteSpace(); | 270 | *it = (*it).stripWhiteSpace(); |
271 | } | 271 | } |
272 | 272 | ||
273 | updated(); | 273 | updated(); |
274 | } | 274 | } |
275 | 275 | ||
276 | QStringList Incidence::categories() const | 276 | QStringList Incidence::categories() const |
277 | { | 277 | { |
278 | return mCategories; | 278 | return mCategories; |
279 | } | 279 | } |
280 | 280 | ||
281 | QString Incidence::categoriesStr() | 281 | QString Incidence::categoriesStr() |
282 | { | 282 | { |
283 | return mCategories.join(","); | 283 | return mCategories.join(","); |
284 | } | 284 | } |
285 | 285 | ||
286 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 286 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
287 | { | 287 | { |
288 | if (mReadOnly) return; | 288 | if (mReadOnly) return; |
289 | mRelatedToUid = relatedToUid; | 289 | mRelatedToUid = relatedToUid; |
290 | } | 290 | } |
291 | 291 | ||
292 | QString Incidence::relatedToUid() const | 292 | QString Incidence::relatedToUid() const |
293 | { | 293 | { |
294 | return mRelatedToUid; | 294 | return mRelatedToUid; |
295 | } | 295 | } |
296 | 296 | ||
297 | void Incidence::setRelatedTo(Incidence *relatedTo) | 297 | void Incidence::setRelatedTo(Incidence *relatedTo) |
298 | { | 298 | { |
299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
301 | if (mReadOnly || mRelatedTo == relatedTo) return; | 301 | if (mReadOnly || mRelatedTo == relatedTo) return; |
302 | if(mRelatedTo) { | 302 | if(mRelatedTo) { |
303 | // updated(); | 303 | // updated(); |
304 | mRelatedTo->removeRelation(this); | 304 | mRelatedTo->removeRelation(this); |
305 | } | 305 | } |
306 | mRelatedTo = relatedTo; | 306 | mRelatedTo = relatedTo; |
307 | if (mRelatedTo) mRelatedTo->addRelation(this); | 307 | if (mRelatedTo) mRelatedTo->addRelation(this); |
308 | } | 308 | } |
309 | 309 | ||
310 | Incidence *Incidence::relatedTo() const | 310 | Incidence *Incidence::relatedTo() const |
311 | { | 311 | { |
312 | return mRelatedTo; | 312 | return mRelatedTo; |
313 | } | 313 | } |
314 | 314 | ||
315 | QPtrList<Incidence> Incidence::relations() const | 315 | QPtrList<Incidence> Incidence::relations() const |
316 | { | 316 | { |
317 | return mRelations; | 317 | return mRelations; |
318 | } | 318 | } |
319 | 319 | ||
320 | void Incidence::addRelation(Incidence *event) | 320 | void Incidence::addRelation(Incidence *event) |
321 | { | 321 | { |
322 | if( mRelations.findRef( event ) == -1 ) { | 322 | if( mRelations.findRef( event ) == -1 ) { |
323 | mRelations.append(event); | 323 | mRelations.append(event); |
324 | //updated(); | 324 | //updated(); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | void Incidence::removeRelation(Incidence *event) | 328 | void Incidence::removeRelation(Incidence *event) |
329 | { | 329 | { |
330 | 330 | ||
331 | mRelations.removeRef(event); | 331 | mRelations.removeRef(event); |
332 | 332 | ||
333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
334 | } | 334 | } |
335 | 335 | ||
336 | bool Incidence::recursOn(const QDate &qd) const | 336 | bool Incidence::recursOn(const QDate &qd) const |
337 | { | 337 | { |
338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
339 | else return false; | 339 | else return false; |
340 | } | 340 | } |
341 | 341 | ||
342 | void Incidence::setExDates(const DateList &exDates) | 342 | void Incidence::setExDates(const DateList &exDates) |
343 | { | 343 | { |
344 | if (mReadOnly) return; | 344 | if (mReadOnly) return; |
345 | mExDates = exDates; | 345 | mExDates = exDates; |
346 | 346 | ||
347 | recurrence()->setRecurExDatesCount(mExDates.count()); | 347 | recurrence()->setRecurExDatesCount(mExDates.count()); |
348 | 348 | ||
349 | updated(); | 349 | updated(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void Incidence::addExDate(const QDate &date) | 352 | void Incidence::addExDate(const QDate &date) |
353 | { | 353 | { |
354 | if (mReadOnly) return; | 354 | if (mReadOnly) return; |
355 | mExDates.append(date); | 355 | mExDates.append(date); |
356 | 356 | ||
357 | recurrence()->setRecurExDatesCount(mExDates.count()); | 357 | recurrence()->setRecurExDatesCount(mExDates.count()); |
358 | 358 | ||
359 | updated(); | 359 | updated(); |
360 | } | 360 | } |
361 | 361 | ||
362 | DateList Incidence::exDates() const | 362 | DateList Incidence::exDates() const |
363 | { | 363 | { |
364 | return mExDates; | 364 | return mExDates; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool Incidence::isException(const QDate &date) const | 367 | bool Incidence::isException(const QDate &date) const |
368 | { | 368 | { |
369 | DateList::ConstIterator it; | 369 | DateList::ConstIterator it; |
370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
371 | if ( (*it) == date ) { | 371 | if ( (*it) == date ) { |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | 378 | ||
379 | void Incidence::addAttachment(Attachment *attachment) | 379 | void Incidence::addAttachment(Attachment *attachment) |
380 | { | 380 | { |
381 | if (mReadOnly || !attachment) return; | 381 | if (mReadOnly || !attachment) return; |
382 | mAttachments.append(attachment); | 382 | mAttachments.append(attachment); |
383 | updated(); | 383 | updated(); |
384 | } | 384 | } |
385 | 385 | ||
386 | void Incidence::deleteAttachment(Attachment *attachment) | 386 | void Incidence::deleteAttachment(Attachment *attachment) |
387 | { | 387 | { |
388 | mAttachments.removeRef(attachment); | 388 | mAttachments.removeRef(attachment); |
389 | } | 389 | } |
390 | 390 | ||
391 | void Incidence::deleteAttachments(const QString& mime) | 391 | void Incidence::deleteAttachments(const QString& mime) |
392 | { | 392 | { |
393 | Attachment *at = mAttachments.first(); | 393 | Attachment *at = mAttachments.first(); |
394 | while (at) { | 394 | while (at) { |
395 | if (at->mimeType() == mime) | 395 | if (at->mimeType() == mime) |
396 | mAttachments.remove(); | 396 | mAttachments.remove(); |
397 | else | 397 | else |
398 | at = mAttachments.next(); | 398 | at = mAttachments.next(); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | QPtrList<Attachment> Incidence::attachments() const | 402 | QPtrList<Attachment> Incidence::attachments() const |
403 | { | 403 | { |
404 | return mAttachments; | 404 | return mAttachments; |
405 | } | 405 | } |
406 | 406 | ||
407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
408 | { | 408 | { |
409 | QPtrList<Attachment> attachments; | 409 | QPtrList<Attachment> attachments; |
410 | QPtrListIterator<Attachment> it( mAttachments ); | 410 | QPtrListIterator<Attachment> it( mAttachments ); |
411 | Attachment *at; | 411 | Attachment *at; |
412 | while ( (at = it.current()) ) { | 412 | while ( (at = it.current()) ) { |
413 | if (at->mimeType() == mime) | 413 | if (at->mimeType() == mime) |
414 | attachments.append(at); | 414 | attachments.append(at); |
415 | ++it; | 415 | ++it; |
416 | } | 416 | } |
417 | 417 | ||
418 | return attachments; | 418 | return attachments; |
419 | } | 419 | } |
420 | 420 | ||
421 | void Incidence::setResources(const QStringList &resources) | 421 | void Incidence::setResources(const QStringList &resources) |
422 | { | 422 | { |
423 | if (mReadOnly) return; | 423 | if (mReadOnly) return; |
424 | mResources = resources; | 424 | mResources = resources; |
425 | updated(); | 425 | updated(); |
426 | } | 426 | } |
427 | 427 | ||
428 | QStringList Incidence::resources() const | 428 | QStringList Incidence::resources() const |
429 | { | 429 | { |
430 | return mResources; | 430 | return mResources; |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | void Incidence::setPriority(int priority) | 434 | void Incidence::setPriority(int priority) |
435 | { | 435 | { |
436 | if (mReadOnly) return; | 436 | if (mReadOnly) return; |
437 | mPriority = priority; | 437 | mPriority = priority; |
438 | updated(); | 438 | updated(); |
439 | } | 439 | } |
440 | 440 | ||
441 | int Incidence::priority() const | 441 | int Incidence::priority() const |
442 | { | 442 | { |
443 | return mPriority; | 443 | return mPriority; |
444 | } | 444 | } |
445 | 445 | ||
446 | void Incidence::setSecrecy(int sec) | 446 | void Incidence::setSecrecy(int sec) |
447 | { | 447 | { |
448 | if (mReadOnly) return; | 448 | if (mReadOnly) return; |
449 | mSecrecy = sec; | 449 | mSecrecy = sec; |
450 | updated(); | 450 | updated(); |
451 | } | 451 | } |
452 | 452 | ||
453 | int Incidence::secrecy() const | 453 | int Incidence::secrecy() const |
454 | { | 454 | { |
455 | return mSecrecy; | 455 | return mSecrecy; |
456 | } | 456 | } |
457 | 457 | ||
458 | QString Incidence::secrecyStr() const | 458 | QString Incidence::secrecyStr() const |
459 | { | 459 | { |
460 | return secrecyName(mSecrecy); | 460 | return secrecyName(mSecrecy); |
461 | } | 461 | } |
462 | 462 | ||
463 | QString Incidence::secrecyName(int secrecy) | 463 | QString Incidence::secrecyName(int secrecy) |
464 | { | 464 | { |
465 | switch (secrecy) { | 465 | switch (secrecy) { |
466 | case SecrecyPublic: | 466 | case SecrecyPublic: |
467 | return i18n("Public"); | 467 | return i18n("Public"); |
468 | break; | 468 | break; |
469 | case SecrecyPrivate: | 469 | case SecrecyPrivate: |
470 | return i18n("Private"); | 470 | return i18n("Private"); |
471 | break; | 471 | break; |
472 | case SecrecyConfidential: | 472 | case SecrecyConfidential: |
473 | return i18n("Confidential"); | 473 | return i18n("Confidential"); |
474 | break; | 474 | break; |
475 | default: | 475 | default: |
476 | return i18n("Undefined"); | 476 | return i18n("Undefined"); |
477 | break; | 477 | break; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | QStringList Incidence::secrecyList() | 481 | QStringList Incidence::secrecyList() |
482 | { | 482 | { |
483 | QStringList list; | 483 | QStringList list; |
484 | list << secrecyName(SecrecyPublic); | 484 | list << secrecyName(SecrecyPublic); |
485 | list << secrecyName(SecrecyPrivate); | 485 | list << secrecyName(SecrecyPrivate); |
486 | list << secrecyName(SecrecyConfidential); | 486 | list << secrecyName(SecrecyConfidential); |
487 | 487 | ||
488 | return list; | 488 | return list; |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | QPtrList<Alarm> Incidence::alarms() const | 492 | QPtrList<Alarm> Incidence::alarms() const |
493 | { | 493 | { |
494 | return mAlarms; | 494 | return mAlarms; |
495 | } | 495 | } |
496 | 496 | ||
497 | Alarm* Incidence::newAlarm() | 497 | Alarm* 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 | ||
505 | void Incidence::addAlarm(Alarm *alarm) | 505 | void Incidence::addAlarm(Alarm *alarm) |
506 | { | 506 | { |
507 | mAlarms.append(alarm); | 507 | mAlarms.append(alarm); |
508 | updated(); | 508 | updated(); |
509 | } | 509 | } |
510 | 510 | ||
511 | void Incidence::removeAlarm(Alarm *alarm) | 511 | void Incidence::removeAlarm(Alarm *alarm) |
512 | { | 512 | { |
513 | mAlarms.removeRef(alarm); | 513 | mAlarms.removeRef(alarm); |
514 | updated(); | 514 | updated(); |
515 | } | 515 | } |
516 | 516 | ||
517 | void Incidence::clearAlarms() | 517 | void Incidence::clearAlarms() |
518 | { | 518 | { |
519 | mAlarms.clear(); | 519 | mAlarms.clear(); |
520 | updated(); | 520 | updated(); |
521 | } | 521 | } |
522 | 522 | ||
523 | bool Incidence::isAlarmEnabled() const | 523 | bool 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 | ||
533 | Recurrence *Incidence::recurrence() const | 533 | Recurrence *Incidence::recurrence() const |
534 | { | 534 | { |
535 | return mRecurrence; | 535 | return mRecurrence; |
536 | } | 536 | } |
537 | void Incidence::setRecurrence( Recurrence * r) | ||
538 | { | ||
539 | delete mRecurrence; | ||
540 | mRecurrence = r; | ||
541 | } | ||
537 | 542 | ||
538 | void Incidence::setLocation(const QString &location) | 543 | void 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 | ||
545 | QString Incidence::location() const | 550 | QString Incidence::location() const |
546 | { | 551 | { |
547 | return mLocation; | 552 | return mLocation; |
548 | } | 553 | } |
549 | 554 | ||
550 | ushort Incidence::doesRecur() const | 555 | ushort 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 | ||
556 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 561 | QDateTime 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 | } |
585 | } else { | 590 | } else { |
586 | if ( hasStartDate () ) { | 591 | if ( hasStartDate () ) { |
587 | incidenceStart = dtStart(); | 592 | incidenceStart = dtStart(); |
588 | 593 | ||
589 | } | 594 | } |
590 | } | 595 | } |
591 | if ( incidenceStart > dt ) | 596 | if ( incidenceStart > dt ) |
592 | *ok = true; | 597 | *ok = true; |
593 | return incidenceStart; | 598 | return incidenceStart; |
594 | } | 599 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index d1972cb..7dc6f10 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -1,298 +1,298 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | 115 | ||
116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; |
117 | void setReadOnly( bool ); | 117 | void setReadOnly( bool ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Recreate event. The event is made a new unique event, but already stored | 120 | Recreate event. The event is made a new unique event, but already stored |
121 | event information is preserved. Sets uniquie id, creation date, last | 121 | event information is preserved. Sets uniquie id, creation date, last |
122 | modification date and revision number. | 122 | modification date and revision number. |
123 | */ | 123 | */ |
124 | void recreate(); | 124 | void recreate(); |
125 | 125 | ||
126 | /** set creation date */ | 126 | /** set creation date */ |
127 | void setCreated(QDateTime); | 127 | void setCreated(QDateTime); |
128 | /** return time and date of creation. */ | 128 | /** return time and date of creation. */ |
129 | QDateTime created() const; | 129 | QDateTime created() const; |
130 | 130 | ||
131 | /** set the number of revisions this event has seen */ | 131 | /** set the number of revisions this event has seen */ |
132 | void setRevision(int rev); | 132 | void setRevision(int rev); |
133 | /** return the number of revisions this event has seen */ | 133 | /** return the number of revisions this event has seen */ |
134 | int revision() const; | 134 | int revision() const; |
135 | 135 | ||
136 | /** Set starting date/time. */ | 136 | /** Set starting date/time. */ |
137 | virtual void setDtStart(const QDateTime &dtStart); | 137 | virtual void setDtStart(const QDateTime &dtStart); |
138 | /** Return the incidence's ending date/time as a QDateTime. */ | 138 | /** Return the incidence's ending date/time as a QDateTime. */ |
139 | virtual QDateTime dtEnd() const { return QDateTime(); } | 139 | virtual QDateTime dtEnd() const { return QDateTime(); } |
140 | 140 | ||
141 | /** sets the event's lengthy description. */ | 141 | /** sets the event's lengthy description. */ |
142 | void setDescription(const QString &description); | 142 | void setDescription(const QString &description); |
143 | /** returns a reference to the event's description. */ | 143 | /** returns a reference to the event's description. */ |
144 | QString description() const; | 144 | QString description() const; |
145 | 145 | ||
146 | /** sets the event's short summary. */ | 146 | /** sets the event's short summary. */ |
147 | void setSummary(const QString &summary); | 147 | void setSummary(const QString &summary); |
148 | /** returns a reference to the event's summary. */ | 148 | /** returns a reference to the event's summary. */ |
149 | QString summary() const; | 149 | QString summary() const; |
150 | 150 | ||
151 | /** set event's applicable categories */ | 151 | /** set event's applicable categories */ |
152 | void setCategories(const QStringList &categories); | 152 | void setCategories(const QStringList &categories); |
153 | /** set event's categories based on a comma delimited string */ | 153 | /** set event's categories based on a comma delimited string */ |
154 | void setCategories(const QString &catStr); | 154 | void setCategories(const QString &catStr); |
155 | /** return categories in a list */ | 155 | /** return categories in a list */ |
156 | QStringList categories() const; | 156 | QStringList categories() const; |
157 | /** return categories as a comma separated string */ | 157 | /** return categories as a comma separated string */ |
158 | QString categoriesStr(); | 158 | QString categoriesStr(); |
159 | 159 | ||
160 | /** point at some other event to which the event relates. This function should | 160 | /** point at some other event to which the event relates. This function should |
161 | * only be used when constructing a calendar before the related Event | 161 | * only be used when constructing a calendar before the related Event |
162 | * exists. */ | 162 | * exists. */ |
163 | void setRelatedToUid(const QString &); | 163 | void setRelatedToUid(const QString &); |
164 | /** what event does this one relate to? This function should | 164 | /** what event does this one relate to? This function should |
165 | * only be used when constructing a calendar before the related Event | 165 | * only be used when constructing a calendar before the related Event |
166 | * exists. */ | 166 | * exists. */ |
167 | QString relatedToUid() const; | 167 | QString relatedToUid() const; |
168 | /** point at some other event to which the event relates */ | 168 | /** point at some other event to which the event relates */ |
169 | void setRelatedTo(Incidence *relatedTo); | 169 | void setRelatedTo(Incidence *relatedTo); |
170 | /** what event does this one relate to? */ | 170 | /** what event does this one relate to? */ |
171 | Incidence *relatedTo() const; | 171 | Incidence *relatedTo() const; |
172 | /** All events that are related to this event */ | 172 | /** All events that are related to this event */ |
173 | QPtrList<Incidence> relations() const; | 173 | QPtrList<Incidence> relations() const; |
174 | /** Add an event which is related to this event */ | 174 | /** Add an event which is related to this event */ |
175 | void addRelation(Incidence *); | 175 | void addRelation(Incidence *); |
176 | /** Remove event that is related to this event */ | 176 | /** Remove event that is related to this event */ |
177 | void removeRelation(Incidence *); | 177 | void removeRelation(Incidence *); |
178 | 178 | ||
179 | /** returns the list of dates which are exceptions to the recurrence rule */ | 179 | /** returns the list of dates which are exceptions to the recurrence rule */ |
180 | DateList exDates() const; | 180 | DateList exDates() const; |
181 | /** sets the list of dates which are exceptions to the recurrence rule */ | 181 | /** sets the list of dates which are exceptions to the recurrence rule */ |
182 | void setExDates(const DateList &_exDates); | 182 | void setExDates(const DateList &_exDates); |
183 | void setExDates(const char *dates); | 183 | void setExDates(const char *dates); |
184 | /** Add a date to the list of exceptions of the recurrence rule. */ | 184 | /** Add a date to the list of exceptions of the recurrence rule. */ |
185 | void addExDate(const QDate &date); | 185 | void addExDate(const QDate &date); |
186 | 186 | ||
187 | /** returns true if there is an exception for this date in the recurrence | 187 | /** returns true if there is an exception for this date in the recurrence |
188 | rule set, or false otherwise. */ | 188 | rule set, or false otherwise. */ |
189 | bool isException(const QDate &qd) const; | 189 | bool isException(const QDate &qd) const; |
190 | 190 | ||
191 | /** add attachment to this event */ | 191 | /** add attachment to this event */ |
192 | void addAttachment(Attachment *attachment); | 192 | void addAttachment(Attachment *attachment); |
193 | /** remove and delete a specific attachment */ | 193 | /** remove and delete a specific attachment */ |
194 | void deleteAttachment(Attachment *attachment); | 194 | void deleteAttachment(Attachment *attachment); |
195 | /** remove and delete all attachments with this mime type */ | 195 | /** remove and delete all attachments with this mime type */ |
196 | void deleteAttachments(const QString& mime); | 196 | void deleteAttachments(const QString& mime); |
197 | /** return list of all associated attachments */ | 197 | /** return list of all associated attachments */ |
198 | QPtrList<Attachment> attachments() const; | 198 | QPtrList<Attachment> attachments() const; |
199 | /** find a list of attachments with this mime type */ | 199 | /** find a list of attachments with this mime type */ |
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 | ||
266 | protected: | 266 | protected: |
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 | ||
294 | bool operator==( const Incidence&, const Incidence& ); | 294 | bool operator==( const Incidence&, const Incidence& ); |
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | #endif | 298 | #endif |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 1769b37..0bc9125 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,1691 +1,581 @@ | |||
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 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | |||
49 | class PhoneParser : public QObject | 48 | class PhoneParser : public QObject |
50 | { | 49 | { |
51 | public: | 50 | public: |
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 | ||
572 | protected: | ||
573 | private: | ||
574 | Calendar *mCalendar; | ||
575 | QString mProfileName ; | ||
576 | }; | 79 | }; |
577 | 80 | ||
81 | |||
578 | 82 | ||
579 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 83 | PhoneFormat::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 | ||
587 | PhoneFormat::~PhoneFormat() | 91 | PhoneFormat::~PhoneFormat() |
588 | { | 92 | { |
589 | } | 93 | } |
94 | #if 0 | ||
590 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 95 | int 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 | ||
615 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 121 | ulong 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 | } |
640 | ulong PhoneFormat::getCsumEvent( Event* event ) | 146 | ulong 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" ); |
663 | list.append( QString::number( rec->frequency() ));//12 | 169 | list.append( QString::number( rec->frequency() ));//12 |
664 | list.append( "0" ); | 170 | list.append( "0" ); |
665 | list.append( "0" ); | 171 | list.append( "0" ); |
666 | writeEndDate = true; | 172 | writeEndDate = true; |
667 | break; | 173 | break; |
668 | case Recurrence::rWeekly:// 1 | 174 | case Recurrence::rWeekly:// 1 |
669 | list.append( "1" ); | 175 | list.append( "1" ); |
670 | list.append( QString::number( rec->frequency()) );//12 | 176 | list.append( QString::number( rec->frequency()) );//12 |
671 | list.append( "0" ); | 177 | list.append( "0" ); |
672 | { | 178 | { |
673 | int days = 0; | 179 | int days = 0; |
674 | QBitArray weekDays = rec->days(); | 180 | QBitArray weekDays = rec->days(); |
675 | int i; | 181 | int i; |
676 | for( i = 1; i <= 7; ++i ) { | 182 | for( i = 1; i <= 7; ++i ) { |
677 | if ( weekDays[i-1] ) { | 183 | if ( weekDays[i-1] ) { |
678 | days += 1 << (i-1); | 184 | days += 1 << (i-1); |
679 | } | 185 | } |
680 | } | 186 | } |
681 | list.append( QString::number( days ) ); | 187 | list.append( QString::number( days ) ); |
682 | } | 188 | } |
683 | //pending weekdays | 189 | //pending weekdays |
684 | writeEndDate = true; | 190 | writeEndDate = true; |
685 | 191 | ||
686 | break; | 192 | break; |
687 | case Recurrence::rMonthlyPos:// 2 | 193 | case Recurrence::rMonthlyPos:// 2 |
688 | list.append( "2" ); | 194 | list.append( "2" ); |
689 | list.append( QString::number( rec->frequency()) );//12 | 195 | list.append( QString::number( rec->frequency()) );//12 |
690 | 196 | ||
691 | writeEndDate = true; | 197 | writeEndDate = true; |
692 | { | 198 | { |
693 | int count = 1; | 199 | int count = 1; |
694 | QPtrList<Recurrence::rMonthPos> rmp; | 200 | QPtrList<Recurrence::rMonthPos> rmp; |
695 | rmp = rec->monthPositions(); | 201 | rmp = rec->monthPositions(); |
696 | if ( rmp.first()->negative ) | 202 | if ( rmp.first()->negative ) |
697 | count = 5 - rmp.first()->rPos - 1; | 203 | count = 5 - rmp.first()->rPos - 1; |
698 | else | 204 | else |
699 | count = rmp.first()->rPos - 1; | 205 | count = rmp.first()->rPos - 1; |
700 | list.append( QString::number( count ) ); | 206 | list.append( QString::number( count ) ); |
701 | 207 | ||
702 | } | 208 | } |
703 | 209 | ||
704 | list.append( "0" ); | 210 | list.append( "0" ); |
705 | break; | 211 | break; |
706 | case Recurrence::rMonthlyDay:// 3 | 212 | case Recurrence::rMonthlyDay:// 3 |
707 | list.append( "3" ); | 213 | list.append( "3" ); |
708 | list.append( QString::number( rec->frequency()) );//12 | 214 | list.append( QString::number( rec->frequency()) );//12 |
709 | list.append( "0" ); | 215 | list.append( "0" ); |
710 | list.append( "0" ); | 216 | list.append( "0" ); |
711 | writeEndDate = true; | 217 | writeEndDate = true; |
712 | break; | 218 | break; |
713 | case Recurrence::rYearlyMonth://4 | 219 | case Recurrence::rYearlyMonth://4 |
714 | list.append( "4" ); | 220 | list.append( "4" ); |
715 | list.append( QString::number( rec->frequency()) );//12 | 221 | list.append( QString::number( rec->frequency()) );//12 |
716 | list.append( "0" ); | 222 | list.append( "0" ); |
717 | list.append( "0" ); | 223 | list.append( "0" ); |
718 | writeEndDate = true; | 224 | writeEndDate = true; |
719 | break; | 225 | break; |
720 | 226 | ||
721 | default: | 227 | default: |
722 | list.append( "255" ); | 228 | list.append( "255" ); |
723 | list.append( QString() ); | 229 | list.append( QString() ); |
724 | list.append( "0" ); | 230 | list.append( "0" ); |
725 | list.append( QString() ); | 231 | list.append( QString() ); |
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 | } |
746 | ulong PhoneFormat::getCsum( const QStringList & attList) | 252 | ulong 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 |
772 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 278 | bool 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,¬e,start); | 305 | calendar->addEvent( event); |
810 | if (error == ERR_EMPTY) break; | 306 | } |
811 | start = false; | 307 | else |
812 | handler.readEvent( existingCal, ¬e ); | 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,¬e); | 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> | 346 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
840 | void 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 | } |
858 | void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) | 385 | void 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 | |||
876 | void PhoneFormat::afterSave( Incidence* inc) | 433 | void 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 | } |
888 | bool PhoneFormat::save( Calendar *calendar) | 445 | bool 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 | } | ||
1441 | QString 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 | } | ||
1463 | QString 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 | } | ||
1629 | QString 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 | ||
1684 | QString PhoneFormat::toString( Calendar * ) | 574 | QString PhoneFormat::toString( Calendar * ) |
1685 | { | 575 | { |
1686 | return QString::null; | 576 | return QString::null; |
1687 | } | 577 | } |
1688 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 578 | bool 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" |
30 | extern "C" { | 30 | |
31 | #include "../gammu/emb/common/gammu.h" | ||
32 | } | ||
33 | namespace KCal { | 31 | namespace 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; |
40 | class PhoneFormat : public QObject { | 38 | class 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 | |||
@@ -1,444 +1,447 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brwon | 3 | Copyright (c) 1998 Preston Brwon |
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 | #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 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
48 | { | 48 | { |
49 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | 50 | useLocalTime = false; |
51 | } | 51 | } |
52 | 52 | ||
53 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
54 | { | 54 | { |
55 | } | 55 | } |
56 | 56 | ||
57 | void VCalFormat::setLocalTime ( bool b ) | ||
58 | { | ||
59 | useLocalTime = b; | ||
60 | } | ||
57 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 61 | bool 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 | ||
89 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 92 | bool 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(); |
109 | QPtrListIterator<Todo> qlt(todoList); | 112 | QPtrListIterator<Todo> qlt(todoList); |
110 | for (; qlt.current(); ++qlt) { | 113 | for (; qlt.current(); ++qlt) { |
111 | vo = eventToVTodo(qlt.current()); | 114 | vo = eventToVTodo(qlt.current()); |
112 | addVObjectProp(vcal, vo); | 115 | addVObjectProp(vcal, vo); |
113 | } | 116 | } |
114 | 117 | ||
115 | // EVENT STUFF | 118 | // EVENT STUFF |
116 | QPtrList<Event> events = mCalendar->rawEvents(); | 119 | QPtrList<Event> events = mCalendar->rawEvents(); |
117 | Event *ev; | 120 | Event *ev; |
118 | for(ev=events.first();ev;ev=events.next()) { | 121 | for(ev=events.first();ev;ev=events.next()) { |
119 | vo = eventToVEvent(ev); | 122 | vo = eventToVEvent(ev); |
120 | addVObjectProp(vcal, vo); | 123 | addVObjectProp(vcal, vo); |
121 | } | 124 | } |
122 | 125 | ||
123 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
124 | cleanVObjects(vcal); | 127 | cleanVObjects(vcal); |
125 | cleanStrTbl(); | 128 | cleanStrTbl(); |
126 | 129 | ||
127 | if (QFile::exists(fileName)) { | 130 | if (QFile::exists(fileName)) { |
128 | kdDebug(5800) << "No error" << endl; | 131 | kdDebug(5800) << "No error" << endl; |
129 | return true; | 132 | return true; |
130 | } else { | 133 | } else { |
131 | kdDebug(5800) << "Error" << endl; | 134 | kdDebug(5800) << "Error" << endl; |
132 | return false; // error | 135 | return false; // error |
133 | } | 136 | } |
134 | } | 137 | } |
135 | 138 | ||
136 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 139 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
137 | { | 140 | { |
138 | // TODO: Factor out VCalFormat::fromString() | 141 | // TODO: Factor out VCalFormat::fromString() |
139 | 142 | ||
140 | QCString data = text.utf8(); | 143 | QCString data = text.utf8(); |
141 | 144 | ||
142 | if ( !data.size() ) return false; | 145 | if ( !data.size() ) return false; |
143 | 146 | ||
144 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 147 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
145 | if ( !vcal ) return false; | 148 | if ( !vcal ) return false; |
146 | 149 | ||
147 | VObjectIterator i; | 150 | VObjectIterator i; |
148 | VObject *curvo; | 151 | VObject *curvo; |
149 | initPropIterator( &i, vcal ); | 152 | initPropIterator( &i, vcal ); |
150 | 153 | ||
151 | // we only take the first object. TODO: parse all incidences. | 154 | // we only take the first object. TODO: parse all incidences. |
152 | do { | 155 | do { |
153 | curvo = nextVObject( &i ); | 156 | curvo = nextVObject( &i ); |
154 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 157 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
155 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 158 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
156 | 159 | ||
157 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 160 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
158 | Event *event = VEventToEvent( curvo ); | 161 | Event *event = VEventToEvent( curvo ); |
159 | calendar->addEvent( event ); | 162 | calendar->addEvent( event ); |
160 | } else { | 163 | } else { |
161 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; | 164 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; |
162 | deleteVObject( vcal ); | 165 | deleteVObject( vcal ); |
163 | return false; | 166 | return false; |
164 | } | 167 | } |
165 | 168 | ||
166 | deleteVObject( vcal ); | 169 | deleteVObject( vcal ); |
167 | 170 | ||
168 | return true; | 171 | return true; |
169 | } | 172 | } |
170 | 173 | ||
171 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 174 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
172 | { | 175 | { |
173 | 176 | ||
174 | if ( !event ) return QString::null; | 177 | if ( !event ) return QString::null; |
175 | bool useL = useLocalTime; | 178 | bool useL = useLocalTime; |
176 | useLocalTime = useLocal; | 179 | useLocalTime = useLocal; |
177 | mCalendar = calendar; | 180 | mCalendar = calendar; |
178 | VObject *vevent = eventToVEvent( event ); | 181 | VObject *vevent = eventToVEvent( event ); |
179 | char *buf = writeMemVObject( 0, 0, vevent ); | 182 | char *buf = writeMemVObject( 0, 0, vevent ); |
180 | QString result( buf ); | 183 | QString result( buf ); |
181 | cleanVObject( vevent ); | 184 | cleanVObject( vevent ); |
182 | useLocalTime = useL; | 185 | useLocalTime = useL; |
183 | return result; | 186 | return result; |
184 | } | 187 | } |
185 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 188 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
186 | { | 189 | { |
187 | 190 | ||
188 | if ( !todo ) return QString::null; | 191 | if ( !todo ) return QString::null; |
189 | bool useL = useLocalTime; | 192 | bool useL = useLocalTime; |
190 | useLocalTime = useLocal; | 193 | useLocalTime = useLocal; |
191 | mCalendar = calendar; | 194 | mCalendar = calendar; |
192 | VObject *vevent = eventToVTodo( todo ); | 195 | VObject *vevent = eventToVTodo( todo ); |
193 | char *buf = writeMemVObject( 0, 0, vevent ); | 196 | char *buf = writeMemVObject( 0, 0, vevent ); |
194 | QString result( buf ); | 197 | QString result( buf ); |
195 | cleanVObject( vevent ); | 198 | cleanVObject( vevent ); |
196 | useLocalTime = useL; | 199 | useLocalTime = useL; |
197 | return result; | 200 | return result; |
198 | } | 201 | } |
199 | 202 | ||
200 | QString VCalFormat::toString( Calendar *calendar ) | 203 | QString VCalFormat::toString( Calendar *calendar ) |
201 | { | 204 | { |
202 | // TODO: Factor out VCalFormat::asString() | 205 | // TODO: Factor out VCalFormat::asString() |
203 | 206 | ||
204 | VObject *vcal = newVObject(VCCalProp); | 207 | VObject *vcal = newVObject(VCCalProp); |
205 | 208 | ||
206 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 209 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
207 | QString tmpStr = mCalendar->getTimeZoneStr(); | 210 | QString tmpStr = mCalendar->getTimeZoneStr(); |
208 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 211 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
209 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 212 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
210 | 213 | ||
211 | // TODO: Use all data. | 214 | // TODO: Use all data. |
212 | QPtrList<Event> events = calendar->events(); | 215 | QPtrList<Event> events = calendar->events(); |
213 | Event *event = events.first(); | 216 | Event *event = events.first(); |
214 | if ( !event ) return QString::null; | 217 | if ( !event ) return QString::null; |
215 | 218 | ||
216 | VObject *vevent = eventToVEvent( event ); | 219 | VObject *vevent = eventToVEvent( event ); |
217 | 220 | ||
218 | addVObjectProp( vcal, vevent ); | 221 | addVObjectProp( vcal, vevent ); |
219 | 222 | ||
220 | char *buf = writeMemVObject( 0, 0, vcal ); | 223 | char *buf = writeMemVObject( 0, 0, vcal ); |
221 | 224 | ||
222 | QString result( buf ); | 225 | QString result( buf ); |
223 | 226 | ||
224 | cleanVObject( vcal ); | 227 | cleanVObject( vcal ); |
225 | 228 | ||
226 | return result; | 229 | return result; |
227 | } | 230 | } |
228 | 231 | ||
229 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 232 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
230 | { | 233 | { |
231 | VObject *vtodo; | 234 | VObject *vtodo; |
232 | QString tmpStr; | 235 | QString tmpStr; |
233 | QStringList tmpStrList; | 236 | QStringList tmpStrList; |
234 | 237 | ||
235 | vtodo = newVObject(VCTodoProp); | 238 | vtodo = newVObject(VCTodoProp); |
236 | 239 | ||
237 | // due date | 240 | // due date |
238 | if (anEvent->hasDueDate()) { | 241 | if (anEvent->hasDueDate()) { |
239 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 242 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
240 | !anEvent->doesFloat()); | 243 | !anEvent->doesFloat()); |
241 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 244 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
242 | } | 245 | } |
243 | 246 | ||
244 | // start date | 247 | // start date |
245 | if (anEvent->hasStartDate()) { | 248 | if (anEvent->hasStartDate()) { |
246 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 249 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
247 | !anEvent->doesFloat()); | 250 | !anEvent->doesFloat()); |
248 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 251 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
249 | } | 252 | } |
250 | 253 | ||
251 | // creation date | 254 | // creation date |
252 | tmpStr = qDateTimeToISO(anEvent->created()); | 255 | tmpStr = qDateTimeToISO(anEvent->created()); |
253 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 256 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
254 | 257 | ||
255 | // unique id | 258 | // unique id |
256 | addPropValue(vtodo, VCUniqueStringProp, | 259 | addPropValue(vtodo, VCUniqueStringProp, |
257 | anEvent->uid().local8Bit()); | 260 | anEvent->uid().local8Bit()); |
258 | 261 | ||
259 | // revision | 262 | // revision |
260 | tmpStr.sprintf("%i", anEvent->revision()); | 263 | tmpStr.sprintf("%i", anEvent->revision()); |
261 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 264 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
262 | 265 | ||
263 | // last modification date | 266 | // last modification date |
264 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 267 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
265 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 268 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
266 | 269 | ||
267 | // organizer stuff | 270 | // organizer stuff |
268 | tmpStr = "MAILTO:" + anEvent->organizer(); | 271 | tmpStr = "MAILTO:" + anEvent->organizer(); |
269 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 272 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
270 | 273 | ||
271 | // attendees | 274 | // attendees |
272 | if (anEvent->attendeeCount() != 0) { | 275 | if (anEvent->attendeeCount() != 0) { |
273 | QPtrList<Attendee> al = anEvent->attendees(); | 276 | QPtrList<Attendee> al = anEvent->attendees(); |
274 | QPtrListIterator<Attendee> ai(al); | 277 | QPtrListIterator<Attendee> ai(al); |
275 | Attendee *curAttendee; | 278 | Attendee *curAttendee; |
276 | 279 | ||
277 | for (; ai.current(); ++ai) { | 280 | for (; ai.current(); ++ai) { |
278 | curAttendee = ai.current(); | 281 | curAttendee = ai.current(); |
279 | if (!curAttendee->email().isEmpty() && | 282 | if (!curAttendee->email().isEmpty() && |
280 | !curAttendee->name().isEmpty()) | 283 | !curAttendee->name().isEmpty()) |
281 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 284 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
282 | curAttendee->email() + ">"; | 285 | curAttendee->email() + ">"; |
283 | else if (curAttendee->name().isEmpty()) | 286 | else if (curAttendee->name().isEmpty()) |
284 | tmpStr = "MAILTO: " + curAttendee->email(); | 287 | tmpStr = "MAILTO: " + curAttendee->email(); |
285 | else if (curAttendee->email().isEmpty()) | 288 | else if (curAttendee->email().isEmpty()) |
286 | tmpStr = "MAILTO: " + curAttendee->name(); | 289 | tmpStr = "MAILTO: " + curAttendee->name(); |
287 | else if (curAttendee->name().isEmpty() && | 290 | else if (curAttendee->name().isEmpty() && |
288 | curAttendee->email().isEmpty()) | 291 | curAttendee->email().isEmpty()) |
289 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 292 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
290 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 293 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
291 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 294 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
292 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 295 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
293 | } | 296 | } |
294 | } | 297 | } |
295 | 298 | ||
296 | // description BL: | 299 | // description BL: |
297 | if (!anEvent->description().isEmpty()) { | 300 | if (!anEvent->description().isEmpty()) { |
298 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 301 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
299 | anEvent->description().local8Bit()); | 302 | anEvent->description().local8Bit()); |
300 | if (anEvent->description().find('\n') != -1) | 303 | if (anEvent->description().find('\n') != -1) |
301 | addProp(d, VCQuotedPrintableProp); | 304 | addProp(d, VCQuotedPrintableProp); |
302 | } | 305 | } |
303 | 306 | ||
304 | // summary | 307 | // summary |
305 | if (!anEvent->summary().isEmpty()) | 308 | if (!anEvent->summary().isEmpty()) |
306 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 309 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
307 | 310 | ||
308 | if (!anEvent->location().isEmpty()) | 311 | if (!anEvent->location().isEmpty()) |
309 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 312 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
310 | 313 | ||
311 | // completed | 314 | // completed |
312 | // status | 315 | // status |
313 | // backward compatibility, KOrganizer used to interpret only these two values | 316 | // backward compatibility, KOrganizer used to interpret only these two values |
314 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 317 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
315 | "NEEDS_ACTION"); | 318 | "NEEDS_ACTION"); |
316 | // completion date | 319 | // completion date |
317 | if (anEvent->hasCompletedDate()) { | 320 | if (anEvent->hasCompletedDate()) { |
318 | tmpStr = qDateTimeToISO(anEvent->completed()); | 321 | tmpStr = qDateTimeToISO(anEvent->completed()); |
319 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 322 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
320 | } | 323 | } |
321 | 324 | ||
322 | // priority | 325 | // priority |
323 | tmpStr.sprintf("%i",anEvent->priority()); | 326 | tmpStr.sprintf("%i",anEvent->priority()); |
324 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 327 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
325 | 328 | ||
326 | // related event | 329 | // related event |
327 | if (anEvent->relatedTo()) { | 330 | if (anEvent->relatedTo()) { |
328 | addPropValue(vtodo, VCRelatedToProp, | 331 | addPropValue(vtodo, VCRelatedToProp, |
329 | anEvent->relatedTo()->uid().local8Bit()); | 332 | anEvent->relatedTo()->uid().local8Bit()); |
330 | } | 333 | } |
331 | 334 | ||
332 | // categories | 335 | // categories |
333 | tmpStrList = anEvent->categories(); | 336 | tmpStrList = anEvent->categories(); |
334 | tmpStr = ""; | 337 | tmpStr = ""; |
335 | QString catStr; | 338 | QString catStr; |
336 | for ( QStringList::Iterator it = tmpStrList.begin(); | 339 | for ( QStringList::Iterator it = tmpStrList.begin(); |
337 | it != tmpStrList.end(); | 340 | it != tmpStrList.end(); |
338 | ++it ) { | 341 | ++it ) { |
339 | catStr = *it; | 342 | catStr = *it; |
340 | if (catStr[0] == ' ') | 343 | if (catStr[0] == ' ') |
341 | tmpStr += catStr.mid(1); | 344 | tmpStr += catStr.mid(1); |
342 | else | 345 | else |
343 | tmpStr += catStr; | 346 | tmpStr += catStr; |
344 | // this must be a ';' character as the vCalendar specification requires! | 347 | // this must be a ';' character as the vCalendar specification requires! |
345 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 348 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
346 | // read in. | 349 | // read in. |
347 | tmpStr += ";"; | 350 | tmpStr += ";"; |
348 | } | 351 | } |
349 | if (!tmpStr.isEmpty()) { | 352 | if (!tmpStr.isEmpty()) { |
350 | tmpStr.truncate(tmpStr.length()-1); | 353 | tmpStr.truncate(tmpStr.length()-1); |
351 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 354 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
352 | } | 355 | } |
353 | 356 | ||
354 | // alarm stuff | 357 | // alarm stuff |
355 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 358 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
356 | QPtrList<Alarm> alarms = anEvent->alarms(); | 359 | QPtrList<Alarm> alarms = anEvent->alarms(); |
357 | Alarm* alarm; | 360 | Alarm* alarm; |
358 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 361 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
359 | if (alarm->enabled()) { | 362 | if (alarm->enabled()) { |
360 | VObject *a; | 363 | VObject *a; |
361 | tmpStr = qDateTimeToISO(alarm->time()); | 364 | tmpStr = qDateTimeToISO(alarm->time()); |
362 | if (alarm->type() == Alarm::Audio) { | 365 | if (alarm->type() == Alarm::Audio) { |
363 | a = addProp(vtodo, VCAAlarmProp); | 366 | a = addProp(vtodo, VCAAlarmProp); |
364 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 367 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
365 | addPropValue(a, VCRepeatCountProp, "1"); | 368 | addPropValue(a, VCRepeatCountProp, "1"); |
366 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 369 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
367 | } | 370 | } |
368 | else if (alarm->type() == Alarm::Procedure) { | 371 | else if (alarm->type() == Alarm::Procedure) { |
369 | a = addProp(vtodo, VCPAlarmProp); | 372 | a = addProp(vtodo, VCPAlarmProp); |
370 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 373 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
371 | addPropValue(a, VCRepeatCountProp, "1"); | 374 | addPropValue(a, VCRepeatCountProp, "1"); |
372 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 375 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
373 | } else { | 376 | } else { |
374 | a = addProp(vtodo, VCDAlarmProp); | 377 | a = addProp(vtodo, VCDAlarmProp); |
375 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 378 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
376 | addPropValue(a, VCRepeatCountProp, "1"); | 379 | addPropValue(a, VCRepeatCountProp, "1"); |
377 | addPropValue(a, VCDisplayStringProp, "beep!"); | 380 | addPropValue(a, VCDisplayStringProp, "beep!"); |
378 | } | 381 | } |
379 | } | 382 | } |
380 | } | 383 | } |
381 | 384 | ||
382 | if (anEvent->pilotId()) { | 385 | if (anEvent->pilotId()) { |
383 | // pilot sync stuff | 386 | // pilot sync stuff |
384 | tmpStr.sprintf("%i",anEvent->pilotId()); | 387 | tmpStr.sprintf("%i",anEvent->pilotId()); |
385 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 388 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
386 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 389 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
387 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 390 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
388 | } | 391 | } |
389 | 392 | ||
390 | return vtodo; | 393 | return vtodo; |
391 | } | 394 | } |
392 | 395 | ||
393 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 396 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
394 | { | 397 | { |
395 | VObject *vevent; | 398 | VObject *vevent; |
396 | QString tmpStr; | 399 | QString tmpStr; |
397 | QStringList tmpStrList; | 400 | QStringList tmpStrList; |
398 | 401 | ||
399 | vevent = newVObject(VCEventProp); | 402 | vevent = newVObject(VCEventProp); |
400 | 403 | ||
401 | // start and end time | 404 | // start and end time |
402 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 405 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
403 | !anEvent->doesFloat()); | 406 | !anEvent->doesFloat()); |
404 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 407 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
405 | 408 | ||
406 | // events that have time associated but take up no time should | 409 | // events that have time associated but take up no time should |
407 | // not have both DTSTART and DTEND. | 410 | // not have both DTSTART and DTEND. |
408 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 411 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
409 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 412 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
410 | !anEvent->doesFloat()); | 413 | !anEvent->doesFloat()); |
411 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 414 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
412 | } | 415 | } |
413 | 416 | ||
414 | // creation date | 417 | // creation date |
415 | tmpStr = qDateTimeToISO(anEvent->created()); | 418 | tmpStr = qDateTimeToISO(anEvent->created()); |
416 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 419 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
417 | 420 | ||
418 | // unique id | 421 | // unique id |
419 | addPropValue(vevent, VCUniqueStringProp, | 422 | addPropValue(vevent, VCUniqueStringProp, |
420 | anEvent->uid().local8Bit()); | 423 | anEvent->uid().local8Bit()); |
421 | 424 | ||
422 | // revision | 425 | // revision |
423 | tmpStr.sprintf("%i", anEvent->revision()); | 426 | tmpStr.sprintf("%i", anEvent->revision()); |
424 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 427 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
425 | 428 | ||
426 | // last modification date | 429 | // last modification date |
427 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 430 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
428 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 431 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
429 | 432 | ||
430 | // attendee and organizer stuff | 433 | // attendee and organizer stuff |
431 | tmpStr = "MAILTO:" + anEvent->organizer(); | 434 | tmpStr = "MAILTO:" + anEvent->organizer(); |
432 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 435 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
433 | 436 | ||
434 | if (anEvent->attendeeCount() != 0) { | 437 | if (anEvent->attendeeCount() != 0) { |
435 | QPtrList<Attendee> al = anEvent->attendees(); | 438 | QPtrList<Attendee> al = anEvent->attendees(); |
436 | QPtrListIterator<Attendee> ai(al); | 439 | QPtrListIterator<Attendee> ai(al); |
437 | Attendee *curAttendee; | 440 | Attendee *curAttendee; |
438 | 441 | ||
439 | // TODO: Put this functionality into Attendee class | 442 | // TODO: Put this functionality into Attendee class |
440 | for (; ai.current(); ++ai) { | 443 | for (; ai.current(); ++ai) { |
441 | curAttendee = ai.current(); | 444 | curAttendee = ai.current(); |
442 | if (!curAttendee->email().isEmpty() && | 445 | if (!curAttendee->email().isEmpty() && |
443 | !curAttendee->name().isEmpty()) | 446 | !curAttendee->name().isEmpty()) |
444 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 447 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index 848be78..5bef7ed 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -1,111 +1,112 @@ | |||
1 | /* | 1 | /* |
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 | ||
29 | class VObject; | 29 | class VObject; |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace 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 | */ |
40 | class VCalFormat : public CalFormat { | 40 | class 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 |