19 #include "harvesterserverlogger.h" |
19 #include "harvesterserverlogger.h" |
20 #include <common.h> |
20 #include <common.h> |
21 #include <csearchdocument.h> |
21 #include <csearchdocument.h> |
22 |
22 |
23 #include <ccpixindexer.h> |
23 #include <ccpixindexer.h> |
24 #include <e32base.h> |
24 #include <s32file.h> |
|
25 #include <BAUTILS.H> |
25 #include <calsession.h> |
26 #include <calsession.h> |
26 #include <calentry.h> |
27 #include <calentry.h> |
27 #include <caliterator.h> |
28 #include <caliterator.h> |
28 #include <calentryview.h> |
29 #include <calentryview.h> |
29 #include <mmfcontrollerpluginresolver.h> |
30 #include <mmfcontrollerpluginresolver.h> |
38 |
39 |
39 _LIT(KExcerptDelimiter, " "); |
40 _LIT(KExcerptDelimiter, " "); |
40 |
41 |
41 /** The delay between harvesting chunks. */ |
42 /** The delay between harvesting chunks. */ |
42 const TInt KHarvestingDelay = 2000; |
43 const TInt KHarvestingDelay = 2000; |
|
44 _LIT(KManagerFileName, "CalendarStore.temp"); |
43 _LIT(KCalendarTimeFormat,"%04d %02d %02d %02d %02d"); |
45 _LIT(KCalendarTimeFormat,"%04d %02d %02d %02d %02d"); |
44 |
46 |
45 _LIT(KExcerptTimeFormat,"%04d/%02d/%02d %02d:%02d"); |
47 _LIT(KExcerptTimeFormat,"%04d/%02d/%02d %02d:%02d"); |
46 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
47 // CMessagePlugin::NewL |
49 // CMessagePlugin::NewL |
116 iSession->CreateCalFileL( iSession->DefaultFileNameL() ); |
120 iSession->CreateCalFileL( iSession->DefaultFileNameL() ); |
117 iSession->OpenL( iSession->DefaultFileNameL() ); |
121 iSession->OpenL( iSession->DefaultFileNameL() ); |
118 } |
122 } |
119 iCalIterator = CCalIter::NewL( *iSession ); |
123 iCalIterator = CCalIter::NewL( *iSession ); |
120 iEntryView = CCalEntryView::NewL( *iSession, *this ); |
124 iEntryView = CCalEntryView::NewL( *iSession, *this ); |
|
125 |
|
126 User::LeaveIfError(iFs.Connect()); |
|
127 TFileName pathWithoutDrive; |
|
128 iFs.CreatePrivatePath(EDriveC); |
|
129 iFilePath = _L("C:"); |
|
130 iFs.PrivatePath( pathWithoutDrive ); |
|
131 iFilePath.Append(pathWithoutDrive); |
|
132 iFilePath.Append(KManagerFileName); |
|
133 |
121 } |
134 } |
122 |
135 |
123 // --------------------------------------------------------------------------- |
136 // --------------------------------------------------------------------------- |
124 // CCalendarPlugin::StartPluginL |
137 // CCalendarPlugin::StartPluginL |
125 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
143 TCalTime endTimeCal; |
156 TCalTime endTimeCal; |
144 startTimeCal.SetTimeUtcL( startTime ); |
157 startTimeCal.SetTimeUtcL( startTime ); |
145 endTimeCal.SetTimeUtcL( endTime ); |
158 endTimeCal.SetTimeUtcL( endTime ); |
146 CCalChangeNotificationFilter* filter = CCalChangeNotificationFilter::NewL( MCalChangeCallBack2::EChangeEntryAll, ETrue, CalCommon::TCalTimeRange( startTimeCal, endTimeCal ) ); |
159 CCalChangeNotificationFilter* filter = CCalChangeNotificationFilter::NewL( MCalChangeCallBack2::EChangeEntryAll, ETrue, CalCommon::TCalTimeRange( startTimeCal, endTimeCal ) ); |
147 iSession->StartChangeNotification( *this, *filter ); |
160 iSession->StartChangeNotification( *this, *filter ); |
148 delete filter; |
161 delete filter; |
|
162 |
|
163 if( BaflUtils::FileExists(iFs,iFilePath) ) |
|
164 LoadL(); |
149 } |
165 } |
150 |
166 |
151 // --------------------------------------------------------------------------- |
167 // --------------------------------------------------------------------------- |
152 // CCalendarPlugin::StartHarvestingL |
168 // CCalendarPlugin::StartHarvestingL |
153 // --------------------------------------------------------------------------- |
169 // --------------------------------------------------------------------------- |
592 // ----------------------------------------------------------------------------- |
608 // ----------------------------------------------------------------------------- |
593 // |
609 // |
594 void CCalendarPlugin::ResumePluginL() |
610 void CCalendarPlugin::ResumePluginL() |
595 { |
611 { |
596 OstTraceFunctionEntry0( CCALENDARPLUGIN_RESUMEPLUGINL_ENTRY ); |
612 OstTraceFunctionEntry0( CCALENDARPLUGIN_RESUMEPLUGINL_ENTRY ); |
597 iIndexState = ETrue; |
613 iIndexState = ETrue; |
598 |
|
599 if( iHarvestState == EHarvesterStartHarvest ) |
614 if( iHarvestState == EHarvesterStartHarvest ) |
600 { |
615 { |
601 if(iAsynchronizer->CallbackPending()) |
616 if(iAsynchronizer->CallbackPending()) |
602 iAsynchronizer->CancelCallback(); |
617 iAsynchronizer->CancelCallback(); |
603 iAsynchronizer->Start( 0, this, KHarvestingDelay ); |
618 iAsynchronizer->Start( 0, this, KHarvestingDelay ); |
638 // ----------------------------------------------------------------------------- |
653 // ----------------------------------------------------------------------------- |
639 // |
654 // |
640 void CCalendarPlugin::IndexQueuedItems() |
655 void CCalendarPlugin::IndexQueuedItems() |
641 { |
656 { |
642 OstTraceFunctionEntry0( CCALENDARPLUGIN_INDEXQUEUEDITEMS_ENTRY ); |
657 OstTraceFunctionEntry0( CCALENDARPLUGIN_INDEXQUEUEDITEMS_ENTRY ); |
643 while (iJobQueue.Count()>0) |
658 while (iJobQueue.Count()>0 && iIndexState ) |
644 { |
659 { |
645 TRecord entry = iJobQueue[0]; |
660 TRecord entry = iJobQueue[0]; |
646 //Let the indexer handle this object TRAP it as it can leave |
661 //Let the indexer handle this object TRAP it as it can leave |
647 TRAPD(err,CreateEntryL( entry.iLocalUid, entry.iActionType )); |
662 TRAPD(err,CreateEntryL( entry.iLocalUid, entry.iActionType )); |
648 if(KErrNone == err) |
663 if(KErrNone == err) |
649 { |
664 { |
650 iJobQueue.Remove(0); |
665 iJobQueue.Remove(0); |
651 } |
666 } |
652 } |
667 } |
|
668 |
|
669 if(iJobQueue.Count() <= 0) |
|
670 { |
|
671 //Check for temp file, it exists delete |
|
672 if( BaflUtils::FileExists( iFs, iFilePath )) |
|
673 BaflUtils::DeleteFile( iFs, iFilePath ); |
|
674 |
|
675 } |
653 OstTraceFunctionExit0( CCALENDARPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
676 OstTraceFunctionExit0( CCALENDARPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
|
677 } |
|
678 |
|
679 void CCalendarPlugin::LoadL() |
|
680 { |
|
681 // Open the stream |
|
682 RFile file; |
|
683 User::LeaveIfError(file.Open(iFs, iFilePath, EFileRead)); |
|
684 CleanupClosePushL(file); |
|
685 RFileReadStream rd(file); |
|
686 rd.PushL(); |
|
687 |
|
688 // Read harvester count |
|
689 TInt count = rd.ReadInt32L(); |
|
690 // Read the harvesters |
|
691 for (TInt i=0; i<count; i++) |
|
692 { |
|
693 TRecord record; |
|
694 record.iLocalUid = rd.ReadUint32L(); |
|
695 record.iActionType = static_cast<TCPixActionType> ( rd.ReadInt16L()); |
|
696 OverWriteOrAddToQueueL(record.iLocalUid, record.iActionType); |
|
697 } |
|
698 |
|
699 if( count > 0) |
|
700 IndexQueuedItems(); |
|
701 // Cleanup |
|
702 CleanupStack::PopAndDestroy(2, &file); |
|
703 } |
|
704 |
|
705 void CCalendarPlugin::SaveL() |
|
706 { |
|
707 if(iJobQueue.Count() <= 0) |
|
708 return; |
|
709 |
|
710 // Open the stream |
|
711 RFile file; |
|
712 User::LeaveIfError(file.Replace(iFs, iFilePath, EFileWrite)); |
|
713 CleanupClosePushL(file); |
|
714 |
|
715 RFileWriteStream wr(file); |
|
716 wr.PushL(); |
|
717 |
|
718 // Write harvester count |
|
719 wr.WriteInt32L(iJobQueue.Count()); |
|
720 |
|
721 for (TInt i=0; i<iJobQueue.Count(); i++) |
|
722 { |
|
723 wr.WriteUint32L(iJobQueue[i].iLocalUid); |
|
724 wr.WriteInt16L(iJobQueue[i].iActionType); |
|
725 } |
|
726 // Commit and cleanup |
|
727 wr.CommitL(); |
|
728 CleanupStack::PopAndDestroy(2, &file); |
654 } |
729 } |
655 // --------------------------------------------------------------------------- |
730 // --------------------------------------------------------------------------- |
656 // CCalendarPlugin::UpdatePerformaceDataL |
731 // CCalendarPlugin::UpdatePerformaceDataL |
657 // --------------------------------------------------------------------------- |
732 // --------------------------------------------------------------------------- |
658 // |
733 // |