summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp16
-rw-r--r--libkcal/incidencebase.cpp81
-rw-r--r--libkcal/incidencebase.h8
3 files changed, 92 insertions, 13 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index df05ab3..c23978d 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -174,199 +174,196 @@ icalcomponent *ICalFormatImpl::writeEvent(Event *event)
174#if 0 174#if 0
175 // attachments 175 // attachments
176 tmpStrList = anEvent->attachments(); 176 tmpStrList = anEvent->attachments();
177 for ( QStringList::Iterator it = tmpStrList.begin(); 177 for ( QStringList::Iterator it = tmpStrList.begin();
178 it != tmpStrList.end(); 178 it != tmpStrList.end();
179 ++it ) 179 ++it )
180 addPropValue(vevent, VCAttachProp, (*it).utf8()); 180 addPropValue(vevent, VCAttachProp, (*it).utf8());
181 181
182 // resources 182 // resources
183 tmpStrList = anEvent->resources(); 183 tmpStrList = anEvent->resources();
184 tmpStr = tmpStrList.join(";"); 184 tmpStr = tmpStrList.join(";");
185 if (!tmpStr.isEmpty()) 185 if (!tmpStr.isEmpty())
186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); 186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8());
187 187
188#endif 188#endif
189 189
190 // Transparency 190 // Transparency
191 switch( event->transparency() ) { 191 switch( event->transparency() ) {
192 case Event::Transparent: 192 case Event::Transparent:
193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); 193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT));
194 break; 194 break;
195 case Event::Opaque: 195 case Event::Opaque:
196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); 196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
197 break; 197 break;
198 } 198 }
199 199
200 return vevent; 200 return vevent;
201} 201}
202 202
203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, 203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
204 Scheduler::Method method) 204 Scheduler::Method method)
205{ 205{
206#if QT_VERSION >= 300 206#if QT_VERSION >= 300
207 kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " 207 kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: "
208 << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " 208 << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: "
209 << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; 209 << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl;
210#endif 210#endif
211 211
212 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); 212 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
213 213
214 writeIncidenceBase(vfreebusy,freebusy); 214 writeIncidenceBase(vfreebusy,freebusy);
215 215
216 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( 216 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart(
217 writeICalDateTime(freebusy->dtStart()))); 217 writeICalDateTime(freebusy->dtStart())));
218 218
219 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( 219 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend(
220 writeICalDateTime(freebusy->dtEnd()))); 220 writeICalDateTime(freebusy->dtEnd())));
221 221
222 if (method == Scheduler::Request) { 222 if (method == Scheduler::Request) {
223 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 223 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
224 freebusy->uid().utf8())); 224 freebusy->uid().utf8()));
225 } 225 }
226 226
227 //Loops through all the periods in the freebusy object 227 //Loops through all the periods in the freebusy object
228 QValueList<Period> list = freebusy->busyPeriods(); 228 QValueList<Period> list = freebusy->busyPeriods();
229 QValueList<Period>::Iterator it; 229 QValueList<Period>::Iterator it;
230 icalperiodtype period; 230 icalperiodtype period;
231 for (it = list.begin(); it!= list.end(); ++it) { 231 for (it = list.begin(); it!= list.end(); ++it) {
232 period.start = writeICalDateTime((*it).start()); 232 period.start = writeICalDateTime((*it).start());
233 period.end = writeICalDateTime((*it).end()); 233 period.end = writeICalDateTime((*it).end());
234 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 234 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
235 } 235 }
236 236
237 return vfreebusy; 237 return vfreebusy;
238} 238}
239 239
240icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 240icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
241{ 241{
242 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); 242 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
243 243
244 writeIncidence(vjournal,journal); 244 writeIncidence(vjournal,journal);
245 245
246 // start time 246 // start time
247 if (journal->dtStart().isValid()) { 247 if (journal->dtStart().isValid()) {
248 icaltimetype start; 248 icaltimetype start;
249 if (journal->doesFloat()) { 249 if (journal->doesFloat()) {
250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
251 start = writeICalDate(journal->dtStart().date()); 251 start = writeICalDate(journal->dtStart().date());
252 } else { 252 } else {
253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
254 start = writeICalDateTime(journal->dtStart()); 254 start = writeICalDateTime(journal->dtStart());
255 } 255 }
256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
257 } 257 }
258 258
259 return vjournal; 259 return vjournal;
260} 260}
261 261
262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
263{ 263{
264 // pilot sync stuff 264 // pilot sync stuff
265// TODO: move this application-specific code to kpilot 265// TODO: move this application-specific code to kpilot
266 if (incidence->pilotId()) { 266 if (incidence->pilotId()) {
267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
269 } 269 }
270 if (incidence->zaurusId() >= 0) { 270 if ( !incidence->IDStr().isEmpty()) {
271 incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); 271 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
272 } 272 }
273 273
274 if (incidence->zaurusUid() > 0) {
275 incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid()));
276 }
277 274
278 writeIncidenceBase(parent,incidence); 275 writeIncidenceBase(parent,incidence);
279 if (incidence->cancelled()) { 276 if (incidence->cancelled()) {
280 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 277 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
281 } 278 }
282 279
283 // creation date 280 // creation date
284 icalcomponent_add_property(parent,icalproperty_new_created( 281 icalcomponent_add_property(parent,icalproperty_new_created(
285 writeICalDateTime(incidence->created()))); 282 writeICalDateTime(incidence->created())));
286 283
287 // unique id 284 // unique id
288 icalcomponent_add_property(parent,icalproperty_new_uid( 285 icalcomponent_add_property(parent,icalproperty_new_uid(
289 incidence->uid().utf8())); 286 incidence->uid().utf8()));
290 287
291 // revision 288 // revision
292 icalcomponent_add_property(parent,icalproperty_new_sequence( 289 icalcomponent_add_property(parent,icalproperty_new_sequence(
293 incidence->revision())); 290 incidence->revision()));
294 291
295 // last modification date 292 // last modification date
296 icalcomponent_add_property(parent,icalproperty_new_lastmodified( 293 icalcomponent_add_property(parent,icalproperty_new_lastmodified(
297 writeICalDateTime(incidence->lastModified()))); 294 writeICalDateTime(incidence->lastModified())));
298 295
299 // description 296 // description
300 if (!incidence->description().isEmpty()) { 297 if (!incidence->description().isEmpty()) {
301 icalcomponent_add_property(parent,icalproperty_new_description( 298 icalcomponent_add_property(parent,icalproperty_new_description(
302 incidence->description().utf8())); 299 incidence->description().utf8()));
303 } 300 }
304 301
305 // summary 302 // summary
306 if (!incidence->summary().isEmpty()) { 303 if (!incidence->summary().isEmpty()) {
307 icalcomponent_add_property(parent,icalproperty_new_summary( 304 icalcomponent_add_property(parent,icalproperty_new_summary(
308 incidence->summary().utf8())); 305 incidence->summary().utf8()));
309 } 306 }
310 307
311 // location 308 // location
312 if (!incidence->location().isEmpty()) { 309 if (!incidence->location().isEmpty()) {
313 icalcomponent_add_property(parent,icalproperty_new_location( 310 icalcomponent_add_property(parent,icalproperty_new_location(
314 incidence->location().utf8())); 311 incidence->location().utf8()));
315 } 312 }
316 313
317// TODO: 314// TODO:
318 // status 315 // status
319// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); 316// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
320 317
321 // secrecy 318 // secrecy
322 enum icalproperty_class classInt; 319 enum icalproperty_class classInt;
323 switch (incidence->secrecy()) { 320 switch (incidence->secrecy()) {
324 case Incidence::SecrecyPublic: 321 case Incidence::SecrecyPublic:
325 classInt = ICAL_CLASS_PUBLIC; 322 classInt = ICAL_CLASS_PUBLIC;
326 break; 323 break;
327 case Incidence::SecrecyConfidential: 324 case Incidence::SecrecyConfidential:
328 classInt = ICAL_CLASS_CONFIDENTIAL; 325 classInt = ICAL_CLASS_CONFIDENTIAL;
329 break; 326 break;
330 case Incidence::SecrecyPrivate: 327 case Incidence::SecrecyPrivate:
331 classInt =ICAL_CLASS_PRIVATE ; 328 classInt =ICAL_CLASS_PRIVATE ;
332 default: 329 default:
333 classInt =ICAL_CLASS_PRIVATE ; 330 classInt =ICAL_CLASS_PRIVATE ;
334 break; 331 break;
335 } 332 }
336 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 333 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
337 334
338 // priority 335 // priority
339 icalcomponent_add_property(parent,icalproperty_new_priority( 336 icalcomponent_add_property(parent,icalproperty_new_priority(
340 incidence->priority())); 337 incidence->priority()));
341 338
342 // categories 339 // categories
343 QStringList categories = incidence->categories(); 340 QStringList categories = incidence->categories();
344 QStringList::Iterator it; 341 QStringList::Iterator it;
345 for(it = categories.begin(); it != categories.end(); ++it ) { 342 for(it = categories.begin(); it != categories.end(); ++it ) {
346 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 343 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
347 } 344 }
348// TODO: Ensure correct concatenation of categories properties. 345// TODO: Ensure correct concatenation of categories properties.
349 346
350/* 347/*
351 // categories 348 // categories
352 tmpStrList = incidence->getCategories(); 349 tmpStrList = incidence->getCategories();
353 tmpStr = ""; 350 tmpStr = "";
354 QString catStr; 351 QString catStr;
355 for ( QStringList::Iterator it = tmpStrList.begin(); 352 for ( QStringList::Iterator it = tmpStrList.begin();
356 it != tmpStrList.end(); 353 it != tmpStrList.end();
357 ++it ) { 354 ++it ) {
358 catStr = *it; 355 catStr = *it;
359 if (catStr[0] == ' ') 356 if (catStr[0] == ' ')
360 tmpStr += catStr.mid(1); 357 tmpStr += catStr.mid(1);
361 else 358 else
362 tmpStr += catStr; 359 tmpStr += catStr;
363 // this must be a ';' character as the vCalendar specification requires! 360 // this must be a ';' character as the vCalendar specification requires!
364 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 361 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
365 // read in. 362 // read in.
366 tmpStr += ";"; 363 tmpStr += ";";
367 } 364 }
368 if (!tmpStr.isEmpty()) { 365 if (!tmpStr.isEmpty()) {
369 tmpStr.truncate(tmpStr.length()-1); 366 tmpStr.truncate(tmpStr.length()-1);
370 icalcomponent_add_property(parent,icalproperty_new_categories( 367 icalcomponent_add_property(parent,icalproperty_new_categories(
371 writeText(incidence->getCategories().join(";")))); 368 writeText(incidence->getCategories().join(";"))));
372 } 369 }
@@ -1187,200 +1184,197 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1187 icalduration = icalproperty_get_duration(p); 1184 icalduration = icalproperty_get_duration(p);
1188 incidence->setDuration(readICalDuration(icalduration)); 1185 incidence->setDuration(readICalDuration(icalduration));
1189 break; 1186 break;
1190 1187
1191 case ICAL_DESCRIPTION_PROPERTY: // description 1188 case ICAL_DESCRIPTION_PROPERTY: // description
1192 text = icalproperty_get_description(p); 1189 text = icalproperty_get_description(p);
1193 incidence->setDescription(QString::fromUtf8(text)); 1190 incidence->setDescription(QString::fromUtf8(text));
1194 break; 1191 break;
1195 1192
1196 case ICAL_SUMMARY_PROPERTY: // summary 1193 case ICAL_SUMMARY_PROPERTY: // summary
1197 { 1194 {
1198 text = icalproperty_get_summary(p); 1195 text = icalproperty_get_summary(p);
1199 incidence->setSummary(QString::fromUtf8(text)); 1196 incidence->setSummary(QString::fromUtf8(text));
1200 } 1197 }
1201 break; 1198 break;
1202 case ICAL_STATUS_PROPERTY: // summary 1199 case ICAL_STATUS_PROPERTY: // summary
1203 { 1200 {
1204 if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) 1201 if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) )
1205 incidence->setCancelled( true ); 1202 incidence->setCancelled( true );
1206 } 1203 }
1207 break; 1204 break;
1208 1205
1209 case ICAL_LOCATION_PROPERTY: // location 1206 case ICAL_LOCATION_PROPERTY: // location
1210 text = icalproperty_get_location(p); 1207 text = icalproperty_get_location(p);
1211 incidence->setLocation(QString::fromUtf8(text)); 1208 incidence->setLocation(QString::fromUtf8(text));
1212 break; 1209 break;
1213 1210
1214#if 0 1211#if 0
1215 // status 1212 // status
1216 if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { 1213 if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) {
1217 incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); 1214 incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo)));
1218 deleteStr(s); 1215 deleteStr(s);
1219 } 1216 }
1220 else 1217 else
1221 incidence->setStatus("NEEDS ACTION"); 1218 incidence->setStatus("NEEDS ACTION");
1222#endif 1219#endif
1223 1220
1224 case ICAL_PRIORITY_PROPERTY: // priority 1221 case ICAL_PRIORITY_PROPERTY: // priority
1225 intvalue = icalproperty_get_priority(p); 1222 intvalue = icalproperty_get_priority(p);
1226 incidence->setPriority(intvalue); 1223 incidence->setPriority(intvalue);
1227 break; 1224 break;
1228 1225
1229 case ICAL_CATEGORIES_PROPERTY: // categories 1226 case ICAL_CATEGORIES_PROPERTY: // categories
1230 text = icalproperty_get_categories(p); 1227 text = icalproperty_get_categories(p);
1231 categories.append(QString::fromUtf8(text)); 1228 categories.append(QString::fromUtf8(text));
1232 break; 1229 break;
1233 //******************************************* 1230 //*******************************************
1234 case ICAL_RRULE_PROPERTY: 1231 case ICAL_RRULE_PROPERTY:
1235 // we do need (maybe )start datetime of incidence for recurrence 1232 // we do need (maybe )start datetime of incidence for recurrence
1236 // such that we can read recurrence only after we read incidence completely 1233 // such that we can read recurrence only after we read incidence completely
1237 readrec = true; 1234 readrec = true;
1238 rectype = icalproperty_get_rrule(p); 1235 rectype = icalproperty_get_rrule(p);
1239 break; 1236 break;
1240 1237
1241 case ICAL_EXDATE_PROPERTY: 1238 case ICAL_EXDATE_PROPERTY:
1242 icaltime = icalproperty_get_exdate(p); 1239 icaltime = icalproperty_get_exdate(p);
1243 incidence->addExDate(readICalDate(icaltime)); 1240 incidence->addExDate(readICalDate(icaltime));
1244 break; 1241 break;
1245 1242
1246 case ICAL_CLASS_PROPERTY: { 1243 case ICAL_CLASS_PROPERTY: {
1247 int inttext = icalproperty_get_class(p); 1244 int inttext = icalproperty_get_class(p);
1248 if (inttext == ICAL_CLASS_PUBLIC ) { 1245 if (inttext == ICAL_CLASS_PUBLIC ) {
1249 incidence->setSecrecy(Incidence::SecrecyPublic); 1246 incidence->setSecrecy(Incidence::SecrecyPublic);
1250 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { 1247 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) {
1251 incidence->setSecrecy(Incidence::SecrecyConfidential); 1248 incidence->setSecrecy(Incidence::SecrecyConfidential);
1252 } else { 1249 } else {
1253 incidence->setSecrecy(Incidence::SecrecyPrivate); 1250 incidence->setSecrecy(Incidence::SecrecyPrivate);
1254 } 1251 }
1255 } 1252 }
1256 break; 1253 break;
1257 1254
1258 case ICAL_ATTACH_PROPERTY: // attachments 1255 case ICAL_ATTACH_PROPERTY: // attachments
1259 incidence->addAttachment(readAttachment(p)); 1256 incidence->addAttachment(readAttachment(p));
1260 break; 1257 break;
1261 1258
1262 default: 1259 default:
1263// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind 1260// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
1264// << endl; 1261// << endl;
1265 break; 1262 break;
1266 } 1263 }
1267 1264
1268 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1265 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1269 } 1266 }
1270 if ( readrec ) { 1267 if ( readrec ) {
1271 readRecurrenceRule(rectype,incidence); 1268 readRecurrenceRule(rectype,incidence);
1272 } 1269 }
1273 // kpilot stuff 1270 // kpilot stuff
1274// TODO: move this application-specific code to kpilot 1271// TODO: move this application-specific code to kpilot
1275 QString kp = incidence->nonKDECustomProperty("X-PILOTID"); 1272 QString kp = incidence->nonKDECustomProperty("X-PILOTID");
1276 if (!kp.isNull()) { 1273 if (!kp.isNull()) {
1277 incidence->setPilotId(kp.toInt()); 1274 incidence->setPilotId(kp.toInt());
1278 } 1275 }
1279 kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); 1276 kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
1280 if (!kp.isNull()) { 1277 if (!kp.isNull()) {
1281 incidence->setSyncStatus(kp.toInt()); 1278 incidence->setSyncStatus(kp.toInt());
1282 } 1279 }
1283 kp = incidence->nonKDECustomProperty("X-ZAURUSID");
1284 if (!kp.isNull()) {
1285 incidence->setZaurusId(kp.toInt());
1286 }
1287 1280
1288 kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); 1281
1282 kp = incidence->nonKDECustomProperty("X-KOPIEXTID");
1289 if (!kp.isNull()) { 1283 if (!kp.isNull()) {
1290 incidence->setZaurusUid(kp.toInt()); 1284 incidence->setIDStr(kp);
1291 } 1285 }
1292 1286
1293 // Cancel backwards compatibility mode for subsequent changes by the application 1287 // Cancel backwards compatibility mode for subsequent changes by the application
1294 incidence->recurrence()->setCompatVersion(); 1288 incidence->recurrence()->setCompatVersion();
1295 1289
1296 // add categories 1290 // add categories
1297 incidence->setCategories(categories); 1291 incidence->setCategories(categories);
1298 1292
1299 // iterate through all alarms 1293 // iterate through all alarms
1300 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); 1294 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
1301 alarm; 1295 alarm;
1302 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { 1296 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
1303 readAlarm(alarm,incidence); 1297 readAlarm(alarm,incidence);
1304 } 1298 }
1305} 1299}
1306 1300
1307void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 1301void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
1308{ 1302{
1309 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1303 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1310 1304
1311 while (p) { 1305 while (p) {
1312 icalproperty_kind kind = icalproperty_isa(p); 1306 icalproperty_kind kind = icalproperty_isa(p);
1313 switch (kind) { 1307 switch (kind) {
1314 1308
1315 case ICAL_UID_PROPERTY: // unique id 1309 case ICAL_UID_PROPERTY: // unique id
1316 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); 1310 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p)));
1317 break; 1311 break;
1318 1312
1319 case ICAL_ORGANIZER_PROPERTY: // organizer 1313 case ICAL_ORGANIZER_PROPERTY: // organizer
1320 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); 1314 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p)));
1321 break; 1315 break;
1322 1316
1323 case ICAL_ATTENDEE_PROPERTY: // attendee 1317 case ICAL_ATTENDEE_PROPERTY: // attendee
1324 incidenceBase->addAttendee(readAttendee(p)); 1318 incidenceBase->addAttendee(readAttendee(p));
1325 break; 1319 break;
1326 1320
1327 default: 1321 default:
1328 break; 1322 break;
1329 } 1323 }
1330 1324
1331 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1325 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1332 } 1326 }
1333 1327
1334 // custom properties 1328 // custom properties
1335 readCustomProperties(parent, incidenceBase); 1329 readCustomProperties(parent, incidenceBase);
1336} 1330}
1337 1331
1338void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1332void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1339{ 1333{
1340 QMap<QCString, QString> customProperties; 1334 QMap<QCString, QString> customProperties;
1341 1335
1342 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); 1336 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY);
1343 1337
1344 while (p) { 1338 while (p) {
1345 QString value = QString::fromUtf8(icalproperty_get_x(p)); 1339 QString value = QString::fromUtf8(icalproperty_get_x(p));
1346 customProperties[icalproperty_get_x_name(p)] = value; 1340 customProperties[icalproperty_get_x_name(p)] = value;
1347 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); 1341 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) );
1348 1342
1349 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); 1343 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY);
1350 } 1344 }
1351 1345
1352 properties->setCustomProperties(customProperties); 1346 properties->setCustomProperties(customProperties);
1353} 1347}
1354 1348
1355void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) 1349void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence)
1356{ 1350{
1357// kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; 1351// kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl;
1358 1352
1359 Recurrence *recur = incidence->recurrence(); 1353 Recurrence *recur = incidence->recurrence();
1360 recur->setCompatVersion(mCalendarVersion); 1354 recur->setCompatVersion(mCalendarVersion);
1361 recur->unsetRecurs(); 1355 recur->unsetRecurs();
1362 1356
1363 struct icalrecurrencetype r = rrule; 1357 struct icalrecurrencetype r = rrule;
1364 1358
1365 dumpIcalRecurrence(r); 1359 dumpIcalRecurrence(r);
1366 readRecurrence( r, recur, incidence); 1360 readRecurrence( r, recur, incidence);
1367} 1361}
1368 1362
1369void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) 1363void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence)
1370{ 1364{
1371 int wkst; 1365 int wkst;
1372 int index = 0; 1366 int index = 0;
1373 short day = 0; 1367 short day = 0;
1374 QBitArray qba(7); 1368 QBitArray qba(7);
1375 int frequ = r.freq; 1369 int frequ = r.freq;
1376 int interv = r.interval; 1370 int interv = r.interval;
1377 // preprocessing for odd recurrence definitions 1371 // preprocessing for odd recurrence definitions
1378 1372
1379 if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { 1373 if ( r.freq == ICAL_MONTHLY_RECURRENCE ) {
1380 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { 1374 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
1381 interv = 12; 1375 interv = 12;
1382 } 1376 }
1383 } 1377 }
1384 if ( r.freq == ICAL_YEARLY_RECURRENCE ) { 1378 if ( r.freq == ICAL_YEARLY_RECURRENCE ) {
1385 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { 1379 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
1386 frequ = ICAL_MONTHLY_RECURRENCE; 1380 frequ = ICAL_MONTHLY_RECURRENCE;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 707d666..d7c4595 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,179 +1,180 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidencebase.h" 27#include "incidencebase.h"
28 28
29using namespace KCal; 29using namespace KCal;
30 30
31IncidenceBase::IncidenceBase() : 31IncidenceBase::IncidenceBase() :
32 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 32 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
33 mPilotId(0), mSyncStatus(SYNCMOD) 33 mPilotId(0), mSyncStatus(SYNCMOD)
34{ 34{
35 setUid(CalFormat::createUniqueId()); 35 setUid(CalFormat::createUniqueId());
36 mOrganizer = ""; 36 mOrganizer = "";
37 mFloats = false; 37 mFloats = false;
38 mDuration = 0; 38 mDuration = 0;
39 mHasDuration = false; 39 mHasDuration = false;
40 mPilotId = 0; 40 mPilotId = 0;
41 mZaurusId = -1; 41 mZaurusId = -1;
42 mZaurusUid = 0; 42 mZaurusUid = 0;
43 mExternalId = ":";
43 mTempSyncStat = 0; 44 mTempSyncStat = 0;
44 mSyncStatus = 0; 45 mSyncStatus = 0;
45 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
46} 47}
47 48
48IncidenceBase::IncidenceBase(const IncidenceBase &i) : 49IncidenceBase::IncidenceBase(const IncidenceBase &i) :
49 CustomProperties( i ) 50 CustomProperties( i )
50{ 51{
51 mReadOnly = i.mReadOnly; 52 mReadOnly = i.mReadOnly;
52 mDtStart = i.mDtStart; 53 mDtStart = i.mDtStart;
53 mDuration = i.mDuration; 54 mDuration = i.mDuration;
54 mHasDuration = i.mHasDuration; 55 mHasDuration = i.mHasDuration;
55 mOrganizer = i.mOrganizer; 56 mOrganizer = i.mOrganizer;
56 mUid = i.mUid; 57 mUid = i.mUid;
57 QPtrList<Attendee> attendees = i.attendees(); 58 QPtrList<Attendee> attendees = i.attendees();
58 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 59 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
59 mAttendees.append( new Attendee( *a ) ); 60 mAttendees.append( new Attendee( *a ) );
60 } 61 }
61 mFloats = i.mFloats; 62 mFloats = i.mFloats;
62 mLastModified = i.mLastModified; 63 mLastModified = i.mLastModified;
63 mPilotId = i.mPilotId; 64 mPilotId = i.mPilotId;
64 mZaurusId = i.mZaurusId; 65 mZaurusId = i.mZaurusId;
65 mZaurusUid = i.mZaurusUid; 66 mZaurusUid = i.mZaurusUid;
66 mTempSyncStat = i.mTempSyncStat; 67 mTempSyncStat = i.mTempSyncStat;
67 mSyncStatus = i.mSyncStatus; 68 mSyncStatus = i.mSyncStatus;
68 69 mExternalId = i.mExternalId;
69 // The copied object is a new one, so it isn't observed by the observer 70 // The copied object is a new one, so it isn't observed by the observer
70 // of the original object. 71 // of the original object.
71 mObservers.clear(); 72 mObservers.clear();
72 73
73 mAttendees.setAutoDelete( true ); 74 mAttendees.setAutoDelete( true );
74} 75}
75 76
76IncidenceBase::~IncidenceBase() 77IncidenceBase::~IncidenceBase()
77{ 78{
78} 79}
79 80
80 81
81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 82bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
82{ 83{
83 84 // do not compare mSyncStatus and mExternalId
84 if( i1.attendees().count() != i2.attendees().count() ) { 85 if( i1.attendees().count() != i2.attendees().count() ) {
85 return false; // no need to check further 86 return false; // no need to check further
86 } 87 }
87 if ( i1.attendees().count() > 0 ) { 88 if ( i1.attendees().count() > 0 ) {
88 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 89 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
89 while ( a1 ) { 90 while ( a1 ) {
90 if ( !( (*a1) == (*a2)) ) 91 if ( !( (*a1) == (*a2)) )
91 { 92 {
92 //qDebug("Attendee not equal "); 93 //qDebug("Attendee not equal ");
93 return false; 94 return false;
94 } 95 }
95 a1 = i1.attendees().next(); 96 a1 = i1.attendees().next();
96 a2 = i2.attendees().next(); 97 a2 = i2.attendees().next();
97 } 98 }
98 } 99 }
99 //if ( i1.dtStart() != i2.dtStart() ) 100 //if ( i1.dtStart() != i2.dtStart() )
100 // return false; 101 // return false;
101#if 0 102#if 0
102 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 103 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
103 qDebug("1 %d ",i1.duration() == i2.duration() ); 104 qDebug("1 %d ",i1.duration() == i2.duration() );
104 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 105 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
105 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 106 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
106 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 107 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
107 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 108 qDebug("6 %d ",i1.organizer() == i2.organizer() );
108 109
109#endif 110#endif
110 return ( i1.organizer() == i2.organizer() && 111 return ( i1.organizer() == i2.organizer() &&
111 // i1.uid() == i2.uid() && 112 // i1.uid() == i2.uid() &&
112 // Don't compare lastModified, otherwise the operator is not 113 // Don't compare lastModified, otherwise the operator is not
113 // of much use. We are not comparing for identity, after all. 114 // of much use. We are not comparing for identity, after all.
114 i1.doesFloat() == i2.doesFloat() && 115 i1.doesFloat() == i2.doesFloat() &&
115 i1.duration() == i2.duration() && 116 i1.duration() == i2.duration() &&
116 i1.hasDuration() == i2.hasDuration() && 117 i1.hasDuration() == i2.hasDuration() &&
117 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 118 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
118 // no need to compare mObserver 119 // no need to compare mObserver
119} 120}
120 121
121 122
122QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 123QDateTime IncidenceBase::getEvenTime( QDateTime dt )
123{ 124{
124 QTime t = dt.time(); 125 QTime t = dt.time();
125 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 126 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
126 return dt; 127 return dt;
127} 128}
128 129
129 130
130void IncidenceBase::setUid(const QString &uid) 131void IncidenceBase::setUid(const QString &uid)
131{ 132{
132 mUid = uid; 133 mUid = uid;
133 updated(); 134 updated();
134} 135}
135 136
136QString IncidenceBase::uid() const 137QString IncidenceBase::uid() const
137{ 138{
138 return mUid; 139 return mUid;
139} 140}
140 141
141void IncidenceBase::setLastModified(const QDateTime &lm) 142void IncidenceBase::setLastModified(const QDateTime &lm)
142{ 143{
143 // DON'T! updated() because we call this from 144 // DON'T! updated() because we call this from
144 // Calendar::updateEvent(). 145 // Calendar::updateEvent().
145 mLastModified = getEvenTime(lm); 146 mLastModified = getEvenTime(lm);
146 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 147 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
147} 148}
148 149
149QDateTime IncidenceBase::lastModified() const 150QDateTime IncidenceBase::lastModified() const
150{ 151{
151 return mLastModified; 152 return mLastModified;
152} 153}
153 154
154void IncidenceBase::setOrganizer(const QString &o) 155void IncidenceBase::setOrganizer(const QString &o)
155{ 156{
156 // we don't check for readonly here, because it is 157 // we don't check for readonly here, because it is
157 // possible that by setting the organizer we are changing 158 // possible that by setting the organizer we are changing
158 // the event's readonly status... 159 // the event's readonly status...
159 mOrganizer = o; 160 mOrganizer = o;
160 if (mOrganizer.left(7).upper() == "MAILTO:") 161 if (mOrganizer.left(7).upper() == "MAILTO:")
161 mOrganizer = mOrganizer.remove(0,7); 162 mOrganizer = mOrganizer.remove(0,7);
162 163
163 updated(); 164 updated();
164} 165}
165 166
166QString IncidenceBase::organizer() const 167QString IncidenceBase::organizer() const
167{ 168{
168 return mOrganizer; 169 return mOrganizer;
169} 170}
170 171
171void IncidenceBase::setReadOnly( bool readOnly ) 172void IncidenceBase::setReadOnly( bool readOnly )
172{ 173{
173 mReadOnly = readOnly; 174 mReadOnly = readOnly;
174} 175}
175 176
176void IncidenceBase::setDtStart(const QDateTime &dtStart) 177void IncidenceBase::setDtStart(const QDateTime &dtStart)
177{ 178{
178// if (mReadOnly) return; 179// if (mReadOnly) return;
179 mDtStart = getEvenTime(dtStart); 180 mDtStart = getEvenTime(dtStart);
@@ -279,115 +280,191 @@ Attendee *IncidenceBase::attendeeByMail(const QString &email)
279 return 0L; 280 return 0L;
280} 281}
281 282
282Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 283Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
283{ 284{
284 QPtrListIterator<Attendee> qli(mAttendees); 285 QPtrListIterator<Attendee> qli(mAttendees);
285 286
286 QStringList mails = emails; 287 QStringList mails = emails;
287 if (!email.isEmpty()) { 288 if (!email.isEmpty()) {
288 mails.append(email); 289 mails.append(email);
289 } 290 }
290 qli.toFirst(); 291 qli.toFirst();
291 while (qli) { 292 while (qli) {
292 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 293 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
293 if (qli.current()->email() == *it) 294 if (qli.current()->email() == *it)
294 return qli.current(); 295 return qli.current();
295 } 296 }
296 297
297 ++qli; 298 ++qli;
298 } 299 }
299 return 0L; 300 return 0L;
300} 301}
301 302
302void IncidenceBase::setDuration(int seconds) 303void IncidenceBase::setDuration(int seconds)
303{ 304{
304 mDuration = seconds; 305 mDuration = seconds;
305 setHasDuration(true); 306 setHasDuration(true);
306} 307}
307 308
308int IncidenceBase::duration() const 309int IncidenceBase::duration() const
309{ 310{
310 return mDuration; 311 return mDuration;
311} 312}
312 313
313void IncidenceBase::setHasDuration(bool b) 314void IncidenceBase::setHasDuration(bool b)
314{ 315{
315 mHasDuration = b; 316 mHasDuration = b;
316} 317}
317 318
318bool IncidenceBase::hasDuration() const 319bool IncidenceBase::hasDuration() const
319{ 320{
320 return mHasDuration; 321 return mHasDuration;
321} 322}
322 323
323void IncidenceBase::setSyncStatus(int stat) 324void IncidenceBase::setSyncStatus(int stat)
324{ 325{
325 if (mReadOnly) return; 326 if (mReadOnly) return;
326 mSyncStatus = stat; 327 mSyncStatus = stat;
327} 328}
328 329
329int IncidenceBase::syncStatus() const 330int IncidenceBase::syncStatus() const
330{ 331{
331 return mSyncStatus; 332 return mSyncStatus;
332} 333}
333 334
334void IncidenceBase::setPilotId( int id ) 335void IncidenceBase::setPilotId( int id )
335{ 336{
336 if (mReadOnly) return; 337 if (mReadOnly) return;
337 mPilotId = id; 338 mPilotId = id;
338} 339}
339 340
340int IncidenceBase::pilotId() const 341int IncidenceBase::pilotId() const
341{ 342{
342 return mPilotId; 343 return mPilotId;
343} 344}
344void IncidenceBase::setZaurusId( int id ) 345void IncidenceBase::setZaurusId( int id )
345{ 346{
346 if (mReadOnly) return; 347 if (mReadOnly) return;
347 mZaurusId = id; 348 mZaurusId = id;
348} 349}
349 350
350int IncidenceBase::zaurusId() const 351int IncidenceBase::zaurusId() const
351{ 352{
352 return mZaurusId; 353 return mZaurusId;
353} 354}
354 355
355int IncidenceBase::zaurusUid() const 356int IncidenceBase::zaurusUid() const
356{ 357{
357 return mZaurusUid; 358 return mZaurusUid;
358} 359}
359void IncidenceBase::setZaurusUid( int id ) 360void IncidenceBase::setZaurusUid( int id )
360{ 361{
361 if (mReadOnly) return; 362 if (mReadOnly) return;
362 mZaurusUid = id; 363 mZaurusUid = id;
363} 364}
364 365
365int IncidenceBase::tempSyncStat() const 366int IncidenceBase::tempSyncStat() const
366{ 367{
367 return mTempSyncStat; 368 return mTempSyncStat;
368} 369}
369void IncidenceBase::setTempSyncStat( int id ) 370void IncidenceBase::setTempSyncStat( int id )
370{ 371{
371 if (mReadOnly) return; 372 if (mReadOnly) return;
372 mTempSyncStat = id; 373 mTempSyncStat = id;
373} 374}
374 375
376void IncidenceBase::setID( const QString & prof , int id )
377{
378 int num = mExternalId.find( ":"+prof+";" );
379 if ( num >= 0 ) {
380 int len = prof.length()+2;
381 int end = mExternalId.find( ";", num+len );
382 if ( end > 0 ) {
383 mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end );
384 } else
385 qDebug("Error in IncidenceBase::setID ");
386 } else {
387 mExternalId += prof+";"+QString::number( id) +";0:";
388 }
389}
390int IncidenceBase::getID( const QString & prof)
391{
392 int ret = -1;
393 int num = mExternalId.find(":"+ prof+";" );
394 if ( num >= 0 ) {
395 int len = prof.length()+2;
396 int end = mExternalId.find( ";", num+len );
397 if ( end > 0 ) {
398 bool ok;
399 ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok );
400 if (!ok)
401 return -1;
402 }
403 }
404 return ret;
405}
406
407// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0:
408// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
409void IncidenceBase::setCsum( const QString & prof , int id )
410{
411 int num = mExternalId.find( ":"+prof+";");
412 if ( num >= 0 ) {
413 int len = prof.length()+2;
414 num = mExternalId.find( ";", num+len );
415 int end = mExternalId.find( ":", num+1 );
416 if ( end > 0 ) {
417 mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end );
418 } else
419 qDebug("Error in IncidenceBase::setCsum ");
420 } else {
421 mExternalId += prof+";-1;"+QString::number( id) +":";
422 }
423}
424int IncidenceBase::getCsum( const QString & prof)
425{
426 int ret = -1;
427 int num = mExternalId.find( ":"+prof+";" );
428 if ( num >= 0 ) {
429 int len = prof.length()+2;
430 num = mExternalId.find( ";", num+len );
431 int end = mExternalId.find( ":", num+1 );
432 if ( end > 0 ) {
433 bool ok;
434 ret = mExternalId.mid ( num ,end-num).toInt( &ok );
435 if (!ok)
436 return -1;
437 }
438 }
439 return ret;
440}
441
442void IncidenceBase::setIDStr( const QString & s )
443{
444 if (mReadOnly) return;
445 mExternalId = s;
446}
447
448QString IncidenceBase::IDStr() const
449{
450 return mExternalId ;
451}
375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 452void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
376{ 453{
377 if( !mObservers.contains(observer) ) mObservers.append( observer ); 454 if( !mObservers.contains(observer) ) mObservers.append( observer );
378} 455}
379 456
380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 457void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
381{ 458{
382 mObservers.remove( observer ); 459 mObservers.remove( observer );
383} 460}
384 461
385void IncidenceBase::updated() 462void IncidenceBase::updated()
386{ 463{
387 QPtrListIterator<Observer> it(mObservers); 464 QPtrListIterator<Observer> it(mObservers);
388 while( it.current() ) { 465 while( it.current() ) {
389 Observer *o = it.current(); 466 Observer *o = it.current();
390 ++it; 467 ++it;
391 o->incidenceUpdated( this ); 468 o->incidenceUpdated( this );
392 } 469 }
393} 470}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index ce6e254..2f85df6 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -39,132 +39,140 @@ typedef QValueList<QDate> DateList;
39 This class provides the base class common to all calendar components. 39 This class provides the base class common to all calendar components.
40*/ 40*/
41class IncidenceBase : public CustomProperties 41class IncidenceBase : public CustomProperties
42{ 42{
43 public: 43 public:
44 class Observer { 44 class Observer {
45 public: 45 public:
46 virtual void incidenceUpdated( IncidenceBase * ) = 0; 46 virtual void incidenceUpdated( IncidenceBase * ) = 0;
47 }; 47 };
48 48
49 IncidenceBase(); 49 IncidenceBase();
50 IncidenceBase(const IncidenceBase &); 50 IncidenceBase(const IncidenceBase &);
51 virtual ~IncidenceBase(); 51 virtual ~IncidenceBase();
52 52
53 virtual QCString type() const = 0; 53 virtual QCString type() const = 0;
54 54
55 /** Set the unique id for the event */ 55 /** Set the unique id for the event */
56 void setUid(const QString &); 56 void setUid(const QString &);
57 /** Return the unique id for the event */ 57 /** Return the unique id for the event */
58 QString uid() const; 58 QString uid() const;
59 59
60 /** Sets the time the incidence was last modified. */ 60 /** Sets the time the incidence was last modified. */
61 void setLastModified(const QDateTime &lm); 61 void setLastModified(const QDateTime &lm);
62 /** Return the time the incidence was last modified. */ 62 /** Return the time the incidence was last modified. */
63 QDateTime lastModified() const; 63 QDateTime lastModified() const;
64 64
65 /** sets the organizer for the event */ 65 /** sets the organizer for the event */
66 void setOrganizer(const QString &o); 66 void setOrganizer(const QString &o);
67 QString organizer() const; 67 QString organizer() const;
68 68
69 /** Set readonly status. */ 69 /** Set readonly status. */
70 virtual void setReadOnly( bool ); 70 virtual void setReadOnly( bool );
71 /** Return if the object is read-only. */ 71 /** Return if the object is read-only. */
72 bool isReadOnly() const { return mReadOnly; } 72 bool isReadOnly() const { return mReadOnly; }
73 73
74 /** for setting the event's starting date/time with a QDateTime. */ 74 /** for setting the event's starting date/time with a QDateTime. */
75 virtual void setDtStart(const QDateTime &dtStart); 75 virtual void setDtStart(const QDateTime &dtStart);
76 /** returns an event's starting date/time as a QDateTime. */ 76 /** returns an event's starting date/time as a QDateTime. */
77 QDateTime dtStart() const; 77 QDateTime dtStart() const;
78 /** returns an event's starting time as a string formatted according to the 78 /** returns an event's starting time as a string formatted according to the
79 users locale settings */ 79 users locale settings */
80 QString dtStartTimeStr() const; 80 QString dtStartTimeStr() const;
81 /** returns an event's starting date as a string formatted according to the 81 /** returns an event's starting date as a string formatted according to the
82 users locale settings */ 82 users locale settings */
83 QString dtStartDateStr(bool shortfmt=true) const; 83 QString dtStartDateStr(bool shortfmt=true) const;
84 /** returns an event's starting date and time as a string formatted according 84 /** returns an event's starting date and time as a string formatted according
85 to the users locale settings */ 85 to the users locale settings */
86 QString dtStartStr(bool shortfmt=true) const; 86 QString dtStartStr(bool shortfmt=true) const;
87 87
88 virtual void setDuration(int seconds); 88 virtual void setDuration(int seconds);
89 int duration() const; 89 int duration() const;
90 void setHasDuration(bool); 90 void setHasDuration(bool);
91 bool hasDuration() const; 91 bool hasDuration() const;
92 92
93 /** Return true or false depending on whether the incidence "floats," 93 /** Return true or false depending on whether the incidence "floats,"
94 * i.e. has a date but no time attached to it. */ 94 * i.e. has a date but no time attached to it. */
95 bool doesFloat() const; 95 bool doesFloat() const;
96 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 96 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
97 void setFloats(bool f); 97 void setFloats(bool f);
98 98
99 /** 99 /**
100 Add Attendee to this incidence. IncidenceBase takes ownership of the 100 Add Attendee to this incidence. IncidenceBase takes ownership of the
101 Attendee object. 101 Attendee object.
102 */ 102 */
103 void addAttendee(Attendee *a, bool doupdate=true ); 103 void addAttendee(Attendee *a, bool doupdate=true );
104// void removeAttendee(Attendee *a); 104// void removeAttendee(Attendee *a);
105// void removeAttendee(const char *n); 105// void removeAttendee(const char *n);
106 /** Remove all Attendees. */ 106 /** Remove all Attendees. */
107 void clearAttendees(); 107 void clearAttendees();
108 /** Return list of attendees. */ 108 /** Return list of attendees. */
109 QPtrList<Attendee> attendees() const { return mAttendees; }; 109 QPtrList<Attendee> attendees() const { return mAttendees; };
110 /** Return number of attendees. */ 110 /** Return number of attendees. */
111 int attendeeCount() const { return mAttendees.count(); }; 111 int attendeeCount() const { return mAttendees.count(); };
112 /** Return the Attendee with this email */ 112 /** Return the Attendee with this email */
113 Attendee* attendeeByMail(const QString &); 113 Attendee* attendeeByMail(const QString &);
114 /** Return first Attendee with one of this emails */ 114 /** Return first Attendee with one of this emails */
115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
116 116
117 /** pilot syncronization states */ 117 /** pilot syncronization states */
118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
119 /** Set synchronisation satus. */ 119 /** Set synchronisation satus. */
120 void setSyncStatus(int stat); 120 void setSyncStatus(int stat);
121 /** Return synchronisation status. */ 121 /** Return synchronisation status. */
122 int syncStatus() const; 122 int syncStatus() const;
123 123
124 /** Set Pilot Id. */ 124 /** Set Pilot Id. */
125 void setPilotId(int id); 125 void setPilotId(int id);
126 /** Return Pilot Id. */ 126 /** Return Pilot Id. */
127 int pilotId() const; 127 int pilotId() const;
128 128
129 void setZaurusId(int id); 129 void setZaurusId(int id);
130 int zaurusId() const; 130 int zaurusId() const;
131 void setZaurusUid(int id); 131 void setZaurusUid(int id);
132 int zaurusUid() const; 132 int zaurusUid() const;
133 void setTempSyncStat(int id); 133 void setTempSyncStat(int id);
134 int tempSyncStat() const; 134 int tempSyncStat() const;
135 void setIDStr( const QString & );
136 QString IDStr() const;
137 void setID( const QString &, int );
138 int getID( const QString & );
139 void setCsum( const QString &, int );
140 int getCsum( const QString & );
141
135 142
136 void registerObserver( Observer * ); 143 void registerObserver( Observer * );
137 void unRegisterObserver( Observer * ); 144 void unRegisterObserver( Observer * );
138 void updated(); 145 void updated();
139 146
140 protected: 147 protected:
141 bool mReadOnly; 148 bool mReadOnly;
142 QDateTime getEvenTime( QDateTime ); 149 QDateTime getEvenTime( QDateTime );
143 150
144 private: 151 private:
145 // base components 152 // base components
146 QDateTime mDtStart; 153 QDateTime mDtStart;
147 QString mOrganizer; 154 QString mOrganizer;
148 QString mUid; 155 QString mUid;
149 QDateTime mLastModified; 156 QDateTime mLastModified;
150 QPtrList<Attendee> mAttendees; 157 QPtrList<Attendee> mAttendees;
151 158
152 bool mFloats; 159 bool mFloats;
153 160
154 int mDuration; 161 int mDuration;
155 bool mHasDuration; 162 bool mHasDuration;
163 QString mExternalId;
156 int mZaurusId; 164 int mZaurusId;
157 int mZaurusUid; 165 int mZaurusUid;
158 int mTempSyncStat; 166 int mTempSyncStat;
159 167
160 // PILOT SYNCHRONIZATION STUFF 168 // PILOT SYNCHRONIZATION STUFF
161 int mPilotId; // unique id for pilot sync 169 int mPilotId; // unique id for pilot sync
162 int mSyncStatus; // status (for sync) 170 int mSyncStatus; // status (for sync)
163 171
164 QPtrList<Observer> mObservers; 172 QPtrList<Observer> mObservers;
165}; 173};
166 174
167bool operator==( const IncidenceBase&, const IncidenceBase& ); 175bool operator==( const IncidenceBase&, const IncidenceBase& );
168} 176}
169 177
170#endif 178#endif