31 #include "cpixmediaaudiodoc.h" |
31 #include "cpixmediaaudiodoc.h" |
32 #include "cpixindexerutils.h" |
32 #include "cpixindexerutils.h" |
33 #include "mmcmonitor.h" |
33 #include "mmcmonitor.h" |
34 #include "cpixmdedbmanager.h" |
34 #include "cpixmdedbmanager.h" |
35 #include "mdsitementity.h" |
35 #include "mdsitementity.h" |
|
36 #include "OstTraceDefinitions.h" |
|
37 #ifdef OST_TRACE_COMPILER_IN_USE |
|
38 #include "mediapluginTraces.h" |
|
39 #endif |
|
40 |
36 |
41 |
37 //Constants |
42 //Constants |
38 _LIT(KPathTrailer, "\\root\\media\\audio"); |
43 _LIT(KPathTrailer, "\\root\\media\\audio"); |
39 |
44 |
40 //***** MEDAI AUDIO***** |
45 //***** MEDAI AUDIO***** |
96 } |
101 } |
97 |
102 |
98 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
99 void CAudioPlugin::StartPluginL() |
104 void CAudioPlugin::StartPluginL() |
100 { |
105 { |
|
106 OstTraceFunctionEntry0( CAUDIOPLUGIN_STARTPLUGINL_ENTRY ); |
101 CPIXLOGSTRING("CAudioPlugin::StartPluginL"); |
107 CPIXLOGSTRING("CAudioPlugin::StartPluginL"); |
102 // Define this base application class, use default location |
108 // Define this base application class, use default location |
103 iIndexerUtil = CCPixIndexerUtils::NewL(iSearchSession); |
109 iIndexerUtil = CCPixIndexerUtils::NewL(iSearchSession); |
104 //Test well before use |
110 //Test well before use |
105 TBuf<KMaxFileName> databasePathTemp; |
111 TBuf<KMaxFileName> databasePathTemp; |
120 // Start harvester for this plugin |
126 // Start harvester for this plugin |
121 iObserver->AddHarvestingQueue(this, _L(MEDIA_QBASEAPPCLASS) ); |
127 iObserver->AddHarvestingQueue(this, _L(MEDIA_QBASEAPPCLASS) ); |
122 TUid uidOfPlugin = {0x20029AB9}; |
128 TUid uidOfPlugin = {0x20029AB9}; |
123 iDBManager = CCPIXMDEDbManager::NewL(uidOfPlugin); |
129 iDBManager = CCPIXMDEDbManager::NewL(uidOfPlugin); |
124 iMdsItem = CMDSEntity::NewL(); |
130 iMdsItem = CMDSEntity::NewL(); |
|
131 OstTraceFunctionExit0( CAUDIOPLUGIN_STARTPLUGINL_EXIT ); |
125 } |
132 } |
126 |
133 |
127 void CAudioPlugin::HarvestingCompletedL() |
134 void CAudioPlugin::HarvestingCompletedL() |
128 { |
135 { |
129 #ifdef __PERFORMANCE_DATA |
136 #ifdef __PERFORMANCE_DATA |
132 iObserver->HarvestingCompleted(this, _L(MEDIA_QBASEAPPCLASS), KErrNone); |
139 iObserver->HarvestingCompleted(this, _L(MEDIA_QBASEAPPCLASS), KErrNone); |
133 } |
140 } |
134 // ----------------------------------------------------------------------------- |
141 // ----------------------------------------------------------------------------- |
135 void CAudioPlugin::StartHarvestingL( const TDesC& /*aMedia*/ ) |
142 void CAudioPlugin::StartHarvestingL( const TDesC& /*aMedia*/ ) |
136 { |
143 { |
|
144 OstTraceFunctionEntry0( CAUDIOPLUGIN_STARTHARVESTINGL_ENTRY ); |
137 //iIndexer->ResetL();//reset any indexes if exist already |
145 //iIndexer->ResetL();//reset any indexes if exist already |
138 CPIXLOGSTRING("CAudioPlugin::StartHarvestingL"); |
146 CPIXLOGSTRING("CAudioPlugin::StartHarvestingL"); |
139 iDBManager->ResetL(); |
147 iDBManager->ResetL(); |
140 iIndexerUtil->ResetAllL(); |
148 iIndexerUtil->ResetAllL(); |
141 //Start Media harvesting here |
149 //Start Media harvesting here |
142 #ifdef __PERFORMANCE_DATA |
150 #ifdef __PERFORMANCE_DATA |
143 iStartTime.UniversalTime(); |
151 iStartTime.UniversalTime(); |
144 #endif |
152 #endif |
145 iMdeHarvester->DoHarvesetL(MdeConstants::Audio::KAudioObject);//Start Harvesting |
153 iMdeHarvester->DoHarvesetL(MdeConstants::Audio::KAudioObject);//Start Harvesting |
|
154 OstTraceFunctionExit0( CAUDIOPLUGIN_STARTHARVESTINGL_EXIT ); |
146 } |
155 } |
147 |
156 |
148 //handle MMC event for the Drive |
157 //handle MMC event for the Drive |
149 void CAudioPlugin::HandleMMCEventL(const TDriveNumber aDrive,const TBool aMMCInsertRemoval) |
158 void CAudioPlugin::HandleMMCEventL(const TDriveNumber aDrive,const TBool aMMCInsertRemoval) |
150 { |
159 { |
168 } |
177 } |
169 |
178 |
170 void CAudioPlugin::HandleMdeItemL( TItemId aObjId, TCPixActionType aActionType) |
179 void CAudioPlugin::HandleMdeItemL( TItemId aObjId, TCPixActionType aActionType) |
171 { |
180 { |
172 //Get the object from object utils and get the CPIX document and add delete or update |
181 //Get the object from object utils and get the CPIX document and add delete or update |
|
182 OstTrace1( TRACE_NORMAL, CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL;aObjId=%d", aObjId ); |
173 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): aObjId = %d ", aObjId ); |
183 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): aObjId = %d ", aObjId ); |
174 // creating CSearchDocument object with unique ID for this application |
184 // creating CSearchDocument object with unique ID for this application |
175 TBuf<KMaxFileName> docid_str; |
185 TBuf<KMaxFileName> docid_str; |
176 if (aActionType == ECPixAddAction || aActionType == ECPixUpdateAction ) |
186 if (aActionType == ECPixAddAction || aActionType == ECPixUpdateAction ) |
177 { |
187 { |
178 //To Improve performance check here only before Getobject if it is Add event |
188 //To Improve performance check here only before Getobject if it is Add event |
179 //and we already have in our database just return in case of update move forward |
189 //and we already have in our database just return in case of update move forward |
180 if(iDBManager->IsAlreadyExistL(aObjId) && aActionType == ECPixAddAction)//Avoid reharvesting |
190 if(iDBManager->IsAlreadyExistL(aObjId) && aActionType == ECPixAddAction)//Avoid reharvesting |
181 { |
191 { |
|
192 OstTrace0( TRACE_NORMAL, DUP1_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Already harvested returning" ); |
182 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Already harvested returning"); |
193 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Already harvested returning"); |
183 return; |
194 return; |
184 } |
195 } |
185 //The caller should always handle leave of HandleMdeItemL |
196 //The caller should always handle leave of HandleMdeItemL |
186 CMdEObject& object= iMdsUtils->GetObjectL(aObjId,MdeConstants::Audio::KAudioObject); |
197 CMdEObject& object= iMdsUtils->GetObjectL(aObjId,MdeConstants::Audio::KAudioObject); |
189 CSearchDocument* index_item = iAudioDocument->GetCpixDocumentL(object,_L(MEDIAAPPCLASS),audioObjDef); |
200 CSearchDocument* index_item = iAudioDocument->GetCpixDocumentL(object,_L(MEDIAAPPCLASS),audioObjDef); |
190 iIndexer = iIndexerUtil->GetIndexerFromMediaId(object.MediaId()); |
201 iIndexer = iIndexerUtil->GetIndexerFromMediaId(object.MediaId()); |
191 if(!iIndexer) |
202 if(!iIndexer) |
192 { |
203 { |
193 delete index_item;//Remove |
204 delete index_item;//Remove |
|
205 OstTrace0( TRACE_NORMAL, DUP2_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Indexer not found" ); |
194 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Indexer not found"); |
206 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Indexer not found"); |
195 return; |
207 return; |
196 } |
208 } |
197 // Send for indexing |
209 // Send for indexing |
198 if (aActionType == ECPixAddAction) |
210 if (aActionType == ECPixAddAction) |
199 { |
211 { |
200 #ifdef __PERFORMANCE_DATA |
212 #ifdef __PERFORMANCE_DATA |
201 ++count; |
213 ++count; |
202 #endif |
214 #endif |
|
215 OstTrace0( TRACE_NORMAL, DUP3_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Indexer found calling AddL" ); |
203 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Indexer found calling AddL"); |
216 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Indexer found calling AddL"); |
204 //First check if it already exist in database |
217 //First check if it already exist in database |
205 TRAPD(err, iIndexer->UpdateL(*index_item)); //Always Update to avoid reharvesting |
218 TRAPD(err, iIndexer->UpdateL(*index_item)); //Always Update to avoid reharvesting |
206 if (err == KErrNone) |
219 if (err == KErrNone) |
207 { |
220 { |
211 iMdsItem->SetUri(iAudioDocument->GetUri());//Use the Absolute URI |
224 iMdsItem->SetUri(iAudioDocument->GetUri());//Use the Absolute URI |
212 TDriveNumber drive; |
225 TDriveNumber drive; |
213 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive); |
226 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive); |
214 iMdsItem->SetDrive(drive); |
227 iMdsItem->SetDrive(drive); |
215 iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB |
228 iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB |
|
229 OstTrace0( TRACE_NORMAL, DUP4_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Added." ); |
216 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Added."); |
230 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Added."); |
217 } |
231 } |
218 else |
232 else |
219 { |
233 { |
|
234 OstTrace1( TRACE_NORMAL, DUP5_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL;Error %d in adding", err ); |
220 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): Error %d in adding.", err); |
235 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): Error %d in adding.", err); |
221 } |
236 } |
222 } |
237 } |
223 else if (aActionType == ECPixUpdateAction) |
238 else if (aActionType == ECPixUpdateAction) |
224 { |
239 { |
235 if(iMdsItem->GetPath().Compare(object.Uri()) != 0) |
250 if(iMdsItem->GetPath().Compare(object.Uri()) != 0) |
236 { |
251 { |
237 CCPixIndexer *tempIndexer; |
252 CCPixIndexer *tempIndexer; |
238 tempIndexer = iIndexerUtil->GetIndexerFromDrive(iMdsItem->DriveNumber()); |
253 tempIndexer = iIndexerUtil->GetIndexerFromDrive(iMdsItem->DriveNumber()); |
239 tempIndexer->DeleteL(iMdsItem->Uri()); |
254 tempIndexer->DeleteL(iMdsItem->Uri()); |
|
255 OstTrace0( TRACE_NORMAL, DUP6_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Deleted existing URI for update" ); |
240 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Deleted existing URI for update"); |
256 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Deleted existing URI for update"); |
241 } |
257 } |
242 TRAPD(error, iIndexer->UpdateL(*index_item)); |
258 TRAPD(error, iIndexer->UpdateL(*index_item)); |
243 if (error == KErrNone) |
259 if (error == KErrNone) |
244 { |
260 { |
246 iMdsItem->Reset();//reset existing values |
262 iMdsItem->Reset();//reset existing values |
247 TDriveNumber drive; |
263 TDriveNumber drive; |
248 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive); |
264 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive); |
249 iMdsItem->Set(aObjId,iAudioDocument->GetUri(),drive); |
265 iMdsItem->Set(aObjId,iAudioDocument->GetUri(),drive); |
250 iDBManager->UpdateL(aObjId,*iMdsItem);//Add to SyncDB |
266 iDBManager->UpdateL(aObjId,*iMdsItem);//Add to SyncDB |
|
267 OstTrace0( TRACE_NORMAL, DUP7_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Updated." ); |
251 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Updated."); |
268 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Updated."); |
252 } |
269 } |
253 else |
270 else |
254 { |
271 { |
|
272 OstTrace1( TRACE_NORMAL, DUP8_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL;Error %d in Updating", err ); |
255 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): Error %d in updating.", error); |
273 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): Error %d in updating.", error); |
256 } |
274 } |
257 } |
275 } |
258 //If a media item is added when downloading or streaming begins, add event is surpassed |
276 //If a media item is added when downloading or streaming begins, add event is surpassed |
259 //by update or delete event because of delay introduced on monitered object by objectqueue manager |
277 //by update or delete event because of delay introduced on monitered object by objectqueue manager |
269 iMdsItem->SetUri(iAudioDocument->GetUri());//Use the Absolute URI |
287 iMdsItem->SetUri(iAudioDocument->GetUri());//Use the Absolute URI |
270 TDriveNumber drive; |
288 TDriveNumber drive; |
271 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive); |
289 iIndexerUtil->GetDriveFromMediaId(object.MediaId(),drive); |
272 iMdsItem->SetDrive(drive); |
290 iMdsItem->SetDrive(drive); |
273 iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB |
291 iDBManager->AddL(aObjId,*iMdsItem);//Add to SyncDB |
|
292 OstTrace0( TRACE_NORMAL, DUP9_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Added Item before Update." ); |
274 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Added Item before Update."); |
293 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Added Item before Update."); |
275 } |
294 } |
276 } |
295 } |
277 } |
296 } |
278 delete index_item; |
297 delete index_item; |
291 { |
310 { |
292 docid_str.Copy(iMdsItem->Uri()); |
311 docid_str.Copy(iMdsItem->Uri()); |
293 TRAPD(err, iIndexer->DeleteL(docid_str));//Delete it |
312 TRAPD(err, iIndexer->DeleteL(docid_str));//Delete it |
294 if (err == KErrNone) |
313 if (err == KErrNone) |
295 { |
314 { |
|
315 OstTrace0( TRACE_NORMAL, DUP10_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL(): Deleted." ); |
296 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Deleted."); |
316 CPIXLOGSTRING("CAudioPlugin::HandleMdeItemL(): Deleted."); |
297 } |
317 } |
298 else |
318 else |
299 { |
319 { |
|
320 OstTrace1( TRACE_NORMAL, DUP11_CAUDIOPLUGIN_HANDLEMDEITEML, "CAudioPlugin::HandleMdeItemL;Error %d in deleting", err ); |
300 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): Error %d in deleting.", err); |
321 CPIXLOGSTRING2("CAudioPlugin::HandleMdeItemL(): Error %d in deleting.", err); |
301 } |
322 } |
302 } |
323 } |
303 //delete entry from database |
324 //delete entry from database |
304 iDBManager->RemoveL(iMdsItem->Key()); |
325 iDBManager->RemoveL(iMdsItem->Key()); |