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