-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 20 | ||||
-rw-r--r-- | kabc/addressee.cpp | 1 | ||||
-rw-r--r-- | kabc/kabc.pro | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | libkcal/event.cpp | 46 | ||||
-rw-r--r-- | libkcal/event.h | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 104 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 | ||||
-rw-r--r-- | libkcal/todo.cpp | 58 | ||||
-rw-r--r-- | libkcal/todo.h | 1 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 141 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 69 | ||||
-rw-r--r-- | microkde/microkde.pro | 2 | ||||
-rw-r--r-- | microkde/ofileselector_p.cpp | 7 |
14 files changed, 305 insertions, 154 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0375fee..7310755 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -1,521 +1,527 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | #include "gsmcal.h" | 5 | #include "gsmcal.h" |
6 | #include "gsmmisc.h" | 6 | #include "gsmmisc.h" |
7 | #include "../misc/coding/coding.h" | 7 | #include "../misc/coding/coding.h" |
8 | 8 | ||
9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) | 9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) |
10 | { | 10 | { |
11 | bool Past = true; | 11 | bool Past = true; |
12 | int i; | 12 | int i; |
13 | GSM_DateTimeDT; | 13 | GSM_DateTimeDT; |
14 | 14 | ||
15 | GSM_GetCurrentDateTime (&DT); | 15 | GSM_GetCurrentDateTime (&DT); |
16 | for (i = 0; i < note->EntriesNum; i++) { | 16 | for (i = 0; i < note->EntriesNum; i++) { |
17 | switch (note->Entries[i].EntryType) { | 17 | switch (note->Entries[i].EntryType) { |
18 | case CAL_RECURRANCE: | 18 | case CAL_RECURRANCE: |
19 | Past = false; | 19 | Past = false; |
20 | break; | 20 | break; |
21 | case CAL_START_DATETIME : | 21 | case CAL_START_DATETIME : |
22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; | 22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; |
23 | if (note->Entries[i].Date.Year == DT.Year && | 23 | if (note->Entries[i].Date.Year == DT.Year && |
24 | note->Entries[i].Date.Month > DT.Month) Past = false; | 24 | note->Entries[i].Date.Month > DT.Month) Past = false; |
25 | if (note->Entries[i].Date.Year == DT.Year && | 25 | if (note->Entries[i].Date.Year == DT.Year && |
26 | note->Entries[i].Date.Month == DT.Month && | 26 | note->Entries[i].Date.Month == DT.Month && |
27 | note->Entries[i].Date.Day > DT.Day) Past = false; | 27 | note->Entries[i].Date.Day > DT.Day) Past = false; |
28 | break; | 28 | break; |
29 | default: | 29 | default: |
30 | break; | 30 | break; |
31 | } | 31 | } |
32 | if (!Past) break; | 32 | if (!Past) break; |
33 | } | 33 | } |
34 | switch (note->Type) { | 34 | switch (note->Type) { |
35 | case GSM_CAL_BIRTHDAY: | 35 | case GSM_CAL_BIRTHDAY: |
36 | Past = false; | 36 | Past = false; |
37 | break; | 37 | break; |
38 | default: | 38 | default: |
39 | break; | 39 | break; |
40 | } | 40 | } |
41 | return Past; | 41 | return Past; |
42 | } | 42 | } |
43 | 43 | ||
44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) | 44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) |
45 | { | 45 | { |
46 | int i; | 46 | int i; |
47 | 47 | ||
48 | *Text = -1; | 48 | *Text = -1; |
49 | *Time = -1; | 49 | *Time = -1; |
50 | *Alarm = -1; | 50 | *Alarm = -1; |
51 | *Phone = -1; | 51 | *Phone = -1; |
52 | *Recurrance= -1; | 52 | *Recurrance= -1; |
53 | *EndTime= -1; | 53 | *EndTime= -1; |
54 | *Location= -1; | 54 | *Location= -1; |
55 | for (i = 0; i < entry->EntriesNum; i++) { | 55 | for (i = 0; i < entry->EntriesNum; i++) { |
56 | switch (entry->Entries[i].EntryType) { | 56 | switch (entry->Entries[i].EntryType) { |
57 | case CAL_START_DATETIME : | 57 | case CAL_START_DATETIME : |
58 | if (*Time == -1) *Time = i; | 58 | if (*Time == -1) *Time = i; |
59 | break; | 59 | break; |
60 | case CAL_END_DATETIME : | 60 | case CAL_END_DATETIME : |
61 | if (*EndTime == -1) *EndTime = i; | 61 | if (*EndTime == -1) *EndTime = i; |
62 | break; | 62 | break; |
63 | case CAL_ALARM_DATETIME : | 63 | case CAL_ALARM_DATETIME : |
64 | case CAL_SILENT_ALARM_DATETIME: | 64 | case CAL_SILENT_ALARM_DATETIME: |
65 | if (*Alarm == -1) *Alarm = i; | 65 | if (*Alarm == -1) *Alarm = i; |
66 | break; | 66 | break; |
67 | case CAL_RECURRANCE: | 67 | case CAL_RECURRANCE: |
68 | if (*Recurrance == -1) *Recurrance = i; | 68 | if (*Recurrance == -1) *Recurrance = i; |
69 | break; | 69 | break; |
70 | case CAL_TEXT: | 70 | case CAL_TEXT: |
71 | *Text = i; | 71 | *Text = i; |
72 | break; | 72 | break; |
73 | case CAL_DESCRIPTION: | 73 | case CAL_DESCRIPTION: |
74 | if (*Text == -1) *Text = i; | 74 | if (*Text == -1) *Text = i; |
75 | break; | 75 | break; |
76 | case CAL_PHONE: | 76 | case CAL_PHONE: |
77 | if (*Phone == -1) *Phone = i; | 77 | if (*Phone == -1) *Phone = i; |
78 | break; | 78 | break; |
79 | case CAL_LOCATION: | 79 | case CAL_LOCATION: |
80 | if (*Location == -1) *Location = i; | 80 | if (*Location == -1) *Location = i; |
81 | break; | 81 | break; |
82 | default: | 82 | default: |
83 | break; | 83 | break; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) | 88 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) |
89 | { | 89 | { |
90 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; | 90 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; |
91 | char buffer[2000]; | 91 | char buffer[2000]; |
92 | 92 | ||
93 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); | 93 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); |
94 | 94 | ||
95 | if (header) { | 95 | if (header) { |
96 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 96 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
97 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 97 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
98 | } | 98 | } |
99 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); | 99 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); |
100 | 100 | ||
101 | if (Version == Nokia_VCalendar) { | 101 | if (Version == Nokia_VCalendar) { |
102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
103 | switch (note->Type) { | 103 | switch (note->Type) { |
104 | case GSM_CAL_REMINDER: | 104 | case GSM_CAL_REMINDER: |
105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
106 | break; | 106 | break; |
107 | case GSM_CAL_MEMO: | 107 | case GSM_CAL_MEMO: |
108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
109 | break; | 109 | break; |
110 | case GSM_CAL_CALL: | 110 | case GSM_CAL_CALL: |
111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
112 | break; | 112 | break; |
113 | case GSM_CAL_BIRTHDAY: | 113 | case GSM_CAL_BIRTHDAY: |
114 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); | 114 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
115 | break; | 115 | break; |
116 | case GSM_CAL_MEETING: | 116 | case GSM_CAL_MEETING: |
117 | default: | 117 | default: |
118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | if (note->Type == GSM_CAL_CALL) { | 121 | if (note->Type == GSM_CAL_CALL) { |
122 | buffer[0] = 0; | 122 | buffer[0] = 0; |
123 | buffer[1] = 0; | 123 | buffer[1] = 0; |
124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
125 | if (Text != -1) { | 125 | if (Text != -1) { |
126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
127 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 127 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
128 | } | 128 | } |
129 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 129 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
130 | } else { | 130 | } else { |
131 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 131 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
132 | } | 132 | } |
133 | if (note->Type == GSM_CAL_MEETING && Location != -1) { | 133 | if (note->Type == GSM_CAL_MEETING && Location != -1) { |
134 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 134 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
135 | } | 135 | } |
136 | 136 | ||
137 | if (Time == -1) return ERR_UNKNOWN; | 137 | if (Time == -1) return ERR_UNKNOWN; |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
139 | 139 | ||
140 | if (EndTime != -1) { | 140 | if (EndTime != -1) { |
141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (Alarm != -1) { | 144 | if (Alarm != -1) { |
145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
147 | } else { | 147 | } else { |
148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /* Birthday is known to be recurranced */ | 152 | /* Birthday is known to be recurranced */ |
153 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 153 | if (Recurrance != -1 ) { |
154 | switch(note->Entries[Recurrance].Number/24) { | 154 | switch(note->Entries[Recurrance].Number/24) { |
155 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; | 155 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; |
156 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; | 156 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; |
157 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; | 157 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; |
158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1 #0%c%c",13,10); break; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | } else if (Version == Siemens_VCalendar) { | 161 | } else if (Version == Siemens_VCalendar) { |
162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
163 | switch (note->Type) { | 163 | switch (note->Type) { |
164 | case GSM_CAL_MEETING: | 164 | case GSM_CAL_MEETING: |
165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
166 | break; | 166 | break; |
167 | case GSM_CAL_CALL: | 167 | case GSM_CAL_CALL: |
168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
169 | break; | 169 | break; |
170 | case GSM_CAL_BIRTHDAY: | 170 | case GSM_CAL_BIRTHDAY: |
171 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 171 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
172 | break; | 172 | break; |
173 | case GSM_CAL_MEMO: | 173 | case GSM_CAL_MEMO: |
174 | default: | 174 | default: |
175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | 178 | ||
179 | if (Time == -1) return ERR_UNKNOWN; | 179 | if (Time == -1) return ERR_UNKNOWN; |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
181 | 181 | ||
182 | if (Alarm != -1) { | 182 | if (Alarm != -1) { |
183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
184 | } | 184 | } |
185 | 185 | ||
186 | if (Recurrance != -1) { | 186 | if (Recurrance != -1) { |
187 | switch(note->Entries[Recurrance].Number/24) { | 187 | switch(note->Entries[Recurrance].Number/24) { |
188 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; | 188 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; |
189 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; | 189 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; |
190 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; | 190 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; |
191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1%c%c",13,10);break; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | if (note->Type == GSM_CAL_CALL) { | 195 | if (note->Type == GSM_CAL_CALL) { |
196 | buffer[0] = 0; | 196 | buffer[0] = 0; |
197 | buffer[1] = 0; | 197 | buffer[1] = 0; |
198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
199 | if (Text != -1) { | 199 | if (Text != -1) { |
200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
202 | } | 202 | } |
203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
204 | } else { | 204 | } else { |
205 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 205 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
206 | } | 206 | } |
207 | } else if (Version == SonyEricsson_VCalendar) { | 207 | } else if (Version == SonyEricsson_VCalendar) { |
208 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 208 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
209 | switch (note->Type) { | 209 | switch (note->Type) { |
210 | case GSM_CAL_MEETING: | 210 | case GSM_CAL_MEETING: |
211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
212 | break; | 212 | break; |
213 | case GSM_CAL_REMINDER: | 213 | case GSM_CAL_REMINDER: |
214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
215 | break; | 215 | break; |
216 | case GSM_CAL_TRAVEL: | 216 | case GSM_CAL_TRAVEL: |
217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
218 | break; | 218 | break; |
219 | case GSM_CAL_VACATION: | 219 | case GSM_CAL_VACATION: |
220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
221 | break; | 221 | break; |
222 | case GSM_CAL_BIRTHDAY: | 222 | case GSM_CAL_BIRTHDAY: |
223 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); | 223 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
224 | break; | 224 | break; |
225 | case GSM_CAL_MEMO: | 225 | case GSM_CAL_MEMO: |
226 | default: | 226 | default: |
227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (Time == -1) return ERR_UNKNOWN; | 231 | if (Time == -1) return ERR_UNKNOWN; |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
233 | 233 | ||
234 | if (EndTime != -1) { | 234 | if (EndTime != -1) { |
235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
236 | } | 236 | } |
237 | 237 | ||
238 | if (Alarm != -1) { | 238 | if (Alarm != -1) { |
239 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 239 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
240 | } | 240 | } |
241 | 241 | ||
242 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 242 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
243 | 243 | ||
244 | if (Location != -1) { | 244 | if (Location != -1) { |
245 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 245 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 249 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
250 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); | 250 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); |
251 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 251 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
252 | 252 | ||
253 | return ERR_NONE; | 253 | return ERR_NONE; |
254 | } | 254 | } |
255 | 255 | ||
256 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) | 256 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) |
257 | { | 257 | { |
258 | int i; | 258 | int i; |
259 | 259 | ||
260 | *Text = -1; | 260 | *Text = -1; |
261 | *EndTime= -1; | 261 | *EndTime= -1; |
262 | *Alarm = -1; | 262 | *Alarm = -1; |
263 | *Completed= -1; | 263 | *Completed= -1; |
264 | *Phone = -1; | 264 | *Phone = -1; |
265 | for (i = 0; i < entry->EntriesNum; i++) { | 265 | for (i = 0; i < entry->EntriesNum; i++) { |
266 | switch (entry->Entries[i].EntryType) { | 266 | switch (entry->Entries[i].EntryType) { |
267 | case TODO_END_DATETIME : | 267 | case TODO_END_DATETIME : |
268 | if (*EndTime == -1) *EndTime = i; | 268 | if (*EndTime == -1) *EndTime = i; |
269 | break; | 269 | break; |
270 | case TODO_ALARM_DATETIME : | 270 | case TODO_ALARM_DATETIME : |
271 | case TODO_SILENT_ALARM_DATETIME: | 271 | case TODO_SILENT_ALARM_DATETIME: |
272 | if (*Alarm == -1) *Alarm = i; | 272 | if (*Alarm == -1) *Alarm = i; |
273 | break; | 273 | break; |
274 | case TODO_TEXT: | 274 | case TODO_TEXT: |
275 | if (*Text == -1) *Text = i; | 275 | if (*Text == -1) *Text = i; |
276 | break; | 276 | break; |
277 | case TODO_COMPLETED: | 277 | case TODO_COMPLETED: |
278 | if (*Completed == -1) *Completed = i; | 278 | if (*Completed == -1) *Completed = i; |
279 | break; | 279 | break; |
280 | case TODO_PHONE: | 280 | case TODO_PHONE: |
281 | if (*Phone == -1) *Phone = i; | 281 | if (*Phone == -1) *Phone = i; |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) | 289 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) |
290 | { | 290 | { |
291 | int Text, Alarm, Completed, EndTime, Phone; | 291 | int Text, Alarm, Completed, EndTime, Phone; |
292 | 292 | ||
293 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); | 293 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); |
294 | 294 | ||
295 | if (header) { | 295 | if (header) { |
296 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 296 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
297 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 297 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
298 | } | 298 | } |
299 | 299 | ||
300 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); | 300 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); |
301 | 301 | ||
302 | if (Version == Nokia_VToDo) { | 302 | if (Version == Nokia_VToDo) { |
303 | if (Text == -1) return ERR_UNKNOWN; | 303 | if (Text == -1) return ERR_UNKNOWN; |
304 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 304 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
305 | 305 | ||
306 | if (Completed == -1) { | 306 | if (Completed == -1) { |
307 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 307 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
308 | } else { | 308 | } else { |
309 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 309 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
310 | } | 310 | } |
311 | 311 | ||
312 | switch (note->Priority) { | 312 | switch (note->Priority) { |
313 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 313 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
314 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 314 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
315 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 315 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
316 | } | 316 | } |
317 | 317 | ||
318 | if (EndTime != -1) { | 318 | if (EndTime != -1) { |
319 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); | 319 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); |
320 | } | 320 | } |
321 | 321 | ||
322 | if (Alarm != -1) { | 322 | if (Alarm != -1) { |
323 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 323 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
324 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 324 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
325 | } else { | 325 | } else { |
326 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 326 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | } else if (Version == SonyEricsson_VToDo) { | 329 | } else if (Version == SonyEricsson_VToDo) { |
330 | if (Text == -1) return ERR_UNKNOWN; | 330 | if (Text == -1) return ERR_UNKNOWN; |
331 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 331 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
332 | 332 | ||
333 | if (Completed == -1) { | 333 | if (Completed == -1) { |
334 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 334 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
335 | } else { | 335 | } else { |
336 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 336 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
337 | } | 337 | } |
338 | 338 | ||
339 | switch (note->Priority) { | 339 | switch (note->Priority) { |
340 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 340 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
341 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 341 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
342 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 342 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
343 | } | 343 | } |
344 | 344 | ||
345 | if (Alarm != -1) { | 345 | if (Alarm != -1) { |
346 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 346 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 350 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
351 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); | 351 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); |
352 | 352 | ||
353 | if (header) { | 353 | if (header) { |
354 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 354 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
355 | } | 355 | } |
356 | return ERR_NONE; | 356 | return ERR_NONE; |
357 | } | 357 | } |
358 | 358 | ||
359 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) | 359 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) |
360 | { | 360 | { |
361 | unsigned char Line[2000],Buff[2000]; | 361 | unsigned char Line[2000],Buff[2000]; |
362 | int Level = 0; | 362 | int Level = 0; |
363 | 363 | ||
364 | Calendar->EntriesNum = 0; | 364 | Calendar->EntriesNum = 0; |
365 | ToDo->EntriesNum = 0; | 365 | ToDo->EntriesNum = 0; |
366 | 366 | ||
367 | while (1) { | 367 | while (1) { |
368 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | 368 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); |
369 | if (strlen(Line) == 0) break; | 369 | if (strlen(Line) == 0) break; |
370 | switch (Level) { | 370 | switch (Level) { |
371 | case 0: | 371 | case 0: |
372 | if (strstr(Line,"BEGIN:VEVENT")) { | 372 | if (strstr(Line,"BEGIN:VEVENT")) { |
373 | Calendar->Type = GSM_CAL_MEMO; | 373 | Calendar->Type = GSM_CAL_MEMO; |
374 | Level = 1; | 374 | Level = 1; |
375 | } | 375 | } |
376 | if (strstr(Line,"BEGIN:VTODO")) { | 376 | if (strstr(Line,"BEGIN:VTODO")) { |
377 | ToDo->Priority = GSM_Priority_Medium; | 377 | ToDo->Priority = GSM_Priority_Medium; |
378 | Level = 2; | 378 | Level = 2; |
379 | } | 379 | } |
380 | break; | 380 | break; |
381 | case 1: /* Calendar note */ | 381 | case 1: /* Calendar note */ |
382 | if (strstr(Line,"END:VEVENT")) { | 382 | if (strstr(Line,"END:VEVENT")) { |
383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
384 | return ERR_NONE; | 384 | return ERR_NONE; |
385 | } | 385 | } |
386 | Calendar->Type = GSM_CAL_MEETING; | 386 | Calendar->Type = GSM_CAL_MEETING; |
387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; | 387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE | 388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE | 390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; | 391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; | 392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
393 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; | ||
394 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; | 393 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
394 | if (strstr(Line,"CATEGORIES:Birthday")) Calendar->Type = GSM_CAL_BIRTHDAY; | ||
395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; | 395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | 396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; |
397 | if (strstr(Line,"RRULE:D1")) { | 397 | if (strstr(Line,"RRULE:D1")) { |
398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
400 | Calendar->EntriesNum++; | 400 | Calendar->EntriesNum++; |
401 | } | 401 | } |
402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
405 | Calendar->EntriesNum++; | 405 | Calendar->EntriesNum++; |
406 | } | 406 | } |
407 | if (strstr(Line,"RRULE:W2")) { | 407 | if (strstr(Line,"RRULE:W2")) { |
408 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 408 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
409 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; | 409 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; |
410 | Calendar->EntriesNum++; | 410 | Calendar->EntriesNum++; |
411 | } | 411 | } |
412 | if (strstr(Line,"RRULE:MD1")) { | 412 | if (strstr(Line,"RRULE:MD1")) { |
413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; | 414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; |
415 | Calendar->EntriesNum++; | 415 | Calendar->EntriesNum++; |
416 | } | 416 | } |
417 | if (strstr(Line,"RRULE:YD1")) { | 417 | if (strstr(Line,"RRULE:YD1")) { |
418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | 419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; |
420 | Calendar->EntriesNum++; | 420 | Calendar->EntriesNum++; |
421 | } | 421 | } |
422 | // LR | 422 | // LR |
423 | if (strstr(Line,"RRULE:YM1")) { | ||
424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | ||
425 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | ||
426 | Calendar->EntriesNum++; | ||
427 | } | ||
428 | // LR | ||
423 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { | 429 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { |
424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; | 430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; |
425 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 431 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
426 | Calendar->EntriesNum++; | 432 | Calendar->EntriesNum++; |
427 | } | 433 | } |
428 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { | 434 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { |
429 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; | 435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; |
430 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 436 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
431 | Calendar->EntriesNum++; | 437 | Calendar->EntriesNum++; |
432 | } | 438 | } |
433 | if (ReadVCALText(Line, "LOCATION", Buff)) { | 439 | if (ReadVCALText(Line, "LOCATION", Buff)) { |
434 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; | 440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; |
435 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 441 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
436 | Calendar->EntriesNum++; | 442 | Calendar->EntriesNum++; |
437 | } | 443 | } |
438 | if (ReadVCALText(Line, "DTSTART", Buff)) { | 444 | if (ReadVCALText(Line, "DTSTART", Buff)) { |
439 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; | 445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; |
440 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
441 | Calendar->EntriesNum++; | 447 | Calendar->EntriesNum++; |
442 | } | 448 | } |
443 | if (ReadVCALText(Line, "DTEND", Buff)) { | 449 | if (ReadVCALText(Line, "DTEND", Buff)) { |
444 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; | 450 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; |
445 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 451 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
446 | Calendar->EntriesNum++; | 452 | Calendar->EntriesNum++; |
447 | } | 453 | } |
448 | if (ReadVCALText(Line, "DALARM", Buff)) { | 454 | if (ReadVCALText(Line, "DALARM", Buff)) { |
449 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | 455 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; |
450 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 456 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
451 | Calendar->EntriesNum++; | 457 | Calendar->EntriesNum++; |
452 | } | 458 | } |
453 | if (ReadVCALText(Line, "AALARM", Buff)) { | 459 | if (ReadVCALText(Line, "AALARM", Buff)) { |
454 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; | 460 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; |
455 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 461 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
456 | Calendar->EntriesNum++; | 462 | Calendar->EntriesNum++; |
457 | } | 463 | } |
458 | break; | 464 | break; |
459 | case 2: /* ToDo note */ | 465 | case 2: /* ToDo note */ |
460 | if (strstr(Line,"END:VTODO")) { | 466 | if (strstr(Line,"END:VTODO")) { |
461 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; | 467 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; |
462 | return ERR_NONE; | 468 | return ERR_NONE; |
463 | } | 469 | } |
464 | if (ReadVCALText(Line, "DUE", Buff)) { | 470 | if (ReadVCALText(Line, "DUE", Buff)) { |
465 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | 471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; |
466 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 472 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
467 | ToDo->EntriesNum++; | 473 | ToDo->EntriesNum++; |
468 | } | 474 | } |
469 | if (ReadVCALText(Line, "DALARM", Buff)) { | 475 | if (ReadVCALText(Line, "DALARM", Buff)) { |
470 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | 476 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; |
471 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 477 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
472 | ToDo->EntriesNum++; | 478 | ToDo->EntriesNum++; |
473 | } | 479 | } |
474 | if (ReadVCALText(Line, "AALARM", Buff)) { | 480 | if (ReadVCALText(Line, "AALARM", Buff)) { |
475 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 481 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
476 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 482 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
477 | ToDo->EntriesNum++; | 483 | ToDo->EntriesNum++; |
478 | } | 484 | } |
479 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 485 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
480 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | 486 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; |
481 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); | 487 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); |
482 | ToDo->EntriesNum++; | 488 | ToDo->EntriesNum++; |
483 | } | 489 | } |
484 | if (ReadVCALText(Line, "PRIORITY", Buff)) { | 490 | if (ReadVCALText(Line, "PRIORITY", Buff)) { |
485 | if (ToDoVer == SonyEricsson_VToDo) { | 491 | if (ToDoVer == SonyEricsson_VToDo) { |
486 | ToDo->Priority = GSM_Priority_Medium; | 492 | ToDo->Priority = GSM_Priority_Medium; |
487 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 493 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
488 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 494 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
489 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); | 495 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); |
490 | } else if (ToDoVer == Nokia_VToDo) { | 496 | } else if (ToDoVer == Nokia_VToDo) { |
491 | ToDo->Priority = GSM_Priority_Medium; | 497 | ToDo->Priority = GSM_Priority_Medium; |
492 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 498 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
493 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 499 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
494 | } | 500 | } |
495 | } | 501 | } |
496 | if (strstr(Line,"PERCENT-COMPLETE:100")) { | 502 | if (strstr(Line,"PERCENT-COMPLETE:100")) { |
497 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | 503 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; |
498 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 504 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
499 | ToDo->EntriesNum++; | 505 | ToDo->EntriesNum++; |
500 | } | 506 | } |
501 | break; | 507 | break; |
502 | } | 508 | } |
503 | } | 509 | } |
504 | 510 | ||
505 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 511 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
506 | return ERR_NONE; | 512 | return ERR_NONE; |
507 | } | 513 | } |
508 | 514 | ||
509 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 515 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
510 | { | 516 | { |
511 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 517 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
512 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 518 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |
513 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); | 519 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); |
514 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); | 520 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); |
515 | 521 | ||
516 | return ERR_NONE; | 522 | return ERR_NONE; |
517 | } | 523 | } |
518 | 524 | ||
519 | /* How should editor hadle tabs in this file? Add editor commands here. | 525 | /* How should editor hadle tabs in this file? Add editor commands here. |
520 | * vim: noexpandtab sw=8 ts=8 sts=8: | 526 | * vim: noexpandtab sw=8 ts=8 sts=8: |
521 | */ | 527 | */ |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2564894..40877ef 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -57,512 +57,513 @@ struct Addressee::AddresseeData : public KShared | |||
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | 302 | ||
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | (*it).setNumber( ( *phoneItAD ).number() ); | ||
313 | break; | 314 | break; |
314 | } | 315 | } |
315 | } | 316 | } |
316 | if ( isSubSet && ! found ) | 317 | if ( isSubSet && ! found ) |
317 | mData->phoneNumbers.append( *phoneItAD ); | 318 | mData->phoneNumbers.append( *phoneItAD ); |
318 | } | 319 | } |
319 | if ( isSubSet ) { | 320 | if ( isSubSet ) { |
320 | // ************* emails; | 321 | // ************* emails; |
321 | t = mData->emails; | 322 | t = mData->emails; |
322 | tAD = ad.mData->emails; | 323 | tAD = ad.mData->emails; |
323 | for ( iii = 0; iii < tAD.count(); ++iii) | 324 | for ( iii = 0; iii < tAD.count(); ++iii) |
324 | if ( !t.contains(tAD[iii] ) ) | 325 | if ( !t.contains(tAD[iii] ) ) |
325 | mData->emails.append( tAD[iii] ); | 326 | mData->emails.append( tAD[iii] ); |
326 | } | 327 | } |
327 | 328 | ||
328 | // ************* categories; | 329 | // ************* categories; |
329 | t = mData->categories; | 330 | t = mData->categories; |
330 | tAD = ad.mData->categories; | 331 | tAD = ad.mData->categories; |
331 | for ( iii = 0; iii < tAD.count(); ++iii) | 332 | for ( iii = 0; iii < tAD.count(); ++iii) |
332 | if ( !t.contains(tAD[iii] ) ) | 333 | if ( !t.contains(tAD[iii] ) ) |
333 | mData->categories.append( tAD[iii] ); | 334 | mData->categories.append( tAD[iii] ); |
334 | QStringList::ConstIterator it; | 335 | QStringList::ConstIterator it; |
335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
336 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 337 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
337 | bool found = false; | 338 | bool found = false; |
338 | QStringList::ConstIterator itL; | 339 | QStringList::ConstIterator itL; |
339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
340 | if ( (*itL).startsWith( qualifiedName ) ) { | 341 | if ( (*itL).startsWith( qualifiedName ) ) { |
341 | found = true; | 342 | found = true; |
342 | break; | 343 | break; |
343 | } | 344 | } |
344 | } | 345 | } |
345 | if ( ! found ) { | 346 | if ( ! found ) { |
346 | mData->custom.append( *it ); | 347 | mData->custom.append( *it ); |
347 | } | 348 | } |
348 | } | 349 | } |
349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
351 | if ( !mData->sound.isIntern() ) { | 352 | if ( !mData->sound.isIntern() ) { |
352 | if ( mData->sound.url().isEmpty() ) { | 353 | if ( mData->sound.url().isEmpty() ) { |
353 | mData->sound = ad.mData->sound; | 354 | mData->sound = ad.mData->sound; |
354 | } | 355 | } |
355 | } | 356 | } |
356 | if ( !mData->agent.isIntern() ) { | 357 | if ( !mData->agent.isIntern() ) { |
357 | if ( mData->agent.url().isEmpty() ) { | 358 | if ( mData->agent.url().isEmpty() ) { |
358 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | { | 362 | { |
362 | Key::List::Iterator itA; | 363 | Key::List::Iterator itA; |
363 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
364 | bool found = false; | 365 | bool found = false; |
365 | Key::List::Iterator it; | 366 | Key::List::Iterator it; |
366 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
367 | if ( (*it) == (*itA)) { | 368 | if ( (*it) == (*itA)) { |
368 | found = true; | 369 | found = true; |
369 | break; | 370 | break; |
370 | 371 | ||
371 | } | 372 | } |
372 | } | 373 | } |
373 | if ( ! found ) { | 374 | if ( ! found ) { |
374 | mData->keys.append( *itA ); | 375 | mData->keys.append( *itA ); |
375 | } | 376 | } |
376 | } | 377 | } |
377 | } | 378 | } |
378 | KABC::Address::List::Iterator addressIterA; | 379 | KABC::Address::List::Iterator addressIterA; |
379 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
380 | bool found = false; | 381 | bool found = false; |
381 | KABC::Address::List::Iterator addressIter; | 382 | KABC::Address::List::Iterator addressIter; |
382 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
383 | ++addressIter ) { | 384 | ++addressIter ) { |
384 | if ( (*addressIter) == (*addressIterA)) { | 385 | if ( (*addressIter) == (*addressIterA)) { |
385 | found = true; | 386 | found = true; |
386 | (*addressIter).setType( (*addressIterA).type() ); | 387 | (*addressIter).setType( (*addressIterA).type() ); |
387 | break; | 388 | break; |
388 | } | 389 | } |
389 | 390 | ||
390 | } | 391 | } |
391 | if ( isSubSet && ! found ) { | 392 | if ( isSubSet && ! found ) { |
392 | mData->addresses.append( *addressIterA ); | 393 | mData->addresses.append( *addressIterA ); |
393 | } | 394 | } |
394 | } | 395 | } |
395 | //qDebug("merge contact %s ", ad.uid().latin1()); | 396 | //qDebug("merge contact %s ", ad.uid().latin1()); |
396 | setUid( ad.uid() ); | 397 | setUid( ad.uid() ); |
397 | setRevision( ad.revision() ); | 398 | setRevision( ad.revision() ); |
398 | } | 399 | } |
399 | 400 | ||
400 | bool Addressee::removeVoice() | 401 | bool Addressee::removeVoice() |
401 | { | 402 | { |
402 | PhoneNumber::List phoneN = phoneNumbers(); | 403 | PhoneNumber::List phoneN = phoneNumbers(); |
403 | PhoneNumber::List::Iterator phoneIt; | 404 | PhoneNumber::List::Iterator phoneIt; |
404 | bool found = false; | 405 | bool found = false; |
405 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
406 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
407 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
408 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
409 | insertPhoneNumber( (*phoneIt) ); | 410 | insertPhoneNumber( (*phoneIt) ); |
410 | found = true; | 411 | found = true; |
411 | } | 412 | } |
412 | } | 413 | } |
413 | 414 | ||
414 | } | 415 | } |
415 | return found; | 416 | return found; |
416 | } | 417 | } |
417 | 418 | ||
418 | bool Addressee::containsAdr(const Addressee& ad ) | 419 | bool Addressee::containsAdr(const Addressee& ad ) |
419 | { | 420 | { |
420 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
421 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
422 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
423 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
424 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
425 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
426 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
427 | 428 | ||
428 | // compare phone numbers | 429 | // compare phone numbers |
429 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 430 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
430 | PhoneNumber::List::Iterator phoneIt; | 431 | PhoneNumber::List::Iterator phoneIt; |
431 | bool found = false; | 432 | bool found = false; |
432 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
433 | bool found = false; | 434 | bool found = false; |
434 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 435 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
435 | PhoneNumber::List::Iterator phoneItL; | 436 | PhoneNumber::List::Iterator phoneItL; |
436 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
437 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
438 | found = true; | 439 | found = true; |
439 | break; | 440 | break; |
440 | } | 441 | } |
441 | } | 442 | } |
442 | if ( ! found ) | 443 | if ( ! found ) |
443 | return false; | 444 | return false; |
444 | } | 445 | } |
445 | return true; | 446 | return true; |
446 | 447 | ||
447 | } | 448 | } |
448 | void Addressee::simplifyAddresses() | 449 | void Addressee::simplifyAddresses() |
449 | { | 450 | { |
450 | 451 | ||
451 | 452 | ||
452 | Address::List list; | 453 | Address::List list; |
453 | Address::List::Iterator it; | 454 | Address::List::Iterator it; |
454 | Address::List::Iterator it2; | 455 | Address::List::Iterator it2; |
455 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
456 | it2 = it; | 457 | it2 = it; |
457 | ++it2; | 458 | ++it2; |
458 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 459 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
459 | if ( (*it) == (*it2) ) { | 460 | if ( (*it) == (*it2) ) { |
460 | list.append( *it ); | 461 | list.append( *it ); |
461 | break; | 462 | break; |
462 | } | 463 | } |
463 | } | 464 | } |
464 | } | 465 | } |
465 | for( it = list.begin(); it != list.end(); ++it ) { | 466 | for( it = list.begin(); it != list.end(); ++it ) { |
466 | removeAddress( (*it) ); | 467 | removeAddress( (*it) ); |
467 | } | 468 | } |
468 | 469 | ||
469 | list.clear(); | 470 | list.clear(); |
470 | int max = 2; | 471 | int max = 2; |
471 | if ( mData->url.isValid() ) | 472 | if ( mData->url.isValid() ) |
472 | max = 1; | 473 | max = 1; |
473 | if ( mData->addresses.count() <= max ) return ; | 474 | if ( mData->addresses.count() <= max ) return ; |
474 | int count = 0; | 475 | int count = 0; |
475 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
476 | if ( count >= max ) | 477 | if ( count >= max ) |
477 | list.append( *it ); | 478 | list.append( *it ); |
478 | ++count; | 479 | ++count; |
479 | } | 480 | } |
480 | for( it = list.begin(); it != list.end(); ++it ) { | 481 | for( it = list.begin(); it != list.end(); ++it ) { |
481 | removeAddress( (*it) ); | 482 | removeAddress( (*it) ); |
482 | } | 483 | } |
483 | } | 484 | } |
484 | 485 | ||
485 | // removes all emails but the first | 486 | // removes all emails but the first |
486 | // needed by phone sync | 487 | // needed by phone sync |
487 | void Addressee::simplifyEmails() | 488 | void Addressee::simplifyEmails() |
488 | { | 489 | { |
489 | if ( mData->emails.count() == 0 ) return ; | 490 | if ( mData->emails.count() == 0 ) return ; |
490 | QString email = mData->emails.first(); | 491 | QString email = mData->emails.first(); |
491 | detach(); | 492 | detach(); |
492 | mData->emails.clear(); | 493 | mData->emails.clear(); |
493 | mData->emails.append( email ); | 494 | mData->emails.append( email ); |
494 | } | 495 | } |
495 | 496 | ||
496 | void Addressee::simplifyPhoneNumbers() | 497 | void Addressee::simplifyPhoneNumbers() |
497 | { | 498 | { |
498 | int max = 4; | 499 | int max = 4; |
499 | int inList = mData->phoneNumbers.count(); | 500 | int inList = mData->phoneNumbers.count(); |
500 | KABC::PhoneNumber::List removeNumbers; | 501 | KABC::PhoneNumber::List removeNumbers; |
501 | KABC::PhoneNumber::List::Iterator phoneIter; | 502 | KABC::PhoneNumber::List::Iterator phoneIter; |
502 | if ( inList > max ) { | 503 | if ( inList > max ) { |
503 | // delete non-preferred numbers | 504 | // delete non-preferred numbers |
504 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
505 | ++phoneIter ) { | 506 | ++phoneIter ) { |
506 | if ( inList > max ) { | 507 | if ( inList > max ) { |
507 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
508 | removeNumbers.append( ( *phoneIter ) ); | 509 | removeNumbers.append( ( *phoneIter ) ); |
509 | --inList; | 510 | --inList; |
510 | } | 511 | } |
511 | } else | 512 | } else |
512 | break; | 513 | break; |
513 | } | 514 | } |
514 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
515 | ++phoneIter ) { | 516 | ++phoneIter ) { |
516 | removePhoneNumber(( *phoneIter )); | 517 | removePhoneNumber(( *phoneIter )); |
517 | } | 518 | } |
518 | // delete preferred numbers | 519 | // delete preferred numbers |
519 | if ( inList > max ) { | 520 | if ( inList > max ) { |
520 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
521 | ++phoneIter ) { | 522 | ++phoneIter ) { |
522 | if ( inList > max ) { | 523 | if ( inList > max ) { |
523 | removeNumbers.append( ( *phoneIter ) ); | 524 | removeNumbers.append( ( *phoneIter ) ); |
524 | --inList; | 525 | --inList; |
525 | } else | 526 | } else |
526 | break; | 527 | break; |
527 | } | 528 | } |
528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
529 | ++phoneIter ) { | 530 | ++phoneIter ) { |
530 | removePhoneNumber(( *phoneIter )); | 531 | removePhoneNumber(( *phoneIter )); |
531 | } | 532 | } |
532 | } | 533 | } |
533 | } | 534 | } |
534 | // remove non-numeric characters | 535 | // remove non-numeric characters |
535 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
536 | ++phoneIter ) { | 537 | ++phoneIter ) { |
537 | if ( ! ( *phoneIter ).simplifyNumber() ) | 538 | if ( ! ( *phoneIter ).simplifyNumber() ) |
538 | removeNumbers.append( ( *phoneIter ) ); | 539 | removeNumbers.append( ( *phoneIter ) ); |
539 | } | 540 | } |
540 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
541 | ++phoneIter ) { | 542 | ++phoneIter ) { |
542 | removePhoneNumber(( *phoneIter )); | 543 | removePhoneNumber(( *phoneIter )); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | void Addressee::simplifyPhoneNumberTypes() | 546 | void Addressee::simplifyPhoneNumberTypes() |
546 | { | 547 | { |
547 | KABC::PhoneNumber::List::Iterator phoneIter; | 548 | KABC::PhoneNumber::List::Iterator phoneIter; |
548 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
549 | ++phoneIter ) | 550 | ++phoneIter ) |
550 | ( *phoneIter ).simplifyType(); | 551 | ( *phoneIter ).simplifyType(); |
551 | } | 552 | } |
552 | void Addressee::removeID(const QString &prof) | 553 | void Addressee::removeID(const QString &prof) |
553 | { | 554 | { |
554 | detach(); | 555 | detach(); |
555 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 556 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
556 | 557 | ||
557 | } | 558 | } |
558 | void Addressee::setID( const QString & prof , const QString & id ) | 559 | void Addressee::setID( const QString & prof , const QString & id ) |
559 | { | 560 | { |
560 | detach(); | 561 | detach(); |
561 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 562 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
562 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 563 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
563 | } | 564 | } |
564 | void Addressee::setTempSyncStat( int id ) | 565 | void Addressee::setTempSyncStat( int id ) |
565 | { | 566 | { |
566 | if ( mData->mTempSyncStat == id ) return; | 567 | if ( mData->mTempSyncStat == id ) return; |
567 | detach(); | 568 | detach(); |
568 | mData->mTempSyncStat = id; | 569 | mData->mTempSyncStat = id; |
diff --git a/kabc/kabc.pro b/kabc/kabc.pro index d690acc..17ebff8 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro | |||
@@ -1,220 +1,218 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | #release debug | 3 | #release debug |
4 | DESTDIR=../bin | 4 | DESTDIR=../bin |
5 | 5 | ||
6 | TARGET = microkabc | 6 | TARGET = microkabc |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui .. | 10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui .. |
11 | 11 | ||
12 | #LIBS += -lmicrokde -lldap | 12 | #LIBS += -lmicrokde -lldap |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION | 14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION |
15 | unix : { | 15 | unix : { |
16 | 16 | ||
17 | OBJECTS_DIR = obj/unix | 17 | OBJECTS_DIR = obj/unix |
18 | MOC_DIR = moc/unix | 18 | MOC_DIR = moc/unix |
19 | } | 19 | } |
20 | win32: { | 20 | win32: { |
21 | DEFINES += _WIN32_ | 21 | DEFINES += _WIN32_ |
22 | OBJECTS_DIR = obj/win | 22 | OBJECTS_DIR = obj/win |
23 | MOC_DIR = moc/win | 23 | MOC_DIR = moc/win |
24 | } | 24 | } |
25 | INTERFACES = \ | 25 | INTERFACES = \ |
26 | 26 | ||
27 | 27 | ||
28 | HEADERS = \ | 28 | HEADERS = \ |
29 | resource.h \ | 29 | resource.h \ |
30 | stdaddressbook.h \ | 30 | stdaddressbook.h \ |
31 | agent.h \ | 31 | agent.h \ |
32 | geo.h \ | 32 | geo.h \ |
33 | key.h \ | 33 | key.h \ |
34 | field.h \ | 34 | field.h \ |
35 | plugin.h \ | 35 | plugin.h \ |
36 | address.h \ | 36 | address.h \ |
37 | addresseelist.h \ | 37 | addresseelist.h \ |
38 | addresseeview.h \ | 38 | addresseeview.h \ |
39 | formatfactory.h \ | 39 | formatfactory.h \ |
40 | formatplugin.h \ | 40 | formatplugin.h \ |
41 | phonenumber.h \ | 41 | phonenumber.h \ |
42 | distributionlist.h \ | 42 | distributionlist.h \ |
43 | distributionlistdialog.h \ | 43 | distributionlistdialog.h \ |
44 | distributionlisteditor.h \ | 44 | distributionlisteditor.h \ |
45 | vcardformatplugin.h \ | 45 | vcardformatplugin.h \ |
46 | formats/vcardformatplugin2.h \ | 46 | formats/vcardformatplugin2.h \ |
47 | picture.h \ | 47 | picture.h \ |
48 | secrecy.h \ | 48 | secrecy.h \ |
49 | sound.h \ | 49 | sound.h \ |
50 | addressbook.h \ | 50 | addressbook.h \ |
51 | syncprefwidget.h \ | ||
52 | timezone.h \ | 51 | timezone.h \ |
53 | tmpaddressbook.h \ | 52 | tmpaddressbook.h \ |
54 | addressee.h \ | 53 | addressee.h \ |
55 | addresseedialog.h \ | 54 | addresseedialog.h \ |
56 | vcardconverter.h \ | 55 | vcardconverter.h \ |
57 | vcard21parser.h \ | 56 | vcard21parser.h \ |
58 | vcardformatimpl.h \ | 57 | vcardformatimpl.h \ |
59 | plugins/file/resourcefile.h \ | 58 | plugins/file/resourcefile.h \ |
60 | plugins/file/resourcefileconfig.h \ | 59 | plugins/file/resourcefileconfig.h \ |
61 | plugins/dir/resourcedir.h \ | 60 | plugins/dir/resourcedir.h \ |
62 | plugins/dir/resourcedirconfig.h \ | 61 | plugins/dir/resourcedirconfig.h \ |
63 | vcardparser/vcardline.h \ | 62 | vcardparser/vcardline.h \ |
64 | vcardparser/vcard.h \ | 63 | vcardparser/vcard.h \ |
65 | vcardparser/vcardtool.h \ | 64 | vcardparser/vcardtool.h \ |
66 | vcardparser/vcardparser.h \ | 65 | vcardparser/vcardparser.h \ |
67 | vcard/include/VCardAdrParam.h \ | 66 | vcard/include/VCardAdrParam.h \ |
68 | vcard/include/VCardAdrValue.h \ | 67 | vcard/include/VCardAdrValue.h \ |
69 | vcard/include/VCardAgentParam.h \ | 68 | vcard/include/VCardAgentParam.h \ |
70 | vcard/include/VCardContentLine.h \ | 69 | vcard/include/VCardContentLine.h \ |
71 | vcard/include/VCardDateParam.h \ | 70 | vcard/include/VCardDateParam.h \ |
72 | vcard/include/VCardDateValue.h \ | 71 | vcard/include/VCardDateValue.h \ |
73 | vcard/include/VCardEmailParam.h \ | 72 | vcard/include/VCardEmailParam.h \ |
74 | vcard/include/VCardGeoValue.h \ | 73 | vcard/include/VCardGeoValue.h \ |
75 | vcard/include/VCardGroup.h \ | 74 | vcard/include/VCardGroup.h \ |
76 | vcard/include/VCardImageParam.h \ | 75 | vcard/include/VCardImageParam.h \ |
77 | vcard/include/VCardImageValue.h \ | 76 | vcard/include/VCardImageValue.h \ |
78 | vcard/include/VCardLangValue.h \ | 77 | vcard/include/VCardLangValue.h \ |
79 | vcard/include/VCardNValue.h \ | 78 | vcard/include/VCardNValue.h \ |
80 | vcard/include/VCardParam.h \ | 79 | vcard/include/VCardParam.h \ |
81 | vcard/include/VCardPhoneNumberValue.h \ | 80 | vcard/include/VCardPhoneNumberValue.h \ |
82 | vcard/include/VCardSourceParam.h \ | 81 | vcard/include/VCardSourceParam.h \ |
83 | vcard/include/VCardTelParam.h \ | 82 | vcard/include/VCardTelParam.h \ |
84 | vcard/include/VCardTextParam.h \ | 83 | vcard/include/VCardTextParam.h \ |
85 | vcard/include/VCardTextValue.h \ | 84 | vcard/include/VCardTextValue.h \ |
86 | vcard/include/VCardTextBinParam.h \ | 85 | vcard/include/VCardTextBinParam.h \ |
87 | vcard/include/VCardURIValue.h \ | 86 | vcard/include/VCardURIValue.h \ |
88 | vcard/include/VCardVCard.h \ | 87 | vcard/include/VCardVCard.h \ |
89 | vcard/include/VCardEntity.h \ | 88 | vcard/include/VCardEntity.h \ |
90 | vcard/include/VCardValue.h \ | 89 | vcard/include/VCardValue.h \ |
91 | vcard/include/VCardSoundValue.h \ | 90 | vcard/include/VCardSoundValue.h \ |
92 | vcard/include/VCardAgentValue.h \ | 91 | vcard/include/VCardAgentValue.h \ |
93 | vcard/include/VCardTelValue.h \ | 92 | vcard/include/VCardTelValue.h \ |
94 | vcard/include/VCardTextBinValue.h \ | 93 | vcard/include/VCardTextBinValue.h \ |
95 | vcard/include/VCardOrgValue.h \ | 94 | vcard/include/VCardOrgValue.h \ |
96 | vcard/include/VCardUTCValue.h \ | 95 | vcard/include/VCardUTCValue.h \ |
97 | vcard/include/VCardClassValue.h \ | 96 | vcard/include/VCardClassValue.h \ |
98 | vcard/include/VCardFloatValue.h \ | 97 | vcard/include/VCardFloatValue.h \ |
99 | vcard/include/VCardTextListValue.h \ | 98 | vcard/include/VCardTextListValue.h \ |
100 | vcard/include/generated/AdrParam-generated.h \ | 99 | vcard/include/generated/AdrParam-generated.h \ |
101 | vcard/include/generated/AdrValue-generated.h \ | 100 | vcard/include/generated/AdrValue-generated.h \ |
102 | vcard/include/generated/AgentParam-generated.h \ | 101 | vcard/include/generated/AgentParam-generated.h \ |
103 | vcard/include/generated/ContentLine-generated.h \ | 102 | vcard/include/generated/ContentLine-generated.h \ |
104 | vcard/include/generated/DateParam-generated.h \ | 103 | vcard/include/generated/DateParam-generated.h \ |
105 | vcard/include/generated/DateValue-generated.h \ | 104 | vcard/include/generated/DateValue-generated.h \ |
106 | vcard/include/generated/EmailParam-generated.h \ | 105 | vcard/include/generated/EmailParam-generated.h \ |
107 | vcard/include/generated/GeoValue-generated.h \ | 106 | vcard/include/generated/GeoValue-generated.h \ |
108 | vcard/include/generated/Group-generated.h \ | 107 | vcard/include/generated/Group-generated.h \ |
109 | vcard/include/generated/ImageParam-generated.h \ | 108 | vcard/include/generated/ImageParam-generated.h \ |
110 | vcard/include/generated/ImageValue-generated.h \ | 109 | vcard/include/generated/ImageValue-generated.h \ |
111 | vcard/include/generated/LangValue-generated.h \ | 110 | vcard/include/generated/LangValue-generated.h \ |
112 | vcard/include/generated/NValue-generated.h \ | 111 | vcard/include/generated/NValue-generated.h \ |
113 | vcard/include/generated/Param-generated.h \ | 112 | vcard/include/generated/Param-generated.h \ |
114 | vcard/include/generated/PhoneNumberValue-generated.h \ | 113 | vcard/include/generated/PhoneNumberValue-generated.h \ |
115 | vcard/include/generated/SourceParam-generated.h \ | 114 | vcard/include/generated/SourceParam-generated.h \ |
116 | vcard/include/generated/TelParam-generated.h \ | 115 | vcard/include/generated/TelParam-generated.h \ |
117 | vcard/include/generated/TextParam-generated.h \ | 116 | vcard/include/generated/TextParam-generated.h \ |
118 | vcard/include/generated/TextNSParam-generated.h \ | 117 | vcard/include/generated/TextNSParam-generated.h \ |
119 | vcard/include/generated/TextValue-generated.h \ | 118 | vcard/include/generated/TextValue-generated.h \ |
120 | vcard/include/generated/TextBinParam-generated.h \ | 119 | vcard/include/generated/TextBinParam-generated.h \ |
121 | vcard/include/generated/URIValue-generated.h \ | 120 | vcard/include/generated/URIValue-generated.h \ |
122 | vcard/include/generated/VCard-generated.h \ | 121 | vcard/include/generated/VCard-generated.h \ |
123 | vcard/include/generated/VCardEntity-generated.h \ | 122 | vcard/include/generated/VCardEntity-generated.h \ |
124 | vcard/include/generated/Value-generated.h \ | 123 | vcard/include/generated/Value-generated.h \ |
125 | vcard/include/generated/SoundValue-generated.h \ | 124 | vcard/include/generated/SoundValue-generated.h \ |
126 | vcard/include/generated/AgentValue-generated.h \ | 125 | vcard/include/generated/AgentValue-generated.h \ |
127 | vcard/include/generated/TelValue-generated.h \ | 126 | vcard/include/generated/TelValue-generated.h \ |
128 | vcard/include/generated/TextBinValue-generated.h \ | 127 | vcard/include/generated/TextBinValue-generated.h \ |
129 | vcard/include/generated/OrgValue-generated.h \ | 128 | vcard/include/generated/OrgValue-generated.h \ |
130 | vcard/include/generated/UTCValue-generated.h \ | 129 | vcard/include/generated/UTCValue-generated.h \ |
131 | vcard/include/generated/ClassValue-generated.h \ | 130 | vcard/include/generated/ClassValue-generated.h \ |
132 | vcard/include/generated/FloatValue-generated.h \ | 131 | vcard/include/generated/FloatValue-generated.h \ |
133 | vcard/include/generated/TextListValue-generated.h | 132 | vcard/include/generated/TextListValue-generated.h |
134 | 133 | ||
135 | 134 | ||
136 | # plugins/ldap/resourceldap.h \ | 135 | # plugins/ldap/resourceldap.h \ |
137 | # plugins/ldap/resourceldapconfig.h \ | 136 | # plugins/ldap/resourceldapconfig.h \ |
138 | #formats/binary/binaryformat.h \ | 137 | #formats/binary/binaryformat.h \ |
139 | 138 | ||
140 | #vcard/include/VCardTextNSParam.h \ | 139 | #vcard/include/VCardTextNSParam.h \ |
141 | 140 | ||
142 | SOURCES = \ | 141 | SOURCES = \ |
143 | distributionlist.cpp \ | 142 | distributionlist.cpp \ |
144 | distributionlistdialog.cpp \ | 143 | distributionlistdialog.cpp \ |
145 | distributionlisteditor.cpp \ | 144 | distributionlisteditor.cpp \ |
146 | vcardformatplugin.cpp \ | 145 | vcardformatplugin.cpp \ |
147 | formats/vcardformatplugin2.cpp \ | 146 | formats/vcardformatplugin2.cpp \ |
148 | formatfactory.cpp \ | 147 | formatfactory.cpp \ |
149 | resource.cpp \ | 148 | resource.cpp \ |
150 | stdaddressbook.cpp \ | 149 | stdaddressbook.cpp \ |
151 | plugin.cpp \ | 150 | plugin.cpp \ |
152 | agent.cpp \ | 151 | agent.cpp \ |
153 | geo.cpp \ | 152 | geo.cpp \ |
154 | key.cpp \ | 153 | key.cpp \ |
155 | field.cpp \ | 154 | field.cpp \ |
156 | addresseeview.cpp \ | 155 | addresseeview.cpp \ |
157 | address.cpp \ | 156 | address.cpp \ |
158 | phonenumber.cpp \ | 157 | phonenumber.cpp \ |
159 | picture.cpp \ | 158 | picture.cpp \ |
160 | secrecy.cpp \ | 159 | secrecy.cpp \ |
161 | sound.cpp \ | 160 | sound.cpp \ |
162 | addressbook.cpp \ | 161 | addressbook.cpp \ |
163 | syncprefwidget.cpp \ | ||
164 | timezone.cpp \ | 162 | timezone.cpp \ |
165 | tmpaddressbook.cpp \ | 163 | tmpaddressbook.cpp \ |
166 | addressee.cpp \ | 164 | addressee.cpp \ |
167 | addresseelist.cpp \ | 165 | addresseelist.cpp \ |
168 | addresseedialog.cpp \ | 166 | addresseedialog.cpp \ |
169 | vcardconverter.cpp \ | 167 | vcardconverter.cpp \ |
170 | vcard21parser.cpp \ | 168 | vcard21parser.cpp \ |
171 | vcardformatimpl.cpp \ | 169 | vcardformatimpl.cpp \ |
172 | plugins/file/resourcefile.cpp \ | 170 | plugins/file/resourcefile.cpp \ |
173 | plugins/file/resourcefileconfig.cpp \ | 171 | plugins/file/resourcefileconfig.cpp \ |
174 | plugins/dir/resourcedir.cpp \ | 172 | plugins/dir/resourcedir.cpp \ |
175 | plugins/dir/resourcedirconfig.cpp \ | 173 | plugins/dir/resourcedirconfig.cpp \ |
176 | vcardparser/vcardline.cpp \ | 174 | vcardparser/vcardline.cpp \ |
177 | vcardparser/vcard.cpp \ | 175 | vcardparser/vcard.cpp \ |
178 | vcardparser/vcardtool.cpp \ | 176 | vcardparser/vcardtool.cpp \ |
179 | vcardparser/vcardparser.cpp \ | 177 | vcardparser/vcardparser.cpp \ |
180 | vcard/AdrParam.cpp \ | 178 | vcard/AdrParam.cpp \ |
181 | vcard/AdrValue.cpp \ | 179 | vcard/AdrValue.cpp \ |
182 | vcard/AgentParam.cpp \ | 180 | vcard/AgentParam.cpp \ |
183 | vcard/ContentLine.cpp \ | 181 | vcard/ContentLine.cpp \ |
184 | vcard/DateParam.cpp \ | 182 | vcard/DateParam.cpp \ |
185 | vcard/DateValue.cpp \ | 183 | vcard/DateValue.cpp \ |
186 | vcard/EmailParam.cpp \ | 184 | vcard/EmailParam.cpp \ |
187 | vcard/Entity.cpp \ | 185 | vcard/Entity.cpp \ |
188 | vcard/Enum.cpp \ | 186 | vcard/Enum.cpp \ |
189 | vcard/GeoValue.cpp \ | 187 | vcard/GeoValue.cpp \ |
190 | vcard/ImageParam.cpp \ | 188 | vcard/ImageParam.cpp \ |
191 | vcard/ImageValue.cpp \ | 189 | vcard/ImageValue.cpp \ |
192 | vcard/LangValue.cpp \ | 190 | vcard/LangValue.cpp \ |
193 | vcard/NValue.cpp \ | 191 | vcard/NValue.cpp \ |
194 | vcard/Param.cpp \ | 192 | vcard/Param.cpp \ |
195 | vcard/PhoneNumberValue.cpp \ | 193 | vcard/PhoneNumberValue.cpp \ |
196 | vcard/RToken.cpp \ | 194 | vcard/RToken.cpp \ |
197 | vcard/SourceParam.cpp \ | 195 | vcard/SourceParam.cpp \ |
198 | vcard/TelParam.cpp \ | 196 | vcard/TelParam.cpp \ |
199 | vcard/TextParam.cpp \ | 197 | vcard/TextParam.cpp \ |
200 | vcard/TextValue.cpp \ | 198 | vcard/TextValue.cpp \ |
201 | vcard/TextBinParam.cpp \ | 199 | vcard/TextBinParam.cpp \ |
202 | vcard/URIValue.cpp \ | 200 | vcard/URIValue.cpp \ |
203 | vcard/VCardv.cpp \ | 201 | vcard/VCardv.cpp \ |
204 | vcard/VCardEntity.cpp \ | 202 | vcard/VCardEntity.cpp \ |
205 | vcard/Value.cpp \ | 203 | vcard/Value.cpp \ |
206 | vcard/SoundValue.cpp \ | 204 | vcard/SoundValue.cpp \ |
207 | vcard/AgentValue.cpp \ | 205 | vcard/AgentValue.cpp \ |
208 | vcard/TelValue.cpp \ | 206 | vcard/TelValue.cpp \ |
209 | vcard/TextBinValue.cpp \ | 207 | vcard/TextBinValue.cpp \ |
210 | vcard/OrgValue.cpp \ | 208 | vcard/OrgValue.cpp \ |
211 | vcard/UTCValue.cpp \ | 209 | vcard/UTCValue.cpp \ |
212 | vcard/ClassValue.cpp \ | 210 | vcard/ClassValue.cpp \ |
213 | vcard/FloatValue.cpp \ | 211 | vcard/FloatValue.cpp \ |
214 | vcard/TextListValue.cpp | 212 | vcard/TextListValue.cpp |
215 | 213 | ||
216 | 214 | ||
217 | # plugins/ldap/resourceldap.cpp \ | 215 | # plugins/ldap/resourceldap.cpp \ |
218 | # plugins/ldap/resourceldapconfig.cpp \ | 216 | # plugins/ldap/resourceldapconfig.cpp \ |
219 | 217 | ||
220 | #formats/binary/binaryformat.cpp \ | 218 | #formats/binary/binaryformat.cpp \ |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3e0a27d..e4a11f5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -877,558 +877,560 @@ Event* CalendarView::getLastSyncEvent() | |||
877 | // we check, if the to delete event has a id for a profile | 877 | // we check, if the to delete event has a id for a profile |
878 | // if yes, we set this id in the profile to delete | 878 | // if yes, we set this id in the profile to delete |
879 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 879 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
880 | { | 880 | { |
881 | if ( lastSync.count() == 0 ) { | 881 | if ( lastSync.count() == 0 ) { |
882 | //qDebug(" lastSync.count() == 0"); | 882 | //qDebug(" lastSync.count() == 0"); |
883 | return; | 883 | return; |
884 | } | 884 | } |
885 | if ( toDelete->type() == "Journal" ) | 885 | if ( toDelete->type() == "Journal" ) |
886 | return; | 886 | return; |
887 | 887 | ||
888 | Event* eve = lastSync.first(); | 888 | Event* eve = lastSync.first(); |
889 | 889 | ||
890 | while ( eve ) { | 890 | while ( eve ) { |
891 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 891 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
892 | if ( !id.isEmpty() ) { | 892 | if ( !id.isEmpty() ) { |
893 | QString des = eve->description(); | 893 | QString des = eve->description(); |
894 | QString pref = "e"; | 894 | QString pref = "e"; |
895 | if ( toDelete->type() == "Todo" ) | 895 | if ( toDelete->type() == "Todo" ) |
896 | pref = "t"; | 896 | pref = "t"; |
897 | des += pref+ id + ","; | 897 | des += pref+ id + ","; |
898 | eve->setReadOnly( false ); | 898 | eve->setReadOnly( false ); |
899 | eve->setDescription( des ); | 899 | eve->setDescription( des ); |
900 | //qDebug("setdes %s ", des.latin1()); | 900 | //qDebug("setdes %s ", des.latin1()); |
901 | eve->setReadOnly( true ); | 901 | eve->setReadOnly( true ); |
902 | } | 902 | } |
903 | eve = lastSync.next(); | 903 | eve = lastSync.next(); |
904 | } | 904 | } |
905 | 905 | ||
906 | } | 906 | } |
907 | void CalendarView::checkExternalId( Incidence * inc ) | 907 | void CalendarView::checkExternalId( Incidence * inc ) |
908 | { | 908 | { |
909 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 909 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
910 | checkExternSyncEvent( lastSync, inc ); | 910 | checkExternSyncEvent( lastSync, inc ); |
911 | 911 | ||
912 | } | 912 | } |
913 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 913 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
914 | { | 914 | { |
915 | bool syncOK = true; | 915 | bool syncOK = true; |
916 | int addedEvent = 0; | 916 | int addedEvent = 0; |
917 | int addedEventR = 0; | 917 | int addedEventR = 0; |
918 | int deletedEventR = 0; | 918 | int deletedEventR = 0; |
919 | int deletedEventL = 0; | 919 | int deletedEventL = 0; |
920 | int changedLocal = 0; | 920 | int changedLocal = 0; |
921 | int changedRemote = 0; | 921 | int changedRemote = 0; |
922 | //QPtrList<Event> el = local->rawEvents(); | 922 | //QPtrList<Event> el = local->rawEvents(); |
923 | Event* eventR; | 923 | Event* eventR; |
924 | QString uid; | 924 | QString uid; |
925 | int take; | 925 | int take; |
926 | Event* eventL; | 926 | Event* eventL; |
927 | Event* eventRSync; | 927 | Event* eventRSync; |
928 | Event* eventLSync; | 928 | Event* eventLSync; |
929 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 929 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
930 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 930 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
931 | bool fullDateRange = false; | 931 | bool fullDateRange = false; |
932 | local->resetTempSyncStat(); | 932 | local->resetTempSyncStat(); |
933 | mLastCalendarSync = QDateTime::currentDateTime(); | 933 | mLastCalendarSync = QDateTime::currentDateTime(); |
934 | QDateTime modifiedCalendar = mLastCalendarSync;; | 934 | QDateTime modifiedCalendar = mLastCalendarSync;; |
935 | eventLSync = getLastSyncEvent(); | 935 | eventLSync = getLastSyncEvent(); |
936 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 936 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
937 | if ( eventR ) { | 937 | if ( eventR ) { |
938 | eventRSync = (Event*) eventR->clone(); | 938 | eventRSync = (Event*) eventR->clone(); |
939 | remote->deleteEvent(eventR ); | 939 | remote->deleteEvent(eventR ); |
940 | 940 | ||
941 | } else { | 941 | } else { |
942 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 942 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
943 | eventRSync = (Event*)eventLSync->clone(); | 943 | eventRSync = (Event*)eventLSync->clone(); |
944 | } else { | 944 | } else { |
945 | fullDateRange = true; | 945 | fullDateRange = true; |
946 | eventRSync = new Event(); | 946 | eventRSync = new Event(); |
947 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 947 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
948 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 948 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
949 | eventRSync->setDtStart( mLastCalendarSync ); | 949 | eventRSync->setDtStart( mLastCalendarSync ); |
950 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 950 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
951 | eventRSync->setCategories( i18n("SyncEvent") ); | 951 | eventRSync->setCategories( i18n("SyncEvent") ); |
952 | } | 952 | } |
953 | } | 953 | } |
954 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 954 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
955 | fullDateRange = true; | 955 | fullDateRange = true; |
956 | 956 | ||
957 | if ( ! fullDateRange ) { | 957 | if ( ! fullDateRange ) { |
958 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 958 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
959 | 959 | ||
960 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 960 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
961 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 961 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
962 | fullDateRange = true; | 962 | fullDateRange = true; |
963 | } | 963 | } |
964 | } | 964 | } |
965 | if ( fullDateRange ) | 965 | if ( fullDateRange ) |
966 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 966 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
967 | else | 967 | else |
968 | mLastCalendarSync = eventLSync->dtStart(); | 968 | mLastCalendarSync = eventLSync->dtStart(); |
969 | // for resyncing if own file has changed | 969 | // for resyncing if own file has changed |
970 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 970 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
971 | mLastCalendarSync = loadedFileVersion; | 971 | mLastCalendarSync = loadedFileVersion; |
972 | qDebug("setting mLastCalendarSync "); | 972 | qDebug("setting mLastCalendarSync "); |
973 | } | 973 | } |
974 | //qDebug("*************************** "); | 974 | //qDebug("*************************** "); |
975 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 975 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
976 | QPtrList<Incidence> er = remote->rawIncidences(); | 976 | QPtrList<Incidence> er = remote->rawIncidences(); |
977 | Incidence* inR = er.first(); | 977 | Incidence* inR = er.first(); |
978 | Incidence* inL; | 978 | Incidence* inL; |
979 | QProgressBar bar( er.count(),0 ); | 979 | QProgressBar bar( er.count(),0 ); |
980 | bar.setCaption (i18n("Syncing - close to abort!") ); | 980 | bar.setCaption (i18n("Syncing - close to abort!") ); |
981 | 981 | ||
982 | int w = 300; | 982 | int w = 300; |
983 | if ( QApplication::desktop()->width() < 320 ) | 983 | if ( QApplication::desktop()->width() < 320 ) |
984 | w = 220; | 984 | w = 220; |
985 | int h = bar.sizeHint().height() ; | 985 | int h = bar.sizeHint().height() ; |
986 | int dw = QApplication::desktop()->width(); | 986 | int dw = QApplication::desktop()->width(); |
987 | int dh = QApplication::desktop()->height(); | 987 | int dh = QApplication::desktop()->height(); |
988 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 988 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
989 | bar.show(); | 989 | bar.show(); |
990 | int modulo = (er.count()/10)+1; | 990 | int modulo = (er.count()/10)+1; |
991 | int incCounter = 0; | 991 | int incCounter = 0; |
992 | while ( inR ) { | 992 | while ( inR ) { |
993 | if ( ! bar.isVisible() ) | 993 | if ( ! bar.isVisible() ) |
994 | return false; | 994 | return false; |
995 | if ( incCounter % modulo == 0 ) | 995 | if ( incCounter % modulo == 0 ) |
996 | bar.setProgress( incCounter ); | 996 | bar.setProgress( incCounter ); |
997 | ++incCounter; | 997 | ++incCounter; |
998 | uid = inR->uid(); | 998 | uid = inR->uid(); |
999 | bool skipIncidence = false; | 999 | bool skipIncidence = false; |
1000 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1000 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1001 | skipIncidence = true; | 1001 | skipIncidence = true; |
1002 | QString idS; | 1002 | QString idS; |
1003 | qApp->processEvents(); | 1003 | qApp->processEvents(); |
1004 | if ( !skipIncidence ) { | 1004 | if ( !skipIncidence ) { |
1005 | inL = local->incidence( uid ); | 1005 | inL = local->incidence( uid ); |
1006 | if ( inL ) { // maybe conflict - same uid in both calendars | 1006 | if ( inL ) { // maybe conflict - same uid in both calendars |
1007 | int maxrev = inL->revision(); | 1007 | int maxrev = inL->revision(); |
1008 | if ( maxrev < inR->revision() ) | 1008 | if ( maxrev < inR->revision() ) |
1009 | maxrev = inR->revision(); | 1009 | maxrev = inR->revision(); |
1010 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1010 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1011 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1011 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1012 | if ( take == 3 ) | 1012 | if ( take == 3 ) |
1013 | return false; | 1013 | return false; |
1014 | if ( take == 1 ) {// take local | 1014 | if ( take == 1 ) {// take local |
1015 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1015 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1016 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1016 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1017 | else | 1017 | else |
1018 | idS = inR->IDStr(); | 1018 | idS = inR->IDStr(); |
1019 | remote->deleteIncidence( inR ); | 1019 | remote->deleteIncidence( inR ); |
1020 | if ( inL->revision() < maxrev ) | 1020 | if ( inL->revision() < maxrev ) |
1021 | inL->setRevision( maxrev ); | 1021 | inL->setRevision( maxrev ); |
1022 | inR = inL->clone(); | 1022 | inR = inL->clone(); |
1023 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1023 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1024 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1024 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1025 | inR->setIDStr( idS ); | 1025 | inR->setIDStr( idS ); |
1026 | remote->addIncidence( inR ); | 1026 | remote->addIncidence( inR ); |
1027 | ++changedRemote; | 1027 | ++changedRemote; |
1028 | } else { | 1028 | } else { |
1029 | if ( inR->revision() < maxrev ) | 1029 | if ( inR->revision() < maxrev ) |
1030 | inR->setRevision( maxrev ); | 1030 | inR->setRevision( maxrev ); |
1031 | idS = inL->IDStr(); | 1031 | idS = inL->IDStr(); |
1032 | local->deleteIncidence( inL ); | 1032 | local->deleteIncidence( inL ); |
1033 | inL = inR->clone(); | 1033 | inL = inR->clone(); |
1034 | inL->setIDStr( idS ); | 1034 | inL->setIDStr( idS ); |
1035 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1035 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1036 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1036 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1037 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1037 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1038 | } | 1038 | } |
1039 | local->addIncidence( inL ); | 1039 | local->addIncidence( inL ); |
1040 | ++changedLocal; | 1040 | ++changedLocal; |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } else { // no conflict | 1043 | } else { // no conflict |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | QString des = eventLSync->description(); | 1045 | QString des = eventLSync->description(); |
1046 | QString pref = "e"; | 1046 | QString pref = "e"; |
1047 | if ( inR->type() == "Todo" ) | 1047 | if ( inR->type() == "Todo" ) |
1048 | pref = "t"; | 1048 | pref = "t"; |
1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1051 | //remote->deleteIncidence( inR ); | 1051 | //remote->deleteIncidence( inR ); |
1052 | ++deletedEventR; | 1052 | ++deletedEventR; |
1053 | } else { | 1053 | } else { |
1054 | inR->setLastModified( modifiedCalendar ); | 1054 | inR->setLastModified( modifiedCalendar ); |
1055 | inL = inR->clone(); | 1055 | inL = inR->clone(); |
1056 | local->addIncidence( inL ); | 1056 | local->addIncidence( inL ); |
1057 | ++addedEvent; | 1057 | ++addedEvent; |
1058 | } | 1058 | } |
1059 | } else { | 1059 | } else { |
1060 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1060 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1061 | inR->setLastModified( modifiedCalendar ); | 1061 | inR->setLastModified( modifiedCalendar ); |
1062 | local->addIncidence( inR->clone() ); | 1062 | local->addIncidence( inR->clone() ); |
1063 | ++addedEvent; | 1063 | ++addedEvent; |
1064 | } else { | 1064 | } else { |
1065 | checkExternSyncEvent(eventRSyncSharp, inR); | 1065 | checkExternSyncEvent(eventRSyncSharp, inR); |
1066 | remote->deleteIncidence( inR ); | 1066 | remote->deleteIncidence( inR ); |
1067 | ++deletedEventR; | 1067 | ++deletedEventR; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | inR = er.next(); | 1072 | inR = er.next(); |
1073 | } | 1073 | } |
1074 | QPtrList<Incidence> el = local->rawIncidences(); | 1074 | QPtrList<Incidence> el = local->rawIncidences(); |
1075 | inL = el.first(); | 1075 | inL = el.first(); |
1076 | modulo = (el.count()/10)+1; | 1076 | modulo = (el.count()/10)+1; |
1077 | bar.setCaption (i18n("Add / remove events") ); | 1077 | bar.setCaption (i18n("Add / remove events") ); |
1078 | bar.setTotalSteps ( el.count() ) ; | 1078 | bar.setTotalSteps ( el.count() ) ; |
1079 | bar.show(); | 1079 | bar.show(); |
1080 | incCounter = 0; | 1080 | incCounter = 0; |
1081 | 1081 | ||
1082 | while ( inL ) { | 1082 | while ( inL ) { |
1083 | 1083 | ||
1084 | qApp->processEvents(); | 1084 | qApp->processEvents(); |
1085 | if ( ! bar.isVisible() ) | 1085 | if ( ! bar.isVisible() ) |
1086 | return false; | 1086 | return false; |
1087 | if ( incCounter % modulo == 0 ) | 1087 | if ( incCounter % modulo == 0 ) |
1088 | bar.setProgress( incCounter ); | 1088 | bar.setProgress( incCounter ); |
1089 | ++incCounter; | 1089 | ++incCounter; |
1090 | uid = inL->uid(); | 1090 | uid = inL->uid(); |
1091 | bool skipIncidence = false; | 1091 | bool skipIncidence = false; |
1092 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1092 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1093 | skipIncidence = true; | 1093 | skipIncidence = true; |
1094 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1094 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1095 | skipIncidence = true; | 1095 | skipIncidence = true; |
1096 | if ( !skipIncidence ) { | 1096 | if ( !skipIncidence ) { |
1097 | inR = remote->incidence( uid ); | 1097 | inR = remote->incidence( uid ); |
1098 | if ( ! inR ) { | 1098 | if ( ! inR ) { |
1099 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1099 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1100 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1100 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1101 | checkExternSyncEvent(eventLSyncSharp, inL); | 1101 | checkExternSyncEvent(eventLSyncSharp, inL); |
1102 | local->deleteIncidence( inL ); | 1102 | local->deleteIncidence( inL ); |
1103 | ++deletedEventL; | 1103 | ++deletedEventL; |
1104 | } else { | 1104 | } else { |
1105 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1105 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1106 | inL->removeID(mCurrentSyncDevice ); | 1106 | inL->removeID(mCurrentSyncDevice ); |
1107 | ++addedEventR; | 1107 | ++addedEventR; |
1108 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1108 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1109 | inL->setLastModified( modifiedCalendar ); | 1109 | inL->setLastModified( modifiedCalendar ); |
1110 | inR = inL->clone(); | 1110 | inR = inL->clone(); |
1111 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1111 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1112 | remote->addIncidence( inR ); | 1112 | remote->addIncidence( inR ); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | } else { | 1115 | } else { |
1116 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1116 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1117 | checkExternSyncEvent(eventLSyncSharp, inL); | 1117 | checkExternSyncEvent(eventLSyncSharp, inL); |
1118 | local->deleteIncidence( inL ); | 1118 | local->deleteIncidence( inL ); |
1119 | ++deletedEventL; | 1119 | ++deletedEventL; |
1120 | } else { | 1120 | } else { |
1121 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1121 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1122 | ++addedEventR; | 1122 | ++addedEventR; |
1123 | inL->setLastModified( modifiedCalendar ); | 1123 | inL->setLastModified( modifiedCalendar ); |
1124 | remote->addIncidence( inL->clone() ); | 1124 | remote->addIncidence( inL->clone() ); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | inL = el.next(); | 1130 | inL = el.next(); |
1131 | } | 1131 | } |
1132 | int delFut = 0; | 1132 | int delFut = 0; |
1133 | int remRem = 0; | ||
1133 | if ( mSyncManager->mWriteBackInFuture ) { | 1134 | if ( mSyncManager->mWriteBackInFuture ) { |
1134 | er = remote->rawIncidences(); | 1135 | er = remote->rawIncidences(); |
1136 | remRem = er.count(); | ||
1135 | inR = er.first(); | 1137 | inR = er.first(); |
1136 | QDateTime dt; | 1138 | QDateTime dt; |
1137 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1139 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1138 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1140 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1139 | while ( inR ) { | 1141 | while ( inR ) { |
1140 | if ( inR->type() == "Todo" ) { | 1142 | if ( inR->type() == "Todo" ) { |
1141 | Todo * t = (Todo*)inR; | 1143 | Todo * t = (Todo*)inR; |
1142 | if ( t->hasDueDate() ) | 1144 | if ( t->hasDueDate() ) |
1143 | dt = t->dtDue(); | 1145 | dt = t->dtDue(); |
1144 | else | 1146 | else |
1145 | dt = cur.addSecs( 62 ); | 1147 | dt = cur.addSecs( 62 ); |
1146 | } | 1148 | } |
1147 | else if (inR->type() == "Event" ) { | 1149 | else if (inR->type() == "Event" ) { |
1148 | bool ok; | 1150 | bool ok; |
1149 | dt = inR->getNextOccurence( cur, &ok ); | 1151 | dt = inR->getNextOccurence( cur, &ok ); |
1150 | if ( !ok ) | 1152 | if ( !ok ) |
1151 | dt = cur.addSecs( -62 ); | 1153 | dt = cur.addSecs( -62 ); |
1152 | } | 1154 | } |
1153 | else | 1155 | else |
1154 | dt = inR->dtStart(); | 1156 | dt = inR->dtStart(); |
1155 | if ( dt < cur || dt > end ) { | 1157 | if ( dt < cur || dt > end ) { |
1156 | remote->deleteIncidence( inR ); | 1158 | remote->deleteIncidence( inR ); |
1157 | ++delFut; | 1159 | ++delFut; |
1158 | } | 1160 | } |
1159 | inR = er.next(); | 1161 | inR = er.next(); |
1160 | } | 1162 | } |
1161 | } | 1163 | } |
1162 | bar.hide(); | 1164 | bar.hide(); |
1163 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1165 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1164 | eventLSync->setReadOnly( false ); | 1166 | eventLSync->setReadOnly( false ); |
1165 | eventLSync->setDtStart( mLastCalendarSync ); | 1167 | eventLSync->setDtStart( mLastCalendarSync ); |
1166 | eventRSync->setDtStart( mLastCalendarSync ); | 1168 | eventRSync->setDtStart( mLastCalendarSync ); |
1167 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1169 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1168 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1170 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1169 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1171 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1170 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1172 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1171 | eventLSync->setReadOnly( true ); | 1173 | eventLSync->setReadOnly( true ); |
1172 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1174 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1173 | remote->addEvent( eventRSync ); | 1175 | remote->addEvent( eventRSync ); |
1174 | QString mes; | 1176 | QString mes; |
1175 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1177 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1176 | QString delmess; | 1178 | QString delmess; |
1177 | if ( delFut ) { | 1179 | if ( delFut ) { |
1178 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); | 1180 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1179 | mes += delmess; | 1181 | mes += delmess; |
1180 | } | 1182 | } |
1181 | if ( mSyncManager->mShowSyncSummary ) { | 1183 | if ( mSyncManager->mShowSyncSummary ) { |
1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1184 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1183 | } | 1185 | } |
1184 | qDebug( mes ); | 1186 | qDebug( mes ); |
1185 | mCalendar->checkAlarmForIncidence( 0, true ); | 1187 | mCalendar->checkAlarmForIncidence( 0, true ); |
1186 | return syncOK; | 1188 | return syncOK; |
1187 | } | 1189 | } |
1188 | 1190 | ||
1189 | void CalendarView::setSyncDevice( QString s ) | 1191 | void CalendarView::setSyncDevice( QString s ) |
1190 | { | 1192 | { |
1191 | mCurrentSyncDevice= s; | 1193 | mCurrentSyncDevice= s; |
1192 | } | 1194 | } |
1193 | void CalendarView::setSyncName( QString s ) | 1195 | void CalendarView::setSyncName( QString s ) |
1194 | { | 1196 | { |
1195 | mCurrentSyncName= s; | 1197 | mCurrentSyncName= s; |
1196 | } | 1198 | } |
1197 | bool CalendarView::syncCalendar(QString filename, int mode) | 1199 | bool CalendarView::syncCalendar(QString filename, int mode) |
1198 | { | 1200 | { |
1199 | //qDebug("syncCalendar %s ", filename.latin1()); | 1201 | //qDebug("syncCalendar %s ", filename.latin1()); |
1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1202 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1201 | CalendarLocal* calendar = new CalendarLocal(); | 1203 | CalendarLocal* calendar = new CalendarLocal(); |
1202 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1204 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1203 | FileStorage* storage = new FileStorage( calendar ); | 1205 | FileStorage* storage = new FileStorage( calendar ); |
1204 | bool syncOK = false; | 1206 | bool syncOK = false; |
1205 | storage->setFileName( filename ); | 1207 | storage->setFileName( filename ); |
1206 | // qDebug("loading ... "); | 1208 | // qDebug("loading ... "); |
1207 | if ( storage->load() ) { | 1209 | if ( storage->load() ) { |
1208 | getEventViewerDialog()->setSyncMode( true ); | 1210 | getEventViewerDialog()->setSyncMode( true ); |
1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1211 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1210 | getEventViewerDialog()->setSyncMode( false ); | 1212 | getEventViewerDialog()->setSyncMode( false ); |
1211 | if ( syncOK ) { | 1213 | if ( syncOK ) { |
1212 | if ( mSyncManager->mWriteBackFile ) | 1214 | if ( mSyncManager->mWriteBackFile ) |
1213 | { | 1215 | { |
1214 | storage->setSaveFormat( new ICalFormat() ); | 1216 | storage->setSaveFormat( new ICalFormat() ); |
1215 | storage->save(); | 1217 | storage->save(); |
1216 | } | 1218 | } |
1217 | } | 1219 | } |
1218 | setModified( true ); | 1220 | setModified( true ); |
1219 | } | 1221 | } |
1220 | delete storage; | 1222 | delete storage; |
1221 | delete calendar; | 1223 | delete calendar; |
1222 | if ( syncOK ) | 1224 | if ( syncOK ) |
1223 | updateView(); | 1225 | updateView(); |
1224 | return syncOK; | 1226 | return syncOK; |
1225 | } | 1227 | } |
1226 | 1228 | ||
1227 | void CalendarView::syncExternal( int mode ) | 1229 | void CalendarView::syncExternal( int mode ) |
1228 | { | 1230 | { |
1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1231 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1230 | 1232 | ||
1231 | qApp->processEvents(); | 1233 | qApp->processEvents(); |
1232 | CalendarLocal* calendar = new CalendarLocal(); | 1234 | CalendarLocal* calendar = new CalendarLocal(); |
1233 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1235 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1234 | bool syncOK = false; | 1236 | bool syncOK = false; |
1235 | bool loadSuccess = false; | 1237 | bool loadSuccess = false; |
1236 | PhoneFormat* phoneFormat = 0; | 1238 | PhoneFormat* phoneFormat = 0; |
1237 | #ifndef DESKTOP_VERSION | 1239 | #ifndef DESKTOP_VERSION |
1238 | SharpFormat* sharpFormat = 0; | 1240 | SharpFormat* sharpFormat = 0; |
1239 | if ( mode == 0 ) { // sharp | 1241 | if ( mode == 0 ) { // sharp |
1240 | sharpFormat = new SharpFormat () ; | 1242 | sharpFormat = new SharpFormat () ; |
1241 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1243 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1242 | 1244 | ||
1243 | } else | 1245 | } else |
1244 | #endif | 1246 | #endif |
1245 | if ( mode == 1 ) { // phone | 1247 | if ( mode == 1 ) { // phone |
1246 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1248 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1247 | mSyncManager->mPhoneDevice, | 1249 | mSyncManager->mPhoneDevice, |
1248 | mSyncManager->mPhoneConnection, | 1250 | mSyncManager->mPhoneConnection, |
1249 | mSyncManager->mPhoneModel); | 1251 | mSyncManager->mPhoneModel); |
1250 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1252 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1251 | 1253 | ||
1252 | } else | 1254 | } else |
1253 | return; | 1255 | return; |
1254 | if ( loadSuccess ) { | 1256 | if ( loadSuccess ) { |
1255 | getEventViewerDialog()->setSyncMode( true ); | 1257 | getEventViewerDialog()->setSyncMode( true ); |
1256 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1258 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1257 | getEventViewerDialog()->setSyncMode( false ); | 1259 | getEventViewerDialog()->setSyncMode( false ); |
1258 | qApp->processEvents(); | 1260 | qApp->processEvents(); |
1259 | if ( syncOK ) { | 1261 | if ( syncOK ) { |
1260 | if ( mSyncManager->mWriteBackFile ) | 1262 | if ( mSyncManager->mWriteBackFile ) |
1261 | { | 1263 | { |
1262 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1264 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1263 | Incidence* inc = iL.first(); | 1265 | Incidence* inc = iL.first(); |
1264 | if ( phoneFormat ) { | 1266 | if ( phoneFormat ) { |
1265 | while ( inc ) { | 1267 | while ( inc ) { |
1266 | inc->removeID(mCurrentSyncDevice); | 1268 | inc->removeID(mCurrentSyncDevice); |
1267 | inc = iL.next(); | 1269 | inc = iL.next(); |
1268 | } | 1270 | } |
1269 | } | 1271 | } |
1270 | #ifndef DESKTOP_VERSION | 1272 | #ifndef DESKTOP_VERSION |
1271 | if ( sharpFormat ) | 1273 | if ( sharpFormat ) |
1272 | sharpFormat->save(calendar); | 1274 | sharpFormat->save(calendar); |
1273 | #endif | 1275 | #endif |
1274 | if ( phoneFormat ) | 1276 | if ( phoneFormat ) |
1275 | phoneFormat->save(calendar); | 1277 | phoneFormat->save(calendar); |
1276 | iL = calendar->rawIncidences(); | 1278 | iL = calendar->rawIncidences(); |
1277 | inc = iL.first(); | 1279 | inc = iL.first(); |
1278 | Incidence* loc; | 1280 | Incidence* loc; |
1279 | while ( inc ) { | 1281 | while ( inc ) { |
1280 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1282 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1281 | loc = mCalendar->incidence(inc->uid() ); | 1283 | loc = mCalendar->incidence(inc->uid() ); |
1282 | if ( loc ) { | 1284 | if ( loc ) { |
1283 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1285 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1284 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1286 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1285 | } | 1287 | } |
1286 | } | 1288 | } |
1287 | inc = iL.next(); | 1289 | inc = iL.next(); |
1288 | } | 1290 | } |
1289 | Incidence* lse = getLastSyncEvent(); | 1291 | Incidence* lse = getLastSyncEvent(); |
1290 | if ( lse ) { | 1292 | if ( lse ) { |
1291 | lse->setReadOnly( false ); | 1293 | lse->setReadOnly( false ); |
1292 | lse->setDescription( "" ); | 1294 | lse->setDescription( "" ); |
1293 | lse->setReadOnly( true ); | 1295 | lse->setReadOnly( true ); |
1294 | } | 1296 | } |
1295 | } | 1297 | } |
1296 | } | 1298 | } |
1297 | setModified( true ); | 1299 | setModified( true ); |
1298 | } else { | 1300 | } else { |
1299 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1301 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1300 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1302 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1301 | question, i18n("Ok")) ; | 1303 | question, i18n("Ok")) ; |
1302 | 1304 | ||
1303 | } | 1305 | } |
1304 | delete calendar; | 1306 | delete calendar; |
1305 | updateView(); | 1307 | updateView(); |
1306 | return ;//syncOK; | 1308 | return ;//syncOK; |
1307 | 1309 | ||
1308 | } | 1310 | } |
1309 | 1311 | ||
1310 | bool CalendarView::importBday() | 1312 | bool CalendarView::importBday() |
1311 | { | 1313 | { |
1312 | #ifndef KORG_NOKABC | 1314 | #ifndef KORG_NOKABC |
1313 | 1315 | ||
1314 | #ifdef DESKTOP_VERSION | 1316 | #ifdef DESKTOP_VERSION |
1315 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1317 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1316 | KABC::AddressBook::Iterator it; | 1318 | KABC::AddressBook::Iterator it; |
1317 | int count = 0; | 1319 | int count = 0; |
1318 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1320 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1319 | ++count; | 1321 | ++count; |
1320 | } | 1322 | } |
1321 | QProgressBar bar(count,0 ); | 1323 | QProgressBar bar(count,0 ); |
1322 | int w = 300; | 1324 | int w = 300; |
1323 | if ( QApplication::desktop()->width() < 320 ) | 1325 | if ( QApplication::desktop()->width() < 320 ) |
1324 | w = 220; | 1326 | w = 220; |
1325 | int h = bar.sizeHint().height() ; | 1327 | int h = bar.sizeHint().height() ; |
1326 | int dw = QApplication::desktop()->width(); | 1328 | int dw = QApplication::desktop()->width(); |
1327 | int dh = QApplication::desktop()->height(); | 1329 | int dh = QApplication::desktop()->height(); |
1328 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1330 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1329 | bar.show(); | 1331 | bar.show(); |
1330 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1332 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1331 | qApp->processEvents(); | 1333 | qApp->processEvents(); |
1332 | count = 0; | 1334 | count = 0; |
1333 | int addCount = 0; | 1335 | int addCount = 0; |
1334 | KCal::Attendee* a = 0; | 1336 | KCal::Attendee* a = 0; |
1335 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1337 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1336 | if ( ! bar.isVisible() ) | 1338 | if ( ! bar.isVisible() ) |
1337 | return false; | 1339 | return false; |
1338 | bar.setProgress( count++ ); | 1340 | bar.setProgress( count++ ); |
1339 | qApp->processEvents(); | 1341 | qApp->processEvents(); |
1340 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1342 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1341 | if ( (*it).birthday().date().isValid() ){ | 1343 | if ( (*it).birthday().date().isValid() ){ |
1342 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1344 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1343 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1345 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1344 | ++addCount; | 1346 | ++addCount; |
1345 | } | 1347 | } |
1346 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1348 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1347 | if ( anni.isValid() ){ | 1349 | if ( anni.isValid() ){ |
1348 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1350 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1349 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1351 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1350 | ++addCount; | 1352 | ++addCount; |
1351 | } | 1353 | } |
1352 | } | 1354 | } |
1353 | updateView(); | 1355 | updateView(); |
1354 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1356 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1355 | #else //DESKTOP_VERSION | 1357 | #else //DESKTOP_VERSION |
1356 | 1358 | ||
1357 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1359 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1358 | // the result should now arrive through method insertBirthdays | 1360 | // the result should now arrive through method insertBirthdays |
1359 | 1361 | ||
1360 | #endif //DESKTOP_VERSION | 1362 | #endif //DESKTOP_VERSION |
1361 | 1363 | ||
1362 | #endif //KORG_NOKABC | 1364 | #endif //KORG_NOKABC |
1363 | 1365 | ||
1364 | 1366 | ||
1365 | return true; | 1367 | return true; |
1366 | } | 1368 | } |
1367 | 1369 | ||
1368 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1370 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1369 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1371 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1370 | const QStringList& anniversaryList, const QStringList& realNameList, | 1372 | const QStringList& anniversaryList, const QStringList& realNameList, |
1371 | const QStringList& emailList, const QStringList& assembledNameList, | 1373 | const QStringList& emailList, const QStringList& assembledNameList, |
1372 | const QStringList& uidList) | 1374 | const QStringList& uidList) |
1373 | { | 1375 | { |
1374 | qDebug("CalendarView::insertBirthdays"); | 1376 | qDebug("CalendarView::insertBirthdays"); |
1375 | if (uid == this->name()) | 1377 | if (uid == this->name()) |
1376 | { | 1378 | { |
1377 | int count = birthdayList.count(); | 1379 | int count = birthdayList.count(); |
1378 | int addCount = 0; | 1380 | int addCount = 0; |
1379 | KCal::Attendee* a = 0; | 1381 | KCal::Attendee* a = 0; |
1380 | 1382 | ||
1381 | qDebug("CalView 1 %i", count); | 1383 | qDebug("CalView 1 %i", count); |
1382 | 1384 | ||
1383 | QProgressBar bar(count,0 ); | 1385 | QProgressBar bar(count,0 ); |
1384 | int w = 300; | 1386 | int w = 300; |
1385 | if ( QApplication::desktop()->width() < 320 ) | 1387 | if ( QApplication::desktop()->width() < 320 ) |
1386 | w = 220; | 1388 | w = 220; |
1387 | int h = bar.sizeHint().height() ; | 1389 | int h = bar.sizeHint().height() ; |
1388 | int dw = QApplication::desktop()->width(); | 1390 | int dw = QApplication::desktop()->width(); |
1389 | int dh = QApplication::desktop()->height(); | 1391 | int dh = QApplication::desktop()->height(); |
1390 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1392 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1391 | bar.show(); | 1393 | bar.show(); |
1392 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1394 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1393 | qApp->processEvents(); | 1395 | qApp->processEvents(); |
1394 | 1396 | ||
1395 | QDate birthday; | 1397 | QDate birthday; |
1396 | QDate anniversary; | 1398 | QDate anniversary; |
1397 | QString realName; | 1399 | QString realName; |
1398 | QString email; | 1400 | QString email; |
1399 | QString assembledName; | 1401 | QString assembledName; |
1400 | QString uid; | 1402 | QString uid; |
1401 | bool ok = true; | 1403 | bool ok = true; |
1402 | for ( int i = 0; i < count; i++) | 1404 | for ( int i = 0; i < count; i++) |
1403 | { | 1405 | { |
1404 | if ( ! bar.isVisible() ) | 1406 | if ( ! bar.isVisible() ) |
1405 | return; | 1407 | return; |
1406 | bar.setProgress( i ); | 1408 | bar.setProgress( i ); |
1407 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1408 | 1410 | ||
1409 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1411 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1410 | if (!ok) { | 1412 | if (!ok) { |
1411 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1413 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1412 | } | 1414 | } |
1413 | 1415 | ||
1414 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1416 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1415 | if (!ok) { | 1417 | if (!ok) { |
1416 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1418 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1417 | } | 1419 | } |
1418 | realName = realNameList[i]; | 1420 | realName = realNameList[i]; |
1419 | email = emailList[i]; | 1421 | email = emailList[i]; |
1420 | assembledName = assembledNameList[i]; | 1422 | assembledName = assembledNameList[i]; |
1421 | uid = uidList[i]; | 1423 | uid = uidList[i]; |
1422 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1424 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1423 | 1425 | ||
1424 | if ( birthday.isValid() ){ | 1426 | if ( birthday.isValid() ){ |
1425 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1427 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1426 | KCal::Attendee::ReqParticipant,uid) ; | 1428 | KCal::Attendee::ReqParticipant,uid) ; |
1427 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1429 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1428 | ++addCount; | 1430 | ++addCount; |
1429 | } | 1431 | } |
1430 | 1432 | ||
1431 | if ( anniversary.isValid() ){ | 1433 | if ( anniversary.isValid() ){ |
1432 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1434 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1433 | KCal::Attendee::ReqParticipant,uid) ; | 1435 | KCal::Attendee::ReqParticipant,uid) ; |
1434 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1436 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index dfa265b..7256f05 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -1,177 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Event::Event() : | 29 | Event::Event() : |
30 | mHasEndDate( false ), mTransparency( Opaque ) | 30 | mHasEndDate( false ), mTransparency( Opaque ) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | Event::Event(const Event &e) : Incidence(e) | 34 | Event::Event(const Event &e) : Incidence(e) |
35 | { | 35 | { |
36 | mDtEnd = e.mDtEnd; | 36 | mDtEnd = e.mDtEnd; |
37 | mHasEndDate = e.mHasEndDate; | 37 | mHasEndDate = e.mHasEndDate; |
38 | mTransparency = e.mTransparency; | 38 | mTransparency = e.mTransparency; |
39 | } | 39 | } |
40 | 40 | ||
41 | Event::~Event() | 41 | Event::~Event() |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence *Event::clone() | 45 | Incidence *Event::clone() |
46 | { | 46 | { |
47 | return new Event(*this); | 47 | return new Event(*this); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool KCal::operator==( const Event& e1, const Event& e2 ) | 50 | bool KCal::operator==( const Event& e1, const Event& e2 ) |
51 | { | 51 | { |
52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && | 52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && |
53 | e1.dtEnd() == e2.dtEnd() && | 53 | e1.dtEnd() == e2.dtEnd() && |
54 | e1.hasEndDate() == e2.hasEndDate() && | 54 | e1.hasEndDate() == e2.hasEndDate() && |
55 | e1.transparency() == e2.transparency(); | 55 | e1.transparency() == e2.transparency(); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | bool Event::contains ( Event* from ) | ||
60 | { | ||
61 | |||
62 | if ( !from->summary().isEmpty() ) | ||
63 | if ( !summary().startsWith( from->summary() )) | ||
64 | return false; | ||
65 | if ( from->dtStart().isValid() ) | ||
66 | if (dtStart() != from->dtStart() ) | ||
67 | return false; | ||
68 | if ( from->dtEnd().isValid() ) | ||
69 | if ( dtEnd() != from->dtEnd() ) | ||
70 | return false; | ||
71 | if ( !from->location().isEmpty() ) | ||
72 | if ( !location().startsWith( from->location() ) ) | ||
73 | return false; | ||
74 | if ( !from->description().isEmpty() ) | ||
75 | if ( !description().startsWith( from->description() )) | ||
76 | return false; | ||
77 | if ( from->alarms().count() ) { | ||
78 | Alarm *a = from->alarms().first(); | ||
79 | if ( a->enabled() ){ | ||
80 | if ( !alarms().count() ) | ||
81 | return false; | ||
82 | Alarm *b = alarms().first(); | ||
83 | if( ! b->enabled() ) | ||
84 | return false; | ||
85 | if ( ! (a->offset() == b->offset() )) | ||
86 | return false; | ||
87 | } | ||
88 | } | ||
89 | QStringList cat = categories(); | ||
90 | QStringList catFrom = from->categories(); | ||
91 | QString nCat; | ||
92 | int iii; | ||
93 | for ( iii = 0; iii < catFrom.count();++iii ) { | ||
94 | nCat = catFrom[iii]; | ||
95 | if ( !nCat.isEmpty() ) | ||
96 | if ( !cat.contains( nCat )) { | ||
97 | return false; | ||
98 | } | ||
99 | } | ||
100 | if ( from->doesRecur() ) | ||
101 | if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) | ||
102 | return false; | ||
103 | return true; | ||
104 | } | ||
59 | 105 | ||
60 | void Event::setDtEnd(const QDateTime &dtEnd) | 106 | void Event::setDtEnd(const QDateTime &dtEnd) |
61 | { | 107 | { |
62 | if (mReadOnly) return; | 108 | if (mReadOnly) return; |
63 | 109 | ||
64 | mDtEnd = getEvenTime( dtEnd ); | 110 | mDtEnd = getEvenTime( dtEnd ); |
65 | 111 | ||
66 | setHasEndDate(true); | 112 | setHasEndDate(true); |
67 | setHasDuration(false); | 113 | setHasDuration(false); |
68 | 114 | ||
69 | updated(); | 115 | updated(); |
70 | } | 116 | } |
71 | 117 | ||
72 | QDateTime Event::dtEnd() const | 118 | QDateTime Event::dtEnd() const |
73 | { | 119 | { |
74 | if (hasEndDate()) return mDtEnd; | 120 | if (hasEndDate()) return mDtEnd; |
75 | if (hasDuration()) return dtStart().addSecs(duration()); | 121 | if (hasDuration()) return dtStart().addSecs(duration()); |
76 | 122 | ||
77 | kdDebug(5800) << "Warning! Event '" << summary() | 123 | kdDebug(5800) << "Warning! Event '" << summary() |
78 | << "' does have neither end date nor duration." << endl; | 124 | << "' does have neither end date nor duration." << endl; |
79 | return dtStart(); | 125 | return dtStart(); |
80 | } | 126 | } |
81 | 127 | ||
82 | QString Event::dtEndTimeStr() const | 128 | QString Event::dtEndTimeStr() const |
83 | { | 129 | { |
84 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 130 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
85 | } | 131 | } |
86 | 132 | ||
87 | QString Event::dtEndDateStr(bool shortfmt) const | 133 | QString Event::dtEndDateStr(bool shortfmt) const |
88 | { | 134 | { |
89 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); | 135 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); |
90 | } | 136 | } |
91 | 137 | ||
92 | QString Event::dtEndStr(bool shortfmt) const | 138 | QString Event::dtEndStr(bool shortfmt) const |
93 | { | 139 | { |
94 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); | 140 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); |
95 | } | 141 | } |
96 | 142 | ||
97 | void Event::setHasEndDate(bool b) | 143 | void Event::setHasEndDate(bool b) |
98 | { | 144 | { |
99 | mHasEndDate = b; | 145 | mHasEndDate = b; |
100 | } | 146 | } |
101 | 147 | ||
102 | bool Event::hasEndDate() const | 148 | bool Event::hasEndDate() const |
103 | { | 149 | { |
104 | return mHasEndDate; | 150 | return mHasEndDate; |
105 | } | 151 | } |
106 | 152 | ||
107 | bool Event::isMultiDay() const | 153 | bool Event::isMultiDay() const |
108 | { | 154 | { |
109 | bool multi = !(dtStart().date() == dtEnd().date()); | 155 | bool multi = !(dtStart().date() == dtEnd().date()); |
110 | return multi; | 156 | return multi; |
111 | } | 157 | } |
112 | 158 | ||
113 | void Event::setTransparency(Event::Transparency transparency) | 159 | void Event::setTransparency(Event::Transparency transparency) |
114 | { | 160 | { |
115 | if (mReadOnly) return; | 161 | if (mReadOnly) return; |
116 | mTransparency = transparency; | 162 | mTransparency = transparency; |
117 | updated(); | 163 | updated(); |
118 | } | 164 | } |
119 | 165 | ||
120 | Event::Transparency Event::transparency() const | 166 | Event::Transparency Event::transparency() const |
121 | { | 167 | { |
122 | return mTransparency; | 168 | return mTransparency; |
123 | } | 169 | } |
124 | 170 | ||
125 | void Event::setDuration(int seconds) | 171 | void Event::setDuration(int seconds) |
126 | { | 172 | { |
127 | setHasEndDate(false); | 173 | setHasEndDate(false); |
128 | Incidence::setDuration(seconds); | 174 | Incidence::setDuration(seconds); |
129 | } | 175 | } |
130 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const | 176 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const |
131 | { | 177 | { |
132 | 178 | ||
133 | bool yes; | 179 | bool yes; |
134 | QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); | 180 | QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); |
135 | if ( ! yes || cancelled() ) { | 181 | if ( ! yes || cancelled() ) { |
136 | *ok = false; | 182 | *ok = false; |
137 | return QDateTime (); | 183 | return QDateTime (); |
138 | } | 184 | } |
139 | 185 | ||
140 | bool enabled = false; | 186 | bool enabled = false; |
141 | Alarm* alarm; | 187 | Alarm* alarm; |
142 | int off; | 188 | int off; |
143 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 189 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
144 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 190 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
145 | // *ok = false; | 191 | // *ok = false; |
146 | // return incidenceStart; | 192 | // return incidenceStart; |
147 | // } | 193 | // } |
148 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 194 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
149 | if (alarm->enabled()) { | 195 | if (alarm->enabled()) { |
150 | if ( alarm->hasTime () ) { | 196 | if ( alarm->hasTime () ) { |
151 | if ( alarm->time() < alarmStart ) { | 197 | if ( alarm->time() < alarmStart ) { |
152 | alarmStart = alarm->time(); | 198 | alarmStart = alarm->time(); |
153 | enabled = true; | 199 | enabled = true; |
154 | off = alarmStart.secsTo( incidenceStart ); | 200 | off = alarmStart.secsTo( incidenceStart ); |
155 | } | 201 | } |
156 | 202 | ||
157 | } else { | 203 | } else { |
158 | int secs = alarm->startOffset().asSeconds(); | 204 | int secs = alarm->startOffset().asSeconds(); |
159 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 205 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
160 | alarmStart = incidenceStart.addSecs( secs ); | 206 | alarmStart = incidenceStart.addSecs( secs ); |
161 | enabled = true; | 207 | enabled = true; |
162 | off = -secs; | 208 | off = -secs; |
163 | } | 209 | } |
164 | } | 210 | } |
165 | } | 211 | } |
166 | } | 212 | } |
167 | if ( enabled ) { | 213 | if ( enabled ) { |
168 | if ( alarmStart > QDateTime::currentDateTime() ) { | 214 | if ( alarmStart > QDateTime::currentDateTime() ) { |
169 | *ok = true; | 215 | *ok = true; |
170 | * offset = off; | 216 | * offset = off; |
171 | return alarmStart; | 217 | return alarmStart; |
172 | } | 218 | } |
173 | } | 219 | } |
174 | *ok = false; | 220 | *ok = false; |
175 | return QDateTime (); | 221 | return QDateTime (); |
176 | 222 | ||
177 | } | 223 | } |
diff --git a/libkcal/event.h b/libkcal/event.h index 2a8bd95..3bc8adc 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -1,88 +1,90 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef EVENT_H | 21 | #ifndef EVENT_H |
22 | #define EVENT_H | 22 | #define EVENT_H |
23 | // | 23 | // |
24 | // Event component, representing a VEVENT object | 24 | // Event component, representing a VEVENT object |
25 | // | 25 | // |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides an Event in the sense of RFC2445. | 31 | This class provides an Event in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Event : public Incidence | 33 | class Event : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | enum Transparency { Opaque, Transparent }; | 36 | enum Transparency { Opaque, Transparent }; |
37 | typedef ListBase<Event> List; | 37 | typedef ListBase<Event> List; |
38 | Event(); | 38 | Event(); |
39 | Event(const Event &); | 39 | Event(const Event &); |
40 | ~Event(); | 40 | ~Event(); |
41 | 41 | ||
42 | QCString type() const { return "Event"; } | 42 | QCString type() const { return "Event"; } |
43 | 43 | ||
44 | Incidence *clone(); | 44 | Incidence *clone(); |
45 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; | 45 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; |
46 | 46 | ||
47 | /** for setting an event's ending date/time with a QDateTime. */ | 47 | /** for setting an event's ending date/time with a QDateTime. */ |
48 | void setDtEnd(const QDateTime &dtEnd); | 48 | void setDtEnd(const QDateTime &dtEnd); |
49 | /** Return the event's ending date/time as a QDateTime. */ | 49 | /** Return the event's ending date/time as a QDateTime. */ |
50 | virtual QDateTime dtEnd() const; | 50 | virtual QDateTime dtEnd() const; |
51 | /** returns an event's end time as a string formatted according to the | 51 | /** returns an event's end time as a string formatted according to the |
52 | users locale settings */ | 52 | users locale settings */ |
53 | QString dtEndTimeStr() const; | 53 | QString dtEndTimeStr() const; |
54 | /** returns an event's end date as a string formatted according to the | 54 | /** returns an event's end date as a string formatted according to the |
55 | users locale settings */ | 55 | users locale settings */ |
56 | QString dtEndDateStr(bool shortfmt=true) const; | 56 | QString dtEndDateStr(bool shortfmt=true) const; |
57 | /** returns an event's end date and time as a string formatted according | 57 | /** returns an event's end date and time as a string formatted according |
58 | to the users locale settings */ | 58 | to the users locale settings */ |
59 | QString dtEndStr(bool shortfmt=true) const; | 59 | QString dtEndStr(bool shortfmt=true) const; |
60 | void setHasEndDate(bool); | 60 | void setHasEndDate(bool); |
61 | /** Return whether the event has an end date/time. */ | 61 | /** Return whether the event has an end date/time. */ |
62 | bool hasEndDate() const; | 62 | bool hasEndDate() const; |
63 | 63 | ||
64 | /** Return true if the event spans multiple days, otherwise return false. */ | 64 | /** Return true if the event spans multiple days, otherwise return false. */ |
65 | bool isMultiDay() const; | 65 | bool isMultiDay() const; |
66 | 66 | ||
67 | /** set the event's time transparency level. */ | 67 | /** set the event's time transparency level. */ |
68 | void setTransparency(Transparency transparency); | 68 | void setTransparency(Transparency transparency); |
69 | /** get the event's time transparency level. */ | 69 | /** get the event's time transparency level. */ |
70 | Transparency transparency() const; | 70 | Transparency transparency() const; |
71 | 71 | ||
72 | void setDuration(int seconds); | 72 | void setDuration(int seconds); |
73 | 73 | ||
74 | bool contains ( Event*); | ||
75 | |||
74 | private: | 76 | private: |
75 | bool accept(Visitor &v) { return v.visit(this); } | 77 | bool accept(Visitor &v) { return v.visit(this); } |
76 | 78 | ||
77 | QDateTime mDtEnd; | 79 | QDateTime mDtEnd; |
78 | bool mHasEndDate; | 80 | bool mHasEndDate; |
79 | Transparency mTransparency; | 81 | Transparency mTransparency; |
80 | }; | 82 | }; |
81 | 83 | ||
82 | bool operator==( const Event&, const Event& ); | 84 | bool operator==( const Event&, const Event& ); |
83 | 85 | ||
84 | 86 | ||
85 | } | 87 | } |
86 | 88 | ||
87 | 89 | ||
88 | #endif | 90 | #endif |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 281434e..101db57 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -59,576 +59,562 @@ public: | |||
59 | QString datestr; | 59 | QString datestr; |
60 | QString timestr; | 60 | QString timestr; |
61 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 61 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
62 | QDateTime dt; | 62 | QDateTime dt; |
63 | if (useTZ) | 63 | if (useTZ) |
64 | dt = dti.addSecs ( -(offset*60)); | 64 | dt = dti.addSecs ( -(offset*60)); |
65 | else | 65 | else |
66 | dt = dti; | 66 | dt = dti; |
67 | if(dt.date().isValid()){ | 67 | if(dt.date().isValid()){ |
68 | const QDate& date = dt.date(); | 68 | const QDate& date = dt.date(); |
69 | datestr.sprintf("%04d%02d%02d", | 69 | datestr.sprintf("%04d%02d%02d", |
70 | date.year(), date.month(), date.day()); | 70 | date.year(), date.month(), date.day()); |
71 | } | 71 | } |
72 | if(dt.time().isValid()){ | 72 | if(dt.time().isValid()){ |
73 | const QTime& time = dt.time(); | 73 | const QTime& time = dt.time(); |
74 | timestr.sprintf("T%02d%02d%02d", | 74 | timestr.sprintf("T%02d%02d%02d", |
75 | time.hour(), time.minute(), time.second()); | 75 | time.hour(), time.minute(), time.second()); |
76 | } | 76 | } |
77 | return datestr + timestr; | 77 | return datestr + timestr; |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
86 | { | 86 | { |
87 | mProfileName = profileName; | 87 | mProfileName = profileName; |
88 | PhoneAccess::writeConfig( device, connection, model ); | 88 | PhoneAccess::writeConfig( device, connection, model ); |
89 | } | 89 | } |
90 | 90 | ||
91 | PhoneFormat::~PhoneFormat() | 91 | PhoneFormat::~PhoneFormat() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | #if 0 | 95 | #if 0 |
96 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 96 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
97 | { | 97 | { |
98 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 98 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
99 | s->ConfigNum = 1; | 99 | s->ConfigNum = 1; |
100 | GSM_Config *cfg = &s->Config[0]; | 100 | GSM_Config *cfg = &s->Config[0]; |
101 | if ( ! mConnection.isEmpty() ) { | 101 | if ( ! mConnection.isEmpty() ) { |
102 | cfg->Connection = strdup(mConnection.latin1()); | 102 | cfg->Connection = strdup(mConnection.latin1()); |
103 | cfg->DefaultConnection = false; | 103 | cfg->DefaultConnection = false; |
104 | qDebug("Connection set %s ", cfg->Connection ); | 104 | qDebug("Connection set %s ", cfg->Connection ); |
105 | 105 | ||
106 | } | 106 | } |
107 | if ( ! mDevice.isEmpty() ) { | 107 | if ( ! mDevice.isEmpty() ) { |
108 | cfg->Device = strdup(mDevice.latin1()); | 108 | cfg->Device = strdup(mDevice.latin1()); |
109 | cfg->DefaultDevice = false; | 109 | cfg->DefaultDevice = false; |
110 | qDebug("Device set %s ", cfg->Device); | 110 | qDebug("Device set %s ", cfg->Device); |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! mModel.isEmpty() ) { | 113 | if ( ! mModel.isEmpty() ) { |
114 | strcpy(cfg->Model,mModel.latin1() ); | 114 | strcpy(cfg->Model,mModel.latin1() ); |
115 | cfg->DefaultModel = false; | 115 | cfg->DefaultModel = false; |
116 | qDebug("Model set %s ",cfg->Model ); | 116 | qDebug("Model set %s ",cfg->Model ); |
117 | } | 117 | } |
118 | int error=GSM_InitConnection(s,3); | 118 | int error=GSM_InitConnection(s,3); |
119 | return error; | 119 | return error; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
123 | { | 123 | { |
124 | QStringList attList; | 124 | QStringList attList; |
125 | if ( todo->hasDueDate() ) | 125 | if ( todo->hasDueDate() ) |
126 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 126 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
127 | attList << todo->summary(); | 127 | attList << todo->summary(); |
128 | QString completedString = "no"; | 128 | QString completedString = "no"; |
129 | if ( todo->isCompleted() ) | 129 | if ( todo->isCompleted() ) |
130 | completedString = "yes"; | 130 | completedString = "yes"; |
131 | attList << completedString; | 131 | attList << completedString; |
132 | int prio = todo->priority(); | 132 | int prio = todo->priority(); |
133 | if( prio == 2 ) prio = 1; | 133 | if( prio == 2 ) prio = 1; |
134 | if (prio == 4 ) prio = 5 ; | 134 | if (prio == 4 ) prio = 5 ; |
135 | attList << QString::number( prio ); | 135 | attList << QString::number( prio ); |
136 | QString alarmString = "na"; | 136 | QString alarmString = "na"; |
137 | Alarm *alarm; | 137 | Alarm *alarm; |
138 | if ( todo->alarms().count() > 0 ) { | 138 | if ( todo->alarms().count() > 0 ) { |
139 | alarm = todo->alarms().first(); | 139 | alarm = todo->alarms().first(); |
140 | if ( alarm->enabled() ) { | 140 | if ( alarm->enabled() ) { |
141 | alarmString = QString::number(alarm->offset() ); | 141 | alarmString = QString::number(alarm->offset() ); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | attList << alarmString; | 144 | attList << alarmString; |
145 | attList << todo->categoriesStr(); | 145 | attList << todo->categoriesStr(); |
146 | attList << todo->secrecyStr(); | 146 | attList << todo->secrecyStr(); |
147 | return PhoneFormat::getCsum(attList ); | 147 | return PhoneFormat::getCsum(attList ); |
148 | 148 | ||
149 | } | 149 | } |
150 | ulong PhoneFormat::getCsumEvent( Event* event ) | 150 | ulong PhoneFormat::getCsumEvent( Event* event ) |
151 | { | 151 | { |
152 | QStringList attList; | 152 | QStringList attList; |
153 | attList << PhoneParser::dtToString ( event->dtStart() ); | 153 | attList << PhoneParser::dtToString ( event->dtStart() ); |
154 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 154 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
155 | attList << event->summary(); | 155 | attList << event->summary(); |
156 | attList << event->location(); | 156 | attList << event->location(); |
157 | QString alarmString = "na"; | 157 | QString alarmString = "na"; |
158 | Alarm *alarm; | 158 | Alarm *alarm; |
159 | if ( event->alarms().count() > 0 ) { | 159 | if ( event->alarms().count() > 0 ) { |
160 | alarm = event->alarms().first(); | 160 | alarm = event->alarms().first(); |
161 | if ( alarm->enabled() ) { | 161 | if ( alarm->enabled() ) { |
162 | alarmString = QString::number( alarm->offset() ); | 162 | alarmString = QString::number( alarm->offset() ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | attList << alarmString; | 165 | attList << alarmString; |
166 | Recurrence* rec = event->recurrence(); | 166 | Recurrence* rec = event->recurrence(); |
167 | QStringList list; | 167 | QStringList list; |
168 | bool writeEndDate = false; | 168 | bool writeEndDate = false; |
169 | switch ( rec->doesRecur() ) | 169 | switch ( rec->doesRecur() ) |
170 | { | 170 | { |
171 | case Recurrence::rDaily: // 0 | 171 | case Recurrence::rDaily: // 0 |
172 | list.append( "0" ); | 172 | list.append( "0" ); |
173 | list.append( QString::number( rec->frequency() ));//12 | 173 | list.append( QString::number( rec->frequency() ));//12 |
174 | list.append( "0" ); | 174 | list.append( "0" ); |
175 | list.append( "0" ); | 175 | list.append( "0" ); |
176 | writeEndDate = true; | 176 | writeEndDate = true; |
177 | break; | 177 | break; |
178 | case Recurrence::rWeekly:// 1 | 178 | case Recurrence::rWeekly:// 1 |
179 | list.append( "1" ); | 179 | list.append( "1" ); |
180 | list.append( QString::number( rec->frequency()) );//12 | 180 | list.append( QString::number( rec->frequency()) );//12 |
181 | list.append( "0" ); | 181 | list.append( "0" ); |
182 | { | 182 | { |
183 | int days = 0; | 183 | int days = 0; |
184 | QBitArray weekDays = rec->days(); | 184 | QBitArray weekDays = rec->days(); |
185 | int i; | 185 | int i; |
186 | for( i = 1; i <= 7; ++i ) { | 186 | for( i = 1; i <= 7; ++i ) { |
187 | if ( weekDays[i-1] ) { | 187 | if ( weekDays[i-1] ) { |
188 | days += 1 << (i-1); | 188 | days += 1 << (i-1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | list.append( QString::number( days ) ); | 191 | list.append( QString::number( days ) ); |
192 | } | 192 | } |
193 | //pending weekdays | 193 | //pending weekdays |
194 | writeEndDate = true; | 194 | writeEndDate = true; |
195 | 195 | ||
196 | break; | 196 | break; |
197 | case Recurrence::rMonthlyPos:// 2 | 197 | case Recurrence::rMonthlyPos:// 2 |
198 | list.append( "2" ); | 198 | list.append( "2" ); |
199 | list.append( QString::number( rec->frequency()) );//12 | 199 | list.append( QString::number( rec->frequency()) );//12 |
200 | 200 | ||
201 | writeEndDate = true; | 201 | writeEndDate = true; |
202 | { | 202 | { |
203 | int count = 1; | 203 | int count = 1; |
204 | QPtrList<Recurrence::rMonthPos> rmp; | 204 | QPtrList<Recurrence::rMonthPos> rmp; |
205 | rmp = rec->monthPositions(); | 205 | rmp = rec->monthPositions(); |
206 | if ( rmp.first()->negative ) | 206 | if ( rmp.first()->negative ) |
207 | count = 5 - rmp.first()->rPos - 1; | 207 | count = 5 - rmp.first()->rPos - 1; |
208 | else | 208 | else |
209 | count = rmp.first()->rPos - 1; | 209 | count = rmp.first()->rPos - 1; |
210 | list.append( QString::number( count ) ); | 210 | list.append( QString::number( count ) ); |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | list.append( "0" ); | 214 | list.append( "0" ); |
215 | break; | 215 | break; |
216 | case Recurrence::rMonthlyDay:// 3 | 216 | case Recurrence::rMonthlyDay:// 3 |
217 | list.append( "3" ); | 217 | list.append( "3" ); |
218 | list.append( QString::number( rec->frequency()) );//12 | 218 | list.append( QString::number( rec->frequency()) );//12 |
219 | list.append( "0" ); | 219 | list.append( "0" ); |
220 | list.append( "0" ); | 220 | list.append( "0" ); |
221 | writeEndDate = true; | 221 | writeEndDate = true; |
222 | break; | 222 | break; |
223 | case Recurrence::rYearlyMonth://4 | 223 | case Recurrence::rYearlyMonth://4 |
224 | list.append( "4" ); | 224 | list.append( "4" ); |
225 | list.append( QString::number( rec->frequency()) );//12 | 225 | list.append( QString::number( rec->frequency()) );//12 |
226 | list.append( "0" ); | 226 | list.append( "0" ); |
227 | list.append( "0" ); | 227 | list.append( "0" ); |
228 | writeEndDate = true; | 228 | writeEndDate = true; |
229 | break; | 229 | break; |
230 | 230 | ||
231 | default: | 231 | default: |
232 | list.append( "255" ); | 232 | list.append( "255" ); |
233 | list.append( QString() ); | 233 | list.append( QString() ); |
234 | list.append( "0" ); | 234 | list.append( "0" ); |
235 | list.append( QString() ); | 235 | list.append( QString() ); |
236 | list.append( "0" ); | 236 | list.append( "0" ); |
237 | list.append( "20991231T000000" ); | 237 | list.append( "20991231T000000" ); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | if ( writeEndDate ) { | 240 | if ( writeEndDate ) { |
241 | 241 | ||
242 | if ( rec->endDate().isValid() ) { // 15 + 16 | 242 | if ( rec->endDate().isValid() ) { // 15 + 16 |
243 | list.append( "1" ); | 243 | list.append( "1" ); |
244 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 244 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
245 | } else { | 245 | } else { |
246 | list.append( "0" ); | 246 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | attList << list.join(""); | 251 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 254 | ||
255 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
257 | } | 257 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 259 | { |
260 | int max = attList.count(); | 260 | int max = attList.count(); |
261 | ulong cSum = 0; | 261 | ulong cSum = 0; |
262 | int j,k,i; | 262 | int j,k,i; |
263 | int add; | 263 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 265 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | } | 279 | } |
280 | //QString dump = attList.join(","); | 280 | //QString dump = attList.join(","); |
281 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
282 | 282 | ||
283 | return cSum; | 283 | return cSum; |
284 | 284 | ||
285 | } | 285 | } |
286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
287 | #include <stdlib.h> | 287 | #include <stdlib.h> |
288 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
290 | { | 290 | { |
291 | 291 | ||
292 | QString fileName; | 292 | QString fileName; |
293 | #ifdef _WIN32_ | 293 | #ifdef _WIN32_ |
294 | fileName = locateLocal("tmp", "phonefile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/phonefile.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | QString command; | 298 | QString command; |
299 | if ( ! PhoneAccess::readFromPhone( fileName )) { | 299 | if ( ! PhoneAccess::readFromPhone( fileName )) { |
300 | return false; | 300 | return false; |
301 | } | 301 | } |
302 | VCalFormat vfload; | 302 | VCalFormat vfload; |
303 | vfload.setLocalTime ( true ); | 303 | vfload.setLocalTime ( true ); |
304 | qDebug("loading file ..."); | 304 | qDebug("loading file ..."); |
305 | 305 | ||
306 | if ( ! vfload.load( calendar, fileName ) ) | 306 | if ( ! vfload.load( calendar, fileName ) ) |
307 | return false; | 307 | return false; |
308 | QPtrList<Event> er = calendar->rawEvents(); | 308 | QPtrList<Event> er = calendar->rawEvents(); |
309 | Event* ev = er.first(); | 309 | Event* ev = er.first(); |
310 | qDebug("reading events... "); | 310 | qDebug("reading events... "); |
311 | while ( ev ) { | 311 | while ( ev ) { |
312 | QStringList cat = ev->categories(); | 312 | QStringList cat = ev->categories(); |
313 | if ( cat.contains( "MeetingDEF" )) { | 313 | if ( cat.contains( "MeetingDEF" )) { |
314 | ev->setCategories( QStringList() ); | 314 | ev->setCategories( QStringList() ); |
315 | } else | ||
316 | if ( cat.contains( "Birthday" )) { | ||
317 | ev->setFloats( true ); | ||
318 | QDate da = ev->dtStart().date(); | ||
319 | ev->setDtStart( QDateTime( da) ); | ||
320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); | ||
321 | |||
315 | } | 322 | } |
323 | uint cSum; | ||
324 | cSum = PhoneFormat::getCsumEvent( ev ); | ||
316 | int id = ev->pilotId(); | 325 | int id = ev->pilotId(); |
317 | Event *event; | 326 | Event *event; |
318 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 327 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
319 | if ( event ) { | 328 | if ( event ) { |
320 | event = (Event*)event->clone(); | 329 | event = (Event*)event->clone(); |
321 | copyEvent( event, ev ); | 330 | copyEvent( event, ev ); |
322 | calendar->deleteEvent( ev ); | 331 | calendar->deleteEvent( ev ); |
323 | calendar->addEvent( event); | 332 | calendar->addEvent( event); |
324 | } | 333 | } |
325 | else | 334 | else |
326 | event = ev; | 335 | event = ev; |
327 | uint cSum; | ||
328 | cSum = PhoneFormat::getCsumEvent( event ); | ||
329 | event->setCsum( mProfileName, QString::number( cSum )); | 336 | event->setCsum( mProfileName, QString::number( cSum )); |
330 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
331 | event->setID( mProfileName,QString::number( id ) ); | 338 | event->setID( mProfileName,QString::number( id ) ); |
332 | ev = er.next(); | 339 | ev = er.next(); |
333 | } | 340 | } |
334 | { | 341 | { |
335 | qDebug("reading todos... "); | 342 | qDebug("reading todos... "); |
336 | QPtrList<Todo> tr = calendar->rawTodos(); | 343 | QPtrList<Todo> tr = calendar->rawTodos(); |
337 | Todo* ev = tr.first(); | 344 | Todo* ev = tr.first(); |
338 | while ( ev ) { | 345 | while ( ev ) { |
339 | 346 | ||
340 | QStringList cat = ev->categories(); | 347 | QStringList cat = ev->categories(); |
341 | if ( cat.contains( "MeetingDEF" )) { | 348 | if ( cat.contains( "MeetingDEF" )) { |
342 | ev->setCategories( QStringList() ); | 349 | ev->setCategories( QStringList() ); |
343 | } | 350 | } |
344 | int id = ev->pilotId(); | 351 | int id = ev->pilotId(); |
352 | uint cSum; | ||
353 | cSum = PhoneFormat::getCsumTodo( ev ); | ||
345 | Todo *event; | 354 | Todo *event; |
346 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
347 | if ( event ) { | 356 | if ( event ) { |
348 | //qDebug("copy todo %s ", event->summary().latin1()); | 357 | //qDebug("copy todo %s ", event->summary().latin1()); |
349 | 358 | ||
350 | event = (Todo*)event->clone(); | 359 | event = (Todo*)event->clone(); |
351 | copyTodo( event, ev ); | 360 | copyTodo( event, ev ); |
352 | calendar->deleteTodo( ev ); | 361 | calendar->deleteTodo( ev ); |
353 | calendar->addTodo( event); | 362 | calendar->addTodo( event); |
354 | } | 363 | } |
355 | else | 364 | else |
356 | event = ev; | 365 | event = ev; |
357 | uint cSum; | ||
358 | cSum = PhoneFormat::getCsumTodo( event ); | ||
359 | event->setCsum( mProfileName, QString::number( cSum )); | 366 | event->setCsum( mProfileName, QString::number( cSum )); |
360 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
361 | event->setID( mProfileName,QString::number( id ) ); | 368 | event->setID( mProfileName,QString::number( id ) ); |
362 | ev = tr.next(); | 369 | ev = tr.next(); |
363 | } | 370 | } |
364 | } | 371 | } |
365 | return true; | 372 | return true; |
366 | } | 373 | } |
367 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 374 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
368 | { | 375 | { |
369 | if ( from->dtStart().isValid() ) | 376 | if ( from->dtStart().isValid() ) |
370 | to->setDtStart( from->dtStart() ); | 377 | to->setDtStart( from->dtStart() ); |
371 | if ( from->dtEnd().isValid() ) | 378 | if ( from->dtEnd().isValid() ) |
372 | to->setDtEnd( from->dtEnd() ); | 379 | to->setDtEnd( from->dtEnd() ); |
373 | if ( !from->location().isEmpty() ) | 380 | if ( !from->location().isEmpty() ) |
374 | to->setLocation( from->location() ); | 381 | to->setLocation( from->location() ); |
375 | if ( !from->description().isEmpty() ) | 382 | if ( !from->description().isEmpty() ) |
376 | to->setDescription( from->description() ); | 383 | to->setDescription( from->description() ); |
377 | if ( !from->summary().isEmpty() ) | 384 | if ( !from->summary().isEmpty() ) |
378 | to->setSummary( from->summary() ); | 385 | to->setSummary( from->summary() ); |
379 | 386 | ||
380 | if ( from->alarms().count() ) { | 387 | if ( from->alarms().count() ) { |
381 | to->clearAlarms(); | 388 | to->clearAlarms(); |
382 | Alarm *a = from->alarms().first(); | 389 | Alarm *a = from->alarms().first(); |
383 | Alarm *b = to->newAlarm( ); | 390 | Alarm *b = to->newAlarm( ); |
384 | b->setEnabled( a->enabled() ); | 391 | b->setEnabled( a->enabled() ); |
385 | if ( a->hasStartOffset() ) { | 392 | b->setStartOffset(Duration( a->offset() ) ); |
386 | b->setStartOffset( a->startOffset() ); | ||
387 | } | ||
388 | if ( a->hasTime() ) | ||
389 | b->setTime( a->time() ); | ||
390 | 393 | ||
391 | } | 394 | } |
392 | QStringList cat = to->categories(); | 395 | QStringList cat = to->categories(); |
393 | QStringList catFrom = from->categories(); | 396 | QStringList catFrom = from->categories(); |
394 | QString nCat; | 397 | QString nCat; |
395 | int iii; | 398 | int iii; |
396 | for ( iii = 0; iii < catFrom.count();++iii ) { | 399 | for ( iii = 0; iii < catFrom.count();++iii ) { |
397 | nCat = catFrom[iii]; | 400 | nCat = catFrom[iii]; |
398 | if ( !nCat.isEmpty() ) | 401 | if ( !nCat.isEmpty() ) |
399 | if ( !cat.contains( nCat )) { | 402 | if ( !cat.contains( nCat )) { |
400 | cat << nCat; | 403 | cat << nCat; |
401 | } | 404 | } |
402 | } | 405 | } |
403 | to->setCategories( cat ); | 406 | to->setCategories( cat ); |
404 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 407 | if ( from->doesRecur() ) { |
405 | to->setRecurrence( r ) ; | 408 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
409 | to->setRecurrence( r ) ; | ||
410 | } | ||
406 | 411 | ||
407 | 412 | ||
408 | } | 413 | } |
409 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 414 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
410 | { | 415 | { |
411 | if ( from->dtStart().isValid() ) | 416 | if ( from->hasStartDate() ) { |
417 | to->setHasStartDate( true ); | ||
412 | to->setDtStart( from->dtStart() ); | 418 | to->setDtStart( from->dtStart() ); |
413 | if ( from->dtDue().isValid() ) | 419 | } |
420 | if ( from->hasDueDate() ){ | ||
421 | to->setHasDueDate( true ); | ||
414 | to->setDtDue( from->dtDue() ); | 422 | to->setDtDue( from->dtDue() ); |
423 | } | ||
415 | if ( !from->location().isEmpty() ) | 424 | if ( !from->location().isEmpty() ) |
416 | to->setLocation( from->location() ); | 425 | to->setLocation( from->location() ); |
417 | if ( !from->description().isEmpty() ) | 426 | if ( !from->description().isEmpty() ) |
418 | to->setDescription( from->description() ); | 427 | to->setDescription( from->description() ); |
419 | if ( !from->summary().isEmpty() ) | 428 | if ( !from->summary().isEmpty() ) |
420 | to->setSummary( from->summary() ); | 429 | to->setSummary( from->summary() ); |
421 | 430 | ||
422 | if ( from->alarms().count() ) { | 431 | if ( from->alarms().count() ) { |
423 | to->clearAlarms(); | 432 | to->clearAlarms(); |
424 | Alarm *a = from->alarms().first(); | 433 | Alarm *a = from->alarms().first(); |
425 | Alarm *b = to->newAlarm( ); | 434 | Alarm *b = to->newAlarm( ); |
426 | b->setEnabled( a->enabled() ); | 435 | b->setEnabled( a->enabled() ); |
427 | if ( a->hasStartOffset() ) | 436 | b->setStartOffset(Duration( a->offset() ) ); |
428 | b->setStartOffset( a->startOffset() ); | ||
429 | if ( a->hasTime() ) | ||
430 | b->setTime( a->time() ); | ||
431 | } | 437 | } |
432 | 438 | ||
433 | QStringList cat = to->categories(); | 439 | QStringList cat = to->categories(); |
434 | QStringList catFrom = from->categories(); | 440 | QStringList catFrom = from->categories(); |
435 | QString nCat; | 441 | QString nCat; |
436 | int iii; | 442 | int iii; |
437 | for ( iii = 0; iii < catFrom.count();++iii ) { | 443 | for ( iii = 0; iii < catFrom.count();++iii ) { |
438 | nCat = catFrom[iii]; | 444 | nCat = catFrom[iii]; |
439 | if ( !nCat.isEmpty() ) | 445 | if ( !nCat.isEmpty() ) |
440 | if ( !cat.contains( nCat )) { | 446 | if ( !cat.contains( nCat )) { |
441 | cat << nCat; | 447 | cat << nCat; |
442 | } | 448 | } |
443 | } | 449 | } |
444 | to->setCategories( cat ); | 450 | to->setCategories( cat ); |
445 | if ( from->isCompleted() ) { | 451 | if ( from->isCompleted() ) { |
446 | to->setCompleted( true ); | 452 | to->setCompleted( true ); |
447 | if( from->completed().isValid() ) | 453 | if( from->completed().isValid() ) |
448 | to->setCompleted( from->completed() ); | 454 | to->setCompleted( from->completed() ); |
449 | } else { | 455 | } else { |
450 | // set percentcomplete only, if to->isCompleted() | 456 | // set percentcomplete only, if to->isCompleted() |
451 | if ( to->isCompleted() ) | 457 | if ( to->isCompleted() ) |
452 | to->setPercentComplete(from->percentComplete()); | 458 | to->setPercentComplete(from->percentComplete()); |
453 | } | 459 | } |
454 | if( to->priority() == 2 && from->priority() == 1 ) | 460 | if( to->priority() == 2 && from->priority() == 1 ) |
455 | ; //skip | 461 | ; //skip |
456 | else if (to->priority() == 4 && from->priority() == 5 ) | 462 | else if (to->priority() == 4 && from->priority() == 5 ) |
457 | ; | 463 | ; |
458 | else | 464 | else |
459 | to->setPriority(from->priority()); | 465 | to->setPriority(from->priority()); |
460 | 466 | ||
461 | } | 467 | } |
462 | #include <qcstring.h> | 468 | #include <qcstring.h> |
463 | 469 | ||
464 | void PhoneFormat::afterSave( Incidence* inc) | 470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) |
465 | { | 471 | { |
466 | uint csum; | 472 | inc->setID( mProfileName, id ); |
467 | inc->removeID( mProfileName ); | 473 | inc->setCsum( mProfileName, csum); |
468 | if ( inc->type() == "Event") | ||
469 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | ||
470 | else | ||
471 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | ||
472 | inc->setCsum( mProfileName, QString::number( csum )); | ||
473 | |||
474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
475 | 475 | ||
476 | } | 476 | } |
477 | 477 | ||
478 | bool PhoneFormat::writeToPhone( Calendar * calendar) | 478 | bool PhoneFormat::writeToPhone( Calendar * calendar) |
479 | { | 479 | { |
480 | #ifdef _WIN32_ | 480 | #ifdef _WIN32_ |
481 | QString fileName = locateLocal("tmp", "tempfile.vcs"); | 481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); |
482 | #else | 482 | #else |
483 | QString fileName = "/tmp/kdepimtemp.vcs"; | 483 | QString fileName = "/tmp/phonefile.vcs"; |
484 | #endif | 484 | #endif |
485 | 485 | ||
486 | VCalFormat vfsave; | 486 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 487 | vfsave.setLocalTime ( true ); |
488 | QString id = calendar->timeZoneId(); | 488 | QString id = calendar->timeZoneId(); |
489 | calendar->setLocalTime(); | 489 | calendar->setLocalTime(); |
490 | if ( ! vfsave.save( calendar, fileName ) ) | 490 | if ( ! vfsave.save( calendar, fileName ) ) |
491 | return false; | 491 | return false; |
492 | calendar->setTimeZoneId( id ); | 492 | calendar->setTimeZoneId( id ); |
493 | return PhoneAccess::writeToPhone( fileName ); | 493 | return PhoneAccess::writeToPhone( fileName ); |
494 | } | 494 | } |
495 | bool PhoneFormat::save( Calendar *calendar) | 495 | bool PhoneFormat::save( Calendar *calendar) |
496 | { | 496 | { |
497 | QLabel status ( i18n(" Opening device ..."), 0 ); | 497 | |
498 | int w = status.sizeHint().width()+20 ; | ||
499 | if ( w < 200 ) w = 230; | ||
500 | int h = status.sizeHint().height()+20 ; | ||
501 | int dw = QApplication::desktop()->width(); | ||
502 | int dh = QApplication::desktop()->height(); | ||
503 | status.setCaption(i18n("Writing to phone...") ); | ||
504 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
505 | status.show(); | ||
506 | status.raise(); | ||
507 | qApp->processEvents(); | ||
508 | QString message; | ||
509 | 498 | ||
510 | // 1 remove events which should be deleted | 499 | // 1 remove events which should be deleted |
511 | QPtrList<Event> er = calendar->rawEvents(); | 500 | QPtrList<Event> er = calendar->rawEvents(); |
512 | Event* ev = er.first(); | 501 | Event* ev = er.first(); |
513 | while ( ev ) { | 502 | while ( ev ) { |
514 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
515 | calendar->deleteEvent( ev ); | 504 | calendar->deleteEvent( ev ); |
516 | } else { | 505 | } else { |
517 | 506 | ||
518 | } | 507 | } |
519 | ev = er.next(); | 508 | ev = er.next(); |
520 | } | 509 | } |
521 | // 2 remove todos which should be deleted | 510 | // 2 remove todos which should be deleted |
522 | QPtrList<Todo> tl = calendar->rawTodos(); | 511 | QPtrList<Todo> tl = calendar->rawTodos(); |
523 | Todo* to = tl.first(); | 512 | Todo* to = tl.first(); |
524 | while ( to ) { | 513 | while ( to ) { |
525 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
526 | calendar->deleteTodo( to ); | 515 | calendar->deleteTodo( to ); |
527 | } else { | 516 | } else { |
528 | if ( to->isCompleted()) { | 517 | if ( to->isCompleted()) { |
529 | calendar->deleteTodo( to ); | 518 | calendar->deleteTodo( to ); |
530 | } | 519 | } |
531 | } | 520 | } |
532 | to = tl.next(); | 521 | to = tl.next(); |
533 | } | 522 | } |
534 | // 3 save file | 523 | // 3 save file |
535 | if ( !writeToPhone( calendar ) ) | 524 | if ( !writeToPhone( calendar ) ) |
536 | return false; | 525 | return false; |
537 | 526 | QLabel status ( i18n(" Opening device ..."), 0 ); | |
527 | int w = status.sizeHint().width()+20 ; | ||
528 | if ( w < 200 ) w = 230; | ||
529 | int h = status.sizeHint().height()+20 ; | ||
530 | int dw = QApplication::desktop()->width(); | ||
531 | int dh = QApplication::desktop()->height(); | ||
532 | status.setCaption(i18n("Writing to phone...") ); | ||
533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
534 | QString message; | ||
535 | status.show(); | ||
536 | status.raise(); | ||
537 | qApp->processEvents(); | ||
538 | // 5 reread data | 538 | // 5 reread data |
539 | message = i18n(" Rereading all data ... "); | 539 | message = i18n(" Rereading all data ... "); |
540 | status.setText ( message ); | 540 | status.setText ( message ); |
541 | qApp->processEvents(); | 541 | qApp->processEvents(); |
542 | CalendarLocal* calendarTemp = new CalendarLocal(); | 542 | CalendarLocal* calendarTemp = new CalendarLocal(); |
543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
544 | if ( ! load( calendarTemp,calendar) ){ | 544 | if ( ! load( calendarTemp,calendar) ){ |
545 | qDebug("error reloading calendar "); | 545 | qDebug("error reloading calendar "); |
546 | delete calendarTemp; | 546 | delete calendarTemp; |
547 | return false; | 547 | return false; |
548 | } | 548 | } |
549 | // 6 compare data | 549 | // 6 compare data |
550 | 550 | ||
551 | //algo 6 compare event | 551 | //algo 6 compare event |
552 | er = calendar->rawEvents(); | 552 | er = calendar->rawEvents(); |
553 | ev = er.first(); | 553 | ev = er.first(); |
554 | message = i18n(" Comparing event # "); | 554 | message = i18n(" Comparing event # "); |
555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
556 | Event* ev1; | 556 | Event* ev1; |
557 | int procCount = 0; | 557 | int procCount = 0; |
558 | while ( ev ) { | 558 | while ( ev ) { |
559 | //qDebug("event new ID %s",ev->summary().latin1()); | 559 | //qDebug("event new ID %s",ev->summary().latin1()); |
560 | status.setText ( message + QString::number ( ++procCount ) ); | 560 | status.setText ( message + QString::number ( ++procCount ) ); |
561 | qApp->processEvents(); | 561 | qApp->processEvents(); |
562 | uint csum; | ||
563 | csum = PhoneFormat::getCsumEvent( ev ); | ||
564 | QString cSum = QString::number( csum ); | ||
565 | //ev->setCsum( mProfileName, cSum ); | ||
566 | //qDebug("Event cSum %s ", cSum.latin1()); | ||
567 | ev1 = er1.first(); | 562 | ev1 = er1.first(); |
568 | while ( ev1 ) { | 563 | while ( ev1 ) { |
569 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 564 | if ( ev->contains( ev1 ) ) { |
565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); | ||
570 | er1.remove( ev1 ); | 566 | er1.remove( ev1 ); |
571 | afterSave( ev ); | ||
572 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | ||
573 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | ||
574 | |||
575 | break; | 567 | break; |
576 | } | 568 | } |
577 | ev1 = er1.next(); | 569 | ev1 = er1.next(); |
578 | } | 570 | } |
579 | if ( ! ev1 ) { | 571 | if ( ! ev1 ) { |
580 | // ev->removeID(mProfileName); | 572 | // ev->removeID(mProfileName); |
581 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
582 | } | 574 | } |
583 | 575 | ||
584 | 576 | ||
585 | ev = er.next(); | 577 | ev = er.next(); |
586 | } | 578 | } |
587 | //algo 6 compare todo | 579 | //algo 6 compare todo |
588 | tl = calendar->rawTodos(); | 580 | tl = calendar->rawTodos(); |
589 | to = tl.first(); | 581 | to = tl.first(); |
590 | procCount = 0; | 582 | procCount = 0; |
591 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
592 | Todo* to1 ; | 584 | Todo* to1 ; |
593 | message = i18n(" Comparing todo # "); | 585 | message = i18n(" Comparing todo # "); |
594 | while ( to ) { | 586 | while ( to ) { |
595 | status.setText ( message + QString::number ( ++procCount ) ); | 587 | status.setText ( message + QString::number ( ++procCount ) ); |
596 | qApp->processEvents(); | 588 | qApp->processEvents(); |
597 | uint csum; | ||
598 | csum = PhoneFormat::getCsumTodo( to ); | ||
599 | QString cSum = QString::number( csum ); | ||
600 | //to->setCsum( mProfileName, cSum ); | ||
601 | //qDebug("Todo cSum %s ", cSum.latin1()); | ||
602 | Todo* to1 = tl1.first(); | 589 | Todo* to1 = tl1.first(); |
603 | while ( to1 ) { | 590 | while ( to1 ) { |
604 | if ( to1->getCsum( mProfileName ) == cSum ) { | 591 | if ( to->contains( to1 ) ) { |
592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); | ||
605 | tl1.remove( to1 ); | 593 | tl1.remove( to1 ); |
606 | afterSave( to ); | ||
607 | to->setID(mProfileName, to1->getID(mProfileName) ); | ||
608 | break; | 594 | break; |
609 | } | 595 | } |
610 | to1 = tl1.next(); | 596 | to1 = tl1.next(); |
611 | } | 597 | } |
612 | if ( ! to1 ) { | 598 | if ( ! to1 ) { |
613 | //to->removeID(mProfileName); | 599 | //to->removeID(mProfileName); |
614 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
615 | } | 601 | } |
616 | 602 | ||
617 | to = tl.next(); | 603 | to = tl.next(); |
618 | } | 604 | } |
619 | delete calendarTemp; | 605 | delete calendarTemp; |
620 | return true; | 606 | return true; |
621 | 607 | ||
622 | 608 | ||
623 | 609 | ||
624 | } | 610 | } |
625 | 611 | ||
626 | 612 | ||
627 | QString PhoneFormat::toString( Calendar * ) | 613 | QString PhoneFormat::toString( Calendar * ) |
628 | { | 614 | { |
629 | return QString::null; | 615 | return QString::null; |
630 | } | 616 | } |
631 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
632 | { | 618 | { |
633 | return false; | 619 | return false; |
634 | } | 620 | } |
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 001fd81..d11f68b 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -1,62 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | #ifndef PHONEFORMAT_H | 21 | #ifndef PHONEFORMAT_H |
22 | #define PHONEFORMAT_H | 22 | #define PHONEFORMAT_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #include "scheduler.h" | 26 | #include "scheduler.h" |
27 | 27 | ||
28 | #include "vcalformat.h" | 28 | #include "vcalformat.h" |
29 | #include "calformat.h" | 29 | #include "calformat.h" |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace KCal { |
32 | 32 | ||
33 | /** | 33 | /** |
34 | This class implements the calendar format used by Phone. | 34 | This class implements the calendar format used by Phone. |
35 | */ | 35 | */ |
36 | class Event; | 36 | class Event; |
37 | class Todo; | 37 | class Todo; |
38 | class PhoneFormat : public QObject { | 38 | class PhoneFormat : public QObject { |
39 | public: | 39 | public: |
40 | /** Create new iCalendar format. */ | 40 | /** Create new iCalendar format. */ |
41 | PhoneFormat(QString profileName, QString device,QString connection, QString model); | 41 | PhoneFormat(QString profileName, QString device,QString connection, QString model); |
42 | virtual ~PhoneFormat(); | 42 | virtual ~PhoneFormat(); |
43 | 43 | ||
44 | bool load( Calendar * ,Calendar * ); | 44 | bool load( Calendar * ,Calendar * ); |
45 | bool save( Calendar * ); | 45 | bool save( Calendar * ); |
46 | bool fromString( Calendar *, const QString & ); | 46 | bool fromString( Calendar *, const QString & ); |
47 | QString toString( Calendar * ); | 47 | QString toString( Calendar * ); |
48 | static ulong getCsum( const QStringList & ); | 48 | static ulong getCsum( const QStringList & ); |
49 | static ulong getCsumTodo( Todo* to ); | 49 | static ulong getCsumTodo( Todo* to ); |
50 | static ulong getCsumEvent( Event* ev ); | 50 | static ulong getCsumEvent( Event* ev ); |
51 | static bool writeToPhone( Calendar * ); | 51 | static bool writeToPhone( Calendar * ); |
52 | private: | 52 | private: |
53 | void copyEvent( Event* to, Event* from ); | 53 | void copyEvent( Event* to, Event* from ); |
54 | void copyTodo( Todo* to, Todo* from ); | 54 | void copyTodo( Todo* to, Todo* from ); |
55 | //int initDevice(GSM_StateMachine *s); | 55 | //int initDevice(GSM_StateMachine *s); |
56 | QString mProfileName; | 56 | QString mProfileName; |
57 | void afterSave( Incidence* ); | 57 | void afterSave( Incidence* ,const QString&,const QString&); |
58 | }; | 58 | }; |
59 | 59 | ||
60 | } | 60 | } |
61 | 61 | ||
62 | #endif | 62 | #endif |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 0c1e3e4..3d2de61 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,315 +1,373 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Todo::Todo(): Incidence() | 29 | Todo::Todo(): Incidence() |
30 | { | 30 | { |
31 | // mStatus = TENTATIVE; | 31 | // mStatus = TENTATIVE; |
32 | 32 | ||
33 | mHasDueDate = false; | 33 | mHasDueDate = false; |
34 | setHasStartDate( false ); | 34 | setHasStartDate( false ); |
35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
36 | mHasCompletedDate = false; | 36 | mHasCompletedDate = false; |
37 | mPercentComplete = 0; | 37 | mPercentComplete = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | Todo::Todo(const Todo &t) : Incidence(t) | 40 | Todo::Todo(const Todo &t) : Incidence(t) |
41 | { | 41 | { |
42 | mDtDue = t.mDtDue; | 42 | mDtDue = t.mDtDue; |
43 | mHasDueDate = t.mHasDueDate; | 43 | mHasDueDate = t.mHasDueDate; |
44 | mCompleted = t.mCompleted; | 44 | mCompleted = t.mCompleted; |
45 | mHasCompletedDate = t.mHasCompletedDate; | 45 | mHasCompletedDate = t.mHasCompletedDate; |
46 | mPercentComplete = t.mPercentComplete; | 46 | mPercentComplete = t.mPercentComplete; |
47 | } | 47 | } |
48 | 48 | ||
49 | Todo::~Todo() | 49 | Todo::~Todo() |
50 | { | 50 | { |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | Incidence *Todo::clone() | 54 | Incidence *Todo::clone() |
55 | { | 55 | { |
56 | return new Todo(*this); | 56 | return new Todo(*this); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool Todo::contains ( Todo* from ) | ||
60 | { | ||
59 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | ||
63 | if ( !summary().startsWith( from->summary() )) | ||
64 | return false; | ||
65 | if ( from->hasStartDate() ) { | ||
66 | if ( !hasStartDate() ) | ||
67 | return false; | ||
68 | if ( from->dtStart() != dtStart()) | ||
69 | return false; | ||
70 | } | ||
71 | if ( from->hasDueDate() ){ | ||
72 | if ( !hasDueDate() ) | ||
73 | return false; | ||
74 | if ( from->dtDue() != dtDue()) | ||
75 | return false; | ||
76 | } | ||
77 | if ( !from->location().isEmpty() ) | ||
78 | if ( !location().startsWith( from->location() ) ) | ||
79 | return false; | ||
80 | if ( !from->description().isEmpty() ) | ||
81 | if ( !description().startsWith( from->description() )) | ||
82 | return false; | ||
83 | if ( from->alarms().count() ) { | ||
84 | Alarm *a = from->alarms().first(); | ||
85 | if ( a->enabled() ){ | ||
86 | if ( !alarms().count() ) | ||
87 | return false; | ||
88 | Alarm *b = alarms().first(); | ||
89 | if( ! b->enabled() ) | ||
90 | return false; | ||
91 | if ( ! (a->offset() == b->offset() )) | ||
92 | return false; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | QStringList cat = categories(); | ||
97 | QStringList catFrom = from->categories(); | ||
98 | QString nCat; | ||
99 | int iii; | ||
100 | for ( iii = 0; iii < catFrom.count();++iii ) { | ||
101 | nCat = catFrom[iii]; | ||
102 | if ( !nCat.isEmpty() ) | ||
103 | if ( !cat.contains( nCat )) { | ||
104 | return false; | ||
105 | } | ||
106 | } | ||
107 | if ( from->isCompleted() ) { | ||
108 | if ( !isCompleted() ) | ||
109 | return false; | ||
110 | } | ||
111 | if( priority() != from->priority() ) | ||
112 | return false; | ||
113 | |||
114 | |||
115 | return true; | ||
116 | |||
117 | } | ||
60 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
61 | { | 119 | { |
62 | 120 | ||
63 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
64 | if ( ! ret ) | 122 | if ( ! ret ) |
65 | return false; | 123 | return false; |
66 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
67 | if ( t1.hasDueDate() ) { | 125 | if ( t1.hasDueDate() ) { |
68 | if ( t1.doesFloat() == t2.doesFloat() ) { | 126 | if ( t1.doesFloat() == t2.doesFloat() ) { |
69 | if ( t1.doesFloat() ) { | 127 | if ( t1.doesFloat() ) { |
70 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 128 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
71 | return false; | 129 | return false; |
72 | } else | 130 | } else |
73 | if ( t1.dtDue() != t2.dtDue() ) | 131 | if ( t1.dtDue() != t2.dtDue() ) |
74 | return false; | 132 | return false; |
75 | } else | 133 | } else |
76 | return false;// float != | 134 | return false;// float != |
77 | } | 135 | } |
78 | 136 | ||
79 | } else | 137 | } else |
80 | return false; | 138 | return false; |
81 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
82 | return false; | 140 | return false; |
83 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
84 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
85 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
86 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
87 | return false; | 145 | return false; |
88 | } | 146 | } |
89 | 147 | ||
90 | } else | 148 | } else |
91 | return false; | 149 | return false; |
92 | } | 150 | } |
93 | return true; | 151 | return true; |
94 | 152 | ||
95 | } | 153 | } |
96 | 154 | ||
97 | void Todo::setDtDue(const QDateTime &dtDue) | 155 | void Todo::setDtDue(const QDateTime &dtDue) |
98 | { | 156 | { |
99 | //int diffsecs = mDtDue.secsTo(dtDue); | 157 | //int diffsecs = mDtDue.secsTo(dtDue); |
100 | 158 | ||
101 | /*if (mReadOnly) return; | 159 | /*if (mReadOnly) return; |
102 | const QPtrList<Alarm>& alarms = alarms(); | 160 | const QPtrList<Alarm>& alarms = alarms(); |
103 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
104 | if (alarm->enabled()) { | 162 | if (alarm->enabled()) { |
105 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 163 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
106 | } | 164 | } |
107 | }*/ | 165 | }*/ |
108 | mDtDue = getEvenTime(dtDue); | 166 | mDtDue = getEvenTime(dtDue); |
109 | 167 | ||
110 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
111 | 169 | ||
112 | /*const QPtrList<Alarm>& alarms = alarms(); | 170 | /*const QPtrList<Alarm>& alarms = alarms(); |
113 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
114 | alarm->setAlarmStart(mDtDue);*/ | 172 | alarm->setAlarmStart(mDtDue);*/ |
115 | 173 | ||
116 | updated(); | 174 | updated(); |
117 | } | 175 | } |
118 | 176 | ||
119 | QDateTime Todo::dtDue() const | 177 | QDateTime Todo::dtDue() const |
120 | { | 178 | { |
121 | return mDtDue; | 179 | return mDtDue; |
122 | } | 180 | } |
123 | 181 | ||
124 | QString Todo::dtDueTimeStr() const | 182 | QString Todo::dtDueTimeStr() const |
125 | { | 183 | { |
126 | return KGlobal::locale()->formatTime(mDtDue.time()); | 184 | return KGlobal::locale()->formatTime(mDtDue.time()); |
127 | } | 185 | } |
128 | 186 | ||
129 | QString Todo::dtDueDateStr(bool shortfmt) const | 187 | QString Todo::dtDueDateStr(bool shortfmt) const |
130 | { | 188 | { |
131 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
132 | } | 190 | } |
133 | 191 | ||
134 | QString Todo::dtDueStr(bool shortfmt) const | 192 | QString Todo::dtDueStr(bool shortfmt) const |
135 | { | 193 | { |
136 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
137 | } | 195 | } |
138 | 196 | ||
139 | bool Todo::hasDueDate() const | 197 | bool Todo::hasDueDate() const |
140 | { | 198 | { |
141 | return mHasDueDate; | 199 | return mHasDueDate; |
142 | } | 200 | } |
143 | 201 | ||
144 | void Todo::setHasDueDate(bool f) | 202 | void Todo::setHasDueDate(bool f) |
145 | { | 203 | { |
146 | if (mReadOnly) return; | 204 | if (mReadOnly) return; |
147 | mHasDueDate = f; | 205 | mHasDueDate = f; |
148 | updated(); | 206 | updated(); |
149 | } | 207 | } |
150 | 208 | ||
151 | 209 | ||
152 | #if 0 | 210 | #if 0 |
153 | void Todo::setStatus(const QString &statStr) | 211 | void Todo::setStatus(const QString &statStr) |
154 | { | 212 | { |
155 | if (mReadOnly) return; | 213 | if (mReadOnly) return; |
156 | QString ss(statStr.upper()); | 214 | QString ss(statStr.upper()); |
157 | 215 | ||
158 | if (ss == "X-ACTION") | 216 | if (ss == "X-ACTION") |
159 | mStatus = NEEDS_ACTION; | 217 | mStatus = NEEDS_ACTION; |
160 | else if (ss == "NEEDS ACTION") | 218 | else if (ss == "NEEDS ACTION") |
161 | mStatus = NEEDS_ACTION; | 219 | mStatus = NEEDS_ACTION; |
162 | else if (ss == "ACCEPTED") | 220 | else if (ss == "ACCEPTED") |
163 | mStatus = ACCEPTED; | 221 | mStatus = ACCEPTED; |
164 | else if (ss == "SENT") | 222 | else if (ss == "SENT") |
165 | mStatus = SENT; | 223 | mStatus = SENT; |
166 | else if (ss == "TENTATIVE") | 224 | else if (ss == "TENTATIVE") |
167 | mStatus = TENTATIVE; | 225 | mStatus = TENTATIVE; |
168 | else if (ss == "CONFIRMED") | 226 | else if (ss == "CONFIRMED") |
169 | mStatus = CONFIRMED; | 227 | mStatus = CONFIRMED; |
170 | else if (ss == "DECLINED") | 228 | else if (ss == "DECLINED") |
171 | mStatus = DECLINED; | 229 | mStatus = DECLINED; |
172 | else if (ss == "COMPLETED") | 230 | else if (ss == "COMPLETED") |
173 | mStatus = COMPLETED; | 231 | mStatus = COMPLETED; |
174 | else if (ss == "DELEGATED") | 232 | else if (ss == "DELEGATED") |
175 | mStatus = DELEGATED; | 233 | mStatus = DELEGATED; |
176 | 234 | ||
177 | updated(); | 235 | updated(); |
178 | } | 236 | } |
179 | 237 | ||
180 | void Todo::setStatus(int status) | 238 | void Todo::setStatus(int status) |
181 | { | 239 | { |
182 | if (mReadOnly) return; | 240 | if (mReadOnly) return; |
183 | mStatus = status; | 241 | mStatus = status; |
184 | updated(); | 242 | updated(); |
185 | } | 243 | } |
186 | 244 | ||
187 | int Todo::status() const | 245 | int Todo::status() const |
188 | { | 246 | { |
189 | return mStatus; | 247 | return mStatus; |
190 | } | 248 | } |
191 | 249 | ||
192 | QString Todo::statusStr() const | 250 | QString Todo::statusStr() const |
193 | { | 251 | { |
194 | switch(mStatus) { | 252 | switch(mStatus) { |
195 | case NEEDS_ACTION: | 253 | case NEEDS_ACTION: |
196 | return QString("NEEDS ACTION"); | 254 | return QString("NEEDS ACTION"); |
197 | break; | 255 | break; |
198 | case ACCEPTED: | 256 | case ACCEPTED: |
199 | return QString("ACCEPTED"); | 257 | return QString("ACCEPTED"); |
200 | break; | 258 | break; |
201 | case SENT: | 259 | case SENT: |
202 | return QString("SENT"); | 260 | return QString("SENT"); |
203 | break; | 261 | break; |
204 | case TENTATIVE: | 262 | case TENTATIVE: |
205 | return QString("TENTATIVE"); | 263 | return QString("TENTATIVE"); |
206 | break; | 264 | break; |
207 | case CONFIRMED: | 265 | case CONFIRMED: |
208 | return QString("CONFIRMED"); | 266 | return QString("CONFIRMED"); |
209 | break; | 267 | break; |
210 | case DECLINED: | 268 | case DECLINED: |
211 | return QString("DECLINED"); | 269 | return QString("DECLINED"); |
212 | break; | 270 | break; |
213 | case COMPLETED: | 271 | case COMPLETED: |
214 | return QString("COMPLETED"); | 272 | return QString("COMPLETED"); |
215 | break; | 273 | break; |
216 | case DELEGATED: | 274 | case DELEGATED: |
217 | return QString("DELEGATED"); | 275 | return QString("DELEGATED"); |
218 | break; | 276 | break; |
219 | } | 277 | } |
220 | return QString(""); | 278 | return QString(""); |
221 | } | 279 | } |
222 | #endif | 280 | #endif |
223 | 281 | ||
224 | bool Todo::isCompleted() const | 282 | bool Todo::isCompleted() const |
225 | { | 283 | { |
226 | if (mPercentComplete == 100) return true; | 284 | if (mPercentComplete == 100) return true; |
227 | else return false; | 285 | else return false; |
228 | } | 286 | } |
229 | 287 | ||
230 | void Todo::setCompleted(bool completed) | 288 | void Todo::setCompleted(bool completed) |
231 | { | 289 | { |
232 | if (completed) mPercentComplete = 100; | 290 | if (completed) mPercentComplete = 100; |
233 | else mPercentComplete = 0; | 291 | else mPercentComplete = 0; |
234 | updated(); | 292 | updated(); |
235 | } | 293 | } |
236 | 294 | ||
237 | QDateTime Todo::completed() const | 295 | QDateTime Todo::completed() const |
238 | { | 296 | { |
239 | return mCompleted; | 297 | return mCompleted; |
240 | } | 298 | } |
241 | 299 | ||
242 | QString Todo::completedStr() const | 300 | QString Todo::completedStr() const |
243 | { | 301 | { |
244 | return KGlobal::locale()->formatDateTime(mCompleted); | 302 | return KGlobal::locale()->formatDateTime(mCompleted); |
245 | } | 303 | } |
246 | 304 | ||
247 | void Todo::setCompleted(const QDateTime &completed) | 305 | void Todo::setCompleted(const QDateTime &completed) |
248 | { | 306 | { |
249 | mHasCompletedDate = true; | 307 | mHasCompletedDate = true; |
250 | mPercentComplete = 100; | 308 | mPercentComplete = 100; |
251 | mCompleted = getEvenTime(completed); | 309 | mCompleted = getEvenTime(completed); |
252 | updated(); | 310 | updated(); |
253 | } | 311 | } |
254 | 312 | ||
255 | bool Todo::hasCompletedDate() const | 313 | bool Todo::hasCompletedDate() const |
256 | { | 314 | { |
257 | return mHasCompletedDate; | 315 | return mHasCompletedDate; |
258 | } | 316 | } |
259 | 317 | ||
260 | int Todo::percentComplete() const | 318 | int Todo::percentComplete() const |
261 | { | 319 | { |
262 | return mPercentComplete; | 320 | return mPercentComplete; |
263 | } | 321 | } |
264 | 322 | ||
265 | void Todo::setPercentComplete(int v) | 323 | void Todo::setPercentComplete(int v) |
266 | { | 324 | { |
267 | mPercentComplete = v; | 325 | mPercentComplete = v; |
268 | updated(); | 326 | updated(); |
269 | } | 327 | } |
270 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 328 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
271 | { | 329 | { |
272 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 330 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
273 | *ok = false; | 331 | *ok = false; |
274 | return QDateTime (); | 332 | return QDateTime (); |
275 | } | 333 | } |
276 | QDateTime incidenceStart; | 334 | QDateTime incidenceStart; |
277 | incidenceStart = dtDue(); | 335 | incidenceStart = dtDue(); |
278 | bool enabled = false; | 336 | bool enabled = false; |
279 | Alarm* alarm; | 337 | Alarm* alarm; |
280 | int off; | 338 | int off; |
281 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 339 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
282 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 340 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
283 | // *ok = false; | 341 | // *ok = false; |
284 | // return incidenceStart; | 342 | // return incidenceStart; |
285 | // } | 343 | // } |
286 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 344 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
287 | if (alarm->enabled()) { | 345 | if (alarm->enabled()) { |
288 | if ( alarm->hasTime () ) { | 346 | if ( alarm->hasTime () ) { |
289 | if ( alarm->time() < alarmStart ) { | 347 | if ( alarm->time() < alarmStart ) { |
290 | alarmStart = alarm->time(); | 348 | alarmStart = alarm->time(); |
291 | enabled = true; | 349 | enabled = true; |
292 | off = alarmStart.secsTo( incidenceStart ); | 350 | off = alarmStart.secsTo( incidenceStart ); |
293 | } | 351 | } |
294 | 352 | ||
295 | } else { | 353 | } else { |
296 | int secs = alarm->startOffset().asSeconds(); | 354 | int secs = alarm->startOffset().asSeconds(); |
297 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 355 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
298 | alarmStart = incidenceStart.addSecs( secs ); | 356 | alarmStart = incidenceStart.addSecs( secs ); |
299 | enabled = true; | 357 | enabled = true; |
300 | off = -secs; | 358 | off = -secs; |
301 | } | 359 | } |
302 | } | 360 | } |
303 | } | 361 | } |
304 | } | 362 | } |
305 | if ( enabled ) { | 363 | if ( enabled ) { |
306 | if ( alarmStart > QDateTime::currentDateTime() ) { | 364 | if ( alarmStart > QDateTime::currentDateTime() ) { |
307 | *ok = true; | 365 | *ok = true; |
308 | * offset = off; | 366 | * offset = off; |
309 | return alarmStart; | 367 | return alarmStart; |
310 | } | 368 | } |
311 | } | 369 | } |
312 | *ok = false; | 370 | *ok = false; |
313 | return QDateTime (); | 371 | return QDateTime (); |
314 | 372 | ||
315 | } | 373 | } |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 9aa92f8..0f22c59 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -1,121 +1,122 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef TODO_H | 20 | #ifndef TODO_H |
21 | #define TODO_H | 21 | #define TODO_H |
22 | // | 22 | // |
23 | // Todo component, representing a VTODO object | 23 | // Todo component, representing a VTODO object |
24 | // | 24 | // |
25 | 25 | ||
26 | #include "incidence.h" | 26 | #include "incidence.h" |
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides a Todo in the sense of RFC2445. | 31 | This class provides a Todo in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Todo : public Incidence | 33 | class Todo : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | Todo(); | 36 | Todo(); |
37 | Todo(const Todo &); | 37 | Todo(const Todo &); |
38 | ~Todo(); | 38 | ~Todo(); |
39 | typedef ListBase<Todo> List; | 39 | typedef ListBase<Todo> List; |
40 | QCString type() const { return "Todo"; } | 40 | QCString type() const { return "Todo"; } |
41 | 41 | ||
42 | /** Return an exact copy of this todo. */ | 42 | /** Return an exact copy of this todo. */ |
43 | Incidence *clone(); | 43 | Incidence *clone(); |
44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; | 44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; |
45 | 45 | ||
46 | /** for setting the todo's due date/time with a QDateTime. */ | 46 | /** for setting the todo's due date/time with a QDateTime. */ |
47 | void setDtDue(const QDateTime &dtDue); | 47 | void setDtDue(const QDateTime &dtDue); |
48 | /** returns an event's Due date/time as a QDateTime. */ | 48 | /** returns an event's Due date/time as a QDateTime. */ |
49 | QDateTime dtDue() const; | 49 | QDateTime dtDue() const; |
50 | /** returns an event's due time as a string formatted according to the | 50 | /** returns an event's due time as a string formatted according to the |
51 | users locale settings */ | 51 | users locale settings */ |
52 | QString dtDueTimeStr() const; | 52 | QString dtDueTimeStr() const; |
53 | /** returns an event's due date as a string formatted according to the | 53 | /** returns an event's due date as a string formatted according to the |
54 | users locale settings */ | 54 | users locale settings */ |
55 | QString dtDueDateStr(bool shortfmt=true) const; | 55 | QString dtDueDateStr(bool shortfmt=true) const; |
56 | /** returns an event's due date and time as a string formatted according | 56 | /** returns an event's due date and time as a string formatted according |
57 | to the users locale settings */ | 57 | to the users locale settings */ |
58 | QString dtDueStr(bool shortfmt=true) const; | 58 | QString dtDueStr(bool shortfmt=true) const; |
59 | 59 | ||
60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
61 | bool hasDueDate() const; | 61 | bool hasDueDate() const; |
62 | /** sets the event's hasDueDate value. */ | 62 | /** sets the event's hasDueDate value. */ |
63 | void setHasDueDate(bool f); | 63 | void setHasDueDate(bool f); |
64 | 64 | ||
65 | 65 | ||
66 | /** sets the event's status to the string specified. The string | 66 | /** sets the event's status to the string specified. The string |
67 | * must be a recognized value for the status field, i.e. a string | 67 | * must be a recognized value for the status field, i.e. a string |
68 | * equivalent of the possible status enumerations previously described. */ | 68 | * equivalent of the possible status enumerations previously described. */ |
69 | // void setStatus(const QString &statStr); | 69 | // void setStatus(const QString &statStr); |
70 | /** sets the event's status to the value specified. See the enumeration | 70 | /** sets the event's status to the value specified. See the enumeration |
71 | * above for possible values. */ | 71 | * above for possible values. */ |
72 | // void setStatus(int); | 72 | // void setStatus(int); |
73 | /** return the event's status. */ | 73 | /** return the event's status. */ |
74 | // int status() const; | 74 | // int status() const; |
75 | /** return the event's status in string format. */ | 75 | /** return the event's status in string format. */ |
76 | // QString statusStr() const; | 76 | // QString statusStr() const; |
77 | 77 | ||
78 | /** return, if this todo is completed */ | 78 | /** return, if this todo is completed */ |
79 | bool isCompleted() const; | 79 | bool isCompleted() const; |
80 | /** set completed state of this todo */ | 80 | /** set completed state of this todo */ |
81 | void setCompleted(bool); | 81 | void setCompleted(bool); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | Return how many percent of the task are completed. Returns a value | 84 | Return how many percent of the task are completed. Returns a value |
85 | between 0 and 100. | 85 | between 0 and 100. |
86 | */ | 86 | */ |
87 | int percentComplete() const; | 87 | int percentComplete() const; |
88 | /** | 88 | /** |
89 | Set how many percent of the task are completed. Valid values are in the | 89 | Set how many percent of the task are completed. Valid values are in the |
90 | range from 0 to 100. | 90 | range from 0 to 100. |
91 | */ | 91 | */ |
92 | void setPercentComplete(int); | 92 | void setPercentComplete(int); |
93 | 93 | ||
94 | /** return date and time when todo was completed */ | 94 | /** return date and time when todo was completed */ |
95 | QDateTime completed() const; | 95 | QDateTime completed() const; |
96 | QString completedStr() const; | 96 | QString completedStr() const; |
97 | /** set date and time of completion */ | 97 | /** set date and time of completion */ |
98 | void setCompleted(const QDateTime &completed); | 98 | void setCompleted(const QDateTime &completed); |
99 | 99 | ||
100 | /** Return true, if todo has a date associated with completion */ | 100 | /** Return true, if todo has a date associated with completion */ |
101 | bool hasCompletedDate() const; | 101 | bool hasCompletedDate() const; |
102 | bool contains ( Todo*); | ||
102 | 103 | ||
103 | private: | 104 | private: |
104 | bool accept(Visitor &v) { return v.visit(this); } | 105 | bool accept(Visitor &v) { return v.visit(this); } |
105 | 106 | ||
106 | QDateTime mDtDue; // due date of todo | 107 | QDateTime mDtDue; // due date of todo |
107 | 108 | ||
108 | bool mHasDueDate; // if todo has associated due date | 109 | bool mHasDueDate; // if todo has associated due date |
109 | 110 | ||
110 | // int mStatus; // confirmed/delegated/tentative/etc | 111 | // int mStatus; // confirmed/delegated/tentative/etc |
111 | 112 | ||
112 | QDateTime mCompleted; | 113 | QDateTime mCompleted; |
113 | bool mHasCompletedDate; | 114 | bool mHasCompletedDate; |
114 | 115 | ||
115 | int mPercentComplete; | 116 | int mPercentComplete; |
116 | }; | 117 | }; |
117 | 118 | ||
118 | bool operator==( const Todo&, const Todo& ); | 119 | bool operator==( const Todo&, const Todo& ); |
119 | } | 120 | } |
120 | 121 | ||
121 | #endif | 122 | #endif |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index a6ae1bc..df93209 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -1,349 +1,351 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brwon | 3 | Copyright (c) 1998 Preston Brwon |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | 36 | ||
37 | #include "vcc.h" | 37 | #include "vcc.h" |
38 | #include "vobject.h" | 38 | #include "vobject.h" |
39 | 39 | ||
40 | #include "vcaldrag.h" | 40 | #include "vcaldrag.h" |
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | 42 | ||
43 | #include "vcalformat.h" | 43 | #include "vcalformat.h" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
48 | { | 48 | { |
49 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | 50 | useLocalTime = false; |
51 | } | 51 | } |
52 | 52 | ||
53 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
54 | { | 54 | { |
55 | } | 55 | } |
56 | 56 | ||
57 | void VCalFormat::setLocalTime ( bool b ) | 57 | void VCalFormat::setLocalTime ( bool b ) |
58 | { | 58 | { |
59 | useLocalTime = b; | 59 | useLocalTime = b; |
60 | } | 60 | } |
61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
62 | { | 62 | { |
63 | mCalendar = calendar; | 63 | mCalendar = calendar; |
64 | clearException(); | 64 | clearException(); |
65 | useLocalTime = mCalendar->isLocalTime(); | 65 | if ( ! useLocalTime ) |
66 | useLocalTime = mCalendar->isLocalTime(); | ||
66 | VObject *vcal = 0; | 67 | VObject *vcal = 0; |
67 | 68 | ||
68 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 69 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
69 | // a vcard... | 70 | // a vcard... |
70 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 71 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
71 | 72 | ||
72 | if (!vcal) { | 73 | if (!vcal) { |
73 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
74 | return FALSE; | 75 | return FALSE; |
75 | } | 76 | } |
76 | 77 | ||
77 | // any other top-level calendar stuff should be added/initialized here | 78 | // any other top-level calendar stuff should be added/initialized here |
78 | 79 | ||
79 | // put all vobjects into their proper places | 80 | // put all vobjects into their proper places |
80 | populate(vcal); | 81 | populate(vcal); |
81 | 82 | ||
82 | // clean up from vcal API stuff | 83 | // clean up from vcal API stuff |
83 | cleanVObjects(vcal); | 84 | cleanVObjects(vcal); |
84 | cleanStrTbl(); | 85 | cleanStrTbl(); |
85 | 86 | ||
86 | return true; | 87 | return true; |
87 | } | 88 | } |
88 | 89 | ||
89 | 90 | ||
90 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
91 | { | 92 | { |
92 | mCalendar = calendar; | 93 | mCalendar = calendar; |
93 | useLocalTime = mCalendar->isLocalTime(); | 94 | if ( ! useLocalTime ) |
95 | useLocalTime = mCalendar->isLocalTime(); | ||
94 | 96 | ||
95 | QString tmpStr; | 97 | QString tmpStr; |
96 | VObject *vcal, *vo; | 98 | VObject *vcal, *vo; |
97 | 99 | ||
98 | 100 | ||
99 | vcal = newVObject(VCCalProp); | 101 | vcal = newVObject(VCCalProp); |
100 | 102 | ||
101 | // addPropValue(vcal,VCLocationProp, "0.0"); | 103 | // addPropValue(vcal,VCLocationProp, "0.0"); |
102 | addPropValue(vcal,VCProdIdProp, productId()); | 104 | addPropValue(vcal,VCProdIdProp, productId()); |
103 | tmpStr = mCalendar->getTimeZoneStr(); | 105 | tmpStr = mCalendar->getTimeZoneStr(); |
104 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
105 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
106 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
107 | 109 | ||
108 | // TODO STUFF | 110 | // TODO STUFF |
109 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
110 | QPtrListIterator<Todo> qlt(todoList); | 112 | QPtrListIterator<Todo> qlt(todoList); |
111 | for (; qlt.current(); ++qlt) { | 113 | for (; qlt.current(); ++qlt) { |
112 | vo = eventToVTodo(qlt.current()); | 114 | vo = eventToVTodo(qlt.current()); |
113 | addVObjectProp(vcal, vo); | 115 | addVObjectProp(vcal, vo); |
114 | } | 116 | } |
115 | 117 | ||
116 | // EVENT STUFF | 118 | // EVENT STUFF |
117 | QPtrList<Event> events = mCalendar->rawEvents(); | 119 | QPtrList<Event> events = mCalendar->rawEvents(); |
118 | Event *ev; | 120 | Event *ev; |
119 | for(ev=events.first();ev;ev=events.next()) { | 121 | for(ev=events.first();ev;ev=events.next()) { |
120 | vo = eventToVEvent(ev); | 122 | vo = eventToVEvent(ev); |
121 | addVObjectProp(vcal, vo); | 123 | addVObjectProp(vcal, vo); |
122 | } | 124 | } |
123 | 125 | ||
124 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
125 | cleanVObjects(vcal); | 127 | cleanVObjects(vcal); |
126 | cleanStrTbl(); | 128 | cleanStrTbl(); |
127 | 129 | ||
128 | if (QFile::exists(fileName)) { | 130 | if (QFile::exists(fileName)) { |
129 | return true; | 131 | return true; |
130 | } else { | 132 | } else { |
131 | return false; // error | 133 | return false; // error |
132 | } | 134 | } |
133 | } | 135 | } |
134 | 136 | ||
135 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 137 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
136 | { | 138 | { |
137 | // TODO: Factor out VCalFormat::fromString() | 139 | // TODO: Factor out VCalFormat::fromString() |
138 | 140 | ||
139 | QCString data = text.utf8(); | 141 | QCString data = text.utf8(); |
140 | 142 | ||
141 | if ( !data.size() ) return false; | 143 | if ( !data.size() ) return false; |
142 | 144 | ||
143 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 145 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
144 | if ( !vcal ) return false; | 146 | if ( !vcal ) return false; |
145 | 147 | ||
146 | VObjectIterator i; | 148 | VObjectIterator i; |
147 | VObject *curvo; | 149 | VObject *curvo; |
148 | initPropIterator( &i, vcal ); | 150 | initPropIterator( &i, vcal ); |
149 | 151 | ||
150 | // we only take the first object. TODO: parse all incidences. | 152 | // we only take the first object. TODO: parse all incidences. |
151 | do { | 153 | do { |
152 | curvo = nextVObject( &i ); | 154 | curvo = nextVObject( &i ); |
153 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 155 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
154 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 156 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
155 | 157 | ||
156 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 158 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
157 | Event *event = VEventToEvent( curvo ); | 159 | Event *event = VEventToEvent( curvo ); |
158 | calendar->addEvent( event ); | 160 | calendar->addEvent( event ); |
159 | } else { | 161 | } else { |
160 | qDebug("VCalFormat::fromString(): Unknown object type. "); | 162 | qDebug("VCalFormat::fromString(): Unknown object type. "); |
161 | deleteVObject( vcal ); | 163 | deleteVObject( vcal ); |
162 | return false; | 164 | return false; |
163 | } | 165 | } |
164 | 166 | ||
165 | deleteVObject( vcal ); | 167 | deleteVObject( vcal ); |
166 | 168 | ||
167 | return true; | 169 | return true; |
168 | } | 170 | } |
169 | 171 | ||
170 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
171 | { | 173 | { |
172 | 174 | ||
173 | if ( !event ) return QString::null; | 175 | if ( !event ) return QString::null; |
174 | bool useL = useLocalTime; | 176 | bool useL = useLocalTime; |
175 | useLocalTime = useLocal; | 177 | useLocalTime = useLocal; |
176 | mCalendar = calendar; | 178 | mCalendar = calendar; |
177 | VObject *vevent = eventToVEvent( event ); | 179 | VObject *vevent = eventToVEvent( event ); |
178 | char *buf = writeMemVObject( 0, 0, vevent ); | 180 | char *buf = writeMemVObject( 0, 0, vevent ); |
179 | QString result( buf ); | 181 | QString result( buf ); |
180 | cleanVObject( vevent ); | 182 | cleanVObject( vevent ); |
181 | useLocalTime = useL; | 183 | useLocalTime = useL; |
182 | return result; | 184 | return result; |
183 | } | 185 | } |
184 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
185 | { | 187 | { |
186 | 188 | ||
187 | if ( !todo ) return QString::null; | 189 | if ( !todo ) return QString::null; |
188 | bool useL = useLocalTime; | 190 | bool useL = useLocalTime; |
189 | useLocalTime = useLocal; | 191 | useLocalTime = useLocal; |
190 | mCalendar = calendar; | 192 | mCalendar = calendar; |
191 | VObject *vevent = eventToVTodo( todo ); | 193 | VObject *vevent = eventToVTodo( todo ); |
192 | char *buf = writeMemVObject( 0, 0, vevent ); | 194 | char *buf = writeMemVObject( 0, 0, vevent ); |
193 | QString result( buf ); | 195 | QString result( buf ); |
194 | cleanVObject( vevent ); | 196 | cleanVObject( vevent ); |
195 | useLocalTime = useL; | 197 | useLocalTime = useL; |
196 | return result; | 198 | return result; |
197 | } | 199 | } |
198 | 200 | ||
199 | QString VCalFormat::toString( Calendar *calendar ) | 201 | QString VCalFormat::toString( Calendar *calendar ) |
200 | { | 202 | { |
201 | // TODO: Factor out VCalFormat::asString() | 203 | // TODO: Factor out VCalFormat::asString() |
202 | 204 | ||
203 | VObject *vcal = newVObject(VCCalProp); | 205 | VObject *vcal = newVObject(VCCalProp); |
204 | 206 | ||
205 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 207 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
206 | QString tmpStr = mCalendar->getTimeZoneStr(); | 208 | QString tmpStr = mCalendar->getTimeZoneStr(); |
207 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 209 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
208 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 210 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
209 | 211 | ||
210 | // TODO: Use all data. | 212 | // TODO: Use all data. |
211 | QPtrList<Event> events = calendar->events(); | 213 | QPtrList<Event> events = calendar->events(); |
212 | Event *event = events.first(); | 214 | Event *event = events.first(); |
213 | if ( !event ) return QString::null; | 215 | if ( !event ) return QString::null; |
214 | 216 | ||
215 | VObject *vevent = eventToVEvent( event ); | 217 | VObject *vevent = eventToVEvent( event ); |
216 | 218 | ||
217 | addVObjectProp( vcal, vevent ); | 219 | addVObjectProp( vcal, vevent ); |
218 | 220 | ||
219 | char *buf = writeMemVObject( 0, 0, vcal ); | 221 | char *buf = writeMemVObject( 0, 0, vcal ); |
220 | 222 | ||
221 | QString result( buf ); | 223 | QString result( buf ); |
222 | 224 | ||
223 | cleanVObject( vcal ); | 225 | cleanVObject( vcal ); |
224 | 226 | ||
225 | return result; | 227 | return result; |
226 | } | 228 | } |
227 | 229 | ||
228 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
229 | { | 231 | { |
230 | VObject *vtodo; | 232 | VObject *vtodo; |
231 | QString tmpStr; | 233 | QString tmpStr; |
232 | QStringList tmpStrList; | 234 | QStringList tmpStrList; |
233 | 235 | ||
234 | vtodo = newVObject(VCTodoProp); | 236 | vtodo = newVObject(VCTodoProp); |
235 | 237 | ||
236 | // due date | 238 | // due date |
237 | if (anEvent->hasDueDate()) { | 239 | if (anEvent->hasDueDate()) { |
238 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
239 | !anEvent->doesFloat()); | 241 | !anEvent->doesFloat()); |
240 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
241 | } | 243 | } |
242 | 244 | ||
243 | // start date | 245 | // start date |
244 | if (anEvent->hasStartDate()) { | 246 | if (anEvent->hasStartDate()) { |
245 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
246 | !anEvent->doesFloat()); | 248 | !anEvent->doesFloat()); |
247 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
248 | } | 250 | } |
249 | 251 | ||
250 | // creation date | 252 | // creation date |
251 | tmpStr = qDateTimeToISO(anEvent->created()); | 253 | tmpStr = qDateTimeToISO(anEvent->created()); |
252 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 254 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
253 | 255 | ||
254 | // unique id | 256 | // unique id |
255 | addPropValue(vtodo, VCUniqueStringProp, | 257 | addPropValue(vtodo, VCUniqueStringProp, |
256 | anEvent->uid().local8Bit()); | 258 | anEvent->uid().local8Bit()); |
257 | 259 | ||
258 | // revision | 260 | // revision |
259 | tmpStr.sprintf("%i", anEvent->revision()); | 261 | tmpStr.sprintf("%i", anEvent->revision()); |
260 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 262 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
261 | 263 | ||
262 | // last modification date | 264 | // last modification date |
263 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 265 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
264 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 266 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
265 | 267 | ||
266 | // organizer stuff | 268 | // organizer stuff |
267 | tmpStr = "MAILTO:" + anEvent->organizer(); | 269 | tmpStr = "MAILTO:" + anEvent->organizer(); |
268 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 270 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
269 | 271 | ||
270 | // attendees | 272 | // attendees |
271 | if (anEvent->attendeeCount() != 0) { | 273 | if (anEvent->attendeeCount() != 0) { |
272 | QPtrList<Attendee> al = anEvent->attendees(); | 274 | QPtrList<Attendee> al = anEvent->attendees(); |
273 | QPtrListIterator<Attendee> ai(al); | 275 | QPtrListIterator<Attendee> ai(al); |
274 | Attendee *curAttendee; | 276 | Attendee *curAttendee; |
275 | 277 | ||
276 | for (; ai.current(); ++ai) { | 278 | for (; ai.current(); ++ai) { |
277 | curAttendee = ai.current(); | 279 | curAttendee = ai.current(); |
278 | if (!curAttendee->email().isEmpty() && | 280 | if (!curAttendee->email().isEmpty() && |
279 | !curAttendee->name().isEmpty()) | 281 | !curAttendee->name().isEmpty()) |
280 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 282 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
281 | curAttendee->email() + ">"; | 283 | curAttendee->email() + ">"; |
282 | else if (curAttendee->name().isEmpty()) | 284 | else if (curAttendee->name().isEmpty()) |
283 | tmpStr = "MAILTO: " + curAttendee->email(); | 285 | tmpStr = "MAILTO: " + curAttendee->email(); |
284 | else if (curAttendee->email().isEmpty()) | 286 | else if (curAttendee->email().isEmpty()) |
285 | tmpStr = "MAILTO: " + curAttendee->name(); | 287 | tmpStr = "MAILTO: " + curAttendee->name(); |
286 | else if (curAttendee->name().isEmpty() && | 288 | else if (curAttendee->name().isEmpty() && |
287 | curAttendee->email().isEmpty()) | 289 | curAttendee->email().isEmpty()) |
288 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 290 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
289 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 291 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
290 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 292 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
291 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 293 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
292 | } | 294 | } |
293 | } | 295 | } |
294 | 296 | ||
295 | // description BL: | 297 | // description BL: |
296 | if (!anEvent->description().isEmpty()) { | 298 | if (!anEvent->description().isEmpty()) { |
297 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 299 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
298 | anEvent->description().local8Bit()); | 300 | anEvent->description().local8Bit()); |
299 | if (anEvent->description().find('\n') != -1) | 301 | if (anEvent->description().find('\n') != -1) |
300 | addProp(d, VCQuotedPrintableProp); | 302 | addProp(d, VCQuotedPrintableProp); |
301 | } | 303 | } |
302 | 304 | ||
303 | // summary | 305 | // summary |
304 | if (!anEvent->summary().isEmpty()) | 306 | if (!anEvent->summary().isEmpty()) |
305 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 307 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
306 | 308 | ||
307 | if (!anEvent->location().isEmpty()) | 309 | if (!anEvent->location().isEmpty()) |
308 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 310 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
309 | 311 | ||
310 | // completed | 312 | // completed |
311 | // status | 313 | // status |
312 | // backward compatibility, KOrganizer used to interpret only these two values | 314 | // backward compatibility, KOrganizer used to interpret only these two values |
313 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 315 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
314 | "NEEDS_ACTION"); | 316 | "NEEDS_ACTION"); |
315 | // completion date | 317 | // completion date |
316 | if (anEvent->hasCompletedDate()) { | 318 | if (anEvent->hasCompletedDate()) { |
317 | tmpStr = qDateTimeToISO(anEvent->completed()); | 319 | tmpStr = qDateTimeToISO(anEvent->completed()); |
318 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 320 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
319 | } | 321 | } |
320 | 322 | ||
321 | // priority | 323 | // priority |
322 | tmpStr.sprintf("%i",anEvent->priority()); | 324 | tmpStr.sprintf("%i",anEvent->priority()); |
323 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 325 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
324 | 326 | ||
325 | // related event | 327 | // related event |
326 | if (anEvent->relatedTo()) { | 328 | if (anEvent->relatedTo()) { |
327 | addPropValue(vtodo, VCRelatedToProp, | 329 | addPropValue(vtodo, VCRelatedToProp, |
328 | anEvent->relatedTo()->uid().local8Bit()); | 330 | anEvent->relatedTo()->uid().local8Bit()); |
329 | } | 331 | } |
330 | 332 | ||
331 | // categories | 333 | // categories |
332 | tmpStrList = anEvent->categories(); | 334 | tmpStrList = anEvent->categories(); |
333 | tmpStr = ""; | 335 | tmpStr = ""; |
334 | QString catStr; | 336 | QString catStr; |
335 | for ( QStringList::Iterator it = tmpStrList.begin(); | 337 | for ( QStringList::Iterator it = tmpStrList.begin(); |
336 | it != tmpStrList.end(); | 338 | it != tmpStrList.end(); |
337 | ++it ) { | 339 | ++it ) { |
338 | catStr = *it; | 340 | catStr = *it; |
339 | if (catStr[0] == ' ') | 341 | if (catStr[0] == ' ') |
340 | tmpStr += catStr.mid(1); | 342 | tmpStr += catStr.mid(1); |
341 | else | 343 | else |
342 | tmpStr += catStr; | 344 | tmpStr += catStr; |
343 | // this must be a ';' character as the vCalendar specification requires! | 345 | // this must be a ';' character as the vCalendar specification requires! |
344 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 346 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
345 | // read in. | 347 | // read in. |
346 | tmpStr += ";"; | 348 | tmpStr += ";"; |
347 | } | 349 | } |
348 | if (!tmpStr.isEmpty()) { | 350 | if (!tmpStr.isEmpty()) { |
349 | tmpStr.truncate(tmpStr.length()-1); | 351 | tmpStr.truncate(tmpStr.length()-1); |
@@ -919,795 +921,800 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
919 | // unique id | 921 | // unique id |
920 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 922 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
921 | // while the UID property is preferred, it is not required. We'll use the | 923 | // while the UID property is preferred, it is not required. We'll use the |
922 | // default Event UID if none is given. | 924 | // default Event UID if none is given. |
923 | if (vo) { | 925 | if (vo) { |
924 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 926 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
925 | deleteStr(s); | 927 | deleteStr(s); |
926 | } | 928 | } |
927 | 929 | ||
928 | // revision | 930 | // revision |
929 | // again NSCAL doesn't give us much to work with, so we improvise... | 931 | // again NSCAL doesn't give us much to work with, so we improvise... |
930 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 932 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
931 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 933 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
932 | deleteStr(s); | 934 | deleteStr(s); |
933 | } | 935 | } |
934 | else | 936 | else |
935 | anEvent->setRevision(0); | 937 | anEvent->setRevision(0); |
936 | 938 | ||
937 | // last modification date | 939 | // last modification date |
938 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 940 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
939 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 941 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
940 | deleteStr(s); | 942 | deleteStr(s); |
941 | } | 943 | } |
942 | else | 944 | else |
943 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 945 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
944 | QTime::currentTime())); | 946 | QTime::currentTime())); |
945 | 947 | ||
946 | // organizer | 948 | // organizer |
947 | // if our extension property for the event's ORGANIZER exists, add it. | 949 | // if our extension property for the event's ORGANIZER exists, add it. |
948 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 950 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
949 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 951 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
950 | deleteStr(s); | 952 | deleteStr(s); |
951 | } else { | 953 | } else { |
952 | anEvent->setOrganizer(mCalendar->getEmail()); | 954 | anEvent->setOrganizer(mCalendar->getEmail()); |
953 | } | 955 | } |
954 | 956 | ||
955 | // deal with attendees. | 957 | // deal with attendees. |
956 | initPropIterator(&voi, vevent); | 958 | initPropIterator(&voi, vevent); |
957 | while (moreIteration(&voi)) { | 959 | while (moreIteration(&voi)) { |
958 | vo = nextVObject(&voi); | 960 | vo = nextVObject(&voi); |
959 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 961 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
960 | Attendee *a; | 962 | Attendee *a; |
961 | VObject *vp; | 963 | VObject *vp; |
962 | s = fakeCString(vObjectUStringZValue(vo)); | 964 | s = fakeCString(vObjectUStringZValue(vo)); |
963 | QString tmpStr = QString::fromLocal8Bit(s); | 965 | QString tmpStr = QString::fromLocal8Bit(s); |
964 | deleteStr(s); | 966 | deleteStr(s); |
965 | tmpStr = tmpStr.simplifyWhiteSpace(); | 967 | tmpStr = tmpStr.simplifyWhiteSpace(); |
966 | int emailPos1, emailPos2; | 968 | int emailPos1, emailPos2; |
967 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 969 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
968 | // both email address and name | 970 | // both email address and name |
969 | emailPos2 = tmpStr.findRev('>'); | 971 | emailPos2 = tmpStr.findRev('>'); |
970 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 972 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
971 | tmpStr.mid(emailPos1 + 1, | 973 | tmpStr.mid(emailPos1 + 1, |
972 | emailPos2 - (emailPos1 + 1))); | 974 | emailPos2 - (emailPos1 + 1))); |
973 | } else if (tmpStr.find('@') > 0) { | 975 | } else if (tmpStr.find('@') > 0) { |
974 | // just an email address | 976 | // just an email address |
975 | a = new Attendee(0, tmpStr); | 977 | a = new Attendee(0, tmpStr); |
976 | } else { | 978 | } else { |
977 | // just a name | 979 | // just a name |
978 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 980 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
979 | a = new Attendee(tmpStr,email); | 981 | a = new Attendee(tmpStr,email); |
980 | } | 982 | } |
981 | 983 | ||
982 | // is there an RSVP property? | 984 | // is there an RSVP property? |
983 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 985 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
984 | a->setRSVP(vObjectStringZValue(vp)); | 986 | a->setRSVP(vObjectStringZValue(vp)); |
985 | // is there a status property? | 987 | // is there a status property? |
986 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 988 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
987 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 989 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
988 | // add the attendee | 990 | // add the attendee |
989 | anEvent->addAttendee(a); | 991 | anEvent->addAttendee(a); |
990 | } | 992 | } |
991 | } | 993 | } |
992 | 994 | ||
993 | // This isn't strictly true. An event that doesn't have a start time | 995 | // This isn't strictly true. An event that doesn't have a start time |
994 | // or an end time doesn't "float", it has an anchor in time but it doesn't | 996 | // or an end time doesn't "float", it has an anchor in time but it doesn't |
995 | // "take up" any time. | 997 | // "take up" any time. |
996 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || | 998 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || |
997 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { | 999 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { |
998 | anEvent->setFloats(TRUE); | 1000 | anEvent->setFloats(TRUE); |
999 | } else { | 1001 | } else { |
1000 | }*/ | 1002 | }*/ |
1001 | 1003 | ||
1002 | anEvent->setFloats(FALSE); | 1004 | anEvent->setFloats(FALSE); |
1003 | 1005 | ||
1004 | // start time | 1006 | // start time |
1005 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { | 1007 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { |
1006 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1008 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1007 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 1009 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
1008 | deleteStr(s); | 1010 | deleteStr(s); |
1009 | if (anEvent->dtStart().time().isNull()) | 1011 | if (anEvent->dtStart().time().isNull()) |
1010 | anEvent->setFloats(TRUE); | 1012 | anEvent->setFloats(TRUE); |
1011 | } | 1013 | } |
1012 | 1014 | ||
1013 | // stop time | 1015 | // stop time |
1014 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { | 1016 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { |
1015 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1017 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1016 | deleteStr(s); | 1018 | deleteStr(s); |
1017 | if (anEvent->dtEnd().time().isNull()) | 1019 | if (anEvent->dtEnd().time().isNull()) |
1018 | anEvent->setFloats(TRUE); | 1020 | anEvent->setFloats(TRUE); |
1019 | } | 1021 | } |
1020 | 1022 | ||
1021 | // at this point, there should be at least a start or end time. | 1023 | // at this point, there should be at least a start or end time. |
1022 | // fix up for events that take up no time but have a time associated | 1024 | // fix up for events that take up no time but have a time associated |
1023 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 1025 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
1024 | anEvent->setDtStart(anEvent->dtEnd()); | 1026 | anEvent->setDtStart(anEvent->dtEnd()); |
1025 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 1027 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
1026 | anEvent->setDtEnd(anEvent->dtStart()); | 1028 | anEvent->setDtEnd(anEvent->dtStart()); |
1027 | 1029 | ||
1028 | /////////////////////////////////////////////////////////////////////////// | 1030 | /////////////////////////////////////////////////////////////////////////// |
1029 | 1031 | ||
1030 | // repeat stuff | 1032 | // repeat stuff |
1031 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { | 1033 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { |
1032 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); | 1034 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); |
1033 | deleteStr(s); | 1035 | deleteStr(s); |
1034 | tmpStr.simplifyWhiteSpace(); | 1036 | tmpStr.simplifyWhiteSpace(); |
1035 | tmpStr = tmpStr.upper(); | 1037 | tmpStr = tmpStr.upper(); |
1036 | 1038 | ||
1037 | /********************************* DAILY ******************************/ | 1039 | /********************************* DAILY ******************************/ |
1038 | if (tmpStr.left(1) == "D") { | 1040 | if (tmpStr.left(1) == "D") { |
1039 | int index = tmpStr.find(' '); | 1041 | int index = tmpStr.find(' '); |
1040 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1042 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1041 | index = tmpStr.findRev(' ') + 1; // advance to last field | 1043 | index = tmpStr.findRev(' ') + 1; // advance to last field |
1042 | if (tmpStr.mid(index,1) == "#") index++; | 1044 | if (tmpStr.mid(index,1) == "#") index++; |
1043 | if (tmpStr.find('T', index) != -1) { | 1045 | if (tmpStr.find('T', index) != -1) { |
1044 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1046 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1045 | anEvent->recurrence()->setDaily(rFreq, rEndDate); | 1047 | anEvent->recurrence()->setDaily(rFreq, rEndDate); |
1046 | } else { | 1048 | } else { |
1047 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1049 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1048 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 | 1050 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 |
1049 | anEvent->recurrence()->setDaily(rFreq, -1); | 1051 | anEvent->recurrence()->setDaily(rFreq, -1); |
1050 | else | 1052 | else |
1051 | anEvent->recurrence()->setDaily(rFreq, rDuration); | 1053 | anEvent->recurrence()->setDaily(rFreq, rDuration); |
1052 | } | 1054 | } |
1053 | } | 1055 | } |
1054 | /********************************* WEEKLY ******************************/ | 1056 | /********************************* WEEKLY ******************************/ |
1055 | else if (tmpStr.left(1) == "W") { | 1057 | else if (tmpStr.left(1) == "W") { |
1056 | int index = tmpStr.find(' '); | 1058 | int index = tmpStr.find(' '); |
1057 | int last = tmpStr.findRev(' ') + 1; | 1059 | int last = tmpStr.findRev(' ') + 1; |
1058 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1060 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1059 | index += 1; // advance to beginning of stuff after freq | 1061 | index += 1; // advance to beginning of stuff after freq |
1060 | QBitArray qba(7); | 1062 | QBitArray qba(7); |
1061 | QString dayStr; | 1063 | QString dayStr; |
1062 | if( index == last ) { | 1064 | if( index == last ) { |
1063 | // e.g. W1 #0 | 1065 | // e.g. W1 #0 |
1064 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1066 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1065 | } | 1067 | } |
1066 | else { | 1068 | else { |
1067 | // e.g. W1 SU #0 | 1069 | // e.g. W1 SU #0 |
1068 | while (index < last) { | 1070 | while (index < last) { |
1069 | dayStr = tmpStr.mid(index, 3); | 1071 | dayStr = tmpStr.mid(index, 3); |
1070 | int dayNum = numFromDay(dayStr); | 1072 | int dayNum = numFromDay(dayStr); |
1071 | qba.setBit(dayNum); | 1073 | qba.setBit(dayNum); |
1072 | index += 3; // advance to next day, or possibly "#" | 1074 | index += 3; // advance to next day, or possibly "#" |
1073 | } | 1075 | } |
1074 | } | 1076 | } |
1075 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1077 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1076 | if (tmpStr.find('T', index) != -1) { | 1078 | if (tmpStr.find('T', index) != -1) { |
1077 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1079 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1078 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); | 1080 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); |
1079 | } else { | 1081 | } else { |
1080 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1082 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1081 | if (rDuration == 0) | 1083 | if (rDuration == 0) |
1082 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); | 1084 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); |
1083 | else | 1085 | else |
1084 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); | 1086 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); |
1085 | } | 1087 | } |
1086 | } | 1088 | } |
1087 | /**************************** MONTHLY-BY-POS ***************************/ | 1089 | /**************************** MONTHLY-BY-POS ***************************/ |
1088 | else if (tmpStr.left(2) == "MP") { | 1090 | else if (tmpStr.left(2) == "MP") { |
1089 | int index = tmpStr.find(' '); | 1091 | int index = tmpStr.find(' '); |
1090 | int last = tmpStr.findRev(' ') + 1; | 1092 | int last = tmpStr.findRev(' ') + 1; |
1091 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1093 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1092 | index += 1; // advance to beginning of stuff after freq | 1094 | index += 1; // advance to beginning of stuff after freq |
1093 | QBitArray qba(7); | 1095 | QBitArray qba(7); |
1094 | short tmpPos; | 1096 | short tmpPos; |
1095 | if( index == last ) { | 1097 | if( index == last ) { |
1096 | // e.g. MP1 #0 | 1098 | // e.g. MP1 #0 |
1097 | tmpPos = anEvent->dtStart().date().day()/7 + 1; | 1099 | tmpPos = anEvent->dtStart().date().day()/7 + 1; |
1098 | if( tmpPos == 5 ) | 1100 | if( tmpPos == 5 ) |
1099 | tmpPos = -1; | 1101 | tmpPos = -1; |
1100 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1102 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1101 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1103 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1102 | } | 1104 | } |
1103 | else { | 1105 | else { |
1104 | // e.g. MP1 1+ SU #0 | 1106 | // e.g. MP1 1+ SU #0 |
1105 | while (index < last) { | 1107 | while (index < last) { |
1106 | tmpPos = tmpStr.mid(index,1).toShort(); | 1108 | tmpPos = tmpStr.mid(index,1).toShort(); |
1107 | index += 1; | 1109 | index += 1; |
1108 | if (tmpStr.mid(index,1) == "-") | 1110 | if (tmpStr.mid(index,1) == "-") |
1109 | // convert tmpPos to negative | 1111 | // convert tmpPos to negative |
1110 | tmpPos = 0 - tmpPos; | 1112 | tmpPos = 0 - tmpPos; |
1111 | index += 2; // advance to day(s) | 1113 | index += 2; // advance to day(s) |
1112 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { | 1114 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { |
1113 | int dayNum = numFromDay(tmpStr.mid(index,3)); | 1115 | int dayNum = numFromDay(tmpStr.mid(index,3)); |
1114 | qba.setBit(dayNum); | 1116 | qba.setBit(dayNum); |
1115 | index += 3; // advance to next day, or possibly pos or "#" | 1117 | index += 3; // advance to next day, or possibly pos or "#" |
1116 | } | 1118 | } |
1117 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1119 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1118 | qba.detach(); | 1120 | qba.detach(); |
1119 | qba.fill(FALSE); // clear out | 1121 | qba.fill(FALSE); // clear out |
1120 | } // while != "#" | 1122 | } // while != "#" |
1121 | } | 1123 | } |
1122 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1124 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1123 | if (tmpStr.find('T', index) != -1) { | 1125 | if (tmpStr.find('T', index) != -1) { |
1124 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - | 1126 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - |
1125 | index))).date(); | 1127 | index))).date(); |
1126 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); | 1128 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); |
1127 | } else { | 1129 | } else { |
1128 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1130 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1129 | if (rDuration == 0) | 1131 | if (rDuration == 0) |
1130 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); | 1132 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); |
1131 | else | 1133 | else |
1132 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); | 1134 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); |
1133 | } | 1135 | } |
1134 | } | 1136 | } |
1135 | 1137 | ||
1136 | /**************************** MONTHLY-BY-DAY ***************************/ | 1138 | /**************************** MONTHLY-BY-DAY ***************************/ |
1137 | else if (tmpStr.left(2) == "MD") { | 1139 | else if (tmpStr.left(2) == "MD") { |
1138 | int index = tmpStr.find(' '); | 1140 | int index = tmpStr.find(' '); |
1139 | int last = tmpStr.findRev(' ') + 1; | 1141 | int last = tmpStr.findRev(' ') + 1; |
1140 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1142 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1141 | index += 1; | 1143 | index += 1; |
1142 | short tmpDay; | 1144 | short tmpDay; |
1143 | if( index == last ) { | 1145 | if( index == last ) { |
1144 | // e.g. MD1 #0 | 1146 | // e.g. MD1 #0 |
1145 | tmpDay = anEvent->dtStart().date().day(); | 1147 | tmpDay = anEvent->dtStart().date().day(); |
1146 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1148 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1147 | } | 1149 | } |
1148 | else { | 1150 | else { |
1149 | // e.g. MD1 3 #0 | 1151 | // e.g. MD1 3 #0 |
1150 | while (index < last) { | 1152 | while (index < last) { |
1151 | int index2 = tmpStr.find(' ', index); | 1153 | int index2 = tmpStr.find(' ', index); |
1152 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1154 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1153 | index = index2-1; | 1155 | index = index2-1; |
1154 | if (tmpStr.mid(index, 1) == "-") | 1156 | if (tmpStr.mid(index, 1) == "-") |
1155 | tmpDay = 0 - tmpDay; | 1157 | tmpDay = 0 - tmpDay; |
1156 | index += 2; // advance the index; | 1158 | index += 2; // advance the index; |
1157 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1159 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1158 | } // while != # | 1160 | } // while != # |
1159 | } | 1161 | } |
1160 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1162 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1161 | if (tmpStr.find('T', index) != -1) { | 1163 | if (tmpStr.find('T', index) != -1) { |
1162 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1164 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1163 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); | 1165 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); |
1164 | } else { | 1166 | } else { |
1165 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1167 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1166 | if (rDuration == 0) | 1168 | if (rDuration == 0) |
1167 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); | 1169 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); |
1168 | else | 1170 | else |
1169 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); | 1171 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); |
1170 | } | 1172 | } |
1171 | } | 1173 | } |
1172 | 1174 | ||
1173 | /*********************** YEARLY-BY-MONTH *******************************/ | 1175 | /*********************** YEARLY-BY-MONTH *******************************/ |
1174 | else if (tmpStr.left(2) == "YM") { | 1176 | else if (tmpStr.left(2) == "YM") { |
1175 | int index = tmpStr.find(' '); | 1177 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); |
1176 | int last = tmpStr.findRev(' ') + 1; | 1178 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); |
1177 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1179 | int index = tmpStr.find(' '); |
1178 | index += 1; | 1180 | int last = tmpStr.findRev(' ') + 1; |
1179 | short tmpMonth; | 1181 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1180 | if( index == last ) { | 1182 | index += 1; |
1181 | // e.g. YM1 #0 | 1183 | short tmpMonth; |
1182 | tmpMonth = anEvent->dtStart().date().month(); | 1184 | if( index == last ) { |
1183 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1185 | // e.g. YM1 #0 |
1184 | } | 1186 | tmpMonth = anEvent->dtStart().date().month(); |
1185 | else { | 1187 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1186 | // e.g. YM1 3 #0 | 1188 | } |
1187 | while (index < last) { | 1189 | else { |
1188 | int index2 = tmpStr.find(' ', index); | 1190 | // e.g. YM1 3 #0 |
1189 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); | 1191 | while (index < last) { |
1190 | index = index2+1; | 1192 | int index2 = tmpStr.find(' ', index); |
1191 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1193 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); |
1192 | } // while != # | 1194 | index = index2+1; |
1193 | } | 1195 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1194 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1196 | } // while != # |
1195 | if (tmpStr.find('T', index) != -1) { | 1197 | } |
1196 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1198 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1197 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); | 1199 | if (tmpStr.find('T', index) != -1) { |
1198 | } else { | 1200 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1199 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); |
1200 | if (rDuration == 0) | 1202 | } else { |
1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); | 1203 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1202 | else | 1204 | if (rDuration == 0) |
1203 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | 1205 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); |
1204 | } | 1206 | else |
1207 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | ||
1208 | } | ||
1205 | } | 1209 | } |
1206 | 1210 | ||
1207 | /*********************** YEARLY-BY-DAY *********************************/ | 1211 | /*********************** YEARLY-BY-DAY *********************************/ |
1208 | else if (tmpStr.left(2) == "YD") { | 1212 | else if (tmpStr.left(2) == "YD") { |
1209 | int index = tmpStr.find(' '); | 1213 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); |
1210 | int last = tmpStr.findRev(' ') + 1; | 1214 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); |
1211 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1215 | int index = tmpStr.find(' '); |
1212 | index += 1; | 1216 | int last = tmpStr.findRev(' ') + 1; |
1213 | short tmpDay; | 1217 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1214 | if( index == last ) { | 1218 | index += 1; |
1215 | // e.g. YD1 #0 | 1219 | short tmpDay; |
1216 | tmpDay = anEvent->dtStart().date().dayOfYear(); | 1220 | if( index == last ) { |
1217 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1221 | // e.g. YD1 #0 |
1218 | } | 1222 | tmpDay = anEvent->dtStart().date().dayOfYear(); |
1219 | else { | 1223 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1220 | // e.g. YD1 123 #0 | 1224 | } |
1221 | while (index < last) { | 1225 | else { |
1222 | int index2 = tmpStr.find(' ', index); | 1226 | // e.g. YD1 123 #0 |
1223 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1227 | while (index < last) { |
1224 | index = index2+1; | 1228 | int index2 = tmpStr.find(' ', index); |
1225 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1229 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1226 | } // while != # | 1230 | index = index2+1; |
1227 | } | 1231 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1228 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1232 | } // while != # |
1229 | if (tmpStr.find('T', index) != -1) { | 1233 | } |
1230 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1234 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1231 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1235 | if (tmpStr.find('T', index) != -1) { |
1232 | } else { | 1236 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1233 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1237 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1234 | if (rDuration == 0) | 1238 | } else { |
1235 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1239 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1236 | else | 1240 | if (rDuration == 0) |
1237 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1241 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1238 | } | 1242 | else |
1243 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | ||
1244 | } | ||
1239 | } else { | 1245 | } else { |
1240 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1246 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1241 | } // if | 1247 | } // if |
1242 | } // repeats | 1248 | } // repeats |
1243 | 1249 | ||
1244 | 1250 | ||
1245 | // recurrence exceptions | 1251 | // recurrence exceptions |
1246 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { | 1252 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1247 | s = fakeCString(vObjectUStringZValue(vo)); | 1253 | s = fakeCString(vObjectUStringZValue(vo)); |
1248 | QStringList exDates = QStringList::split(",",s); | 1254 | QStringList exDates = QStringList::split(",",s); |
1249 | QStringList::ConstIterator it; | 1255 | QStringList::ConstIterator it; |
1250 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1256 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1251 | anEvent->addExDate(ISOToQDate(*it)); | 1257 | anEvent->addExDate(ISOToQDate(*it)); |
1252 | } | 1258 | } |
1253 | deleteStr(s); | 1259 | deleteStr(s); |
1254 | } | 1260 | } |
1255 | 1261 | ||
1256 | // summary | 1262 | // summary |
1257 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1263 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1258 | s = fakeCString(vObjectUStringZValue(vo)); | 1264 | s = fakeCString(vObjectUStringZValue(vo)); |
1259 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1265 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1260 | deleteStr(s); | 1266 | deleteStr(s); |
1261 | } | 1267 | } |
1262 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1268 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1263 | s = fakeCString(vObjectUStringZValue(vo)); | 1269 | s = fakeCString(vObjectUStringZValue(vo)); |
1264 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1270 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1265 | deleteStr(s); | 1271 | deleteStr(s); |
1266 | } | 1272 | } |
1267 | 1273 | ||
1268 | // description | 1274 | // description |
1269 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1275 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1270 | s = fakeCString(vObjectUStringZValue(vo)); | 1276 | s = fakeCString(vObjectUStringZValue(vo)); |
1271 | if (!anEvent->description().isEmpty()) { | 1277 | if (!anEvent->description().isEmpty()) { |
1272 | anEvent->setDescription(anEvent->description() + "\n" + | 1278 | anEvent->setDescription(anEvent->description() + "\n" + |
1273 | QString::fromLocal8Bit(s)); | 1279 | QString::fromLocal8Bit(s)); |
1274 | } else { | 1280 | } else { |
1275 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1281 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1276 | } | 1282 | } |
1277 | deleteStr(s); | 1283 | deleteStr(s); |
1278 | } | 1284 | } |
1279 | 1285 | ||
1280 | // some stupid vCal exporters ignore the standard and use Description | 1286 | // some stupid vCal exporters ignore the standard and use Description |
1281 | // instead of Summary for the default field. Correct for this. | 1287 | // instead of Summary for the default field. Correct for this. |
1282 | if (anEvent->summary().isEmpty() && | 1288 | if (anEvent->summary().isEmpty() && |
1283 | !(anEvent->description().isEmpty())) { | 1289 | !(anEvent->description().isEmpty())) { |
1284 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); | 1290 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); |
1285 | anEvent->setDescription(""); | 1291 | anEvent->setDescription(""); |
1286 | anEvent->setSummary(tmpStr); | 1292 | anEvent->setSummary(tmpStr); |
1287 | } | 1293 | } |
1288 | 1294 | ||
1289 | #if 0 | 1295 | #if 0 |
1290 | // status | 1296 | // status |
1291 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { | 1297 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { |
1292 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); | 1298 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); |
1293 | deleteStr(s); | 1299 | deleteStr(s); |
1294 | // TODO: Define Event status | 1300 | // TODO: Define Event status |
1295 | // anEvent->setStatus(tmpStr); | 1301 | // anEvent->setStatus(tmpStr); |
1296 | } | 1302 | } |
1297 | else | 1303 | else |
1298 | // anEvent->setStatus("NEEDS ACTION"); | 1304 | // anEvent->setStatus("NEEDS ACTION"); |
1299 | #endif | 1305 | #endif |
1300 | 1306 | ||
1301 | // secrecy | 1307 | // secrecy |
1302 | int secrecy = Incidence::SecrecyPublic; | 1308 | int secrecy = Incidence::SecrecyPublic; |
1303 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 1309 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
1304 | s = fakeCString(vObjectUStringZValue(vo)); | 1310 | s = fakeCString(vObjectUStringZValue(vo)); |
1305 | if (strcmp(s,"PRIVATE") == 0) { | 1311 | if (strcmp(s,"PRIVATE") == 0) { |
1306 | secrecy = Incidence::SecrecyPrivate; | 1312 | secrecy = Incidence::SecrecyPrivate; |
1307 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { | 1313 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { |
1308 | secrecy = Incidence::SecrecyConfidential; | 1314 | secrecy = Incidence::SecrecyConfidential; |
1309 | } | 1315 | } |
1310 | deleteStr(s); | 1316 | deleteStr(s); |
1311 | } | 1317 | } |
1312 | anEvent->setSecrecy(secrecy); | 1318 | anEvent->setSecrecy(secrecy); |
1313 | 1319 | ||
1314 | // categories | 1320 | // categories |
1315 | QStringList tmpStrList; | 1321 | QStringList tmpStrList; |
1316 | int index1 = 0; | 1322 | int index1 = 0; |
1317 | int index2 = 0; | 1323 | int index2 = 0; |
1318 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { | 1324 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { |
1319 | s = fakeCString(vObjectUStringZValue(vo)); | 1325 | s = fakeCString(vObjectUStringZValue(vo)); |
1320 | QString categories = QString::fromLocal8Bit(s); | 1326 | QString categories = QString::fromLocal8Bit(s); |
1321 | deleteStr(s); | 1327 | deleteStr(s); |
1322 | //const char* category; | 1328 | //const char* category; |
1323 | QString category; | 1329 | QString category; |
1324 | while ((index2 = categories.find(',', index1)) != -1) { | 1330 | while ((index2 = categories.find(',', index1)) != -1) { |
1325 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 1331 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
1326 | category = categories.mid(index1, (index2 - index1)); | 1332 | category = categories.mid(index1, (index2 - index1)); |
1327 | tmpStrList.append(category); | 1333 | tmpStrList.append(category); |
1328 | index1 = index2+1; | 1334 | index1 = index2+1; |
1329 | } | 1335 | } |
1330 | // get last category | 1336 | // get last category |
1331 | category = categories.mid(index1, (categories.length()-index1)); | 1337 | category = categories.mid(index1, (categories.length()-index1)); |
1332 | tmpStrList.append(category); | 1338 | tmpStrList.append(category); |
1333 | anEvent->setCategories(tmpStrList); | 1339 | anEvent->setCategories(tmpStrList); |
1334 | } | 1340 | } |
1335 | 1341 | ||
1336 | // attachments | 1342 | // attachments |
1337 | tmpStrList.clear(); | 1343 | tmpStrList.clear(); |
1338 | initPropIterator(&voi, vevent); | 1344 | initPropIterator(&voi, vevent); |
1339 | while (moreIteration(&voi)) { | 1345 | while (moreIteration(&voi)) { |
1340 | vo = nextVObject(&voi); | 1346 | vo = nextVObject(&voi); |
1341 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 1347 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
1342 | s = fakeCString(vObjectUStringZValue(vo)); | 1348 | s = fakeCString(vObjectUStringZValue(vo)); |
1343 | anEvent->addAttachment(new Attachment(QString(s))); | 1349 | anEvent->addAttachment(new Attachment(QString(s))); |
1344 | deleteStr(s); | 1350 | deleteStr(s); |
1345 | } | 1351 | } |
1346 | } | 1352 | } |
1347 | 1353 | ||
1348 | // resources | 1354 | // resources |
1349 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 1355 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
1350 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 1356 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
1351 | deleteStr(s); | 1357 | deleteStr(s); |
1352 | tmpStrList.clear(); | 1358 | tmpStrList.clear(); |
1353 | index1 = 0; | 1359 | index1 = 0; |
1354 | index2 = 0; | 1360 | index2 = 0; |
1355 | QString resource; | 1361 | QString resource; |
1356 | while ((index2 = resources.find(';', index1)) != -1) { | 1362 | while ((index2 = resources.find(';', index1)) != -1) { |
1357 | resource = resources.mid(index1, (index2 - index1)); | 1363 | resource = resources.mid(index1, (index2 - index1)); |
1358 | tmpStrList.append(resource); | 1364 | tmpStrList.append(resource); |
1359 | index1 = index2; | 1365 | index1 = index2; |
1360 | } | 1366 | } |
1361 | anEvent->setResources(tmpStrList); | 1367 | anEvent->setResources(tmpStrList); |
1362 | } | 1368 | } |
1363 | 1369 | ||
1364 | /* alarm stuff */ | 1370 | /* alarm stuff */ |
1365 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { | 1371 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { |
1366 | Alarm* alarm = anEvent->newAlarm(); | 1372 | Alarm* alarm = anEvent->newAlarm(); |
1367 | VObject *a; | 1373 | VObject *a; |
1368 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 1374 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
1369 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 1375 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
1370 | deleteStr(s); | 1376 | deleteStr(s); |
1371 | } | 1377 | } |
1372 | alarm->setEnabled(true); | 1378 | alarm->setEnabled(true); |
1373 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1379 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1374 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1380 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1375 | s = fakeCString(vObjectUStringZValue(a)); | 1381 | s = fakeCString(vObjectUStringZValue(a)); |
1376 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1382 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1377 | deleteStr(s); | 1383 | deleteStr(s); |
1378 | } | 1384 | } |
1379 | } | 1385 | } |
1380 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1386 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1381 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1387 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1382 | s = fakeCString(vObjectUStringZValue(a)); | 1388 | s = fakeCString(vObjectUStringZValue(a)); |
1383 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1389 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1384 | deleteStr(s); | 1390 | deleteStr(s); |
1385 | } | 1391 | } |
1386 | } | 1392 | } |
1387 | } | 1393 | } |
1388 | 1394 | ||
1389 | // priority | 1395 | // priority |
1390 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1396 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1391 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1397 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1392 | deleteStr(s); | 1398 | deleteStr(s); |
1393 | } | 1399 | } |
1394 | 1400 | ||
1395 | // transparency | 1401 | // transparency |
1396 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1402 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1397 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1403 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1398 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1404 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1399 | deleteStr(s); | 1405 | deleteStr(s); |
1400 | } | 1406 | } |
1401 | 1407 | ||
1402 | // related event | 1408 | // related event |
1403 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1409 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1404 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1410 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1405 | deleteStr(s); | 1411 | deleteStr(s); |
1406 | mEventsRelate.append(anEvent); | 1412 | mEventsRelate.append(anEvent); |
1407 | } | 1413 | } |
1408 | 1414 | ||
1409 | /* PILOT SYNC STUFF */ | 1415 | /* PILOT SYNC STUFF */ |
1410 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1416 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1411 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1417 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1412 | deleteStr(s); | 1418 | deleteStr(s); |
1413 | } | 1419 | } |
1414 | else | 1420 | else |
1415 | anEvent->setPilotId(0); | 1421 | anEvent->setPilotId(0); |
1416 | 1422 | ||
1417 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1423 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1418 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1424 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1419 | deleteStr(s); | 1425 | deleteStr(s); |
1420 | } | 1426 | } |
1421 | else | 1427 | else |
1422 | anEvent->setSyncStatus(Event::SYNCMOD); | 1428 | anEvent->setSyncStatus(Event::SYNCMOD); |
1423 | 1429 | ||
1424 | return anEvent; | 1430 | return anEvent; |
1425 | } | 1431 | } |
1426 | 1432 | ||
1427 | 1433 | ||
1428 | QString VCalFormat::qDateToISO(const QDate &qd) | 1434 | QString VCalFormat::qDateToISO(const QDate &qd) |
1429 | { | 1435 | { |
1430 | QString tmpStr; | 1436 | QString tmpStr; |
1431 | 1437 | ||
1432 | ASSERT(qd.isValid()); | 1438 | ASSERT(qd.isValid()); |
1433 | 1439 | ||
1434 | tmpStr.sprintf("%.2d%.2d%.2d", | 1440 | tmpStr.sprintf("%.2d%.2d%.2d", |
1435 | qd.year(), qd.month(), qd.day()); | 1441 | qd.year(), qd.month(), qd.day()); |
1436 | return tmpStr; | 1442 | return tmpStr; |
1437 | 1443 | ||
1438 | } | 1444 | } |
1439 | 1445 | ||
1440 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1446 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1441 | { | 1447 | { |
1442 | QString tmpStr; | 1448 | QString tmpStr; |
1443 | 1449 | ||
1444 | ASSERT(qdt.date().isValid()); | 1450 | ASSERT(qdt.date().isValid()); |
1445 | ASSERT(qdt.time().isValid()); | 1451 | ASSERT(qdt.time().isValid()); |
1446 | if (zulu && !useLocalTime ) { | 1452 | if (zulu && !useLocalTime ) { |
1447 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); | 1453 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1448 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1454 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1449 | tmpDT.date().year(), tmpDT.date().month(), | 1455 | tmpDT.date().year(), tmpDT.date().month(), |
1450 | tmpDT.date().day(), tmpDT.time().hour(), | 1456 | tmpDT.date().day(), tmpDT.time().hour(), |
1451 | tmpDT.time().minute(), tmpDT.time().second()); | 1457 | tmpDT.time().minute(), tmpDT.time().second()); |
1452 | } else { | 1458 | } else { |
1453 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1459 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1454 | qdt.date().year(), qdt.date().month(), | 1460 | qdt.date().year(), qdt.date().month(), |
1455 | qdt.date().day(), qdt.time().hour(), | 1461 | qdt.date().day(), qdt.time().hour(), |
1456 | qdt.time().minute(), qdt.time().second()); | 1462 | qdt.time().minute(), qdt.time().second()); |
1457 | } | 1463 | } |
1458 | return tmpStr; | 1464 | return tmpStr; |
1459 | } | 1465 | } |
1460 | 1466 | ||
1461 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1467 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) |
1462 | { | 1468 | { |
1463 | QDate tmpDate; | 1469 | QDate tmpDate; |
1464 | QTime tmpTime; | 1470 | QTime tmpTime; |
1465 | QString tmpStr; | 1471 | QString tmpStr; |
1466 | int year, month, day, hour, minute, second; | 1472 | int year, month, day, hour, minute, second; |
1467 | 1473 | ||
1468 | tmpStr = dtStr; | 1474 | tmpStr = dtStr; |
1469 | year = tmpStr.left(4).toInt(); | 1475 | year = tmpStr.left(4).toInt(); |
1470 | month = tmpStr.mid(4,2).toInt(); | 1476 | month = tmpStr.mid(4,2).toInt(); |
1471 | day = tmpStr.mid(6,2).toInt(); | 1477 | day = tmpStr.mid(6,2).toInt(); |
1472 | hour = tmpStr.mid(9,2).toInt(); | 1478 | hour = tmpStr.mid(9,2).toInt(); |
1473 | minute = tmpStr.mid(11,2).toInt(); | 1479 | minute = tmpStr.mid(11,2).toInt(); |
1474 | second = tmpStr.mid(13,2).toInt(); | 1480 | second = tmpStr.mid(13,2).toInt(); |
1475 | tmpDate.setYMD(year, month, day); | 1481 | tmpDate.setYMD(year, month, day); |
1476 | tmpTime.setHMS(hour, minute, second); | 1482 | tmpTime.setHMS(hour, minute, second); |
1477 | 1483 | ||
1478 | ASSERT(tmpDate.isValid()); | 1484 | ASSERT(tmpDate.isValid()); |
1479 | ASSERT(tmpTime.isValid()); | 1485 | ASSERT(tmpTime.isValid()); |
1480 | QDateTime tmpDT(tmpDate, tmpTime); | 1486 | QDateTime tmpDT(tmpDate, tmpTime); |
1481 | // correct for GMT if string is in Zulu format | 1487 | // correct for GMT if string is in Zulu format |
1482 | if (dtStr.at(dtStr.length()-1) == 'Z') | 1488 | if (dtStr.at(dtStr.length()-1) == 'Z') |
1483 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); | 1489 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); |
1484 | return tmpDT; | 1490 | return tmpDT; |
1485 | } | 1491 | } |
1486 | 1492 | ||
1487 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1493 | QDate VCalFormat::ISOToQDate(const QString &dateStr) |
1488 | { | 1494 | { |
1489 | int year, month, day; | 1495 | int year, month, day; |
1490 | 1496 | ||
1491 | year = dateStr.left(4).toInt(); | 1497 | year = dateStr.left(4).toInt(); |
1492 | month = dateStr.mid(4,2).toInt(); | 1498 | month = dateStr.mid(4,2).toInt(); |
1493 | day = dateStr.mid(6,2).toInt(); | 1499 | day = dateStr.mid(6,2).toInt(); |
1494 | 1500 | ||
1495 | return(QDate(year, month, day)); | 1501 | return(QDate(year, month, day)); |
1496 | } | 1502 | } |
1497 | 1503 | ||
1498 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1504 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1499 | // and break it down from it's tree-like format into the dictionary format | 1505 | // and break it down from it's tree-like format into the dictionary format |
1500 | // that is used internally in the VCalFormat. | 1506 | // that is used internally in the VCalFormat. |
1501 | void VCalFormat::populate(VObject *vcal) | 1507 | void VCalFormat::populate(VObject *vcal) |
1502 | { | 1508 | { |
1503 | // this function will populate the caldict dictionary and other event | 1509 | // this function will populate the caldict dictionary and other event |
1504 | // lists. It turns vevents into Events and then inserts them. | 1510 | // lists. It turns vevents into Events and then inserts them. |
1505 | 1511 | ||
1506 | VObjectIterator i; | 1512 | VObjectIterator i; |
1507 | VObject *curVO, *curVOProp; | 1513 | VObject *curVO, *curVOProp; |
1508 | Event *anEvent; | 1514 | Event *anEvent; |
1509 | 1515 | ||
1510 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1516 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1511 | char *methodType = 0; | 1517 | char *methodType = 0; |
1512 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1518 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1513 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1519 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1514 | << methodType << "'" << endl; | 1520 | << methodType << "'" << endl; |
1515 | delete methodType; | 1521 | delete methodType; |
1516 | } | 1522 | } |
1517 | 1523 | ||
1518 | // warn the user that we might have trouble reading non-known calendar. | 1524 | // warn the user that we might have trouble reading non-known calendar. |
1519 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1525 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1520 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1526 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1521 | if (strcmp(productId().local8Bit(), s) != 0) | 1527 | if (strcmp(productId().local8Bit(), s) != 0) |
1522 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1528 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1523 | "or any other product we support. Loading anyway..." << endl; | 1529 | "or any other product we support. Loading anyway..." << endl; |
1524 | mLoadedProductId = s; | 1530 | mLoadedProductId = s; |
1525 | deleteStr(s); | 1531 | deleteStr(s); |
1526 | } | 1532 | } |
1527 | 1533 | ||
1528 | // warn the user we might have trouble reading this unknown version. | 1534 | // warn the user we might have trouble reading this unknown version. |
1529 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1535 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1530 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1536 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1531 | if (strcmp(_VCAL_VERSION, s) != 0) | 1537 | if (strcmp(_VCAL_VERSION, s) != 0) |
1532 | kdDebug() << "This vCalendar file has version " << s | 1538 | kdDebug() << "This vCalendar file has version " << s |
1533 | << "We only support " << _VCAL_VERSION << endl; | 1539 | << "We only support " << _VCAL_VERSION << endl; |
1534 | deleteStr(s); | 1540 | deleteStr(s); |
1535 | } | 1541 | } |
1536 | 1542 | ||
1537 | // set the time zone | 1543 | // set the time zone |
1538 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1544 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1539 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1545 | if ( vObjectUStringZValue(curVO) != 0 ) { |
1540 | mCalendar->setTimeZone(s); | 1546 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1541 | deleteStr(s); | 1547 | mCalendar->setTimeZone(s); |
1548 | deleteStr(s); | ||
1549 | } | ||
1542 | } | 1550 | } |
1543 | 1551 | ||
1544 | |||
1545 | // Store all events with a relatedTo property in a list for post-processing | 1552 | // Store all events with a relatedTo property in a list for post-processing |
1546 | mEventsRelate.clear(); | 1553 | mEventsRelate.clear(); |
1547 | mTodosRelate.clear(); | 1554 | mTodosRelate.clear(); |
1548 | 1555 | ||
1549 | initPropIterator(&i, vcal); | 1556 | initPropIterator(&i, vcal); |
1550 | 1557 | ||
1551 | // go through all the vobjects in the vcal | 1558 | // go through all the vobjects in the vcal |
1552 | while (moreIteration(&i)) { | 1559 | while (moreIteration(&i)) { |
1553 | curVO = nextVObject(&i); | 1560 | curVO = nextVObject(&i); |
1554 | 1561 | ||
1555 | /************************************************************************/ | 1562 | /************************************************************************/ |
1556 | 1563 | ||
1557 | // now, check to see that the object is an event or todo. | 1564 | // now, check to see that the object is an event or todo. |
1558 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1565 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1559 | 1566 | ||
1560 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1567 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1561 | char *s; | 1568 | char *s; |
1562 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1569 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1563 | // check to see if event was deleted by the kpilot conduit | 1570 | // check to see if event was deleted by the kpilot conduit |
1564 | if (atoi(s) == Event::SYNCDEL) { | 1571 | if (atoi(s) == Event::SYNCDEL) { |
1565 | deleteStr(s); | 1572 | deleteStr(s); |
1566 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1573 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1567 | goto SKIP; | 1574 | goto SKIP; |
1568 | } | 1575 | } |
1569 | deleteStr(s); | 1576 | deleteStr(s); |
1570 | } | 1577 | } |
1571 | 1578 | ||
1572 | // this code checks to see if we are trying to read in an event | 1579 | // this code checks to see if we are trying to read in an event |
1573 | // that we already find to be in the calendar. If we find this | 1580 | // that we already find to be in the calendar. If we find this |
1574 | // to be the case, we skip the event. | 1581 | // to be the case, we skip the event. |
1575 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1582 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1576 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1583 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1577 | QString tmpStr(s); | 1584 | QString tmpStr(s); |
1578 | deleteStr(s); | 1585 | deleteStr(s); |
1579 | 1586 | ||
1580 | if (mCalendar->event(tmpStr)) { | 1587 | if (mCalendar->event(tmpStr)) { |
1581 | goto SKIP; | 1588 | goto SKIP; |
1582 | } | 1589 | } |
1583 | if (mCalendar->todo(tmpStr)) { | 1590 | if (mCalendar->todo(tmpStr)) { |
1584 | goto SKIP; | 1591 | goto SKIP; |
1585 | } | 1592 | } |
1586 | } | 1593 | } |
1587 | 1594 | ||
1588 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1595 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1589 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1596 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1590 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1597 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1591 | goto SKIP; | 1598 | goto SKIP; |
1592 | } | 1599 | } |
1593 | 1600 | ||
1594 | anEvent = VEventToEvent(curVO); | 1601 | anEvent = VEventToEvent(curVO); |
1595 | // we now use addEvent instead of insertEvent so that the | 1602 | // we now use addEvent instead of insertEvent so that the |
1596 | // signal/slot get connected. | 1603 | // signal/slot get connected. |
1597 | if (anEvent) { | 1604 | if (anEvent) { |
1598 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1605 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1599 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1606 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1600 | << endl; | 1607 | << endl; |
1601 | } else { | 1608 | } else { |
1602 | mCalendar->addEvent(anEvent); | 1609 | mCalendar->addEvent(anEvent); |
1603 | } | 1610 | } |
1604 | } else { | 1611 | } else { |
1605 | // some sort of error must have occurred while in translation. | 1612 | // some sort of error must have occurred while in translation. |
1606 | goto SKIP; | 1613 | goto SKIP; |
1607 | } | 1614 | } |
1608 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1615 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1609 | Todo *aTodo = VTodoToEvent(curVO); | 1616 | Todo *aTodo = VTodoToEvent(curVO); |
1610 | mCalendar->addTodo(aTodo); | 1617 | mCalendar->addTodo(aTodo); |
1611 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1618 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1612 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1619 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1613 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1620 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1614 | // do nothing, we know these properties and we want to skip them. | 1621 | // do nothing, we know these properties and we want to skip them. |
1615 | // we have either already processed them or are ignoring them. | 1622 | // we have either already processed them or are ignoring them. |
1616 | ; | 1623 | ; |
1617 | } else { | 1624 | } else { |
1618 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1625 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1619 | } | 1626 | } |
1620 | SKIP: | 1627 | SKIP: |
1621 | ; | 1628 | ; |
1622 | } // while | 1629 | } // while |
1623 | 1630 | ||
1624 | // Post-Process list of events with relations, put Event objects in relation | 1631 | // Post-Process list of events with relations, put Event objects in relation |
1625 | Event *ev; | 1632 | Event *ev; |
1626 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1633 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1627 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); | 1634 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); |
1628 | } | 1635 | } |
1629 | Todo *todo; | 1636 | Todo *todo; |
1630 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1637 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1631 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); | 1638 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); |
1632 | } | 1639 | } |
1633 | } | 1640 | } |
1634 | 1641 | ||
1635 | const char *VCalFormat::dayFromNum(int day) | 1642 | const char *VCalFormat::dayFromNum(int day) |
1636 | { | 1643 | { |
1637 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1644 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1638 | 1645 | ||
1639 | return days[day]; | 1646 | return days[day]; |
1640 | } | 1647 | } |
1641 | 1648 | ||
1642 | int VCalFormat::numFromDay(const QString &day) | 1649 | int VCalFormat::numFromDay(const QString &day) |
1643 | { | 1650 | { |
1644 | if (day == "MO ") return 0; | 1651 | if (day == "MO ") return 0; |
1645 | if (day == "TU ") return 1; | 1652 | if (day == "TU ") return 1; |
1646 | if (day == "WE ") return 2; | 1653 | if (day == "WE ") return 2; |
1647 | if (day == "TH ") return 3; | 1654 | if (day == "TH ") return 3; |
1648 | if (day == "FR ") return 4; | 1655 | if (day == "FR ") return 4; |
1649 | if (day == "SA ") return 5; | 1656 | if (day == "SA ") return 5; |
1650 | if (day == "SU ") return 6; | 1657 | if (day == "SU ") return 6; |
1651 | 1658 | ||
1652 | return -1; // something bad happened. :) | 1659 | return -1; // something bad happened. :) |
1653 | } | 1660 | } |
1654 | 1661 | ||
1655 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1662 | Attendee::PartStat VCalFormat::readStatus(const char *s) const |
1656 | { | 1663 | { |
1657 | QString statStr = s; | 1664 | QString statStr = s; |
1658 | statStr = statStr.upper(); | 1665 | statStr = statStr.upper(); |
1659 | Attendee::PartStat status; | 1666 | Attendee::PartStat status; |
1660 | 1667 | ||
1661 | if (statStr == "X-ACTION") | 1668 | if (statStr == "X-ACTION") |
1662 | status = Attendee::NeedsAction; | 1669 | status = Attendee::NeedsAction; |
1663 | else if (statStr == "NEEDS ACTION") | 1670 | else if (statStr == "NEEDS ACTION") |
1664 | status = Attendee::NeedsAction; | 1671 | status = Attendee::NeedsAction; |
1665 | else if (statStr== "ACCEPTED") | 1672 | else if (statStr== "ACCEPTED") |
1666 | status = Attendee::Accepted; | 1673 | status = Attendee::Accepted; |
1667 | else if (statStr== "SENT") | 1674 | else if (statStr== "SENT") |
1668 | status = Attendee::NeedsAction; | 1675 | status = Attendee::NeedsAction; |
1669 | else if (statStr== "TENTATIVE") | 1676 | else if (statStr== "TENTATIVE") |
1670 | status = Attendee::Tentative; | 1677 | status = Attendee::Tentative; |
1671 | else if (statStr== "CONFIRMED") | 1678 | else if (statStr== "CONFIRMED") |
1672 | status = Attendee::Accepted; | 1679 | status = Attendee::Accepted; |
1673 | else if (statStr== "DECLINED") | 1680 | else if (statStr== "DECLINED") |
1674 | status = Attendee::Declined; | 1681 | status = Attendee::Declined; |
1675 | else if (statStr== "COMPLETED") | 1682 | else if (statStr== "COMPLETED") |
1676 | status = Attendee::Completed; | 1683 | status = Attendee::Completed; |
1677 | else if (statStr== "DELEGATED") | 1684 | else if (statStr== "DELEGATED") |
1678 | status = Attendee::Delegated; | 1685 | status = Attendee::Delegated; |
1679 | else { | 1686 | else { |
1680 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; | 1687 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; |
1681 | status = Attendee::NeedsAction; | 1688 | status = Attendee::NeedsAction; |
1682 | } | 1689 | } |
1683 | 1690 | ||
1684 | return status; | 1691 | return status; |
1685 | } | 1692 | } |
1686 | 1693 | ||
1687 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1694 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const |
1688 | { | 1695 | { |
1689 | switch(status) { | 1696 | switch(status) { |
1690 | default: | 1697 | default: |
1691 | case Attendee::NeedsAction: | 1698 | case Attendee::NeedsAction: |
1692 | return "NEEDS ACTION"; | 1699 | return "NEEDS ACTION"; |
1693 | break; | 1700 | break; |
1694 | case Attendee::Accepted: | 1701 | case Attendee::Accepted: |
1695 | return "ACCEPTED"; | 1702 | return "ACCEPTED"; |
1696 | break; | 1703 | break; |
1697 | case Attendee::Declined: | 1704 | case Attendee::Declined: |
1698 | return "DECLINED"; | 1705 | return "DECLINED"; |
1699 | break; | 1706 | break; |
1700 | case Attendee::Tentative: | 1707 | case Attendee::Tentative: |
1701 | return "TENTATIVE"; | 1708 | return "TENTATIVE"; |
1702 | break; | 1709 | break; |
1703 | case Attendee::Delegated: | 1710 | case Attendee::Delegated: |
1704 | return "DELEGATED"; | 1711 | return "DELEGATED"; |
1705 | break; | 1712 | break; |
1706 | case Attendee::Completed: | 1713 | case Attendee::Completed: |
1707 | return "COMPLETED"; | 1714 | return "COMPLETED"; |
1708 | break; | 1715 | break; |
1709 | case Attendee::InProcess: | 1716 | case Attendee::InProcess: |
1710 | return "NEEDS ACTION"; | 1717 | return "NEEDS ACTION"; |
1711 | break; | 1718 | break; |
1712 | } | 1719 | } |
1713 | } | 1720 | } |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 8298aa6..e24ad9e 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -1,173 +1,216 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | 22 | ||
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 <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qlabel.h> | ||
28 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
29 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
30 | #include <qdir.h> | 31 | #include <qdir.h> |
31 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
32 | #include <stdlib.h> | 33 | #include <stdlib.h> |
33 | #include "phoneaccess.h" | 34 | #include "phoneaccess.h" |
34 | 35 | ||
35 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) | 36 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) |
36 | { | 37 | { |
37 | #ifdef _WIN32_ | 38 | #ifdef _WIN32_ |
38 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; | 39 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; |
39 | #else | 40 | #else |
40 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | 41 | QString fileName = QDir::homeDirPath() +"/.gammurc"; |
41 | #endif | 42 | #endif |
42 | //qDebug("save %d ", load ); | 43 | //qDebug("save %d ", load ); |
43 | QString content = "[gammu]\n";; | 44 | QString content = "[gammu]\n";; |
44 | bool write = false; | 45 | bool write = false; |
45 | bool addPort = true, addConnection = true, addModel = true; | 46 | bool addPort = true, addConnection = true, addModel = true; |
46 | QFile file( fileName ); | 47 | QFile file( fileName ); |
47 | if ( QFile::exists( fileName) ) { | 48 | if ( QFile::exists( fileName) ) { |
48 | if (!file.open( IO_ReadOnly ) ) { | 49 | if (!file.open( IO_ReadOnly ) ) { |
49 | qDebug("Error: cannot open %s ", fileName.latin1() ); | 50 | qDebug("Error: cannot open %s ", fileName.latin1() ); |
50 | return; | 51 | return; |
51 | } | 52 | } |
52 | QString line; | 53 | QString line; |
53 | while ( file.readLine( line, 1024 ) > 0 ) { | 54 | while ( file.readLine( line, 1024 ) > 0 ) { |
54 | //qDebug("*%s* ", line.latin1() ); | 55 | //qDebug("*%s* ", line.latin1() ); |
55 | if ( line.left(7 ) == "[gammu]" ) { | 56 | if ( line.left(7 ) == "[gammu]" ) { |
56 | ; | 57 | ; |
57 | } else | 58 | } else |
58 | if ( line.left(4 ) == "port" ) { | 59 | if ( line.left(4 ) == "port" ) { |
59 | if ( line == "port = " + device+"\n" ) { | 60 | if ( line == "port = " + device+"\n" ) { |
60 | content += line ; | 61 | content += line ; |
61 | addPort = false; | 62 | addPort = false; |
62 | //qDebug("port found" ); | 63 | //qDebug("port found" ); |
63 | } | 64 | } |
64 | 65 | ||
65 | } else if ( line.left(5 ) == "model" ) { | 66 | } else if ( line.left(5 ) == "model" ) { |
66 | if ( line == "model = " + model +"\n") { | 67 | if ( line == "model = " + model +"\n") { |
67 | content += line ; | 68 | content += line ; |
68 | addModel = false; | 69 | addModel = false; |
69 | //qDebug("model found" ); | 70 | //qDebug("model found" ); |
70 | } | 71 | } |
71 | 72 | ||
72 | } else if ( line.left( 10 ) == "connection" ) { | 73 | } else if ( line.left( 10 ) == "connection" ) { |
73 | if ( line == "connection = " + connection +"\n") { | 74 | if ( line == "connection = " + connection +"\n") { |
74 | addConnection = false; | 75 | addConnection = false; |
75 | content += line ; | 76 | content += line ; |
76 | //qDebug("con found" ); | 77 | //qDebug("con found" ); |
77 | } | 78 | } |
78 | 79 | ||
79 | } else { | 80 | } else { |
80 | content += line ; | 81 | content += line ; |
81 | } | 82 | } |
82 | } | 83 | } |
83 | file.close(); | 84 | file.close(); |
84 | } else { | 85 | } else { |
85 | if ( ! connection.isEmpty() ) { | 86 | if ( ! connection.isEmpty() ) { |
86 | addConnection = true; | 87 | addConnection = true; |
87 | } | 88 | } |
88 | if ( ! device.isEmpty() ) { | 89 | if ( ! device.isEmpty() ) { |
89 | addPort = true; | 90 | addPort = true; |
90 | 91 | ||
91 | } | 92 | } |
92 | if ( ! model.isEmpty() ) { | 93 | if ( ! model.isEmpty() ) { |
93 | addModel = true; | 94 | addModel = true; |
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
97 | if ( addConnection ) { | 98 | if ( addConnection ) { |
98 | write = true; | 99 | write = true; |
99 | content += "connection = "; | 100 | content += "connection = "; |
100 | content += connection; | 101 | content += connection; |
101 | content += "\n"; | 102 | content += "\n"; |
102 | } | 103 | } |
103 | if ( addPort ) { | 104 | if ( addPort ) { |
104 | write = true; | 105 | write = true; |
105 | content += "port = "; | 106 | content += "port = "; |
106 | content += device; | 107 | content += device; |
107 | content += "\n"; | 108 | content += "\n"; |
108 | 109 | ||
109 | } | 110 | } |
110 | if ( addModel ) { | 111 | if ( addModel ) { |
111 | write = true; | 112 | write = true; |
112 | content += "model = "; | 113 | content += "model = "; |
113 | content += model; | 114 | content += model; |
114 | content += "\n"; | 115 | content += "\n"; |
115 | } | 116 | } |
116 | if ( write ) { | 117 | if ( write ) { |
117 | if (!file.open( IO_WriteOnly ) ) { | 118 | if (!file.open( IO_WriteOnly ) ) { |
118 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | 119 | qDebug("Error: cannot write file %s ", fileName.latin1() ); |
119 | return; | 120 | return; |
120 | } | 121 | } |
121 | qDebug("Writing file %s ", fileName.latin1() ); | 122 | qDebug("Writing file %s ", fileName.latin1() ); |
122 | QTextStream ts( &file ); | 123 | QTextStream ts( &file ); |
123 | ts << content ; | 124 | ts << content ; |
124 | file.close(); | 125 | file.close(); |
125 | } | 126 | } |
126 | 127 | ||
127 | } | 128 | } |
128 | 129 | ||
129 | 130 | ||
130 | bool PhoneAccess::writeToPhone( QString fileName) | 131 | bool PhoneAccess::writeToPhone( QString fileName) |
131 | { | 132 | { |
132 | 133 | ||
133 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
134 | #ifdef _WIN32_ | 135 | #ifdef _WIN32_ |
135 | QString command ="kammu --restore " + fileName ; | 136 | QString command ="kammu --restore " + fileName ; |
136 | #else | 137 | #else |
137 | QString command ="./kammu --restore " + fileName ; | 138 | QString command ="./kammu --restore " + fileName ; |
138 | #endif | 139 | #endif |
139 | #else | 140 | #else |
140 | QString command ="kammu --restore " + fileName ; | 141 | QString command ="kammu --restore " + fileName ; |
141 | #endif | 142 | #endif |
142 | int ret; | 143 | int ret = 1; |
143 | while ( (ret = system ( command.latin1())) != 0 ) { | 144 | while ( ret != 0 ) { |
144 | qDebug("Error S::command returned %d.", ret); | 145 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); |
145 | int retval = KMessageBox::warningContinueCancel(0, | 146 | int w = 235; |
146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 147 | int h = status->sizeHint().height()+20 ; |
147 | if ( retval != KMessageBox::Continue ) | 148 | int dw = QApplication::desktop()->width(); |
148 | return false; | 149 | int dh = QApplication::desktop()->height(); |
150 | if ( dw > 310 ) | ||
151 | w = 310; | ||
152 | status->setCaption(i18n("Writing to phone...") ); | ||
153 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
154 | status->show(); | ||
155 | status->raise(); | ||
156 | status->update(); | ||
157 | qApp->processEvents(); | ||
158 | status->update(); | ||
159 | qApp->processEvents(); | ||
160 | ret = system ( command.latin1()); | ||
161 | delete status; | ||
162 | qApp->processEvents(); | ||
163 | if ( ret ) { | ||
164 | qDebug("Error S::command returned %d.", ret); | ||
165 | int retval = KMessageBox::warningContinueCancel(0, | ||
166 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | ||
167 | if ( retval != KMessageBox::Continue ) | ||
168 | return false; | ||
169 | } | ||
149 | } | 170 | } |
150 | return true; | 171 | return true; |
151 | } | 172 | } |
152 | bool PhoneAccess::readFromPhone( QString fileName) | 173 | bool PhoneAccess::readFromPhone( QString fileName) |
153 | { | 174 | { |
154 | 175 | ||
155 | #ifdef DESKTOP_VERSION | 176 | #ifdef DESKTOP_VERSION |
156 | #ifdef _WIN32_ | 177 | #ifdef _WIN32_ |
157 | QString command ="kammu --backup " + fileName + " -yes" ; | 178 | QString command ="kammu --backup " + fileName + " -yes" ; |
158 | #else | 179 | #else |
159 | QString command ="./kammu --backup " + fileName + " -yes" ; | 180 | QString command ="./kammu --backup " + fileName + " -yes" ; |
160 | #endif | 181 | #endif |
161 | #else | 182 | #else |
162 | QString command ="kammu --backup " + fileName + " -yes" ; | 183 | QString command ="kammu --backup " + fileName + " -yes" ; |
163 | #endif | 184 | #endif |
164 | int ret; | 185 | int ret; |
165 | while ( (ret = system ( command.latin1())) != 0 ) { | 186 | while ( ret != 0 ) { |
166 | qDebug("Error reading from phone:Command returned %d", ret); | 187 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); |
167 | int retval = KMessageBox::warningContinueCancel(0, | 188 | int w = 235; |
168 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 189 | int h = status->sizeHint().height()+20 ; |
169 | if ( retval != KMessageBox::Continue ) | 190 | int dw = QApplication::desktop()->width(); |
170 | return false; | 191 | int dh = QApplication::desktop()->height(); |
192 | if ( dw > 310 ) | ||
193 | w = 310; | ||
194 | status->setCaption(i18n("Reading from phone...") ); | ||
195 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
196 | status->show(); | ||
197 | status->raise(); | ||
198 | status->update(); | ||
199 | qApp->processEvents(); | ||
200 | status->update(); | ||
201 | qApp->processEvents(); | ||
202 | ret = system ( command.latin1() ); | ||
203 | delete status; | ||
204 | qApp->processEvents(); | ||
205 | if ( ret ) { | ||
206 | qDebug("Error reading from phone:Command returned %d", ret); | ||
207 | int retval = KMessageBox::warningContinueCancel(0, | ||
208 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | ||
209 | if ( retval != KMessageBox::Continue ) | ||
210 | return false; | ||
211 | |||
212 | } | ||
171 | } | 213 | } |
214 | qApp->processEvents(); | ||
172 | return true; | 215 | return true; |
173 | } | 216 | } |
diff --git a/microkde/microkde.pro b/microkde/microkde.pro index 71d662b..21da158 100644 --- a/microkde/microkde.pro +++ b/microkde/microkde.pro | |||
@@ -1,176 +1,174 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | #INCLUDEPATH += $(QTDIR)/include . | 3 | #INCLUDEPATH += $(QTDIR)/include . |
4 | #DEPENDPATH += $(QTDIR)/include | 4 | #DEPENDPATH += $(QTDIR)/include |
5 | INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio | 5 | INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio |
6 | #LIBS += -lqtcompat | 6 | #LIBS += -lqtcompat |
7 | 7 | ||
8 | TARGET = microkde | 8 | TARGET = microkde |
9 | DESTDIR= ../bin | 9 | DESTDIR= ../bin |
10 | DEFINES += DESKTOP_VERSION KDE_QT_ONLY | 10 | DEFINES += DESKTOP_VERSION KDE_QT_ONLY |
11 | unix : { | 11 | unix : { |
12 | OBJECTS_DIR = obj/unix | 12 | OBJECTS_DIR = obj/unix |
13 | MOC_DIR = moc/unix | 13 | MOC_DIR = moc/unix |
14 | } | 14 | } |
15 | win32: { | 15 | win32: { |
16 | DEFINES += _WIN32_ | 16 | DEFINES += _WIN32_ |
17 | OBJECTS_DIR = obj/win | 17 | OBJECTS_DIR = obj/win |
18 | MOC_DIR = moc/win | 18 | MOC_DIR = moc/win |
19 | } | 19 | } |
20 | include( ../variables.pri ) | 20 | include( ../variables.pri ) |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
24 | HEADERS = \ | 24 | HEADERS = \ |
25 | qlayoutengine_p.h \ | 25 | qlayoutengine_p.h \ |
26 | KDGanttMinimizeSplitter.h \ | 26 | KDGanttMinimizeSplitter.h \ |
27 | kapplication.h \ | 27 | kapplication.h \ |
28 | kaudioplayer.h \ | 28 | kaudioplayer.h \ |
29 | kcalendarsystem.h \ | 29 | kcalendarsystem.h \ |
30 | kcalendarsystemgregorian.h \ | 30 | kcalendarsystemgregorian.h \ |
31 | kcolorbutton.h \ | 31 | kcolorbutton.h \ |
32 | kcolordialog.h \ | 32 | kcolordialog.h \ |
33 | kcombobox.h \ | 33 | kcombobox.h \ |
34 | kconfig.h \ | 34 | kconfig.h \ |
35 | kdatetbl.h \ | 35 | kdatetbl.h \ |
36 | kdebug.h \ | 36 | kdebug.h \ |
37 | kdialog.h \ | 37 | kdialog.h \ |
38 | kdialogbase.h \ | 38 | kdialogbase.h \ |
39 | keditlistbox.h \ | 39 | keditlistbox.h \ |
40 | kemailsettings.h \ | 40 | kemailsettings.h \ |
41 | kfiledialog.h \ | 41 | kfiledialog.h \ |
42 | kfontdialog.h \ | 42 | kfontdialog.h \ |
43 | kglobal.h \ | 43 | kglobal.h \ |
44 | kglobalsettings.h \ | 44 | kglobalsettings.h \ |
45 | kiconloader.h \ | 45 | kiconloader.h \ |
46 | klineedit.h \ | 46 | klineedit.h \ |
47 | klineeditdlg.h \ | 47 | klineeditdlg.h \ |
48 | kmessagebox.h \ | 48 | kmessagebox.h \ |
49 | knotifyclient.h \ | 49 | knotifyclient.h \ |
50 | kprinter.h \ | 50 | kprinter.h \ |
51 | kprocess.h \ | 51 | kprocess.h \ |
52 | krestrictedline.h \ | 52 | krestrictedline.h \ |
53 | krun.h \ | 53 | krun.h \ |
54 | ksimpleconfig.h \ | 54 | ksimpleconfig.h \ |
55 | kstaticdeleter.h \ | 55 | kstaticdeleter.h \ |
56 | ksystemtray.h \ | 56 | ksystemtray.h \ |
57 | ktempfile.h \ | 57 | ktempfile.h \ |
58 | ktextedit.h \ | 58 | ktextedit.h \ |
59 | kunload.h \ | 59 | kunload.h \ |
60 | kurl.h \ | 60 | kurl.h \ |
61 | kdeui/kguiitem.h \ | 61 | kdeui/kguiitem.h \ |
62 | kdeui/kcmodule.h \ | 62 | kdeui/kcmodule.h \ |
63 | kdeui/kbuttonbox.h \ | 63 | kdeui/kbuttonbox.h \ |
64 | kdeui/klistbox.h \ | 64 | kdeui/klistbox.h \ |
65 | kdeui/klistview.h \ | 65 | kdeui/klistview.h \ |
66 | kdeui/kjanuswidget.h \ | 66 | kdeui/kjanuswidget.h \ |
67 | kdeui/kseparator.h \ | 67 | kdeui/kseparator.h \ |
68 | kdeui/knuminput.h \ | 68 | kdeui/knuminput.h \ |
69 | kdeui/knumvalidator.h \ | 69 | kdeui/knumvalidator.h \ |
70 | kdeui/ksqueezedtextlabel.h \ | 70 | kdeui/ksqueezedtextlabel.h \ |
71 | kio/job.h \ | 71 | kio/job.h \ |
72 | kio/kio/kdirwatch.h \ | 72 | kio/kio/kdirwatch.h \ |
73 | kio/kio/kdirwatch_p.h \ | 73 | kio/kio/kdirwatch_p.h \ |
74 | kio/kfile/kurlrequester.h \ | 74 | kio/kfile/kurlrequester.h \ |
75 | kresources/resource.h \ | 75 | kresources/resource.h \ |
76 | kresources/factory.h \ | 76 | kresources/factory.h \ |
77 | kresources/managerimpl.h \ | 77 | kresources/managerimpl.h \ |
78 | kresources/manager.h \ | 78 | kresources/manager.h \ |
79 | kresources/selectdialog.h \ | 79 | kresources/selectdialog.h \ |
80 | kresources/configpage.h \ | 80 | kresources/configpage.h \ |
81 | kresources/configwidget.h \ | 81 | kresources/configwidget.h \ |
82 | kresources/configdialog.h \ | 82 | kresources/configdialog.h \ |
83 | kresources/kcmkresources.h \ | 83 | kresources/kcmkresources.h \ |
84 | kresources/syncwidget.h \ | ||
85 | kdecore/kmdcodec.h \ | 84 | kdecore/kmdcodec.h \ |
86 | kdecore/kconfigbase.h \ | 85 | kdecore/kconfigbase.h \ |
87 | kdecore/klocale.h \ | 86 | kdecore/klocale.h \ |
88 | kdecore/kcatalogue.h \ | 87 | kdecore/kcatalogue.h \ |
89 | kdecore/ksharedptr.h \ | 88 | kdecore/ksharedptr.h \ |
90 | kdecore/kshell.h \ | 89 | kdecore/kshell.h \ |
91 | kdecore/kstandarddirs.h \ | 90 | kdecore/kstandarddirs.h \ |
92 | kdecore/kstringhandler.h \ | 91 | kdecore/kstringhandler.h \ |
93 | kdecore/kshortcut.h \ | 92 | kdecore/kshortcut.h \ |
94 | kutils/kcmultidialog.h \ | 93 | kutils/kcmultidialog.h \ |
95 | kdeui/kxmlguiclient.h \ | 94 | kdeui/kxmlguiclient.h \ |
96 | kdeui/kstdaction.h \ | 95 | kdeui/kstdaction.h \ |
97 | kdeui/kmainwindow.h \ | 96 | kdeui/kmainwindow.h \ |
98 | kdeui/ktoolbar.h \ | 97 | kdeui/ktoolbar.h \ |
99 | kdeui/ktoolbarbutton.h \ | 98 | kdeui/ktoolbarbutton.h \ |
100 | kdeui/ktoolbarhandler.h \ | 99 | kdeui/ktoolbarhandler.h \ |
101 | kdeui/kaction.h \ | 100 | kdeui/kaction.h \ |
102 | kdeui/kactionclasses.h \ | 101 | kdeui/kactionclasses.h \ |
103 | kdeui/kactioncollection.h \ | 102 | kdeui/kactioncollection.h \ |
104 | kdecore/kprefs.h \ | 103 | kdecore/kprefs.h \ |
105 | kdecore/klibloader.h \ | 104 | kdecore/klibloader.h \ |
106 | kidmanager.h | 105 | kidmanager.h |
107 | 106 | ||
108 | 107 | ||
109 | # kdecore/klibloader.h \ | 108 | # kdecore/klibloader.h \ |
110 | 109 | ||
111 | 110 | ||
112 | SOURCES = \ | 111 | SOURCES = \ |
113 | KDGanttMinimizeSplitter.cpp \ | 112 | KDGanttMinimizeSplitter.cpp \ |
114 | kapplication.cpp \ | 113 | kapplication.cpp \ |
115 | kcalendarsystem.cpp \ | 114 | kcalendarsystem.cpp \ |
116 | kcalendarsystemgregorian.cpp \ | 115 | kcalendarsystemgregorian.cpp \ |
117 | kcolorbutton.cpp \ | 116 | kcolorbutton.cpp \ |
118 | kcolordialog.cpp \ | 117 | kcolordialog.cpp \ |
119 | kconfig.cpp \ | 118 | kconfig.cpp \ |
120 | kdatetbl.cpp \ | 119 | kdatetbl.cpp \ |
121 | kdialog.cpp \ | 120 | kdialog.cpp \ |
122 | kdialogbase.cpp \ | 121 | kdialogbase.cpp \ |
123 | keditlistbox.cpp \ | 122 | keditlistbox.cpp \ |
124 | kemailsettings.cpp \ | 123 | kemailsettings.cpp \ |
125 | kfontdialog.cpp \ | 124 | kfontdialog.cpp \ |
126 | kfiledialog.cpp \ | 125 | kfiledialog.cpp \ |
127 | kglobal.cpp \ | 126 | kglobal.cpp \ |
128 | kglobalsettings.cpp \ | 127 | kglobalsettings.cpp \ |
129 | kiconloader.cpp \ | 128 | kiconloader.cpp \ |
130 | kmessagebox.cpp \ | 129 | kmessagebox.cpp \ |
131 | ktextedit.cpp \ | 130 | ktextedit.cpp \ |
132 | kprocess.cpp \ | 131 | kprocess.cpp \ |
133 | krun.cpp \ | 132 | krun.cpp \ |
134 | ksystemtray.cpp \ | 133 | ksystemtray.cpp \ |
135 | ktempfile.cpp \ | 134 | ktempfile.cpp \ |
136 | kurl.cpp \ | 135 | kurl.cpp \ |
137 | kdecore/kcatalogue.cpp \ | 136 | kdecore/kcatalogue.cpp \ |
138 | kdecore/klocale.cpp \ | 137 | kdecore/klocale.cpp \ |
139 | kdecore/kmdcodec.cpp \ | 138 | kdecore/kmdcodec.cpp \ |
140 | kdecore/kshell.cpp \ | 139 | kdecore/kshell.cpp \ |
141 | kdecore/kstandarddirs.cpp \ | 140 | kdecore/kstandarddirs.cpp \ |
142 | kdecore/kstringhandler.cpp \ | 141 | kdecore/kstringhandler.cpp \ |
143 | kdeui/kbuttonbox.cpp \ | 142 | kdeui/kbuttonbox.cpp \ |
144 | kdeui/kcmodule.cpp \ | 143 | kdeui/kcmodule.cpp \ |
145 | kdeui/kguiitem.cpp \ | 144 | kdeui/kguiitem.cpp \ |
146 | kdeui/kjanuswidget.cpp \ | 145 | kdeui/kjanuswidget.cpp \ |
147 | kdeui/klistbox.cpp \ | 146 | kdeui/klistbox.cpp \ |
148 | kdeui/klistview.cpp \ | 147 | kdeui/klistview.cpp \ |
149 | kdeui/knuminput.cpp \ | 148 | kdeui/knuminput.cpp \ |
150 | kdeui/knumvalidator.cpp \ | 149 | kdeui/knumvalidator.cpp \ |
151 | kdeui/kseparator.cpp \ | 150 | kdeui/kseparator.cpp \ |
152 | kdeui/ksqueezedtextlabel.cpp \ | 151 | kdeui/ksqueezedtextlabel.cpp \ |
153 | kio/kio/kdirwatch.cpp \ | 152 | kio/kio/kdirwatch.cpp \ |
154 | kio/kfile/kurlrequester.cpp \ | 153 | kio/kfile/kurlrequester.cpp \ |
155 | kresources/configpage.cpp \ | 154 | kresources/configpage.cpp \ |
156 | kresources/configdialog.cpp \ | 155 | kresources/configdialog.cpp \ |
157 | kresources/configwidget.cpp \ | 156 | kresources/configwidget.cpp \ |
158 | kresources/factory.cpp \ | 157 | kresources/factory.cpp \ |
159 | kresources/kcmkresources.cpp \ | 158 | kresources/kcmkresources.cpp \ |
160 | kresources/managerimpl.cpp \ | 159 | kresources/managerimpl.cpp \ |
161 | kresources/resource.cpp \ | 160 | kresources/resource.cpp \ |
162 | kresources/selectdialog.cpp \ | 161 | kresources/selectdialog.cpp \ |
163 | kresources/syncwidget.cpp \ | ||
164 | kutils/kcmultidialog.cpp \ | 162 | kutils/kcmultidialog.cpp \ |
165 | kdeui/kaction.cpp \ | 163 | kdeui/kaction.cpp \ |
166 | kdeui/kactionclasses.cpp \ | 164 | kdeui/kactionclasses.cpp \ |
167 | kdeui/kactioncollection.cpp \ | 165 | kdeui/kactioncollection.cpp \ |
168 | kdeui/kmainwindow.cpp \ | 166 | kdeui/kmainwindow.cpp \ |
169 | kdeui/ktoolbar.cpp \ | 167 | kdeui/ktoolbar.cpp \ |
170 | kdeui/ktoolbarbutton.cpp \ | 168 | kdeui/ktoolbarbutton.cpp \ |
171 | kdeui/ktoolbarhandler.cpp \ | 169 | kdeui/ktoolbarhandler.cpp \ |
172 | kdeui/kstdaction.cpp \ | 170 | kdeui/kstdaction.cpp \ |
173 | kdeui/kxmlguiclient.cpp \ | 171 | kdeui/kxmlguiclient.cpp \ |
174 | kdecore/kprefs.cpp \ | 172 | kdecore/kprefs.cpp \ |
175 | kdecore/klibloader.cpp \ | 173 | kdecore/klibloader.cpp \ |
176 | kidmanager.cpp | 174 | kidmanager.cpp |
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index cf6074d..fd5f965 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp | |||
@@ -1,746 +1,749 @@ | |||
1 | #include <qcombobox.h> | 1 | #include <qcombobox.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include <qheader.h> | 4 | #include <qheader.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
8 | #include <qlistview.h> | 8 | #include <qlistview.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
11 | #include <qregexp.h> | 11 | #include <qregexp.h> |
12 | #include <qobjectlist.h> | 12 | #include <qobjectlist.h> |
13 | 13 | ||
14 | /* hacky but we need to get FileSelector::filter */ | 14 | /* hacky but we need to get FileSelector::filter */ |
15 | #define private public | 15 | #define private public |
16 | #include <qpe/fileselector.h> | 16 | #include <qpe/fileselector.h> |
17 | #undef private | 17 | #undef private |
18 | 18 | ||
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/mimetype.h> | 20 | #include <qpe/mimetype.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/storage.h> | 22 | #include <qpe/storage.h> |
23 | #include <kglobal.h> | ||
24 | #include <klocale.h> | ||
23 | 25 | ||
24 | #include "ofileselector_p.h" | 26 | #include "ofileselector_p.h" |
25 | //US#include "ofileselector.h" | 27 | //US#include "ofileselector.h" |
26 | 28 | ||
27 | #include "klocale.h" | 29 | #include "klocale.h" |
28 | 30 | ||
29 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | 31 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) |
30 | : m_selector( selector ) { | 32 | : m_selector( selector ) { |
31 | } | 33 | } |
32 | OFileViewInterface::~OFileViewInterface() { | 34 | OFileViewInterface::~OFileViewInterface() { |
33 | } | 35 | } |
34 | QString OFileViewInterface::name()const{ | 36 | QString OFileViewInterface::name()const{ |
35 | return m_name; | 37 | return m_name; |
36 | } | 38 | } |
37 | void OFileViewInterface::setName( const QString& name ) { | 39 | void OFileViewInterface::setName( const QString& name ) { |
38 | m_name = name; | 40 | m_name = name; |
39 | } | 41 | } |
40 | OFileSelector* OFileViewInterface::selector()const { | 42 | OFileSelector* OFileViewInterface::selector()const { |
41 | return m_selector; | 43 | return m_selector; |
42 | } | 44 | } |
43 | 45 | ||
44 | DocLnk OFileViewInterface::selectedDocument()const { | 46 | DocLnk OFileViewInterface::selectedDocument()const { |
45 | return DocLnk( selectedName() ); | 47 | return DocLnk( selectedName() ); |
46 | } | 48 | } |
47 | 49 | ||
48 | bool OFileViewInterface::showNew()const { | 50 | bool OFileViewInterface::showNew()const { |
49 | return selector()->showNew(); | 51 | return selector()->showNew(); |
50 | } | 52 | } |
51 | bool OFileViewInterface::showClose()const { | 53 | bool OFileViewInterface::showClose()const { |
52 | return selector()->showClose(); | 54 | return selector()->showClose(); |
53 | } | 55 | } |
54 | MimeTypes OFileViewInterface::mimeTypes()const { | 56 | MimeTypes OFileViewInterface::mimeTypes()const { |
55 | return selector()->mimeTypes(); | 57 | return selector()->mimeTypes(); |
56 | } | 58 | } |
57 | QStringList OFileViewInterface::currentMimeType()const { | 59 | QStringList OFileViewInterface::currentMimeType()const { |
58 | return selector()->currentMimeType(); | 60 | return selector()->currentMimeType(); |
59 | } | 61 | } |
60 | void OFileViewInterface::activate( const QString& ) { | 62 | void OFileViewInterface::activate( const QString& ) { |
61 | // not implemented here | 63 | // not implemented here |
62 | } | 64 | } |
63 | void OFileViewInterface::ok() { | 65 | void OFileViewInterface::ok() { |
64 | emit selector()->ok(); | 66 | emit selector()->ok(); |
65 | } | 67 | } |
66 | void OFileViewInterface::cancel() { | 68 | void OFileViewInterface::cancel() { |
67 | emit selector()->cancel(); | 69 | emit selector()->cancel(); |
68 | } | 70 | } |
69 | void OFileViewInterface::closeMe() { | 71 | void OFileViewInterface::closeMe() { |
70 | emit selector()->closeMe(); | 72 | emit selector()->closeMe(); |
71 | } | 73 | } |
72 | void OFileViewInterface::fileSelected( const QString& str) { | 74 | void OFileViewInterface::fileSelected( const QString& str) { |
73 | emit selector()->fileSelected( str); | 75 | emit selector()->fileSelected( str); |
74 | } | 76 | } |
75 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { | 77 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { |
76 | emit selector()->fileSelected( lnk ); | 78 | emit selector()->fileSelected( lnk ); |
77 | } | 79 | } |
78 | void OFileViewInterface::setCurrentFileName( const QString& str ) { | 80 | void OFileViewInterface::setCurrentFileName( const QString& str ) { |
79 | selector()->m_lneEdit->setText( str ); | 81 | selector()->m_lneEdit->setText( str ); |
80 | } | 82 | } |
81 | QString OFileViewInterface::currentFileName()const{ | 83 | QString OFileViewInterface::currentFileName()const{ |
82 | return selector()->m_lneEdit->text(); | 84 | return selector()->m_lneEdit->text(); |
83 | } | 85 | } |
84 | QString OFileViewInterface::startDirectory()const{ | 86 | QString OFileViewInterface::startDirectory()const{ |
85 | return selector()->m_startDir; | 87 | return selector()->m_startDir; |
86 | } | 88 | } |
87 | 89 | ||
88 | 90 | ||
89 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 91 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
90 | : OFileViewInterface( selector ) { | 92 | : OFileViewInterface( selector ) { |
91 | m_selector = 0; | 93 | m_selector = 0; |
92 | setName( i18n("Documents") ); | 94 | setName( i18n("Documents") ); |
93 | } | 95 | } |
94 | ODocumentFileView::~ODocumentFileView() { | 96 | ODocumentFileView::~ODocumentFileView() { |
95 | 97 | ||
96 | } | 98 | } |
97 | QString ODocumentFileView::selectedName()const { | 99 | QString ODocumentFileView::selectedName()const { |
98 | if (!m_selector) | 100 | if (!m_selector) |
99 | return QString::null; | 101 | return QString::null; |
100 | 102 | ||
101 | return m_selector->selected()->file(); | 103 | return m_selector->selected()->file(); |
102 | } | 104 | } |
103 | QString ODocumentFileView::selectedPath()const { | 105 | QString ODocumentFileView::selectedPath()const { |
104 | return QPEApplication::documentDir(); | 106 | return QPEApplication::documentDir(); |
105 | } | 107 | } |
106 | QString ODocumentFileView::directory()const { | 108 | QString ODocumentFileView::directory()const { |
107 | return selectedPath(); | 109 | return selectedPath(); |
108 | } | 110 | } |
109 | void ODocumentFileView::reread() { | 111 | void ODocumentFileView::reread() { |
110 | if (!m_selector) | 112 | if (!m_selector) |
111 | return; | 113 | return; |
112 | 114 | ||
113 | m_selector->setNewVisible( showNew() ); | 115 | m_selector->setNewVisible( showNew() ); |
114 | m_selector->setCloseVisible( showClose() ); | 116 | m_selector->setCloseVisible( showClose() ); |
115 | m_selector->filter = currentMimeType().join(";"); | 117 | m_selector->filter = currentMimeType().join(";"); |
116 | m_selector->reread(); | 118 | m_selector->reread(); |
117 | } | 119 | } |
118 | int ODocumentFileView::fileCount()const { | 120 | int ODocumentFileView::fileCount()const { |
119 | if (!m_selector) | 121 | if (!m_selector) |
120 | return -1; | 122 | return -1; |
121 | 123 | ||
122 | return m_selector->fileCount(); | 124 | return m_selector->fileCount(); |
123 | } | 125 | } |
124 | 126 | ||
125 | DocLnk ODocumentFileView::selectedDocument()const { | 127 | DocLnk ODocumentFileView::selectedDocument()const { |
126 | if (!m_selector) | 128 | if (!m_selector) |
127 | return DocLnk(); | 129 | return DocLnk(); |
128 | DocLnk lnk = *m_selector->selected(); | 130 | DocLnk lnk = *m_selector->selected(); |
129 | return lnk; | 131 | return lnk; |
130 | } | 132 | } |
131 | 133 | ||
132 | QWidget* ODocumentFileView::widget( QWidget* parent ) { | 134 | QWidget* ODocumentFileView::widget( QWidget* parent ) { |
133 | if (!m_selector ) { | 135 | if (!m_selector ) { |
134 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 136 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
135 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), | 137 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), |
136 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 138 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
137 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 139 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
138 | selector(), SIGNAL(closeMe() ) ); | 140 | selector(), SIGNAL(closeMe() ) ); |
139 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), | 141 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), |
140 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); | 142 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); |
141 | } | 143 | } |
142 | 144 | ||
143 | return m_selector; | 145 | return m_selector; |
144 | } | 146 | } |
145 | 147 | ||
146 | /* | 148 | /* |
147 | * This is the file system view used | 149 | * This is the file system view used |
148 | * we use a QListView + QListViewItems for it | 150 | * we use a QListView + QListViewItems for it |
149 | */ | 151 | */ |
150 | 152 | ||
151 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 153 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
152 | const QString& path, const QString& date, | 154 | const QString& path, const QString& date, |
153 | const QString& size, const QString& dir, | 155 | const QString& size, const QString& dir, |
154 | bool isLocked, bool isDir ) | 156 | bool isLocked, bool isDir ) |
155 | : QListViewItem( view ) | 157 | : QListViewItem( view ) |
156 | { | 158 | { |
157 | setPixmap(0, pixmap ); | 159 | setPixmap(0, pixmap ); |
158 | setText(1, path ); | 160 | setText(1, path ); |
159 | setText(2, size ); | 161 | setText(2, size ); |
160 | setText(3, date ); | 162 | setText(3, date ); |
161 | m_isDir = isDir; | 163 | m_isDir = isDir; |
162 | m_dir = dir; | 164 | m_dir = dir; |
163 | m_locked = isLocked; | 165 | m_locked = isLocked; |
164 | } | 166 | } |
165 | OFileSelectorItem::~OFileSelectorItem() { | 167 | OFileSelectorItem::~OFileSelectorItem() { |
166 | 168 | ||
167 | } | 169 | } |
168 | bool OFileSelectorItem::isLocked()const { | 170 | bool OFileSelectorItem::isLocked()const { |
169 | return m_locked; | 171 | return m_locked; |
170 | } | 172 | } |
171 | QString OFileSelectorItem::directory()const { | 173 | QString OFileSelectorItem::directory()const { |
172 | return m_dir; | 174 | return m_dir; |
173 | } | 175 | } |
174 | bool OFileSelectorItem::isDir()const { | 176 | bool OFileSelectorItem::isDir()const { |
175 | return m_isDir; | 177 | return m_isDir; |
176 | } | 178 | } |
177 | QString OFileSelectorItem::path()const { | 179 | QString OFileSelectorItem::path()const { |
178 | return text( 1 ); | 180 | return text( 1 ); |
179 | } | 181 | } |
180 | QString OFileSelectorItem::key( int id, bool )const { | 182 | QString OFileSelectorItem::key( int id, bool )const { |
181 | QString ke; | 183 | QString ke; |
182 | if( id == 0 || id == 1 ){ // name | 184 | if( id == 0 || id == 1 ){ // name |
183 | if( m_isDir ){ | 185 | if( m_isDir ){ |
184 | ke.append("0" ); | 186 | ke.append("0" ); |
185 | ke.append( text(1) ); | 187 | ke.append( text(1) ); |
186 | }else{ | 188 | }else{ |
187 | ke.append("1" ); | 189 | ke.append("1" ); |
188 | ke.append( text(1) ); | 190 | ke.append( text(1) ); |
189 | } | 191 | } |
190 | return ke; | 192 | return ke; |
191 | }else | 193 | }else |
192 | return text( id ); | 194 | return text( id ); |
193 | 195 | ||
194 | } | 196 | } |
195 | 197 | ||
196 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | 198 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, |
197 | OFileSelector* sel) | 199 | OFileSelector* sel) |
198 | : QWidget( parent ), m_sel( sel ) { | 200 | : QWidget( parent ), m_sel( sel ) { |
199 | m_all = false; | 201 | m_all = false; |
200 | QVBoxLayout* lay = new QVBoxLayout( this ); | 202 | QVBoxLayout* lay = new QVBoxLayout( this ); |
201 | m_currentDir = startDir; | 203 | m_currentDir = startDir; |
202 | 204 | ||
203 | /* | 205 | /* |
204 | * now we add a special bar | 206 | * now we add a special bar |
205 | * One Button For Up | 207 | * One Button For Up |
206 | * Home | 208 | * Home |
207 | * Doc | 209 | * Doc |
208 | * And a dropdown menu with FileSystems | 210 | * And a dropdown menu with FileSystems |
209 | * FUTURE: one to change dir with lineedit | 211 | * FUTURE: one to change dir with lineedit |
210 | * Bookmarks | 212 | * Bookmarks |
211 | * Create Dir | 213 | * Create Dir |
212 | */ | 214 | */ |
213 | QHBox* box = new QHBox(this ); | 215 | QHBox* box = new QHBox(this ); |
214 | box->setBackgroundMode( PaletteButton ); | 216 | box->setBackgroundMode( PaletteButton ); |
215 | box->setSpacing( 0 ); | 217 | box->setSpacing( 0 ); |
216 | 218 | ||
217 | QToolButton *btn = new QToolButton( box ); | 219 | QToolButton *btn = new QToolButton( box ); |
218 | btn->setIconSet( Resource::loadPixmap("up") ); | 220 | btn->setIconSet( Resource::loadPixmap("up") ); |
219 | connect(btn, SIGNAL(clicked() ), | 221 | connect(btn, SIGNAL(clicked() ), |
220 | this, SLOT( cdUP() ) ); | 222 | this, SLOT( cdUP() ) ); |
221 | 223 | ||
222 | btn = new QToolButton( box ); | 224 | btn = new QToolButton( box ); |
223 | btn->setIconSet( Resource::loadPixmap("home") ); | 225 | btn->setIconSet( Resource::loadPixmap("home") ); |
224 | connect(btn, SIGNAL(clicked() ), | 226 | connect(btn, SIGNAL(clicked() ), |
225 | this, SLOT( cdHome() ) ); | 227 | this, SLOT( cdHome() ) ); |
226 | 228 | ||
227 | btn = new QToolButton( box ); | 229 | btn = new QToolButton( box ); |
228 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); | 230 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); |
229 | connect(btn, SIGNAL(clicked() ), | 231 | connect(btn, SIGNAL(clicked() ), |
230 | this, SLOT(cdDoc() ) ); | 232 | this, SLOT(cdDoc() ) ); |
231 | 233 | ||
232 | m_btnNew = new QToolButton( box ); | 234 | m_btnNew = new QToolButton( box ); |
233 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); | 235 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); |
234 | connect(m_btnNew, SIGNAL(clicked() ), | 236 | connect(m_btnNew, SIGNAL(clicked() ), |
235 | this, SLOT(slotNew() ) ); | 237 | this, SLOT(slotNew() ) ); |
236 | 238 | ||
237 | 239 | ||
238 | m_btnClose = new QToolButton( box ); | 240 | m_btnClose = new QToolButton( box ); |
239 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); | 241 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); |
240 | connect(m_btnClose, SIGNAL(clicked() ), | 242 | connect(m_btnClose, SIGNAL(clicked() ), |
241 | selector(), SIGNAL(closeMe() ) ); | 243 | selector(), SIGNAL(closeMe() ) ); |
242 | 244 | ||
243 | btn = new QToolButton( box ); | 245 | btn = new QToolButton( box ); |
244 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); | 246 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); |
245 | 247 | ||
246 | /* let's fill device parts */ | 248 | /* let's fill device parts */ |
247 | QPopupMenu* pop = new QPopupMenu(this); | 249 | QPopupMenu* pop = new QPopupMenu(this); |
248 | connect(pop, SIGNAL( activated(int) ), | 250 | connect(pop, SIGNAL( activated(int) ), |
249 | this, SLOT(slotFSActivated(int) ) ); | 251 | this, SLOT(slotFSActivated(int) ) ); |
250 | 252 | ||
251 | StorageInfo storage; | 253 | StorageInfo storage; |
252 | const QList<FileSystem> &fs = storage.fileSystems(); | 254 | const QList<FileSystem> &fs = storage.fileSystems(); |
253 | QListIterator<FileSystem> it(fs); | 255 | QListIterator<FileSystem> it(fs); |
254 | for ( ; it.current(); ++it ) { | 256 | for ( ; it.current(); ++it ) { |
255 | const QString disk = (*it)->name(); | 257 | const QString disk = (*it)->name(); |
256 | const QString path = (*it)->path(); | 258 | const QString path = (*it)->path(); |
257 | m_dev.insert( disk, path ); | 259 | m_dev.insert( disk, path ); |
258 | pop->insertItem( disk ); | 260 | pop->insertItem( disk ); |
259 | } | 261 | } |
260 | m_fsPop = pop; | 262 | m_fsPop = pop; |
261 | 263 | ||
262 | 264 | ||
263 | btn->setPopup( pop ); | 265 | btn->setPopup( pop ); |
264 | btn->setPopupDelay ( 0 ); | 266 | btn->setPopupDelay ( 0 ); |
265 | lay->addWidget( box ); | 267 | lay->addWidget( box ); |
266 | 268 | ||
267 | m_view = new QListView( this ); | 269 | m_view = new QListView( this ); |
268 | 270 | ||
269 | m_view->installEventFilter(this); | 271 | m_view->installEventFilter(this); |
270 | 272 | ||
271 | QPEApplication::setStylusOperation( m_view->viewport(), | 273 | QPEApplication::setStylusOperation( m_view->viewport(), |
272 | QPEApplication::RightOnHold); | 274 | QPEApplication::RightOnHold); |
273 | m_view->addColumn(" " ); | 275 | m_view->addColumn(" " ); |
274 | m_view->addColumn(i18n("Name"), 135 ); | 276 | m_view->addColumn(i18n("Name"), 135 ); |
275 | m_view->addColumn(i18n("Size"), -1 ); | 277 | m_view->addColumn(i18n("Size"), -1 ); |
276 | m_view->addColumn(i18n("Date"), 60 ); | 278 | m_view->addColumn(i18n("Date"), 60 ); |
277 | m_view->addColumn(i18n("Mime Type"), -1 ); | 279 | m_view->addColumn(i18n("Mime Type"), -1 ); |
278 | 280 | ||
279 | 281 | ||
280 | m_view->setSorting( 1 ); | 282 | m_view->setSorting( 1 ); |
281 | m_view->setAllColumnsShowFocus( TRUE ); | 283 | m_view->setAllColumnsShowFocus( TRUE ); |
282 | 284 | ||
283 | lay->addWidget( m_view, 1000 ); | 285 | lay->addWidget( m_view, 1000 ); |
284 | connectSlots(); | 286 | connectSlots(); |
285 | } | 287 | } |
286 | OFileViewFileListView::~OFileViewFileListView() { | 288 | OFileViewFileListView::~OFileViewFileListView() { |
287 | } | 289 | } |
288 | void OFileViewFileListView::slotNew() { | 290 | void OFileViewFileListView::slotNew() { |
289 | DocLnk lnk; | 291 | DocLnk lnk; |
290 | emit selector()->newSelected( lnk ); | 292 | emit selector()->newSelected( lnk ); |
291 | } | 293 | } |
292 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | 294 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ |
293 | QListViewItem* item = m_view->currentItem(); | 295 | QListViewItem* item = m_view->currentItem(); |
294 | if (!item ) | 296 | if (!item ) |
295 | return 0l; | 297 | return 0l; |
296 | 298 | ||
297 | return static_cast<OFileSelectorItem*>(item); | 299 | return static_cast<OFileSelectorItem*>(item); |
298 | } | 300 | } |
299 | void OFileViewFileListView::reread( bool all ) { | 301 | void OFileViewFileListView::reread( bool all ) { |
300 | m_view->clear(); | 302 | m_view->clear(); |
301 | 303 | ||
302 | if (selector()->showClose() ) | 304 | if (selector()->showClose() ) |
303 | m_btnClose->show(); | 305 | m_btnClose->show(); |
304 | else | 306 | else |
305 | m_btnClose->hide(); | 307 | m_btnClose->hide(); |
306 | 308 | ||
307 | if (selector()->showNew() ) | 309 | if (selector()->showNew() ) |
308 | m_btnNew->show(); | 310 | m_btnNew->show(); |
309 | else | 311 | else |
310 | m_btnNew->hide(); | 312 | m_btnNew->hide(); |
311 | 313 | ||
312 | m_mimes = selector()->currentMimeType(); | 314 | m_mimes = selector()->currentMimeType(); |
313 | m_all = all; | 315 | m_all = all; |
314 | 316 | ||
315 | QDir dir( m_currentDir ); | 317 | QDir dir( m_currentDir ); |
316 | if (!dir.exists() ) | 318 | if (!dir.exists() ) |
317 | return; | 319 | return; |
318 | topLevelWidget()->setCaption( dir.path() ); | 320 | topLevelWidget()->setCaption( dir.path() ); |
319 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 321 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
320 | int filter; | 322 | int filter; |
321 | if (m_all ) | 323 | if (m_all ) |
322 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 324 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
323 | else | 325 | else |
324 | filter = QDir::Files | QDir::Dirs | QDir::All; | 326 | filter = QDir::Files | QDir::Dirs | QDir::All; |
325 | dir.setFilter( filter ); | 327 | dir.setFilter( filter ); |
326 | 328 | ||
327 | // now go through all files | 329 | // now go through all files |
328 | const QFileInfoList *list = dir.entryInfoList(); | 330 | const QFileInfoList *list = dir.entryInfoList(); |
329 | if (!list) { | 331 | if (!list) { |
330 | cdUP(); | 332 | cdUP(); |
331 | return; | 333 | return; |
332 | } | 334 | } |
333 | QFileInfoListIterator it( *list ); | 335 | QFileInfoListIterator it( *list ); |
334 | QFileInfo *fi; | 336 | QFileInfo *fi; |
335 | while( (fi=it.current() ) ){ | 337 | while( (fi=it.current() ) ){ |
336 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 338 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
337 | ++it; | 339 | ++it; |
338 | continue; | 340 | continue; |
339 | } | 341 | } |
340 | 342 | ||
341 | /* | 343 | /* |
342 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 344 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
343 | * | 345 | * |
344 | */ | 346 | */ |
345 | if( fi->isSymLink() ){ | 347 | if( fi->isSymLink() ){ |
346 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 348 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
347 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 349 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
348 | QFileInfo info( file ); | 350 | QFileInfo info( file ); |
349 | if( !info.exists() ){ | 351 | if( !info.exists() ){ |
350 | addSymlink( fi, TRUE ); | 352 | addSymlink( fi, TRUE ); |
351 | break; | 353 | break; |
352 | }else if( info.isDir() ){ | 354 | }else if( info.isDir() ){ |
353 | addDir( fi, TRUE ); | 355 | addDir( fi, TRUE ); |
354 | break; | 356 | break; |
355 | }else if( info.isFile() ){ | 357 | }else if( info.isFile() ){ |
356 | addFile( fi, TRUE ); | 358 | addFile( fi, TRUE ); |
357 | break; | 359 | break; |
358 | }else if( info.isSymLink() ){ | 360 | }else if( info.isSymLink() ){ |
359 | file = info.dirPath(true ) + "/" + info.readLink() ; | 361 | file = info.dirPath(true ) + "/" + info.readLink() ; |
360 | break; | 362 | break; |
361 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | 363 | }else if( i == 4){ // couldn't resolve symlink add it as symlink |
362 | addSymlink( fi ); | 364 | addSymlink( fi ); |
363 | } | 365 | } |
364 | } // off for loop for symlink resolving | 366 | } // off for loop for symlink resolving |
365 | }else if( fi->isDir() ) | 367 | }else if( fi->isDir() ) |
366 | addDir( fi ); | 368 | addDir( fi ); |
367 | else if( fi->isFile() ) | 369 | else if( fi->isFile() ) |
368 | addFile( fi ); | 370 | addFile( fi ); |
369 | 371 | ||
370 | ++it; | 372 | ++it; |
371 | } // of while loop | 373 | } // of while loop |
372 | m_view->sort(); | 374 | m_view->sort(); |
373 | 375 | ||
374 | } | 376 | } |
375 | int OFileViewFileListView::fileCount()const{ | 377 | int OFileViewFileListView::fileCount()const{ |
376 | return m_view->childCount(); | 378 | return m_view->childCount(); |
377 | } | 379 | } |
378 | QString OFileViewFileListView::currentDir()const{ | 380 | QString OFileViewFileListView::currentDir()const{ |
379 | return m_currentDir; | 381 | return m_currentDir; |
380 | } | 382 | } |
381 | OFileSelector* OFileViewFileListView::selector() { | 383 | OFileSelector* OFileViewFileListView::selector() { |
382 | return m_sel; | 384 | return m_sel; |
383 | } | 385 | } |
384 | 386 | ||
385 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | 387 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { |
386 | if ( e->type() == QEvent::KeyPress ) { | 388 | if ( e->type() == QEvent::KeyPress ) { |
387 | QKeyEvent *k = (QKeyEvent *)e; | 389 | QKeyEvent *k = (QKeyEvent *)e; |
388 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 390 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
389 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 391 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
390 | return true; | 392 | return true; |
391 | } | 393 | } |
392 | } | 394 | } |
393 | return false; | 395 | return false; |
394 | } | 396 | } |
395 | 397 | ||
396 | 398 | ||
397 | void OFileViewFileListView::connectSlots() { | 399 | void OFileViewFileListView::connectSlots() { |
398 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 400 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
399 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 401 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
400 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | 402 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), |
401 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | 403 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); |
402 | } | 404 | } |
403 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | 405 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { |
404 | if (!item) | 406 | if (!item) |
405 | return; | 407 | return; |
406 | #if 0 | 408 | #if 0 |
407 | 409 | ||
408 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 410 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
409 | 411 | ||
410 | if (!sel->isDir() ) { | 412 | if (!sel->isDir() ) { |
411 | selector()->m_lneEdit->setText( sel->text(1) ); | 413 | selector()->m_lneEdit->setText( sel->text(1) ); |
412 | // if in fileselector mode we will emit selected | 414 | // if in fileselector mode we will emit selected |
413 | if ( selector()->mode() == OFileSelector::FileSelector ) { | 415 | if ( selector()->mode() == OFileSelector::FileSelector ) { |
414 | qWarning("slot Current Changed"); | 416 | qWarning("slot Current Changed"); |
415 | QStringList str = QStringList::split("->", sel->text(1) ); | 417 | QStringList str = QStringList::split("->", sel->text(1) ); |
416 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 418 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
417 | emit selector()->fileSelected( path ); | 419 | emit selector()->fileSelected( path ); |
418 | DocLnk lnk( path ); | 420 | DocLnk lnk( path ); |
419 | emit selector()->fileSelected( lnk ); | 421 | emit selector()->fileSelected( lnk ); |
420 | } | 422 | } |
421 | } | 423 | } |
422 | #endif | 424 | #endif |
423 | } | 425 | } |
424 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { | 426 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { |
425 | if (!item || ( button != Qt::LeftButton) ) | 427 | if (!item || ( button != Qt::LeftButton) ) |
426 | return; | 428 | return; |
427 | 429 | ||
428 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 430 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
429 | if (!sel->isLocked() ) { | 431 | if (!sel->isLocked() ) { |
430 | QStringList str = QStringList::split("->", sel->text(1) ); | 432 | QStringList str = QStringList::split("->", sel->text(1) ); |
431 | if (sel->isDir() ) { | 433 | if (sel->isDir() ) { |
432 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 434 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
433 | emit selector()->dirSelected( m_currentDir ); | 435 | emit selector()->dirSelected( m_currentDir ); |
434 | reread( m_all ); | 436 | reread( m_all ); |
435 | }else { // file | 437 | }else { // file |
436 | qWarning("slot Clicked"); | 438 | qWarning("slot Clicked"); |
437 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 439 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
438 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 440 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
439 | emit selector()->fileSelected( path ); | 441 | emit selector()->fileSelected( path ); |
440 | DocLnk lnk( path ); | 442 | DocLnk lnk( path ); |
441 | emit selector()->fileSelected( lnk ); | 443 | emit selector()->fileSelected( lnk ); |
442 | } | 444 | } |
443 | } // not locked | 445 | } // not locked |
444 | } | 446 | } |
445 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { | 447 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { |
446 | MimeType type( info->absFilePath() ); | 448 | MimeType type( info->absFilePath() ); |
447 | if (!compliesMime( type.id() ) ) | 449 | if (!compliesMime( type.id() ) ) |
448 | return; | 450 | return; |
449 | 451 | ||
450 | QPixmap pix = type.pixmap(); | 452 | QPixmap pix = type.pixmap(); |
451 | QString dir, name; bool locked; | 453 | QString dir, name; bool locked; |
452 | if ( pix.isNull() ) { | 454 | if ( pix.isNull() ) { |
453 | QWMatrix matrix; | 455 | QWMatrix matrix; |
454 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 456 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
455 | matrix.scale( .4, .4 ); | 457 | matrix.scale( .4, .4 ); |
456 | pix = pixer.xForm( matrix ); | 458 | pix = pixer.xForm( matrix ); |
457 | } | 459 | } |
458 | dir = info->dirPath( true ); | 460 | dir = info->dirPath( true ); |
459 | locked = false; | 461 | locked = false; |
460 | if ( symlink ) | 462 | if ( symlink ) |
461 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 463 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
462 | else{ | 464 | else{ |
463 | name = info->fileName(); | 465 | name = info->fileName(); |
464 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 466 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
465 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { | 467 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { |
466 | locked = true; pix = Resource::loadPixmap("locked"); | 468 | locked = true; pix = Resource::loadPixmap("locked"); |
467 | } | 469 | } |
468 | } | 470 | } |
469 | (void)new OFileSelectorItem( m_view, pix, name, | 471 | (void)new OFileSelectorItem( m_view, pix, name, |
470 | info->lastModified().toString(), QString::number( info->size() ), | 472 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), |
473 | QString::number( info->size() ), | ||
471 | dir, locked ); | 474 | dir, locked ); |
472 | } | 475 | } |
473 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { | 476 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { |
474 | bool locked = false; QString name; QPixmap pix; | 477 | bool locked = false; QString name; QPixmap pix; |
475 | 478 | ||
476 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 479 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
477 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { | 480 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { |
478 | locked = true; | 481 | locked = true; |
479 | if ( symlink ) | 482 | if ( symlink ) |
480 | pix = Resource::loadPixmap( "symlink" ); | 483 | pix = Resource::loadPixmap( "symlink" ); |
481 | else | 484 | else |
482 | pix = Resource::loadPixmap( "lockedfolder" ); | 485 | pix = Resource::loadPixmap( "lockedfolder" ); |
483 | }else | 486 | }else |
484 | pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); | 487 | pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); |
485 | 488 | ||
486 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | 489 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : |
487 | info->fileName(); | 490 | info->fileName(); |
488 | 491 | ||
489 | (void)new OFileSelectorItem( m_view, pix, name, | 492 | (void)new OFileSelectorItem( m_view, pix, name, |
490 | info->lastModified().toString(), | 493 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), |
491 | QString::number( info->size() ), | 494 | QString::number( info->size() ), |
492 | info->dirPath( true ), locked, true ); | 495 | info->dirPath( true ), locked, true ); |
493 | 496 | ||
494 | 497 | ||
495 | } | 498 | } |
496 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { | 499 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { |
497 | 500 | ||
498 | } | 501 | } |
499 | void OFileViewFileListView::cdUP() { | 502 | void OFileViewFileListView::cdUP() { |
500 | QDir dir( m_currentDir ); | 503 | QDir dir( m_currentDir ); |
501 | dir.cdUp(); | 504 | dir.cdUp(); |
502 | 505 | ||
503 | if (!dir.exists() ) | 506 | if (!dir.exists() ) |
504 | m_currentDir = "/"; | 507 | m_currentDir = "/"; |
505 | else | 508 | else |
506 | m_currentDir = dir.absPath(); | 509 | m_currentDir = dir.absPath(); |
507 | 510 | ||
508 | emit selector()->dirSelected( m_currentDir ); | 511 | emit selector()->dirSelected( m_currentDir ); |
509 | reread( m_all ); | 512 | reread( m_all ); |
510 | } | 513 | } |
511 | void OFileViewFileListView::cdHome() { | 514 | void OFileViewFileListView::cdHome() { |
512 | m_currentDir = QDir::homeDirPath(); | 515 | m_currentDir = QDir::homeDirPath(); |
513 | emit selector()->dirSelected( m_currentDir ); | 516 | emit selector()->dirSelected( m_currentDir ); |
514 | reread( m_all ); | 517 | reread( m_all ); |
515 | } | 518 | } |
516 | void OFileViewFileListView::cdDoc() { | 519 | void OFileViewFileListView::cdDoc() { |
517 | m_currentDir = QPEApplication::documentDir(); | 520 | m_currentDir = QPEApplication::documentDir(); |
518 | emit selector()->dirSelected( m_currentDir ); | 521 | emit selector()->dirSelected( m_currentDir ); |
519 | reread( m_all ); | 522 | reread( m_all ); |
520 | } | 523 | } |
521 | void OFileViewFileListView::changeDir( const QString& dir ) { | 524 | void OFileViewFileListView::changeDir( const QString& dir ) { |
522 | m_currentDir = dir; | 525 | m_currentDir = dir; |
523 | emit selector()->dirSelected( m_currentDir ); | 526 | emit selector()->dirSelected( m_currentDir ); |
524 | reread( m_all ); | 527 | reread( m_all ); |
525 | } | 528 | } |
526 | void OFileViewFileListView::slotFSActivated( int id ) { | 529 | void OFileViewFileListView::slotFSActivated( int id ) { |
527 | changeDir ( m_dev[m_fsPop->text(id)] ); | 530 | changeDir ( m_dev[m_fsPop->text(id)] ); |
528 | } | 531 | } |
529 | 532 | ||
530 | /* check if the mimetype in mime | 533 | /* check if the mimetype in mime |
531 | * complies with the one which is current | 534 | * complies with the one which is current |
532 | */ | 535 | */ |
533 | /* | 536 | /* |
534 | * We've the mimetype of the file | 537 | * We've the mimetype of the file |
535 | * We need to get the stringlist of the current mimetype | 538 | * We need to get the stringlist of the current mimetype |
536 | * | 539 | * |
537 | * mime = image@slashjpeg | 540 | * mime = image@slashjpeg |
538 | * QStringList = 'image@slash*' | 541 | * QStringList = 'image@slash*' |
539 | * or QStringList = image/jpeg;image/png;application/x-ogg | 542 | * or QStringList = image/jpeg;image/png;application/x-ogg |
540 | * or QStringList = application/x-ogg;image@slash*; | 543 | * or QStringList = application/x-ogg;image@slash*; |
541 | * with all these mime filters it should get acceptes | 544 | * with all these mime filters it should get acceptes |
542 | * to do so we need to look if mime is contained inside | 545 | * to do so we need to look if mime is contained inside |
543 | * the stringlist | 546 | * the stringlist |
544 | * if it's contained return true | 547 | * if it's contained return true |
545 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 548 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
546 | * is contained in the mimefilter and then we will | 549 | * is contained in the mimefilter and then we will |
547 | * look if both are equal until the '/' | 550 | * look if both are equal until the '/' |
548 | */ | 551 | */ |
549 | bool OFileViewFileListView::compliesMime( const QString& str) { | 552 | bool OFileViewFileListView::compliesMime( const QString& str) { |
550 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 553 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
551 | return true; | 554 | return true; |
552 | 555 | ||
553 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | 556 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { |
554 | QRegExp reg( (*it) ); | 557 | QRegExp reg( (*it) ); |
555 | reg.setWildcard( true ); | 558 | reg.setWildcard( true ); |
556 | if ( str.find( reg ) != -1 ) | 559 | if ( str.find( reg ) != -1 ) |
557 | return true; | 560 | return true; |
558 | 561 | ||
559 | } | 562 | } |
560 | return false; | 563 | return false; |
561 | } | 564 | } |
562 | /* | 565 | /* |
563 | * The listView giving access to the file system! | 566 | * The listView giving access to the file system! |
564 | */ | 567 | */ |
565 | class OFileViewFileSystem : public OFileViewInterface { | 568 | class OFileViewFileSystem : public OFileViewInterface { |
566 | public: | 569 | public: |
567 | OFileViewFileSystem( OFileSelector* ); | 570 | OFileViewFileSystem( OFileSelector* ); |
568 | ~OFileViewFileSystem(); | 571 | ~OFileViewFileSystem(); |
569 | 572 | ||
570 | QString selectedName() const; | 573 | QString selectedName() const; |
571 | QString selectedPath() const; | 574 | QString selectedPath() const; |
572 | 575 | ||
573 | QString directory()const; | 576 | QString directory()const; |
574 | void reread(); | 577 | void reread(); |
575 | int fileCount()const; | 578 | int fileCount()const; |
576 | 579 | ||
577 | QWidget* widget( QWidget* parent ); | 580 | QWidget* widget( QWidget* parent ); |
578 | void activate( const QString& ); | 581 | void activate( const QString& ); |
579 | private: | 582 | private: |
580 | OFileViewFileListView* m_view; | 583 | OFileViewFileListView* m_view; |
581 | bool m_all : 1; | 584 | bool m_all : 1; |
582 | }; | 585 | }; |
583 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 586 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
584 | : OFileViewInterface( sel ) { | 587 | : OFileViewInterface( sel ) { |
585 | m_view = 0; | 588 | m_view = 0; |
586 | m_all = false; | 589 | m_all = false; |
587 | } | 590 | } |
588 | OFileViewFileSystem::~OFileViewFileSystem() { | 591 | OFileViewFileSystem::~OFileViewFileSystem() { |
589 | } | 592 | } |
590 | QString OFileViewFileSystem::selectedName()const{ | 593 | QString OFileViewFileSystem::selectedName()const{ |
591 | if (!m_view ) | 594 | if (!m_view ) |
592 | return QString::null; | 595 | return QString::null; |
593 | 596 | ||
594 | QString cFN=currentFileName(); | 597 | QString cFN=currentFileName(); |
595 | if (cFN.startsWith("/")) return cFN; | 598 | if (cFN.startsWith("/")) return cFN; |
596 | return m_view->currentDir() + "/" + cFN; | 599 | return m_view->currentDir() + "/" + cFN; |
597 | } | 600 | } |
598 | QString OFileViewFileSystem::selectedPath()const{ | 601 | QString OFileViewFileSystem::selectedPath()const{ |
599 | return QString::null; | 602 | return QString::null; |
600 | } | 603 | } |
601 | QString OFileViewFileSystem::directory()const{ | 604 | QString OFileViewFileSystem::directory()const{ |
602 | if (!m_view) | 605 | if (!m_view) |
603 | return QString::null; | 606 | return QString::null; |
604 | 607 | ||
605 | OFileSelectorItem* item = m_view->currentItem(); | 608 | OFileSelectorItem* item = m_view->currentItem(); |
606 | if (!item ) | 609 | if (!item ) |
607 | return QString::null; | 610 | return QString::null; |
608 | 611 | ||
609 | return QDir(item->directory() ).absPath(); | 612 | return QDir(item->directory() ).absPath(); |
610 | } | 613 | } |
611 | void OFileViewFileSystem::reread() { | 614 | void OFileViewFileSystem::reread() { |
612 | if (!m_view) | 615 | if (!m_view) |
613 | return; | 616 | return; |
614 | 617 | ||
615 | m_view->reread( m_all ); | 618 | m_view->reread( m_all ); |
616 | } | 619 | } |
617 | int OFileViewFileSystem::fileCount()const{ | 620 | int OFileViewFileSystem::fileCount()const{ |
618 | if (!m_view ) | 621 | if (!m_view ) |
619 | return -1; | 622 | return -1; |
620 | return m_view->fileCount(); | 623 | return m_view->fileCount(); |
621 | } | 624 | } |
622 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | 625 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { |
623 | if (!m_view ) { | 626 | if (!m_view ) { |
624 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 627 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
625 | } | 628 | } |
626 | return m_view; | 629 | return m_view; |
627 | } | 630 | } |
628 | void OFileViewFileSystem::activate( const QString& str) { | 631 | void OFileViewFileSystem::activate( const QString& str) { |
629 | m_all = (str !=i18n("Files") ); | 632 | m_all = (str !=i18n("Files") ); |
630 | 633 | ||
631 | 634 | ||
632 | } | 635 | } |
633 | 636 | ||
634 | /* Selector */ | 637 | /* Selector */ |
635 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 638 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
636 | const QString& dirName, const QString& fileName, | 639 | const QString& dirName, const QString& fileName, |
637 | const MimeTypes& mimetypes, | 640 | const MimeTypes& mimetypes, |
638 | bool showNew, bool showClose) | 641 | bool showNew, bool showClose) |
639 | : QWidget( parent, "OFileSelector" ) | 642 | : QWidget( parent, "OFileSelector" ) |
640 | { | 643 | { |
641 | m_current = 0; | 644 | m_current = 0; |
642 | m_shNew = showNew; | 645 | m_shNew = showNew; |
643 | m_shClose = showClose; | 646 | m_shClose = showClose; |
644 | m_mimeType = mimetypes; | 647 | m_mimeType = mimetypes; |
645 | m_startDir = dirName; | 648 | m_startDir = dirName; |
646 | m_mode = mode; | 649 | m_mode = mode; |
647 | m_selector = sel; | 650 | m_selector = sel; |
648 | 651 | ||
649 | initUI(); | 652 | initUI(); |
650 | m_lneEdit->setText( fileName ); | 653 | m_lneEdit->setText( fileName ); |
651 | initMime(); | 654 | initMime(); |
652 | initViews(); | 655 | initViews(); |
653 | 656 | ||
654 | QString str; | 657 | QString str; |
655 | switch ( m_selector ) { | 658 | switch ( m_selector ) { |
656 | default: | 659 | default: |
657 | case Normal: | 660 | case Normal: |
658 | str = i18n("Documents"); | 661 | str = i18n("Documents"); |
659 | m_cmbView->setCurrentItem( 0 ); | 662 | m_cmbView->setCurrentItem( 0 ); |
660 | break; | 663 | break; |
661 | case Extended: | 664 | case Extended: |
662 | str = i18n("Files"); | 665 | str = i18n("Files"); |
663 | m_cmbView->setCurrentItem( 1 ); | 666 | m_cmbView->setCurrentItem( 1 ); |
664 | break; | 667 | break; |
665 | case ExtendedAll: | 668 | case ExtendedAll: |
666 | str = i18n("All Files"); | 669 | str = i18n("All Files"); |
667 | m_cmbView->setCurrentItem( 2 ); | 670 | m_cmbView->setCurrentItem( 2 ); |
668 | break; | 671 | break; |
669 | } | 672 | } |
670 | slotViewChange( str ); | 673 | slotViewChange( str ); |
671 | 674 | ||
672 | } | 675 | } |
673 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 676 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
674 | bool showNew, bool showClose ) | 677 | bool showNew, bool showClose ) |
675 | : QWidget( parent, name ) | 678 | : QWidget( parent, name ) |
676 | { | 679 | { |
677 | m_current = 0; | 680 | m_current = 0; |
678 | m_shNew = showNew; | 681 | m_shNew = showNew; |
679 | m_shClose = showClose; | 682 | m_shClose = showClose; |
680 | m_startDir = QPEApplication::documentDir(); | 683 | m_startDir = QPEApplication::documentDir(); |
681 | 684 | ||
682 | if (!mimeFilter.isEmpty() ) | 685 | if (!mimeFilter.isEmpty() ) |
683 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 686 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
684 | 687 | ||
685 | m_mode = OFileSelector::FileSelector; | 688 | m_mode = OFileSelector::FileSelector; |
686 | m_selector = OFileSelector::Normal; | 689 | m_selector = OFileSelector::Normal; |
687 | 690 | ||
688 | initUI(); | 691 | initUI(); |
689 | initMime(); | 692 | initMime(); |
690 | initViews(); | 693 | initViews(); |
691 | m_cmbView->setCurrentItem( 0 ); | 694 | m_cmbView->setCurrentItem( 0 ); |
692 | slotViewChange( i18n("Documents") ); | 695 | slotViewChange( i18n("Documents") ); |
693 | } | 696 | } |
694 | /* | 697 | /* |
695 | * INIT UI will set up the basic GUI | 698 | * INIT UI will set up the basic GUI |
696 | * Layout: Simple VBoxLayout | 699 | * Layout: Simple VBoxLayout |
697 | * On top a WidgetStack containing the Views... | 700 | * On top a WidgetStack containing the Views... |
698 | * - List View | 701 | * - List View |
699 | * - Document View | 702 | * - Document View |
700 | * Below we will have a Label + LineEdit | 703 | * Below we will have a Label + LineEdit |
701 | * Below we will have two ComoBoxes one for choosing the view one for | 704 | * Below we will have two ComoBoxes one for choosing the view one for |
702 | * choosing the mimetype | 705 | * choosing the mimetype |
703 | */ | 706 | */ |
704 | void OFileSelector::initUI() { | 707 | void OFileSelector::initUI() { |
705 | QVBoxLayout* lay = new QVBoxLayout( this ); | 708 | QVBoxLayout* lay = new QVBoxLayout( this ); |
706 | 709 | ||
707 | m_stack = new QWidgetStack( this ); | 710 | m_stack = new QWidgetStack( this ); |
708 | lay->addWidget( m_stack, 1000 ); | 711 | lay->addWidget( m_stack, 1000 ); |
709 | 712 | ||
710 | m_nameBox = new QHBox( this ); | 713 | m_nameBox = new QHBox( this ); |
711 | (void)new QLabel( i18n("Name:"), m_nameBox ); | 714 | (void)new QLabel( i18n("Name:"), m_nameBox ); |
712 | m_lneEdit = new QLineEdit( m_nameBox ); | 715 | m_lneEdit = new QLineEdit( m_nameBox ); |
713 | m_lneEdit ->installEventFilter(this); | 716 | m_lneEdit ->installEventFilter(this); |
714 | lay->addWidget( m_nameBox ); | 717 | lay->addWidget( m_nameBox ); |
715 | 718 | ||
716 | m_cmbBox = new QHBox( this ); | 719 | m_cmbBox = new QHBox( this ); |
717 | m_cmbView = new QComboBox( m_cmbBox ); | 720 | m_cmbView = new QComboBox( m_cmbBox ); |
718 | m_cmbMime = new QComboBox( m_cmbBox ); | 721 | m_cmbMime = new QComboBox( m_cmbBox ); |
719 | lay->addWidget( m_cmbBox ); | 722 | lay->addWidget( m_cmbBox ); |
720 | } | 723 | } |
721 | 724 | ||
722 | /* | 725 | /* |
723 | * This will make sure that the return key in the name edit causes dialogs to close | 726 | * This will make sure that the return key in the name edit causes dialogs to close |
724 | */ | 727 | */ |
725 | 728 | ||
726 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { | 729 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { |
727 | if ( e->type() == QEvent::KeyPress ) { | 730 | if ( e->type() == QEvent::KeyPress ) { |
728 | QKeyEvent *k = (QKeyEvent *)e; | 731 | QKeyEvent *k = (QKeyEvent *)e; |
729 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 732 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
730 | emit ok(); | 733 | emit ok(); |
731 | return true; | 734 | return true; |
732 | } | 735 | } |
733 | } | 736 | } |
734 | return false; | 737 | return false; |
735 | } | 738 | } |
736 | 739 | ||
737 | /* | 740 | /* |
738 | * This will insert the MimeTypes into the Combo Box | 741 | * This will insert the MimeTypes into the Combo Box |
739 | * And also connect the changed signal | 742 | * And also connect the changed signal |
740 | * | 743 | * |
741 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 744 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
742 | */ | 745 | */ |
743 | void OFileSelector::initMime() { | 746 | void OFileSelector::initMime() { |
744 | MimeTypes::Iterator it; | 747 | MimeTypes::Iterator it; |
745 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { | 748 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { |
746 | m_cmbMime->insertItem( it.key() ); | 749 | m_cmbMime->insertItem( it.key() ); |