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,130 +1,152 @@ | |||
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. |
67 | 89 | ||
68 | Implemented direct KDE<->KA/Pi sync for KA/Pi running | 90 | Implemented direct KDE<->KA/Pi sync for KA/Pi running |
69 | on Linux desktop. | 91 | on Linux desktop. |
70 | 92 | ||
71 | Added feature "remove sync info" to sync menu. | 93 | Added feature "remove sync info" to sync menu. |
72 | 94 | ||
73 | Tweaked the KO/Pi What's next view a bit, added | 95 | Tweaked the KO/Pi What's next view a bit, added |
74 | setting to hide events that are done. | 96 | setting to hide events that are done. |
75 | 97 | ||
76 | Disabled "beam receive enabled" on startup to | 98 | Disabled "beam receive enabled" on startup to |
77 | avoid problems if Fastload is enabled. | 99 | avoid problems if Fastload is enabled. |
78 | Please set "beam receive enabled", | 100 | Please set "beam receive enabled", |
79 | if you want to receive data via IR. | 101 | if you want to receive data via IR. |
80 | 102 | ||
81 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running | 103 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running |
82 | on Linux desktop. | 104 | on Linux desktop. |
83 | 105 | ||
84 | Made in KA/Pi scrolling possible, if details view is selected. | 106 | Made in KA/Pi scrolling possible, if details view is selected. |
85 | (The keyboard focus is set automatically to the search line) | 107 | (The keyboard focus is set automatically to the search line) |
86 | 108 | ||
87 | Fixed a bug in DMT sync, that a new entry in DTM was added | 109 | Fixed a bug in DMT sync, that a new entry in DTM was added |
88 | on every sync to Kx/Pi. | 110 | on every sync to Kx/Pi. |
89 | 111 | ||
90 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. | 112 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. |
91 | 113 | ||
92 | Fixed a bug in DMT sync with todos created in KO/Pi containing | 114 | Fixed a bug in DMT sync with todos created in KO/Pi containing |
93 | non-latin1 characters. | 115 | non-latin1 characters. |
94 | 116 | ||
95 | Rearranged package contents of Sharp-ipks and made all | 117 | Rearranged package contents of Sharp-ipks and made all |
96 | packages installable on SD again. | 118 | packages installable on SD again. |
97 | 119 | ||
98 | Fixed the writing of addressbook data in DTM sync. | 120 | Fixed the writing of addressbook data in DTM sync. |
99 | Empty fields in KA/Pi were not removed. | 121 | Empty fields in KA/Pi were not removed. |
100 | 122 | ||
101 | Added better category handling in KA/Pi: | 123 | Added better category handling in KA/Pi: |
102 | Added item | 124 | Added item |
103 | Edit Categories and | 125 | Edit Categories and |
104 | Manage new categories | 126 | Manage new categories |
105 | to the settings menu. | 127 | to the settings menu. |
106 | Possible to configure a view to display categories. | 128 | Possible to configure a view to display categories. |
107 | 129 | ||
108 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. | 130 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. |
109 | 131 | ||
110 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. | 132 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. |
111 | 133 | ||
112 | ... and many other bugfixes. | 134 | ... and many other bugfixes. |
113 | 135 | ||
114 | ********** VERSION 1.9.10 ************ | 136 | ********** VERSION 1.9.10 ************ |
115 | 137 | ||
116 | Many internal small bugfixes. | 138 | Many internal small bugfixes. |
117 | And fix of the "big" bug in KO/Pi, | 139 | And fix of the "big" bug in KO/Pi, |
118 | that after Syncing the appointments had an offset by several hours. | 140 | that after Syncing the appointments had an offset by several hours. |
119 | That was a problem with the internal timezone setting, | 141 | That was a problem with the internal timezone setting, |
120 | introduced by the changed timezone configuration settings. | 142 | introduced by the changed timezone configuration settings. |
121 | 143 | ||
122 | German translation for OM/Pi is now available. | 144 | German translation for OM/Pi is now available. |
123 | 145 | ||
124 | 146 | ||
125 | ********** VERSION 1.9.9 ************ | 147 | ********** VERSION 1.9.9 ************ |
126 | 148 | ||
127 | KDE-Pim/Pi has a new Member! | 149 | KDE-Pim/Pi has a new Member! |
128 | It is called PWM/Pi (Passwordmanager/platform-independent) | 150 | It is called PWM/Pi (Passwordmanager/platform-independent) |
129 | and it is available for the Zaurus. | 151 | and it is available for the Zaurus. |
130 | It is planned, that it will be available later for Windows. | 152 | It is planned, that it will be available later for Windows. |
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 | |||
@@ -1,729 +1,740 @@ | |||
1 | /* | 1 | /* |
2 | * libEtPan! -- a mail stuff library | 2 | * libEtPan! -- a mail stuff library |
3 | * | 3 | * |
4 | * Copyright (C) 2001 - 2003 - DINH Viet Hoa | 4 | * Copyright (C) 2001 - 2003 - DINH Viet Hoa |
5 | * All rights reserved. | 5 | * All rights reserved. |
6 | * | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. |
15 | * 3. Neither the name of the libEtPan! project nor the names of its | 15 | * 3. Neither the name of the libEtPan! project nor the names of its |
16 | * contributors may be used to endorse or promote products derived | 16 | * contributors may be used to endorse or promote products derived |
17 | * from this software without specific prior written permission. | 17 | * from this software without specific prior written permission. |
18 | * | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * $Id$ | 33 | * $Id$ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "maildir.h" | 36 | #include "maildir.h" |
37 | 37 | ||
38 | #include <string.h> | 38 | #include <string.h> |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <stdio.h> | 40 | #include <stdio.h> |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <sys/types.h> | 42 | #include <sys/types.h> |
43 | #include <dirent.h> | 43 | #include <dirent.h> |
44 | #include <time.h> | 44 | #include <time.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <sys/mman.h> | 46 | #include <sys/mman.h> |
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; |
194 | case 'F': | 199 | case 'F': |
195 | flags |= MAILDIR_FLAG_FLAGGED; | 200 | flags |= MAILDIR_FLAG_FLAGGED; |
196 | break; | 201 | break; |
197 | case 'T': | 202 | case 'T': |
198 | flags |= MAILDIR_FLAG_TRASHED; | 203 | flags |= MAILDIR_FLAG_TRASHED; |
199 | break; | 204 | break; |
200 | } | 205 | } |
201 | p ++; | 206 | p ++; |
202 | } | 207 | } |
203 | } | 208 | } |
204 | 209 | ||
205 | if (new_msg) | 210 | if (new_msg) |
206 | flags |= MAILDIR_FLAG_NEW; | 211 | flags |= MAILDIR_FLAG_NEW; |
207 | 212 | ||
208 | msg->msg_flags = flags; | 213 | msg->msg_flags = flags; |
209 | 214 | ||
210 | msg->msg_uid = malloc(uid_len + 1); | 215 | msg->msg_uid = malloc(uid_len + 1); |
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 | ||
339 | closedir(d); | 345 | closedir(d); |
340 | 346 | ||
341 | return MAILDIR_NO_ERROR; | 347 | return MAILDIR_NO_ERROR; |
342 | 348 | ||
343 | err: | 349 | err: |
344 | return res; | 350 | return res; |
345 | } | 351 | } |
346 | 352 | ||
347 | int maildir_update(struct maildir * md) | 353 | int maildir_update(struct maildir * md) |
348 | { | 354 | { |
349 | struct stat stat_info; | 355 | struct stat stat_info; |
350 | char path_new[PATH_MAX]; | 356 | char path_new[PATH_MAX]; |
351 | char path_cur[PATH_MAX]; | 357 | char path_cur[PATH_MAX]; |
352 | int r; | 358 | int r; |
353 | int res; | 359 | int res; |
354 | 360 | ||
355 | snprintf(path_new, sizeof(path_new), "%s/new", md->mdir_path); | 361 | snprintf(path_new, sizeof(path_new), "%s/new", md->mdir_path); |
356 | snprintf(path_cur, sizeof(path_cur), "%s/cur", md->mdir_path); | 362 | snprintf(path_cur, sizeof(path_cur), "%s/cur", md->mdir_path); |
357 | 363 | ||
358 | /* did new/ changed ? */ | 364 | /* did new/ changed ? */ |
359 | 365 | ||
360 | r = stat(path_new, &stat_info); | 366 | r = stat(path_new, &stat_info); |
361 | if (r < 0) { | 367 | if (r < 0) { |
362 | res = MAILDIR_ERROR_DIRECTORY; | 368 | res = MAILDIR_ERROR_DIRECTORY; |
363 | goto free; | 369 | goto free; |
364 | } | 370 | } |
365 | 371 | ||
366 | if (md->mdir_mtime_new != stat_info.st_mtime) { | 372 | if (md->mdir_mtime_new != stat_info.st_mtime) { |
367 | md->mdir_mtime_new = stat_info.st_mtime; | 373 | md->mdir_mtime_new = stat_info.st_mtime; |
368 | 374 | ||
369 | maildir_flush(md, 1); | 375 | maildir_flush(md, 1); |
370 | 376 | ||
371 | /* messages in new */ | 377 | /* messages in new */ |
372 | r = add_directory(md, path_new, 1); | 378 | r = add_directory(md, path_new, 1); |
373 | if (r != MAILDIR_NO_ERROR) { | 379 | if (r != MAILDIR_NO_ERROR) { |
374 | res = r; | 380 | res = r; |
375 | goto free; | 381 | goto free; |
376 | } | 382 | } |
377 | } | 383 | } |
378 | 384 | ||
379 | /* did cur/ changed ? */ | 385 | /* did cur/ changed ? */ |
380 | 386 | ||
381 | r = stat(path_cur, &stat_info); | 387 | r = stat(path_cur, &stat_info); |
382 | if (r < 0) { | 388 | if (r < 0) { |
383 | res = MAILDIR_ERROR_DIRECTORY; | 389 | res = MAILDIR_ERROR_DIRECTORY; |
384 | goto free; | 390 | goto free; |
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 | |||
@@ -482,274 +482,278 @@ int mailmh_folder_update(struct mailmh_folder * folder) | |||
482 | int mailmh_folder_add_subfolder(struct mailmh_folder * parent, | 482 | int mailmh_folder_add_subfolder(struct mailmh_folder * parent, |
483 | const char * name) | 483 | const char * name) |
484 | { | 484 | { |
485 | char * foldername; | 485 | char * foldername; |
486 | int r; | 486 | int r; |
487 | struct mailmh_folder * folder; | 487 | struct mailmh_folder * folder; |
488 | unsigned int array_index; | 488 | unsigned int array_index; |
489 | chashdatum key; | 489 | chashdatum key; |
490 | chashdatum data; | 490 | chashdatum data; |
491 | 491 | ||
492 | foldername = malloc(strlen(parent->fl_filename) + strlen(name) + 2); | 492 | foldername = malloc(strlen(parent->fl_filename) + strlen(name) + 2); |
493 | if (foldername == NULL) | 493 | if (foldername == NULL) |
494 | return MAILMH_ERROR_MEMORY; | 494 | return MAILMH_ERROR_MEMORY; |
495 | strcpy(foldername, parent->fl_filename); | 495 | strcpy(foldername, parent->fl_filename); |
496 | strcat(foldername, MAIL_DIR_SEPARATOR_S); | 496 | strcat(foldername, MAIL_DIR_SEPARATOR_S); |
497 | strcat(foldername, name); | 497 | strcat(foldername, name); |
498 | 498 | ||
499 | r = mkdir(foldername, 0700); | 499 | r = mkdir(foldername, 0700); |
500 | free(foldername); | 500 | free(foldername); |
501 | 501 | ||
502 | if (r < 0) | 502 | if (r < 0) |
503 | return MAILMH_ERROR_FOLDER; | 503 | return MAILMH_ERROR_FOLDER; |
504 | 504 | ||
505 | folder = mailmh_folder_new(parent, name); | 505 | folder = mailmh_folder_new(parent, name); |
506 | if (folder == NULL) | 506 | if (folder == NULL) |
507 | return MAILMH_ERROR_MEMORY; | 507 | return MAILMH_ERROR_MEMORY; |
508 | 508 | ||
509 | r = carray_add(parent->fl_subfolders_tab, folder, &array_index); | 509 | r = carray_add(parent->fl_subfolders_tab, folder, &array_index); |
510 | if (r < 0) { | 510 | if (r < 0) { |
511 | mailmh_folder_free(folder); | 511 | mailmh_folder_free(folder); |
512 | return MAILMH_ERROR_MEMORY; | 512 | return MAILMH_ERROR_MEMORY; |
513 | } | 513 | } |
514 | folder->fl_array_index = array_index; | 514 | folder->fl_array_index = array_index; |
515 | 515 | ||
516 | key.data = folder->fl_filename; | 516 | key.data = folder->fl_filename; |
517 | key.len = strlen(folder->fl_filename); | 517 | key.len = strlen(folder->fl_filename); |
518 | data.data = folder; | 518 | data.data = folder; |
519 | data.len = 0; | 519 | data.len = 0; |
520 | 520 | ||
521 | r = chash_set(parent->fl_subfolders_hash, &key, &data, NULL); | 521 | r = chash_set(parent->fl_subfolders_hash, &key, &data, NULL); |
522 | if (r < 0) { | 522 | if (r < 0) { |
523 | carray_delete_fast(folder->fl_subfolders_tab, folder->fl_array_index); | 523 | carray_delete_fast(folder->fl_subfolders_tab, folder->fl_array_index); |
524 | mailmh_folder_free(folder); | 524 | mailmh_folder_free(folder); |
525 | return MAILMH_ERROR_MEMORY; | 525 | return MAILMH_ERROR_MEMORY; |
526 | } | 526 | } |
527 | 527 | ||
528 | return MAILMH_NO_ERROR; | 528 | return MAILMH_NO_ERROR; |
529 | } | 529 | } |
530 | 530 | ||
531 | int mailmh_folder_remove_subfolder(struct mailmh_folder * folder) | 531 | int mailmh_folder_remove_subfolder(struct mailmh_folder * folder) |
532 | { | 532 | { |
533 | struct mailmh_folder * parent; | 533 | struct mailmh_folder * parent; |
534 | chashdatum key; | 534 | chashdatum key; |
535 | chashdatum data; | 535 | chashdatum data; |
536 | int r; | 536 | int r; |
537 | 537 | ||
538 | parent = folder->fl_parent; | 538 | parent = folder->fl_parent; |
539 | 539 | ||
540 | key.data = folder->fl_filename; | 540 | key.data = folder->fl_filename; |
541 | key.len = strlen(folder->fl_filename); | 541 | key.len = strlen(folder->fl_filename); |
542 | 542 | ||
543 | r = chash_get(parent->fl_subfolders_hash, &key, &data); | 543 | r = chash_get(parent->fl_subfolders_hash, &key, &data); |
544 | if (r < 0) | 544 | if (r < 0) |
545 | return MAILMH_ERROR_FOLDER; | 545 | return MAILMH_ERROR_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); |
692 | if (r != MAILMH_NO_ERROR) | 696 | if (r != MAILMH_NO_ERROR) |
693 | return r; | 697 | return r; |
694 | 698 | ||
695 | fd = open(filename, flags); | 699 | fd = open(filename, flags); |
696 | free(filename); | 700 | free(filename); |
697 | if (fd == -1) | 701 | if (fd == -1) |
698 | return MAILMH_ERROR_MSG_NOT_FOUND; | 702 | return MAILMH_ERROR_MSG_NOT_FOUND; |
699 | 703 | ||
700 | * result = fd; | 704 | * result = fd; |
701 | 705 | ||
702 | return MAILMH_NO_ERROR; | 706 | return MAILMH_NO_ERROR; |
703 | } | 707 | } |
704 | 708 | ||
705 | int mailmh_folder_get_message_size(struct mailmh_folder * folder, | 709 | int mailmh_folder_get_message_size(struct mailmh_folder * folder, |
706 | uint32_t index, size_t * result) | 710 | uint32_t index, size_t * result) |
707 | { | 711 | { |
708 | int r; | 712 | int r; |
709 | char * filename; | 713 | char * filename; |
710 | struct stat buf; | 714 | struct stat buf; |
711 | 715 | ||
712 | r = mailmh_folder_get_message_filename(folder, index, &filename); | 716 | r = mailmh_folder_get_message_filename(folder, index, &filename); |
713 | if (r != MAILMH_NO_ERROR) | 717 | if (r != MAILMH_NO_ERROR) |
714 | return r; | 718 | return r; |
715 | 719 | ||
716 | r = stat(filename, &buf); | 720 | r = stat(filename, &buf); |
717 | free(filename); | 721 | free(filename); |
718 | if (r < 0) | 722 | if (r < 0) |
719 | return MAILMH_ERROR_FILE; | 723 | return MAILMH_ERROR_FILE; |
720 | 724 | ||
721 | * result = buf.st_size; | 725 | * result = buf.st_size; |
722 | 726 | ||
723 | return MAILMH_NO_ERROR; | 727 | return MAILMH_NO_ERROR; |
724 | } | 728 | } |
725 | 729 | ||
726 | int mailmh_folder_add_message_uid(struct mailmh_folder * folder, | 730 | int mailmh_folder_add_message_uid(struct mailmh_folder * folder, |
727 | const char * message, size_t size, | 731 | const char * message, size_t size, |
728 | uint32_t * pindex) | 732 | uint32_t * pindex) |
729 | { | 733 | { |
730 | char * tmpname; | 734 | char * tmpname; |
731 | int fd; | 735 | int fd; |
732 | size_t namesize; | 736 | size_t namesize; |
733 | size_t left; | 737 | size_t left; |
734 | ssize_t res; | 738 | ssize_t res; |
735 | struct mailmh_msg_info * msg_info; | 739 | struct mailmh_msg_info * msg_info; |
736 | uint32_t index; | 740 | uint32_t index; |
737 | int error; | 741 | int error; |
738 | int r; | 742 | int r; |
739 | unsigned int array_index; | 743 | unsigned int array_index; |
740 | struct stat buf; | 744 | struct stat buf; |
741 | chashdatum key; | 745 | chashdatum key; |
742 | chashdatum data; | 746 | chashdatum data; |
743 | 747 | ||
744 | #if 0 | 748 | #if 0 |
745 | r = mailmh_folder_update(folder); | 749 | r = mailmh_folder_update(folder); |
746 | if (r != MAILMH_NO_ERROR) { | 750 | if (r != MAILMH_NO_ERROR) { |
747 | error = r; | 751 | error = r; |
748 | goto err; | 752 | goto err; |
749 | } | 753 | } |
750 | #endif | 754 | #endif |
751 | 755 | ||
752 | namesize = strlen(folder->fl_filename) + 20; | 756 | namesize = strlen(folder->fl_filename) + 20; |
753 | tmpname = malloc(namesize); | 757 | tmpname = malloc(namesize); |
754 | snprintf(tmpname, namesize, "%s%ctmpXXXXXX", | 758 | snprintf(tmpname, namesize, "%s%ctmpXXXXXX", |
755 | folder->fl_filename, MAIL_DIR_SEPARATOR); | 759 | folder->fl_filename, MAIL_DIR_SEPARATOR); |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2321087..3908dbb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2322,264 +2322,268 @@ void CalendarView::beamCalendar() | |||
2322 | { | 2322 | { |
2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2324 | //qDebug("beamCalendar() "); | 2324 | //qDebug("beamCalendar() "); |
2325 | beamIncidenceList( delSel ); | 2325 | beamIncidenceList( delSel ); |
2326 | } | 2326 | } |
2327 | void CalendarView::beamFilteredCalendar() | 2327 | void CalendarView::beamFilteredCalendar() |
2328 | { | 2328 | { |
2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2330 | //qDebug("beamFilteredCalendar() "); | 2330 | //qDebug("beamFilteredCalendar() "); |
2331 | beamIncidenceList( delSel ); | 2331 | beamIncidenceList( delSel ); |
2332 | } | 2332 | } |
2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2334 | { | 2334 | { |
2335 | if ( beamDialog->exec () == QDialog::Rejected ) | 2335 | if ( beamDialog->exec () == QDialog::Rejected ) |
2336 | return; | 2336 | return; |
2337 | #ifdef DESKTOP_VERSION | 2337 | #ifdef DESKTOP_VERSION |
2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2339 | #else | 2339 | #else |
2340 | QString fn = "/tmp/kopibeamfile"; | 2340 | QString fn = "/tmp/kopibeamfile"; |
2341 | #endif | 2341 | #endif |
2342 | QString mes; | 2342 | QString mes; |
2343 | bool createbup = true; | 2343 | bool createbup = true; |
2344 | if ( createbup ) { | 2344 | if ( createbup ) { |
2345 | QString description = "\n"; | 2345 | QString description = "\n"; |
2346 | CalendarLocal* cal = new CalendarLocal(); | 2346 | CalendarLocal* cal = new CalendarLocal(); |
2347 | if ( beamDialog->beamLocal() ) | 2347 | if ( beamDialog->beamLocal() ) |
2348 | cal->setLocalTime(); | 2348 | cal->setLocalTime(); |
2349 | else | 2349 | else |
2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2351 | Incidence *incidence = delSel.first(); | 2351 | Incidence *incidence = delSel.first(); |
2352 | bool addText = false; | 2352 | bool addText = false; |
2353 | if ( delSel.count() < 10 ) | 2353 | if ( delSel.count() < 10 ) |
2354 | addText = true; | 2354 | addText = true; |
2355 | else { | 2355 | else { |
2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2357 | } | 2357 | } |
2358 | while ( incidence ) { | 2358 | while ( incidence ) { |
2359 | Incidence *in = incidence->clone(); | 2359 | Incidence *in = incidence->clone(); |
2360 | if ( ! in->summary().isEmpty() ) { | 2360 | if ( ! in->summary().isEmpty() ) { |
2361 | in->setDescription(""); | 2361 | in->setDescription(""); |
2362 | } else { | 2362 | } else { |
2363 | in->setSummary( in->description().left(20)); | 2363 | in->setSummary( in->description().left(20)); |
2364 | in->setDescription(""); | 2364 | in->setDescription(""); |
2365 | } | 2365 | } |
2366 | if ( addText ) | 2366 | if ( addText ) |
2367 | description += in->summary() + "\n"; | 2367 | description += in->summary() + "\n"; |
2368 | cal->addIncidence( in ); | 2368 | cal->addIncidence( in ); |
2369 | incidence = delSel.next(); | 2369 | incidence = delSel.next(); |
2370 | } | 2370 | } |
2371 | if ( beamDialog->beamVcal() ) { | 2371 | if ( beamDialog->beamVcal() ) { |
2372 | fn += ".vcs"; | 2372 | fn += ".vcs"; |
2373 | FileStorage storage( cal, fn, new VCalFormat ); | 2373 | FileStorage storage( cal, fn, new VCalFormat ); |
2374 | storage.save(); | 2374 | storage.save(); |
2375 | } else { | 2375 | } else { |
2376 | fn += ".ics"; | 2376 | fn += ".ics"; |
2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2378 | storage.save(); | 2378 | storage.save(); |
2379 | } | 2379 | } |
2380 | delete cal; | 2380 | delete cal; |
2381 | mes = i18n("KO/Pi: Ready for beaming"); | 2381 | mes = i18n("KO/Pi: Ready for beaming"); |
2382 | topLevelWidget()->setCaption(mes); | 2382 | topLevelWidget()->setCaption(mes); |
2383 | KApplication::convert2latin1( fn ); | 2383 | KApplication::convert2latin1( fn ); |
2384 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2385 | Ir *ir = new Ir( this ); | 2385 | Ir *ir = new Ir( this ); |
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(); |
2522 | if ( mEventEditor->exec() ) { | 2526 | if ( mEventEditor->exec() ) { |
2523 | mCalendar->addEvent( e ); | 2527 | mCalendar->addEvent( e ); |
2524 | updateView(); | 2528 | updateView(); |
2525 | } else { | 2529 | } else { |
2526 | delete e; | 2530 | delete e; |
2527 | } | 2531 | } |
2528 | } | 2532 | } |
2529 | } | 2533 | } |
2530 | 2534 | ||
2531 | void CalendarView::newEvent() | 2535 | void CalendarView::newEvent() |
2532 | { | 2536 | { |
2533 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2537 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2534 | KOAgendaView *aView = mViewManager->agendaView(); | 2538 | KOAgendaView *aView = mViewManager->agendaView(); |
2535 | if (aView) { | 2539 | if (aView) { |
2536 | if (aView->selectionStart().isValid()) { | 2540 | if (aView->selectionStart().isValid()) { |
2537 | if (aView->selectedIsAllDay()) { | 2541 | if (aView->selectedIsAllDay()) { |
2538 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2542 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2539 | } else { | 2543 | } else { |
2540 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2544 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2541 | } | 2545 | } |
2542 | return; | 2546 | return; |
2543 | } | 2547 | } |
2544 | } | 2548 | } |
2545 | 2549 | ||
2546 | QDate date = mNavigator->selectedDates().first(); | 2550 | QDate date = mNavigator->selectedDates().first(); |
2547 | QDateTime current = QDateTime::currentDateTime(); | 2551 | QDateTime current = QDateTime::currentDateTime(); |
2548 | if ( date <= current.date() ) { | 2552 | if ( date <= current.date() ) { |
2549 | int hour = current.time().hour() +1; | 2553 | int hour = current.time().hour() +1; |
2550 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2554 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2551 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2555 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2552 | } else | 2556 | } else |
2553 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2557 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2554 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2558 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2555 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2559 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2556 | } | 2560 | } |
2557 | 2561 | ||
2558 | void CalendarView::newEvent(QDateTime fh) | 2562 | void CalendarView::newEvent(QDateTime fh) |
2559 | { | 2563 | { |
2560 | newEvent(fh, | 2564 | newEvent(fh, |
2561 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2565 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2562 | } | 2566 | } |
2563 | 2567 | ||
2564 | void CalendarView::newEvent(QDate dt) | 2568 | void CalendarView::newEvent(QDate dt) |
2565 | { | 2569 | { |
2566 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2570 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2567 | QDateTime(dt, QTime(0,0,0)), true); | 2571 | QDateTime(dt, QTime(0,0,0)), true); |
2568 | } | 2572 | } |
2569 | 2573 | ||
2570 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2574 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2571 | { | 2575 | { |
2572 | 2576 | ||
2573 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2577 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2574 | if ( mFilterView->filtersEnabled() ) { | 2578 | if ( mFilterView->filtersEnabled() ) { |
2575 | CalFilter *filter = mFilterView->selectedFilter(); | 2579 | CalFilter *filter = mFilterView->selectedFilter(); |
2576 | if (filter && filter->showCategories()) { | 2580 | if (filter && filter->showCategories()) { |
2577 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2581 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2578 | } | 2582 | } |
2579 | if ( filter ) | 2583 | if ( filter ) |
2580 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2584 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2581 | } | 2585 | } |
2582 | showEventEditor(); | 2586 | showEventEditor(); |
2583 | } | 2587 | } |
2584 | void CalendarView::todoAdded(Todo * t) | 2588 | void CalendarView::todoAdded(Todo * t) |
2585 | { | 2589 | { |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12acd1..9cafc60 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -249,256 +249,257 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | |||
249 | if ( cn ) { | 249 | if ( cn ) { |
250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
251 | if ( ci ){ | 251 | if ( ci ){ |
252 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
253 | ci->setOn( false ); | 253 | ci->setOn( false ); |
254 | else | 254 | else |
255 | ci->setOn( true ); | 255 | ci->setOn( true ); |
256 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
257 | if ( cn ) { | 257 | if ( cn ) { |
258 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
259 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
270 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
271 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
272 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
273 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
274 | break; | 274 | break; |
275 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
276 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
277 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | 278 | e->accept(); |
279 | return; | 279 | return; |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | e->ignore(); | 282 | e->ignore(); |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | e->ignore(); | 287 | e->ignore(); |
288 | } | 288 | } |
289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
290 | { | 290 | { |
291 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
292 | mMousePressed = false; | 292 | mMousePressed = false; |
293 | } | 293 | } |
294 | 294 | ||
295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | if (!e) return; | 297 | if (!e) return; |
298 | 298 | ||
299 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
300 | 300 | ||
301 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
302 | 302 | ||
303 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
304 | if (!item) return; | 304 | if (!item) return; |
305 | 305 | ||
306 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
307 | } | 307 | } |
308 | 308 | ||
309 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
310 | 310 | ||
311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
312 | QLineEdit(parent) | 312 | QLineEdit(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 ); |
441 | 442 | ||
442 | mPopupMenu->setCheckable( true ); | 443 | mPopupMenu->setCheckable( true ); |
443 | mItemPopupMenu->setCheckable( true ); | 444 | mItemPopupMenu->setCheckable( true ); |
444 | // Double clicking conflicts with opening/closing the subtree | 445 | // Double clicking conflicts with opening/closing the subtree |
445 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 446 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
446 | SLOT( editItem( QListViewItem *) ) ); | 447 | SLOT( editItem( QListViewItem *) ) ); |
447 | /* | 448 | /* |
448 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 449 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
449 | const QPoint &,int ) ), | 450 | const QPoint &,int ) ), |
450 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 451 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
451 | */ | 452 | */ |
452 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 453 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
453 | const QPoint &,int ) ), | 454 | const QPoint &,int ) ), |
454 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 455 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
455 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 456 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
456 | SLOT( itemClicked( QListViewItem * ) ) ); | 457 | SLOT( itemClicked( QListViewItem * ) ) ); |
457 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 458 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
458 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 459 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
459 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 460 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
460 | SLOT( updateView() ) ); | 461 | SLOT( updateView() ) ); |
461 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 462 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
462 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 463 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
463 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 464 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
464 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 465 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
465 | 466 | ||
466 | #if 0 | 467 | #if 0 |
467 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 468 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
468 | SLOT(selectionChanged(QListViewItem *))); | 469 | SLOT(selectionChanged(QListViewItem *))); |
469 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 470 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
470 | SLOT(selectionChanged(QListViewItem *))); | 471 | SLOT(selectionChanged(QListViewItem *))); |
471 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 472 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
472 | SLOT(selectionChanged(QListViewItem *))); | 473 | SLOT(selectionChanged(QListViewItem *))); |
473 | #endif | 474 | #endif |
474 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 475 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
475 | SLOT( processSelectionChange() ) ); | 476 | SLOT( processSelectionChange() ) ); |
476 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 477 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
477 | SLOT( addQuickTodo() ) ); | 478 | SLOT( addQuickTodo() ) ); |
478 | // if ( QApplication::desktop()->width() < 480 ) { | 479 | // if ( QApplication::desktop()->width() < 480 ) { |
479 | // setNarrow(); | 480 | // setNarrow(); |
480 | // mTodoListView->setColumnWidth( 0, 100 ); | 481 | // mTodoListView->setColumnWidth( 0, 100 ); |
481 | 482 | ||
482 | // } | 483 | // } |
483 | 484 | ||
484 | } | 485 | } |
485 | 486 | ||
486 | KOTodoView::~KOTodoView() | 487 | KOTodoView::~KOTodoView() |
487 | { | 488 | { |
488 | delete mDocPrefs; | 489 | delete mDocPrefs; |
489 | } | 490 | } |
490 | 491 | ||
491 | void KOTodoView::jumpToDate () | 492 | void KOTodoView::jumpToDate () |
492 | { | 493 | { |
493 | // if (mActiveItem) { | 494 | // if (mActiveItem) { |
494 | // mActiveItem->todo()); | 495 | // mActiveItem->todo()); |
495 | // if ( mActiveItem->todo()->hasDueDate() ) | 496 | // if ( mActiveItem->todo()->hasDueDate() ) |
496 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 497 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
497 | } | 498 | } |
498 | 499 | ||
499 | void KOTodoView::setNarrow() | 500 | void KOTodoView::setNarrow() |
500 | { | 501 | { |
501 | //mTodoListView->setColumnWidth( 0, 120 ); | 502 | //mTodoListView->setColumnWidth( 0, 120 ); |
502 | mTodoListView->setColumnWidth( 1, 35 ); | 503 | mTodoListView->setColumnWidth( 1, 35 ); |
503 | mTodoListView->setColumnWidth( 2, 40 ); | 504 | mTodoListView->setColumnWidth( 2, 40 ); |
504 | mTodoListView->setColumnWidth( 3, 80 ); | 505 | mTodoListView->setColumnWidth( 3, 80 ); |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 85647b1..ae0b334 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,173 +1,173 @@ | |||
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 { |
110 | setText(3,""); | 110 | setText(3,""); |
111 | setText(4,""); | 111 | setText(4,""); |
112 | } | 112 | } |
113 | setSortKey(3,keyd); | 113 | setSortKey(3,keyd); |
114 | setSortKey(4,keyt); | 114 | setSortKey(4,keyt); |
115 | 115 | ||
116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
118 | 118 | ||
119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
120 | setText(6,mTodo->categoriesStr()); | 120 | setText(6,mTodo->categoriesStr()); |
121 | 121 | ||
122 | #if 0 | 122 | #if 0 |
123 | // Find sort id in description. It's the text behind the last '#' character | 123 | // Find sort id in description. It's the text behind the last '#' character |
124 | // found in the description. White spaces are removed from beginning and end | 124 | // found in the description. White spaces are removed from beginning and end |
125 | // of sort id. | 125 | // of sort id. |
126 | int pos = mTodo->description().findRev('#'); | 126 | int pos = mTodo->description().findRev('#'); |
127 | if (pos < 0) { | 127 | if (pos < 0) { |
128 | setText(6,""); | 128 | setText(6,""); |
129 | } else { | 129 | } else { |
130 | QString str = mTodo->description().mid(pos+1); | 130 | QString str = mTodo->description().mid(pos+1); |
131 | str.stripWhiteSpace(); | 131 | str.stripWhiteSpace(); |
132 | setText(6,str); | 132 | setText(6,str); |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | m_known = false; | 136 | m_known = false; |
137 | m_init = false; | 137 | m_init = false; |
138 | 138 | ||
139 | setMyPixmap(); | 139 | setMyPixmap(); |
140 | 140 | ||
141 | } | 141 | } |
142 | void KOTodoViewItem::setMyPixmap() | 142 | void KOTodoViewItem::setMyPixmap() |
143 | { | 143 | { |
144 | int size = 5; | 144 | int size = 5; |
145 | QPixmap pixi = QPixmap( 1, 1 ); | 145 | QPixmap pixi = QPixmap( 1, 1 ); |
146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
147 | // pixi = SmallIcon("redcross16"); | 147 | // pixi = SmallIcon("redcross16"); |
148 | // } else { | 148 | // } else { |
149 | QPainter p; | 149 | QPainter p; |
150 | 150 | ||
151 | int pixSize = 0; | 151 | int pixSize = 0; |
152 | QPixmap pPix = QPixmap( size, size ); | 152 | QPixmap pPix = QPixmap( size, size ); |
153 | if ( mTodo->description().length() > 0 ) { | 153 | if ( mTodo->description().length() > 0 ) { |
154 | pixi.resize(size, pixSize+size); | 154 | pixi.resize(size, pixSize+size); |
155 | pPix.fill( Qt::darkGreen ); | 155 | pPix.fill( Qt::darkGreen ); |
156 | p.begin( &pixi ); | 156 | p.begin( &pixi ); |
157 | p. drawPixmap ( 0, pixSize, pPix); | 157 | p. drawPixmap ( 0, pixSize, pPix); |
158 | p.end(); | 158 | p.end(); |
159 | pixSize += size; | 159 | pixSize += size; |
160 | } | 160 | } |
161 | if ( mTodo->isAlarmEnabled() ) { | 161 | if ( mTodo->isAlarmEnabled() ) { |
162 | pixi.resize(size, pixSize+size); | 162 | pixi.resize(size, pixSize+size); |
163 | pPix.fill( Qt::red ); | 163 | pPix.fill( Qt::red ); |
164 | p.begin( &pixi ); | 164 | p.begin( &pixi ); |
165 | p. drawPixmap ( 0, pixSize, pPix); | 165 | p. drawPixmap ( 0, pixSize, pPix); |
166 | p.end(); | 166 | p.end(); |
167 | pixSize += size; | 167 | pixSize += size; |
168 | } | 168 | } |
169 | // } | 169 | // } |
170 | if ( pixi.width() > 1 ) { | 170 | if ( pixi.width() > 1 ) { |
171 | setPixmap ( 0,pixi ) ; | 171 | setPixmap ( 0,pixi ) ; |
172 | } | 172 | } |
173 | 173 | ||
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 24b8349..c2ee2c9 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -129,258 +129,261 @@ class SharpParser : public QObject | |||
129 | for( i = 1; i <= 7; ++i ) { | 129 | for( i = 1; i <= 7; ++i ) { |
130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
131 | bb = 2 << (i-1); | 131 | bb = 2 << (i-1); |
132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
133 | } | 133 | } |
134 | // qDebug("next "); | 134 | // qDebug("next "); |
135 | QString posStr = attList[13]; | 135 | QString posStr = attList[13]; |
136 | int pos = posStr.toInt(); | 136 | int pos = posStr.toInt(); |
137 | Recurrence *r = event->recurrence(); | 137 | Recurrence *r = event->recurrence(); |
138 | 138 | ||
139 | if ( rtype == "0" ) { | 139 | if ( rtype == "0" ) { |
140 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 140 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
141 | else r->setDaily( freq, -1 ); | 141 | else r->setDaily( freq, -1 ); |
142 | } else if ( rtype == "1" ) { | 142 | } else if ( rtype == "1" ) { |
143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
144 | else r->setWeekly( freq, weekDays, -1 ); | 144 | else r->setWeekly( freq, weekDays, -1 ); |
145 | } else if ( rtype == "3" ) { | 145 | } else if ( rtype == "3" ) { |
146 | if ( hasEndDate ) | 146 | if ( hasEndDate ) |
147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
148 | else | 148 | else |
149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
150 | r->addMonthlyDay( startDate.day() ); | 150 | r->addMonthlyDay( startDate.day() ); |
151 | } else if ( rtype == "2" ) { | 151 | } else if ( rtype == "2" ) { |
152 | if ( hasEndDate ) | 152 | if ( hasEndDate ) |
153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
154 | else | 154 | else |
155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
156 | QBitArray days( 7 ); | 156 | QBitArray days( 7 ); |
157 | days.fill( false ); | 157 | days.fill( false ); |
158 | days.setBit( startDate.dayOfWeek() - 1 ); | 158 | days.setBit( startDate.dayOfWeek() - 1 ); |
159 | r->addMonthlyPos( pos, days ); | 159 | r->addMonthlyPos( pos, days ); |
160 | } else if ( rtype == "4" ) { | 160 | } else if ( rtype == "4" ) { |
161 | if ( hasEndDate ) | 161 | if ( hasEndDate ) |
162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
163 | else | 163 | else |
164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
165 | r->addYearlyNum( startDate.month() ); | 165 | r->addYearlyNum( startDate.month() ); |
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | event->recurrence()->unsetRecurs(); | 168 | event->recurrence()->unsetRecurs(); |
169 | } | 169 | } |
170 | 170 | ||
171 | QString categoryList = attList[1] ; | 171 | QString categoryList = attList[1] ; |
172 | event->setCategories( categoryList ); | 172 | event->setCategories( categoryList ); |
173 | 173 | ||
174 | // strange 0 semms to mean: alarm enabled | 174 | // strange 0 semms to mean: alarm enabled |
175 | if ( attList[8] == "0" ) { | 175 | if ( attList[8] == "0" ) { |
176 | Alarm *alarm; | 176 | Alarm *alarm; |
177 | if ( event->alarms().count() > 0 ) | 177 | if ( event->alarms().count() > 0 ) |
178 | alarm = event->alarms().first(); | 178 | alarm = event->alarms().first(); |
179 | else { | 179 | else { |
180 | alarm = new Alarm( event ); | 180 | alarm = new Alarm( event ); |
181 | event->addAlarm( alarm ); | 181 | event->addAlarm( alarm ); |
182 | alarm->setType( Alarm::Audio ); | 182 | alarm->setType( Alarm::Audio ); |
183 | } | 183 | } |
184 | //alarm->setType( Alarm::Audio ); | 184 | //alarm->setType( Alarm::Audio ); |
185 | alarm->setEnabled( true ); | 185 | alarm->setEnabled( true ); |
186 | int alarmOffset = attList[9].toInt(); | 186 | int alarmOffset = attList[9].toInt(); |
187 | alarm->setStartOffset( alarmOffset * -60 ); | 187 | alarm->setStartOffset( alarmOffset * -60 ); |
188 | } else { | 188 | } else { |
189 | Alarm *alarm; | 189 | Alarm *alarm; |
190 | if ( event->alarms().count() > 0 ) { | 190 | if ( event->alarms().count() > 0 ) { |
191 | alarm = event->alarms().first(); | 191 | alarm = event->alarms().first(); |
192 | alarm->setType( Alarm::Audio ); | 192 | alarm->setType( Alarm::Audio ); |
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; |
323 | add = s[k].unicode (); | 326 | add = s[k].unicode (); |
324 | if ( k < 16 ) | 327 | if ( k < 16 ) |
325 | mul = mul * mul; | 328 | mul = mul * mul; |
326 | add = add * mul *i*i*i; | 329 | add = add * mul *i*i*i; |
327 | cSum += add; | 330 | cSum += add; |
328 | } | 331 | } |
329 | } | 332 | } |
330 | } | 333 | } |
331 | return cSum; | 334 | return cSum; |
332 | 335 | ||
333 | } | 336 | } |
334 | #include <stdlib.h> | 337 | #include <stdlib.h> |
335 | #define DEBUGMODE false | 338 | #define DEBUGMODE false |
336 | //#define DEBUGMODE true | 339 | //#define DEBUGMODE true |
337 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 340 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
338 | { | 341 | { |
339 | 342 | ||
340 | 343 | ||
341 | bool debug = DEBUGMODE; | 344 | bool debug = DEBUGMODE; |
342 | QString text; | 345 | QString text; |
343 | QString codec = "utf8"; | 346 | QString codec = "utf8"; |
344 | QLabel status ( i18n("Reading events ..."), 0 ); | 347 | QLabel status ( i18n("Reading events ..."), 0 ); |
345 | 348 | ||
346 | int w = status.sizeHint().width()+20 ; | 349 | int w = status.sizeHint().width()+20 ; |
347 | if ( w < 200 ) w = 200; | 350 | if ( w < 200 ) w = 200; |
348 | int h = status.sizeHint().height()+20 ; | 351 | int h = status.sizeHint().height()+20 ; |
349 | int dw = QApplication::desktop()->width(); | 352 | int dw = QApplication::desktop()->width(); |
350 | int dh = QApplication::desktop()->height(); | 353 | int dh = QApplication::desktop()->height(); |
351 | status.setCaption(i18n("Reading DTM Data") ); | 354 | status.setCaption(i18n("Reading DTM Data") ); |
352 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 355 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
353 | status.show(); | 356 | status.show(); |
354 | status.raise(); | 357 | status.raise(); |
355 | qApp->processEvents(); | 358 | qApp->processEvents(); |
356 | QString fileName; | 359 | QString fileName; |
357 | if ( ! debug ) { | 360 | if ( ! debug ) { |
358 | fileName = "/tmp/kopitempout"; | 361 | fileName = "/tmp/kopitempout"; |
359 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 362 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
360 | system ( command.latin1() ); | 363 | system ( command.latin1() ); |
361 | } else { | 364 | } else { |
362 | fileName = "/tmp/events.txt"; | 365 | fileName = "/tmp/events.txt"; |
363 | 366 | ||
364 | } | 367 | } |
365 | QFile file( fileName ); | 368 | QFile file( fileName ); |
366 | if (!file.open( IO_ReadOnly ) ) { | 369 | if (!file.open( IO_ReadOnly ) ) { |
367 | return false; | 370 | return false; |
368 | 371 | ||
369 | } | 372 | } |
370 | QTextStream ts( &file ); | 373 | QTextStream ts( &file ); |
371 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 374 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
372 | text = ts.read(); | 375 | text = ts.read(); |
373 | file.close(); | 376 | file.close(); |
374 | status.setText( i18n("Processing events ...") ); | 377 | status.setText( i18n("Processing events ...") ); |
375 | status.raise(); | 378 | status.raise(); |
376 | qApp->processEvents(); | 379 | qApp->processEvents(); |
377 | fromString2Cal( calendar, existngCal, text, "Event" ); | 380 | fromString2Cal( calendar, existngCal, text, "Event" ); |
378 | status.setText( i18n("Reading todos ...") ); | 381 | status.setText( i18n("Reading todos ...") ); |
379 | qApp->processEvents(); | 382 | qApp->processEvents(); |
380 | if ( ! debug ) { | 383 | if ( ! debug ) { |
381 | fileName = "/tmp/kopitempout"; | 384 | fileName = "/tmp/kopitempout"; |
382 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 385 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
383 | system ( command.latin1() ); | 386 | system ( command.latin1() ); |
384 | } else { | 387 | } else { |
385 | fileName = "/tmp/todo.txt"; | 388 | fileName = "/tmp/todo.txt"; |
386 | } | 389 | } |
@@ -1 +1 @@ | |||
version = "1.9.13"; | version = "1.9.14"; | ||