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,258 +1,280 @@ | |||
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. |
131 | (And for Linux, of course). | 153 | (And for Linux, of course). |
132 | It is a port of the Passwordmanager of KDE. | 154 | It is a port of the Passwordmanager of KDE. |
133 | It will need the MicroKDElibs to run. | 155 | It will need the MicroKDElibs to run. |
134 | 156 | ||
135 | Made loading of addressbooks in KA/Pi up to 7 times faster! | 157 | Made loading of addressbooks in KA/Pi up to 7 times faster! |
136 | The bigger your addressbook file, the more starting speed | 158 | The bigger your addressbook file, the more starting speed |
137 | will you gain. (relatively) | 159 | will you gain. (relatively) |
138 | 160 | ||
139 | The Qtopia addressbook connector is now platform independend | 161 | The Qtopia addressbook connector is now platform independend |
140 | as well and should work on any platform for importing/exporting | 162 | as well and should work on any platform for importing/exporting |
141 | Qtopia and Opie XML files. | 163 | Qtopia and Opie XML files. |
142 | 164 | ||
143 | Added a +30min feature to the timezone settings to make | 165 | Added a +30min feature to the timezone settings to make |
144 | KDE-Pim/Pi useable in Australia and other parts on the | 166 | KDE-Pim/Pi useable in Australia and other parts on the |
145 | world with strange timezones ;-) | 167 | world with strange timezones ;-) |
146 | 168 | ||
147 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. | 169 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. |
148 | 170 | ||
149 | It is now possible to disable the | 171 | It is now possible to disable the |
150 | "receive data via infrared" feature, such that syncing with | 172 | "receive data via infrared" feature, such that syncing with |
151 | Outlook is now possible again with Kx/Pi runing. | 173 | Outlook is now possible again with Kx/Pi runing. |
152 | Please disable it, before syncing Sharp DTM with Outlook. | 174 | Please disable it, before syncing Sharp DTM with Outlook. |
153 | For your convenience, the "receive data via infrared" feature | 175 | For your convenience, the "receive data via infrared" feature |
154 | is disabled automatically, if you sync Kx/Pi with DTM. | 176 | is disabled automatically, if you sync Kx/Pi with DTM. |
155 | You have to enable it again manually after syncing. | 177 | You have to enable it again manually after syncing. |
156 | Enabling this feature makes it impossible to start the | 178 | Enabling this feature makes it impossible to start the |
157 | Sharp DTM apps. If this feature is enabled, you will only get the | 179 | Sharp DTM apps. If this feature is enabled, you will only get the |
158 | alarm notification from KO/Pi and not from the Sharp calendar. | 180 | alarm notification from KO/Pi and not from the Sharp calendar. |
159 | This is very useful if you sync KO/Pi with Sharp DTM, | 181 | This is very useful if you sync KO/Pi with Sharp DTM, |
160 | because after syncing you usually would get notified about | 182 | because after syncing you usually would get notified about |
161 | an alarm by KO/Pi and the Sharp Calendar. | 183 | an alarm by KO/Pi and the Sharp Calendar. |
162 | 184 | ||
163 | Together with the Linux desktop version of KO/Pi | 185 | Together with the Linux desktop version of KO/Pi |
164 | it is now possible to sync KO/Pi on the Zaurus | 186 | it is now possible to sync KO/Pi on the Zaurus |
165 | with the complete KDE-desktop (3.3 or later) | 187 | with the complete KDE-desktop (3.3 or later) |
166 | calendar data easily. | 188 | calendar data easily. |
167 | That makes it possible to sync the Z with one | 189 | That makes it possible to sync the Z with one |
168 | click of a mouse with the KDE-Desktop. | 190 | click of a mouse with the KDE-Desktop. |
169 | This feature it available for all Zaurus platforms KO/Pi | 191 | This feature it available for all Zaurus platforms KO/Pi |
170 | is running on. | 192 | is running on. |
171 | The only thing needed is a running KO/Pi on Linux and | 193 | The only thing needed is a running KO/Pi on Linux and |
172 | a compiled version of the small | 194 | a compiled version of the small |
173 | KDE-Pim/Pi<->KDE-Desktop access command line program, | 195 | KDE-Pim/Pi<->KDE-Desktop access command line program, |
174 | which is in the KDE-Pim/Pi sources available. | 196 | which is in the KDE-Pim/Pi sources available. |
175 | 197 | ||
176 | The "KDE-desktop" syncing feature for KA/Pi will follow | 198 | The "KDE-desktop" syncing feature for KA/Pi will follow |
177 | in the next releases. | 199 | in the next releases. |
178 | 200 | ||
179 | Fixed the vcard export bug, which had the version 1.9.8. | 201 | Fixed the vcard export bug, which had the version 1.9.8. |
180 | 202 | ||
181 | Added missing GERMAN translation to KO/Pi. | 203 | Added missing GERMAN translation to KO/Pi. |
182 | Hi PsionX, could you add the missing french translation?Thx! | 204 | Hi PsionX, could you add the missing french translation?Thx! |
183 | 205 | ||
184 | Translation files for KA/Pi are available as well. | 206 | Translation files for KA/Pi are available as well. |
185 | GERMAN translation will be available in the next release. | 207 | GERMAN translation will be available in the next release. |
186 | PsionX ( yres, you again ;-) ), could you start translating | 208 | PsionX ( yres, you again ;-) ), could you start translating |
187 | KA/Pi? Thx! | 209 | KA/Pi? Thx! |
188 | 210 | ||
189 | You can download the version 1.9.9 at | 211 | You can download the version 1.9.9 at |
190 | 212 | ||
191 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 | 213 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 |
192 | 214 | ||
193 | Note: | 215 | Note: |
194 | To run the mail program OM/Pi you need libopenssl. | 216 | To run the mail program OM/Pi you need libopenssl. |
195 | A link to a download loaction is available at | 217 | A link to a download loaction is available at |
196 | ZSI at www.killefiz.de | 218 | ZSI at www.killefiz.de |
197 | 219 | ||
198 | 220 | ||
199 | ********** VERSION 1.9.8 ************ | 221 | ********** VERSION 1.9.8 ************ |
200 | 222 | ||
201 | Fixed character decoding in OM/Pi. | 223 | Fixed character decoding in OM/Pi. |
202 | (e.g. German "Umlaute" were not displayed properly.) | 224 | (e.g. German "Umlaute" were not displayed properly.) |
203 | 225 | ||
204 | Made is possible to reparent todos in KO/Pi. | 226 | Made is possible to reparent todos in KO/Pi. |
205 | Use contextmenu or keys (look at Help-Keys + Colors) for that. | 227 | Use contextmenu or keys (look at Help-Keys + Colors) for that. |
206 | 228 | ||
207 | Added the missing Sync-Howto and WhatsNew to the packages. | 229 | Added the missing Sync-Howto and WhatsNew to the packages. |
208 | 230 | ||
209 | KO/Pi on Linux desktop can now sync with KDE desktop. | 231 | KO/Pi on Linux desktop can now sync with KDE desktop. |
210 | That means: When using KO/Pi on Linux desktop for syncing with | 232 | That means: When using KO/Pi on Linux desktop for syncing with |
211 | KDE desktop and the Zaurus, the Zaurus can be synced now | 233 | KDE desktop and the Zaurus, the Zaurus can be synced now |
212 | with all KDE-Calendar resources, not only with one local file. | 234 | with all KDE-Calendar resources, not only with one local file. |
213 | (That makes it possible to sync the Zaurus with the | 235 | (That makes it possible to sync the Zaurus with the |
214 | calendar data on a Kolab server) | 236 | calendar data on a Kolab server) |
215 | 237 | ||
216 | KA/Pi syncing with KDE desktop will be available in the next version. | 238 | KA/Pi syncing with KDE desktop will be available in the next version. |
217 | 239 | ||
218 | 240 | ||
219 | ********** VERSION 1.9.7 ************ | 241 | ********** VERSION 1.9.7 ************ |
220 | 242 | ||
221 | KO/Pi - KA/Pi on Windows: | 243 | KO/Pi - KA/Pi on Windows: |
222 | Now a directory can be defined by the user, where the | 244 | Now a directory can be defined by the user, where the |
223 | application/config data should be saved. | 245 | application/config data should be saved. |
224 | Define your desired path in the evironment variable | 246 | Define your desired path in the evironment variable |
225 | MICROKDEHOME | 247 | MICROKDEHOME |
226 | before starting KO/Pi or KA/Pi. | 248 | before starting KO/Pi or KA/Pi. |
227 | 249 | ||
228 | An easy Kx/Pi to Kx/Pi syncing is now possible | 250 | An easy Kx/Pi to Kx/Pi syncing is now possible |
229 | (it is called Pi-Sync) via network. | 251 | (it is called Pi-Sync) via network. |
230 | Please look at the Sync Howto. | 252 | Please look at the Sync Howto. |
231 | 253 | ||
232 | Exporting of calendar data and contacts to mobile phones is now possible. | 254 | Exporting of calendar data and contacts to mobile phones is now possible. |
233 | The SyncHowto is updated with information howto | 255 | The SyncHowto is updated with information howto |
234 | access/sync mobile phones. | 256 | access/sync mobile phones. |
235 | Please look at the Sync Howto. | 257 | Please look at the Sync Howto. |
236 | 258 | ||
237 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. | 259 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. |
238 | Please disable Fastload for the original contact/calendar applications | 260 | Please disable Fastload for the original contact/calendar applications |
239 | and close them. | 261 | and close them. |
240 | KO/Pi and KA/Pi must be running in order to receive the data. | 262 | KO/Pi and KA/Pi must be running in order to receive the data. |
241 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) | 263 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) |
242 | 264 | ||
243 | In the KA/Pi details view are now the preferred tel. numbers displayed on top | 265 | In the KA/Pi details view are now the preferred tel. numbers displayed on top |
244 | of the other data ( emails/tel.numbers/addresses) | 266 | of the other data ( emails/tel.numbers/addresses) |
245 | 267 | ||
246 | Fixed some syncing problems in KA/Pi. | 268 | Fixed some syncing problems in KA/Pi. |
247 | 269 | ||
248 | Added font settings for the KA/Pi details view. | 270 | Added font settings for the KA/Pi details view. |
249 | Added fields "children's name" and "gender" to KA/Pi. | 271 | Added fields "children's name" and "gender" to KA/Pi. |
250 | 272 | ||
251 | Made searching in KA/Pi better: | 273 | Made searching in KA/Pi better: |
252 | Now the first item in a view is selected after a search automatically and | 274 | Now the first item in a view is selected after a search automatically and |
253 | the views can be scrolled up/down when the search input field has the keyboard focus. | 275 | the views can be scrolled up/down when the search input field has the keyboard focus. |
254 | 276 | ||
255 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. | 277 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. |
256 | 278 | ||
257 | 279 | ||
258 | ********** VERSION 1.9.6 ************ | 280 | ********** VERSION 1.9.6 ************ |
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 | |||
@@ -354,530 +354,534 @@ int mailmh_folder_update(struct mailmh_folder * folder) | |||
354 | if (ent != NULL) { | 354 | if (ent != NULL) { |
355 | 355 | ||
356 | snprintf(filename, PATH_MAX, | 356 | snprintf(filename, PATH_MAX, |
357 | "%s%c%s", folder->fl_filename, MAIL_DIR_SEPARATOR, ent->d_name); | 357 | "%s%c%s", folder->fl_filename, MAIL_DIR_SEPARATOR, ent->d_name); |
358 | 358 | ||
359 | if (stat(filename, &buf) == -1) | 359 | if (stat(filename, &buf) == -1) |
360 | continue; | 360 | continue; |
361 | 361 | ||
362 | if (S_ISREG(buf.st_mode)) { | 362 | if (S_ISREG(buf.st_mode)) { |
363 | index = strtoul(ent->d_name, NULL, 10); | 363 | index = strtoul(ent->d_name, NULL, 10); |
364 | if (index != 0) { | 364 | if (index != 0) { |
365 | struct mailmh_msg_info * msg_info; | 365 | struct mailmh_msg_info * msg_info; |
366 | unsigned int array_index; | 366 | unsigned int array_index; |
367 | chashdatum key; | 367 | chashdatum key; |
368 | chashdatum data; | 368 | chashdatum data; |
369 | 369 | ||
370 | msg_info = mailmh_msg_info_new(index, buf.st_size, buf.st_mtime); | 370 | msg_info = mailmh_msg_info_new(index, buf.st_size, buf.st_mtime); |
371 | if (msg_info == NULL) { | 371 | if (msg_info == NULL) { |
372 | res = MAILMH_ERROR_MEMORY; | 372 | res = MAILMH_ERROR_MEMORY; |
373 | goto closedir; | 373 | goto closedir; |
374 | } | 374 | } |
375 | 375 | ||
376 | r = carray_add(folder->fl_msgs_tab, msg_info, &array_index); | 376 | r = carray_add(folder->fl_msgs_tab, msg_info, &array_index); |
377 | if (r < 0) { | 377 | if (r < 0) { |
378 | mailmh_msg_info_free(msg_info); | 378 | mailmh_msg_info_free(msg_info); |
379 | res = MAILMH_ERROR_MEMORY; | 379 | res = MAILMH_ERROR_MEMORY; |
380 | goto closedir; | 380 | goto closedir; |
381 | } | 381 | } |
382 | msg_info->msg_array_index = array_index; | 382 | msg_info->msg_array_index = array_index; |
383 | 383 | ||
384 | if (index > max_index) | 384 | if (index > max_index) |
385 | max_index = index; | 385 | max_index = index; |
386 | 386 | ||
387 | #if 0 | 387 | #if 0 |
388 | r = cinthash_add(folder->fl_msgs_hash, msg_info->msg_index, msg_info); | 388 | r = cinthash_add(folder->fl_msgs_hash, msg_info->msg_index, msg_info); |
389 | #endif | 389 | #endif |
390 | key.data = &msg_info->msg_index; | 390 | key.data = &msg_info->msg_index; |
391 | key.len = sizeof(msg_info->msg_index); | 391 | key.len = sizeof(msg_info->msg_index); |
392 | data.data = msg_info; | 392 | data.data = msg_info; |
393 | data.len = 0; | 393 | data.len = 0; |
394 | 394 | ||
395 | r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); | 395 | r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); |
396 | if (r < 0) { | 396 | if (r < 0) { |
397 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); | 397 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); |
398 | mailmh_msg_info_free(msg_info); | 398 | mailmh_msg_info_free(msg_info); |
399 | res = MAILMH_ERROR_MEMORY; | 399 | res = MAILMH_ERROR_MEMORY; |
400 | goto closedir; | 400 | goto closedir; |
401 | } | 401 | } |
402 | } | 402 | } |
403 | } | 403 | } |
404 | else if (S_ISDIR(buf.st_mode)) { | 404 | else if (S_ISDIR(buf.st_mode)) { |
405 | struct mailmh_folder * subfolder; | 405 | struct mailmh_folder * subfolder; |
406 | unsigned int array_index; | 406 | unsigned int array_index; |
407 | chashdatum key; | 407 | chashdatum key; |
408 | chashdatum data; | 408 | chashdatum data; |
409 | 409 | ||
410 | if (ent->d_name[0] == '.') { | 410 | if (ent->d_name[0] == '.') { |
411 | if (ent->d_name[1] == 0) | 411 | if (ent->d_name[1] == 0) |
412 | continue; | 412 | continue; |
413 | if ((ent->d_name[1] == '.') && (ent->d_name[2] == 0)) | 413 | if ((ent->d_name[1] == '.') && (ent->d_name[2] == 0)) |
414 | continue; | 414 | continue; |
415 | } | 415 | } |
416 | 416 | ||
417 | key.data = ent->d_name; | 417 | key.data = ent->d_name; |
418 | key.len = strlen(ent->d_name); | 418 | key.len = strlen(ent->d_name); |
419 | r = chash_get(folder->fl_subfolders_hash, &key, &data); | 419 | r = chash_get(folder->fl_subfolders_hash, &key, &data); |
420 | if (r < 0) { | 420 | if (r < 0) { |
421 | subfolder = mailmh_folder_new(folder, ent->d_name); | 421 | subfolder = mailmh_folder_new(folder, ent->d_name); |
422 | if (subfolder == NULL) { | 422 | if (subfolder == NULL) { |
423 | res = MAILMH_ERROR_MEMORY; | 423 | res = MAILMH_ERROR_MEMORY; |
424 | goto closedir; | 424 | goto closedir; |
425 | } | 425 | } |
426 | 426 | ||
427 | r = carray_add(folder->fl_subfolders_tab, subfolder, &array_index); | 427 | r = carray_add(folder->fl_subfolders_tab, subfolder, &array_index); |
428 | if (r < 0) { | 428 | if (r < 0) { |
429 | mailmh_folder_free(subfolder); | 429 | mailmh_folder_free(subfolder); |
430 | res = MAILMH_ERROR_MEMORY; | 430 | res = MAILMH_ERROR_MEMORY; |
431 | goto closedir; | 431 | goto closedir; |
432 | } | 432 | } |
433 | subfolder->fl_array_index = array_index; | 433 | subfolder->fl_array_index = array_index; |
434 | 434 | ||
435 | key.data = subfolder->fl_filename; | 435 | key.data = subfolder->fl_filename; |
436 | key.len = strlen(subfolder->fl_filename); | 436 | key.len = strlen(subfolder->fl_filename); |
437 | data.data = subfolder; | 437 | data.data = subfolder; |
438 | data.len = 0; | 438 | data.len = 0; |
439 | r = chash_set(folder->fl_subfolders_hash, &key, &data, NULL); | 439 | r = chash_set(folder->fl_subfolders_hash, &key, &data, NULL); |
440 | if (r < 0) { | 440 | if (r < 0) { |
441 | carray_delete_fast(folder->fl_subfolders_tab, subfolder->fl_array_index); | 441 | carray_delete_fast(folder->fl_subfolders_tab, subfolder->fl_array_index); |
442 | mailmh_folder_free(subfolder); | 442 | mailmh_folder_free(subfolder); |
443 | res = MAILMH_ERROR_MEMORY; | 443 | res = MAILMH_ERROR_MEMORY; |
444 | goto closedir; | 444 | goto closedir; |
445 | } | 445 | } |
446 | } | 446 | } |
447 | } | 447 | } |
448 | } | 448 | } |
449 | } | 449 | } |
450 | while (ent != NULL); | 450 | while (ent != NULL); |
451 | 451 | ||
452 | folder->fl_max_index = max_index; | 452 | folder->fl_max_index = max_index; |
453 | 453 | ||
454 | mh_seq = malloc(strlen(folder->fl_filename) + 2 + sizeof(".mh_sequences")); | 454 | mh_seq = malloc(strlen(folder->fl_filename) + 2 + sizeof(".mh_sequences")); |
455 | if (mh_seq == NULL) { | 455 | if (mh_seq == NULL) { |
456 | res = MAILMH_ERROR_MEMORY; | 456 | res = MAILMH_ERROR_MEMORY; |
457 | goto closedir; | 457 | goto closedir; |
458 | } | 458 | } |
459 | strcpy(mh_seq, folder->fl_filename); | 459 | strcpy(mh_seq, folder->fl_filename); |
460 | strcat(mh_seq, MAIL_DIR_SEPARATOR_S); | 460 | strcat(mh_seq, MAIL_DIR_SEPARATOR_S); |
461 | strcat(mh_seq, ".mh_sequences"); | 461 | strcat(mh_seq, ".mh_sequences"); |
462 | 462 | ||
463 | if (stat(mh_seq, &buf) == -1) { | 463 | if (stat(mh_seq, &buf) == -1) { |
464 | int fd; | 464 | int fd; |
465 | 465 | ||
466 | fd = creat(mh_seq, S_IRUSR | S_IWUSR); | 466 | fd = creat(mh_seq, S_IRUSR | S_IWUSR); |
467 | if (fd != -1) | 467 | if (fd != -1) |
468 | close(fd); | 468 | close(fd); |
469 | } | 469 | } |
470 | free(mh_seq); | 470 | free(mh_seq); |
471 | 471 | ||
472 | closedir(d); | 472 | closedir(d); |
473 | 473 | ||
474 | return MAILMH_NO_ERROR; | 474 | return MAILMH_NO_ERROR; |
475 | 475 | ||
476 | closedir: | 476 | closedir: |
477 | closedir(d); | 477 | closedir(d); |
478 | err: | 478 | err: |
479 | return res; | 479 | return res; |
480 | } | 480 | } |
481 | 481 | ||
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); |
756 | fd = mkstemp(tmpname); | 760 | fd = mkstemp(tmpname); |
757 | if (fd < 0) { | 761 | if (fd < 0) { |
758 | error = MAILMH_ERROR_FILE; | 762 | error = MAILMH_ERROR_FILE; |
759 | goto free; | 763 | goto free; |
760 | } | 764 | } |
761 | 765 | ||
762 | left = size; | 766 | left = size; |
763 | while (left > 0) { | 767 | while (left > 0) { |
764 | res = write(fd, message, left); | 768 | res = write(fd, message, left); |
765 | if (res == -1) { | 769 | if (res == -1) { |
766 | close(fd); | 770 | close(fd); |
767 | error = MAILMH_ERROR_FILE; | 771 | error = MAILMH_ERROR_FILE; |
768 | goto free; | 772 | goto free; |
769 | } | 773 | } |
770 | 774 | ||
771 | left -= res; | 775 | left -= res; |
772 | } | 776 | } |
773 | close(fd); | 777 | close(fd); |
774 | 778 | ||
775 | r = stat(tmpname, &buf); | 779 | r = stat(tmpname, &buf); |
776 | if (r < 0) { | 780 | if (r < 0) { |
777 | error = MAILMH_ERROR_FILE; | 781 | error = MAILMH_ERROR_FILE; |
778 | goto free; | 782 | goto free; |
779 | } | 783 | } |
780 | 784 | ||
781 | r = mailmh_folder_alloc_msg(folder, tmpname, &index); | 785 | r = mailmh_folder_alloc_msg(folder, tmpname, &index); |
782 | if (r != MAILMH_NO_ERROR) { | 786 | if (r != MAILMH_NO_ERROR) { |
783 | unlink(tmpname); | 787 | unlink(tmpname); |
784 | error = MAILMH_ERROR_COULD_NOT_ALLOC_MSG; | 788 | error = MAILMH_ERROR_COULD_NOT_ALLOC_MSG; |
785 | goto free; | 789 | goto free; |
786 | } | 790 | } |
787 | free(tmpname); | 791 | free(tmpname); |
788 | 792 | ||
789 | msg_info = mailmh_msg_info_new(index, size, buf.st_mtime); | 793 | msg_info = mailmh_msg_info_new(index, size, buf.st_mtime); |
790 | if (msg_info == NULL) { | 794 | if (msg_info == NULL) { |
791 | mailmh_folder_remove_message(folder, index); | 795 | mailmh_folder_remove_message(folder, index); |
792 | error = MAILMH_ERROR_MEMORY; | 796 | error = MAILMH_ERROR_MEMORY; |
793 | goto err; | 797 | goto err; |
794 | } | 798 | } |
795 | 799 | ||
796 | r = carray_add(folder->fl_msgs_tab, msg_info, &array_index); | 800 | r = carray_add(folder->fl_msgs_tab, msg_info, &array_index); |
797 | if (r < 0) { | 801 | if (r < 0) { |
798 | mailmh_folder_remove_message(folder, index); | 802 | mailmh_folder_remove_message(folder, index); |
799 | mailmh_msg_info_free(msg_info); | 803 | mailmh_msg_info_free(msg_info); |
800 | error = MAILMH_ERROR_MEMORY; | 804 | error = MAILMH_ERROR_MEMORY; |
801 | goto err; | 805 | goto err; |
802 | } | 806 | } |
803 | msg_info->msg_array_index = array_index; | 807 | msg_info->msg_array_index = array_index; |
804 | 808 | ||
805 | #if 0 | 809 | #if 0 |
806 | r = cinthash_add(folder->fl_msgs_hash, index, msg_info); | 810 | r = cinthash_add(folder->fl_msgs_hash, index, msg_info); |
807 | #endif | 811 | #endif |
808 | key.data = &index; | 812 | key.data = &index; |
809 | key.len = sizeof(index); | 813 | key.len = sizeof(index); |
810 | data.data = msg_info; | 814 | data.data = msg_info; |
811 | data.len = 0; | 815 | data.len = 0; |
812 | 816 | ||
813 | if (pindex != NULL) | 817 | if (pindex != NULL) |
814 | * pindex = index; | 818 | * pindex = index; |
815 | 819 | ||
816 | r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); | 820 | r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); |
817 | if (r < 0) { | 821 | if (r < 0) { |
818 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); | 822 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); |
819 | mailmh_msg_info_free(msg_info); | 823 | mailmh_msg_info_free(msg_info); |
820 | error = MAILMH_ERROR_MEMORY; | 824 | error = MAILMH_ERROR_MEMORY; |
821 | goto err; | 825 | goto err; |
822 | } | 826 | } |
823 | 827 | ||
824 | return MAILMH_NO_ERROR; | 828 | return MAILMH_NO_ERROR; |
825 | 829 | ||
826 | free: | 830 | free: |
827 | free(tmpname); | 831 | free(tmpname); |
828 | err: | 832 | err: |
829 | return error; | 833 | return error; |
830 | } | 834 | } |
831 | 835 | ||
832 | int mailmh_folder_add_message(struct mailmh_folder * folder, | 836 | int mailmh_folder_add_message(struct mailmh_folder * folder, |
833 | const char * message, size_t size) | 837 | const char * message, size_t size) |
834 | { | 838 | { |
835 | return mailmh_folder_add_message_uid(folder, message, size, NULL); | 839 | return mailmh_folder_add_message_uid(folder, message, size, NULL); |
836 | } | 840 | } |
837 | 841 | ||
838 | int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder, | 842 | int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder, |
839 | int fd, uint32_t * pindex) | 843 | int fd, uint32_t * pindex) |
840 | { | 844 | { |
841 | char * message; | 845 | char * message; |
842 | struct stat buf; | 846 | struct stat buf; |
843 | int r; | 847 | int r; |
844 | 848 | ||
845 | #if 0 | 849 | #if 0 |
846 | r = mailmh_folder_update(folder); | 850 | r = mailmh_folder_update(folder); |
847 | if (r != MAILMH_NO_ERROR) | 851 | if (r != MAILMH_NO_ERROR) |
848 | return r; | 852 | return r; |
849 | #endif | 853 | #endif |
850 | 854 | ||
851 | if (fstat(fd, &buf) == -1) | 855 | if (fstat(fd, &buf) == -1) |
852 | return MAILMH_ERROR_FILE; | 856 | return MAILMH_ERROR_FILE; |
853 | 857 | ||
854 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | 858 | message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); |
855 | if (message == MAP_FAILED) | 859 | if (message == MAP_FAILED) |
856 | return MAILMH_ERROR_FILE; | 860 | return MAILMH_ERROR_FILE; |
857 | 861 | ||
858 | r = mailmh_folder_add_message_uid(folder, message, buf.st_size, pindex); | 862 | r = mailmh_folder_add_message_uid(folder, message, buf.st_size, pindex); |
859 | 863 | ||
860 | munmap(message, buf.st_size); | 864 | munmap(message, buf.st_size); |
861 | 865 | ||
862 | return r; | 866 | return r; |
863 | } | 867 | } |
864 | 868 | ||
865 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, | 869 | int mailmh_folder_add_message_file(struct mailmh_folder * folder, |
866 | int fd) | 870 | int fd) |
867 | { | 871 | { |
868 | return mailmh_folder_add_message_file_uid(folder, fd, NULL); | 872 | return mailmh_folder_add_message_file_uid(folder, fd, NULL); |
869 | } | 873 | } |
870 | 874 | ||
871 | int mailmh_folder_remove_message(struct mailmh_folder * folder, | 875 | int mailmh_folder_remove_message(struct mailmh_folder * folder, |
872 | uint32_t index) | 876 | uint32_t index) |
873 | { | 877 | { |
874 | char * filename; | 878 | char * filename; |
875 | struct mailmh_msg_info * msg_info; | 879 | struct mailmh_msg_info * msg_info; |
876 | int res; | 880 | int res; |
877 | int r; | 881 | int r; |
878 | chashdatum key; | 882 | chashdatum key; |
879 | chashdatum data; | 883 | chashdatum data; |
880 | 884 | ||
881 | #if 0 | 885 | #if 0 |
882 | r = mailmh_folder_update(folder); | 886 | r = mailmh_folder_update(folder); |
883 | if (r != MAILMH_NO_ERROR) { | 887 | if (r != MAILMH_NO_ERROR) { |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2321087..3908dbb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2194,520 +2194,524 @@ void CalendarView::edit_paste() | |||
2194 | { | 2194 | { |
2195 | QDate date = mNavigator->selectedDates().first(); | 2195 | QDate date = mNavigator->selectedDates().first(); |
2196 | 2196 | ||
2197 | DndFactory factory( mCalendar ); | 2197 | DndFactory factory( mCalendar ); |
2198 | Event *pastedEvent = factory.pasteEvent( date ); | 2198 | Event *pastedEvent = factory.pasteEvent( date ); |
2199 | 2199 | ||
2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void CalendarView::edit_options() | 2203 | void CalendarView::edit_options() |
2204 | { | 2204 | { |
2205 | mDialogManager->showOptionsDialog(); | 2205 | mDialogManager->showOptionsDialog(); |
2206 | //writeSettings(); | 2206 | //writeSettings(); |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | void CalendarView::slotSelectPickerDate( QDate d) | 2209 | void CalendarView::slotSelectPickerDate( QDate d) |
2210 | { | 2210 | { |
2211 | mDateFrame->hide(); | 2211 | mDateFrame->hide(); |
2212 | if ( mDatePickerMode == 1 ) { | 2212 | if ( mDatePickerMode == 1 ) { |
2213 | mNavigator->slotDaySelect( d ); | 2213 | mNavigator->slotDaySelect( d ); |
2214 | } else if ( mDatePickerMode == 2 ) { | 2214 | } else if ( mDatePickerMode == 2 ) { |
2215 | if ( mMoveIncidence->type() == "Todo" ) { | 2215 | if ( mMoveIncidence->type() == "Todo" ) { |
2216 | Todo * to = (Todo *) mMoveIncidence; | 2216 | Todo * to = (Todo *) mMoveIncidence; |
2217 | QTime tim; | 2217 | QTime tim; |
2218 | if ( to->hasDueDate() ) | 2218 | if ( to->hasDueDate() ) |
2219 | tim = to->dtDue().time(); | 2219 | tim = to->dtDue().time(); |
2220 | else { | 2220 | else { |
2221 | tim = QTime ( 0,0,0 ); | 2221 | tim = QTime ( 0,0,0 ); |
2222 | to->setFloats( true ); | 2222 | to->setFloats( true ); |
2223 | to->setHasDueDate( true ); | 2223 | to->setHasDueDate( true ); |
2224 | } | 2224 | } |
2225 | QDateTime dt ( d,tim ); | 2225 | QDateTime dt ( d,tim ); |
2226 | to->setDtDue( dt ); | 2226 | to->setDtDue( dt ); |
2227 | todoChanged( to ); | 2227 | todoChanged( to ); |
2228 | } else { | 2228 | } else { |
2229 | QTime tim = mMoveIncidence->dtStart().time(); | 2229 | QTime tim = mMoveIncidence->dtStart().time(); |
2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2231 | QDateTime dt ( d,tim ); | 2231 | QDateTime dt ( d,tim ); |
2232 | mMoveIncidence->setDtStart( dt ); | 2232 | mMoveIncidence->setDtStart( dt ); |
2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2238 | } | 2238 | } |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::removeCategories() | 2241 | void CalendarView::removeCategories() |
2242 | { | 2242 | { |
2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2245 | QStringList catIncList; | 2245 | QStringList catIncList; |
2246 | QStringList newCatList; | 2246 | QStringList newCatList; |
2247 | Incidence* inc = incList.first(); | 2247 | Incidence* inc = incList.first(); |
2248 | int i; | 2248 | int i; |
2249 | int count = 0; | 2249 | int count = 0; |
2250 | while ( inc ) { | 2250 | while ( inc ) { |
2251 | newCatList.clear(); | 2251 | newCatList.clear(); |
2252 | catIncList = inc->categories() ; | 2252 | catIncList = inc->categories() ; |
2253 | for( i = 0; i< catIncList.count(); ++i ) { | 2253 | for( i = 0; i< catIncList.count(); ++i ) { |
2254 | if ( catList.contains (catIncList[i])) | 2254 | if ( catList.contains (catIncList[i])) |
2255 | newCatList.append( catIncList[i] ); | 2255 | newCatList.append( catIncList[i] ); |
2256 | } | 2256 | } |
2257 | newCatList.sort(); | 2257 | newCatList.sort(); |
2258 | inc->setCategories( newCatList.join(",") ); | 2258 | inc->setCategories( newCatList.join(",") ); |
2259 | inc = incList.next(); | 2259 | inc = incList.next(); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | int CalendarView::addCategories() | 2263 | int CalendarView::addCategories() |
2264 | { | 2264 | { |
2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2267 | QStringList catIncList; |
2268 | Incidence* inc = incList.first(); | 2268 | Incidence* inc = incList.first(); |
2269 | int i; | 2269 | int i; |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | while ( inc ) { | 2271 | while ( inc ) { |
2272 | catIncList = inc->categories() ; | 2272 | catIncList = inc->categories() ; |
2273 | for( i = 0; i< catIncList.count(); ++i ) { | 2273 | for( i = 0; i< catIncList.count(); ++i ) { |
2274 | if ( !catList.contains (catIncList[i])) { | 2274 | if ( !catList.contains (catIncList[i])) { |
2275 | catList.append( catIncList[i] ); | 2275 | catList.append( catIncList[i] ); |
2276 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2276 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2277 | ++count; | 2277 | ++count; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | inc = incList.next(); | 2280 | inc = incList.next(); |
2281 | } | 2281 | } |
2282 | catList.sort(); | 2282 | catList.sort(); |
2283 | KOPrefs::instance()->mCustomCategories = catList; | 2283 | KOPrefs::instance()->mCustomCategories = catList; |
2284 | return count; | 2284 | return count; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | void CalendarView::manageCategories() | 2287 | void CalendarView::manageCategories() |
2288 | { | 2288 | { |
2289 | KOCatPrefs* cp = new KOCatPrefs(); | 2289 | KOCatPrefs* cp = new KOCatPrefs(); |
2290 | cp->show(); | 2290 | cp->show(); |
2291 | int w =cp->sizeHint().width() ; | 2291 | int w =cp->sizeHint().width() ; |
2292 | int h = cp->sizeHint().height() ; | 2292 | int h = cp->sizeHint().height() ; |
2293 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2294 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2296 | if ( !cp->exec() ) { | 2296 | if ( !cp->exec() ) { |
2297 | delete cp; | 2297 | delete cp; |
2298 | return; | 2298 | return; |
2299 | } | 2299 | } |
2300 | int count = 0; | 2300 | int count = 0; |
2301 | if ( cp->addCat() ) { | 2301 | if ( cp->addCat() ) { |
2302 | count = addCategories(); | 2302 | count = addCategories(); |
2303 | if ( count ) { | 2303 | if ( count ) { |
2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2305 | writeSettings(); | 2305 | writeSettings(); |
2306 | } else | 2306 | } else |
2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2308 | } else { | 2308 | } else { |
2309 | removeCategories(); | 2309 | removeCategories(); |
2310 | updateView(); | 2310 | updateView(); |
2311 | } | 2311 | } |
2312 | delete cp; | 2312 | delete cp; |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | void CalendarView::beamIncidence(Incidence * Inc) | 2315 | void CalendarView::beamIncidence(Incidence * Inc) |
2316 | { | 2316 | { |
2317 | QPtrList<Incidence> delSel ; | 2317 | QPtrList<Incidence> delSel ; |
2318 | delSel.append(Inc); | 2318 | delSel.append(Inc); |
2319 | beamIncidenceList( delSel ); | 2319 | beamIncidenceList( delSel ); |
2320 | } | 2320 | } |
2321 | void CalendarView::beamCalendar() | 2321 | 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 | { |
2586 | 2590 | ||
2587 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2591 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2588 | updateTodoViews(); | 2592 | updateTodoViews(); |
2589 | } | 2593 | } |
2590 | void CalendarView::todoChanged(Todo * t) | 2594 | void CalendarView::todoChanged(Todo * t) |
2591 | { | 2595 | { |
2592 | emit todoModified( t, 4 ); | 2596 | emit todoModified( t, 4 ); |
2593 | // updateTodoViews(); | 2597 | // updateTodoViews(); |
2594 | } | 2598 | } |
2595 | void CalendarView::todoToBeDeleted(Todo *) | 2599 | void CalendarView::todoToBeDeleted(Todo *) |
2596 | { | 2600 | { |
2597 | //qDebug("todoToBeDeleted(Todo *) "); | 2601 | //qDebug("todoToBeDeleted(Todo *) "); |
2598 | updateTodoViews(); | 2602 | updateTodoViews(); |
2599 | } | 2603 | } |
2600 | void CalendarView::todoDeleted() | 2604 | void CalendarView::todoDeleted() |
2601 | { | 2605 | { |
2602 | //qDebug(" todoDeleted()"); | 2606 | //qDebug(" todoDeleted()"); |
2603 | updateTodoViews(); | 2607 | updateTodoViews(); |
2604 | } | 2608 | } |
2605 | 2609 | ||
2606 | 2610 | ||
2607 | 2611 | ||
2608 | void CalendarView::newTodo() | 2612 | void CalendarView::newTodo() |
2609 | { | 2613 | { |
2610 | 2614 | ||
2611 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2615 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2612 | if ( mFilterView->filtersEnabled() ) { | 2616 | if ( mFilterView->filtersEnabled() ) { |
2613 | CalFilter *filter = mFilterView->selectedFilter(); | 2617 | CalFilter *filter = mFilterView->selectedFilter(); |
2614 | if (filter && filter->showCategories()) { | 2618 | if (filter && filter->showCategories()) { |
2615 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2619 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2616 | } | 2620 | } |
2617 | if ( filter ) | 2621 | if ( filter ) |
2618 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2622 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2619 | } | 2623 | } |
2620 | showTodoEditor(); | 2624 | showTodoEditor(); |
2621 | } | 2625 | } |
2622 | 2626 | ||
2623 | void CalendarView::newSubTodo() | 2627 | void CalendarView::newSubTodo() |
2624 | { | 2628 | { |
2625 | Todo *todo = selectedTodo(); | 2629 | Todo *todo = selectedTodo(); |
2626 | if ( todo ) newSubTodo( todo ); | 2630 | if ( todo ) newSubTodo( todo ); |
2627 | } | 2631 | } |
2628 | 2632 | ||
2629 | void CalendarView::newSubTodo(Todo *parentEvent) | 2633 | void CalendarView::newSubTodo(Todo *parentEvent) |
2630 | { | 2634 | { |
2631 | 2635 | ||
2632 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2636 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2633 | showTodoEditor(); | 2637 | showTodoEditor(); |
2634 | } | 2638 | } |
2635 | 2639 | ||
2636 | void CalendarView::newFloatingEvent() | 2640 | void CalendarView::newFloatingEvent() |
2637 | { | 2641 | { |
2638 | DateList tmpList = mNavigator->selectedDates(); | 2642 | DateList tmpList = mNavigator->selectedDates(); |
2639 | QDate date = tmpList.first(); | 2643 | QDate date = tmpList.first(); |
2640 | 2644 | ||
2641 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2645 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2642 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2646 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2643 | } | 2647 | } |
2644 | 2648 | ||
2645 | 2649 | ||
2646 | void CalendarView::editEvent( Event *event ) | 2650 | void CalendarView::editEvent( Event *event ) |
2647 | { | 2651 | { |
2648 | 2652 | ||
2649 | if ( !event ) return; | 2653 | if ( !event ) return; |
2650 | if ( event->isReadOnly() ) { | 2654 | if ( event->isReadOnly() ) { |
2651 | showEvent( event ); | 2655 | showEvent( event ); |
2652 | return; | 2656 | return; |
2653 | } | 2657 | } |
2654 | mEventEditor->editEvent( event , mFlagEditDescription); | 2658 | mEventEditor->editEvent( event , mFlagEditDescription); |
2655 | showEventEditor(); | 2659 | showEventEditor(); |
2656 | } | 2660 | } |
2657 | void CalendarView::editJournal( Journal *jour ) | 2661 | void CalendarView::editJournal( Journal *jour ) |
2658 | { | 2662 | { |
2659 | if ( !jour ) return; | 2663 | if ( !jour ) return; |
2660 | mDialogManager->hideSearchDialog(); | 2664 | mDialogManager->hideSearchDialog(); |
2661 | mViewManager->showJournalView(); | 2665 | mViewManager->showJournalView(); |
2662 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2666 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2663 | } | 2667 | } |
2664 | void CalendarView::editTodo( Todo *todo ) | 2668 | void CalendarView::editTodo( Todo *todo ) |
2665 | { | 2669 | { |
2666 | if ( !todo ) return; | 2670 | if ( !todo ) return; |
2667 | 2671 | ||
2668 | if ( todo->isReadOnly() ) { | 2672 | if ( todo->isReadOnly() ) { |
2669 | showTodo( todo ); | 2673 | showTodo( todo ); |
2670 | return; | 2674 | return; |
2671 | } | 2675 | } |
2672 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2676 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2673 | showTodoEditor(); | 2677 | showTodoEditor(); |
2674 | 2678 | ||
2675 | } | 2679 | } |
2676 | 2680 | ||
2677 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2681 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2678 | { | 2682 | { |
2679 | if ( !mEventViewerDialog ) { | 2683 | if ( !mEventViewerDialog ) { |
2680 | mEventViewerDialog = new KOEventViewerDialog(this); | 2684 | mEventViewerDialog = new KOEventViewerDialog(this); |
2681 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2685 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2682 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2686 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2683 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2687 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2684 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2688 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2685 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2689 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2686 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2690 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2687 | mEventViewerDialog->resize( 640, 480 ); | 2691 | mEventViewerDialog->resize( 640, 480 ); |
2688 | 2692 | ||
2689 | } | 2693 | } |
2690 | return mEventViewerDialog; | 2694 | return mEventViewerDialog; |
2691 | } | 2695 | } |
2692 | void CalendarView::showEvent(Event *event) | 2696 | void CalendarView::showEvent(Event *event) |
2693 | { | 2697 | { |
2694 | getEventViewerDialog()->setEvent(event); | 2698 | getEventViewerDialog()->setEvent(event); |
2695 | getEventViewerDialog()->showMe(); | 2699 | getEventViewerDialog()->showMe(); |
2696 | } | 2700 | } |
2697 | 2701 | ||
2698 | void CalendarView::showTodo(Todo *event) | 2702 | void CalendarView::showTodo(Todo *event) |
2699 | { | 2703 | { |
2700 | getEventViewerDialog()->setTodo(event); | 2704 | getEventViewerDialog()->setTodo(event); |
2701 | getEventViewerDialog()->showMe(); | 2705 | getEventViewerDialog()->showMe(); |
2702 | } | 2706 | } |
2703 | void CalendarView::showJournal( Journal *jour ) | 2707 | void CalendarView::showJournal( Journal *jour ) |
2704 | { | 2708 | { |
2705 | getEventViewerDialog()->setJournal(jour); | 2709 | getEventViewerDialog()->setJournal(jour); |
2706 | getEventViewerDialog()->showMe(); | 2710 | getEventViewerDialog()->showMe(); |
2707 | 2711 | ||
2708 | } | 2712 | } |
2709 | // void CalendarView::todoModified (Todo *event, int changed) | 2713 | // void CalendarView::todoModified (Todo *event, int changed) |
2710 | // { | 2714 | // { |
2711 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2715 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2712 | // // kdDebug() << "Todo modified and open" << endl; | 2716 | // // kdDebug() << "Todo modified and open" << endl; |
2713 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2717 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12acd1..9cafc60 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -121,512 +121,513 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | // kdDebug() << "Drop existing Todo" << endl; | 142 | // kdDebug() << "Drop existing Todo" << endl; |
143 | Incidence *to = destinationEvent; | 143 | Incidence *to = destinationEvent; |
144 | while(to) { | 144 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 145 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 146 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 147 | i18n("Cannot move To-Do to itself or a child of itself"), |
148 | i18n("Drop To-Do")); | 148 | i18n("Drop To-Do")); |
149 | delete todo; | 149 | delete todo; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | to = to->relatedTo(); | 152 | to = to->relatedTo(); |
153 | } | 153 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 154 | existingTodo->setRelatedTo(destinationEvent); |
155 | emit todoDropped(todo); | 155 | emit todoDropped(todo); |
156 | delete todo; | 156 | delete todo; |
157 | } else { | 157 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | 158 | // kdDebug() << "Drop new Todo" << endl; |
159 | todo->setRelatedTo(destinationEvent); | 159 | todo->setRelatedTo(destinationEvent); |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | ||
162 | emit todoDropped(todo); | 162 | emit todoDropped(todo); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | QString text; | 166 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 167 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 170 | kdDebug() << "Dropped : " << text << endl; |
171 | QStringList emails = QStringList::split(",",text); | 171 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | 173 | kdDebug() << " Email: " << (*it) << endl; |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | 214 | ||
215 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
224 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
227 | if (vd->drag()) { | 227 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
229 | } | 229 | } |
230 | /* | 230 | /* |
231 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
232 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
233 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
234 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
235 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
236 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
237 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
238 | */ | 238 | */ |
239 | } | 239 | } |
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
244 | { | 244 | { |
245 | 245 | ||
246 | QListViewItem* cn; | 246 | QListViewItem* cn; |
247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
248 | cn = currentItem(); | 248 | cn = currentItem(); |
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 ); |
505 | mTodoListView->setColumnWidth( 4, 40 ); | 506 | mTodoListView->setColumnWidth( 4, 40 ); |
506 | mTodoListView->setColumnWidth( 5, 90 ); | 507 | mTodoListView->setColumnWidth( 5, 90 ); |
507 | 508 | ||
508 | } | 509 | } |
509 | void KOTodoView::updateView() | 510 | void KOTodoView::updateView() |
510 | { | 511 | { |
511 | pendingSubtodo = 0; | 512 | pendingSubtodo = 0; |
512 | if ( mBlockUpdate ) { | 513 | if ( mBlockUpdate ) { |
513 | //qDebug("blocked "); | 514 | //qDebug("blocked "); |
514 | return; | 515 | return; |
515 | } | 516 | } |
516 | //qDebug("update "); | 517 | //qDebug("update "); |
517 | // kdDebug() << "KOTodoView::updateView()" << endl; | 518 | // kdDebug() << "KOTodoView::updateView()" << endl; |
518 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 519 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
519 | mTodoListView->clear(); | 520 | mTodoListView->clear(); |
520 | if ( mName == "todolistsmall" ) { | 521 | if ( mName == "todolistsmall" ) { |
521 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 522 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
522 | int ps = fo.pointSize() -2; | 523 | int ps = fo.pointSize() -2; |
523 | if ( ps > 12 ) | 524 | if ( ps > 12 ) |
524 | ps -= 2; | 525 | ps -= 2; |
525 | fo.setPointSize( ps ); | 526 | fo.setPointSize( ps ); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | 529 | ||
529 | mTodoListView->setFont( fo ); | 530 | mTodoListView->setFont( fo ); |
530 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 531 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
531 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 532 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
532 | QPtrList<Todo> todoList = calendar()->todos(); | 533 | QPtrList<Todo> todoList = calendar()->todos(); |
533 | 534 | ||
534 | /* | 535 | /* |
535 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 536 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
536 | Event *t; | 537 | Event *t; |
537 | for(t = todoList.first(); t; t = todoList.next()) { | 538 | for(t = todoList.first(); t; t = todoList.next()) { |
538 | kdDebug() << " " << t->getSummary() << endl; | 539 | kdDebug() << " " << t->getSummary() << endl; |
539 | 540 | ||
540 | if (t->getRelatedTo()) { | 541 | if (t->getRelatedTo()) { |
541 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 542 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
542 | } | 543 | } |
543 | 544 | ||
544 | QPtrList<Event> l = t->getRelations(); | 545 | QPtrList<Event> l = t->getRelations(); |
545 | Event *c; | 546 | Event *c; |
546 | for(c=l.first();c;c=l.next()) { | 547 | for(c=l.first();c;c=l.next()) { |
547 | kdDebug() << " - relation: " << c->getSummary() << endl; | 548 | kdDebug() << " - relation: " << c->getSummary() << endl; |
548 | } | 549 | } |
549 | } | 550 | } |
550 | */ | 551 | */ |
551 | 552 | ||
552 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 553 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
553 | // specific order of events. That means that we have to generate parent items | 554 | // specific order of events. That means that we have to generate parent items |
554 | // recursively for proper hierarchical display of Todos. | 555 | // recursively for proper hierarchical display of Todos. |
555 | mTodoMap.clear(); | 556 | mTodoMap.clear(); |
556 | Todo *todo; | 557 | Todo *todo; |
557 | todo = todoList.first();// todo; todo = todoList.next()) { | 558 | todo = todoList.first();// todo; todo = todoList.next()) { |
558 | while ( todo ) { | 559 | while ( todo ) { |
559 | bool next = true; | 560 | bool next = true; |
560 | // qDebug("todo %s ", todo->summary().latin1()); | 561 | // qDebug("todo %s ", todo->summary().latin1()); |
561 | Incidence *incidence = todo->relatedTo(); | 562 | Incidence *incidence = todo->relatedTo(); |
562 | while ( incidence ) { | 563 | while ( incidence ) { |
563 | if ( incidence->type() == "Todo") { | 564 | if ( incidence->type() == "Todo") { |
564 | //qDebug("related %s ",incidence->summary().latin1() ); | 565 | //qDebug("related %s ",incidence->summary().latin1() ); |
565 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 566 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
566 | //qDebug("related not found "); | 567 | //qDebug("related not found "); |
567 | todoList.remove( ); | 568 | todoList.remove( ); |
568 | todo = todoList.current(); | 569 | todo = todoList.current(); |
569 | next = false; | 570 | next = false; |
570 | incidence = 0; | 571 | incidence = 0; |
571 | 572 | ||
572 | } else { | 573 | } else { |
573 | //qDebug("related found "); | 574 | //qDebug("related found "); |
574 | incidence = incidence->relatedTo(); | 575 | incidence = incidence->relatedTo(); |
575 | } | 576 | } |
576 | } else | 577 | } else |
577 | incidence = 0; | 578 | incidence = 0; |
578 | } | 579 | } |
579 | if ( next ) | 580 | if ( next ) |
580 | todo = todoList.next(); | 581 | todo = todoList.next(); |
581 | } | 582 | } |
582 | // qDebug("again .... "); | 583 | // qDebug("again .... "); |
583 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 584 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
584 | 585 | ||
585 | // qDebug("yytodo %s ", todo->summary().latin1()); | 586 | // qDebug("yytodo %s ", todo->summary().latin1()); |
586 | // } | 587 | // } |
587 | //qDebug("for "); | 588 | //qDebug("for "); |
588 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 589 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
589 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) | 590 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) |
590 | { | 591 | { |
591 | insertTodoItem(todo); | 592 | insertTodoItem(todo); |
592 | } | 593 | } |
593 | } | 594 | } |
594 | //qDebug("for end "); | 595 | //qDebug("for end "); |
595 | // Restore opened/closed state | 596 | // Restore opened/closed state |
596 | mTodoListView->blockSignals( true ); | 597 | mTodoListView->blockSignals( true ); |
597 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 598 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
598 | mTodoListView->blockSignals( false ); | 599 | mTodoListView->blockSignals( false ); |
599 | mTodoListView->setFocus(); | 600 | mTodoListView->setFocus(); |
600 | processSelectionChange(); | 601 | processSelectionChange(); |
601 | } | 602 | } |
602 | 603 | ||
603 | void KOTodoView::restoreItemState( QListViewItem *item ) | 604 | void KOTodoView::restoreItemState( QListViewItem *item ) |
604 | { | 605 | { |
605 | pendingSubtodo = 0; | 606 | pendingSubtodo = 0; |
606 | while( item ) { | 607 | while( item ) { |
607 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 608 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
608 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 609 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
609 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 610 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
610 | item = item->nextSibling(); | 611 | item = item->nextSibling(); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
614 | 615 | ||
615 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 616 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
616 | KOTodoView::insertTodoItem(Todo *todo) | 617 | KOTodoView::insertTodoItem(Todo *todo) |
617 | { | 618 | { |
618 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 619 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
619 | // TODO: Check, if dynmaic cast is necessary | 620 | // TODO: Check, if dynmaic cast is necessary |
620 | 621 | ||
621 | pendingSubtodo = 0; | 622 | pendingSubtodo = 0; |
622 | Incidence *incidence = todo->relatedTo(); | 623 | Incidence *incidence = todo->relatedTo(); |
623 | if (incidence && incidence->type() == "Todo") { | 624 | if (incidence && incidence->type() == "Todo") { |
624 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 625 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
625 | 626 | ||
626 | // kdDebug() << " has Related" << endl; | 627 | // kdDebug() << " has Related" << endl; |
627 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 628 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
628 | itemIterator = mTodoMap.find(relatedTodo); | 629 | itemIterator = mTodoMap.find(relatedTodo); |
629 | if (itemIterator == mTodoMap.end()) { | 630 | if (itemIterator == mTodoMap.end()) { |
630 | // kdDebug() << " related not yet in list" << endl; | 631 | // kdDebug() << " related not yet in list" << endl; |
631 | itemIterator = insertTodoItem (relatedTodo); | 632 | itemIterator = insertTodoItem (relatedTodo); |
632 | } | 633 | } |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 85647b1..ae0b334 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,301 +1,301 @@ | |||
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 | ||
174 | 174 | ||
175 | } | 175 | } |
176 | void KOTodoViewItem::stateChange(bool state) | 176 | void KOTodoViewItem::stateChange(bool state) |
177 | { | 177 | { |
178 | // qDebug("KOTodoViewItem::stateChange "); | 178 | // qDebug("KOTodoViewItem::stateChange "); |
179 | // do not change setting on startup | 179 | // do not change setting on startup |
180 | if ( m_init ) return; | 180 | if ( m_init ) return; |
181 | 181 | ||
182 | kdDebug() << "State changed, modified " << state << endl; | 182 | kdDebug() << "State changed, modified " << state << endl; |
183 | QString keyd = "=="; | 183 | QString keyd = "=="; |
184 | QString keyt = "=="; | 184 | QString keyt = "=="; |
185 | 185 | ||
186 | if (state) mTodo->setCompleted(state); | 186 | if (state) mTodo->setCompleted(state); |
187 | else mTodo->setPercentComplete(0); | 187 | else mTodo->setPercentComplete(0); |
188 | if (isOn()!=state) { | 188 | if (isOn()!=state) { |
189 | setOn(state); | 189 | setOn(state); |
190 | } | 190 | } |
191 | 191 | ||
192 | if (mTodo->hasDueDate()) { | 192 | if (mTodo->hasDueDate()) { |
193 | setText(3, mTodo->dtDueDateStr()); | 193 | setText(3, mTodo->dtDueDateStr()); |
194 | QDate d = mTodo->dtDue().date(); | 194 | QDate d = mTodo->dtDue().date(); |
195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
196 | setSortKey(3,keyd); | 196 | setSortKey(3,keyd); |
197 | if (mTodo->doesFloat()) { | 197 | if (mTodo->doesFloat()) { |
198 | setText(4,""); | 198 | setText(4,""); |
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | setText(4,mTodo->dtDueTimeStr()); | 201 | setText(4,mTodo->dtDueTimeStr()); |
202 | QTime t = mTodo->dtDue().time(); | 202 | QTime t = mTodo->dtDue().time(); |
203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
204 | setSortKey(4,keyt); | 204 | setSortKey(4,keyt); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
209 | 209 | ||
210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
211 | if (mTodo->percentComplete()<100) { | 211 | if (mTodo->percentComplete()<100) { |
212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
213 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 213 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
217 | else setSortKey(2,QString::number(99)); | 217 | else setSortKey(2,QString::number(99)); |
218 | } | 218 | } |
219 | QListViewItem * myChild = firstChild(); | 219 | QListViewItem * myChild = firstChild(); |
220 | KOTodoViewItem *item; | 220 | KOTodoViewItem *item; |
221 | while( myChild ) { | 221 | while( myChild ) { |
222 | item = static_cast<KOTodoViewItem*>(myChild); | 222 | item = static_cast<KOTodoViewItem*>(myChild); |
223 | item->stateChange(state); | 223 | item->stateChange(state); |
224 | myChild = myChild->nextSibling(); | 224 | myChild = myChild->nextSibling(); |
225 | } | 225 | } |
226 | mTodoView->modified(true); | 226 | mTodoView->modified(true); |
227 | mTodoView->setTodoModified( mTodo ); | 227 | mTodoView->setTodoModified( mTodo ); |
228 | setMyPixmap(); | 228 | setMyPixmap(); |
229 | } | 229 | } |
230 | 230 | ||
231 | bool KOTodoViewItem::isAlternate() | 231 | bool KOTodoViewItem::isAlternate() |
232 | { | 232 | { |
233 | #ifndef KORG_NOLVALTERNATION | 233 | #ifndef KORG_NOLVALTERNATION |
234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
235 | if (lv && lv->alternateBackground().isValid()) | 235 | if (lv && lv->alternateBackground().isValid()) |
236 | { | 236 | { |
237 | KOTodoViewItem *above = 0; | 237 | KOTodoViewItem *above = 0; |
238 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); | 238 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); |
239 | m_known = above ? above->m_known : true; | 239 | m_known = above ? above->m_known : true; |
240 | if (m_known) | 240 | if (m_known) |
241 | { | 241 | { |
242 | m_odd = above ? !above->m_odd : false; | 242 | m_odd = above ? !above->m_odd : false; |
243 | } | 243 | } |
244 | else | 244 | else |
245 | { | 245 | { |
246 | KOTodoViewItem *item; | 246 | KOTodoViewItem *item; |
247 | bool previous = true; | 247 | bool previous = true; |
248 | if (QListViewItem::parent()) | 248 | if (QListViewItem::parent()) |
249 | { | 249 | { |
250 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); | 250 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); |
251 | if (item) | 251 | if (item) |
252 | previous = item->m_odd; | 252 | previous = item->m_odd; |
253 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 253 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
254 | } | 254 | } |
255 | else | 255 | else |
256 | { | 256 | { |
257 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); | 257 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); |
258 | } | 258 | } |
259 | 259 | ||
260 | while(item) | 260 | while(item) |
261 | { | 261 | { |
262 | item->m_odd = previous = !previous; | 262 | item->m_odd = previous = !previous; |
263 | item->m_known = true; | 263 | item->m_known = true; |
264 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); | 264 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | return m_odd; | 267 | return m_odd; |
268 | } | 268 | } |
269 | return false; | 269 | return false; |
270 | #else | 270 | #else |
271 | return false; | 271 | return false; |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 275 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
276 | { | 276 | { |
277 | QColorGroup _cg = cg; | 277 | QColorGroup _cg = cg; |
278 | QColorGroup::ColorRole role; | 278 | QColorGroup::ColorRole role; |
279 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) | 279 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) |
280 | role = QColorGroup::Text; | 280 | role = QColorGroup::Text; |
281 | else | 281 | else |
282 | role = QColorGroup::Base; | 282 | role = QColorGroup::Base; |
283 | //#ifndef KORG_NOLVALTERNATION | 283 | //#ifndef KORG_NOLVALTERNATION |
284 | // if (isAlternate()) | 284 | // if (isAlternate()) |
285 | // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 285 | // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
286 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 286 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
287 | QColor colorToSet; | 287 | QColor colorToSet; |
288 | if ( setColor ) { | 288 | if ( setColor ) { |
289 | QStringList categories = mTodo->categories(); | 289 | QStringList categories = mTodo->categories(); |
290 | QString cat = categories.first(); | 290 | QString cat = categories.first(); |
291 | if ( !cat.isEmpty()) { | 291 | if ( !cat.isEmpty()) { |
292 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 292 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
293 | } else | 293 | } else |
294 | setColor = false; | 294 | setColor = false; |
295 | } | 295 | } |
296 | if (mTodo->hasDueDate()) { | 296 | if (mTodo->hasDueDate()) { |
297 | if (mTodo->dtDue().date()==QDate::currentDate() && | 297 | if (mTodo->dtDue().date()==QDate::currentDate() && |
298 | !mTodo->isCompleted()) { | 298 | !mTodo->isCompleted()) { |
299 | //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); | 299 | //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); |
300 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 300 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
301 | setColor = true; | 301 | setColor = true; |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 24b8349..c2ee2c9 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -1,514 +1,517 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
43 | 43 | ||
44 | #include "sharpformat.h" | 44 | #include "sharpformat.h" |
45 | #include "syncdefines.h" | 45 | #include "syncdefines.h" |
46 | 46 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | 49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY |
50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
51 | 51 | ||
52 | //ARSD silentalarm = 0 | 52 | //ARSD silentalarm = 0 |
53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | 53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly |
54 | // 12 RFRQ | 54 | // 12 RFRQ |
55 | // 13 RPOS pos = 4. monday in month | 55 | // 13 RPOS pos = 4. monday in month |
56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | 56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun |
57 | // 15 REND 0 = no end/ 1 = end | 57 | // 15 REND 0 = no end/ 1 = end |
58 | // 16 REDT rec end dt | 58 | // 16 REDT rec end dt |
59 | //ALSD | 59 | //ALSD |
60 | //ALED | 60 | //ALED |
61 | //MDAY | 61 | //MDAY |
62 | 62 | ||
63 | class SharpParser : public QObject | 63 | class SharpParser : public QObject |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { | 66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { |
67 | } | 67 | } |
68 | 68 | ||
69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) | 69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) |
70 | { | 70 | { |
71 | int i = 1; | 71 | int i = 1; |
72 | bool skip = true; | 72 | bool skip = true; |
73 | int max = attList.count() -2; | 73 | int max = attList.count() -2; |
74 | while ( i < max ) { | 74 | while ( i < max ) { |
75 | if ( !attList[i].isEmpty() ) { | 75 | if ( !attList[i].isEmpty() ) { |
76 | skip = false; | 76 | skip = false; |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | ++i ; | 79 | ++i ; |
80 | } | 80 | } |
81 | if ( skip ) | 81 | if ( skip ) |
82 | return false; | 82 | return false; |
83 | ulong cSum = SharpFormat::getCsum(attList ); | 83 | ulong cSum = SharpFormat::getCsum(attList ); |
84 | 84 | ||
85 | if ( qName == "Event" ) { | 85 | if ( qName == "Event" ) { |
86 | Event *event; | 86 | Event *event; |
87 | event = existingCalendar->event( "Sharp_DTM",attList[0] ); | 87 | event = existingCalendar->event( "Sharp_DTM",attList[0] ); |
88 | if ( event ) | 88 | if ( event ) |
89 | event = (Event*)event->clone(); | 89 | event = (Event*)event->clone(); |
90 | else | 90 | else |
91 | event = new Event; | 91 | event = new Event; |
92 | event->setID("Sharp_DTM", attList[0] ); | 92 | event->setID("Sharp_DTM", attList[0] ); |
93 | event->setCsum( "Sharp_DTM", QString::number( cSum )); | 93 | event->setCsum( "Sharp_DTM", QString::number( cSum )); |
94 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 94 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
95 | 95 | ||
96 | event->setSummary( attList[2] ); | 96 | event->setSummary( attList[2] ); |
97 | event->setLocation( attList[3] ); | 97 | event->setLocation( attList[3] ); |
98 | event->setDescription( attList[4] ); | 98 | event->setDescription( attList[4] ); |
99 | if ( attList[7] == "1" ) { | 99 | if ( attList[7] == "1" ) { |
100 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); | 100 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); |
101 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); | 101 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); |
102 | event->setFloats( true ); | 102 | event->setFloats( true ); |
103 | } else { | 103 | } else { |
104 | event->setFloats( false ); | 104 | event->setFloats( false ); |
105 | event->setDtStart( fromString( attList[5] ) ); | 105 | event->setDtStart( fromString( attList[5] ) ); |
106 | event->setDtEnd( fromString( attList[6] )); | 106 | event->setDtEnd( fromString( attList[6] )); |
107 | } | 107 | } |
108 | 108 | ||
109 | QString rtype = attList[11]; | 109 | QString rtype = attList[11]; |
110 | if ( rtype != "255" ) { | 110 | if ( rtype != "255" ) { |
111 | // qDebug("recurs "); | 111 | // qDebug("recurs "); |
112 | QDate startDate = event->dtStart().date(); | 112 | QDate startDate = event->dtStart().date(); |
113 | 113 | ||
114 | QString freqStr = attList[12]; | 114 | QString freqStr = attList[12]; |
115 | int freq = freqStr.toInt(); | 115 | int freq = freqStr.toInt(); |
116 | 116 | ||
117 | QString hasEndDateStr = attList[15] ; | 117 | QString hasEndDateStr = attList[15] ; |
118 | bool hasEndDate = hasEndDateStr == "1"; | 118 | bool hasEndDate = hasEndDateStr == "1"; |
119 | 119 | ||
120 | QString endDateStr = attList[16]; | 120 | QString endDateStr = attList[16]; |
121 | QDate endDate = fromString( endDateStr ).date(); | 121 | QDate endDate = fromString( endDateStr ).date(); |
122 | 122 | ||
123 | QString weekDaysStr = attList[14]; | 123 | QString weekDaysStr = attList[14]; |
124 | uint weekDaysNum = weekDaysStr.toInt(); | 124 | uint weekDaysNum = weekDaysStr.toInt(); |
125 | 125 | ||
126 | QBitArray weekDays( 7 ); | 126 | QBitArray weekDays( 7 ); |
127 | int i; | 127 | int i; |
128 | int bb = 1; | 128 | int bb = 1; |
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 | } |
387 | file.setName( fileName ); | 390 | file.setName( fileName ); |
388 | if (!file.open( IO_ReadOnly ) ) { | 391 | if (!file.open( IO_ReadOnly ) ) { |
389 | return false; | 392 | return false; |
390 | 393 | ||
391 | } | 394 | } |
392 | ts.setDevice( &file ); | 395 | ts.setDevice( &file ); |
393 | text = ts.read(); | 396 | text = ts.read(); |
394 | file.close(); | 397 | file.close(); |
395 | 398 | ||
396 | status.setText( i18n("Processing todos ...") ); | 399 | status.setText( i18n("Processing todos ...") ); |
397 | status.raise(); | 400 | status.raise(); |
398 | qApp->processEvents(); | 401 | qApp->processEvents(); |
399 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 402 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
400 | return true; | 403 | return true; |
401 | } | 404 | } |
402 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 405 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
403 | { | 406 | { |
404 | int retval = -1; | 407 | int retval = -1; |
405 | QStringList templist; | 408 | QStringList templist; |
406 | QString tempString; | 409 | QString tempString; |
407 | int start = 0; | 410 | int start = 0; |
408 | int len = answer.length(); | 411 | int len = answer.length(); |
409 | int end = answer.find ("\n",start)+1; | 412 | int end = answer.find ("\n",start)+1; |
410 | bool ok = true; | 413 | bool ok = true; |
411 | start = end; | 414 | start = end; |
412 | int ccc = 0; | 415 | int ccc = 0; |
413 | while ( start > 0 ) { | 416 | while ( start > 0 ) { |
414 | templist.clear(); | 417 | templist.clear(); |
415 | ok = true; | 418 | ok = true; |
416 | int loopCount = 0; | 419 | int loopCount = 0; |
417 | while ( ok ) { | 420 | while ( ok ) { |
418 | ++loopCount; | 421 | ++loopCount; |
419 | if ( loopCount > 25 ) { | 422 | if ( loopCount > 25 ) { |
420 | qDebug("KO: Error in while loop"); | 423 | qDebug("KO: Error in while loop"); |
421 | ok = false; | 424 | ok = false; |
422 | start = 0; | 425 | start = 0; |
423 | break; | 426 | break; |
424 | } | 427 | } |
425 | if ( ok ) | 428 | if ( ok ) |
426 | tempString = getPart( answer, ok, start ); | 429 | tempString = getPart( answer, ok, start ); |
427 | if ( start >= len || start == 0 ) { | 430 | if ( start >= len || start == 0 ) { |
428 | start = 0; | 431 | start = 0; |
429 | ok = false; | 432 | ok = false; |
430 | } | 433 | } |
431 | if ( tempString.right(1) =="\n" ) | 434 | if ( tempString.right(1) =="\n" ) |
432 | tempString = tempString.left( tempString.length()-1); | 435 | tempString = tempString.left( tempString.length()-1); |
433 | 436 | ||
434 | templist.append( tempString ); | 437 | templist.append( tempString ); |
435 | } | 438 | } |
436 | ++ccc; | 439 | ++ccc; |
437 | if ( ccc == 2 && loopCount < 25 ) { | 440 | if ( ccc == 2 && loopCount < 25 ) { |
438 | start = 0; | 441 | start = 0; |
439 | bool ok; | 442 | bool ok; |
440 | int newnum = templist[0].toInt( &ok ); | 443 | int newnum = templist[0].toInt( &ok ); |
441 | if ( ok && newnum > 0) { | 444 | if ( ok && newnum > 0) { |
442 | retval = newnum; | 445 | retval = newnum; |
443 | inc->setID( "Sharp_DTM",templist[0] ); | 446 | inc->setID( "Sharp_DTM",templist[0] ); |
444 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); | 447 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); |
445 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 448 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
446 | } | 449 | } |
447 | if ( ok && newnum == -1 ) { | 450 | if ( ok && newnum == -1 ) { |
448 | qDebug("Error writing back %s ", inc->summary().latin1()); | 451 | qDebug("Error writing back %s ", inc->summary().latin1()); |
449 | } | 452 | } |
450 | } | 453 | } |
451 | } | 454 | } |
452 | //qDebug("getNumFromRecord returning : %d ", retval); | 455 | //qDebug("getNumFromRecord returning : %d ", retval); |
453 | return retval; | 456 | return retval; |
454 | } | 457 | } |
455 | bool SharpFormat::save( Calendar *calendar) | 458 | bool SharpFormat::save( Calendar *calendar) |
456 | { | 459 | { |
457 | 460 | ||
458 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 461 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
459 | int w = status.sizeHint().width()+20 ; | 462 | int w = status.sizeHint().width()+20 ; |
460 | if ( w < 200 ) w = 200; | 463 | if ( w < 200 ) w = 200; |
461 | int h = status.sizeHint().height()+20 ; | 464 | int h = status.sizeHint().height()+20 ; |
462 | int dw = QApplication::desktop()->width(); | 465 | int dw = QApplication::desktop()->width(); |
463 | int dh = QApplication::desktop()->height(); | 466 | int dh = QApplication::desktop()->height(); |
464 | status.setCaption(i18n("Writing DTM Data") ); | 467 | status.setCaption(i18n("Writing DTM Data") ); |
465 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 468 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
466 | status.show(); | 469 | status.show(); |
467 | status.raise(); | 470 | status.raise(); |
468 | qApp->processEvents(); | 471 | qApp->processEvents(); |
469 | bool debug = DEBUGMODE; | 472 | bool debug = DEBUGMODE; |
470 | QString codec = "utf8"; | 473 | QString codec = "utf8"; |
471 | QString answer; | 474 | QString answer; |
472 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 475 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
473 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 476 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
474 | QString command; | 477 | QString command; |
475 | QPtrList<Event> er = calendar->rawEvents(); | 478 | QPtrList<Event> er = calendar->rawEvents(); |
476 | Event* ev = er.first(); | 479 | Event* ev = er.first(); |
477 | QString fileName = "/tmp/kopitempout"; | 480 | QString fileName = "/tmp/kopitempout"; |
478 | int i = 0; | 481 | int i = 0; |
479 | QString changeString = ePrefix; | 482 | QString changeString = ePrefix; |
480 | QString deleteString = ePrefix; | 483 | QString deleteString = ePrefix; |
481 | bool deleteEnt = false; | 484 | bool deleteEnt = false; |
482 | bool changeEnt = false; | 485 | bool changeEnt = false; |
483 | QString message = i18n("Processing event # "); | 486 | QString message = i18n("Processing event # "); |
484 | int procCount = 0; | 487 | int procCount = 0; |
485 | while ( ev ) { | 488 | while ( ev ) { |
486 | //qDebug("i %d ", ++i); | 489 | //qDebug("i %d ", ++i); |
487 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 490 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
488 | status.setText ( message + QString::number ( ++procCount ) ); | 491 | status.setText ( message + QString::number ( ++procCount ) ); |
489 | qApp->processEvents(); | 492 | qApp->processEvents(); |
490 | QString eString = getEventString( ev ); | 493 | QString eString = getEventString( ev ); |
491 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 494 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
492 | // deleting empty strings does not work. | 495 | // deleting empty strings does not work. |
493 | // we write first and x and then delete the record with the x | 496 | // we write first and x and then delete the record with the x |
494 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 497 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
495 | changeString += eString + "\n"; | 498 | changeString += eString + "\n"; |
496 | deleteString += eString + "\n"; | 499 | deleteString += eString + "\n"; |
497 | deleteEnt = true; | 500 | deleteEnt = true; |
498 | changeEnt = true; | 501 | changeEnt = true; |
499 | } | 502 | } |
500 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new | 503 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new |
501 | QString fileNameIn = "/tmp/kopitempin"; | 504 | QString fileNameIn = "/tmp/kopitempin"; |
502 | QFile fileIn( fileNameIn ); | 505 | QFile fileIn( fileNameIn ); |
503 | if (!fileIn.open( IO_WriteOnly ) ) { | 506 | if (!fileIn.open( IO_WriteOnly ) ) { |
504 | return false; | 507 | return false; |
505 | } | 508 | } |
506 | QTextStream tsIn( &fileIn ); | 509 | QTextStream tsIn( &fileIn ); |
507 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 510 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
508 | tsIn << ePrefix << eString ; | 511 | tsIn << ePrefix << eString ; |
509 | fileIn.close(); | 512 | fileIn.close(); |
510 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 513 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
511 | command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; | 514 | command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; |
512 | //qDebug("command ++++++++ "); | 515 | //qDebug("command ++++++++ "); |
513 | //qDebug("%s ",command.latin1()); | 516 | //qDebug("%s ",command.latin1()); |
514 | //qDebug("command -------- "); | 517 | //qDebug("command -------- "); |
@@ -1 +1 @@ | |||
version = "1.9.13"; | version = "1.9.14"; | ||