1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <msvids.h> |
|
21 #include <msvuids.h> |
|
22 #include <mmsconst.h> |
|
23 #include <mmsclient.h> |
|
24 #include <smsclnt.h> |
|
25 #include <txtrich.h> |
|
26 #include <smuthdr.h> |
|
27 #include <smut.h> |
|
28 #include <miutset.h> |
|
29 #include <senduiconsts.h> |
|
30 #include <mtclreg.h> |
|
31 #include <gsmuelem.h> |
|
32 #include <msventry.h> |
|
33 #include <ccpixindexer.h> |
|
34 |
|
35 #include "cmessageplugin.h" |
|
36 #include "cmessagemonitor.h" |
|
37 #include "cmessageharvester.h" |
|
38 #include "cmessagedatahandler.h" |
|
39 #include "harvesterserverlogger.h" |
|
40 |
|
41 // maximum length that the fully qualified msg Plugin base app class descriptor can be |
|
42 // e.g. "@c:root msg" |
|
43 const TInt KMsgPluginBaseAppClassMaxLen = 64; |
|
44 |
|
45 |
|
46 // local declarations and functions |
|
47 namespace { |
|
48 |
|
49 _LIT(KCPixSearchServerPrivateDirectory, "\\Private\\2001f6f7\\"); |
|
50 _LIT(KPathIndexDbPath, CPIX_INDEVICE_INDEXDB); |
|
51 |
|
52 _LIT(KPathTrailer, "\\root\\msg"); |
|
53 _LIT(KMsgBaseAppClassGeneric, ":root msg"); |
|
54 _LIT(KAtSign, "@"); |
|
55 _LIT(KColon, ":"); |
|
56 |
|
57 /** |
|
58 * MapFileToDrive - gets the TDriveNumber associated with the aBaseAppClass. |
|
59 * @aBaseAppClass e.g. "@c:root file" |
|
60 * @aDrive returns the TDriveNumber for the aBaseAppClass |
|
61 * returns KErrNone on success or a standard error code |
|
62 */ |
|
63 TInt MapBaseAppClassToDrive(const TDesC& aBaseAppClass, TDriveNumber& aDrive) |
|
64 { |
|
65 if (KErrNone != aBaseAppClass.Left(1).Compare(KAtSign)) |
|
66 { |
|
67 return KErrGeneral; |
|
68 } |
|
69 |
|
70 TPtrC drvChar = aBaseAppClass.Left(2).Right(1); |
|
71 TChar d(drvChar[0]); |
|
72 TInt drive; |
|
73 const TInt ret = RFs::CharToDrive(d, drive); |
|
74 if (!ret) |
|
75 { |
|
76 aDrive = TDriveNumber(drive); |
|
77 } |
|
78 |
|
79 return ret; |
|
80 } |
|
81 |
|
82 }// anonymous namespace |
|
83 |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CMessagePlugin::NewL |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CMessagePlugin* CMessagePlugin::NewL() |
|
90 { |
|
91 CMessagePlugin* instance = CMessagePlugin::NewLC(); |
|
92 CleanupStack::Pop(instance); |
|
93 return instance; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CMessagePlugin::NewLC |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CMessagePlugin* CMessagePlugin::NewLC() |
|
101 { |
|
102 CMessagePlugin* instance = new (ELeave)CMessagePlugin(); |
|
103 CleanupStack::PushL(instance); |
|
104 instance->ConstructL(); |
|
105 return instance; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CMessagePlugin::CMessagePlugin |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 CMessagePlugin::CMessagePlugin() |
|
113 { |
|
114 iMessageDataHandler = NULL; |
|
115 iMessageHarvester = NULL; |
|
116 iMessageMonitor = NULL; |
|
117 iMsvSession = NULL; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CMessagePlugin::~CMessagePlugin |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 CMessagePlugin::~CMessagePlugin() |
|
125 { |
|
126 // remove notification paths before destroying iMonitor |
|
127 for (TInt i=EDriveA; i<=EDriveZ; i++) |
|
128 UnMount(TDriveNumber(i), EFalse); |
|
129 delete iMessageDataHandler; |
|
130 delete iMessageHarvester; |
|
131 delete iMessageMonitor; |
|
132 delete iMsvSession; |
|
133 iFs.Close(); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // CMessagePlugin::ConstructL |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CMessagePlugin::ConstructL() |
|
141 { |
|
142 TInt err = iFs.Connect(); |
|
143 CPIXLOGSTRING2("CMessagePlugin::ConstructL, iFs.Connect: %i", err); |
|
144 User::LeaveIfError(err); |
|
145 iCurrentDrive = EDriveC; //Default drive is C drive |
|
146 iMsvSession = CMsvSession::OpenSyncL(*this); |
|
147 iMessageMonitor = CMessageMonitor::NewL( *this, *iMsvSession ); |
|
148 iMessageHarvester = CMessageHarvester::NewL( *this, *iMsvSession ); |
|
149 iMessageDataHandler = CMessageDataHandler::NewL( *this, *iMsvSession ); |
|
150 for (TInt i=EDriveA; i<=EDriveZ; i++) |
|
151 { |
|
152 iIndexer[i] = NULL; //Initialize to NULL |
|
153 } |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CMessagePlugin::StartPluginL |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CMessagePlugin::StartPluginL() |
|
161 { |
|
162 //Get the current Drive for storage |
|
163 iCurrentDrive = iMsvSession->CurrentDriveL(); |
|
164 CPIXLOGSTRING2("currentDrive from messaging app : %d", iCurrentDrive ); |
|
165 MountL(TDriveNumber(iCurrentDrive)); //Mount current drive |
|
166 // Define this base application class, use default location |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CMessagePlugin::StartHarvestingL |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 void CMessagePlugin::StartHarvestingL(const TDesC& aQualifiedBaseAppClass) |
|
174 { |
|
175 CPIXLOGSTRING("START CMessagePlugin::StartHarvestingL"); |
|
176 // Map base app class to a drive number |
|
177 TDriveNumber drive ( EDriveA );//Initialize to silence compiler warnings. |
|
178 if (KErrNone != MapBaseAppClassToDrive(aQualifiedBaseAppClass, drive)) |
|
179 User::Leave(KErrGeneral); |
|
180 |
|
181 // Leave if no indexer for this drive |
|
182 if (!iIndexer[drive]) |
|
183 User::Leave(KErrGeneral); |
|
184 |
|
185 // Reset the database |
|
186 iIndexer[drive]->ResetL(); |
|
187 #ifdef __PERFORMANCE_DATA |
|
188 iStartTime.UniversalTime(); |
|
189 #endif |
|
190 iMessageHarvester->StartHarvestingL(); |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CMessagePlugin::MountL |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void CMessagePlugin::MountL(TDriveNumber aMedia,TBool aForceReharvesting) |
|
198 { |
|
199 CPIXLOGSTRING("START CMessagePlugin::MountL"); |
|
200 // Check if already exists |
|
201 if (iIndexer[aMedia]) |
|
202 return; |
|
203 |
|
204 // Form the baseappclass for this media |
|
205 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
206 FormBaseAppClass(aMedia, baseAppClass); |
|
207 |
|
208 // Define this volume |
|
209 HBufC* path = DatabasePathLC(aMedia); |
|
210 User::LeaveIfError(iSearchSession.DefineVolume(baseAppClass, *path)); |
|
211 CleanupStack::PopAndDestroy(path); |
|
212 |
|
213 // construct and open the database |
|
214 TRAPD(err,iIndexer[aMedia] = CCPixIndexer::NewL(iSearchSession)); |
|
215 CPIXLOGSTRING2("CCPixIndexer::NewL returned : %d", err ); |
|
216 TRAP(err,iIndexer[aMedia]->OpenDatabaseL(baseAppClass)); |
|
217 |
|
218 // Add to harvesting queue |
|
219 iObserver->AddHarvestingQueue(this, baseAppClass,aForceReharvesting); |
|
220 CPIXLOGSTRING("END CMessagePlugin::MountL"); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CMessagePlugin::UnMount |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CMessagePlugin::UnMount(TDriveNumber aMedia, TBool aUndefineAsWell) |
|
228 { |
|
229 CPIXLOGSTRING("START CMessagePlugin::UnMount"); |
|
230 // Check if already exists |
|
231 if (!iIndexer[aMedia]) |
|
232 return; |
|
233 |
|
234 // Form the baseappclass for this media |
|
235 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
236 FormBaseAppClass(aMedia, baseAppClass); |
|
237 |
|
238 // Remove from harvesting queue |
|
239 iObserver->RemoveHarvestingQueue(this, baseAppClass); |
|
240 |
|
241 // Delete the index object |
|
242 if (iIndexer[aMedia]) |
|
243 { |
|
244 delete iIndexer[aMedia]; |
|
245 iIndexer[aMedia] = NULL; |
|
246 } |
|
247 |
|
248 // if the aActionType is EFFMmcDismount, then the |
|
249 // parameter aFilename is the baseAppClass of the Index database |
|
250 // to be dropped. |
|
251 if (aUndefineAsWell) |
|
252 iSearchSession.UnDefineVolume(baseAppClass); |
|
253 } |
|
254 |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CMessagePlugin::FormBaseAppClass |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 TInt CMessagePlugin::FormBaseAppClass(TDriveNumber aMedia, TDes& aBaseAppClass) |
|
261 { |
|
262 TChar chr; |
|
263 const TInt ret = RFs::DriveToChar(aMedia, chr); |
|
264 if (KErrNone == ret) |
|
265 { |
|
266 aBaseAppClass.Copy(KAtSign); |
|
267 aBaseAppClass.Append(chr); |
|
268 aBaseAppClass.LowerCase(); |
|
269 aBaseAppClass.Append(KMsgBaseAppClassGeneric); |
|
270 } |
|
271 |
|
272 return ret; |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // CMessagePlugin::DatabasePathLC |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 HBufC* CMessagePlugin::DatabasePathLC(TDriveNumber aMedia) |
|
280 { |
|
281 CPIXLOGSTRING("START CMessagePlugin::DatabasePathLC"); |
|
282 // Allocate extra space for root path e.g. "C:\\Private\\2001f6f7\\" |
|
283 const TInt KRootPathMaxLength = 30; |
|
284 HBufC* indexDbPath = HBufC::NewLC(KRootPathMaxLength + KPathIndexDbPath().Length() + KPathTrailer().Length()); |
|
285 TPtr indexDbPathPtr = indexDbPath->Des(); |
|
286 |
|
287 #if 1 // Data caging implementation |
|
288 iFs.CreatePrivatePath(aMedia); |
|
289 |
|
290 TChar chr; |
|
291 RFs::DriveToChar(aMedia, chr); |
|
292 indexDbPathPtr.Append(chr); |
|
293 indexDbPathPtr.Append(KColon); |
|
294 |
|
295 TFileName pathWithoutDrive; |
|
296 iFs.PrivatePath(pathWithoutDrive); |
|
297 indexDbPathPtr.Append(KCPixSearchServerPrivateDirectory); |
|
298 #else // here is the way to calculate the path if data caging is not being used. |
|
299 TFileName rootPath; |
|
300 PathInfo::GetRootPath(rootPath, aMedia); |
|
301 indexDbPathPtr.Append(rootPath); |
|
302 #endif |
|
303 |
|
304 indexDbPathPtr.Append(KPathIndexDbPath); |
|
305 indexDbPathPtr.Append(KPathTrailer); |
|
306 |
|
307 return indexDbPath; |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // CMessagePlugin::GetIndexer |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 CCPixIndexer* CMessagePlugin::GetIndexer() |
|
315 { |
|
316 return iIndexer[iCurrentDrive]; |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // CMessagePlugin::IsMediaRemovableL |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 TBool CMessagePlugin::IsMediaRemovableL(TDriveNumber& aDrive) |
|
324 { |
|
325 TDriveInfo driveInfo; |
|
326 User::LeaveIfError(iFs.Drive(driveInfo,aDrive)); |
|
327 TBool mediaRemovable(EFalse); |
|
328 driveInfo.iDriveAtt & KDriveAttRemovable ? mediaRemovable = ETrue : mediaRemovable = EFalse; |
|
329 return mediaRemovable; |
|
330 } |
|
331 // --------------------------------------------------------------------------- |
|
332 // CMessagePlugin::HandleSessionEventL |
|
333 // --------------------------------------------------------------------------- |
|
334 // |
|
335 void CMessagePlugin::HandleSessionEventL( TMsvSessionEvent aEvent, |
|
336 TAny* aArg1, |
|
337 TAny* aArg2, |
|
338 TAny* aArg3 ) |
|
339 { |
|
340 CPIXLOGSTRING("ENTER CMessagePlugin::HandleSessionEventL"); |
|
341 CPIXLOGSTRING2("TMsvSessionEvent aEvent: %d", aEvent ); |
|
342 |
|
343 switch( aEvent ) |
|
344 { |
|
345 case EMsvEntriesCreated: |
|
346 case EMsvEntriesChanged: |
|
347 { |
|
348 // Handle changed / created event |
|
349 CMsvEntrySelection* selection = reinterpret_cast<CMsvEntrySelection*>(aArg1); |
|
350 TMsvId folderId = *( reinterpret_cast<TMsvId*>(aArg2)); |
|
351 #ifdef __PERFORMANCE_DATA |
|
352 iStartTime.UniversalTime(); |
|
353 iMessageMonitor->HandleMsgCreatedChangedL(*selection, folderId, aEvent); |
|
354 UpdatePerformaceDataL(EMsvEntriesChanged); |
|
355 #else |
|
356 iMessageMonitor->HandleMsgCreatedChangedL(*selection, folderId, aEvent); |
|
357 #endif |
|
358 break; |
|
359 } |
|
360 case EMsvEntriesDeleted: |
|
361 { |
|
362 // Handle deletion event |
|
363 CMsvEntrySelection* selection = reinterpret_cast<CMsvEntrySelection*> ( aArg1 ); |
|
364 #ifdef __PERFORMANCE_DATA |
|
365 iStartTime.UniversalTime(); |
|
366 iMessageMonitor->HandleMsgDeletedL( *selection ); |
|
367 UpdatePerformaceDataL(EMsvEntriesDeleted); |
|
368 #else |
|
369 iMessageMonitor->HandleMsgDeletedL( *selection ); |
|
370 #endif |
|
371 break; |
|
372 } |
|
373 case EMsvEntriesMoved: |
|
374 { |
|
375 // track move operations |
|
376 // or sent folder |
|
377 // ... extract the useful parameters |
|
378 if( aArg1 && aArg2 && aArg3 ) |
|
379 { |
|
380 CMsvEntrySelection* selection = reinterpret_cast<CMsvEntrySelection*> ( aArg1 ); |
|
381 // aArg2 is the TMsvId of the new parent. aArg3 is the TMsvId of |
|
382 // the old parent entry. |
|
383 TMsvId newFolderId = *(reinterpret_cast<TMsvId*>(aArg2)); |
|
384 TMsvId oldFolderId = *(reinterpret_cast<TMsvId*>(aArg3)); |
|
385 #ifdef __PERFORMANCE_DATA |
|
386 iStartTime.UniversalTime(); |
|
387 iMessageMonitor->HandleMsgMovedL(newFolderId, oldFolderId, *selection); |
|
388 UpdatePerformaceDataL(EMsvEntriesMoved); |
|
389 #else |
|
390 iMessageMonitor->HandleMsgMovedL(newFolderId, oldFolderId, *selection); |
|
391 #endif |
|
392 } |
|
393 break; |
|
394 } |
|
395 case EMsvMediaChanged: |
|
396 { |
|
397 //Unmount old media drive |
|
398 CPIXLOGSTRING("ENTER CMessagePlugin::HandleSessionEventL EMsvMediaChanged"); |
|
399 TDriveNumber drive = *(reinterpret_cast<TDriveNumber*>(aArg1)); |
|
400 UnMount(drive); |
|
401 drive = *(reinterpret_cast<TDriveNumber*>(aArg2)); |
|
402 //Check if Media is removable then force reharvesting else keep indexes same |
|
403 MountL(drive,IsMediaRemovableL(drive)); //Mount new media drive for harvesting |
|
404 iCurrentDrive = drive;//Index of current drive |
|
405 } |
|
406 break; |
|
407 case EMsvMediaUnavailable: |
|
408 { |
|
409 //No need to handle as when drive will be removed EMsvMediaChanged event |
|
410 //will be received for default media drive can be handled there |
|
411 //Unmount old media drive |
|
412 CPIXLOGSTRING("ENTER CMessagePlugin::HandleSessionEventL EMsvMediaUnavailable"); |
|
413 TDriveNumber drive = *(reinterpret_cast<TDriveNumber*>(aArg1)); |
|
414 UnMount(drive); |
|
415 } |
|
416 break; |
|
417 case EMsvMediaAvailable: |
|
418 { |
|
419 CPIXLOGSTRING("ENTER CMessagePlugin::HandleSessionEventL EMsvMediaAvailable"); |
|
420 //Removed media drive available again mount media drive and unmount default |
|
421 UnMount(TDriveNumber(iCurrentDrive)); //Unmount current drive |
|
422 TDriveNumber drive = *(reinterpret_cast<TDriveNumber*>(aArg1)); |
|
423 MountL(drive,IsMediaRemovableL(drive)); //Mount avilable media drive for harvesting |
|
424 } |
|
425 break; |
|
426 case EMsvServerFailedToStart: |
|
427 case EMsvCloseSession: |
|
428 case EMsvServerTerminated: |
|
429 { |
|
430 User::Panic(_L("CMessagePlugin PANIC"), KErrServerTerminated); |
|
431 break; |
|
432 } |
|
433 case EMsvMtmGroupInstalled: |
|
434 case EMsvMtmGroupDeInstalled: |
|
435 case EMsvGeneralError: // not used after v5 |
|
436 case EMsvServerReady: |
|
437 case EMsvCorruptedIndexRebuilt: |
|
438 case EMsvMediaIncorrect: |
|
439 case EMsvCorruptedIndexRebuilding: |
|
440 default: |
|
441 { |
|
442 break; |
|
443 } |
|
444 } |
|
445 CPIXLOGSTRING("END CMessagePlugin::HandleSessionEventL"); |
|
446 |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CMessageDataHandler::CalculateMessageType |
|
451 // --------------------------------------------------------------------------- |
|
452 // |
|
453 TMsgType CMessagePlugin::CalculateMessageType (const TMsvEntry& aEntry ) |
|
454 { |
|
455 CPIXLOGSTRING("ENTER CMessagePlugin::CalculateMessageType"); |
|
456 TMsgType ret = EMsgTypeInvalid; |
|
457 CPIXLOGSTRING2("CMessagePlugin::CalculateMessageType uid: %x", aEntry.iMtm.iUid ); |
|
458 if( aEntry.iMtm.iUid == KUidMsgTypeMultimedia.iUid ) |
|
459 { |
|
460 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### Mms Message ###"); |
|
461 ret = EMsgTypeMms; |
|
462 } |
|
463 else if( aEntry.iMtm.iUid == KUidMsgTypeSMTP.iUid ) |
|
464 { |
|
465 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### ESmtpEmail ###"); |
|
466 ret = EMsgTypeEmailSmtp; |
|
467 } |
|
468 else if( aEntry.iMtm.iUid == KUidMsgTypePOP3.iUid ) |
|
469 { |
|
470 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### EPop3Email ###"); |
|
471 ret = EMsgTypeEmailPop3; |
|
472 } |
|
473 else if( aEntry.iMtm.iUid == KUidMsgTypeIMAP4.iUid ) |
|
474 { |
|
475 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### EImap4Email ###"); |
|
476 ret = EMsgTypeEmailImap4; |
|
477 } |
|
478 // Add J.J |
|
479 #ifndef __SERIES60_30__ // Not supported before S60 3d FP1 |
|
480 else if ( aEntry.iMtm.iUid == KSenduiMtmUniMessageUid.iUid ) |
|
481 { |
|
482 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### EDraftMessage ###"); |
|
483 ret = EMsgTypeDraft; |
|
484 } |
|
485 #endif |
|
486 // else if we have a normal text based SMS it is valid |
|
487 else if ( aEntry.iMtm.iUid == KUidMsgTypeSMS.iUid ) |
|
488 { |
|
489 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### SMS Message ###"); |
|
490 ret = EMsgTypeSms; |
|
491 } |
|
492 else if ( aEntry.iMtm.iUid == KSenduiMtmSmsUid.iUid ) |
|
493 { |
|
494 CPIXLOGSTRING("CMessagePlugin:CalculateMessageType ### Sms Message ###"); |
|
495 ret = EMsgTypeSms; |
|
496 } |
|
497 CPIXLOGSTRING("END CMessagePlugin::CalculateMessageType"); |
|
498 return ret; |
|
499 } |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // CMessagePlugin::MessageItemL |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 void CMessagePlugin::MessageItemL( TMsvId aMsgId, TCPixActionType aActionType, TMsvId aFolderId ) |
|
506 { |
|
507 //New item found gather data from that. |
|
508 iMessageDataHandler->GatherDataL( aMsgId, aActionType, aFolderId ); |
|
509 } |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // CMessagePlugin::HarvestingCompleted |
|
513 // --------------------------------------------------------------------------- |
|
514 // |
|
515 void CMessagePlugin::HarvestingCompleted(TInt aError) |
|
516 { |
|
517 // Notifies the indexing manager of completed harvesting, called by CMessageHarvester |
|
518 Flush( *GetIndexer() ); |
|
519 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
520 FormBaseAppClass(TDriveNumber(iCurrentDrive), baseAppClass); |
|
521 #ifdef __PERFORMANCE_DATA |
|
522 TRAP_IGNORE( UpdatePerformaceDataL() ); |
|
523 #endif |
|
524 iObserver->HarvestingCompleted(this, baseAppClass, aError); |
|
525 } |
|
526 |
|
527 // --------------------------------------------------------------------------- |
|
528 // CMessagePlugin::UpdatePerformaceDataL |
|
529 // --------------------------------------------------------------------------- |
|
530 // |
|
531 #ifdef __PERFORMANCE_DATA |
|
532 void CMessagePlugin::UpdatePerformaceDataL() |
|
533 { |
|
534 TTime now; |
|
535 |
|
536 |
|
537 iCompleteTime.UniversalTime(); |
|
538 TTimeIntervalMicroSeconds timeDiff = iCompleteTime.MicroSecondsFrom(iStartTime); |
|
539 |
|
540 RFs fileSession; |
|
541 RFile perfFile; |
|
542 User::LeaveIfError( fileSession.Connect () ); |
|
543 |
|
544 |
|
545 /* Open file if it exists, otherwise create it and write content in it */ |
|
546 |
|
547 if(perfFile.Open(fileSession, _L("c:\\data\\MessagePerf.txt"), EFileWrite)) |
|
548 User::LeaveIfError(perfFile.Create (fileSession, _L("c:\\data\\MessagePerf.txt"), EFileWrite)); |
|
549 |
|
550 HBufC8 *heap = HBufC8::NewL(100); |
|
551 TPtr8 ptr = heap->Des(); |
|
552 now.HomeTime(); |
|
553 TBuf<50> timeString; |
|
554 |
|
555 _LIT(KOwnTimeFormat,"%:0%H%:1%T%:2%S"); |
|
556 now.FormatL(timeString,KOwnTimeFormat); |
|
557 ptr.AppendNum(now.DateTime().Day()); |
|
558 ptr.Append(_L("/")); |
|
559 ptr.AppendNum(now.DateTime().Month()); |
|
560 ptr.Append(_L("/")); |
|
561 ptr.AppendNum(now.DateTime().Year()); |
|
562 ptr.Append(_L(":")); |
|
563 ptr.Append(timeString); |
|
564 ptr.Append( _L("Time taken for Harvesting Message is : ")); |
|
565 ptr.AppendNum(timeDiff.Int64()/1000) ; |
|
566 ptr.Append(_L(" MilliSeonds \n")); |
|
567 TInt myInt = 0; |
|
568 perfFile.Seek(ESeekEnd,myInt); |
|
569 perfFile.Write (ptr); |
|
570 perfFile.Close (); |
|
571 fileSession.Close (); |
|
572 delete heap; |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // CMessagePlugin::UpdatePerformaceDataL |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 void CMessagePlugin::UpdatePerformaceDataL(TMsvSessionEvent action) { |
|
580 |
|
581 iCompleteTime.UniversalTime(); |
|
582 TTimeIntervalMicroSeconds timeDiff = iCompleteTime.MicroSecondsFrom(iStartTime); |
|
583 |
|
584 RFs fileSession; |
|
585 RFile perfFile; |
|
586 User::LeaveIfError( fileSession.Connect () ); |
|
587 |
|
588 |
|
589 /* Open file if it exists, otherwise create it and write content in it */ |
|
590 |
|
591 if(perfFile.Open(fileSession, _L("c:\\data\\MessagePerf.txt"), EFileWrite)) |
|
592 User::LeaveIfError(perfFile.Create (fileSession, _L("c:\\data\\MessagePerf.txt"), EFileWrite)); |
|
593 |
|
594 HBufC8 *heap = HBufC8::NewL(100); |
|
595 TPtr8 ptr = heap->Des(); |
|
596 |
|
597 switch (action) { |
|
598 case EMsvEntriesDeleted: ptr.Append( _L("del "));break; |
|
599 case EMsvEntriesChanged: ptr.Append( _L("upd "));break; |
|
600 case EMsvEntriesMoved: ptr.Append( _L("mov "));break; |
|
601 } |
|
602 ptr.AppendNum(timeDiff.Int64()/1000) ; |
|
603 ptr.Append(_L("\n")); |
|
604 TInt myInt = 0; |
|
605 perfFile.Seek(ESeekEnd,myInt); |
|
606 perfFile.Write (ptr); |
|
607 perfFile.Close (); |
|
608 fileSession.Close (); |
|
609 delete heap; |
|
610 } |
|
611 |
|
612 #endif |
|