1 /* |
|
2 * Copyright (c) 2008 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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "creator_contactelement.h" |
|
20 #include "creator_traces.h" |
|
21 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
|
22 #include "creator_virtualphonebook.h" |
|
23 #endif |
|
24 #include "creator_factory.h" |
|
25 #include "creator_contactsetcache.h" |
|
26 #include <xml/documentparameters.h> |
|
27 |
|
28 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
|
29 #include "VPbkEng.rsg" |
|
30 #endif |
|
31 |
|
32 using namespace Xml; |
|
33 using namespace creatorcontact; |
|
34 |
|
35 /** |
|
36 * Contact field element mappings: |
|
37 */ |
|
38 enum TContactFieldDataType |
|
39 { |
|
40 EDataTypeText, |
|
41 EDataTypeBinary, |
|
42 EDataTypeDateTime |
|
43 }; |
|
44 |
|
45 class FieldMapping |
|
46 { |
|
47 public: |
|
48 TPtrC iElementName; |
|
49 TInt iFieldCode; |
|
50 TContactFieldDataType iDataType; |
|
51 }; |
|
52 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
|
53 FieldMapping fieldMappingTbl[] = { |
|
54 {TPtrC(KFirstname), R_VPBK_FIELD_TYPE_FIRSTNAME, EDataTypeText}, |
|
55 {TPtrC(KLastname), R_VPBK_FIELD_TYPE_LASTNAME, EDataTypeText}, |
|
56 {TPtrC(KFirstnameReading), R_VPBK_FIELD_TYPE_FIRSTNAMEREADING, EDataTypeText}, |
|
57 {TPtrC(KLastnameReading), R_VPBK_FIELD_TYPE_LASTNAMEREADING, EDataTypeText}, |
|
58 {TPtrC(KPrefix), R_VPBK_FIELD_TYPE_PREFIX, EDataTypeText}, |
|
59 {TPtrC(KSuffix), R_VPBK_FIELD_TYPE_SUFFIX, EDataTypeText}, |
|
60 {TPtrC(KSecondname), R_VPBK_FIELD_TYPE_SECONDNAME, EDataTypeText}, |
|
61 {TPtrC(KLandphoneHome), R_VPBK_FIELD_TYPE_LANDPHONEHOME, EDataTypeText}, |
|
62 |
|
63 {TPtrC(KMobilephoneHome), R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, EDataTypeText}, |
|
64 {TPtrC(KVideonumberHome), R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, EDataTypeText}, |
|
65 {TPtrC(KFaxnumberHome), R_VPBK_FIELD_TYPE_FAXNUMBERHOME, EDataTypeText}, |
|
66 {TPtrC(KVoipHome), R_VPBK_FIELD_TYPE_VOIPHOME, EDataTypeText}, |
|
67 {TPtrC(KEmailHome), R_VPBK_FIELD_TYPE_EMAILHOME, EDataTypeText}, |
|
68 {TPtrC(KUrlHome), R_VPBK_FIELD_TYPE_URLHOME, EDataTypeText}, |
|
69 {TPtrC(KAddrlabelHome), R_VPBK_FIELD_TYPE_ADDRLABELHOME, EDataTypeText}, |
|
70 {TPtrC(KAddrpoHome), R_VPBK_FIELD_TYPE_ADDRPOHOME, EDataTypeText}, |
|
71 |
|
72 {TPtrC(KAddrextHome), R_VPBK_FIELD_TYPE_ADDREXTHOME, EDataTypeText}, |
|
73 {TPtrC(KAddrstreetHome), R_VPBK_FIELD_TYPE_ADDRSTREETHOME, EDataTypeText}, |
|
74 {TPtrC(KAddrlocalHome), R_VPBK_FIELD_TYPE_ADDRLOCALHOME, EDataTypeText}, |
|
75 {TPtrC(KAddrregionHome), R_VPBK_FIELD_TYPE_ADDRREGIONHOME, EDataTypeText}, |
|
76 {TPtrC(KAddrpostcodeHome), R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME, EDataTypeText}, |
|
77 {TPtrC(KAddrcountryHome), R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME, EDataTypeText}, |
|
78 {TPtrC(KJobtitle), R_VPBK_FIELD_TYPE_JOBTITLE, EDataTypeText}, |
|
79 {TPtrC(KCompanyname), R_VPBK_FIELD_TYPE_COMPANYNAME, EDataTypeText}, |
|
80 |
|
81 {TPtrC(KLandphoneWork), R_VPBK_FIELD_TYPE_LANDPHONEWORK, EDataTypeText}, |
|
82 {TPtrC(KMobilephoneWork), R_VPBK_FIELD_TYPE_MOBILEPHONEWORK, EDataTypeText}, |
|
83 {TPtrC(KVideonumberWork), R_VPBK_FIELD_TYPE_VIDEONUMBERWORK, EDataTypeText}, |
|
84 {TPtrC(KFaxnumberWork), R_VPBK_FIELD_TYPE_FAXNUMBERWORK, EDataTypeText}, |
|
85 {TPtrC(KVoipWork), R_VPBK_FIELD_TYPE_VOIPWORK, EDataTypeText}, |
|
86 {TPtrC(KEmailWork), R_VPBK_FIELD_TYPE_EMAILWORK, EDataTypeText}, |
|
87 {TPtrC(KUrlWork), R_VPBK_FIELD_TYPE_URLWORK, EDataTypeText}, |
|
88 {TPtrC(KAddrlabelWork), R_VPBK_FIELD_TYPE_ADDRLABELWORK, EDataTypeText}, |
|
89 |
|
90 {TPtrC(KAddrpoWork), R_VPBK_FIELD_TYPE_ADDRPOWORK, EDataTypeText}, |
|
91 {TPtrC(KAddrextWork), R_VPBK_FIELD_TYPE_ADDREXTWORK, EDataTypeText}, |
|
92 {TPtrC(KAddrstreetWork), R_VPBK_FIELD_TYPE_ADDRSTREETWORK, EDataTypeText}, |
|
93 {TPtrC(KAddrlocalWork), R_VPBK_FIELD_TYPE_ADDRLOCALWORK, EDataTypeText}, |
|
94 {TPtrC(KAddrregionWork), R_VPBK_FIELD_TYPE_ADDRREGIONWORK, EDataTypeText}, |
|
95 {TPtrC(KAddrpostcodeWork), R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK, EDataTypeText}, |
|
96 {TPtrC(KAddrcountryWork), R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK, EDataTypeText}, |
|
97 {TPtrC(KLandphoneGen), R_VPBK_FIELD_TYPE_LANDPHONEGEN, EDataTypeText}, |
|
98 |
|
99 {TPtrC(KMobilephoneGen), R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, EDataTypeText}, |
|
100 {TPtrC(KVideonumberGen), R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, EDataTypeText}, |
|
101 {TPtrC(KFaxnumberGen), R_VPBK_FIELD_TYPE_FAXNUMBERGEN, EDataTypeText}, |
|
102 {TPtrC(KVoipGen), R_VPBK_FIELD_TYPE_VOIPGEN, EDataTypeText}, |
|
103 {TPtrC(KPoc), R_VPBK_FIELD_TYPE_POC, EDataTypeText}, |
|
104 {TPtrC(KSwis), R_VPBK_FIELD_TYPE_SWIS, EDataTypeText}, |
|
105 {TPtrC(KSip), R_VPBK_FIELD_TYPE_SIP, EDataTypeText}, |
|
106 {TPtrC(KEmailGen), R_VPBK_FIELD_TYPE_EMAILGEN, EDataTypeText}, |
|
107 |
|
108 {TPtrC(KUrlGen), R_VPBK_FIELD_TYPE_URLGEN, EDataTypeText}, |
|
109 {TPtrC(KAddrlabelGen), R_VPBK_FIELD_TYPE_ADDRLABELGEN, EDataTypeText}, |
|
110 {TPtrC(KAddrpoGen), R_VPBK_FIELD_TYPE_ADDRPOGEN, EDataTypeText}, |
|
111 {TPtrC(KAddrextGen), R_VPBK_FIELD_TYPE_ADDREXTGEN, EDataTypeText}, |
|
112 {TPtrC(KAddrstreetGen), R_VPBK_FIELD_TYPE_ADDRSTREETGEN, EDataTypeText}, |
|
113 {TPtrC(KAddrlocalGen), R_VPBK_FIELD_TYPE_ADDRLOCALGEN, EDataTypeText}, |
|
114 {TPtrC(KAddrregionGen), R_VPBK_FIELD_TYPE_ADDRREGIONGEN, EDataTypeText}, |
|
115 {TPtrC(KAddrpostcodeGen), R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN, EDataTypeText}, |
|
116 |
|
117 {TPtrC(KAddrcountryGen), R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN, EDataTypeText}, |
|
118 {TPtrC(KPagerNumber), R_VPBK_FIELD_TYPE_PAGERNUMBER, EDataTypeText}, |
|
119 {TPtrC(KDtmfString), R_VPBK_FIELD_TYPE_DTMFSTRING, EDataTypeText}, |
|
120 {TPtrC(KWvAddress), R_VPBK_FIELD_TYPE_WVADDRESS, EDataTypeText}, |
|
121 {TPtrC(KDate), R_VPBK_FIELD_TYPE_DATE, EDataTypeDateTime}, |
|
122 {TPtrC(KNote), R_VPBK_FIELD_TYPE_NOTE, EDataTypeText}, |
|
123 {TPtrC(KThumbnailPath), R_VPBK_FIELD_TYPE_THUMBNAILPIC, EDataTypeText}, |
|
124 {TPtrC(KThumbnailId), R_VPBK_FIELD_TYPE_THUMBNAILPIC, EDataTypeText}, |
|
125 {TPtrC(KRingTone), R_VPBK_FIELD_TYPE_RINGTONE, EDataTypeText}, |
|
126 {TPtrC(KRingToneId), R_VPBK_FIELD_TYPE_RINGTONE, EDataTypeText}, |
|
127 |
|
128 {TPtrC(KCallerobjImg), R_VPBK_FIELD_TYPE_CALLEROBJIMG, EDataTypeText}, |
|
129 {TPtrC(KCallerobjText), R_VPBK_FIELD_TYPE_CALLEROBJTEXT, EDataTypeText}, |
|
130 {TPtrC(KMiddlename), R_VPBK_FIELD_TYPE_MIDDLENAME, EDataTypeText}, |
|
131 {TPtrC(KDepartment), R_VPBK_FIELD_TYPE_DEPARTMENT, EDataTypeText}, |
|
132 {TPtrC(KAsstname), R_VPBK_FIELD_TYPE_ASSTNAME, EDataTypeText}, |
|
133 {TPtrC(KSpouse), R_VPBK_FIELD_TYPE_SPOUSE, EDataTypeText}, |
|
134 {TPtrC(KChildren), R_VPBK_FIELD_TYPE_CHILDREN, EDataTypeText}, |
|
135 {TPtrC(KAsstphone), R_VPBK_FIELD_TYPE_ASSTPHONE, EDataTypeText}, |
|
136 |
|
137 {TPtrC(KCarphone), R_VPBK_FIELD_TYPE_CARPHONE, EDataTypeText}, |
|
138 {TPtrC(KAnniversary), R_VPBK_FIELD_TYPE_ANNIVERSARY, EDataTypeDateTime}, |
|
139 {TPtrC(KSyncclass), R_VPBK_FIELD_TYPE_SYNCCLASS, EDataTypeText}, |
|
140 {TPtrC(KLocPrivacy), R_VPBK_FIELD_TYPE_LOCPRIVACY, EDataTypeText}, |
|
141 {TPtrC(KGenlabel), R_VPBK_FIELD_TYPE_GENLABEL, EDataTypeText} |
|
142 }; |
|
143 #endif |
|
144 |
|
145 CCreatorContactElementBase* CCreatorContactElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
146 { |
|
147 LOGSTRING("Creator: CCreatorContactElementBase::NewL"); |
|
148 CCreatorContactElementBase* self = new (ELeave) CCreatorContactElementBase(aEngine); |
|
149 CleanupStack::PushL(self); |
|
150 self->ConstructL(aName, aContext); |
|
151 CleanupStack::Pop(); |
|
152 return self; |
|
153 } |
|
154 CCreatorContactElementBase::CCreatorContactElementBase(CCreatorEngine* aEngine) : CCreatorScriptElement(aEngine) |
|
155 { } |
|
156 |
|
157 CCreatorContactElement* CCreatorContactElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
158 { |
|
159 LOGSTRING("Creator: CCreatorContactElement::NewL"); |
|
160 CCreatorContactElement* self = new (ELeave) CCreatorContactElement(aEngine); |
|
161 CleanupStack::PushL(self); |
|
162 self->ConstructL(aName, aContext); |
|
163 CleanupStack::Pop(); |
|
164 return self; |
|
165 } |
|
166 CCreatorContactElement::CCreatorContactElement(CCreatorEngine* aEngine) |
|
167 : |
|
168 CCreatorContactElementBase(aEngine) |
|
169 { |
|
170 iIsCommandElement = ETrue; |
|
171 } |
|
172 |
|
173 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
|
174 void CCreatorContactElement::ExecuteCommandL() |
|
175 { |
|
176 LOGSTRING("Creator: CCreatorContactElement::ExecuteCommandL"); |
|
177 // Find out how many contacts should we create: |
|
178 const CCreatorScriptAttribute* contactAmountAttr = this->FindAttributeByName(KAmount); |
|
179 TInt contactAmount = 1; |
|
180 if( contactAmountAttr ) |
|
181 { |
|
182 contactAmount = ConvertStrToIntL(contactAmountAttr->Value()); |
|
183 } |
|
184 CCreatorScriptElement* fieldsElement = FindSubElement(KFields); |
|
185 TInt fieldMappingTblSize = sizeof(fieldMappingTbl)/sizeof(FieldMapping); |
|
186 for( TInt cI = 0; cI < contactAmount; ++cI ) |
|
187 { |
|
188 CVirtualPhonebookParameters* param = (CVirtualPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL(); |
|
189 CleanupStack::PushL(param); |
|
190 // Loop all the field elements |
|
191 if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) |
|
192 { |
|
193 |
|
194 const RPointerArray<CCreatorScriptElement>& fieldList = fieldsElement->SubElements(); |
|
195 |
|
196 if( fieldList.Count() == 0 ) |
|
197 { |
|
198 |
|
199 } |
|
200 for( TInt i = 0; i < fieldList.Count(); ++i ) |
|
201 { |
|
202 TPtrC fieldName = fieldList[i]->Name(); |
|
203 const CCreatorScriptAttribute* amountAttr = fieldList[i]->FindAttributeByName(KAmount); |
|
204 const CCreatorScriptAttribute* rndLenAttr = fieldList[i]->FindAttributeByName(KRandomLength); |
|
205 const CCreatorScriptAttribute* increaseAttr = fieldList[i]->FindAttributeByName(KIncrease); |
|
206 TBool increase( EFalse ); |
|
207 if ( increaseAttr ) |
|
208 { |
|
209 increase = ConvertStrToBooleanL( increaseAttr->Value() ); |
|
210 } |
|
211 CCreatorContactField* field = 0; |
|
212 for( TInt j = 0; j < fieldMappingTblSize; ++j ) |
|
213 { |
|
214 const FieldMapping& mapping = fieldMappingTbl[j]; |
|
215 if( fieldName == mapping.iElementName ) |
|
216 { |
|
217 TInt rndLen = 0; |
|
218 TPtrC content = fieldList[i]->Content(); |
|
219 |
|
220 MCreatorRandomDataField::TRandomLengthType randomLenType = MCreatorRandomDataField::ERandomLengthUndefined; |
|
221 |
|
222 if( content == TPtrC(KEmpty) || content == TPtrC(KNullDesC) ) |
|
223 { |
|
224 if( rndLenAttr == 0 ) |
|
225 { |
|
226 randomLenType = MCreatorRandomDataField::ERandomLengthDefault; |
|
227 } |
|
228 else |
|
229 { |
|
230 randomLenType = ResolveRandomDataTypeL(*rndLenAttr, rndLen); |
|
231 } |
|
232 } |
|
233 else |
|
234 { |
|
235 // Special handling for file id content: |
|
236 if( fieldName == KThumbnailId ) |
|
237 { |
|
238 // Thumbnail data is copied to the contact entry, so we can use temporary file: |
|
239 CCreatorEngine::TTestDataPath id = (CCreatorEngine::TTestDataPath) iEngine->GetAttachmentIdL(content); |
|
240 content.Set(iEngine->TestDataPathL(id)); |
|
241 } |
|
242 else if( fieldName == KRingToneId ) |
|
243 { |
|
244 // Contact entry contains just a link to the sound file, so we must |
|
245 // copy the temporary file to a permanent location: |
|
246 CCreatorEngine::TTestDataPath id = (CCreatorEngine::TTestDataPath) iEngine->GetAttachmentIdL(content); |
|
247 TPtrC fullTargetPath(iEngine->CreateSoundFileL(id)); |
|
248 content.Set(fullTargetPath); |
|
249 } |
|
250 } |
|
251 TInt amountValue = 1; |
|
252 if( amountAttr ) |
|
253 { |
|
254 amountValue = ConvertStrToIntL(amountAttr->Value()); |
|
255 } |
|
256 for( TInt k = 0; k < amountValue; ++k ) |
|
257 { |
|
258 if ( increase && |
|
259 ( fieldName.FindF( _L("number") ) > KErrNotFound || |
|
260 fieldName.FindF( _L("phone") ) > KErrNotFound ) ) |
|
261 { |
|
262 // increase phonenumber for each copy |
|
263 HBufC* incNum = HBufC::NewLC( content.Length() + 3 ); |
|
264 if ( amountValue > 1 ) |
|
265 { |
|
266 // amount defined in number field level |
|
267 IncreasePhoneNumL( content, k, incNum ); |
|
268 } |
|
269 else |
|
270 { |
|
271 // amount defined in contact field level |
|
272 IncreasePhoneNumL( content, cI, incNum ); |
|
273 } |
|
274 field = CCreatorContactField::NewL( mapping.iFieldCode, *incNum ); |
|
275 CleanupStack::PushL( field ); |
|
276 field->SetRandomParametersL( randomLenType, rndLen ); |
|
277 param->iContactFields.AppendL( field ); |
|
278 CleanupStack::Pop( field ); |
|
279 CleanupStack::PopAndDestroy( incNum ); |
|
280 } |
|
281 else |
|
282 { |
|
283 field = CCreatorContactField::NewL(mapping.iFieldCode, content); |
|
284 CleanupStack::PushL(field); |
|
285 field->SetRandomParametersL(randomLenType, rndLen); |
|
286 param->iContactFields.AppendL(field); |
|
287 CleanupStack::Pop(field); |
|
288 } |
|
289 } |
|
290 break; |
|
291 } |
|
292 } |
|
293 } |
|
294 } |
|
295 else |
|
296 { |
|
297 // No fields specified, so add all fields with random content: |
|
298 for( TInt i = 0; i < fieldMappingTblSize; ++i ) |
|
299 { |
|
300 if( fieldMappingTbl[i].iElementName == KThumbnailId || |
|
301 fieldMappingTbl[i].iElementName == KRingToneId ) |
|
302 { |
|
303 // Skip thumbnail and ringtone IDs, since they are duplicates with thumbnailpath and ringtonepath |
|
304 continue; |
|
305 } |
|
306 CCreatorContactField* field = 0; |
|
307 if(fieldMappingTbl[i].iDataType == EDataTypeText ) |
|
308 { |
|
309 field = CCreatorContactField::NewL(fieldMappingTbl[i].iFieldCode, KNullDesC); |
|
310 } |
|
311 else if( fieldMappingTbl[i].iDataType == EDataTypeBinary ) |
|
312 { |
|
313 field = CCreatorContactField::NewL(fieldMappingTbl[i].iFieldCode, KNullDesC8); |
|
314 } |
|
315 else if( fieldMappingTbl[i].iDataType == EDataTypeDateTime ) |
|
316 { |
|
317 TDateTime dateTime(Time::NullTTime().DateTime()); |
|
318 field = CCreatorContactField::NewL(fieldMappingTbl[i].iFieldCode, dateTime); |
|
319 } |
|
320 if( field ) |
|
321 { |
|
322 CleanupStack::PushL(field); |
|
323 field->SetRandomParametersL(MCreatorRandomDataField::ERandomLengthDefault, 0); |
|
324 param->iContactFields.AppendL(field); |
|
325 CleanupStack::Pop(field); |
|
326 } |
|
327 } |
|
328 } |
|
329 iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryContacts, param); |
|
330 iParameters.AppendL(param); // Save the pointer to the parametes. |
|
331 CleanupStack::Pop(param); |
|
332 } |
|
333 } |
|
334 #else |
|
335 void CCreatorContactElement::ExecuteCommandL() |
|
336 {} |
|
337 #endif |
|
338 |
|
339 CCreatorContactSetElement* CCreatorContactSetElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
340 { |
|
341 LOGSTRING("Creator: CCreatorContactSetElement::NewL"); |
|
342 CCreatorContactSetElement* self = new (ELeave) CCreatorContactSetElement(aEngine); |
|
343 CleanupStack::PushL(self); |
|
344 self->ConstructL(aName, aContext); |
|
345 CleanupStack::Pop(); |
|
346 return self; |
|
347 } |
|
348 CCreatorContactSetElement::CCreatorContactSetElement(CCreatorEngine* aEngine) |
|
349 : |
|
350 CCreatorContactElementBase(aEngine) |
|
351 { } |
|
352 |
|
353 void CCreatorContactSetElement::ExecuteCommandL() |
|
354 { } |
|
355 |
|
356 void CCreatorContactSetElement::AddToCacheL() |
|
357 { |
|
358 LOGSTRING("Creator: CCreatorContactSetElement::AddToCacheL"); |
|
359 const CCreatorScriptAttribute* linkIdAttr = this->FindAttributeByName(KId); |
|
360 const CCreatorScriptAttribute* existingElemsAttr = this->FindAttributeByName(KExistingContacts); |
|
361 TInt numOfExistingContacts = 0; |
|
362 if( existingElemsAttr ) |
|
363 { |
|
364 numOfExistingContacts = ConvertStrToIntL(existingElemsAttr->Value()); |
|
365 } |
|
366 if( linkIdAttr ) |
|
367 { |
|
368 TInt linkId = ConvertStrToIntL(linkIdAttr->Value()); |
|
369 if( linkId > 0 ) |
|
370 { |
|
371 CCreatorContactSet* newSet = CCreatorContactSet::NewL(linkId, numOfExistingContacts); |
|
372 CleanupStack::PushL(newSet); |
|
373 ContactLinkCache::Instance()->AppendL(newSet); |
|
374 CleanupStack::Pop(newSet); |
|
375 |
|
376 // Mark sub-elements (i.e. contacts) to this contact-set: |
|
377 for( TInt i = 0; i < iSubElements.Count(); ++i ) |
|
378 { |
|
379 for( TInt j = 0; j < iSubElements[i]->CommandParameters().Count(); ++j) |
|
380 { |
|
381 CCreatorModuleBaseParameters* params = iSubElements[i]->CommandParameters()[j]; |
|
382 if( params ) |
|
383 { |
|
384 params->SetScriptLinkId(linkId); |
|
385 } |
|
386 } |
|
387 } |
|
388 } |
|
389 } |
|
390 } |
|
391 |
|
392 CCreatorContactGroupElement* CCreatorContactGroupElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
393 { |
|
394 LOGSTRING("Creator: CCreatorContactGroupElement::NewL"); |
|
395 CCreatorContactGroupElement* self = new (ELeave) CCreatorContactGroupElement(aEngine); |
|
396 CleanupStack::PushL(self); |
|
397 self->ConstructL(aName, aContext); |
|
398 CleanupStack::Pop(); |
|
399 return self; |
|
400 } |
|
401 CCreatorContactGroupElement::CCreatorContactGroupElement(CCreatorEngine* aEngine) |
|
402 : |
|
403 CCreatorContactElementBase(aEngine) |
|
404 { |
|
405 iIsCommandElement = ETrue; |
|
406 } |
|
407 |
|
408 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__ ) |
|
409 void CCreatorContactGroupElement::ExecuteCommandL() |
|
410 { |
|
411 LOGSTRING("Creator: CCreatorContactGroupElement::ExecuteCommandL"); |
|
412 // Get attributes (amount and name) |
|
413 const CCreatorScriptAttribute* groupAmountAttr = this->FindAttributeByName(KAmount); |
|
414 const CCreatorScriptAttribute* groupNameAttr = this->FindAttributeByName(KName); |
|
415 // How many groups to create: |
|
416 TInt groupAmount = 1; |
|
417 if( groupAmountAttr ) |
|
418 { |
|
419 groupAmount = ConvertStrToIntL(groupAmountAttr->Value()); |
|
420 } |
|
421 |
|
422 for( TInt i = 0; i < groupAmount; ++i ) |
|
423 { |
|
424 CCreatorScriptElement* membersElement = FindSubElement(KMembers); |
|
425 |
|
426 if( membersElement ) |
|
427 { |
|
428 CVirtualPhonebookParameters* param = (CVirtualPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL(); |
|
429 CleanupStack::PushL(param); |
|
430 |
|
431 // Links to contact-sets: |
|
432 const RPointerArray<CCreatorScriptElement>& linkList = membersElement->SubElements(); |
|
433 if( linkList.Count() > 0 ) |
|
434 { |
|
435 for( TInt i = 0; i < linkList.Count(); ++i ) |
|
436 { |
|
437 AppendContactSetReferenceL(*linkList[i], param->iLinkIds); |
|
438 } |
|
439 } |
|
440 |
|
441 if( groupNameAttr ) |
|
442 { |
|
443 param->iGroupName->Des().Copy( groupNameAttr->Value() ); |
|
444 } |
|
445 else |
|
446 { |
|
447 param->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); |
|
448 } |
|
449 iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryGroups, param); |
|
450 CleanupStack::Pop(param); |
|
451 } |
|
452 } |
|
453 } |
|
454 #else |
|
455 void CCreatorContactGroupElement::ExecuteCommandL() |
|
456 {} |
|
457 #endif |
|
458 |
|
459 CCreatorContactFieldElement* CCreatorContactFieldElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
460 { |
|
461 LOGSTRING("Creator: CCreatorContactFieldElement::NewL"); |
|
462 CCreatorContactFieldElement* self = new (ELeave) CCreatorContactFieldElement(aEngine); |
|
463 CleanupStack::PushL(self); |
|
464 self->ConstructL(aName, aContext); |
|
465 CleanupStack::Pop(); |
|
466 return self; |
|
467 } |
|
468 |
|
469 CCreatorContactFieldElement::CCreatorContactFieldElement(CCreatorEngine* aEngine) |
|
470 : |
|
471 CCreatorScriptElement(aEngine) |
|
472 { } |
|