skins/AknSkins/srvsrc/tfxconfigparser.cpp
changeset 0 05e9090e2422
child 10 08459e712984
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Tfx parser.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <TfxSrvEcomIds.h>
       
    20 #include <f32file.h>
       
    21 #include "tfxconfigparser.h"
       
    22 
       
    23 _LIT8(KMimetype,"text/xml");
       
    24 _LIT8(KManifestTag, "mf");
       
    25 _LIT8(KSelTag,"sel");
       
    26 _LIT8(KBaseSkinTag, "baseskin");
       
    27 _LIT8(KEffectNameTag, "name");
       
    28 _LIT8(KEffectFileTag, "file");
       
    29 _LIT8(KEffectDefinitionsTag, "effectdefinitions");
       
    30 _LIT8(KEffectTag, "effect");
       
    31 _LIT8(KEffectWantedTimeTag, "wanted_frame_time");
       
    32 _LIT8(KEffectMinTimeTag,"min_sleep_time");
       
    33 _LIT8(KEffectCachePriorityTag, "cachepriority");
       
    34 _LIT8(KPathTag, "path");
       
    35 _LIT8(KMaxTransCacheSizeTag, "max_transition_cache_size");
       
    36 _LIT8(KMaxCacheSizeTag, "max_cache_size");
       
    37 
       
    38 
       
    39 _LIT8(KFullSCRTransTag,"fullscreentransitions");
       
    40 _LIT8(KTransitionTag, "transition");
       
    41 _LIT8(KContextTag, "context");
       
    42 _LIT8(KUidTag, "Uid");
       
    43 
       
    44 _LIT8(KCtrlTransTag, "controltransitions");
       
    45 _LIT8(KContextUidTag, "context_uid");
       
    46 _LIT8(KActionTag, "action");
       
    47 _LIT8(KActionStringTag, "actionstring" );
       
    48 
       
    49 _LIT8( KListTransTag, "listtransitions");
       
    50 _LIT8( KTypeTag, "type" );
       
    51 
       
    52 const TInt KListBackgroundContext = 1;
       
    53 const TInt KListItemContext = 2;
       
    54 
       
    55 
       
    56 
       
    57 
       
    58 _LIT(KTFXManifestFile, "z:\\resource\\effects\\manifest.mf");
       
    59 
       
    60 
       
    61 CTFxEffect::~CTFxEffect()
       
    62     {
       
    63     delete iName;
       
    64     delete iFilename;
       
    65     }
       
    66 
       
    67 const TDesC& CTFxEffect::Name()
       
    68     {
       
    69     if (!iName)
       
    70         {
       
    71         return KNullDesC;
       
    72         }
       
    73     return *iName;
       
    74     }
       
    75 
       
    76 const TDesC& CTFxEffect::Filename()
       
    77     {
       
    78     if (!iFilename)
       
    79         {
       
    80         return KNullDesC;
       
    81         }
       
    82     return *iFilename;
       
    83     }
       
    84 
       
    85 void CTFxEffect::SetName(const TDesC8& aName)
       
    86     {
       
    87     if (iName)
       
    88         {
       
    89         delete iName;
       
    90         iName = NULL;
       
    91         }
       
    92     iName = HBufC::NewL(aName.Length()*2);
       
    93     iName->Des().Copy(aName);
       
    94     }
       
    95 
       
    96 void CTFxEffect::SetFilename(const TDesC8& aFilename)
       
    97     {
       
    98     if (iFilename)
       
    99         {
       
   100         delete iFilename;
       
   101         iFilename = NULL;
       
   102         }
       
   103     iFilename = HBufC::NewL(aFilename.Length()*2);
       
   104     iFilename->Des().Copy(aFilename);
       
   105     }
       
   106 
       
   107 TInt CTFxEffect::WantedTime()
       
   108     {
       
   109     return iWantedTime;
       
   110     }
       
   111 TInt CTFxEffect::MinTime()
       
   112     {
       
   113     return iMinTime;
       
   114     }
       
   115 
       
   116 TInt CTFxEffect::CachePriority()
       
   117     {
       
   118     return iCachePriority;
       
   119     }
       
   120 
       
   121 void CTFxEffect::SetWantedTime(const TDesC8& aTime)
       
   122     {
       
   123     if (aTime.Length() > 0)
       
   124         {
       
   125         TLex8 lexer(aTime);
       
   126         User::LeaveIfError(lexer.Val(iWantedTime));
       
   127         }
       
   128     else
       
   129         {
       
   130         iWantedTime = -1;
       
   131         }
       
   132     }
       
   133 
       
   134 void CTFxEffect::SetMinTime(const TDesC8& aTime)
       
   135     {
       
   136     if (aTime.Length() > 0)
       
   137         {
       
   138         TLex8 lexer(aTime);
       
   139         User::LeaveIfError(lexer.Val(iMinTime));
       
   140         }
       
   141     else
       
   142         {
       
   143         iMinTime = -1;
       
   144         }
       
   145     }
       
   146 
       
   147 void CTFxEffect::SetCachePriority(const TDesC8& aPriority)
       
   148     {
       
   149     if (aPriority.Length() > 0)
       
   150         {
       
   151         TLex8 lexer(aPriority);
       
   152         User::LeaveIfError(lexer.Val(iCachePriority));
       
   153         }
       
   154     else
       
   155         {
       
   156         iCachePriority = -1;
       
   157         }
       
   158     }
       
   159 
       
   160 CTFxEffect::CTFxEffect() :  iWantedTime(-1), iMinTime(-1), iCachePriority(-1), iPathIndex(-1)
       
   161     {
       
   162 
       
   163     }
       
   164 
       
   165 TInt CTFxEffect::PathIndex()
       
   166     {
       
   167     return iPathIndex;
       
   168     }
       
   169 
       
   170 void CTFxEffect::SetPathIndex(TInt aIndex)
       
   171     {
       
   172     iPathIndex = aIndex;
       
   173     }
       
   174 
       
   175 void CTFxEffect::SetMaxCacheSize(TInt aSize)
       
   176     {
       
   177     iMaxCacheSize = aSize;
       
   178     }
       
   179 
       
   180 void CTFxEffect::SetMaxTransCacheSize(TInt aSize)
       
   181     {
       
   182     iMaxTransCacheSize = aSize;
       
   183     }
       
   184 
       
   185 TInt CTFxEffect::MaxCacheSize()
       
   186     {
       
   187     return iMaxCacheSize;
       
   188     }
       
   189 
       
   190 TInt CTFxEffect::MaxTransCacheSize()
       
   191     {
       
   192     return iMaxTransCacheSize;
       
   193     }
       
   194 
       
   195 CTFxTransition::CTFxTransition()
       
   196     {
       
   197     }
       
   198 
       
   199 CTFxTransition::~CTFxTransition()
       
   200     {
       
   201     delete iEffectName;
       
   202     }
       
   203 
       
   204 const TUid CTFxTransition::Uid()
       
   205     {
       
   206     return iUid;
       
   207     }
       
   208 
       
   209 TInt CTFxTransition::Type()
       
   210     {
       
   211     return iType;
       
   212     }
       
   213 
       
   214 void CTFxTransition::SetUid(const TDesC8& aUid)
       
   215     {
       
   216     if (aUid.Length())
       
   217         {
       
   218         TLex8 lexer(aUid.Mid(2));
       
   219         TUint32 uid;
       
   220 
       
   221         User::LeaveIfError(lexer.BoundedVal(uid,EHex,KMaxTUint));
       
   222         iUid.iUid = uid;
       
   223         }
       
   224     else
       
   225         {
       
   226         iUid = KNullUid;
       
   227         }
       
   228     }
       
   229 
       
   230 TInt CTFxTransition::ContextId()
       
   231     {
       
   232     return iContextId;
       
   233     }
       
   234 
       
   235 
       
   236 void CTFxTransition::SetContextId(const TDesC8& aId)
       
   237     {
       
   238     if (aId.Length() > 0)
       
   239         {
       
   240         TLex8 lexer(aId);
       
   241         User::LeaveIfError(lexer.Val(iContextId));
       
   242         }
       
   243     else
       
   244         {
       
   245         iContextId = KMaxTInt;
       
   246         }
       
   247     }
       
   248 
       
   249 void CTFxTransition::SetEffectNameL(const TDesC8& aEffect)
       
   250     {
       
   251     if (iEffectName)
       
   252         {
       
   253         delete iEffectName;
       
   254         iEffectName = NULL;
       
   255         }
       
   256     iEffectName = HBufC::NewL(aEffect.Length()*2);
       
   257     iEffectName->Des().Copy(aEffect);
       
   258     }
       
   259 
       
   260 void CTFxTransition::SetType(const TDesC8& aType)
       
   261     {
       
   262     if (aType.Length() > 0)
       
   263         {
       
   264         TLex8 lexer(aType);
       
   265         User::LeaveIfError(lexer.Val(iType));
       
   266         }
       
   267     else
       
   268         {
       
   269         iType = 0;
       
   270         }
       
   271     }
       
   272 
       
   273 
       
   274 const TDesC& CTFxTransition::EffectName()
       
   275     {
       
   276     if (iEffectName)
       
   277         {
       
   278         return *iEffectName;
       
   279         }
       
   280     return KNullDesC;
       
   281     }
       
   282 
       
   283 void CTFxTransition::SetEffect(CTFxEffect* aEffect)
       
   284     {
       
   285     iEffect = aEffect;
       
   286     }
       
   287 
       
   288 CTFxEffect* CTFxTransition::Effect()
       
   289     {
       
   290     return iEffect;
       
   291     }
       
   292 
       
   293 
       
   294 
       
   295 CTFXConfigParser* CTFXConfigParser::NewL()
       
   296     {
       
   297     CTFXConfigParser* self = new (ELeave) CTFXConfigParser;
       
   298     CleanupStack::PushL(self);
       
   299     self->ConstructL();
       
   300     CleanupStack::Pop( self );
       
   301     return self;
       
   302     }
       
   303 
       
   304 CTFxCtrlTransition::CTFxCtrlTransition()
       
   305     {
       
   306 
       
   307     }
       
   308 
       
   309 CTFxCtrlTransition::~CTFxCtrlTransition()
       
   310     {
       
   311     delete iEffectName;
       
   312     delete iActionString;
       
   313     }
       
   314 
       
   315 const TUid CTFxCtrlTransition::ContextUid()
       
   316     {
       
   317     return iContextUid;
       
   318     }
       
   319 
       
   320 void CTFxCtrlTransition::SetContextUidL(const TDesC8& aUid)
       
   321     {
       
   322     if (aUid.Length())
       
   323         {
       
   324         TLex8 lexer(aUid.Mid(2));
       
   325         TUint32 uid;
       
   326 
       
   327         User::LeaveIfError(lexer.BoundedVal(uid,EHex,KMaxTUint));
       
   328         iContextUid.iUid = uid;
       
   329         }
       
   330     else
       
   331         {
       
   332         iContextUid = KNullUid;
       
   333         }
       
   334 
       
   335     }
       
   336 
       
   337 const TDesC& CTFxCtrlTransition::EffectName()
       
   338     {
       
   339     if (!iEffectName)
       
   340         {
       
   341         return KNullDesC;
       
   342         }
       
   343 
       
   344     return *iEffectName;
       
   345     }
       
   346 
       
   347 void CTFxCtrlTransition::SetEffectNameL(const TDesC8& aEffect)
       
   348     {
       
   349     if (iEffectName)
       
   350         {
       
   351         delete iEffectName;
       
   352         iEffectName = NULL;
       
   353         }
       
   354     iEffectName = HBufC::NewL(aEffect.Length()*2);
       
   355     iEffectName->Des().Copy(aEffect);
       
   356     }
       
   357 
       
   358 void CTFxCtrlTransition::SetActionStringL(const TDesC8& aActionStr)
       
   359     {
       
   360     if (iActionString)
       
   361         {
       
   362         delete iActionString;
       
   363         iActionString = NULL;
       
   364         }
       
   365     iActionString = HBufC::NewL(aActionStr.Length()*2);
       
   366     iActionString->Des().Copy(aActionStr);
       
   367     }
       
   368 
       
   369 const TDesC& CTFxCtrlTransition::ActionString()
       
   370     {
       
   371     if (!iActionString)
       
   372         {
       
   373         return KNullDesC;
       
   374         }
       
   375 
       
   376     return *iActionString;
       
   377     }
       
   378 
       
   379 void CTFxCtrlTransition::SetActionL(const TDesC8& aAction)
       
   380     {
       
   381     if (aAction.Length() > 0)
       
   382         {
       
   383         TLex8 lexer(aAction);
       
   384         User::LeaveIfError(lexer.Val(iAction));
       
   385         }
       
   386     else
       
   387         {
       
   388         iAction = 0;
       
   389         }
       
   390     }
       
   391 
       
   392 TInt  CTFxCtrlTransition::Action()
       
   393     {
       
   394     return iAction;
       
   395     }
       
   396 
       
   397 CTFxEffect*  CTFxCtrlTransition::Effect()
       
   398     {
       
   399     return iEffect;
       
   400     }
       
   401 
       
   402 void CTFxCtrlTransition::SetEffect(CTFxEffect* aEffect)
       
   403     {
       
   404     iEffect = aEffect;
       
   405     }
       
   406 
       
   407 void CTFxCtrlTransition::SetKmlRegistrationStatus(TBool aStatus)
       
   408     {
       
   409     iKmlRegistrationStatus = aStatus;
       
   410     }
       
   411 
       
   412 TBool CTFxCtrlTransition::KmlRegistrationStatus()
       
   413     {
       
   414     return iKmlRegistrationStatus;
       
   415     }
       
   416 
       
   417 void CTFXConfigParser::ConstructL()
       
   418     {
       
   419     iParser = CParser::NewL(KMimetype(), *this);
       
   420     }
       
   421 
       
   422 CTFXConfigParser::CTFXConfigParser() : iParserState(EStateParsingNone)
       
   423     {
       
   424     }
       
   425 
       
   426 CTFXConfigParser::~CTFXConfigParser()
       
   427     {
       
   428     if (iFsEffectArray)
       
   429         {
       
   430         iFsEffectArray->ResetAndDestroy();
       
   431         }
       
   432     if (iFsTransitionArray)
       
   433         {
       
   434         iFsTransitionArray->ResetAndDestroy();
       
   435         }
       
   436     if (iEffectDefPathArray)
       
   437         {
       
   438         iEffectDefPathArray->ResetAndDestroy();
       
   439         }
       
   440     if (iCtrlTransitionArray)
       
   441         {
       
   442         iCtrlTransitionArray->ResetAndDestroy();
       
   443         }
       
   444     if (iListTransitionArray)
       
   445         {
       
   446         iListTransitionArray->ResetAndDestroy();
       
   447         }
       
   448     delete iFsEffectArray;
       
   449     delete iFsTransitionArray;
       
   450     delete iEffectDefPathArray;
       
   451     delete iCtrlTransitionArray;
       
   452     delete iParser;
       
   453     delete iListTransitionArray;
       
   454     }
       
   455 
       
   456 const TDesC& CTFXConfigParser::KmlBasePath(TInt aIndex)
       
   457     {
       
   458     if (iEffectDefPathArray && iEffectDefPathArray->Count() >= aIndex+1)
       
   459         {
       
   460         return *(iEffectDefPathArray->operator[](aIndex));
       
   461         }
       
   462     return KNullDesC;
       
   463     }
       
   464 
       
   465 const TDesC& CTFXConfigParser::BaseSkinSelFile() const
       
   466     {
       
   467     return iBaseSkinSelFile;
       
   468     }
       
   469 
       
   470 RPointerArray<CTFxTransition>* CTFXConfigParser::FsTransitionArrayL()
       
   471     {
       
   472     if (iFsTransitionArray)
       
   473         {
       
   474         return iFsTransitionArray;
       
   475         }
       
   476     return NULL; // disables compiler nag
       
   477     }
       
   478 
       
   479 RPointerArray<CTFxCtrlTransition>* CTFXConfigParser::CtrlTransitionArrayL()
       
   480     {
       
   481     if (iCtrlTransitionArray)
       
   482         {
       
   483         return iCtrlTransitionArray;
       
   484         }
       
   485     return NULL; // disables compiler nag
       
   486     }
       
   487 
       
   488 RPointerArray<CTFxTransition>* CTFXConfigParser::ListTransitionArrayL()
       
   489     {
       
   490     if (iListTransitionArray)
       
   491         {
       
   492         return iListTransitionArray;
       
   493         }
       
   494     return NULL; // disables compiler nag
       
   495     }
       
   496 
       
   497 void CTFXConfigParser::ParseL(const TDesC& aFilename)
       
   498     {
       
   499     RFs fs;
       
   500     User::LeaveIfError(fs.Connect());
       
   501     CleanupClosePushL(fs);
       
   502     RFile file;
       
   503     User::LeaveIfError(file.Open(fs, aFilename, EFileRead | EFileShareReadersOnly));
       
   504     CleanupClosePushL(file);
       
   505     TInt filesize = 0;
       
   506     User::LeaveIfError(file.Size(filesize));
       
   507     HBufC8* buffer = HBufC8::NewLC(filesize);
       
   508     TPtr8 ptr( buffer->Des() );
       
   509     User::LeaveIfError(file.Read(ptr, filesize));
       
   510 
       
   511     iParser->ParseBeginL();
       
   512     iParser->ParseL(*buffer);
       
   513     iParser->ParseEndL();
       
   514     CleanupStack::PopAndDestroy(3); // fs, file, buffer
       
   515     }
       
   516 
       
   517 
       
   518 void CTFXConfigParser::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt /*aErrorCode*/)
       
   519     {
       
   520     }
       
   521 
       
   522 void CTFXConfigParser::OnEndDocumentL(TInt /*aErrorCode*/)
       
   523     {
       
   524     }
       
   525 
       
   526 void CTFXConfigParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode)
       
   527     {
       
   528     if (iFileType == EConfigFileManifest)
       
   529         {
       
   530         OnMfStartElementL(aElement, aAttributes, aErrorCode);
       
   531         return;
       
   532         }
       
   533     else if (iFileType == EConfigFileSel)
       
   534         {
       
   535         OnSelStartElementL(aElement, aAttributes, aErrorCode);
       
   536         return;
       
   537         }
       
   538 
       
   539 
       
   540     if (!aElement.LocalName().DesC().CompareF(KManifestTag))
       
   541         {
       
   542         iFileType = EConfigFileManifest;
       
   543         return;
       
   544         }
       
   545     else if (!aElement.LocalName().DesC().CompareF(KSelTag))
       
   546         {
       
   547         iFileType = EConfigFileSel;
       
   548 
       
   549         // find if there's baseskin attribute
       
   550         // if baseskin is found then parsing is stopped and
       
   551         // baseskin is parsed and registered first
       
   552         TInt attrCount( aAttributes.Count() );
       
   553         for( TInt i( 0 ); i < attrCount; i++ )
       
   554             {
       
   555             RAttribute attribute = aAttributes[i];
       
   556             RTagInfo tag = attribute.Attribute();
       
   557             if (!tag.LocalName().DesC().CompareF(KBaseSkinTag))
       
   558                 {
       
   559                 // base skin can be found once per parser
       
   560                 if( iBaseSkinSelFile.Length() == 0 )
       
   561                     {
       
   562                     iBaseSkinSelFile.Copy( attribute.Value().DesC() );
       
   563                     User::Leave( KBaseSkinParserLeave );
       
   564                     }
       
   565                 }
       
   566             }
       
   567         return;
       
   568         }
       
   569     }
       
   570 
       
   571 void CTFXConfigParser::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode)
       
   572     {
       
   573     if (!aElement.LocalName().DesC().CompareF(KManifestTag))
       
   574         {
       
   575         iFileType = EConfigFileUndefined;
       
   576         iManifestParsed = ETrue;
       
   577         return;
       
   578         }
       
   579     else if (!aElement.LocalName().DesC().CompareF(KSelTag))
       
   580         {
       
   581         iFileType = EConfigFileUndefined;
       
   582         return;
       
   583         }
       
   584 
       
   585     if (iFileType == EConfigFileManifest)
       
   586         {
       
   587         OnMfEndElementL(aElement, aErrorCode);
       
   588         iExtensionParsed = ETrue;
       
   589         return;
       
   590         }
       
   591     else if (iFileType == EConfigFileSel)
       
   592         {
       
   593         OnSelEndElementL(aElement, aErrorCode);
       
   594         return;
       
   595         }
       
   596     }
       
   597 
       
   598 void CTFXConfigParser::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
       
   599     {
       
   600     }
       
   601 
       
   602 void CTFXConfigParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, TInt /*aErrorCode*/)
       
   603     {
       
   604     }
       
   605 
       
   606 void CTFXConfigParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
       
   607     {
       
   608     }
       
   609 
       
   610 void CTFXConfigParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
       
   611     {
       
   612     }
       
   613 
       
   614 void CTFXConfigParser::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
       
   615     {
       
   616     }
       
   617 
       
   618 void CTFXConfigParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/)
       
   619     {
       
   620     }
       
   621 
       
   622 void CTFXConfigParser::OnError(TInt /*aErrorCode*/)
       
   623     {
       
   624     }
       
   625 
       
   626 TAny* CTFXConfigParser::GetExtendedInterface(const TInt32 /*aUid*/)
       
   627     {
       
   628     return NULL;
       
   629     }
       
   630 
       
   631 void CTFXConfigParser::SetMaxTransCacheSizeL(const TDesC8& aCacheSize)
       
   632     {
       
   633     if (aCacheSize.Length() > 0)
       
   634         {
       
   635         TLex8 lexer(aCacheSize);
       
   636         User::LeaveIfError(lexer.Val(iMaxTransCacheSize));
       
   637         }
       
   638     else
       
   639         {
       
   640         iMaxTransCacheSize = 0;
       
   641         }
       
   642     }
       
   643 
       
   644 void CTFXConfigParser::SetMaxCacheSizeL(const TDesC8& aCacheSize)
       
   645     {
       
   646     if (aCacheSize.Length() > 0)
       
   647         {
       
   648         TLex8 lexer(aCacheSize);
       
   649         User::LeaveIfError(lexer.Val(iMaxCacheSize));
       
   650         }
       
   651     else
       
   652         {
       
   653         iMaxCacheSize = 0;
       
   654         }
       
   655     }
       
   656 
       
   657 void CTFXConfigParser::OnMfStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
       
   658     {
       
   659     if (!aElement.LocalName().DesC().CompareF(KEffectDefinitionsTag))
       
   660         {
       
   661         if (!iFsEffectArray)
       
   662             {
       
   663             iFsEffectArray = new (ELeave) RPointerArray<CTFxEffect>;
       
   664             }
       
   665         if (!iEffectDefPathArray)
       
   666             {
       
   667             iEffectDefPathArray = new (ELeave) RPointerArray<HBufC>;
       
   668             }
       
   669         for (TInt count = 0; count < aAttributes.Count(); count++)
       
   670             {
       
   671             RAttribute attribute = aAttributes[count];
       
   672             RTagInfo tag = attribute.Attribute();
       
   673             if (!tag.LocalName().DesC().CompareF(KPathTag))
       
   674                 {
       
   675                 HBufC* path;
       
   676                 path = HBufC::NewL(attribute.Value().DesC().Length()*2);
       
   677                 path->Des().Copy(attribute.Value().DesC());
       
   678                 iEffectDefPathArray->Append(path);
       
   679                 }
       
   680             else if (!tag.LocalName().DesC().CompareF(KMaxTransCacheSizeTag))
       
   681                 {
       
   682                 SetMaxTransCacheSizeL(attribute.Value().DesC());
       
   683                 }
       
   684             else if (!tag.LocalName().DesC().CompareF(KMaxCacheSizeTag))
       
   685                 {
       
   686                 SetMaxCacheSizeL(attribute.Value().DesC());
       
   687                 }
       
   688             }
       
   689         return;
       
   690         }
       
   691     else if (!aElement.LocalName().DesC().CompareF(KEffectTag))
       
   692         {
       
   693         if (!iFsEffectArray)
       
   694             {
       
   695             User::Leave(KErrCorrupt);
       
   696             }
       
   697         iCurrentEffect = new (ELeave) CTFxEffect;
       
   698         iCurrentEffect->SetPathIndex(iEffectDefPathArray->Count()-1);
       
   699         iCurrentEffect->SetMaxTransCacheSize(iMaxTransCacheSize);
       
   700         iCurrentEffect->SetMaxCacheSize(iMaxCacheSize);
       
   701         }
       
   702 
       
   703     for (TInt count = 0; count < aAttributes.Count(); count++)
       
   704         {
       
   705         RAttribute attribute = aAttributes[count];
       
   706         RTagInfo tag = attribute.Attribute();
       
   707         if (!tag.LocalName().DesC().CompareF(KEffectNameTag))
       
   708             {
       
   709             iCurrentEffect->SetName(attribute.Value().DesC());
       
   710             }
       
   711         else if (!tag.LocalName().DesC().CompareF(KEffectFileTag))
       
   712             {
       
   713             iCurrentEffect->SetFilename(attribute.Value().DesC());
       
   714             }
       
   715         else if (!tag.LocalName().DesC().CompareF(KEffectWantedTimeTag))
       
   716             {
       
   717             iCurrentEffect->SetWantedTime(attribute.Value().DesC());
       
   718             }
       
   719         else if (!tag.LocalName().DesC().CompareF(KEffectMinTimeTag))
       
   720             {
       
   721             iCurrentEffect->SetMinTime(attribute.Value().DesC());
       
   722             }
       
   723         else if (!tag.LocalName().DesC().CompareF(KEffectCachePriorityTag))
       
   724             {
       
   725             iCurrentEffect->SetCachePriority(attribute.Value().DesC());
       
   726             }
       
   727         }
       
   728     }
       
   729 
       
   730 void CTFXConfigParser::OnSelStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
       
   731     {
       
   732     if (!aElement.LocalName().DesC().CompareF(KFullSCRTransTag))
       
   733         {
       
   734         iFsTransitionArray = new (ELeave) RPointerArray<CTFxTransition>;
       
   735         iParserState = EStateParsingFs;
       
   736         return;
       
   737         }
       
   738     else if (!aElement.LocalName().DesC().CompareF(KCtrlTransTag))
       
   739         {
       
   740         iCtrlTransitionArray = new (ELeave) RPointerArray<CTFxCtrlTransition>;
       
   741         iParserState = EStateParsingCtrl;
       
   742         return;
       
   743         }
       
   744     else if(!aElement.LocalName().DesC().CompareF(KListTransTag))
       
   745         {
       
   746         iListTransitionArray = new (ELeave) RPointerArray<CTFxTransition>;
       
   747         iParserState = EStateParsingList;
       
   748         }
       
   749 
       
   750    else if (!aElement.LocalName().DesC().CompareF(KTransitionTag))
       
   751         {
       
   752         if (iParserState == EStateParsingFs && !iFsTransitionArray)
       
   753             {
       
   754             User::Leave(KErrCorrupt);
       
   755             }
       
   756         else if (iParserState == EStateParsingCtrl && !iCtrlTransitionArray)
       
   757             {
       
   758             User::Leave(KErrCorrupt);
       
   759             }
       
   760         else if (iParserState == EStateParsingList && !iListTransitionArray)
       
   761             {
       
   762             User::Leave(KErrCorrupt);
       
   763             }
       
   764         // list transition has same params as fs transition
       
   765         if (iParserState == EStateParsingFs
       
   766             || iParserState == EStateParsingList)
       
   767             {
       
   768             iCurrentTransition = new (ELeave) CTFxTransition;
       
   769 
       
   770             for (TInt count = 0; count < aAttributes.Count(); count++)
       
   771                 {
       
   772                 RAttribute attribute = aAttributes[count];
       
   773                 RTagInfo tag = attribute.Attribute();
       
   774                 if (!tag.LocalName().DesC().CompareF(KContextTag))
       
   775                     {
       
   776                     iCurrentTransition->SetContextId(attribute.Value().DesC());
       
   777                     }
       
   778                 else if (!tag.LocalName().DesC().CompareF(KEffectTag))
       
   779                     {
       
   780                     iCurrentTransition->SetEffectNameL(attribute.Value().DesC());
       
   781                     }
       
   782                 else if (!tag.LocalName().DesC().CompareF(KUidTag))
       
   783                     {
       
   784                     iCurrentTransition->SetUid(attribute.Value().DesC());
       
   785                     }
       
   786                 else if( !tag.LocalName().DesC().CompareF(KTypeTag))
       
   787                     {
       
   788                     iCurrentTransition->SetType(attribute.Value().DesC());
       
   789                     }
       
   790                 }
       
   791             }
       
   792         else if (iParserState == EStateParsingCtrl)
       
   793             {
       
   794             iCurrentCtrlTransition = new (ELeave) CTFxCtrlTransition;
       
   795             for (TInt count = 0; count < aAttributes.Count(); count++)
       
   796                 {
       
   797                 RAttribute attribute = aAttributes[count];
       
   798                 RTagInfo tag = attribute.Attribute();
       
   799                 if (!tag.LocalName().DesC().CompareF(KContextUidTag))
       
   800                     {
       
   801                     iCurrentCtrlTransition->SetContextUidL(attribute.Value().DesC());
       
   802                     }
       
   803                 else if (!tag.LocalName().DesC().CompareF(KEffectTag))
       
   804                     {
       
   805                     iCurrentCtrlTransition->SetEffectNameL(attribute.Value().DesC());
       
   806                     }
       
   807                 else if (!tag.LocalName().DesC().CompareF(KActionTag))
       
   808                     {
       
   809                     iCurrentCtrlTransition->SetActionL(attribute.Value().DesC());
       
   810                     }
       
   811                 else if (!tag.LocalName().DesC().CompareF(KActionStringTag))
       
   812                     {
       
   813                     iCurrentCtrlTransition->SetActionStringL(attribute.Value().DesC());
       
   814                     }
       
   815                 }
       
   816             }
       
   817         }
       
   818     }
       
   819 
       
   820 void CTFXConfigParser::OnMfEndElementL(const RTagInfo& aElement, TInt /*aErrorCode*/)
       
   821     {
       
   822     if (!aElement.LocalName().DesC().CompareF(KEffectDefinitionsTag))
       
   823         {
       
   824         }
       
   825     else if (!aElement.LocalName().DesC().CompareF(KEffectTag))
       
   826         {
       
   827         iFsEffectArray->Append(iCurrentEffect);
       
   828         iCurrentEffect = NULL;
       
   829         }
       
   830     }
       
   831 
       
   832 void CTFXConfigParser::OnSelEndElementL(const RTagInfo& aElement, TInt /*aErrorCode*/)
       
   833     {
       
   834     if (!aElement.LocalName().DesC().CompareF(KFullSCRTransTag))
       
   835         {
       
   836         iParserState = EStateParsingNone;
       
   837         return;
       
   838         }
       
   839     else if (!aElement.LocalName().DesC().CompareF(KCtrlTransTag))
       
   840         {
       
   841         iParserState = EStateParsingNone;
       
   842         return;
       
   843         }
       
   844     else if(!aElement.LocalName().DesC().CompareF(KListTransTag))
       
   845         {
       
   846         iParserState = EStateParsingNone;
       
   847         return;
       
   848         }
       
   849 
       
   850     if (iParserState == EStateParsingFs || iParserState == EStateParsingList )
       
   851         {
       
   852         if (!aElement.LocalName().DesC().CompareF(KTransitionTag))
       
   853             {
       
   854             if (iFsEffectArray)
       
   855                 {
       
   856                 // pick up the associated kml file to the transition
       
   857                 // from the effect definition
       
   858                 for (TInt count = 0; count < iFsEffectArray->Count(); count++)
       
   859                     {
       
   860                     CTFxEffect* effect = iFsEffectArray->operator[](count);
       
   861                     if (! ( effect->Name().CompareF(iCurrentTransition->EffectName()) ) )
       
   862                         {
       
   863                         if (iCurrentTransition->ContextId() != KMaxTInt)
       
   864                             {
       
   865                             iCurrentTransition->SetEffect(effect);
       
   866                             }
       
   867                         }
       
   868                     }
       
   869                 }
       
   870             if( iParserState == EStateParsingFs )
       
   871                 {
       
   872                 iFsTransitionArray->Append(iCurrentTransition);
       
   873                 }
       
   874             else
       
   875                 {
       
   876                 iListTransitionArray->Append(iCurrentTransition);
       
   877                 }
       
   878             iCurrentTransition=NULL;
       
   879             }
       
   880         }
       
   881     else if (iParserState == EStateParsingCtrl)
       
   882         {
       
   883         if (!aElement.LocalName().DesC().CompareF(KTransitionTag))
       
   884             {
       
   885             if (iFsEffectArray)
       
   886                 {
       
   887                 // pick up the associated kml file to the transition
       
   888                 // from the effect definition
       
   889                 TInt count = 0;
       
   890                 for (count = 0; count < iFsEffectArray->Count(); count++)
       
   891                     {
       
   892                     CTFxEffect* effect = iFsEffectArray->operator[](count);
       
   893                     if (! ( effect->Name().CompareF(iCurrentCtrlTransition->EffectName()) ) )
       
   894                         {
       
   895                         iCurrentCtrlTransition->SetEffect(effect);
       
   896                         }
       
   897                     }
       
   898                 // find duplicate kmls so that kml files get registered only once
       
   899                 for (count = 0; count < iCtrlTransitionArray->Count(); count++)
       
   900                     {
       
   901                     CTFxCtrlTransition* trans = iCtrlTransitionArray->operator[](count);
       
   902                     if (!trans->EffectName().CompareF(iCurrentCtrlTransition->EffectName()))
       
   903                         {
       
   904                         iCurrentCtrlTransition->SetKmlRegistrationStatus(ETrue);
       
   905                         break;
       
   906                         }
       
   907                     }
       
   908                 }
       
   909             iCtrlTransitionArray->Append(iCurrentCtrlTransition);
       
   910             iCurrentCtrlTransition=NULL;
       
   911             }
       
   912         }
       
   913     }
       
   914 
       
   915 void StartSrvAndRegisterTransitionsL(const TDesC& aSkinExtensionFilename,
       
   916                                     MTransitionServer* aTransSrv,
       
   917                                     MTransitionServerController* aTransSrvCtrl,
       
   918                                     CTFXConfigParser* aConfigParser,
       
   919                                     TBool aSkipSrvStart )
       
   920     {
       
   921 
       
   922     aConfigParser->ParseL(KTFXManifestFile);
       
   923 
       
   924     aConfigParser->ParseL(aSkinExtensionFilename);
       
   925 
       
   926     // effectarray is owned by the parser -> don't push it
       
   927     RPointerArray<CTFxTransition>* transitionarray = aConfigParser->FsTransitionArrayL();
       
   928 
       
   929     RPointerArray<CTFxCtrlTransition>* ctrltransitionarray = aConfigParser->CtrlTransitionArrayL();
       
   930 
       
   931     RPointerArray<CTFxTransition>* listTransitionArray = aConfigParser->ListTransitionArrayL();
       
   932 
       
   933     TInt err(KErrNone);
       
   934 
       
   935     if (!transitionarray && !ctrltransitionarray && !listTransitionArray )
       
   936         {
       
   937         User::Leave(KErrGeneral);
       
   938         }
       
   939 
       
   940     TInt maxtransitioncachesize = 0;
       
   941     TInt maxcachesize = 0;
       
   942     if (transitionarray && transitionarray->Count())
       
   943         {
       
   944         CTFxTransition* transition = transitionarray->operator[](0);
       
   945         CTFxEffect* effect = transition->Effect();
       
   946         if (effect)
       
   947             {
       
   948             maxtransitioncachesize = effect->MaxTransCacheSize();
       
   949             maxcachesize = effect->MaxCacheSize();
       
   950             }
       
   951         }
       
   952     else if (ctrltransitionarray && ctrltransitionarray->Count())
       
   953         {
       
   954         CTFxCtrlTransition* ctrltransition = ctrltransitionarray->operator[](0);
       
   955         CTFxEffect* effect = ctrltransition->Effect();
       
   956         if (effect)
       
   957             {
       
   958             maxtransitioncachesize = effect->MaxTransCacheSize();
       
   959             maxcachesize = effect->MaxCacheSize();
       
   960             }
       
   961         }
       
   962     else if( listTransitionArray && listTransitionArray->Count() )
       
   963         {
       
   964         CTFxTransition* listTransition = listTransitionArray->operator[](0);
       
   965         CTFxEffect* effect = listTransition->Effect();
       
   966         if ( effect )
       
   967             {
       
   968             maxtransitioncachesize = effect->MaxTransCacheSize();
       
   969             maxcachesize = effect->MaxCacheSize();
       
   970             }
       
   971         }
       
   972 
       
   973     if( !aSkipSrvStart )
       
   974         {
       
   975         User::LeaveIfError(aTransSrvCtrl->StartTransitionServer(
       
   976                                     maxtransitioncachesize, maxcachesize ) );
       
   977         }
       
   978 
       
   979     if (!aTransSrv->IsConnected())
       
   980         {
       
   981         User::LeaveIfError(aTransSrv->Connect());
       
   982         }
       
   983 
       
   984 
       
   985     if (transitionarray)
       
   986         {
       
   987 
       
   988         for (TInt count = 0; count < transitionarray->Count();count++)
       
   989             {
       
   990             CTFxTransition* transition = transitionarray->operator[](count);
       
   991             CTFxEffect* effect = transition->Effect();
       
   992             if (transition && effect && effect->PathIndex() >=0)
       
   993                 {
       
   994                 err = aTransSrv->RegisterFullscreenKml(transition->ContextId(),
       
   995                     transition->Uid(),
       
   996                     aConfigParser->KmlBasePath(effect->PathIndex()),
       
   997                     effect->Filename(),
       
   998                     effect->CachePriority(),
       
   999                     effect->WantedTime(),
       
  1000                     effect->MinTime());
       
  1001                 }
       
  1002             // in KML registration leave only in OOM cases, otherwise
       
  1003             // ignore errors and try to register all possible KMLs
       
  1004             if( err == KErrNoMemory )
       
  1005                 {
       
  1006                 User::LeaveNoMemory();
       
  1007                 }
       
  1008             }
       
  1009         }
       
  1010     if (ctrltransitionarray)
       
  1011         {
       
  1012 
       
  1013         for (TInt count = 0; count < ctrltransitionarray->Count();count++)
       
  1014             {
       
  1015             CTFxCtrlTransition* ctrltransition = ctrltransitionarray->operator[](count);
       
  1016             CTFxEffect* effect = ctrltransition->Effect();
       
  1017             if (ctrltransition && effect && effect->PathIndex() >=0)
       
  1018                 {
       
  1019                 if (!ctrltransition->KmlRegistrationStatus())
       
  1020                     {
       
  1021                     err = aTransSrv->RegisterControlKml(ctrltransition->ContextUid(),
       
  1022                         aConfigParser->KmlBasePath(effect->PathIndex()),
       
  1023                         effect->Filename(), effect->WantedTime(), effect->MinTime());
       
  1024                     if( err == KErrNoMemory )
       
  1025                         {
       
  1026                         User::LeaveNoMemory();
       
  1027                         }
       
  1028                     }
       
  1029                 err = aTransSrv->RegisterControlAction(ctrltransition->ContextUid(),
       
  1030                     ctrltransition->Action(),
       
  1031                     ctrltransition->ActionString());
       
  1032 
       
  1033                 if( err == KErrNoMemory )
       
  1034                     {
       
  1035                     User::LeaveNoMemory();
       
  1036                     }
       
  1037                 }
       
  1038             }
       
  1039         }
       
  1040 
       
  1041     if (listTransitionArray)
       
  1042         {
       
  1043 
       
  1044         for( TInt i( 0 ); i < listTransitionArray->Count(); i++ )
       
  1045             {
       
  1046 
       
  1047             CTFxTransition* listTransition = listTransitionArray->operator[](i);
       
  1048 
       
  1049             CTFxTransition* listBackgroundTrans = NULL;
       
  1050             CTFxTransition* listItemTrans = NULL;
       
  1051 
       
  1052             if( listTransition->ContextId() == KListBackgroundContext )
       
  1053                 {
       
  1054                 listBackgroundTrans = listTransition;
       
  1055                 }
       
  1056             else if( listTransition->ContextId() == KListItemContext )
       
  1057                 {
       
  1058                 listItemTrans = listTransition;
       
  1059                 }
       
  1060 
       
  1061             // find a pair (list item - list background) for this transition
       
  1062             for( TInt j(i+1); j < listTransitionArray->Count(); j++ )
       
  1063                 {
       
  1064                 CTFxTransition* lt = listTransitionArray->operator[]( j );
       
  1065 
       
  1066                 if ( (lt->Uid() == listTransition->Uid()) &&
       
  1067                     lt->Type() == listTransition->Type() )
       
  1068                     {
       
  1069                     if( lt->ContextId() == KListBackgroundContext )
       
  1070                         {
       
  1071                         listBackgroundTrans = lt;
       
  1072                         }
       
  1073                      else if( lt->ContextId() == KListItemContext )
       
  1074                         {
       
  1075                         listItemTrans = lt;
       
  1076                         }
       
  1077                     }
       
  1078                 }
       
  1079 
       
  1080             if( listBackgroundTrans && listItemTrans )
       
  1081                 {
       
  1082                 CTFxEffect* listBgEffect = listBackgroundTrans->Effect();
       
  1083                 CTFxEffect* listItemEffect = listItemTrans->Effect();
       
  1084 
       
  1085                 if( listBgEffect && listItemEffect )
       
  1086                     {
       
  1087                     TInt type( 0 );
       
  1088                     type = listBackgroundTrans->Type();
       
  1089                     if( type == 0 )
       
  1090                         {
       
  1091                         type = listItemTrans->Type();
       
  1092                         }
       
  1093 
       
  1094                     err = aTransSrv->RegisterListBoxKml(
       
  1095                                             listBackgroundTrans->Uid(),
       
  1096                                             type,
       
  1097                                             aConfigParser->KmlBasePath(listBgEffect->PathIndex()),
       
  1098                                             listBgEffect->Filename(),
       
  1099                                             listItemEffect->Filename() );
       
  1100 
       
  1101                     if( err == KErrNoMemory )
       
  1102                         {
       
  1103                         User::LeaveNoMemory();
       
  1104                         }
       
  1105                     }
       
  1106                 }
       
  1107             }
       
  1108         }
       
  1109     }
       
  1110 
       
  1111 // End of file