194 else |
195 else |
195 { |
196 { |
196 caltime.SetTimeUtcL(recurrenceId); |
197 caltime.SetTimeUtcL(recurrenceId); |
197 } |
198 } |
198 |
199 |
199 iEntry = CCalEntry::NewL(entryType,guid8, methodStatus, seqNumber, caltime, CalCommon::EThisOnly); |
200 iEntry = CCalEntry::NewL(entryType, guid8, methodStatus, seqNumber, |
|
201 caltime, CalCommon::EThisOnly); |
200 } |
202 } |
201 |
203 |
202 CleanupStack::Pop(guid8); // ownership was passed to calGSData |
204 CleanupStack::Pop(guid8); // ownership was passed to calGSData |
203 // Fill in the entry description from the SUMMARY property |
205 // Fill in the entry description from the SUMMARY property |
204 // If this doesn't exist, use the DESCRIPTION property, and if this |
206 // If this doesn't exist, use the DESCRIPTION property, and if this |
205 // doesn't exist, return a NULL entry |
207 // doesn't exist, return a NULL entry |
206 |
208 |
207 // get properties but don't take ownership of the elements of the array |
209 if (entryType != CCalEntry::ENote) |
208 CArrayPtr<CParserProperty>* properties = aParser.PropertyL(KVersitTokenSUMMARY, TUid::Uid(KVersitPropertyHBufCUid), EFalse); |
210 { |
209 |
211 ImportVCalendarL(aParser, relativeTime, entryType); |
|
212 } |
|
213 else |
|
214 { |
|
215 ImportNoteL(aParser,relativeTime); |
|
216 } |
|
217 |
|
218 // Import favourite property. The type will be converted to an usigned integer |
|
219 // implicitly. |
|
220 TInt favourite = 0; |
|
221 TBool integerFound = ImportIntegerPropertyL( |
|
222 aParser, KVCalTokenXFavourite, favourite ); |
|
223 |
|
224 if(integerFound) |
|
225 { |
|
226 iEntry->SetFavouriteL(favourite); |
|
227 } |
|
228 |
|
229 aEntryArray.AppendL(iEntry); // takes ownership of entry |
|
230 iEntry = NULL; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CVCalToAgendaEntryConverter::ImportVCalendarL |
|
235 // Imports vcalendar for calendar types EAppt/EReminder/EAnniv/ETodo/EEvent |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CVCalToAgendaEntryConverter::ImportVCalendarL(CVersitParser& aParser, |
|
239 TVersitDateTime::TRelativeTime& aRelativeTime, |
|
240 CCalEntry::TType& aEntryType) |
|
241 { |
|
242 // Fill in the entry description from the SUMMARY property |
|
243 // If this doesn't exist, use the DESCRIPTION property, and if this |
|
244 // doesn't exist, return a NULL entry |
|
245 |
|
246 // get properties but don't take ownership of the elements of the array |
|
247 CArrayPtr<CParserProperty>* properties = aParser.PropertyL( |
|
248 KVersitTokenSUMMARY, TUid::Uid(KVersitPropertyHBufCUid), EFalse); |
|
249 |
210 if (!properties) |
250 if (!properties) |
211 { |
251 { |
212 // get properties but don't take ownership of the elements of the array |
252 // get properties but don't take ownership of the elements of the array |
213 properties = aParser.PropertyL(KVersitTokenDESCRIPTION, TUid::Uid(KVersitPropertyHBufCUid), EFalse); |
253 properties = aParser.PropertyL(KVersitTokenDESCRIPTION, |
|
254 TUid::Uid(KVersitPropertyHBufCUid), EFalse); |
214 } |
255 } |
215 CleanupStack::PushL(properties); |
256 CleanupStack::PushL(properties); |
216 |
257 |
217 // Use the value found from the Summary/Description |
258 // Use the value found from the Summary/Description |
218 // Both Summary and Description are not found in imported vCal file |
259 // Both Summary and Description are not found in imported vCal file |
219 //then insert empty enties for summary and description |
260 //then insert empty enties for summary and description |
220 // these empty entries will be descarded while exporting vCal file |
261 // these empty entries will be descarded while exporting vCal file |
221 TPtrC summary; |
262 TPtrC summary; |
222 if (properties) |
263 if (properties) |
223 { |
264 { |
224 summary.Set(static_cast<CParserPropertyValueHBufC*>((*properties)[0]->Value())->Value()); |
265 summary.Set(static_cast<CParserPropertyValueHBufC*>( |
|
266 (*properties)[0]->Value())->Value()); |
225 } |
267 } |
226 |
268 |
227 HBufC* summaryBuf = AgnConvertUtil::EncodeL(summary,KUidTextToEtextNoTrim); |
269 HBufC* summaryBuf = AgnConvertUtil::EncodeL(summary,KUidTextToEtextNoTrim); |
228 CleanupStack::PushL(summaryBuf); |
270 CleanupStack::PushL(summaryBuf); |
229 if (summaryBuf) |
271 if (summaryBuf) |
230 { |
272 { |
231 iEntry->SetSummaryL(*summaryBuf); |
273 iEntry->SetSummaryL(*summaryBuf); |
232 } |
274 } |
233 CleanupStack::PopAndDestroy(summaryBuf); |
275 CleanupStack::PopAndDestroy(summaryBuf); |
234 |
276 |
235 HBufC* description =ImportDesPropertyL(aParser,KVersitTokenDESCRIPTION); |
277 HBufC* description =ImportDesPropertyL(aParser,KVersitTokenDESCRIPTION); |
236 CleanupStack::PushL(description); |
278 CleanupStack::PushL(description); |
237 if (description != NULL) |
279 if (description != NULL) |
238 { |
280 { |
239 iEntry->SetDescriptionL(*description); // Takes ownership |
281 iEntry->SetDescriptionL(*description); // Takes ownership |
240 } |
282 } |
241 CleanupStack::PopAndDestroy(description); |
283 CleanupStack::PopAndDestroy(description); |
242 |
284 |
243 TBool validEntry = EFalse; |
285 TBool validEntry = EFalse; |
244 if (entryType == CCalEntry::ETodo) |
286 if (aEntryType == CCalEntry::ETodo) |
245 { |
287 { |
246 validEntry = ImportTodoPropertiesL(aParser); |
288 validEntry = ImportTodoPropertiesL(aParser); |
247 } |
289 } |
248 else |
290 else |
249 { |
291 { |
269 iEntry->SetReplicationStatusL(CCalEntry::EPrivate); |
311 iEntry->SetReplicationStatusL(CCalEntry::EPrivate); |
270 else if (*property == KVCalTokenCONFIDENTIAL) |
312 else if (*property == KVCalTokenCONFIDENTIAL) |
271 iEntry->SetReplicationStatusL(CCalEntry::ERestricted); |
313 iEntry->SetReplicationStatusL(CCalEntry::ERestricted); |
272 CleanupStack::PopAndDestroy(property); |
314 CleanupStack::PopAndDestroy(property); |
273 } |
315 } |
|
316 |
274 // Import LOCATION property |
317 // Import LOCATION property |
275 property=ImportDesPropertyL(aParser, KVersitTokenLOCATION); |
318 HBufC* locationProperty=ImportDesPropertyL(aParser, KVersitTokenLOCATION); |
276 if (property) |
319 if (locationProperty) |
277 { |
320 { |
278 CleanupStack::PushL(property); |
321 CleanupStack::PushL(locationProperty); |
279 iEntry->SetLocationL(*property); |
322 iEntry->SetLocationL(*locationProperty); |
280 CleanupStack::PopAndDestroy(property); |
323 CleanupStack::PopAndDestroy(locationProperty); |
281 } |
324 } |
282 // Import DTSTAMP |
325 // Import DTSTAMP |
283 TTime timeProperty; |
326 TTime timeProperty; |
284 if (ImportDateTimePropertyL(aParser, KVersitTokenXDTSTAMP, timeProperty, relativeTime)) |
327 if (ImportDateTimePropertyL(aParser, KVersitTokenXDTSTAMP, timeProperty, |
|
328 aRelativeTime)) |
285 { |
329 { |
286 TCalTime caltimeProperty; |
330 TCalTime caltimeProperty; |
287 caltimeProperty.SetTimeUtcL(timeProperty); |
331 caltimeProperty.SetTimeUtcL(timeProperty); |
288 iEntry->SetDTStampL(caltimeProperty); |
332 iEntry->SetDTStampL(caltimeProperty); |
289 } |
333 } |
290 |
334 |
291 // Attendee property |
335 // Attendee property |
292 ImportAttendeePropertiesL(aParser, KVersitTokenATTENDEE); |
336 ImportAttendeePropertiesL(aParser, KVersitTokenATTENDEE); |
293 |
337 |
294 // Categories property |
338 // Categories property |
295 ImportCategoriesPropertyL(aParser, KVersitTokenCATEGORIES); |
339 ImportCategoriesPropertyL(aParser, KVersitTokenCATEGORIES); |
296 |
340 |
297 |
341 |
298 |
|
299 TInt localId; |
342 TInt localId; |
300 if (ImportIntegerPropertyL(aParser, KVersitTokenXLOCALUID, localId)) |
343 if (ImportIntegerPropertyL(aParser, KVersitTokenXLOCALUID, localId)) |
301 { |
344 { |
302 iEntry->SetLocalUidL(localId); |
345 iEntry->SetLocalUidL(localId); |
303 } |
346 } |
306 // All entries have a priority not just ToDo's |
349 // All entries have a priority not just ToDo's |
307 // Todo Functionality merged into this code block |
350 // Todo Functionality merged into this code block |
308 TInt priority; |
351 TInt priority; |
309 if (ImportIntegerPropertyL(aParser, KVersitTokenPRIORITY, priority)) |
352 if (ImportIntegerPropertyL(aParser, KVersitTokenPRIORITY, priority)) |
310 { |
353 { |
311 iEntry->SetPriorityL(priority); |
354 iEntry->SetPriorityL(priority); |
312 } |
355 } |
313 |
356 |
314 // All entries have a status - will default to Needs Action if cannot be read |
357 // All entries have a status - will default to Needs Action if cannot be read |
315 CCalEntry::TStatus entryStatus=CCalEntry::ENullStatus; |
358 CCalEntry::TStatus entryStatus=CCalEntry::ENullStatus; |
316 ImportStatusPropertyL(aParser, entryStatus); |
359 ImportStatusPropertyL(aParser, entryStatus); |
317 //Now sync completed and ECompleted status to keep entry consistenty |
360 //Now sync completed and ECompleted status to keep entry consistenty |
318 if(entryType==CCalEntry::ETodo && (iEntry->CompletedTimeL().TimeUtcL()) != Time::NullTTime()) |
361 if (aEntryType == CCalEntry::ETodo |
|
362 && (iEntry->CompletedTimeL().TimeUtcL()) != Time::NullTTime()) |
319 { |
363 { |
320 iEntry->SetCompletedL(ETrue, iEntry->CompletedTimeL()); |
364 iEntry->SetCompletedL(ETrue, iEntry->CompletedTimeL()); |
321 } |
365 } |
322 iEntry->SetStatusL(entryStatus); |
366 iEntry->SetStatusL(entryStatus); |
323 |
367 |
324 //Get last changed date from vcal |
368 //Get last changed date from vcal |
325 if (ImportDateTimePropertyL(aParser, KVersitTokenLASTMODIFIED, timeProperty, relativeTime)) |
369 if (ImportDateTimePropertyL(aParser, KVersitTokenLASTMODIFIED, |
326 { |
370 timeProperty, aRelativeTime)) |
327 if (iTzZone && (relativeTime == TVersitDateTime::EIsVCardLocal)) |
371 { |
|
372 if (iTzZone && (aRelativeTime == TVersitDateTime::EIsVCardLocal)) |
328 { |
373 { |
329 iTzZone->ConvertToUtcL(timeProperty); |
374 iTzZone->ConvertToUtcL(timeProperty); |
330 } |
375 } |
331 TCalTime lastModifiedDate; |
376 TCalTime lastModifiedDate; |
332 lastModifiedDate.SetTimeUtcL(timeProperty); |
377 lastModifiedDate.SetTimeUtcL(timeProperty); |
378 } |
425 } |
379 CleanupStack::PopAndDestroy(geoString); |
426 CleanupStack::PopAndDestroy(geoString); |
380 } |
427 } |
381 |
428 |
382 CleanupStack::PopAndDestroy(properties); |
429 CleanupStack::PopAndDestroy(properties); |
383 aEntryArray.AppendL(iEntry); // takes ownership of entry |
430 } |
384 iEntry = NULL; |
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CVCalToAgendaEntryConverter::ImportNoteL |
|
434 // Imports note from vcal and maps it to CCalEntry::ENote |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 void CVCalToAgendaEntryConverter::ImportNoteL(CVersitParser& aParser, |
|
438 TVersitDateTime::TRelativeTime& aRelativeTime) |
|
439 { |
|
440 |
|
441 // set description to entry from vcal |
|
442 // if description property is not present,look for summary property and |
|
443 // set the summary as description field for the note |
|
444 CArrayPtr<CParserProperty>* properties = aParser.PropertyL( |
|
445 KVersitTokenDESCRIPTION, TUid::Uid(KVersitPropertyHBufCUid),EFalse); |
|
446 if(!properties) |
|
447 { |
|
448 properties = aParser.PropertyL(KVersitTokenSUMMARY, TUid::Uid( |
|
449 KVersitPropertyHBufCUid), EFalse); |
|
450 CleanupStack::PushL(properties); |
|
451 TPtrC summary; |
|
452 if (properties) |
|
453 { |
|
454 summary.Set(static_cast<CParserPropertyValueHBufC*>( |
|
455 (*properties)[0]->Value())->Value()); |
|
456 } |
|
457 |
|
458 HBufC* summaryBuf = AgnConvertUtil::EncodeL(summary, |
|
459 KUidTextToEtextNoTrim); |
|
460 CleanupStack::PushL(summaryBuf); |
|
461 if (summaryBuf) |
|
462 { |
|
463 iEntry->SetDescriptionL(*summaryBuf); |
|
464 } |
|
465 CleanupStack::PopAndDestroy(summaryBuf); |
|
466 CleanupStack::PopAndDestroy(properties); |
|
467 } |
|
468 else |
|
469 { |
|
470 HBufC* description = ImportDesPropertyL(aParser,KVersitTokenDESCRIPTION); |
|
471 CleanupStack::PushL(description); |
|
472 if (description != NULL) |
|
473 { |
|
474 iEntry->SetDescriptionL(*description); // Takes ownership |
|
475 } |
|
476 CleanupStack::PopAndDestroy(description); |
|
477 } |
|
478 |
|
479 // get local uid from vcal |
|
480 TInt localId; |
|
481 if (ImportIntegerPropertyL(aParser, KVersitTokenXLOCALUID, localId)) |
|
482 { |
|
483 iEntry->SetLocalUidL(localId); |
|
484 } |
|
485 |
|
486 // get last changed date from vcal |
|
487 TTime timeProperty; |
|
488 if (ImportDateTimePropertyL(aParser, KVersitTokenLASTMODIFIED, |
|
489 timeProperty, aRelativeTime)) |
|
490 { |
|
491 if (iTzZone && (aRelativeTime == TVersitDateTime::EIsVCardLocal)) |
|
492 { |
|
493 iTzZone->ConvertToUtcL(timeProperty); |
|
494 } |
|
495 TCalTime lastModifiedDate; |
|
496 lastModifiedDate.SetTimeUtcL(timeProperty); |
|
497 iEntry->SetLastModifiedDateL(lastModifiedDate); |
|
498 } |
|
499 else |
|
500 { |
|
501 iEntry->SetLastModifiedDateL(); //set changed date to now |
|
502 } |
|
503 |
|
504 // get attachments from the vcal |
|
505 ImportAttachmentPropertyL(aParser); |
385 } |
506 } |
386 |
507 |
387 CVCalToAgendaEntryConverter::~CVCalToAgendaEntryConverter() |
508 CVCalToAgendaEntryConverter::~CVCalToAgendaEntryConverter() |
388 { |
509 { |
389 delete iEntry; |
510 delete iEntry; |