|
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 interface for |
|
15 * calling the functionality to Media Management SAPI. |
|
16 * Interafce |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include <liwcommon.h> |
|
23 #include <utf.h> |
|
24 |
|
25 #include "mginterface.h" |
|
26 #include "mgservice.h" |
|
27 #include "mgserviceobserver.h" |
|
28 #include "serviceerrno.h" |
|
29 #include"mgservicethumbnailobserver.h" |
|
30 |
|
31 //using namespace LIW; |
|
32 |
|
33 //Supported Operation |
|
34 _LIT8(KGetList,"GetList"); |
|
35 _LIT8(KCmdCancel,"Cancel"); |
|
36 |
|
37 _LIT8(KGetThumbnail,"GetThumbnail"); |
|
38 |
|
39 //Input Keys/arguments |
|
40 |
|
41 // for Url |
|
42 _LIT8(KUrl,"Url"); |
|
43 |
|
44 // thumbnailsize |
|
45 _LIT8(KThumbnailSize,"ThumbnailSize"); |
|
46 |
|
47 // Width |
|
48 _LIT8(KWidth,"width"); |
|
49 //height |
|
50 _LIT8(KHeight,"height"); |
|
51 |
|
52 // Data source name |
|
53 _LIT8(KDsName,"Type"); |
|
54 |
|
55 // Filter Map |
|
56 _LIT8(KFilter,"Filter"); |
|
57 |
|
58 // Sorting Map |
|
59 _LIT8(KSort,"Sort"); |
|
60 |
|
61 //Required file type |
|
62 _LIT8(KFileType,"FileType"); |
|
63 |
|
64 //Filter criteria |
|
65 _LIT8(KKey,"Key"); |
|
66 |
|
67 //Start range of filter |
|
68 _LIT8(KStartRange,"StartRange"); |
|
69 |
|
70 //End range of filter |
|
71 _LIT8(KEndRange,"EndRange"); |
|
72 |
|
73 |
|
74 //Sorting order |
|
75 _LIT8(KOrder,"Order"); |
|
76 |
|
77 |
|
78 //Possible DataSource or supported operation |
|
79 _LIT(KFile,"FileInfo"); |
|
80 _LIT(KFileInfo,"FileInfo"); |
|
81 |
|
82 |
|
83 //Output Keys/arguments |
|
84 _LIT8(KErrorCode,"ErrorCode"); |
|
85 _LIT8(KErrorMessage,"ErrorMessage"); |
|
86 _LIT8(KTransactionID,"TransactionID"); |
|
87 _LIT(KCmdInvalid, "Command Not Supported"); |
|
88 _LIT(KMissing, " is missing"); |
|
89 _LIT(KMissingOrInvalid, " is missing/invalid"); |
|
90 _LIT(KInvalid, " is invalid"); |
|
91 _LIT(KNotSupported, " not supported"); |
|
92 _LIT(KInvalidAsyncParam,"Insufficient arguments for async request"); |
|
93 _LIT(KInvalidCancelParam,"Cancel bit not set in aCmdOptions"); |
|
94 _LIT(KServerBusy, "Server busy"); |
|
95 //_LIT(KTypeMismatch, " Type mismatch"); |
|
96 |
|
97 |
|
98 // Constants for Error Message |
|
99 _LIT(KErrorMsgSeparator, " : "); |
|
100 _LIT(KDomainName, "MediaMgmt"); |
|
101 |
|
102 // Lenght for media file path |
|
103 const TInt KFilePath = 230; |
|
104 const TInt KNegVal = -1; |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CMgInterface::NewLC |
|
107 // Returns the instance of CMgInterface. |
|
108 // ----------------------------------------------------------------------------- |
|
109 CMgInterface* CMgInterface::NewL() |
|
110 { |
|
111 |
|
112 CMgInterface* self = new ( ELeave )CMgInterface(); |
|
113 CleanupStack::PushL( self ); |
|
114 self->ConstructL(); |
|
115 CleanupStack::Pop( self ); |
|
116 return self; |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CMgInterface::~CMgInterface |
|
122 // Destructor of class |
|
123 // ----------------------------------------------------------------------------- |
|
124 CMgInterface::~CMgInterface() |
|
125 { |
|
126 |
|
127 //Release the instance of service observer class |
|
128 delete iServiceObserver; |
|
129 iServiceObserver = NULL; |
|
130 |
|
131 //Release the instance of core class |
|
132 delete iCoreClass; |
|
133 iCoreClass = NULL; |
|
134 |
|
135 } |
|
136 |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMgService::ExecuteCmdL |
|
140 // Request handler method of interface class |
|
141 // ----------------------------------------------------------------------------- |
|
142 |
|
143 void CMgInterface::ExecuteCmdL(const TDesC8& aCmdName, |
|
144 const CLiwGenericParamList& aInParamList, |
|
145 CLiwGenericParamList& aOutParamList, |
|
146 TUint aCmdOptions , |
|
147 MLiwNotifyCallback* aCallBack) |
|
148 { |
|
149 |
|
150 TInt32 transactionID = 0; |
|
151 TInt errCode = 0; |
|
152 TInt pos = 0; |
|
153 TPtrC dsName(KNullDesC); |
|
154 const TLiwGenericParam* param = NULL; |
|
155 TLiwGenericParam posbasedparam; |
|
156 TBool postionbasedsearching = EFalse; |
|
157 |
|
158 TPtrC url(KNullDesC); |
|
159 TPtrC thumbnailsize(KNullDesC); |
|
160 if( 0 == aCmdName.CompareF( KCmdCancel ) ) |
|
161 { |
|
162 if( aCmdOptions & KLiwOptCancel ) // for cancel asynchronous request |
|
163 { |
|
164 |
|
165 param = aInParamList.FindFirst( pos, KTransactionID ); |
|
166 if( ( !param ) && ( aInParamList.Count() > 0) ) |
|
167 { |
|
168 pos = 0; |
|
169 aInParamList.AtL( pos, posbasedparam ); |
|
170 if ( posbasedparam.Name().Compare(KNullDesC8) != 0 || posbasedparam.Value().IsEmpty() ) |
|
171 { |
|
172 param = NULL; |
|
173 } |
|
174 else |
|
175 { |
|
176 param = &posbasedparam; |
|
177 } |
|
178 } |
|
179 if( param ) |
|
180 { |
|
181 |
|
182 if ((*param).Value().Get( transactionID )) |
|
183 |
|
184 { |
|
185 errCode = iCoreClass->CancelL( transactionID ); |
|
186 |
|
187 if ( KErrNone != errCode ) |
|
188 { |
|
189 TInt sapiErr = SapiError(errCode); |
|
190 AppendErrorMessageL( aCmdName, KTransactionID, KInvalid ); |
|
191 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
192 aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
193 } |
|
194 else |
|
195 { |
|
196 |
|
197 TInt sapiErr = SapiError(errCode); |
|
198 |
|
199 aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
200 |
|
201 } |
|
202 } |
|
203 else |
|
204 { |
|
205 AppendErrorMessageL( aCmdName, KTransactionID, KInvalid ); |
|
206 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
207 aOutParamList.AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( TInt32( SErrBadArgumentType ) ) ) ); |
|
208 } |
|
209 |
|
210 } |
|
211 else |
|
212 { |
|
213 AppendErrorMessageL( aCmdName, KTransactionID, KMissing ); |
|
214 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
215 aOutParamList.AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( TInt32( SErrMissingArgument ) ) ) ); |
|
216 } |
|
217 |
|
218 } |
|
219 else |
|
220 { |
|
221 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidCancelParam ); |
|
222 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
223 aOutParamList.AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( TInt32( SErrBadArgumentType ) ) ) ); |
|
224 } |
|
225 return; |
|
226 } |
|
227 |
|
228 // Check the command name;Cmd name should be GetList |
|
229 else if( 0 == aCmdName.CompareF( KGetList ) ) |
|
230 { |
|
231 pos = 0 ; |
|
232 param = aInParamList.FindFirst( pos, KDsName ); |
|
233 if( ( !param ) && ( aInParamList.Count() > 0 ) ) |
|
234 { |
|
235 pos = 0; |
|
236 aInParamList.AtL( pos,posbasedparam ); |
|
237 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
238 { |
|
239 param = NULL; |
|
240 } |
|
241 else |
|
242 { |
|
243 param = &posbasedparam; |
|
244 postionbasedsearching = ETrue; |
|
245 } |
|
246 } |
|
247 if(param) |
|
248 { |
|
249 if ((*param).Value().Get( dsName )) |
|
250 |
|
251 { |
|
252 //dsName.Set((*param).Value().AsDes()); |
|
253 |
|
254 if( ( 0 == dsName.CompareF( KFileInfo ) ) |
|
255 || ( 0 == dsName.CompareF( KFile ) ) ) |
|
256 { |
|
257 // check if core class ready to accept request |
|
258 if( EMgFree == iCoreClass->State() ) |
|
259 { |
|
260 if( aCmdOptions & KLiwOptASyncronous ) //Asynchronous request |
|
261 { |
|
262 if( NULL != aCallBack ) // Asynchronous call |
|
263 { |
|
264 transactionID = aCallBack->GetTransactionID(); |
|
265 if( 0 == dsName.CompareF( KFileInfo ) ) |
|
266 { |
|
267 iServiceObserver->SetMemberVar( EMgGetFilesInfo, |
|
268 NULL,aCallBack ); |
|
269 } |
|
270 else |
|
271 { |
|
272 iServiceObserver->SetMemberVar( EMgGetFiles, |
|
273 NULL,aCallBack ); |
|
274 } |
|
275 |
|
276 //Sending request to core class |
|
277 TRAP (errCode,SendRequestL( aInParamList , transactionID ,postionbasedsearching )); |
|
278 |
|
279 } |
|
280 else //Callback missing |
|
281 { |
|
282 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
283 errCode = KErrNotFound; |
|
284 } |
|
285 |
|
286 } |
|
287 else //synchronous request |
|
288 { |
|
289 //synch request currently not supported |
|
290 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
291 errCode = KErrNotFound; |
|
292 }//synchronous request |
|
293 |
|
294 }//Sapi status |
|
295 else |
|
296 { |
|
297 AppendErrorMessageL( aCmdName, KNullDesC8, KServerBusy ); |
|
298 errCode = KErrServerBusy; |
|
299 } |
|
300 |
|
301 }//Data Source support |
|
302 else |
|
303 { |
|
304 //Incorrect Data source |
|
305 AppendErrorMessageL( aCmdName, KDsName, KNotSupported ); |
|
306 errCode = KErrNotSupported; |
|
307 } |
|
308 |
|
309 |
|
310 }//DataType Mismatch |
|
311 else |
|
312 { |
|
313 AppendErrorMessageL( aCmdName, KDsName, KInvalid ); |
|
314 errCode = KErrArgument; |
|
315 } |
|
316 |
|
317 |
|
318 }//datasource missing |
|
319 else |
|
320 { |
|
321 AppendErrorMessageL( aCmdName, KDsName, KMissing ); |
|
322 errCode = KErrNotFound; |
|
323 } |
|
324 |
|
325 |
|
326 }//GetList |
|
327 else if(0 == aCmdName.CompareF( KGetThumbnail ))// Here we need to put implementation for getThumbnail |
|
328 { |
|
329 //Call |
|
330 if( (aCmdOptions & KLiwOptASyncronous ) && ( NULL != aCallBack ) ) //Asynchronous request |
|
331 { |
|
332 //Asynch Call |
|
333 transactionID = aCallBack->GetTransactionID(); |
|
334 TInt err =0; |
|
335 |
|
336 TRAP(err,GetThumbnailL( aInParamList, aOutParamList, aCallBack , transactionID )); |
|
337 errCode = err; |
|
338 } |
|
339 else |
|
340 { |
|
341 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
342 errCode = KErrNotFound; |
|
343 } |
|
344 |
|
345 |
|
346 }// GetThumbnail |
|
347 else |
|
348 { |
|
349 AppendErrorMessageL( aCmdName, KNullDesC8, KCmdInvalid ); |
|
350 errCode = KErrNotSupported; //command not supported |
|
351 } |
|
352 |
|
353 // check error code if any error occurs then insert into output list |
|
354 posbasedparam.Reset(); |
|
355 TInt sapiErr = SErrNone; |
|
356 if (errCode) |
|
357 { |
|
358 sapiErr = SapiError(errCode); |
|
359 } |
|
360 |
|
361 aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
362 if ( iErrorMessage ) |
|
363 { |
|
364 aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, |
|
365 TLiwVariant(iErrorMessage->Des()))); |
|
366 delete iErrorMessage; |
|
367 iErrorMessage = NULL; |
|
368 } |
|
369 |
|
370 aOutParamList.AppendL( TLiwGenericParam( KTransactionID, TLiwVariant( (TInt32)transactionID ) ) ); |
|
371 |
|
372 } |
|
373 |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CMgInterface::CMgInterface |
|
377 // Constructor of class |
|
378 // ----------------------------------------------------------------------------- |
|
379 |
|
380 CMgInterface::CMgInterface() |
|
381 :iCoreClass( NULL ), |
|
382 iServiceObserver( NULL ) |
|
383 { |
|
384 |
|
385 } |
|
386 |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CMgInterface::ConstructL |
|
390 // Two-phased constructor of class |
|
391 // ----------------------------------------------------------------------------- |
|
392 |
|
393 void CMgInterface::ConstructL() |
|
394 { |
|
395 // Create the instance of core class |
|
396 iCoreClass = CMgService::NewL(); |
|
397 |
|
398 //Create the instance of service observer class |
|
399 iServiceObserver = CMgServiceObserver::NewL(); |
|
400 |
|
401 } |
|
402 |
|
403 |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // CMgInterface::SendRequestL |
|
407 // This function will send the request to Core class |
|
408 // ----------------------------------------------------------------------------- |
|
409 |
|
410 void CMgInterface::SendRequestL(const CLiwGenericParamList& aInParamList , TUint aTransactionID , TBool aPostionBasedSearching ) |
|
411 |
|
412 { |
|
413 TInt pos=0; |
|
414 const CLiwMap* filter = NULL; |
|
415 const CLiwMap* sorting = NULL; |
|
416 TMgServiceRequest requestParam; |
|
417 const TLiwGenericParam* param; |
|
418 TLiwVariant fileType; |
|
419 TLiwVariant filterField; |
|
420 TLiwVariant startVal; |
|
421 TLiwVariant endVal; |
|
422 TLiwVariant sortingField; |
|
423 TLiwVariant order; |
|
424 TLiwGenericParam posbasedparam; |
|
425 |
|
426 //setting the TransactionID |
|
427 requestParam.iTransactionID = aTransactionID; |
|
428 |
|
429 //Get the Filter Map |
|
430 if ( aPostionBasedSearching && ( aInParamList.Count() > 1) ) |
|
431 { |
|
432 pos = 1; |
|
433 aInParamList.AtL( pos,posbasedparam ); |
|
434 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
435 { |
|
436 param = NULL; |
|
437 } |
|
438 else |
|
439 { |
|
440 param = &posbasedparam; |
|
441 } |
|
442 } |
|
443 else |
|
444 { |
|
445 pos=0;//Search from starting point |
|
446 //filter map |
|
447 param = aInParamList.FindFirst( pos, KFilter ); |
|
448 } |
|
449 |
|
450 |
|
451 HBufC8* heapBuffer3 = NULL; |
|
452 HBufC8* heapBuffer4 = NULL; |
|
453 |
|
454 |
|
455 if(param) |
|
456 { |
|
457 filter = (*param).Value().AsMap(); |
|
458 if(!filter) |
|
459 { |
|
460 //Filter Map missing : |
|
461 posbasedparam.Reset(); |
|
462 AppendErrorMessageL( KGetList, KFilter, KInvalid ); |
|
463 User ::Leave(KErrArgument); |
|
464 } |
|
465 |
|
466 } |
|
467 |
|
468 |
|
469 if( (param) && (filter) ) |
|
470 {//filter map |
|
471 |
|
472 TPtrC type16; |
|
473 |
|
474 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &fileType) ); |
|
475 if( (filter->FindL( KFileType, fileType )) ) |
|
476 { |
|
477 if ( (fileType.Get( type16 )) && (type16.Length() > 0 ) ) |
|
478 { |
|
479 heapBuffer3 = HBufC8::NewL( type16.Length() ); |
|
480 CleanupStack::PushL( heapBuffer3 ); |
|
481 TPtr8 type8( heapBuffer3->Des() ); |
|
482 type8.Copy( type16 ); |
|
483 requestParam.iFileType.Set(type8); |
|
484 } |
|
485 else |
|
486 { |
|
487 //fileType.Reset(); |
|
488 posbasedparam.Reset(); |
|
489 AppendErrorMessageL( KGetList, KFileType, KMissingOrInvalid ); |
|
490 User ::Leave(KErrArgument); |
|
491 } |
|
492 } |
|
493 else |
|
494 { |
|
495 //fileType.Reset(); |
|
496 posbasedparam.Reset(); |
|
497 AppendErrorMessageL( KGetList, KFileType, KMissing ); |
|
498 User ::Leave(KErrNotFound); |
|
499 } |
|
500 |
|
501 |
|
502 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &filterField) ); |
|
503 if( filter->FindL( KKey, filterField ) ) |
|
504 { |
|
505 TPtrC filter16; |
|
506 |
|
507 if ( filterField.Get( filter16 )) |
|
508 { |
|
509 heapBuffer4 = HBufC8::NewL( filter16.Length() ); |
|
510 CleanupStack::PushL( heapBuffer4 ); |
|
511 TPtr8 filter8( heapBuffer4->Des() ); |
|
512 filter8.Copy( filter16 ); |
|
513 requestParam.iFilterField.Set(filter8); |
|
514 } |
|
515 else |
|
516 { |
|
517 //fileType.Reset(); |
|
518 //filterField.Reset(); |
|
519 posbasedparam.Reset(); |
|
520 AppendErrorMessageL( KGetList, KKey, KInvalid ); |
|
521 User ::Leave(KErrArgument); |
|
522 } |
|
523 } |
|
524 |
|
525 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &startVal) ); |
|
526 if(filter->FindL( KStartRange, startVal )) |
|
527 { |
|
528 if ( !startVal.Get( requestParam.iStartVal )) |
|
529 { |
|
530 //fileType.Reset(); |
|
531 //filterField.Reset(); |
|
532 //startVal.Reset(); |
|
533 posbasedparam.Reset(); |
|
534 AppendErrorMessageL( KGetList, KStartRange, KInvalid ); |
|
535 User ::Leave(KErrArgument); |
|
536 } |
|
537 } |
|
538 |
|
539 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &endVal) ); |
|
540 if (filter->FindL( KEndRange, endVal )) |
|
541 { |
|
542 if ( !endVal.Get( requestParam.iEndVal )) |
|
543 { |
|
544 //fileType.Reset(); |
|
545 //filterField.Reset(); |
|
546 //startVal.Reset(); |
|
547 //endVal.Reset(); |
|
548 posbasedparam.Reset(); |
|
549 AppendErrorMessageL( KGetList, KEndRange, KInvalid ); |
|
550 User ::Leave(KErrArgument); |
|
551 } |
|
552 } |
|
553 |
|
554 }//filter map |
|
555 |
|
556 else |
|
557 { |
|
558 //Filter Map missing : |
|
559 posbasedparam.Reset(); |
|
560 AppendErrorMessageL( KGetList, KFilter, KMissing ); |
|
561 User ::Leave(KErrNotFound); |
|
562 } |
|
563 |
|
564 if ( aPostionBasedSearching && ( aInParamList.Count() > 2) ) |
|
565 { |
|
566 pos = 2; |
|
567 aInParamList.AtL( pos,posbasedparam ); |
|
568 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
569 { |
|
570 param = NULL; |
|
571 } |
|
572 else |
|
573 { |
|
574 param = &posbasedparam; |
|
575 } |
|
576 } |
|
577 else |
|
578 { |
|
579 pos=0;//Search from starting point |
|
580 //Sorting map |
|
581 param = aInParamList.FindFirst( pos, KSort ); |
|
582 } |
|
583 |
|
584 HBufC8* heapBuffer1 = NULL; |
|
585 HBufC8* heapBuffer2 = NULL; |
|
586 |
|
587 if(param) |
|
588 { |
|
589 sorting = (*param).Value().AsMap(); |
|
590 if(!sorting) |
|
591 { |
|
592 //Filter Map missing : |
|
593 posbasedparam.Reset(); |
|
594 AppendErrorMessageL( KGetList, KSort, KInvalid ); |
|
595 User ::Leave(KErrArgument); |
|
596 } |
|
597 } |
|
598 |
|
599 if( (param) && sorting ) |
|
600 {//sort map |
|
601 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &sortingField) ); |
|
602 if (sorting->FindL( KKey, sortingField )) |
|
603 { |
|
604 TPtrC sort16; |
|
605 if ( sortingField.Get( sort16)) |
|
606 { |
|
607 heapBuffer1 = HBufC8::NewL( sort16.Length() ); |
|
608 CleanupStack::PushL( heapBuffer1 ); |
|
609 TPtr8 sort8( heapBuffer1->Des() ); |
|
610 sort8.Copy( sort16 ); |
|
611 requestParam.iSortField.Set(sort8); |
|
612 } |
|
613 else |
|
614 { |
|
615 //fileType.Reset(); |
|
616 //filterField.Reset(); |
|
617 //startVal.Reset(); |
|
618 //endVal.Reset(); |
|
619 //sortingField.Reset(); |
|
620 posbasedparam.Reset(); |
|
621 AppendErrorMessageL( KGetList, KKey, KInvalid ); |
|
622 User ::Leave(KErrArgument); |
|
623 } |
|
624 } |
|
625 |
|
626 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &order) ); |
|
627 if (sorting->FindL( KOrder, order )) |
|
628 { |
|
629 TPtrC sortOrder16; |
|
630 if ( order.Get( sortOrder16)) |
|
631 { |
|
632 heapBuffer2 = HBufC8::NewL( sortOrder16.Length() ); |
|
633 CleanupStack::PushL( heapBuffer2 ); |
|
634 TPtr8 sortOrder8( heapBuffer2->Des() ); |
|
635 sortOrder8.Copy( sortOrder16 ); |
|
636 order.Get( requestParam.iOrder ); |
|
637 requestParam.iOrder.Set(sortOrder8); |
|
638 } |
|
639 else |
|
640 { |
|
641 //fileType.Reset(); |
|
642 //filterField.Reset(); |
|
643 //startVal.Reset(); |
|
644 //endVal.Reset(); |
|
645 //sortingField.Reset(); |
|
646 //order.Reset(); |
|
647 posbasedparam.Reset(); |
|
648 AppendErrorMessageL( KGetList, KOrder, KInvalid ); |
|
649 User ::Leave(KErrArgument); |
|
650 } |
|
651 } |
|
652 |
|
653 }//sort map |
|
654 |
|
655 |
|
656 iCoreClass->GetListL( requestParam,iServiceObserver ) ; |
|
657 |
|
658 |
|
659 |
|
660 //Sorting is an optional parameter, if it is present only then sorting fields and order present in stack |
|
661 if( (param) && sorting ) |
|
662 { |
|
663 |
|
664 if( heapBuffer2 ) |
|
665 CleanupStack::PopAndDestroy( heapBuffer2 ); |
|
666 |
|
667 CleanupStack::Pop(&order); |
|
668 |
|
669 if( heapBuffer1 ) |
|
670 CleanupStack::PopAndDestroy( heapBuffer1 ); |
|
671 |
|
672 CleanupStack::Pop(&sortingField); |
|
673 |
|
674 } |
|
675 |
|
676 CleanupStack::Pop(&endVal); |
|
677 CleanupStack::Pop(&startVal); |
|
678 |
|
679 if( heapBuffer4 ) |
|
680 CleanupStack::PopAndDestroy( heapBuffer4 ); |
|
681 |
|
682 CleanupStack::Pop(&filterField); |
|
683 |
|
684 if( heapBuffer3 ) |
|
685 CleanupStack::PopAndDestroy( heapBuffer3 ); |
|
686 |
|
687 CleanupStack::Pop(&fileType); |
|
688 |
|
689 fileType.Reset(); |
|
690 filterField.Reset(); |
|
691 startVal.Reset(); |
|
692 endVal.Reset(); |
|
693 sortingField.Reset(); |
|
694 order.Reset(); |
|
695 posbasedparam.Reset(); |
|
696 |
|
697 } |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CMgInterface::SendRequestL |
|
701 // This function is called by the user to get mapped SAPI generic error code |
|
702 // from symbian error codes . |
|
703 // ----------------------------------------------------------------------------- |
|
704 |
|
705 TInt CMgInterface::SapiError( TInt aSymbianErr ) |
|
706 { |
|
707 TInt sapiErr(SErrGeneralError); |
|
708 |
|
709 switch (aSymbianErr) |
|
710 { |
|
711 case KErrArgument: |
|
712 { |
|
713 sapiErr = SErrBadArgumentType; |
|
714 break; |
|
715 } |
|
716 case KErrNotFound: |
|
717 { |
|
718 sapiErr = SErrMissingArgument; |
|
719 break; |
|
720 } |
|
721 |
|
722 case KErrNotSupported: |
|
723 { |
|
724 sapiErr = SErrServiceNotSupported; |
|
725 break; |
|
726 } |
|
727 case KErrServerBusy: |
|
728 { |
|
729 sapiErr = SErrServerBusy; |
|
730 break; |
|
731 } |
|
732 case KErrGeneral: |
|
733 { |
|
734 sapiErr = SErrGeneralError; |
|
735 break; |
|
736 } |
|
737 case KErrCancel: |
|
738 { |
|
739 sapiErr = SErrCancelSuccess; |
|
740 break; |
|
741 } |
|
742 case KErrNone: |
|
743 { |
|
744 sapiErr= SErrNone; |
|
745 break; |
|
746 } |
|
747 |
|
748 case KErrNoMemory: |
|
749 { |
|
750 sapiErr = SErrNoMemory; |
|
751 break; |
|
752 } |
|
753 case KErrInUse: |
|
754 { |
|
755 sapiErr = SErrServiceInUse; |
|
756 break; |
|
757 } |
|
758 case KErrNotReady: |
|
759 { |
|
760 sapiErr = SErrServiceNotReady; |
|
761 break; |
|
762 } |
|
763 case KErrBadName: |
|
764 { |
|
765 sapiErr = SErrUnknownFormat; |
|
766 break; |
|
767 } |
|
768 case KErrAlreadyExists: |
|
769 { |
|
770 sapiErr = SErrEntryExists; |
|
771 break; |
|
772 } |
|
773 } |
|
774 return sapiErr; |
|
775 } |
|
776 |
|
777 // --------------------------------------------------------------------------- |
|
778 // Append Error Message |
|
779 // --------------------------------------------------------------------------- |
|
780 // |
|
781 void CMgInterface::AppendErrorMessageL( const TDesC8& aCmdName, const TDesC8& aParameter, const TDesC& aMessage ) |
|
782 { |
|
783 iErrorMessage = HBufC::NewL( KMaxErrorMessageLength ); |
|
784 TPtr tmpMsgPtr = iErrorMessage->Des(); |
|
785 tmpMsgPtr.Copy(KDomainName); |
|
786 |
|
787 HBufC* temp = HBufC::New( KMaxErrorMessageLength ); |
|
788 |
|
789 if ( aCmdName.Length() ) |
|
790 { |
|
791 tmpMsgPtr.Append( KErrorMsgSeparator ); |
|
792 temp->Des().Copy( aCmdName ); |
|
793 tmpMsgPtr.Append( temp->Des() ); |
|
794 } |
|
795 |
|
796 tmpMsgPtr.Append(KErrorMsgSeparator); |
|
797 |
|
798 if ( aParameter.Length() ) |
|
799 { |
|
800 temp->Des().Copy(aParameter); |
|
801 tmpMsgPtr.Append(temp->Des()); |
|
802 } |
|
803 |
|
804 if ( aMessage.Length() ) |
|
805 { |
|
806 tmpMsgPtr.Append( aMessage ); |
|
807 } |
|
808 |
|
809 delete temp; |
|
810 } |
|
811 // ----------------------------------------------------------------------------- |
|
812 // CMgInterface::GetThumbnailL |
|
813 // This method will send request to core class fot getthumbnail |
|
814 // ----------------------------------------------------------------------------- |
|
815 |
|
816 void CMgInterface::GetThumbnailL( const CLiwGenericParamList& aInParamList, |
|
817 CLiwGenericParamList& aOutParamList, |
|
818 MLiwNotifyCallback* aCallBack , |
|
819 TInt32 aTransactionID ) |
|
820 { |
|
821 |
|
822 TLiwGenericParam posbasedparam; |
|
823 TBool postionbasedsearching = EFalse; |
|
824 const TLiwGenericParam* param = NULL; |
|
825 TInt pos = 0; |
|
826 const CLiwMap* thumbnailSizemap = NULL; |
|
827 TLiwVariant width; |
|
828 TLiwVariant height; |
|
829 TInt widthThumb = KNegVal; |
|
830 TInt heightThumb = KNegVal; |
|
831 TBuf<KFilePath> mediaUrl; |
|
832 // Finding url by name |
|
833 param = aInParamList.FindFirst( pos, KUrl ); |
|
834 |
|
835 if( !param ) |
|
836 { |
|
837 // finding url by position based |
|
838 if( aInParamList.Count() > 0 ) |
|
839 { |
|
840 pos = 0; |
|
841 aInParamList.AtL( pos,posbasedparam ); |
|
842 |
|
843 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
844 { |
|
845 param = NULL; |
|
846 } |
|
847 else |
|
848 { |
|
849 param = &posbasedparam; |
|
850 postionbasedsearching = ETrue; |
|
851 } |
|
852 } |
|
853 } |
|
854 // checking the type of url it should be string |
|
855 // if ((param) && (param->Value().TypeId() != LIW::EVariantTypeNull) && (param->Value().TypeId() != LIW::EVariantTypeDesC) ) |
|
856 if ((param) && (param->Value().TypeId() != LIW::EVariantTypeDesC ) ) |
|
857 { |
|
858 |
|
859 posbasedparam.Reset(); |
|
860 AppendErrorMessageL( KGetThumbnail, KUrl, KInvalid ); |
|
861 User::Leave(KErrArgument); |
|
862 |
|
863 } |
|
864 // present : Mandatory Argument |
|
865 |
|
866 if( ( (param) && ( param->Value().AsDes().Length() < KFilePath ) && (param->Value().Get( mediaUrl ) ) ) ) |
|
867 { |
|
868 // Got the url |
|
869 |
|
870 // Now checking for optional argument Thumbnailsize |
|
871 param = NULL; |
|
872 |
|
873 |
|
874 if ( postionbasedsearching && ( aInParamList.Count() > 1) ) |
|
875 { |
|
876 pos = 2; |
|
877 aInParamList.AtL( pos,posbasedparam ); |
|
878 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
879 { |
|
880 param = NULL; |
|
881 } |
|
882 else |
|
883 { |
|
884 param = &posbasedparam; |
|
885 } |
|
886 } |
|
887 else |
|
888 { |
|
889 pos=0;//Search from starting point |
|
890 //ThumbnailSize map |
|
891 param = aInParamList.FindFirst( pos, KThumbnailSize ); |
|
892 } |
|
893 |
|
894 // ThumbnailSize map is present |
|
895 if ( param ) |
|
896 { |
|
897 if( (param->Value().TypeId() != LIW::EVariantTypeMap ) ) |
|
898 { |
|
899 //ThumbnailSize Type MisMatch |
|
900 |
|
901 |
|
902 posbasedparam.Reset(); |
|
903 AppendErrorMessageL( KGetThumbnail, KThumbnailSize, KInvalid ); |
|
904 User::Leave(KErrArgument); |
|
905 |
|
906 |
|
907 } |
|
908 |
|
909 thumbnailSizemap = param->Value().AsMap(); |
|
910 |
|
911 if(thumbnailSizemap) |
|
912 |
|
913 { |
|
914 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &width) ); |
|
915 |
|
916 if(thumbnailSizemap->FindL( KWidth, width )) |
|
917 { |
|
918 if ( width.TypeId() != LIW::EVariantTypeTInt32 ) |
|
919 { |
|
920 |
|
921 CleanupStack::Pop(&width); |
|
922 width.Reset() ; |
|
923 posbasedparam.Reset(); |
|
924 AppendErrorMessageL( KGetThumbnail, KWidth, KInvalid ); |
|
925 User::Leave(KErrArgument); |
|
926 |
|
927 } |
|
928 |
|
929 |
|
930 widthThumb = width.AsTInt32(); |
|
931 if(widthThumb <= 0 ) // If width is negative and zero then throw error |
|
932 { |
|
933 CleanupStack::Pop(&width); |
|
934 width.Reset() ; |
|
935 posbasedparam.Reset(); |
|
936 AppendErrorMessageL( KGetThumbnail, KWidth, KInvalid ); |
|
937 User::Leave(KErrArgument); |
|
938 } |
|
939 |
|
940 |
|
941 |
|
942 CleanupStack::Pop(&width); |
|
943 width.Reset(); |
|
944 |
|
945 } // End if thumbnail width is there |
|
946 else |
|
947 { |
|
948 CleanupStack::Pop(&width); |
|
949 width.Reset(); |
|
950 |
|
951 } |
|
952 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &height) ); |
|
953 if(thumbnailSizemap->FindL( KHeight, height )) |
|
954 { |
|
955 if ( height.TypeId() != LIW::EVariantTypeTInt32 ) |
|
956 { |
|
957 |
|
958 CleanupStack::Pop(&height); |
|
959 height.Reset() ; |
|
960 |
|
961 posbasedparam.Reset(); |
|
962 AppendErrorMessageL( KGetThumbnail, KHeight, KInvalid ); |
|
963 User::Leave(KErrArgument); |
|
964 |
|
965 } |
|
966 |
|
967 |
|
968 heightThumb = height.AsTInt32(); |
|
969 if(heightThumb <= 0 ) // If height is negative or zero then throw error |
|
970 { |
|
971 CleanupStack::Pop(&height); |
|
972 height.Reset() ; |
|
973 posbasedparam.Reset(); |
|
974 AppendErrorMessageL( KGetThumbnail, KHeight, KInvalid ); |
|
975 User::Leave(KErrArgument); |
|
976 } |
|
977 |
|
978 |
|
979 |
|
980 CleanupStack::Pop(&height); |
|
981 height.Reset(); |
|
982 |
|
983 } // End If Height is there in thumbnail size map |
|
984 else |
|
985 { |
|
986 CleanupStack::Pop(&height); |
|
987 height.Reset(); |
|
988 } |
|
989 } // End of thumbnailsize map |
|
990 |
|
991 }// For optional argument thumbanil size |
|
992 |
|
993 // now calling GetThumbnailL method of core class |
|
994 |
|
995 |
|
996 if( aCallBack ) |
|
997 { |
|
998 //Asynch Call |
|
999 CServiceThumbnailObserver* observer = CServiceThumbnailObserver::NewL( aCallBack ); |
|
1000 CleanupStack::PushL( observer ); |
|
1001 |
|
1002 iCoreClass->GetThumbnailL( observer, mediaUrl, aTransactionID,heightThumb , widthThumb); |
|
1003 |
|
1004 CleanupStack::Pop( observer ); |
|
1005 } |
|
1006 |
|
1007 height.Reset(); |
|
1008 width.Reset(); |
|
1009 |
|
1010 |
|
1011 }// End of mandatory argument url |
|
1012 else |
|
1013 { |
|
1014 posbasedparam.Reset(); |
|
1015 AppendErrorMessageL( KGetThumbnail, KUrl, KMissing ); |
|
1016 User::Leave(KErrNotFound); |
|
1017 } |
|
1018 posbasedparam.Reset(); |
|
1019 |
|
1020 } |