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