19 #include "notesplugin.h" |
19 #include "notesplugin.h" |
20 #include "harvesterserverlogger.h" |
20 #include "harvesterserverlogger.h" |
21 #include <common.h> |
21 #include <common.h> |
22 #include <csearchdocument.h> |
22 #include <csearchdocument.h> |
23 #include <ccpixindexer.h> |
23 #include <ccpixindexer.h> |
24 #include <e32base.h> |
24 #include <e32base.h> |
|
25 #include <s32file.h> |
|
26 #include <BAUTILS.H> |
25 #include <calsession.h> |
27 #include <calsession.h> |
26 #include <calentry.h> |
28 #include <calentry.h> |
27 #include <calinstanceview.h> |
29 #include <calinstanceview.h> |
28 #include <calentryview.h> |
30 #include <calentryview.h> |
29 #include <e32std.h> |
31 #include <e32std.h> |
49 /** Field names */ |
51 /** Field names */ |
50 //Memo Field name in CPIX indexer for notepad record |
52 //Memo Field name in CPIX indexer for notepad record |
51 _LIT(KNpdMemo , "Memo"); |
53 _LIT(KNpdMemo , "Memo"); |
52 //date Field name in CPIX indexer for notepad record |
54 //date Field name in CPIX indexer for notepad record |
53 _LIT(KNpdUpdateTime , "Date"); |
55 _LIT(KNpdUpdateTime , "Date"); |
54 |
56 _LIT(KManagerFileName, "NotesStore.temp"); |
55 //Reference from CPix calender harvester plugin. |
57 //Reference from CPix calender harvester plugin. |
56 _LIT(KNotesTimeFormat,"%04d %02d %02d %02d %02d"); |
58 _LIT(KNotesTimeFormat,"%04d %02d %02d %02d %02d"); |
57 |
59 |
58 //_LIT(KExcerptDelimiter, " "); |
60 //_LIT(KExcerptDelimiter, " "); |
59 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
123 { |
126 { |
124 iSession->CreateCalFileL( iSession->DefaultFileNameL() ); |
127 iSession->CreateCalFileL( iSession->DefaultFileNameL() ); |
125 iSession->OpenL( iSession->DefaultFileNameL() ); |
128 iSession->OpenL( iSession->DefaultFileNameL() ); |
126 } |
129 } |
127 iNotesInstanceView = CCalInstanceView::NewL( *iSession ); |
130 iNotesInstanceView = CCalInstanceView::NewL( *iSession ); |
128 iEntryView = CCalEntryView::NewL( *iSession ); |
131 iEntryView = CCalEntryView::NewL( *iSession ); |
|
132 |
|
133 //Load the temp stored items if any |
|
134 User::LeaveIfError(iFs.Connect()); |
|
135 TFileName pathWithoutDrive; |
|
136 iFs.CreatePrivatePath(EDriveC); |
|
137 iFilePath = _L("C:"); |
|
138 iFs.PrivatePath( pathWithoutDrive ); |
|
139 iFilePath.Append(pathWithoutDrive); |
|
140 iFilePath.Append(KManagerFileName); |
129 } |
141 } |
130 |
142 |
131 // --------------------------------------------------------------------------- |
143 // --------------------------------------------------------------------------- |
132 // CNotesPlugin::StartPluginL |
144 // CNotesPlugin::StartPluginL |
133 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
159 CCalChangeNotificationFilter* filter = CCalChangeNotificationFilter::NewL( MCalChangeCallBack2::EChangeEntryAll, ETrue, |
171 CCalChangeNotificationFilter* filter = CCalChangeNotificationFilter::NewL( MCalChangeCallBack2::EChangeEntryAll, ETrue, |
160 CalCommon::TCalTimeRange( startTimeCal, endTimeCal ) ); |
172 CalCommon::TCalTimeRange( startTimeCal, endTimeCal ) ); |
161 //Start the Monitoring |
173 //Start the Monitoring |
162 iSession->StartChangeNotification( *this, *filter ); |
174 iSession->StartChangeNotification( *this, *filter ); |
163 delete filter; |
175 delete filter; |
|
176 |
|
177 if( BaflUtils::FileExists(iFs,iFilePath) ) |
|
178 LoadL(); |
164 CPIXLOGSTRING("CNotesPlugin::StartPluginL: Exit"); |
179 CPIXLOGSTRING("CNotesPlugin::StartPluginL: Exit"); |
165 OstTraceFunctionExit0( CNOTESPLUGIN_STARTPLUGINL_EXIT ); |
180 OstTraceFunctionExit0( CNOTESPLUGIN_STARTPLUGINL_EXIT ); |
166 } |
181 } |
167 |
182 |
168 // --------------------------------------------------------------------------- |
183 // --------------------------------------------------------------------------- |
481 // |
496 // |
482 void CNotesPlugin::ResumePluginL() |
497 void CNotesPlugin::ResumePluginL() |
483 { |
498 { |
484 OstTraceFunctionEntry0( CNOTESPLUGIN_RESUMEPLUGINL_ENTRY ); |
499 OstTraceFunctionEntry0( CNOTESPLUGIN_RESUMEPLUGINL_ENTRY ); |
485 iIndexState = ETrue; |
500 iIndexState = ETrue; |
486 |
501 |
|
502 //Check for temp file, it exists delete |
|
503 if( BaflUtils::FileExists( iFs, iFilePath )) |
|
504 BaflUtils::DeleteFile( iFs, iFilePath ); |
|
505 |
487 if(iHarvestState == EHarvesterStartHarvest) |
506 if(iHarvestState == EHarvesterStartHarvest) |
488 { |
507 { |
489 if(iAsynchronizer->CallbackPending()) |
508 if(iAsynchronizer->CallbackPending()) |
490 iAsynchronizer->CancelCallback(); |
509 iAsynchronizer->CancelCallback(); |
491 iAsynchronizer->Start( 0, this, KHarvestingDelay ); |
510 iAsynchronizer->Start( 0, this, KHarvestingDelay ); |
526 // --------------------------------------------------------------------------- |
545 // --------------------------------------------------------------------------- |
527 // |
546 // |
528 void CNotesPlugin::IndexQueuedItems() |
547 void CNotesPlugin::IndexQueuedItems() |
529 { |
548 { |
530 OstTraceFunctionEntry0( CNOTESPLUGIN_INDEXQUEUEDITEMS_ENTRY ); |
549 OstTraceFunctionEntry0( CNOTESPLUGIN_INDEXQUEUEDITEMS_ENTRY ); |
531 while (iJobQueue.Count()>0) |
550 while ( iJobQueue.Count()>0 && iIndexState ) |
532 { |
551 { |
533 TRecord entry = iJobQueue[0]; |
552 TRecord entry = iJobQueue[0]; |
534 //Let the indexer handle this object TRAP it as it can leave |
553 //Let the indexer handle this object TRAP it as it can leave |
535 TRAPD(err,CreateNoteEntryL( entry.iLocalUid, entry.iActionType )); |
554 TRAPD(err,CreateNoteEntryL( entry.iLocalUid, entry.iActionType )); |
536 if(KErrNone == err) |
555 if(KErrNone == err) |
537 { |
556 { |
538 iJobQueue.Remove(0); |
557 iJobQueue.Remove(0); |
539 } |
558 } |
540 } |
559 } |
|
560 if(iJobQueue.Count() <= 0) |
|
561 { |
|
562 if( BaflUtils::FileExists( iFs, iFilePath )) |
|
563 BaflUtils::DeleteFile( iFs, iFilePath ); |
|
564 } |
541 OstTraceFunctionExit0( CNOTESPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
565 OstTraceFunctionExit0( CNOTESPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
|
566 } |
|
567 |
|
568 void CNotesPlugin::LoadL() |
|
569 { |
|
570 // Open the stream |
|
571 RFile file; |
|
572 User::LeaveIfError(file.Open(iFs, iFilePath, EFileRead)); |
|
573 CleanupClosePushL(file); |
|
574 RFileReadStream rd(file); |
|
575 rd.PushL(); |
|
576 |
|
577 // Read harvester count |
|
578 TInt count = rd.ReadInt32L(); |
|
579 // Read the harvesters |
|
580 for (TInt i=0; i<count; i++) |
|
581 { |
|
582 TRecord record; |
|
583 record.iLocalUid = rd.ReadUint32L(); |
|
584 record.iActionType = static_cast<TCPixActionType> ( rd.ReadInt16L()); |
|
585 OverWriteOrAddToQueueL(record.iLocalUid, record.iActionType); |
|
586 } |
|
587 |
|
588 if( count > 0) |
|
589 IndexQueuedItems(); |
|
590 // Cleanup |
|
591 CleanupStack::PopAndDestroy(2, &file); |
|
592 } |
|
593 |
|
594 void CNotesPlugin::SaveL() |
|
595 { |
|
596 if( iJobQueue.Count() <= 0) |
|
597 return; |
|
598 // Open the stream |
|
599 RFile file; |
|
600 User::LeaveIfError(file.Replace(iFs, iFilePath, EFileWrite)); |
|
601 CleanupClosePushL(file); |
|
602 |
|
603 RFileWriteStream wr(file); |
|
604 wr.PushL(); |
|
605 |
|
606 // Write harvester count |
|
607 wr.WriteInt32L(iJobQueue.Count()); |
|
608 |
|
609 for (TInt i=0; i<iJobQueue.Count(); i++) |
|
610 { |
|
611 wr.WriteUint32L(iJobQueue[i].iLocalUid); |
|
612 wr.WriteInt16L(iJobQueue[i].iActionType); |
|
613 } |
|
614 // Commit and cleanup |
|
615 wr.CommitL(); |
|
616 CleanupStack::PopAndDestroy(2, &file); |
542 } |
617 } |
543 |
618 |
544 #ifdef __PERFORMANCE_DATA |
619 #ifdef __PERFORMANCE_DATA |
545 void CNotesPlugin::UpdatePerformaceDataL() |
620 void CNotesPlugin::UpdatePerformaceDataL() |
546 { |
621 { |