summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-30 07:47:56 (UTC)
committer zautrix <zautrix>2004-08-30 07:47:56 (UTC)
commitb36bcd92b643c87ee5e2bfc39076ea56abf4c7d2 (patch) (unidiff)
tree99223dd8edf0e00a4f060610ea0642f915cf4703
parent78f44f13835e3fa501997f485b505b193bd474f5 (diff)
downloadkdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.zip
kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.tar.gz
kdepimpi-b36bcd92b643c87ee5e2bfc39076ea56abf4c7d2.tar.bz2
Changes in gammu connection
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile16
-rw-r--r--gammu/emb/common/service/gsmcal.c85
-rw-r--r--kdepim-desktop.pro6
-rw-r--r--kopi-desktop.pro6
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/korganizer.pro1
-rw-r--r--libkcal/incidence.cpp5
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/phoneformat.cpp1464
-rw-r--r--libkcal/phoneformat.h14
-rw-r--r--libkcal/vcalformat.cpp5
-rw-r--r--libkcal/vcalformat.h5
12 files changed, 259 insertions, 1352 deletions
diff --git a/Makefile b/Makefile
index ac314b9..f21e524 100644
--- a/Makefile
+++ b/Makefile
@@ -1,157 +1,169 @@
1############################################################################# 1#############################################################################
2# Makefile for building: kopi-desktop 2# Makefile for building: kopi-desktop
3# Generated by qmake (1.07a) (Qt 3.3.1) on: Sun Aug 29 13:39:55 2004 3# Generated by qmake (1.07a) (Qt 3.3.1) on: Sun Aug 29 18:50:00 2004
4# Project: kopi-desktop.pro 4# Project: kopi-desktop.pro
5# Template: subdirs 5# Template: subdirs
6# Command: $(QMAKE) -o Makefile kopi-desktop.pro 6# Command: $(QMAKE) -o Makefile kopi-desktop.pro
7############################################################################# 7#############################################################################
8 8
9 MAKEFILE =Makefile 9 MAKEFILE =Makefile
10 QMAKE =qmake 10 QMAKE =qmake
11DEL_FILE = rm -f 11DEL_FILE = rm -f
12CHK_DIR_EXISTS= test -d 12CHK_DIR_EXISTS= test -d
13MKDIR = mkdir -p 13MKDIR = mkdir -p
14 SUBTARGETS = \ 14 SUBTARGETS = \
15 sub-gammu-emb-common \ 15 sub-gammu-emb-common \
16 sub-gammu-emb-gammu \
16 sub-libical \ 17 sub-libical \
17 sub-libkcal \ 18 sub-libkcal \
18 sub-microkde \ 19 sub-microkde \
19 sub-libkdepim \ 20 sub-libkdepim \
20 sub-kabc \ 21 sub-kabc \
21 sub-korganizer \ 22 sub-korganizer \
22 sub-kaddressbook \ 23 sub-kaddressbook \
23 sub-kabc-plugins-file \ 24 sub-kabc-plugins-file \
24 sub-kabc-plugins-dir 25 sub-kabc-plugins-dir
25 26
26first: all 27first: all
27 28
28all: Makefile $(SUBTARGETS) 29all: Makefile $(SUBTARGETS)
29 30
30gammu/emb/common/$(MAKEFILE): 31gammu/emb/common/$(MAKEFILE):
31 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" 32 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
32 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE) 33 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE)
33sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE 34sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
34 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) 35 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
35 36
37gammu/emb/gammu/$(MAKEFILE):
38 @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
39 cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE)
40sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
41 cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
42
36libical/$(MAKEFILE): 43libical/$(MAKEFILE):
37 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" 44 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
38 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE) 45 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE)
39sub-libical: libical/$(MAKEFILE) FORCE 46sub-libical: libical/$(MAKEFILE) FORCE
40 cd libical && $(MAKE) -f $(MAKEFILE) 47 cd libical && $(MAKE) -f $(MAKEFILE)
41 48
42libkcal/$(MAKEFILE): 49libkcal/$(MAKEFILE):
43 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" 50 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
44 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE) 51 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE)
45sub-libkcal: libkcal/$(MAKEFILE) FORCE 52sub-libkcal: libkcal/$(MAKEFILE) FORCE
46 cd libkcal && $(MAKE) -f $(MAKEFILE) 53 cd libkcal && $(MAKE) -f $(MAKEFILE)
47 54
48microkde/$(MAKEFILE): 55microkde/$(MAKEFILE):
49 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" 56 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
50 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE) 57 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE)
51sub-microkde: microkde/$(MAKEFILE) FORCE 58sub-microkde: microkde/$(MAKEFILE) FORCE
52 cd microkde && $(MAKE) -f $(MAKEFILE) 59 cd microkde && $(MAKE) -f $(MAKEFILE)
53 60
54libkdepim/$(MAKEFILE): 61libkdepim/$(MAKEFILE):
55 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" 62 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
56 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE) 63 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE)
57sub-libkdepim: libkdepim/$(MAKEFILE) FORCE 64sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
58 cd libkdepim && $(MAKE) -f $(MAKEFILE) 65 cd libkdepim && $(MAKE) -f $(MAKEFILE)
59 66
60kabc/$(MAKEFILE): 67kabc/$(MAKEFILE):
61 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" 68 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
62 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE) 69 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE)
63sub-kabc: kabc/$(MAKEFILE) FORCE 70sub-kabc: kabc/$(MAKEFILE) FORCE
64 cd kabc && $(MAKE) -f $(MAKEFILE) 71 cd kabc && $(MAKE) -f $(MAKEFILE)
65 72
66korganizer/$(MAKEFILE): 73korganizer/$(MAKEFILE):
67 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" 74 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
68 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE) 75 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE)
69sub-korganizer: korganizer/$(MAKEFILE) FORCE 76sub-korganizer: korganizer/$(MAKEFILE) FORCE
70 cd korganizer && $(MAKE) -f $(MAKEFILE) 77 cd korganizer && $(MAKE) -f $(MAKEFILE)
71 78
72kaddressbook/$(MAKEFILE): 79kaddressbook/$(MAKEFILE):
73 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" 80 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
74 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE) 81 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE)
75sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE 82sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
76 cd kaddressbook && $(MAKE) -f $(MAKEFILE) 83 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
77 84
78kabc/plugins/file/$(MAKEFILE): 85kabc/plugins/file/$(MAKEFILE):
79 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" 86 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
80 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE) 87 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
81sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE 88sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
82 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) 89 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
83 90
84kabc/plugins/dir/$(MAKEFILE): 91kabc/plugins/dir/$(MAKEFILE):
85 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" 92 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
86 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE) 93 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE)
87sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE 94sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
88 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) 95 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
89 96
90Makefile: kopi-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf 97Makefile: kopi-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf
91 $(QMAKE) -o Makefile kopi-desktop.pro 98 $(QMAKE) -o Makefile kopi-desktop.pro
92qmake: qmake_all 99qmake: qmake_all
93 @$(QMAKE) -o Makefile kopi-desktop.pro 100 @$(QMAKE) -o Makefile kopi-desktop.pro
94 101
95all: $(SUBTARGETS) 102all: $(SUBTARGETS)
96qmake_all: gammu/emb/common/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) 103qmake_all: gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE)
97 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 104 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
105 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
98 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 106 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
99 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 107 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
100 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 108 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
101 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 109 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
102 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 110 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
103 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 111 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
104 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 112 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
105 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 113 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
106 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true 114 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
107clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE 115clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
108 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true 116 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
117 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
109 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true 118 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
110 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true 119 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
111 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true 120 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
112 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true 121 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
113 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true 122 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
114 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true 123 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
115 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true 124 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
116 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true 125 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
117 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true 126 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
118uninstall_subdirs: qmake_all FORCE 127uninstall_subdirs: qmake_all FORCE
119 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 128 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
129 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
120 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 130 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
121 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 131 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
122 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 132 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
123 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 133 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
124 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 134 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
125 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 135 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
126 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 136 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
127 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 137 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
128 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true 138 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
129install_subdirs: qmake_all FORCE 139install_subdirs: qmake_all FORCE
130 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true 140 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
141 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
131 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true 142 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
132 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true 143 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
133 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true 144 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
134 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true 145 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
135 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true 146 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
136 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true 147 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
137 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true 148 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
138 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true 149 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
139 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true 150 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
140distclean: qmake_all FORCE 151distclean: qmake_all FORCE
141 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 152 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
153 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
142 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 154 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
143 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 155 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
144 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 156 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
145 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 157 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
146 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 158 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
147 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 159 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
148 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 160 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
149 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 161 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
150 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true 162 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
151 163
152install: install_subdirs 164install: install_subdirs
153 165
154uninstall: uninstall_subdirs 166uninstall: uninstall_subdirs
155 167
156FORCE: 168FORCE:
157 169
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c
index 950e35e..598292c 100644
--- a/gammu/emb/common/service/gsmcal.c
+++ b/gammu/emb/common/service/gsmcal.c
@@ -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
9bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) 9bool 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
44void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) 44void 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
85GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) 85GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version)
86{ 86{
87 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; 87 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location;
88 char buffer[2000]; 88 char buffer[2000];
89 89
90 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); 90 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
91 91
92 if (header) { 92 if (header) {
93 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); 93 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
94 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); 94 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
95 } 95 }
96 *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); 96 *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10);
97 97
98 if (Version == Nokia_VCalendar) { 98 if (Version == Nokia_VCalendar) {
99 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 99 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
100 switch (note->Type) { 100 switch (note->Type) {
101 case GSM_CAL_REMINDER: 101 case GSM_CAL_REMINDER:
102 *Length+=sprintf(Buffer+(*Length), "REMINDER%c%c",13,10); 102 *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10);
103 break; 103 break;
104 case GSM_CAL_MEMO: 104 case GSM_CAL_MEMO:
105 *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); 105 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
106 break; 106 break;
107 case GSM_CAL_CALL: 107 case GSM_CAL_CALL:
108 *Length+=sprintf(Buffer+(*Length), "PHONE CALL%c%c",13,10); 108 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
109 break; 109 break;
110 case GSM_CAL_BIRTHDAY: 110 case GSM_CAL_BIRTHDAY:
111 *Length+=sprintf(Buffer+(*Length), "SPECIAL OCCASION%c%c",13,10); 111 *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10);
112 break; 112 break;
113 case GSM_CAL_MEETING: 113 case GSM_CAL_MEETING:
114 default: 114 default:
115 *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); 115 *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10);
116 break; 116 break;
117 } 117 }
118 if (note->Type == GSM_CAL_CALL) { 118 if (note->Type == GSM_CAL_CALL) {
119 buffer[0] = 0; 119 buffer[0] = 0;
120 buffer[1] = 0; 120 buffer[1] = 0;
121 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); 121 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
122 if (Text != -1) { 122 if (Text != -1) {
123 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); 123 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
124 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); 124 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
125 } 125 }
126 SaveVCALText(Buffer, Length, buffer, "SUMMARY"); 126 SaveVCALText(Buffer, Length, buffer, "SUMMARY");
127 } else { 127 } else {
128 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 128 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
129 } 129 }
130 if (note->Type == GSM_CAL_MEETING && Location != -1) { 130 if (note->Type == GSM_CAL_MEETING && Location != -1) {
131 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); 131 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
132 } 132 }
133 133
134 if (Time == -1) return ERR_UNKNOWN; 134 if (Time == -1) return ERR_UNKNOWN;
135 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 135 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
136 136
137 if (EndTime != -1) { 137 if (EndTime != -1) {
138 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 138 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
139 } 139 }
140 140
141 if (Alarm != -1) { 141 if (Alarm != -1) {
142 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 142 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
143 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 143 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
144 } else { 144 } else {
145 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 145 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
146 } 146 }
147 } 147 }
148 148
149 /* Birthday is known to be recurranced */ 149 /* Birthday is known to be recurranced */
150 if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { 150 if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) {
151 switch(note->Entries[Recurrance].Number/24) { 151 switch(note->Entries[Recurrance].Number/24) {
152 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; 152 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break;
153 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; 153 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break;
154 case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; 154 case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break;
155 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; 155 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break;
156 } 156 }
157 } 157 }
158 } else if (Version == Siemens_VCalendar) { 158 } else if (Version == Siemens_VCalendar) {
159 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 159 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
160 switch (note->Type) { 160 switch (note->Type) {
161 case GSM_CAL_MEETING: 161 case GSM_CAL_MEETING:
162 *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); 162 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
163 break; 163 break;
164 case GSM_CAL_CALL: 164 case GSM_CAL_CALL:
165 *Length+=sprintf(Buffer+(*Length), "PHONE CALL%c%c",13,10); 165 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
166 break; 166 break;
167 case GSM_CAL_BIRTHDAY: 167 case GSM_CAL_BIRTHDAY:
168 *Length+=sprintf(Buffer+(*Length), "ANNIVERSARY%c%c",13,10); 168 *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10);
169 break; 169 break;
170 case GSM_CAL_MEMO: 170 case GSM_CAL_MEMO:
171 default: 171 default:
172 *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); 172 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
173 break; 173 break;
174 } 174 }
175 175
176 if (Time == -1) return ERR_UNKNOWN; 176 if (Time == -1) return ERR_UNKNOWN;
177 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 177 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
178 178
179 if (Alarm != -1) { 179 if (Alarm != -1) {
180 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 180 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
181 } 181 }
182 182
183 if (Recurrance != -1) { 183 if (Recurrance != -1) {
184 switch(note->Entries[Recurrance].Number/24) { 184 switch(note->Entries[Recurrance].Number/24) {
185 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; 185 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break;
186 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; 186 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break;
187 case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; 187 case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break;
188 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; 188 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break;
189 } 189 }
190 } 190 }
191 191
192 if (note->Type == GSM_CAL_CALL) { 192 if (note->Type == GSM_CAL_CALL) {
193 buffer[0] = 0; 193 buffer[0] = 0;
194 buffer[1] = 0; 194 buffer[1] = 0;
195 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); 195 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
196 if (Text != -1) { 196 if (Text != -1) {
197 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); 197 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
198 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); 198 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
199 } 199 }
200 SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); 200 SaveVCALText(Buffer, Length, buffer, "DESCRIPTION");
201 } else { 201 } else {
202 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); 202 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION");
203 } 203 }
204 } else if (Version == SonyEricsson_VCalendar) { 204 } else if (Version == SonyEricsson_VCalendar) {
205 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 205 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
206 switch (note->Type) { 206 switch (note->Type) {
207 case GSM_CAL_MEETING: 207 case GSM_CAL_MEETING:
208 *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); 208 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
209 break; 209 break;
210 case GSM_CAL_REMINDER: 210 case GSM_CAL_REMINDER:
211 *Length+=sprintf(Buffer+(*Length), "DATE%c%c",13,10); 211 *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10);
212 break; 212 break;
213 case GSM_CAL_TRAVEL: 213 case GSM_CAL_TRAVEL:
214 *Length+=sprintf(Buffer+(*Length), "TRAVEL%c%c",13,10); 214 *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10);
215 break; 215 break;
216 case GSM_CAL_VACATION: 216 case GSM_CAL_VACATION:
217 *Length+=sprintf(Buffer+(*Length), "VACATION%c%c",13,10); 217 *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10);
218 break; 218 break;
219 case GSM_CAL_BIRTHDAY: 219 case GSM_CAL_BIRTHDAY:
220 *Length+=sprintf(Buffer+(*Length), "ANNIVERSARY%c%c",13,10); 220 *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10);
221 break; 221 break;
222 case GSM_CAL_MEMO: 222 case GSM_CAL_MEMO:
223 default: 223 default:
224 *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); 224 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
225 break; 225 break;
226 } 226 }
227 227
228 if (Time == -1) return ERR_UNKNOWN; 228 if (Time == -1) return ERR_UNKNOWN;
229 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 229 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
230 230
231 if (EndTime != -1) { 231 if (EndTime != -1) {
232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
233 } 233 }
234 234
235 if (Alarm != -1) { 235 if (Alarm != -1) {
236 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 236 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
237 } 237 }
238 238
239 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 239 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
240 240
241 if (Location != -1) { 241 if (Location != -1) {
242 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); 242 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
243 } 243 }
244 } 244 }
245 245
246 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
246 *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); 247 *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10);
247 if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); 248 if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
248 249
249 return ERR_NONE; 250 return ERR_NONE;
250} 251}
251 252
252void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) 253void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone)
253{ 254{
254 int i; 255 int i;
255 256
256 *Text = -1; 257 *Text = -1;
257 *EndTime= -1; 258 *EndTime= -1;
258 *Alarm = -1; 259 *Alarm = -1;
259 *Completed= -1; 260 *Completed= -1;
260 *Phone = -1; 261 *Phone = -1;
261 for (i = 0; i < entry->EntriesNum; i++) { 262 for (i = 0; i < entry->EntriesNum; i++) {
262 switch (entry->Entries[i].EntryType) { 263 switch (entry->Entries[i].EntryType) {
263 case TODO_END_DATETIME : 264 case TODO_END_DATETIME :
264 if (*EndTime == -1) *EndTime = i; 265 if (*EndTime == -1) *EndTime = i;
265 break; 266 break;
266 case TODO_ALARM_DATETIME : 267 case TODO_ALARM_DATETIME :
267 case TODO_SILENT_ALARM_DATETIME: 268 case TODO_SILENT_ALARM_DATETIME:
268 if (*Alarm == -1) *Alarm = i; 269 if (*Alarm == -1) *Alarm = i;
269 break; 270 break;
270 case TODO_TEXT: 271 case TODO_TEXT:
271 if (*Text == -1) *Text = i; 272 if (*Text == -1) *Text = i;
272 break; 273 break;
273 case TODO_COMPLETED: 274 case TODO_COMPLETED:
274 if (*Completed == -1) *Completed = i; 275 if (*Completed == -1) *Completed = i;
275 break; 276 break;
276 case TODO_PHONE: 277 case TODO_PHONE:
277 if (*Phone == -1) *Phone = i; 278 if (*Phone == -1) *Phone = i;
278 break; 279 break;
279 default: 280 default:
280 break; 281 break;
281 } 282 }
282 } 283 }
283} 284}
284 285
285GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) 286GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version)
286{ 287{
287 int Text, Alarm, Completed, EndTime, Phone; 288 int Text, Alarm, Completed, EndTime, Phone;
288 289
289 GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); 290 GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone);
290 291
291 if (header) { 292 if (header) {
292 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); 293 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
293 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); 294 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
294 } 295 }
295 296
296 *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); 297 *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10);
297 298
298 if (Version == Nokia_VToDo) { 299 if (Version == Nokia_VToDo) {
299 if (Text == -1) return ERR_UNKNOWN; 300 if (Text == -1) return ERR_UNKNOWN;
300 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 301 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
301 302
302 if (Completed == -1) { 303 if (Completed == -1) {
303 *Length+=sprintf(Buffer+(*Length), "STATUS:NEEDS ACTION%c%c",13,10); 304 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
304 } else { 305 } else {
305 *Length+=sprintf(Buffer+(*Length), "STATUS:COMPLETED%c%c",13,10); 306 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
306 } 307 }
307 308
308 switch (note->Priority) { 309 switch (note->Priority) {
309 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; 310 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
310 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:2%c%c",13,10); break; 311 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
311 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; 312 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
312 } 313 }
313 314
314 if (EndTime != -1) { 315 if (EndTime != -1) {
315 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DUE"); 316 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DUE");
316 } 317 }
317 318
318 if (Alarm != -1) { 319 if (Alarm != -1) {
319 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 320 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
320 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 321 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
321 } else { 322 } else {
322 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 323 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
323 } 324 }
324 } 325 }
325 } else if (Version == SonyEricsson_VToDo) { 326 } else if (Version == SonyEricsson_VToDo) {
326 if (Text == -1) return ERR_UNKNOWN; 327 if (Text == -1) return ERR_UNKNOWN;
327 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 328 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
328 329
329 if (Completed == -1) { 330 if (Completed == -1) {
330 *Length+=sprintf(Buffer+(*Length), "STATUS:NEEDS ACTION%c%c",13,10); 331 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
331 } else { 332 } else {
332 *Length+=sprintf(Buffer+(*Length), "STATUS:COMPLETED%c%c",13,10); 333 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
333 } 334 }
334 335
335 switch (note->Priority) { 336 switch (note->Priority) {
336 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; 337 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
337 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:2%c%c",13,10); break; 338 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
338 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; 339 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
339 } 340 }
340 341
341 if (Alarm != -1) { 342 if (Alarm != -1) {
342 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 343 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
343 } 344 }
344 } 345 }
345 346
347 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
346 *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); 348 *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10);
347 349
348 if (header) { 350 if (header) {
349 *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); 351 *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
350 } 352 }
351 return ERR_NONE; 353 return ERR_NONE;
352} 354}
353 355
354GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) 356GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer)
355{ 357{
356 unsigned char Line[2000],Buff[2000]; 358 unsigned char Line[2000],Buff[2000];
357 int Level = 0; 359 int Level = 0;
358 360
359 Calendar->EntriesNum = 0; 361 Calendar->EntriesNum = 0;
360 ToDo->EntriesNum = 0; 362 ToDo->EntriesNum = 0;
361 363
362 while (1) { 364 while (1) {
363 MyGetLine(Buffer, Pos, Line, strlen(Buffer)); 365 MyGetLine(Buffer, Pos, Line, strlen(Buffer));
364 if (strlen(Line) == 0) break; 366 if (strlen(Line) == 0) break;
365 switch (Level) { 367 switch (Level) {
366 case 0: 368 case 0:
367 if (strstr(Line,"BEGIN:VEVENT")) { 369 if (strstr(Line,"BEGIN:VEVENT")) {
368 Calendar->Type = GSM_CAL_MEMO; 370 Calendar->Type = GSM_CAL_MEMO;
369 Level = 1; 371 Level = 1;
370 } 372 }
371 if (strstr(Line,"BEGIN:VTODO")) { 373 if (strstr(Line,"BEGIN:VTODO")) {
372 ToDo->Priority = GSM_Priority_Low; 374 ToDo->Priority = GSM_Priority_Medium;
373 Level = 2; 375 Level = 2;
374 } 376 }
375 break; 377 break;
376 case 1: /* Calendar note */ 378 case 1: /* Calendar note */
377 if (strstr(Line,"END:VEVENT")) { 379 if (strstr(Line,"END:VEVENT")) {
378 if (Calendar->EntriesNum == 0) return ERR_EMPTY; 380 if (Calendar->EntriesNum == 0) return ERR_EMPTY;
379 return ERR_NONE; 381 return ERR_NONE;
380 } 382 }
381 if (strstr(Line,"CATEGORIES:REMINDER")) Calendar->Type = GSM_CAL_REMINDER; 383 Calendar->Type = GSM_CAL_MEETING;
382 if (strstr(Line,"CATEGORIES:DATE")) Calendar->Type = GSM_CAL_REMINDER;//SE 384 if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER;
383 if (strstr(Line,"CATEGORIES:TRAVEL")) Calendar->Type = GSM_CAL_TRAVEL; //SE 385 if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE
384 if (strstr(Line,"CATEGORIES:VACATION")) Calendar->Type = GSM_CAL_VACATION;//SE 386 if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE
385 if (strstr(Line,"CATEGORIES:MISCELLANEOUS")) Calendar->Type = GSM_CAL_MEMO; 387 if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE
386 if (strstr(Line,"CATEGORIES:PHONE CALL")) Calendar->Type = GSM_CAL_CALL; 388 if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO;
387 if (strstr(Line,"CATEGORIES:SPECIAL OCCASION")) Calendar->Type = GSM_CAL_BIRTHDAY; 389 if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL;
388 if (strstr(Line,"CATEGORIES:ANNIVERSARY")) Calendar->Type = GSM_CAL_BIRTHDAY; 390 if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY;
389 if (strstr(Line,"CATEGORIES:MEETING")) Calendar->Type = GSM_CAL_MEETING; 391 if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY;
390 if (strstr(Line,"CATEGORIES:APPOINTMENT")) Calendar->Type = GSM_CAL_MEETING; 392 if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING;
393 if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING;
391 if (strstr(Line,"RRULE:D1")) { 394 if (strstr(Line,"RRULE:D1")) {
392 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 395 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
393 Calendar->Entries[Calendar->EntriesNum].Number = 1*24; 396 Calendar->Entries[Calendar->EntriesNum].Number = 1*24;
394 Calendar->EntriesNum++; 397 Calendar->EntriesNum++;
395 } 398 }
396 if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { 399 if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) {
397 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 400 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
398 Calendar->Entries[Calendar->EntriesNum].Number = 7*24; 401 Calendar->Entries[Calendar->EntriesNum].Number = 7*24;
399 Calendar->EntriesNum++; 402 Calendar->EntriesNum++;
400 } 403 }
401 if (strstr(Line,"RRULE:W2")) { 404 if (strstr(Line,"RRULE:W2")) {
402 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 405 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
403 Calendar->Entries[Calendar->EntriesNum].Number = 14*24; 406 Calendar->Entries[Calendar->EntriesNum].Number = 14*24;
404 Calendar->EntriesNum++; 407 Calendar->EntriesNum++;
405 } 408 }
406 if (strstr(Line,"RRULE:MD1")) { 409 if (strstr(Line,"RRULE:MD1")) {
407 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 410 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
408 Calendar->Entries[Calendar->EntriesNum].Number = 30*24; 411 Calendar->Entries[Calendar->EntriesNum].Number = 30*24;
409 Calendar->EntriesNum++; 412 Calendar->EntriesNum++;
410 } 413 }
411 if (strstr(Line,"RRULE:YD1")) { 414 if (strstr(Line,"RRULE:YD1")) {
412 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 415 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
413 Calendar->Entries[Calendar->EntriesNum].Number = 365*24; 416 Calendar->Entries[Calendar->EntriesNum].Number = 365*24;
414 Calendar->EntriesNum++; 417 Calendar->EntriesNum++;
415 } 418 }
416 if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { 419 if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) {
417 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; 420 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT;
418 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); 421 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
419 Calendar->EntriesNum++; 422 Calendar->EntriesNum++;
420 } 423 }
421 if (ReadVCALText(Line, "LOCATION", Buff)) { 424 if (ReadVCALText(Line, "LOCATION", Buff)) {
422 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; 425 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION;
423 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); 426 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
424 Calendar->EntriesNum++; 427 Calendar->EntriesNum++;
425 } 428 }
426 if (ReadVCALText(Line, "DTSTART", Buff)) { 429 if (ReadVCALText(Line, "DTSTART", Buff)) {
427 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; 430 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME;
428 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 431 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
429 Calendar->EntriesNum++; 432 Calendar->EntriesNum++;
430 } 433 }
431 if (ReadVCALText(Line, "DTEND", Buff)) { 434 if (ReadVCALText(Line, "DTEND", Buff)) {
432 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; 435 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME;
433 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 436 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
434 Calendar->EntriesNum++; 437 Calendar->EntriesNum++;
435 } 438 }
436 if (ReadVCALText(Line, "DALARM", Buff)) { 439 if (ReadVCALText(Line, "DALARM", Buff)) {
437 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; 440 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME;
438 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 441 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
439 Calendar->EntriesNum++; 442 Calendar->EntriesNum++;
440 } 443 }
441 if (ReadVCALText(Line, "AALARM", Buff)) { 444 if (ReadVCALText(Line, "AALARM", Buff)) {
442 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; 445 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME;
443 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 446 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
444 Calendar->EntriesNum++; 447 Calendar->EntriesNum++;
445 } 448 }
446 break; 449 break;
447 case 2: /* ToDo note */ 450 case 2: /* ToDo note */
448 if (strstr(Line,"END:VTODO")) { 451 if (strstr(Line,"END:VTODO")) {
449 if (ToDo->EntriesNum == 0) return ERR_EMPTY; 452 if (ToDo->EntriesNum == 0) return ERR_EMPTY;
450 return ERR_NONE; 453 return ERR_NONE;
451 } 454 }
452 if (ReadVCALText(Line, "DUE", Buff)) { 455 if (ReadVCALText(Line, "DUE", Buff)) {
453 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; 456 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME;
454 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 457 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
455 ToDo->EntriesNum++; 458 ToDo->EntriesNum++;
456 } 459 }
457 if (ReadVCALText(Line, "DALARM", Buff)) { 460 if (ReadVCALText(Line, "DALARM", Buff)) {
458 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; 461 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
459 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 462 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
460 ToDo->EntriesNum++; 463 ToDo->EntriesNum++;
461 } 464 }
462 if (ReadVCALText(Line, "AALARM", Buff)) { 465 if (ReadVCALText(Line, "AALARM", Buff)) {
463 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; 466 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME;
464 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 467 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
465 ToDo->EntriesNum++; 468 ToDo->EntriesNum++;
466 } 469 }
467 if (ReadVCALText(Line, "SUMMARY", Buff)) { 470 if (ReadVCALText(Line, "SUMMARY", Buff)) {
468 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; 471 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT;
469 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); 472 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff);
470 ToDo->EntriesNum++; 473 ToDo->EntriesNum++;
471 } 474 }
472 if (ReadVCALText(Line, "PRIORITY", Buff)) { 475 if (ReadVCALText(Line, "PRIORITY", Buff)) {
473 if (ToDoVer == SonyEricsson_VToDo) { 476 if (ToDoVer == SonyEricsson_VToDo) {
474 ToDo->Priority = GSM_Priority_Low; 477 ToDo->Priority = GSM_Priority_Low;
475 if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium; 478 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
476 if (atoi(DecodeUnicodeString(Buff))==1) ToDo->Priority = GSM_Priority_High; 479 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
477 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); 480 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff));
478 } else if (ToDoVer == Nokia_VToDo) { 481 } else if (ToDoVer == Nokia_VToDo) {
479 ToDo->Priority = GSM_Priority_Low; 482 ToDo->Priority = GSM_Priority_Low;
480 if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium; 483 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
481 if (atoi(DecodeUnicodeString(Buff))==3) ToDo->Priority = GSM_Priority_High; 484 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
482 } 485 }
483 } 486 }
484 if (strstr(Line,"STATUS:COMPLETED")) { 487 if (strstr(Line,"PERCENT-COMPLETE:100")) {
485 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; 488 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED;
486 ToDo->Entries[ToDo->EntriesNum].Number = 1; 489 ToDo->Entries[ToDo->EntriesNum].Number = 1;
487 ToDo->EntriesNum++; 490 ToDo->EntriesNum++;
488 } 491 }
489 break; 492 break;
490 } 493 }
491 } 494 }
492 495
493 if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; 496 if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY;
494 return ERR_NONE; 497 return ERR_NONE;
495} 498}
496 499
497GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) 500GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note)
498{ 501{
499 *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); 502 *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10);
500 *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); 503 *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10);
501 SaveVCALText(Buffer, Length, Note->Text, "BODY"); 504 SaveVCALText(Buffer, Length, Note->Text, "BODY");
502 *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); 505 *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10);
503 506
504 return ERR_NONE; 507 return ERR_NONE;
505} 508}
506 509
507/* How should editor hadle tabs in this file? Add editor commands here. 510/* How should editor hadle tabs in this file? Add editor commands here.
508 * vim: noexpandtab sw=8 ts=8 sts=8: 511 * vim: noexpandtab sw=8 ts=8 sts=8:
509 */ 512 */
diff --git a/kdepim-desktop.pro b/kdepim-desktop.pro
new file mode 100644
index 0000000..7a3a96e
--- a/dev/null
+++ b/kdepim-desktop.pro
@@ -0,0 +1,6 @@
1
2
3TEMPLATE = subdirs
4SUBDIRS = gammu/emb/common gammu/emb/gammu libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir
5#kalarmd
6
diff --git a/kopi-desktop.pro b/kopi-desktop.pro
deleted file mode 100644
index 69c874f..0000000
--- a/kopi-desktop.pro
+++ b/dev/null
@@ -1,6 +0,0 @@
1
2
3TEMPLATE = subdirs
4SUBDIRS = gammu/emb/common libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir
5#kalarmd
6
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 7444bad..db07713 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3550 +1,3550 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#include <libkcal/phoneformat.h> 86#include <libkcal/phoneformat.h>
87#ifndef KORG_NOMAIL 87#ifndef KORG_NOMAIL
88#include "komailclient.h" 88#include "komailclient.h"
89#endif 89#endif
90#ifndef KORG_NOPRINTER 90#ifndef KORG_NOPRINTER
91#include "calprinter.h" 91#include "calprinter.h"
92#endif 92#endif
93#ifndef KORG_NOPLUGINS 93#ifndef KORG_NOPLUGINS
94#include "kocore.h" 94#include "kocore.h"
95#endif 95#endif
96#include "koeventeditor.h" 96#include "koeventeditor.h"
97#include "kotodoeditor.h" 97#include "kotodoeditor.h"
98#include "koprefs.h" 98#include "koprefs.h"
99#include "koeventviewerdialog.h" 99#include "koeventviewerdialog.h"
100#include "publishdialog.h" 100#include "publishdialog.h"
101#include "kofilterview.h" 101#include "kofilterview.h"
102#include "koglobals.h" 102#include "koglobals.h"
103#include "koviewmanager.h" 103#include "koviewmanager.h"
104#include "koagendaview.h" 104#include "koagendaview.h"
105#include "kodialogmanager.h" 105#include "kodialogmanager.h"
106#include "outgoingdialog.h" 106#include "outgoingdialog.h"
107#include "incomingdialog.h" 107#include "incomingdialog.h"
108#include "statusdialog.h" 108#include "statusdialog.h"
109#include "kdatenavigator.h" 109#include "kdatenavigator.h"
110#include "kotodoview.h" 110#include "kotodoview.h"
111#include "datenavigator.h" 111#include "datenavigator.h"
112#include "resourceview.h" 112#include "resourceview.h"
113#include "navigatorbar.h" 113#include "navigatorbar.h"
114#include "searchdialog.h" 114#include "searchdialog.h"
115#include "mainwindow.h" 115#include "mainwindow.h"
116 116
117#include "calendarview.h" 117#include "calendarview.h"
118#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
119#include <qtopia/alarmserver.h> 119#include <qtopia/alarmserver.h>
120#endif 120#endif
121#ifndef _WIN32_ 121#ifndef _WIN32_
122#include <stdlib.h> 122#include <stdlib.h>
123#include <stdio.h> 123#include <stdio.h>
124#include <unistd.h> 124#include <unistd.h>
125#else 125#else
126#include <qprocess.h> 126#include <qprocess.h>
127#endif 127#endif
128using namespace KOrg; 128using namespace KOrg;
129using namespace KCal; 129using namespace KCal;
130extern int globalFlagBlockAgenda; 130extern int globalFlagBlockAgenda;
131extern int globalFlagBlockStartup; 131extern int globalFlagBlockStartup;
132 132
133 133
134 134
135class KOBeamPrefs : public QDialog 135class KOBeamPrefs : public QDialog
136{ 136{
137 public: 137 public:
138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
139 QDialog( parent, name, true ) 139 QDialog( parent, name, true )
140 { 140 {
141 setCaption( i18n("Beam Options") ); 141 setCaption( i18n("Beam Options") );
142 QVBoxLayout* lay = new QVBoxLayout( this ); 142 QVBoxLayout* lay = new QVBoxLayout( this );
143 lay->setSpacing( 3 ); 143 lay->setSpacing( 3 );
144 lay->setMargin( 3 ); 144 lay->setMargin( 3 );
145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
146 lay->addWidget( format ); 146 lay->addWidget( format );
147 format->setExclusive ( true ) ; 147 format->setExclusive ( true ) ;
148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
149 lay->addWidget( time ); time->setExclusive ( true ) ; 149 lay->addWidget( time ); time->setExclusive ( true ) ;
150 vcal = new QRadioButton(" vCalendar ", format ); 150 vcal = new QRadioButton(" vCalendar ", format );
151 ical = new QRadioButton(" iCalendar ", format ); 151 ical = new QRadioButton(" iCalendar ", format );
152 vcal->setChecked( true ); 152 vcal->setChecked( true );
153 tz = new QRadioButton(i18n(" With timezone "), time ); 153 tz = new QRadioButton(i18n(" With timezone "), time );
154 local = new QRadioButton(i18n(" Local time "), time ); 154 local = new QRadioButton(i18n(" Local time "), time );
155 tz->setChecked( true ); 155 tz->setChecked( true );
156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
157 lay->addWidget( ok ); 157 lay->addWidget( ok );
158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
159 lay->addWidget( cancel ); 159 lay->addWidget( cancel );
160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
162 resize( 200, 200 ); 162 resize( 200, 200 );
163 } 163 }
164 164
165 bool beamVcal() { return vcal->isChecked(); } 165 bool beamVcal() { return vcal->isChecked(); }
166 bool beamLocal() { return local->isChecked(); } 166 bool beamLocal() { return local->isChecked(); }
167private: 167private:
168 QRadioButton* vcal, *ical, *local, *tz; 168 QRadioButton* vcal, *ical, *local, *tz;
169}; 169};
170class KOCatPrefs : public QDialog 170class KOCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from Events/Todos"), format ); 186 new QRadioButton(i18n("Remove from Events/Todos"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202 202
203 203
204CalendarView::CalendarView( CalendarResources *calendar, 204CalendarView::CalendarView( CalendarResources *calendar,
205 QWidget *parent, const char *name ) 205 QWidget *parent, const char *name )
206 : CalendarViewBase( parent, name ), 206 : CalendarViewBase( parent, name ),
207 mCalendar( calendar ), 207 mCalendar( calendar ),
208 mResourceManager( calendar->resourceManager() ) 208 mResourceManager( calendar->resourceManager() )
209{ 209{
210 210
211 mEventEditor = 0; 211 mEventEditor = 0;
212 mTodoEditor = 0; 212 mTodoEditor = 0;
213 213
214 init(); 214 init();
215} 215}
216 216
217CalendarView::CalendarView( Calendar *calendar, 217CalendarView::CalendarView( Calendar *calendar,
218 QWidget *parent, const char *name ) 218 QWidget *parent, const char *name )
219 : CalendarViewBase( parent, name ), 219 : CalendarViewBase( parent, name ),
220 mCalendar( calendar ), 220 mCalendar( calendar ),
221 mResourceManager( 0 ) 221 mResourceManager( 0 )
222{ 222{
223 223
224 mEventEditor = 0; 224 mEventEditor = 0;
225 mTodoEditor = 0; 225 mTodoEditor = 0;
226 init();} 226 init();}
227 227
228void CalendarView::init() 228void CalendarView::init()
229{ 229{
230 beamDialog = new KOBeamPrefs(); 230 beamDialog = new KOBeamPrefs();
231 mDatePickerMode = 0; 231 mDatePickerMode = 0;
232 mCurrentSyncDevice = ""; 232 mCurrentSyncDevice = "";
233 writeLocale(); 233 writeLocale();
234 mViewManager = new KOViewManager( this ); 234 mViewManager = new KOViewManager( this );
235 mDialogManager = new KODialogManager( this ); 235 mDialogManager = new KODialogManager( this );
236 mEventViewerDialog = 0; 236 mEventViewerDialog = 0;
237 mModified = false; 237 mModified = false;
238 mReadOnly = false; 238 mReadOnly = false;
239 mSelectedIncidence = 0; 239 mSelectedIncidence = 0;
240 mCalPrinter = 0; 240 mCalPrinter = 0;
241 mFilters.setAutoDelete(true); 241 mFilters.setAutoDelete(true);
242 242
243 mCalendar->registerObserver( this ); 243 mCalendar->registerObserver( this );
244 // TODO: Make sure that view is updated, when calendar is changed. 244 // TODO: Make sure that view is updated, when calendar is changed.
245 245
246 mStorage = new FileStorage( mCalendar ); 246 mStorage = new FileStorage( mCalendar );
247 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 247 mNavigator = new DateNavigator( this, "datevav", mViewManager );
248 248
249 QBoxLayout *topLayout = (QBoxLayout*)layout(); 249 QBoxLayout *topLayout = (QBoxLayout*)layout();
250#ifndef KORG_NOSPLITTER 250#ifndef KORG_NOSPLITTER
251 // create the main layout frames. 251 // create the main layout frames.
252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
253 topLayout->addWidget(mPanner); 253 topLayout->addWidget(mPanner);
254 254
255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
256 "CalendarView::LeftFrame"); 256 "CalendarView::LeftFrame");
257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
258 258
259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
260 "CalendarView::DateNavigator", QDate::currentDate() ); 260 "CalendarView::DateNavigator", QDate::currentDate() );
261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
264 264
265#ifdef KORG_NORESOURCEVIEW 265#ifdef KORG_NORESOURCEVIEW
266 mResourceView = 0; 266 mResourceView = 0;
267#else 267#else
268 if ( mResourceManager ) { 268 if ( mResourceManager ) {
269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
270 mResourceView->updateView(); 270 mResourceView->updateView();
271 connect( mResourceView, SIGNAL( resourcesChanged() ), 271 connect( mResourceView, SIGNAL( resourcesChanged() ),
272 SLOT( updateView() ) ); 272 SLOT( updateView() ) );
273 } else { 273 } else {
274 mResourceView = 0; 274 mResourceView = 0;
275 } 275 }
276#endif 276#endif
277 QWidget *rightBox = new QWidget( mPanner ); 277 QWidget *rightBox = new QWidget( mPanner );
278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
279 279
280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
281 rightLayout->addWidget( mNavigatorBar ); 281 rightLayout->addWidget( mNavigatorBar );
282 282
283 mRightFrame = new QWidgetStack( rightBox ); 283 mRightFrame = new QWidgetStack( rightBox );
284 rightLayout->addWidget( mRightFrame, 1 ); 284 rightLayout->addWidget( mRightFrame, 1 );
285 285
286 mLeftFrame = mLeftSplitter; 286 mLeftFrame = mLeftSplitter;
287#else 287#else
288 QWidget *mainBox = new QWidget( this ); 288 QWidget *mainBox = new QWidget( this );
289 QWidget *leftFrame = new QWidget( mainBox ); 289 QWidget *leftFrame = new QWidget( mainBox );
290 290
291 QBoxLayout * mainBoxLayout; 291 QBoxLayout * mainBoxLayout;
292 QBoxLayout * leftFrameLayout; 292 QBoxLayout * leftFrameLayout;
293 if ( KOPrefs::instance()->mVerticalScreen ) { 293 if ( KOPrefs::instance()->mVerticalScreen ) {
294 mainBoxLayout = new QVBoxLayout(mainBox); 294 mainBoxLayout = new QVBoxLayout(mainBox);
295 leftFrameLayout = new QHBoxLayout(leftFrame ); 295 leftFrameLayout = new QHBoxLayout(leftFrame );
296 } else { 296 } else {
297 mainBoxLayout = new QHBoxLayout(mainBox); 297 mainBoxLayout = new QHBoxLayout(mainBox);
298 leftFrameLayout = new QVBoxLayout(leftFrame ); 298 leftFrameLayout = new QVBoxLayout(leftFrame );
299 } 299 }
300 topLayout->addWidget( mainBox ); 300 topLayout->addWidget( mainBox );
301 mainBoxLayout->addWidget (leftFrame); 301 mainBoxLayout->addWidget (leftFrame);
302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
303 "CalendarView::DateNavigator", QDate::currentDate()); 303 "CalendarView::DateNavigator", QDate::currentDate());
304 // mDateNavigator->blockSignals( true ); 304 // mDateNavigator->blockSignals( true );
305 leftFrameLayout->addWidget( mDateNavigator ); 305 leftFrameLayout->addWidget( mDateNavigator );
306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
308 308
309 if ( QApplication::desktop()->width() < 480 ) { 309 if ( QApplication::desktop()->width() < 480 ) {
310 leftFrameLayout->addWidget(mFilterView); 310 leftFrameLayout->addWidget(mFilterView);
311 leftFrameLayout->addWidget(mTodoList, 2 ); 311 leftFrameLayout->addWidget(mTodoList, 2 );
312 312
313 } else { 313 } else {
314 leftFrameLayout->addWidget(mTodoList,2 ); 314 leftFrameLayout->addWidget(mTodoList,2 );
315 leftFrameLayout->addWidget(mFilterView ); 315 leftFrameLayout->addWidget(mFilterView );
316 } 316 }
317 mFilterView->hide(); 317 mFilterView->hide();
318 QWidget *rightBox = new QWidget( mainBox ); 318 QWidget *rightBox = new QWidget( mainBox );
319 mainBoxLayout->addWidget ( rightBox, 10 ); 319 mainBoxLayout->addWidget ( rightBox, 10 );
320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
322 mRightFrame = new QWidgetStack( rightBox ); 322 mRightFrame = new QWidgetStack( rightBox );
323 rightLayout->addWidget( mNavigatorBar ); 323 rightLayout->addWidget( mNavigatorBar );
324 rightLayout->addWidget( mRightFrame, 10 ); 324 rightLayout->addWidget( mRightFrame, 10 );
325 325
326 mLeftFrame = leftFrame; 326 mLeftFrame = leftFrame;
327 if ( KOPrefs::instance()->mVerticalScreen ) { 327 if ( KOPrefs::instance()->mVerticalScreen ) {
328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
330 } else { 330 } else {
331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
333 } 333 }
334 334
335 //qDebug("Calendarview Size %d %d ", width(), height()); 335 //qDebug("Calendarview Size %d %d ", width(), height());
336#endif 336#endif
337 337
338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
339 SLOT( showDates( const KCal::DateList & ) ) ); 339 SLOT( showDates( const KCal::DateList & ) ) );
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
342 342
343 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 343 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
344 mNavigator, SLOT( selectPreviousYear() ) ); 344 mNavigator, SLOT( selectPreviousYear() ) );
345 connect( mNavigatorBar, SIGNAL( goNextYear() ), 345 connect( mNavigatorBar, SIGNAL( goNextYear() ),
346 mNavigator, SLOT( selectNextYear() ) ); 346 mNavigator, SLOT( selectNextYear() ) );
347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
348 mNavigator, SLOT( selectPreviousMonth() ) ); 348 mNavigator, SLOT( selectPreviousMonth() ) );
349 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 349 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
350 mNavigator, SLOT( selectNextMonth() ) ); 350 mNavigator, SLOT( selectNextMonth() ) );
351 351
352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
354 354
355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
356 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 356 mNavigator, SLOT( selectWeek( const QDate & ) ) );
357 357
358 connect( mDateNavigator, SIGNAL( goPrevYear() ), 358 connect( mDateNavigator, SIGNAL( goPrevYear() ),
359 mNavigator, SLOT( selectPreviousYear() ) ); 359 mNavigator, SLOT( selectPreviousYear() ) );
360 connect( mDateNavigator, SIGNAL( goNextYear() ), 360 connect( mDateNavigator, SIGNAL( goNextYear() ),
361 mNavigator, SLOT( selectNextYear() ) ); 361 mNavigator, SLOT( selectNextYear() ) );
362 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 362 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
363 mNavigator, SLOT( selectPreviousMonth() ) ); 363 mNavigator, SLOT( selectPreviousMonth() ) );
364 connect( mDateNavigator, SIGNAL( goNextMonth() ), 364 connect( mDateNavigator, SIGNAL( goNextMonth() ),
365 mNavigator, SLOT( selectNextMonth() ) ); 365 mNavigator, SLOT( selectNextMonth() ) );
366 366
367 connect( mDateNavigator, SIGNAL( goPrevious() ), 367 connect( mDateNavigator, SIGNAL( goPrevious() ),
368 mNavigator, SLOT( selectPrevious() ) ); 368 mNavigator, SLOT( selectPrevious() ) );
369 connect( mDateNavigator, SIGNAL( goNext() ), 369 connect( mDateNavigator, SIGNAL( goNext() ),
370 mNavigator, SLOT( selectNext() ) ); 370 mNavigator, SLOT( selectNext() ) );
371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
372 mNavigator, SLOT( slotMonthSelect( int ) ) ); 372 mNavigator, SLOT( slotMonthSelect( int ) ) );
373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 375
376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
378 378
379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
380 SLOT( eventAdded( Event *) ) ); 380 SLOT( eventAdded( Event *) ) );
381 381
382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
383 383
384 connect( this, SIGNAL( configChanged() ), 384 connect( this, SIGNAL( configChanged() ),
385 mDateNavigator, SLOT( updateConfig() ) ); 385 mDateNavigator, SLOT( updateConfig() ) );
386 386
387 connect( mTodoList, SIGNAL( newTodoSignal() ), 387 connect( mTodoList, SIGNAL( newTodoSignal() ),
388 SLOT( newTodo() ) ); 388 SLOT( newTodo() ) );
389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
390 SLOT( newSubTodo( Todo * ) ) ); 390 SLOT( newSubTodo( Todo * ) ) );
391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
392 SLOT( editTodo( Todo * ) ) ); 392 SLOT( editTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
394 SLOT( showTodo( Todo *) ) ); 394 SLOT( showTodo( Todo *) ) );
395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
396 SLOT( deleteTodo( Todo *) ) ); 396 SLOT( deleteTodo( Todo *) ) );
397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
399 SLOT( purgeCompleted() ) ); 399 SLOT( purgeCompleted() ) );
400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
401 SIGNAL( todoModified( Todo *, int ) ) ); 401 SIGNAL( todoModified( Todo *, int ) ) );
402 402
403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
404 this, SLOT ( cloneIncidence( Incidence * ) ) ); 404 this, SLOT ( cloneIncidence( Incidence * ) ) );
405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
406 this, SLOT (cancelIncidence( Incidence * ) ) ); 406 this, SLOT (cancelIncidence( Incidence * ) ) );
407 407
408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
409 this, SLOT ( moveIncidence( Incidence * ) ) ); 409 this, SLOT ( moveIncidence( Incidence * ) ) );
410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
411 this, SLOT ( beamIncidence( Incidence * ) ) ); 411 this, SLOT ( beamIncidence( Incidence * ) ) );
412 412
413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
414 this, SLOT ( todo_unsub( Todo * ) ) ); 414 this, SLOT ( todo_unsub( Todo * ) ) );
415 415
416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
417 SLOT( updateTodo( Todo *, int ) ) ); 417 SLOT( updateTodo( Todo *, int ) ) );
418 connect( this, SIGNAL( todoModified( Todo *, int )), this, 418 connect( this, SIGNAL( todoModified( Todo *, int )), this,
419 SLOT( changeTodoDisplay( Todo *, int ) ) ); 419 SLOT( changeTodoDisplay( Todo *, int ) ) );
420 420
421 421
422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
426 426
427 427
428 428
429 429
430 430
431 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 431 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
432 SLOT(checkClipboard())); 432 SLOT(checkClipboard()));
433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
434 SLOT( processTodoListSelection( Incidence * ) ) ); 434 SLOT( processTodoListSelection( Incidence * ) ) );
435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
436 436
437 // kdDebug() << "CalendarView::CalendarView() done" << endl; 437 // kdDebug() << "CalendarView::CalendarView() done" << endl;
438 438
439 mDateFrame = new QVBox(0,0,WType_Popup); 439 mDateFrame = new QVBox(0,0,WType_Popup);
440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
442 mDateFrame->setLineWidth(3); 442 mDateFrame->setLineWidth(3);
443 mDateFrame->hide(); 443 mDateFrame->hide();
444 mDateFrame->setCaption( i18n( "Pick a date to display")); 444 mDateFrame->setCaption( i18n( "Pick a date to display"));
445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
446 446
447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
448 448
449 mEventEditor = mDialogManager->getEventEditor(); 449 mEventEditor = mDialogManager->getEventEditor();
450 mTodoEditor = mDialogManager->getTodoEditor(); 450 mTodoEditor = mDialogManager->getTodoEditor();
451 451
452 mFlagEditDescription = false; 452 mFlagEditDescription = false;
453 453
454 mSuspendTimer = new QTimer( this ); 454 mSuspendTimer = new QTimer( this );
455 mAlarmTimer = new QTimer( this ); 455 mAlarmTimer = new QTimer( this );
456 mRecheckAlarmTimer = new QTimer( this ); 456 mRecheckAlarmTimer = new QTimer( this );
457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 460 mAlarmDialog = new AlarmDialog( this );
461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
462 mAlarmDialog->setServerNotification( false ); 462 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 464}
465 465
466 466
467CalendarView::~CalendarView() 467CalendarView::~CalendarView()
468{ 468{
469 // kdDebug() << "~CalendarView()" << endl; 469 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 470 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 471 delete mDialogManager;
472 delete mViewManager; 472 delete mViewManager;
473 delete mStorage; 473 delete mStorage;
474 delete mDateFrame ; 474 delete mDateFrame ;
475 delete beamDialog; 475 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 476 //kdDebug() << "~CalendarView() done" << endl;
477} 477}
478void CalendarView::timerAlarm() 478void CalendarView::timerAlarm()
479{ 479{
480 //qDebug("CalendarView::timerAlarm() "); 480 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 481 computeAlarm(mAlarmNotification );
482} 482}
483 483
484void CalendarView::suspendAlarm() 484void CalendarView::suspendAlarm()
485{ 485{
486 //qDebug(" CalendarView::suspendAlarm() "); 486 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 487 computeAlarm(mSuspendAlarmNotification );
488 488
489} 489}
490 490
491void CalendarView::startAlarm( QString mess , QString filename) 491void CalendarView::startAlarm( QString mess , QString filename)
492{ 492{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
495 495
496} 496}
497 497
498void CalendarView::checkNextTimerAlarm() 498void CalendarView::checkNextTimerAlarm()
499{ 499{
500 mCalendar->checkAlarmForIncidence( 0, true ); 500 mCalendar->checkAlarmForIncidence( 0, true );
501} 501}
502 502
503void CalendarView::computeAlarm( QString msg ) 503void CalendarView::computeAlarm( QString msg )
504{ 504{
505 505
506 QString mess = msg; 506 QString mess = msg;
507 QString mAlarmMessage = mess.mid( 9 ); 507 QString mAlarmMessage = mess.mid( 9 );
508 QString filename = MainWindow::resourcePath(); 508 QString filename = MainWindow::resourcePath();
509 filename += "koalarm.wav"; 509 filename += "koalarm.wav";
510 QString tempfilename; 510 QString tempfilename;
511 if ( mess.left( 13 ) == "suspend_alarm") { 511 if ( mess.left( 13 ) == "suspend_alarm") {
512 bool error = false; 512 bool error = false;
513 int len = mess.mid( 13 ).find("+++"); 513 int len = mess.mid( 13 ).find("+++");
514 if ( len < 2 ) 514 if ( len < 2 )
515 error = true; 515 error = true;
516 else { 516 else {
517 tempfilename = mess.mid( 13, len ); 517 tempfilename = mess.mid( 13, len );
518 if ( !QFile::exists( tempfilename ) ) 518 if ( !QFile::exists( tempfilename ) )
519 error = true; 519 error = true;
520 } 520 }
521 if ( ! error ) { 521 if ( ! error ) {
522 filename = tempfilename; 522 filename = tempfilename;
523 } 523 }
524 mAlarmMessage = mess.mid( 13+len+3 ); 524 mAlarmMessage = mess.mid( 13+len+3 );
525 //qDebug("suspend file %s ",tempfilename.latin1() ); 525 //qDebug("suspend file %s ",tempfilename.latin1() );
526 startAlarm( mAlarmMessage, filename); 526 startAlarm( mAlarmMessage, filename);
527 return; 527 return;
528 } 528 }
529 if ( mess.left( 11 ) == "timer_alarm") { 529 if ( mess.left( 11 ) == "timer_alarm") {
530 //mTimerTime = 0; 530 //mTimerTime = 0;
531 startAlarm( mess.mid( 11 ), filename ); 531 startAlarm( mess.mid( 11 ), filename );
532 return; 532 return;
533 } 533 }
534 if ( mess.left( 10 ) == "proc_alarm") { 534 if ( mess.left( 10 ) == "proc_alarm") {
535 bool error = false; 535 bool error = false;
536 int len = mess.mid( 10 ).find("+++"); 536 int len = mess.mid( 10 ).find("+++");
537 if ( len < 2 ) 537 if ( len < 2 )
538 error = true; 538 error = true;
539 else { 539 else {
540 tempfilename = mess.mid( 10, len ); 540 tempfilename = mess.mid( 10, len );
541 if ( !QFile::exists( tempfilename ) ) 541 if ( !QFile::exists( tempfilename ) )
542 error = true; 542 error = true;
543 } 543 }
544 if ( error ) { 544 if ( error ) {
545 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 545 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
546 mAlarmMessage += mess.mid( 10+len+3+9 ); 546 mAlarmMessage += mess.mid( 10+len+3+9 );
547 } else { 547 } else {
548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
549 //qDebug("-----system command %s ",tempfilename.latin1() ); 549 //qDebug("-----system command %s ",tempfilename.latin1() );
550#ifndef _WIN32_ 550#ifndef _WIN32_
551 if ( vfork () == 0 ) { 551 if ( vfork () == 0 ) {
552 execl ( tempfilename.latin1(), 0 ); 552 execl ( tempfilename.latin1(), 0 );
553 return; 553 return;
554 } 554 }
555#else 555#else
556 QProcess* p = new QProcess(); 556 QProcess* p = new QProcess();
557 p->addArgument( tempfilename.latin1() ); 557 p->addArgument( tempfilename.latin1() );
558 p->start(); 558 p->start();
559 return; 559 return;
560#endif 560#endif
561 561
562 return; 562 return;
563 } 563 }
564 564
565 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 565 //qDebug("+++++++system command %s ",tempfilename.latin1() );
566 } 566 }
567 if ( mess.left( 11 ) == "audio_alarm") { 567 if ( mess.left( 11 ) == "audio_alarm") {
568 bool error = false; 568 bool error = false;
569 int len = mess.mid( 11 ).find("+++"); 569 int len = mess.mid( 11 ).find("+++");
570 if ( len < 2 ) 570 if ( len < 2 )
571 error = true; 571 error = true;
572 else { 572 else {
573 tempfilename = mess.mid( 11, len ); 573 tempfilename = mess.mid( 11, len );
574 if ( !QFile::exists( tempfilename ) ) 574 if ( !QFile::exists( tempfilename ) )
575 error = true; 575 error = true;
576 } 576 }
577 if ( ! error ) { 577 if ( ! error ) {
578 filename = tempfilename; 578 filename = tempfilename;
579 } 579 }
580 mAlarmMessage = mess.mid( 11+len+3+9 ); 580 mAlarmMessage = mess.mid( 11+len+3+9 );
581 //qDebug("audio file command %s ",tempfilename.latin1() ); 581 //qDebug("audio file command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 9 ) == "cal_alarm") { 583 if ( mess.left( 9 ) == "cal_alarm") {
584 mAlarmMessage = mess.mid( 9 ) ; 584 mAlarmMessage = mess.mid( 9 ) ;
585 } 585 }
586 586
587 startAlarm( mAlarmMessage, filename ); 587 startAlarm( mAlarmMessage, filename );
588 588
589 589
590} 590}
591 591
592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
593{ 593{
594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
595 595
596 mSuspendAlarmNotification = noti; 596 mSuspendAlarmNotification = noti;
597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
599 mSuspendTimer->start( ms , true ); 599 mSuspendTimer->start( ms , true );
600 600
601} 601}
602 602
603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
604{ 604{
605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
607#ifndef DESKTOP_VERSION 607#ifndef DESKTOP_VERSION
608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
609#endif 609#endif
610 return; 610 return;
611 } 611 }
612 int maxSec; 612 int maxSec;
613 //maxSec = 5; //testing only 613 //maxSec = 5; //testing only
614 maxSec = 86400+3600; // one day+1hour 614 maxSec = 86400+3600; // one day+1hour
615 mAlarmNotification = noti; 615 mAlarmNotification = noti;
616 int sec = QDateTime::currentDateTime().secsTo( qdt ); 616 int sec = QDateTime::currentDateTime().secsTo( qdt );
617 if ( sec > maxSec ) { 617 if ( sec > maxSec ) {
618 mRecheckAlarmTimer->start( maxSec * 1000 ); 618 mRecheckAlarmTimer->start( maxSec * 1000 );
619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
620 return; 620 return;
621 } else { 621 } else {
622 mRecheckAlarmTimer->stop(); 622 mRecheckAlarmTimer->stop();
623 } 623 }
624 //qDebug("Alarm timer started with secs: %d ", sec); 624 //qDebug("Alarm timer started with secs: %d ", sec);
625 mAlarmTimer->start( sec *1000 , true ); 625 mAlarmTimer->start( sec *1000 , true );
626 626
627} 627}
628// called by mRecheckAlarmTimer to get next alarm 628// called by mRecheckAlarmTimer to get next alarm
629// we need this, because a QTimer has only a max range of 25 days 629// we need this, because a QTimer has only a max range of 25 days
630void CalendarView::recheckTimerAlarm() 630void CalendarView::recheckTimerAlarm()
631{ 631{
632 mAlarmTimer->stop(); 632 mAlarmTimer->stop();
633 mRecheckAlarmTimer->stop(); 633 mRecheckAlarmTimer->stop();
634 mCalendar->checkAlarmForIncidence( 0, true ); 634 mCalendar->checkAlarmForIncidence( 0, true );
635} 635}
636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
637{ 637{
638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
640#ifndef DESKTOP_VERSION 640#ifndef DESKTOP_VERSION
641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
642#endif 642#endif
643 return; 643 return;
644 } 644 }
645 mAlarmTimer->stop(); 645 mAlarmTimer->stop();
646} 646}
647void CalendarView::selectWeekNum ( int num ) 647void CalendarView::selectWeekNum ( int num )
648{ 648{
649 dateNavigator()->selectWeek( num ); 649 dateNavigator()->selectWeek( num );
650 mViewManager->showWeekView(); 650 mViewManager->showWeekView();
651} 651}
652KOViewManager *CalendarView::viewManager() 652KOViewManager *CalendarView::viewManager()
653{ 653{
654 return mViewManager; 654 return mViewManager;
655} 655}
656 656
657KODialogManager *CalendarView::dialogManager() 657KODialogManager *CalendarView::dialogManager()
658{ 658{
659 return mDialogManager; 659 return mDialogManager;
660} 660}
661 661
662QDate CalendarView::startDate() 662QDate CalendarView::startDate()
663{ 663{
664 DateList dates = mNavigator->selectedDates(); 664 DateList dates = mNavigator->selectedDates();
665 665
666 return dates.first(); 666 return dates.first();
667} 667}
668 668
669QDate CalendarView::endDate() 669QDate CalendarView::endDate()
670{ 670{
671 DateList dates = mNavigator->selectedDates(); 671 DateList dates = mNavigator->selectedDates();
672 672
673 return dates.last(); 673 return dates.last();
674} 674}
675 675
676 676
677void CalendarView::createPrinter() 677void CalendarView::createPrinter()
678{ 678{
679#ifndef KORG_NOPRINTER 679#ifndef KORG_NOPRINTER
680 if (!mCalPrinter) { 680 if (!mCalPrinter) {
681 mCalPrinter = new CalPrinter(this, mCalendar); 681 mCalPrinter = new CalPrinter(this, mCalendar);
682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
683 } 683 }
684#endif 684#endif
685} 685}
686 686
687void CalendarView::confSync() 687void CalendarView::confSync()
688{ 688{
689 static KSyncPrefsDialog* sp = 0; 689 static KSyncPrefsDialog* sp = 0;
690 if ( ! sp ) { 690 if ( ! sp ) {
691 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 691 sp = new KSyncPrefsDialog( this, "syncprefs", true );
692 } 692 }
693 sp->usrReadConfig(); 693 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 695 sp->showMaximized();
696#else 696#else
697 sp->show(); 697 sp->show();
698#endif 698#endif
699 sp->exec(); 699 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 702}
703 703
704 704
705//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
707 707
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 714
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 716{
717 717
718 //void setZaurusId(int id); 718 //void setZaurusId(int id);
719 // int zaurusId() const; 719 // int zaurusId() const;
720 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
721 // int zaurusUid() const; 721 // int zaurusUid() const;
722 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
723 // int zaurusStat() const; 723 // int zaurusStat() const;
724 // 0 equal 724 // 0 equal
725 // 1 take local 725 // 1 take local
726 // 2 take remote 726 // 2 take remote
727 // 3 cancel 727 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 730 bool remCh, locCh;
731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
732 locCh = ( local->lastModified() > mLastCalendarSync ); 732 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 735 //qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 736 lastSync = local->lastModified().addDays(1);
737 } else { 737 } else {
738 if ( locCh ) { 738 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 740 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 741 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 742 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 743 } else {
744 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 745 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 746 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 747 remote->setLastModified( lastSync.addDays( 1 ) );
748 748
749 } 749 }
750 } 750 }
751 full = true; 751 full = true;
752 if ( mode < SYNC_PREF_ASK ) 752 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 753 mode = SYNC_PREF_ASK;
754 } else { 754 } else {
755 if ( local->lastModified() == remote->lastModified() ) 755 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 756 if ( local->revision() == remote->revision() )
757 return 0; 757 return 0;
758 758
759 } 759 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 761
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 764 //full = true; //debug only
765 if ( full ) { 765 if ( full ) {
766 bool equ = false; 766 bool equ = false;
767 if ( local->type() == "Event" ) { 767 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 768 equ = (*((Event*) local) == *((Event*) remote));
769 } 769 }
770 else if ( local->type() =="Todo" ) 770 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 771 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 772 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 773 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 774 if ( equ ) {
775 //qDebug("equal "); 775 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
778 } 778 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 779 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 780 return 0;
781 781
782 }//else //debug only 782 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 784 }
785 int result; 785 int result;
786 bool localIsNew; 786 bool localIsNew;
787 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
789 789
790 switch( mode ) { 790 switch( mode ) {
791 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 792 if ( lastSync > remote->lastModified() )
793 return 1; 793 return 1;
794 if ( lastSync > local->lastModified() ) 794 if ( lastSync > local->lastModified() )
795 return 2; 795 return 2;
796 return 1; 796 return 1;
797 break; 797 break;
798 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 799 if ( lastSync > remote->lastModified() )
800 return 1; 800 return 1;
801 if ( lastSync > local->lastModified() ) 801 if ( lastSync > local->lastModified() )
802 return 2; 802 return 2;
803 return 2; 803 return 2;
804 break; 804 break;
805 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 806 if ( local->lastModified() > remote->lastModified() )
807 return 1; 807 return 1;
808 else 808 else
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 813 if ( lastSync > remote->lastModified() )
814 return 1; 814 return 1;
815 if ( lastSync > local->lastModified() ) 815 if ( lastSync > local->lastModified() )
816 return 2; 816 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 818 localIsNew = local->lastModified() > remote->lastModified();
819 if ( localIsNew ) 819 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
821 else 821 else
822 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 824 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 else 826 else
827 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 834 return result;
835 835
836 break; 836 break;
837 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 838 return 1;
839 break; 839 break;
840 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 841 return 2;
842 break; 842 break;
843 843
844 default: 844 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 858 QString sum = "";
859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 860 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
867 } 867 }
868 868
869 return lse; 869 return lse;
870 870
871} 871}
872// probaly useless 872// probaly useless
873void CalendarView::setupExternSyncProfiles() 873void CalendarView::setupExternSyncProfiles()
874{ 874{
875 Event* lse; 875 Event* lse;
876 mExternLastSyncEvent.clear(); 876 mExternLastSyncEvent.clear();
877 int i; 877 int i;
878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
880 if ( lse ) 880 if ( lse )
881 mExternLastSyncEvent.append( lse ); 881 mExternLastSyncEvent.append( lse );
882 else 882 else
883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
884 } 884 }
885 885
886} 886}
887// we check, if the to delete event has a id for a profile 887// we check, if the to delete event has a id for a profile
888// if yes, we set this id in the profile to delete 888// if yes, we set this id in the profile to delete
889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
890{ 890{
891 if ( lastSync.count() == 0 ) { 891 if ( lastSync.count() == 0 ) {
892 //qDebug(" lastSync.count() == 0"); 892 //qDebug(" lastSync.count() == 0");
893 return; 893 return;
894 } 894 }
895 if ( toDelete->type() == "Journal" ) 895 if ( toDelete->type() == "Journal" )
896 return; 896 return;
897 897
898 Event* eve = lastSync.first(); 898 Event* eve = lastSync.first();
899 899
900 while ( eve ) { 900 while ( eve ) {
901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
902 if ( !id.isEmpty() ) { 902 if ( !id.isEmpty() ) {
903 QString des = eve->description(); 903 QString des = eve->description();
904 QString pref = "e"; 904 QString pref = "e";
905 if ( toDelete->type() == "Todo" ) 905 if ( toDelete->type() == "Todo" )
906 pref = "t"; 906 pref = "t";
907 des += pref+ id + ","; 907 des += pref+ id + ",";
908 eve->setReadOnly( false ); 908 eve->setReadOnly( false );
909 eve->setDescription( des ); 909 eve->setDescription( des );
910 //qDebug("setdes %s ", des.latin1()); 910 //qDebug("setdes %s ", des.latin1());
911 eve->setReadOnly( true ); 911 eve->setReadOnly( true );
912 } 912 }
913 eve = lastSync.next(); 913 eve = lastSync.next();
914 } 914 }
915 915
916} 916}
917void CalendarView::checkExternalId( Incidence * inc ) 917void CalendarView::checkExternalId( Incidence * inc )
918{ 918{
919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
920 checkExternSyncEvent( lastSync, inc ); 920 checkExternSyncEvent( lastSync, inc );
921 921
922} 922}
923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
924{ 924{
925 bool syncOK = true; 925 bool syncOK = true;
926 int addedEvent = 0; 926 int addedEvent = 0;
927 int addedEventR = 0; 927 int addedEventR = 0;
928 int deletedEventR = 0; 928 int deletedEventR = 0;
929 int deletedEventL = 0; 929 int deletedEventL = 0;
930 int changedLocal = 0; 930 int changedLocal = 0;
931 int changedRemote = 0; 931 int changedRemote = 0;
932 //QPtrList<Event> el = local->rawEvents(); 932 //QPtrList<Event> el = local->rawEvents();
933 Event* eventR; 933 Event* eventR;
934 QString uid; 934 QString uid;
935 int take; 935 int take;
936 Event* eventL; 936 Event* eventL;
937 Event* eventRSync; 937 Event* eventRSync;
938 Event* eventLSync; 938 Event* eventLSync;
939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
941 bool fullDateRange = false; 941 bool fullDateRange = false;
942 local->resetTempSyncStat(); 942 local->resetTempSyncStat();
943 mLastCalendarSync = QDateTime::currentDateTime(); 943 mLastCalendarSync = QDateTime::currentDateTime();
944 QDateTime modifiedCalendar = mLastCalendarSync;; 944 QDateTime modifiedCalendar = mLastCalendarSync;;
945 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 945 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
946 if ( eventR ) { 946 if ( eventR ) {
947 eventRSync = (Event*) eventR->clone(); 947 eventRSync = (Event*) eventR->clone();
948 remote->deleteEvent(eventR ); 948 remote->deleteEvent(eventR );
949 949
950 } else { 950 } else {
951 fullDateRange = true; 951 fullDateRange = true;
952 eventRSync = new Event(); 952 eventRSync = new Event();
953 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 953 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
954 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 954 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
955 eventRSync->setDtStart( mLastCalendarSync ); 955 eventRSync->setDtStart( mLastCalendarSync );
956 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 956 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
957 eventRSync->setCategories( i18n("SyncEvent") ); 957 eventRSync->setCategories( i18n("SyncEvent") );
958 } 958 }
959 eventLSync = getLastSyncEvent(); 959 eventLSync = getLastSyncEvent();
960 if ( eventLSync->dtStart() == mLastCalendarSync ) 960 if ( eventLSync->dtStart() == mLastCalendarSync )
961 fullDateRange = true; 961 fullDateRange = true;
962 962
963 if ( ! fullDateRange ) { 963 if ( ! fullDateRange ) {
964 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 964 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
965 965
966 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 966 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
967 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 967 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
968 fullDateRange = true; 968 fullDateRange = true;
969 } 969 }
970 } 970 }
971 if ( fullDateRange ) 971 if ( fullDateRange )
972 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 972 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
973 else 973 else
974 mLastCalendarSync = eventLSync->dtStart(); 974 mLastCalendarSync = eventLSync->dtStart();
975 // for resyncing if own file has changed 975 // for resyncing if own file has changed
976 if ( mCurrentSyncDevice == "deleteaftersync" ) { 976 if ( mCurrentSyncDevice == "deleteaftersync" ) {
977 mLastCalendarSync = loadedFileVersion; 977 mLastCalendarSync = loadedFileVersion;
978 qDebug("setting mLastCalendarSync "); 978 qDebug("setting mLastCalendarSync ");
979 } 979 }
980 //qDebug("*************************** "); 980 //qDebug("*************************** ");
981 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 981 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
982 QPtrList<Incidence> er = remote->rawIncidences(); 982 QPtrList<Incidence> er = remote->rawIncidences();
983 Incidence* inR = er.first(); 983 Incidence* inR = er.first();
984 Incidence* inL; 984 Incidence* inL;
985 QProgressBar bar( er.count(),0 ); 985 QProgressBar bar( er.count(),0 );
986 bar.setCaption (i18n("Syncing - close to abort!") ); 986 bar.setCaption (i18n("Syncing - close to abort!") );
987 987
988 int w = 300; 988 int w = 300;
989 if ( QApplication::desktop()->width() < 320 ) 989 if ( QApplication::desktop()->width() < 320 )
990 w = 220; 990 w = 220;
991 int h = bar.sizeHint().height() ; 991 int h = bar.sizeHint().height() ;
992 int dw = QApplication::desktop()->width(); 992 int dw = QApplication::desktop()->width();
993 int dh = QApplication::desktop()->height(); 993 int dh = QApplication::desktop()->height();
994 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 994 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
995 bar.show(); 995 bar.show();
996 int modulo = (er.count()/10)+1; 996 int modulo = (er.count()/10)+1;
997 int incCounter = 0; 997 int incCounter = 0;
998 while ( inR ) { 998 while ( inR ) {
999 if ( ! bar.isVisible() ) 999 if ( ! bar.isVisible() )
1000 return false; 1000 return false;
1001 if ( incCounter % modulo == 0 ) 1001 if ( incCounter % modulo == 0 )
1002 bar.setProgress( incCounter ); 1002 bar.setProgress( incCounter );
1003 ++incCounter; 1003 ++incCounter;
1004 uid = inR->uid(); 1004 uid = inR->uid();
1005 bool skipIncidence = false; 1005 bool skipIncidence = false;
1006 if ( uid.left(15) == QString("last-syncEvent-") ) 1006 if ( uid.left(15) == QString("last-syncEvent-") )
1007 skipIncidence = true; 1007 skipIncidence = true;
1008 1008
1009 qApp->processEvents(); 1009 qApp->processEvents();
1010 if ( !skipIncidence ) { 1010 if ( !skipIncidence ) {
1011 inL = local->incidence( uid ); 1011 inL = local->incidence( uid );
1012 if ( inL ) { // maybe conflict - same uid in both calendars 1012 if ( inL ) { // maybe conflict - same uid in both calendars
1013 int maxrev = inL->revision(); 1013 int maxrev = inL->revision();
1014 if ( maxrev < inR->revision() ) 1014 if ( maxrev < inR->revision() )
1015 maxrev = inR->revision(); 1015 maxrev = inR->revision();
1016 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1016 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1017 //qDebug("take %d %s ", take, inL->summary().latin1()); 1017 //qDebug("take %d %s ", take, inL->summary().latin1());
1018 if ( take == 3 ) 1018 if ( take == 3 )
1019 return false; 1019 return false;
1020 if ( take == 1 ) {// take local 1020 if ( take == 1 ) {// take local
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 remote->deleteIncidence( inR ); 1022 remote->deleteIncidence( inR );
1023 if ( inL->revision() < maxrev ) 1023 if ( inL->revision() < maxrev )
1024 inL->setRevision( maxrev ); 1024 inL->setRevision( maxrev );
1025 remote->addIncidence( inL->clone() ); 1025 remote->addIncidence( inL->clone() );
1026 ++changedRemote; 1026 ++changedRemote;
1027 } else { 1027 } else {
1028 if ( inR->revision() < maxrev ) 1028 if ( inR->revision() < maxrev )
1029 inR->setRevision( maxrev ); 1029 inR->setRevision( maxrev );
1030 local->deleteIncidence( inL ); 1030 local->deleteIncidence( inL );
1031 local->addIncidence( inR->clone() ); 1031 local->addIncidence( inR->clone() );
1032 ++changedLocal; 1032 ++changedLocal;
1033 } 1033 }
1034 } 1034 }
1035 } else { // no conflict 1035 } else { // no conflict
1036 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1036 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1037 QString des = eventLSync->description(); 1037 QString des = eventLSync->description();
1038 QString pref = "e"; 1038 QString pref = "e";
1039 if ( inR->type() == "Todo" ) 1039 if ( inR->type() == "Todo" )
1040 pref = "t"; 1040 pref = "t";
1041 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1041 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1042 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1042 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1043 //remote->deleteIncidence( inR ); 1043 //remote->deleteIncidence( inR );
1044 ++deletedEventR; 1044 ++deletedEventR;
1045 } else { 1045 } else {
1046 inR->setLastModified( modifiedCalendar ); 1046 inR->setLastModified( modifiedCalendar );
1047 local->addIncidence( inR->clone() ); 1047 local->addIncidence( inR->clone() );
1048 ++addedEvent; 1048 ++addedEvent;
1049 } 1049 }
1050 } else { 1050 } else {
1051 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1051 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1052 inR->setLastModified( modifiedCalendar ); 1052 inR->setLastModified( modifiedCalendar );
1053 local->addIncidence( inR->clone() ); 1053 local->addIncidence( inR->clone() );
1054 ++addedEvent; 1054 ++addedEvent;
1055 } else { 1055 } else {
1056 checkExternSyncEvent(eventRSyncSharp, inR); 1056 checkExternSyncEvent(eventRSyncSharp, inR);
1057 remote->deleteIncidence( inR ); 1057 remote->deleteIncidence( inR );
1058 ++deletedEventR; 1058 ++deletedEventR;
1059 } 1059 }
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063 inR = er.next(); 1063 inR = er.next();
1064 } 1064 }
1065 QPtrList<Incidence> el = local->rawIncidences(); 1065 QPtrList<Incidence> el = local->rawIncidences();
1066 inL = el.first(); 1066 inL = el.first();
1067 modulo = (el.count()/10)+1; 1067 modulo = (el.count()/10)+1;
1068 bar.setCaption (i18n("Add / remove events") ); 1068 bar.setCaption (i18n("Add / remove events") );
1069 bar.setTotalSteps ( el.count() ) ; 1069 bar.setTotalSteps ( el.count() ) ;
1070 bar.show(); 1070 bar.show();
1071 incCounter = 0; 1071 incCounter = 0;
1072 1072
1073 while ( inL ) { 1073 while ( inL ) {
1074 1074
1075 qApp->processEvents(); 1075 qApp->processEvents();
1076 if ( ! bar.isVisible() ) 1076 if ( ! bar.isVisible() )
1077 return false; 1077 return false;
1078 if ( incCounter % modulo == 0 ) 1078 if ( incCounter % modulo == 0 )
1079 bar.setProgress( incCounter ); 1079 bar.setProgress( incCounter );
1080 ++incCounter; 1080 ++incCounter;
1081 uid = inL->uid(); 1081 uid = inL->uid();
1082 bool skipIncidence = false; 1082 bool skipIncidence = false;
1083 if ( uid.left(15) == QString("last-syncEvent-") ) 1083 if ( uid.left(15) == QString("last-syncEvent-") )
1084 skipIncidence = true; 1084 skipIncidence = true;
1085 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1085 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1086 skipIncidence = true; 1086 skipIncidence = true;
1087 if ( !skipIncidence ) { 1087 if ( !skipIncidence ) {
1088 inR = remote->incidence( uid ); 1088 inR = remote->incidence( uid );
1089 if ( ! inR ) { 1089 if ( ! inR ) {
1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1091 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1091 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1092 local->deleteIncidence( inL ); 1092 local->deleteIncidence( inL );
1093 ++deletedEventL; 1093 ++deletedEventL;
1094 } else { 1094 } else {
1095 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1095 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1096 inL->removeID(mCurrentSyncDevice ); 1096 inL->removeID(mCurrentSyncDevice );
1097 ++addedEventR; 1097 ++addedEventR;
1098 inL->setLastModified( modifiedCalendar ); 1098 inL->setLastModified( modifiedCalendar );
1099 remote->addIncidence( inL->clone() ); 1099 remote->addIncidence( inL->clone() );
1100 } 1100 }
1101 } 1101 }
1102 } else { 1102 } else {
1103 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1103 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1104 checkExternSyncEvent(eventLSyncSharp, inL); 1104 checkExternSyncEvent(eventLSyncSharp, inL);
1105 local->deleteIncidence( inL ); 1105 local->deleteIncidence( inL );
1106 ++deletedEventL; 1106 ++deletedEventL;
1107 } else { 1107 } else {
1108 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1108 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1109 ++addedEventR; 1109 ++addedEventR;
1110 inL->setLastModified( modifiedCalendar ); 1110 inL->setLastModified( modifiedCalendar );
1111 remote->addIncidence( inL->clone() ); 1111 remote->addIncidence( inL->clone() );
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 inL = el.next(); 1117 inL = el.next();
1118 } 1118 }
1119 1119
1120 bar.hide(); 1120 bar.hide();
1121 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1121 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1122 eventLSync->setReadOnly( false ); 1122 eventLSync->setReadOnly( false );
1123 eventLSync->setDtStart( mLastCalendarSync ); 1123 eventLSync->setDtStart( mLastCalendarSync );
1124 eventRSync->setDtStart( mLastCalendarSync ); 1124 eventRSync->setDtStart( mLastCalendarSync );
1125 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1125 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1126 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1126 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1127 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1127 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1128 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1128 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1129 eventLSync->setReadOnly( true ); 1129 eventLSync->setReadOnly( true );
1130 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1130 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1131 remote->addEvent( eventRSync ); 1131 remote->addEvent( eventRSync );
1132 QString mes; 1132 QString mes;
1133 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1133 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1134 if ( KOPrefs::instance()->mShowSyncSummary ) { 1134 if ( KOPrefs::instance()->mShowSyncSummary ) {
1135 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1135 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1136 } 1136 }
1137 qDebug( mes ); 1137 qDebug( mes );
1138 mCalendar->checkAlarmForIncidence( 0, true ); 1138 mCalendar->checkAlarmForIncidence( 0, true );
1139 return syncOK; 1139 return syncOK;
1140} 1140}
1141 1141
1142void CalendarView::setSyncDevice( QString s ) 1142void CalendarView::setSyncDevice( QString s )
1143{ 1143{
1144 mCurrentSyncDevice= s; 1144 mCurrentSyncDevice= s;
1145} 1145}
1146void CalendarView::setSyncName( QString s ) 1146void CalendarView::setSyncName( QString s )
1147{ 1147{
1148 mCurrentSyncName= s; 1148 mCurrentSyncName= s;
1149} 1149}
1150bool CalendarView::syncCalendar(QString filename, int mode) 1150bool CalendarView::syncCalendar(QString filename, int mode)
1151{ 1151{
1152 mGlobalSyncMode = SYNC_MODE_NORMAL; 1152 mGlobalSyncMode = SYNC_MODE_NORMAL;
1153 CalendarLocal* calendar = new CalendarLocal(); 1153 CalendarLocal* calendar = new CalendarLocal();
1154 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1154 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1155 FileStorage* storage = new FileStorage( calendar ); 1155 FileStorage* storage = new FileStorage( calendar );
1156 bool syncOK = false; 1156 bool syncOK = false;
1157 storage->setFileName( filename ); 1157 storage->setFileName( filename );
1158 // qDebug("loading ... "); 1158 // qDebug("loading ... ");
1159 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1159 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1160 getEventViewerDialog()->setSyncMode( true ); 1160 getEventViewerDialog()->setSyncMode( true );
1161 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1161 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1162 getEventViewerDialog()->setSyncMode( false ); 1162 getEventViewerDialog()->setSyncMode( false );
1163 if ( syncOK ) { 1163 if ( syncOK ) {
1164 if ( KOPrefs::instance()->mWriteBackFile ) 1164 if ( KOPrefs::instance()->mWriteBackFile )
1165 { 1165 {
1166 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1166 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1167 storage->save(); 1167 storage->save();
1168 } 1168 }
1169 } 1169 }
1170 setModified( true ); 1170 setModified( true );
1171 } 1171 }
1172 delete storage; 1172 delete storage;
1173 delete calendar; 1173 delete calendar;
1174 if ( syncOK ) 1174 if ( syncOK )
1175 updateView(); 1175 updateView();
1176 return syncOK; 1176 return syncOK;
1177} 1177}
1178void CalendarView::syncPhone() 1178void CalendarView::syncPhone()
1179{ 1179{
1180 syncExternal( 1 ); 1180 syncExternal( 1 );
1181} 1181}
1182void CalendarView::syncExternal( int mode ) 1182void CalendarView::syncExternal( int mode )
1183{ 1183{
1184 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1184 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1185 //mCurrentSyncDevice = "sharp-DTM"; 1185 //mCurrentSyncDevice = "sharp-DTM";
1186 if ( KOPrefs::instance()->mAskForPreferences ) 1186 if ( KOPrefs::instance()->mAskForPreferences )
1187 edit_sync_options(); 1187 edit_sync_options();
1188 qApp->processEvents(); 1188 qApp->processEvents();
1189 CalendarLocal* calendar = new CalendarLocal(); 1189 CalendarLocal* calendar = new CalendarLocal();
1190 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1190 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1191 bool syncOK = false; 1191 bool syncOK = false;
1192 bool loadSuccess = false; 1192 bool loadSuccess = false;
1193 PhoneFormat* phoneFormat = 0; 1193 PhoneFormat* phoneFormat = 0;
1194#ifndef DESKTOP_VERSION 1194#ifndef DESKTOP_VERSION
1195 SharpFormat* sharpFormat = 0; 1195 SharpFormat* sharpFormat = 0;
1196 if ( mode == 0 ) { // sharp 1196 if ( mode == 0 ) { // sharp
1197 sharpFormat = new SharpFormat () ; 1197 sharpFormat = new SharpFormat () ;
1198 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1198 loadSuccess = sharpFormat->load( calendar, mCalendar );
1199 1199
1200 } else 1200 } else
1201#endif 1201#endif
1202 if ( mode == 1 ) { // phone 1202 if ( mode == 1 ) { // phone
1203 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1203 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1204 KOPrefs::instance()->mPhoneDevice, 1204 KOPrefs::instance()->mPhoneDevice,
1205 KOPrefs::instance()->mPhoneConnection, 1205 KOPrefs::instance()->mPhoneConnection,
1206 KOPrefs::instance()->mPhoneModel); 1206 KOPrefs::instance()->mPhoneModel);
1207 loadSuccess = phoneFormat->load( calendar,mCalendar); 1207 loadSuccess = phoneFormat->load( calendar,mCalendar);
1208 1208
1209 } else 1209 } else
1210 return; 1210 return;
1211 if ( loadSuccess ) { 1211 if ( loadSuccess ) {
1212 getEventViewerDialog()->setSyncMode( true ); 1212 getEventViewerDialog()->setSyncMode( true );
1213 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1213 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1214 getEventViewerDialog()->setSyncMode( false ); 1214 getEventViewerDialog()->setSyncMode( false );
1215 qApp->processEvents(); 1215 qApp->processEvents();
1216 if ( syncOK ) { 1216 if ( syncOK ) {
1217 if ( KOPrefs::instance()->mWriteBackFile ) 1217 if ( KOPrefs::instance()->mWriteBackFile )
1218 { 1218 {
1219 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1219 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1220 Incidence* inc = iL.first(); 1220 Incidence* inc = iL.first();
1221 /* obsolete 1221 /* obsolete
1222 while ( inc ) { 1222 while ( inc ) {
1223 inc->setZaurusStat( inc->revision () ); 1223 inc->setZaurusStat( inc->revision () );
1224 inc = iL.next(); 1224 inc = iL.next();
1225 } 1225 }
1226 */ 1226 */
1227#ifndef DESKTOP_VERSION 1227#ifndef DESKTOP_VERSION
1228 if ( sharpFormat ) 1228 if ( sharpFormat )
1229 sharpFormat->save(calendar); 1229 sharpFormat->save(calendar);
1230#endif 1230#endif
1231 if ( phoneFormat ) 1231 if ( phoneFormat )
1232 phoneFormat->save(calendar); 1232 phoneFormat->save(calendar);
1233 iL = calendar->rawIncidences(); 1233 iL = calendar->rawIncidences();
1234 inc = iL.first(); 1234 inc = iL.first();
1235 Incidence* loc; 1235 Incidence* loc;
1236 while ( inc ) { 1236 while ( inc ) {
1237 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1237 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1238 loc = mCalendar->incidence(inc->uid() ); 1238 loc = mCalendar->incidence(inc->uid() );
1239 if ( loc ) { 1239 if ( loc ) {
1240 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1240 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1241 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1241 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1242 } 1242 }
1243 } 1243 }
1244 inc = iL.next(); 1244 inc = iL.next();
1245 } 1245 }
1246 Incidence* lse = getLastSyncEvent(); 1246 Incidence* lse = getLastSyncEvent();
1247 if ( lse ) { 1247 if ( lse ) {
1248 lse->setReadOnly( false ); 1248 lse->setReadOnly( false );
1249 lse->setDescription( "" ); 1249 lse->setDescription( "" );
1250 lse->setReadOnly( true ); 1250 lse->setReadOnly( true );
1251 } 1251 }
1252 } 1252 }
1253 } 1253 }
1254 setModified( true ); 1254 setModified( true );
1255 } else { 1255 } else {
1256 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1256 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1257 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1257 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1258 question, i18n("Ok")) ; 1258 question, i18n("Ok")) ;
1259 1259
1260 } 1260 }
1261 delete calendar; 1261 delete calendar;
1262 updateView(); 1262 updateView();
1263 return ;//syncOK; 1263 return ;//syncOK;
1264 1264
1265} 1265}
1266void CalendarView::syncSharp() 1266void CalendarView::syncSharp()
1267{ 1267{
1268 syncExternal( 0 ); 1268 syncExternal( 0 );
1269 1269
1270} 1270}
1271 1271
1272 1272
1273#include <kabc/stdaddressbook.h> 1273#include <kabc/stdaddressbook.h>
1274bool CalendarView::importBday() 1274bool CalendarView::importBday()
1275{ 1275{
1276 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1276 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1277 KABC::AddressBook::Iterator it; 1277 KABC::AddressBook::Iterator it;
1278 int count = 0; 1278 int count = 0;
1279 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1279 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1280 ++count; 1280 ++count;
1281 } 1281 }
1282 QProgressBar bar(count,0 ); 1282 QProgressBar bar(count,0 );
1283 int w = 300; 1283 int w = 300;
1284 if ( QApplication::desktop()->width() < 320 ) 1284 if ( QApplication::desktop()->width() < 320 )
1285 w = 220; 1285 w = 220;
1286 int h = bar.sizeHint().height() ; 1286 int h = bar.sizeHint().height() ;
1287 int dw = QApplication::desktop()->width(); 1287 int dw = QApplication::desktop()->width();
1288 int dh = QApplication::desktop()->height(); 1288 int dh = QApplication::desktop()->height();
1289 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1289 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1290 bar.show(); 1290 bar.show();
1291 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1291 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1292 qApp->processEvents(); 1292 qApp->processEvents();
1293 count = 0; 1293 count = 0;
1294 int addCount = 0; 1294 int addCount = 0;
1295 KCal::Attendee* a = 0; 1295 KCal::Attendee* a = 0;
1296 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1296 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1297 if ( ! bar.isVisible() ) 1297 if ( ! bar.isVisible() )
1298 return false; 1298 return false;
1299 bar.setProgress( count++ ); 1299 bar.setProgress( count++ );
1300 qApp->processEvents(); 1300 qApp->processEvents();
1301 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1301 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1302 if ( (*it).birthday().date().isValid() ){ 1302 if ( (*it).birthday().date().isValid() ){
1303 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1303 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1304 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1304 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1305 ++addCount; 1305 ++addCount;
1306 } 1306 }
1307 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1307 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1308 if ( anni.isValid() ){ 1308 if ( anni.isValid() ){
1309 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1309 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1310 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1310 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1311 ++addCount; 1311 ++addCount;
1312 } 1312 }
1313 } 1313 }
1314 updateView(); 1314 updateView();
1315 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1315 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1316 return true; 1316 return true;
1317} 1317}
1318 1318
1319bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1319bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1320{ 1320{
1321 //qDebug("addAnni "); 1321 //qDebug("addAnni ");
1322 Event * ev = new Event(); 1322 Event * ev = new Event();
1323 if ( a ) { 1323 if ( a ) {
1324 ev->addAttendee( a ); 1324 ev->addAttendee( a );
1325 } 1325 }
1326 QString kind; 1326 QString kind;
1327 if ( birthday ) 1327 if ( birthday )
1328 kind = i18n( "Birthday" ); 1328 kind = i18n( "Birthday" );
1329 else 1329 else
1330 kind = i18n( "Anniversary" ); 1330 kind = i18n( "Anniversary" );
1331 ev->setSummary( name + " - " + kind ); 1331 ev->setSummary( name + " - " + kind );
1332 ev->setOrganizer( "nobody@nowhere" ); 1332 ev->setOrganizer( "nobody@nowhere" );
1333 ev->setCategories( kind ); 1333 ev->setCategories( kind );
1334 ev->setDtStart( QDateTime(date) ); 1334 ev->setDtStart( QDateTime(date) );
1335 ev->setDtEnd( QDateTime(date) ); 1335 ev->setDtEnd( QDateTime(date) );
1336 ev->setFloats( true ); 1336 ev->setFloats( true );
1337 Recurrence * rec = ev->recurrence(); 1337 Recurrence * rec = ev->recurrence();
1338 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1338 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1339 rec->addYearlyNum( date.month() ); 1339 rec->addYearlyNum( date.month() );
1340 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1340 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1341 delete ev; 1341 delete ev;
1342 return false; 1342 return false;
1343 } 1343 }
1344 return true; 1344 return true;
1345 1345
1346} 1346}
1347bool CalendarView::importQtopia( const QString &categories, 1347bool CalendarView::importQtopia( const QString &categories,
1348 const QString &datebook, 1348 const QString &datebook,
1349 const QString &todolist ) 1349 const QString &todolist )
1350{ 1350{
1351 1351
1352 QtopiaFormat qtopiaFormat; 1352 QtopiaFormat qtopiaFormat;
1353 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1353 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1354 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1354 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1355 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1355 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1356 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1356 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1357 1357
1358 updateView(); 1358 updateView();
1359 return true; 1359 return true;
1360 1360
1361#if 0 1361#if 0
1362 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1362 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1363 mCurrentSyncDevice = "qtopia-XML"; 1363 mCurrentSyncDevice = "qtopia-XML";
1364 if ( KOPrefs::instance()->mAskForPreferences ) 1364 if ( KOPrefs::instance()->mAskForPreferences )
1365 edit_sync_options(); 1365 edit_sync_options();
1366 qApp->processEvents(); 1366 qApp->processEvents();
1367 CalendarLocal* calendar = new CalendarLocal(); 1367 CalendarLocal* calendar = new CalendarLocal();
1368 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1368 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1369 bool syncOK = false; 1369 bool syncOK = false;
1370 QtopiaFormat qtopiaFormat; 1370 QtopiaFormat qtopiaFormat;
1371 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1371 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1372 bool loadOk = true; 1372 bool loadOk = true;
1373 if ( !categories.isEmpty() ) 1373 if ( !categories.isEmpty() )
1374 loadOk = qtopiaFormat.load( calendar, categories ); 1374 loadOk = qtopiaFormat.load( calendar, categories );
1375 if ( loadOk && !datebook.isEmpty() ) 1375 if ( loadOk && !datebook.isEmpty() )
1376 loadOk = qtopiaFormat.load( calendar, datebook ); 1376 loadOk = qtopiaFormat.load( calendar, datebook );
1377 if ( loadOk && !todolist.isEmpty() ) 1377 if ( loadOk && !todolist.isEmpty() )
1378 loadOk = qtopiaFormat.load( calendar, todolist ); 1378 loadOk = qtopiaFormat.load( calendar, todolist );
1379 1379
1380 if ( loadOk ) { 1380 if ( loadOk ) {
1381 getEventViewerDialog()->setSyncMode( true ); 1381 getEventViewerDialog()->setSyncMode( true );
1382 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1382 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1383 getEventViewerDialog()->setSyncMode( false ); 1383 getEventViewerDialog()->setSyncMode( false );
1384 qApp->processEvents(); 1384 qApp->processEvents();
1385 if ( syncOK ) { 1385 if ( syncOK ) {
1386 if ( KOPrefs::instance()->mWriteBackFile ) 1386 if ( KOPrefs::instance()->mWriteBackFile )
1387 { 1387 {
1388 // write back XML file 1388 // write back XML file
1389 1389
1390 } 1390 }
1391 setModified( true ); 1391 setModified( true );
1392 } 1392 }
1393 } else { 1393 } else {
1394 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1394 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1395 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1395 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1396 question, i18n("Ok")) ; 1396 question, i18n("Ok")) ;
1397 } 1397 }
1398 delete calendar; 1398 delete calendar;
1399 updateView(); 1399 updateView();
1400 return syncOK; 1400 return syncOK;
1401 1401
1402 1402
1403#endif 1403#endif
1404 1404
1405} 1405}
1406 1406
1407void CalendarView::setSyncEventsReadOnly() 1407void CalendarView::setSyncEventsReadOnly()
1408{ 1408{
1409 Event * ev; 1409 Event * ev;
1410 QPtrList<Event> eL = mCalendar->rawEvents(); 1410 QPtrList<Event> eL = mCalendar->rawEvents();
1411 ev = eL.first(); 1411 ev = eL.first();
1412 while ( ev ) { 1412 while ( ev ) {
1413 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1413 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1414 ev->setReadOnly( true ); 1414 ev->setReadOnly( true );
1415 ev = eL.next(); 1415 ev = eL.next();
1416 } 1416 }
1417} 1417}
1418bool CalendarView::openCalendar(QString filename, bool merge) 1418bool CalendarView::openCalendar(QString filename, bool merge)
1419{ 1419{
1420 1420
1421 if (filename.isEmpty()) { 1421 if (filename.isEmpty()) {
1422 return false; 1422 return false;
1423 } 1423 }
1424 1424
1425 if (!QFile::exists(filename)) { 1425 if (!QFile::exists(filename)) {
1426 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1426 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1427 return false; 1427 return false;
1428 } 1428 }
1429 1429
1430 globalFlagBlockAgenda = 1; 1430 globalFlagBlockAgenda = 1;
1431 if (!merge) mCalendar->close(); 1431 if (!merge) mCalendar->close();
1432 1432
1433 mStorage->setFileName( filename ); 1433 mStorage->setFileName( filename );
1434 1434
1435 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1435 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1436 if ( merge ) ;//setModified( true ); 1436 if ( merge ) ;//setModified( true );
1437 else { 1437 else {
1438 //setModified( true ); 1438 //setModified( true );
1439 mViewManager->setDocumentId( filename ); 1439 mViewManager->setDocumentId( filename );
1440 mDialogManager->setDocumentId( filename ); 1440 mDialogManager->setDocumentId( filename );
1441 mTodoList->setDocumentId( filename ); 1441 mTodoList->setDocumentId( filename );
1442 } 1442 }
1443 globalFlagBlockAgenda = 2; 1443 globalFlagBlockAgenda = 2;
1444 // if ( getLastSyncEvent() ) 1444 // if ( getLastSyncEvent() )
1445 // getLastSyncEvent()->setReadOnly( true ); 1445 // getLastSyncEvent()->setReadOnly( true );
1446 mCalendar->reInitAlarmSettings(); 1446 mCalendar->reInitAlarmSettings();
1447 setSyncEventsReadOnly(); 1447 setSyncEventsReadOnly();
1448 updateUnmanagedViews(); 1448 updateUnmanagedViews();
1449 updateView(); 1449 updateView();
1450 if ( filename != MainWindow::defaultFileName() ) 1450 if ( filename != MainWindow::defaultFileName() )
1451 saveCalendar( MainWindow::defaultFileName() ); 1451 saveCalendar( MainWindow::defaultFileName() );
1452 loadedFileVersion = QDateTime::currentDateTime(); 1452 loadedFileVersion = QDateTime::currentDateTime();
1453 return true; 1453 return true;
1454 } else { 1454 } else {
1455 // while failing to load, the calendar object could 1455 // while failing to load, the calendar object could
1456 // have become partially populated. Clear it out. 1456 // have become partially populated. Clear it out.
1457 if ( !merge ) mCalendar->close(); 1457 if ( !merge ) mCalendar->close();
1458 1458
1459 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1459 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1460 1460
1461 globalFlagBlockAgenda = 2; 1461 globalFlagBlockAgenda = 2;
1462 updateView(); 1462 updateView();
1463 } 1463 }
1464 return false; 1464 return false;
1465} 1465}
1466void CalendarView::setLoadedFileVersion(QDateTime dt) 1466void CalendarView::setLoadedFileVersion(QDateTime dt)
1467{ 1467{
1468 loadedFileVersion = dt; 1468 loadedFileVersion = dt;
1469} 1469}
1470bool CalendarView::checkFileChanged(QString fn) 1470bool CalendarView::checkFileChanged(QString fn)
1471{ 1471{
1472 QFileInfo finf ( fn ); 1472 QFileInfo finf ( fn );
1473 if ( !finf.exists() ) 1473 if ( !finf.exists() )
1474 return true; 1474 return true;
1475 QDateTime dt = finf.lastModified (); 1475 QDateTime dt = finf.lastModified ();
1476 if ( dt <= loadedFileVersion ) 1476 if ( dt <= loadedFileVersion )
1477 return false; 1477 return false;
1478 return true; 1478 return true;
1479 1479
1480} 1480}
1481bool CalendarView::checkFileVersion(QString fn) 1481bool CalendarView::checkFileVersion(QString fn)
1482{ 1482{
1483 QFileInfo finf ( fn ); 1483 QFileInfo finf ( fn );
1484 if ( !finf.exists() ) 1484 if ( !finf.exists() )
1485 return true; 1485 return true;
1486 QDateTime dt = finf.lastModified (); 1486 QDateTime dt = finf.lastModified ();
1487 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1487 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1488 //qDebug("file on disk version %s",dt.toString().latin1()); 1488 //qDebug("file on disk version %s",dt.toString().latin1());
1489 if ( dt <= loadedFileVersion ) 1489 if ( dt <= loadedFileVersion )
1490 return true; 1490 return true;
1491 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1491 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1492 i18n("KO/Pi Warning"),i18n("Overwrite"), 1492 i18n("KO/Pi Warning"),i18n("Overwrite"),
1493 i18n("Sync+save")); 1493 i18n("Sync+save"));
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
1513bool CalendarView::saveCalendar( QString filename ) 1513bool 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
1534void CalendarView::closeCalendar() 1534void 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
1545void CalendarView::archiveCalendar() 1545void CalendarView::archiveCalendar()
1546{ 1546{
1547 mDialogManager->showArchiveDialog(); 1547 mDialogManager->showArchiveDialog();
1548} 1548}
1549 1549
1550 1550
1551void CalendarView::readSettings() 1551void 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
1637void CalendarView::writeSettings() 1637void 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
1734void CalendarView::readFilterSettings(KConfig *config) 1734void 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
1774void CalendarView::writeFilterSettings(KConfig *config) 1774void 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
1798void CalendarView::goToday() 1798void CalendarView::goToday()
1799{ 1799{
1800 mNavigator->selectToday(); 1800 mNavigator->selectToday();
1801} 1801}
1802 1802
1803void CalendarView::goNext() 1803void CalendarView::goNext()
1804{ 1804{
1805 mNavigator->selectNext(); 1805 mNavigator->selectNext();
1806} 1806}
1807 1807
1808void CalendarView::goPrevious() 1808void CalendarView::goPrevious()
1809{ 1809{
1810 mNavigator->selectPrevious(); 1810 mNavigator->selectPrevious();
1811} 1811}
1812void CalendarView::goNextMonth() 1812void CalendarView::goNextMonth()
1813{ 1813{
1814 mNavigator->selectNextMonth(); 1814 mNavigator->selectNextMonth();
1815} 1815}
1816 1816
1817void CalendarView::goPreviousMonth() 1817void CalendarView::goPreviousMonth()
1818{ 1818{
1819 mNavigator->selectPreviousMonth(); 1819 mNavigator->selectPreviousMonth();
1820} 1820}
1821void CalendarView::writeLocale() 1821void 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}
1836void CalendarView::updateConfig() 1836void CalendarView::updateConfig()
1837{ 1837{
1838 writeLocale(); 1838 writeLocale();
1839 if ( KOPrefs::instance()->mUseAppColors ) 1839 if ( KOPrefs::instance()->mUseAppColors )
1840 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1840 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1841 emit configChanged(); 1841 emit configChanged();
1842 mTodoList->updateConfig(); 1842 mTodoList->updateConfig();
1843 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1843 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1844 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1844 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1845 // To make the "fill window" configurations work 1845 // To make the "fill window" configurations work
1846 //mViewManager->raiseCurrentView(); 1846 //mViewManager->raiseCurrentView();
1847} 1847}
1848 1848
1849 1849
1850void CalendarView::eventChanged(Event *event) 1850void CalendarView::eventChanged(Event *event)
1851{ 1851{
1852 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1852 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1853 //updateUnmanagedViews(); 1853 //updateUnmanagedViews();
1854} 1854}
1855 1855
1856void CalendarView::eventAdded(Event *event) 1856void CalendarView::eventAdded(Event *event)
1857{ 1857{
1858 changeEventDisplay(event,KOGlobals::EVENTADDED); 1858 changeEventDisplay(event,KOGlobals::EVENTADDED);
1859} 1859}
1860 1860
1861void CalendarView::eventToBeDeleted(Event *) 1861void CalendarView::eventToBeDeleted(Event *)
1862{ 1862{
1863 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1863 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1864} 1864}
1865 1865
1866void CalendarView::eventDeleted() 1866void CalendarView::eventDeleted()
1867{ 1867{
1868 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1868 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1869} 1869}
1870void CalendarView::changeTodoDisplay(Todo *which, int action) 1870void CalendarView::changeTodoDisplay(Todo *which, int action)
1871{ 1871{
1872 changeIncidenceDisplay((Incidence *)which, action); 1872 changeIncidenceDisplay((Incidence *)which, action);
1873 mDateNavigator->updateView(); 1873 mDateNavigator->updateView();
1874 //mDialogManager->updateSearchDialog(); 1874 //mDialogManager->updateSearchDialog();
1875 1875
1876 if (which) { 1876 if (which) {
1877 mViewManager->currentView()->updateView(); 1877 mViewManager->currentView()->updateView();
1878 mTodoList->updateView(); 1878 //mTodoList->updateView();
1879 } 1879 }
1880 1880
1881} 1881}
1882 1882
1883void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1883void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1884{ 1884{
1885 updateUnmanagedViews(); 1885 updateUnmanagedViews();
1886 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1886 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1887 if ( action == KOGlobals::EVENTDELETED ) { //delete 1887 if ( action == KOGlobals::EVENTDELETED ) { //delete
1888 mCalendar->checkAlarmForIncidence( 0, true ); 1888 mCalendar->checkAlarmForIncidence( 0, true );
1889 if ( mEventViewerDialog ) 1889 if ( mEventViewerDialog )
1890 mEventViewerDialog->hide(); 1890 mEventViewerDialog->hide();
1891 } 1891 }
1892 else 1892 else
1893 mCalendar->checkAlarmForIncidence( which , false ); 1893 mCalendar->checkAlarmForIncidence( which , false );
1894} 1894}
1895 1895
1896// most of the changeEventDisplays() right now just call the view's 1896// most of the changeEventDisplays() right now just call the view's
1897// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1897// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1898void CalendarView::changeEventDisplay(Event *which, int action) 1898void CalendarView::changeEventDisplay(Event *which, int action)
1899{ 1899{
1900 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1900 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1901 changeIncidenceDisplay((Incidence *)which, action); 1901 changeIncidenceDisplay((Incidence *)which, action);
1902 mDateNavigator->updateView(); 1902 mDateNavigator->updateView();
1903 //mDialogManager->updateSearchDialog(); 1903 //mDialogManager->updateSearchDialog();
1904 1904
1905 if (which) { 1905 if (which) {
1906 // If there is an event view visible update the display 1906 // If there is an event view visible update the display
1907 mViewManager->currentView()->changeEventDisplay(which,action); 1907 mViewManager->currentView()->changeEventDisplay(which,action);
1908 // TODO: check, if update needed 1908 // TODO: check, if update needed
1909 // if (which->getTodoStatus()) { 1909 // if (which->getTodoStatus()) {
1910 mTodoList->updateView(); 1910 mTodoList->updateView();
1911 // } 1911 // }
1912 } else { 1912 } else {
1913 mViewManager->currentView()->updateView(); 1913 mViewManager->currentView()->updateView();
1914 } 1914 }
1915} 1915}
1916 1916
1917 1917
1918void CalendarView::updateTodoViews() 1918void CalendarView::updateTodoViews()
1919{ 1919{
1920 1920
1921 mTodoList->updateView(); 1921 mTodoList->updateView();
1922 mViewManager->currentView()->updateView(); 1922 mViewManager->currentView()->updateView();
1923 1923
1924} 1924}
1925 1925
1926 1926
1927void CalendarView::updateView(const QDate &start, const QDate &end) 1927void 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
1934void CalendarView::updateView() 1934void 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
1942void CalendarView::updateUnmanagedViews() 1942void CalendarView::updateUnmanagedViews()
1943{ 1943{
1944 mDateNavigator->updateDayMatrix(); 1944 mDateNavigator->updateDayMatrix();
1945} 1945}
1946 1946
1947int CalendarView::msgItemDelete() 1947int 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
1955void CalendarView::edit_cut() 1955void 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
1976void CalendarView::edit_copy() 1976void 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
1996void CalendarView::edit_paste() 1996void 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
2006void CalendarView::edit_options() 2006void CalendarView::edit_options()
2007{ 2007{
2008 mDialogManager->showOptionsDialog(); 2008 mDialogManager->showOptionsDialog();
2009 //writeSettings(); 2009 //writeSettings();
2010} 2010}
2011void CalendarView::edit_sync_options() 2011void 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
2063void CalendarView::slotSelectPickerDate( QDate d) 2063void 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
2095void CalendarView::removeCategories() 2095void 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
2117int CalendarView::addCategories() 2117int 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
2141void CalendarView::manageCategories() 2141void 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
2168void CalendarView::beamIncidence(Incidence * Inc) 2168void 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}
2174void CalendarView::beamCalendar() 2174void 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}
2180void CalendarView::beamFilteredCalendar() 2180void 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}
2186void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2186void 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}
2235void CalendarView::beamDone( Ir *ir ) 2235void 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
2242void CalendarView::moveIncidence(Incidence * inc ) 2242void 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();
2263 else 2263 else
2264 da = QDate::currentDate(); 2264 da = QDate::currentDate();
2265 } else { 2265 } else {
2266 da = mMoveIncidence->dtStart().date(); 2266 da = mMoveIncidence->dtStart().date();
2267 } 2267 }
2268 mDatePicker->setDate( da ); 2268 mDatePicker->setDate( da );
2269} 2269}
2270void CalendarView::showDatePicker( ) 2270void CalendarView::showDatePicker( )
2271{ 2271{
2272 //qDebug("CalendarView::showDatePicker( ) "); 2272 //qDebug("CalendarView::showDatePicker( ) ");
2273 if ( mDateFrame->isVisible() ) 2273 if ( mDateFrame->isVisible() )
2274 mDateFrame->hide(); 2274 mDateFrame->hide();
2275 else { 2275 else {
2276 int w =mDatePicker->sizeHint().width() ; 2276 int w =mDatePicker->sizeHint().width() ;
2277 int h = mDatePicker->sizeHint().height() ; 2277 int h = mDatePicker->sizeHint().height() ;
2278 int dw = QApplication::desktop()->width(); 2278 int dw = QApplication::desktop()->width();
2279 int dh = QApplication::desktop()->height(); 2279 int dh = QApplication::desktop()->height();
2280 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2280 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2281 mDateFrame->show(); 2281 mDateFrame->show();
2282 } 2282 }
2283 mDatePickerMode = 1; 2283 mDatePickerMode = 1;
2284 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2284 mDatePicker->setDate( mNavigator->selectedDates().first() );
2285} 2285}
2286 2286
2287void CalendarView::showEventEditor() 2287void CalendarView::showEventEditor()
2288{ 2288{
2289#ifdef DESKTOP_VERSION 2289#ifdef DESKTOP_VERSION
2290 mEventEditor->show(); 2290 mEventEditor->show();
2291#else 2291#else
2292 mEventEditor->showMaximized(); 2292 mEventEditor->showMaximized();
2293#endif 2293#endif
2294} 2294}
2295void CalendarView::showTodoEditor() 2295void CalendarView::showTodoEditor()
2296{ 2296{
2297#ifdef DESKTOP_VERSION 2297#ifdef DESKTOP_VERSION
2298 mTodoEditor->show(); 2298 mTodoEditor->show();
2299#else 2299#else
2300 mTodoEditor->showMaximized(); 2300 mTodoEditor->showMaximized();
2301#endif 2301#endif
2302} 2302}
2303void CalendarView::cancelIncidence(Incidence * inc ) 2303void CalendarView::cancelIncidence(Incidence * inc )
2304{ 2304{
2305 inc->setCancelled( ! inc->cancelled() ); 2305 inc->setCancelled( ! inc->cancelled() );
2306 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2306 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2307 updateView(); 2307 updateView();
2308} 2308}
2309void CalendarView::cloneIncidence(Incidence * orgInc ) 2309void CalendarView::cloneIncidence(Incidence * orgInc )
2310{ 2310{
2311 Incidence * newInc = orgInc->clone(); 2311 Incidence * newInc = orgInc->clone();
2312 newInc->recreate(); 2312 newInc->recreate();
2313 2313
2314 if ( newInc->type() == "Todo" ) { 2314 if ( newInc->type() == "Todo" ) {
2315 Todo* t = (Todo*) newInc; 2315 Todo* t = (Todo*) newInc;
2316 mTodoEditor->editTodo( t ); 2316 mTodoEditor->editTodo( t );
2317 showTodoEditor(); 2317 showTodoEditor();
2318 if ( mTodoEditor->exec() ) { 2318 if ( mTodoEditor->exec() ) {
2319 mCalendar->addTodo( t ); 2319 mCalendar->addTodo( t );
2320 updateView(); 2320 updateView();
2321 } else { 2321 } else {
2322 delete t; 2322 delete t;
2323 } 2323 }
2324 } 2324 }
2325 else { 2325 else {
2326 Event* e = (Event*) newInc; 2326 Event* e = (Event*) newInc;
2327 mEventEditor->editEvent( e ); 2327 mEventEditor->editEvent( e );
2328 showEventEditor(); 2328 showEventEditor();
2329 if ( mEventEditor->exec() ) { 2329 if ( mEventEditor->exec() ) {
2330 mCalendar->addEvent( e ); 2330 mCalendar->addEvent( e );
2331 updateView(); 2331 updateView();
2332 } else { 2332 } else {
2333 delete e; 2333 delete e;
2334 } 2334 }
2335 } 2335 }
2336} 2336}
2337 2337
2338void CalendarView::newEvent() 2338void CalendarView::newEvent()
2339{ 2339{
2340 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2340 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2341 KOAgendaView *aView = mViewManager->agendaView(); 2341 KOAgendaView *aView = mViewManager->agendaView();
2342 if (aView) { 2342 if (aView) {
2343 if (aView->selectionStart().isValid()) { 2343 if (aView->selectionStart().isValid()) {
2344 if (aView->selectedIsAllDay()) { 2344 if (aView->selectedIsAllDay()) {
2345 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2345 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2346 } else { 2346 } else {
2347 newEvent(aView->selectionStart(),aView->selectionEnd()); 2347 newEvent(aView->selectionStart(),aView->selectionEnd());
2348 } 2348 }
2349 return; 2349 return;
2350 } 2350 }
2351 } 2351 }
2352 2352
2353 QDate date = mNavigator->selectedDates().first(); 2353 QDate date = mNavigator->selectedDates().first();
2354 QDateTime current = QDateTime::currentDateTime(); 2354 QDateTime current = QDateTime::currentDateTime();
2355 if ( date <= current.date() ) { 2355 if ( date <= current.date() ) {
2356 int hour = current.time().hour() +1; 2356 int hour = current.time().hour() +1;
2357 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2357 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2358 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2358 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2359 } else 2359 } else
2360 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2360 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2361 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2361 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2362 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2362 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2363} 2363}
2364 2364
2365void CalendarView::newEvent(QDateTime fh) 2365void CalendarView::newEvent(QDateTime fh)
2366{ 2366{
2367 newEvent(fh, 2367 newEvent(fh,
2368 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2368 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2369} 2369}
2370 2370
2371void CalendarView::newEvent(QDate dt) 2371void CalendarView::newEvent(QDate dt)
2372{ 2372{
2373 newEvent(QDateTime(dt, QTime(0,0,0)), 2373 newEvent(QDateTime(dt, QTime(0,0,0)),
2374 QDateTime(dt, QTime(0,0,0)), true); 2374 QDateTime(dt, QTime(0,0,0)), true);
2375} 2375}
2376 2376
2377void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2377void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2378{ 2378{
2379 2379
2380 mEventEditor->newEvent(fromHint,toHint,allDay); 2380 mEventEditor->newEvent(fromHint,toHint,allDay);
2381 if ( mFilterView->filtersEnabled() ) { 2381 if ( mFilterView->filtersEnabled() ) {
2382 CalFilter *filter = mFilterView->selectedFilter(); 2382 CalFilter *filter = mFilterView->selectedFilter();
2383 if (filter && filter->showCategories()) { 2383 if (filter && filter->showCategories()) {
2384 mEventEditor->setCategories(filter->categoryList().join(",") ); 2384 mEventEditor->setCategories(filter->categoryList().join(",") );
2385 } 2385 }
2386 if ( filter ) 2386 if ( filter )
2387 mEventEditor->setSecrecy( filter->getSecrecy() ); 2387 mEventEditor->setSecrecy( filter->getSecrecy() );
2388 } 2388 }
2389 showEventEditor(); 2389 showEventEditor();
2390} 2390}
2391void CalendarView::todoAdded(Todo * t) 2391void CalendarView::todoAdded(Todo * t)
2392{ 2392{
2393 2393
2394 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2394 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2395 updateTodoViews(); 2395 updateTodoViews();
2396} 2396}
2397void CalendarView::todoChanged(Todo * t) 2397void CalendarView::todoChanged(Todo * t)
2398{ 2398{
2399 emit todoModified( t, 4 ); 2399 emit todoModified( t, 4 );
2400 // updateTodoViews(); 2400 // updateTodoViews();
2401} 2401}
2402void CalendarView::todoToBeDeleted(Todo *) 2402void CalendarView::todoToBeDeleted(Todo *)
2403{ 2403{
2404 //qDebug("todoToBeDeleted(Todo *) "); 2404 //qDebug("todoToBeDeleted(Todo *) ");
2405 updateTodoViews(); 2405 updateTodoViews();
2406} 2406}
2407void CalendarView::todoDeleted() 2407void CalendarView::todoDeleted()
2408{ 2408{
2409 //qDebug(" todoDeleted()"); 2409 //qDebug(" todoDeleted()");
2410 updateTodoViews(); 2410 updateTodoViews();
2411} 2411}
2412 2412
2413 2413
2414 2414
2415void CalendarView::newTodo() 2415void CalendarView::newTodo()
2416{ 2416{
2417 2417
2418 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2418 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2419 if ( mFilterView->filtersEnabled() ) { 2419 if ( mFilterView->filtersEnabled() ) {
2420 CalFilter *filter = mFilterView->selectedFilter(); 2420 CalFilter *filter = mFilterView->selectedFilter();
2421 if (filter && filter->showCategories()) { 2421 if (filter && filter->showCategories()) {
2422 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2422 mTodoEditor->setCategories(filter->categoryList().join(",") );
2423 } 2423 }
2424 if ( filter ) 2424 if ( filter )
2425 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2425 mTodoEditor->setSecrecy( filter->getSecrecy() );
2426 } 2426 }
2427 showTodoEditor(); 2427 showTodoEditor();
2428} 2428}
2429 2429
2430void CalendarView::newSubTodo() 2430void CalendarView::newSubTodo()
2431{ 2431{
2432 Todo *todo = selectedTodo(); 2432 Todo *todo = selectedTodo();
2433 if ( todo ) newSubTodo( todo ); 2433 if ( todo ) newSubTodo( todo );
2434} 2434}
2435 2435
2436void CalendarView::newSubTodo(Todo *parentEvent) 2436void CalendarView::newSubTodo(Todo *parentEvent)
2437{ 2437{
2438 2438
2439 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2439 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2440 showTodoEditor(); 2440 showTodoEditor();
2441} 2441}
2442 2442
2443void CalendarView::newFloatingEvent() 2443void CalendarView::newFloatingEvent()
2444{ 2444{
2445 DateList tmpList = mNavigator->selectedDates(); 2445 DateList tmpList = mNavigator->selectedDates();
2446 QDate date = tmpList.first(); 2446 QDate date = tmpList.first();
2447 2447
2448 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2448 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2449 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2449 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2450} 2450}
2451 2451
2452 2452
2453void CalendarView::editEvent( Event *event ) 2453void CalendarView::editEvent( Event *event )
2454{ 2454{
2455 2455
2456 if ( !event ) return; 2456 if ( !event ) return;
2457 if ( event->isReadOnly() ) { 2457 if ( event->isReadOnly() ) {
2458 showEvent( event ); 2458 showEvent( event );
2459 return; 2459 return;
2460 } 2460 }
2461 mEventEditor->editEvent( event , mFlagEditDescription); 2461 mEventEditor->editEvent( event , mFlagEditDescription);
2462 showEventEditor(); 2462 showEventEditor();
2463} 2463}
2464void CalendarView::editJournal( Journal *jour ) 2464void CalendarView::editJournal( Journal *jour )
2465{ 2465{
2466 if ( !jour ) return; 2466 if ( !jour ) return;
2467 mDialogManager->hideSearchDialog(); 2467 mDialogManager->hideSearchDialog();
2468 mViewManager->showJournalView(); 2468 mViewManager->showJournalView();
2469 mNavigator->slotDaySelect( jour->dtStart().date() ); 2469 mNavigator->slotDaySelect( jour->dtStart().date() );
2470} 2470}
2471void CalendarView::editTodo( Todo *todo ) 2471void CalendarView::editTodo( Todo *todo )
2472{ 2472{
2473 if ( !todo ) return; 2473 if ( !todo ) return;
2474 2474
2475 if ( todo->isReadOnly() ) { 2475 if ( todo->isReadOnly() ) {
2476 showTodo( todo ); 2476 showTodo( todo );
2477 return; 2477 return;
2478 } 2478 }
2479 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2479 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2480 showTodoEditor(); 2480 showTodoEditor();
2481 2481
2482} 2482}
2483 2483
2484KOEventViewerDialog* CalendarView::getEventViewerDialog() 2484KOEventViewerDialog* CalendarView::getEventViewerDialog()
2485{ 2485{
2486 if ( !mEventViewerDialog ) { 2486 if ( !mEventViewerDialog ) {
2487 mEventViewerDialog = new KOEventViewerDialog(this); 2487 mEventViewerDialog = new KOEventViewerDialog(this);
2488 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2488 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2489 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2489 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2490 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2490 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2491 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2491 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2492 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2492 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2493 viewManager(), SLOT( showAgendaView( bool ) ) ); 2493 viewManager(), SLOT( showAgendaView( bool ) ) );
2494 mEventViewerDialog->resize( 640, 480 ); 2494 mEventViewerDialog->resize( 640, 480 );
2495 2495
2496 } 2496 }
2497 return mEventViewerDialog; 2497 return mEventViewerDialog;
2498} 2498}
2499void CalendarView::showEvent(Event *event) 2499void CalendarView::showEvent(Event *event)
2500{ 2500{
2501 getEventViewerDialog()->setEvent(event); 2501 getEventViewerDialog()->setEvent(event);
2502 getEventViewerDialog()->showMe(); 2502 getEventViewerDialog()->showMe();
2503} 2503}
2504 2504
2505void CalendarView::showTodo(Todo *event) 2505void CalendarView::showTodo(Todo *event)
2506{ 2506{
2507 getEventViewerDialog()->setTodo(event); 2507 getEventViewerDialog()->setTodo(event);
2508 getEventViewerDialog()->showMe(); 2508 getEventViewerDialog()->showMe();
2509} 2509}
2510void CalendarView::showJournal( Journal *jour ) 2510void CalendarView::showJournal( Journal *jour )
2511{ 2511{
2512 getEventViewerDialog()->setJournal(jour); 2512 getEventViewerDialog()->setJournal(jour);
2513 getEventViewerDialog()->showMe(); 2513 getEventViewerDialog()->showMe();
2514 2514
2515} 2515}
2516// void CalendarView::todoModified (Todo *event, int changed) 2516// void CalendarView::todoModified (Todo *event, int changed)
2517// { 2517// {
2518// // if (mDialogList.find (event) != mDialogList.end ()) { 2518// // if (mDialogList.find (event) != mDialogList.end ()) {
2519// // kdDebug() << "Todo modified and open" << endl; 2519// // kdDebug() << "Todo modified and open" << endl;
2520// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2520// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2521// // temp->modified (changed); 2521// // temp->modified (changed);
2522 2522
2523// // } 2523// // }
2524 2524
2525// mViewManager->updateView(); 2525// mViewManager->updateView();
2526// } 2526// }
2527 2527
2528void CalendarView::appointment_show() 2528void CalendarView::appointment_show()
2529{ 2529{
2530 Event *anEvent = 0; 2530 Event *anEvent = 0;
2531 2531
2532 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2532 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2533 2533
2534 if (mViewManager->currentView()->isEventView()) { 2534 if (mViewManager->currentView()->isEventView()) {
2535 if ( incidence && incidence->type() == "Event" ) { 2535 if ( incidence && incidence->type() == "Event" ) {
2536 anEvent = static_cast<Event *>(incidence); 2536 anEvent = static_cast<Event *>(incidence);
2537 } 2537 }
2538 } 2538 }
2539 2539
2540 if (!anEvent) { 2540 if (!anEvent) {
2541 KNotifyClient::beep(); 2541 KNotifyClient::beep();
2542 return; 2542 return;
2543 } 2543 }
2544 2544
2545 showEvent(anEvent); 2545 showEvent(anEvent);
2546} 2546}
2547 2547
2548void CalendarView::appointment_edit() 2548void CalendarView::appointment_edit()
2549{ 2549{
2550 Event *anEvent = 0; 2550 Event *anEvent = 0;
2551 2551
2552 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2552 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2553 2553
2554 if (mViewManager->currentView()->isEventView()) { 2554 if (mViewManager->currentView()->isEventView()) {
2555 if ( incidence && incidence->type() == "Event" ) { 2555 if ( incidence && incidence->type() == "Event" ) {
2556 anEvent = static_cast<Event *>(incidence); 2556 anEvent = static_cast<Event *>(incidence);
2557 } 2557 }
2558 } 2558 }
2559 2559
2560 if (!anEvent) { 2560 if (!anEvent) {
2561 KNotifyClient::beep(); 2561 KNotifyClient::beep();
2562 return; 2562 return;
2563 } 2563 }
2564 2564
2565 editEvent(anEvent); 2565 editEvent(anEvent);
2566} 2566}
2567 2567
2568void CalendarView::appointment_delete() 2568void CalendarView::appointment_delete()
2569{ 2569{
2570 Event *anEvent = 0; 2570 Event *anEvent = 0;
2571 2571
2572 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2572 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2573 2573
2574 if (mViewManager->currentView()->isEventView()) { 2574 if (mViewManager->currentView()->isEventView()) {
2575 if ( incidence && incidence->type() == "Event" ) { 2575 if ( incidence && incidence->type() == "Event" ) {
2576 anEvent = static_cast<Event *>(incidence); 2576 anEvent = static_cast<Event *>(incidence);
2577 } 2577 }
2578 } 2578 }
2579 2579
2580 if (!anEvent) { 2580 if (!anEvent) {
2581 KNotifyClient::beep(); 2581 KNotifyClient::beep();
2582 return; 2582 return;
2583 } 2583 }
2584 2584
2585 deleteEvent(anEvent); 2585 deleteEvent(anEvent);
2586} 2586}
2587 2587
2588void CalendarView::todo_unsub(Todo *anTodo ) 2588void CalendarView::todo_unsub(Todo *anTodo )
2589{ 2589{
2590 // Todo *anTodo = selectedTodo(); 2590 // Todo *anTodo = selectedTodo();
2591 if (!anTodo) return; 2591 if (!anTodo) return;
2592 if (!anTodo->relatedTo()) return; 2592 if (!anTodo->relatedTo()) return;
2593 anTodo->relatedTo()->removeRelation(anTodo); 2593 anTodo->relatedTo()->removeRelation(anTodo);
2594 anTodo->setRelatedTo(0); 2594 anTodo->setRelatedTo(0);
2595 anTodo->updated(); 2595 anTodo->updated();
2596 anTodo->setRelatedToUid(""); 2596 anTodo->setRelatedToUid("");
2597 setModified(true); 2597 setModified(true);
2598 updateView(); 2598 updateView();
2599} 2599}
2600 2600
2601void CalendarView::deleteTodo(Todo *todo) 2601void CalendarView::deleteTodo(Todo *todo)
2602{ 2602{
2603 if (!todo) { 2603 if (!todo) {
2604 KNotifyClient::beep(); 2604 KNotifyClient::beep();
2605 return; 2605 return;
2606 } 2606 }
2607 if (KOPrefs::instance()->mConfirm) { 2607 if (KOPrefs::instance()->mConfirm) {
2608 switch (msgItemDelete()) { 2608 switch (msgItemDelete()) {
2609 case KMessageBox::Continue: // OK 2609 case KMessageBox::Continue: // OK
2610 if (!todo->relations().isEmpty()) { 2610 if (!todo->relations().isEmpty()) {
2611 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2611 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2612 i18n("Delete To-Do")); 2612 i18n("Delete To-Do"));
2613 } else { 2613 } else {
2614 checkExternalId( todo ); 2614 checkExternalId( todo );
2615 calendar()->deleteTodo(todo); 2615 calendar()->deleteTodo(todo);
2616 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2616 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2617 updateView(); 2617 updateView();
2618 } 2618 }
2619 break; 2619 break;
2620 } // switch 2620 } // switch
2621 } else { 2621 } else {
2622 if (!todo->relations().isEmpty()) { 2622 if (!todo->relations().isEmpty()) {
2623 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2623 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2624 i18n("Delete To-Do")); 2624 i18n("Delete To-Do"));
2625 } else { 2625 } else {
2626 checkExternalId( todo ); 2626 checkExternalId( todo );
2627 mCalendar->deleteTodo(todo); 2627 mCalendar->deleteTodo(todo);
2628 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2628 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2629 updateView(); 2629 updateView();
2630 } 2630 }
2631 } 2631 }
2632 emit updateSearchDialog(); 2632 emit updateSearchDialog();
2633} 2633}
2634void CalendarView::deleteJournal(Journal *jour) 2634void CalendarView::deleteJournal(Journal *jour)
2635{ 2635{
2636 if (!jour) { 2636 if (!jour) {
2637 KNotifyClient::beep(); 2637 KNotifyClient::beep();
2638 return; 2638 return;
2639 } 2639 }
2640 if (KOPrefs::instance()->mConfirm) { 2640 if (KOPrefs::instance()->mConfirm) {
2641 switch (msgItemDelete()) { 2641 switch (msgItemDelete()) {
2642 case KMessageBox::Continue: // OK 2642 case KMessageBox::Continue: // OK
2643 calendar()->deleteJournal(jour); 2643 calendar()->deleteJournal(jour);
2644 updateView(); 2644 updateView();
2645 break; 2645 break;
2646 } // switch 2646 } // switch
2647 } else { 2647 } else {
2648 calendar()->deleteJournal(jour);; 2648 calendar()->deleteJournal(jour);;
2649 updateView(); 2649 updateView();
2650 } 2650 }
2651 emit updateSearchDialog(); 2651 emit updateSearchDialog();
2652} 2652}
2653 2653
2654void CalendarView::deleteEvent(Event *anEvent) 2654void CalendarView::deleteEvent(Event *anEvent)
2655{ 2655{
2656 if (!anEvent) { 2656 if (!anEvent) {
2657 KNotifyClient::beep(); 2657 KNotifyClient::beep();
2658 return; 2658 return;
2659 } 2659 }
2660 2660
2661 if (anEvent->recurrence()->doesRecur()) { 2661 if (anEvent->recurrence()->doesRecur()) {
2662 QDate itemDate = mViewManager->currentSelectionDate(); 2662 QDate itemDate = mViewManager->currentSelectionDate();
2663 int km; 2663 int km;
2664 if (!itemDate.isValid()) { 2664 if (!itemDate.isValid()) {
2665 //kdDebug() << "Date Not Valid" << endl; 2665 //kdDebug() << "Date Not Valid" << endl;
2666 if (KOPrefs::instance()->mConfirm) { 2666 if (KOPrefs::instance()->mConfirm) {
2667 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2667 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2668 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2668 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2669 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2669 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2670 if ( km == KMessageBox::Continue ) 2670 if ( km == KMessageBox::Continue )
2671 km = KMessageBox::No; // No = all below 2671 km = KMessageBox::No; // No = all below
2672 } else 2672 } else
2673 km = KMessageBox::No; 2673 km = KMessageBox::No;
2674 } else { 2674 } else {
2675 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2675 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2676 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2676 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2677 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2677 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2678 i18n("KO/Pi Confirmation"),i18n("Current"), 2678 i18n("KO/Pi Confirmation"),i18n("Current"),
2679 i18n("All")); 2679 i18n("All"));
2680 } 2680 }
2681 switch(km) { 2681 switch(km) {
2682 2682
2683 case KMessageBox::No: // Continue // all 2683 case KMessageBox::No: // Continue // all
2684 //qDebug("KMessageBox::No "); 2684 //qDebug("KMessageBox::No ");
2685 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2685 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2686 schedule(Scheduler::Cancel,anEvent); 2686 schedule(Scheduler::Cancel,anEvent);
2687 2687
2688 checkExternalId( anEvent); 2688 checkExternalId( anEvent);
2689 mCalendar->deleteEvent(anEvent); 2689 mCalendar->deleteEvent(anEvent);
2690 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2690 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2691 break; 2691 break;
2692 2692
2693 // Disabled because it does not work 2693 // Disabled because it does not work
2694 //#if 0 2694 //#if 0
2695 case KMessageBox::Yes: // just this one 2695 case KMessageBox::Yes: // just this one
2696 //QDate qd = mNavigator->selectedDates().first(); 2696 //QDate qd = mNavigator->selectedDates().first();
2697 //if (!qd.isValid()) { 2697 //if (!qd.isValid()) {
2698 // kdDebug() << "no date selected, or invalid date" << endl; 2698 // kdDebug() << "no date selected, or invalid date" << endl;
2699 // KNotifyClient::beep(); 2699 // KNotifyClient::beep();
2700 // return; 2700 // return;
2701 //} 2701 //}
2702 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2702 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2703 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2703 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2704 anEvent->addExDate(itemDate); 2704 anEvent->addExDate(itemDate);
2705 int duration = anEvent->recurrence()->duration(); 2705 int duration = anEvent->recurrence()->duration();
2706 if ( duration > 0 ) { 2706 if ( duration > 0 ) {
2707 anEvent->recurrence()->setDuration( duration - 1 ); 2707 anEvent->recurrence()->setDuration( duration - 1 );
2708 } 2708 }
2709 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2709 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2710 } 2710 }
2711 break; 2711 break;
2712 //#endif 2712 //#endif
2713 } // switch 2713 } // switch
2714 } else { 2714 } else {
2715 if (KOPrefs::instance()->mConfirm) { 2715 if (KOPrefs::instance()->mConfirm) {
2716 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2716 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2717 i18n("\nAre you sure you want\nto delete this event?"), 2717 i18n("\nAre you sure you want\nto delete this event?"),
2718 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2718 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2719 case KMessageBox::Continue: // OK 2719 case KMessageBox::Continue: // OK
2720 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2720 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2721 schedule(Scheduler::Cancel,anEvent); 2721 schedule(Scheduler::Cancel,anEvent);
2722 checkExternalId( anEvent); 2722 checkExternalId( anEvent);
2723 mCalendar->deleteEvent(anEvent); 2723 mCalendar->deleteEvent(anEvent);
2724 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2724 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2725 break; 2725 break;
2726 } // switch 2726 } // switch
2727 } else { 2727 } else {
2728 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2728 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2729 schedule(Scheduler::Cancel,anEvent); 2729 schedule(Scheduler::Cancel,anEvent);
2730 checkExternalId( anEvent); 2730 checkExternalId( anEvent);
2731 mCalendar->deleteEvent(anEvent); 2731 mCalendar->deleteEvent(anEvent);
2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2733 } 2733 }
2734 } // if-else 2734 } // if-else
2735 emit updateSearchDialog(); 2735 emit updateSearchDialog();
2736} 2736}
2737 2737
2738bool CalendarView::deleteEvent(const QString &uid) 2738bool CalendarView::deleteEvent(const QString &uid)
2739{ 2739{
2740 Event *ev = mCalendar->event(uid); 2740 Event *ev = mCalendar->event(uid);
2741 if (ev) { 2741 if (ev) {
2742 deleteEvent(ev); 2742 deleteEvent(ev);
2743 return true; 2743 return true;
2744 } else { 2744 } else {
2745 return false; 2745 return false;
2746 } 2746 }
2747} 2747}
2748 2748
2749/*****************************************************************************/ 2749/*****************************************************************************/
2750 2750
2751void CalendarView::action_mail() 2751void CalendarView::action_mail()
2752{ 2752{
2753#ifndef KORG_NOMAIL 2753#ifndef KORG_NOMAIL
2754 KOMailClient mailClient; 2754 KOMailClient mailClient;
2755 2755
2756 Incidence *incidence = currentSelection(); 2756 Incidence *incidence = currentSelection();
2757 2757
2758 if (!incidence) { 2758 if (!incidence) {
2759 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2759 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2760 return; 2760 return;
2761 } 2761 }
2762 if(incidence->attendeeCount() == 0 ) { 2762 if(incidence->attendeeCount() == 0 ) {
2763 KMessageBox::sorry(this, 2763 KMessageBox::sorry(this,
2764 i18n("Can't generate mail:\nNo attendees defined.\n")); 2764 i18n("Can't generate mail:\nNo attendees defined.\n"));
2765 return; 2765 return;
2766 } 2766 }
2767 2767
2768 CalendarLocal cal_tmp; 2768 CalendarLocal cal_tmp;
2769 Event *event = 0; 2769 Event *event = 0;
2770 Event *ev = 0; 2770 Event *ev = 0;
2771 if ( incidence && incidence->type() == "Event" ) { 2771 if ( incidence && incidence->type() == "Event" ) {
2772 event = static_cast<Event *>(incidence); 2772 event = static_cast<Event *>(incidence);
2773 ev = new Event(*event); 2773 ev = new Event(*event);
2774 cal_tmp.addEvent(ev); 2774 cal_tmp.addEvent(ev);
2775 } 2775 }
2776 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2776 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2777 QString attachment = mForm.toString( &cal_tmp ); 2777 QString attachment = mForm.toString( &cal_tmp );
2778 if (ev) delete(ev); 2778 if (ev) delete(ev);
2779 2779
2780 mailClient.mailAttendees(currentSelection(), attachment); 2780 mailClient.mailAttendees(currentSelection(), attachment);
2781 2781
2782#endif 2782#endif
2783 2783
2784#if 0 2784#if 0
2785 Event *anEvent = 0; 2785 Event *anEvent = 0;
2786 if (mViewManager->currentView()->isEventView()) { 2786 if (mViewManager->currentView()->isEventView()) {
2787 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2787 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2788 } 2788 }
2789 2789
2790 if (!anEvent) { 2790 if (!anEvent) {
2791 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2791 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2792 return; 2792 return;
2793 } 2793 }
2794 if(anEvent->attendeeCount() == 0 ) { 2794 if(anEvent->attendeeCount() == 0 ) {
2795 KMessageBox::sorry(this, 2795 KMessageBox::sorry(this,
2796 i18n("Can't generate mail:\nNo attendees defined.\n")); 2796 i18n("Can't generate mail:\nNo attendees defined.\n"));
2797 return; 2797 return;
2798 } 2798 }
2799 2799
2800 mailobject.emailEvent(anEvent); 2800 mailobject.emailEvent(anEvent);
2801#endif 2801#endif
2802} 2802}
2803 2803
2804 2804
2805void CalendarView::schedule_publish(Incidence *incidence) 2805void CalendarView::schedule_publish(Incidence *incidence)
2806{ 2806{
2807 Event *event = 0; 2807 Event *event = 0;
2808 Todo *todo = 0; 2808 Todo *todo = 0;
2809 2809
2810 if (incidence == 0) { 2810 if (incidence == 0) {
2811 incidence = mViewManager->currentView()->selectedIncidences().first(); 2811 incidence = mViewManager->currentView()->selectedIncidences().first();
2812 if (incidence == 0) { 2812 if (incidence == 0) {
2813 incidence = mTodoList->selectedIncidences().first(); 2813 incidence = mTodoList->selectedIncidences().first();
2814 } 2814 }
2815 } 2815 }
2816 if ( incidence && incidence->type() == "Event" ) { 2816 if ( incidence && incidence->type() == "Event" ) {
2817 event = static_cast<Event *>(incidence); 2817 event = static_cast<Event *>(incidence);
2818 } else { 2818 } else {
2819 if ( incidence && incidence->type() == "Todo" ) { 2819 if ( incidence && incidence->type() == "Todo" ) {
2820 todo = static_cast<Todo *>(incidence); 2820 todo = static_cast<Todo *>(incidence);
2821 } 2821 }
2822 } 2822 }
2823 2823
2824 if (!event && !todo) { 2824 if (!event && !todo) {
2825 KMessageBox::sorry(this,i18n("No event selected.")); 2825 KMessageBox::sorry(this,i18n("No event selected."));
2826 return; 2826 return;
2827 } 2827 }
2828 2828
2829 PublishDialog *publishdlg = new PublishDialog(); 2829 PublishDialog *publishdlg = new PublishDialog();
2830 if (incidence->attendeeCount()>0) { 2830 if (incidence->attendeeCount()>0) {
2831 QPtrList<Attendee> attendees = incidence->attendees(); 2831 QPtrList<Attendee> attendees = incidence->attendees();
2832 attendees.first(); 2832 attendees.first();
2833 while ( attendees.current()!=0 ) { 2833 while ( attendees.current()!=0 ) {
2834 publishdlg->addAttendee(attendees.current()); 2834 publishdlg->addAttendee(attendees.current());
2835 attendees.next(); 2835 attendees.next();
2836 } 2836 }
2837 } 2837 }
2838 bool send = true; 2838 bool send = true;
2839 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2839 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2840 if ( publishdlg->exec() != QDialog::Accepted ) 2840 if ( publishdlg->exec() != QDialog::Accepted )
2841 send = false; 2841 send = false;
2842 } 2842 }
2843 if ( send ) { 2843 if ( send ) {
2844 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2844 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2845 if ( event ) { 2845 if ( event ) {
2846 Event *ev = new Event(*event); 2846 Event *ev = new Event(*event);
2847 ev->registerObserver(0); 2847 ev->registerObserver(0);
2848 ev->clearAttendees(); 2848 ev->clearAttendees();
2849 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2849 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2850 delete(ev); 2850 delete(ev);
2851 } 2851 }
2852 } else { 2852 } else {
2853 if ( todo ) { 2853 if ( todo ) {
2854 Todo *ev = new Todo(*todo); 2854 Todo *ev = new Todo(*todo);
2855 ev->registerObserver(0); 2855 ev->registerObserver(0);
2856 ev->clearAttendees(); 2856 ev->clearAttendees();
2857 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2857 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2858 delete(ev); 2858 delete(ev);
2859 } 2859 }
2860 } 2860 }
2861 } 2861 }
2862 } 2862 }
2863 delete publishdlg; 2863 delete publishdlg;
2864} 2864}
2865 2865
2866void CalendarView::schedule_request(Incidence *incidence) 2866void CalendarView::schedule_request(Incidence *incidence)
2867{ 2867{
2868 schedule(Scheduler::Request,incidence); 2868 schedule(Scheduler::Request,incidence);
2869} 2869}
2870 2870
2871void CalendarView::schedule_refresh(Incidence *incidence) 2871void CalendarView::schedule_refresh(Incidence *incidence)
2872{ 2872{
2873 schedule(Scheduler::Refresh,incidence); 2873 schedule(Scheduler::Refresh,incidence);
2874} 2874}
2875 2875
2876void CalendarView::schedule_cancel(Incidence *incidence) 2876void CalendarView::schedule_cancel(Incidence *incidence)
2877{ 2877{
2878 schedule(Scheduler::Cancel,incidence); 2878 schedule(Scheduler::Cancel,incidence);
2879} 2879}
2880 2880
2881void CalendarView::schedule_add(Incidence *incidence) 2881void CalendarView::schedule_add(Incidence *incidence)
2882{ 2882{
2883 schedule(Scheduler::Add,incidence); 2883 schedule(Scheduler::Add,incidence);
2884} 2884}
2885 2885
2886void CalendarView::schedule_reply(Incidence *incidence) 2886void CalendarView::schedule_reply(Incidence *incidence)
2887{ 2887{
2888 schedule(Scheduler::Reply,incidence); 2888 schedule(Scheduler::Reply,incidence);
2889} 2889}
2890 2890
2891void CalendarView::schedule_counter(Incidence *incidence) 2891void CalendarView::schedule_counter(Incidence *incidence)
2892{ 2892{
2893 schedule(Scheduler::Counter,incidence); 2893 schedule(Scheduler::Counter,incidence);
2894} 2894}
2895 2895
2896void CalendarView::schedule_declinecounter(Incidence *incidence) 2896void CalendarView::schedule_declinecounter(Incidence *incidence)
2897{ 2897{
2898 schedule(Scheduler::Declinecounter,incidence); 2898 schedule(Scheduler::Declinecounter,incidence);
2899} 2899}
2900 2900
2901void CalendarView::schedule_publish_freebusy(int daysToPublish) 2901void CalendarView::schedule_publish_freebusy(int daysToPublish)
2902{ 2902{
2903 QDateTime start = QDateTime::currentDateTime(); 2903 QDateTime start = QDateTime::currentDateTime();
2904 QDateTime end = start.addDays(daysToPublish); 2904 QDateTime end = start.addDays(daysToPublish);
2905 2905
2906 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2906 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2907 freebusy->setOrganizer(KOPrefs::instance()->email()); 2907 freebusy->setOrganizer(KOPrefs::instance()->email());
2908 2908
2909 2909
2910 PublishDialog *publishdlg = new PublishDialog(); 2910 PublishDialog *publishdlg = new PublishDialog();
2911 if ( publishdlg->exec() == QDialog::Accepted ) { 2911 if ( publishdlg->exec() == QDialog::Accepted ) {
2912 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2912 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2913 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2913 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2914 delete(freebusy); 2914 delete(freebusy);
2915 } 2915 }
2916 } 2916 }
2917 delete publishdlg; 2917 delete publishdlg;
2918} 2918}
2919 2919
2920void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2920void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2921{ 2921{
2922 Event *event = 0; 2922 Event *event = 0;
2923 Todo *todo = 0; 2923 Todo *todo = 0;
2924 2924
2925 if (incidence == 0) { 2925 if (incidence == 0) {
2926 incidence = mViewManager->currentView()->selectedIncidences().first(); 2926 incidence = mViewManager->currentView()->selectedIncidences().first();
2927 if (incidence == 0) { 2927 if (incidence == 0) {
2928 incidence = mTodoList->selectedIncidences().first(); 2928 incidence = mTodoList->selectedIncidences().first();
2929 } 2929 }
2930 } 2930 }
2931 if ( incidence && incidence->type() == "Event" ) { 2931 if ( incidence && incidence->type() == "Event" ) {
2932 event = static_cast<Event *>(incidence); 2932 event = static_cast<Event *>(incidence);
2933 } 2933 }
2934 if ( incidence && incidence->type() == "Todo" ) { 2934 if ( incidence && incidence->type() == "Todo" ) {
2935 todo = static_cast<Todo *>(incidence); 2935 todo = static_cast<Todo *>(incidence);
2936 } 2936 }
2937 2937
2938 if (!event && !todo) { 2938 if (!event && !todo) {
2939 KMessageBox::sorry(this,i18n("No event selected.")); 2939 KMessageBox::sorry(this,i18n("No event selected."));
2940 return; 2940 return;
2941 } 2941 }
2942 2942
2943 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2943 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2944 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2944 KMessageBox::sorry(this,i18n("The event has no attendees."));
2945 return; 2945 return;
2946 } 2946 }
2947 2947
2948 Event *ev = 0; 2948 Event *ev = 0;
2949 if (event) ev = new Event(*event); 2949 if (event) ev = new Event(*event);
2950 Todo *to = 0; 2950 Todo *to = 0;
2951 if (todo) to = new Todo(*todo); 2951 if (todo) to = new Todo(*todo);
2952 2952
2953 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2953 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2954 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2954 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2955 if (!me) { 2955 if (!me) {
2956 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2956 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2957 return; 2957 return;
2958 } 2958 }
2959 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2959 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2960 StatusDialog *statdlg = new StatusDialog(this); 2960 StatusDialog *statdlg = new StatusDialog(this);
2961 if (!statdlg->exec()==QDialog::Accepted) return; 2961 if (!statdlg->exec()==QDialog::Accepted) return;
2962 me->setStatus( statdlg->status() ); 2962 me->setStatus( statdlg->status() );
2963 delete(statdlg); 2963 delete(statdlg);
2964 } 2964 }
2965 Attendee *menew = new Attendee(*me); 2965 Attendee *menew = new Attendee(*me);
2966 if (ev) { 2966 if (ev) {
2967 ev->clearAttendees(); 2967 ev->clearAttendees();
2968 ev->addAttendee(menew,false); 2968 ev->addAttendee(menew,false);
2969 } else { 2969 } else {
2970 if (to) { 2970 if (to) {
2971 todo->clearAttendees(); 2971 todo->clearAttendees();
2972 todo->addAttendee(menew,false); 2972 todo->addAttendee(menew,false);
2973 } 2973 }
2974 } 2974 }
2975 } 2975 }
2976 2976
2977 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2977 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2978 if (ev) { 2978 if (ev) {
2979 if ( !dlg->addMessage(ev,method) ) delete(ev); 2979 if ( !dlg->addMessage(ev,method) ) delete(ev);
2980 } else { 2980 } else {
2981 if (to) { 2981 if (to) {
2982 if ( !dlg->addMessage(to,method) ) delete(to); 2982 if ( !dlg->addMessage(to,method) ) delete(to);
2983 } 2983 }
2984 } 2984 }
2985} 2985}
2986 2986
2987void CalendarView::openAddressbook() 2987void CalendarView::openAddressbook()
2988{ 2988{
2989 KRun::runCommand("kaddressbook"); 2989 KRun::runCommand("kaddressbook");
2990} 2990}
2991 2991
2992void CalendarView::setModified(bool modified) 2992void CalendarView::setModified(bool modified)
2993{ 2993{
2994 if ( modified ) 2994 if ( modified )
2995 emit signalmodified(); 2995 emit signalmodified();
2996 if (mModified != modified) { 2996 if (mModified != modified) {
2997 mModified = modified; 2997 mModified = modified;
2998 emit modifiedChanged(mModified); 2998 emit modifiedChanged(mModified);
2999 } 2999 }
3000} 3000}
3001 3001
3002bool CalendarView::isReadOnly() 3002bool CalendarView::isReadOnly()
3003{ 3003{
3004 return mReadOnly; 3004 return mReadOnly;
3005} 3005}
3006 3006
3007void CalendarView::setReadOnly(bool readOnly) 3007void CalendarView::setReadOnly(bool readOnly)
3008{ 3008{
3009 if (mReadOnly != readOnly) { 3009 if (mReadOnly != readOnly) {
3010 mReadOnly = readOnly; 3010 mReadOnly = readOnly;
3011 emit readOnlyChanged(mReadOnly); 3011 emit readOnlyChanged(mReadOnly);
3012 } 3012 }
3013} 3013}
3014 3014
3015bool CalendarView::isModified() 3015bool CalendarView::isModified()
3016{ 3016{
3017 return mModified; 3017 return mModified;
3018} 3018}
3019 3019
3020void CalendarView::printSetup() 3020void CalendarView::printSetup()
3021{ 3021{
3022#ifndef KORG_NOPRINTER 3022#ifndef KORG_NOPRINTER
3023 createPrinter(); 3023 createPrinter();
3024 3024
3025 mCalPrinter->setupPrinter(); 3025 mCalPrinter->setupPrinter();
3026#endif 3026#endif
3027} 3027}
3028 3028
3029void CalendarView::print() 3029void CalendarView::print()
3030{ 3030{
3031#ifndef KORG_NOPRINTER 3031#ifndef KORG_NOPRINTER
3032 createPrinter(); 3032 createPrinter();
3033 3033
3034 DateList tmpDateList = mNavigator->selectedDates(); 3034 DateList tmpDateList = mNavigator->selectedDates();
3035 mCalPrinter->print(CalPrinter::Month, 3035 mCalPrinter->print(CalPrinter::Month,
3036 tmpDateList.first(), tmpDateList.last()); 3036 tmpDateList.first(), tmpDateList.last());
3037#endif 3037#endif
3038} 3038}
3039 3039
3040void CalendarView::printPreview() 3040void CalendarView::printPreview()
3041{ 3041{
3042#ifndef KORG_NOPRINTER 3042#ifndef KORG_NOPRINTER
3043 kdDebug() << "CalendarView::printPreview()" << endl; 3043 kdDebug() << "CalendarView::printPreview()" << endl;
3044 3044
3045 createPrinter(); 3045 createPrinter();
3046 3046
3047 DateList tmpDateList = mNavigator->selectedDates(); 3047 DateList tmpDateList = mNavigator->selectedDates();
3048 3048
3049 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3049 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3050 tmpDateList.last()); 3050 tmpDateList.last());
3051#endif 3051#endif
3052} 3052}
3053 3053
3054void CalendarView::exportICalendar() 3054void CalendarView::exportICalendar()
3055{ 3055{
3056 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3056 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3057 3057
3058 // Force correct extension 3058 // Force correct extension
3059 if (filename.right(4) != ".ics") filename += ".ics"; 3059 if (filename.right(4) != ".ics") filename += ".ics";
3060 3060
3061 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3061 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3062 storage.save(); 3062 storage.save();
3063} 3063}
3064 3064
3065bool CalendarView::exportVCalendar( QString filename ) 3065bool CalendarView::exportVCalendar( QString filename )
3066{ 3066{
3067 if (mCalendar->journals().count() > 0) { 3067 if (mCalendar->journals().count() > 0) {
3068 int result = KMessageBox::warningContinueCancel(this, 3068 int result = KMessageBox::warningContinueCancel(this,
3069 i18n("The journal entries can not be\nexported to a vCalendar file."), 3069 i18n("The journal entries can not be\nexported to a vCalendar file."),
3070 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3070 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3071 true); 3071 true);
3072 if (result != KMessageBox::Continue) return false; 3072 if (result != KMessageBox::Continue) return false;
3073 } 3073 }
3074 3074
3075 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3075 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3076 3076
3077 // Force correct extension 3077 // Force correct extension
3078 if (filename.right(4) != ".vcs") filename += ".vcs"; 3078 if (filename.right(4) != ".vcs") filename += ".vcs";
3079 3079
3080 FileStorage storage( mCalendar, filename, new VCalFormat ); 3080 FileStorage storage( mCalendar, filename, new VCalFormat );
3081 return storage.save(); 3081 return storage.save();
3082 3082
3083} 3083}
3084 3084
3085void CalendarView::eventUpdated(Incidence *) 3085void CalendarView::eventUpdated(Incidence *)
3086{ 3086{
3087 setModified(); 3087 setModified();
3088 // Don't call updateView here. The code, which has caused the update of the 3088 // Don't call updateView here. The code, which has caused the update of the
3089 // event is responsible for updating the view. 3089 // event is responsible for updating the view.
3090 // updateView(); 3090 // updateView();
3091} 3091}
3092 3092
3093void CalendarView::adaptNavigationUnits() 3093void CalendarView::adaptNavigationUnits()
3094{ 3094{
3095 if (mViewManager->currentView()->isEventView()) { 3095 if (mViewManager->currentView()->isEventView()) {
3096 int days = mViewManager->currentView()->currentDateCount(); 3096 int days = mViewManager->currentView()->currentDateCount();
3097 if (days == 1) { 3097 if (days == 1) {
3098 emit changeNavStringPrev(i18n("&Previous Day")); 3098 emit changeNavStringPrev(i18n("&Previous Day"));
3099 emit changeNavStringNext(i18n("&Next Day")); 3099 emit changeNavStringNext(i18n("&Next Day"));
3100 } else { 3100 } else {
3101 emit changeNavStringPrev(i18n("&Previous Week")); 3101 emit changeNavStringPrev(i18n("&Previous Week"));
3102 emit changeNavStringNext(i18n("&Next Week")); 3102 emit changeNavStringNext(i18n("&Next Week"));
3103 } 3103 }
3104 } 3104 }
3105} 3105}
3106 3106
3107void CalendarView::processMainViewSelection( Incidence *incidence ) 3107void CalendarView::processMainViewSelection( Incidence *incidence )
3108{ 3108{
3109 if ( incidence ) mTodoList->clearSelection(); 3109 if ( incidence ) mTodoList->clearSelection();
3110 processIncidenceSelection( incidence ); 3110 processIncidenceSelection( incidence );
3111} 3111}
3112 3112
3113void CalendarView::processTodoListSelection( Incidence *incidence ) 3113void CalendarView::processTodoListSelection( Incidence *incidence )
3114{ 3114{
3115 if ( incidence && mViewManager->currentView() ) { 3115 if ( incidence && mViewManager->currentView() ) {
3116 mViewManager->currentView()->clearSelection(); 3116 mViewManager->currentView()->clearSelection();
3117 } 3117 }
3118 processIncidenceSelection( incidence ); 3118 processIncidenceSelection( incidence );
3119} 3119}
3120 3120
3121void CalendarView::processIncidenceSelection( Incidence *incidence ) 3121void CalendarView::processIncidenceSelection( Incidence *incidence )
3122{ 3122{
3123 if ( incidence == mSelectedIncidence ) return; 3123 if ( incidence == mSelectedIncidence ) return;
3124 3124
3125 mSelectedIncidence = incidence; 3125 mSelectedIncidence = incidence;
3126 3126
3127 emit incidenceSelected( mSelectedIncidence ); 3127 emit incidenceSelected( mSelectedIncidence );
3128 3128
3129 if ( incidence && incidence->type() == "Event" ) { 3129 if ( incidence && incidence->type() == "Event" ) {
3130 Event *event = static_cast<Event *>( incidence ); 3130 Event *event = static_cast<Event *>( incidence );
3131 if ( event->organizer() == KOPrefs::instance()->email() ) { 3131 if ( event->organizer() == KOPrefs::instance()->email() ) {
3132 emit organizerEventsSelected( true ); 3132 emit organizerEventsSelected( true );
3133 } else { 3133 } else {
3134 emit organizerEventsSelected(false); 3134 emit organizerEventsSelected(false);
3135 } 3135 }
3136 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3136 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3137 KOPrefs::instance()->email() ) ) { 3137 KOPrefs::instance()->email() ) ) {
3138 emit groupEventsSelected( true ); 3138 emit groupEventsSelected( true );
3139 } else { 3139 } else {
3140 emit groupEventsSelected(false); 3140 emit groupEventsSelected(false);
3141 } 3141 }
3142 return; 3142 return;
3143 } else { 3143 } else {
3144 if ( incidence && incidence->type() == "Todo" ) { 3144 if ( incidence && incidence->type() == "Todo" ) {
3145 emit todoSelected( true ); 3145 emit todoSelected( true );
3146 Todo *event = static_cast<Todo *>( incidence ); 3146 Todo *event = static_cast<Todo *>( incidence );
3147 if ( event->organizer() == KOPrefs::instance()->email() ) { 3147 if ( event->organizer() == KOPrefs::instance()->email() ) {
3148 emit organizerEventsSelected( true ); 3148 emit organizerEventsSelected( true );
3149 } else { 3149 } else {
3150 emit organizerEventsSelected(false); 3150 emit organizerEventsSelected(false);
3151 } 3151 }
3152 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3152 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3153 KOPrefs::instance()->email() ) ) { 3153 KOPrefs::instance()->email() ) ) {
3154 emit groupEventsSelected( true ); 3154 emit groupEventsSelected( true );
3155 } else { 3155 } else {
3156 emit groupEventsSelected(false); 3156 emit groupEventsSelected(false);
3157 } 3157 }
3158 return; 3158 return;
3159 } else { 3159 } else {
3160 emit todoSelected( false ); 3160 emit todoSelected( false );
3161 emit organizerEventsSelected(false); 3161 emit organizerEventsSelected(false);
3162 emit groupEventsSelected(false); 3162 emit groupEventsSelected(false);
3163 } 3163 }
3164 return; 3164 return;
3165 } 3165 }
3166 3166
3167 /* if ( incidence && incidence->type() == "Todo" ) { 3167 /* if ( incidence && incidence->type() == "Todo" ) {
3168 emit todoSelected( true ); 3168 emit todoSelected( true );
3169 } else { 3169 } else {
3170 emit todoSelected( false ); 3170 emit todoSelected( false );
3171 }*/ 3171 }*/
3172} 3172}
3173 3173
3174 3174
3175void CalendarView::checkClipboard() 3175void CalendarView::checkClipboard()
3176{ 3176{
3177#ifndef KORG_NODND 3177#ifndef KORG_NODND
3178 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3178 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3179 emit pasteEnabled(true); 3179 emit pasteEnabled(true);
3180 } else { 3180 } else {
3181 emit pasteEnabled(false); 3181 emit pasteEnabled(false);
3182 } 3182 }
3183#endif 3183#endif
3184} 3184}
3185 3185
3186void CalendarView::showDates(const DateList &selectedDates) 3186void CalendarView::showDates(const DateList &selectedDates)
3187{ 3187{
3188 // kdDebug() << "CalendarView::selectDates()" << endl; 3188 // kdDebug() << "CalendarView::selectDates()" << endl;
3189 3189
3190 if ( mViewManager->currentView() ) { 3190 if ( mViewManager->currentView() ) {
3191 updateView( selectedDates.first(), selectedDates.last() ); 3191 updateView( selectedDates.first(), selectedDates.last() );
3192 } else { 3192 } else {
3193 mViewManager->showAgendaView(); 3193 mViewManager->showAgendaView();
3194 } 3194 }
3195 3195
3196 QString selDates; 3196 QString selDates;
3197 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3197 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3198 if (selectedDates.first() < selectedDates.last() ) 3198 if (selectedDates.first() < selectedDates.last() )
3199 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3199 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3200 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3200 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3201 3201
3202} 3202}
3203 3203
3204QPtrList<CalFilter> CalendarView::filters() 3204QPtrList<CalFilter> CalendarView::filters()
3205{ 3205{
3206 return mFilters; 3206 return mFilters;
3207 3207
3208} 3208}
3209void CalendarView::editFilters() 3209void CalendarView::editFilters()
3210{ 3210{
3211 // kdDebug() << "CalendarView::editFilters()" << endl; 3211 // kdDebug() << "CalendarView::editFilters()" << endl;
3212 3212
3213 CalFilter *filter = mFilters.first(); 3213 CalFilter *filter = mFilters.first();
3214 while(filter) { 3214 while(filter) {
3215 kdDebug() << " Filter: " << filter->name() << endl; 3215 kdDebug() << " Filter: " << filter->name() << endl;
3216 filter = mFilters.next(); 3216 filter = mFilters.next();
3217 } 3217 }
3218 3218
3219 mDialogManager->showFilterEditDialog(&mFilters); 3219 mDialogManager->showFilterEditDialog(&mFilters);
3220} 3220}
3221void CalendarView::toggleFilter() 3221void CalendarView::toggleFilter()
3222{ 3222{
3223 showFilter(! mFilterView->isVisible()); 3223 showFilter(! mFilterView->isVisible());
3224} 3224}
3225 3225
3226KOFilterView *CalendarView::filterView() 3226KOFilterView *CalendarView::filterView()
3227{ 3227{
3228 return mFilterView; 3228 return mFilterView;
3229} 3229}
3230void CalendarView::selectFilter( int fil ) 3230void CalendarView::selectFilter( int fil )
3231{ 3231{
3232 mFilterView->setSelectedFilter( fil ); 3232 mFilterView->setSelectedFilter( fil );
3233} 3233}
3234void CalendarView::showFilter(bool visible) 3234void CalendarView::showFilter(bool visible)
3235{ 3235{
3236 if (visible) mFilterView->show(); 3236 if (visible) mFilterView->show();
3237 else mFilterView->hide(); 3237 else mFilterView->hide();
3238} 3238}
3239void CalendarView::toggleFilerEnabled( ) 3239void CalendarView::toggleFilerEnabled( )
3240{ 3240{
3241 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3241 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3242 if ( !mFilterView->filtersEnabled() ) 3242 if ( !mFilterView->filtersEnabled() )
3243 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3243 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3244 3244
3245} 3245}
3246void CalendarView::updateFilter() 3246void CalendarView::updateFilter()
3247{ 3247{
3248 CalFilter *filter = mFilterView->selectedFilter(); 3248 CalFilter *filter = mFilterView->selectedFilter();
3249 if (filter) { 3249 if (filter) {
3250 if (mFilterView->filtersEnabled()) { 3250 if (mFilterView->filtersEnabled()) {
3251 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3251 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3252 filter->setEnabled(true); 3252 filter->setEnabled(true);
3253 } 3253 }
3254 else filter->setEnabled(false); 3254 else filter->setEnabled(false);
3255 mCalendar->setFilter(filter); 3255 mCalendar->setFilter(filter);
3256 updateView(); 3256 updateView();
3257 } 3257 }
3258} 3258}
3259 3259
3260void CalendarView::filterEdited() 3260void CalendarView::filterEdited()
3261{ 3261{
3262 mFilterView->updateFilters(); 3262 mFilterView->updateFilters();
3263 updateFilter(); 3263 updateFilter();
3264 writeSettings(); 3264 writeSettings();
3265} 3265}
3266 3266
3267 3267
3268void CalendarView::takeOverEvent() 3268void CalendarView::takeOverEvent()
3269{ 3269{
3270 Incidence *incidence = currentSelection(); 3270 Incidence *incidence = currentSelection();
3271 3271
3272 if (!incidence) return; 3272 if (!incidence) return;
3273 3273
3274 incidence->setOrganizer(KOPrefs::instance()->email()); 3274 incidence->setOrganizer(KOPrefs::instance()->email());
3275 incidence->recreate(); 3275 incidence->recreate();
3276 incidence->setReadOnly(false); 3276 incidence->setReadOnly(false);
3277 3277
3278 updateView(); 3278 updateView();
3279} 3279}
3280 3280
3281void CalendarView::takeOverCalendar() 3281void CalendarView::takeOverCalendar()
3282{ 3282{
3283 // TODO: Create Calendar::allIncidences() function and use it here 3283 // TODO: Create Calendar::allIncidences() function and use it here
3284 3284
3285 QPtrList<Event> events = mCalendar->events(); 3285 QPtrList<Event> events = mCalendar->events();
3286 for(uint i=0; i<events.count(); ++i) { 3286 for(uint i=0; i<events.count(); ++i) {
3287 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3287 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3288 events.at(i)->recreate(); 3288 events.at(i)->recreate();
3289 events.at(i)->setReadOnly(false); 3289 events.at(i)->setReadOnly(false);
3290 } 3290 }
3291 3291
3292 QPtrList<Todo> todos = mCalendar->todos(); 3292 QPtrList<Todo> todos = mCalendar->todos();
3293 for(uint i=0; i<todos.count(); ++i) { 3293 for(uint i=0; i<todos.count(); ++i) {
3294 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3294 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3295 todos.at(i)->recreate(); 3295 todos.at(i)->recreate();
3296 todos.at(i)->setReadOnly(false); 3296 todos.at(i)->setReadOnly(false);
3297 } 3297 }
3298 3298
3299 QPtrList<Journal> journals = mCalendar->journals(); 3299 QPtrList<Journal> journals = mCalendar->journals();
3300 for(uint i=0; i<journals.count(); ++i) { 3300 for(uint i=0; i<journals.count(); ++i) {
3301 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3301 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3302 journals.at(i)->recreate(); 3302 journals.at(i)->recreate();
3303 journals.at(i)->setReadOnly(false); 3303 journals.at(i)->setReadOnly(false);
3304 } 3304 }
3305 3305
3306 updateView(); 3306 updateView();
3307} 3307}
3308 3308
3309void CalendarView::showIntro() 3309void CalendarView::showIntro()
3310{ 3310{
3311 kdDebug() << "To be implemented." << endl; 3311 kdDebug() << "To be implemented." << endl;
3312} 3312}
3313 3313
3314QWidgetStack *CalendarView::viewStack() 3314QWidgetStack *CalendarView::viewStack()
3315{ 3315{
3316 return mRightFrame; 3316 return mRightFrame;
3317} 3317}
3318 3318
3319QWidget *CalendarView::leftFrame() 3319QWidget *CalendarView::leftFrame()
3320{ 3320{
3321 return mLeftFrame; 3321 return mLeftFrame;
3322} 3322}
3323 3323
3324DateNavigator *CalendarView::dateNavigator() 3324DateNavigator *CalendarView::dateNavigator()
3325{ 3325{
3326 return mNavigator; 3326 return mNavigator;
3327} 3327}
3328 3328
3329KDateNavigator* CalendarView::dateNavigatorWidget() 3329KDateNavigator* CalendarView::dateNavigatorWidget()
3330{ 3330{
3331 return mDateNavigator; 3331 return mDateNavigator;
3332} 3332}
3333void CalendarView::toggleDateNavigatorWidget() 3333void CalendarView::toggleDateNavigatorWidget()
3334{ 3334{
3335 if (mDateNavigator->isVisible()) 3335 if (mDateNavigator->isVisible())
3336 mDateNavigator->hide(); 3336 mDateNavigator->hide();
3337 else 3337 else
3338 mDateNavigator->show(); 3338 mDateNavigator->show();
3339} 3339}
3340void CalendarView::addView(KOrg::BaseView *view) 3340void CalendarView::addView(KOrg::BaseView *view)
3341{ 3341{
3342 mViewManager->addView(view); 3342 mViewManager->addView(view);
3343} 3343}
3344 3344
3345void CalendarView::showView(KOrg::BaseView *view) 3345void CalendarView::showView(KOrg::BaseView *view)
3346{ 3346{
3347 mViewManager->showView(view, mLeftFrame->isVisible()); 3347 mViewManager->showView(view, mLeftFrame->isVisible());
3348} 3348}
3349 3349
3350Incidence *CalendarView::currentSelection() 3350Incidence *CalendarView::currentSelection()
3351{ 3351{
3352 return mViewManager->currentSelection(); 3352 return mViewManager->currentSelection();
3353} 3353}
3354void CalendarView::toggleAllDaySize() 3354void CalendarView::toggleAllDaySize()
3355{ 3355{
3356 /* 3356 /*
3357 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3357 if ( KOPrefs::instance()->mAllDaySize > 47 )
3358 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3358 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3359 else 3359 else
3360 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3360 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3361 */ 3361 */
3362 viewManager()->agendaView()->toggleAllDay(); 3362 viewManager()->agendaView()->toggleAllDay();
3363} 3363}
3364void CalendarView::toggleExpand() 3364void CalendarView::toggleExpand()
3365{ 3365{
3366 // if ( mLeftFrame->isHidden() ) { 3366 // if ( mLeftFrame->isHidden() ) {
3367 // mLeftFrame->show(); 3367 // mLeftFrame->show();
3368 // emit calendarViewExpanded( false ); 3368 // emit calendarViewExpanded( false );
3369 // } else { 3369 // } else {
3370 // mLeftFrame->hide(); 3370 // mLeftFrame->hide();
3371 // emit calendarViewExpanded( true ); 3371 // emit calendarViewExpanded( true );
3372 // } 3372 // }
3373 3373
3374 globalFlagBlockAgenda = 1; 3374 globalFlagBlockAgenda = 1;
3375 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3375 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3376 globalFlagBlockAgenda = 5; 3376 globalFlagBlockAgenda = 5;
3377 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3377 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3378 //mViewManager->showView( 0, true ); 3378 //mViewManager->showView( 0, true );
3379} 3379}
3380 3380
3381void CalendarView::calendarModified( bool modified, Calendar * ) 3381void CalendarView::calendarModified( bool modified, Calendar * )
3382{ 3382{
3383 setModified( modified ); 3383 setModified( modified );
3384} 3384}
3385 3385
3386Todo *CalendarView::selectedTodo() 3386Todo *CalendarView::selectedTodo()
3387{ 3387{
3388 Incidence *incidence = currentSelection(); 3388 Incidence *incidence = currentSelection();
3389 if ( incidence && incidence->type() == "Todo" ) { 3389 if ( incidence && incidence->type() == "Todo" ) {
3390 return static_cast<Todo *>( incidence ); 3390 return static_cast<Todo *>( incidence );
3391 } 3391 }
3392 3392
3393 incidence = mTodoList->selectedIncidences().first(); 3393 incidence = mTodoList->selectedIncidences().first();
3394 if ( incidence && incidence->type() == "Todo" ) { 3394 if ( incidence && incidence->type() == "Todo" ) {
3395 return static_cast<Todo *>( incidence ); 3395 return static_cast<Todo *>( incidence );
3396 } 3396 }
3397 3397
3398 return 0; 3398 return 0;
3399} 3399}
3400 3400
3401void CalendarView::dialogClosing(Incidence *in) 3401void CalendarView::dialogClosing(Incidence *in)
3402{ 3402{
3403 // mDialogList.remove(in); 3403 // mDialogList.remove(in);
3404} 3404}
3405 3405
3406void CalendarView::showIncidence() 3406void CalendarView::showIncidence()
3407{ 3407{
3408 Incidence *incidence = currentSelection(); 3408 Incidence *incidence = currentSelection();
3409 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3409 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3410 if ( incidence ) { 3410 if ( incidence ) {
3411 ShowIncidenceVisitor v; 3411 ShowIncidenceVisitor v;
3412 v.act( incidence, this ); 3412 v.act( incidence, this );
3413 } 3413 }
3414} 3414}
3415void CalendarView::editIncidenceDescription() 3415void CalendarView::editIncidenceDescription()
3416{ 3416{
3417 mFlagEditDescription = true; 3417 mFlagEditDescription = true;
3418 editIncidence(); 3418 editIncidence();
3419 mFlagEditDescription = false; 3419 mFlagEditDescription = false;
3420} 3420}
3421void CalendarView::editIncidence() 3421void CalendarView::editIncidence()
3422{ 3422{
3423 // qDebug("editIncidence() "); 3423 // qDebug("editIncidence() ");
3424 Incidence *incidence = currentSelection(); 3424 Incidence *incidence = currentSelection();
3425 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3425 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3426 if ( incidence ) { 3426 if ( incidence ) {
3427 EditIncidenceVisitor v; 3427 EditIncidenceVisitor v;
3428 v.act( incidence, this ); 3428 v.act( incidence, this );
3429 } 3429 }
3430} 3430}
3431 3431
3432void CalendarView::deleteIncidence() 3432void CalendarView::deleteIncidence()
3433{ 3433{
3434 Incidence *incidence = currentSelection(); 3434 Incidence *incidence = currentSelection();
3435 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3435 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3436 if ( incidence ) { 3436 if ( incidence ) {
3437 deleteIncidence(incidence); 3437 deleteIncidence(incidence);
3438 } 3438 }
3439} 3439}
3440 3440
3441void CalendarView::showIncidence(Incidence *incidence) 3441void CalendarView::showIncidence(Incidence *incidence)
3442{ 3442{
3443 if ( incidence ) { 3443 if ( incidence ) {
3444 ShowIncidenceVisitor v; 3444 ShowIncidenceVisitor v;
3445 v.act( incidence, this ); 3445 v.act( incidence, this );
3446 } 3446 }
3447} 3447}
3448 3448
3449void CalendarView::editIncidence(Incidence *incidence) 3449void CalendarView::editIncidence(Incidence *incidence)
3450{ 3450{
3451 if ( incidence ) { 3451 if ( incidence ) {
3452 3452
3453 EditIncidenceVisitor v; 3453 EditIncidenceVisitor v;
3454 v.act( incidence, this ); 3454 v.act( incidence, this );
3455 3455
3456 } 3456 }
3457} 3457}
3458 3458
3459void CalendarView::deleteIncidence(Incidence *incidence) 3459void CalendarView::deleteIncidence(Incidence *incidence)
3460{ 3460{
3461 //qDebug(" CalendarView::deleteIncidence "); 3461 //qDebug(" CalendarView::deleteIncidence ");
3462 if ( incidence ) { 3462 if ( incidence ) {
3463 DeleteIncidenceVisitor v; 3463 DeleteIncidenceVisitor v;
3464 v.act( incidence, this ); 3464 v.act( incidence, this );
3465 } 3465 }
3466} 3466}
3467 3467
3468 3468
3469void CalendarView::lookForOutgoingMessages() 3469void CalendarView::lookForOutgoingMessages()
3470{ 3470{
3471 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3471 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3472 ogd->loadMessages(); 3472 ogd->loadMessages();
3473} 3473}
3474 3474
3475void CalendarView::lookForIncomingMessages() 3475void CalendarView::lookForIncomingMessages()
3476{ 3476{
3477 IncomingDialog *icd = mDialogManager->incomingDialog(); 3477 IncomingDialog *icd = mDialogManager->incomingDialog();
3478 icd->retrieve(); 3478 icd->retrieve();
3479} 3479}
3480 3480
3481bool CalendarView::removeCompletedSubTodos( Todo* t ) 3481bool CalendarView::removeCompletedSubTodos( Todo* t )
3482{ 3482{
3483 bool deleteTodo = true; 3483 bool deleteTodo = true;
3484 QPtrList<Incidence> subTodos; 3484 QPtrList<Incidence> subTodos;
3485 Incidence *aTodo; 3485 Incidence *aTodo;
3486 subTodos = t->relations(); 3486 subTodos = t->relations();
3487 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3487 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3488 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3488 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3489 deleteTodo = false; 3489 deleteTodo = false;
3490 } 3490 }
3491 if ( deleteTodo ) { 3491 if ( deleteTodo ) {
3492 if ( t->isCompleted() ) { 3492 if ( t->isCompleted() ) {
3493 checkExternalId( t ); 3493 checkExternalId( t );
3494 mCalendar->deleteTodo( t ); 3494 mCalendar->deleteTodo( t );
3495 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3495 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3496 } 3496 }
3497 else 3497 else
3498 deleteTodo = false; 3498 deleteTodo = false;
3499 } 3499 }
3500 return deleteTodo; 3500 return deleteTodo;
3501 3501
3502} 3502}
3503void CalendarView::purgeCompleted() 3503void CalendarView::purgeCompleted()
3504{ 3504{
3505 int result = KMessageBox::warningContinueCancel(this, 3505 int result = KMessageBox::warningContinueCancel(this,
3506 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3506 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3507 3507
3508 if (result == KMessageBox::Continue) { 3508 if (result == KMessageBox::Continue) {
3509 3509
3510 QPtrList<Todo> todoCal; 3510 QPtrList<Todo> todoCal;
3511 QPtrList<Todo> rootTodos; 3511 QPtrList<Todo> rootTodos;
3512 //QPtrList<Incidence> rel; 3512 //QPtrList<Incidence> rel;
3513 Todo *aTodo;//, *rTodo; 3513 Todo *aTodo;//, *rTodo;
3514 Incidence *rIncidence; 3514 Incidence *rIncidence;
3515 bool childDelete = false; 3515 bool childDelete = false;
3516 bool deletedOne = true; 3516 bool deletedOne = true;
3517 todoCal = calendar()->todos(); 3517 todoCal = calendar()->todos();
3518 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3518 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3519 if ( !aTodo->relatedTo() ) 3519 if ( !aTodo->relatedTo() )
3520 rootTodos.append( aTodo ); 3520 rootTodos.append( aTodo );
3521 } 3521 }
3522 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3522 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3523 removeCompletedSubTodos( aTodo ); 3523 removeCompletedSubTodos( aTodo );
3524 } 3524 }
3525 3525
3526 updateView(); 3526 updateView();
3527 } 3527 }
3528} 3528}
3529 3529
3530void CalendarView::slotCalendarChanged() 3530void CalendarView::slotCalendarChanged()
3531{ 3531{
3532 ; 3532 ;
3533} 3533}
3534 3534
3535NavigatorBar *CalendarView::navigatorBar() 3535NavigatorBar *CalendarView::navigatorBar()
3536{ 3536{
3537 return mNavigatorBar; 3537 return mNavigatorBar;
3538} 3538}
3539 3539
3540 3540
3541 3541
3542void CalendarView::keyPressEvent ( QKeyEvent *e) 3542void CalendarView::keyPressEvent ( QKeyEvent *e)
3543{ 3543{
3544 //qDebug(" alendarView::keyPressEvent "); 3544 //qDebug(" alendarView::keyPressEvent ");
3545 e->ignore(); 3545 e->ignore();
3546} 3546}
3547 3547
3548//#include "calendarview.moc" 3548//#include "calendarview.moc"
3549 3549
3550//#include "calendarviewbase.moc" 3550//#include "calendarviewbase.moc"
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
4OBJECTS_DIR = _obj/ 4OBJECTS_DIR = _obj/
5MOC_DIR = _moc 5MOC_DIR = _moc
6DESTDIR= ../bin 6DESTDIR= ../bin
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim 10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
11#../qtcompat 11#../qtcompat
12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC 14#KORG_NOPRINTER KORG_NOKABC
15DEFINES += KORG_NOLVALTERNATION 15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION 16DEFINES += DESKTOP_VERSION
17unix : { 17unix : {
18LIBS += ../bin/libmicrokdepim.so 18LIBS += ../bin/libmicrokdepim.so
19LIBS += ../bin/libmicrokcal.so 19LIBS += ../bin/libmicrokcal.so
20LIBS += ../bin/libmicrokde.so 20LIBS += ../bin/libmicrokde.so
21LIBS += ../bin/libmicrokabc.so 21LIBS += ../bin/libmicrokabc.so
22LIBS += ../bin/libmicrogammu.so
23LIBS += -lbluetooth 22LIBS += -lbluetooth
24LIBS += -lsdp 23LIBS += -lsdp
25 24
26LIBS += -lldap 25LIBS += -lldap
27OBJECTS_DIR = obj/unix 26OBJECTS_DIR = obj/unix
28MOC_DIR = moc/unix 27MOC_DIR = moc/unix
29} 28}
30win32: { 29win32: {
31DEFINES += _WIN32_ 30DEFINES += _WIN32_
32LIBS += ../bin/microkdepim.lib 31LIBS += ../bin/microkdepim.lib
33LIBS += ../bin/microkcal.lib 32LIBS += ../bin/microkcal.lib
34LIBS += ../bin/microkde.lib 33LIBS += ../bin/microkde.lib
35LIBS += ../bin/microkabc.lib 34LIBS += ../bin/microkabc.lib
36LIBS += ../libical/lib/ical.lib 35LIBS += ../libical/lib/ical.lib
37LIBS += ../libical/lib/icalss.lib 36LIBS += ../libical/lib/icalss.lib
38#LIBS += atls.lib 37#LIBS += atls.lib
39LIBS += mfc71u.lib 38LIBS += mfc71u.lib
40QMAKE_LINK += /NODEFAULTLIB:LIBC 39QMAKE_LINK += /NODEFAULTLIB:LIBC
41#QMAKE_LINK += /NODEFAULTLIB:MSVCRT 40#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
42#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib 41#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
43OBJECTS_DIR = obj/win 42OBJECTS_DIR = obj/win
44MOC_DIR = moc/win 43MOC_DIR = moc/win
45} 44}
46 45
47 46
48INTERFACES = kofilterview_base.ui 47INTERFACES = kofilterview_base.ui
49# filteredit_base.ui 48# filteredit_base.ui
50 49
51# kdateedit.h \ 50# kdateedit.h \
52 51
53HEADERS = \ 52HEADERS = \
54 filteredit_base.h \ 53 filteredit_base.h \
55 alarmclient.h \ 54 alarmclient.h \
56 calendarview.h \ 55 calendarview.h \
57 customlistviewitem.h \ 56 customlistviewitem.h \
58 datenavigator.h \ 57 datenavigator.h \
59 docprefs.h \ 58 docprefs.h \
60 filtereditdialog.h \ 59 filtereditdialog.h \
61 incomingdialog.h \ 60 incomingdialog.h \
62 incomingdialog_base.h \ 61 incomingdialog_base.h \
63 interfaces/korganizer/baseview.h \ 62 interfaces/korganizer/baseview.h \
64 interfaces/korganizer/calendarviewbase.h \ 63 interfaces/korganizer/calendarviewbase.h \
65 journalentry.h \ 64 journalentry.h \
66 kdatenavigator.h \ 65 kdatenavigator.h \
67 koagenda.h \ 66 koagenda.h \
68 koagendaitem.h \ 67 koagendaitem.h \
69 koagendaview.h \ 68 koagendaview.h \
70 kocounterdialog.h \ 69 kocounterdialog.h \
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
116SOURCES = \ 115SOURCES = \
117filteredit_base.cpp \ 116filteredit_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
174HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h 173HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
175INTERFACES += calprintdayconfig_base.ui \ 174INTERFACES += 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
179SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp 178SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
180 179
181 180
182 181
183win32: { 182win32: {
184HEADERS += ../outport/msoutl9.h \ 183HEADERS += ../outport/msoutl9.h \
185 koimportoldialog.h 184 koimportoldialog.h
186 185
187 186
188SOURCES += ../outport/msoutl9.cpp \ 187SOURCES += ../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
@@ -1,594 +1,599 @@
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 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidence.h" 27#include "incidence.h"
28#include "todo.h" 28#include "todo.h"
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32Incidence::Incidence() : 32Incidence::Incidence() :
33 IncidenceBase(), 33 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 35{
36 mRecurrence = new Recurrence(this); 36 mRecurrence = new Recurrence(this);
37 mCancelled = false; 37 mCancelled = false;
38 recreate(); 38 recreate();
39 mHasStartDate = true; 39 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 40 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 41 mAttachments.setAutoDelete(true);
42} 42}
43 43
44Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 44Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
45{ 45{
46// TODO: reenable attributes currently commented out. 46// TODO: reenable attributes currently commented out.
47 mRevision = i.mRevision; 47 mRevision = i.mRevision;
48 mCreated = i.mCreated; 48 mCreated = i.mCreated;
49 mDescription = i.mDescription; 49 mDescription = i.mDescription;
50 mSummary = i.mSummary; 50 mSummary = i.mSummary;
51 mCategories = i.mCategories; 51 mCategories = i.mCategories;
52// Incidence *mRelatedTo; Incidence *mRelatedTo; 52// Incidence *mRelatedTo; Incidence *mRelatedTo;
53 mRelatedTo = 0; 53 mRelatedTo = 0;
54 mRelatedToUid = i.mRelatedToUid; 54 mRelatedToUid = i.mRelatedToUid;
55// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 55// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
56 mExDates = i.mExDates; 56 mExDates = i.mExDates;
57 mAttachments = i.mAttachments; 57 mAttachments = i.mAttachments;
58 mResources = i.mResources; 58 mResources = i.mResources;
59 mSecrecy = i.mSecrecy; 59 mSecrecy = i.mSecrecy;
60 mPriority = i.mPriority; 60 mPriority = i.mPriority;
61 mLocation = i.mLocation; 61 mLocation = i.mLocation;
62 mCancelled = i.mCancelled; 62 mCancelled = i.mCancelled;
63 mHasStartDate = i.mHasStartDate; 63 mHasStartDate = i.mHasStartDate;
64 QPtrListIterator<Alarm> it( i.mAlarms ); 64 QPtrListIterator<Alarm> it( i.mAlarms );
65 const Alarm *a; 65 const Alarm *a;
66 while( (a = it.current()) ) { 66 while( (a = it.current()) ) {
67 Alarm *b = new Alarm( *a ); 67 Alarm *b = new Alarm( *a );
68 b->setParent( this ); 68 b->setParent( this );
69 mAlarms.append( b ); 69 mAlarms.append( b );
70 70
71 ++it; 71 ++it;
72 } 72 }
73 mAlarms.setAutoDelete(true); 73 mAlarms.setAutoDelete(true);
74 74
75 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 75 mRecurrence = new Recurrence( *(i.mRecurrence), this );
76} 76}
77 77
78Incidence::~Incidence() 78Incidence::~Incidence()
79{ 79{
80 80
81 Incidence *ev; 81 Incidence *ev;
82 QPtrList<Incidence> Relations = relations(); 82 QPtrList<Incidence> Relations = relations();
83 for (ev=Relations.first();ev;ev=Relations.next()) { 83 for (ev=Relations.first();ev;ev=Relations.next()) {
84 if (ev->relatedTo() == this) ev->setRelatedTo(0); 84 if (ev->relatedTo() == this) ev->setRelatedTo(0);
85 } 85 }
86 if (relatedTo()) relatedTo()->removeRelation(this); 86 if (relatedTo()) relatedTo()->removeRelation(this);
87 delete mRecurrence; 87 delete mRecurrence;
88 88
89} 89}
90 90
91bool Incidence::cancelled() const 91bool Incidence::cancelled() const
92{ 92{
93 return mCancelled; 93 return mCancelled;
94} 94}
95void Incidence::setCancelled( bool b ) 95void Incidence::setCancelled( bool b )
96{ 96{
97 mCancelled = b; 97 mCancelled = b;
98 updated(); 98 updated();
99} 99}
100bool Incidence::hasStartDate() const 100bool Incidence::hasStartDate() const
101{ 101{
102 return mHasStartDate; 102 return mHasStartDate;
103} 103}
104 104
105void Incidence::setHasStartDate(bool f) 105void Incidence::setHasStartDate(bool f)
106{ 106{
107 if (mReadOnly) return; 107 if (mReadOnly) return;
108 mHasStartDate = f; 108 mHasStartDate = f;
109 updated(); 109 updated();
110} 110}
111 111
112// A string comparison that considers that null and empty are the same 112// A string comparison that considers that null and empty are the same
113static bool stringCompare( const QString& s1, const QString& s2 ) 113static bool stringCompare( const QString& s1, const QString& s2 )
114{ 114{
115 if ( s1.isEmpty() && s2.isEmpty() ) 115 if ( s1.isEmpty() && s2.isEmpty() )
116 return true; 116 return true;
117 return s1 == s2; 117 return s1 == s2;
118} 118}
119 119
120bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 120bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
121{ 121{
122 122
123 if( i1.alarms().count() != i2.alarms().count() ) { 123 if( i1.alarms().count() != i2.alarms().count() ) {
124 return false; // no need to check further 124 return false; // no need to check further
125 } 125 }
126 if ( i1.alarms().count() > 0 ) { 126 if ( i1.alarms().count() > 0 ) {
127 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 127 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
128 { 128 {
129 qDebug("alarm not equal "); 129 qDebug("alarm not equal ");
130 return false; 130 return false;
131 } 131 }
132 } 132 }
133#if 0 133#if 0
134 QPtrListIterator<Alarm> a1( i1.alarms() ); 134 QPtrListIterator<Alarm> a1( i1.alarms() );
135 QPtrListIterator<Alarm> a2( i2.alarms() ); 135 QPtrListIterator<Alarm> a2( i2.alarms() );
136 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 136 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
137 if( *a1.current() == *a2.current() ) { 137 if( *a1.current() == *a2.current() ) {
138 continue; 138 continue;
139 } 139 }
140 else { 140 else {
141 return false; 141 return false;
142 } 142 }
143 } 143 }
144#endif 144#endif
145 145
146 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 146 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
147 return false; 147 return false;
148 if ( i1.hasStartDate() == i2.hasStartDate() ) { 148 if ( i1.hasStartDate() == i2.hasStartDate() ) {
149 if ( i1.hasStartDate() ) { 149 if ( i1.hasStartDate() ) {
150 if ( i1.dtStart() != i2.dtStart() ) 150 if ( i1.dtStart() != i2.dtStart() )
151 return false; 151 return false;
152 } 152 }
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
177void Incidence::recreate() 177void 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
188void Incidence::setReadOnly( bool readOnly ) 188void 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
194void Incidence::setCreated(QDateTime created) 194void 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
200QDateTime Incidence::created() const 200QDateTime Incidence::created() const
201{ 201{
202 return mCreated; 202 return mCreated;
203} 203}
204 204
205void Incidence::setRevision(int rev) 205void 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
213int Incidence::revision() const 213int Incidence::revision() const
214{ 214{
215 return mRevision; 215 return mRevision;
216} 216}
217 217
218void Incidence::setDtStart(const QDateTime &dtStart) 218void 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
226void Incidence::setDescription(const QString &description) 226void 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
233QString Incidence::description() const 233QString Incidence::description() const
234{ 234{
235 return mDescription; 235 return mDescription;
236} 236}
237 237
238 238
239void Incidence::setSummary(const QString &summary) 239void 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
246QString Incidence::summary() const 246QString Incidence::summary() const
247{ 247{
248 return mSummary; 248 return mSummary;
249} 249}
250 250
251void Incidence::setCategories(const QStringList &categories) 251void 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
259void Incidence::setCategories(const QString &catStr) 259void 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
276QStringList Incidence::categories() const 276QStringList Incidence::categories() const
277{ 277{
278 return mCategories; 278 return mCategories;
279} 279}
280 280
281QString Incidence::categoriesStr() 281QString Incidence::categoriesStr()
282{ 282{
283 return mCategories.join(","); 283 return mCategories.join(",");
284} 284}
285 285
286void Incidence::setRelatedToUid(const QString &relatedToUid) 286void 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
292QString Incidence::relatedToUid() const 292QString Incidence::relatedToUid() const
293{ 293{
294 return mRelatedToUid; 294 return mRelatedToUid;
295} 295}
296 296
297void Incidence::setRelatedTo(Incidence *relatedTo) 297void 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
310Incidence *Incidence::relatedTo() const 310Incidence *Incidence::relatedTo() const
311{ 311{
312 return mRelatedTo; 312 return mRelatedTo;
313} 313}
314 314
315QPtrList<Incidence> Incidence::relations() const 315QPtrList<Incidence> Incidence::relations() const
316{ 316{
317 return mRelations; 317 return mRelations;
318} 318}
319 319
320void Incidence::addRelation(Incidence *event) 320void 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
328void Incidence::removeRelation(Incidence *event) 328void 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
336bool Incidence::recursOn(const QDate &qd) const 336bool 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
342void Incidence::setExDates(const DateList &exDates) 342void 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
352void Incidence::addExDate(const QDate &date) 352void 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
362DateList Incidence::exDates() const 362DateList Incidence::exDates() const
363{ 363{
364 return mExDates; 364 return mExDates;
365} 365}
366 366
367bool Incidence::isException(const QDate &date) const 367bool 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
379void Incidence::addAttachment(Attachment *attachment) 379void 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
386void Incidence::deleteAttachment(Attachment *attachment) 386void Incidence::deleteAttachment(Attachment *attachment)
387{ 387{
388 mAttachments.removeRef(attachment); 388 mAttachments.removeRef(attachment);
389} 389}
390 390
391void Incidence::deleteAttachments(const QString& mime) 391void 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
402QPtrList<Attachment> Incidence::attachments() const 402QPtrList<Attachment> Incidence::attachments() const
403{ 403{
404 return mAttachments; 404 return mAttachments;
405} 405}
406 406
407QPtrList<Attachment> Incidence::attachments(const QString& mime) const 407QPtrList<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
421void Incidence::setResources(const QStringList &resources) 421void 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
428QStringList Incidence::resources() const 428QStringList Incidence::resources() const
429{ 429{
430 return mResources; 430 return mResources;
431} 431}
432 432
433 433
434void Incidence::setPriority(int priority) 434void 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
441int Incidence::priority() const 441int Incidence::priority() const
442{ 442{
443 return mPriority; 443 return mPriority;
444} 444}
445 445
446void Incidence::setSecrecy(int sec) 446void 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
453int Incidence::secrecy() const 453int Incidence::secrecy() const
454{ 454{
455 return mSecrecy; 455 return mSecrecy;
456} 456}
457 457
458QString Incidence::secrecyStr() const 458QString Incidence::secrecyStr() const
459{ 459{
460 return secrecyName(mSecrecy); 460 return secrecyName(mSecrecy);
461} 461}
462 462
463QString Incidence::secrecyName(int secrecy) 463QString 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
481QStringList Incidence::secrecyList() 481QStringList 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
492QPtrList<Alarm> Incidence::alarms() const 492QPtrList<Alarm> Incidence::alarms() const
493{ 493{
494 return mAlarms; 494 return mAlarms;
495} 495}
496 496
497Alarm* Incidence::newAlarm() 497Alarm* Incidence::newAlarm()
498{ 498{
499 Alarm* alarm = new Alarm(this); 499 Alarm* alarm = new Alarm(this);
500 mAlarms.append(alarm); 500 mAlarms.append(alarm);
501// updated(); 501// updated();
502 return alarm; 502 return alarm;
503} 503}
504 504
505void Incidence::addAlarm(Alarm *alarm) 505void Incidence::addAlarm(Alarm *alarm)
506{ 506{
507 mAlarms.append(alarm); 507 mAlarms.append(alarm);
508 updated(); 508 updated();
509} 509}
510 510
511void Incidence::removeAlarm(Alarm *alarm) 511void Incidence::removeAlarm(Alarm *alarm)
512{ 512{
513 mAlarms.removeRef(alarm); 513 mAlarms.removeRef(alarm);
514 updated(); 514 updated();
515} 515}
516 516
517void Incidence::clearAlarms() 517void Incidence::clearAlarms()
518{ 518{
519 mAlarms.clear(); 519 mAlarms.clear();
520 updated(); 520 updated();
521} 521}
522 522
523bool Incidence::isAlarmEnabled() const 523bool Incidence::isAlarmEnabled() const
524{ 524{
525 Alarm* alarm; 525 Alarm* alarm;
526 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 526 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
527 if (alarm->enabled()) 527 if (alarm->enabled())
528 return true; 528 return true;
529 } 529 }
530 return false; 530 return false;
531} 531}
532 532
533Recurrence *Incidence::recurrence() const 533Recurrence *Incidence::recurrence() const
534{ 534{
535 return mRecurrence; 535 return mRecurrence;
536} 536}
537void Incidence::setRecurrence( Recurrence * r)
538{
539 delete mRecurrence;
540 mRecurrence = r;
541}
537 542
538void Incidence::setLocation(const QString &location) 543void Incidence::setLocation(const QString &location)
539{ 544{
540 if (mReadOnly) return; 545 if (mReadOnly) return;
541 mLocation = location; 546 mLocation = location;
542 updated(); 547 updated();
543} 548}
544 549
545QString Incidence::location() const 550QString Incidence::location() const
546{ 551{
547 return mLocation; 552 return mLocation;
548} 553}
549 554
550ushort Incidence::doesRecur() const 555ushort Incidence::doesRecur() const
551{ 556{
552 if ( mRecurrence ) return mRecurrence->doesRecur(); 557 if ( mRecurrence ) return mRecurrence->doesRecur();
553 else return Recurrence::rNone; 558 else return Recurrence::rNone;
554} 559}
555 560
556QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 561QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
557{ 562{
558 QDateTime incidenceStart = dt; 563 QDateTime incidenceStart = dt;
559 *ok = false; 564 *ok = false;
560 if ( doesRecur() ) { 565 if ( doesRecur() ) {
561 bool last; 566 bool last;
562 recurrence()->getPreviousDateTime( incidenceStart , &last ); 567 recurrence()->getPreviousDateTime( incidenceStart , &last );
563 int count = 0; 568 int count = 0;
564 if ( !last ) { 569 if ( !last ) {
565 while ( !last ) { 570 while ( !last ) {
566 ++count; 571 ++count;
567 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 572 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
568 if ( recursOn( incidenceStart.date() ) ) { 573 if ( recursOn( incidenceStart.date() ) ) {
569 last = true; // exit while llop 574 last = true; // exit while llop
570 } else { 575 } else {
571 if ( last ) { // no alarm on last recurrence 576 if ( last ) { // no alarm on last recurrence
572 return QDateTime (); 577 return QDateTime ();
573 } 578 }
574 int year = incidenceStart.date().year(); 579 int year = incidenceStart.date().year();
575 // workaround for bug in recurrence 580 // workaround for bug in recurrence
576 if ( count == 100 || year < 1980 || year > 5000 ) { 581 if ( count == 100 || year < 1980 || year > 5000 ) {
577 return QDateTime (); 582 return QDateTime ();
578 } 583 }
579 incidenceStart = incidenceStart.addSecs( 1 ); 584 incidenceStart = incidenceStart.addSecs( 1 );
580 } 585 }
581 } 586 }
582 } else { 587 } else {
583 return QDateTime (); 588 return QDateTime ();
584 } 589 }
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
36namespace KCal { 36namespace KCal {
37 37
38class Event; 38class Event;
39class Todo; 39class Todo;
40class Journal; 40class 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*/
45class Incidence : public IncidenceBase 45class 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
266protected: 266protected:
267 QPtrList<Alarm> mAlarms; 267 QPtrList<Alarm> mAlarms;
268 private: 268 private:
269 int mRevision; 269 int mRevision;
270 bool mCancelled; 270 bool mCancelled;
271 271
272 // base components of jounal, event and todo 272 // base components of jounal, event and todo
273 QDateTime mCreated; 273 QDateTime mCreated;
274 QString mDescription; 274 QString mDescription;
275 QString mSummary; 275 QString mSummary;
276 QStringList mCategories; 276 QStringList mCategories;
277 Incidence *mRelatedTo; 277 Incidence *mRelatedTo;
278 QString mRelatedToUid; 278 QString mRelatedToUid;
279 QPtrList<Incidence> mRelations; 279 QPtrList<Incidence> mRelations;
280 DateList mExDates; 280 DateList mExDates;
281 QPtrList<Attachment> mAttachments; 281 QPtrList<Attachment> mAttachments;
282 QStringList mResources; 282 QStringList mResources;
283 bool mHasStartDate; // if todo has associated start date 283 bool mHasStartDate; // if todo has associated start date
284 284
285 int mSecrecy; 285 int mSecrecy;
286 int mPriority; // 1 = highest, 2 = less, etc. 286 int mPriority; // 1 = highest, 2 = less, etc.
287 287
288 //QPtrList<Alarm> mAlarms; 288 //QPtrList<Alarm> mAlarms;
289 Recurrence *mRecurrence; 289 Recurrence *mRecurrence;
290 290
291 QString mLocation; 291 QString mLocation;
292}; 292};
293 293
294bool operator==( const Incidence&, const Incidence& ); 294bool operator==( const Incidence&, const Incidence& );
295 295
296} 296}
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
47using namespace KCal; 47using namespace KCal;
48
49class PhoneParser : public QObject 48class PhoneParser : public QObject
50{ 49{
51public: 50public:
52 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { 51 PhoneParser( ) {
53 ; 52 ;
54 } 53 }
55 bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) 54
56 {
57
58 int id = ToDo->Location;
59 Todo *todo;
60 todo = existingCalendar->todo( mProfileName ,QString::number( id ) );
61 if (todo )
62 todo = (Todo *)todo->clone();
63 else
64 todo = new Todo;
65 todo->setID( mProfileName,QString::number( id ) );
66 todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
67 int priority;
68 switch (ToDo->Priority) {
69 case GSM_Priority_Low : priority = 5; break;
70 case GSM_Priority_Medium : priority = 3; break;
71 case GSM_Priority_High : priority = 1; break;
72 default :priority = 3 ;break;
73 }
74 todo->setPriority( priority );
75 GSM_Phone_Functions*Phone;
76 Phone=s->Phone.Functions;
77 int j;
78 GSM_DateTime* dtp;
79 bool alarm = false;
80 QDateTime alarmDt;
81 GSM_Category Category;
82 int error;
83 for (j=0;j<ToDo->EntriesNum;j++) {
84
85 //qDebug(" for todo %d",ToDo->Location );
86 switch (ToDo->Entries[j].EntryType) {
87 case TODO_END_DATETIME:
88 dtp = &ToDo->Entries[j].Date ;
89 todo->setDtDue (fromGSM ( dtp ));
90 break;
91 case TODO_COMPLETED:
92 if ( ToDo->Entries[j].Number == 1 ) {
93 todo->setCompleted( true );
94 }
95 else {
96 todo->setCompleted( false );
97 }
98 break;
99 case TODO_ALARM_DATETIME:
100 dtp = &ToDo->Entries[j].Date ;
101 alarm = true;
102 alarmDt = fromGSM ( dtp );
103 break;
104 case TODO_SILENT_ALARM_DATETIME:
105 dtp = &ToDo->Entries[j].Date ;
106 alarm = true;
107 alarmDt = fromGSM ( dtp );
108 break;
109 case TODO_TEXT:
110 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text ));
111 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text )));
112 break;
113 case TODO_PRIVATE:
114 if ( ToDo->Entries[j].Number == 1 )
115 todo->setSecrecy( Incidence::SecrecyPrivate );
116 else
117 todo->setSecrecy( Incidence::SecrecyPublic );
118 break;
119 case TODO_CATEGORY:
120 Category.Location = ToDo->Entries[j].Number;
121 Category.Type = Category_ToDo;
122 error=Phone->GetCategory(s, &Category);
123 if (error == ERR_NONE) {
124 QStringList cat = todo->categories();
125 QString nCat = QString ( (const char*)Category.Name );
126 if ( !nCat.isEmpty() )
127 if ( !cat.contains( nCat )) {
128 cat << nCat;
129 todo->setCategories( cat );
130 }
131 }
132 break;
133 case TODO_CONTACTID:
134#if 0
135 // not supported
136 entry.Location = ToDo->Entries[j].Number;
137 entry.MemoryType = MEM_ME;
138 error=Phone->GetMemory(s, &entry);
139 if (error == ERR_NONE) {
140 name = GSM_PhonebookGetEntryName(&entry);
141 if (name != NULL) {
142 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
143 } else {
144 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
145 }
146 } else {
147 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
148 }
149#endif
150 break;
151 case TODO_PHONE:
152#if 0
153 // not supported
154 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
155#endif
156 break;
157 }
158 }
159 QString alarmString = "na";
160 if ( alarm ) {
161 Alarm *alarm;
162 if ( todo->alarms().count() > 0 )
163 alarm = todo->alarms().first();
164 else {
165 alarm = new Alarm( todo );
166 todo->addAlarm( alarm );
167 }
168 alarm->setType( Alarm::Audio );
169 alarm->setEnabled( true );
170 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
171 alarm->setStartOffset( -alarmOffset );
172 alarmString = QString::number( alarmOffset );
173 } else {
174 Alarm *alarm;
175 if ( todo->alarms().count() > 0 ) {
176 alarm = todo->alarms().first();
177 alarm->setType( Alarm::Audio );
178 alarm->setStartOffset( -60*15 );
179 alarm->setEnabled( false );
180 }
181 }
182 // csum *****************************************
183 uint cSum;
184 cSum = PhoneFormat::getCsumTodo( todo );
185 todo->setCsum( mProfileName, QString::number( cSum ));
186 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
187 mCalendar->addTodo( todo);
188
189 return true;
190 }
191 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
192 {
193
194 int id = Note->Location;
195 Event *event;
196 event = existingCalendar->event( mProfileName ,QString::number( id ) );
197 if ( event )
198 event = (Event*)event->clone();
199 else
200 event = new Event;
201 event->setID( mProfileName,QString::number( id ) );
202 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
203
204
205 int i = 0;
206 bool repeating = false;
207 int repeat_dayofweek = -1;
208 int repeat_day = -1;
209 int repeat_weekofmonth = -1;
210 int repeat_month = -1;
211 int repeat_frequency = -1;
212 int rec_type = -1;
213 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
214 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
215 GSM_DateTime* dtp;
216 bool alarm = false;
217 QDateTime alarmDt;
218 repeat_startdate.Day= 0;
219 repeat_stopdate.Day = 0;
220 for (i=0;i<Note->EntriesNum;i++) {
221
222 //qDebug(" for ev");
223 switch (Note->Entries[i].EntryType) {
224 case CAL_START_DATETIME:
225 dtp = &Note->Entries[i].Date ;
226 if ( dtp->Hour > 24 ) {
227 event->setFloats( true );
228 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
229 } else {
230 event->setDtStart (fromGSM ( dtp ));
231
232 }
233 //Note->Entries[i].Date.Hour = 5;
234 break;
235 case CAL_END_DATETIME:
236 dtp = &Note->Entries[i].Date ;
237 if ( dtp->Hour > 24 ) {
238 event->setFloats( true );
239 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
240 } else {
241 event->setDtEnd (fromGSM ( dtp ));
242 }
243 break;
244 case CAL_ALARM_DATETIME:
245 dtp = &Note->Entries[i].Date ;
246 alarm = true;
247 alarmDt = fromGSM ( dtp );
248 break;
249 case CAL_SILENT_ALARM_DATETIME:
250 dtp = &Note->Entries[i].Date ;
251 alarm = true;
252 alarmDt = fromGSM ( dtp );
253 break;
254 case CAL_RECURRANCE:
255 rec_type = Note->Entries[i].Number;
256 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
257 break;
258 case CAL_TEXT:
259 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) );
260 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text )));
261 break;
262 case CAL_LOCATION:
263 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) ));
264 break;
265 case CAL_PHONE:
266 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
267 break;
268 case CAL_PRIVATE:
269 if ( Note->Entries[i].Number == 1 )
270 event->setSecrecy( Incidence::SecrecyPrivate );
271 else
272 event->setSecrecy( Incidence::SecrecyPublic );
273
274 break;
275 case CAL_CONTACTID:
276#if 0
277 entry.Location = Note->Entries[i].Number;
278 entry.MemoryType = MEM_ME;
279 error=Phone->GetMemory(&s, &entry);
280 if (error == ERR_NONE) {
281 name = GSM_PhonebookGetEntryName(&entry);
282 if (name != NULL) {
283 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
284 } else {
285 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
286 }
287 } else {
288 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
289 }
290#endif
291 break;
292 case CAL_REPEAT_DAYOFWEEK:
293 repeat_dayofweek = Note->Entries[i].Number;
294 repeating = true;
295 break;
296 case CAL_REPEAT_DAY:
297 repeat_day = Note->Entries[i].Number;
298 repeating = true;
299 break;
300 case CAL_REPEAT_WEEKOFMONTH:
301 repeat_weekofmonth = Note->Entries[i].Number;
302 repeating = true;
303 break;
304 case CAL_REPEAT_MONTH:
305 repeat_month = Note->Entries[i].Number;
306 repeating = true;
307 break;
308 case CAL_REPEAT_FREQUENCY:
309 repeat_frequency = Note->Entries[i].Number;
310 repeating = true;
311 break;
312 case CAL_REPEAT_STARTDATE:
313 repeat_startdate = Note->Entries[i].Date;
314 repeating = true;
315 break;
316 case CAL_REPEAT_STOPDATE:
317 repeat_stopdate = Note->Entries[i].Date;
318 repeating = true;
319 break;
320 }
321 }
322#if 0
323 event->setDescription( attList[4] );
324 bool repeating = false;
325 int repeat_dayofweek = -1;
326 int repeat_day = -1;
327 int repeat_weekofmonth = -1;
328 int repeat_month = -1;
329 int repeat_frequency = -1;
330 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
331 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
332
333#endif
334
335 QString recurString = "no";
336 if ( repeating && repeat_frequency != -1) {
337 recurString = "y";
338 if ( repeat_dayofweek >= 0 )
339 recurString += "dow" + QString::number (repeat_dayofweek);
340 if ( repeat_day >= 0 )
341 recurString += "d" + QString::number (repeat_day);
342 if ( repeat_weekofmonth >= 0 )
343 recurString += "w" + QString::number (repeat_weekofmonth);
344 if ( repeat_month >= 0 )
345 recurString += "m" + QString::number ( repeat_month );
346 if ( repeat_frequency >= 0 )
347 recurString += "f" + QString::number (repeat_frequency );
348
349 int rtype = 0;
350 // qDebug("recurs ");
351 QDate startDate, endDate;
352 if ( repeat_startdate.Day > 0 ) {
353 startDate = datefromGSM ( &repeat_startdate );
354 event->setDtStart(QDateTime ( startDate, event->dtStart().time()));
355 } else {
356 startDate = event->dtStart().date();
357 }
358 int freq = repeat_frequency;
359 bool hasEndDate = false;
360 if ( repeat_stopdate.Day > 0 ) {
361 endDate = datefromGSM ( &repeat_stopdate );
362 hasEndDate = true;
363 }
364
365 uint weekDaysNum = repeat_dayofweek ;
366 // 1 == monday, 7 == sunday
367 QBitArray weekDays( 7 );
368 int i;
369 int bb = 1;
370 for( i = 1; i <= 7; ++i ) {
371 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
372 bb = 2 << (i-1);
373 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
374 }
375 // qDebug("next ");
376 int pos = 0;
377 Recurrence *r = event->recurrence();
378 /*
379 0 daily;
380 1 weekly;x
381 2 monthpos;x
382 3 monthlyday;
383 4 rYearlyMont
384 bool repeating = false;
385 int repeat_dayofweek = -1;
386 int repeat_day = -1;
387 int repeat_weekofmonth = -1;
388 int repeat_month = -1;
389 int repeat_frequency = -1;
390 */
391 int dayOfWeek = startDate.dayOfWeek();
392 if ( repeat_weekofmonth >= 0 ) {
393 rtype = 2; // ************************ 2 MonthlyPos
394 pos = repeat_weekofmonth;
395 if ( repeat_dayofweek >= 0 )
396 dayOfWeek = repeat_dayofweek;
397 if (repeat_month > 0) {
398 if ( repeat_month != event->dtStart().date().month() ) {
399 QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() );
400 event->setDtStart(QDateTime ( date , event->dtStart().time()) );
401 }
402 if ( freq == 1 )
403 freq = 12;
404 }
405 } else if ( repeat_dayofweek >= 0 ) {
406 rtype = 1;// ************************ 1 Weekly
407 } else if ( repeat_day >= 0 ) {
408 if ( repeat_month > 0) {
409 rtype = 4;
410 } else {
411 rtype = 3;
412 }
413 } else {
414 rtype = 0 ;
415 }
416
417 if ( rtype == 0 ) {
418 if ( hasEndDate ) r->setDaily( freq, endDate );
419 else r->setDaily( freq, -1 );
420 } else if ( rtype == 1 ) {
421 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
422 else r->setWeekly( freq, weekDays, -1 );
423 } else if ( rtype == 3 ) {
424 if ( hasEndDate )
425 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
426 else
427 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
428 r->addMonthlyDay( startDate.day() );
429 } else if ( rtype == 2 ) {
430 if ( hasEndDate )
431 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
432 else
433 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
434 QBitArray days( 7 );
435 days.fill( false );
436 days.setBit( dayOfWeek - 1 );
437 r->addMonthlyPos( pos, days );
438 } else if ( rtype == 4 ) {
439 if ( hasEndDate )
440 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
441 else
442 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
443 r->addYearlyNum( startDate.month() );
444 }
445 } else {
446 event->recurrence()->unsetRecurs();
447 }
448
449 QStringList cat = event->categories();
450 QString nCat = getCategory( Note );
451
452 if ( !nCat.isEmpty() )
453 if ( !cat.contains( nCat )) {
454 cat << nCat;
455 event->setCategories( cat );
456 }
457
458 if ( alarm ) {
459 Alarm *alarm;
460 if ( event->alarms().count() > 0 )
461 alarm = event->alarms().first();
462 else {
463 alarm = new Alarm( event );
464 event->addAlarm( alarm );
465 }
466 alarm->setType( Alarm::Audio );
467 alarm->setEnabled( true );
468 int alarmOffset = alarmDt.secsTo( event->dtStart() );
469 alarm->setStartOffset( -alarmOffset );
470 } else {
471 Alarm *alarm;
472 if ( event->alarms().count() > 0 ) {
473 alarm = event->alarms().first();
474 alarm->setType( Alarm::Audio );
475 alarm->setStartOffset( -60*15 );
476 alarm->setEnabled( false );
477 }
478 }
479 // csum *****************************************
480
481 uint cSum;
482 cSum = PhoneFormat::getCsumEvent( event );
483 event->setCsum( mProfileName, QString::number( cSum ));
484 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
485 mCalendar->addEvent( event);
486
487 return true;
488 }
489
490
491 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = false ) {
492 QDateTime dt;
493 int y,m,t,h,min,sec;
494 y = dtp->Year;
495 m = dtp->Month;
496 t = dtp->Day;
497 h = dtp->Hour;
498 min = dtp->Minute;
499 sec = dtp->Second;
500 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
501 // dtp->Timezone: offset in hours
502 int offset = KGlobal::locale()->localTimeOffset( dt );
503 if ( useTz )
504 dt = dt.addSecs ( offset*60);
505 return dt;
506
507 }
508
509 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 55 static QString dtToString( const QDateTime& dti, bool useTZ = false )
510 { 56 {
511 QString datestr; 57 QString datestr;
512 QString timestr; 58 QString timestr;
513 int offset = KGlobal::locale()->localTimeOffset( dti ); 59 int offset = KGlobal::locale()->localTimeOffset( dti );
514 QDateTime dt; 60 QDateTime dt;
515 if (useTZ) 61 if (useTZ)
516 dt = dti.addSecs ( -(offset*60)); 62 dt = dti.addSecs ( -(offset*60));
517 else 63 else
518 dt = dti; 64 dt = dti;
519 if(dt.date().isValid()){ 65 if(dt.date().isValid()){
520 const QDate& date = dt.date(); 66 const QDate& date = dt.date();
521 datestr.sprintf("%04d%02d%02d", 67 datestr.sprintf("%04d%02d%02d",
522 date.year(), date.month(), date.day()); 68 date.year(), date.month(), date.day());
523 } 69 }
524 if(dt.time().isValid()){ 70 if(dt.time().isValid()){
525 const QTime& time = dt.time(); 71 const QTime& time = dt.time();
526 timestr.sprintf("T%02d%02d%02d", 72 timestr.sprintf("T%02d%02d%02d",
527 time.hour(), time.minute(), time.second()); 73 time.hour(), time.minute(), time.second());
528 } 74 }
529 return datestr + timestr; 75 return datestr + timestr;
530 } 76 }
531 QDate datefromGSM ( GSM_DateTime*dtp ) {
532 return QDate ( dtp->Year, dtp->Month, dtp->Day );
533 }
534 QString getCategory( GSM_CalendarEntry*Note)
535 {
536 QString CATEGORY;
537 switch (Note->Type) {
538 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
539 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
540 //case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
541 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
542 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
543 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
544 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
545 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
546 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
547 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
548 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
549 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
550 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
551 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
552 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
553 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
554 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
555 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
556 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
557 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
558 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
559 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
560 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
561 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
562 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
563 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
564 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
565 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
566 default : CATEGORY = QString("");
567 }
568 77
569 return CATEGORY;
570 }
571 78
572protected:
573private:
574 Calendar *mCalendar;
575 QString mProfileName ;
576}; 79};
577 80
81
578 82
579PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 83PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
580{ 84{
581 mProfileName = profileName; 85 mProfileName = profileName;
582 mDevice = device; 86 mDevice = device;
583 mConnection = connection; 87 mConnection = connection;
584 mModel = model; 88 mModel = model;
585} 89}
586 90
587PhoneFormat::~PhoneFormat() 91PhoneFormat::~PhoneFormat()
588{ 92{
589} 93}
94#if 0
590int PhoneFormat::initDevice(GSM_StateMachine *s) 95int PhoneFormat::initDevice(GSM_StateMachine *s)
591{ 96{
592 GSM_ReadConfig(NULL, &s->Config[0], 0); 97 GSM_ReadConfig(NULL, &s->Config[0], 0);
593 s->ConfigNum = 1; 98 s->ConfigNum = 1;
594 GSM_Config *cfg = &s->Config[0]; 99 GSM_Config *cfg = &s->Config[0];
595 if ( ! mConnection.isEmpty() ) { 100 if ( ! mConnection.isEmpty() ) {
596 cfg->Connection = strdup(mConnection.latin1()); 101 cfg->Connection = strdup(mConnection.latin1());
597 cfg->DefaultConnection = false; 102 cfg->DefaultConnection = false;
598 qDebug("Connection set %s ", cfg->Connection ); 103 qDebug("Connection set %s ", cfg->Connection );
599 104
600 } 105 }
601 if ( ! mDevice.isEmpty() ) { 106 if ( ! mDevice.isEmpty() ) {
602 cfg->Device = strdup(mDevice.latin1()); 107 cfg->Device = strdup(mDevice.latin1());
603 cfg->DefaultDevice = false; 108 cfg->DefaultDevice = false;
604 qDebug("Device set %s ", cfg->Device); 109 qDebug("Device set %s ", cfg->Device);
605 110
606 } 111 }
607 if ( ! mModel.isEmpty() ) { 112 if ( ! mModel.isEmpty() ) {
608 strcpy(cfg->Model,mModel.latin1() ); 113 strcpy(cfg->Model,mModel.latin1() );
609 cfg->DefaultModel = false; 114 cfg->DefaultModel = false;
610 qDebug("Model set %s ",cfg->Model ); 115 qDebug("Model set %s ",cfg->Model );
611 } 116 }
612 int error=GSM_InitConnection(s,3); 117 int error=GSM_InitConnection(s,3);
613 return error; 118 return error;
614} 119}
120#endif
615ulong PhoneFormat::getCsumTodo( Todo* todo ) 121ulong PhoneFormat::getCsumTodo( Todo* todo )
616{ 122{
617 QStringList attList; 123 QStringList attList;
618 if ( todo->hasDueDate() ) 124 if ( todo->hasDueDate() )
619 attList << PhoneParser::dtToString ( todo->dtDue() ); 125 attList << PhoneParser::dtToString ( todo->dtDue() );
620 attList << todo->summary(); 126 attList << todo->summary();
621 QString completedString = "no"; 127 QString completedString = "no";
622 if ( todo->isCompleted() ) 128 if ( todo->isCompleted() )
623 completedString = "yes"; 129 completedString = "yes";
624 attList << completedString; 130 attList << completedString;
625 attList << QString::number( todo->priority() ); 131 attList << QString::number( todo->priority() );
626 QString alarmString = "na"; 132 QString alarmString = "na";
627 Alarm *alarm; 133 Alarm *alarm;
628 if ( todo->alarms().count() > 0 ) { 134 if ( todo->alarms().count() > 0 ) {
629 alarm = todo->alarms().first(); 135 alarm = todo->alarms().first();
630 if ( alarm->enabled() ) { 136 if ( alarm->enabled() ) {
631 alarmString = QString::number(alarm->startOffset().asSeconds() ); 137 alarmString = QString::number(alarm->startOffset().asSeconds() );
632 } 138 }
633 } 139 }
634 attList << alarmString; 140 attList << alarmString;
635 attList << todo->categoriesStr(); 141 attList << todo->categoriesStr();
636 attList << todo->secrecyStr(); 142 attList << todo->secrecyStr();
637 return PhoneFormat::getCsum(attList ); 143 return PhoneFormat::getCsum(attList );
638 144
639} 145}
640ulong PhoneFormat::getCsumEvent( Event* event ) 146ulong PhoneFormat::getCsumEvent( Event* event )
641{ 147{
642 QStringList attList; 148 QStringList attList;
643 attList << PhoneParser::dtToString ( event->dtStart() ); 149 attList << PhoneParser::dtToString ( event->dtStart() );
644 attList << PhoneParser::dtToString ( event->dtEnd() ); 150 attList << PhoneParser::dtToString ( event->dtEnd() );
645 attList << event->summary(); 151 attList << event->summary();
646 attList << event->location(); 152 attList << event->location();
647 QString alarmString = "na"; 153 QString alarmString = "na";
648 Alarm *alarm; 154 Alarm *alarm;
649 if ( event->alarms().count() > 0 ) { 155 if ( event->alarms().count() > 0 ) {
650 alarm = event->alarms().first(); 156 alarm = event->alarms().first();
651 if ( alarm->enabled() ) { 157 if ( alarm->enabled() ) {
652 alarmString = QString::number( alarm->startOffset().asSeconds() ); 158 alarmString = QString::number( alarm->startOffset().asSeconds() );
653 } 159 }
654 } 160 }
655 attList << alarmString; 161 attList << alarmString;
656 Recurrence* rec = event->recurrence(); 162 Recurrence* rec = event->recurrence();
657 QStringList list; 163 QStringList list;
658 bool writeEndDate = false; 164 bool writeEndDate = false;
659 switch ( rec->doesRecur() ) 165 switch ( rec->doesRecur() )
660 { 166 {
661 case Recurrence::rDaily: // 0 167 case Recurrence::rDaily: // 0
662 list.append( "0" ); 168 list.append( "0" );
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}
746ulong PhoneFormat::getCsum( const QStringList & attList) 252ulong PhoneFormat::getCsum( const QStringList & attList)
747{ 253{
748 int max = attList.count() -1; 254 int max = attList.count() -1;
749 ulong cSum = 0; 255 ulong cSum = 0;
750 int j,k,i; 256 int j,k,i;
751 int add; 257 int add;
752 for ( i = 1; i < max ; ++i ) { 258 for ( i = 1; i < max ; ++i ) {
753 QString s = attList[i]; 259 QString s = attList[i];
754 if ( ! s.isEmpty() ){ 260 if ( ! s.isEmpty() ){
755 j = s.length(); 261 j = s.length();
756 for ( k = 0; k < j; ++k ) { 262 for ( k = 0; k < j; ++k ) {
757 int mul = k +1; 263 int mul = k +1;
758 add = s[k].unicode (); 264 add = s[k].unicode ();
759 if ( k < 16 ) 265 if ( k < 16 )
760 mul = mul * mul; 266 mul = mul * mul;
761 add = add * mul *i*i*i; 267 add = add * mul *i*i*i;
762 cSum += add; 268 cSum += add;
763 } 269 }
764 } 270 }
765 } 271 }
766 return cSum; 272 return cSum;
767 273
768} 274}
769//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 275//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
770#include <stdlib.h> 276#include <stdlib.h>
771#define DEBUGMODE false 277#define DEBUGMODE false
772bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 278bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
773{ 279{
774 GSM_StateMachines;
775 qDebug(" load ");
776 s.opened = false;
777 s.msg = NULL;
778 s.ConfigNum = 0;
779 QLabel status ( i18n("Opening device ..."), 0 );
780 int w = status.sizeHint().width()+20 ;
781 if ( w < 200 ) w = 230;
782 int h = status.sizeHint().height()+20 ;
783 int dw = QApplication::desktop()->width();
784 int dh = QApplication::desktop()->height();
785 status.setCaption(i18n("Reading phone...") );
786 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
787 status.show();
788 status.raise();
789 qApp->processEvents();
790 280
791 int error=initDevice(&s); 281 QString fileName;
792 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 282#ifdef _WIN32_
793 if ( error != ERR_NONE ) 283 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
284#else
285 fileName = "/tmp/kdepimtemp.vcs";
286#endif
287 QString command ="./kammu --backup " + fileName + " -yes";
288 int ret = system ( command.latin1() );
289 if ( ret != 0 )
794 return false; 290 return false;
795 GSM_Phone_Functions*Phone; 291 VCalFormat vfload;
796 GSM_CalendarEntrynote; 292 vfload.setLocalTime ( true );
797 bool start = true; 293 if ( ! vfload.load( calendar, fileName ) )
798 Phone=s.Phone.Functions; 294 return false;
799 bool gshutdown = false; 295 QPtrList<Event> er = calendar->rawEvents();
800 PhoneParser handler( calendar, mProfileName ); 296 Event* ev = er.first();
801 int ccc = 0; 297 while ( ev ) {
802 QString message = i18n(" Reading event # "); 298 int id = ev->pilotId();
803 int procCount = 0; 299 Event *event;
804 qDebug("Debug: only 10 calender items are downloaded "); 300 event = existingCal->event( mProfileName ,QString::number( id ) );
805 while (!gshutdown && ccc++ < 10) { 301 if ( event ) {
806 status.setText ( message + QString::number ( ++procCount ) ); 302 event = (Event*)event->clone();
807 qApp->processEvents(); 303 copyEvent( event, ev );
808 qDebug("readEvent %d ", ccc); 304 calendar->deleteEvent( ev );
809 error=Phone->GetNextCalendar(&s,&note,start); 305 calendar->addEvent( event);
810 if (error == ERR_EMPTY) break; 306 }
811 start = false; 307 else
812 handler.readEvent( existingCal, &note ); 308 event = ev;
813 qDebug("Org loc %d ",note.Location); 309 uint cSum;
814 //note.Location = 0; 310 cSum = PhoneFormat::getCsumEvent( event );
815 error=Phone->SetCalendar(&s,&note); 311 event->setCsum( mProfileName, QString::number( cSum ));
816 qDebug("new loc %d ",note.Location); 312 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
313 event->setID( mProfileName,QString::number( id ) );
314 ev = er.next();
315 }
316 {
317 QPtrList<Todo> tr = calendar->rawTodos();
318 Todo* ev = tr.first();
319 while ( ev ) {
320
321 QStringList cat = ev->categories();
322 if ( cat.contains( "MeetingDEF" )) {
323 ev->setCategories( QStringList() );
324 }
325 int id = ev->pilotId();
326 Todo *event;
327 event = existingCal->todo( mProfileName ,QString::number( id ) );
328 if ( event ) {
329 event = (Todo*)event->clone();
330 copyTodo( event, ev );
331 calendar->deleteTodo( ev );
332 calendar->addTodo( event);
333 }
334 else
335 event = ev;
336 uint cSum;
337 cSum = PhoneFormat::getCsumTodo( event );
338 event->setCsum( mProfileName, QString::number( cSum ));
339 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
340 event->setID( mProfileName,QString::number( id ) );
341 ev = tr.next();
342 }
817 } 343 }
818
819 start = true;
820 GSM_ToDoEntry ToDo;
821 ccc = 0;
822 message = i18n(" Reading todo # ");
823 procCount = 0;
824 while (!gshutdown && ccc++ < 10) {
825 status.setText ( message + QString::number ( ++procCount ) );
826 qApp->processEvents();
827 error = Phone->GetNextToDo(&s, &ToDo, start);
828 if (error == ERR_EMPTY) break;
829 start = false;
830 qDebug("ReadTodo %d ", ccc);
831 handler.readTodo( existingCal, &ToDo, &s);
832
833 }
834
835 error=GSM_TerminateConnection(&s);
836
837 return true; 344 return true;
838} 345}
839#include <qcstring.h> 346void PhoneFormat::copyEvent( Event* to, Event* from )
840void PhoneFormat::event2GSM( Calendar *cal,Event* ev, GSM_CalendarEntry*Note )
841{ 347{
842 QString eText = vfconverter.eventToString( ev, cal ); 348 if ( from->dtStart().isValid() )
843 int pos = 0; 349 to->setDtStart( from->dtStart() );
844 GSM_ToDoEntry dummy; 350 if ( from->dtEnd().isValid() )
845 qDebug( "Convert event"); 351 to->setDtEnd( from->dtEnd() );
846 QByteArray ba; 352 if ( !from->location().isEmpty() )
847 QDataStream s ( ba, IO_WriteOnly ); 353 to->setLocation( from->location() );
848 s << eText.utf8(); 354 if ( !from->description().isEmpty() )
849 GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); 355 to->setDescription( from->description() );
850 qDebug( "Convert event done"); 356 if ( !from->summary().isEmpty() )
851 Note->Location = 0; 357 to->setSummary( from->summary() );
852 QString loc = ev->getID(mProfileName); 358
853 if ( !loc.isEmpty() ){ 359 QPtrListIterator<Alarm> it( from->alarms() );
854 Note->Location = loc.toInt(); 360 to->clearAlarms();
361 const Alarm *a;
362 while( (a = it.current()) ) {
363 Alarm *b = new Alarm( *a );
364 b->setParent( to );
365 to->addAlarm( b );
366 ++it;
367 }
368 QStringList cat = to->categories();
369 QStringList catFrom = from->categories();
370 QString nCat;
371 int iii;
372 for ( iii = 0; iii < catFrom.count();++iii ) {
373 nCat = catFrom[iii];
374 if ( !nCat.isEmpty() )
375 if ( !cat.contains( nCat )) {
376 cat << nCat;
377 }
855 } 378 }
379 to->setCategories( cat );
380 Recurrence * r = new Recurrence( *from->recurrence(),to);
381 to->setRecurrence( r ) ;
382
856 383
857} 384}
858void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) 385void PhoneFormat::copyTodo( Todo* to, Todo* from )
859{ 386{
860 qDebug( "Convert todo1"); 387 if ( from->dtStart().isValid() )
861 QString tText = vfconverter.todoToString( todo, cal ); 388 to->setDtStart( from->dtStart() );
862 int pos = 0; 389 if ( from->dtDue().isValid() )
863 GSM_CalendarEntry dummy; 390 to->setDtDue( from->dtDue() );
864 QByteArray ba; 391 if ( !from->location().isEmpty() )
865 QDataStream s ( ba, IO_WriteOnly ); 392 to->setLocation( from->location() );
866 s << tText.utf8(); 393 if ( !from->description().isEmpty() )
867 GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); 394 to->setDescription( from->description() );
868 qDebug( "Convert todo done "); 395 if ( !from->summary().isEmpty() )
869 gsmTodo->Location = 0; 396 to->setSummary( from->summary() );
870 QString loc = todo->getID(mProfileName); 397
871 if ( !loc.isEmpty() ){ 398 QPtrListIterator<Alarm> it( from->alarms() );
872 gsmTodo->Location = loc.toInt(); 399 to->clearAlarms();
400 const Alarm *a;
401 while( (a = it.current()) ) {
402 Alarm *b = new Alarm( *a );
403 b->setParent( to );
404 to->addAlarm( b );
405 ++it;
406 }
407 QStringList cat = to->categories();
408 QStringList catFrom = from->categories();
409 QString nCat;
410 int iii;
411 for ( iii = 0; iii < catFrom.count();++iii ) {
412 nCat = catFrom[iii];
413 if ( !nCat.isEmpty() )
414 if ( !cat.contains( nCat )) {
415 cat << nCat;
416 }
873 } 417 }
874 418 to->setCategories( cat );
419 if ( from->isCompleted() ) {
420 to->setCompleted( true );
421 if( from->completed().isValid() )
422 to->setCompleted( from->completed() );
423 } else {
424 // set percentcomplete only, if to->isCompleted()
425 if ( to->isCompleted() )
426 to->setPercentComplete(from->percentComplete());
427 }
428 to->setPriority(from->priority());
429
875} 430}
431#include <qcstring.h>
432
876void PhoneFormat::afterSave( Incidence* inc) 433void PhoneFormat::afterSave( Incidence* inc)
877{ 434{
878 uint csum; 435 uint csum;
879 inc->removeID( mProfileName ); 436 inc->removeID( mProfileName );
880 if ( inc->type() == "Event") 437 if ( inc->type() == "Event")
881 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 438 csum = PhoneFormat::getCsumEvent( (Event*) inc );
882 else 439 else
883 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 440 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
884 inc->setCsum( mProfileName, QString::number( csum )); 441 inc->setCsum( mProfileName, QString::number( csum ));
885 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 442 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
886 443
887} 444}
888bool PhoneFormat::save( Calendar *calendar) 445bool PhoneFormat::save( Calendar *calendar)
889{ 446{
890
891 GSM_StateMachines;
892 qDebug(" save ");
893 s.opened = false;
894 s.msg = NULL;
895 s.ConfigNum = 0;
896 QLabel status ( i18n(" Opening device ..."), 0 ); 447 QLabel status ( i18n(" Opening device ..."), 0 );
897 int w = status.sizeHint().width()+20 ; 448 int w = status.sizeHint().width()+20 ;
898 if ( w < 200 ) w = 230; 449 if ( w < 200 ) w = 230;
899 int h = status.sizeHint().height()+20 ; 450 int h = status.sizeHint().height()+20 ;
900 int dw = QApplication::desktop()->width(); 451 int dw = QApplication::desktop()->width();
901 int dh = QApplication::desktop()->height(); 452 int dh = QApplication::desktop()->height();
902 status.setCaption(i18n("Writing to phone...") ); 453 status.setCaption(i18n("Writing to phone...") );
903 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 454 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
904 status.show(); 455 status.show();
905 status.raise(); 456 status.raise();
906 qApp->processEvents(); 457 qApp->processEvents();
907 458 QString message;
908 int error=initDevice(&s);
909 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
910 if ( error != ERR_NONE )
911 return false;
912 GSM_Phone_Functions*Phone;
913 GSM_CalendarEntryNote;
914 bool start = true;
915 Phone=s.Phone.Functions;
916 bool gshutdown = false;
917 QPtrList<Event> er = calendar->rawEvents();
918 Event* ev = er.first();
919 QString message = i18n(" Deleting event # ");
920 int procCount = 0;
921 int diffProc = 0;
922 bool setPossible = true;
923#ifdef _WIN32_ 459#ifdef _WIN32_
924 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 460 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
925#else 461#else
926 QString fileName = "/tmp/kdepimtemp.vcs"; 462 QString fileName = "/tmp/kdepimtemp.vcs";
927#endif 463#endif
928 //algo 1 delete event
929 while ( ev ) {
930 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
931
932 status.setText ( message + QString::number ( ++procCount ) );
933 qApp->processEvents();
934 qDebug("del event1 %d ", procCount);
935 //event2GSM( calendar, ev, &Note );
936 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
937 464
938 QString loc = ev->getID(mProfileName); 465 // 1 remove events which should be deleted
939 if ( !loc.isEmpty() ){ 466 QPtrList<Event> er = calendar->rawEvents();
940 Note.Location = loc.toInt(); 467 Event* ev = er.first();
941 } else { 468 while ( ev ) {
942 qDebug("error: loc is empty "); 469 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
943 } 470 calendar->deleteEvent( ev );
944 error = Phone->DeleteCalendar(&s, &Note); 471 } else {
945 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
946 qDebug(" e error delete1 planB %d ", error);
947 break;
948 }
949 }
950 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
951 // we have to do this later after deleting
952
953 }
954 else { // change existing
955 472
956 QString loc = ev->getID(mProfileName); 473 }
957 if ( !loc.isEmpty() ){
958 Note.Location = loc.toInt();
959 } else {
960 qDebug("error3: loc is empty ");
961 }
962 error = Phone->DeleteCalendar(&s, &Note);
963 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
964 qDebug(" e error delete2 planB %d ", error);
965 break;
966 }
967 ev->removeID( mProfileName );
968 }
969 }
970 ev = er.next(); 474 ev = er.next();
971 } 475 }
972 //algo 1 delete todo 476 // 2 remove todos which should be deleted
973 GSM_ToDoEntry ToDoEntry;
974 QPtrList<Todo> tl = calendar->rawTodos(); 477 QPtrList<Todo> tl = calendar->rawTodos();
975 Todo* to = tl.first(); 478 Todo* to = tl.first();
976 message = i18n(" Deleting todo # ");
977 procCount = 0;
978 while ( to ) { 479 while ( to ) {
979 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 480 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
980 qDebug("todo3 %d ", procCount); 481 calendar->deleteTodo( to );
981 status.setText ( message + QString::number ( ++procCount ) );
982 qApp->processEvents();
983 qDebug("todo5 %d ", procCount);
984 // todo2GSM( calendar, to, &ToDoEntry );
985 QString loc = to->getID(mProfileName);
986 if ( !loc.isEmpty() ){
987 ToDoEntry.Location = loc.toInt();
988 } else {
989 qDebug("error2: loc is empty ");
990 }
991 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
992 error=Phone->DeleteToDo(&s,&ToDoEntry);
993 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
994 qDebug("delete planB %d ", error);
995 }
996 }
997 else if ( to->getID(mProfileName).isEmpty() ) { // add new
998 ;
999 }
1000 else { // change existing
1001 error=Phone->DeleteToDo(&s,&ToDoEntry);
1002 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1003 qDebug("set planB %d ", error);
1004 }
1005 to->removeID( mProfileName );
1006 }
1007 } 482 }
1008 to = tl.next(); 483 to = tl.next();
1009 } 484 }
1010 //algo 2 add event 485 // 3 save file
1011 ev = er.first(); 486 VCalFormat vfsave;
1012 QString filec; 487 vfsave.setLocalTime ( true );
1013 message = i18n(" Preparing event # "); 488 if ( ! vfsave.save( calendar, fileName ) )
1014 procCount = 0;
1015 while ( ev ) {
1016 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1017 if ( ev->getID(mProfileName).isEmpty() ) {
1018 status.setText ( message + QString::number ( ++procCount ) );
1019 qApp->processEvents();
1020 filec += vfconverter.eventToString( ev, calendar )+ "\n";
1021 afterSave ( ev );
1022
1023 }
1024 }
1025 ev = er.next();
1026 }
1027 //algo 2 add todo
1028 to = tl.first();
1029 procCount = 0;
1030 message = i18n(" Preparing todo # ");
1031 while ( to ) {
1032 qDebug("todo2 %d ", procCount);
1033 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1034 qDebug("todo4 %d ", procCount);
1035 if ( to->getID(mProfileName).isEmpty() ) {
1036 status.setText ( message + QString::number ( ++procCount ) );
1037 qApp->processEvents();
1038 filec += vfconverter.todoToString( to, calendar )+ "\n";
1039 afterSave ( to );
1040 }
1041 }
1042 to = tl.next();
1043 }
1044 if ( filec.isEmpty() ) {
1045 qDebug("Nothing to write back.Finished. ");
1046 error=GSM_TerminateConnection(&s);
1047 return true;
1048 }
1049 //algo 3 saving file
1050 message = i18n(" Saving temp file ... ");
1051 status.setText ( message );
1052 qApp->processEvents();
1053 QFile file( fileName );
1054 if (!file.open( IO_WriteOnly ) ) {
1055 qDebug("error open file ");
1056 error=GSM_TerminateConnection(&s);
1057 return false; 489 return false;
1058 } 490 // 4 call kammu
1059 QTextStream ts( &file ); 491 QString command ="./kammu --restore " + fileName ;
1060 ts.setCodec( QTextCodec::codecForName("utf8") ); 492 int ret = system ( command.latin1() );
1061 ts << filec ; 493 if ( ret != 0 )
1062 file.close(); 494 return false;
1063 495 // 5 reread data
1064
1065 message = i18n(" Parsing temp file ... ");
1066 status.setText ( message );
1067 qApp->processEvents();
1068 GSM_Backup Backup;
1069 error=GSM_ReadBackupFile( (char*) fileName.latin1() ,&Backup);
1070 qDebug("Read file result %d ",error );
1071 //algo 4 writing event
1072 int max, i;
1073 procCount = 0;
1074 message = i18n(" Writing event # ");
1075 if (Backup.Calendar[0] != NULL) {
1076 max = 0;
1077 while (Backup.Calendar[max]!=NULL) max++;
1078
1079 GSM_DateTime*dtp;
1080
1081 for (i=0;i<max;i++) {
1082 status.setText ( message + QString::number ( ++procCount ) );
1083 qApp->processEvents();
1084 Note = *Backup.Calendar[i];
1085
1086#if 0
1087 int j;
1088 for (j=0;j<Note.EntriesNum;j++) {
1089 //qDebug(" for ev");
1090 switch (Note.Entries[j].EntryType) {
1091 case CAL_START_DATETIME:
1092 //Note->Entries[i].Date.Hour = 5;
1093 dtp = &Note.Entries[j].Date;
1094 qDebug("start event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second );
1095 break;
1096 case CAL_END_DATETIME:
1097 dtp = &Note.Entries[j].Date;
1098 qDebug("end event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second );
1099 break;
1100 }
1101 }
1102 int type = Note.Type;
1103 qDebug(" event type %d - %d %d - %d %d %d",type, GSM_CAL_CALL , GSM_CAL_MEETING ,GSM_CAL_BIRTHDAY, GSM_CAL_MEMO ,GSM_CAL_ALARM );
1104#endif
1105
1106 Note.Type = GSM_CAL_MEETING;
1107 // pending: fix in gammu GSM_ReadBackupFile the type settings
1108 int loc = Note.Location;
1109 Note.Location = 0;
1110 error=Phone->AddCalendar(&s,&Note);
1111 qDebug("add event %d %d %d", error, Note.Location, loc );
1112 }
1113 }
1114 //algo 4 writing todo
1115 procCount = 0;
1116 message = i18n(" Writing todo # ");
1117 if (Backup.ToDo[0] != NULL) {
1118 max = 0;
1119 while (Backup.ToDo[max]!=NULL) max++;
1120 for (i=0;i<max;i++) {
1121 status.setText ( message + QString::number ( ++procCount ) );
1122 qApp->processEvents();
1123 ToDoEntry = *Backup.ToDo[i];
1124 error = Phone->AddToDo(&s,&ToDoEntry);
1125 qDebug("add todo %d ", error);
1126 }
1127 }
1128 //algo 5 reread
1129 message = i18n(" Rereading all data ... "); 496 message = i18n(" Rereading all data ... ");
1130 status.setText ( message ); 497 status.setText ( message );
1131 qApp->processEvents(); 498 qApp->processEvents();
1132 error=GSM_TerminateConnection(&s);
1133 CalendarLocal* calendarTemp = new CalendarLocal(); 499 CalendarLocal* calendarTemp = new CalendarLocal();
1134 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 500 calendarTemp->setTimeZoneId( calendar->timeZoneId());
1135 if ( ! load( calendarTemp,calendar) ){ 501 if ( ! load( calendarTemp,calendar) ){
1136 qDebug("error reloading calendar "); 502 qDebug("error reloading calendar ");
1137 delete calendarTemp; 503 delete calendarTemp;
1138 return false; 504 return false;
1139 } 505 }
506 // 6 compare data
1140 507
1141 508//algo 6 compare event
1142 //algo 6 compare event 509 er = calendar->rawEvents();
1143 ev = er.first(); 510 ev = er.first();
1144 message = i18n(" Comparing event # "); 511 message = i18n(" Comparing event # ");
1145 QPtrList<Event> er1 = calendarTemp->rawEvents(); 512 QPtrList<Event> er1 = calendarTemp->rawEvents();
1146 Event* ev1; 513 Event* ev1;
1147 procCount = 0; 514 int procCount = 0;
1148 while ( ev ) { 515 while ( ev ) {
1149 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) {
1150 qDebug("event new ID "); 516 qDebug("event new ID ");
1151 status.setText ( message + QString::number ( ++procCount ) ); 517 status.setText ( message + QString::number ( ++procCount ) );
1152 qApp->processEvents(); 518 qApp->processEvents();
1153 QString cSum = ev->getCsum(mProfileName); 519 QString cSum = ev->getCsum(mProfileName);
1154 ev1 = er1.first(); 520 ev1 = er1.first();
1155 while ( ev1 ) { 521 while ( ev1 ) {
1156 if ( ev1->getCsum( mProfileName ) == cSum ) { 522 if ( ev1->getCsum( mProfileName ) == cSum ) {
1157 er1.remove( ev1 ); 523 er1.remove( ev1 );
524 afterSave( ev );
1158 ev->setID(mProfileName, ev1->getID(mProfileName) ); 525 ev->setID(mProfileName, ev1->getID(mProfileName) );
1159 break; 526 break;
1160 } 527 }
1161 ev1 = er1.next(); 528 ev1 = er1.next();
1162 } 529 }
1163 if ( ! ev1 ) { 530 if ( ! ev1 ) {
1164 ev->removeID(mProfileName); 531 ev->removeID(mProfileName);
1165 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 532 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
1166 qDebug("Probably writing back of events not supported ");
1167 } 533 }
1168 534
1169 } 535
1170 ev = er.next(); 536 ev = er.next();
1171 } 537 }
1172 //algo 6 compare todo 538 //algo 6 compare todo
1173 to = tl.first(); 539 to = tl.first();
1174 procCount = 0; 540 procCount = 0;
1175 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 541 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
1176 Todo* to1 ; 542 Todo* to1 ;
1177 message = i18n(" Comparing todo # "); 543 message = i18n(" Comparing todo # ");
1178 while ( to ) { 544 while ( to ) {
1179 qDebug("todo2 %d ", procCount); 545 qDebug("todo2 %d ", procCount);
1180 if ( to->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) {
1181 status.setText ( message + QString::number ( ++procCount ) ); 546 status.setText ( message + QString::number ( ++procCount ) );
1182 qApp->processEvents(); 547 qApp->processEvents();
1183 QString cSum = to->getCsum(mProfileName); 548 QString cSum = to->getCsum(mProfileName);
1184 Todo* to1 = tl1.first(); 549 Todo* to1 = tl1.first();
1185 while ( to1 ) { 550 while ( to1 ) {
1186 if ( to1->getCsum( mProfileName ) == cSum ) { 551 if ( to1->getCsum( mProfileName ) == cSum ) {
1187 tl1.remove( to1 ); 552 tl1.remove( to1 );
553 afterSave( to );
1188 to->setID(mProfileName, to1->getID(mProfileName) ); 554 to->setID(mProfileName, to1->getID(mProfileName) );
1189 break; 555 break;
1190 } 556 }
1191 to1 = tl1.next(); 557 to1 = tl1.next();
1192 } 558 }
1193 if ( ! to1 ) { 559 if ( ! to1 ) {
1194 to->removeID(mProfileName); 560 to->removeID(mProfileName);
1195 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 561 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
1196 qDebug("Probably writing back of todos not supported ");
1197 } 562 }
1198 } 563
1199 to = tl.next(); 564 to = tl.next();
1200 } 565 }
1201 delete calendarTemp; 566 delete calendarTemp;
1202 return true; 567 return true;
1203 // *******************************************************************
1204 // *******************************************************************
1205 // *******************************************************************
1206#if 0
1207 while ( ev && ! planB) {
1208 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
1209
1210 status.setText ( message + QString::number ( ++procCount ) );
1211 qApp->processEvents();
1212 qDebug("event1 %d ", procCount);
1213 event2GSM( calendar, ev, &Note );
1214 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1215 error = Phone->DeleteCalendar(&s, &Note);
1216 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1217 planB = true;
1218 qDebug(" e delete1 planB %d ", error);
1219 break;
1220 }
1221 }
1222 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
1223 // we have to do this later after deleting
1224
1225 }
1226 else { // change existing
1227 if ( setPossible ) {
1228 error = Phone->SetCalendar(&s, &Note);
1229 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1230 setPossible = false;
1231 ++diffProc;
1232 qDebug("Set cal not supported %d ", error);
1233 break;
1234 }
1235 }
1236 if ( ! setPossible) {
1237 ++diffProc;
1238 error = Phone->DeleteCalendar(&s, &Note);
1239 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1240 planB = true;
1241 qDebug(" e delete2 planB %d ", error);
1242 break;
1243 }
1244 ev->removeID( mProfileName );
1245 }
1246 qDebug("Change Calendar. Location %d status: %d",Note.Location, error );
1247 }
1248 }
1249 ev = er.next();
1250 }
1251 ev = er.first();
1252 // pending get empty slots
1253 int loc = 0;
1254 procCount -= diffProc;
1255 while ( ev && ! planB) {
1256 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1257 qDebug("event2 %d ", procCount);
1258 if ( ev->getID(mProfileName).isEmpty() ) {
1259 status.setText ( message + QString::number ( ++procCount ) );
1260 qApp->processEvents();
1261 //int newID ;//= pending
1262 //ev->setID(mProfileName, QString::number( newID ));
1263 event2GSM( calendar, ev, &Note );
1264 ++loc;
1265 Note.Location = loc;
1266 error = Phone->AddCalendar(&s, &Note);
1267 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1268 planB = true;
1269 qDebug(" e add planB %d ", error);
1270 break;
1271 }
1272 ev->setID( mProfileName, QString::number( Note.Location ) );
1273 qDebug("New Calendar. Location %d stat %d %d",Note.Location ,error, ERR_UNKNOWN);
1274 afterSave( ev );
1275 } else {
1276 afterSave( ev ); // setting temp sync stat for changed items
1277 }
1278 }
1279 ev = er.next();
1280 }
1281 568
1282 569
1283 if ( planB ) {
1284 qDebug("delete all calendar...");
1285 status.setText ( i18n("Deleting all calendar..."));
1286 qApp->processEvents();
1287 error=Phone->DeleteAllCalendar(&s);
1288 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1289 message = i18n(" Deleting event # ");
1290 procCount = 0;
1291 while (1) {
1292 status.setText ( message + QString::number ( ++procCount ) );
1293 qApp->processEvents();
1294 qDebug("deleting event ... %d", procCount);
1295 error = Phone->GetNextCalendar(&s,&Note,true);
1296 if (error != ERR_NONE) break;
1297 error = Phone->DeleteCalendar(&s,&Note);
1298 }
1299 qDebug("deleting calendar ... finished");
1300 } else {
1301 status.setText ( i18n("All calendar deleted!"));
1302 qDebug("all cal deleted");
1303 }
1304 bool planC = false;
1305 ev = er.first();
1306 procCount = 0;
1307 message = i18n(" Writing event # ");
1308 while ( ev && ! planC) {
1309 status.setText ( message + QString::number ( ++procCount ) );
1310 qApp->processEvents();
1311 event2GSM( calendar, ev, &Note );
1312 Note.Location = procCount;
1313 error=Phone->AddCalendar(&s,&Note);
1314 if (error != ERR_NONE ) {
1315 // we have currently no planC :-(
1316 // planC = true;
1317 //qDebug("add planC %d ", error);
1318 //break;
1319 // we remove the ID such that this todo is not deleted after next sync
1320 ev->removeID(mProfileName);
1321 ev->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1322 qDebug("error :cal adding loc %d planB stat %d ", Note.Location ,error);
1323 } else {
1324 qDebug("cal adding loc %d planB stat %d ", Note.Location ,error);
1325 ev->setID(mProfileName, QString::number( Note.Location ));
1326 afterSave( ev );
1327 }
1328 ev = er.next();
1329 }
1330 if ( planC ) {
1331 qDebug("writing cal went wrong...");
1332 570
1333 // we have currently no planC :-(
1334 }
1335 }
1336 GSM_ToDoEntry ToDoEntry;
1337 QPtrList<Todo> tl = calendar->rawTodos();
1338 Todo* to = tl.first();
1339
1340 message = i18n(" Processing todo # ");
1341 procCount = 0;
1342 planB = false;
1343 while ( to && ! planB ) {
1344 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1345 qDebug("todo3 %d ", procCount);
1346 status.setText ( message + QString::number ( ++procCount ) );
1347 qApp->processEvents();
1348 qDebug("todo5 %d ", procCount);
1349 todo2GSM( calendar, to, &ToDoEntry );
1350 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1351 error=Phone->DeleteToDo(&s,&ToDoEntry);
1352 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1353 planB = true;
1354 qDebug("delete planB %d ", error);
1355 }
1356 }
1357 else if ( to->getID(mProfileName).isEmpty() ) { // add new
1358 ;
1359 }
1360 else { // change existing
1361 error=Phone->SetToDo(&s,&ToDoEntry);
1362 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1363 planB = true;
1364 qDebug("set planB %d ", error);
1365 }
1366 qDebug("Old Todo. Location %d %d",ToDoEntry.Location , error );
1367 }
1368 }
1369 to = tl.next();
1370 }
1371
1372 // pending get empty slots
1373 to = tl.first();
1374 while ( to && ! planB ) {
1375 qDebug("todo2 %d ", procCount);
1376 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1377 qDebug("todo4 %d ", procCount);
1378 if ( to->getID(mProfileName).isEmpty() ) {
1379 status.setText ( message + QString::number ( ++procCount ) );
1380 qApp->processEvents();
1381 //int newID ;//= pending
1382 //to->setID(mProfileName, QString::number( newID ));
1383 todo2GSM( calendar,to, &ToDoEntry );
1384 ToDoEntry.Location = 0;
1385 error=Phone->AddToDo(&s,&ToDoEntry);
1386 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1387 planB = true;
1388 qDebug("new planB %d ", error);
1389 }
1390 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1391 afterSave( to );
1392 qDebug("New Todo. Location %d %d",ToDoEntry.Location, error );
1393 } else {
1394 afterSave( to );
1395 }
1396 }
1397 to = tl.next();
1398 }
1399 if ( planB ) {
1400 qDebug("delete all ...");
1401 error=Phone->DeleteAllToDo(&s);
1402 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1403 while (1) {
1404 qDebug("deleting todo ...");
1405 error = Phone->GetNextToDo(&s,&ToDoEntry,true);
1406 if (error != ERR_NONE) break;
1407 error = Phone->DeleteToDo(&s,&ToDoEntry);
1408 }
1409 qDebug("deleting todo ... finished");
1410 } else {
1411 qDebug("all todo deleted");
1412 }
1413 bool planC = false;
1414 to = tl.first();
1415 while ( to && ! planC ) {
1416 todo2GSM( calendar,to, &ToDoEntry );
1417 ToDoEntry.Location = 0;
1418 error=Phone->AddToDo(&s,&ToDoEntry);
1419 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1420 // we have currently no planC :-(
1421 // planC = true;
1422 //qDebug("add planC %d ", error);
1423 //break;
1424 // we remove the ID such that this todo is not deleted after next sync
1425 to->removeID(mProfileName);
1426 to->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1427 } else {
1428 qDebug("adding %d planB %d ", ToDoEntry.Location ,error);
1429 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1430 afterSave( to );
1431 }
1432 to = tl.next();
1433 }
1434 if ( planC ) {
1435 // we have currently no planC :-(
1436 }
1437 }
1438 return true;
1439#endif
1440}
1441QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ )
1442{
1443 QString datestr;
1444 QString timestr;
1445 int offset = KGlobal::locale()->localTimeOffset( dti );
1446 QDateTime dt;
1447 if (useTZ)
1448 dt = dti.addSecs ( -(offset*60));
1449 else
1450 dt = dti;
1451 if(dt.date().isValid()){
1452 const QDate& date = dt.date();
1453 datestr.sprintf("%04d%02d%02d",
1454 date.year(), date.month(), date.day());
1455 }
1456 if(dt.time().isValid()){
1457 const QTime& time = dt.time();
1458 timestr.sprintf("T%02d%02d%02d",
1459 time.hour(), time.minute(), time.second());
1460 }
1461 return datestr + timestr;
1462}
1463QString PhoneFormat::getEventString( Event* event )
1464{
1465#if 0
1466 QStringList list;
1467 list.append( QString::number(event->zaurusId() ) );
1468 list.append( event->categories().join(",") );
1469 if ( !event->summary().isEmpty() )
1470 list.append( event->summary() );
1471 else
1472 list.append("" );
1473 if ( !event->location().isEmpty() )
1474 list.append( event->location() );
1475 else
1476 list.append("" );
1477 if ( !event->description().isEmpty() )
1478 list.append( event->description() );
1479 else
1480 list.append( "" );
1481 if ( event->doesFloat () ) {
1482 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
1483 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
1484 list.append( "1" );
1485
1486 }
1487 else {
1488 list.append( dtToString( event->dtStart()) );
1489 list.append( dtToString( event->dtEnd()) ); //6
1490 list.append( "0" );
1491 }
1492 bool noAlarm = true;
1493 if ( event->alarms().count() > 0 ) {
1494 Alarm * al = event->alarms().first();
1495 if ( al->enabled() ) {
1496 noAlarm = false;
1497 list.append( "0" ); // yes, 0 == alarm
1498 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
1499 if ( al->type() == Alarm::Audio )
1500 list.append( "1" ); // type audio
1501 else
1502 list.append( "0" ); // type silent
1503 }
1504 }
1505 if ( noAlarm ) {
1506 list.append( "1" ); // yes, 1 == no alarm
1507 list.append( "0" ); // no alarm offset
1508 list.append( "1" ); // type
1509 }
1510 // next is: 11
1511 // next is: 11-16 are recurrence
1512 Recurrence* rec = event->recurrence();
1513
1514 bool writeEndDate = false;
1515 switch ( rec->doesRecur() )
1516 {
1517 case Recurrence::rDaily: // 0
1518 list.append( "0" );
1519 list.append( QString::number( rec->frequency() ));//12
1520 list.append( "0" );
1521 list.append( "0" );
1522 writeEndDate = true;
1523 break;
1524 case Recurrence::rWeekly:// 1
1525 list.append( "1" );
1526 list.append( QString::number( rec->frequency()) );//12
1527 list.append( "0" );
1528 {
1529 int days = 0;
1530 QBitArray weekDays = rec->days();
1531 int i;
1532 for( i = 1; i <= 7; ++i ) {
1533 if ( weekDays[i-1] ) {
1534 days += 1 << (i-1);
1535 }
1536 }
1537 list.append( QString::number( days ) );
1538 }
1539 //pending weekdays
1540 writeEndDate = true;
1541
1542 break;
1543 case Recurrence::rMonthlyPos:// 2
1544 list.append( "2" );
1545 list.append( QString::number( rec->frequency()) );//12
1546
1547 writeEndDate = true;
1548 {
1549 int count = 1;
1550 QPtrList<Recurrence::rMonthPos> rmp;
1551 rmp = rec->monthPositions();
1552 if ( rmp.first()->negative )
1553 count = 5 - rmp.first()->rPos - 1;
1554 else
1555 count = rmp.first()->rPos - 1;
1556 list.append( QString::number( count ) );
1557
1558 }
1559
1560 list.append( "0" );
1561 break;
1562 case Recurrence::rMonthlyDay:// 3
1563 list.append( "3" );
1564 list.append( QString::number( rec->frequency()) );//12
1565 list.append( "0" );
1566 list.append( "0" );
1567 writeEndDate = true;
1568 break;
1569 case Recurrence::rYearlyMonth://4
1570 list.append( "4" );
1571 list.append( QString::number( rec->frequency()) );//12
1572 list.append( "0" );
1573 list.append( "0" );
1574 writeEndDate = true;
1575 break;
1576
1577 default:
1578 list.append( "255" );
1579 list.append( QString() );
1580 list.append( "0" );
1581 list.append( QString() );
1582 list.append( "0" );
1583 list.append( "20991231T000000" );
1584 break;
1585 }
1586 if ( writeEndDate ) {
1587
1588 if ( rec->endDate().isValid() ) { // 15 + 16
1589 list.append( "1" );
1590 list.append( dtToString( rec->endDate()) );
1591 } else {
1592 list.append( "0" );
1593 list.append( "20991231T000000" );
1594 }
1595
1596 }
1597 if ( event->doesFloat () ) {
1598 list.append( dtToString( event->dtStart(), false ).left( 8 ));
1599 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
1600
1601 }
1602 else {
1603 list.append( QString() );
1604 list.append( QString() );
1605
1606 }
1607 if (event->dtStart().date() == event->dtEnd().date() )
1608 list.append( "0" );
1609 else
1610 list.append( "1" );
1611
1612
1613 for(QStringList::Iterator it=list.begin();
1614 it!=list.end(); ++it){
1615 QString& s = (*it);
1616 s.replace(QRegExp("\""), "\"\"");
1617 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
1618 s.prepend('\"');
1619 s.append('\"');
1620 } else if(s.isEmpty() && !s.isNull()){
1621 s = "\"\"";
1622 }
1623 }
1624 return list.join(",");
1625#endif
1626 return QString();
1627
1628}
1629QString PhoneFormat::getTodoString( Todo* todo )
1630{
1631#if 0
1632 QStringList list;
1633 list.append( QString::number( todo->zaurusId() ) );
1634 list.append( todo->categories().join(",") );
1635
1636 if ( todo->hasStartDate() ) {
1637 list.append( dtToString( todo->dtStart()) );
1638 } else
1639 list.append( QString() );
1640
1641 if ( todo->hasDueDate() ) {
1642 QTime tim;
1643 if ( todo->doesFloat()) {
1644 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
1645 } else {
1646 list.append( dtToString(todo->dtDue() ) );
1647 }
1648 } else
1649 list.append( QString() );
1650
1651 if ( todo->isCompleted() ) {
1652 list.append( dtToString( todo->completed()) );
1653 list.append( "0" ); // yes 0 == completed
1654 } else {
1655 list.append( dtToString( todo->completed()) );
1656 list.append( "1" );
1657 }
1658 list.append( QString::number( todo->priority() ));
1659 if( ! todo->summary().isEmpty() )
1660 list.append( todo->summary() );
1661 else
1662 list.append( "" );
1663 if (! todo->description().isEmpty() )
1664 list.append( todo->description() );
1665 else
1666 list.append( "" );
1667 for(QStringList::Iterator it=list.begin();
1668 it!=list.end(); ++it){
1669 QString& s = (*it);
1670 s.replace(QRegExp("\""), "\"\"");
1671 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
1672 s.prepend('\"');
1673 s.append('\"');
1674 } else if(s.isEmpty() && !s.isNull()){
1675 s = "\"\"";
1676 }
1677 }
1678 return list.join(",");
1679#endif
1680 return QString();
1681} 571}
1682 572
1683 573
1684QString PhoneFormat::toString( Calendar * ) 574QString PhoneFormat::toString( Calendar * )
1685{ 575{
1686 return QString::null; 576 return QString::null;
1687} 577}
1688bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 578bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
1689{ 579{
1690 return false; 580 return false;
1691} 581}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2c2e51c..8286098 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,67 +1,61 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "vcalformat.h" 28#include "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30extern "C" { 30
31#include "../gammu/emb/common/gammu.h"
32}
33namespace KCal { 31namespace KCal {
34 32
35/** 33/**
36 This class implements the calendar format used by Phone. 34 This class implements the calendar format used by Phone.
37*/ 35*/
38 class Event; 36 class Event;
39 class Todo; 37 class Todo;
40class PhoneFormat : public QObject { 38class PhoneFormat : public QObject {
41 public: 39 public:
42 /** Create new iCalendar format. */ 40 /** Create new iCalendar format. */
43 PhoneFormat(QString profileName, QString device,QString connection, QString model); 41 PhoneFormat(QString profileName, QString device,QString connection, QString model);
44 virtual ~PhoneFormat(); 42 virtual ~PhoneFormat();
45 43
46 bool load( Calendar * ,Calendar * ); 44 bool load( Calendar * ,Calendar * );
47 bool save( Calendar * ); 45 bool save( Calendar * );
48 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
49 QString toString( Calendar * ); 47 QString toString( Calendar * );
50 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
51 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
52 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
53 private: 51 private:
54 VCalFormat vfconverter; 52 void copyEvent( Event* to, Event* from );
55 void event2GSM( Calendar *, Event* ev, GSM_CalendarEntry*Note ); 53 void copyTodo( Todo* to, Todo* from );
56 void todo2GSM( Calendar *, Todo* ev, GSM_ToDoEntry *ToDo ); 54 //int initDevice(GSM_StateMachine *s);
57 int initDevice(GSM_StateMachine *s);
58 QString getEventString( Event* );
59 QString getTodoString( Todo* );
60 QString dtToGSM( const QDateTime& dt, bool useTZ = true );
61 QString mProfileName, mDevice, mConnection, mModel; 55 QString mProfileName, mDevice, mConnection, mModel;
62 void afterSave( Incidence* ); 56 void afterSave( Incidence* );
63}; 57};
64 58
65} 59}
66 60
67#endif 61#endif
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 0ebd7d1..4727a7a 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -1,1714 +1,1717 @@
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
45using namespace KCal; 45using namespace KCal;
46 46
47VCalFormat::VCalFormat() 47VCalFormat::VCalFormat()
48{ 48{
49 mCalendar = 0; 49 mCalendar = 0;
50 useLocalTime = false; 50 useLocalTime = false;
51} 51}
52 52
53VCalFormat::~VCalFormat() 53VCalFormat::~VCalFormat()
54{ 54{
55} 55}
56 56
57void VCalFormat::setLocalTime ( bool b )
58{
59 useLocalTime = b;
60}
57bool VCalFormat::load(Calendar *calendar, const QString &fileName) 61bool VCalFormat::load(Calendar *calendar, const QString &fileName)
58{ 62{
59 mCalendar = calendar; 63 mCalendar = calendar;
60
61 clearException(); 64 clearException();
62 65
63 kdDebug(5800) << "VCalFormat::load() " << fileName << endl; 66 kdDebug(5800) << "VCalFormat::load() " << fileName << endl;
64 67
65 VObject *vcal = 0; 68 VObject *vcal = 0;
66 69
67 // this is not necessarily only 1 vcal. Could be many vcals, or include 70 // this is not necessarily only 1 vcal. Could be many vcals, or include
68 // a vcard... 71 // a vcard...
69 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); 72 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data()));
70 73
71 if (!vcal) { 74 if (!vcal) {
72 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 75 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
73 return FALSE; 76 return FALSE;
74 } 77 }
75 78
76 // any other top-level calendar stuff should be added/initialized here 79 // any other top-level calendar stuff should be added/initialized here
77 80
78 // put all vobjects into their proper places 81 // put all vobjects into their proper places
79 populate(vcal); 82 populate(vcal);
80 83
81 // clean up from vcal API stuff 84 // clean up from vcal API stuff
82 cleanVObjects(vcal); 85 cleanVObjects(vcal);
83 cleanStrTbl(); 86 cleanStrTbl();
84 87
85 return true; 88 return true;
86} 89}
87 90
88 91
89bool VCalFormat::save(Calendar *calendar, const QString &fileName) 92bool VCalFormat::save(Calendar *calendar, const QString &fileName)
90{ 93{
91 mCalendar = calendar; 94 mCalendar = calendar;
92 95
93 QString tmpStr; 96 QString tmpStr;
94 VObject *vcal, *vo; 97 VObject *vcal, *vo;
95 98
96 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; 99 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl;
97 100
98 vcal = newVObject(VCCalProp); 101 vcal = newVObject(VCCalProp);
99 102
100 // addPropValue(vcal,VCLocationProp, "0.0"); 103 // addPropValue(vcal,VCLocationProp, "0.0");
101 addPropValue(vcal,VCProdIdProp, productId()); 104 addPropValue(vcal,VCProdIdProp, productId());
102 tmpStr = mCalendar->getTimeZoneStr(); 105 tmpStr = mCalendar->getTimeZoneStr();
103 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 106 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
104 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 107 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
105 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 108 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
106 109
107 // TODO STUFF 110 // TODO STUFF
108 QPtrList<Todo> todoList = mCalendar->rawTodos(); 111 QPtrList<Todo> todoList = mCalendar->rawTodos();
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
136bool VCalFormat::fromString( Calendar *calendar, const QString &text ) 139bool 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
171QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) 174QString 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}
185QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) 188QString 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
200QString VCalFormat::toString( Calendar *calendar ) 203QString 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
229VObject *VCalFormat::eventToVTodo(const Todo *anEvent) 232VObject *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
393VObject* VCalFormat::eventToVEvent(const Event *anEvent) 396VObject* 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() + " <" +
445 curAttendee->email() + ">"; 448 curAttendee->email() + ">";
446 else if (curAttendee->name().isEmpty()) 449 else if (curAttendee->name().isEmpty())
447 tmpStr = "MAILTO: " + curAttendee->email(); 450 tmpStr = "MAILTO: " + curAttendee->email();
448 else if (curAttendee->email().isEmpty()) 451 else if (curAttendee->email().isEmpty())
449 tmpStr = "MAILTO: " + curAttendee->name(); 452 tmpStr = "MAILTO: " + curAttendee->name();
450 else if (curAttendee->name().isEmpty() && 453 else if (curAttendee->name().isEmpty() &&
451 curAttendee->email().isEmpty()) 454 curAttendee->email().isEmpty())
452 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 455 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
453 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 456 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
454 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; 457 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");;
455 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 458 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
456 } 459 }
457 } 460 }
458 461
459 // recurrence rule stuff 462 // recurrence rule stuff
460 if (anEvent->recurrence()->doesRecur()) { 463 if (anEvent->recurrence()->doesRecur()) {
461 // some more variables 464 // some more variables
462 QPtrList<Recurrence::rMonthPos> tmpPositions; 465 QPtrList<Recurrence::rMonthPos> tmpPositions;
463 QPtrList<int> tmpDays; 466 QPtrList<int> tmpDays;
464 int *tmpDay; 467 int *tmpDay;
465 Recurrence::rMonthPos *tmpPos; 468 Recurrence::rMonthPos *tmpPos;
466 QString tmpStr2; 469 QString tmpStr2;
467 int i; 470 int i;
468 471
469 switch(anEvent->recurrence()->doesRecur()) { 472 switch(anEvent->recurrence()->doesRecur()) {
470 case Recurrence::rDaily: 473 case Recurrence::rDaily:
471 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 474 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
472// if (anEvent->rDuration > 0) 475// if (anEvent->rDuration > 0)
473 //tmpStr += "#"; 476 //tmpStr += "#";
474 break; 477 break;
475 case Recurrence::rWeekly: 478 case Recurrence::rWeekly:
476 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); 479 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency());
477 for (i = 0; i < 7; i++) { 480 for (i = 0; i < 7; i++) {
478 if (anEvent->recurrence()->days().testBit(i)) 481 if (anEvent->recurrence()->days().testBit(i))
479 tmpStr += dayFromNum(i); 482 tmpStr += dayFromNum(i);
480 } 483 }
481 break; 484 break;
482 case Recurrence::rMonthlyPos: 485 case Recurrence::rMonthlyPos:
483 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); 486 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency());
484 // write out all rMonthPos's 487 // write out all rMonthPos's
485 tmpPositions = anEvent->recurrence()->monthPositions(); 488 tmpPositions = anEvent->recurrence()->monthPositions();
486 for (tmpPos = tmpPositions.first(); 489 for (tmpPos = tmpPositions.first();
487 tmpPos; 490 tmpPos;
488 tmpPos = tmpPositions.next()) { 491 tmpPos = tmpPositions.next()) {
489 492
490 tmpStr2.sprintf("%i", tmpPos->rPos); 493 tmpStr2.sprintf("%i", tmpPos->rPos);
491 if (tmpPos->negative) 494 if (tmpPos->negative)
492 tmpStr2 += "- "; 495 tmpStr2 += "- ";
493 else 496 else
494 tmpStr2 += "+ "; 497 tmpStr2 += "+ ";
495 tmpStr += tmpStr2; 498 tmpStr += tmpStr2;
496 for (i = 0; i < 7; i++) { 499 for (i = 0; i < 7; i++) {
497 if (tmpPos->rDays.testBit(i)) 500 if (tmpPos->rDays.testBit(i))
498 tmpStr += dayFromNum(i); 501 tmpStr += dayFromNum(i);
499 } 502 }
500 } // loop for all rMonthPos's 503 } // loop for all rMonthPos's
501 break; 504 break;
502 case Recurrence::rMonthlyDay: 505 case Recurrence::rMonthlyDay:
503 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); 506 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency());
504 // write out all rMonthDays; 507 // write out all rMonthDays;
505 tmpDays = anEvent->recurrence()->monthDays(); 508 tmpDays = anEvent->recurrence()->monthDays();
506 for (tmpDay = tmpDays.first(); 509 for (tmpDay = tmpDays.first();
507 tmpDay; 510 tmpDay;
508 tmpDay = tmpDays.next()) { 511 tmpDay = tmpDays.next()) {
509 tmpStr2.sprintf("%i ", *tmpDay); 512 tmpStr2.sprintf("%i ", *tmpDay);
510 tmpStr += tmpStr2; 513 tmpStr += tmpStr2;
511 } 514 }
512 break; 515 break;
513 case Recurrence::rYearlyMonth: 516 case Recurrence::rYearlyMonth:
514 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); 517 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency());
515 // write out all the rYearNums; 518 // write out all the rYearNums;
516 tmpDays = anEvent->recurrence()->yearNums(); 519 tmpDays = anEvent->recurrence()->yearNums();
517 for (tmpDay = tmpDays.first(); 520 for (tmpDay = tmpDays.first();
518 tmpDay; 521 tmpDay;
519 tmpDay = tmpDays.next()) { 522 tmpDay = tmpDays.next()) {
520 tmpStr2.sprintf("%i ", *tmpDay); 523 tmpStr2.sprintf("%i ", *tmpDay);
521 tmpStr += tmpStr2; 524 tmpStr += tmpStr2;
522 } 525 }
523 break; 526 break;
524 case Recurrence::rYearlyDay: 527 case Recurrence::rYearlyDay:
525 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); 528 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency());
526 // write out all the rYearNums; 529 // write out all the rYearNums;
527 tmpDays = anEvent->recurrence()->yearNums(); 530 tmpDays = anEvent->recurrence()->yearNums();
528 for (tmpDay = tmpDays.first(); 531 for (tmpDay = tmpDays.first();
529 tmpDay; 532 tmpDay;
530 tmpDay = tmpDays.next()) { 533 tmpDay = tmpDays.next()) {
531 tmpStr2.sprintf("%i ", *tmpDay); 534 tmpStr2.sprintf("%i ", *tmpDay);
532 tmpStr += tmpStr2; 535 tmpStr += tmpStr2;
533 } 536 }
534 break; 537 break;
535 default: 538 default:
536 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; 539 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
537 break; 540 break;
538 } // switch 541 } // switch
539 542
540 if (anEvent->recurrence()->duration() > 0) { 543 if (anEvent->recurrence()->duration() > 0) {
541 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); 544 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration());
542 tmpStr += tmpStr2; 545 tmpStr += tmpStr2;
543 } else if (anEvent->recurrence()->duration() == -1) { 546 } else if (anEvent->recurrence()->duration() == -1) {
544 tmpStr += "#0"; // defined as repeat forever 547 tmpStr += "#0"; // defined as repeat forever
545 } else { 548 } else {
546 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); 549 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE);
547 } 550 }
548 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); 551 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
549 552
550 } // event repeats 553 } // event repeats
551 554
552 // exceptions to recurrence 555 // exceptions to recurrence
553 DateList dateList = anEvent->exDates(); 556 DateList dateList = anEvent->exDates();
554 DateList::ConstIterator it; 557 DateList::ConstIterator it;
555 QString tmpStr2; 558 QString tmpStr2;
556 559
557 for (it = dateList.begin(); it != dateList.end(); ++it) { 560 for (it = dateList.begin(); it != dateList.end(); ++it) {
558 tmpStr = qDateToISO(*it) + ";"; 561 tmpStr = qDateToISO(*it) + ";";
559 tmpStr2 += tmpStr; 562 tmpStr2 += tmpStr;
560 } 563 }
561 if (!tmpStr2.isEmpty()) { 564 if (!tmpStr2.isEmpty()) {
562 tmpStr2.truncate(tmpStr2.length()-1); 565 tmpStr2.truncate(tmpStr2.length()-1);
563 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); 566 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit());
564 } 567 }
565 568
566 // description 569 // description
567 if (!anEvent->description().isEmpty()) { 570 if (!anEvent->description().isEmpty()) {
568 VObject *d = addPropValue(vevent, VCDescriptionProp, 571 VObject *d = addPropValue(vevent, VCDescriptionProp,
569 anEvent->description().local8Bit()); 572 anEvent->description().local8Bit());
570 if (anEvent->description().find('\n') != -1) 573 if (anEvent->description().find('\n') != -1)
571 addProp(d, VCQuotedPrintableProp); 574 addProp(d, VCQuotedPrintableProp);
572 } 575 }
573 576
574 // summary 577 // summary
575 if (!anEvent->summary().isEmpty()) 578 if (!anEvent->summary().isEmpty())
576 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); 579 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit());
577 580
578 if (!anEvent->location().isEmpty()) 581 if (!anEvent->location().isEmpty())
579 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); 582 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit());
580 583
581 // status 584 // status
582// TODO: define Event status 585// TODO: define Event status
583// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); 586// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit());
584 587
585 // secrecy 588 // secrecy
586 const char *text = 0; 589 const char *text = 0;
587 switch (anEvent->secrecy()) { 590 switch (anEvent->secrecy()) {
588 case Incidence::SecrecyPublic: 591 case Incidence::SecrecyPublic:
589 text = "PUBLIC"; 592 text = "PUBLIC";
590 break; 593 break;
591 case Incidence::SecrecyPrivate: 594 case Incidence::SecrecyPrivate:
592 text = "PRIVATE"; 595 text = "PRIVATE";
593 break; 596 break;
594 case Incidence::SecrecyConfidential: 597 case Incidence::SecrecyConfidential:
595 text = "CONFIDENTIAL"; 598 text = "CONFIDENTIAL";
596 break; 599 break;
597 } 600 }
598 if (text) { 601 if (text) {
599 addPropValue(vevent, VCClassProp, text); 602 addPropValue(vevent, VCClassProp, text);
600 } 603 }
601 604
602 // categories 605 // categories
603 tmpStrList = anEvent->categories(); 606 tmpStrList = anEvent->categories();
604 tmpStr = ""; 607 tmpStr = "";
605 QString catStr; 608 QString catStr;
606 for ( QStringList::Iterator it = tmpStrList.begin(); 609 for ( QStringList::Iterator it = tmpStrList.begin();
607 it != tmpStrList.end(); 610 it != tmpStrList.end();
608 ++it ) { 611 ++it ) {
609 catStr = *it; 612 catStr = *it;
610 if (catStr[0] == ' ') 613 if (catStr[0] == ' ')
611 tmpStr += catStr.mid(1); 614 tmpStr += catStr.mid(1);
612 else 615 else
613 tmpStr += catStr; 616 tmpStr += catStr;
614 // this must be a ';' character as the vCalendar specification requires! 617 // this must be a ';' character as the vCalendar specification requires!
615 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 618 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
616 // read in. 619 // read in.
617 tmpStr += ";"; 620 tmpStr += ";";
618 } 621 }
619 if (!tmpStr.isEmpty()) { 622 if (!tmpStr.isEmpty()) {
620 tmpStr.truncate(tmpStr.length()-1); 623 tmpStr.truncate(tmpStr.length()-1);
621 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); 624 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
622 } 625 }
623 626
624 // attachments 627 // attachments
625 // TODO: handle binary attachments! 628 // TODO: handle binary attachments!
626 QPtrList<Attachment> attachments = anEvent->attachments(); 629 QPtrList<Attachment> attachments = anEvent->attachments();
627 for ( Attachment *at = attachments.first(); at; at = attachments.next() ) 630 for ( Attachment *at = attachments.first(); at; at = attachments.next() )
628 addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); 631 addPropValue(vevent, VCAttachProp, at->uri().local8Bit());
629 632
630 // resources 633 // resources
631 tmpStrList = anEvent->resources(); 634 tmpStrList = anEvent->resources();
632 tmpStr = tmpStrList.join(";"); 635 tmpStr = tmpStrList.join(";");
633 if (!tmpStr.isEmpty()) 636 if (!tmpStr.isEmpty())
634 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 637 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
635 638
636 // alarm stuff 639 // alarm stuff
637 QPtrList<Alarm> alarms = anEvent->alarms(); 640 QPtrList<Alarm> alarms = anEvent->alarms();
638 Alarm* alarm; 641 Alarm* alarm;
639 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 642 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
640 if (alarm->enabled()) { 643 if (alarm->enabled()) {
641 VObject *a ; 644 VObject *a ;
642 tmpStr = qDateTimeToISO(alarm->time()); 645 tmpStr = qDateTimeToISO(alarm->time());
643 if (alarm->type() == Alarm::Audio) { 646 if (alarm->type() == Alarm::Audio) {
644 a = addProp(vevent, VCAAlarmProp); 647 a = addProp(vevent, VCAAlarmProp);
645 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 648 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
646 addPropValue(a, VCRepeatCountProp, "1"); 649 addPropValue(a, VCRepeatCountProp, "1");
647 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 650 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
648 } 651 }
649 if (alarm->type() == Alarm::Procedure) { 652 if (alarm->type() == Alarm::Procedure) {
650 a = addProp(vevent, VCPAlarmProp); 653 a = addProp(vevent, VCPAlarmProp);
651 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 654 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
652 addPropValue(a, VCRepeatCountProp, "1"); 655 addPropValue(a, VCRepeatCountProp, "1");
653 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 656 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
654 } else { 657 } else {
655 a = addProp(vevent, VCDAlarmProp); 658 a = addProp(vevent, VCDAlarmProp);
656 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 659 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
657 addPropValue(a, VCRepeatCountProp, "1"); 660 addPropValue(a, VCRepeatCountProp, "1");
658 addPropValue(a, VCDisplayStringProp, "beep!"); 661 addPropValue(a, VCDisplayStringProp, "beep!");
659 662
660 } 663 }
661 } 664 }
662 } 665 }
663 666
664 // priority 667 // priority
665 tmpStr.sprintf("%i",anEvent->priority()); 668 tmpStr.sprintf("%i",anEvent->priority());
666 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 669 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
667 670
668 // transparency 671 // transparency
669 tmpStr.sprintf("%i",anEvent->transparency()); 672 tmpStr.sprintf("%i",anEvent->transparency());
670 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 673 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
671 674
672 // related event 675 // related event
673 if (anEvent->relatedTo()) { 676 if (anEvent->relatedTo()) {
674 addPropValue(vevent, VCRelatedToProp, 677 addPropValue(vevent, VCRelatedToProp,
675 anEvent->relatedTo()->uid().local8Bit()); 678 anEvent->relatedTo()->uid().local8Bit());
676 } 679 }
677 680
678 if (anEvent->pilotId()) { 681 if (anEvent->pilotId()) {
679 // pilot sync stuff 682 // pilot sync stuff
680 tmpStr.sprintf("%i",anEvent->pilotId()); 683 tmpStr.sprintf("%i",anEvent->pilotId());
681 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 684 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
682 tmpStr.sprintf("%i",anEvent->syncStatus()); 685 tmpStr.sprintf("%i",anEvent->syncStatus());
683 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 686 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
684 } 687 }
685 688
686 return vevent; 689 return vevent;
687} 690}
688 691
689Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 692Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
690{ 693{
691 VObject *vo; 694 VObject *vo;
692 VObjectIterator voi; 695 VObjectIterator voi;
693 char *s; 696 char *s;
694 697
695 Todo *anEvent = new Todo; 698 Todo *anEvent = new Todo;
696 699
697 // creation date 700 // creation date
698 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { 701 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) {
699 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 702 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
700 deleteStr(s); 703 deleteStr(s);
701 } 704 }
702 705
703 // unique id 706 // unique id
704 vo = isAPropertyOf(vtodo, VCUniqueStringProp); 707 vo = isAPropertyOf(vtodo, VCUniqueStringProp);
705 // while the UID property is preferred, it is not required. We'll use the 708 // while the UID property is preferred, it is not required. We'll use the
706 // default Event UID if none is given. 709 // default Event UID if none is given.
707 if (vo) { 710 if (vo) {
708 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 711 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
709 deleteStr(s); 712 deleteStr(s);
710 } 713 }
711 714
712 // last modification date 715 // last modification date
713 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { 716 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) {
714 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 717 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
715 deleteStr(s); 718 deleteStr(s);
716 } 719 }
717 else 720 else
718 anEvent->setLastModified(QDateTime(QDate::currentDate(), 721 anEvent->setLastModified(QDateTime(QDate::currentDate(),
719 QTime::currentTime())); 722 QTime::currentTime()));
720 723
721 // organizer 724 // organizer
722 // if our extension property for the event's ORGANIZER exists, add it. 725 // if our extension property for the event's ORGANIZER exists, add it.
723 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { 726 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) {
724 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 727 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
725 deleteStr(s); 728 deleteStr(s);
726 } else { 729 } else {
727 anEvent->setOrganizer(mCalendar->getEmail()); 730 anEvent->setOrganizer(mCalendar->getEmail());
728 } 731 }
729 732
730 // attendees. 733 // attendees.
731 initPropIterator(&voi, vtodo); 734 initPropIterator(&voi, vtodo);
732 while (moreIteration(&voi)) { 735 while (moreIteration(&voi)) {
733 vo = nextVObject(&voi); 736 vo = nextVObject(&voi);
734 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 737 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
735 Attendee *a; 738 Attendee *a;
736 VObject *vp; 739 VObject *vp;
737 s = fakeCString(vObjectUStringZValue(vo)); 740 s = fakeCString(vObjectUStringZValue(vo));
738 QString tmpStr = QString::fromLocal8Bit(s); 741 QString tmpStr = QString::fromLocal8Bit(s);
739 deleteStr(s); 742 deleteStr(s);
740 tmpStr = tmpStr.simplifyWhiteSpace(); 743 tmpStr = tmpStr.simplifyWhiteSpace();
741 int emailPos1, emailPos2; 744 int emailPos1, emailPos2;
742 if ((emailPos1 = tmpStr.find('<')) > 0) { 745 if ((emailPos1 = tmpStr.find('<')) > 0) {
743 // both email address and name 746 // both email address and name
744 emailPos2 = tmpStr.findRev('>'); 747 emailPos2 = tmpStr.findRev('>');
745 a = new Attendee(tmpStr.left(emailPos1 - 1), 748 a = new Attendee(tmpStr.left(emailPos1 - 1),
746 tmpStr.mid(emailPos1 + 1, 749 tmpStr.mid(emailPos1 + 1,
747 emailPos2 - (emailPos1 + 1))); 750 emailPos2 - (emailPos1 + 1)));
748 } else if (tmpStr.find('@') > 0) { 751 } else if (tmpStr.find('@') > 0) {
749 // just an email address 752 // just an email address
750 a = new Attendee(0, tmpStr); 753 a = new Attendee(0, tmpStr);
751 } else { 754 } else {
752 // just a name 755 // just a name
753 QString email = tmpStr.replace( QRegExp(" "), "." ); 756 QString email = tmpStr.replace( QRegExp(" "), "." );
754 a = new Attendee(tmpStr,email); 757 a = new Attendee(tmpStr,email);
755 } 758 }
756 759
757 // is there an RSVP property? 760 // is there an RSVP property?
758 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) 761 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
759 a->setRSVP(vObjectStringZValue(vp)); 762 a->setRSVP(vObjectStringZValue(vp));
760 // is there a status property? 763 // is there a status property?
761 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) 764 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
762 a->setStatus(readStatus(vObjectStringZValue(vp))); 765 a->setStatus(readStatus(vObjectStringZValue(vp)));
763 // add the attendee 766 // add the attendee
764 anEvent->addAttendee(a); 767 anEvent->addAttendee(a);
765 } 768 }
766 } 769 }
767 770
768 // description for todo 771 // description for todo
769 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { 772 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) {
770 s = fakeCString(vObjectUStringZValue(vo)); 773 s = fakeCString(vObjectUStringZValue(vo));
771 anEvent->setDescription(QString::fromLocal8Bit(s)); 774 anEvent->setDescription(QString::fromLocal8Bit(s));
772 deleteStr(s); 775 deleteStr(s);
773 } 776 }
774 777
775 // summary 778 // summary
776 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { 779 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) {
777 s = fakeCString(vObjectUStringZValue(vo)); 780 s = fakeCString(vObjectUStringZValue(vo));
778 anEvent->setSummary(QString::fromLocal8Bit(s)); 781 anEvent->setSummary(QString::fromLocal8Bit(s));
779 deleteStr(s); 782 deleteStr(s);
780 } 783 }
781 if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { 784 if ((vo = isAPropertyOf(vtodo, VCLocationProp))) {
782 s = fakeCString(vObjectUStringZValue(vo)); 785 s = fakeCString(vObjectUStringZValue(vo));
783 anEvent->setLocation(QString::fromLocal8Bit(s)); 786 anEvent->setLocation(QString::fromLocal8Bit(s));
784 deleteStr(s); 787 deleteStr(s);
785 } 788 }
786 789
787 790
788 // completed 791 // completed
789 // was: status 792 // was: status
790 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { 793 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) {
791 s = fakeCString(vObjectUStringZValue(vo)); 794 s = fakeCString(vObjectUStringZValue(vo));
792 if (strcmp(s,"COMPLETED") == 0) { 795 if (strcmp(s,"COMPLETED") == 0) {
793 anEvent->setCompleted(true); 796 anEvent->setCompleted(true);
794 } else { 797 } else {
795 anEvent->setCompleted(false); 798 anEvent->setCompleted(false);
796 } 799 }
797 deleteStr(s); 800 deleteStr(s);
798 } 801 }
799 else 802 else
800 anEvent->setCompleted(false); 803 anEvent->setCompleted(false);
801 804
802 // completion date 805 // completion date
803 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { 806 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) {
804 anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 807 anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
805 deleteStr(s); 808 deleteStr(s);
806 } 809 }
807 810
808 // priority 811 // priority
809 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { 812 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) {
810 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 813 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
811 deleteStr(s); 814 deleteStr(s);
812 } 815 }
813 816
814 // due date 817 // due date
815 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { 818 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) {
816 anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 819 anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
817 deleteStr(s); 820 deleteStr(s);
818 anEvent->setHasDueDate(true); 821 anEvent->setHasDueDate(true);
819 } else { 822 } else {
820 anEvent->setHasDueDate(false); 823 anEvent->setHasDueDate(false);
821 } 824 }
822 825
823 // start time 826 // start time
824 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { 827 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) {
825 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 828 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
826 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; 829 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
827 deleteStr(s); 830 deleteStr(s);
828 anEvent->setHasStartDate(true); 831 anEvent->setHasStartDate(true);
829 } else { 832 } else {
830 anEvent->setHasStartDate(false); 833 anEvent->setHasStartDate(false);
831 } 834 }
832 835
833 /* alarm stuff */ 836 /* alarm stuff */
834 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; 837 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl;
835 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { 838 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) {
836 Alarm* alarm = anEvent->newAlarm(); 839 Alarm* alarm = anEvent->newAlarm();
837 VObject *a; 840 VObject *a;
838 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 841 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
839 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 842 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
840 deleteStr(s); 843 deleteStr(s);
841 } 844 }
842 alarm->setEnabled(true); 845 alarm->setEnabled(true);
843 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { 846 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
844 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 847 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
845 s = fakeCString(vObjectUStringZValue(a)); 848 s = fakeCString(vObjectUStringZValue(a));
846 alarm->setProcedureAlarm(QFile::decodeName(s)); 849 alarm->setProcedureAlarm(QFile::decodeName(s));
847 deleteStr(s); 850 deleteStr(s);
848 } 851 }
849 } 852 }
850 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { 853 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
851 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 854 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
852 s = fakeCString(vObjectUStringZValue(a)); 855 s = fakeCString(vObjectUStringZValue(a));
853 alarm->setAudioAlarm(QFile::decodeName(s)); 856 alarm->setAudioAlarm(QFile::decodeName(s));
854 deleteStr(s); 857 deleteStr(s);
855 } 858 }
856 } 859 }
857 } 860 }
858 861
859 // related todo 862 // related todo
860 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { 863 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) {
861 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); 864 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
862 deleteStr(s); 865 deleteStr(s);
863 mTodosRelate.append(anEvent); 866 mTodosRelate.append(anEvent);
864 } 867 }
865 868
866 // categories 869 // categories
867 QStringList tmpStrList; 870 QStringList tmpStrList;
868 int index1 = 0; 871 int index1 = 0;
869 int index2 = 0; 872 int index2 = 0;
870 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { 873 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) {
871 s = fakeCString(vObjectUStringZValue(vo)); 874 s = fakeCString(vObjectUStringZValue(vo));
872 QString categories = QString::fromLocal8Bit(s); 875 QString categories = QString::fromLocal8Bit(s);
873 deleteStr(s); 876 deleteStr(s);
874 //const char* category; 877 //const char* category;
875 QString category; 878 QString category;
876 while ((index2 = categories.find(',', index1)) != -1) { 879 while ((index2 = categories.find(',', index1)) != -1) {
877 //category = (const char *) categories.mid(index1, (index2 - index1)); 880 //category = (const char *) categories.mid(index1, (index2 - index1));
878 category = categories.mid(index1, (index2 - index1)); 881 category = categories.mid(index1, (index2 - index1));
879 tmpStrList.append(category); 882 tmpStrList.append(category);
880 index1 = index2+1; 883 index1 = index2+1;
881 } 884 }
882 // get last category 885 // get last category
883 category = categories.mid(index1, (categories.length()-index1)); 886 category = categories.mid(index1, (categories.length()-index1));
884 tmpStrList.append(category); 887 tmpStrList.append(category);
885 anEvent->setCategories(tmpStrList); 888 anEvent->setCategories(tmpStrList);
886 } 889 }
887 890
888 /* PILOT SYNC STUFF */ 891 /* PILOT SYNC STUFF */
889 if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { 892 if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) {
890 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 893 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
891 deleteStr(s); 894 deleteStr(s);
892 } 895 }
893 else 896 else
894 anEvent->setPilotId(0); 897 anEvent->setPilotId(0);
895 898
896 if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { 899 if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) {
897 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 900 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
898 deleteStr(s); 901 deleteStr(s);
899 } 902 }
900 else 903 else
901 anEvent->setSyncStatus(Event::SYNCMOD); 904 anEvent->setSyncStatus(Event::SYNCMOD);
902 905
903 return anEvent; 906 return anEvent;
904} 907}
905 908
906Event* VCalFormat::VEventToEvent(VObject *vevent) 909Event* VCalFormat::VEventToEvent(VObject *vevent)
907{ 910{
908 VObject *vo; 911 VObject *vo;
909 VObjectIterator voi; 912 VObjectIterator voi;
910 char *s; 913 char *s;
911 914
912 Event *anEvent = new Event; 915 Event *anEvent = new Event;
913 916
914 // creation date 917 // creation date
915 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { 918 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) {
916 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 919 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
917 deleteStr(s); 920 deleteStr(s);
918 } 921 }
919 922
920 // unique id 923 // unique id
921 vo = isAPropertyOf(vevent, VCUniqueStringProp); 924 vo = isAPropertyOf(vevent, VCUniqueStringProp);
922 // while the UID property is preferred, it is not required. We'll use the 925 // while the UID property is preferred, it is not required. We'll use the
923 // default Event UID if none is given. 926 // default Event UID if none is given.
924 if (vo) { 927 if (vo) {
925 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 928 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
926 deleteStr(s); 929 deleteStr(s);
927 } 930 }
928 931
929 // revision 932 // revision
930 // again NSCAL doesn't give us much to work with, so we improvise... 933 // again NSCAL doesn't give us much to work with, so we improvise...
931 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { 934 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) {
932 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 935 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo))));
933 deleteStr(s); 936 deleteStr(s);
934 } 937 }
935 else 938 else
936 anEvent->setRevision(0); 939 anEvent->setRevision(0);
937 940
938 // last modification date 941 // last modification date
939 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { 942 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) {
940 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 943 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
941 deleteStr(s); 944 deleteStr(s);
942 } 945 }
943 else 946 else
944 anEvent->setLastModified(QDateTime(QDate::currentDate(), 947 anEvent->setLastModified(QDateTime(QDate::currentDate(),
945 QTime::currentTime())); 948 QTime::currentTime()));
946 949
947 // organizer 950 // organizer
948 // if our extension property for the event's ORGANIZER exists, add it. 951 // if our extension property for the event's ORGANIZER exists, add it.
949 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { 952 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) {
950 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 953 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
951 deleteStr(s); 954 deleteStr(s);
952 } else { 955 } else {
953 anEvent->setOrganizer(mCalendar->getEmail()); 956 anEvent->setOrganizer(mCalendar->getEmail());
954 } 957 }
955 958
956 // deal with attendees. 959 // deal with attendees.
957 initPropIterator(&voi, vevent); 960 initPropIterator(&voi, vevent);
958 while (moreIteration(&voi)) { 961 while (moreIteration(&voi)) {
959 vo = nextVObject(&voi); 962 vo = nextVObject(&voi);
960 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 963 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
961 Attendee *a; 964 Attendee *a;
962 VObject *vp; 965 VObject *vp;
963 s = fakeCString(vObjectUStringZValue(vo)); 966 s = fakeCString(vObjectUStringZValue(vo));
964 QString tmpStr = QString::fromLocal8Bit(s); 967 QString tmpStr = QString::fromLocal8Bit(s);
965 deleteStr(s); 968 deleteStr(s);
966 tmpStr = tmpStr.simplifyWhiteSpace(); 969 tmpStr = tmpStr.simplifyWhiteSpace();
967 int emailPos1, emailPos2; 970 int emailPos1, emailPos2;
968 if ((emailPos1 = tmpStr.find('<')) > 0) { 971 if ((emailPos1 = tmpStr.find('<')) > 0) {
969 // both email address and name 972 // both email address and name
970 emailPos2 = tmpStr.findRev('>'); 973 emailPos2 = tmpStr.findRev('>');
971 a = new Attendee(tmpStr.left(emailPos1 - 1), 974 a = new Attendee(tmpStr.left(emailPos1 - 1),
972 tmpStr.mid(emailPos1 + 1, 975 tmpStr.mid(emailPos1 + 1,
973 emailPos2 - (emailPos1 + 1))); 976 emailPos2 - (emailPos1 + 1)));
974 } else if (tmpStr.find('@') > 0) { 977 } else if (tmpStr.find('@') > 0) {
975 // just an email address 978 // just an email address
976 a = new Attendee(0, tmpStr); 979 a = new Attendee(0, tmpStr);
977 } else { 980 } else {
978 // just a name 981 // just a name
979 QString email = tmpStr.replace( QRegExp(" "), "." ); 982 QString email = tmpStr.replace( QRegExp(" "), "." );
980 a = new Attendee(tmpStr,email); 983 a = new Attendee(tmpStr,email);
981 } 984 }
982 985
983 // is there an RSVP property? 986 // is there an RSVP property?
984 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) 987 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
985 a->setRSVP(vObjectStringZValue(vp)); 988 a->setRSVP(vObjectStringZValue(vp));
986 // is there a status property? 989 // is there a status property?
987 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) 990 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
988 a->setStatus(readStatus(vObjectStringZValue(vp))); 991 a->setStatus(readStatus(vObjectStringZValue(vp)));
989 // add the attendee 992 // add the attendee
990 anEvent->addAttendee(a); 993 anEvent->addAttendee(a);
991 } 994 }
992 } 995 }
993 996
994 // This isn't strictly true. An event that doesn't have a start time 997 // This isn't strictly true. An event that doesn't have a start time
995 // or an end time doesn't "float", it has an anchor in time but it doesn't 998 // or an end time doesn't "float", it has an anchor in time but it doesn't
996 // "take up" any time. 999 // "take up" any time.
997 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || 1000 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) ||
998 (isAPropertyOf(vevent, VCDTendProp) == 0)) { 1001 (isAPropertyOf(vevent, VCDTendProp) == 0)) {
999 anEvent->setFloats(TRUE); 1002 anEvent->setFloats(TRUE);
1000 } else { 1003 } else {
1001 }*/ 1004 }*/
1002 1005
1003 anEvent->setFloats(FALSE); 1006 anEvent->setFloats(FALSE);
1004 1007
1005 // start time 1008 // start time
1006 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { 1009 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) {
1007 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 1010 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
1008 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; 1011 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
1009 deleteStr(s); 1012 deleteStr(s);
1010 if (anEvent->dtStart().time().isNull()) 1013 if (anEvent->dtStart().time().isNull())
1011 anEvent->setFloats(TRUE); 1014 anEvent->setFloats(TRUE);
1012 } 1015 }
1013 1016
1014 // stop time 1017 // stop time
1015 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { 1018 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) {
1016 anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 1019 anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
1017 deleteStr(s); 1020 deleteStr(s);
1018 if (anEvent->dtEnd().time().isNull()) 1021 if (anEvent->dtEnd().time().isNull())
1019 anEvent->setFloats(TRUE); 1022 anEvent->setFloats(TRUE);
1020 } 1023 }
1021 1024
1022 // at this point, there should be at least a start or end time. 1025 // at this point, there should be at least a start or end time.
1023 // fix up for events that take up no time but have a time associated 1026 // fix up for events that take up no time but have a time associated
1024 if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) 1027 if (!(vo = isAPropertyOf(vevent, VCDTstartProp)))
1025 anEvent->setDtStart(anEvent->dtEnd()); 1028 anEvent->setDtStart(anEvent->dtEnd());
1026 if (!(vo = isAPropertyOf(vevent, VCDTendProp))) 1029 if (!(vo = isAPropertyOf(vevent, VCDTendProp)))
1027 anEvent->setDtEnd(anEvent->dtStart()); 1030 anEvent->setDtEnd(anEvent->dtStart());
1028 1031
1029 /////////////////////////////////////////////////////////////////////////// 1032 ///////////////////////////////////////////////////////////////////////////
1030 1033
1031 // repeat stuff 1034 // repeat stuff
1032 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { 1035 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) {
1033 QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); 1036 QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo)));
1034 deleteStr(s); 1037 deleteStr(s);
1035 tmpStr.simplifyWhiteSpace(); 1038 tmpStr.simplifyWhiteSpace();
1036 tmpStr = tmpStr.upper(); 1039 tmpStr = tmpStr.upper();
1037 1040
1038 /********************************* DAILY ******************************/ 1041 /********************************* DAILY ******************************/
1039 if (tmpStr.left(1) == "D") { 1042 if (tmpStr.left(1) == "D") {
1040 int index = tmpStr.find(' '); 1043 int index = tmpStr.find(' ');
1041 int rFreq = tmpStr.mid(1, (index-1)).toInt(); 1044 int rFreq = tmpStr.mid(1, (index-1)).toInt();
1042 index = tmpStr.findRev(' ') + 1; // advance to last field 1045 index = tmpStr.findRev(' ') + 1; // advance to last field
1043 if (tmpStr.mid(index,1) == "#") index++; 1046 if (tmpStr.mid(index,1) == "#") index++;
1044 if (tmpStr.find('T', index) != -1) { 1047 if (tmpStr.find('T', index) != -1) {
1045 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1048 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1046 anEvent->recurrence()->setDaily(rFreq, rEndDate); 1049 anEvent->recurrence()->setDaily(rFreq, rEndDate);
1047 } else { 1050 } else {
1048 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1051 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1049 if (rDuration == 0) // VEvents set this to 0 forever, we use -1 1052 if (rDuration == 0) // VEvents set this to 0 forever, we use -1
1050 anEvent->recurrence()->setDaily(rFreq, -1); 1053 anEvent->recurrence()->setDaily(rFreq, -1);
1051 else 1054 else
1052 anEvent->recurrence()->setDaily(rFreq, rDuration); 1055 anEvent->recurrence()->setDaily(rFreq, rDuration);
1053 } 1056 }
1054 } 1057 }
1055 /********************************* WEEKLY ******************************/ 1058 /********************************* WEEKLY ******************************/
1056 else if (tmpStr.left(1) == "W") { 1059 else if (tmpStr.left(1) == "W") {
1057 int index = tmpStr.find(' '); 1060 int index = tmpStr.find(' ');
1058 int last = tmpStr.findRev(' ') + 1; 1061 int last = tmpStr.findRev(' ') + 1;
1059 int rFreq = tmpStr.mid(1, (index-1)).toInt(); 1062 int rFreq = tmpStr.mid(1, (index-1)).toInt();
1060 index += 1; // advance to beginning of stuff after freq 1063 index += 1; // advance to beginning of stuff after freq
1061 QBitArray qba(7); 1064 QBitArray qba(7);
1062 QString dayStr; 1065 QString dayStr;
1063 if( index == last ) { 1066 if( index == last ) {
1064 // e.g. W1 #0 1067 // e.g. W1 #0
1065 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); 1068 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1066 } 1069 }
1067 else { 1070 else {
1068 // e.g. W1 SU #0 1071 // e.g. W1 SU #0
1069 while (index < last) { 1072 while (index < last) {
1070 dayStr = tmpStr.mid(index, 3); 1073 dayStr = tmpStr.mid(index, 3);
1071 int dayNum = numFromDay(dayStr); 1074 int dayNum = numFromDay(dayStr);
1072 qba.setBit(dayNum); 1075 qba.setBit(dayNum);
1073 index += 3; // advance to next day, or possibly "#" 1076 index += 3; // advance to next day, or possibly "#"
1074 } 1077 }
1075 } 1078 }
1076 index = last; if (tmpStr.mid(index,1) == "#") index++; 1079 index = last; if (tmpStr.mid(index,1) == "#") index++;
1077 if (tmpStr.find('T', index) != -1) { 1080 if (tmpStr.find('T', index) != -1) {
1078 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1081 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1079 anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); 1082 anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate);
1080 } else { 1083 } else {
1081 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1084 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1082 if (rDuration == 0) 1085 if (rDuration == 0)
1083 anEvent->recurrence()->setWeekly(rFreq, qba, -1); 1086 anEvent->recurrence()->setWeekly(rFreq, qba, -1);
1084 else 1087 else
1085 anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); 1088 anEvent->recurrence()->setWeekly(rFreq, qba, rDuration);
1086 } 1089 }
1087 } 1090 }
1088 /**************************** MONTHLY-BY-POS ***************************/ 1091 /**************************** MONTHLY-BY-POS ***************************/
1089 else if (tmpStr.left(2) == "MP") { 1092 else if (tmpStr.left(2) == "MP") {
1090 int index = tmpStr.find(' '); 1093 int index = tmpStr.find(' ');
1091 int last = tmpStr.findRev(' ') + 1; 1094 int last = tmpStr.findRev(' ') + 1;
1092 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1095 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1093 index += 1; // advance to beginning of stuff after freq 1096 index += 1; // advance to beginning of stuff after freq
1094 QBitArray qba(7); 1097 QBitArray qba(7);
1095 short tmpPos; 1098 short tmpPos;
1096 if( index == last ) { 1099 if( index == last ) {
1097 // e.g. MP1 #0 1100 // e.g. MP1 #0
1098 tmpPos = anEvent->dtStart().date().day()/7 + 1; 1101 tmpPos = anEvent->dtStart().date().day()/7 + 1;
1099 if( tmpPos == 5 ) 1102 if( tmpPos == 5 )
1100 tmpPos = -1; 1103 tmpPos = -1;
1101 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); 1104 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1102 anEvent->recurrence()->addMonthlyPos(tmpPos, qba); 1105 anEvent->recurrence()->addMonthlyPos(tmpPos, qba);
1103 } 1106 }
1104 else { 1107 else {
1105 // e.g. MP1 1+ SU #0 1108 // e.g. MP1 1+ SU #0
1106 while (index < last) { 1109 while (index < last) {
1107 tmpPos = tmpStr.mid(index,1).toShort(); 1110 tmpPos = tmpStr.mid(index,1).toShort();
1108 index += 1; 1111 index += 1;
1109 if (tmpStr.mid(index,1) == "-") 1112 if (tmpStr.mid(index,1) == "-")
1110 // convert tmpPos to negative 1113 // convert tmpPos to negative
1111 tmpPos = 0 - tmpPos; 1114 tmpPos = 0 - tmpPos;
1112 index += 2; // advance to day(s) 1115 index += 2; // advance to day(s)
1113 while (numFromDay(tmpStr.mid(index,3)) >= 0) { 1116 while (numFromDay(tmpStr.mid(index,3)) >= 0) {
1114 int dayNum = numFromDay(tmpStr.mid(index,3)); 1117 int dayNum = numFromDay(tmpStr.mid(index,3));
1115 qba.setBit(dayNum); 1118 qba.setBit(dayNum);
1116 index += 3; // advance to next day, or possibly pos or "#" 1119 index += 3; // advance to next day, or possibly pos or "#"
1117 } 1120 }
1118 anEvent->recurrence()->addMonthlyPos(tmpPos, qba); 1121 anEvent->recurrence()->addMonthlyPos(tmpPos, qba);
1119 qba.detach(); 1122 qba.detach();
1120 qba.fill(FALSE); // clear out 1123 qba.fill(FALSE); // clear out
1121 } // while != "#" 1124 } // while != "#"
1122 } 1125 }
1123 index = last; if (tmpStr.mid(index,1) == "#") index++; 1126 index = last; if (tmpStr.mid(index,1) == "#") index++;
1124 if (tmpStr.find('T', index) != -1) { 1127 if (tmpStr.find('T', index) != -1) {
1125 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - 1128 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() -
1126 index))).date(); 1129 index))).date();
1127 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); 1130 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate);
1128 } else { 1131 } else {
1129 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1132 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1130 if (rDuration == 0) 1133 if (rDuration == 0)
1131 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); 1134 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1);
1132 else 1135 else
1133 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); 1136 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration);
1134 } 1137 }
1135 } 1138 }
1136 1139
1137 /**************************** MONTHLY-BY-DAY ***************************/ 1140 /**************************** MONTHLY-BY-DAY ***************************/
1138 else if (tmpStr.left(2) == "MD") { 1141 else if (tmpStr.left(2) == "MD") {
1139 int index = tmpStr.find(' '); 1142 int index = tmpStr.find(' ');
1140 int last = tmpStr.findRev(' ') + 1; 1143 int last = tmpStr.findRev(' ') + 1;
1141 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1144 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1142 index += 1; 1145 index += 1;
1143 short tmpDay; 1146 short tmpDay;
1144 if( index == last ) { 1147 if( index == last ) {
1145 // e.g. MD1 #0 1148 // e.g. MD1 #0
1146 tmpDay = anEvent->dtStart().date().day(); 1149 tmpDay = anEvent->dtStart().date().day();
1147 anEvent->recurrence()->addMonthlyDay(tmpDay); 1150 anEvent->recurrence()->addMonthlyDay(tmpDay);
1148 } 1151 }
1149 else { 1152 else {
1150 // e.g. MD1 3 #0 1153 // e.g. MD1 3 #0
1151 while (index < last) { 1154 while (index < last) {
1152 int index2 = tmpStr.find(' ', index); 1155 int index2 = tmpStr.find(' ', index);
1153 tmpDay = tmpStr.mid(index, (index2-index)).toShort(); 1156 tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1154 index = index2-1; 1157 index = index2-1;
1155 if (tmpStr.mid(index, 1) == "-") 1158 if (tmpStr.mid(index, 1) == "-")
1156 tmpDay = 0 - tmpDay; 1159 tmpDay = 0 - tmpDay;
1157 index += 2; // advance the index; 1160 index += 2; // advance the index;
1158 anEvent->recurrence()->addMonthlyDay(tmpDay); 1161 anEvent->recurrence()->addMonthlyDay(tmpDay);
1159 } // while != # 1162 } // while != #
1160 } 1163 }
1161 index = last; if (tmpStr.mid(index,1) == "#") index++; 1164 index = last; if (tmpStr.mid(index,1) == "#") index++;
1162 if (tmpStr.find('T', index) != -1) { 1165 if (tmpStr.find('T', index) != -1) {
1163 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1166 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1164 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); 1167 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate);
1165 } else { 1168 } else {
1166 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1169 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1167 if (rDuration == 0) 1170 if (rDuration == 0)
1168 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); 1171 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1);
1169 else 1172 else
1170 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); 1173 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration);
1171 } 1174 }
1172 } 1175 }
1173 1176
1174 /*********************** YEARLY-BY-MONTH *******************************/ 1177 /*********************** YEARLY-BY-MONTH *******************************/
1175 else if (tmpStr.left(2) == "YM") { 1178 else if (tmpStr.left(2) == "YM") {
1176 int index = tmpStr.find(' '); 1179 int index = tmpStr.find(' ');
1177 int last = tmpStr.findRev(' ') + 1; 1180 int last = tmpStr.findRev(' ') + 1;
1178 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1181 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1179 index += 1; 1182 index += 1;
1180 short tmpMonth; 1183 short tmpMonth;
1181 if( index == last ) { 1184 if( index == last ) {
1182 // e.g. YM1 #0 1185 // e.g. YM1 #0
1183 tmpMonth = anEvent->dtStart().date().month(); 1186 tmpMonth = anEvent->dtStart().date().month();
1184 anEvent->recurrence()->addYearlyNum(tmpMonth); 1187 anEvent->recurrence()->addYearlyNum(tmpMonth);
1185 } 1188 }
1186 else { 1189 else {
1187 // e.g. YM1 3 #0 1190 // e.g. YM1 3 #0
1188 while (index < last) { 1191 while (index < last) {
1189 int index2 = tmpStr.find(' ', index); 1192 int index2 = tmpStr.find(' ', index);
1190 tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); 1193 tmpMonth = tmpStr.mid(index, (index2-index)).toShort();
1191 index = index2+1; 1194 index = index2+1;
1192 anEvent->recurrence()->addYearlyNum(tmpMonth); 1195 anEvent->recurrence()->addYearlyNum(tmpMonth);
1193 } // while != # 1196 } // while != #
1194 } 1197 }
1195 index = last; if (tmpStr.mid(index,1) == "#") index++; 1198 index = last; if (tmpStr.mid(index,1) == "#") index++;
1196 if (tmpStr.find('T', index) != -1) { 1199 if (tmpStr.find('T', index) != -1) {
1197 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1200 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1198 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); 1201 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate);
1199 } else { 1202 } else {
1200 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1203 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1201 if (rDuration == 0) 1204 if (rDuration == 0)
1202 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); 1205 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1);
1203 else 1206 else
1204 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); 1207 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration);
1205 } 1208 }
1206 } 1209 }
1207 1210
1208 /*********************** YEARLY-BY-DAY *********************************/ 1211 /*********************** YEARLY-BY-DAY *********************************/
1209 else if (tmpStr.left(2) == "YD") { 1212 else if (tmpStr.left(2) == "YD") {
1210 int index = tmpStr.find(' '); 1213 int index = tmpStr.find(' ');
1211 int last = tmpStr.findRev(' ') + 1; 1214 int last = tmpStr.findRev(' ') + 1;
1212 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1215 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1213 index += 1; 1216 index += 1;
1214 short tmpDay; 1217 short tmpDay;
1215 if( index == last ) { 1218 if( index == last ) {
1216 // e.g. YD1 #0 1219 // e.g. YD1 #0
1217 tmpDay = anEvent->dtStart().date().dayOfYear(); 1220 tmpDay = anEvent->dtStart().date().dayOfYear();
1218 anEvent->recurrence()->addYearlyNum(tmpDay); 1221 anEvent->recurrence()->addYearlyNum(tmpDay);
1219 } 1222 }
1220 else { 1223 else {
1221 // e.g. YD1 123 #0 1224 // e.g. YD1 123 #0
1222 while (index < last) { 1225 while (index < last) {
1223 int index2 = tmpStr.find(' ', index); 1226 int index2 = tmpStr.find(' ', index);
1224 tmpDay = tmpStr.mid(index, (index2-index)).toShort(); 1227 tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1225 index = index2+1; 1228 index = index2+1;
1226 anEvent->recurrence()->addYearlyNum(tmpDay); 1229 anEvent->recurrence()->addYearlyNum(tmpDay);
1227 } // while != # 1230 } // while != #
1228 } 1231 }
1229 index = last; if (tmpStr.mid(index,1) == "#") index++; 1232 index = last; if (tmpStr.mid(index,1) == "#") index++;
1230 if (tmpStr.find('T', index) != -1) { 1233 if (tmpStr.find('T', index) != -1) {
1231 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1234 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1232 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); 1235 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate);
1233 } else { 1236 } else {
1234 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1237 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1235 if (rDuration == 0) 1238 if (rDuration == 0)
1236 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); 1239 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1);
1237 else 1240 else
1238 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); 1241 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration);
1239 } 1242 }
1240 } else { 1243 } else {
1241 kdDebug(5800) << "we don't understand this type of recurrence!" << endl; 1244 kdDebug(5800) << "we don't understand this type of recurrence!" << endl;
1242 } // if 1245 } // if
1243 } // repeats 1246 } // repeats
1244 1247
1245 1248
1246 // recurrence exceptions 1249 // recurrence exceptions
1247 if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { 1250 if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) {
1248 s = fakeCString(vObjectUStringZValue(vo)); 1251 s = fakeCString(vObjectUStringZValue(vo));
1249 QStringList exDates = QStringList::split(",",s); 1252 QStringList exDates = QStringList::split(",",s);
1250 QStringList::ConstIterator it; 1253 QStringList::ConstIterator it;
1251 for(it = exDates.begin(); it != exDates.end(); ++it ) { 1254 for(it = exDates.begin(); it != exDates.end(); ++it ) {
1252 anEvent->addExDate(ISOToQDate(*it)); 1255 anEvent->addExDate(ISOToQDate(*it));
1253 } 1256 }
1254 deleteStr(s); 1257 deleteStr(s);
1255 } 1258 }
1256 1259
1257 // summary 1260 // summary
1258 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { 1261 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) {
1259 s = fakeCString(vObjectUStringZValue(vo)); 1262 s = fakeCString(vObjectUStringZValue(vo));
1260 anEvent->setSummary(QString::fromLocal8Bit(s)); 1263 anEvent->setSummary(QString::fromLocal8Bit(s));
1261 deleteStr(s); 1264 deleteStr(s);
1262 } 1265 }
1263 if ((vo = isAPropertyOf(vevent, VCLocationProp))) { 1266 if ((vo = isAPropertyOf(vevent, VCLocationProp))) {
1264 s = fakeCString(vObjectUStringZValue(vo)); 1267 s = fakeCString(vObjectUStringZValue(vo));
1265 anEvent->setLocation(QString::fromLocal8Bit(s)); 1268 anEvent->setLocation(QString::fromLocal8Bit(s));
1266 deleteStr(s); 1269 deleteStr(s);
1267 } 1270 }
1268 1271
1269 // description 1272 // description
1270 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { 1273 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) {
1271 s = fakeCString(vObjectUStringZValue(vo)); 1274 s = fakeCString(vObjectUStringZValue(vo));
1272 if (!anEvent->description().isEmpty()) { 1275 if (!anEvent->description().isEmpty()) {
1273 anEvent->setDescription(anEvent->description() + "\n" + 1276 anEvent->setDescription(anEvent->description() + "\n" +
1274 QString::fromLocal8Bit(s)); 1277 QString::fromLocal8Bit(s));
1275 } else { 1278 } else {
1276 anEvent->setDescription(QString::fromLocal8Bit(s)); 1279 anEvent->setDescription(QString::fromLocal8Bit(s));
1277 } 1280 }
1278 deleteStr(s); 1281 deleteStr(s);
1279 } 1282 }
1280 1283
1281 // some stupid vCal exporters ignore the standard and use Description 1284 // some stupid vCal exporters ignore the standard and use Description
1282 // instead of Summary for the default field. Correct for this. 1285 // instead of Summary for the default field. Correct for this.
1283 if (anEvent->summary().isEmpty() && 1286 if (anEvent->summary().isEmpty() &&
1284 !(anEvent->description().isEmpty())) { 1287 !(anEvent->description().isEmpty())) {
1285 QString tmpStr = anEvent->description().simplifyWhiteSpace(); 1288 QString tmpStr = anEvent->description().simplifyWhiteSpace();
1286 anEvent->setDescription(""); 1289 anEvent->setDescription("");
1287 anEvent->setSummary(tmpStr); 1290 anEvent->setSummary(tmpStr);
1288 } 1291 }
1289 1292
1290#if 0 1293#if 0
1291 // status 1294 // status
1292 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { 1295 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) {
1293 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); 1296 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
1294 deleteStr(s); 1297 deleteStr(s);
1295// TODO: Define Event status 1298// TODO: Define Event status
1296// anEvent->setStatus(tmpStr); 1299// anEvent->setStatus(tmpStr);
1297 } 1300 }
1298 else 1301 else
1299// anEvent->setStatus("NEEDS ACTION"); 1302// anEvent->setStatus("NEEDS ACTION");
1300#endif 1303#endif
1301 1304
1302 // secrecy 1305 // secrecy
1303 int secrecy = Incidence::SecrecyPublic; 1306 int secrecy = Incidence::SecrecyPublic;
1304 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { 1307 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) {
1305 s = fakeCString(vObjectUStringZValue(vo)); 1308 s = fakeCString(vObjectUStringZValue(vo));
1306 if (strcmp(s,"PRIVATE") == 0) { 1309 if (strcmp(s,"PRIVATE") == 0) {
1307 secrecy = Incidence::SecrecyPrivate; 1310 secrecy = Incidence::SecrecyPrivate;
1308 } else if (strcmp(s,"CONFIDENTIAL") == 0) { 1311 } else if (strcmp(s,"CONFIDENTIAL") == 0) {
1309 secrecy = Incidence::SecrecyConfidential; 1312 secrecy = Incidence::SecrecyConfidential;
1310 } 1313 }
1311 deleteStr(s); 1314 deleteStr(s);
1312 } 1315 }
1313 anEvent->setSecrecy(secrecy); 1316 anEvent->setSecrecy(secrecy);
1314 1317
1315 // categories 1318 // categories
1316 QStringList tmpStrList; 1319 QStringList tmpStrList;
1317 int index1 = 0; 1320 int index1 = 0;
1318 int index2 = 0; 1321 int index2 = 0;
1319 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { 1322 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) {
1320 s = fakeCString(vObjectUStringZValue(vo)); 1323 s = fakeCString(vObjectUStringZValue(vo));
1321 QString categories = QString::fromLocal8Bit(s); 1324 QString categories = QString::fromLocal8Bit(s);
1322 deleteStr(s); 1325 deleteStr(s);
1323 //const char* category; 1326 //const char* category;
1324 QString category; 1327 QString category;
1325 while ((index2 = categories.find(',', index1)) != -1) { 1328 while ((index2 = categories.find(',', index1)) != -1) {
1326 //category = (const char *) categories.mid(index1, (index2 - index1)); 1329 //category = (const char *) categories.mid(index1, (index2 - index1));
1327 category = categories.mid(index1, (index2 - index1)); 1330 category = categories.mid(index1, (index2 - index1));
1328 tmpStrList.append(category); 1331 tmpStrList.append(category);
1329 index1 = index2+1; 1332 index1 = index2+1;
1330 } 1333 }
1331 // get last category 1334 // get last category
1332 category = categories.mid(index1, (categories.length()-index1)); 1335 category = categories.mid(index1, (categories.length()-index1));
1333 tmpStrList.append(category); 1336 tmpStrList.append(category);
1334 anEvent->setCategories(tmpStrList); 1337 anEvent->setCategories(tmpStrList);
1335 } 1338 }
1336 1339
1337 // attachments 1340 // attachments
1338 tmpStrList.clear(); 1341 tmpStrList.clear();
1339 initPropIterator(&voi, vevent); 1342 initPropIterator(&voi, vevent);
1340 while (moreIteration(&voi)) { 1343 while (moreIteration(&voi)) {
1341 vo = nextVObject(&voi); 1344 vo = nextVObject(&voi);
1342 if (strcmp(vObjectName(vo), VCAttachProp) == 0) { 1345 if (strcmp(vObjectName(vo), VCAttachProp) == 0) {
1343 s = fakeCString(vObjectUStringZValue(vo)); 1346 s = fakeCString(vObjectUStringZValue(vo));
1344 anEvent->addAttachment(new Attachment(QString(s))); 1347 anEvent->addAttachment(new Attachment(QString(s)));
1345 deleteStr(s); 1348 deleteStr(s);
1346 } 1349 }
1347 } 1350 }
1348 1351
1349 // resources 1352 // resources
1350 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { 1353 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) {
1351 QString resources = (s = fakeCString(vObjectUStringZValue(vo))); 1354 QString resources = (s = fakeCString(vObjectUStringZValue(vo)));
1352 deleteStr(s); 1355 deleteStr(s);
1353 tmpStrList.clear(); 1356 tmpStrList.clear();
1354 index1 = 0; 1357 index1 = 0;
1355 index2 = 0; 1358 index2 = 0;
1356 QString resource; 1359 QString resource;
1357 while ((index2 = resources.find(';', index1)) != -1) { 1360 while ((index2 = resources.find(';', index1)) != -1) {
1358 resource = resources.mid(index1, (index2 - index1)); 1361 resource = resources.mid(index1, (index2 - index1));
1359 tmpStrList.append(resource); 1362 tmpStrList.append(resource);
1360 index1 = index2; 1363 index1 = index2;
1361 } 1364 }
1362 anEvent->setResources(tmpStrList); 1365 anEvent->setResources(tmpStrList);
1363 } 1366 }
1364 1367
1365 /* alarm stuff */ 1368 /* alarm stuff */
1366 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { 1369 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) {
1367 Alarm* alarm = anEvent->newAlarm(); 1370 Alarm* alarm = anEvent->newAlarm();
1368 VObject *a; 1371 VObject *a;
1369 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 1372 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
1370 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 1373 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
1371 deleteStr(s); 1374 deleteStr(s);
1372 } 1375 }
1373 alarm->setEnabled(true); 1376 alarm->setEnabled(true);
1374 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { 1377 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) {
1375 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 1378 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
1376 s = fakeCString(vObjectUStringZValue(a)); 1379 s = fakeCString(vObjectUStringZValue(a));
1377 alarm->setProcedureAlarm(QFile::decodeName(s)); 1380 alarm->setProcedureAlarm(QFile::decodeName(s));
1378 deleteStr(s); 1381 deleteStr(s);
1379 } 1382 }
1380 } 1383 }
1381 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { 1384 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) {
1382 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 1385 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
1383 s = fakeCString(vObjectUStringZValue(a)); 1386 s = fakeCString(vObjectUStringZValue(a));
1384 alarm->setAudioAlarm(QFile::decodeName(s)); 1387 alarm->setAudioAlarm(QFile::decodeName(s));
1385 deleteStr(s); 1388 deleteStr(s);
1386 } 1389 }
1387 } 1390 }
1388 } 1391 }
1389 1392
1390 // priority 1393 // priority
1391 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { 1394 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) {
1392 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1395 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1393 deleteStr(s); 1396 deleteStr(s);
1394 } 1397 }
1395 1398
1396 // transparency 1399 // transparency
1397 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { 1400 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) {
1398 int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); 1401 int i = atoi(s = fakeCString(vObjectUStringZValue(vo)));
1399 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); 1402 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque );
1400 deleteStr(s); 1403 deleteStr(s);
1401 } 1404 }
1402 1405
1403 // related event 1406 // related event
1404 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { 1407 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) {
1405 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); 1408 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
1406 deleteStr(s); 1409 deleteStr(s);
1407 mEventsRelate.append(anEvent); 1410 mEventsRelate.append(anEvent);
1408 } 1411 }
1409 1412
1410 /* PILOT SYNC STUFF */ 1413 /* PILOT SYNC STUFF */
1411 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { 1414 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) {
1412 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1415 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1413 deleteStr(s); 1416 deleteStr(s);
1414 } 1417 }
1415 else 1418 else
1416 anEvent->setPilotId(0); 1419 anEvent->setPilotId(0);
1417 1420
1418 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { 1421 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) {
1419 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1422 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1420 deleteStr(s); 1423 deleteStr(s);
1421 } 1424 }
1422 else 1425 else
1423 anEvent->setSyncStatus(Event::SYNCMOD); 1426 anEvent->setSyncStatus(Event::SYNCMOD);
1424 1427
1425 return anEvent; 1428 return anEvent;
1426} 1429}
1427 1430
1428 1431
1429QString VCalFormat::qDateToISO(const QDate &qd) 1432QString VCalFormat::qDateToISO(const QDate &qd)
1430{ 1433{
1431 QString tmpStr; 1434 QString tmpStr;
1432 1435
1433 ASSERT(qd.isValid()); 1436 ASSERT(qd.isValid());
1434 1437
1435 tmpStr.sprintf("%.2d%.2d%.2d", 1438 tmpStr.sprintf("%.2d%.2d%.2d",
1436 qd.year(), qd.month(), qd.day()); 1439 qd.year(), qd.month(), qd.day());
1437 return tmpStr; 1440 return tmpStr;
1438 1441
1439} 1442}
1440 1443
1441QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) 1444QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu)
1442{ 1445{
1443 QString tmpStr; 1446 QString tmpStr;
1444 1447
1445 ASSERT(qdt.date().isValid()); 1448 ASSERT(qdt.date().isValid());
1446 ASSERT(qdt.time().isValid()); 1449 ASSERT(qdt.time().isValid());
1447 if (zulu && !useLocalTime ) { 1450 if (zulu && !useLocalTime ) {
1448 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); 1451 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60);
1449 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", 1452 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ",
1450 tmpDT.date().year(), tmpDT.date().month(), 1453 tmpDT.date().year(), tmpDT.date().month(),
1451 tmpDT.date().day(), tmpDT.time().hour(), 1454 tmpDT.date().day(), tmpDT.time().hour(),
1452 tmpDT.time().minute(), tmpDT.time().second()); 1455 tmpDT.time().minute(), tmpDT.time().second());
1453 } else { 1456 } else {
1454 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", 1457 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
1455 qdt.date().year(), qdt.date().month(), 1458 qdt.date().year(), qdt.date().month(),
1456 qdt.date().day(), qdt.time().hour(), 1459 qdt.date().day(), qdt.time().hour(),
1457 qdt.time().minute(), qdt.time().second()); 1460 qdt.time().minute(), qdt.time().second());
1458 } 1461 }
1459 return tmpStr; 1462 return tmpStr;
1460} 1463}
1461 1464
1462QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) 1465QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1463{ 1466{
1464 QDate tmpDate; 1467 QDate tmpDate;
1465 QTime tmpTime; 1468 QTime tmpTime;
1466 QString tmpStr; 1469 QString tmpStr;
1467 int year, month, day, hour, minute, second; 1470 int year, month, day, hour, minute, second;
1468 1471
1469 tmpStr = dtStr; 1472 tmpStr = dtStr;
1470 year = tmpStr.left(4).toInt(); 1473 year = tmpStr.left(4).toInt();
1471 month = tmpStr.mid(4,2).toInt(); 1474 month = tmpStr.mid(4,2).toInt();
1472 day = tmpStr.mid(6,2).toInt(); 1475 day = tmpStr.mid(6,2).toInt();
1473 hour = tmpStr.mid(9,2).toInt(); 1476 hour = tmpStr.mid(9,2).toInt();
1474 minute = tmpStr.mid(11,2).toInt(); 1477 minute = tmpStr.mid(11,2).toInt();
1475 second = tmpStr.mid(13,2).toInt(); 1478 second = tmpStr.mid(13,2).toInt();
1476 tmpDate.setYMD(year, month, day); 1479 tmpDate.setYMD(year, month, day);
1477 tmpTime.setHMS(hour, minute, second); 1480 tmpTime.setHMS(hour, minute, second);
1478 1481
1479 ASSERT(tmpDate.isValid()); 1482 ASSERT(tmpDate.isValid());
1480 ASSERT(tmpTime.isValid()); 1483 ASSERT(tmpTime.isValid());
1481 QDateTime tmpDT(tmpDate, tmpTime); 1484 QDateTime tmpDT(tmpDate, tmpTime);
1482 // correct for GMT if string is in Zulu format 1485 // correct for GMT if string is in Zulu format
1483 if (dtStr.at(dtStr.length()-1) == 'Z') 1486 if (dtStr.at(dtStr.length()-1) == 'Z')
1484 tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone()); 1487 tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone());
1485 return tmpDT; 1488 return tmpDT;
1486} 1489}
1487 1490
1488QDate VCalFormat::ISOToQDate(const QString &dateStr) 1491QDate VCalFormat::ISOToQDate(const QString &dateStr)
1489{ 1492{
1490 int year, month, day; 1493 int year, month, day;
1491 1494
1492 year = dateStr.left(4).toInt(); 1495 year = dateStr.left(4).toInt();
1493 month = dateStr.mid(4,2).toInt(); 1496 month = dateStr.mid(4,2).toInt();
1494 day = dateStr.mid(6,2).toInt(); 1497 day = dateStr.mid(6,2).toInt();
1495 1498
1496 return(QDate(year, month, day)); 1499 return(QDate(year, month, day));
1497} 1500}
1498 1501
1499// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. 1502// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
1500// and break it down from it's tree-like format into the dictionary format 1503// and break it down from it's tree-like format into the dictionary format
1501// that is used internally in the VCalFormat. 1504// that is used internally in the VCalFormat.
1502void VCalFormat::populate(VObject *vcal) 1505void VCalFormat::populate(VObject *vcal)
1503{ 1506{
1504 // this function will populate the caldict dictionary and other event 1507 // this function will populate the caldict dictionary and other event
1505 // lists. It turns vevents into Events and then inserts them. 1508 // lists. It turns vevents into Events and then inserts them.
1506 1509
1507 VObjectIterator i; 1510 VObjectIterator i;
1508 VObject *curVO, *curVOProp; 1511 VObject *curVO, *curVOProp;
1509 Event *anEvent; 1512 Event *anEvent;
1510 1513
1511 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { 1514 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) {
1512 char *methodType = 0; 1515 char *methodType = 0;
1513 methodType = fakeCString(vObjectUStringZValue(curVO)); 1516 methodType = fakeCString(vObjectUStringZValue(curVO));
1514 kdDebug() << "This calendar is an iTIP transaction of type '" 1517 kdDebug() << "This calendar is an iTIP transaction of type '"
1515 << methodType << "'" << endl; 1518 << methodType << "'" << endl;
1516 delete methodType; 1519 delete methodType;
1517 } 1520 }
1518 1521
1519 // warn the user that we might have trouble reading non-known calendar. 1522 // warn the user that we might have trouble reading non-known calendar.
1520 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { 1523 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) {
1521 char *s = fakeCString(vObjectUStringZValue(curVO)); 1524 char *s = fakeCString(vObjectUStringZValue(curVO));
1522 if (strcmp(productId().local8Bit(), s) != 0) 1525 if (strcmp(productId().local8Bit(), s) != 0)
1523 kdDebug() << "This vCalendar file was not created by KOrganizer " 1526 kdDebug() << "This vCalendar file was not created by KOrganizer "
1524 "or any other product we support. Loading anyway..." << endl; 1527 "or any other product we support. Loading anyway..." << endl;
1525 mLoadedProductId = s; 1528 mLoadedProductId = s;
1526 deleteStr(s); 1529 deleteStr(s);
1527 } 1530 }
1528 1531
1529 // warn the user we might have trouble reading this unknown version. 1532 // warn the user we might have trouble reading this unknown version.
1530 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { 1533 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
1531 char *s = fakeCString(vObjectUStringZValue(curVO)); 1534 char *s = fakeCString(vObjectUStringZValue(curVO));
1532 if (strcmp(_VCAL_VERSION, s) != 0) 1535 if (strcmp(_VCAL_VERSION, s) != 0)
1533 kdDebug() << "This vCalendar file has version " << s 1536 kdDebug() << "This vCalendar file has version " << s
1534 << "We only support " << _VCAL_VERSION << endl; 1537 << "We only support " << _VCAL_VERSION << endl;
1535 deleteStr(s); 1538 deleteStr(s);
1536 } 1539 }
1537 1540
1538 // set the time zone 1541 // set the time zone
1539 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { 1542 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
1540 char *s = fakeCString(vObjectUStringZValue(curVO)); 1543 char *s = fakeCString(vObjectUStringZValue(curVO));
1541 mCalendar->setTimeZone(s); 1544 mCalendar->setTimeZone(s);
1542 deleteStr(s); 1545 deleteStr(s);
1543 } 1546 }
1544 1547
1545 1548
1546 // Store all events with a relatedTo property in a list for post-processing 1549 // Store all events with a relatedTo property in a list for post-processing
1547 mEventsRelate.clear(); 1550 mEventsRelate.clear();
1548 mTodosRelate.clear(); 1551 mTodosRelate.clear();
1549 1552
1550 initPropIterator(&i, vcal); 1553 initPropIterator(&i, vcal);
1551 1554
1552 // go through all the vobjects in the vcal 1555 // go through all the vobjects in the vcal
1553 while (moreIteration(&i)) { 1556 while (moreIteration(&i)) {
1554 curVO = nextVObject(&i); 1557 curVO = nextVObject(&i);
1555 1558
1556 /************************************************************************/ 1559 /************************************************************************/
1557 1560
1558 // now, check to see that the object is an event or todo. 1561 // now, check to see that the object is an event or todo.
1559 if (strcmp(vObjectName(curVO), VCEventProp) == 0) { 1562 if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
1560 1563
1561 if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { 1564 if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) {
1562 char *s; 1565 char *s;
1563 s = fakeCString(vObjectUStringZValue(curVOProp)); 1566 s = fakeCString(vObjectUStringZValue(curVOProp));
1564 // check to see if event was deleted by the kpilot conduit 1567 // check to see if event was deleted by the kpilot conduit
1565 if (atoi(s) == Event::SYNCDEL) { 1568 if (atoi(s) == Event::SYNCDEL) {
1566 deleteStr(s); 1569 deleteStr(s);
1567 kdDebug(5800) << "skipping pilot-deleted event" << endl; 1570 kdDebug(5800) << "skipping pilot-deleted event" << endl;
1568 goto SKIP; 1571 goto SKIP;
1569 } 1572 }
1570 deleteStr(s); 1573 deleteStr(s);
1571 } 1574 }
1572 1575
1573 // this code checks to see if we are trying to read in an event 1576 // this code checks to see if we are trying to read in an event
1574 // that we already find to be in the calendar. If we find this 1577 // that we already find to be in the calendar. If we find this
1575 // to be the case, we skip the event. 1578 // to be the case, we skip the event.
1576 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { 1579 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
1577 char *s = fakeCString(vObjectUStringZValue(curVOProp)); 1580 char *s = fakeCString(vObjectUStringZValue(curVOProp));
1578 QString tmpStr(s); 1581 QString tmpStr(s);
1579 deleteStr(s); 1582 deleteStr(s);
1580 1583
1581 if (mCalendar->event(tmpStr)) { 1584 if (mCalendar->event(tmpStr)) {
1582 goto SKIP; 1585 goto SKIP;
1583 } 1586 }
1584 if (mCalendar->todo(tmpStr)) { 1587 if (mCalendar->todo(tmpStr)) {
1585 goto SKIP; 1588 goto SKIP;
1586 } 1589 }
1587 } 1590 }
1588 1591
1589 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && 1592 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
1590 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { 1593 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
1591 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; 1594 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
1592 goto SKIP; 1595 goto SKIP;
1593 } 1596 }
1594 1597
1595 anEvent = VEventToEvent(curVO); 1598 anEvent = VEventToEvent(curVO);
1596 // we now use addEvent instead of insertEvent so that the 1599 // we now use addEvent instead of insertEvent so that the
1597 // signal/slot get connected. 1600 // signal/slot get connected.
1598 if (anEvent) { 1601 if (anEvent) {
1599 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { 1602 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) {
1600 kdDebug() << "VCalFormat::populate(): Event has invalid dates." 1603 kdDebug() << "VCalFormat::populate(): Event has invalid dates."
1601 << endl; 1604 << endl;
1602 } else { 1605 } else {
1603 mCalendar->addEvent(anEvent); 1606 mCalendar->addEvent(anEvent);
1604 } 1607 }
1605 } else { 1608 } else {
1606 // some sort of error must have occurred while in translation. 1609 // some sort of error must have occurred while in translation.
1607 goto SKIP; 1610 goto SKIP;
1608 } 1611 }
1609 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { 1612 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
1610 Todo *aTodo = VTodoToEvent(curVO); 1613 Todo *aTodo = VTodoToEvent(curVO);
1611 mCalendar->addTodo(aTodo); 1614 mCalendar->addTodo(aTodo);
1612 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || 1615 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
1613 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || 1616 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
1614 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { 1617 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
1615 // do nothing, we know these properties and we want to skip them. 1618 // do nothing, we know these properties and we want to skip them.
1616 // we have either already processed them or are ignoring them. 1619 // we have either already processed them or are ignoring them.
1617 ; 1620 ;
1618 } else { 1621 } else {
1619 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; 1622 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl;
1620 } 1623 }
1621 SKIP: 1624 SKIP:
1622 ; 1625 ;
1623 } // while 1626 } // while
1624 1627
1625 // Post-Process list of events with relations, put Event objects in relation 1628 // Post-Process list of events with relations, put Event objects in relation
1626 Event *ev; 1629 Event *ev;
1627 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { 1630 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
1628 ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); 1631 ev->setRelatedTo(mCalendar->event(ev->relatedToUid()));
1629 } 1632 }
1630 Todo *todo; 1633 Todo *todo;
1631 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { 1634 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
1632 todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); 1635 todo->setRelatedTo(mCalendar->todo(todo->relatedToUid()));
1633 } 1636 }
1634} 1637}
1635 1638
1636const char *VCalFormat::dayFromNum(int day) 1639const char *VCalFormat::dayFromNum(int day)
1637{ 1640{
1638 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; 1641 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " };
1639 1642
1640 return days[day]; 1643 return days[day];
1641} 1644}
1642 1645
1643int VCalFormat::numFromDay(const QString &day) 1646int VCalFormat::numFromDay(const QString &day)
1644{ 1647{
1645 if (day == "MO ") return 0; 1648 if (day == "MO ") return 0;
1646 if (day == "TU ") return 1; 1649 if (day == "TU ") return 1;
1647 if (day == "WE ") return 2; 1650 if (day == "WE ") return 2;
1648 if (day == "TH ") return 3; 1651 if (day == "TH ") return 3;
1649 if (day == "FR ") return 4; 1652 if (day == "FR ") return 4;
1650 if (day == "SA ") return 5; 1653 if (day == "SA ") return 5;
1651 if (day == "SU ") return 6; 1654 if (day == "SU ") return 6;
1652 1655
1653 return -1; // something bad happened. :) 1656 return -1; // something bad happened. :)
1654} 1657}
1655 1658
1656Attendee::PartStat VCalFormat::readStatus(const char *s) const 1659Attendee::PartStat VCalFormat::readStatus(const char *s) const
1657{ 1660{
1658 QString statStr = s; 1661 QString statStr = s;
1659 statStr = statStr.upper(); 1662 statStr = statStr.upper();
1660 Attendee::PartStat status; 1663 Attendee::PartStat status;
1661 1664
1662 if (statStr == "X-ACTION") 1665 if (statStr == "X-ACTION")
1663 status = Attendee::NeedsAction; 1666 status = Attendee::NeedsAction;
1664 else if (statStr == "NEEDS ACTION") 1667 else if (statStr == "NEEDS ACTION")
1665 status = Attendee::NeedsAction; 1668 status = Attendee::NeedsAction;
1666 else if (statStr== "ACCEPTED") 1669 else if (statStr== "ACCEPTED")
1667 status = Attendee::Accepted; 1670 status = Attendee::Accepted;
1668 else if (statStr== "SENT") 1671 else if (statStr== "SENT")
1669 status = Attendee::NeedsAction; 1672 status = Attendee::NeedsAction;
1670 else if (statStr== "TENTATIVE") 1673 else if (statStr== "TENTATIVE")
1671 status = Attendee::Tentative; 1674 status = Attendee::Tentative;
1672 else if (statStr== "CONFIRMED") 1675 else if (statStr== "CONFIRMED")
1673 status = Attendee::Accepted; 1676 status = Attendee::Accepted;
1674 else if (statStr== "DECLINED") 1677 else if (statStr== "DECLINED")
1675 status = Attendee::Declined; 1678 status = Attendee::Declined;
1676 else if (statStr== "COMPLETED") 1679 else if (statStr== "COMPLETED")
1677 status = Attendee::Completed; 1680 status = Attendee::Completed;
1678 else if (statStr== "DELEGATED") 1681 else if (statStr== "DELEGATED")
1679 status = Attendee::Delegated; 1682 status = Attendee::Delegated;
1680 else { 1683 else {
1681 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; 1684 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl;
1682 status = Attendee::NeedsAction; 1685 status = Attendee::NeedsAction;
1683 } 1686 }
1684 1687
1685 return status; 1688 return status;
1686} 1689}
1687 1690
1688QCString VCalFormat::writeStatus(Attendee::PartStat status) const 1691QCString VCalFormat::writeStatus(Attendee::PartStat status) const
1689{ 1692{
1690 switch(status) { 1693 switch(status) {
1691 default: 1694 default:
1692 case Attendee::NeedsAction: 1695 case Attendee::NeedsAction:
1693 return "NEEDS ACTION"; 1696 return "NEEDS ACTION";
1694 break; 1697 break;
1695 case Attendee::Accepted: 1698 case Attendee::Accepted:
1696 return "ACCEPTED"; 1699 return "ACCEPTED";
1697 break; 1700 break;
1698 case Attendee::Declined: 1701 case Attendee::Declined:
1699 return "DECLINED"; 1702 return "DECLINED";
1700 break; 1703 break;
1701 case Attendee::Tentative: 1704 case Attendee::Tentative:
1702 return "TENTATIVE"; 1705 return "TENTATIVE";
1703 break; 1706 break;
1704 case Attendee::Delegated: 1707 case Attendee::Delegated:
1705 return "DELEGATED"; 1708 return "DELEGATED";
1706 break; 1709 break;
1707 case Attendee::Completed: 1710 case Attendee::Completed:
1708 return "COMPLETED"; 1711 return "COMPLETED";
1709 break; 1712 break;
1710 case Attendee::InProcess: 1713 case Attendee::InProcess:
1711 return "NEEDS ACTION"; 1714 return "NEEDS ACTION";
1712 break; 1715 break;
1713 } 1716 }
1714} 1717}
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
29class VObject; 29class VObject;
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the vCalendar format. It provides methods for 34 This class implements the vCalendar format. It provides methods for
35 loading/saving/converting vCalendar format data into the internal KOrganizer 35 loading/saving/converting vCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 36 representation as Calendar and Events.
37 37
38 @short vCalendar format implementation 38 @short vCalendar format implementation
39*/ 39*/
40class VCalFormat : public CalFormat { 40class VCalFormat : public CalFormat {
41 public: 41 public:
42 VCalFormat(); 42 VCalFormat();
43 virtual ~VCalFormat(); 43 virtual ~VCalFormat();
44 44
45 /** loads a calendar on disk in vCalendar format into the current calendar. 45 /** loads a calendar on disk in vCalendar format into the current calendar.
46 * any information already present is lost. Returns TRUE if successful, 46 * any information already present is lost. Returns TRUE if successful,
47 * else returns FALSE. 47 * else returns FALSE.
48 * @param fileName the name of the calendar on disk. 48 * @param fileName the name of the calendar on disk.
49 */ 49 */
50 bool load(Calendar *,const QString &fileName); 50 bool load(Calendar *,const QString &fileName );
51 /** writes out the calendar to disk in vCalendar format. Returns true if 51 /** writes out the calendar to disk in vCalendar format. Returns true if
52 * successful and false on error. 52 * successful and false on error.
53 * @param fileName the name of the file 53 * @param fileName the name of the file
54 */ 54 */
55 bool save(Calendar *,const QString &fileName); 55 bool save(Calendar *,const QString &fileName );
56 56
57 /** 57 /**
58 Parse string and populate calendar with that information. 58 Parse string and populate calendar with that information.
59 */ 59 */
60 bool fromString( Calendar *, const QString & ); 60 bool fromString( Calendar *, const QString & );
61 /** 61 /**
62 Return calendar information as string. 62 Return calendar information as string.
63 */ 63 */
64 void setLocalTime ( bool );
64 QString toString( Calendar * ); 65 QString toString( Calendar * );
65 QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); 66 QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true );
66 QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); 67 QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true );
67 68
68 protected: 69 protected:
69 /** translates a VObject of the TODO type into a Event */ 70 /** translates a VObject of the TODO type into a Event */
70 Todo *VTodoToEvent(VObject *vtodo); 71 Todo *VTodoToEvent(VObject *vtodo);
71 /** translates a VObject into a Event and returns a pointer to it. */ 72 /** translates a VObject into a Event and returns a pointer to it. */
72 Event *VEventToEvent(VObject *vevent); 73 Event *VEventToEvent(VObject *vevent);
73 /** translate a Event into a VTodo-type VObject and return pointer */ 74 /** translate a Event into a VTodo-type VObject and return pointer */
74 VObject *eventToVTodo(const Todo *anEvent); 75 VObject *eventToVTodo(const Todo *anEvent);
75 /** translate a Event into a VObject and returns a pointer to it. */ 76 /** translate a Event into a VObject and returns a pointer to it. */
76 VObject* eventToVEvent(const Event *anEvent); 77 VObject* eventToVEvent(const Event *anEvent);
77 78
78 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ 79 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
79 QString qDateToISO(const QDate &); 80 QString qDateToISO(const QDate &);
80 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ 81 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */
81 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); 82 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE);
82 /** takes a string in the format YYYYMMDDTHHMMSS and returns a 83 /** takes a string in the format YYYYMMDDTHHMMSS and returns a
83 * valid QDateTime. */ 84 * valid QDateTime. */
84 QDateTime ISOToQDateTime(const QString & dtStr); 85 QDateTime ISOToQDateTime(const QString & dtStr);
85 /** takes a string in the format YYYYMMDD and returns a 86 /** takes a string in the format YYYYMMDD and returns a
86 * valid QDate. */ 87 * valid QDate. */
87 QDate ISOToQDate(const QString & dtStr); 88 QDate ISOToQDate(const QString & dtStr);
88 /** takes a vCalendar tree of VObjects, and puts all of them that have 89 /** takes a vCalendar tree of VObjects, and puts all of them that have
89 * the "event" property into the dictionary, todos in the todo-list, etc. */ 90 * the "event" property into the dictionary, todos in the todo-list, etc. */
90 void populate(VObject *vcal); 91 void populate(VObject *vcal);
91 92
92 /** takes a number 0 - 6 and returns the two letter string of that day, 93 /** takes a number 0 - 6 and returns the two letter string of that day,
93 * i.e. MO, TU, WE, etc. */ 94 * i.e. MO, TU, WE, etc. */
94 const char *dayFromNum(int day); 95 const char *dayFromNum(int day);
95 /** the reverse of the above function. */ 96 /** the reverse of the above function. */
96 int numFromDay(const QString &day); 97 int numFromDay(const QString &day);
97 98
98 Attendee::PartStat readStatus(const char *s) const; 99 Attendee::PartStat readStatus(const char *s) const;
99 QCString writeStatus(Attendee::PartStat status) const; 100 QCString writeStatus(Attendee::PartStat status) const;
100 101
101 private: 102 private:
102 Calendar *mCalendar; 103 Calendar *mCalendar;
103 bool useLocalTime; 104 bool useLocalTime;
104 105
105 QPtrList<Event> mEventsRelate; // events with relations 106 QPtrList<Event> mEventsRelate; // events with relations
106 QPtrList<Todo> mTodosRelate; // todos with relations 107 QPtrList<Todo> mTodosRelate; // todos with relations
107}; 108};
108 109
109} 110}
110 111
111#endif 112#endif