author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 Aug 2009 07:43:07 +0300 | |
changeset 22 | fc9cf246af83 |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2007-2007 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 the License "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: This Class provides the core functionality to Media Management |
|
15 |
* SAPI Interafce |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
//#include <liwserviceifbase.h> |
|
21 |
#include <liwcommon.h> |
|
22 |
#include <mclfitemlistmodel.h> |
|
23 |
#include <mclfcontentlistingengine.h> |
|
24 |
#include <contentlistingfactory.h> |
|
25 |
#include <mclfsortingstyle.h> |
|
26 |
||
27 |
||
28 |
#include "mgservice.h" |
|
29 |
#include "mgpostfilter.h" |
|
30 |
#include "mgoperationobserver.h" |
|
31 |
#include "mgclfoperationobserver.h" |
|
32 |
#include "mgconsts.h" |
|
33 |
||
34 |
||
35 |
_LIT8( KMgMusic ,"Music" ); |
|
36 |
_LIT8( KMgSound ,"Sound" ); |
|
37 |
_LIT8( KMgImage ,"Image" ); |
|
38 |
_LIT8( KMgVideo ,"Video" ); |
|
39 |
_LIT8( KMgStreamingURL ,"StreamingURL" ); |
|
40 |
//SortingOrder |
|
41 |
_LIT8( KMgDescending, "Descending" ); |
|
42 |
||
43 |
_LIT(LogFileName , "C:\\Performance_Image.txt") ; |
|
44 |
RFile LogFile ; |
|
45 |
RFs LogSession ; |
|
46 |
||
47 |
||
48 |
// ----------------------------------------------------------------------------- |
|
49 |
// CMgService::NewLC |
|
50 |
// Returns the instance of CMgService class. |
|
51 |
// ----------------------------------------------------------------------------- |
|
52 |
CMgService* CMgService::NewL() |
|
53 |
{ |
|
54 |
CMgService* self = new ( ELeave )CMgService(); |
|
55 |
CleanupStack::PushL( self ); |
|
56 |
self->ConstructL(); |
|
57 |
CleanupStack::Pop( self ); |
|
58 |
return self; |
|
59 |
} |
|
60 |
// ----------------------------------------------------------------------------- |
|
61 |
// CMgService::~CMgService |
|
62 |
// Destructor |
|
63 |
// ----------------------------------------------------------------------------- |
|
64 |
||
65 |
CMgService::~CMgService() |
|
66 |
{ |
|
67 |
//release iEngine; |
|
68 |
delete iEngine; |
|
69 |
||
70 |
//release filter class |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
71 |
//delete iFilter; |
19 | 72 |
|
73 |
// release sorting style |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
74 |
// delete iSortingStyle; |
19 | 75 |
|
76 |
// release clf observer class |
|
77 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
78 |
// delete iClfObserver; |
19 | 79 |
|
80 |
||
81 |
} |
|
82 |
||
83 |
||
84 |
||
85 |
||
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// CMgService::GetFiles |
|
88 |
// This function extracts all media item that match the given arguments |
|
89 |
// ----------------------------------------------------------------------------- |
|
90 |
||
91 |
void CMgService::GetListL(const TMgServiceRequest& aInParameters, |
|
92 |
MMgOperationObserver* aServiceObserver) |
|
93 |
{ |
|
94 |
||
95 |
//Check if the class is busy or waiting for asynchronous request |
|
96 |
//This has already been verified by SAPI interface class ,still this condition |
|
97 |
//is checked keeping in mind that this class may be called directly by a |
|
98 |
//Series60 application in future |
|
99 |
if( EMgFree == iState ) |
|
100 |
{ |
|
101 |
||
102 |
||
103 |
||
104 |
if( NULL != aServiceObserver )//Asynchronous request |
|
105 |
{ |
|
106 |
// create the instance of CLF list Model for the current request |
|
107 |
MCLFItemListModel* listModel = iEngine-> |
|
108 |
CreateListModelLC( *iClfObserver ); |
|
109 |
||
110 |
||
111 |
||
112 |
||
113 |
SendRequestToClfL( aInParameters.iFileType, |
|
114 |
aInParameters.iFilterField, |
|
115 |
aInParameters.iStartVal, |
|
116 |
aInParameters.iEndVal, |
|
117 |
aInParameters.iSortField, |
|
118 |
aInParameters.iOrder, |
|
119 |
listModel ); |
|
120 |
||
121 |
CleanupStack::Pop(); |
|
122 |
||
123 |
iTransactionID = aInParameters.iTransactionID; |
|
124 |
iClfObserver->SetMemberVar( aInParameters.iTransactionID, |
|
125 |
aServiceObserver, |
|
126 |
listModel, |
|
127 |
this ); |
|
128 |
||
129 |
||
130 |
||
131 |
} |
|
132 |
else |
|
133 |
{ |
|
134 |
//Synchronous request handling is currently not supported |
|
135 |
User::Leave( KErrNotSupported ); |
|
136 |
} |
|
137 |
||
138 |
}//SAPI State |
|
139 |
else |
|
140 |
{ |
|
141 |
User::Leave( KErrServerBusy ); // busy in previous request |
|
142 |
} |
|
143 |
||
144 |
} |
|
145 |
||
146 |
||
147 |
// ----------------------------------------------------------------------------- |
|
148 |
// CMgService::Cancel |
|
149 |
// Cancel the pending asynchronous request |
|
150 |
// ----------------------------------------------------------------------------- |
|
151 |
TInt CMgService::Cancel( TUint aTransactionID) |
|
152 |
{ |
|
153 |
// call cancel of CLF |
|
154 |
// Right now we are not supporting aTransactionID |
|
155 |
// but in future we have to find the iClfObserver |
|
156 |
// coresponding to this Transaction ID and Call cancel |
|
157 |
// on that observer |
|
158 |
if( EMgBusy == iState ) |
|
159 |
{ |
|
160 |
if( aTransactionID == iTransactionID ) |
|
161 |
{ |
|
162 |
iClfObserver->Cancel( ); |
|
163 |
Clear(); |
|
164 |
} |
|
165 |
else |
|
166 |
{ |
|
167 |
return KErrArgument; |
|
168 |
} |
|
169 |
||
170 |
} |
|
171 |
||
172 |
return KErrNone; |
|
173 |
} |
|
174 |
||
175 |
// ----------------------------------------------------------------------------- |
|
176 |
// CMgService::Clear |
|
177 |
// It will clear the set filter metadata field ,registered callback |
|
178 |
// function and sorting fields |
|
179 |
// ----------------------------------------------------------------------------- |
|
180 |
||
181 |
void CMgService::Clear() |
|
182 |
{ |
|
183 |
iFilter->Clear(); |
|
184 |
iState = EMgFree; |
|
185 |
iTransactionID = 0; |
|
186 |
} |
|
187 |
||
188 |
||
189 |
||
190 |
||
191 |
// ----------------------------------------------------------------------------- |
|
192 |
// CMgService::State |
|
193 |
// It will return the state of service class. |
|
194 |
// return EMgFree if it is free and ready to accept |
|
195 |
// the another request else EMgBusy |
|
196 |
// ----------------------------------------------------------------------------- |
|
197 |
const TMgState& CMgService::State() const |
|
198 |
{ |
|
199 |
return iState; |
|
200 |
} |
|
201 |
||
202 |
||
203 |
||
204 |
||
205 |
// ----------------------------------------------------------------------------- |
|
206 |
// CMgService::SetSortingField |
|
207 |
// It will set the metadata field on which the result |
|
208 |
// should be sorted. |
|
209 |
// Leave with KErrArgument if aSortField is not valid. |
|
210 |
// ----------------------------------------------------------------------------- |
|
211 |
||
212 |
void CMgService::SetSortingFieldL(const TDesC8& aSortField , |
|
213 |
const TDesC8& aOrder , |
|
214 |
const RArray<TInt>& aMediaTypes, |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
215 |
MCLFItemListModel* alistModel , |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
216 |
MCLFSortingStyle* aSortingStyle ) |
19 | 217 |
{ |
218 |
||
219 |
// Default sorting as per file name |
|
220 |
TCLFDefaultFieldId metaDataId = ECLFFieldIdFileName; |
|
221 |
TCLFItemDataType metaDataType = ECLFItemDataTypeDesC; |
|
222 |
||
223 |
//Check If the aSortField is not NULL Descriptor i.e. |
|
224 |
// sorting metadata is specified |
|
225 |
||
226 |
if( 0 != aSortField.CompareF( KNullDesC8 ) ) |
|
227 |
{ |
|
228 |
||
229 |
GetMetaDataIdAndType( aSortField, |
|
230 |
metaDataId, |
|
231 |
metaDataType, |
|
232 |
aMediaTypes ); |
|
233 |
||
234 |
if( ECLFFieldIdNull == metaDataId ) // check the return type |
|
235 |
{ |
|
236 |
// The given Sort Field is not supported by Media Management SAPI |
|
237 |
User::Leave( KErrArgument ); |
|
238 |
} |
|
239 |
} |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
240 |
aSortingStyle->ResetL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
241 |
//iSortingStyle->ResetL(); |
19 | 242 |
|
243 |
||
244 |
//Set the field on which sorting has to perform |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
245 |
aSortingStyle->AddFieldL( metaDataId ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
246 |
//iSortingStyle->AddFieldL( metaDataId ); |
19 | 247 |
|
248 |
// Set the sorting field data type |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
249 |
aSortingStyle->SetSortingDataType( metaDataType ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
250 |
//iSortingStyle->SetSortingDataType( metaDataType ); |
19 | 251 |
|
252 |
if( 0 == aOrder.CompareF( KMgDescending ) ) |
|
253 |
{ |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
254 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
255 |
aSortingStyle->SetOrdering( ECLFOrderingDescending ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
256 |
//iSortingStyle->SetOrdering( ECLFOrderingDescending ); |
19 | 257 |
} |
258 |
else |
|
259 |
{ |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
260 |
aSortingStyle->SetOrdering( ECLFOrderingAscending ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
261 |
//iSortingStyle->SetOrdering( ECLFOrderingAscending ); |
19 | 262 |
} |
263 |
||
264 |
//Items with undefined fields are placed after items with defined fields |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
265 |
aSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
266 |
//iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd ); |
19 | 267 |
|
268 |
// set sorting style in CLF. |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
269 |
alistModel->SetSortingStyle( aSortingStyle ); |
19 | 270 |
|
271 |
||
272 |
} |
|
273 |
||
274 |
||
275 |
// ----------------------------------------------------------------------------- |
|
276 |
// CPostFilter::SetFilterMetaData |
|
277 |
// Method to set the filter metadata |
|
278 |
// ----------------------------------------------------------------------------- |
|
279 |
void CMgService::SetFilterMetaDataL( const TDesC8& aFilterField, |
|
280 |
const TDesC& aStartVal, |
|
281 |
const TDesC& aEndVal, |
|
282 |
const RArray<TInt>& aMediaTypes, |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
283 |
MCLFItemListModel* alistModel, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
284 |
CPostFilter* aFilter) |
19 | 285 |
{ |
286 |
TCLFDefaultFieldId metaDataId; |
|
287 |
TCLFItemDataType metaDataType; |
|
288 |
||
289 |
||
290 |
||
291 |
//Check If the Filter Meta Data is NULL Descriptor, if so |
|
292 |
// no filtration will be performed |
|
293 |
if( 0 == aFilterField.CompareF( KNullDesC8 ) ) |
|
294 |
{ |
|
295 |
metaDataId = ECLFFieldIdNull; |
|
296 |
metaDataType = ECLFItemDataTypeDesC; // Blank Descriptor |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
297 |
aFilter->SetFilterMetaData( metaDataId, metaDataType ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
298 |
//iFilter->SetFilterMetaData( metaDataId, metaDataType ); |
19 | 299 |
} |
300 |
else |
|
301 |
{ |
|
302 |
GetMetaDataIdAndType( aFilterField, |
|
303 |
metaDataId, |
|
304 |
metaDataType, |
|
305 |
aMediaTypes); |
|
306 |
||
307 |
if( ECLFFieldIdNull == metaDataId ) |
|
308 |
{ |
|
309 |
// The given metaData is not supported by Media Management SAPI |
|
310 |
User::Leave( KErrNotSupported ); |
|
311 |
} |
|
312 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
313 |
aFilter->SetFilterMetaData( metaDataId, metaDataType ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
314 |
//iFilter->SetFilterMetaData( metaDataId, metaDataType ); |
19 | 315 |
|
316 |
// set filter value of CLF |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
317 |
aFilter->SetFilterValueL( aStartVal,aEndVal ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
318 |
//iFilter->SetFilterValueL( aStartVal,aEndVal ); |
19 | 319 |
|
320 |
// Set Post Filter in CLF |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
321 |
alistModel->SetPostFilter( aFilter ); |
19 | 322 |
|
323 |
} |
|
324 |
||
325 |
} |
|
326 |
||
327 |
||
328 |
// ----------------------------------------------------------------------------- |
|
329 |
// CMgService::ConstuctL |
|
330 |
// It will intialize the underlying CLF(Content Listing Framework) |
|
331 |
// framework classes and CPostFilter class. |
|
332 |
// ----------------------------------------------------------------------------- |
|
333 |
void CMgService::ConstructL() |
|
334 |
{ |
|
335 |
// create the instance of CLF engine and store it in member data. |
|
336 |
iEngine = ContentListingFactory::NewContentListingEngineLC(); |
|
337 |
CleanupStack::Pop(); |
|
338 |
||
339 |
||
340 |
// create the instance of CPostFilter and store it in member data |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
341 |
// iFilter = CPostFilter::NewL(); |
19 | 342 |
|
343 |
// Get the sorting style from CLF |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
344 |
// iSortingStyle = ContentListingFactory::NewSortingStyleLC(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
345 |
// CleanupStack::Pop(); |
19 | 346 |
|
347 |
//create the instance of clf observer |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
348 |
// iClfObserver = CClfOperationObserver::NewL(); |
19 | 349 |
|
350 |
} |
|
351 |
||
352 |
||
353 |
||
354 |
||
355 |
// ----------------------------------------------------------------------------- |
|
356 |
// CMgService::CMgService |
|
357 |
// Constructor |
|
358 |
// ----------------------------------------------------------------------------- |
|
359 |
CMgService::CMgService() |
|
360 |
: iState( EMgFree ), |
|
361 |
iEngine( NULL ), |
|
362 |
iTransactionID( 0 ) |
|
363 |
{ |
|
364 |
||
365 |
} |
|
366 |
||
367 |
||
368 |
||
369 |
// ----------------------------------------------------------------------------- |
|
370 |
// CMgService::SetMediaTypeL |
|
371 |
// It will convert the aFiletype string into |
|
372 |
// equivalent Mediatype ID and Fill the Media Type Array |
|
373 |
// if it is not valid then return KErrNotSupported |
|
374 |
// ----------------------------------------------------------------------------- |
|
375 |
void CMgService::SetMediaTypeL (const TDesC8& aFileType, |
|
376 |
RArray<TInt>& aMediaType) |
|
377 |
{ |
|
378 |
||
379 |
if( 0 == aFileType.CompareF( KMgMusic ) ) |
|
380 |
{ |
|
381 |
aMediaType.AppendL( ECLFMediaTypeMusic ); |
|
382 |
} |
|
383 |
else if( 0 == aFileType.CompareF( KMgSound ) ) |
|
384 |
{ |
|
385 |
aMediaType.AppendL( ECLFMediaTypeSound ); |
|
386 |
} |
|
387 |
||
388 |
else if( 0 == aFileType.CompareF( KMgImage ) ) |
|
389 |
{ |
|
390 |
aMediaType.AppendL( ECLFMediaTypeImage ); |
|
391 |
} |
|
392 |
||
393 |
else if( 0 == aFileType.CompareF( KMgVideo ) ) |
|
394 |
{ |
|
395 |
aMediaType.AppendL( ECLFMediaTypeVideo ); |
|
396 |
} |
|
397 |
||
398 |
else if( 0 == aFileType.CompareF( KMgStreamingURL ) ) |
|
399 |
{ |
|
400 |
aMediaType.AppendL( ECLFMediaTypeStreamingURL ); |
|
401 |
} |
|
402 |
else |
|
403 |
{ |
|
404 |
User::Leave ( KErrNotSupported ); // Media Type Not suuported |
|
405 |
} |
|
406 |
||
407 |
} |
|
408 |
||
409 |
||
410 |
||
411 |
||
412 |
||
413 |
// ----------------------------------------------------------------------------- |
|
414 |
// CMgService::SendRequestToCLF |
|
415 |
// This Function will pass the request to CLF frame work for required media type. |
|
416 |
// return KErrArgument if the FilterMetaData is not Supported |
|
417 |
// return KErrArgument if the Start Value is not Supported |
|
418 |
// return KErrArgument if the End Value is mot supported |
|
419 |
// return KErrNone if sucessful |
|
420 |
// ----------------------------------------------------------------------------- |
|
421 |
||
422 |
void CMgService::SendRequestToClfL( const TDesC8& aFileType, |
|
423 |
const TDesC8& aFilterField, |
|
424 |
const TDesC& aStartVal, |
|
425 |
const TDesC& aEndVal, |
|
426 |
const TDesC8& aSortField, |
|
427 |
const TDesC8& aOrder, |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
428 |
MCLFItemListModel* alistModel , |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
429 |
CPostFilter* aFilter, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
430 |
MCLFSortingStyle* aSortingStyle) |
19 | 431 |
{ |
432 |
||
433 |
||
434 |
||
435 |
RArray<TInt> mediaTypes; |
|
436 |
CleanupClosePushL( mediaTypes ); |
|
437 |
||
438 |
//check if it is a valid file type or not |
|
439 |
SetMediaTypeL( aFileType,mediaTypes ); |
|
440 |
||
441 |
||
442 |
//set wanted media type in CLF |
|
443 |
alistModel->SetWantedMediaTypesL( mediaTypes.Array() ); |
|
444 |
||
445 |
||
446 |
// Set Filter Meta Data and Value |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
447 |
SetFilterMetaDataL( aFilterField,aStartVal,aEndVal,mediaTypes,alistModel,aFilter); |
19 | 448 |
|
449 |
||
450 |
||
451 |
// call set sorting field of CLF |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
452 |
SetSortingFieldL( aSortField,aOrder,mediaTypes,alistModel, aSortingStyle); |
19 | 453 |
|
454 |
// set the state = Busy |
|
455 |
// till this request is complete |
|
456 |
//which indicates no further request will be taken |
|
457 |
iState = EMgBusy; |
|
458 |
||
459 |
//asynchronous call to CLF ECLFRefreshAll |
|
460 |
alistModel->RefreshL(); |
|
461 |
||
462 |
||
463 |
CleanupStack::PopAndDestroy( &mediaTypes ); |
|
464 |
||
465 |
||
466 |
} |
|
467 |
||
468 |
||
469 |
||
470 |
// ----------------------------------------------------------------------------- |
|
471 |
// CMgService::GetMetaDataIdAndType |
|
472 |
// It will convert the aFilterData string into equivalent Metadata ID and Type |
|
473 |
// which is recognized by underlying framework.(i.e CLF) |
|
474 |
// ----------------------------------------------------------------------------- |
|
475 |
void CMgService::GetMetaDataIdAndType(const TDesC8& aMetaData, |
|
476 |
TCLFDefaultFieldId& aMetaDataId, |
|
477 |
TCLFItemDataType& aMetaDataType, |
|
478 |
const RArray<TInt> &aMediaTypes) |
|
479 |
{ |
|
480 |
//File name field |
|
481 |
if( 0 == aMetaData.CompareF( KMgFileName )) |
|
482 |
{ |
|
483 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
484 |
aMetaDataId = ECLFFieldIdFileName; |
|
485 |
} |
|
486 |
||
487 |
||
488 |
||
489 |
// File Extension |
|
490 |
else if( 0 == aMetaData.CompareF( KMgFileExtension )) |
|
491 |
{ |
|
492 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
493 |
aMetaDataId = ECLFFieldIdFileExtension; |
|
494 |
} |
|
495 |
||
496 |
||
497 |
// File path field |
|
498 |
else if( 0 == aMetaData.CompareF( KMgPath )) |
|
499 |
{ |
|
500 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
501 |
aMetaDataId = ECLFFieldIdPath; |
|
502 |
} |
|
503 |
||
504 |
||
505 |
// File drive field |
|
506 |
else if( 0 == aMetaData.CompareF( KMgDrive )) |
|
507 |
{ |
|
508 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
509 |
aMetaDataId = ECLFFieldIdDrive; |
|
510 |
} |
|
511 |
||
512 |
||
513 |
// File size field |
|
514 |
else if( 0 == aMetaData.CompareF( KMgFileSize )) |
|
515 |
{ |
|
516 |
aMetaDataType = ECLFItemDataTypeTInt32; |
|
517 |
aMetaDataId = ECLFFieldIdFileSize; |
|
518 |
} |
|
519 |
||
520 |
||
521 |
||
522 |
// File date field |
|
523 |
else if( 0 == aMetaData.CompareF( KMgFileDate )) |
|
524 |
{ |
|
525 |
aMetaDataType = ECLFItemDataTypeTTime; |
|
526 |
aMetaDataId = ECLFFieldIdFileDate; |
|
527 |
} |
|
528 |
||
529 |
||
530 |
||
531 |
// Mime type field |
|
532 |
else if( 0 == aMetaData.CompareF( KMgMimeType )) |
|
533 |
{ |
|
534 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
535 |
aMetaDataId = ECLFFieldIdMimeType; |
|
536 |
} |
|
537 |
||
538 |
||
539 |
// Full name and path of the file |
|
540 |
else if( 0 == aMetaData.CompareF( KMgFileNameAndPath )) |
|
541 |
{ |
|
542 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
543 |
aMetaDataId = ECLFFieldIdFileNameAndPath; |
|
544 |
} |
|
545 |
||
546 |
// Music file song name: and also check If the File type is Music File |
|
547 |
else if( ( 0 == aMetaData.CompareF( KMgSongName ) ) && |
|
548 |
( ( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeMusic ) ) |
|
549 |
|| ( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeVideo ) ) ) ) |
|
550 |
{ |
|
551 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
552 |
aMetaDataId = ECLFFieldIdSongName; |
|
553 |
||
554 |
} |
|
555 |
// Music file artist |
|
556 |
else if( (0 == aMetaData.CompareF( KMgArtist )) && |
|
557 |
( ( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeMusic )) |
|
558 |
||( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeVideo ) ) ) ) |
|
559 |
{ |
|
560 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
561 |
aMetaDataId = ECLFFieldIdArtist; |
|
562 |
} |
|
563 |
||
564 |
||
565 |
// Music file album |
|
566 |
else if((0 == aMetaData.CompareF( KMgAlbum )) && |
|
567 |
( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeMusic ) ) ) |
|
568 |
{ |
|
569 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
570 |
aMetaDataId = ECLFFieldIdAlbum; |
|
571 |
} |
|
572 |
||
573 |
||
574 |
||
575 |
// Music file genre |
|
576 |
else if((0==aMetaData.CompareF( KMgGenre))&& |
|
577 |
( KErrNotFound != aMediaTypes.Find(ECLFMediaTypeMusic) ) ) |
|
578 |
{ |
|
579 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
580 |
aMetaDataId = ECLFFieldIdGenre; |
|
581 |
} |
|
582 |
||
583 |
||
584 |
||
585 |
// Music file track number |
|
586 |
else if((0 == aMetaData.CompareF( KMgTrackNumber ))&& |
|
587 |
( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeMusic ) ) ) |
|
588 |
{ |
|
589 |
aMetaDataType = ECLFItemDataTypeTInt32; |
|
590 |
aMetaDataId = ECLFFieldIdTrackNumber; |
|
591 |
} |
|
592 |
||
593 |
||
594 |
||
595 |
// Music file composer |
|
596 |
else if( (0 == aMetaData.CompareF( KMgComposer )) && |
|
597 |
( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeMusic ) ) ) |
|
598 |
{ |
|
599 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
600 |
aMetaDataId = ECLFFieldIdComposer; |
|
601 |
} |
|
602 |
||
603 |
// Ram link first URL |
|
604 |
else if( (0 == aMetaData.CompareF( KMgLinkFirstURL )) && |
|
605 |
( KErrNotFound != aMediaTypes.Find( ECLFMediaTypeStreamingURL ) ) ) |
|
606 |
{ |
|
607 |
aMetaDataType = ECLFItemDataTypeDesC; |
|
608 |
aMetaDataId = ECLFFieldIdRamLinkFirstURL; |
|
609 |
} |
|
610 |
||
611 |
else |
|
612 |
{ |
|
613 |
aMetaDataType = ECLFItemDataTypeTInt32; |
|
614 |
aMetaDataId = ECLFFieldIdNull; |
|
615 |
} |
|
616 |
||
617 |
||
618 |
} |
|
619 |
||
620 |
void Callback::MgNotifyL(TUint /*aTransactionID*/, |
|
621 |
MCLFItemListModel* aListModel, |
|
622 |
TMgOperationEvent& aOperationEvent, |
|
623 |
const TInt& aError ) |
|
624 |
{ |
|
625 |
CActiveScheduler :: Stop() ; |
|
626 |
return ; |
|
627 |
} |
|
628 |
||
629 |
TInt E32Main() |
|
630 |
{ |
|
631 |
||
632 |
// __UHEAP_MARK; |
|
633 |
||
634 |
CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
635 |
||
636 |
TRAPD(error, Performance_mgmt()); |
|
637 |
__ASSERT_ALWAYS(!error, User::Panic(_L("SAPIcode PANIC"), error)); |
|
638 |
||
639 |
delete cleanup; |
|
640 |
// __UHEAP_MARKEND; |
|
641 |
return 0; |
|
642 |
||
643 |
} //E32main() function ends here |
|
644 |
||
645 |
TInt Performance_mgmt() |
|
646 |
{ |
|
647 |
||
648 |
||
649 |
//Create the object of callback |
|
650 |
TTime start ; // TTime class objects for storing time |
|
651 |
TTime end ; |
|
652 |
TTimeIntervalMicroSeconds aTimeTaken ; |
|
653 |
TInt64 aTimeDelay, aSum = 0.0, aAvgTime = 0.0 ; |
|
654 |
TInt retcode = 0; |
|
655 |
TBool aFlag = EFalse ; |
|
656 |
||
657 |
||
658 |
TBuf8<50> buf ; |
|
659 |
TRealFormat format ; |
|
660 |
||
661 |
OpenFile() ; |
|
662 |
LogFile.Write(_L8("<SAPI GetFile MediaMgmt Async PERFORMANCE DATA>\n ")) ; |
|
663 |
||
664 |
||
665 |
//for (TInt i=0; i<20 ; i++) |
|
666 |
//{ |
|
667 |
aFlag = ETrue ; |
|
668 |
start.HomeTime() ; |
|
669 |
||
670 |
MMgOperationObserver* aCallBack = new (ELeave) Callback(); |
|
671 |
CleanupStack::PushL(aCallBack); |
|
672 |
||
673 |
// Start Scheduler |
|
674 |
CActiveScheduler *Scheduler = new CActiveScheduler() ; |
|
675 |
CActiveScheduler :: Install(Scheduler) ; |
|
676 |
CleanupStack::PushL(Scheduler); |
|
677 |
||
678 |
||
679 |
CMgService* CoreObj = CMgService ::NewL() ; |
|
680 |
CleanupStack::PushL(CoreObj); |
|
681 |
||
682 |
TMgServiceRequest reqArgument; |
|
683 |
reqArgument.iFileType.Set(_L8("Music") ); |
|
684 |
reqArgument.iStartVal.Set(_L("0") ); |
|
685 |
reqArgument.iEndVal.Set(_L("NULL") ); |
|
686 |
reqArgument.iSortField.Set( _L8("Composer") ); |
|
687 |
reqArgument.iOrder.Set( _L8("Descending") ); |
|
688 |
||
689 |
||
690 |
TRAP( retcode , CoreObj->GetListL(reqArgument ,aCallBack) ); |
|
691 |
||
692 |
if(retcode < 0) |
|
693 |
{ |
|
694 |
||
695 |
||
696 |
CleanupStack::PopAndDestroy();//Remove callback |
|
697 |
CleanupStack::PopAndDestroy();//Remove scheduler |
|
698 |
CleanupStack::PopAndDestroy();//Remove core object |
|
699 |
end.HomeTime(); |
|
700 |
} |
|
701 |
||
702 |
else |
|
703 |
{ |
|
704 |
CActiveScheduler :: Start(); |
|
705 |
||
706 |
CleanupStack::PopAndDestroy();//Remove callback |
|
707 |
CleanupStack::PopAndDestroy();//Remove scheduler |
|
708 |
CleanupStack::PopAndDestroy();//Remove core object |
|
709 |
||
710 |
end.HomeTime(); |
|
711 |
} |
|
712 |
||
713 |
aTimeTaken = end.MicroSecondsFrom(start) ; |
|
714 |
aTimeDelay = aTimeTaken.Int64() ; |
|
715 |
aSum = aSum + aTimeDelay ; |
|
716 |
||
717 |
||
718 |
||
719 |
if( aFlag ) |
|
720 |
{ |
|
721 |
buf.Num(aTimeDelay , format) ; |
|
722 |
LogFile.Write(_L8("Time = ")) ; |
|
723 |
LogFile.Write(buf) ; |
|
724 |
LogFile.Write(_L8("\n") ) ; |
|
725 |
} |
|
726 |
else |
|
727 |
{ |
|
728 |
LogFile.Write(_L8("Failed..\n ")) ; |
|
729 |
} |
|
730 |
||
731 |
||
732 |
// } |
|
733 |
||
734 |
/*aAvgTime = aSum/20.0 ; |
|
735 |
buf.Num(aAvgTime , format) ; |
|
736 |
LogFile.Write(_L8("\n\nAverage = ")) ; |
|
737 |
LogFile.Write(buf) ; |
|
738 |
LogFile.Write(_L8("\n\n") ) ;*/ |
|
739 |
||
740 |
CloseFile() ; |
|
741 |
return retcode; |
|
742 |
||
743 |
||
744 |
} |
|
745 |
||
746 |
void OpenFile() |
|
747 |
{ |
|
748 |
LogSession.Connect() ; |
|
749 |
||
750 |
LogFile.Replace(LogSession ,LogFileName , EFileWrite ); |
|
751 |
TInt End = 0 ; |
|
752 |
LogFile.Seek(ESeekEnd , End) ; |
|
753 |
} |
|
754 |
||
755 |
void CloseFile() |
|
756 |
{ |
|
757 |
LogFile.Close() ; |
|
758 |
LogSession.Close() ; |
|
759 |
} |
|
760 |
||
761 |
// End of File |