author | zautrix <zautrix> | 2004-12-04 04:53:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-04 04:53:22 (UTC) |
commit | 7828f46413766ee5db72dc9bd457eac0868f0646 (patch) (unidiff) | |
tree | d3da09120bdef2b498f836c5b1b97a5b2aa2da99 | |
parent | 967f7c879d06961dd7a25d019380c521f7a84792 (diff) | |
download | kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.zip kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.tar.gz kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.tar.bz2 |
fixed some bugs
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 22 | ||||
-rw-r--r-- | kmicromail/libetpan/maildir/maildir.c | 25 | ||||
-rw-r--r-- | kmicromail/libetpan/mh/mailmh.c | 12 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 2 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 7 | ||||
-rw-r--r-- | version | 2 |
8 files changed, 60 insertions, 15 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 4905631..eb7cf13 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,66 +1,88 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 1.9.14 ************ | ||
4 | |||
5 | Fixed some problems with the dialog sizes when switching | ||
6 | portrait/landscape mode on 640x480 PDA display. | ||
7 | |||
8 | Fixed some other small bugs. | ||
9 | |||
10 | Fixed an ugly bug in KOpieMail: | ||
11 | KOpieMail was not able to write files (mails) to MSDOS file system, | ||
12 | like on an usual preformatted SD card. That should work now. | ||
13 | To save your mail data on the Sd card do the following: | ||
14 | Create a dir on the SD card: | ||
15 | mkdir /mnt/card/localmail | ||
16 | Go to your home dir: | ||
17 | cd | ||
18 | Go to kopiemail data storage dir: | ||
19 | cd kdepim/apps/kopiemail | ||
20 | Create a symlink to the SD card: | ||
21 | ls -s /mnt/card/localmail | ||
22 | Now KOpieMail will store all mails on the SD card. | ||
23 | |||
24 | |||
3 | ********** VERSION 1.9.13 ************ | 25 | ********** VERSION 1.9.13 ************ |
4 | 26 | ||
5 | Fixed nasty PwM/Pi file reading bug, when | 27 | Fixed nasty PwM/Pi file reading bug, when |
6 | the used hash algo of file is different then the global | 28 | the used hash algo of file is different then the global |
7 | hash algo. | 29 | hash algo. |
8 | 30 | ||
9 | Added KA/Pi support for opie mailit mailapplication. | 31 | Added KA/Pi support for opie mailit mailapplication. |
10 | 32 | ||
11 | Fixed some bugs in OM/Pi. | 33 | Fixed some bugs in OM/Pi. |
12 | Now character conversion tables are available for the Zaurus | 34 | Now character conversion tables are available for the Zaurus |
13 | to make OM/Pi working properly. | 35 | to make OM/Pi working properly. |
14 | To get the character conversion in OM/Pi working, please download | 36 | To get the character conversion in OM/Pi working, please download |
15 | at the sourceforge project site the package | 37 | at the sourceforge project site the package |
16 | sr-character-conversion_SharpROM_arm.ipk.zip | 38 | sr-character-conversion_SharpROM_arm.ipk.zip |
17 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) | 39 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) |
18 | from the section "general files for KDE/Pim" | 40 | from the section "general files for KDE/Pim" |
19 | Instructions how to install this package are in a ReadMe in this file. | 41 | Instructions how to install this package are in a ReadMe in this file. |
20 | 42 | ||
21 | 43 | ||
22 | Fixed the orientation change problem in KA/Pi when switching | 44 | Fixed the orientation change problem in KA/Pi when switching |
23 | portrait/landscape mode. | 45 | portrait/landscape mode. |
24 | 46 | ||
25 | French translation available for KA/Pi and OM/Pi. | 47 | French translation available for KA/Pi and OM/Pi. |
26 | 48 | ||
27 | Fixed some problems with categories in KO/Pi in DTM sync. | 49 | Fixed some problems with categories in KO/Pi in DTM sync. |
28 | 50 | ||
29 | Added selection dialog for export to phone in KA/Pi. | 51 | Added selection dialog for export to phone in KA/Pi. |
30 | 52 | ||
31 | If in KO/Pi is an attendee selected to add to a meeting and this | 53 | If in KO/Pi is an attendee selected to add to a meeting and this |
32 | attendee is already in the list of attendees, this person is not added | 54 | attendee is already in the list of attendees, this person is not added |
33 | again. | 55 | again. |
34 | 56 | ||
35 | Some menu cleanup in KA/Pi. | 57 | Some menu cleanup in KA/Pi. |
36 | 58 | ||
37 | ********** VERSION 1.9.12 ************ | 59 | ********** VERSION 1.9.12 ************ |
38 | 60 | ||
39 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. | 61 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. |
40 | 62 | ||
41 | Bugfix: Licence file is now shown again. | 63 | Bugfix: Licence file is now shown again. |
42 | 64 | ||
43 | OM/Pi now supports Unicode (utf8 charset). | 65 | OM/Pi now supports Unicode (utf8 charset). |
44 | Fixed some bugs in OM/Pi. | 66 | Fixed some bugs in OM/Pi. |
45 | 67 | ||
46 | KA/Pi has more German translation. | 68 | KA/Pi has more German translation. |
47 | 69 | ||
48 | 70 | ||
49 | ********** VERSION 1.9.11 ************ | 71 | ********** VERSION 1.9.11 ************ |
50 | 72 | ||
51 | Fixed several problems in PWM/Pi, like | 73 | Fixed several problems in PWM/Pi, like |
52 | asking the user, if unsaved changed are pending | 74 | asking the user, if unsaved changed are pending |
53 | when closing the app. | 75 | when closing the app. |
54 | And PwM/Pi handles now different texts for the | 76 | And PwM/Pi handles now different texts for the |
55 | fields Description, Username, Password, configurable per category. | 77 | fields Description, Username, Password, configurable per category. |
56 | 78 | ||
57 | Fixed a crash in KO/Pi , when importing/loading vcs files | 79 | Fixed a crash in KO/Pi , when importing/loading vcs files |
58 | which have an entry with an attendee with state: | 80 | which have an entry with an attendee with state: |
59 | NEEDS ACTION | 81 | NEEDS ACTION |
60 | 82 | ||
61 | Fixed some problems in the German translation of OM/Pi, | 83 | Fixed some problems in the German translation of OM/Pi, |
62 | which makes some dialogs not fitting on the screen | 84 | which makes some dialogs not fitting on the screen |
63 | of the Z 5500. | 85 | of the Z 5500. |
64 | 86 | ||
65 | Fixed Qtopia crash, when disabling/deinstalling | 87 | Fixed Qtopia crash, when disabling/deinstalling |
66 | KO/Pi alarm applet. | 88 | KO/Pi alarm applet. |
diff --git a/kmicromail/libetpan/maildir/maildir.c b/kmicromail/libetpan/maildir/maildir.c index 0e038b1..1ef0b7a 100644 --- a/kmicromail/libetpan/maildir/maildir.c +++ b/kmicromail/libetpan/maildir/maildir.c | |||
@@ -47,147 +47,152 @@ | |||
47 | 47 | ||
48 | #ifdef LIBETPAN_SYSTEM_BASENAME | 48 | #ifdef LIBETPAN_SYSTEM_BASENAME |
49 | #include <libgen.h> | 49 | #include <libgen.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | /* | 52 | /* |
53 | We suppose the maildir mailbox remains on one unique filesystem. | 53 | We suppose the maildir mailbox remains on one unique filesystem. |
54 | */ | 54 | */ |
55 | 55 | ||
56 | struct maildir * maildir_new(const char * path) | 56 | struct maildir * maildir_new(const char * path) |
57 | { | 57 | { |
58 | struct maildir * md; | 58 | struct maildir * md; |
59 | 59 | ||
60 | md = malloc(sizeof(* md)); | 60 | md = malloc(sizeof(* md)); |
61 | if (md == NULL) | 61 | if (md == NULL) |
62 | goto err; | 62 | goto err; |
63 | 63 | ||
64 | md->mdir_counter = 0; | 64 | md->mdir_counter = 0; |
65 | md->mdir_mtime_new = (time_t) -1; | 65 | md->mdir_mtime_new = (time_t) -1; |
66 | md->mdir_mtime_cur = (time_t) -1; | 66 | md->mdir_mtime_cur = (time_t) -1; |
67 | 67 | ||
68 | md->mdir_pid = getpid(); | 68 | md->mdir_pid = getpid(); |
69 | gethostname(md->mdir_hostname, sizeof(md->mdir_hostname)); | 69 | gethostname(md->mdir_hostname, sizeof(md->mdir_hostname)); |
70 | strncpy(md->mdir_path, path, sizeof(md->mdir_path)); | 70 | strncpy(md->mdir_path, path, sizeof(md->mdir_path)); |
71 | md->mdir_path[PATH_MAX - 1] = '\0'; | 71 | md->mdir_path[PATH_MAX - 1] = '\0'; |
72 | 72 | ||
73 | md->mdir_msg_list = carray_new(128); | 73 | md->mdir_msg_list = carray_new(128); |
74 | if (md->mdir_msg_list == NULL) | 74 | if (md->mdir_msg_list == NULL) |
75 | goto free; | 75 | goto free; |
76 | 76 | ||
77 | md->mdir_msg_hash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYNONE); | 77 | md->mdir_msg_hash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYNONE); |
78 | if (md->mdir_msg_hash == NULL) | 78 | if (md->mdir_msg_hash == NULL) |
79 | goto free_msg_list; | 79 | goto free_msg_list; |
80 | 80 | ||
81 | return md; | 81 | return md; |
82 | 82 | ||
83 | free_msg_list: | 83 | free_msg_list: |
84 | carray_free(md->mdir_msg_list); | 84 | carray_free(md->mdir_msg_list); |
85 | free: | 85 | free: |
86 | free(md); | 86 | free(md); |
87 | err: | 87 | err: |
88 | return NULL; | 88 | return NULL; |
89 | } | 89 | } |
90 | 90 | ||
91 | static void maildir_flush(struct maildir * md, int msg_new); | 91 | static void maildir_flush(struct maildir * md, int msg_new); |
92 | 92 | ||
93 | void maildir_free(struct maildir * md) | 93 | void maildir_free(struct maildir * md) |
94 | { | 94 | { |
95 | maildir_flush(md, 0); | 95 | maildir_flush(md, 0); |
96 | maildir_flush(md, 1); | 96 | maildir_flush(md, 1); |
97 | chash_free(md->mdir_msg_hash); | 97 | chash_free(md->mdir_msg_hash); |
98 | carray_free(md->mdir_msg_list); | 98 | carray_free(md->mdir_msg_list); |
99 | free(md); | 99 | free(md); |
100 | } | 100 | } |
101 | 101 | ||
102 | #define MAX_TRY_ALLOC 32 | 102 | #define MAX_TRY_ALLOC 32 |
103 | 103 | ||
104 | static char * maildir_get_new_message_filename(struct maildir * md, | 104 | static char * maildir_get_new_message_filename(struct maildir * md, |
105 | char * tmpfile) | 105 | char * tmpfile) |
106 | { | 106 | { |
107 | char filename[PATH_MAX]; | 107 | char filename[PATH_MAX]; |
108 | char basename[PATH_MAX]; | 108 | char basename[PATH_MAX]; |
109 | int k; | 109 | int k; |
110 | time_t now; | 110 | time_t now; |
111 | 111 | struct stat f_stat; | |
112 | now = time(NULL); | 112 | now = time(NULL); |
113 | k = 0; | 113 | k = 0; |
114 | |||
115 | fprintf(stderr,"maildir_get_new_message_filename: %s \n", tmpfile); | ||
114 | while (k < MAX_TRY_ALLOC) { | 116 | while (k < MAX_TRY_ALLOC) { |
115 | snprintf(basename, sizeof(basename), "%lu.%u_%u.%s", | 117 | snprintf(basename, sizeof(basename), "%lu.%u_%u.%s", |
116 | (unsigned long) now, md->mdir_pid, md->mdir_counter, md->mdir_hostname); | 118 | (unsigned long) now, md->mdir_pid, md->mdir_counter, md->mdir_hostname); |
117 | snprintf(filename, sizeof(filename), "%s/tmp/%s", | 119 | snprintf(filename, sizeof(filename), "%s/tmp/%s", |
118 | md->mdir_path, basename); | 120 | md->mdir_path, basename); |
119 | 121 | fprintf(stderr,"filename %s \n", filename); | |
120 | if (link(tmpfile, filename) == 0) { | 122 | // LR changed following lines |
123 | if ( stat( filename, &f_stat ) == -1 ) { | ||
124 | //if (link(tmpfile, filename) == 0) { | ||
121 | char * dup_filename; | 125 | char * dup_filename; |
122 | 126 | ||
123 | dup_filename = strdup(filename); | 127 | dup_filename = strdup(filename); |
124 | if (dup_filename == NULL) { | 128 | if (dup_filename == NULL) { |
125 | unlink(filename); | 129 | //unlink(filename); |
126 | return NULL; | 130 | return NULL; |
127 | } | 131 | } |
128 | 132 | fprintf(stderr,"filename %s %s \n", tmpfile,dup_filename); | |
129 | unlink(tmpfile); | 133 | //unlink(tmpfile); |
134 | rename (tmpfile,dup_filename ); | ||
130 | md->mdir_counter ++; | 135 | md->mdir_counter ++; |
131 | 136 | ||
132 | return dup_filename; | 137 | return dup_filename; |
133 | } | 138 | } |
134 | 139 | ||
135 | md->mdir_counter ++; | 140 | md->mdir_counter ++; |
136 | k ++; | 141 | k ++; |
137 | } | 142 | } |
138 | 143 | ||
139 | return NULL; | 144 | return NULL; |
140 | } | 145 | } |
141 | 146 | ||
142 | 147 | ||
143 | static void msg_free(struct maildir_msg * msg) | 148 | static void msg_free(struct maildir_msg * msg) |
144 | { | 149 | { |
145 | free(msg->msg_uid); | 150 | free(msg->msg_uid); |
146 | free(msg->msg_filename); | 151 | free(msg->msg_filename); |
147 | free(msg); | 152 | free(msg); |
148 | } | 153 | } |
149 | 154 | ||
150 | /* | 155 | /* |
151 | msg_new() | 156 | msg_new() |
152 | 157 | ||
153 | filename is given without path | 158 | filename is given without path |
154 | */ | 159 | */ |
155 | 160 | ||
156 | static struct maildir_msg * msg_new(char * filename, int new_msg) | 161 | static struct maildir_msg * msg_new(char * filename, int new_msg) |
157 | { | 162 | { |
158 | struct maildir_msg * msg; | 163 | struct maildir_msg * msg; |
159 | char * p; | 164 | char * p; |
160 | int flags; | 165 | int flags; |
161 | size_t uid_len; | 166 | size_t uid_len; |
162 | char * begin_uid; | 167 | char * begin_uid; |
163 | 168 | ||
164 | /* name of file : xxx-xxx_xxx-xxx:2,SRFT */ | 169 | /* name of file : xxx-xxx_xxx-xxx:2,SRFT */ |
165 | 170 | ||
166 | msg = malloc(sizeof(* msg)); | 171 | msg = malloc(sizeof(* msg)); |
167 | if (msg == NULL) | 172 | if (msg == NULL) |
168 | goto err; | 173 | goto err; |
169 | 174 | ||
170 | msg->msg_filename = strdup(filename); | 175 | msg->msg_filename = strdup(filename); |
171 | if (msg->msg_filename == NULL) | 176 | if (msg->msg_filename == NULL) |
172 | goto free; | 177 | goto free; |
173 | 178 | ||
174 | begin_uid = filename; | 179 | begin_uid = filename; |
175 | 180 | ||
176 | uid_len = strlen(begin_uid); | 181 | uid_len = strlen(begin_uid); |
177 | 182 | ||
178 | flags = 0; | 183 | flags = 0; |
179 | p = strstr(filename, ":2,"); | 184 | p = strstr(filename, ":2,"); |
180 | if (p != NULL) { | 185 | if (p != NULL) { |
181 | uid_len = p - begin_uid; | 186 | uid_len = p - begin_uid; |
182 | 187 | ||
183 | p += 3; | 188 | p += 3; |
184 | 189 | ||
185 | /* parse flags */ | 190 | /* parse flags */ |
186 | while (* p != '\0') { | 191 | while (* p != '\0') { |
187 | switch (* p) { | 192 | switch (* p) { |
188 | case 'S': | 193 | case 'S': |
189 | flags |= MAILDIR_FLAG_SEEN; | 194 | flags |= MAILDIR_FLAG_SEEN; |
190 | break; | 195 | break; |
191 | case 'R': | 196 | case 'R': |
192 | flags |= MAILDIR_FLAG_REPLIED; | 197 | flags |= MAILDIR_FLAG_REPLIED; |
193 | break; | 198 | break; |
@@ -211,128 +216,129 @@ static struct maildir_msg * msg_new(char * filename, int new_msg) | |||
211 | if (msg->msg_uid == NULL) | 216 | if (msg->msg_uid == NULL) |
212 | goto free_filename; | 217 | goto free_filename; |
213 | 218 | ||
214 | strncpy(msg->msg_uid, begin_uid, uid_len); | 219 | strncpy(msg->msg_uid, begin_uid, uid_len); |
215 | msg->msg_uid[uid_len] = '\0'; | 220 | msg->msg_uid[uid_len] = '\0'; |
216 | 221 | ||
217 | return msg; | 222 | return msg; |
218 | 223 | ||
219 | free_filename: | 224 | free_filename: |
220 | free(msg->msg_filename); | 225 | free(msg->msg_filename); |
221 | free: | 226 | free: |
222 | free(msg); | 227 | free(msg); |
223 | err: | 228 | err: |
224 | return NULL; | 229 | return NULL; |
225 | } | 230 | } |
226 | 231 | ||
227 | static void maildir_flush(struct maildir * md, int msg_new) | 232 | static void maildir_flush(struct maildir * md, int msg_new) |
228 | { | 233 | { |
229 | unsigned int i; | 234 | unsigned int i; |
230 | 235 | ||
231 | i = 0; | 236 | i = 0; |
232 | while (i < carray_count(md->mdir_msg_list)) { | 237 | while (i < carray_count(md->mdir_msg_list)) { |
233 | struct maildir_msg * msg; | 238 | struct maildir_msg * msg; |
234 | int delete; | 239 | int delete; |
235 | 240 | ||
236 | msg = carray_get(md->mdir_msg_list, i); | 241 | msg = carray_get(md->mdir_msg_list, i); |
237 | 242 | ||
238 | if (msg_new) { | 243 | if (msg_new) { |
239 | delete = 0; | 244 | delete = 0; |
240 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) | 245 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) |
241 | delete = 1; | 246 | delete = 1; |
242 | } | 247 | } |
243 | else { | 248 | else { |
244 | delete = 1; | 249 | delete = 1; |
245 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) | 250 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) |
246 | delete = 0; | 251 | delete = 0; |
247 | } | 252 | } |
248 | 253 | ||
249 | if (delete) { | 254 | if (delete) { |
250 | chashdatum key; | 255 | chashdatum key; |
251 | 256 | ||
252 | key.data = msg->msg_uid; | 257 | key.data = msg->msg_uid; |
253 | key.len = strlen(msg->msg_uid); | 258 | key.len = strlen(msg->msg_uid); |
254 | chash_delete(md->mdir_msg_hash, &key, NULL); | 259 | chash_delete(md->mdir_msg_hash, &key, NULL); |
255 | 260 | ||
256 | carray_delete(md->mdir_msg_list, i); | 261 | carray_delete(md->mdir_msg_list, i); |
257 | msg_free(msg); | 262 | msg_free(msg); |
258 | } | 263 | } |
259 | else { | 264 | else { |
260 | i ++; | 265 | i ++; |
261 | } | 266 | } |
262 | } | 267 | } |
263 | } | 268 | } |
264 | 269 | ||
265 | static int add_message(struct maildir * md, | 270 | static int add_message(struct maildir * md, |
266 | char * filename, int is_new) | 271 | char * filename, int is_new) |
267 | { | 272 | { |
268 | struct maildir_msg * msg; | 273 | struct maildir_msg * msg; |
269 | chashdatum key; | 274 | chashdatum key; |
270 | chashdatum value; | 275 | chashdatum value; |
271 | unsigned int i; | 276 | unsigned int i; |
272 | int res; | 277 | int res; |
273 | int r; | 278 | int r; |
274 | 279 | ||
280 | fprintf(stderr,"add_message filename: %s \n", filename); | ||
275 | msg = msg_new(filename, is_new); | 281 | msg = msg_new(filename, is_new); |
276 | if (msg == NULL) { | 282 | if (msg == NULL) { |
277 | res = MAILDIR_ERROR_MEMORY; | 283 | res = MAILDIR_ERROR_MEMORY; |
278 | goto err; | 284 | goto err; |
279 | } | 285 | } |
280 | 286 | ||
281 | r = carray_add(md->mdir_msg_list, msg, &i); | 287 | r = carray_add(md->mdir_msg_list, msg, &i); |
282 | if (r < 0) { | 288 | if (r < 0) { |
283 | res = MAILDIR_ERROR_MEMORY; | 289 | res = MAILDIR_ERROR_MEMORY; |
284 | goto free_msg; | 290 | goto free_msg; |
285 | } | 291 | } |
286 | 292 | ||
287 | key.data = msg->msg_uid; | 293 | key.data = msg->msg_uid; |
288 | key.len = strlen(msg->msg_uid); | 294 | key.len = strlen(msg->msg_uid); |
289 | value.data = msg; | 295 | value.data = msg; |
290 | value.len = 0; | 296 | value.len = 0; |
291 | 297 | ||
292 | r = chash_set(md->mdir_msg_hash, &key, &value, NULL); | 298 | r = chash_set(md->mdir_msg_hash, &key, &value, NULL); |
293 | if (r < 0) { | 299 | if (r < 0) { |
294 | res = MAILDIR_ERROR_MEMORY; | 300 | res = MAILDIR_ERROR_MEMORY; |
295 | goto delete; | 301 | goto delete; |
296 | } | 302 | } |
297 | 303 | ||
298 | return MAILDIR_NO_ERROR; | 304 | return MAILDIR_NO_ERROR; |
299 | 305 | ||
300 | delete: | 306 | delete: |
301 | carray_delete(md->mdir_msg_list, i); | 307 | carray_delete(md->mdir_msg_list, i); |
302 | free_msg: | 308 | free_msg: |
303 | msg_free(msg); | 309 | msg_free(msg); |
304 | err: | 310 | err: |
305 | return res; | 311 | return res; |
306 | } | 312 | } |
307 | 313 | ||
308 | static int add_directory(struct maildir * md, char * path, int is_new) | 314 | static int add_directory(struct maildir * md, char * path, int is_new) |
309 | { | 315 | { |
310 | DIR * d; | 316 | DIR * d; |
311 | struct dirent * entry; | 317 | struct dirent * entry; |
312 | int res; | 318 | int res; |
313 | int r; | 319 | int r; |
314 | char filename[PATH_MAX]; | 320 | char filename[PATH_MAX]; |
315 | 321 | ||
316 | d = opendir(path); | 322 | d = opendir(path); |
317 | if (d == NULL) { | 323 | if (d == NULL) { |
318 | res = MAILDIR_ERROR_DIRECTORY; | 324 | res = MAILDIR_ERROR_DIRECTORY; |
319 | goto err; | 325 | goto err; |
320 | } | 326 | } |
321 | 327 | ||
322 | while ((entry = readdir(d)) != NULL) { | 328 | while ((entry = readdir(d)) != NULL) { |
323 | struct stat stat_info; | 329 | struct stat stat_info; |
324 | 330 | ||
325 | snprintf(filename, sizeof(filename), "%s/%s", path, entry->d_name); | 331 | snprintf(filename, sizeof(filename), "%s/%s", path, entry->d_name); |
326 | r = stat(filename, &stat_info); | 332 | r = stat(filename, &stat_info); |
327 | if (r < 0) | 333 | if (r < 0) |
328 | continue; | 334 | continue; |
329 | 335 | ||
330 | if (S_ISDIR(stat_info.st_mode)) | 336 | if (S_ISDIR(stat_info.st_mode)) |
331 | continue; | 337 | continue; |
332 | 338 | ||
333 | r = add_message(md, entry->d_name, is_new); | 339 | r = add_message(md, entry->d_name, is_new); |
334 | if (r != MAILDIR_NO_ERROR) { | 340 | if (r != MAILDIR_NO_ERROR) { |
335 | /* ignore errors */ | 341 | /* ignore errors */ |
336 | } | 342 | } |
337 | } | 343 | } |
338 | 344 | ||
@@ -385,345 +391,350 @@ int maildir_update(struct maildir * md) | |||
385 | } | 391 | } |
386 | 392 | ||
387 | if (md->mdir_mtime_cur != stat_info.st_mtime) { | 393 | if (md->mdir_mtime_cur != stat_info.st_mtime) { |
388 | md->mdir_mtime_cur = stat_info.st_mtime; | 394 | md->mdir_mtime_cur = stat_info.st_mtime; |
389 | 395 | ||
390 | maildir_flush(md, 0); | 396 | maildir_flush(md, 0); |
391 | 397 | ||
392 | /* messages in cur */ | 398 | /* messages in cur */ |
393 | r = add_directory(md, path_cur, 0); | 399 | r = add_directory(md, path_cur, 0); |
394 | if (r != MAILDIR_NO_ERROR) { | 400 | if (r != MAILDIR_NO_ERROR) { |
395 | res = r; | 401 | res = r; |
396 | goto free; | 402 | goto free; |
397 | } | 403 | } |
398 | } | 404 | } |
399 | 405 | ||
400 | return MAILDIR_NO_ERROR; | 406 | return MAILDIR_NO_ERROR; |
401 | 407 | ||
402 | free: | 408 | free: |
403 | maildir_flush(md, 0); | 409 | maildir_flush(md, 0); |
404 | maildir_flush(md, 1); | 410 | maildir_flush(md, 1); |
405 | md->mdir_mtime_cur = (time_t) -1; | 411 | md->mdir_mtime_cur = (time_t) -1; |
406 | md->mdir_mtime_new = (time_t) -1; | 412 | md->mdir_mtime_new = (time_t) -1; |
407 | return res; | 413 | return res; |
408 | } | 414 | } |
409 | 415 | ||
410 | #ifndef LIBETPAN_SYSTEM_BASENAME | 416 | #ifndef LIBETPAN_SYSTEM_BASENAME |
411 | static char * libetpan_basename(char * filename) | 417 | static char * libetpan_basename(char * filename) |
412 | { | 418 | { |
413 | char * next; | 419 | char * next; |
414 | char * p; | 420 | char * p; |
415 | 421 | ||
416 | p = filename; | 422 | p = filename; |
417 | next = strchr(p, '/'); | 423 | next = strchr(p, '/'); |
418 | 424 | ||
419 | while (next != NULL) { | 425 | while (next != NULL) { |
420 | p = next; | 426 | p = next; |
421 | next = strchr(p + 1, '/'); | 427 | next = strchr(p + 1, '/'); |
422 | } | 428 | } |
423 | 429 | ||
424 | if (p == filename) | 430 | if (p == filename) |
425 | return filename; | 431 | return filename; |
426 | else | 432 | else |
427 | return p + 1; | 433 | return p + 1; |
428 | } | 434 | } |
429 | #else | 435 | #else |
430 | #define libetpan_basename(a) basename(a) | 436 | #define libetpan_basename(a) basename(a) |
431 | #endif | 437 | #endif |
432 | 438 | ||
433 | int maildir_message_add_uid(struct maildir * md, | 439 | int maildir_message_add_uid(struct maildir * md, |
434 | const char * message, size_t size, | 440 | const char * message, size_t size, |
435 | char * uid, size_t max_uid_len) | 441 | char * uid, size_t max_uid_len) |
436 | { | 442 | { |
437 | char path_new[PATH_MAX]; | 443 | char path_new[PATH_MAX]; |
438 | char tmpname[PATH_MAX]; | 444 | char tmpname[PATH_MAX]; |
439 | int fd; | 445 | int fd; |
440 | int r; | 446 | int r; |
441 | char * mapping; | 447 | char * mapping; |
442 | char * delivery_tmp_name; | 448 | char * delivery_tmp_name; |
443 | char * delivery_tmp_basename; | 449 | char * delivery_tmp_basename; |
444 | char delivery_new_name[PATH_MAX]; | 450 | char delivery_new_name[PATH_MAX]; |
445 | char * delivery_new_basename; | 451 | char * delivery_new_basename; |
446 | int res; | 452 | int res; |
447 | struct stat stat_info; | 453 | struct stat stat_info; |
448 | 454 | ||
455 | fprintf(stderr,"maildir_message_add_uid for uid: %s \n", uid); | ||
449 | r = maildir_update(md); | 456 | r = maildir_update(md); |
450 | if (r != MAILDIR_NO_ERROR) { | 457 | if (r != MAILDIR_NO_ERROR) { |
451 | res = r; | 458 | res = r; |
452 | goto err; | 459 | goto err; |
453 | } | 460 | } |
454 | 461 | ||
455 | /* write to tmp/ with a classic temporary file */ | 462 | /* write to tmp/ with a classic temporary file */ |
456 | 463 | ||
457 | snprintf(tmpname, sizeof(tmpname), "%s/tmp/etpan-maildir-XXXXXX", | 464 | snprintf(tmpname, sizeof(tmpname), "%s/tmp/etpan-maildir-XXXXXX", |
458 | md->mdir_path); | 465 | md->mdir_path); |
459 | fd = mkstemp(tmpname); | 466 | fd = mkstemp(tmpname); |
460 | if (fd < 0) { | 467 | if (fd < 0) { |
461 | res = MAILDIR_ERROR_FILE; | 468 | res = MAILDIR_ERROR_FILE; |
462 | goto err; | 469 | goto err; |
463 | } | 470 | } |
464 | 471 | ||
465 | r = ftruncate(fd, size); | 472 | r = ftruncate(fd, size); |
466 | if (r < 0) { | 473 | if (r < 0) { |
467 | res = MAILDIR_ERROR_FILE; | 474 | res = MAILDIR_ERROR_FILE; |
468 | goto close; | 475 | goto close; |
469 | } | 476 | } |
470 | 477 | ||
471 | mapping = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | 478 | mapping = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
472 | if (mapping == MAP_FAILED) { | 479 | if (mapping == MAP_FAILED) { |
473 | res = MAILDIR_ERROR_FILE; | 480 | res = MAILDIR_ERROR_FILE; |
474 | goto close; | 481 | goto close; |
475 | } | 482 | } |
476 | 483 | ||
477 | memcpy(mapping, message, size); | 484 | memcpy(mapping, message, size); |
478 | 485 | ||
479 | msync(mapping, size, MS_SYNC); | 486 | msync(mapping, size, MS_SYNC); |
480 | munmap(mapping, size); | 487 | munmap(mapping, size); |
481 | 488 | ||
482 | close(fd); | 489 | close(fd); |
483 | 490 | ||
484 | /* write to tmp/ with maildir standard name */ | 491 | /* write to tmp/ with maildir standard name */ |
485 | 492 | ||
486 | delivery_tmp_name = maildir_get_new_message_filename(md, tmpname); | 493 | delivery_tmp_name = maildir_get_new_message_filename(md, tmpname); |
487 | if (delivery_tmp_name == NULL) { | 494 | if (delivery_tmp_name == NULL) { |
488 | res = MAILDIR_ERROR_FILE; | 495 | res = MAILDIR_ERROR_FILE; |
489 | goto unlink; | 496 | goto unlink; |
490 | } | 497 | } |
491 | 498 | ||
492 | /* write to new/ with maildir standard name */ | 499 | /* write to new/ with maildir standard name */ |
493 | 500 | ||
494 | strncpy(tmpname, delivery_tmp_name, sizeof(tmpname)); | 501 | strncpy(tmpname, delivery_tmp_name, sizeof(tmpname)); |
495 | tmpname[sizeof(tmpname) - 1] = '\0'; | 502 | tmpname[sizeof(tmpname) - 1] = '\0'; |
496 | 503 | ||
497 | delivery_tmp_basename = libetpan_basename(tmpname); | 504 | delivery_tmp_basename = libetpan_basename(tmpname); |
498 | 505 | ||
499 | snprintf(delivery_new_name, sizeof(delivery_new_name), "%s/new/%s", | 506 | snprintf(delivery_new_name, sizeof(delivery_new_name), "%s/new/%s", |
500 | md->mdir_path, delivery_tmp_basename); | 507 | md->mdir_path, delivery_tmp_basename); |
501 | 508 | ||
502 | r = link(delivery_tmp_name, delivery_new_name); | 509 | r = link(delivery_tmp_name, delivery_new_name); |
503 | if (r < 0) { | 510 | if (r < 0) { |
504 | res = MAILDIR_ERROR_FILE; | 511 | res = MAILDIR_ERROR_FILE; |
505 | goto unlink_tmp; | 512 | goto unlink_tmp; |
506 | } | 513 | } |
507 | 514 | ||
508 | snprintf(path_new, sizeof(path_new), "%s/new", md->mdir_path); | 515 | snprintf(path_new, sizeof(path_new), "%s/new", md->mdir_path); |
509 | r = stat(path_new, &stat_info); | 516 | r = stat(path_new, &stat_info); |
510 | if (r < 0) { | 517 | if (r < 0) { |
511 | unlink(delivery_new_name); | 518 | unlink(delivery_new_name); |
512 | res = MAILDIR_ERROR_FILE; | 519 | res = MAILDIR_ERROR_FILE; |
513 | goto unlink_tmp; | 520 | goto unlink_tmp; |
514 | } | 521 | } |
515 | 522 | ||
516 | md->mdir_mtime_new = stat_info.st_mtime; | 523 | md->mdir_mtime_new = stat_info.st_mtime; |
517 | 524 | ||
518 | delivery_new_basename = libetpan_basename(delivery_new_name); | 525 | delivery_new_basename = libetpan_basename(delivery_new_name); |
519 | 526 | ||
520 | r = add_message(md, delivery_new_basename, 1); | 527 | r = add_message(md, delivery_new_basename, 1); |
521 | if (r != MAILDIR_NO_ERROR) { | 528 | if (r != MAILDIR_NO_ERROR) { |
522 | unlink(delivery_new_name); | 529 | unlink(delivery_new_name); |
523 | res = MAILDIR_ERROR_FILE; | 530 | res = MAILDIR_ERROR_FILE; |
524 | goto unlink_tmp; | 531 | goto unlink_tmp; |
525 | } | 532 | } |
526 | 533 | ||
527 | if (uid != NULL) | 534 | if (uid != NULL) |
528 | strncpy(uid, delivery_new_basename, max_uid_len); | 535 | strncpy(uid, delivery_new_basename, max_uid_len); |
529 | 536 | ||
530 | unlink(delivery_tmp_name); | 537 | unlink(delivery_tmp_name); |
531 | free(delivery_tmp_name); | 538 | free(delivery_tmp_name); |
532 | 539 | ||
533 | return MAILDIR_NO_ERROR; | 540 | return MAILDIR_NO_ERROR; |
534 | 541 | ||
535 | unlink_tmp: | 542 | unlink_tmp: |
536 | unlink(delivery_tmp_name); | 543 | unlink(delivery_tmp_name); |
537 | free(delivery_tmp_name); | 544 | free(delivery_tmp_name); |
538 | goto err; | 545 | goto err; |
539 | close: | 546 | close: |
540 | close(fd); | 547 | close(fd); |
541 | unlink: | 548 | unlink: |
542 | unlink(tmpname); | 549 | unlink(tmpname); |
543 | err: | 550 | err: |
544 | return res; | 551 | return res; |
545 | } | 552 | } |
546 | 553 | ||
547 | int maildir_message_add(struct maildir * md, | 554 | int maildir_message_add(struct maildir * md, |
548 | const char * message, size_t size) | 555 | const char * message, size_t size) |
549 | { | 556 | { |
550 | return maildir_message_add_uid(md, message, size, | 557 | return maildir_message_add_uid(md, message, size, |
551 | NULL, 0); | 558 | NULL, 0); |
552 | } | 559 | } |
553 | 560 | ||
554 | int maildir_message_add_file_uid(struct maildir * md, int fd, | 561 | int maildir_message_add_file_uid(struct maildir * md, int fd, |
555 | char * uid, size_t max_uid_len) | 562 | char * uid, size_t max_uid_len) |
556 | { | 563 | { |
557 | char * message; | 564 | char * message; |
558 | struct stat buf; | 565 | struct stat buf; |
559 | int r; | 566 | int r; |
560 | 567 | ||
568 | fprintf(stderr,"maildir_message_add_file_uid: %s \n", uid); | ||
561 | if (fstat(fd, &buf) == -1) | 569 | if (fstat(fd, &buf) == -1) |
562 | return MAILDIR_ERROR_FILE; | 570 | return MAILDIR_ERROR_FILE; |
563 | 571 | ||
564 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | 572 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); |
565 | if (message == MAP_FAILED) | 573 | if (message == MAP_FAILED) |
566 | return MAILDIR_ERROR_FILE; | 574 | return MAILDIR_ERROR_FILE; |
567 | 575 | ||
568 | r = maildir_message_add_uid(md, message, buf.st_size, uid, max_uid_len); | 576 | r = maildir_message_add_uid(md, message, buf.st_size, uid, max_uid_len); |
569 | 577 | ||
570 | munmap(message, buf.st_size); | 578 | munmap(message, buf.st_size); |
571 | 579 | ||
572 | return r; | 580 | return r; |
573 | } | 581 | } |
574 | 582 | ||
575 | int maildir_message_add_file(struct maildir * md, int fd) | 583 | int maildir_message_add_file(struct maildir * md, int fd) |
576 | { | 584 | { |
585 | fprintf(stderr,"maildir_message_add_file \n"); | ||
577 | return maildir_message_add_file_uid(md, fd, | 586 | return maildir_message_add_file_uid(md, fd, |
578 | NULL, 0); | 587 | NULL, 0); |
579 | } | 588 | } |
580 | 589 | ||
581 | char * maildir_message_get(struct maildir * md, const char * uid) | 590 | char * maildir_message_get(struct maildir * md, const char * uid) |
582 | { | 591 | { |
583 | chashdatum key; | 592 | chashdatum key; |
584 | chashdatum value; | 593 | chashdatum value; |
585 | char filename[PATH_MAX]; | 594 | char filename[PATH_MAX]; |
586 | char * dup_filename; | 595 | char * dup_filename; |
587 | struct maildir_msg * msg; | 596 | struct maildir_msg * msg; |
588 | char * dir; | 597 | char * dir; |
589 | int r; | 598 | int r; |
590 | 599 | ||
600 | fprintf(stderr,"maildir_message_get for uid: %s \n", uid); | ||
591 | key.data = (void *) uid; | 601 | key.data = (void *) uid; |
592 | key.len = strlen(uid); | 602 | key.len = strlen(uid); |
593 | r = chash_get(md->mdir_msg_hash, &key, &value); | 603 | r = chash_get(md->mdir_msg_hash, &key, &value); |
594 | if (r < 0) | 604 | if (r < 0) |
595 | return NULL; | 605 | return NULL; |
596 | 606 | ||
597 | msg = value.data; | 607 | msg = value.data; |
598 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) | 608 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) |
599 | dir = "new"; | 609 | dir = "new"; |
600 | else | 610 | else |
601 | dir = "cur"; | 611 | dir = "cur"; |
602 | 612 | ||
603 | snprintf(filename, sizeof(filename), "%s/%s/%s", | 613 | snprintf(filename, sizeof(filename), "%s/%s/%s", |
604 | md->mdir_path, dir, msg->msg_filename); | 614 | md->mdir_path, dir, msg->msg_filename); |
605 | 615 | ||
606 | dup_filename = strdup(filename); | 616 | dup_filename = strdup(filename); |
607 | if (dup_filename == NULL) | 617 | if (dup_filename == NULL) |
608 | return NULL; | 618 | return NULL; |
609 | 619 | ||
610 | return dup_filename; | 620 | return dup_filename; |
611 | } | 621 | } |
612 | 622 | ||
613 | int maildir_message_remove(struct maildir * md, const char * uid) | 623 | int maildir_message_remove(struct maildir * md, const char * uid) |
614 | { | 624 | { |
615 | chashdatum key; | 625 | chashdatum key; |
616 | chashdatum value; | 626 | chashdatum value; |
617 | char filename[PATH_MAX]; | 627 | char filename[PATH_MAX]; |
618 | struct maildir_msg * msg; | 628 | struct maildir_msg * msg; |
619 | char * dir; | 629 | char * dir; |
620 | int r; | 630 | int r; |
621 | int res; | 631 | int res; |
622 | 632 | ||
633 | fprintf(stderr,"maildir_message_remove for uid: %s \n", uid); | ||
623 | key.data = (void *) uid; | 634 | key.data = (void *) uid; |
624 | key.len = strlen(uid); | 635 | key.len = strlen(uid); |
625 | r = chash_get(md->mdir_msg_hash, &key, &value); | 636 | r = chash_get(md->mdir_msg_hash, &key, &value); |
626 | if (r < 0) { | 637 | if (r < 0) { |
627 | res = MAILDIR_ERROR_NOT_FOUND; | 638 | res = MAILDIR_ERROR_NOT_FOUND; |
628 | goto err; | 639 | goto err; |
629 | } | 640 | } |
630 | 641 | ||
631 | msg = value.data; | 642 | msg = value.data; |
632 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) | 643 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) |
633 | dir = "new"; | 644 | dir = "new"; |
634 | else | 645 | else |
635 | dir = "cur"; | 646 | dir = "cur"; |
636 | 647 | ||
637 | snprintf(filename, sizeof(filename), "%s/%s/%s", | 648 | snprintf(filename, sizeof(filename), "%s/%s/%s", |
638 | md->mdir_path, dir, msg->msg_filename); | 649 | md->mdir_path, dir, msg->msg_filename); |
639 | 650 | ||
640 | r = unlink(filename); | 651 | r = unlink(filename); |
641 | if (r < 0) { | 652 | if (r < 0) { |
642 | res = MAILDIR_ERROR_FILE; | 653 | res = MAILDIR_ERROR_FILE; |
643 | goto err; | 654 | goto err; |
644 | } | 655 | } |
645 | 656 | ||
646 | return MAILDIR_NO_ERROR; | 657 | return MAILDIR_NO_ERROR; |
647 | 658 | ||
648 | err: | 659 | err: |
649 | return res; | 660 | return res; |
650 | } | 661 | } |
651 | 662 | ||
652 | int maildir_message_change_flags(struct maildir * md, | 663 | int maildir_message_change_flags(struct maildir * md, |
653 | const char * uid, int new_flags) | 664 | const char * uid, int new_flags) |
654 | { | 665 | { |
655 | chashdatum key; | 666 | chashdatum key; |
656 | chashdatum value; | 667 | chashdatum value; |
657 | char filename[PATH_MAX]; | 668 | char filename[PATH_MAX]; |
658 | struct maildir_msg * msg; | 669 | struct maildir_msg * msg; |
659 | char * dir; | 670 | char * dir; |
660 | int r; | 671 | int r; |
661 | char new_filename[PATH_MAX]; | 672 | char new_filename[PATH_MAX]; |
662 | char flag_str[5]; | 673 | char flag_str[5]; |
663 | size_t i; | 674 | size_t i; |
664 | int res; | 675 | int res; |
665 | 676 | fprintf(stderr,"maildir_message_change_flags for uid: %s \n", uid); | |
666 | key.data = (void *) uid; | 677 | key.data = (void *) uid; |
667 | key.len = strlen(uid); | 678 | key.len = strlen(uid); |
668 | r = chash_get(md->mdir_msg_hash, &key, &value); | 679 | r = chash_get(md->mdir_msg_hash, &key, &value); |
669 | if (r < 0) { | 680 | if (r < 0) { |
670 | res = MAILDIR_ERROR_NOT_FOUND; | 681 | res = MAILDIR_ERROR_NOT_FOUND; |
671 | goto err; | 682 | goto err; |
672 | } | 683 | } |
673 | 684 | ||
674 | msg = value.data; | 685 | msg = value.data; |
675 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) | 686 | if ((msg->msg_flags & MAILDIR_FLAG_NEW) != 0) |
676 | dir = "new"; | 687 | dir = "new"; |
677 | else | 688 | else |
678 | dir = "cur"; | 689 | dir = "cur"; |
679 | 690 | ||
680 | snprintf(filename, sizeof(filename), "%s/%s/%s", | 691 | snprintf(filename, sizeof(filename), "%s/%s/%s", |
681 | md->mdir_path, dir, msg->msg_filename); | 692 | md->mdir_path, dir, msg->msg_filename); |
682 | 693 | ||
683 | if ((new_flags & MAILDIR_FLAG_NEW) != 0) | 694 | if ((new_flags & MAILDIR_FLAG_NEW) != 0) |
684 | dir = "new"; | 695 | dir = "new"; |
685 | else | 696 | else |
686 | dir = "cur"; | 697 | dir = "cur"; |
687 | 698 | ||
688 | i = 0; | 699 | i = 0; |
689 | if ((new_flags & MAILDIR_FLAG_SEEN) != 0) { | 700 | if ((new_flags & MAILDIR_FLAG_SEEN) != 0) { |
690 | flag_str[i] = 'S'; | 701 | flag_str[i] = 'S'; |
691 | i ++; | 702 | i ++; |
692 | } | 703 | } |
693 | if ((new_flags & MAILDIR_FLAG_REPLIED) != 0) { | 704 | if ((new_flags & MAILDIR_FLAG_REPLIED) != 0) { |
694 | flag_str[i] = 'R'; | 705 | flag_str[i] = 'R'; |
695 | i ++; | 706 | i ++; |
696 | } | 707 | } |
697 | if ((new_flags & MAILDIR_FLAG_FLAGGED) != 0) { | 708 | if ((new_flags & MAILDIR_FLAG_FLAGGED) != 0) { |
698 | flag_str[i] = 'F'; | 709 | flag_str[i] = 'F'; |
699 | i ++; | 710 | i ++; |
700 | } | 711 | } |
701 | if ((new_flags & MAILDIR_FLAG_TRASHED) != 0) { | 712 | if ((new_flags & MAILDIR_FLAG_TRASHED) != 0) { |
702 | flag_str[i] = 'T'; | 713 | flag_str[i] = 'T'; |
703 | i ++; | 714 | i ++; |
704 | } | 715 | } |
705 | flag_str[i] = 0; | 716 | flag_str[i] = 0; |
706 | 717 | ||
707 | if (flag_str[0] == '\0') | 718 | if (flag_str[0] == '\0') |
708 | snprintf(new_filename, sizeof(new_filename), "%s/%s/%s", | 719 | snprintf(new_filename, sizeof(new_filename), "%s/%s/%s", |
709 | md->mdir_path, dir, msg->msg_uid); | 720 | md->mdir_path, dir, msg->msg_uid); |
710 | else | 721 | else |
711 | snprintf(new_filename, sizeof(new_filename), "%s/%s/%s:2,%s", | 722 | snprintf(new_filename, sizeof(new_filename), "%s/%s/%s:2,%s", |
712 | md->mdir_path, dir, msg->msg_uid, flag_str); | 723 | md->mdir_path, dir, msg->msg_uid, flag_str); |
713 | 724 | ||
714 | if (strcmp(filename, new_filename) == 0) | 725 | if (strcmp(filename, new_filename) == 0) |
715 | return MAILDIR_NO_ERROR; | 726 | return MAILDIR_NO_ERROR; |
716 | 727 | ||
717 | r = link(filename, new_filename); | 728 | r = link(filename, new_filename); |
718 | if (r < 0) { | 729 | if (r < 0) { |
719 | res = MAILDIR_ERROR_FILE; | 730 | res = MAILDIR_ERROR_FILE; |
720 | goto err; | 731 | goto err; |
721 | } | 732 | } |
722 | 733 | ||
723 | unlink(filename); | 734 | unlink(filename); |
724 | 735 | ||
725 | return MAILDIR_NO_ERROR; | 736 | return MAILDIR_NO_ERROR; |
726 | 737 | ||
727 | err: | 738 | err: |
728 | return res; | 739 | return res; |
729 | } | 740 | } |
diff --git a/kmicromail/libetpan/mh/mailmh.c b/kmicromail/libetpan/mh/mailmh.c index 119f217..5e2b4cc 100644 --- a/kmicromail/libetpan/mh/mailmh.c +++ b/kmicromail/libetpan/mh/mailmh.c | |||
@@ -546,146 +546,150 @@ int mailmh_folder_remove_subfolder(struct mailmh_folder * folder) | |||
546 | 546 | ||
547 | chash_delete(parent->fl_subfolders_hash, &key, NULL); | 547 | chash_delete(parent->fl_subfolders_hash, &key, NULL); |
548 | carray_delete_fast(parent->fl_subfolders_tab, folder->fl_array_index); | 548 | carray_delete_fast(parent->fl_subfolders_tab, folder->fl_array_index); |
549 | 549 | ||
550 | mailmh_folder_free(folder); | 550 | mailmh_folder_free(folder); |
551 | 551 | ||
552 | return MAILMH_NO_ERROR; | 552 | return MAILMH_NO_ERROR; |
553 | 553 | ||
554 | } | 554 | } |
555 | 555 | ||
556 | int mailmh_folder_rename_subfolder(struct mailmh_folder * src_folder, | 556 | int mailmh_folder_rename_subfolder(struct mailmh_folder * src_folder, |
557 | struct mailmh_folder * dst_folder, | 557 | struct mailmh_folder * dst_folder, |
558 | const char * new_name) | 558 | const char * new_name) |
559 | { | 559 | { |
560 | int r; | 560 | int r; |
561 | struct mailmh_folder * folder; | 561 | struct mailmh_folder * folder; |
562 | struct mailmh_folder * parent; | 562 | struct mailmh_folder * parent; |
563 | char * new_foldername; | 563 | char * new_foldername; |
564 | 564 | ||
565 | parent = src_folder->fl_parent; | 565 | parent = src_folder->fl_parent; |
566 | if (parent == NULL) | 566 | if (parent == NULL) |
567 | return MAILMH_ERROR_RENAME; | 567 | return MAILMH_ERROR_RENAME; |
568 | 568 | ||
569 | new_foldername = malloc(strlen(dst_folder->fl_filename) + 2 + strlen(new_name)); | 569 | new_foldername = malloc(strlen(dst_folder->fl_filename) + 2 + strlen(new_name)); |
570 | if (new_foldername == NULL) | 570 | if (new_foldername == NULL) |
571 | return MAILMH_ERROR_MEMORY; | 571 | return MAILMH_ERROR_MEMORY; |
572 | 572 | ||
573 | strcpy(new_foldername, dst_folder->fl_filename); | 573 | strcpy(new_foldername, dst_folder->fl_filename); |
574 | strcat(new_foldername, MAIL_DIR_SEPARATOR_S); | 574 | strcat(new_foldername, MAIL_DIR_SEPARATOR_S); |
575 | strcat(new_foldername, new_name); | 575 | strcat(new_foldername, new_name); |
576 | 576 | ||
577 | r = rename(src_folder->fl_filename, new_foldername); | 577 | r = rename(src_folder->fl_filename, new_foldername); |
578 | free(new_foldername); | 578 | free(new_foldername); |
579 | if (r < 0) | 579 | if (r < 0) |
580 | return MAILMH_ERROR_RENAME; | 580 | return MAILMH_ERROR_RENAME; |
581 | 581 | ||
582 | r = mailmh_folder_remove_subfolder(src_folder); | 582 | r = mailmh_folder_remove_subfolder(src_folder); |
583 | if (r != MAILMH_NO_ERROR) | 583 | if (r != MAILMH_NO_ERROR) |
584 | return r; | 584 | return r; |
585 | 585 | ||
586 | folder = mailmh_folder_new(dst_folder, new_name); | 586 | folder = mailmh_folder_new(dst_folder, new_name); |
587 | if (folder == NULL) | 587 | if (folder == NULL) |
588 | return MAILMH_ERROR_MEMORY; | 588 | return MAILMH_ERROR_MEMORY; |
589 | 589 | ||
590 | r = carray_add(parent->fl_subfolders_tab, folder, NULL); | 590 | r = carray_add(parent->fl_subfolders_tab, folder, NULL); |
591 | if (r < 0) { | 591 | if (r < 0) { |
592 | mailmh_folder_free(folder); | 592 | mailmh_folder_free(folder); |
593 | return MAILMH_ERROR_MEMORY; | 593 | return MAILMH_ERROR_MEMORY; |
594 | } | 594 | } |
595 | 595 | ||
596 | return MAILMH_NO_ERROR; | 596 | return MAILMH_NO_ERROR; |
597 | } | 597 | } |
598 | 598 | ||
599 | #define MAX_TRY_ALLOC 32 | 599 | #define MAX_TRY_ALLOC 32 |
600 | 600 | ||
601 | /* initial file MUST be in the same directory */ | 601 | /* initial file MUST be in the same directory */ |
602 | 602 | ||
603 | static int mailmh_folder_alloc_msg(struct mailmh_folder * folder, | 603 | static int mailmh_folder_alloc_msg(struct mailmh_folder * folder, |
604 | char * filename, uint32_t * result) | 604 | char * filename, uint32_t * result) |
605 | { | 605 | { |
606 | uint32_t max; | 606 | uint32_t max; |
607 | uint32_t k; | 607 | uint32_t k; |
608 | char * new_filename; | 608 | char * new_filename; |
609 | size_t len; | 609 | size_t len; |
610 | struct stat f_stat; | ||
610 | 611 | ||
611 | len = strlen(folder->fl_filename) + 20; | 612 | len = strlen(folder->fl_filename) + 20; |
612 | new_filename = malloc(len); | 613 | new_filename = malloc(len); |
613 | if (new_filename == NULL) | 614 | if (new_filename == NULL) |
614 | return MAILMH_ERROR_MEMORY; | 615 | return MAILMH_ERROR_MEMORY; |
615 | 616 | ||
616 | max = folder->fl_max_index + 1; | 617 | max = folder->fl_max_index + 1; |
617 | 618 | ||
619 | //fprintf(stderr,"mailmh_folder_alloc_msg filename: %s \n", filename); | ||
618 | k = 0; | 620 | k = 0; |
619 | while (k < MAX_TRY_ALLOC) { | 621 | while (k < MAX_TRY_ALLOC) { |
620 | snprintf(new_filename, len, "%s%c%lu", folder->fl_filename, | 622 | snprintf(new_filename, len, "%s%c%lu", folder->fl_filename, |
621 | MAIL_DIR_SEPARATOR, (unsigned long) (max + k)); | 623 | MAIL_DIR_SEPARATOR, (unsigned long) (max + k)); |
622 | 624 | //fprintf(stderr,"mailmh_folder_alloc_msg new_filename: %s \n", new_filename); | |
623 | if (link(filename, new_filename) == 0) { | 625 | if ( stat( new_filename, &f_stat ) == -1 ) { |
626 | // if (link(filename, new_filename) == 0) { | ||
624 | int r; | 627 | int r; |
625 | 628 | //fprintf(stderr,"filename found \n"); | |
629 | //unlink(filename); | ||
630 | rename (filename,new_filename ); | ||
626 | free(new_filename); | 631 | free(new_filename); |
627 | unlink(filename); | ||
628 | 632 | ||
629 | if (k > MAX_TRY_ALLOC / 2) { | 633 | if (k > MAX_TRY_ALLOC / 2) { |
630 | r = mailmh_folder_update(folder); | 634 | r = mailmh_folder_update(folder); |
631 | /* ignore errors */ | 635 | /* ignore errors */ |
632 | } | 636 | } |
633 | 637 | ||
634 | * result = max + k; | 638 | * result = max + k; |
635 | 639 | ||
636 | folder->fl_max_index = max + k; | 640 | folder->fl_max_index = max + k; |
637 | 641 | ||
638 | return MAILMH_NO_ERROR; | 642 | return MAILMH_NO_ERROR; |
639 | } | 643 | } |
640 | else if (errno == EXDEV) { | 644 | else if (errno == EXDEV) { |
641 | free(filename); | 645 | free(filename); |
642 | return MAILMH_ERROR_FOLDER; | 646 | return MAILMH_ERROR_FOLDER; |
643 | } | 647 | } |
644 | k ++; | 648 | k ++; |
645 | } | 649 | } |
646 | 650 | ||
647 | free(new_filename); | 651 | free(new_filename); |
648 | 652 | ||
649 | return MAILMH_ERROR_FOLDER; | 653 | return MAILMH_ERROR_FOLDER; |
650 | } | 654 | } |
651 | 655 | ||
652 | int mailmh_folder_get_message_filename(struct mailmh_folder * folder, | 656 | int mailmh_folder_get_message_filename(struct mailmh_folder * folder, |
653 | uint32_t index, char ** result) | 657 | uint32_t index, char ** result) |
654 | { | 658 | { |
655 | char * filename; | 659 | char * filename; |
656 | int len; | 660 | int len; |
657 | 661 | ||
658 | #if 0 | 662 | #if 0 |
659 | r = mailmh_folder_update(folder); | 663 | r = mailmh_folder_update(folder); |
660 | if (r != MAILMH_NO_ERROR) | 664 | if (r != MAILMH_NO_ERROR) |
661 | return r; | 665 | return r; |
662 | #endif | 666 | #endif |
663 | 667 | ||
664 | len = strlen(folder->fl_filename) + 20; | 668 | len = strlen(folder->fl_filename) + 20; |
665 | filename = malloc(len); | 669 | filename = malloc(len); |
666 | if (filename == NULL) | 670 | if (filename == NULL) |
667 | return MAILMH_ERROR_MEMORY; | 671 | return MAILMH_ERROR_MEMORY; |
668 | 672 | ||
669 | snprintf(filename, len, "%s%c%lu", folder->fl_filename, MAIL_DIR_SEPARATOR, | 673 | snprintf(filename, len, "%s%c%lu", folder->fl_filename, MAIL_DIR_SEPARATOR, |
670 | (unsigned long) index); | 674 | (unsigned long) index); |
671 | 675 | ||
672 | * result = filename; | 676 | * result = filename; |
673 | 677 | ||
674 | return MAILMH_NO_ERROR;; | 678 | return MAILMH_NO_ERROR;; |
675 | } | 679 | } |
676 | 680 | ||
677 | 681 | ||
678 | int mailmh_folder_get_message_fd(struct mailmh_folder * folder, | 682 | int mailmh_folder_get_message_fd(struct mailmh_folder * folder, |
679 | uint32_t index, int flags, int * result) | 683 | uint32_t index, int flags, int * result) |
680 | { | 684 | { |
681 | char * filename; | 685 | char * filename; |
682 | int fd; | 686 | int fd; |
683 | int r; | 687 | int r; |
684 | 688 | ||
685 | #if 0 | 689 | #if 0 |
686 | r = mailmh_folder_update(folder); | 690 | r = mailmh_folder_update(folder); |
687 | if (r != MAILMH_NO_ERROR) | 691 | if (r != MAILMH_NO_ERROR) |
688 | return r; | 692 | return r; |
689 | #endif | 693 | #endif |
690 | 694 | ||
691 | r = mailmh_folder_get_message_filename(folder, index, &filename); | 695 | r = mailmh_folder_get_message_filename(folder, index, &filename); |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2321087..3908dbb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2386,136 +2386,140 @@ void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | |||
2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2387 | ir->send( fn, description, "text/x-vCalendar" ); | 2387 | ir->send( fn, description, "text/x-vCalendar" ); |
2388 | #endif | 2388 | #endif |
2389 | } | 2389 | } |
2390 | } | 2390 | } |
2391 | void CalendarView::beamDone( Ir *ir ) | 2391 | void CalendarView::beamDone( Ir *ir ) |
2392 | { | 2392 | { |
2393 | #ifndef DESKTOP_VERSION | 2393 | #ifndef DESKTOP_VERSION |
2394 | delete ir; | 2394 | delete ir; |
2395 | #endif | 2395 | #endif |
2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2397 | topLevelWidget()->raise(); | 2397 | topLevelWidget()->raise(); |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | void CalendarView::moveIncidence(Incidence * inc ) | 2400 | void CalendarView::moveIncidence(Incidence * inc ) |
2401 | { | 2401 | { |
2402 | if ( !inc ) return; | 2402 | if ( !inc ) return; |
2403 | // qDebug("showDatePickerForIncidence( ) "); | 2403 | // qDebug("showDatePickerForIncidence( ) "); |
2404 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2405 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2406 | else { | 2406 | else { |
2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2409 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2410 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2412 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2413 | } | 2413 | } |
2414 | mDatePickerMode = 2; | 2414 | mDatePickerMode = 2; |
2415 | mMoveIncidence = inc ; | 2415 | mMoveIncidence = inc ; |
2416 | QDate da; | 2416 | QDate da; |
2417 | if ( mMoveIncidence->type() == "Todo" ) { | 2417 | if ( mMoveIncidence->type() == "Todo" ) { |
2418 | Todo * to = (Todo *) mMoveIncidence; | 2418 | Todo * to = (Todo *) mMoveIncidence; |
2419 | if ( to->hasDueDate() ) | 2419 | if ( to->hasDueDate() ) |
2420 | da = to->dtDue().date(); | 2420 | da = to->dtDue().date(); |
2421 | else | 2421 | else |
2422 | da = QDate::currentDate(); | 2422 | da = QDate::currentDate(); |
2423 | } else { | 2423 | } else { |
2424 | da = mMoveIncidence->dtStart().date(); | 2424 | da = mMoveIncidence->dtStart().date(); |
2425 | } | 2425 | } |
2426 | mDatePicker->setDate( da ); | 2426 | mDatePicker->setDate( da ); |
2427 | } | 2427 | } |
2428 | void CalendarView::showDatePicker( ) | 2428 | void CalendarView::showDatePicker( ) |
2429 | { | 2429 | { |
2430 | //qDebug("CalendarView::showDatePicker( ) "); | 2430 | //qDebug("CalendarView::showDatePicker( ) "); |
2431 | if ( mDateFrame->isVisible() ) | 2431 | if ( mDateFrame->isVisible() ) |
2432 | mDateFrame->hide(); | 2432 | mDateFrame->hide(); |
2433 | else { | 2433 | else { |
2434 | int w =mDatePicker->sizeHint().width() ; | 2434 | int w =mDatePicker->sizeHint().width() ; |
2435 | int h = mDatePicker->sizeHint().height() ; | 2435 | int h = mDatePicker->sizeHint().height() ; |
2436 | int dw = QApplication::desktop()->width(); | 2436 | int dw = QApplication::desktop()->width(); |
2437 | int dh = QApplication::desktop()->height(); | 2437 | int dh = QApplication::desktop()->height(); |
2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2439 | mDateFrame->show(); | 2439 | mDateFrame->show(); |
2440 | } | 2440 | } |
2441 | mDatePickerMode = 1; | 2441 | mDatePickerMode = 1; |
2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2443 | } | 2443 | } |
2444 | 2444 | ||
2445 | void CalendarView::showEventEditor() | 2445 | void CalendarView::showEventEditor() |
2446 | { | 2446 | { |
2447 | #ifdef DESKTOP_VERSION | 2447 | #ifdef DESKTOP_VERSION |
2448 | mEventEditor->show(); | 2448 | mEventEditor->show(); |
2449 | #else | 2449 | #else |
2450 | if ( mEventEditor->width() != QApplication::desktop()->width() ) | ||
2451 | mEventEditor->hide(); | ||
2450 | mEventEditor->showMaximized(); | 2452 | mEventEditor->showMaximized(); |
2451 | #endif | 2453 | #endif |
2452 | } | 2454 | } |
2453 | void CalendarView::showTodoEditor() | 2455 | void CalendarView::showTodoEditor() |
2454 | { | 2456 | { |
2455 | #ifdef DESKTOP_VERSION | 2457 | #ifdef DESKTOP_VERSION |
2456 | mTodoEditor->show(); | 2458 | mTodoEditor->show(); |
2457 | #else | 2459 | #else |
2460 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) | ||
2461 | mTodoEditor->hide(); | ||
2458 | mTodoEditor->showMaximized(); | 2462 | mTodoEditor->showMaximized(); |
2459 | #endif | 2463 | #endif |
2460 | } | 2464 | } |
2461 | 2465 | ||
2462 | void CalendarView::cloneIncidence() | 2466 | void CalendarView::cloneIncidence() |
2463 | { | 2467 | { |
2464 | Incidence *incidence = currentSelection(); | 2468 | Incidence *incidence = currentSelection(); |
2465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2469 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2466 | if ( incidence ) { | 2470 | if ( incidence ) { |
2467 | cloneIncidence(incidence); | 2471 | cloneIncidence(incidence); |
2468 | } | 2472 | } |
2469 | } | 2473 | } |
2470 | void CalendarView::moveIncidence() | 2474 | void CalendarView::moveIncidence() |
2471 | { | 2475 | { |
2472 | Incidence *incidence = currentSelection(); | 2476 | Incidence *incidence = currentSelection(); |
2473 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2477 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2474 | if ( incidence ) { | 2478 | if ( incidence ) { |
2475 | moveIncidence(incidence); | 2479 | moveIncidence(incidence); |
2476 | } | 2480 | } |
2477 | } | 2481 | } |
2478 | void CalendarView::beamIncidence() | 2482 | void CalendarView::beamIncidence() |
2479 | { | 2483 | { |
2480 | Incidence *incidence = currentSelection(); | 2484 | Incidence *incidence = currentSelection(); |
2481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2485 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2482 | if ( incidence ) { | 2486 | if ( incidence ) { |
2483 | beamIncidence(incidence); | 2487 | beamIncidence(incidence); |
2484 | } | 2488 | } |
2485 | } | 2489 | } |
2486 | void CalendarView::toggleCancelIncidence() | 2490 | void CalendarView::toggleCancelIncidence() |
2487 | { | 2491 | { |
2488 | Incidence *incidence = currentSelection(); | 2492 | Incidence *incidence = currentSelection(); |
2489 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2493 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2490 | if ( incidence ) { | 2494 | if ( incidence ) { |
2491 | cancelIncidence(incidence); | 2495 | cancelIncidence(incidence); |
2492 | } | 2496 | } |
2493 | } | 2497 | } |
2494 | 2498 | ||
2495 | 2499 | ||
2496 | void CalendarView::cancelIncidence(Incidence * inc ) | 2500 | void CalendarView::cancelIncidence(Incidence * inc ) |
2497 | { | 2501 | { |
2498 | inc->setCancelled( ! inc->cancelled() ); | 2502 | inc->setCancelled( ! inc->cancelled() ); |
2499 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2503 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2500 | updateView(); | 2504 | updateView(); |
2501 | } | 2505 | } |
2502 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2506 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2503 | { | 2507 | { |
2504 | Incidence * newInc = orgInc->clone(); | 2508 | Incidence * newInc = orgInc->clone(); |
2505 | newInc->recreate(); | 2509 | newInc->recreate(); |
2506 | 2510 | ||
2507 | if ( newInc->type() == "Todo" ) { | 2511 | if ( newInc->type() == "Todo" ) { |
2508 | Todo* t = (Todo*) newInc; | 2512 | Todo* t = (Todo*) newInc; |
2509 | mTodoEditor->editTodo( t ); | 2513 | mTodoEditor->editTodo( t ); |
2510 | showTodoEditor(); | 2514 | showTodoEditor(); |
2511 | if ( mTodoEditor->exec() ) { | 2515 | if ( mTodoEditor->exec() ) { |
2512 | mCalendar->addTodo( t ); | 2516 | mCalendar->addTodo( t ); |
2513 | updateView(); | 2517 | updateView(); |
2514 | } else { | 2518 | } else { |
2515 | delete t; | 2519 | delete t; |
2516 | } | 2520 | } |
2517 | } | 2521 | } |
2518 | else { | 2522 | else { |
2519 | Event* e = (Event*) newInc; | 2523 | Event* e = (Event*) newInc; |
2520 | mEventEditor->editEvent( e ); | 2524 | mEventEditor->editEvent( e ); |
2521 | showEventEditor(); | 2525 | showEventEditor(); |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12acd1..9cafc60 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -313,128 +313,129 @@ KOQuickTodo::KOQuickTodo(QWidget *parent) : | |||
313 | { | 313 | { |
314 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
318 | { | 318 | { |
319 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
320 | setText(""); | 320 | setText(""); |
321 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
325 | { | 325 | { |
326 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
327 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
331 | 331 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
334 | { | 334 | { |
335 | QBoxLayout *topLayout = new QVBoxLayout(this); | 335 | QBoxLayout *topLayout = new QVBoxLayout(this); |
336 | mName = QString ( name ); | 336 | mName = QString ( name ); |
337 | mBlockUpdate = false; | 337 | mBlockUpdate = false; |
338 | mQuickAdd = new KOQuickTodo(this); | 338 | mQuickAdd = new KOQuickTodo(this); |
339 | topLayout->addWidget(mQuickAdd); | 339 | topLayout->addWidget(mQuickAdd); |
340 | 340 | ||
341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
342 | 342 | ||
343 | mTodoListView = new KOTodoListView(calendar,this, name ); | 343 | mTodoListView = new KOTodoListView(calendar,this, name ); |
344 | topLayout->addWidget(mTodoListView); | 344 | topLayout->addWidget(mTodoListView); |
345 | //mTodoListView->header()->setMaximumHeight(30); | 345 | //mTodoListView->header()->setMaximumHeight(30); |
346 | mTodoListView->setRootIsDecorated(true); | 346 | mTodoListView->setRootIsDecorated(true); |
347 | mTodoListView->setAllColumnsShowFocus(true); | 347 | mTodoListView->setAllColumnsShowFocus(true); |
348 | 348 | ||
349 | mTodoListView->setShowSortIndicator(true); | 349 | mTodoListView->setShowSortIndicator(true); |
350 | 350 | ||
351 | mTodoListView->addColumn(i18n("Todo")); | 351 | mTodoListView->addColumn(i18n("Todo")); |
352 | mTodoListView->addColumn(i18n("Prio")); | 352 | mTodoListView->addColumn(i18n("Prio")); |
353 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 353 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
354 | mTodoListView->addColumn(i18n("Complete")); | 354 | mTodoListView->addColumn(i18n("Complete")); |
355 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 355 | mTodoListView->setColumnAlignment(2,AlignHCenter); |
356 | mTodoListView->addColumn(i18n("Due Date")); | 356 | mTodoListView->addColumn(i18n("Due Date")); |
357 | mTodoListView->setColumnAlignment(3,AlignLeft); | 357 | mTodoListView->setColumnAlignment(3,AlignLeft); |
358 | mTodoListView->addColumn(i18n("Due Time")); | 358 | mTodoListView->addColumn(i18n("Due Time")); |
359 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 359 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
360 | mTodoListView->addColumn(i18n("Cancelled")); | 360 | mTodoListView->addColumn(i18n("Cancelled")); |
361 | mTodoListView->addColumn(i18n("Categories")); | 361 | mTodoListView->addColumn(i18n("Categories")); |
362 | #if 0 | 362 | #if 0 |
363 | mTodoListView->addColumn(i18n("Sort Id")); | 363 | mTodoListView->addColumn(i18n("Sort Id")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | #endif | 365 | #endif |
366 | 366 | ||
367 | mTodoListView->setMinimumHeight( 60 ); | 367 | mTodoListView->setMinimumHeight( 60 ); |
368 | mTodoListView->setItemsRenameable( true ); | 368 | mTodoListView->setItemsRenameable( true ); |
369 | mTodoListView->setRenameable( 0 ); | 369 | mTodoListView->setRenameable( 0 ); |
370 | mTodoListView->setColumnWidth( 0, 120 ); | 370 | mTodoListView->setColumnWidth( 0, 120 ); |
371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
377 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | ||
377 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 378 | mTodoListView->setColumnAlignment( 2, AlignCenter ); |
378 | #if 0 | 379 | #if 0 |
379 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 380 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
380 | #endif | 381 | #endif |
381 | 382 | ||
382 | mPriorityPopupMenu = new QPopupMenu(this); | 383 | mPriorityPopupMenu = new QPopupMenu(this); |
383 | for (int i = 1; i <= 5; i++) { | 384 | for (int i = 1; i <= 5; i++) { |
384 | QString label = QString ("%1").arg (i); | 385 | QString label = QString ("%1").arg (i); |
385 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 386 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
386 | } | 387 | } |
387 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 388 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
388 | 389 | ||
389 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 390 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
390 | for (int i = 0; i <= 100; i+=20) { | 391 | for (int i = 0; i <= 100; i+=20) { |
391 | QString label = QString ("%1 %").arg (i); | 392 | QString label = QString ("%1 %").arg (i); |
392 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 393 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
393 | } | 394 | } |
394 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 395 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | mItemPopupMenu = new QPopupMenu(this); | 399 | mItemPopupMenu = new QPopupMenu(this); |
399 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 400 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
400 | SLOT (showTodo())); | 401 | SLOT (showTodo())); |
401 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 402 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
402 | SLOT (editTodo())); | 403 | SLOT (editTodo())); |
403 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 404 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
404 | SLOT (deleteTodo())); | 405 | SLOT (deleteTodo())); |
405 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 406 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
406 | SLOT (cloneTodo())); | 407 | SLOT (cloneTodo())); |
407 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 408 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
408 | SLOT (moveTodo())); | 409 | SLOT (moveTodo())); |
409 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 410 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
410 | SLOT (beamTodo())); | 411 | SLOT (beamTodo())); |
411 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 412 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
412 | SLOT (cancelTodo())); | 413 | SLOT (cancelTodo())); |
413 | mItemPopupMenu->insertSeparator(); | 414 | mItemPopupMenu->insertSeparator(); |
414 | 415 | ||
415 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 416 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
416 | SLOT (newTodo())); | 417 | SLOT (newTodo())); |
417 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 418 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
418 | SLOT (newSubTodo())); | 419 | SLOT (newSubTodo())); |
419 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 420 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
420 | SLOT (unparentTodo()),0,21); | 421 | SLOT (unparentTodo()),0,21); |
421 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 422 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
422 | SLOT (reparentTodo()),0,22); | 423 | SLOT (reparentTodo()),0,22); |
423 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
424 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 425 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
425 | this, SLOT( purgeCompleted() ) ); | 426 | this, SLOT( purgeCompleted() ) ); |
426 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 427 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
427 | this, SLOT( toggleCompleted() ),0, 33 ); | 428 | this, SLOT( toggleCompleted() ),0, 33 ); |
428 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 429 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
429 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 430 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
430 | 431 | ||
431 | mPopupMenu = new QPopupMenu(this); | 432 | mPopupMenu = new QPopupMenu(this); |
432 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 433 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
433 | SLOT (newTodo()),0,1); | 434 | SLOT (newTodo()),0,1); |
434 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 435 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
435 | this, SLOT(purgeCompleted()),0,2); | 436 | this, SLOT(purgeCompleted()),0,2); |
436 | mPopupMenu->insertItem(i18n("Show Completed"), | 437 | mPopupMenu->insertItem(i18n("Show Completed"), |
437 | this, SLOT( toggleCompleted() ),0,3 ); | 438 | this, SLOT( toggleCompleted() ),0,3 ); |
438 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 439 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
439 | this, SLOT( toggleQuickTodo() ),0,4 ); | 440 | this, SLOT( toggleQuickTodo() ),0,4 ); |
440 | mDocPrefs = new DocPrefs( name ); | 441 | mDocPrefs = new DocPrefs( name ); |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 85647b1..ae0b334 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,109 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | 23 | ||
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include "kotodoviewitem.h" | 25 | #include "kotodoviewitem.h" |
26 | #include "kotodoview.h" | 26 | #include "kotodoview.h" |
27 | #include "koprefs.h" | 27 | #include "koprefs.h" |
28 | 28 | ||
29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
31 | { | 31 | { |
32 | construct(); | 32 | construct(); |
33 | } | 33 | } |
34 | 34 | ||
35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
37 | { | 37 | { |
38 | construct(); | 38 | construct(); |
39 | } | 39 | } |
40 | 40 | ||
41 | QString KOTodoViewItem::key(int column,bool) const | 41 | QString KOTodoViewItem::key(int column,bool) const |
42 | { | 42 | { |
43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
44 | if (it == mKeyMap.end()) { | 44 | if (it == mKeyMap.end()) { |
45 | return text(column); | 45 | return text(column).lower(); |
46 | } else { | 46 | } else { |
47 | return *it; | 47 | return *it; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void KOTodoViewItem:: setup() | 51 | void KOTodoViewItem:: setup() |
52 | { | 52 | { |
53 | 53 | ||
54 | int h = 20; | 54 | int h = 20; |
55 | if ( listView () ) { | 55 | if ( listView () ) { |
56 | QFontMetrics fm ( listView ()->font () ); | 56 | QFontMetrics fm ( listView ()->font () ); |
57 | h = fm.height(); | 57 | h = fm.height(); |
58 | } | 58 | } |
59 | setHeight( h ); | 59 | setHeight( h ); |
60 | 60 | ||
61 | } | 61 | } |
62 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 62 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
63 | { | 63 | { |
64 | mKeyMap.insert(column,key); | 64 | mKeyMap.insert(column,key); |
65 | } | 65 | } |
66 | 66 | ||
67 | #if QT_VERSION >= 300 | 67 | #if QT_VERSION >= 300 |
68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
69 | int y,int h) | 69 | int y,int h) |
70 | { | 70 | { |
71 | QListViewItem::paintBranches(p,cg,w,y,h); | 71 | QListViewItem::paintBranches(p,cg,w,y,h); |
72 | } | 72 | } |
73 | #else | 73 | #else |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | void KOTodoViewItem::construct() | 76 | void KOTodoViewItem::construct() |
77 | { | 77 | { |
78 | // qDebug("KOTodoViewItem::construct() "); | 78 | // qDebug("KOTodoViewItem::construct() "); |
79 | m_init = true; | 79 | m_init = true; |
80 | QString keyd = "=="; | 80 | QString keyd = "=="; |
81 | QString keyt = "=="; | 81 | QString keyt = "=="; |
82 | 82 | ||
83 | setOn(mTodo->isCompleted()); | 83 | setOn(mTodo->isCompleted()); |
84 | setText(0,mTodo->summary()); | 84 | setText(0,mTodo->summary()); |
85 | setText(1,QString::number(mTodo->priority())); | 85 | setText(1,QString::number(mTodo->priority())); |
86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
87 | if (mTodo->percentComplete()<100) { | 87 | if (mTodo->percentComplete()<100) { |
88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
89 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 89 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
90 | } | 90 | } |
91 | else { | 91 | else { |
92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
93 | else setSortKey(2,QString::number(99)); | 93 | else setSortKey(2,QString::number(99)); |
94 | } | 94 | } |
95 | if (mTodo->hasDueDate()) { | 95 | if (mTodo->hasDueDate()) { |
96 | setText(3, mTodo->dtDueDateStr()); | 96 | setText(3, mTodo->dtDueDateStr()); |
97 | QDate d = mTodo->dtDue().date(); | 97 | QDate d = mTodo->dtDue().date(); |
98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
99 | setSortKey(3,keyd); | 99 | setSortKey(3,keyd); |
100 | if (mTodo->doesFloat()) { | 100 | if (mTodo->doesFloat()) { |
101 | setText(4,""); | 101 | setText(4,""); |
102 | } | 102 | } |
103 | else { | 103 | else { |
104 | setText(4,mTodo->dtDueTimeStr()); | 104 | setText(4,mTodo->dtDueTimeStr()); |
105 | QTime t = mTodo->dtDue().time(); | 105 | QTime t = mTodo->dtDue().time(); |
106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
107 | setSortKey(4,keyt); | 107 | setSortKey(4,keyt); |
108 | } | 108 | } |
109 | } else { | 109 | } else { |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 24b8349..c2ee2c9 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -193,130 +193,133 @@ class SharpParser : public QObject | |||
193 | alarm->setStartOffset( -60*15 ); | 193 | alarm->setStartOffset( -60*15 ); |
194 | alarm->setEnabled( false ); | 194 | alarm->setEnabled( false ); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | mCalendar->addEvent( event); | 198 | mCalendar->addEvent( event); |
199 | } else if ( qName == "Todo" ) { | 199 | } else if ( qName == "Todo" ) { |
200 | Todo *todo; | 200 | Todo *todo; |
201 | 201 | ||
202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
203 | if (todo ) | 203 | if (todo ) |
204 | todo = (Todo*)todo->clone(); | 204 | todo = (Todo*)todo->clone(); |
205 | else | 205 | else |
206 | todo = new Todo; | 206 | todo = new Todo; |
207 | 207 | ||
208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
209 | // 0 1 2 3 4 5 6 7 8 | 209 | // 0 1 2 3 4 5 6 7 8 |
210 | //1,,,,,1,4,Loch zumachen,"" | 210 | //1,,,,,1,4,Loch zumachen,"" |
211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
213 | 213 | ||
214 | todo->setID( "Sharp_DTM", attList[0]); | 214 | todo->setID( "Sharp_DTM", attList[0]); |
215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
217 | 217 | ||
218 | todo->setSummary( attList[7] ); | 218 | todo->setSummary( attList[7] ); |
219 | todo->setDescription( attList[8]); | 219 | todo->setDescription( attList[8]); |
220 | 220 | ||
221 | int priority = attList[6].toInt(); | 221 | int priority = attList[6].toInt(); |
222 | if ( priority == 0 ) priority = 3; | 222 | if ( priority == 0 ) priority = 3; |
223 | todo->setPriority( priority ); | 223 | todo->setPriority( priority ); |
224 | 224 | ||
225 | QString categoryList = attList[1]; | 225 | QString categoryList = attList[1]; |
226 | todo->setCategories( categoryList ); | 226 | todo->setCategories( categoryList ); |
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | QString hasDateStr = attList[3]; // due | 230 | QString hasDateStr = attList[3]; // due |
231 | if ( !hasDateStr.isEmpty() ) { | 231 | if ( !hasDateStr.isEmpty() ) { |
232 | if ( hasDateStr.right(6) == "000000" ) { | 232 | if ( hasDateStr.right(6) == "000000" ) { |
233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
234 | todo->setFloats( true ); | 234 | todo->setFloats( true ); |
235 | } | 235 | } |
236 | else { | 236 | else { |
237 | todo->setDtDue( fromString( hasDateStr ) ); | 237 | todo->setDtDue( fromString( hasDateStr ) ); |
238 | todo->setFloats( false ); | 238 | todo->setFloats( false ); |
239 | } | 239 | } |
240 | 240 | ||
241 | todo->setHasDueDate( true ); | 241 | todo->setHasDueDate( true ); |
242 | } | 242 | } |
243 | hasDateStr = attList[2];//start | 243 | hasDateStr = attList[2];//start |
244 | if ( !hasDateStr.isEmpty() ) { | 244 | if ( !hasDateStr.isEmpty() ) { |
245 | 245 | ||
246 | todo->setDtStart( fromString( hasDateStr ) ); | 246 | todo->setDtStart( fromString( hasDateStr ) ); |
247 | todo->setHasStartDate( true); | 247 | todo->setHasStartDate( true); |
248 | } else | 248 | } else |
249 | todo->setHasStartDate( false ); | 249 | todo->setHasStartDate( false ); |
250 | hasDateStr = attList[4];//completed | 250 | hasDateStr = attList[4];//completed |
251 | if ( !hasDateStr.isEmpty() ) { | 251 | if ( !hasDateStr.isEmpty() ) { |
252 | todo->setCompleted(fromString( hasDateStr ) ); | 252 | todo->setCompleted(fromString( hasDateStr ) ); |
253 | } | 253 | } |
254 | QString completedStr = attList[5]; | 254 | QString completedStr = attList[5]; |
255 | if ( completedStr == "0" ) | 255 | if ( completedStr == "0" ) |
256 | todo->setCompleted( true ); | 256 | todo->setCompleted( true ); |
257 | else | 257 | else { |
258 | todo->setCompleted( false ); | 258 | // do not change percent complete |
259 | if ( todo->isCompleted() ) | ||
260 | todo->setCompleted( false ); | ||
261 | } | ||
259 | mCalendar->addTodo( todo ); | 262 | mCalendar->addTodo( todo ); |
260 | 263 | ||
261 | } else if ( qName == "Category" ) { | 264 | } else if ( qName == "Category" ) { |
262 | /* | 265 | /* |
263 | QString id = attributes.value( "id" ); | 266 | QString id = attributes.value( "id" ); |
264 | QString name = attributes.value( "name" ); | 267 | QString name = attributes.value( "name" ); |
265 | setCategory( id, name ); | 268 | setCategory( id, name ); |
266 | */ | 269 | */ |
267 | } | 270 | } |
268 | //qDebug("end "); | 271 | //qDebug("end "); |
269 | return true; | 272 | return true; |
270 | } | 273 | } |
271 | 274 | ||
272 | 275 | ||
273 | QDateTime fromString ( QString s, bool useTz = true ) { | 276 | QDateTime fromString ( QString s, bool useTz = true ) { |
274 | QDateTime dt; | 277 | QDateTime dt; |
275 | int y,m,t,h,min,sec; | 278 | int y,m,t,h,min,sec; |
276 | y = s.mid(0,4).toInt(); | 279 | y = s.mid(0,4).toInt(); |
277 | m = s.mid(4,2).toInt(); | 280 | m = s.mid(4,2).toInt(); |
278 | t = s.mid(6,2).toInt(); | 281 | t = s.mid(6,2).toInt(); |
279 | h = s.mid(9,2).toInt(); | 282 | h = s.mid(9,2).toInt(); |
280 | min = s.mid(11,2).toInt(); | 283 | min = s.mid(11,2).toInt(); |
281 | sec = s.mid(13,2).toInt(); | 284 | sec = s.mid(13,2).toInt(); |
282 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 285 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
283 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 286 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
284 | if ( useTz ) | 287 | if ( useTz ) |
285 | dt = dt.addSecs ( offset*60); | 288 | dt = dt.addSecs ( offset*60); |
286 | return dt; | 289 | return dt; |
287 | 290 | ||
288 | } | 291 | } |
289 | protected: | 292 | protected: |
290 | QDateTime toDateTime( const QString &value ) | 293 | QDateTime toDateTime( const QString &value ) |
291 | { | 294 | { |
292 | QDateTime dt; | 295 | QDateTime dt; |
293 | dt.setTime_t( value.toUInt() ); | 296 | dt.setTime_t( value.toUInt() ); |
294 | 297 | ||
295 | return dt; | 298 | return dt; |
296 | } | 299 | } |
297 | 300 | ||
298 | private: | 301 | private: |
299 | Calendar *mCalendar; | 302 | Calendar *mCalendar; |
300 | }; | 303 | }; |
301 | 304 | ||
302 | 305 | ||
303 | SharpFormat::SharpFormat() | 306 | SharpFormat::SharpFormat() |
304 | { | 307 | { |
305 | 308 | ||
306 | } | 309 | } |
307 | 310 | ||
308 | SharpFormat::~SharpFormat() | 311 | SharpFormat::~SharpFormat() |
309 | { | 312 | { |
310 | } | 313 | } |
311 | ulong SharpFormat::getCsum( const QStringList & attList) | 314 | ulong SharpFormat::getCsum( const QStringList & attList) |
312 | { | 315 | { |
313 | int max = attList.count() -1; | 316 | int max = attList.count() -1; |
314 | ulong cSum = 0; | 317 | ulong cSum = 0; |
315 | int j,k,i; | 318 | int j,k,i; |
316 | int add; | 319 | int add; |
317 | for ( i = 1; i < max ; ++i ) { | 320 | for ( i = 1; i < max ; ++i ) { |
318 | QString s = attList[i]; | 321 | QString s = attList[i]; |
319 | if ( ! s.isEmpty() ){ | 322 | if ( ! s.isEmpty() ){ |
320 | j = s.length(); | 323 | j = s.length(); |
321 | for ( k = 0; k < j; ++k ) { | 324 | for ( k = 0; k < j; ++k ) { |
322 | int mul = k +1; | 325 | int mul = k +1; |
@@ -1 +1 @@ | |||
version = "1.9.13"; | version = "1.9.14"; | ||