28 #include <rsearchserversession.h> |
28 #include <rsearchserversession.h> |
29 #include <csearchdocument.h> |
29 #include <csearchdocument.h> |
30 #include <common.h> |
30 #include <common.h> |
31 |
31 |
32 #include <ccpixindexer.h> |
32 #include <ccpixindexer.h> |
|
33 #include "OstTraceDefinitions.h" |
|
34 #ifdef OST_TRACE_COMPILER_IN_USE |
|
35 #include "cfilepluginTraces.h" |
|
36 #endif |
|
37 |
|
38 |
33 |
39 |
34 // local declarations and functions |
40 // local declarations and functions |
35 namespace { |
41 namespace { |
36 |
42 |
37 _LIT(KCPixSearchServerPrivateDirectory, "\\Private\\2001f6f7\\"); |
43 _LIT(KCPixSearchServerPrivateDirectory, "\\Private\\2001f6f7\\"); |
38 _LIT(KPathIndexDbPath, CPIX_INDEVICE_INDEXDB); |
44 _LIT(KPathIndexDbPath, CPIX_INDEVICE_INDEXDB); |
39 |
45 |
40 _LIT(KPathTrailer, "\\root\\file"); |
46 _LIT(KPathFolder, "\\root\\file\\folder"); |
41 _LIT(KFileBaseAppClassGeneric, ":root file"); |
47 _LIT(KPathFileContent, "\\root\\file\\content"); |
|
48 _LIT(KFileBaseAppClassContent, "root file content"); |
|
49 _LIT(KFileBaseAppClassFolder, "root file folder"); |
42 _LIT(KFilePluginAtSign, "@"); |
50 _LIT(KFilePluginAtSign, "@"); |
43 _LIT(KFilePluginColon, ":"); |
51 _LIT(KFilePluginColon, ":"); |
|
52 _LIT(KNameField, "Name"); |
|
53 _LIT(KExtensionField, "Extension"); |
|
54 _LIT(KMimeTypeFile, FILE_MIMETYPE); |
|
55 _LIT(KMimeTypeFolder , FOLDER_MIMETYPE); |
|
56 _LIT(KMimeTypeField , CPIX_MIMETYPE_FIELD); |
|
57 |
|
58 #define CONSTANT_TO_PTR16(ptr, c) TPtrC16 ptr; ptr.Set((const TUint16*)c,User::StringLength(c) ); |
44 |
59 |
45 /** |
60 /** |
46 * MapFileToDrive - returns the TDriveNumber that the file is located on. |
61 * MapFileToDrive - returns the TDriveNumber that the file is located on. |
47 * @aFilename filename |
62 * @aFilename filename |
48 * @aDrive returns the TDriveNumber |
63 * @aDrive returns the TDriveNumber |
89 return ret; |
104 return ret; |
90 } |
105 } |
91 |
106 |
92 } // anonymous namespace |
107 } // anonymous namespace |
93 |
108 |
|
109 |
|
110 TBool CFilePlugin::IsFileTypeMedia(const TDesC& aExt) |
|
111 { |
|
112 |
|
113 const TText* KMediaExt[] = {_S("txt"),_S("pdf"), _S("jpg"),_S("mp3"), _S("jpeg"), _S("wma"), _S("3gp"), _S("mpg4"), |
|
114 _S("avi"), _S("jpf"), _S("mbm"), _S("png"), _S("gif"), _S("bmp"), _S("mp4"), _S("mpeg4"), |
|
115 _S("m4v"), _S("m4a"), _S("3gpp"), _S("3g2"), _S("aac"), _S("amr"), _S("wmv"), _S("divx"), |
|
116 _S("awb"),_S("mid"), _S("midi"), _S("spmid"), _S("rng"), _S("mxmf"), _S("wav"), |
|
117 _S("au"), _S("nrt"), _S("mka"),_S("jp2"), _S("j2k"), _S("jpx"), |
|
118 _S("rm"), _S("rmvb"),_S("ota"), _S("wbmp"), _S("wmf"),_S("otb"), |
|
119 _S("rv"), _S("mkv"), _S("ra"),_S("tif"), _S("tiff")}; |
|
120 |
|
121 const TInt count = sizeof( KMediaExt ) / sizeof( TText* ); |
|
122 |
|
123 TBool isValid = false; |
|
124 |
|
125 for (TInt i = 0; i < count; i++) |
|
126 { |
|
127 CONSTANT_TO_PTR16(type, KMediaExt[i]); |
|
128 if(!aExt.Compare(type)) |
|
129 { |
|
130 isValid = true; |
|
131 break; |
|
132 } |
|
133 } |
|
134 return isValid; |
|
135 } |
|
136 |
94 CFilePlugin* CFilePlugin::NewL() |
137 CFilePlugin* CFilePlugin::NewL() |
95 { |
138 { |
96 CFilePlugin* instance = CFilePlugin::NewLC(); |
139 CFilePlugin* instance = CFilePlugin::NewLC(); |
97 CleanupStack::Pop(instance); |
140 CleanupStack::Pop(instance); |
98 return instance; |
141 return instance; |
136 |
180 |
137 void CFilePlugin::ConstructL() |
181 void CFilePlugin::ConstructL() |
138 { |
182 { |
139 User::LeaveIfError( iFs.Connect() ); |
183 User::LeaveIfError( iFs.Connect() ); |
140 TInt err = iFs.AddPlugin(KFastFindFSPluginFile); |
184 TInt err = iFs.AddPlugin(KFastFindFSPluginFile); |
|
185 OstTrace1( TRACE_NORMAL, CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.AddPlugin=%d", err ); |
141 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.AddPlugin: %i", err); |
186 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.AddPlugin: %i", err); |
142 if ( err != KErrAlreadyExists ) |
187 if ( err != KErrAlreadyExists ) |
143 { |
188 { |
144 err = iFs.MountPlugin(KFastFindFSPluginName); |
189 err = iFs.MountPlugin(KFastFindFSPluginName); |
|
190 OstTrace1( TRACE_NORMAL, DUP1_CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.MountPlugin=%d", err ); |
145 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.MountPlugin: %i", err); |
191 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.MountPlugin: %i", err); |
146 } |
192 } |
147 // check if already up, unload and reload |
193 // check if already up, unload and reload |
148 else if ( err == KErrAlreadyExists ) |
194 else if ( err == KErrAlreadyExists ) |
149 { |
195 { |
150 // dismount |
196 // dismount |
151 TInt err = iFs.DismountPlugin(KFastFindFSPluginName); |
197 TInt err = iFs.DismountPlugin(KFastFindFSPluginName); |
|
198 OstTrace1( TRACE_NORMAL, DUP2_CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.DismountPlugin=%d", err ); |
152 CPIXLOGSTRING2("CFilePlugin::ConstructL(), iFs.DismountPlugin: %i", err); |
199 CPIXLOGSTRING2("CFilePlugin::ConstructL(), iFs.DismountPlugin: %i", err); |
153 err = iFs.RemovePlugin(KFastFindFSPluginName); |
200 err = iFs.RemovePlugin(KFastFindFSPluginName); |
|
201 OstTrace1( TRACE_NORMAL, DUP3_CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.RemovePlugin=%d", err ); |
154 CPIXLOGSTRING2("CFilePlugin::ConstructL(), iFs.RemovePlugin: %i", err); |
202 CPIXLOGSTRING2("CFilePlugin::ConstructL(), iFs.RemovePlugin: %i", err); |
155 // if no error reload |
203 // if no error reload |
156 if ( err == KErrNone ) |
204 if ( err == KErrNone ) |
157 { |
205 { |
158 err = iFs.AddPlugin(KFastFindFSPluginFile); |
206 err = iFs.AddPlugin(KFastFindFSPluginFile); |
|
207 OstTrace1( TRACE_NORMAL, DUP4_CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.AddPlugin=%d", err ); |
159 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.AddPlugin: %i", err); |
208 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.AddPlugin: %i", err); |
160 err = iFs.MountPlugin(KFastFindFSPluginName); |
209 err = iFs.MountPlugin(KFastFindFSPluginName); |
|
210 OstTrace1( TRACE_NORMAL, DUP5_CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.MountPlugin=%d", err ); |
161 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.MountPlugin: %i", err); |
211 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.MountPlugin: %i", err); |
162 } |
212 } |
163 } |
213 } |
164 |
214 |
165 iHarvester = CFileHarvester::NewL(*this, iFs); |
215 iHarvester = CFileHarvester::NewL(*this, iFs); |
213 } |
266 } |
214 } |
267 } |
215 |
268 |
216 void CFilePlugin::MountL(TDriveNumber aMedia, TBool aForceReharvest) |
269 void CFilePlugin::MountL(TDriveNumber aMedia, TBool aForceReharvest) |
217 { |
270 { |
|
271 OstTraceFunctionEntry0( CFILEPLUGIN_MOUNTL_ENTRY ); |
218 CPIXLOGSTRING("ENTER CFilePlugin::MountL"); |
272 CPIXLOGSTRING("ENTER CFilePlugin::MountL"); |
219 // Check if already exists |
273 // Check if already exists |
220 if (iIndexer[aMedia]) |
274 if (iIndexer[aMedia] && iFolderIndexer[aMedia]) |
221 return; |
275 return; |
222 |
276 |
223 // Add Notifications paths prior to opening IndexDB. |
277 // Add Notifications paths prior to opening IndexDB. |
224 AddNotificationPathsL(aMedia); |
278 AddNotificationPathsL(aMedia); |
225 |
279 |
226 // Form the baseappclass for this media |
280 // Form the baseappclass for folder |
227 TBuf<KFilePluginBaseAppClassMaxLen> baseAppClass; |
281 TBuf<KFilePluginBaseAppClassMaxLen> baseFolderAppClass; |
228 FormBaseAppClass(aMedia, baseAppClass); |
282 FormBaseAppClass(aMedia,KFileBaseAppClassFolder, baseFolderAppClass); |
229 |
283 //Form the baseappclass for content |
230 // Define this volume |
284 TBuf<KFilePluginBaseAppClassMaxLen> baseContentAppClass; |
231 HBufC* path = DatabasePathLC(aMedia); |
285 FormBaseAppClass(aMedia,KFileBaseAppClassContent, baseContentAppClass); |
232 User::LeaveIfError(iSearchSession.DefineVolume(baseAppClass, *path)); |
286 |
|
287 // Define volume for folder and content index database |
|
288 HBufC* path = DatabasePathLC(aMedia,KPathFolder); |
|
289 User::LeaveIfError(iSearchSession.DefineVolume(baseFolderAppClass, *path)); |
233 CleanupStack::PopAndDestroy(path); |
290 CleanupStack::PopAndDestroy(path); |
|
291 |
|
292 HBufC* contentpath = DatabasePathLC(aMedia,KPathFileContent); |
|
293 User::LeaveIfError(iSearchSession.DefineVolume(baseContentAppClass, *contentpath)); |
|
294 CleanupStack::PopAndDestroy(contentpath); |
234 |
295 |
235 // construct and open the database |
296 // construct and open the database |
236 iIndexer[aMedia] = CCPixIndexer::NewL(iSearchSession); |
297 iIndexer[aMedia] = CCPixIndexer::NewL(iSearchSession); |
237 iIndexer[aMedia]->OpenDatabaseL(baseAppClass); |
298 iIndexer[aMedia]->OpenDatabaseL(baseContentAppClass); |
|
299 |
|
300 iFolderIndexer[aMedia]= CCPixIndexer::NewL(iSearchSession); |
|
301 iFolderIndexer[aMedia]->OpenDatabaseL(baseFolderAppClass); |
238 |
302 |
239 // Add to harvesting queue |
303 // Add to harvesting queue |
240 iObserver->AddHarvestingQueue(this, baseAppClass, aForceReharvest); |
304 iObserver->AddHarvestingQueue(this, baseContentAppClass, aForceReharvest); |
|
305 |
241 CPIXLOGSTRING("END CFilePlugin::MountL"); |
306 CPIXLOGSTRING("END CFilePlugin::MountL"); |
|
307 OstTraceFunctionExit0( CFILEPLUGIN_MOUNTL_EXIT ); |
242 } |
308 } |
243 |
309 |
244 void CFilePlugin::UnMount(TDriveNumber aMedia, TBool aUndefineAsWell) |
310 void CFilePlugin::UnMount(TDriveNumber aMedia, TBool aUndefineAsWell) |
245 { |
311 { |
|
312 OstTraceFunctionEntry0( CFILEPLUGIN_UNMOUNT_ENTRY ); |
246 CPIXLOGSTRING("ENTER CFilePlugin::UnMount "); |
313 CPIXLOGSTRING("ENTER CFilePlugin::UnMount "); |
247 // Check if already exists |
314 // Check if already exists |
248 if (!iIndexer[aMedia]) |
315 if (!iIndexer[aMedia] && !iFolderIndexer[aMedia]) |
249 { |
316 { |
|
317 OstTraceFunctionExit0( CFILEPLUGIN_UNMOUNT_EXIT ); |
250 return; |
318 return; |
251 } |
319 } |
252 |
320 |
253 // Form the baseappclass for this media |
321 // Form the baseappclass for folder |
254 TBuf<KFilePluginBaseAppClassMaxLen> baseAppClass; |
322 TBuf<KFilePluginBaseAppClassMaxLen> baseFolderAppClass; |
255 FormBaseAppClass(aMedia, baseAppClass); |
323 FormBaseAppClass(aMedia,KFileBaseAppClassFolder, baseFolderAppClass); |
|
324 //Form the baseappclass for content |
|
325 TBuf<KFilePluginBaseAppClassMaxLen> baseContentAppClass; |
|
326 FormBaseAppClass(aMedia,KFileBaseAppClassContent, baseContentAppClass); |
256 |
327 |
257 // Remove from harvesting queue |
328 // Remove from harvesting queue |
258 iObserver->RemoveHarvestingQueue(this, baseAppClass); |
329 iObserver->RemoveHarvestingQueue(this, baseContentAppClass); |
259 |
330 |
260 // Delete the index object |
331 // Delete the index object |
261 if (iIndexer[aMedia]) |
332 if (iIndexer[aMedia]) |
262 { |
333 { |
263 delete iIndexer[aMedia]; |
334 delete iIndexer[aMedia]; |
264 iIndexer[aMedia] = NULL; |
335 iIndexer[aMedia] = NULL; |
265 } |
336 } |
266 |
337 |
|
338 if (iFolderIndexer[aMedia]) |
|
339 { |
|
340 delete iFolderIndexer[aMedia]; |
|
341 iFolderIndexer[aMedia] = NULL; |
|
342 } |
267 RemoveNotificationPaths(aMedia); |
343 RemoveNotificationPaths(aMedia); |
268 |
344 |
269 if (aUndefineAsWell) |
345 if (aUndefineAsWell) |
270 { |
346 { |
271 iSearchSession.UnDefineVolume(baseAppClass); |
347 iSearchSession.UnDefineVolume(baseFolderAppClass); |
|
348 iSearchSession.UnDefineVolume(baseContentAppClass); |
272 } |
349 } |
273 CPIXLOGSTRING("END CFilePlugin::UnMount "); |
350 CPIXLOGSTRING("END CFilePlugin::UnMount "); |
|
351 OstTraceFunctionExit0( DUP1_CFILEPLUGIN_UNMOUNT_EXIT ); |
274 } |
352 } |
275 |
353 |
276 void CFilePlugin::StartHarvestingL(const TDesC& aQualifiedBaseAppClass) |
354 void CFilePlugin::StartHarvestingL(const TDesC& aQualifiedBaseAppClass) |
277 { |
355 { |
|
356 OstTraceFunctionEntry0( CFILEPLUGIN_STARTHARVESTINGL_ENTRY ); |
278 CPIXLOGSTRING("ENTER CFilePlugin::StartHarvestingL "); |
357 CPIXLOGSTRING("ENTER CFilePlugin::StartHarvestingL "); |
279 // Map base app class to a drive number |
358 // Map base app class to a drive number |
280 TDriveNumber drive(EDriveA); //Initialize to get rid of compiler warning. |
359 TDriveNumber drive(EDriveA); //Initialize to get rid of compiler warning. |
281 if (KErrNone != MapBaseAppClassToDrive(aQualifiedBaseAppClass, drive)) |
360 if (KErrNone != MapBaseAppClassToDrive(aQualifiedBaseAppClass, drive)) |
282 { |
361 { |
283 User::Leave(KErrGeneral); |
362 User::Leave(KErrGeneral); |
284 } |
363 } |
285 |
364 |
286 // Leave if no indexer for this drive |
365 // Leave if no indexer for this drive |
287 if (!iIndexer[drive]) |
366 if (!iIndexer[drive] && !iFolderIndexer[drive]) |
288 { |
367 { |
289 User::Leave(KErrGeneral); |
368 User::Leave(KErrGeneral); |
290 } |
369 } |
291 |
370 |
292 #ifdef __PERFORMANCE_DATA |
371 #ifdef __PERFORMANCE_DATA |
293 iStartTime[drive].UniversalTime(); |
372 iStartTime[drive].UniversalTime(); |
294 #endif |
373 #endif |
295 // Reset the database |
374 // Reset the database |
296 iIndexer[drive]->ResetL(); |
375 iIndexer[drive]->ResetL(); |
297 |
376 iFolderIndexer[drive]->ResetL(); |
|
377 |
298 // Start the actual harvest |
378 // Start the actual harvest |
299 iHarvester->StartL(drive); |
379 iHarvester->StartL(drive); |
300 CPIXLOGSTRING("END CFilePlugin::StartHarvestingL "); |
380 CPIXLOGSTRING("END CFilePlugin::StartHarvestingL "); |
301 } |
381 OstTraceFunctionExit0( CFILEPLUGIN_STARTHARVESTINGL_EXIT ); |
302 |
382 } |
303 void CFilePlugin::CreateFileIndexItemL(const TDesC& aFilename, TCPixActionType aActionType) |
383 |
|
384 void CFilePlugin::CreateContentIndexItemL(const TDesC& aFilename, TCPixActionType aActionType) |
304 { |
385 { |
305 TFileName lowerCaseFilename(aFilename); |
386 TFileName lowerCaseFilename(aFilename); |
306 lowerCaseFilename.LowerCase(); |
387 lowerCaseFilename.LowerCase(); |
307 |
388 |
|
389 OstTraceExt2( TRACE_NORMAL, DUP1_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateContentIndexItemL;lowerCaseFilename=%S;aActionType=%d", lowerCaseFilename, aActionType ); |
308 CPIXLOGSTRING3("CFilePlugin::CreateFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
390 CPIXLOGSTRING3("CFilePlugin::CreateFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
309 &lowerCaseFilename, aActionType); |
391 &lowerCaseFilename, aActionType); |
310 |
392 |
311 TDriveNumber drive(EDriveA); |
393 TDriveNumber drive(EDriveA); |
312 User::LeaveIfError( MapFileToDrive( lowerCaseFilename, drive ) ); |
394 User::LeaveIfError( MapFileToDrive( lowerCaseFilename, drive ) ); |
313 |
395 |
314 CCPixIndexer* indexer = iIndexer[drive]; |
396 CCPixIndexer* indexer = iIndexer[drive]; |
|
397 |
315 if (!indexer) |
398 if (!indexer) |
316 { |
399 { |
|
400 OstTrace0( TRACE_NORMAL, DUP2_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateFileIndexItemL(): Could not map file to drive." ); |
317 CPIXLOGSTRING("CFilePlugin::CreateFileIndexItemL(): Could not map file to drive."); |
401 CPIXLOGSTRING("CFilePlugin::CreateFileIndexItemL(): Could not map file to drive."); |
318 return; |
402 return; |
319 } |
403 } |
320 |
404 |
321 // Index an empty item if removal action |
405 // Index an empty item if removal action |
322 if (aActionType == ECPixRemoveAction) |
406 if (aActionType == ECPixRemoveAction) |
323 { |
407 { |
324 #ifdef _DEBUG |
408 #ifdef _DEBUG |
325 TRAPD(err, indexer->DeleteL(lowerCaseFilename)); |
409 TRAPD(err, indexer->DeleteL(lowerCaseFilename)); |
|
410 OstTrace1( TRACE_NORMAL, CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateContentIndexItemL;DeleteL returned=%d", err ); |
326 CPIXLOGSTRING2("CFilePlugin::CreateFileIndexItemL(): DeleteL returned %d.", err); |
411 CPIXLOGSTRING2("CFilePlugin::CreateFileIndexItemL(): DeleteL returned %d.", err); |
327 #else |
412 #else |
328 TRAP_IGNORE( indexer->DeleteL(lowerCaseFilename) ); |
413 TRAP_IGNORE( indexer->DeleteL(lowerCaseFilename) ); |
329 #endif |
414 #endif |
330 } |
415 } |
336 // Send for indexing |
421 // Send for indexing |
337 if (aActionType == ECPixAddAction) |
422 if (aActionType == ECPixAddAction) |
338 { |
423 { |
339 #ifdef _DEBUG |
424 #ifdef _DEBUG |
340 TRAPD(err, indexer->AddL(*index_item)); |
425 TRAPD(err, indexer->AddL(*index_item)); |
|
426 OstTrace1( TRACE_NORMAL, DUP3_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateContentIndexItemL;AddL returned=%d", err ); |
341 CPIXLOGSTRING2("CFilePlugin::CreateFileIndexItemL(): AddL returned %d.", err); |
427 CPIXLOGSTRING2("CFilePlugin::CreateFileIndexItemL(): AddL returned %d.", err); |
342 #else |
428 #else |
343 TRAP_IGNORE( indexer->AddL(*index_item) ); |
429 TRAP_IGNORE( indexer->AddL(*index_item) ); |
344 #endif |
430 #endif |
345 } |
431 } |
346 else if (aActionType == ECPixUpdateAction) |
432 else if (aActionType == ECPixUpdateAction) |
347 { |
433 { |
348 #ifdef _DEBUG |
434 #ifdef _DEBUG |
349 TRAPD(err, indexer->UpdateL(*index_item)); |
435 TRAPD(err, indexer->UpdateL(*index_item)); |
|
436 OstTrace1( TRACE_NORMAL, DUP4_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateContentIndexItemL;UpdateL returned=%d", err ); |
350 CPIXLOGSTRING2("CFilePlugin::CreateFileIndexItemL(): UpdateL returned %d.", err); |
437 CPIXLOGSTRING2("CFilePlugin::CreateFileIndexItemL(): UpdateL returned %d.", err); |
351 #else |
438 #else |
352 TRAP_IGNORE( indexer->UpdateL(*index_item) ); |
439 TRAP_IGNORE( indexer->UpdateL(*index_item) ); |
353 #endif |
440 #endif |
354 } |
441 } |
355 CleanupStack::PopAndDestroy(index_item); |
442 CleanupStack::PopAndDestroy(index_item); |
356 } |
443 } |
|
444 } |
|
445 |
|
446 void CFilePlugin::CreateFolderFileIndexItemL(const TDesC& aFilename, TCPixActionType aActionType, TBool aIsDir) |
|
447 { |
|
448 CSearchDocument* index_item = NULL; |
|
449 TBool isMediaFile = false; |
|
450 TFileName lowerCaseFilename(aFilename); |
|
451 lowerCaseFilename.LowerCase(); |
|
452 |
|
453 // Adding the file entry to folder index,check for file or folder entry, |
|
454 //if file, extract the extension |
|
455 if (!aIsDir) |
|
456 { |
|
457 TFileName extension; |
|
458 TInt pos = lowerCaseFilename.LocateReverse('.'); |
|
459 if (pos > 0) |
|
460 { |
|
461 extension.Copy(lowerCaseFilename.Mid(pos+1)); |
|
462 isMediaFile = IsFileTypeMedia(extension); |
|
463 } |
|
464 } |
|
465 //Check for extension type, if media items do not index them |
|
466 if(!isMediaFile) |
|
467 { |
|
468 OstTraceExt2( TRACE_NORMAL, CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL;lowerCaseFilename=%S;aActionType=%d", lowerCaseFilename, aActionType ); |
|
469 CPIXLOGSTRING3("CFilePlugin::CreateFolderFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
|
470 &lowerCaseFilename, aActionType); |
|
471 |
|
472 TDriveNumber drive(EDriveA); |
|
473 User::LeaveIfError( MapFileToDrive( lowerCaseFilename, drive ) ); |
|
474 |
|
475 CCPixIndexer* indexer = iFolderIndexer[drive]; |
|
476 if (!indexer) |
|
477 { |
|
478 OstTrace0( TRACE_NORMAL, DUP1_CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL(): Could not map file to drive." ); |
|
479 CPIXLOGSTRING("CFilePlugin::CreateFolderFileIndexItemL(): Could not map file to drive."); |
|
480 return; |
|
481 } |
|
482 |
|
483 if (aActionType == ECPixRemoveAction) |
|
484 { |
|
485 #ifdef _DEBUG |
|
486 TRAPD(err, indexer->DeleteL(lowerCaseFilename)); |
|
487 OstTrace1( TRACE_NORMAL, DUP2_CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL;DeleteL returned=%d", err ); |
|
488 CPIXLOGSTRING2("CFilePlugin::CreateFolderFileIndexItemL(): DeleteL returned %d.", err); |
|
489 #else |
|
490 TRAP_IGNORE( indexer->DeleteL(lowerCaseFilename) ); |
|
491 #endif |
|
492 } |
|
493 else |
|
494 { |
|
495 index_item = CreateCpixDocumentL(lowerCaseFilename, aIsDir); |
|
496 |
|
497 if( aActionType == ECPixAddAction ) |
|
498 { |
|
499 #ifdef _DEBUG |
|
500 TRAPD(err, indexer->AddL(*index_item)); |
|
501 OstTrace1( TRACE_NORMAL, DUP3_CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL;AddL returned=%d", err ); |
|
502 CPIXLOGSTRING2("CFilePlugin::CreateFolderFileIndexItemL(): AddL returned %d.", err); |
|
503 #else |
|
504 TRAP_IGNORE( indexer->AddL(*index_item) ); |
|
505 #endif |
|
506 } |
|
507 else if( aActionType == ECPixUpdateAction ) |
|
508 { |
|
509 #ifdef _DEBUG |
|
510 TRAPD(err, indexer->UpdateL(*index_item)); |
|
511 OstTrace1( TRACE_NORMAL, DUP4_CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL;UpdateL returned=%d", err ); |
|
512 CPIXLOGSTRING2("CFilePlugin::CreateFolderFileIndexItemL(): UpdateL returned %d.", err); |
|
513 #else |
|
514 TRAP_IGNORE( indexer->UpdateL(*index_item) ); |
|
515 #endif |
|
516 } |
|
517 delete index_item; |
|
518 } |
|
519 } |
357 } |
520 } |
358 |
521 |
359 void CFilePlugin::HarvestingCompleted(TDriveNumber aDriveNumber, TInt aError) |
522 void CFilePlugin::HarvestingCompleted(TDriveNumber aDriveNumber, TInt aError) |
360 { |
523 { |
|
524 OstTraceFunctionEntry0( CFILEPLUGIN_HARVESTINGCOMPLETED_ENTRY ); |
361 CPIXLOGSTRING("ENTER CFilePlugin::HarvestingCompleted "); |
525 CPIXLOGSTRING("ENTER CFilePlugin::HarvestingCompleted "); |
362 |
526 |
363 if (iIndexer[aDriveNumber]) |
527 if (iIndexer[aDriveNumber]) |
364 { |
528 { |
365 Flush(*iIndexer[aDriveNumber]); |
529 Flush(*iIndexer[aDriveNumber]); |
366 } |
530 } |
367 TBuf<KFilePluginBaseAppClassMaxLen> baseAppClass; |
531 if (iFolderIndexer[aDriveNumber]) |
368 FormBaseAppClass(TDriveNumber(aDriveNumber), baseAppClass); |
532 { |
|
533 Flush(*iFolderIndexer[aDriveNumber]); |
|
534 } |
|
535 |
|
536 //Form baseapp class for folder and content database |
|
537 TBuf<KFilePluginBaseAppClassMaxLen> baseContentAppClass; |
|
538 FormBaseAppClass(TDriveNumber(aDriveNumber),KFileBaseAppClassContent, baseContentAppClass); |
|
539 |
|
540 iObserver->HarvestingCompleted(this, baseContentAppClass, aError); |
|
541 |
369 #ifdef __PERFORMANCE_DATA |
542 #ifdef __PERFORMANCE_DATA |
370 TRAP_IGNORE( UpdatePerformaceDataL(aDriveNumber) ); |
543 TRAP_IGNORE( UpdatePerformaceDataL(aDriveNumber) ); |
371 #endif |
544 #endif |
372 iObserver->HarvestingCompleted(this, baseAppClass, aError); |
545 |
373 |
546 |
374 CPIXLOGSTRING("END CFilePlugin::HarvestingCompleted "); |
547 CPIXLOGSTRING("END CFilePlugin::HarvestingCompleted "); |
|
548 OstTraceFunctionExit0( CFILEPLUGIN_HARVESTINGCOMPLETED_EXIT ); |
375 } |
549 } |
376 |
550 |
377 void CFilePlugin::AddNotificationPathsL(const TDriveNumber aDriveNumber) |
551 void CFilePlugin::AddNotificationPathsL(const TDriveNumber aDriveNumber) |
378 { |
552 { |
|
553 OstTraceFunctionEntry0( CFILEPLUGIN_ADDNOTIFICATIONPATHSL_ENTRY ); |
379 CPIXLOGSTRING("ENTER CFilePlugin::AddNotificationPathsL "); |
554 CPIXLOGSTRING("ENTER CFilePlugin::AddNotificationPathsL "); |
380 iMonitor->AddNotificationPathsL(aDriveNumber); |
555 iMonitor->AddNotificationPathsL(aDriveNumber); |
381 iHarvester->AddIgnorePathsL(aDriveNumber); |
556 iHarvester->AddIgnorePathsL(aDriveNumber); |
382 CPIXLOGSTRING("END CFilePlugin::AddNotificationPathsL "); |
557 CPIXLOGSTRING("END CFilePlugin::AddNotificationPathsL "); |
|
558 OstTraceFunctionExit0( CFILEPLUGIN_ADDNOTIFICATIONPATHSL_EXIT ); |
383 } |
559 } |
384 |
560 |
385 void CFilePlugin::RemoveNotificationPaths(const TDriveNumber aDriveNumber) |
561 void CFilePlugin::RemoveNotificationPaths(const TDriveNumber aDriveNumber) |
386 { |
562 { |
|
563 OstTraceFunctionEntry0( CFILEPLUGIN_REMOVENOTIFICATIONPATHS_ENTRY ); |
387 CPIXLOGSTRING("ENTER CFilePlugin::RemoveNotificationPaths"); |
564 CPIXLOGSTRING("ENTER CFilePlugin::RemoveNotificationPaths"); |
388 iMonitor->RemoveNotificationPaths(aDriveNumber); |
565 iMonitor->RemoveNotificationPaths(aDriveNumber); |
389 iHarvester->RemoveIgnorePaths(aDriveNumber); |
566 iHarvester->RemoveIgnorePaths(aDriveNumber); |
390 CPIXLOGSTRING("END CFilePlugin::RemoveNotificationPaths"); |
567 CPIXLOGSTRING("END CFilePlugin::RemoveNotificationPaths"); |
391 } |
568 OstTraceFunctionExit0( CFILEPLUGIN_REMOVENOTIFICATIONPATHS_EXIT ); |
392 |
569 } |
393 TInt CFilePlugin::FormBaseAppClass(TDriveNumber aMedia, TDes& aBaseAppClass) |
570 |
394 { |
571 TInt CFilePlugin::FormBaseAppClass(TDriveNumber aMedia, const TDesC& aGenericAppClass, TDes& aBaseAppClass) |
|
572 { |
|
573 OstTraceFunctionEntry0( CFILEPLUGIN_FORMBASEAPPCLASS_ENTRY ); |
395 CPIXLOGSTRING("ENTER CFilePlugin::FormBaseAppClass"); |
574 CPIXLOGSTRING("ENTER CFilePlugin::FormBaseAppClass"); |
396 TChar chr; |
575 TChar chr; |
397 const TInt ret = RFs::DriveToChar(aMedia, chr); |
576 const TInt ret = RFs::DriveToChar(aMedia, chr); |
398 if (KErrNone == ret) |
577 if (KErrNone == ret) |
399 { |
578 { |
400 aBaseAppClass.Copy(KFilePluginAtSign); |
579 aBaseAppClass.Copy(KFilePluginAtSign); |
401 aBaseAppClass.Append(chr); |
580 aBaseAppClass.Append(chr); |
402 aBaseAppClass.LowerCase(); |
581 aBaseAppClass.LowerCase(); |
403 aBaseAppClass.Append(KFileBaseAppClassGeneric); |
582 aBaseAppClass.Append(KFilePluginColon); |
|
583 aBaseAppClass.Append(aGenericAppClass); |
404 } |
584 } |
405 |
585 |
406 CPIXLOGSTRING("END CFilePlugin::FormBaseAppClass"); |
586 CPIXLOGSTRING("END CFilePlugin::FormBaseAppClass"); |
|
587 OstTraceFunctionExit0( CFILEPLUGIN_FORMBASEAPPCLASS_EXIT ); |
407 return ret; |
588 return ret; |
408 } |
589 } |
409 |
590 |
410 HBufC* CFilePlugin::DatabasePathLC(TDriveNumber aMedia) |
591 HBufC* CFilePlugin::DatabasePathLC(TDriveNumber aMedia,const TDesC& aPath) |
411 { |
592 { |
|
593 OstTraceFunctionEntry0( CFILEPLUGIN_DATABASEPATHLC_ENTRY ); |
412 CPIXLOGSTRING("ENTER CFilePlugin::DatabasePathLC"); |
594 CPIXLOGSTRING("ENTER CFilePlugin::DatabasePathLC"); |
413 // Allocate extra space for root path e.g. "C:\\Private\\2001f6f7\\" |
595 // Allocate extra space for root path e.g. "C:\\Private\\2001f6f7\\" |
414 const TInt KRootPathMaxLength = 30; |
596 const TInt KRootPathMaxLength = 30; |
415 HBufC* indexDbPath = HBufC::NewLC(KRootPathMaxLength + KPathIndexDbPath().Length() + KPathTrailer().Length()); |
597 HBufC* indexDbPath = HBufC::NewLC(KRootPathMaxLength + KPathIndexDbPath().Length() + aPath.Length()); |
416 TPtr indexDbPathPtr = indexDbPath->Des(); |
598 TPtr indexDbPathPtr = indexDbPath->Des(); |
417 |
599 |
418 // Data caging implementation |
600 // Data caging implementation |
419 iFs.CreatePrivatePath(aMedia); |
601 iFs.CreatePrivatePath(aMedia); |
420 |
602 |
426 TFileName pathWithoutDrive; |
608 TFileName pathWithoutDrive; |
427 iFs.PrivatePath(pathWithoutDrive); |
609 iFs.PrivatePath(pathWithoutDrive); |
428 indexDbPathPtr.Append(KCPixSearchServerPrivateDirectory); |
610 indexDbPathPtr.Append(KCPixSearchServerPrivateDirectory); |
429 |
611 |
430 indexDbPathPtr.Append(KPathIndexDbPath); |
612 indexDbPathPtr.Append(KPathIndexDbPath); |
431 indexDbPathPtr.Append(KPathTrailer); |
613 indexDbPathPtr.Append(aPath); |
432 |
614 |
433 CPIXLOGSTRING("END CFilePlugin::DatabasePathLC"); |
615 CPIXLOGSTRING("END CFilePlugin::DatabasePathLC"); |
|
616 OstTraceFunctionExit0( CFILEPLUGIN_DATABASEPATHLC_EXIT ); |
434 return indexDbPath; |
617 return indexDbPath; |
|
618 } |
|
619 |
|
620 CSearchDocument* CFilePlugin::CreateCpixDocumentL(const TDesC& aFilePath, TBool aIsDir) |
|
621 { |
|
622 |
|
623 CSearchDocument* index_item = CSearchDocument::NewLC(aFilePath, KFileBaseAppClassFolder); |
|
624 |
|
625 TParse file; |
|
626 file.Set(aFilePath, NULL, NULL); |
|
627 |
|
628 TFileName fileFoldername; |
|
629 TInt pos = aFilePath.LocateReverse('\\'); |
|
630 if (pos > 0) |
|
631 { |
|
632 fileFoldername.Copy(aFilePath.Mid(pos+1)); |
|
633 index_item->AddFieldL(KNameField, fileFoldername); |
|
634 } |
|
635 |
|
636 //check for the extension, for folders names store the extension field as NULL |
|
637 //adding Mimetype and Extension field |
|
638 if(!aIsDir) |
|
639 { |
|
640 if( file.ExtPresent()) |
|
641 { |
|
642 TPtrC extension = file.Ext(); |
|
643 index_item->AddFieldL(KExtensionField, extension); |
|
644 } |
|
645 index_item->AddFieldL(KMimeTypeField, KMimeTypeFile, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
|
646 } |
|
647 else |
|
648 { |
|
649 index_item->AddFieldL(KExtensionField, KNullDesC); |
|
650 index_item->AddFieldL(KMimeTypeField, KMimeTypeFolder, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
|
651 } |
|
652 |
|
653 //Add excerpt field |
|
654 index_item->AddExcerptL(aFilePath); |
|
655 |
|
656 CleanupStack::Pop(index_item); |
|
657 return index_item; |
435 } |
658 } |
436 |
659 |
437 #ifdef __PERFORMANCE_DATA |
660 #ifdef __PERFORMANCE_DATA |
438 void CFilePlugin::UpdatePerformaceDataL(TDriveNumber aDriveNumber) |
661 void CFilePlugin::UpdatePerformaceDataL(TDriveNumber aDriveNumber) |
439 { |
662 { |