author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 27 Apr 2010 17:33:05 +0300 | |
branch | RCL_3 |
changeset 36 | c210248fa89d |
parent 10 | fc9cf246af83 |
permissions | -rw-r--r-- |
5 | 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 |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
128 |
// delete iServiceObserver; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
129 |
// iServiceObserver = NULL; |
5 | 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 |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
258 |
/* if( EMgFree == iCoreClass->State() ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
259 |
{*/ |
5 | 260 |
if( aCmdOptions & KLiwOptASyncronous ) //Asynchronous request |
261 |
{ |
|
262 |
if( NULL != aCallBack ) // Asynchronous call |
|
263 |
{ |
|
264 |
transactionID = aCallBack->GetTransactionID(); |
|
265 |
//Sending request to core class |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
266 |
TRAP (errCode,SendRequestL( aInParamList , transactionID ,postionbasedsearching,aCallBack )); |
5 | 267 |
|
268 |
} |
|
269 |
else //Callback missing |
|
270 |
{ |
|
271 |
AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
272 |
errCode = KErrNotFound; |
|
273 |
} |
|
274 |
||
275 |
} |
|
276 |
else //synchronous request |
|
277 |
{ |
|
278 |
//synch request currently not supported |
|
279 |
AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
280 |
errCode = KErrNotFound; |
|
281 |
}//synchronous request |
|
282 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
283 |
/*}//Sapi status |
5 | 284 |
else |
285 |
{ |
|
286 |
AppendErrorMessageL( aCmdName, KNullDesC8, KServerBusy ); |
|
287 |
errCode = KErrServerBusy; |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
288 |
}*/ |
5 | 289 |
|
290 |
}//Data Source support |
|
291 |
else |
|
292 |
{ |
|
293 |
//Incorrect Data source |
|
294 |
AppendErrorMessageL( aCmdName, KDsName, KNotSupported ); |
|
295 |
errCode = KErrNotSupported; |
|
296 |
} |
|
297 |
||
298 |
||
299 |
}//DataType Mismatch |
|
300 |
else |
|
301 |
{ |
|
302 |
AppendErrorMessageL( aCmdName, KDsName, KInvalid ); |
|
303 |
errCode = KErrArgument; |
|
304 |
} |
|
305 |
||
306 |
||
307 |
}//datasource missing |
|
308 |
else |
|
309 |
{ |
|
310 |
AppendErrorMessageL( aCmdName, KDsName, KMissing ); |
|
311 |
errCode = KErrNotFound; |
|
312 |
} |
|
313 |
||
314 |
||
315 |
}//GetList |
|
316 |
else if(0 == aCmdName.CompareF( KGetThumbnail ))// Here we need to put implementation for getThumbnail |
|
317 |
{ |
|
318 |
//Call |
|
319 |
if( (aCmdOptions & KLiwOptASyncronous ) && ( NULL != aCallBack ) ) //Asynchronous request |
|
320 |
{ |
|
321 |
//Asynch Call |
|
322 |
transactionID = aCallBack->GetTransactionID(); |
|
323 |
TInt err =0; |
|
324 |
||
325 |
TRAP(err,GetThumbnailL( aInParamList, aOutParamList, aCallBack , transactionID )); |
|
326 |
errCode = err; |
|
327 |
} |
|
328 |
else |
|
329 |
{ |
|
330 |
AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidAsyncParam ); |
|
331 |
errCode = KErrNotFound; |
|
332 |
} |
|
333 |
||
334 |
||
335 |
}// GetThumbnail |
|
336 |
else |
|
337 |
{ |
|
338 |
AppendErrorMessageL( aCmdName, KNullDesC8, KCmdInvalid ); |
|
339 |
errCode = KErrNotSupported; //command not supported |
|
340 |
} |
|
341 |
||
342 |
// check error code if any error occurs then insert into output list |
|
343 |
posbasedparam.Reset(); |
|
344 |
TInt sapiErr = SErrNone; |
|
345 |
if (errCode) |
|
346 |
{ |
|
347 |
sapiErr = SapiError(errCode); |
|
348 |
} |
|
349 |
||
350 |
aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
351 |
if ( iErrorMessage ) |
|
352 |
{ |
|
353 |
aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, |
|
354 |
TLiwVariant(iErrorMessage->Des()))); |
|
355 |
delete iErrorMessage; |
|
356 |
iErrorMessage = NULL; |
|
357 |
} |
|
358 |
||
359 |
aOutParamList.AppendL( TLiwGenericParam( KTransactionID, TLiwVariant( (TInt32)transactionID ) ) ); |
|
360 |
||
361 |
} |
|
362 |
||
363 |
||
364 |
// ----------------------------------------------------------------------------- |
|
365 |
// CMgInterface::CMgInterface |
|
366 |
// Constructor of class |
|
367 |
// ----------------------------------------------------------------------------- |
|
368 |
||
369 |
CMgInterface::CMgInterface() |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
370 |
:iCoreClass( NULL ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
371 |
|
5 | 372 |
{ |
373 |
||
374 |
} |
|
375 |
||
376 |
||
377 |
// ----------------------------------------------------------------------------- |
|
378 |
// CMgInterface::ConstructL |
|
379 |
// Two-phased constructor of class |
|
380 |
// ----------------------------------------------------------------------------- |
|
381 |
||
382 |
void CMgInterface::ConstructL() |
|
383 |
{ |
|
384 |
// Create the instance of core class |
|
385 |
iCoreClass = CMgService::NewL(); |
|
386 |
||
387 |
//Create the instance of service observer class |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
388 |
//iServiceObserver = CMgServiceObserver::NewL(); |
5 | 389 |
|
390 |
} |
|
391 |
||
392 |
||
393 |
||
394 |
// ----------------------------------------------------------------------------- |
|
395 |
// CMgInterface::SendRequestL |
|
396 |
// This function will send the request to Core class |
|
397 |
// ----------------------------------------------------------------------------- |
|
398 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
399 |
void CMgInterface::SendRequestL(const CLiwGenericParamList& aInParamList , TUint aTransactionID , TBool aPostionBasedSearching , MLiwNotifyCallback* aCallBack) |
5 | 400 |
|
401 |
{ |
|
402 |
TInt pos=0; |
|
403 |
const CLiwMap* filter = NULL; |
|
404 |
const CLiwMap* sorting = NULL; |
|
405 |
TMgServiceRequest requestParam; |
|
406 |
const TLiwGenericParam* param; |
|
407 |
TLiwVariant fileType; |
|
408 |
TLiwVariant filterField; |
|
409 |
TLiwVariant startVal; |
|
410 |
TLiwVariant endVal; |
|
411 |
TLiwVariant sortingField; |
|
412 |
TLiwVariant order; |
|
413 |
TLiwGenericParam posbasedparam; |
|
414 |
||
415 |
//setting the TransactionID |
|
416 |
requestParam.iTransactionID = aTransactionID; |
|
417 |
||
418 |
//Get the Filter Map |
|
419 |
if ( aPostionBasedSearching && ( aInParamList.Count() > 1) ) |
|
420 |
{ |
|
421 |
pos = 1; |
|
422 |
aInParamList.AtL( pos,posbasedparam ); |
|
423 |
if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
424 |
{ |
|
425 |
param = NULL; |
|
426 |
} |
|
427 |
else |
|
428 |
{ |
|
429 |
param = &posbasedparam; |
|
430 |
} |
|
431 |
} |
|
432 |
else |
|
433 |
{ |
|
434 |
pos=0;//Search from starting point |
|
435 |
//filter map |
|
436 |
param = aInParamList.FindFirst( pos, KFilter ); |
|
437 |
} |
|
438 |
||
439 |
||
440 |
HBufC8* heapBuffer3 = NULL; |
|
441 |
HBufC8* heapBuffer4 = NULL; |
|
442 |
||
443 |
||
444 |
if(param) |
|
445 |
{ |
|
446 |
filter = (*param).Value().AsMap(); |
|
447 |
if(!filter) |
|
448 |
{ |
|
449 |
//Filter Map missing : |
|
450 |
posbasedparam.Reset(); |
|
451 |
AppendErrorMessageL( KGetList, KFilter, KInvalid ); |
|
452 |
User ::Leave(KErrArgument); |
|
453 |
} |
|
454 |
||
455 |
} |
|
456 |
||
457 |
||
458 |
if( (param) && (filter) ) |
|
459 |
{//filter map |
|
460 |
||
461 |
TPtrC type16; |
|
462 |
||
463 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &fileType) ); |
|
464 |
if( (filter->FindL( KFileType, fileType )) ) |
|
465 |
{ |
|
466 |
if ( (fileType.Get( type16 )) && (type16.Length() > 0 ) ) |
|
467 |
{ |
|
468 |
heapBuffer3 = HBufC8::NewL( type16.Length() ); |
|
469 |
CleanupStack::PushL( heapBuffer3 ); |
|
470 |
TPtr8 type8( heapBuffer3->Des() ); |
|
471 |
type8.Copy( type16 ); |
|
472 |
requestParam.iFileType.Set(type8); |
|
473 |
} |
|
474 |
else |
|
475 |
{ |
|
476 |
//fileType.Reset(); |
|
477 |
posbasedparam.Reset(); |
|
478 |
AppendErrorMessageL( KGetList, KFileType, KMissingOrInvalid ); |
|
479 |
User ::Leave(KErrArgument); |
|
480 |
} |
|
481 |
} |
|
482 |
else |
|
483 |
{ |
|
484 |
//fileType.Reset(); |
|
485 |
posbasedparam.Reset(); |
|
486 |
AppendErrorMessageL( KGetList, KFileType, KMissing ); |
|
487 |
User ::Leave(KErrNotFound); |
|
488 |
} |
|
489 |
||
490 |
||
491 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &filterField) ); |
|
492 |
if( filter->FindL( KKey, filterField ) ) |
|
493 |
{ |
|
494 |
TPtrC filter16; |
|
495 |
||
496 |
if ( filterField.Get( filter16 )) |
|
497 |
{ |
|
498 |
heapBuffer4 = HBufC8::NewL( filter16.Length() ); |
|
499 |
CleanupStack::PushL( heapBuffer4 ); |
|
500 |
TPtr8 filter8( heapBuffer4->Des() ); |
|
501 |
filter8.Copy( filter16 ); |
|
502 |
requestParam.iFilterField.Set(filter8); |
|
503 |
} |
|
504 |
else |
|
505 |
{ |
|
506 |
//fileType.Reset(); |
|
507 |
//filterField.Reset(); |
|
508 |
posbasedparam.Reset(); |
|
509 |
AppendErrorMessageL( KGetList, KKey, KInvalid ); |
|
510 |
User ::Leave(KErrArgument); |
|
511 |
} |
|
512 |
} |
|
513 |
||
514 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &startVal) ); |
|
515 |
if(filter->FindL( KStartRange, startVal )) |
|
516 |
{ |
|
517 |
if ( !startVal.Get( requestParam.iStartVal )) |
|
518 |
{ |
|
519 |
//fileType.Reset(); |
|
520 |
//filterField.Reset(); |
|
521 |
//startVal.Reset(); |
|
522 |
posbasedparam.Reset(); |
|
523 |
AppendErrorMessageL( KGetList, KStartRange, KInvalid ); |
|
524 |
User ::Leave(KErrArgument); |
|
525 |
} |
|
526 |
} |
|
527 |
||
528 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &endVal) ); |
|
529 |
if (filter->FindL( KEndRange, endVal )) |
|
530 |
{ |
|
531 |
if ( !endVal.Get( requestParam.iEndVal )) |
|
532 |
{ |
|
533 |
//fileType.Reset(); |
|
534 |
//filterField.Reset(); |
|
535 |
//startVal.Reset(); |
|
536 |
//endVal.Reset(); |
|
537 |
posbasedparam.Reset(); |
|
538 |
AppendErrorMessageL( KGetList, KEndRange, KInvalid ); |
|
539 |
User ::Leave(KErrArgument); |
|
540 |
} |
|
541 |
} |
|
542 |
||
543 |
}//filter map |
|
544 |
||
545 |
else |
|
546 |
{ |
|
547 |
//Filter Map missing : |
|
548 |
posbasedparam.Reset(); |
|
549 |
AppendErrorMessageL( KGetList, KFilter, KMissing ); |
|
550 |
User ::Leave(KErrNotFound); |
|
551 |
} |
|
552 |
||
553 |
if ( aPostionBasedSearching && ( aInParamList.Count() > 2) ) |
|
554 |
{ |
|
555 |
pos = 2; |
|
556 |
aInParamList.AtL( pos,posbasedparam ); |
|
557 |
if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
558 |
{ |
|
559 |
param = NULL; |
|
560 |
} |
|
561 |
else |
|
562 |
{ |
|
563 |
param = &posbasedparam; |
|
564 |
} |
|
565 |
} |
|
566 |
else |
|
567 |
{ |
|
568 |
pos=0;//Search from starting point |
|
569 |
//Sorting map |
|
570 |
param = aInParamList.FindFirst( pos, KSort ); |
|
571 |
} |
|
572 |
||
573 |
HBufC8* heapBuffer1 = NULL; |
|
574 |
HBufC8* heapBuffer2 = NULL; |
|
575 |
||
576 |
if(param) |
|
577 |
{ |
|
578 |
sorting = (*param).Value().AsMap(); |
|
579 |
if(!sorting) |
|
580 |
{ |
|
581 |
//Filter Map missing : |
|
582 |
posbasedparam.Reset(); |
|
583 |
AppendErrorMessageL( KGetList, KSort, KInvalid ); |
|
584 |
User ::Leave(KErrArgument); |
|
585 |
} |
|
586 |
} |
|
587 |
||
588 |
if( (param) && sorting ) |
|
589 |
{//sort map |
|
590 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &sortingField) ); |
|
591 |
if (sorting->FindL( KKey, sortingField )) |
|
592 |
{ |
|
593 |
TPtrC sort16; |
|
594 |
if ( sortingField.Get( sort16)) |
|
595 |
{ |
|
596 |
heapBuffer1 = HBufC8::NewL( sort16.Length() ); |
|
597 |
CleanupStack::PushL( heapBuffer1 ); |
|
598 |
TPtr8 sort8( heapBuffer1->Des() ); |
|
599 |
sort8.Copy( sort16 ); |
|
600 |
requestParam.iSortField.Set(sort8); |
|
601 |
} |
|
602 |
else |
|
603 |
{ |
|
604 |
//fileType.Reset(); |
|
605 |
//filterField.Reset(); |
|
606 |
//startVal.Reset(); |
|
607 |
//endVal.Reset(); |
|
608 |
//sortingField.Reset(); |
|
609 |
posbasedparam.Reset(); |
|
610 |
AppendErrorMessageL( KGetList, KKey, KInvalid ); |
|
611 |
User ::Leave(KErrArgument); |
|
612 |
} |
|
613 |
} |
|
614 |
||
615 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &order) ); |
|
616 |
if (sorting->FindL( KOrder, order )) |
|
617 |
{ |
|
618 |
TPtrC sortOrder16; |
|
619 |
if ( order.Get( sortOrder16)) |
|
620 |
{ |
|
621 |
heapBuffer2 = HBufC8::NewL( sortOrder16.Length() ); |
|
622 |
CleanupStack::PushL( heapBuffer2 ); |
|
623 |
TPtr8 sortOrder8( heapBuffer2->Des() ); |
|
624 |
sortOrder8.Copy( sortOrder16 ); |
|
625 |
order.Get( requestParam.iOrder ); |
|
626 |
requestParam.iOrder.Set(sortOrder8); |
|
627 |
} |
|
628 |
else |
|
629 |
{ |
|
630 |
//fileType.Reset(); |
|
631 |
//filterField.Reset(); |
|
632 |
//startVal.Reset(); |
|
633 |
//endVal.Reset(); |
|
634 |
//sortingField.Reset(); |
|
635 |
//order.Reset(); |
|
636 |
posbasedparam.Reset(); |
|
637 |
AppendErrorMessageL( KGetList, KOrder, KInvalid ); |
|
638 |
User ::Leave(KErrArgument); |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
}//sort map |
|
643 |
||
644 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
645 |
// Need to give seperate observer for each call |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
646 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
647 |
// Creating instance of serviceobserver for back to back callback support |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
648 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
649 |
CMgServiceObserver* serviceObserver = CMgServiceObserver::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
650 |
CleanupStack::PushL(serviceObserver); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
651 |
// For supporting back to back callback |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
652 |
serviceObserver->SetMemberVar( EMgBlankCmdId, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
653 |
NULL,aCallBack ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
654 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
655 |
iCoreClass->GetListL( requestParam,serviceObserver ) ; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
656 |
CleanupStack::Pop(serviceObserver); |
5 | 657 |
|
658 |
||
659 |
//Sorting is an optional parameter, if it is present only then sorting fields and order present in stack |
|
660 |
if( (param) && sorting ) |
|
661 |
{ |
|
662 |
||
663 |
if( heapBuffer2 ) |
|
664 |
CleanupStack::PopAndDestroy( heapBuffer2 ); |
|
665 |
||
666 |
CleanupStack::Pop(&order); |
|
667 |
||
668 |
if( heapBuffer1 ) |
|
669 |
CleanupStack::PopAndDestroy( heapBuffer1 ); |
|
670 |
||
671 |
CleanupStack::Pop(&sortingField); |
|
672 |
||
673 |
} |
|
674 |
||
675 |
CleanupStack::Pop(&endVal); |
|
676 |
CleanupStack::Pop(&startVal); |
|
677 |
||
678 |
if( heapBuffer4 ) |
|
679 |
CleanupStack::PopAndDestroy( heapBuffer4 ); |
|
680 |
||
681 |
CleanupStack::Pop(&filterField); |
|
682 |
||
683 |
if( heapBuffer3 ) |
|
684 |
CleanupStack::PopAndDestroy( heapBuffer3 ); |
|
685 |
||
686 |
CleanupStack::Pop(&fileType); |
|
687 |
||
688 |
fileType.Reset(); |
|
689 |
filterField.Reset(); |
|
690 |
startVal.Reset(); |
|
691 |
endVal.Reset(); |
|
692 |
sortingField.Reset(); |
|
693 |
order.Reset(); |
|
694 |
posbasedparam.Reset(); |
|
695 |
||
696 |
} |
|
697 |
||
698 |
// ----------------------------------------------------------------------------- |
|
699 |
// CMgInterface::SendRequestL |
|
700 |
// This function is called by the user to get mapped SAPI generic error code |
|
701 |
// from symbian error codes . |
|
702 |
// ----------------------------------------------------------------------------- |
|
703 |
||
704 |
TInt CMgInterface::SapiError( TInt aSymbianErr ) |
|
705 |
{ |
|
706 |
TInt sapiErr(SErrGeneralError); |
|
707 |
||
708 |
switch (aSymbianErr) |
|
709 |
{ |
|
710 |
case KErrArgument: |
|
711 |
{ |
|
712 |
sapiErr = SErrBadArgumentType; |
|
713 |
break; |
|
714 |
} |
|
715 |
case KErrNotFound: |
|
716 |
{ |
|
717 |
sapiErr = SErrMissingArgument; |
|
718 |
break; |
|
719 |
} |
|
720 |
||
721 |
case KErrNotSupported: |
|
722 |
{ |
|
723 |
sapiErr = SErrServiceNotSupported; |
|
724 |
break; |
|
725 |
} |
|
726 |
case KErrServerBusy: |
|
727 |
{ |
|
728 |
sapiErr = SErrServerBusy; |
|
729 |
break; |
|
730 |
} |
|
731 |
case KErrGeneral: |
|
732 |
{ |
|
733 |
sapiErr = SErrGeneralError; |
|
734 |
break; |
|
735 |
} |
|
736 |
case KErrCancel: |
|
737 |
{ |
|
738 |
sapiErr = SErrCancelSuccess; |
|
739 |
break; |
|
740 |
} |
|
741 |
case KErrNone: |
|
742 |
{ |
|
743 |
sapiErr= SErrNone; |
|
744 |
break; |
|
745 |
} |
|
746 |
||
747 |
case KErrNoMemory: |
|
748 |
{ |
|
749 |
sapiErr = SErrNoMemory; |
|
750 |
break; |
|
751 |
} |
|
752 |
case KErrInUse: |
|
753 |
{ |
|
754 |
sapiErr = SErrServiceInUse; |
|
755 |
break; |
|
756 |
} |
|
757 |
case KErrNotReady: |
|
758 |
{ |
|
759 |
sapiErr = SErrServiceNotReady; |
|
760 |
break; |
|
761 |
} |
|
762 |
case KErrBadName: |
|
763 |
{ |
|
764 |
sapiErr = SErrUnknownFormat; |
|
765 |
break; |
|
766 |
} |
|
767 |
case KErrAlreadyExists: |
|
768 |
{ |
|
769 |
sapiErr = SErrEntryExists; |
|
770 |
break; |
|
771 |
} |
|
772 |
} |
|
773 |
return sapiErr; |
|
774 |
} |
|
775 |
||
776 |
// --------------------------------------------------------------------------- |
|
777 |
// Append Error Message |
|
778 |
// --------------------------------------------------------------------------- |
|
779 |
// |
|
780 |
void CMgInterface::AppendErrorMessageL( const TDesC8& aCmdName, const TDesC8& aParameter, const TDesC& aMessage ) |
|
781 |
{ |
|
782 |
iErrorMessage = HBufC::NewL( KMaxErrorMessageLength ); |
|
783 |
TPtr tmpMsgPtr = iErrorMessage->Des(); |
|
784 |
tmpMsgPtr.Copy(KDomainName); |
|
785 |
||
786 |
HBufC* temp = HBufC::New( KMaxErrorMessageLength ); |
|
787 |
||
788 |
if ( aCmdName.Length() ) |
|
789 |
{ |
|
790 |
tmpMsgPtr.Append( KErrorMsgSeparator ); |
|
791 |
temp->Des().Copy( aCmdName ); |
|
792 |
tmpMsgPtr.Append( temp->Des() ); |
|
793 |
} |
|
794 |
||
795 |
tmpMsgPtr.Append(KErrorMsgSeparator); |
|
796 |
||
797 |
if ( aParameter.Length() ) |
|
798 |
{ |
|
799 |
temp->Des().Copy(aParameter); |
|
800 |
tmpMsgPtr.Append(temp->Des()); |
|
801 |
} |
|
802 |
||
803 |
if ( aMessage.Length() ) |
|
804 |
{ |
|
805 |
tmpMsgPtr.Append( aMessage ); |
|
806 |
} |
|
807 |
||
808 |
delete temp; |
|
809 |
} |
|
810 |
// ----------------------------------------------------------------------------- |
|
811 |
// CMgInterface::GetThumbnailL |
|
812 |
// This method will send request to core class fot getthumbnail |
|
813 |
// ----------------------------------------------------------------------------- |
|
814 |
||
815 |
void CMgInterface::GetThumbnailL( const CLiwGenericParamList& aInParamList, |
|
816 |
CLiwGenericParamList& aOutParamList, |
|
817 |
MLiwNotifyCallback* aCallBack , |
|
818 |
TInt32 aTransactionID ) |
|
819 |
{ |
|
820 |
||
821 |
TLiwGenericParam posbasedparam; |
|
822 |
TBool postionbasedsearching = EFalse; |
|
823 |
const TLiwGenericParam* param = NULL; |
|
824 |
TInt pos = 0; |
|
825 |
const CLiwMap* thumbnailSizemap = NULL; |
|
826 |
TLiwVariant width; |
|
827 |
TLiwVariant height; |
|
828 |
TInt widthThumb = KNegVal; |
|
829 |
TInt heightThumb = KNegVal; |
|
830 |
TBuf<KFilePath> mediaUrl; |
|
831 |
// Finding url by name |
|
832 |
param = aInParamList.FindFirst( pos, KUrl ); |
|
833 |
||
834 |
if( !param ) |
|
835 |
{ |
|
836 |
// finding url by position based |
|
837 |
if( aInParamList.Count() > 0 ) |
|
838 |
{ |
|
839 |
pos = 0; |
|
840 |
aInParamList.AtL( pos,posbasedparam ); |
|
841 |
||
842 |
if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
843 |
{ |
|
844 |
param = NULL; |
|
845 |
} |
|
846 |
else |
|
847 |
{ |
|
848 |
param = &posbasedparam; |
|
849 |
postionbasedsearching = ETrue; |
|
850 |
} |
|
851 |
} |
|
852 |
} |
|
853 |
// checking the type of url it should be string |
|
854 |
// if ((param) && (param->Value().TypeId() != LIW::EVariantTypeNull) && (param->Value().TypeId() != LIW::EVariantTypeDesC) ) |
|
855 |
if ((param) && (param->Value().TypeId() != LIW::EVariantTypeDesC ) ) |
|
856 |
{ |
|
857 |
||
858 |
posbasedparam.Reset(); |
|
859 |
AppendErrorMessageL( KGetThumbnail, KUrl, KInvalid ); |
|
860 |
User::Leave(KErrArgument); |
|
861 |
||
862 |
} |
|
863 |
// present : Mandatory Argument |
|
864 |
||
865 |
if( ( (param) && ( param->Value().AsDes().Length() < KFilePath ) && (param->Value().Get( mediaUrl ) ) ) ) |
|
866 |
{ |
|
867 |
// Got the url |
|
868 |
||
869 |
// Now checking for optional argument Thumbnailsize |
|
870 |
param = NULL; |
|
871 |
||
872 |
||
873 |
if ( postionbasedsearching && ( aInParamList.Count() > 1) ) |
|
874 |
{ |
|
875 |
pos = 2; |
|
876 |
aInParamList.AtL( pos,posbasedparam ); |
|
877 |
if ( (posbasedparam.Name().CompareF(KNullDesC8) != 0 ) || posbasedparam.Value().IsEmpty() ) |
|
878 |
{ |
|
879 |
param = NULL; |
|
880 |
} |
|
881 |
else |
|
882 |
{ |
|
883 |
param = &posbasedparam; |
|
884 |
} |
|
885 |
} |
|
886 |
else |
|
887 |
{ |
|
888 |
pos=0;//Search from starting point |
|
889 |
//ThumbnailSize map |
|
890 |
param = aInParamList.FindFirst( pos, KThumbnailSize ); |
|
891 |
} |
|
892 |
||
893 |
// ThumbnailSize map is present |
|
894 |
if ( param ) |
|
895 |
{ |
|
896 |
if( (param->Value().TypeId() != LIW::EVariantTypeMap ) ) |
|
897 |
{ |
|
898 |
//ThumbnailSize Type MisMatch |
|
899 |
||
900 |
||
901 |
posbasedparam.Reset(); |
|
902 |
AppendErrorMessageL( KGetThumbnail, KThumbnailSize, KInvalid ); |
|
903 |
User::Leave(KErrArgument); |
|
904 |
||
905 |
||
906 |
} |
|
907 |
||
908 |
thumbnailSizemap = param->Value().AsMap(); |
|
909 |
||
910 |
if(thumbnailSizemap) |
|
911 |
||
912 |
{ |
|
913 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &width) ); |
|
914 |
||
915 |
if(thumbnailSizemap->FindL( KWidth, width )) |
|
916 |
{ |
|
917 |
if ( width.TypeId() != LIW::EVariantTypeTInt32 ) |
|
918 |
{ |
|
919 |
||
920 |
CleanupStack::Pop(&width); |
|
921 |
width.Reset() ; |
|
922 |
posbasedparam.Reset(); |
|
923 |
AppendErrorMessageL( KGetThumbnail, KWidth, KInvalid ); |
|
924 |
User::Leave(KErrArgument); |
|
925 |
||
926 |
} |
|
927 |
||
928 |
||
929 |
widthThumb = width.AsTInt32(); |
|
930 |
if(widthThumb <= 0 ) // If width is negative and zero then throw error |
|
931 |
{ |
|
932 |
CleanupStack::Pop(&width); |
|
933 |
width.Reset() ; |
|
934 |
posbasedparam.Reset(); |
|
935 |
AppendErrorMessageL( KGetThumbnail, KWidth, KInvalid ); |
|
936 |
User::Leave(KErrArgument); |
|
937 |
} |
|
938 |
||
939 |
||
940 |
||
941 |
CleanupStack::Pop(&width); |
|
942 |
width.Reset(); |
|
943 |
||
944 |
} // End if thumbnail width is there |
|
945 |
else |
|
946 |
{ |
|
947 |
CleanupStack::Pop(&width); |
|
948 |
width.Reset(); |
|
949 |
||
950 |
} |
|
951 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &height) ); |
|
952 |
if(thumbnailSizemap->FindL( KHeight, height )) |
|
953 |
{ |
|
954 |
if ( height.TypeId() != LIW::EVariantTypeTInt32 ) |
|
955 |
{ |
|
956 |
||
957 |
CleanupStack::Pop(&height); |
|
958 |
height.Reset() ; |
|
959 |
||
960 |
posbasedparam.Reset(); |
|
961 |
AppendErrorMessageL( KGetThumbnail, KHeight, KInvalid ); |
|
962 |
User::Leave(KErrArgument); |
|
963 |
||
964 |
} |
|
965 |
||
966 |
||
967 |
heightThumb = height.AsTInt32(); |
|
968 |
if(heightThumb <= 0 ) // If height is negative or zero then throw error |
|
969 |
{ |
|
970 |
CleanupStack::Pop(&height); |
|
971 |
height.Reset() ; |
|
972 |
posbasedparam.Reset(); |
|
973 |
AppendErrorMessageL( KGetThumbnail, KHeight, KInvalid ); |
|
974 |
User::Leave(KErrArgument); |
|
975 |
} |
|
976 |
||
977 |
||
978 |
||
979 |
CleanupStack::Pop(&height); |
|
980 |
height.Reset(); |
|
981 |
||
982 |
} // End If Height is there in thumbnail size map |
|
983 |
else |
|
984 |
{ |
|
985 |
CleanupStack::Pop(&height); |
|
986 |
height.Reset(); |
|
987 |
} |
|
988 |
} // End of thumbnailsize map |
|
989 |
||
990 |
}// For optional argument thumbanil size |
|
991 |
||
992 |
// now calling GetThumbnailL method of core class |
|
993 |
||
994 |
||
995 |
if( aCallBack ) |
|
996 |
{ |
|
997 |
//Asynch Call |
|
998 |
CServiceThumbnailObserver* observer = CServiceThumbnailObserver::NewL( aCallBack ); |
|
999 |
CleanupStack::PushL( observer ); |
|
1000 |
||
1001 |
iCoreClass->GetThumbnailL( observer, mediaUrl, aTransactionID,heightThumb , widthThumb); |
|
1002 |
||
1003 |
CleanupStack::Pop( observer ); |
|
1004 |
} |
|
1005 |
||
1006 |
height.Reset(); |
|
1007 |
width.Reset(); |
|
1008 |
||
1009 |
||
1010 |
}// End of mandatory argument url |
|
1011 |
else |
|
1012 |
{ |
|
1013 |
posbasedparam.Reset(); |
|
1014 |
AppendErrorMessageL( KGetThumbnail, KUrl, KMissing ); |
|
1015 |
User::Leave(KErrNotFound); |
|
1016 |
} |
|
1017 |
posbasedparam.Reset(); |
|
1018 |
||
1019 |
} |