1 /* |
|
2 * Copyright (c) 2010 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 |
|
20 #include "creator_traces.h" |
|
21 #include "creator_scriptelement.h" |
|
22 #include <xml/documentparameters.h> |
|
23 #include <collate.h> |
|
24 #include <etel3rdparty.h> // KMaxTelNumberSize |
|
25 |
|
26 using namespace Xml; |
|
27 |
|
28 CCreatorScriptElementCache* CCreatorScriptElementCache::NewL() |
|
29 { |
|
30 CCreatorScriptElementCache* self = new (ELeave) CCreatorScriptElementCache; |
|
31 CleanupStack::PushL(self); |
|
32 |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CCreatorScriptElementCache::CCreatorScriptElementCache() |
|
39 { |
|
40 |
|
41 } |
|
42 |
|
43 void CCreatorScriptElementCache::ConstructL() |
|
44 { |
|
45 |
|
46 } |
|
47 |
|
48 CCreatorScriptElementCache::~CCreatorScriptElementCache() |
|
49 { |
|
50 iElementCache.Reset(); |
|
51 iElementCache.Close(); |
|
52 } |
|
53 |
|
54 void CCreatorScriptElementCache::RemoveElements() |
|
55 { |
|
56 iElementCache.Reset(); |
|
57 } |
|
58 |
|
59 |
|
60 void CCreatorScriptElementCache::AddElementL(CCreatorScriptElement* aElement) |
|
61 { |
|
62 iElementCache.AppendL(aElement); |
|
63 } |
|
64 |
|
65 /** |
|
66 * |
|
67 */ |
|
68 CCreatorScriptAttribute* CCreatorScriptAttribute::NewLC(const TDesC& aName, const TDesC& aValue) |
|
69 { |
|
70 CCreatorScriptAttribute* self = new(ELeave) CCreatorScriptAttribute(); |
|
71 CleanupStack::PushL(self); |
|
72 self->ConstructL(aName, aValue); |
|
73 return self; |
|
74 } |
|
75 |
|
76 CCreatorScriptAttribute* CCreatorScriptAttribute::NewL(const TDesC& aName, const TDesC& aValue) |
|
77 { |
|
78 CCreatorScriptAttribute* self = CCreatorScriptAttribute::NewLC(aName, aValue); |
|
79 CleanupStack::Pop(); // self |
|
80 return self; |
|
81 } |
|
82 |
|
83 CCreatorScriptAttribute::~CCreatorScriptAttribute() |
|
84 { |
|
85 delete iName; |
|
86 delete iValue; |
|
87 } |
|
88 |
|
89 TPtrC CCreatorScriptAttribute::Name() const |
|
90 { |
|
91 return iName->Des(); |
|
92 } |
|
93 |
|
94 void CCreatorScriptAttribute::SetNameL(const TDesC& aName) |
|
95 { |
|
96 if( iName ) |
|
97 { |
|
98 delete iName; |
|
99 iName = 0; |
|
100 } |
|
101 iName = HBufC::NewL(aName.Length()); |
|
102 iName->Des() = aName; |
|
103 } |
|
104 |
|
105 TPtrC CCreatorScriptAttribute::Value() const |
|
106 { |
|
107 return iValue->Des(); |
|
108 } |
|
109 |
|
110 void CCreatorScriptAttribute::SetValueL(const TDesC& aValue) |
|
111 { |
|
112 if( iValue ) |
|
113 { |
|
114 delete iValue; |
|
115 iValue = 0; |
|
116 } |
|
117 iValue = HBufC::NewL(aValue.Length()); |
|
118 iValue->Des() = aValue; |
|
119 } |
|
120 |
|
121 CCreatorScriptAttribute::CCreatorScriptAttribute() |
|
122 { |
|
123 } |
|
124 |
|
125 void CCreatorScriptAttribute::ConstructL(const TDesC& aName, const TDesC& aValue) |
|
126 { |
|
127 SetNameL(aName); |
|
128 SetValueL(aValue); |
|
129 } |
|
130 |
|
131 /** |
|
132 * CCreatorScriptElement |
|
133 */ |
|
134 |
|
135 CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
136 { |
|
137 CCreatorScriptElement* self = new (ELeave) CCreatorScriptElement(aEngine); |
|
138 CleanupStack::PushL(self); |
|
139 self->ConstructL(aName, aContext); |
|
140 CleanupStack::Pop(); |
|
141 return self; |
|
142 } |
|
143 |
|
144 CCreatorScriptElement::~CCreatorScriptElement() |
|
145 { |
|
146 LOGSTRING("Creator: CCreatorScriptElement::~CCreatorScriptElement"); |
|
147 iSubElements.ResetAndDestroy(); |
|
148 iAttributes.ResetAndDestroy(); |
|
149 iSubElements.Close(); |
|
150 iAttributes.Close(); |
|
151 iParameters.Reset(); |
|
152 iParameters.Close(); |
|
153 delete iName; |
|
154 delete iContent; |
|
155 delete iContext; |
|
156 } |
|
157 |
|
158 RPointerArray<CCreatorScriptElement> const& CCreatorScriptElement::SubElements() const |
|
159 { |
|
160 return iSubElements; |
|
161 } |
|
162 |
|
163 RPointerArray<CCreatorScriptElement>& CCreatorScriptElement::SubElements() |
|
164 { |
|
165 return iSubElements; |
|
166 } |
|
167 |
|
168 CCreatorScriptElement* CCreatorScriptElement::SubElement(TInt aIndex) |
|
169 { |
|
170 return iSubElements[aIndex]; |
|
171 } |
|
172 |
|
173 CCreatorScriptElement* CCreatorScriptElement::FindSubElement(const TDesC& aName) |
|
174 { |
|
175 for( TInt i = 0; i < iSubElements.Count(); ++i ) |
|
176 { |
|
177 if( iSubElements[i]->Name() == aName ) |
|
178 { |
|
179 return iSubElements[i]; |
|
180 } |
|
181 } |
|
182 return 0; |
|
183 } |
|
184 |
|
185 void CCreatorScriptElement::RemoveSubElements() |
|
186 { |
|
187 iSubElements.ResetAndDestroy(); |
|
188 } |
|
189 |
|
190 void CCreatorScriptElement::RemoveSubElementL(TInt aIndex) |
|
191 { |
|
192 if( aIndex < iSubElements.Count()) |
|
193 { |
|
194 delete iSubElements[aIndex]; |
|
195 iSubElements.Remove(aIndex); |
|
196 } |
|
197 else |
|
198 { |
|
199 User::Leave(KErrArgument); |
|
200 } |
|
201 } |
|
202 |
|
203 void CCreatorScriptElement::AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex ) |
|
204 { |
|
205 if( aIndex == -1 || aIndex == iSubElements.Count() ) |
|
206 { |
|
207 iSubElements.AppendL(aElem); |
|
208 } |
|
209 else if( aIndex < iSubElements.Count()) |
|
210 { |
|
211 iSubElements.Insert(aElem, aIndex); |
|
212 } |
|
213 else |
|
214 { |
|
215 User::Leave(KErrArgument); |
|
216 } |
|
217 } |
|
218 |
|
219 RPointerArray<CCreatorScriptAttribute> const& CCreatorScriptElement::Attributes() const |
|
220 { |
|
221 return iAttributes; |
|
222 } |
|
223 |
|
224 |
|
225 CCreatorScriptAttribute* CCreatorScriptElement::Attribute(TInt aIndex) |
|
226 { |
|
227 return iAttributes[aIndex]; |
|
228 } |
|
229 |
|
230 void CCreatorScriptElement::RemoveAttributes() |
|
231 { |
|
232 iAttributes.ResetAndDestroy(); |
|
233 } |
|
234 |
|
235 |
|
236 void CCreatorScriptElement::RemoveAttributeL(TInt aIndex) |
|
237 { |
|
238 if( aIndex < iAttributes.Count()) |
|
239 { |
|
240 delete iAttributes[aIndex]; |
|
241 iAttributes.Remove(aIndex); |
|
242 } |
|
243 else |
|
244 { |
|
245 User::Leave(KErrArgument); |
|
246 } |
|
247 } |
|
248 |
|
249 void CCreatorScriptElement::AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex ) |
|
250 { |
|
251 if( aIndex == -1 || aIndex == iAttributes.Count() ) |
|
252 { |
|
253 iAttributes.AppendL(aAttribute); |
|
254 } |
|
255 else if( aIndex < iAttributes.Count()) |
|
256 { |
|
257 iAttributes.Insert(aAttribute, aIndex); |
|
258 } |
|
259 else |
|
260 { |
|
261 User::Leave(KErrArgument); |
|
262 } |
|
263 } |
|
264 |
|
265 TPtrC CCreatorScriptElement::Name() const |
|
266 { |
|
267 if( iName ) |
|
268 return iName->Des(); |
|
269 return TPtrC(); |
|
270 } |
|
271 |
|
272 void CCreatorScriptElement::SetNameL(const TDesC& aName) |
|
273 { |
|
274 if( iName ) |
|
275 { |
|
276 delete iName; |
|
277 iName = 0; |
|
278 } |
|
279 iName = HBufC::NewL(aName.Length()); |
|
280 iName->Des() = aName; |
|
281 } |
|
282 |
|
283 |
|
284 TPtrC CCreatorScriptElement::Content() const |
|
285 { |
|
286 if (iContent) |
|
287 return iContent->Des(); |
|
288 return TPtrC(); |
|
289 } |
|
290 |
|
291 void CCreatorScriptElement::SetContentL(const TDesC& aContent) |
|
292 { |
|
293 if( iContent ) |
|
294 { |
|
295 delete iContent; |
|
296 iContent = 0; |
|
297 } |
|
298 iContent = HBufC::NewL(aContent.Length()); |
|
299 iContent->Des() = aContent; |
|
300 } |
|
301 |
|
302 void CCreatorScriptElement::AppendContentL(const TDesC& aContent) |
|
303 { |
|
304 if( iContent == 0 ) |
|
305 { |
|
306 SetContentL(aContent); |
|
307 return; |
|
308 } |
|
309 |
|
310 iContent = iContent->ReAllocL(iContent->Length() + aContent.Length() ); |
|
311 |
|
312 TPtr ptr(iContent->Des()); |
|
313 ptr += aContent; |
|
314 } |
|
315 |
|
316 TPtrC CCreatorScriptElement::Context() const |
|
317 { |
|
318 if( iContext ) |
|
319 return iContext->Des(); |
|
320 return TPtrC(); |
|
321 } |
|
322 |
|
323 void CCreatorScriptElement::SetContextL(const TDesC& aContext) |
|
324 { |
|
325 if( iContext ) |
|
326 { |
|
327 delete iContext; |
|
328 iContext = 0; |
|
329 } |
|
330 iContext = HBufC::NewL(aContext.Length()); |
|
331 iContext->Des() = aContext; |
|
332 } |
|
333 |
|
334 const CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) const |
|
335 { |
|
336 for( TInt i = 0; i < iAttributes.Count(); ++i ) |
|
337 { |
|
338 CCreatorScriptAttribute* attr = iAttributes[i]; |
|
339 if( attr->Name() == aName ) |
|
340 { |
|
341 return attr; |
|
342 } |
|
343 } |
|
344 return 0; |
|
345 } |
|
346 |
|
347 CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) |
|
348 { |
|
349 for( TInt i = 0; i < iAttributes.Count(); ++i ) |
|
350 { |
|
351 CCreatorScriptAttribute* attr = iAttributes[i]; |
|
352 if( attr->Name() == aName ) |
|
353 { |
|
354 return attr; |
|
355 } |
|
356 } |
|
357 return 0; |
|
358 } |
|
359 |
|
360 TBool CCreatorScriptElement::IsCacheNeeded() |
|
361 { |
|
362 _LIT(KIDAttrName, "id"); |
|
363 const CCreatorScriptAttribute* attr = FindAttributeByName(KIDAttrName); |
|
364 return attr != 0; |
|
365 } |
|
366 |
|
367 void CCreatorScriptElement::AddToCacheL(CCreatorScriptElementCache& aCache) |
|
368 { |
|
369 aCache.AddElementL(this); |
|
370 } |
|
371 |
|
372 RPointerArray<CCreatorModuleBaseParameters>& CCreatorScriptElement::CommandParameters() |
|
373 { |
|
374 return iParameters; |
|
375 } |
|
376 |
|
377 const RPointerArray<CCreatorModuleBaseParameters>& CCreatorScriptElement::CommandParameters() const |
|
378 { |
|
379 return iParameters; |
|
380 } |
|
381 |
|
382 void CCreatorScriptElement::AddToCacheL() |
|
383 { |
|
384 } |
|
385 |
|
386 TBool CCreatorScriptElement::IsCommandElement() const |
|
387 { |
|
388 return iIsCommandElement; |
|
389 } |
|
390 |
|
391 void CCreatorScriptElement::ExecuteCommandL() |
|
392 { |
|
393 |
|
394 } |
|
395 |
|
396 TBool CCreatorScriptElement::IsRoot() const |
|
397 { |
|
398 _LIT(KRootName, "creatorscript"); |
|
399 if(iName->Des() == KRootName) |
|
400 return ETrue; |
|
401 return EFalse; |
|
402 } |
|
403 |
|
404 CCreatorScriptElement::CCreatorScriptElement(CCreatorEngine* aEngine) |
|
405 : |
|
406 iIsCommandElement(EFalse), |
|
407 iIsRoot(EFalse), |
|
408 iEngine(aEngine) |
|
409 {} |
|
410 |
|
411 void CCreatorScriptElement::ConstructL(const TDesC& aName, const TDesC& aContext) |
|
412 { |
|
413 SetNameL(aName); |
|
414 SetContextL(aContext); |
|
415 } |
|
416 |
|
417 TBool CCreatorScriptElement::IsSubElementSupported(const CCreatorScriptElement& /*aElem*/) const |
|
418 { |
|
419 return ETrue; |
|
420 } |
|
421 |
|
422 TBool CCreatorScriptElement::ConvertStrToBooleanL(const TDesC& aStr) const |
|
423 { |
|
424 TBool boolVal = EFalse; |
|
425 _LIT(KYes, "yes"); |
|
426 _LIT(KTrue, "true"); |
|
427 if( CompareIgnoreCase(aStr, KYes) == 0 || |
|
428 CompareIgnoreCase(aStr, KTrue) == 0 ) |
|
429 { |
|
430 boolVal = ETrue; |
|
431 } |
|
432 return boolVal; |
|
433 } |
|
434 |
|
435 TInt CCreatorScriptElement::ConvertStrToIntL(const TDesC& aStr) const |
|
436 { |
|
437 TInt intVal = 0; |
|
438 TLex lex(aStr); |
|
439 TInt errorCode=lex.Val(intVal); |
|
440 User::LeaveIfError(errorCode); |
|
441 return intVal; |
|
442 } |
|
443 |
|
444 TUint CCreatorScriptElement::ConvertStrToUintL(const TDesC& aStr) const |
|
445 { |
|
446 TUint uintVal = 0; |
|
447 TLex lex(aStr); |
|
448 TInt errorCode=lex.Val(uintVal); |
|
449 User::LeaveIfError(errorCode); |
|
450 return uintVal; |
|
451 } |
|
452 void CCreatorScriptElement::ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const |
|
453 { |
|
454 TLex lex(aStr); |
|
455 TInt errorCode=lex.Val(aVal); |
|
456 User::LeaveIfError(errorCode); |
|
457 } |
|
458 |
|
459 void CCreatorScriptElement::ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const |
|
460 { |
|
461 TLex lex(aStr); |
|
462 TInt errorCode=lex.Val(aVal); |
|
463 User::LeaveIfError(errorCode); |
|
464 } |
|
465 |
|
466 MCreatorRandomDataField::TRandomLengthType CCreatorScriptElement::ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen) const |
|
467 { |
|
468 TPtrC attrVal = aAttr.Value(); |
|
469 if(attrVal == KMax ) |
|
470 return MCreatorRandomDataField::ERandomLengthMax; |
|
471 if(attrVal == KDefault) |
|
472 return MCreatorRandomDataField::ERandomLengthDefault; |
|
473 |
|
474 // Let's see if the value is numeric: |
|
475 TInt val = 0; |
|
476 TLex lex(attrVal); |
|
477 TInt errorCode=lex.Val(val); |
|
478 if( errorCode == KErrNone ) |
|
479 { |
|
480 aRandomLen = val; |
|
481 return MCreatorRandomDataField::ERandomLengthExplicit; |
|
482 } |
|
483 return MCreatorRandomDataField::ERandomLengthUndefined; |
|
484 } |
|
485 |
|
486 void CCreatorScriptElement::AppendContactSetReferenceL( |
|
487 const CCreatorScriptElement& aContactSetRefElem, |
|
488 RArray<TLinkIdParam>& aLinkArray ) const |
|
489 { |
|
490 const TDesC& eName = aContactSetRefElem.Name(); |
|
491 if( eName != KContactSetRef ) |
|
492 return; |
|
493 |
|
494 const CCreatorScriptAttribute* linkIdAttr = aContactSetRefElem.FindAttributeByName(KId); |
|
495 if( linkIdAttr ) |
|
496 { |
|
497 TInt linkId = ConvertStrToIntL(linkIdAttr->Value()); |
|
498 if( linkId > 0 ) |
|
499 { |
|
500 TLinkIdParam linkParams; |
|
501 // Add contact-set-reference id to links |
|
502 linkParams.iLinkId = linkId; |
|
503 linkParams.iLinkAmount = KUndef; // undefined |
|
504 // Resolve maxamount: |
|
505 const CCreatorScriptAttribute* maxAmount = aContactSetRefElem.FindAttributeByName(KMaxAmount); |
|
506 if( maxAmount ) |
|
507 { |
|
508 TInt maxAmountVal = ConvertStrToIntL(maxAmount->Value()); |
|
509 if( maxAmountVal > 0 ) |
|
510 { |
|
511 linkParams.iLinkAmount = maxAmountVal; |
|
512 } |
|
513 } |
|
514 aLinkArray.AppendL(linkParams); |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 TTime CCreatorScriptElement::ConvertToDateTimeL(const TDesC& aDtStr) const |
|
520 { |
|
521 _LIT(KDateFieldSeparator, "-"); |
|
522 _LIT(KTimeFieldSeparator, ":"); |
|
523 _LIT(KDateTimeSeparator, "T"); |
|
524 _LIT(KTimeSuffix, "."); |
|
525 _LIT(KDateSuffix, ":"); |
|
526 // Format date-time string: |
|
527 HBufC* formatted = HBufC::NewLC(aDtStr.Length()); |
|
528 formatted->Des().Copy(aDtStr); |
|
529 |
|
530 TBool hasTimePart = EFalse; |
|
531 TBool hasDateTimeSeparator = EFalse; |
|
532 TInt pos = 0; |
|
533 |
|
534 // Date and month numbering starts from 0 in Symbian, so first |
|
535 // we need to decrease the date and month by one. Script format is following: |
|
536 // yyyy-mm-ddThh:mm:ss |
|
537 // Remove also date field separators ('-') |
|
538 while( (pos = formatted->Find(KDateFieldSeparator)) != KErrNotFound ) |
|
539 { |
|
540 // decrease month or date by one |
|
541 |
|
542 // First char. Can be zero also: |
|
543 TInt newValue = 0; |
|
544 const TPtrC& char1 = formatted->Des().Mid(pos+1).Left(1); |
|
545 newValue = 10 * ConvertStrToIntL(char1); |
|
546 // Next char: |
|
547 const TPtrC& char2 = formatted->Des().Mid(pos+2).Left(1); |
|
548 newValue += ConvertStrToIntL(char2); |
|
549 |
|
550 if( newValue > 0 ) |
|
551 { |
|
552 --newValue; |
|
553 } |
|
554 |
|
555 _LIT(KTemp, "%d"); |
|
556 HBufC* formatBuf = KTemp().AllocLC(); |
|
557 HBufC* buf = 0; |
|
558 if( newValue < 10 ) |
|
559 buf = HBufC::NewLC(1); |
|
560 else |
|
561 buf = HBufC::NewLC(2); |
|
562 |
|
563 TPtr temp(buf->Des()); |
|
564 temp.Format(*formatBuf, newValue); |
|
565 if( newValue < 10 ) |
|
566 { |
|
567 formatted->Des()[pos+1] = TChar('0'); |
|
568 formatted->Des()[pos+2] = buf->Des()[0]; |
|
569 } |
|
570 else |
|
571 { |
|
572 formatted->Des()[pos+1] = buf->Des()[0]; |
|
573 formatted->Des()[pos+2] = buf->Des()[1]; |
|
574 } |
|
575 // Finally, delete the '-' separator: |
|
576 formatted->Des().Delete(pos, 1); |
|
577 CleanupStack::PopAndDestroy(2); |
|
578 } |
|
579 |
|
580 while( (pos = formatted->Find(KTimeFieldSeparator)) != KErrNotFound ) |
|
581 { |
|
582 formatted->Des().Delete(pos, 1); |
|
583 hasTimePart = ETrue; |
|
584 } |
|
585 |
|
586 // Replace 'T' with ':': |
|
587 if( (pos = formatted->Find(KDateTimeSeparator)) != KErrNotFound ) |
|
588 { |
|
589 formatted->Des().Replace(pos, 1, KDateSuffix); |
|
590 hasDateTimeSeparator = ETrue; |
|
591 } |
|
592 |
|
593 if( hasTimePart ) |
|
594 formatted->Des().Append(KTimeSuffix); |
|
595 else if( !hasDateTimeSeparator ) |
|
596 formatted->Des().Append(KDateSuffix); |
|
597 |
|
598 |
|
599 TTime ret; |
|
600 ret.Set(*formatted); |
|
601 CleanupStack::PopAndDestroy(); // formatted |
|
602 return ret; |
|
603 } |
|
604 |
|
605 TInt CCreatorScriptElement::CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const |
|
606 { |
|
607 // Get default collation method: |
|
608 TCollationMethod defaultCollationMethod = *Mem::CollationMethodByIndex(0); |
|
609 |
|
610 // Add ignore case flag: |
|
611 defaultCollationMethod.iFlags |= TCollationMethod::EFoldCase; |
|
612 |
|
613 return aStr1.CompareF(aStr2); |
|
614 } |
|
615 |
|
616 void CCreatorScriptElement::SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent ) |
|
617 { |
|
618 delete aPtr; |
|
619 aPtr = 0; |
|
620 aPtr = HBufC::NewL(aContent.Length()); |
|
621 aPtr->Des().Copy(aContent); |
|
622 } |
|
623 |
|
624 /** |
|
625 * Increases phonenumber by aDelta. |
|
626 */ |
|
627 void CCreatorScriptElement::IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const |
|
628 { |
|
629 LOGSTRING("Creator: CCreatorMessageElement::IncreasePhoneNumL"); |
|
630 __ASSERT_ALWAYS( aDelta >= 0, User::Panic( _L("IncreasePhoneNumL"), KErrArgument ) ); |
|
631 |
|
632 // special cases, that are handled: |
|
633 // +9 -> +9, +10, +11... |
|
634 // +3584098#99 -> +3584098#99, +3584098#100, +3584098#101... |
|
635 // # -> #0, #1, #2... |
|
636 // 123# -> 123#0, 123#1, 123#2... |
|
637 // 099 -> 099, 100, 101... |
|
638 |
|
639 // find out if there are any special characters, like # p or *, in the original number |
|
640 TInt startIndex( aOriginal.Length() -1 ); |
|
641 while ( startIndex >= 0 && |
|
642 aOriginal[startIndex] >= '0' && |
|
643 aOriginal[startIndex] <= '9' ) |
|
644 { |
|
645 startIndex--; |
|
646 } |
|
647 startIndex++; |
|
648 |
|
649 // append original head that may contain any non number characters |
|
650 aIncreased->Des().Append( aOriginal.Left( startIndex ) ); |
|
651 |
|
652 TBuf<CTelephony::KMaxTelNumberSize> tailBuf; |
|
653 if ( aOriginal.Length() > startIndex ) |
|
654 { |
|
655 tailBuf.Copy( aOriginal.Right( aOriginal.Length() -startIndex ) ); |
|
656 } |
|
657 |
|
658 // parse the tail part of the original number |
|
659 TInt64 intVal = 0; |
|
660 if ( aOriginal.Length() > startIndex ) |
|
661 { |
|
662 TLex lex( tailBuf ); |
|
663 User::LeaveIfError( lex.Val( intVal ) ); // this loses leading zeros |
|
664 } |
|
665 |
|
666 // increase |
|
667 intVal += aDelta; |
|
668 |
|
669 // restore leading zeros to tail, if any |
|
670 TBuf<CTelephony::KMaxTelNumberSize> resultTailNoZeros; |
|
671 resultTailNoZeros.AppendNum( intVal ); |
|
672 TInt tailLeadingZerosToRestore = tailBuf.Length() - resultTailNoZeros.Length(); |
|
673 for ( TInt i = 0; i < tailLeadingZerosToRestore; i++ ) |
|
674 { |
|
675 aIncreased->Des().AppendNum( 0 ); |
|
676 } |
|
677 |
|
678 // and finally, append the increased value as tail part of the result |
|
679 aIncreased->Des().Append( resultTailNoZeros ); |
|
680 } |
|
681 |
|
682 CCreatorScriptRoot* CCreatorScriptRoot::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
683 { |
|
684 CCreatorScriptRoot* self = new (ELeave) CCreatorScriptRoot(aEngine); |
|
685 CleanupStack::PushL(self); |
|
686 self->ConstructL(aName, aContext); |
|
687 CleanupStack::Pop(); |
|
688 return self; |
|
689 } |
|
690 CCreatorScriptRoot::CCreatorScriptRoot(CCreatorEngine* aEngine) |
|
691 : |
|
692 CCreatorScriptElement(aEngine) |
|
693 { |
|
694 iIsRoot=ETrue; |
|
695 } |
|
696 |
|
697 |
|
698 CCreatorCalendarElementBase* CCreatorCalendarElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
699 { |
|
700 CCreatorCalendarElementBase* self = new (ELeave) CCreatorCalendarElementBase(aEngine); |
|
701 CleanupStack::PushL(self); |
|
702 self->ConstructL(aName, aContext); |
|
703 CleanupStack::Pop(); |
|
704 return self; |
|
705 } |
|
706 CCreatorCalendarElementBase::CCreatorCalendarElementBase(CCreatorEngine* aEngine) |
|
707 : |
|
708 CCreatorScriptElement(aEngine) |
|
709 { } |
|
710 |
|
711 CCreatorMessageElementBase* CCreatorMessageElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) |
|
712 { |
|
713 CCreatorMessageElementBase* self = new (ELeave) CCreatorMessageElementBase(aEngine); |
|
714 CleanupStack::PushL(self); |
|
715 self->ConstructL(aName, aContext); |
|
716 CleanupStack::Pop(); |
|
717 return self; |
|
718 } |
|
719 CCreatorMessageElementBase::CCreatorMessageElementBase(CCreatorEngine* aEngine) |
|
720 : |
|
721 CCreatorScriptElement(aEngine) |
|
722 { } |
|