|
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 |
|
30 //using namespace LIW; |
|
31 |
|
32 //Supported Operation |
|
33 _LIT8(KGetList,"GetList"); |
|
34 _LIT8(KCmdCancel,"Cancel"); |
|
35 |
|
36 //Input Keys/arguments |
|
37 |
|
38 // Data source name |
|
39 _LIT8(KDsName,"Type"); |
|
40 |
|
41 // Filter Map |
|
42 _LIT8(KFilter,"Filter"); |
|
43 |
|
44 // Sorting Map |
|
45 _LIT8(KSort,"Sort"); |
|
46 |
|
47 //Required file type |
|
48 _LIT8(KFileType,"FileType"); |
|
49 |
|
50 //Filter criteria |
|
51 _LIT8(KKey,"Key"); |
|
52 |
|
53 //Start range of filter |
|
54 _LIT8(KStartRange,"StartRange"); |
|
55 |
|
56 //End range of filter |
|
57 _LIT8(KEndRange,"EndRange"); |
|
58 |
|
59 |
|
60 //Sorting order |
|
61 _LIT8(KOrder,"Order"); |
|
62 |
|
63 |
|
64 //Possible DataSource or supported operation |
|
65 _LIT(KFile,"FileInfo"); |
|
66 _LIT(KFileInfo,"FileInfo"); |
|
67 |
|
68 |
|
69 //Output Keys/arguments |
|
70 _LIT8(KErrorCode,"ErrorCode"); |
|
71 _LIT8(KErrorMessage,"ErrorMessage"); |
|
72 _LIT8(KTransactionID,"TransactionID"); |
|
73 _LIT(KCmdInvalid, "Command Not Supported"); |
|
74 _LIT(KMissing, " is missing"); |
|
75 _LIT(KMissingOrInvalid, " is missing/invalid"); |
|
76 _LIT(KInvalid, " is invalid"); |
|
77 _LIT(KNotSupported, " not supported"); |
|
78 _LIT(KInvalidAsyncParam,"Insufficient arguments for async request"); |
|
79 _LIT(KInvalidCancelParam,"Cancel bit not set in aCmdOptions"); |
|
80 _LIT(KServerBusy, "Server busy"); |
|
81 //_LIT(KTypeMismatch, " Type mismatch"); |
|
82 |
|
83 |
|
84 // Constants for Error Message |
|
85 _LIT(KErrorMsgSeparator, " : "); |
|
86 _LIT(KDomainName, "MediaMgmt"); |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CMgInterface::NewLC |
|
91 // Returns the instance of CMgInterface. |
|
92 // ----------------------------------------------------------------------------- |
|
93 CMgInterface* CMgInterface::NewL() |
|
94 { |
|
95 |
|
96 CMgInterface* self = new ( ELeave )CMgInterface(); |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL(); |
|
99 CleanupStack::Pop( self ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CMgInterface::~CMgInterface |
|
106 // Destructor of class |
|
107 // ----------------------------------------------------------------------------- |
|
108 CMgInterface::~CMgInterface() |
|
109 { |
|
110 |
|
111 //Release the instance of service observer class |
|
112 delete iServiceObserver; |
|
113 iServiceObserver = NULL; |
|
114 |
|
115 //Release the instance of core class |
|
116 delete iCoreClass; |
|
117 iCoreClass = NULL; |
|
118 |
|
119 } |
|
120 |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CMgService::ExecuteCmdL |
|
124 // Request handler method of interface class |
|
125 // ----------------------------------------------------------------------------- |
|
126 |
|
127 void CMgInterface::ExecuteCmdL(const TDesC8& aCmdName, |
|
128 const CLiwGenericParamList& aInParamList, |
|
129 CLiwGenericParamList& aOutParamList, |
|
130 TUint aCmdOptions , |
|
131 MLiwNotifyCallback* aCallBack) |
|
132 { |
|
133 |
|
134 TInt32 transactionID = 0; |
|
135 TInt errCode = 0; |
|
136 TInt pos = 0; |
|
137 TPtrC dsName(KNullDesC); |
|
138 const TLiwGenericParam* param = NULL; |
|
139 TLiwGenericParam posbasedparam; |
|
140 TBool postionbasedsearching = EFalse; |
|
141 |
|
142 if( 0 == aCmdName.CompareF( KCmdCancel ) ) |
|
143 { |
|
144 if( aCmdOptions & KLiwOptCancel ) // for cancel asynchronous request |
|
145 { |
|
146 |
|
147 param = aInParamList.FindFirst( pos, KTransactionID ); |
|
148 if( ( !param ) && ( aInParamList.Count() > 0) ) |
|
149 { |
|
150 pos = 0; |
|
151 aInParamList.AtL( pos, posbasedparam ); |
|
152 if ( posbasedparam.Name().Compare(KNullDesC8) != 0 || posbasedparam.Value().IsEmpty() ) |
|
153 { |
|
154 param = NULL; |
|
155 } |
|
156 else |
|
157 { |
|
158 param = &posbasedparam; |
|
159 } |
|
160 } |
|
161 if( param ) |
|
162 { |
|
163 |
|
164 if ((*param).Value().Get( transactionID )) |
|
165 |
|
166 { |
|
167 errCode = iCoreClass->CancelL( transactionID ); |
|
168 |
|
169 if ( KErrNone != errCode ) |
|
170 { |
|
171 TInt sapiErr = SapiError(errCode); |
|
172 AppendErrorMessageL( aCmdName, KTransactionID, KInvalid ); |
|
173 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
174 aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
175 } |
|
176 } |
|
177 else |
|
178 { |
|
179 AppendErrorMessageL( aCmdName, KTransactionID, KInvalid ); |
|
180 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
181 aOutParamList.AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( TInt32( SErrBadArgumentType ) ) ) ); |
|
182 } |
|
183 |
|
184 } |
|
185 else |
|
186 { |
|
187 AppendErrorMessageL( aCmdName, KTransactionID, KMissing ); |
|
188 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
189 aOutParamList.AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( TInt32( SErrMissingArgument ) ) ) ); |
|
190 } |
|
191 |
|
192 } |
|
193 else |
|
194 { |
|
195 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidCancelParam ); |
|
196 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant( iErrorMessage ) ) ); |
|
197 aOutParamList.AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( TInt32( SErrBadArgumentType ) ) ) ); |
|
198 } |
|
199 return; |
|
200 } |
|
201 |
|
202 // Check the command name;Cmd name should be GetList |
|
203 else if( 0 == aCmdName.CompareF( KGetList ) ) |
|
204 { |
|
205 pos = 0 ; |
|
206 param = aInParamList.FindFirst( pos, KDsName ); |
|
207 if( ( !param ) && ( aInParamList.Count() > 0 ) ) |
|
208 { |
|
209 pos = 0; |
|
210 aInParamList.AtL( pos,posbasedparam ); |
|
211 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
212 { |
|
213 param = NULL; |
|
214 } |
|
215 else |
|
216 { |
|
217 param = &posbasedparam; |
|
218 postionbasedsearching = ETrue; |
|
219 } |
|
220 } |
|
221 if(param) |
|
222 { |
|
223 if ((*param).Value().Get( dsName )) |
|
224 |
|
225 { |
|
226 //dsName.Set((*param).Value().AsDes()); |
|
227 |
|
228 if( ( 0 == dsName.CompareF( KFileInfo ) ) |
|
229 || ( 0 == dsName.CompareF( KFile ) ) ) |
|
230 { |
|
231 // check if core class ready to accept request |
|
232 if( EMgFree == iCoreClass->State() ) |
|
233 { |
|
234 if( aCmdOptions & KLiwOptASyncronous ) //Asynchronous request |
|
235 { |
|
236 if( NULL != aCallBack ) // Asynchronous call |
|
237 { |
|
238 transactionID = aCallBack->GetTransactionID(); |
|
239 if( 0 == dsName.CompareF( KFileInfo ) ) |
|
240 { |
|
241 iServiceObserver->SetMemberVar( EMgGetFilesInfo, |
|
242 NULL,aCallBack ); |
|
243 } |
|
244 else |
|
245 { |
|
246 iServiceObserver->SetMemberVar( EMgGetFiles, |
|
247 NULL,aCallBack ); |
|
248 } |
|
249 |
|
250 //Sending request to core class |
|
251 TRAP (errCode,SendRequestL( aInParamList , transactionID ,postionbasedsearching )); |
|
252 |
|
253 } |
|
254 else //Callback missing |
|
255 { |
|
256 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
257 errCode = KErrNotFound; |
|
258 } |
|
259 |
|
260 } |
|
261 else //synchronous request |
|
262 { |
|
263 //synch request currently not supported |
|
264 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
265 errCode = KErrNotFound; |
|
266 }//synchronous request |
|
267 |
|
268 }//Sapi status |
|
269 else |
|
270 { |
|
271 AppendErrorMessageL( aCmdName, KNullDesC8, KServerBusy ); |
|
272 errCode = KErrServerBusy; |
|
273 } |
|
274 |
|
275 }//Data Source support |
|
276 else |
|
277 { |
|
278 //Incorrect Data source |
|
279 AppendErrorMessageL( aCmdName, KDsName, KNotSupported ); |
|
280 errCode = KErrNotSupported; |
|
281 } |
|
282 |
|
283 |
|
284 }//DataType Mismatch |
|
285 else |
|
286 { |
|
287 AppendErrorMessageL( aCmdName, KDsName, KInvalid ); |
|
288 errCode = KErrArgument; |
|
289 } |
|
290 |
|
291 |
|
292 }//datasource missing |
|
293 else |
|
294 { |
|
295 AppendErrorMessageL( aCmdName, KDsName, KMissing ); |
|
296 errCode = KErrNotFound; |
|
297 } |
|
298 |
|
299 |
|
300 }//GetList |
|
301 else |
|
302 { |
|
303 AppendErrorMessageL( aCmdName, KNullDesC8, KCmdInvalid ); |
|
304 errCode = KErrNotSupported; //command not supported |
|
305 } |
|
306 |
|
307 // check error code if any error occurs then insert into output list |
|
308 posbasedparam.Reset(); |
|
309 TInt sapiErr = SErrNone; |
|
310 if (errCode) |
|
311 { |
|
312 sapiErr = SapiError(errCode); |
|
313 } |
|
314 |
|
315 aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
316 if ( iErrorMessage ) |
|
317 { |
|
318 aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, |
|
319 TLiwVariant(iErrorMessage->Des()))); |
|
320 delete iErrorMessage; |
|
321 iErrorMessage = NULL; |
|
322 } |
|
323 |
|
324 aOutParamList.AppendL( TLiwGenericParam( KTransactionID, TLiwVariant( (TInt32)transactionID ) ) ); |
|
325 |
|
326 } |
|
327 |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CMgInterface::CMgInterface |
|
331 // Constructor of class |
|
332 // ----------------------------------------------------------------------------- |
|
333 |
|
334 CMgInterface::CMgInterface() |
|
335 :iCoreClass( NULL ), |
|
336 iServiceObserver( NULL ) |
|
337 { |
|
338 ; |
|
339 } |
|
340 |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CMgInterface::ConstructL |
|
344 // Two-phased constructor of class |
|
345 // ----------------------------------------------------------------------------- |
|
346 |
|
347 void CMgInterface::ConstructL() |
|
348 { |
|
349 // Create the instance of core class |
|
350 iCoreClass = CMgService::NewL(); |
|
351 |
|
352 //Create the instance of service observer class |
|
353 iServiceObserver = CMgServiceObserver::NewL(); |
|
354 |
|
355 } |
|
356 |
|
357 |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CMgInterface::SendRequestL |
|
361 // This function will send the request to Core class |
|
362 // ----------------------------------------------------------------------------- |
|
363 |
|
364 void CMgInterface::SendRequestL(const CLiwGenericParamList& aInParamList , TUint aTransactionID , TBool aPostionBasedSearching ) |
|
365 |
|
366 { |
|
367 TInt pos=0; |
|
368 const CLiwMap* filter; |
|
369 const CLiwMap* sorting; |
|
370 TMgServiceRequest requestParam; |
|
371 const TLiwGenericParam* param; |
|
372 TLiwVariant fileType; |
|
373 TLiwVariant filterField; |
|
374 TLiwVariant startVal; |
|
375 TLiwVariant endVal; |
|
376 TLiwVariant sortingField; |
|
377 TLiwVariant order; |
|
378 TLiwGenericParam posbasedparam; |
|
379 |
|
380 //setting the TransactionID |
|
381 requestParam.iTransactionID = aTransactionID; |
|
382 |
|
383 //Get the Filter Map |
|
384 if ( aPostionBasedSearching && ( aInParamList.Count() > 1) ) |
|
385 { |
|
386 pos = 1; |
|
387 aInParamList.AtL( pos,posbasedparam ); |
|
388 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
389 { |
|
390 param = NULL; |
|
391 } |
|
392 else |
|
393 { |
|
394 param = &posbasedparam; |
|
395 } |
|
396 } |
|
397 else |
|
398 { |
|
399 pos=0;//Search from starting point |
|
400 //filter map |
|
401 param = aInParamList.FindFirst( pos, KFilter ); |
|
402 } |
|
403 |
|
404 |
|
405 HBufC8* heapBuffer3 = NULL; |
|
406 HBufC8* heapBuffer4 = NULL; |
|
407 |
|
408 |
|
409 if(param) |
|
410 { |
|
411 filter = (*param).Value().AsMap(); |
|
412 if(!filter) |
|
413 { |
|
414 //Filter Map missing : |
|
415 posbasedparam.Reset(); |
|
416 AppendErrorMessageL( KGetList, KFilter, KInvalid ); |
|
417 User ::Leave(KErrArgument); |
|
418 } |
|
419 |
|
420 } |
|
421 |
|
422 |
|
423 if( (param) && (filter) ) |
|
424 {//filter map |
|
425 |
|
426 TPtrC type16; |
|
427 |
|
428 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &fileType) ); |
|
429 if( (filter->FindL( KFileType, fileType )) ) |
|
430 { |
|
431 if ( (fileType.Get( type16 )) && (type16.Length() > 0 ) ) |
|
432 { |
|
433 heapBuffer3 = HBufC8::NewL( type16.Length() ); |
|
434 CleanupStack::PushL( heapBuffer3 ); |
|
435 TPtr8 type8( heapBuffer3->Des() ); |
|
436 type8.Copy( type16 ); |
|
437 requestParam.iFileType.Set(type8); |
|
438 } |
|
439 else |
|
440 { |
|
441 //fileType.Reset(); |
|
442 posbasedparam.Reset(); |
|
443 AppendErrorMessageL( KGetList, KFileType, KMissingOrInvalid ); |
|
444 User ::Leave(KErrArgument); |
|
445 } |
|
446 } |
|
447 else |
|
448 { |
|
449 //fileType.Reset(); |
|
450 posbasedparam.Reset(); |
|
451 AppendErrorMessageL( KGetList, KFileType, KMissing ); |
|
452 User ::Leave(KErrNotFound); |
|
453 } |
|
454 |
|
455 |
|
456 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &filterField) ); |
|
457 if( filter->FindL( KKey, filterField ) ) |
|
458 { |
|
459 TPtrC filter16; |
|
460 |
|
461 if ( filterField.Get( filter16 )) |
|
462 { |
|
463 heapBuffer4 = HBufC8::NewL( filter16.Length() ); |
|
464 CleanupStack::PushL( heapBuffer4 ); |
|
465 TPtr8 filter8( heapBuffer4->Des() ); |
|
466 filter8.Copy( filter16 ); |
|
467 requestParam.iFilterField.Set(filter8); |
|
468 } |
|
469 else |
|
470 { |
|
471 //fileType.Reset(); |
|
472 //filterField.Reset(); |
|
473 posbasedparam.Reset(); |
|
474 AppendErrorMessageL( KGetList, KKey, KInvalid ); |
|
475 User ::Leave(KErrArgument); |
|
476 } |
|
477 } |
|
478 |
|
479 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &startVal) ); |
|
480 if(filter->FindL( KStartRange, startVal )) |
|
481 { |
|
482 if ( !startVal.Get( requestParam.iStartVal )) |
|
483 { |
|
484 //fileType.Reset(); |
|
485 //filterField.Reset(); |
|
486 //startVal.Reset(); |
|
487 posbasedparam.Reset(); |
|
488 AppendErrorMessageL( KGetList, KStartRange, KInvalid ); |
|
489 User ::Leave(KErrArgument); |
|
490 } |
|
491 } |
|
492 |
|
493 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &endVal) ); |
|
494 if (filter->FindL( KEndRange, endVal )) |
|
495 { |
|
496 if ( !endVal.Get( requestParam.iEndVal )) |
|
497 { |
|
498 //fileType.Reset(); |
|
499 //filterField.Reset(); |
|
500 //startVal.Reset(); |
|
501 //endVal.Reset(); |
|
502 posbasedparam.Reset(); |
|
503 AppendErrorMessageL( KGetList, KEndRange, KInvalid ); |
|
504 User ::Leave(KErrArgument); |
|
505 } |
|
506 } |
|
507 |
|
508 }//filter map |
|
509 |
|
510 else |
|
511 { |
|
512 //Filter Map missing : |
|
513 posbasedparam.Reset(); |
|
514 AppendErrorMessageL( KGetList, KFilter, KMissing ); |
|
515 User ::Leave(KErrNotFound); |
|
516 } |
|
517 |
|
518 if ( aPostionBasedSearching && ( aInParamList.Count() > 2) ) |
|
519 { |
|
520 pos = 2; |
|
521 aInParamList.AtL( pos,posbasedparam ); |
|
522 if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
523 { |
|
524 param = NULL; |
|
525 } |
|
526 else |
|
527 { |
|
528 param = &posbasedparam; |
|
529 } |
|
530 } |
|
531 else |
|
532 { |
|
533 pos=0;//Search from starting point |
|
534 //Sorting map |
|
535 param = aInParamList.FindFirst( pos, KSort ); |
|
536 } |
|
537 |
|
538 HBufC8* heapBuffer1 = NULL; |
|
539 HBufC8* heapBuffer2 = NULL; |
|
540 |
|
541 if(param) |
|
542 { |
|
543 sorting = (*param).Value().AsMap(); |
|
544 if(!sorting) |
|
545 { |
|
546 //Filter Map missing : |
|
547 posbasedparam.Reset(); |
|
548 AppendErrorMessageL( KGetList, KSort, KInvalid ); |
|
549 User ::Leave(KErrArgument); |
|
550 } |
|
551 } |
|
552 |
|
553 if( (param) && sorting ) |
|
554 {//sort map |
|
555 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &sortingField) ); |
|
556 if (sorting->FindL( KKey, sortingField )) |
|
557 { |
|
558 TPtrC sort16; |
|
559 if ( sortingField.Get( sort16)) |
|
560 { |
|
561 heapBuffer1 = HBufC8::NewL( sort16.Length() ); |
|
562 CleanupStack::PushL( heapBuffer1 ); |
|
563 TPtr8 sort8( heapBuffer1->Des() ); |
|
564 sort8.Copy( sort16 ); |
|
565 requestParam.iSortField.Set(sort8); |
|
566 } |
|
567 else |
|
568 { |
|
569 //fileType.Reset(); |
|
570 //filterField.Reset(); |
|
571 //startVal.Reset(); |
|
572 //endVal.Reset(); |
|
573 //sortingField.Reset(); |
|
574 posbasedparam.Reset(); |
|
575 AppendErrorMessageL( KGetList, KKey, KInvalid ); |
|
576 User ::Leave(KErrArgument); |
|
577 } |
|
578 } |
|
579 |
|
580 CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &order) ); |
|
581 if (sorting->FindL( KOrder, order )) |
|
582 { |
|
583 TPtrC sortOrder16; |
|
584 if ( order.Get( sortOrder16)) |
|
585 { |
|
586 heapBuffer2 = HBufC8::NewL( sortOrder16.Length() ); |
|
587 CleanupStack::PushL( heapBuffer2 ); |
|
588 TPtr8 sortOrder8( heapBuffer2->Des() ); |
|
589 sortOrder8.Copy( sortOrder16 ); |
|
590 order.Get( requestParam.iOrder ); |
|
591 requestParam.iOrder.Set(sortOrder8); |
|
592 } |
|
593 else |
|
594 { |
|
595 //fileType.Reset(); |
|
596 //filterField.Reset(); |
|
597 //startVal.Reset(); |
|
598 //endVal.Reset(); |
|
599 //sortingField.Reset(); |
|
600 //order.Reset(); |
|
601 posbasedparam.Reset(); |
|
602 AppendErrorMessageL( KGetList, KOrder, KInvalid ); |
|
603 User ::Leave(KErrArgument); |
|
604 } |
|
605 } |
|
606 |
|
607 }//sort map |
|
608 |
|
609 |
|
610 iCoreClass->GetListL( requestParam,iServiceObserver ) ; |
|
611 |
|
612 |
|
613 |
|
614 //Sorting is an optional parameter, if it is present only then sorting fields and order present in stack |
|
615 if( (param) && sorting ) |
|
616 { |
|
617 |
|
618 if( heapBuffer2 ) |
|
619 CleanupStack::PopAndDestroy( heapBuffer2 ); |
|
620 |
|
621 CleanupStack::Pop(&order); |
|
622 |
|
623 if( heapBuffer1 ) |
|
624 CleanupStack::PopAndDestroy( heapBuffer1 ); |
|
625 |
|
626 CleanupStack::Pop(&sortingField); |
|
627 |
|
628 } |
|
629 |
|
630 CleanupStack::Pop(&endVal); |
|
631 CleanupStack::Pop(&startVal); |
|
632 |
|
633 if( heapBuffer4 ) |
|
634 CleanupStack::PopAndDestroy( heapBuffer4 ); |
|
635 |
|
636 CleanupStack::Pop(&filterField); |
|
637 |
|
638 if( heapBuffer3 ) |
|
639 CleanupStack::PopAndDestroy( heapBuffer3 ); |
|
640 |
|
641 CleanupStack::Pop(&fileType); |
|
642 |
|
643 fileType.Reset(); |
|
644 filterField.Reset(); |
|
645 startVal.Reset(); |
|
646 endVal.Reset(); |
|
647 sortingField.Reset(); |
|
648 order.Reset(); |
|
649 posbasedparam.Reset(); |
|
650 |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // CMgInterface::SendRequestL |
|
655 // This function is called by the user to get mapped SAPI generic error code |
|
656 // from symbian error codes . |
|
657 // ----------------------------------------------------------------------------- |
|
658 |
|
659 TInt CMgInterface::SapiError( TInt aSymbianErr ) |
|
660 { |
|
661 TInt sapiErr(SErrGeneralError); |
|
662 |
|
663 switch (aSymbianErr) |
|
664 { |
|
665 case KErrArgument: |
|
666 { |
|
667 sapiErr = SErrBadArgumentType; |
|
668 break; |
|
669 } |
|
670 case KErrNotFound: |
|
671 { |
|
672 sapiErr = SErrMissingArgument; |
|
673 break; |
|
674 } |
|
675 |
|
676 case KErrNotSupported: |
|
677 { |
|
678 sapiErr = SErrServiceNotSupported; |
|
679 break; |
|
680 } |
|
681 case KErrServerBusy: |
|
682 { |
|
683 sapiErr = SErrServerBusy; |
|
684 break; |
|
685 } |
|
686 case KErrGeneral: |
|
687 { |
|
688 sapiErr = SErrGeneralError; |
|
689 break; |
|
690 } |
|
691 case KErrCancel: |
|
692 { |
|
693 sapiErr = SErrCancelSuccess; |
|
694 break; |
|
695 } |
|
696 case KErrNone: |
|
697 { |
|
698 sapiErr= SErrNone; |
|
699 break; |
|
700 } |
|
701 |
|
702 case KErrNoMemory: |
|
703 { |
|
704 sapiErr = SErrNoMemory; |
|
705 break; |
|
706 } |
|
707 case KErrInUse: |
|
708 { |
|
709 sapiErr = SErrServiceInUse; |
|
710 break; |
|
711 } |
|
712 case KErrNotReady: |
|
713 { |
|
714 sapiErr = SErrServiceNotReady; |
|
715 break; |
|
716 } |
|
717 } |
|
718 return sapiErr; |
|
719 } |
|
720 |
|
721 // --------------------------------------------------------------------------- |
|
722 // Append Error Message |
|
723 // --------------------------------------------------------------------------- |
|
724 // |
|
725 void CMgInterface::AppendErrorMessageL( const TDesC8& aCmdName, const TDesC8& aParameter, const TDesC& aMessage ) |
|
726 { |
|
727 iErrorMessage = HBufC::NewL( KMaxErrorMessageLength ); |
|
728 TPtr tmpMsgPtr = iErrorMessage->Des(); |
|
729 tmpMsgPtr.Copy(KDomainName); |
|
730 |
|
731 HBufC* temp = HBufC::New( KMaxErrorMessageLength ); |
|
732 |
|
733 if ( aCmdName.Length() ) |
|
734 { |
|
735 tmpMsgPtr.Append( KErrorMsgSeparator ); |
|
736 temp->Des().Copy( aCmdName ); |
|
737 tmpMsgPtr.Append( temp->Des() ); |
|
738 } |
|
739 |
|
740 tmpMsgPtr.Append(KErrorMsgSeparator); |
|
741 |
|
742 if ( aParameter.Length() ) |
|
743 { |
|
744 temp->Des().Copy(aParameter); |
|
745 tmpMsgPtr.Append(temp->Des()); |
|
746 } |
|
747 |
|
748 if ( aMessage.Length() ) |
|
749 { |
|
750 tmpMsgPtr.Append( aMessage ); |
|
751 } |
|
752 |
|
753 delete temp; |
|
754 } |