39 _LIT8( KMgMusic ,"Music" ); |
40 _LIT8( KMgMusic ,"Music" ); |
40 _LIT8( KMgSound ,"Sound" ); |
41 _LIT8( KMgSound ,"Sound" ); |
41 _LIT8( KMgImage ,"Image" ); |
42 _LIT8( KMgImage ,"Image" ); |
42 _LIT8( KMgVideo ,"Video" ); |
43 _LIT8( KMgVideo ,"Video" ); |
43 _LIT8( KMgStreamingURL ,"StreamingURL" ); |
44 _LIT8( KMgStreamingURL ,"StreamingURL" ); |
44 |
45 _LIT8(KAudio,"Audio"); |
|
46 _LIT8(KAll,"All"); |
45 |
47 |
46 //SortingOrder |
48 //SortingOrder |
47 _LIT8( KMgDescending, "Descending" ); |
49 _LIT8( KMgDescending, "Descending" ); |
48 //_LIT8( KMgAscending, "Ascending" ); |
50 //_LIT8( KMgAscending, "Ascending" ); |
49 |
51 |
115 |
123 |
116 //Check if the class is busy or waiting for asynchronous request |
124 //Check if the class is busy or waiting for asynchronous request |
117 //This has already been verified by SAPI interface class ,still this condition |
125 //This has already been verified by SAPI interface class ,still this condition |
118 //is checked keeping in mind that this class may be called directly by a |
126 //is checked keeping in mind that this class may be called directly by a |
119 //Series60 application in future |
127 //Series60 application in future |
120 if( EMgFree == iState ) |
|
121 { |
|
122 |
|
123 |
|
124 |
|
125 if( NULL != aServiceObserver )//Asynchronous request |
128 if( NULL != aServiceObserver )//Asynchronous request |
126 { |
129 { |
|
130 |
|
131 //create the instance of clf observer |
|
132 CClfOperationObserver* clfObserver = CClfOperationObserver::NewL(); |
|
133 CleanupStack::PushL(clfObserver); |
|
134 |
127 // create the instance of CLF list Model for the current request |
135 // create the instance of CLF list Model for the current request |
128 MCLFItemListModel* listModel = iEngine-> |
136 MCLFItemListModel* listModel = iEngine-> |
129 CreateListModelLC( *iClfObserver ); |
137 CreateListModelLC( *clfObserver ); |
130 |
138 // CleanupStack::Pop(); |
131 |
139 // CleanupStack::PushL(listModel); |
132 |
140 // adding observer to asynrequestmanager |
|
141 |
|
142 //iAsyncRequestManager->AddObserverL(clfObserver,aInParameters.iTransactionID); |
|
143 |
|
144 |
|
145 // We need to make post filter and sorting style each for each call |
|
146 |
|
147 // create the instance of CPostFilter and store it in member data |
|
148 CPostFilter* filter = CPostFilter::NewL(); |
|
149 CleanupStack::PushL(filter); |
|
150 |
|
151 // Get the sorting style from CLF |
|
152 MCLFSortingStyle* sortingStyle = ContentListingFactory::NewSortingStyleLC(); |
|
153 |
|
154 |
133 |
155 |
134 SendRequestToClfL( aInParameters.iFileType, |
156 SendRequestToClfL( aInParameters.iFileType, |
135 aInParameters.iFilterField, |
157 aInParameters.iFilterField, |
136 aInParameters.iStartVal, |
158 aInParameters.iStartVal, |
137 aInParameters.iEndVal, |
159 aInParameters.iEndVal, |
138 aInParameters.iSortField, |
160 aInParameters.iSortField, |
139 aInParameters.iOrder, |
161 aInParameters.iOrder, |
140 listModel ); |
162 listModel,filter,sortingStyle ); |
141 |
163 |
142 CleanupStack::Pop(); |
164 CleanupStack::Pop();//sortingStyle |
|
165 CleanupStack::Pop(filter); |
|
166 CleanupStack::Pop(); //listModel |
|
167 CleanupStack::Pop(clfObserver); //clfObserver |
|
168 |
|
169 iAsyncRequestManager->AddObserverL(clfObserver,aInParameters.iTransactionID); |
143 |
170 |
144 iTransactionID = aInParameters.iTransactionID; |
171 // Adding aServiceObserver, listmodel instance , filter and sorting instance to observer |
145 iClfObserver->SetMemberVar( aInParameters.iTransactionID, |
172 clfObserver->SetMemberVar( aInParameters.iTransactionID, |
146 aServiceObserver, |
173 aServiceObserver, |
147 listModel, |
174 listModel, |
148 this ); |
175 this ,iAsyncRequestManager, |
149 |
176 filter,sortingStyle ); |
150 |
177 |
151 |
178 |
152 } |
179 } |
153 else |
180 else |
154 { |
181 { |
155 //Synchronous request handling is currently not supported |
182 //Synchronous request handling is currently not supported |
156 User::Leave( KErrNotSupported ); |
183 User::Leave( KErrNotSupported ); |
157 } |
184 } |
158 |
|
159 }//SAPI State |
|
160 else |
|
161 { |
|
162 User::Leave( KErrServerBusy ); // busy in previous request |
|
163 } |
|
164 |
|
165 } |
185 } |
166 |
186 |
167 |
187 |
168 // ----------------------------------------------------------------------------- |
188 // ----------------------------------------------------------------------------- |
169 // CMgService::Cancel |
189 // CMgService::Cancel |
174 // call cancel of CLF |
194 // call cancel of CLF |
175 // Right now we are not supporting aTransactionID |
195 // Right now we are not supporting aTransactionID |
176 // but in future we have to find the iClfObserver |
196 // but in future we have to find the iClfObserver |
177 // coresponding to this Transaction ID and Call cancel |
197 // coresponding to this Transaction ID and Call cancel |
178 // on that observer |
198 // on that observer |
179 if( EMgBusy == iState ) |
199 /* if( EMgBusy == iState ) |
180 { |
200 { |
|
201 // Need to change the implementation of cancel here LOK |
181 if( aTransactionID == iTransactionID ) |
202 if( aTransactionID == iTransactionID ) |
182 { |
203 { |
183 iClfObserver->CancelL( ); |
204 iClfObserver->CancelL( ); |
184 Clear(); |
205 Clear(); |
185 return KErrNone; |
206 return KErrNone; |
186 } |
207 } |
187 } |
208 } |
188 |
209 */ |
|
210 TInt ret = KErrNone; |
|
211 |
|
212 ret = iAsyncRequestManager->Cancel(aTransactionID); |
|
213 |
|
214 if(KErrNotFound == ret ) |
|
215 { |
|
216 // Cancel request if for thumbnail |
|
217 ret = CancelThumbnailReq(aTransactionID); |
|
218 |
|
219 } |
|
220 |
|
221 return ret ; |
189 // Calling cancel of thumbnail |
222 // Calling cancel of thumbnail |
190 |
223 |
191 if(aTransactionID != iTransactionID) |
224 /*if(aTransactionID != iTransactionID) // Need to check this condion LOK |
192 { |
225 { |
193 return CancelThumbnailReq(aTransactionID); |
226 return CancelThumbnailReq(aTransactionID); |
194 } |
227 } |
195 |
228 |
196 return KErrArgument; |
229 return KErrArgument;*/ |
197 |
230 |
198 } |
231 } |
|
232 |
199 // ----------------------------------------------------------------------------- |
233 // ----------------------------------------------------------------------------- |
200 // CMgService::CancelThumbnailReq |
234 // CMgService::CancelThumbnailReq |
201 // Cancel the pending asynchronous request for thumbnail generation |
235 // Cancel the pending asynchronous request for thumbnail generation |
202 // ----------------------------------------------------------------------------- |
236 // ----------------------------------------------------------------------------- |
203 TInt CMgService::CancelThumbnailReq( TUint aTransactionID ) |
237 TInt CMgService::CancelThumbnailReq( TUint aTransactionID ) |
242 // ----------------------------------------------------------------------------- |
276 // ----------------------------------------------------------------------------- |
243 |
277 |
244 void CMgService::SetSortingFieldL(const TDesC8& aSortField , |
278 void CMgService::SetSortingFieldL(const TDesC8& aSortField , |
245 const TDesC8& aOrder , |
279 const TDesC8& aOrder , |
246 const RArray<TInt>& aMediaTypes, |
280 const RArray<TInt>& aMediaTypes, |
247 MCLFItemListModel* alistModel ) |
281 MCLFItemListModel* alistModel, |
|
282 MCLFSortingStyle* aSortingStyle ) |
248 { |
283 { |
249 |
284 |
250 // Default sorting as per file name |
285 // Default sorting as per file name |
251 TCLFDefaultFieldId metaDataId = ECLFFieldIdFileName; |
286 TCLFDefaultFieldId metaDataId = ECLFFieldIdFileName; |
252 TCLFItemDataType metaDataType = ECLFItemDataTypeDesC; |
287 TCLFItemDataType metaDataType = ECLFItemDataTypeDesC; |
267 // The given Sort Field is not supported by Media Management SAPI |
302 // The given Sort Field is not supported by Media Management SAPI |
268 User::Leave( KErrArgument ); |
303 User::Leave( KErrArgument ); |
269 } |
304 } |
270 } |
305 } |
271 |
306 |
272 iSortingStyle->ResetL(); |
307 aSortingStyle->ResetL(); |
273 |
308 |
274 |
309 |
275 //Set the field on which sorting has to perform |
310 //Set the field on which sorting has to perform |
276 iSortingStyle->AddFieldL( metaDataId ); |
311 aSortingStyle->AddFieldL( metaDataId ); |
277 |
312 |
278 // Set the sorting field data type |
313 // Set the sorting field data type |
279 iSortingStyle->SetSortingDataType( metaDataType ); |
314 aSortingStyle->SetSortingDataType( metaDataType ); |
280 |
315 |
281 if( 0 == aOrder.CompareF( KMgDescending ) ) |
316 if( 0 == aOrder.CompareF( KMgDescending ) ) |
282 { |
317 { |
283 iSortingStyle->SetOrdering( ECLFOrderingDescending ); |
318 aSortingStyle->SetOrdering( ECLFOrderingDescending ); |
284 } |
319 } |
285 else if( 0 == aOrder.CompareF( KMgAscending) ) |
320 else if( 0 == aOrder.CompareF( KMgAscending) ) |
286 { |
321 { |
287 iSortingStyle->SetOrdering( ECLFOrderingAscending ); |
322 aSortingStyle->SetOrdering( ECLFOrderingAscending ); |
288 } |
323 } |
289 else |
324 else |
290 { |
325 { |
291 User::Leave( KErrArgument ); |
326 User::Leave( KErrArgument ); |
292 } |
327 } |
293 |
328 |
294 //Items with undefined fields are placed after items with defined fields |
329 //Items with undefined fields are placed after items with defined fields |
295 iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd ); |
330 aSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd ); |
296 |
331 |
297 // set sorting style in CLF. |
332 // set sorting style in CLF. |
298 alistModel->SetSortingStyle( iSortingStyle ); |
333 alistModel->SetSortingStyle( aSortingStyle ); |
299 |
334 |
300 |
335 |
301 } |
336 } |
302 |
337 |
303 |
338 |
307 // ----------------------------------------------------------------------------- |
342 // ----------------------------------------------------------------------------- |
308 void CMgService::SetFilterMetaDataL( const TDesC8& aFilterField, |
343 void CMgService::SetFilterMetaDataL( const TDesC8& aFilterField, |
309 const TDesC& aStartVal, |
344 const TDesC& aStartVal, |
310 const TDesC& aEndVal, |
345 const TDesC& aEndVal, |
311 const RArray<TInt>& aMediaTypes, |
346 const RArray<TInt>& aMediaTypes, |
312 MCLFItemListModel* alistModel ) |
347 MCLFItemListModel* alistModel, |
|
348 CPostFilter* aFilter) |
313 { |
349 { |
314 TCLFDefaultFieldId metaDataId; |
350 TCLFDefaultFieldId metaDataId; |
315 TCLFItemDataType metaDataType; |
351 TCLFItemDataType metaDataType; |
316 |
352 |
317 |
353 |
336 // The given metaData is not supported by Media Management SAPI |
372 // The given metaData is not supported by Media Management SAPI |
337 User::Leave( KErrArgument ); |
373 User::Leave( KErrArgument ); |
338 } |
374 } |
339 |
375 |
340 |
376 |
341 iFilter->SetFilterMetaData( metaDataId, metaDataType ); |
377 aFilter->SetFilterMetaData( metaDataId, metaDataType ); |
342 |
378 |
343 // set filter value of CLF |
379 // set filter value of CLF |
344 iFilter->SetFilterValueL( aStartVal,aEndVal ); |
380 aFilter->SetFilterValueL( aStartVal,aEndVal ); |
345 |
381 |
346 // Set Post Filter in CLF |
382 // Set Post Filter in CLF |
347 alistModel->SetPostFilter( iFilter ); |
383 alistModel->SetPostFilter( aFilter ); |
348 |
384 |
349 } |
385 } |
350 |
386 |
351 } |
387 } |
352 |
388 |
361 // create the instance of CLF engine and store it in member data. |
397 // create the instance of CLF engine and store it in member data. |
362 iEngine = ContentListingFactory::NewContentListingEngineLC(); |
398 iEngine = ContentListingFactory::NewContentListingEngineLC(); |
363 CleanupStack::Pop(); |
399 CleanupStack::Pop(); |
364 |
400 |
365 |
401 |
366 // create the instance of CPostFilter and store it in member data |
402 // creates instance for thumbnailgeneration calss |
367 iFilter = CPostFilter::NewL(); |
403 iTumbnailGeneration = CThumbnailGeneration::NewL(); |
368 |
|
369 // Get the sorting style from CLF |
|
370 iSortingStyle = ContentListingFactory::NewSortingStyleLC(); |
|
371 CleanupStack::Pop(); |
|
372 |
|
373 //create the instance of clf observer |
|
374 iClfObserver = CClfOperationObserver::NewL(); |
|
375 |
404 |
376 // creates instance for async requestmanager for thumbnail |
405 //creates the instance of async request manager for getlist |
377 iTumbnailGeneration = CThumbnailGeneration::NewL(); |
406 iAsyncRequestManager = CAsynchRequestManager::NewL(); |
378 |
407 |
379 } |
408 } |
380 |
409 |
381 |
410 |
382 |
411 |
386 // Constructor |
415 // Constructor |
387 // ----------------------------------------------------------------------------- |
416 // ----------------------------------------------------------------------------- |
388 CMgService::CMgService() |
417 CMgService::CMgService() |
389 : iState( EMgFree ), |
418 : iState( EMgFree ), |
390 iEngine( NULL ), |
419 iEngine( NULL ), |
391 iFilter( NULL ), |
420 iTransactionID( 0 ), |
392 iSortingStyle( NULL ), |
421 iTumbnailGeneration(NULL), |
393 iClfObserver( NULL ), |
422 iAsyncRequestManager(NULL) |
394 iTransactionID( 0 ), |
423 { |
395 iTumbnailGeneration(NULL) |
424 |
396 { |
425 } |
397 |
|
398 } |
|
399 |
|
400 |
426 |
401 |
427 |
402 // ----------------------------------------------------------------------------- |
428 // ----------------------------------------------------------------------------- |
403 // CMgService::SetMediaTypeL |
429 // CMgService::SetMediaTypeL |
404 // It will convert the aFiletype string into |
430 // It will convert the aFiletype string into |
406 // if it is not valid then return KErrNotSupported |
432 // if it is not valid then return KErrNotSupported |
407 // ----------------------------------------------------------------------------- |
433 // ----------------------------------------------------------------------------- |
408 void CMgService::SetMediaTypeL (const TDesC8& aFileType, |
434 void CMgService::SetMediaTypeL (const TDesC8& aFileType, |
409 RArray<TInt>& aMediaType) |
435 RArray<TInt>& aMediaType) |
410 { |
436 { |
411 |
437 if(0 == aFileType.CompareF( KAll )) |
412 if( 0 == aFileType.CompareF( KMgMusic ) ) |
438 { |
|
439 aMediaType.AppendL( ECLFMediaTypeMusic ); |
|
440 aMediaType.AppendL( ECLFMediaTypeSound ); |
|
441 aMediaType.AppendL( ECLFMediaTypeImage ); |
|
442 aMediaType.AppendL( ECLFMediaTypeVideo ); |
|
443 //aMediaType.AppendL( ECLFMediaTypeStreamingURL ); Not supported by MDS till now |
|
444 } |
|
445 else if( 0 == aFileType.CompareF( KMgMusic ) ) |
413 { |
446 { |
414 aMediaType.AppendL( ECLFMediaTypeMusic ); |
447 aMediaType.AppendL( ECLFMediaTypeMusic ); |
415 } |
448 } |
416 else if( 0 == aFileType.CompareF( KMgSound ) ) |
449 else if( 0 == aFileType.CompareF( KMgSound ) ) |
417 { |
450 { |
456 const TDesC8& aFilterField, |
494 const TDesC8& aFilterField, |
457 const TDesC& aStartVal, |
495 const TDesC& aStartVal, |
458 const TDesC& aEndVal, |
496 const TDesC& aEndVal, |
459 const TDesC8& aSortField, |
497 const TDesC8& aSortField, |
460 const TDesC8& aOrder, |
498 const TDesC8& aOrder, |
461 MCLFItemListModel* alistModel ) |
499 MCLFItemListModel* alistModel , |
|
500 CPostFilter* aFilter, |
|
501 MCLFSortingStyle* aSortingStyle) |
462 { |
502 { |
463 |
503 |
464 |
504 |
465 |
505 |
466 RArray<TInt> mediaTypes; |
506 RArray<TInt> mediaTypes; |
473 //set wanted media type in CLF |
513 //set wanted media type in CLF |
474 alistModel->SetWantedMediaTypesL( mediaTypes.Array() ); |
514 alistModel->SetWantedMediaTypesL( mediaTypes.Array() ); |
475 |
515 |
476 |
516 |
477 // Set Filter Meta Data and Value |
517 // Set Filter Meta Data and Value |
478 SetFilterMetaDataL( aFilterField,aStartVal,aEndVal,mediaTypes,alistModel); |
518 SetFilterMetaDataL( aFilterField,aStartVal,aEndVal,mediaTypes,alistModel,aFilter); |
479 |
519 |
480 |
520 |
481 |
521 |
482 // call set sorting field of CLF |
522 // call set sorting field of CLF |
483 SetSortingFieldL( aSortField,aOrder,mediaTypes,alistModel ); |
523 SetSortingFieldL( aSortField,aOrder,mediaTypes,alistModel ,aSortingStyle); |
484 |
524 |
485 // set the state = Busy |
525 // set the state = Busy |
486 // till this request is complete |
526 // till this request is complete |
487 //which indicates no further request will be taken |
527 //which indicates no further request will be taken |
488 iState = EMgBusy; |
528 iState = EMgBusy; |