author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 Aug 2009 07:43:07 +0300 | |
changeset 10 | fc9cf246af83 |
parent 5 | 989d2f495d90 |
child 23 | 50974a8b132e |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2006-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: Provides interface between the AIW FrameWork and Service Provider. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <LiwVariant.h> |
|
19 |
#include <LiwGenericParam.h> |
|
20 |
#include <LiwCommon.h> |
|
21 |
||
22 |
#include <CVPbkContactLinkArray.h> |
|
23 |
#include <CVPbkContactStoreUriArray.h> |
|
24 |
#include <CVPbkContactManager.h> |
|
25 |
#include <MVPbkContactStoreList.h> |
|
26 |
#include <TVPbkContactStoreUriPtr.h> |
|
27 |
#include <MVPbkContactLink.h> |
|
28 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
29 |
#include <f32file.h> |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
30 |
#include <e32des16.h> |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
31 |
#include <e32base.h> |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
32 |
#include <e32svr.h> |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
33 |
|
5 | 34 |
// User Includes |
35 |
#include "contactservice.h" |
|
36 |
#include "contactinterface.h" |
|
37 |
#include "contactinterfacecallback.h" |
|
38 |
#include "searchfields.h" |
|
39 |
#include "contactservice.hrh" |
|
40 |
#include "contacterrormessage.hrh" |
|
41 |
#include "../../inc/serviceerrno.h" |
|
42 |
#include "contactsmaxlength.h" |
|
43 |
||
44 |
using namespace LIW; |
|
45 |
||
46 |
#define KMissingArg -100 |
|
47 |
||
48 |
/* |
|
49 |
----------------------------------------------------------------------------- |
|
50 |
CContactInterface::CContactInterface() |
|
51 |
Description : Constructor |
|
52 |
Return values : N/A |
|
53 |
----------------------------------------------------------------------------- |
|
54 |
*/ |
|
55 |
CContactInterface::CContactInterface() |
|
56 |
: iContactService( NULL ), |
|
57 |
iErrorMess(NULL), |
|
58 |
iDburi(NULL) |
|
59 |
{ |
|
60 |
} |
|
61 |
||
62 |
/* |
|
63 |
----------------------------------------------------------------------------- |
|
64 |
void CContactInterface::ConstructL() |
|
65 |
Description : Symbian 2nd phase constructor can leave. |
|
66 |
Return values : N/A |
|
67 |
----------------------------------------------------------------------------- |
|
68 |
*/ |
|
69 |
void CContactInterface::ConstructL() |
|
70 |
{ |
|
71 |
iContactService = CContactService::NewL(); |
|
72 |
iErrorMess = HBufC::NewL(250); |
|
73 |
} |
|
74 |
/* |
|
75 |
----------------------------------------------------------------------------- |
|
76 |
CContactInterface* CContactInterface::NewL() |
|
77 |
Description : Two-phased constructor. |
|
78 |
Return values : CContactInterface object pointer |
|
79 |
||
80 |
----------------------------------------------------------------------------- |
|
81 |
*/ |
|
82 |
EXPORT_C CContactInterface* CContactInterface::NewL() |
|
83 |
{ |
|
84 |
CContactInterface* self = new ( ELeave ) CContactInterface(); |
|
85 |
CleanupStack::PushL( self ); |
|
86 |
self->ConstructL(); |
|
87 |
CleanupStack::Pop( self ); |
|
88 |
return self; |
|
89 |
} |
|
90 |
/* |
|
91 |
----------------------------------------------------------------------------- |
|
92 |
CContactInterface::~CContactInterface() |
|
93 |
Description : Destructor, free allocated resources |
|
94 |
Return values : N/A |
|
95 |
----------------------------------------------------------------------------- |
|
96 |
*/ |
|
97 |
CContactInterface::~CContactInterface() |
|
98 |
{ |
|
99 |
delete iContactService; |
|
100 |
delete iErrorMess; |
|
101 |
delete iDburi; |
|
102 |
iCallbackMap.ResetAndDestroy(); |
|
103 |
iCallbackMap.Close(); |
|
104 |
} |
|
105 |
||
106 |
/* |
|
107 |
----------------------------------------------------------------------------- |
|
108 |
CContactInterface::GetFieldMaxLength() |
|
109 |
Description : Gets the max length of the field. |
|
110 |
Return values : MaxLength |
|
111 |
----------------------------------------------------------------------------- |
|
112 |
*/ |
|
113 |
||
114 |
TInt CContactInterface :: GetFieldMaxLength(TInt aFieldKeyID, TDesC& aDbUri) |
|
115 |
{ |
|
116 |
TInt fieldmaxlength = -1; |
|
117 |
switch(aFieldKeyID) |
|
118 |
{ |
|
119 |
case R_VPBK_FIELD_TYPE_LASTNAME : |
|
120 |
case R_VPBK_FIELD_TYPE_FIRSTNAME : |
|
121 |
case R_VPBK_FIELD_TYPE_SECONDNAME : |
|
122 |
case R_VPBK_FIELD_TYPE_DEPARTMENT : |
|
123 |
case R_VPBK_FIELD_TYPE_JOBTITLE : |
|
124 |
case R_VPBK_FIELD_TYPE_ASSTNAME : |
|
125 |
case R_VPBK_FIELD_TYPE_ASSTPHONE : |
|
126 |
case R_VPBK_FIELD_TYPE_SPOUSE : |
|
127 |
case R_VPBK_FIELD_TYPE_CHILDREN : |
|
128 |
case R_VPBK_FIELD_TYPE_COMPANYNAME : |
|
129 |
case R_VPBK_FIELD_TYPE_MIDDLENAME : |
|
130 |
case R_VPBK_FIELD_TYPE_ADDRSTREETGEN: |
|
131 |
case R_VPBK_FIELD_TYPE_ADDRSTREETHOME: |
|
132 |
case R_VPBK_FIELD_TYPE_ADDRSTREETWORK: |
|
133 |
case R_VPBK_FIELD_TYPE_ADDRLOCALGEN : |
|
134 |
case R_VPBK_FIELD_TYPE_ADDRLOCALHOME: |
|
135 |
case R_VPBK_FIELD_TYPE_ADDRLOCALWORK: |
|
136 |
case R_VPBK_FIELD_TYPE_ADDRREGIONGEN: |
|
137 |
case R_VPBK_FIELD_TYPE_ADDRREGIONHOME: |
|
138 |
case R_VPBK_FIELD_TYPE_ADDRREGIONWORK: |
|
139 |
case R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN: |
|
140 |
case R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME: |
|
141 |
case R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK: |
|
142 |
case R_VPBK_FIELD_TYPE_ADDREXTGEN: |
|
143 |
case R_VPBK_FIELD_TYPE_ADDREXTHOME: |
|
144 |
case R_VPBK_FIELD_TYPE_ADDREXTWORK: |
|
145 |
{ |
|
146 |
// a very bad fix for sim case |
|
147 |
if(aFieldKeyID == R_VPBK_FIELD_TYPE_LASTNAME && (aDbUri.CompareF(KSimDataBaseOne) == 0)) |
|
148 |
{ |
|
149 |
//comparing the database uri for sim and setting the length |
|
150 |
fieldmaxlength = KMaLengthFourteen; |
|
151 |
} |
|
152 |
else |
|
153 |
{ |
|
154 |
fieldmaxlength = KMaxLengthFifty; |
|
155 |
} |
|
156 |
break; |
|
157 |
} |
|
158 |
||
159 |
case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN : |
|
160 |
case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME : |
|
161 |
case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK : |
|
162 |
case R_VPBK_FIELD_TYPE_LANDPHONEGEN : |
|
163 |
case R_VPBK_FIELD_TYPE_LANDPHONEHOME : |
|
164 |
case R_VPBK_FIELD_TYPE_LANDPHONEWORK : |
|
165 |
case R_VPBK_FIELD_TYPE_VIDEONUMBERHOME : |
|
166 |
case R_VPBK_FIELD_TYPE_VIDEONUMBERWORK : |
|
167 |
case R_VPBK_FIELD_TYPE_VIDEONUMBERGEN : |
|
168 |
case R_VPBK_FIELD_TYPE_CARPHONE : |
|
169 |
case R_VPBK_FIELD_TYPE_PAGERNUMBER : |
|
170 |
case R_VPBK_FIELD_TYPE_FAXNUMBERHOME : |
|
171 |
case R_VPBK_FIELD_TYPE_FAXNUMBERWORK : |
|
172 |
case R_VPBK_FIELD_TYPE_FAXNUMBERGEN : |
|
173 |
{ |
|
174 |
fieldmaxlength = KMaxLengthFourtyEight; |
|
175 |
break; |
|
176 |
} |
|
177 |
case R_VPBK_FIELD_TYPE_ADDRPOGEN : |
|
178 |
case R_VPBK_FIELD_TYPE_ADDRPOHOME : |
|
179 |
case R_VPBK_FIELD_TYPE_ADDRPOWORK : |
|
180 |
case R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN : |
|
181 |
case R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME : |
|
182 |
case R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK : |
|
183 |
{ |
|
184 |
fieldmaxlength = KMaxLengthTwenty; |
|
185 |
break; |
|
186 |
} |
|
187 |
case R_VPBK_FIELD_TYPE_PREFIX: |
|
188 |
case R_VPBK_FIELD_TYPE_SUFFIX: |
|
189 |
{ |
|
190 |
fieldmaxlength = KMaxLengthTen; |
|
191 |
break; |
|
192 |
} |
|
193 |
||
194 |
case R_VPBK_FIELD_TYPE_DTMFSTRING: |
|
195 |
{ |
|
196 |
fieldmaxlength = KMaxLengthSixty; |
|
197 |
break; |
|
198 |
} |
|
199 |
||
200 |
case R_VPBK_FIELD_TYPE_SIP: |
|
201 |
case R_VPBK_FIELD_TYPE_POC: |
|
202 |
case R_VPBK_FIELD_TYPE_VOIPHOME: |
|
203 |
case R_VPBK_FIELD_TYPE_VOIPWORK: |
|
204 |
case R_VPBK_FIELD_TYPE_VOIPGEN: |
|
205 |
case R_VPBK_FIELD_TYPE_SWIS: |
|
206 |
{ |
|
207 |
fieldmaxlength = KMaxLengthHundred; |
|
208 |
break; |
|
209 |
} |
|
210 |
case R_VPBK_FIELD_TYPE_EMAILGEN : |
|
211 |
case R_VPBK_FIELD_TYPE_EMAILWORK: |
|
212 |
case R_VPBK_FIELD_TYPE_EMAILHOME: |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
213 |
case R_VPBK_FIELD_TYPE_IMPP: |
5 | 214 |
{ |
215 |
fieldmaxlength = KMaxLengthOneHundredAndFifty; |
|
216 |
break; |
|
217 |
} |
|
218 |
case R_VPBK_FIELD_TYPE_ADDRLABELHOME: |
|
219 |
case R_VPBK_FIELD_TYPE_ADDRLABELGEN: |
|
220 |
case R_VPBK_FIELD_TYPE_ADDRLABELWORK : |
|
221 |
{ |
|
222 |
fieldmaxlength = KMaxLengthTwoHundredAndFifty; |
|
223 |
break; |
|
224 |
} |
|
225 |
case R_VPBK_FIELD_TYPE_LOCPRIVACY: |
|
226 |
case R_VPBK_FIELD_TYPE_RINGTONE: |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
227 |
case R_VPBK_FIELD_TYPE_CALLEROBJIMG: |
5 | 228 |
{ |
229 |
fieldmaxlength = KMaxLengthTwoHundredAndFiftySix; |
|
230 |
break; |
|
231 |
} |
|
232 |
case R_VPBK_FIELD_TYPE_URLWORK: |
|
233 |
case R_VPBK_FIELD_TYPE_URLHOME: |
|
234 |
case R_VPBK_FIELD_TYPE_URLGEN: |
|
235 |
case R_VPBK_FIELD_TYPE_NOTE: |
|
236 |
case R_VPBK_FIELD_TYPE_SYNCCLASS: |
|
237 |
{ |
|
238 |
fieldmaxlength = KMaxLengthThousand; |
|
239 |
break; |
|
240 |
} |
|
241 |
} |
|
242 |
return fieldmaxlength; |
|
243 |
} |
|
244 |
||
245 |
/* |
|
246 |
----------------------------------------------------------------------------- |
|
247 |
CContactInterface::ExecuteCmdL() |
|
248 |
Description : This is called by the consumer with command to execute. |
|
249 |
Return values : N/A |
|
250 |
----------------------------------------------------------------------------- |
|
251 |
*/ |
|
252 |
EXPORT_C void CContactInterface:: |
|
253 |
ExecuteCmdL(const TDesC8& aCmdName, |
|
254 |
const CLiwGenericParamList& aInParamList, |
|
255 |
CLiwGenericParamList& aOutParamList, |
|
256 |
TUint aCmdOptions, |
|
257 |
MLiwNotifyCallback* aCallback) |
|
258 |
{ |
|
259 |
//Top level TRAP for all the api's |
|
260 |
TRAPD(returnCode, |
|
261 |
ProcessCmdL(aCmdName, |
|
262 |
aInParamList, |
|
263 |
aOutParamList, |
|
264 |
aCmdOptions, |
|
265 |
aCallback)); |
|
266 |
//append the appropriate error code. |
|
267 |
TInt32 SapiErr = SapiError(returnCode); |
|
268 |
aOutParamList.AppendL(TLiwGenericParam(KErrorCode, |
|
269 |
TLiwVariant((TInt32)SapiErr))); |
|
270 |
} |
|
271 |
||
272 |
/* |
|
273 |
--------------------------------------------------------------------------- |
|
274 |
CContactInterface::SapiError(err) |
|
275 |
Description :This function is called by the user to get mapped SAPI |
|
276 |
generic error code from symbian error codes. |
|
277 |
Return values :Integer Value TInt. |
|
278 |
--------------------------------------------------------------------------- |
|
279 |
*/ |
|
280 |
TInt CContactInterface::SapiError( TInt aSymbianErr ) |
|
281 |
{ |
|
282 |
TInt sapiErr(SErrGeneralError); |
|
283 |
||
284 |
switch (aSymbianErr) |
|
285 |
{ |
|
286 |
case KErrBadName: |
|
287 |
case KErrArgument: |
|
288 |
{ |
|
289 |
sapiErr = SErrBadArgumentType; |
|
290 |
break; |
|
291 |
} |
|
292 |
case KErrNotSupported: |
|
293 |
{ |
|
294 |
sapiErr = SErrServiceNotSupported; |
|
295 |
break; |
|
296 |
} |
|
297 |
case KErrInUse: |
|
298 |
{ |
|
299 |
sapiErr = SErrServiceInUse; |
|
300 |
break; |
|
301 |
} |
|
302 |
case KErrAccessDenied: |
|
303 |
{ |
|
304 |
sapiErr = SErrAccessDenied; |
|
305 |
break; |
|
306 |
} |
|
307 |
case KErrNoMemory: |
|
308 |
{ |
|
309 |
sapiErr = SErrNoMemory; |
|
310 |
break; |
|
311 |
} |
|
312 |
case KErrAlreadyExists: |
|
313 |
{ |
|
314 |
sapiErr = SErrEntryExists; |
|
315 |
break; |
|
316 |
} |
|
317 |
case KErrNotReady: |
|
318 |
{ |
|
319 |
sapiErr = SErrServiceNotReady; |
|
320 |
break; |
|
321 |
} |
|
322 |
case KErrNotFound: |
|
323 |
{ |
|
324 |
sapiErr = SErrNotFound; |
|
325 |
break; |
|
326 |
} |
|
327 |
case KErrNone: |
|
328 |
{ |
|
329 |
sapiErr = SErrNone; |
|
330 |
break; |
|
331 |
} |
|
332 |
case KErrPathNotFound: |
|
333 |
{ |
|
334 |
sapiErr = SErrPathNotFound; |
|
335 |
break; |
|
336 |
} |
|
337 |
case KMissingArg: |
|
338 |
{ |
|
339 |
sapiErr = SErrMissingArgument; |
|
340 |
break; |
|
341 |
} |
|
342 |
default: |
|
343 |
{ |
|
344 |
sapiErr = SErrGeneralError; |
|
345 |
} |
|
346 |
} |
|
347 |
return sapiErr; |
|
348 |
} |
|
349 |
||
350 |
/* |
|
351 |
----------------------------------------------------------------------------- |
|
352 |
CContactInterface::Close() |
|
353 |
Description : This is called by the consumer to delete the handle. |
|
354 |
Return values : N/A |
|
355 |
----------------------------------------------------------------------------- |
|
356 |
*/ |
|
357 |
void CContactInterface::Close() |
|
358 |
{ |
|
359 |
delete this; |
|
360 |
} |
|
361 |
||
362 |
/* |
|
363 |
----------------------------------------------------------------------------- |
|
364 |
CContactInterface::ContactIDUTFToStreamL() |
|
365 |
Description : This method is used to convert the UTF to stream. |
|
366 |
Return values : N/A |
|
367 |
----------------------------------------------------------------------------- |
|
368 |
*/ |
|
369 |
HBufC8* CContactInterface::ContactIDUTFToStreamL(TDesC& aContactIDUTF) |
|
370 |
{ |
|
371 |
TInt len = aContactIDUTF.Length(); |
|
372 |
HBufC8* buf = HBufC8 :: NewL(len); |
|
373 |
buf->Des().SetLength(len); |
|
374 |
TUint16* ptr = const_cast<TUint16*>(aContactIDUTF.Ptr()); |
|
375 |
TUint8* ptr8 = const_cast<TUint8*>(buf->Des().Ptr()); |
|
376 |
||
377 |
for(TInt i=0; i<len; i++) |
|
378 |
{ |
|
379 |
TUint c = ptr[i]; |
|
380 |
if(c>=0x100) |
|
381 |
c = c & 0x00ff; |
|
382 |
ptr8[i] = (TUint8)c; |
|
383 |
} |
|
384 |
return buf; |
|
385 |
} |
|
386 |
||
387 |
/* |
|
388 |
----------------------------------------------------------------------------- |
|
389 |
CContactInterface::ProcessAddDataL(const CLiwMap* aMap, |
|
390 |
TPtrC& aDbUri, |
|
391 |
CSingleContact* aContact) |
|
392 |
Description : Constructs a contact from the fields that exist in the map.. |
|
393 |
Return values : N/A |
|
394 |
----------------------------------------------------------------------------- |
|
395 |
*/ |
|
396 |
||
397 |
void CContactInterface::ProcessAddDataL(const CLiwMap* aMap, |
|
398 |
CSingleContact* aContact, |
|
399 |
CLiwGenericParamList& aOutParamList) |
|
400 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
401 |
TBool xspid = EFalse; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
402 |
TBool xspidIsDes = EFalse; |
5 | 403 |
TBool atleastOneField = EFalse; |
404 |
iDburi = HBufC::NewL(VPbkContactStoreUris::DefaultCntDbUri().Length()); |
|
405 |
//set the DBUri to the default value. |
|
406 |
iDburi->Des().Copy(VPbkContactStoreUris::DefaultCntDbUri()); |
|
407 |
//get the number of entries in the map |
|
408 |
TInt keyCount = aMap->Count(); |
|
409 |
||
410 |
for(TInt index=0;index<keyCount;index++) |
|
411 |
{ |
|
412 |
//iterate through each entry in the map |
|
413 |
//starting from the first element |
|
414 |
||
415 |
//this variable should be reemoved |
|
416 |
//when the AtL signature is changed in LIW. |
|
417 |
TBuf8<KMaxName> fieldKey; |
|
418 |
TLiwVariant fieldVal; |
|
419 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup ,&fieldVal) ); |
|
420 |
||
421 |
//AtL gives us the key stored at a particular index |
|
422 |
aMap->AtL(index, fieldKey); |
|
423 |
//check whether the key is DBUri |
|
424 |
//if it is extract it and mark it. |
|
425 |
if( fieldKey.Compare(KDBUri) == 0 ) |
|
426 |
{ |
|
427 |
//get the DBUri from the map |
|
428 |
if(aMap->FindL(fieldKey, fieldVal)) |
|
429 |
{ |
|
430 |
if(fieldVal.AsDes().CompareF(KNullDesC)!=0) |
|
431 |
{ |
|
432 |
delete iDburi; |
|
433 |
iDburi = NULL; |
|
434 |
iDburi = HBufC::NewL(fieldVal.AsDes().Length()); |
|
435 |
iDburi->Des().Copy(fieldVal.AsDes()); |
|
436 |
} |
|
437 |
} |
|
438 |
} |
|
439 |
else if( fieldKey.Compare(KContactId) == 0 ) |
|
440 |
{ |
|
441 |
//get the contact ID from the map |
|
442 |
if(aMap->FindL(fieldKey, fieldVal)) |
|
443 |
{ |
|
444 |
TPtrC cntIdUnicode = fieldVal.AsDes(); |
|
445 |
if(cntIdUnicode == NULL) |
|
446 |
{ |
|
447 |
aOutParamList.AppendL(TLiwGenericParam (KErrorMessage, |
|
448 |
TLiwVariant(KAddWrongContactId))); |
|
449 |
User::Leave(KErrArgument); |
|
450 |
} |
|
451 |
||
452 |
HBufC8* cntid = ContactIDUTFToStreamL(cntIdUnicode); |
|
453 |
aContact->SetContactIdL(*cntid); |
|
454 |
delete cntid; |
|
455 |
} |
|
456 |
} |
|
457 |
else |
|
458 |
{ |
|
459 |
//if the key is not uri and is not a contact id |
|
460 |
//search for the field |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
461 |
if(CSearchFields::GetIdFromFieldKey(fieldKey) != -1) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
462 |
/* { |
5 | 463 |
TBuf<25> buff; |
464 |
buff.Copy(fieldKey); |
|
465 |
TBuf<KMaxName> errmsg(KAddInvalidFieldKey); |
|
466 |
errmsg.Append(buff); |
|
467 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
468 |
TLiwVariant(errmsg))); |
|
469 |
User::Leave(KErrArgument); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
470 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
471 |
else*/ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
472 |
{ |
5 | 473 |
aMap->FindL(fieldKey,fieldVal); |
474 |
if(EVariantTypeMap == fieldVal.TypeId()) |
|
475 |
{ |
|
476 |
const CLiwMap* pMap = fieldVal.AsMap(); |
|
477 |
if(pMap) |
|
478 |
{ |
|
479 |
TLiwVariant labelVar; |
|
480 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &labelVar) ); |
|
481 |
||
482 |
TLiwVariant valueVar; |
|
483 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueVar) ); |
|
484 |
||
485 |
TLiwVariant nextVar; |
|
486 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &nextVar) ); |
|
487 |
while(1) |
|
488 |
{ |
|
489 |
//Get field label and value from map |
|
490 |
if(pMap->FindL(KFieldLabel, labelVar)) |
|
491 |
{ |
|
492 |
if(EVariantTypeDesC != labelVar.TypeId()) |
|
493 |
{ |
|
494 |
TPtr16 err(iErrorMess->Des()); |
|
495 |
TBuf<KMaxName> buf; |
|
496 |
buf.Copy(labelVar.AsData()); |
|
497 |
err.Append(KAddCnt); |
|
498 |
err.Append(buf); |
|
499 |
err.Append(KAddInvalidStr); |
|
500 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(*iErrorMess) ) ); |
|
501 |
CleanupStack::Pop(&nextVar); |
|
502 |
nextVar.Reset(); |
|
503 |
CleanupStack::Pop(&valueVar); |
|
504 |
valueVar.Reset(); |
|
505 |
CleanupStack::Pop(&labelVar); |
|
506 |
labelVar.Reset(); |
|
507 |
CleanupStack::Pop(&fieldVal); |
|
508 |
fieldVal.Reset(); |
|
509 |
err.Delete(0,iErrorMess->Length()); |
|
510 |
User::Leave(KErrArgument); |
|
511 |
} |
|
512 |
} |
|
513 |
TBool date = EFalse; |
|
514 |
//Set contact item field value |
|
515 |
if(pMap->FindL(KFieldValue, valueVar)) |
|
516 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
517 |
if(fieldKey.Compare(KXspid) == 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
518 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
519 |
xspid = ETrue; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
520 |
if(EVariantTypeList != valueVar.TypeId()) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
521 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
522 |
if(EVariantTypeDesC == valueVar.TypeId()) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
523 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
524 |
//xspidIsDes = ETrue; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
525 |
CLiwList* xspidList = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
526 |
xspidList = CLiwDefaultList::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
527 |
/* TPtrC val = valueVar.AsDes(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
528 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
529 |
TBuf<1000> bufVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
530 |
bufVal.Copy(val); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
531 |
HBufC* xspidVal = bufVal.AllocLC();*/ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
532 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
533 |
xspidList->AppendL(valueVar); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
534 |
valueVar.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
535 |
valueVar.Set(xspidList); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
536 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
537 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
538 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
539 |
TPtr16 err(iErrorMess->Des()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
540 |
TBuf<KMaxName> buf; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
541 |
buf.Copy(valueVar.AsData()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
542 |
err.Append(KAddCnt); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
543 |
err.Append(buf); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
544 |
err.Append(KAddInvalidTime); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
545 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
546 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(*iErrorMess) ) ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
547 |
CleanupStack::Pop(&nextVar); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
548 |
nextVar.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
549 |
CleanupStack::Pop(&valueVar); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
550 |
valueVar.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
551 |
CleanupStack::Pop(&labelVar); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
552 |
labelVar.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
553 |
CleanupStack::Pop(&fieldVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
554 |
fieldVal.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
555 |
err.Delete(0,iErrorMess->Length()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
556 |
User::Leave(KErrArgument); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
557 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
558 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
559 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
560 |
if((fieldKey.Compare(KDate) == 0 || (fieldKey.Compare(KAnniversary) == 0))) // || (fieldKey.Compare(KBirthDay) == 0)) |
5 | 561 |
{ |
562 |
if(EVariantTypeTTime != valueVar.TypeId()) |
|
563 |
{ |
|
564 |
TPtr16 err(iErrorMess->Des()); |
|
565 |
TBuf<KMaxName> buf; |
|
566 |
buf.Copy(valueVar.AsData()); |
|
567 |
err.Append(KAddCnt); |
|
568 |
err.Append(buf); |
|
569 |
err.Append(KAddInvalidTime); |
|
570 |
||
571 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(*iErrorMess) ) ); |
|
572 |
CleanupStack::Pop(&nextVar); |
|
573 |
nextVar.Reset(); |
|
574 |
CleanupStack::Pop(&valueVar); |
|
575 |
valueVar.Reset(); |
|
576 |
CleanupStack::Pop(&labelVar); |
|
577 |
labelVar.Reset(); |
|
578 |
CleanupStack::Pop(&fieldVal); |
|
579 |
fieldVal.Reset(); |
|
580 |
err.Delete(0,iErrorMess->Length()); |
|
581 |
User::Leave(KErrArgument); |
|
582 |
} |
|
583 |
date = ETrue; |
|
584 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
585 |
if((EVariantTypeDesC != valueVar.TypeId()) && (date == EFalse) && (xspid == EFalse)) |
5 | 586 |
{ |
587 |
TPtr16 err(iErrorMess->Des()); |
|
588 |
TBuf<KMaxName> buf; |
|
589 |
buf.Copy(valueVar.AsData()); |
|
590 |
err.Append(KAddCnt); |
|
591 |
err.Append(buf); |
|
592 |
err.Append(KAddInvalidStr); |
|
593 |
||
594 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(*iErrorMess) ) ); |
|
595 |
CleanupStack::Pop(&nextVar); |
|
596 |
nextVar.Reset(); |
|
597 |
CleanupStack::Pop(&valueVar); |
|
598 |
valueVar.Reset(); |
|
599 |
CleanupStack::Pop(&labelVar); |
|
600 |
labelVar.Reset(); |
|
601 |
CleanupStack::Pop(&fieldVal); |
|
602 |
fieldVal.Reset(); |
|
603 |
err.Delete(0,iErrorMess->Length()); |
|
604 |
User::Leave(KErrArgument); |
|
605 |
} |
|
606 |
} |
|
607 |
CSingleContactField* field = |
|
608 |
CSingleContactField::NewL(); |
|
609 |
CleanupStack::PushL(field); |
|
610 |
if(date) |
|
611 |
{ |
|
612 |
field->SetFieldParamsL(fieldKey, |
|
613 |
labelVar.AsDes(), |
|
614 |
KNullDesC); |
|
615 |
field->SetDateTime(valueVar.AsTTime()); |
|
616 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
617 |
else if(xspid && !xspidIsDes) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
618 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
619 |
RPointerArray<HBufC> xspidArray; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
620 |
const CLiwList* xspidList = valueVar.AsList(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
621 |
TInt count = xspidList->Count(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
622 |
for(int i =0; i< count; i++) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
623 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
624 |
TLiwVariant xspidVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
625 |
if(xspidList->AtL(i,xspidVal)) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
626 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
627 |
TPtrC ptrVal = xspidVal.AsDes(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
628 |
HBufC *pHeap1 = ptrVal.AllocLC(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
629 |
xspidArray.Append(pHeap1); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
630 |
TInt len = pHeap1->Find(_L(":")); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
631 |
if(len == -1) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
632 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
633 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
634 |
TLiwVariant(KAddXspidInvalidFormat))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
635 |
User::Leave(KErrArgument); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
636 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
637 |
CleanupStack::Pop(pHeap1); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
638 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
639 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
640 |
field->SetXspidDataL(fieldKey, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
641 |
labelVar.AsDes(), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
642 |
xspidArray); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
643 |
xspid = EFalse; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
644 |
} |
5 | 645 |
else |
646 |
{ |
|
647 |
field->SetFieldParamsL(fieldKey, |
|
648 |
labelVar.AsDes(), |
|
649 |
valueVar.AsDes()); |
|
650 |
||
651 |
} |
|
652 |
aContact->AddFieldToContactL(field); |
|
653 |
atleastOneField = ETrue; |
|
654 |
CleanupStack::Pop(field); |
|
655 |
if(pMap->FindL(KFieldNext,nextVar)) |
|
656 |
{ |
|
657 |
if(EVariantTypeMap == nextVar.TypeId()) |
|
658 |
{ |
|
659 |
pMap = nextVar.AsMap(); |
|
660 |
} |
|
661 |
else |
|
662 |
{ |
|
663 |
//if the map is not found |
|
664 |
//Leave with the error code |
|
665 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
666 |
TLiwVariant(KAddNextFieldType))); |
|
667 |
User::Leave(KErrArgument); |
|
668 |
} |
|
669 |
} |
|
670 |
else //EVariantTypeNull |
|
671 |
{ |
|
672 |
break; |
|
673 |
} |
|
674 |
} //end of while |
|
675 |
CleanupStack::Pop(&nextVar); |
|
676 |
nextVar.Reset(); |
|
677 |
CleanupStack::Pop(&valueVar); |
|
678 |
valueVar.Reset(); |
|
679 |
CleanupStack::Pop(&labelVar); |
|
680 |
labelVar.Reset(); |
|
681 |
} |
|
682 |
else |
|
683 |
{ |
|
684 |
//if the map is not found |
|
685 |
//Leave with the error code |
|
686 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
687 |
TLiwVariant(KAddInvalidFieldType))); |
|
688 |
User::Leave(KErrArgument); |
|
689 |
} |
|
690 |
} |
|
691 |
else |
|
692 |
{ |
|
693 |
CleanupStack::Pop(&fieldVal); |
|
694 |
fieldVal.Reset(); |
|
695 |
TPtr16 err(iErrorMess->Des()); |
|
696 |
TBuf<KMaxName> fld; |
|
697 |
fld.Copy(fieldKey); |
|
698 |
err.Append(fld); |
|
699 |
err.Append(_L(",Invalid Type,Map is Required")); |
|
700 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage, |
|
701 |
TLiwVariant(*iErrorMess) ) ); |
|
702 |
err.Delete(0,iErrorMess->Length()); |
|
703 |
User::Leave(KErrArgument); |
|
704 |
||
705 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
706 |
} |
5 | 707 |
} |
708 |
CleanupStack::Pop(&fieldVal); |
|
709 |
fieldVal.Reset(); |
|
710 |
} //end of for |
|
711 |
//checking for the maximum length (this is a temporary check since there is no support from vpbk) |
|
712 |
CSingleContactField* contactfield = NULL; |
|
713 |
TPtrC8 fieldKey(KNullDesC8); |
|
714 |
TPtrC fieldLabel(KNullDesC); |
|
715 |
TPtrC fieldValue(KNullDesC); |
|
716 |
TInt fieldCount = aContact->FieldCount(); |
|
717 |
for( TInt i=0;i<fieldCount;i++ ) |
|
718 |
{ |
|
719 |
contactfield = aContact->FieldAt(i); |
|
720 |
if(contactfield) |
|
721 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
722 |
contactfield->GetFieldDataL(fieldKey, fieldLabel, fieldValue); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
723 |
if(fieldKey.Compare(KXspid) == 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
724 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
725 |
RPointerArray<HBufC> xspidArr; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
726 |
contactfield->GetXspidDataL(xspidArr); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
727 |
for(TInt j=0;j<xspidArr.Count(); j++) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
728 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
729 |
HBufC* xspidVal = xspidArr[j]; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
730 |
//HBufC* xspidBufVal = xspidVal.AllocL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
731 |
if(xspidVal->Length() > GetFieldMaxLength(CSearchFields::GetIdFromFieldKey(fieldKey), *iDburi)) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
732 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
733 |
TPtr16 err(iErrorMess->Des()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
734 |
TBuf<KMaxName> fld; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
735 |
fld.Copy(fieldKey); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
736 |
err.Append(_L("Contacts : Add : Field Value too long for key : ")); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
737 |
err.Append(fld); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
738 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
739 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
740 |
TLiwVariant(*iErrorMess))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
741 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
742 |
err.Delete(0,iErrorMess->Length()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
743 |
User::Leave(KErrArgument); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
744 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
745 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
746 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
747 |
else if(!(fieldKey.Compare(KDate) == 0 || fieldKey.Compare(KAnniversary) == 0)) |
5 | 748 |
{ |
749 |
if(fieldValue.Length() > GetFieldMaxLength(CSearchFields::GetIdFromFieldKey(fieldKey), *iDburi)) |
|
750 |
{ |
|
751 |
TPtr16 err(iErrorMess->Des()); |
|
752 |
TBuf<KMaxName> fld; |
|
753 |
fld.Copy(fieldKey); |
|
754 |
err.Append(_L("Contacts : Add : Field Value too long for key : ")); |
|
755 |
err.Append(fld); |
|
756 |
||
757 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
758 |
TLiwVariant(*iErrorMess))); |
|
759 |
||
760 |
err.Delete(0,iErrorMess->Length()); |
|
761 |
User::Leave(KErrArgument); |
|
762 |
} |
|
763 |
||
764 |
} |
|
765 |
} |
|
766 |
||
767 |
} |
|
768 |
||
769 |
if(atleastOneField == EFalse) |
|
770 |
{ |
|
771 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
772 |
TLiwVariant(KAddKeyNotSpecified))); |
|
773 |
User::Leave(KErrArgument); |
|
774 |
} |
|
775 |
} //End of function : ProcessAddDataL() |
|
776 |
||
777 |
||
778 |
/* |
|
779 |
----------------------------------------------------------------------------- |
|
780 |
CContactInterface::ProcessCmdL(const TDesC8& aCmdName, |
|
781 |
const CLiwGenericParamList& aInParamList, |
|
782 |
CLiwGenericParamList& aOutParamList, |
|
783 |
TUint aCmdOptions, |
|
784 |
MLiwNotifyCallback* aCallback ) |
|
785 |
Description : This function processes the commands like add, delete, organise, |
|
786 |
getlist.....etc. |
|
787 |
Return values : N/A |
|
788 |
----------------------------------------------------------------------------- |
|
789 |
*/ |
|
790 |
void CContactInterface::ProcessCmdL(const TDesC8& aCmdName, |
|
791 |
const CLiwGenericParamList& aInParamList, |
|
792 |
CLiwGenericParamList& aOutParamList, |
|
793 |
TUint aCmdOptions, |
|
794 |
MLiwNotifyCallback* aCallback ) |
|
795 |
{ |
|
796 |
TInt returnCode = KErrNone; |
|
797 |
TInt transId = 0; |
|
798 |
//if callback parameter is not null then retrieve the transaction id. |
|
799 |
if(aCallback && aCmdOptions == KLiwOptASyncronous) |
|
800 |
{ |
|
801 |
transId = aCallback->GetTransactionID(); |
|
802 |
||
803 |
CContactCallbackMap* map = |
|
804 |
new (ELeave) CContactCallbackMap(transId, |
|
805 |
aCallback); |
|
806 |
CleanupStack::PushL(map); |
|
807 |
iCallbackMap.AppendL(map); |
|
808 |
CleanupStack::Pop(map); |
|
809 |
||
810 |
//In case of async calls, also set the transaction id |
|
811 |
aOutParamList.AppendL(TLiwGenericParam(KTransactionID, |
|
812 |
TLiwVariant((TInt32)transId))); |
|
813 |
||
814 |
} |
|
815 |
else if((aCmdOptions == KLiwOptASyncronous) && (!aCallback)) |
|
816 |
{ |
|
817 |
//Leave with the error code |
|
818 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
819 |
TLiwVariant(KCallbackNotFound))); |
|
820 |
User::Leave(KErrArgument); |
|
821 |
} |
|
822 |
else if(aCallback && (aCmdOptions == 0)) |
|
823 |
{ |
|
824 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
825 |
TLiwVariant(KCallbackNotFound))); |
|
826 |
User::Leave(KErrArgument); |
|
827 |
||
828 |
} |
|
829 |
||
830 |
if( aCmdName.CompareF(KCmdCancel) == 0) // for cancel asynchronous request |
|
831 |
{ |
|
832 |
if(aCmdOptions != KLiwOptCancel) |
|
833 |
{ |
|
834 |
//Leave with the error code |
|
835 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
836 |
TLiwVariant(KCancleCommandoptionWrong))); |
|
837 |
User::Leave(KErrArgument); |
|
838 |
||
839 |
} |
|
840 |
returnCode = CancelCommandL(aInParamList, |
|
841 |
aOutParamList); |
|
842 |
if(returnCode != KErrNone) |
|
843 |
{ |
|
844 |
//Leave with the error code |
|
845 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
846 |
TLiwVariant(KCancelUnsuccessful))); |
|
847 |
User::Leave(returnCode); |
|
848 |
} |
|
849 |
} |
|
850 |
//check for the command name,...if Import proceed further. |
|
851 |
else if ( (aCmdName.CompareF( KCmdImport ) == 0)) |
|
852 |
{ |
|
853 |
ImportCommandL(aInParamList, |
|
854 |
aOutParamList, |
|
855 |
aCallback, |
|
856 |
aCmdOptions, |
|
857 |
transId); |
|
858 |
} |
|
859 |
//check for the command name,...if Export, proceed further. |
|
860 |
else if ( (aCmdName.CompareF( KCmdExport ) == 0)) |
|
861 |
{ |
|
862 |
ExportCommandL(aInParamList, |
|
863 |
aOutParamList, |
|
864 |
aCallback, |
|
865 |
aCmdOptions, |
|
866 |
transId); |
|
867 |
} |
|
868 |
//check for the command name,...if Add, proceed further. |
|
869 |
else if ( (aCmdName.CompareF( KCmdAdd ) == 0)) |
|
870 |
{ |
|
871 |
AddCommandL(aInParamList, |
|
872 |
aOutParamList, |
|
873 |
aCallback, |
|
874 |
aCmdOptions, |
|
875 |
transId); |
|
876 |
} |
|
877 |
//check for the command name,...if Delete, proceed further. |
|
878 |
else if ( (aCmdName.CompareF( KCmdDelete ) == 0)) |
|
879 |
{ |
|
880 |
DeleteCommandL(aInParamList, |
|
881 |
aOutParamList, |
|
882 |
aCallback, |
|
883 |
aCmdOptions, |
|
884 |
transId); |
|
885 |
} |
|
886 |
||
887 |
//check for the command name,...if OrganiseGroups, proceed further. |
|
888 |
else if ( (aCmdName.CompareF( KCmdOrganiseGroups ) == 0)) |
|
889 |
{ |
|
890 |
OrganiseGroupCommandL(aInParamList, |
|
891 |
aOutParamList, |
|
892 |
aCallback, |
|
893 |
aCmdOptions, |
|
894 |
transId); |
|
895 |
} |
|
896 |
//Passing arguments for GetList command |
|
897 |
else if( aCmdName.CompareF( KCmdGetList ) == 0 ) |
|
898 |
{ |
|
899 |
GetListCommandL(aInParamList, |
|
900 |
aOutParamList, |
|
901 |
aCallback, |
|
902 |
aCmdOptions, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
903 |
transId, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
904 |
EGetList); |
5 | 905 |
} |
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
906 |
//Passing arguments for GetIds command |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
907 |
else if( aCmdName.CompareF( KCmdGetIds ) == 0 ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
908 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
909 |
GetListCommandL(aInParamList, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
910 |
aOutParamList, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
911 |
aCallback, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
912 |
aCmdOptions, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
913 |
transId, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
914 |
EGetIds); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
915 |
} |
5 | 916 |
else |
917 |
{ |
|
918 |
//Leave with the error code |
|
919 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
920 |
TLiwVariant(KCommandNotSupported))); |
|
921 |
User::Leave(KErrNotSupported); |
|
922 |
} |
|
923 |
||
924 |
} //end of ProcessCmdL |
|
925 |
||
926 |
/* |
|
927 |
----------------------------------------------------------------------------- |
|
928 |
CContactInterface::GetListCommandL(const CLiwGenericParamList& aInParamList, |
|
929 |
CLiwGenericParamList& aOutParamList, |
|
930 |
MLiwNotifyCallback* aCallback, |
|
931 |
TUint aCmdOptions, |
|
932 |
TInt aTransId) |
|
933 |
Description : This function parses the input param list |
|
934 |
: and calls the Getlist API |
|
935 |
Return values : N/A |
|
936 |
----------------------------------------------------------------------------- |
|
937 |
*/ |
|
938 |
void CContactInterface:: |
|
939 |
GetListCommandL(const CLiwGenericParamList& aInParamList, |
|
940 |
CLiwGenericParamList& aOutParamList, |
|
941 |
MLiwNotifyCallback* aCallback, |
|
942 |
TUint aCmdOptions, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
943 |
TInt aTransId, TCmdType aVal) |
5 | 944 |
{ |
945 |
const TLiwGenericParam* paramContentType = NULL; |
|
946 |
const TLiwGenericParam* paramGetListData = NULL; |
|
947 |
const TLiwGenericParam* paramGetListSortOrder = NULL; |
|
948 |
||
949 |
TInt pos = 0; |
|
950 |
//Get the content type: it can be "contact" or "group" |
|
951 |
paramContentType = aInParamList.FindFirst( pos, KType ); |
|
952 |
if(!paramContentType) |
|
953 |
{ |
|
954 |
if(aInParamList.Count()>0) |
|
955 |
paramContentType = &aInParamList[0] ; |
|
956 |
||
957 |
if(!paramContentType || paramContentType->Name().Compare(KNullDesC8) != 0) |
|
958 |
{ |
|
959 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetListContentTypeMissing) ) ); |
|
960 |
User::Leave(KMissingArg); |
|
961 |
} |
|
962 |
if(aInParamList.Count()>1) |
|
963 |
paramGetListData = &aInParamList[1]; |
|
964 |
||
965 |
if(aInParamList.Count()>2) |
|
966 |
paramGetListSortOrder = &aInParamList[2] ; |
|
967 |
} |
|
968 |
pos = 0; |
|
969 |
//Get the filter criteria, the value of which is a Map |
|
970 |
paramGetListData = aInParamList.FindFirst( pos, KFilter ); |
|
971 |
||
972 |
pos = 0; |
|
973 |
paramGetListSortOrder = aInParamList.FindFirst( pos, KSort ); |
|
974 |
||
975 |
TLiwVariant cnttyp = paramContentType->Value(); |
|
976 |
if(EVariantTypeDesC != cnttyp.TypeId()) |
|
977 |
{ |
|
978 |
cnttyp.Reset(); |
|
979 |
||
980 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetListWrongContentType) ) ); |
|
981 |
User::Leave(KErrArgument); |
|
982 |
} |
|
983 |
||
984 |
//Retrieve the map |
|
985 |
const CLiwMap* pMap = NULL; |
|
986 |
if(paramGetListData) |
|
987 |
{ |
|
988 |
TLiwVariant getlistdata = paramGetListData->Value(); |
|
989 |
if(EVariantTypeMap != getlistdata.TypeId() ) |
|
990 |
{ |
|
991 |
getlistdata.Reset(); |
|
992 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetListInvalidFilterType) ) ); |
|
993 |
User::Leave(KErrArgument); |
|
994 |
} |
|
995 |
pMap = getlistdata.AsMap(); |
|
996 |
getlistdata.Reset(); |
|
997 |
} |
|
998 |
||
999 |
const CLiwMap* sortMap = NULL; |
|
1000 |
||
1001 |
if(paramGetListSortOrder) |
|
1002 |
{ |
|
1003 |
TLiwVariant map = paramGetListSortOrder->Value(); |
|
1004 |
||
1005 |
if(EVariantTypeMap == map.TypeId()) |
|
1006 |
{ |
|
1007 |
sortMap= paramGetListSortOrder->Value().AsMap(); |
|
1008 |
} |
|
1009 |
else |
|
1010 |
{ |
|
1011 |
map.Reset(); |
|
1012 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetListInvalidSortType) ) ); |
|
1013 |
User::Leave(KErrArgument); |
|
1014 |
||
1015 |
} |
|
1016 |
map.Reset(); |
|
1017 |
} |
|
1018 |
||
1019 |
//Get the type of the list requested |
|
1020 |
Ttype listType = EContacts; |
|
1021 |
TPtrC contentType; |
|
1022 |
||
1023 |
contentType.Set(paramContentType->Value().AsDes()); |
|
1024 |
||
1025 |
//Based on content type set the value of the enum Ttype |
|
1026 |
if(contentType.Compare(KDatabase) == 0) |
|
1027 |
{ |
|
1028 |
listType = EDatabase; |
|
1029 |
} |
|
1030 |
else if(contentType.Compare(KGroup) == 0) |
|
1031 |
{ |
|
1032 |
listType = EGroups; |
|
1033 |
} |
|
1034 |
else if(contentType.Compare(KContact) == 0) |
|
1035 |
{ |
|
1036 |
listType = EContacts; |
|
1037 |
} |
|
1038 |
else |
|
1039 |
{ |
|
1040 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1041 |
TLiwVariant(KGetListInvalidContentType))); |
|
1042 |
User::Leave(KErrArgument); |
|
1043 |
} |
|
1044 |
||
1045 |
TLiwVariant uriofDb; |
|
1046 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &uriofDb) ); |
|
1047 |
||
1048 |
TLiwVariant groupId; |
|
1049 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &groupId) ); |
|
1050 |
||
1051 |
TPtrC8 ptrToCntId(KNullDesC8); |
|
1052 |
HBufC8* cntid = NULL; |
|
1053 |
CContactIter* iter; |
|
1054 |
CContactIterator* iterator; |
|
1055 |
TPtrC dbUri(VPbkContactStoreUris::DefaultCntDbUri()); |
|
1056 |
//Switch based on the Ttype var value |
|
1057 |
switch(listType) |
|
1058 |
{ |
|
1059 |
case EDatabase: |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1060 |
if(aVal == EGetIds) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1061 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1062 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1063 |
TLiwVariant(KGetIdsInvalidContentType))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1064 |
User::Leave(KErrArgument); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1065 |
} |
5 | 1066 |
//In case it is GetList of dabases, the call is synchronous |
1067 |
iter = CContactIter::NewL(); |
|
1068 |
CleanupStack::PushL(iter); |
|
1069 |
iContactService->GetListL(*iter); |
|
1070 |
CleanupStack::Pop(iter); |
|
1071 |
//Setting the output param |
|
1072 |
if(iter) |
|
1073 |
{ |
|
1074 |
iterator = CContactIterator::NewL(iter); |
|
1075 |
CleanupStack::PushL(iterator); |
|
1076 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
|
1077 |
TLiwVariant(iterator))); |
|
1078 |
||
1079 |
CleanupStack::Pop(iterator); |
|
1080 |
iterator->DecRef(); |
|
1081 |
CleanupStack::Pop(&groupId); |
|
1082 |
groupId.Reset(); |
|
1083 |
CleanupStack::Pop(&uriofDb); |
|
1084 |
uriofDb.Reset(); |
|
1085 |
return; |
|
1086 |
} |
|
1087 |
break; |
|
1088 |
case EGroups: |
|
1089 |
//In case it is GetList of groups, its asynchronous |
|
1090 |
//All that is required to get the list of groups is the database name |
|
1091 |
//(in case its null default database is used) and callback function |
|
1092 |
if(pMap && (EFalse != pMap->FindL(KDBUri, uriofDb))) |
|
1093 |
{ |
|
1094 |
if(uriofDb.AsDes().Compare(KNullDesC)!= 0) |
|
1095 |
{ |
|
1096 |
dbUri.Set(uriofDb.AsDes()); |
|
1097 |
} |
|
1098 |
} |
|
1099 |
// Get the contact id, in case it is specified single contact is retrived |
|
1100 |
// If content is NULL, search is performed using search criteria |
|
1101 |
// If the ID is mentioned then the search value and fields are ignored. |
|
1102 |
if(pMap && (EFalse != pMap->FindL(KGroupId, groupId))) |
|
1103 |
{ |
|
1104 |
TPtrC ptr = groupId.AsDes(); |
|
1105 |
cntid = ContactIDUTFToStreamL(ptr); |
|
1106 |
CleanupStack::PushL(cntid); |
|
1107 |
if(aCmdOptions == KLiwOptASyncronous) |
|
1108 |
{ |
|
1109 |
CContactInterfaceCallback* contactCallback = |
|
1110 |
CContactInterfaceCallback::NewL(); |
|
1111 |
CleanupStack :: PushL(contactCallback); |
|
1112 |
contactCallback->SetParams(aCallback, |
|
1113 |
aTransId, |
|
1114 |
&aInParamList); |
|
1115 |
//Call GetList in case of retrieval of a |
|
1116 |
//single contact whose id is known |
|
1117 |
iContactService->GetListL(contactCallback, |
|
1118 |
aTransId, |
|
1119 |
listType, |
|
1120 |
*cntid, |
|
1121 |
KNullDesC, |
|
1122 |
NULL, |
|
1123 |
EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1124 |
dbUri,aVal); |
5 | 1125 |
|
1126 |
CleanupStack :: Pop(contactCallback); |
|
1127 |
CleanupStack::PopAndDestroy(cntid); |
|
1128 |
} |
|
1129 |
else |
|
1130 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1131 |
if(aVal == EGetList) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1132 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1133 |
//it is assumed that the call is synchronous |
5 | 1134 |
CContactIter* iter = |
1135 |
iContactService->GetListL(listType, |
|
1136 |
*cntid, |
|
1137 |
KNullDesC, |
|
1138 |
NULL, |
|
1139 |
EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1140 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1141 |
aVal); |
5 | 1142 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
1143 |
TLiwVariant((TInt32)SErrNone))); |
|
1144 |
//Setting the output param |
|
1145 |
CContactIterator* iterator=CContactIterator::NewL(iter); |
|
1146 |
CleanupStack::PushL(iterator); |
|
1147 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
|
1148 |
TLiwVariant(iterator))); |
|
1149 |
CleanupStack::Pop(iterator); |
|
1150 |
iterator->DecRef(); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1151 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1152 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1153 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1154 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1155 |
TLiwVariant((TInt32)SErrBadArgumentType))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1156 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetIdsBadArgGrpId) ) ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1157 |
} |
5 | 1158 |
CleanupStack::PopAndDestroy(cntid); |
1159 |
CleanupStack::Pop(&groupId); |
|
1160 |
groupId.Reset(); |
|
1161 |
CleanupStack::Pop(&uriofDb); |
|
1162 |
uriofDb.Reset(); |
|
1163 |
return; |
|
1164 |
} |
|
1165 |
break; |
|
1166 |
} |
|
1167 |
if(aCmdOptions == KLiwOptASyncronous) |
|
1168 |
{ |
|
1169 |
CContactInterfaceCallback* contactCallback = |
|
1170 |
CContactInterfaceCallback::NewL(); |
|
1171 |
CleanupStack :: PushL(contactCallback); |
|
1172 |
contactCallback->SetParams(aCallback, |
|
1173 |
aTransId, |
|
1174 |
&aInParamList); |
|
1175 |
//Call the contactservice api |
|
1176 |
iContactService->GetListL(contactCallback, |
|
1177 |
aTransId, |
|
1178 |
listType, |
|
1179 |
ptrToCntId, |
|
1180 |
KNullDesC, |
|
1181 |
NULL, |
|
1182 |
EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1183 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1184 |
aVal); |
5 | 1185 |
|
1186 |
CleanupStack :: Pop(contactCallback); |
|
1187 |
} |
|
1188 |
else |
|
1189 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1190 |
if(aVal == EGetList) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1191 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1192 |
//it is assumed that the call is synchronous |
5 | 1193 |
CContactIter* iter = |
1194 |
iContactService->GetListL(listType, |
|
1195 |
ptrToCntId, |
|
1196 |
KNullDesC, |
|
1197 |
NULL, |
|
1198 |
EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1199 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1200 |
aVal); |
5 | 1201 |
//Setting the output param |
1202 |
CContactIterator* iterator=CContactIterator::NewL(iter); |
|
1203 |
CleanupStack::PushL(iterator); |
|
1204 |
aOutParamList.AppendL(TLiwGenericParam( KReturnValue, |
|
1205 |
TLiwVariant(iterator) )); |
|
1206 |
CleanupStack::Pop(iterator); |
|
1207 |
iterator->DecRef(); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1208 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1209 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1210 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1211 |
//call the GetIds() service api |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1212 |
RPointerArray<HBufC8>& arrayid = |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1213 |
iContactService->GetIdsL(listType, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1214 |
KNullDesC, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1215 |
NULL, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1216 |
EAsc, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1217 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1218 |
aVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1219 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1220 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1221 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1222 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1223 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1224 |
TLiwVariant((TInt32)SErrNone))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1225 |
//Setting the output param |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1226 |
if(arrayid.Count() > 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1227 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1228 |
CLiwList* iList = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1229 |
iList = CLiwDefaultList::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1230 |
TLiwVariant outputVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1231 |
TInt count = arrayid.Count(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1232 |
TInt i; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1233 |
for(i=0; i<count; i++) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1234 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1235 |
TDesC8* idVal = arrayid[i]; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1236 |
HBufC* cntIdUnicode = HBufC::NewL(idVal->Length()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1237 |
CleanupStack :: PushL(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1238 |
cntIdUnicode->Des().Copy(*idVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1239 |
CContactInterfaceCallback::ContactIDToUTF(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1240 |
outputVal.Set(*cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1241 |
iList->AppendL(outputVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1242 |
CleanupStack :: Pop(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1243 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1244 |
CLiwMap* pFieldLinkedMap = CLiwDefaultMap::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1245 |
CleanupClosePushL(*pFieldLinkedMap); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1246 |
pFieldLinkedMap->InsertL(KIdsLabel,TLiwVariant(iList)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1247 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1248 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1249 |
TLiwVariant(pFieldLinkedMap))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1250 |
CleanupStack::PopAndDestroy(pFieldLinkedMap); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1251 |
arrayid.ResetAndDestroy(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1252 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1253 |
} |
5 | 1254 |
CleanupStack::Pop(&groupId); |
1255 |
groupId.Reset(); |
|
1256 |
CleanupStack::Pop(&uriofDb); |
|
1257 |
uriofDb.Reset(); |
|
1258 |
return; |
|
1259 |
} |
|
1260 |
break; |
|
1261 |
case EContacts: |
|
1262 |
//In case it is GetList of contacts, its asynchronous |
|
1263 |
//Get the database uri, if not specified default database is used |
|
1264 |
if(pMap && (EFalse != pMap->FindL(KDBUri,uriofDb))) |
|
1265 |
{ |
|
1266 |
if(uriofDb.AsDes().Compare(KNullDesC)!= 0) |
|
1267 |
{ |
|
1268 |
dbUri.Set(uriofDb.AsDes()); |
|
1269 |
} |
|
1270 |
} |
|
1271 |
TLiwVariant contactId; |
|
1272 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &contactId) ); |
|
1273 |
||
1274 |
// Get the contact id, in case it is specified single contact is retrived |
|
1275 |
// If content is NULL, search is performed using search criteria |
|
1276 |
// If the ID is mentioned then the search value and fields are ignored. |
|
1277 |
if(pMap && (EFalse != pMap->FindL(KContactId, contactId))) |
|
1278 |
{ |
|
1279 |
TPtrC ptr = contactId.AsDes(); |
|
1280 |
cntid = ContactIDUTFToStreamL(ptr); |
|
1281 |
CleanupStack::PushL(cntid); |
|
1282 |
if(aCmdOptions == KLiwOptASyncronous) |
|
1283 |
{ |
|
1284 |
CContactInterfaceCallback* contactCallback = |
|
1285 |
CContactInterfaceCallback::NewL(); |
|
1286 |
CleanupStack :: PushL(contactCallback); |
|
1287 |
contactCallback->SetParams(aCallback, |
|
1288 |
aTransId, |
|
1289 |
&aInParamList); |
|
1290 |
//Call GetList in case of retrieval of a |
|
1291 |
//single contact whose id is known |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1292 |
iContactService->GetListL(contactCallback, |
5 | 1293 |
aTransId, |
1294 |
listType, |
|
1295 |
*cntid, |
|
1296 |
KNullDesC, |
|
1297 |
NULL, |
|
1298 |
EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1299 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1300 |
aVal); |
5 | 1301 |
CleanupStack :: Pop(contactCallback); |
1302 |
CleanupStack::PopAndDestroy(cntid); |
|
1303 |
} |
|
1304 |
else |
|
1305 |
{ |
|
1306 |
//it is assumed that the call is synchronous |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1307 |
if(aVal == EGetList) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1308 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1309 |
CContactIter* iter = |
5 | 1310 |
iContactService->GetListL(listType, |
1311 |
*cntid, |
|
1312 |
KNullDesC, |
|
1313 |
NULL, |
|
1314 |
EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1315 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1316 |
aVal); |
5 | 1317 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
1318 |
TLiwVariant((TInt32)SErrNone))); |
|
1319 |
//Setting the output param |
|
1320 |
CContactIterator* iterator=CContactIterator::NewL(iter); |
|
1321 |
CleanupStack::PushL(iterator); |
|
1322 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
|
1323 |
TLiwVariant(iterator))); |
|
1324 |
CleanupStack::Pop(iterator); |
|
1325 |
iterator->DecRef(); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1326 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1327 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1328 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1329 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1330 |
TLiwVariant((TInt32)SErrBadArgumentType))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1331 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1332 |
TLiwVariant(KGetIdsBadArgCntId) ) ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1333 |
} |
5 | 1334 |
CleanupStack::PopAndDestroy(cntid); |
1335 |
CleanupStack::Pop(&contactId); |
|
1336 |
contactId.Reset(); |
|
1337 |
CleanupStack::Pop(&groupId); |
|
1338 |
groupId.Reset(); |
|
1339 |
CleanupStack::Pop(&uriofDb); |
|
1340 |
uriofDb.Reset(); |
|
1341 |
return; |
|
1342 |
} |
|
1343 |
CleanupStack::Pop(&contactId); |
|
1344 |
contactId.Reset(); |
|
1345 |
break; |
|
1346 |
} |
|
1347 |
CleanupStack::Pop(&contactId); |
|
1348 |
contactId.Reset(); |
|
1349 |
TLiwVariant searchVal; |
|
1350 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &searchVal) ); |
|
1351 |
||
1352 |
TPtrC srchVal(KNullDesC); |
|
1353 |
TLiwVariant searchFieldKeys; |
|
1354 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &searchFieldKeys) ); |
|
1355 |
||
1356 |
//Get the searchval, the value to be searched in the fields specified. |
|
1357 |
//If the value is NULL, the whole database is listed as an output |
|
1358 |
if(pMap && (EFalse != pMap->FindL(KSearchVal,searchVal))) |
|
1359 |
{ |
|
1360 |
if(EVariantTypeDesC != searchVal.TypeId()) |
|
1361 |
{ |
|
1362 |
CleanupStack::Pop(&searchFieldKeys); |
|
1363 |
CleanupStack::Pop(&searchVal); |
|
1364 |
searchVal.Reset(); |
|
1365 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetListInvalidSearchVal) ) ); |
|
1366 |
User::Leave(KErrArgument); |
|
1367 |
} |
|
1368 |
if(searchVal.AsDes().Compare(KNullDesC)) |
|
1369 |
srchVal.Set(searchVal.AsDes()); |
|
1370 |
} |
|
1371 |
||
1372 |
CSearchFields* searchFields = NULL; |
|
1373 |
// Get the search fields, fields in which |
|
1374 |
//the given searchval is to looked for |
|
1375 |
// in all the contacts of the database. |
|
1376 |
//If not specified, fields are first and last name |
|
1377 |
// by default |
|
1378 |
||
1379 |
TLiwVariant order; |
|
1380 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &order) ); |
|
1381 |
||
1382 |
TPtrC sortOrder; |
|
1383 |
TOrder srtOrder = EAsc; |
|
1384 |
||
1385 |
if(NULL != paramGetListSortOrder) |
|
1386 |
{ |
|
1387 |
if(EFalse != sortMap->FindL(KOrder, order)) |
|
1388 |
{ |
|
1389 |
if(EVariantTypeDesC != order.TypeId()) |
|
1390 |
{ |
|
1391 |
CleanupStack::Pop(&order); |
|
1392 |
order.Reset(); |
|
1393 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetListSortOrderValue) ) ); |
|
1394 |
User::Leave(KErrArgument); |
|
1395 |
||
1396 |
} |
|
1397 |
sortOrder.Set(order.AsDes()); |
|
1398 |
||
1399 |
// Set the TOrder variable to the sort order preference |
|
1400 |
if( sortOrder.CompareF( KAscending ) == 0) |
|
1401 |
{ |
|
1402 |
srtOrder = EAsc; |
|
1403 |
} |
|
1404 |
else if(sortOrder.CompareF( KDescending ) == 0) |
|
1405 |
{ |
|
1406 |
srtOrder = EDesc; |
|
1407 |
} |
|
1408 |
else |
|
1409 |
{ |
|
1410 |
CleanupStack::Pop(&order); |
|
1411 |
order.Reset(); |
|
1412 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1413 |
TLiwVariant(KGetListInvalidSortordVal))); |
|
1414 |
User::Leave(KErrArgument); |
|
1415 |
} |
|
1416 |
} |
|
1417 |
} |
|
1418 |
||
1419 |
||
1420 |
if(aCmdOptions == KLiwOptASyncronous) |
|
1421 |
{ |
|
1422 |
CContactInterfaceCallback* contactCallback = |
|
1423 |
CContactInterfaceCallback::NewL(); |
|
1424 |
CleanupStack :: PushL(contactCallback); |
|
1425 |
contactCallback->SetParams(aCallback, |
|
1426 |
aTransId, |
|
1427 |
&aInParamList); |
|
1428 |
||
1429 |
||
1430 |
//Call to GetList in case of searching |
|
1431 |
iContactService->GetListL(contactCallback, |
|
1432 |
aTransId, |
|
1433 |
listType, |
|
1434 |
ptrToCntId, |
|
1435 |
srchVal, |
|
1436 |
searchFields, |
|
1437 |
srtOrder, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1438 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1439 |
aVal); |
5 | 1440 |
|
1441 |
CleanupStack :: Pop(contactCallback); |
|
1442 |
} |
|
1443 |
else |
|
1444 |
{ |
|
1445 |
//it is assumed that the call is synchronous |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1446 |
if(aVal == EGetList) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1447 |
{ |
5 | 1448 |
CContactIter* iter = |
1449 |
iContactService->GetListL(listType, |
|
1450 |
ptrToCntId, |
|
1451 |
srchVal, |
|
1452 |
searchFields, |
|
1453 |
srtOrder, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1454 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1455 |
aVal); |
5 | 1456 |
|
1457 |
aOutParamList.AppendL(TLiwGenericParam(KErrorCode, |
|
1458 |
TLiwVariant((TInt32)SErrNone))); |
|
1459 |
||
1460 |
//Setting the output param |
|
1461 |
CContactIterator* iterator=CContactIterator::NewL(iter); |
|
1462 |
CleanupStack::PushL(iterator); |
|
1463 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
|
1464 |
TLiwVariant(iterator))); |
|
1465 |
CleanupStack::Pop(iterator); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1466 |
iterator->DecRef(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1467 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1468 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1469 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1470 |
RPointerArray<HBufC8>& arrayid = |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1471 |
iContactService->GetIdsL(listType, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1472 |
srchVal, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1473 |
searchFields, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1474 |
srtOrder, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1475 |
dbUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1476 |
aVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1477 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1478 |
TLiwVariant((TInt32)SErrNone))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1479 |
//Setting the output param |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1480 |
if(arrayid.Count() > 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1481 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1482 |
CLiwList* iList = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1483 |
iList = CLiwDefaultList::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1484 |
TLiwVariant outputVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1485 |
TInt count = arrayid.Count(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1486 |
TInt i; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1487 |
for(i=0; i<count; i++) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1488 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1489 |
TDesC8* idVal = arrayid[i]; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1490 |
HBufC* cntIdUnicode = HBufC::NewL(idVal->Length()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1491 |
CleanupStack :: PushL(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1492 |
cntIdUnicode->Des().Copy(*idVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1493 |
CContactInterfaceCallback::ContactIDToUTF(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1494 |
outputVal.Set(*cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1495 |
iList->AppendL(outputVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1496 |
CleanupStack :: Pop(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1497 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1498 |
CLiwMap* pFieldLinkedMap = CLiwDefaultMap::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1499 |
CleanupClosePushL(*pFieldLinkedMap); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1500 |
pFieldLinkedMap->InsertL(KIdsLabel,TLiwVariant(iList)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1501 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1502 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1503 |
TLiwVariant(pFieldLinkedMap))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1504 |
CleanupStack::PopAndDestroy(pFieldLinkedMap); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1505 |
arrayid.ResetAndDestroy(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1506 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1507 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1508 |
} |
5 | 1509 |
CleanupStack::Pop(&order); |
1510 |
order.Reset(); |
|
1511 |
CleanupStack::Pop(&searchFieldKeys); |
|
1512 |
searchFieldKeys.Reset(); |
|
1513 |
CleanupStack::Pop(&searchVal); |
|
1514 |
searchVal.Reset(); |
|
1515 |
CleanupStack::Pop(&groupId); |
|
1516 |
groupId.Reset(); |
|
1517 |
CleanupStack::Pop(&uriofDb); |
|
1518 |
uriofDb.Reset(); |
|
1519 |
return; |
|
1520 |
} |
|
1521 |
||
1522 |
CleanupStack::Pop(&order); |
|
1523 |
order.Reset(); |
|
1524 |
CleanupStack::Pop(&searchFieldKeys); |
|
1525 |
searchFieldKeys.Reset(); |
|
1526 |
CleanupStack::Pop(&searchVal); |
|
1527 |
searchVal.Reset(); |
|
1528 |
||
1529 |
break; |
|
1530 |
} |
|
1531 |
CleanupStack::Pop(&groupId); |
|
1532 |
groupId.Reset(); |
|
1533 |
CleanupStack::Pop(&uriofDb); |
|
1534 |
uriofDb.Reset(); |
|
1535 |
||
1536 |
if( aCallback && aCmdOptions == KLiwOptASyncronous ) |
|
1537 |
{ |
|
1538 |
//In case of async calls, also set the transaction id |
|
1539 |
aOutParamList.AppendL(TLiwGenericParam(KTransactionID, |
|
1540 |
TLiwVariant((TInt32)aTransId ))); |
|
1541 |
} |
|
1542 |
} |
|
1543 |
||
1544 |
/* |
|
1545 |
----------------------------------------------------------------------------- |
|
1546 |
CContactInterface::CancelCommandL(const CLiwGenericParamList& aInParamList, |
|
1547 |
MLiwNotifyCallback* aCallback, |
|
1548 |
TUint aCmdOptions, |
|
1549 |
TInt aTransId) |
|
1550 |
Description : This function parses the input param list |
|
1551 |
: and calls the Cancel on the given transaction id |
|
1552 |
Return values : TInt |
|
1553 |
----------------------------------------------------------------------------- |
|
1554 |
*/ |
|
1555 |
||
1556 |
TInt CContactInterface::CancelCommandL(const CLiwGenericParamList& aInParamList, |
|
1557 |
CLiwGenericParamList& aOutParamList) |
|
1558 |
{ |
|
1559 |
||
1560 |
TInt32 transactionID = 0; |
|
1561 |
TInt errCode = KErrArgument; |
|
1562 |
TInt pos = 0; |
|
1563 |
const TLiwGenericParam* param = NULL; |
|
1564 |
TLiwGenericParam posbasedparam; |
|
1565 |
||
1566 |
param = aInParamList.FindFirst( pos, KTransactionID ); |
|
1567 |
if((!param) && (aInParamList.Count()<=0)) |
|
1568 |
{ |
|
1569 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1570 |
TLiwVariant(KCancelTransIdMissing))); |
|
1571 |
User::Leave(KMissingArg); |
|
1572 |
} |
|
1573 |
else |
|
1574 |
{ |
|
1575 |
pos = 0; |
|
1576 |
aInParamList.AtL( pos, posbasedparam ); |
|
1577 |
||
1578 |
if (posbasedparam.Value().IsEmpty() ) |
|
1579 |
{ |
|
1580 |
param = NULL; |
|
1581 |
} |
|
1582 |
else |
|
1583 |
{ |
|
1584 |
param = &posbasedparam; |
|
1585 |
} |
|
1586 |
} |
|
1587 |
if( param ) |
|
1588 |
{ |
|
1589 |
param->Value().Get( transactionID ); |
|
1590 |
errCode = iContactService->Cancel( transactionID ); |
|
1591 |
} |
|
1592 |
return errCode; |
|
1593 |
} |
|
1594 |
||
1595 |
||
1596 |
/* |
|
1597 |
----------------------------------------------------------------------------- |
|
1598 |
CContactInterface::AddCommandL(const CLiwGenericParamList& aInParamList, |
|
1599 |
MLiwNotifyCallback* aCallback, |
|
1600 |
TUint aCmdOptions, |
|
1601 |
TInt aTransId) |
|
1602 |
Description : This function parses the input param list |
|
1603 |
: and calls the Add API |
|
1604 |
Return values : TInt |
|
1605 |
----------------------------------------------------------------------------- |
|
1606 |
*/ |
|
1607 |
||
1608 |
void CContactInterface::AddCommandL(const CLiwGenericParamList& aInParamList, |
|
1609 |
CLiwGenericParamList& aOutParamList, |
|
1610 |
MLiwNotifyCallback* aCallback, |
|
1611 |
TUint aCmdOptions, |
|
1612 |
TInt aTransId) |
|
1613 |
{ |
|
1614 |
TInt pos = 0; |
|
1615 |
const TLiwGenericParam* paramAddData = NULL; |
|
1616 |
const TLiwGenericParam* paramContentType = NULL; |
|
1617 |
||
1618 |
if(aInParamList.Count()<2) |
|
1619 |
{ |
|
1620 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage, |
|
1621 |
TLiwVariant(KAddLessArguments) ) ); |
|
1622 |
||
1623 |
User::Leave(KMissingArg); |
|
1624 |
||
1625 |
} |
|
1626 |
//get the content type and add data. |
|
1627 |
paramContentType = aInParamList.FindFirst( pos, KType ); |
|
1628 |
if(!paramContentType) |
|
1629 |
{ |
|
1630 |
paramContentType = &aInParamList[0]; |
|
1631 |
if(!paramContentType || paramContentType->Name().Compare(KNullDesC8) != 0) |
|
1632 |
{ |
|
1633 |
// Append error message |
|
1634 |
aOutParamList.AppendL(TLiwGenericParam (KErrorMessage, |
|
1635 |
TLiwVariant(KAddContentTypeMissing))); |
|
1636 |
||
1637 |
User::Leave(KMissingArg); |
|
1638 |
} |
|
1639 |
} |
|
1640 |
||
1641 |
pos = 0; |
|
1642 |
//Get the add data, the value of which is a Map |
|
1643 |
paramAddData = aInParamList.FindFirst( pos, KData ); |
|
1644 |
if(!paramAddData) |
|
1645 |
{ |
|
1646 |
paramAddData = &aInParamList[1]; |
|
1647 |
||
1648 |
if(!paramAddData || paramAddData->Name().Compare(KNullDesC8) != 0) |
|
1649 |
{ |
|
1650 |
// Append error message |
|
1651 |
aOutParamList.AppendL(TLiwGenericParam ( KErrorMessage, |
|
1652 |
TLiwVariant(KAddDataMissing) ) ); |
|
1653 |
User::Leave(KMissingArg); |
|
1654 |
} |
|
1655 |
} |
|
1656 |
||
1657 |
//get the content type. |
|
1658 |
TLiwVariant contentTypeVar = paramContentType->Value(); |
|
1659 |
||
1660 |
if(EVariantTypeDesC != contentTypeVar.TypeId()) |
|
1661 |
{ |
|
1662 |
contentTypeVar.Reset(); |
|
1663 |
aOutParamList.AppendL(TLiwGenericParam ( KErrorMessage, |
|
1664 |
TLiwVariant(KAddWrongContentType) ) ); |
|
1665 |
User::Leave(KErrArgument); |
|
1666 |
||
1667 |
} |
|
1668 |
||
1669 |
//if content type is "Contacts" then.... |
|
1670 |
if(contentTypeVar.AsDes().CompareF(KContact) == 0 ) |
|
1671 |
{ |
|
1672 |
contentTypeVar.Reset(); |
|
1673 |
//get the liw map from the add data generic parameter. |
|
1674 |
//if map is not null then call the function ProcesAddDataL(), |
|
1675 |
//which will parse the map and gets dburi and creates a new contact. |
|
1676 |
const CLiwMap* pMap = paramAddData->Value().AsMap(); |
|
1677 |
if( pMap ) |
|
1678 |
{ |
|
1679 |
//create a new contact. |
|
1680 |
CSingleContact* contact = CSingleContact::NewL(); |
|
1681 |
CleanupStack::PushL(contact); |
|
1682 |
//call to ProcessAddDataL to parse the |
|
1683 |
//map and create a new contact. |
|
1684 |
ProcessAddDataL(pMap, contact, aOutParamList); |
|
1685 |
||
1686 |
if( aCmdOptions == KLiwOptASyncronous ) |
|
1687 |
{ |
|
1688 |
CContactInterfaceCallback* contactCallback = |
|
1689 |
CContactInterfaceCallback::NewL(contact); |
|
1690 |
||
1691 |
CleanupStack :: PushL(contactCallback); |
|
1692 |
//set the callback parameter values. |
|
1693 |
contactCallback->SetParams(aCallback, |
|
1694 |
aTransId, |
|
1695 |
&aInParamList); |
|
1696 |
||
1697 |
//invoke the main method of contactService |
|
1698 |
//to add/edit a contact/group |
|
1699 |
//into the database. |
|
1700 |
iContactService->AddL(contactCallback, |
|
1701 |
aTransId, |
|
1702 |
contact, |
|
1703 |
KNullDesC8, //group id |
|
1704 |
KNullDesC, //group label |
|
1705 |
*iDburi); |
|
1706 |
||
1707 |
CleanupStack :: Pop(contactCallback); |
|
1708 |
} |
|
1709 |
else |
|
1710 |
{ |
|
1711 |
//it is assumed that the call is synchronous |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1712 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1713 |
HBufC8* cntIdVal = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1714 |
TRAPD(err, cntIdVal = iContactService->AddL(contact, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1715 |
KNullDesC8, //group id |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1716 |
KNullDesC, //group label |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1717 |
*iDburi)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1718 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1719 |
|
5 | 1720 |
if(err == KErrNotSupported) |
1721 |
{ |
|
1722 |
TInt errkey = iContactService->GetErrKey(); |
|
1723 |
TPtrC8 ptr = CSearchFields::GetFieldKeyFromId(errkey); |
|
1724 |
TBuf<25> buff; |
|
1725 |
buff.Copy(ptr); |
|
1726 |
TBuf<KMaxName> errmsg(KAddFieldKeyNotSupported); |
|
1727 |
errmsg.Append(buff); |
|
1728 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1729 |
TLiwVariant(errmsg))); |
|
1730 |
User::Leave(err); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1731 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1732 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1733 |
if(err == KErrNone) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1734 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1735 |
HBufC* cntIdUnicode = HBufC::NewL(cntIdVal->Length()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1736 |
CleanupStack :: PushL(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1737 |
cntIdUnicode->Des().Copy(*cntIdVal); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1738 |
delete cntIdVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1739 |
cntIdVal = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1740 |
CContactInterfaceCallback::ContactIDToUTF(cntIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1741 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue,TLiwVariant(*cntIdUnicode))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1742 |
CleanupStack :: Pop(cntIdUnicode); |
5 | 1743 |
} |
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1744 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1745 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1746 |
User::Leave(err); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1747 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1748 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1749 |
|
5 | 1750 |
CleanupStack::Pop(contact); |
1751 |
} //end of if pMap |
|
1752 |
else |
|
1753 |
{ |
|
1754 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1755 |
TLiwVariant(KAddInvalidDataType))); |
|
1756 |
User::Leave(KErrArgument); |
|
1757 |
} |
|
1758 |
} //end of if contentType == KContact |
|
1759 |
//if content type is "Groups", then.... |
|
1760 |
else if(contentTypeVar.AsDes().CompareF(KGroup)==0) |
|
1761 |
{ |
|
1762 |
contentTypeVar.Reset(); |
|
1763 |
//get the map from the addgroup data. |
|
1764 |
const CLiwMap* pMap = paramAddData->Value().AsMap(); |
|
1765 |
if(pMap) |
|
1766 |
{ |
|
1767 |
TLiwVariant valueGrpid; |
|
1768 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueGrpid) ); |
|
1769 |
||
1770 |
TLiwVariant valueGrplabel; |
|
1771 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueGrplabel)); |
|
1772 |
||
1773 |
TLiwVariant valueUri; |
|
1774 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueUri) ); |
|
1775 |
||
1776 |
//set the Db Uri to default database. |
|
1777 |
TPtrC dbUri(VPbkContactStoreUris::DefaultCntDbUri()); |
|
1778 |
||
1779 |
TPtrC grpIdUnicode(KNullDesC); |
|
1780 |
TPtrC grpLabel(KNullDesC); |
|
1781 |
||
1782 |
HBufC8* groupId = NULL; |
|
1783 |
if( EFalse != pMap->FindL(KDBUri,valueUri)) |
|
1784 |
{ |
|
1785 |
if( valueUri.AsDes().CompareF(KNullDesC) != 0 ) |
|
1786 |
{ |
|
1787 |
dbUri.Set(valueUri.AsDes()); |
|
1788 |
} |
|
1789 |
} |
|
1790 |
if(EFalse != pMap->FindL(KGroupId,valueGrpid)) |
|
1791 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1792 |
TInt typeofgrpId = valueGrpid.TypeId(); |
5 | 1793 |
TPtrC grpIdUnicode = valueGrpid.AsDes(); |
1794 |
if(grpIdUnicode == NULL) |
|
1795 |
{ |
|
1796 |
CleanupStack::Pop(&valueGrpid); |
|
1797 |
valueGrpid.Reset(); |
|
1798 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KAddInvalGrpId) ) ); |
|
1799 |
User::Leave(KErrArgument); |
|
1800 |
//Leave |
|
1801 |
} |
|
1802 |
//Convert the values back to the 8 bit descriptor. |
|
1803 |
groupId = ContactIDUTFToStreamL(grpIdUnicode); |
|
1804 |
} |
|
1805 |
else |
|
1806 |
{ |
|
1807 |
groupId = KNullDesC8().AllocL(); |
|
1808 |
} |
|
1809 |
//get the values for dburi, group id and group label |
|
1810 |
if(EFalse != pMap->FindL(KGroupLabel,valueGrplabel)) |
|
1811 |
{ |
|
1812 |
if(EVariantTypeDesC != valueGrplabel.TypeId()) |
|
1813 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1814 |
CleanupStack::Pop(&valueUri); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1815 |
valueUri.Reset(); |
5 | 1816 |
CleanupStack::Pop(&valueGrplabel); |
1817 |
valueGrplabel.Reset(); |
|
1818 |
CleanupStack::Pop(&valueGrpid); |
|
1819 |
valueGrpid.Reset(); |
|
1820 |
||
1821 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KAddInvalGrpLabel) ) ); |
|
1822 |
User::Leave(KErrArgument); |
|
1823 |
//Leave |
|
1824 |
} |
|
1825 |
if( valueGrplabel.AsDes().CompareF(KNullDesC) != 0) |
|
1826 |
{ |
|
1827 |
grpLabel.Set(valueGrplabel.AsDes()); |
|
1828 |
} |
|
1829 |
else |
|
1830 |
{ |
|
1831 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KAddGroupLabelEmpty) ) ); |
|
1832 |
User::Leave(KErrArgument); |
|
1833 |
} |
|
1834 |
} |
|
1835 |
else |
|
1836 |
{ |
|
1837 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1838 |
TLiwVariant(KAddLabelMissing))); |
|
1839 |
||
1840 |
User::Leave(KErrArgument); |
|
1841 |
} |
|
1842 |
CleanupStack :: PushL(groupId); |
|
1843 |
//All the params are retrieved now call the main api. |
|
1844 |
if( aCmdOptions == KLiwOptASyncronous ) |
|
1845 |
{ |
|
1846 |
CContactInterfaceCallback* contactCallback = |
|
1847 |
CContactInterfaceCallback::NewL(); |
|
1848 |
||
1849 |
CleanupStack :: PushL(contactCallback); |
|
1850 |
//set the parameters for callback |
|
1851 |
contactCallback->SetParams(aCallback, |
|
1852 |
aTransId, |
|
1853 |
&aInParamList); |
|
1854 |
||
1855 |
//invoke the main method of the contactService to Add/Edit Group. |
|
1856 |
iContactService->AddL(contactCallback, |
|
1857 |
aTransId, |
|
1858 |
NULL, |
|
1859 |
*groupId, |
|
1860 |
grpLabel, |
|
1861 |
dbUri); |
|
1862 |
||
1863 |
CleanupStack :: Pop(contactCallback); |
|
1864 |
} |
|
1865 |
else |
|
1866 |
{ |
|
1867 |
//it is assumed that the call is synchronous |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1868 |
HBufC8* grpId = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1869 |
TRAPD(err,grpId = iContactService->AddL(NULL, |
5 | 1870 |
*groupId, |
1871 |
grpLabel, |
|
1872 |
dbUri)); |
|
1873 |
if(err == KErrNotSupported) |
|
1874 |
{ |
|
1875 |
TInt errkey = iContactService->GetErrKey(); |
|
1876 |
TPtrC8 ptr = CSearchFields::GetFieldKeyFromId(errkey); |
|
1877 |
TBuf<25> buff; |
|
1878 |
buff.Copy(ptr); |
|
1879 |
TBuf<KMaxName> errmsg(KAddFieldKeyNotSupported); |
|
1880 |
errmsg.Append(buff); |
|
1881 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1882 |
TLiwVariant(errmsg))); |
|
1883 |
User::Leave(err); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1884 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1885 |
if(err == KErrNone) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1886 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1887 |
if(grpId) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1888 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1889 |
HBufC* grpIdUnicode = HBufC::NewL(grpId->Length()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1890 |
CleanupStack :: PushL(grpIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1891 |
grpIdUnicode->Des().Copy(*grpId); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1892 |
delete grpId; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1893 |
grpId = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1894 |
CContactInterfaceCallback::ContactIDToUTF(grpIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1895 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1896 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue,TLiwVariant(*grpIdUnicode))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1897 |
CleanupStack :: Pop(grpIdUnicode); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1898 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1899 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1900 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1901 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1902 |
User::Leave(err); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1903 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1904 |
|
5 | 1905 |
|
1906 |
} |
|
1907 |
CleanupStack :: PopAndDestroy(groupId); |
|
1908 |
CleanupStack::Pop(&valueUri); |
|
1909 |
valueUri.Reset(); |
|
1910 |
CleanupStack::Pop(&valueGrplabel); |
|
1911 |
valueGrplabel.Reset(); |
|
1912 |
CleanupStack::Pop(&valueGrpid); |
|
1913 |
valueGrpid.Reset(); |
|
1914 |
} |
|
1915 |
else |
|
1916 |
{ |
|
1917 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1918 |
TLiwVariant(KAddInvalidDataType))); |
|
1919 |
User::Leave(KMissingArg); |
|
1920 |
} |
|
1921 |
||
1922 |
} |
|
1923 |
else |
|
1924 |
{ |
|
1925 |
contentTypeVar.Reset(); |
|
1926 |
||
1927 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1928 |
TLiwVariant(KAddInvalidContentType))); |
|
1929 |
User::Leave(KErrArgument); |
|
1930 |
} |
|
1931 |
||
1932 |
} |
|
1933 |
||
1934 |
/* |
|
1935 |
----------------------------------------------------------------------------- |
|
1936 |
CContactInterface::ImportCommandL(const CLiwGenericParamList& aInParamList, |
|
1937 |
MLiwNotifyCallback* aCallback, |
|
1938 |
TUint aCmdOptions, |
|
1939 |
TInt aTransId) |
|
1940 |
Description : This function parses the input param list |
|
1941 |
: and calls the Import API |
|
1942 |
Return values : TInt |
|
1943 |
----------------------------------------------------------------------------- |
|
1944 |
*/ |
|
1945 |
void CContactInterface::ImportCommandL(const CLiwGenericParamList& aInParamList, |
|
1946 |
CLiwGenericParamList& aOutParamList, |
|
1947 |
MLiwNotifyCallback* aCallback, |
|
1948 |
TUint aCmdOptions, |
|
1949 |
TInt aTransId) |
|
1950 |
{ |
|
1951 |
TInt pos = 0; |
|
1952 |
const TLiwGenericParam* paramImportData = NULL; |
|
1953 |
const TLiwGenericParam* paramContentType = NULL; |
|
1954 |
||
1955 |
//get the content type and import data. |
|
1956 |
paramContentType = aInParamList.FindFirst( pos, KType ); |
|
1957 |
||
1958 |
if(!paramContentType) |
|
1959 |
{ |
|
1960 |
||
1961 |
if(aInParamList.Count()<2) |
|
1962 |
{ |
|
1963 |
||
1964 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KImportLessArguments) ) ); |
|
1965 |
User::Leave(KMissingArg); |
|
1966 |
} |
|
1967 |
paramContentType = &aInParamList[0] ; |
|
1968 |
if(!paramContentType || paramContentType->Name().Compare(KNullDesC8) != 0) |
|
1969 |
{ |
|
1970 |
// Append error message |
|
1971 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KImportContentTypeMissing) ) ); |
|
1972 |
User::Leave(KMissingArg); |
|
1973 |
} |
|
1974 |
} |
|
1975 |
pos = 0; |
|
1976 |
//Get the delete data, the value of which is a Map |
|
1977 |
paramImportData = aInParamList.FindFirst( pos, KData ); |
|
1978 |
if(!paramImportData) |
|
1979 |
{ |
|
1980 |
if(aInParamList.Count()>1) |
|
1981 |
paramImportData = &aInParamList[1] ; |
|
1982 |
if(!paramImportData || paramImportData->Name().Compare(KNullDesC8) != 0) |
|
1983 |
{ |
|
1984 |
// Append error message |
|
1985 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KImportDataMissing) ) ); |
|
1986 |
User::Leave(KMissingArg); |
|
1987 |
} |
|
1988 |
} |
|
1989 |
||
1990 |
TLiwVariant cnttent = paramContentType->Value(); |
|
1991 |
||
1992 |
if(EVariantTypeDesC !=cnttent.TypeId()) |
|
1993 |
{ |
|
1994 |
cnttent.Reset(); |
|
1995 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KImportWrongContentType) ) ); |
|
1996 |
User::Leave(KErrArgument); |
|
1997 |
||
1998 |
} |
|
1999 |
cnttent.Reset(); |
|
2000 |
||
2001 |
TPtrC contentType; |
|
2002 |
contentType.Set(paramContentType->Value().AsDes()); |
|
2003 |
||
2004 |
// Check for content type |
|
2005 |
||
2006 |
if(contentType !=KContact) |
|
2007 |
{ |
|
2008 |
||
2009 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KImportInvalidContentType) ) ); |
|
2010 |
User::Leave(KErrArgument); |
|
2011 |
} |
|
2012 |
||
2013 |
//get the liw map from the import data generic parameter. |
|
2014 |
//if map is not null then get db name, source file from the |
|
2015 |
//contact has to be imported. |
|
2016 |
const CLiwMap* pMap = paramImportData->Value().AsMap(); |
|
2017 |
if(NULL != pMap) |
|
2018 |
{ |
|
2019 |
TPtrC dburi(VPbkContactStoreUris::DefaultCntDbUri()); |
|
2020 |
TLiwVariant valueFname; |
|
2021 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueFname) ); |
|
2022 |
||
2023 |
TLiwVariant valueUri; |
|
2024 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueUri) ); |
|
2025 |
||
2026 |
if( EFalse != pMap->FindL(KDBUri,valueUri)) |
|
2027 |
{ |
|
2028 |
if(EVariantTypeDesC != valueUri.TypeId()) |
|
2029 |
{ |
|
2030 |
||
2031 |
CleanupStack::Pop(&valueUri); |
|
2032 |
valueUri.Reset(); |
|
2033 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2034 |
TLiwVariant(KImportDbUriNotString))); |
|
2035 |
User::Leave(KErrArgument); |
|
2036 |
||
2037 |
} |
|
2038 |
||
2039 |
if(valueUri.AsDes().CompareF(KNullDesC)!=0) |
|
2040 |
{ |
|
2041 |
dburi.Set(valueUri.AsDes()); |
|
2042 |
} |
|
2043 |
} |
|
2044 |
if(EFalse != pMap->FindL(KSourceFileNameParam,valueFname)) |
|
2045 |
{ |
|
2046 |
//get the uri and filename. |
|
2047 |
if(EVariantTypeDesC != valueFname.TypeId()) |
|
2048 |
{ |
|
2049 |
CleanupStack::Pop(&valueUri); |
|
2050 |
valueUri.Reset(); |
|
2051 |
CleanupStack::Pop(&valueFname); |
|
2052 |
valueFname.Reset(); |
|
2053 |
||
2054 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2055 |
TLiwVariant(KImportSrcFileNotString))); |
|
2056 |
User::Leave(KErrArgument); |
|
2057 |
||
2058 |
} |
|
2059 |
TPtrC filename = valueFname.AsDes(); |
|
2060 |
TInt length = filename.Length(); |
|
2061 |
||
2062 |
if(length > KMaxFileName) |
|
2063 |
{ |
|
2064 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2065 |
TLiwVariant(KImportFileNameTooLong))); |
|
2066 |
User::Leave(KErrBadName); |
|
2067 |
} |
|
2068 |
||
2069 |
if( aCmdOptions == KLiwOptASyncronous ) |
|
2070 |
{ |
|
2071 |
CContactInterfaceCallback* contactCallback = |
|
2072 |
CContactInterfaceCallback::NewL(); |
|
2073 |
||
2074 |
CleanupStack::PushL(contactCallback); |
|
2075 |
//if callback is not null, set the params like |
|
2076 |
//callback, transid..etc |
|
2077 |
contactCallback->SetParams(aCallback, |
|
2078 |
aTransId, |
|
2079 |
&aInParamList); |
|
2080 |
//invoke the main method of contact service |
|
2081 |
//to import the contact. |
|
2082 |
iContactService->ImportVCardToStoreL(contactCallback, |
|
2083 |
aTransId, |
|
2084 |
filename, |
|
2085 |
dburi); |
|
2086 |
CleanupStack::Pop(contactCallback); |
|
2087 |
||
2088 |
} |
|
2089 |
else |
|
2090 |
{ |
|
2091 |
//it is assumed that the call is synchronous |
|
2092 |
iContactService->ImportVCardToStoreL(filename, |
|
2093 |
dburi); |
|
2094 |
} |
|
2095 |
} |
|
2096 |
else |
|
2097 |
{ |
|
2098 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2099 |
TLiwVariant(KImportSrcFileNameMissing))); |
|
2100 |
User::Leave(KMissingArg); |
|
2101 |
} |
|
2102 |
CleanupStack::Pop(&valueUri); |
|
2103 |
valueUri.Reset(); |
|
2104 |
CleanupStack::Pop(&valueFname); |
|
2105 |
valueFname.Reset(); |
|
2106 |
} |
|
2107 |
||
2108 |
else |
|
2109 |
{ |
|
2110 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2111 |
TLiwVariant(KImportDataMapMissing))); |
|
2112 |
User::Leave(KMissingArg); |
|
2113 |
} |
|
2114 |
} |
|
2115 |
||
2116 |
/* |
|
2117 |
----------------------------------------------------------------------------- |
|
2118 |
CContactInterface::ExportCommandL(const CLiwGenericParamList& aInParamList, |
|
2119 |
MLiwNotifyCallback* aCallback, |
|
2120 |
TUint aCmdOptions, |
|
2121 |
TInt aTransId) |
|
2122 |
Description : This function parses the input param list |
|
2123 |
: and calls the Export API |
|
2124 |
Return values : TInt |
|
2125 |
----------------------------------------------------------------------------- |
|
2126 |
*/ |
|
2127 |
void CContactInterface::ExportCommandL(const CLiwGenericParamList& aInParamList, |
|
2128 |
CLiwGenericParamList& aOutParamList, |
|
2129 |
MLiwNotifyCallback* aCallback, |
|
2130 |
TUint aCmdOptions, |
|
2131 |
TInt aTransId) |
|
2132 |
{ |
|
2133 |
TInt pos = 0; |
|
2134 |
const TLiwGenericParam* paramExportData = NULL; |
|
2135 |
const TLiwGenericParam* paramContentType = NULL; |
|
2136 |
//get the content type and export data. |
|
2137 |
paramContentType = aInParamList.FindFirst( pos, KType ); |
|
2138 |
||
2139 |
//get the content type and export data. |
|
2140 |
if(!paramContentType) |
|
2141 |
{ |
|
2142 |
||
2143 |
if(aInParamList.Count()<2) |
|
2144 |
{ |
|
2145 |
||
2146 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KExportLessArguments) ) ); |
|
2147 |
User::Leave(KMissingArg); |
|
2148 |
} |
|
2149 |
||
2150 |
paramContentType = &aInParamList[0] ; |
|
2151 |
if(!paramContentType || paramContentType->Name().Compare(KNullDesC8) != 0) |
|
2152 |
{ |
|
2153 |
// Append error message |
|
2154 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KExportContentTypeMissing) ) ); |
|
2155 |
User::Leave(KMissingArg); |
|
2156 |
} |
|
2157 |
} |
|
2158 |
||
2159 |
pos = 0; |
|
2160 |
//Get the export data, the value of which is a Map |
|
2161 |
paramExportData = aInParamList.FindFirst( pos, KData ); |
|
2162 |
if(!paramExportData) |
|
2163 |
{ |
|
2164 |
if(aInParamList.Count()>1) |
|
2165 |
paramExportData = &aInParamList[1] ; |
|
2166 |
if(!paramExportData || paramExportData->Name().Compare(KNullDesC8) != 0) |
|
2167 |
{ |
|
2168 |
// Append error message |
|
2169 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KExportDataMissing) ) ); |
|
2170 |
User::Leave(KMissingArg); |
|
2171 |
} |
|
2172 |
} |
|
2173 |
||
2174 |
TLiwVariant cnttent = paramContentType->Value(); |
|
2175 |
||
2176 |
if(EVariantTypeDesC !=cnttent.TypeId()) |
|
2177 |
{ |
|
2178 |
cnttent.Reset(); |
|
2179 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KExportWrongContentType) ) ); |
|
2180 |
User::Leave(KErrArgument); |
|
2181 |
||
2182 |
} |
|
2183 |
cnttent.Reset(); |
|
2184 |
||
2185 |
||
2186 |
||
2187 |
TPtrC contentType; |
|
2188 |
contentType.Set(paramContentType->Value().AsDes()); |
|
2189 |
||
2190 |
// Check for content type |
|
2191 |
if(contentType.Compare(KContact) != 0) |
|
2192 |
{ |
|
2193 |
||
2194 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KExportInvalidContentType) ) ); |
|
2195 |
User::Leave(KErrArgument); |
|
2196 |
} |
|
2197 |
||
2198 |
//get the liw map from the export data generic parameter. |
|
2199 |
//if map is not null then get db name, contact id and dest file |
|
2200 |
//to whi the contact has to be exported. |
|
2201 |
const CLiwMap* pMap = paramExportData->Value().AsMap(); |
|
2202 |
if(NULL != pMap) |
|
2203 |
{ |
|
2204 |
TLiwVariant valueFname; |
|
2205 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueFname) ); |
|
2206 |
||
2207 |
TLiwVariant valueUri; |
|
2208 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueUri) ); |
|
2209 |
||
2210 |
TPtrC dburi(VPbkContactStoreUris::DefaultCntDbUri()); |
|
2211 |
if( EFalse != pMap->FindL(KDBUri,valueUri)) |
|
2212 |
{ |
|
2213 |
if(EVariantTypeDesC != valueUri.TypeId()) |
|
2214 |
{ |
|
2215 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2216 |
TLiwVariant(KExportDbUriNotString))); |
|
2217 |
User::Leave(KErrArgument); |
|
2218 |
||
2219 |
} |
|
2220 |
if(valueUri.AsDes().CompareF(KNullDesC)!=0) |
|
2221 |
{ |
|
2222 |
dburi.Set(valueUri.AsDes()); |
|
2223 |
} |
|
2224 |
} |
|
2225 |
if(EFalse != pMap->FindL(KDestFileNameParam,valueFname)) |
|
2226 |
{ |
|
2227 |
||
2228 |
if(EVariantTypeDesC !=valueFname.TypeId() ) |
|
2229 |
{ |
|
2230 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2231 |
TLiwVariant(KExportDestnFlNmWrongType))); |
|
2232 |
User::Leave(KErrArgument); |
|
2233 |
} |
|
2234 |
TLiwVariant valueCntid; |
|
2235 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueCntid) ); |
|
2236 |
||
2237 |
if(EFalse != pMap->FindL(KContactId,valueCntid)) |
|
2238 |
{ |
|
2239 |
//get dburi, filename and contact id parameters from the map. |
|
2240 |
if(EVariantTypeDesC != valueCntid.TypeId()) |
|
2241 |
{ |
|
2242 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2243 |
TLiwVariant(KExportContactIdWrongType))); |
|
2244 |
User::Leave(KErrArgument); |
|
2245 |
||
2246 |
} |
|
2247 |
TPtrC filename = valueFname.AsDes(); |
|
2248 |
TInt length = filename.Length(); |
|
2249 |
||
2250 |
if(length > KMaxFileName) |
|
2251 |
{ |
|
2252 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2253 |
TLiwVariant(KExportFileNameTooLong))); |
|
2254 |
User::Leave(KErrBadName); |
|
2255 |
} |
|
2256 |
||
2257 |
TPtrC cntIdUnicode = valueCntid.AsDes(); |
|
2258 |
||
2259 |
HBufC8* cntid = ContactIDUTFToStreamL(cntIdUnicode); |
|
2260 |
CleanupStack::PushL(cntid); |
|
2261 |
||
2262 |
if( aCmdOptions == KLiwOptASyncronous ) |
|
2263 |
{ |
|
2264 |
CContactInterfaceCallback* contactCallback = |
|
2265 |
CContactInterfaceCallback::NewL(); |
|
2266 |
CleanupStack :: PushL(contactCallback); |
|
2267 |
//if callback is not null, set the params like callback, transid..etc |
|
2268 |
contactCallback->SetParams(aCallback, |
|
2269 |
aTransId, |
|
2270 |
&aInParamList); |
|
2271 |
//invoke the main method of contact service to export the contact. |
|
2272 |
iContactService->ExportVCardL(contactCallback, |
|
2273 |
aTransId, |
|
2274 |
filename, |
|
2275 |
*cntid , |
|
2276 |
dburi); |
|
2277 |
CleanupStack :: Pop(contactCallback); |
|
2278 |
} |
|
2279 |
else |
|
2280 |
{ |
|
2281 |
//it is assumed that the call is synchronous |
|
2282 |
iContactService->ExportVCardL(filename, |
|
2283 |
*cntid, |
|
2284 |
dburi); |
|
2285 |
||
2286 |
||
2287 |
} |
|
2288 |
CleanupStack :: PopAndDestroy(cntid); |
|
2289 |
} //end of if Find of cntid |
|
2290 |
else |
|
2291 |
{ |
|
2292 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2293 |
TLiwVariant(KExportContactIdMissing))); |
|
2294 |
User::Leave(KMissingArg); |
|
2295 |
||
2296 |
} |
|
2297 |
CleanupStack::Pop(&valueCntid); |
|
2298 |
valueCntid.Reset(); |
|
2299 |
} |
|
2300 |
else |
|
2301 |
{ |
|
2302 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2303 |
TLiwVariant(KExportDstFileNameMissing))); |
|
2304 |
User::Leave(KMissingArg); |
|
2305 |
||
2306 |
} |
|
2307 |
CleanupStack::Pop(&valueUri); |
|
2308 |
valueUri.Reset(); |
|
2309 |
CleanupStack::Pop(&valueFname); |
|
2310 |
valueFname.Reset(); |
|
2311 |
} |
|
2312 |
else |
|
2313 |
{ |
|
2314 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2315 |
TLiwVariant(KExportDataMapMissing))); |
|
2316 |
User::Leave(KMissingArg); |
|
2317 |
||
2318 |
} |
|
2319 |
} |
|
2320 |
||
2321 |
/* |
|
2322 |
----------------------------------------------------------------------------- |
|
2323 |
CContactInterface::DeleteCommandL(const CLiwGenericParamList& aInParamList, |
|
2324 |
MLiwNotifyCallback* aCallback, |
|
2325 |
TUint aCmdOptions, |
|
2326 |
TInt aTransId) |
|
2327 |
Description : This function parses the input param list |
|
2328 |
: and calls the Delete API |
|
2329 |
Return values : TInt |
|
2330 |
----------------------------------------------------------------------------- |
|
2331 |
*/ |
|
2332 |
void CContactInterface::DeleteCommandL(const CLiwGenericParamList& aInParamList, |
|
2333 |
CLiwGenericParamList& aOutParamList, |
|
2334 |
MLiwNotifyCallback* aCallback, |
|
2335 |
TUint aCmdOptions, |
|
2336 |
TInt aTransId) |
|
2337 |
{ |
|
2338 |
TInt pos = 0; |
|
2339 |
const TLiwGenericParam* paramDeleteData = NULL; |
|
2340 |
const TLiwGenericParam* paramContentType = NULL; |
|
2341 |
||
2342 |
//get the content type and delete data. |
|
2343 |
paramContentType = aInParamList.FindFirst(pos, KType); |
|
2344 |
if(!paramContentType) |
|
2345 |
{ |
|
2346 |
||
2347 |
if(aInParamList.Count()<1) |
|
2348 |
{ |
|
2349 |
||
2350 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KDeleteLessArguments) ) ); |
|
2351 |
User::Leave(KMissingArg); |
|
2352 |
} |
|
2353 |
if(aInParamList.Count()>0) |
|
2354 |
paramContentType = &aInParamList[0] ; |
|
2355 |
if(!paramContentType || paramContentType->Name().Compare(KNullDesC8) != 0) |
|
2356 |
{ |
|
2357 |
||
2358 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KDeleteContentTypeMissing) ) ); |
|
2359 |
User::Leave(KMissingArg); |
|
2360 |
} |
|
2361 |
} |
|
2362 |
||
2363 |
pos = 0; |
|
2364 |
//Get the delete data, the value of which is a Map |
|
2365 |
paramDeleteData = aInParamList.FindFirst( pos, KData ); |
|
2366 |
if(!paramDeleteData) |
|
2367 |
{ |
|
2368 |
if(aInParamList.Count()>1) |
|
2369 |
paramDeleteData = &aInParamList[1] ; |
|
2370 |
if(!paramDeleteData || paramDeleteData->Name().Compare(KNullDesC8) != 0) |
|
2371 |
{ |
|
2372 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KDeleteDataMissing) ) ); |
|
2373 |
User::Leave(KMissingArg); |
|
2374 |
} |
|
2375 |
} |
|
2376 |
||
2377 |
//Get the content type |
|
2378 |
TLiwVariant contentTypeVar = paramContentType->Value(); |
|
2379 |
||
2380 |
if(EVariantTypeDesC !=contentTypeVar.TypeId()) |
|
2381 |
{ |
|
2382 |
contentTypeVar.Reset(); |
|
2383 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KDeleteWrongContentType) ) ); |
|
2384 |
User::Leave(KErrArgument); |
|
2385 |
||
2386 |
||
2387 |
} |
|
2388 |
||
2389 |
//either gorups or contacts |
|
2390 |
if(contentTypeVar.AsDes() == KContact || contentTypeVar.AsDes() == KGroup) |
|
2391 |
{ |
|
2392 |
//get the map from the delete data generic parameter. |
|
2393 |
const CLiwMap* pMap = paramDeleteData->Value().AsMap(); |
|
2394 |
if( pMap ) |
|
2395 |
{ |
|
2396 |
TLiwVariant valueList; |
|
2397 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueList) ); |
|
2398 |
||
2399 |
TLiwVariant valueUri; |
|
2400 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueUri) ); |
|
2401 |
||
2402 |
TLiwVariant valueId; |
|
2403 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueId) ); |
|
2404 |
||
2405 |
TPtrC dbUri(VPbkContactStoreUris::DefaultCntDbUri()); |
|
2406 |
const CLiwList* contactIdList = NULL; |
|
2407 |
||
2408 |
if( EFalse != pMap->FindL(KDBUri,valueUri)) |
|
2409 |
{ |
|
2410 |
if(valueUri.AsDes().CompareF(KNullDesC)!=0) |
|
2411 |
{ |
|
2412 |
dbUri.Set(valueUri.AsDes()); |
|
2413 |
} |
|
2414 |
} |
|
2415 |
//get the dbUri and contact id list from the map. |
|
2416 |
if(EFalse != pMap->FindL(KList,valueList) ) |
|
2417 |
{ |
|
2418 |
if(EVariantTypeList != valueList.TypeId()) |
|
2419 |
{ |
|
2420 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KDeleteInvalidTypeIdList) ) ); |
|
2421 |
User::Leave(KErrArgument); |
|
2422 |
} |
|
2423 |
contactIdList = valueList.AsList(); |
|
2424 |
||
2425 |
//get the contact id count in the list. |
|
2426 |
TInt idCount = contactIdList->Count(); |
|
2427 |
//create the array of contact ids from the liw list. |
|
2428 |
RPointerArray<TDesC8> contactIdArray; |
|
2429 |
for(TInt index = 0; index < idCount; index++) |
|
2430 |
{ |
|
2431 |
contactIdList->AtL(index, valueId); |
|
2432 |
if(EVariantTypeDesC !=valueId.TypeId()) |
|
2433 |
{ |
|
2434 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KDeleteInvalidIdType) ) ); |
|
2435 |
User::Leave(KErrArgument); |
|
2436 |
} |
|
2437 |
||
2438 |
TPtrC cntidptr = valueId.AsDes(); |
|
2439 |
HBufC8* cntid = ContactIDUTFToStreamL(cntidptr); |
|
2440 |
CleanupStack :: PushL(cntid); |
|
2441 |
contactIdArray.AppendL(cntid); |
|
2442 |
CleanupStack :: Pop(cntid); |
|
2443 |
||
2444 |
} |
|
2445 |
if(aCmdOptions == KLiwOptASyncronous) |
|
2446 |
{ |
|
2447 |
CContactInterfaceCallback* contactCallback = |
|
2448 |
CContactInterfaceCallback::NewL(); |
|
2449 |
||
2450 |
CleanupStack :: PushL(contactCallback); |
|
2451 |
//set the basic params of callback object. |
|
2452 |
contactCallback->SetParams(aCallback, |
|
2453 |
aTransId, |
|
2454 |
&aInParamList); |
|
2455 |
//invoke the main method of contactservice |
|
2456 |
//to delete the list |
|
2457 |
//contacts/groups. |
|
2458 |
iContactService->DeleteL(contactCallback, |
|
2459 |
aTransId, |
|
2460 |
contactIdArray, |
|
2461 |
dbUri); |
|
2462 |
||
2463 |
CleanupStack :: Pop(contactCallback); |
|
2464 |
} |
|
2465 |
else |
|
2466 |
{ |
|
2467 |
//it is assumed that the call is synchronous |
|
2468 |
iContactService->DeleteL(contactIdArray, |
|
2469 |
dbUri); |
|
2470 |
} |
|
2471 |
||
2472 |
}//if pMap |
|
2473 |
else |
|
2474 |
{ |
|
2475 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2476 |
TLiwVariant(KDeleteDataListMissing))); |
|
2477 |
User::Leave(KMissingArg); |
|
2478 |
} |
|
2479 |
CleanupStack::Pop(&valueId); |
|
2480 |
valueId.Reset(); |
|
2481 |
CleanupStack::Pop(&valueUri); |
|
2482 |
valueUri.Reset(); |
|
2483 |
CleanupStack::Pop(&valueList); |
|
2484 |
valueList.Reset(); |
|
2485 |
} |
|
2486 |
else |
|
2487 |
{ |
|
2488 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2489 |
TLiwVariant(KDeleteDataMapMissing))); |
|
2490 |
User::Leave(KMissingArg); |
|
2491 |
} |
|
2492 |
contentTypeVar.Reset(); |
|
2493 |
}//if ContentType == KContact or KGroup |
|
2494 |
else |
|
2495 |
{ |
|
2496 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2497 |
TLiwVariant(KDeleteInvalidContentType))); |
|
2498 |
User::Leave(KErrArgument); |
|
2499 |
} |
|
2500 |
} |
|
2501 |
||
2502 |
/* |
|
2503 |
----------------------------------------------------------------------------- |
|
2504 |
CContactInterface::OrganiseGroupCommandL(const CLiwGenericParamList& aInParamList, |
|
2505 |
MLiwNotifyCallback* aCallback, |
|
2506 |
TUint aCmdOptions, |
|
2507 |
TInt aTransId) |
|
2508 |
Description : This function parses the input param list |
|
2509 |
: and calls the Organise API |
|
2510 |
Return values : TInt |
|
2511 |
----------------------------------------------------------------------------- |
|
2512 |
*/ |
|
2513 |
void CContactInterface::OrganiseGroupCommandL(const CLiwGenericParamList& aInParamList, |
|
2514 |
CLiwGenericParamList& aOutParamList, |
|
2515 |
MLiwNotifyCallback* aCallback, |
|
2516 |
TUint aCmdOptions, |
|
2517 |
TInt aTransId) |
|
2518 |
{ |
|
2519 |
TInt position = 0; |
|
2520 |
const TLiwGenericParam* paramOrganiseData = NULL; |
|
2521 |
const TLiwGenericParam* paramOperationType = NULL; |
|
2522 |
const TLiwGenericParam* paramContentType = NULL; |
|
2523 |
||
2524 |
//get the content type and Organise data. |
|
2525 |
paramContentType = aInParamList.FindFirst( position, KType ); |
|
2526 |
if(!paramContentType) |
|
2527 |
{ |
|
2528 |
if(aInParamList.Count()<3) |
|
2529 |
{ |
|
2530 |
||
2531 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseLessArguments) ) ); |
|
2532 |
User::Leave(KMissingArg); |
|
2533 |
} |
|
2534 |
||
2535 |
||
2536 |
paramContentType = &aInParamList[0] ; |
|
2537 |
if(!paramContentType || paramContentType->Name().Compare(KNullDesC8) != 0) |
|
2538 |
{ |
|
2539 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseContentTypeMissing) ) ); |
|
2540 |
User::Leave(KMissingArg); |
|
2541 |
} |
|
2542 |
} |
|
2543 |
||
2544 |
position = 0; |
|
2545 |
//Get the orgainse data, the value of which is a Map |
|
2546 |
paramOrganiseData = aInParamList.FindFirst( position, KData ); |
|
2547 |
if(!paramOrganiseData) |
|
2548 |
{ |
|
2549 |
if(aInParamList.Count()>2) |
|
2550 |
paramOrganiseData = &aInParamList[1] ; |
|
2551 |
if(!paramOrganiseData || paramOrganiseData->Name().Compare(KNullDesC8) != 0) |
|
2552 |
{ |
|
2553 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseDataMissing) ) ); |
|
2554 |
User::Leave(KMissingArg); |
|
2555 |
} |
|
2556 |
} |
|
2557 |
||
2558 |
position = 0; |
|
2559 |
//Get the operation type, the value of which is a Map |
|
2560 |
paramOperationType = aInParamList.FindFirst( position, KOperationType ); |
|
2561 |
if(!paramOperationType) |
|
2562 |
{ |
|
2563 |
if(aInParamList.Count() == 3) |
|
2564 |
paramOperationType = &aInParamList[2] ; |
|
2565 |
if(!paramOperationType || paramOperationType->Name().Compare(KNullDesC8) != 0) |
|
2566 |
{ |
|
2567 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseOperationTypeMissing) ) ); |
|
2568 |
User::Leave(KMissingArg); |
|
2569 |
} |
|
2570 |
} |
|
2571 |
||
2572 |
//get the content type.. |
|
2573 |
TLiwVariant contentTypeVar = paramContentType->Value(); |
|
2574 |
||
2575 |
if(EVariantTypeDesC !=contentTypeVar.TypeId()) |
|
2576 |
{ |
|
2577 |
contentTypeVar.Reset(); |
|
2578 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseWrongContentType) ) ); |
|
2579 |
||
2580 |
User::Leave(KErrArgument); |
|
2581 |
} |
|
2582 |
||
2583 |
//if content type is " Groups", then.... |
|
2584 |
if( contentTypeVar.AsDes() == KGroup) |
|
2585 |
{ |
|
2586 |
//get the pointer to map in the organise data. |
|
2587 |
const CLiwMap* pMap = paramOrganiseData->Value().AsMap(); |
|
2588 |
if( pMap ) |
|
2589 |
{ |
|
2590 |
TLiwVariant valueGroupid; |
|
2591 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueGroupid) ); |
|
2592 |
||
2593 |
TLiwVariant valueList; |
|
2594 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueList) ); |
|
2595 |
||
2596 |
TLiwVariant valueUri; |
|
2597 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueUri) ); |
|
2598 |
||
2599 |
TPtrC dbUri(VPbkContactStoreUris::DefaultCntDbUri()); |
|
2600 |
TBool associateType = EFalse; |
|
2601 |
HBufC8* groupId = NULL; |
|
2602 |
||
2603 |
if(EVariantTypeDesC != paramOperationType->Value().TypeId() ) |
|
2604 |
{ |
|
2605 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseOperationTypeWrong) ) ); |
|
2606 |
User::Leave(KErrArgument); |
|
2607 |
} |
|
2608 |
||
2609 |
if(paramOperationType->Value().AsDes().Compare(KAssociate)==0) |
|
2610 |
{ |
|
2611 |
associateType = ETrue; |
|
2612 |
} |
|
2613 |
else if(paramOperationType->Value().AsDes().Compare(KDissociate)==0) |
|
2614 |
{ |
|
2615 |
associateType = EFalse; |
|
2616 |
} |
|
2617 |
else |
|
2618 |
{ |
|
2619 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2620 |
TLiwVariant(KOrganiseDataInvalidOpType))); |
|
2621 |
User::Leave(KErrArgument); |
|
2622 |
} |
|
2623 |
||
2624 |
const CLiwList* contactIdList = NULL; |
|
2625 |
//get the values for dburi, groupid, associatetype and id list. |
|
2626 |
if( EFalse != pMap->FindL(KDBUri,valueUri)) |
|
2627 |
{ |
|
2628 |
if(valueUri.AsDes().CompareF(KNullDesC)!=0) |
|
2629 |
{ |
|
2630 |
dbUri.Set(valueUri.AsDes()); |
|
2631 |
} |
|
2632 |
} |
|
2633 |
||
2634 |
if(EFalse != pMap->FindL(KGroupId,valueGroupid)) |
|
2635 |
{ |
|
2636 |
if(EVariantTypeDesC != valueGroupid.TypeId()) |
|
2637 |
{ |
|
2638 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseWrongGrpIdType) ) ); |
|
2639 |
||
2640 |
User::Leave(KErrArgument); |
|
2641 |
} |
|
2642 |
TPtrC grpid = valueGroupid.AsDes(); |
|
2643 |
groupId = ContactIDUTFToStreamL(grpid); |
|
2644 |
} |
|
2645 |
else |
|
2646 |
{ |
|
2647 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2648 |
TLiwVariant(KOrganiseGrpIdMissing))); |
|
2649 |
User::Leave(KMissingArg); |
|
2650 |
} |
|
2651 |
||
2652 |
if(EFalse != pMap->FindL(KList,valueList)) |
|
2653 |
{ |
|
2654 |
if(EVariantTypeList != valueList.TypeId()) |
|
2655 |
{ |
|
2656 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseWrongIdListType) ) ); |
|
2657 |
User::Leave(KErrArgument); |
|
2658 |
} |
|
2659 |
contactIdList = valueList.AsList(); |
|
2660 |
} |
|
2661 |
else |
|
2662 |
{ |
|
2663 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2664 |
TLiwVariant(KOrganiseDataListMissing))); |
|
2665 |
User::Leave(KMissingArg); |
|
2666 |
} |
|
2667 |
||
2668 |
CleanupStack :: PushL(groupId); |
|
2669 |
//get the number of contact ids in the list. |
|
2670 |
TInt idCount = contactIdList->Count(); |
|
2671 |
if(idCount == 0) |
|
2672 |
{ |
|
2673 |
aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KOrganiseEmptyIdList) ) ); |
|
2674 |
User::Leave(KErrArgument); |
|
2675 |
} |
|
2676 |
TLiwVariant valueId; |
|
2677 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &valueId) ); |
|
2678 |
||
2679 |
//create the contact id array and append the ids from the list to this |
|
2680 |
//contactIdArray |
|
2681 |
RPointerArray<TDesC8> contactIdArray; |
|
2682 |
CleanupClosePushL(contactIdArray); |
|
2683 |
||
2684 |
for(TInt index = 0; index < idCount; index++) |
|
2685 |
{ |
|
2686 |
contactIdList->AtL(index, valueId); |
|
2687 |
if(EVariantTypeDesC != valueId.TypeId()) |
|
2688 |
{ |
|
2689 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2690 |
TLiwVariant(KOrganiseWrongIdType))); |
|
2691 |
User::Leave(KErrArgument); |
|
2692 |
} |
|
2693 |
||
2694 |
TPtrC cntIdUnicode = valueId.AsDes(); |
|
2695 |
HBufC8* cntid = ContactIDUTFToStreamL(cntIdUnicode); |
|
2696 |
CleanupStack :: PushL(cntid); |
|
2697 |
contactIdArray.AppendL(cntid); |
|
2698 |
} |
|
2699 |
if(aCmdOptions == KLiwOptASyncronous) |
|
2700 |
{ |
|
2701 |
CContactInterfaceCallback* contactCallback = |
|
2702 |
CContactInterfaceCallback::NewL(); |
|
2703 |
||
2704 |
CleanupStack :: PushL(contactCallback); |
|
2705 |
//Set the params of the contact callback |
|
2706 |
contactCallback->SetParams(aCallback, |
|
2707 |
aTransId, |
|
2708 |
&aInParamList); |
|
2709 |
//invoke the main method of the contactService |
|
2710 |
//to Associate/Disassocite |
|
2711 |
//list of contacts to/from the group. |
|
2712 |
iContactService->OrganiseGroupsL(contactCallback, |
|
2713 |
aTransId, |
|
2714 |
*groupId, |
|
2715 |
contactIdArray, |
|
2716 |
associateType, |
|
2717 |
dbUri); |
|
2718 |
||
2719 |
CleanupStack :: Pop(contactCallback); |
|
2720 |
} |
|
2721 |
else |
|
2722 |
{ |
|
2723 |
//it is assumed that the call is synchronous |
|
2724 |
iContactService->OrganiseGroupsL(*groupId, |
|
2725 |
contactIdArray, |
|
2726 |
associateType, |
|
2727 |
dbUri); |
|
2728 |
} |
|
2729 |
//cleanup |
|
2730 |
CleanupStack::PopAndDestroy(contactIdArray.Count()); |
|
2731 |
CleanupStack::PopAndDestroy(); |
|
2732 |
CleanupStack::Pop(&valueId); |
|
2733 |
valueId.Reset(); |
|
2734 |
CleanupStack::PopAndDestroy(groupId); |
|
2735 |
CleanupStack::Pop(&valueUri); |
|
2736 |
valueUri.Reset(); |
|
2737 |
CleanupStack::Pop(&valueList); |
|
2738 |
valueList.Reset(); |
|
2739 |
CleanupStack::Pop(&valueGroupid); |
|
2740 |
valueGroupid.Reset(); |
|
2741 |
} |
|
2742 |
else |
|
2743 |
{ |
|
2744 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2745 |
TLiwVariant(KOrganiseDataMapMissing))); |
|
2746 |
User::Leave(KMissingArg); |
|
2747 |
||
2748 |
} |
|
2749 |
contentTypeVar.Reset(); |
|
2750 |
} |
|
2751 |
else |
|
2752 |
{ |
|
2753 |
aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
2754 |
TLiwVariant(KOrganiseInvalidContentType))); |
|
2755 |
User::Leave(KMissingArg); |
|
2756 |
} |
|
2757 |
} |