560 aCalendarInfo.SetPropertyL(keyBuff, pkgMarkAsDelete); |
574 aCalendarInfo.SetPropertyL(keyBuff, pkgMarkAsDelete); |
561 |
575 |
562 TRACE_EXIT_POINT |
576 TRACE_EXIT_POINT |
563 } |
577 } |
564 |
578 |
|
579 // ---------------------------------------------------------------------------- |
|
580 // CCalenServer::CalendarInfoChangeNotificationL |
|
581 // Handle calendar file change notifications |
|
582 // ---------------------------------------------------------------------------- |
|
583 void CCalenServer::CalendarInfoChangeNotificationL( |
|
584 RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries) |
|
585 { |
|
586 TRACE_ENTRY_POINT; |
|
587 |
|
588 // get the file change count |
|
589 TInt calenInfoChangeCount = aCalendarInfoChangeEntries.Count(); |
|
590 RArray<TInt> calendarColors; |
|
591 // read calendar colors from central repository |
|
592 ReadCalendarColorsFromCenrepL(calendarColors); |
|
593 |
|
594 for(TInt index = 0;index < calenInfoChangeCount;index++) |
|
595 { |
|
596 // default calendar is deleted/updated. |
|
597 if( !aCalendarInfoChangeEntries[index]->FileNameL().CompareF(KCalendarDatabaseFilePath) ) |
|
598 { |
|
599 MCalFileChangeObserver::TChangeType changeType = |
|
600 aCalendarInfoChangeEntries[index]->ChangeType(); |
|
601 switch(changeType) |
|
602 { |
|
603 case MCalFileChangeObserver::ECalendarFileDeleted: |
|
604 { |
|
605 // create cal session |
|
606 CCalSession* session = CCalSession::NewL(); |
|
607 CleanupStack::PushL(session); |
|
608 |
|
609 // create and set metadata information from central repository |
|
610 CCalCalendarInfo* calendarInfo = CCalCalendarInfo::NewL(); |
|
611 CleanupStack::PushL(calendarInfo); |
|
612 |
|
613 // EFolderLUID |
|
614 TBuf8<KBuffLength> keyBuff; |
|
615 keyBuff.AppendNum(EFolderLUID); |
|
616 TRAPD(err,calendarInfo->PropertyValueL(keyBuff)); |
|
617 |
|
618 //First set the folder uid as 100000 for default calendar. |
|
619 // Later set the other properties |
|
620 if (KErrNotFound == err) |
|
621 { |
|
622 TUint calValue = 0; |
|
623 //Get the available offset value and set as property value. |
|
624 calValue = 100000; |
|
625 TPckgC<TUint> calValuePckg(calValue); |
|
626 calendarInfo->SetPropertyL(keyBuff, calValuePckg); |
|
627 } |
|
628 SetCalendarAddPropertiesL(*calendarInfo); |
|
629 calendarInfo->SetNameL(KCalendarDatabaseFilePath); |
|
630 calendarInfo->SetColor(TRgb(calendarColors[0])); |
|
631 calendarInfo->SetEnabled(ETrue); |
|
632 TBuf<KMaxFileName> calendarFileName; |
|
633 calendarFileName.Append(KCalendarDatabaseFilePath); |
|
634 //create the default calendar. |
|
635 TRAPD(error,session->CreateCalFileL(calendarFileName,*calendarInfo)); |
|
636 User::LeaveIfError(error); |
|
637 CleanupStack::PopAndDestroy(calendarInfo); |
|
638 CleanupStack::PopAndDestroy(session); |
|
639 } |
|
640 break; |
|
641 case MCalFileChangeObserver::ECalendarInfoUpdated: |
|
642 { |
|
643 // create cal session |
|
644 CCalSession* session = CCalSession::NewL(); |
|
645 CleanupStack::PushL(session); |
|
646 session->OpenL(KCalendarDatabaseFilePath); |
|
647 |
|
648 CCalCalendarInfo* calendarInfo = session->CalendarInfoL(); |
|
649 CleanupStack::PushL(calendarInfo); |
|
650 |
|
651 TBuf8<KBuffLength> keyBuff; |
|
652 keyBuff.AppendNum(EMarkAsDelete); |
|
653 |
|
654 TBool markAsdelete; |
|
655 TPckgC<TBool> pkgMarkAsDelete(markAsdelete); |
|
656 TRAPD(err,pkgMarkAsDelete.Set(calendarInfo->PropertyValueL(keyBuff))); |
|
657 markAsdelete = pkgMarkAsDelete(); |
|
658 if( markAsdelete ) |
|
659 { |
|
660 // Mark the CalFile as visible. |
|
661 calendarInfo->SetEnabled( ETrue ); |
|
662 TBuf8<KBuffLength> keyBuff; |
|
663 |
|
664 // Set the modification time as home time. |
|
665 keyBuff.Zero(); |
|
666 keyBuff.AppendNum(EModificationTime); |
|
667 TTime modificationTime; |
|
668 modificationTime.HomeTime(); |
|
669 TPckgC<TTime> pkgModificationTime(modificationTime); |
|
670 calendarInfo->SetPropertyL(keyBuff, pkgModificationTime); |
|
671 |
|
672 // Set the SyncStatus to ETrue |
|
673 keyBuff.Zero(); |
|
674 keyBuff.AppendNum( ESyncStatus ); |
|
675 TBool syncstatus( ETrue ); |
|
676 TPckgC<TBool> pckgSyncStatusValue( syncstatus ); |
|
677 calendarInfo->SetPropertyL( keyBuff, pckgSyncStatusValue ); |
|
678 |
|
679 // Mark the meta property as SoftDeleted |
|
680 keyBuff.Zero(); |
|
681 keyBuff.AppendNum(EMarkAsDelete); |
|
682 TPckgC<TBool> pkgSoftDelete( EFalse ); |
|
683 calendarInfo->SetPropertyL(keyBuff, pkgSoftDelete); |
|
684 |
|
685 session->SetCalendarInfoL( *calendarInfo ); |
|
686 } |
|
687 CleanupStack::PopAndDestroy(calendarInfo); |
|
688 CleanupStack::PopAndDestroy(session); |
|
689 } |
|
690 } |
|
691 } |
|
692 } |
|
693 TRACE_EXIT_POINT; |
|
694 } |
565 // End of File |
695 // End of File |