sysresmonitoring/oommonitor/tsrc/ut_oom_memorymonitor/src/mockoomconfigparser.cpp
changeset 77 b01c07dfcf84
equal deleted inserted replaced
74:1505405bc645 77:b01c07dfcf84
       
     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:  The parser for the OOM configuration file.
       
    15 *
       
    16 */
       
    17 #include <e32base.h>
       
    18 #include <xml/parser.h>
       
    19 
       
    20 #include "oomconfigparser.h"
       
    21 #include "oompanic.h"
       
    22 #include "OomTraces.h"
       
    23 #include "oomidletimerule.h"
       
    24 #include "oomforegroundrule.h"
       
    25 #include "oomconstants.hrh"
       
    26 #include "oomapplicationconfig.h"
       
    27 #include "oomcloseappconfig.h"
       
    28 #include "oomconfig.h"
       
    29 #include "oomrunpluginconfig.h"
       
    30 
       
    31 #include "diclog.h"
       
    32 #include "globaldata.h"
       
    33 
       
    34 enum TOomConfigParserPanic
       
    35 {
       
    36 KOomErrMoreThanOneOomConfig = 0,
       
    37 KOomErrGlobalSettingsMustComeAfterRoot,
       
    38 KOomErrAppSettingsMustComeAfterGlobalSettings,
       
    39 KOomErrCloseAppSettingsMustComeAfterAppSettings,
       
    40 KOomErrAppIdleSettingsMustComeAfterAppCloseSettings,
       
    41 KOomErrLowRamErrorInGlobalSettings,
       
    42 KOomErrGoodRamErrorInGlobalSettings,
       
    43 KOomErrSwapUsageMonitoredErrorInGlobalSettings,
       
    44 KOomErrLowSwapErrorInGlobalSettings,
       
    45 KOomErrGoodSwapErrorInGlobalSettings,
       
    46 KOomErrMaxCloseErrorInGlobalSettings,
       
    47 KOomErrDefaultPriorityErrorInGlobalSettings,
       
    48 KOomErrMissingUidFromAppCloseConfig,
       
    49 KOomErrMissingPriorityFromAppCloseConfig,
       
    50 KOomErrMissingSyncModeFromAppCloseConfig,
       
    51 KOomErrMissingEstimateFromAppCloseConfig,
       
    52 KOomErrInvalidSyncMode,
       
    53 KOomErrMissingSyncModeInAppCloseConfig,
       
    54 KOomErrBadOrMissingPriorityInAppIdleRule,
       
    55 KOomErrBadOrMissingIdleTimeInAppIdleRule,
       
    56 KOomErrBadOrMissingUidInAppIdleRule,
       
    57 KOomErrBadNeverCloseValue,
       
    58 KOomErrBadOrMissingUidInAppConfig,
       
    59 KOomErrBadOrMissingPriorityInAppCloseConfig,
       
    60 KOomErrBadLowThresholdValueForAppConfig,
       
    61 KOomErrBadGoodThresholdValueForAppConfig,
       
    62 KOomErrSystemPluginSettingsMustComeAfterAppCloseSettings,
       
    63 KOomErrAppPluginSettingsMustComeAfterSystemPluginSettings,
       
    64 KOomErrAppPluginIdleTimeRulesMustComeAfterAppPluginSettings,
       
    65 KOomErrBadOrMissingUidInAppCloseConfig,
       
    66 KOomErrBadOrMissingUidInSystemPluginConfig,
       
    67 KOomErrBadOrMissingPriorityInSystemPluginConfig,
       
    68 KOomErrBadOrMissingTargetAppIdInAppPluginConfig,
       
    69 KOomErrBadOrMissingUidInAppPluginConfig,
       
    70 KOomErrBadOrMissingPriorityInAppPluginConfig,
       
    71 KOomErrBadOrMissingPriorityInPluginIdleRule,
       
    72 KOomErrBadOrMissingIdleTimeInPluginIdleRule,
       
    73 KOomErrBadOrMissingUidInPluginIdleRule,
       
    74 KOomErrBadOrMissingUidInForegroundAppRule,
       
    75 KOomErrBadOrMissingPriorityInForegroundAppRule,
       
    76 KOomErrBadOrMissingTargetAppIdInForegroundAppRule,
       
    77 KOomErrDefaultWaitAfterPluginInGlobalSettings,
       
    78 KOomErrBadOrMissingPriorityInForceCheck,
       
    79 KOomErrOomRulesMustComeLast,
       
    80 KOomErrBadPluginWaitTime,
       
    81 KOomErrBadXml,
       
    82 KOomErrAppCloseIdleRuleOutsideAppCloseElement,
       
    83 KOomErrForegroundAppRuleOutsideAppCloseElement,
       
    84 KOomErrPluginIdleRuleOutsideAppPluginElement,
       
    85 KOomErrPluginForegroundRuleOutsidePluginElement,
       
    86 KOomErrBadCallIfTargetAppNotRunning
       
    87 };
       
    88 
       
    89 const TInt KOomXmlFileBufferSize = 1024;
       
    90 const TInt KOomMaxAppExitTime = 2000;
       
    91 const TInt KBytesInMegabyte = 1024;
       
    92 #ifdef __WINS__
       
    93 const TInt KEmulatorTickDivisor = 5; // The tick is 5 times slower on the emulator than on the phone
       
    94 #endif
       
    95 using namespace Xml;
       
    96 
       
    97 // Mime type of the parsed document
       
    98 _LIT8(KXmlMimeType, "text/xml");
       
    99 
       
   100 _LIT(KOomConfigFilePath, ":\\testframework\\oomconfig.xml");
       
   101 _LIT(KRomDrive, "z");
       
   102 
       
   103 // Element strings
       
   104 // Root
       
   105 _LIT8(KOomConfigOomConfig, "oom_config");
       
   106 
       
   107 // Global settings
       
   108 _LIT8(KOomConfigGlobalSettings, "global_settings");
       
   109 _LIT8(KOomConfigForceCheckAtPriority, "force_check");
       
   110 
       
   111 // App settings
       
   112 _LIT8(KOomConfigAppSettings, "app_specific_thresholds");
       
   113 _LIT8(KOomConfigApp, "app");
       
   114 
       
   115 // App close settings
       
   116 _LIT8(KOomConfigAppCloseSettings, "app_close_settings");
       
   117 _LIT8(KOomConfigCloseApp, "close_app");
       
   118 
       
   119 // App close idle time
       
   120 _LIT8(KOomConfigAppCloseIdlePriority, "app_close_idle_priority");
       
   121 
       
   122 _LIT8(KOomConfigForegroundAppPriority, "foreground_app_priority");
       
   123 
       
   124 // Global settings attribute names
       
   125 _LIT8(KOomAttributeLowRamThreshold, "low_ram_threshold");
       
   126 _LIT8(KOomAttributeGoodRamThreshold, "good_ram_threshold");
       
   127 _LIT8(KOomAttributeSwapUsageMonitored, "swap_usage_monitored");
       
   128 _LIT8(KOomAttributeLowSwapThreshold, "low_swap_threshold");
       
   129 _LIT8(KOomAttributeGoodSwapThreshold, "good_swap_threshold");
       
   130 _LIT8(KOomAttributeMaxAppCloseBatch, "max_app_close_batch");
       
   131 _LIT8(KOomAttributeDefaultWaitAfterPlugin, "default_wait_after_plugin");
       
   132 _LIT8(KOomAttributeMaxAppExitTime , "max_app_exit_time");
       
   133 
       
   134 // System plugins 
       
   135 
       
   136 _LIT8(KOomAttributeSystemPluginSettings, "system_plugin_settings");
       
   137 _LIT8(KOomAttributeSystemPlugin, "system_plugin");
       
   138 
       
   139 // Application plugins
       
   140 
       
   141 _LIT8(KOomAttributeAppPluginSettings, "app_plugin_settings");
       
   142 _LIT8(KOomAttributeAppPlugin, "app_plugin");
       
   143 
       
   144 // Plugin idle time rules
       
   145 
       
   146 _LIT8(KOomAttributePluginIdlePriority, "plugin_idle_priority");
       
   147 
       
   148 // Plugin foreground app rules
       
   149 _LIT8(KOomAttributePluginForegroundAppPriority, "plugin_foreground_app_priority");
       
   150 
       
   151 // Atribute names
       
   152 _LIT8(KOomAttibuteUid, "uid");
       
   153 _LIT8(KOomAttibuteSyncMode, "sync_mode");
       
   154 _LIT8(KOomAttibutePriority, "priority");
       
   155 _LIT8(KOomAttibuteRamEstimate, "ram_estimate");
       
   156 
       
   157 _LIT8(KOomConfigSyncModeContinue, "continue");
       
   158 _LIT8(KOomConfigSyncModeCheck, "check");
       
   159 _LIT8(KOomConfigSyncModeEstimate, "estimate");
       
   160 
       
   161 _LIT8(KOomAttibuteIdleTime, "idle_time");
       
   162 _LIT8(KOomAttibuteIdlePriority, "priority");
       
   163 
       
   164 _LIT8(KOomAttibuteNeverClose, "NEVER_CLOSE");
       
   165 
       
   166 _LIT8(KOomAttributeTargetAppId, "target_app_id");
       
   167 
       
   168 _LIT8(KOomAttributeWait, "wait");
       
   169 
       
   170 _LIT8(KOomAttributeIfForegroundAppId, "if_foreground_app_id");
       
   171 
       
   172 _LIT8(KOomAttributeCallIfTargetAppNotRunning, "call_if_target_app_not_running");
       
   173 _LIT8(KOomAttributeTrue, "true");
       
   174 _LIT8(KOomAttributeFalse, "false");
       
   175 _LIT8(KOomAttribute0, "0");
       
   176 _LIT8(KOomAttribute1, "1");
       
   177 
       
   178 
       
   179 _LIT8(KOomConfigDefaultAppUid, "DEFAULT_APP");
       
   180 _LIT8(KOomConfigDefaultPluginUid, "DEFAULT_PLUGIN");
       
   181 _LIT8(KOomConfigTargetAppValue, "TARGET_APP");
       
   182 
       
   183 _LIT8(KOomConfigBusyAppUid, "BUSY_APP");
       
   184 _LIT8(KOomConfigHighPriorityAppUid, "HIGH_PRIORITY_APP");
       
   185 
       
   186 COomConfigParser::COomConfigParser(COomConfig& aConfig, RFs& aFs) : iConfig(aConfig), iFs(aFs), iState(EOomParsingStateNone)
       
   187     {
       
   188     }
       
   189 
       
   190 void COomConfigParser::ParseL()
       
   191     {
       
   192     TBuf<KIntValue8> buf(KConfigParserParser);
       
   193     DicLog::WriteLog(TUid::Uid(0x0001), buf);
       
   194     
       
   195     FUNC_LOG;
       
   196 
       
   197     TRACES("COomConfigParser::ParseL: Parsing Config File");
       
   198     
       
   199     CParser* parser = CParser::NewLC(KXmlMimeType, *this);
       
   200     
       
   201     RFile configFile;
       
   202     TFileName configFileName;
       
   203     TChar driveChar = iFs.GetSystemDriveChar();
       
   204     configFileName.Append(driveChar);
       
   205     configFileName.Append(KOomConfigFilePath);
       
   206     if (configFile.Open(iFs, configFileName, EFileShareExclusive) != KErrNone)
       
   207         {
       
   208         configFileName.Replace(0,1,KRomDrive); //replace 'c' with 'z'
       
   209         User::LeaveIfError(configFile.Open(iFs, configFileName, EFileShareExclusive));
       
   210         }
       
   211     CleanupClosePushL(configFile);
       
   212     
       
   213     TBuf8<KOomXmlFileBufferSize> fileBuffer;
       
   214     TInt bytesRead;
       
   215     do
       
   216         {
       
   217         User::LeaveIfError(configFile.Read(fileBuffer));
       
   218         bytesRead = fileBuffer.Size();
       
   219         
       
   220         parser->ParseL(fileBuffer);
       
   221         
       
   222         } while (bytesRead != 0);
       
   223     
       
   224     CleanupStack::PopAndDestroy(2, parser); // config file - automatically closes it
       
   225                                             // parser
       
   226             
       
   227     TRACES("COomConfigParser::ParseL: Finished Parsing Config File");    
       
   228     }
       
   229 
       
   230 void COomConfigParser::OnStartDocumentL(const RDocumentParameters&, TInt)
       
   231     {
       
   232     FUNC_LOG;
       
   233     }
       
   234 
       
   235 void COomConfigParser::OnEndDocumentL(TInt)
       
   236     {
       
   237     FUNC_LOG;
       
   238     }
       
   239 
       
   240 
       
   241 void COomConfigParser::OnEndElementL(const RTagInfo&, TInt)
       
   242     {
       
   243     }
       
   244 
       
   245 void COomConfigParser::OnContentL(const TDesC8&, TInt)
       
   246     {
       
   247     }
       
   248 
       
   249 void COomConfigParser::OnStartPrefixMappingL(const RString&, const RString&, 
       
   250                                    TInt)
       
   251     {
       
   252     }
       
   253 
       
   254 void COomConfigParser::OnEndPrefixMappingL(const RString&, TInt)
       
   255     {
       
   256     }
       
   257 
       
   258 void COomConfigParser::OnIgnorableWhiteSpaceL(const TDesC8&, TInt)
       
   259     {
       
   260     }
       
   261 
       
   262 void COomConfigParser::OnSkippedEntityL(const RString&, TInt)
       
   263     {
       
   264     }
       
   265 
       
   266 void COomConfigParser::OnProcessingInstructionL(const TDesC8&, const TDesC8&, 
       
   267                                       TInt)
       
   268     {
       
   269     }
       
   270 
       
   271 void COomConfigParser::OnError(TInt)
       
   272     {
       
   273     }
       
   274 
       
   275 TAny* COomConfigParser::GetExtendedInterface(const TInt32)
       
   276     {
       
   277     return 0;
       
   278     }
       
   279 
       
   280 void COomConfigParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, 
       
   281                              TInt aErrorCode)
       
   282     {
       
   283     if (aErrorCode != KErrNone)
       
   284         ConfigError(KOomErrBadXml);
       
   285     
       
   286     StartElementL(aElement.LocalName().DesC(), aAttributes);
       
   287     }
       
   288 
       
   289 void COomConfigParser::StartElementL(const TDesC8& aLocalName,
       
   290                                         const RAttributeArray& aAttributes)
       
   291     {
       
   292     // Root
       
   293     if (aLocalName == KOomConfigOomConfig)
       
   294         {
       
   295         if (iState != EOomParsingStateNone)
       
   296             ConfigError(KOomErrMoreThanOneOomConfig);
       
   297         
       
   298         ChangeState(EOomParsingStateRoot);
       
   299         }
       
   300     // Parse main elements
       
   301     else if (aLocalName == KOomConfigGlobalSettings)
       
   302         {
       
   303         if (iState != EOomParsingStateRoot)
       
   304             ConfigError(KOomErrGlobalSettingsMustComeAfterRoot);
       
   305         
       
   306         SetGlobalSettings(aAttributes);
       
   307         
       
   308         ChangeState(EOomParsingStateGlobalSettings);
       
   309         }
       
   310     else if (aLocalName == KOomConfigAppSettings)
       
   311         {
       
   312         ChangeState(EOomParsingStateAppSettings);
       
   313         }
       
   314     else if (aLocalName == KOomConfigAppCloseSettings)
       
   315         {
       
   316         ChangeState(EOomParsingStateAppCloseSettings);
       
   317         }
       
   318     else if (aLocalName == KOomAttributeSystemPluginSettings)
       
   319         {
       
   320         ChangeState(EOomParsingStateSystemPluginSettings);
       
   321         }
       
   322     else if (aLocalName == KOomAttributeAppPluginSettings)
       
   323         {
       
   324         ChangeState(EOomParsingStateAppPluginSettings);
       
   325         }
       
   326     // Parse actual configuration elements
       
   327     else if (aLocalName == KOomConfigForceCheckAtPriority)
       
   328         {
       
   329         SetForceCheckConfigL(aAttributes);
       
   330         }
       
   331     else if (aLocalName == KOomConfigApp)
       
   332         {
       
   333         SetAppConfigL(aAttributes);
       
   334         }
       
   335     else if (aLocalName == KOomConfigCloseApp)
       
   336         {
       
   337         SetCloseAppConfigL(aAttributes);
       
   338         }
       
   339     else if (aLocalName == KOomConfigAppCloseIdlePriority)
       
   340         {
       
   341         CheckState(EOomParsingStateAppCloseSettings, KOomErrAppCloseIdleRuleOutsideAppCloseElement);
       
   342         SetAppCloseIdlePriorityConfigL(aAttributes);
       
   343         }
       
   344     else if (aLocalName == KOomConfigForegroundAppPriority)
       
   345         {
       
   346         CheckState(EOomParsingStateAppCloseSettings, KOomErrForegroundAppRuleOutsideAppCloseElement);
       
   347         SetForegroundAppPriorityL(aAttributes);
       
   348         }
       
   349     else if (aLocalName == KOomAttributeSystemPlugin)
       
   350         {
       
   351         SetSystemPluginConfigL(aAttributes);
       
   352         }
       
   353     else if (aLocalName == KOomAttributeAppPlugin)
       
   354         {
       
   355         SetAppPluginConfigL(aAttributes);
       
   356         }
       
   357     else if (aLocalName == KOomAttributePluginIdlePriority)
       
   358         {
       
   359         CheckState(EOomParsingStateAppPluginSettings, KOomErrPluginIdleRuleOutsideAppPluginElement);
       
   360         SetPluginIdlePriorityL(aAttributes);
       
   361         }
       
   362     else if (aLocalName == KOomAttributePluginForegroundAppPriority)
       
   363         {
       
   364         CheckState(EOomParsingStateAppPluginSettings, EOomParsingStateSystemPluginSettings, KOomErrPluginForegroundRuleOutsidePluginElement);
       
   365         SetPluginForegroundAppPriorityL(aAttributes);
       
   366         }
       
   367     
       
   368     }
       
   369 
       
   370 void COomConfigParser::ConfigError(TInt aError)
       
   371     {
       
   372     OomConfigParserPanic(aError);
       
   373     }
       
   374 
       
   375 void COomConfigParser::SetGlobalSettings(const RAttributeArray& aAttributes)
       
   376     {
       
   377     TInt defaultLowMemoryThreshold;    
       
   378     TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowRamThreshold, defaultLowMemoryThreshold);
       
   379 
       
   380     if (err == KErrNone)
       
   381         iConfig.SetDefaultLowRamThreshold(defaultLowMemoryThreshold * KBytesInMegabyte);
       
   382     else
       
   383         ConfigError(KOomErrLowRamErrorInGlobalSettings);
       
   384     
       
   385     if (err == KErrNone)
       
   386         {
       
   387         TInt defaultGoodMemoryThreshold;    
       
   388         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodRamThreshold, defaultGoodMemoryThreshold);
       
   389 
       
   390         if (err == KErrNone)
       
   391             iConfig.SetDefaultGoodRamThreshold(defaultGoodMemoryThreshold * KBytesInMegabyte);
       
   392         else
       
   393             ConfigError(KOomErrGoodRamErrorInGlobalSettings);
       
   394         }
       
   395 
       
   396     if (err == KErrNone)
       
   397         {
       
   398         TInt swapUsageMonitored;
       
   399         TInt err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeSwapUsageMonitored, swapUsageMonitored);
       
   400         
       
   401         if (err == KErrNone)
       
   402             iConfig.SetSwapUsageMonitored(swapUsageMonitored);
       
   403         else
       
   404             ConfigError(KOomErrSwapUsageMonitoredErrorInGlobalSettings);
       
   405         }
       
   406     
       
   407     if (err == KErrNone)
       
   408         {
       
   409         TInt defaultLowSwapThreshold;    
       
   410         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, defaultLowSwapThreshold);
       
   411 
       
   412         if (err == KErrNone)
       
   413             iConfig.SetDefaultLowSwapThreshold(defaultLowSwapThreshold * KBytesInMegabyte);
       
   414         else
       
   415             ConfigError(KOomErrLowSwapErrorInGlobalSettings);
       
   416         }
       
   417 
       
   418     if (err == KErrNone)
       
   419         {
       
   420         TInt defaultGoodSwapThreshold;    
       
   421         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, defaultGoodSwapThreshold);
       
   422 
       
   423         if (err == KErrNone)
       
   424             iConfig.SetDefaultGoodSwapThreshold(defaultGoodSwapThreshold * KBytesInMegabyte);
       
   425         else
       
   426             ConfigError(KOomErrGoodSwapErrorInGlobalSettings);
       
   427         }
       
   428     
       
   429     if (err == KErrNone)
       
   430         {
       
   431         TInt defaultMaxCloseAppBatch;    
       
   432         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppCloseBatch, defaultMaxCloseAppBatch);
       
   433 
       
   434         if (err == KErrNone)
       
   435             iConfig.SetMaxCloseAppBatch(defaultMaxCloseAppBatch);
       
   436         else
       
   437             ConfigError(KOomErrMaxCloseErrorInGlobalSettings);
       
   438         }
       
   439     
       
   440     if (err == KErrNone)
       
   441         {
       
   442         TInt defaultWaitAfterPlugin;    
       
   443         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeDefaultWaitAfterPlugin, defaultWaitAfterPlugin);
       
   444 
       
   445         if (err == KErrNone)
       
   446             iConfig.SetDefaultWaitAfterPlugin(defaultWaitAfterPlugin);
       
   447         else
       
   448             ConfigError(KOomErrDefaultWaitAfterPluginInGlobalSettings);
       
   449         }
       
   450     
       
   451     if (err == KErrNone)
       
   452         {
       
   453         TInt maxAppExitTime;    
       
   454         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppExitTime, maxAppExitTime);
       
   455 
       
   456         if (err == KErrNone)
       
   457             iConfig.SetMaxAppExitTime(maxAppExitTime);
       
   458         else
       
   459             iConfig.SetMaxAppExitTime(KOomMaxAppExitTime);
       
   460         }
       
   461     }
       
   462 
       
   463 void COomConfigParser::SetForceCheckConfigL(const RAttributeArray& aAttributes)
       
   464     {
       
   465     TUint priority;
       
   466     TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
       
   467     if (err == KErrNone)
       
   468         {
       
   469         iConfig.GlobalConfig().AddForceCheckPriorityL(priority);
       
   470         }
       
   471     else
       
   472         {
       
   473         ConfigError(KOomErrBadOrMissingPriorityInForceCheck);    
       
   474         }
       
   475     }
       
   476 
       
   477 void COomConfigParser::SetAppConfigL(const RAttributeArray& aAttributes)
       
   478     {
       
   479     TUint uid;
       
   480     COomApplicationConfig* appConfig = NULL;
       
   481     
       
   482     TInt err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
       
   483     
       
   484     if (err != KErrNone)
       
   485         {
       
   486         ConfigError(KOomErrBadOrMissingUidInAppConfig);
       
   487         }
       
   488     else
       
   489         iParentUid = uid;
       
   490 
       
   491     appConfig = COomApplicationConfig::NewL(uid);
       
   492     CleanupStack::PushL(appConfig);    
       
   493         
       
   494     // Set the app specific memory thresholds (if they exist)
       
   495     // Get the app specific low threshold
       
   496     if (err == KErrNone)
       
   497         {
       
   498         TUint lowThreshold;
       
   499         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowRamThreshold, lowThreshold);
       
   500         if (err == KErrNone)
       
   501             {
       
   502             appConfig->iLowRamThreshold = lowThreshold * KBytesInMegabyte;
       
   503             }
       
   504         else if (err == KErrNotFound)
       
   505             err = KErrNone;
       
   506         
       
   507         if (err != KErrNone)
       
   508             ConfigError(KOomErrBadLowThresholdValueForAppConfig);
       
   509         }
       
   510 
       
   511     // Get the app specific good threshold
       
   512     if (err == KErrNone)
       
   513         {
       
   514         TUint goodThreshold;
       
   515         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodRamThreshold, goodThreshold);
       
   516         if (err == KErrNone)
       
   517             {
       
   518             appConfig->iGoodRamThreshold = goodThreshold * KBytesInMegabyte;
       
   519             }
       
   520         else if (err == KErrNotFound)
       
   521             err = KErrNone;
       
   522         
       
   523         if (err != KErrNone)
       
   524             ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
       
   525         }
       
   526     
       
   527     // Set the app specific swap thresholds (if they exist)
       
   528     // Get the app specific low swap threshold
       
   529     if (err == KErrNone)
       
   530         {
       
   531         TUint lowThreshold;
       
   532         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, lowThreshold);
       
   533         if (err == KErrNone)
       
   534             {
       
   535             appConfig->iLowSwapThreshold = lowThreshold * KBytesInMegabyte;
       
   536             }
       
   537         else if (err == KErrNotFound)
       
   538             err = KErrNone;
       
   539             
       
   540         if (err != KErrNone)
       
   541             ConfigError(KOomErrBadLowThresholdValueForAppConfig);
       
   542         }
       
   543 
       
   544     // Get the app specific good swapthreshold
       
   545     if (err == KErrNone)
       
   546         {
       
   547         TUint goodThreshold;
       
   548         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, goodThreshold);
       
   549         if (err == KErrNone)
       
   550             {
       
   551             appConfig->iGoodSwapThreshold = goodThreshold * KBytesInMegabyte;
       
   552             }
       
   553         else if (err == KErrNotFound)
       
   554             err = KErrNone;
       
   555             
       
   556         if (err != KErrNone)
       
   557             ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
       
   558         }  
       
   559         
       
   560     // Add the applciation config to the main config
       
   561     if ((err == KErrNone) && (appConfig))
       
   562         {
       
   563         iConfig.AddApplicationConfigL(appConfig);
       
   564         }
       
   565     
       
   566     if (appConfig)
       
   567         CleanupStack::Pop(appConfig);
       
   568     }
       
   569 
       
   570 void COomConfigParser::SetCloseAppConfigL(const RAttributeArray& aAttributes)
       
   571     {
       
   572     // Get and convert uid attribute to TInt
       
   573     TInt err = KErrNone;
       
   574     
       
   575     TUint uid;
       
   576     err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
       
   577 
       
   578     if (err != KErrNone)
       
   579         {
       
   580         ConfigError(KOomErrBadOrMissingUidInAppCloseConfig);    
       
   581         return;
       
   582         }
       
   583     else
       
   584         iParentUid = uid;
       
   585     
       
   586     COomCloseAppConfig* closeAppConfig = COomCloseAppConfig::NewL(uid); // Radio UID
       
   587     CleanupStack::PushL(closeAppConfig);
       
   588 
       
   589      if (err == KErrNone)
       
   590         {
       
   591         // Check that we have a priority for the added app_close event
       
   592         // Specifying a priority is mandatory
       
   593         TUint priority;
       
   594         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
       
   595         if (err == KErrNone)
       
   596             {
       
   597             closeAppConfig->SetDefaultPriority(priority);
       
   598             }
       
   599         else
       
   600             {
       
   601             ConfigError(KOomErrBadOrMissingPriorityInAppCloseConfig);    
       
   602             }
       
   603         }
       
   604     
       
   605     if (err == KErrNone)
       
   606         {
       
   607         TPtrC8 syncModeString;
       
   608         err = GetValueFromAttributeList(aAttributes, KOomAttibuteSyncMode, syncModeString);
       
   609         
       
   610         if (err == KErrNone)
       
   611             {
       
   612             TOomSyncMode syncMode = EContinue;
       
   613             
       
   614             if (syncModeString == KOomConfigSyncModeContinue)
       
   615                 syncMode = EContinue;
       
   616             else if (syncModeString == KOomConfigSyncModeCheck)
       
   617                 syncMode = ECheckRam;
       
   618             else if (syncModeString == KOomConfigSyncModeEstimate)
       
   619                 syncMode = EEstimate;
       
   620             else
       
   621                 ConfigError(KOomErrInvalidSyncMode);
       
   622             
       
   623             if (err == KErrNone)
       
   624                 {
       
   625                 closeAppConfig->iSyncMode = syncMode;
       
   626                 }
       
   627             }
       
   628         else
       
   629             {
       
   630             ConfigError(KOomErrMissingSyncModeInAppCloseConfig);
       
   631             }
       
   632         }
       
   633     
       
   634     
       
   635     if (err == KErrNone)
       
   636         {
       
   637         // If we have a default priority attribute then add it, otherwise use the global default priority
       
   638         TInt ramEstimate;
       
   639         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteRamEstimate, ramEstimate);
       
   640         if ((err == KErrNotFound) && (closeAppConfig->iSyncMode != EEstimate))
       
   641             {
       
   642             err = KErrNone;
       
   643             }
       
   644         
       
   645         if (err != KErrNone)
       
   646             ConfigError(KOomErrMissingEstimateFromAppCloseConfig);
       
   647         else
       
   648             closeAppConfig->iRamEstimate = ramEstimate * KBytesInMegabyte;
       
   649            }
       
   650 
       
   651     if (err == KErrNone)
       
   652         iConfig.SetAppCloseConfigL(closeAppConfig);
       
   653     
       
   654     CleanupStack::Pop(closeAppConfig);
       
   655     }
       
   656 
       
   657 void COomConfigParser::SetAppCloseIdlePriorityConfigL(const RAttributeArray& aAttributes)
       
   658     {
       
   659     TUint uid;
       
   660     TInt idleTime;
       
   661     TUint priority;
       
   662 
       
   663     // Use the UID from the parent scope
       
   664     uid = iParentUid;
       
   665 
       
   666     TInt err = KErrNone;
       
   667     
       
   668     err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdleTime, idleTime);
       
   669     
       
   670 #ifdef __WINS__
       
   671     // The tick is 5 times slower on the emulator than on the phone
       
   672     idleTime = idleTime / KEmulatorTickDivisor;
       
   673 #endif
       
   674     
       
   675     if (err != KErrNone)
       
   676         {
       
   677         ConfigError(KOomErrBadOrMissingIdleTimeInAppIdleRule);
       
   678         }
       
   679     
       
   680     if (err == KErrNone)
       
   681         {
       
   682         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
       
   683         
       
   684         if (err != KErrNone)
       
   685             {
       
   686             ConfigError(KOomErrBadOrMissingPriorityInAppIdleRule);
       
   687             }
       
   688         }
       
   689     
       
   690     if (err == KErrNone)
       
   691         {
       
   692         COomIdleTimeRule* idleRule = COomIdleTimeRule::NewL(idleTime, priority);
       
   693         CleanupStack::PushL(idleRule);
       
   694         iConfig.AddApplicationRuleL(uid, idleRule);
       
   695         CleanupStack::Pop(idleRule);
       
   696         }
       
   697     }
       
   698 
       
   699 void COomConfigParser::SetForegroundAppPriorityL(const RAttributeArray& aAttributes)
       
   700     {
       
   701     TUint appUid;
       
   702     TUint targetAppId;
       
   703     TUint priority;
       
   704 
       
   705     TInt err = KErrNone;
       
   706     
       
   707     // Use the UID from the parent scope
       
   708     appUid = iParentUid;
       
   709 
       
   710     // Check that we have a priority for the added system plugin action
       
   711     // Specifying a priority is mandatory
       
   712     err = GetValueFromHexAttributeList(aAttributes, KOomAttributeIfForegroundAppId, targetAppId);
       
   713     if (err != KErrNone)
       
   714         {
       
   715         ConfigError(KOomErrBadOrMissingTargetAppIdInForegroundAppRule);    
       
   716         }
       
   717     
       
   718     if (err == KErrNone)
       
   719         {
       
   720         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
       
   721         
       
   722         if (err != KErrNone)
       
   723             {
       
   724             ConfigError(KOomErrBadOrMissingPriorityInForegroundAppRule);
       
   725             }
       
   726         }
       
   727     
       
   728     if (err == KErrNone)
       
   729         {
       
   730         COomForegroundRule* foregroundRule = new (ELeave) COomForegroundRule(targetAppId, priority);
       
   731         CleanupStack::PushL(foregroundRule);
       
   732         iConfig.AddApplicationRuleL(appUid, foregroundRule);
       
   733         CleanupStack::Pop(foregroundRule);
       
   734         }
       
   735 
       
   736     }
       
   737 
       
   738 void COomConfigParser::SetSystemPluginConfigL(const RAttributeArray& aAttributes)
       
   739     {
       
   740     // Get and convert uid attribute to TInt
       
   741     TInt err = KErrNone;
       
   742     
       
   743     TUint uid;
       
   744     err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
       
   745 
       
   746     if (err != KErrNone)
       
   747         {
       
   748         ConfigError(KOomErrBadOrMissingUidInSystemPluginConfig);    
       
   749         return;
       
   750         }
       
   751     else
       
   752         iParentUid = uid;
       
   753     
       
   754     COomRunPluginConfig* pluginConfig = COomRunPluginConfig::NewL(uid, EOomSystemPlugin);
       
   755     CleanupStack::PushL(pluginConfig);
       
   756 
       
   757      if (err == KErrNone)
       
   758         {
       
   759         // Check that we have a priority for the added system plugin action
       
   760         // Specifying a priority is mandatory
       
   761         TUint priority;
       
   762         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
       
   763         if (err == KErrNone)
       
   764             {
       
   765             pluginConfig->SetDefaultPriority(priority);
       
   766             }
       
   767         else
       
   768             {
       
   769             ConfigError(KOomErrBadOrMissingPriorityInSystemPluginConfig);    
       
   770             }
       
   771         }
       
   772      
       
   773      if (err == KErrNone)
       
   774         {
       
   775         TInt wait;
       
   776         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeWait, wait);
       
   777         if (err == KErrNone)
       
   778             {
       
   779             pluginConfig->SetWaitAfterPlugin(wait);
       
   780             }
       
   781         else if (err == KErrNotFound)
       
   782             {
       
   783             // If this attribute isn't present then just don't set it, and clear the error
       
   784             err = KErrNone;
       
   785             }
       
   786         else
       
   787             ConfigError(KOomErrBadPluginWaitTime);
       
   788         }
       
   789      
       
   790      if (err == KErrNone)
       
   791          {
       
   792          // Get the config for the sync mode for this plugin (if one is specified) and set it
       
   793          SetPluginSyncMode(aAttributes, *pluginConfig);
       
   794          }
       
   795 
       
   796      iConfig.AddPluginConfigL(pluginConfig);
       
   797      
       
   798      CleanupStack::Pop(pluginConfig);
       
   799     }
       
   800 
       
   801 void COomConfigParser::SetAppPluginConfigL(const RAttributeArray& aAttributes)
       
   802     {
       
   803     // Get and convert uid attribute to TInt
       
   804     TInt err = KErrNone;
       
   805     
       
   806     TUint uid;
       
   807     err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
       
   808 
       
   809     if (err != KErrNone)
       
   810         {
       
   811         ConfigError(KOomErrBadOrMissingUidInAppPluginConfig);    
       
   812         return;
       
   813         }
       
   814     else
       
   815         iParentUid = uid;
       
   816     
       
   817     COomRunPluginConfig* pluginConfig = COomRunPluginConfig::NewL(uid, EOomAppPlugin);
       
   818     CleanupStack::PushL(pluginConfig);
       
   819 
       
   820     if (err == KErrNone)
       
   821        {
       
   822        // Check that we have a priority for the added system plugin action
       
   823        // Specifying a priority is mandatory
       
   824         TUint priority;
       
   825         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
       
   826         if (err == KErrNone)
       
   827             {
       
   828             pluginConfig->SetDefaultPriority(priority);
       
   829             }
       
   830         else
       
   831             {
       
   832             ConfigError(KOomErrBadOrMissingPriorityInAppPluginConfig);    
       
   833             }
       
   834        }
       
   835 
       
   836     if (err == KErrNone)
       
   837        {
       
   838        // Check that we have a priority for the added system plugin action
       
   839        // Specifying a priority is mandatory
       
   840         TUint targetAppId;
       
   841         err = GetValueFromHexAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppId);
       
   842         if (err == KErrNone)
       
   843             {
       
   844             pluginConfig->SetTargetApp(targetAppId);
       
   845             iParentTargetApp = targetAppId;
       
   846             }
       
   847         else
       
   848             {
       
   849             ConfigError(KOomErrBadOrMissingTargetAppIdInAppPluginConfig);    
       
   850             }
       
   851        }
       
   852     
       
   853     if (err == KErrNone)
       
   854        {
       
   855        TInt wait;
       
   856         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeWait, wait);
       
   857         if (err == KErrNone)
       
   858             {
       
   859             pluginConfig->SetWaitAfterPlugin(wait);
       
   860             }
       
   861         else if (err == KErrNotFound)
       
   862             {
       
   863             // If this attribute isn't present then just don't set it, and clear the error
       
   864             err = KErrNone;
       
   865             }
       
   866         else
       
   867             ConfigError(KOomErrBadPluginWaitTime);
       
   868        }    
       
   869     
       
   870     if (err == KErrNone)
       
   871         {
       
   872         // Get the config for the sync mode for this plugin (if one is specified) and set it
       
   873         SetPluginSyncMode(aAttributes, *pluginConfig);
       
   874         
       
   875         TBool targetAppNotRunning;
       
   876         err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeCallIfTargetAppNotRunning, targetAppNotRunning);
       
   877         if (err == KErrNone)
       
   878             {
       
   879             pluginConfig->SetCallIfTargetAppNotRunning(targetAppNotRunning);
       
   880             }
       
   881         else if (err == KErrNotFound)
       
   882             {
       
   883             // If this attribute isn't present then just don't set it, and clear the error
       
   884             err = KErrNone;
       
   885             }
       
   886         else
       
   887             {
       
   888             ConfigError(KOomErrBadCallIfTargetAppNotRunning);
       
   889             }
       
   890         }
       
   891 
       
   892      iConfig.AddPluginConfigL(pluginConfig);
       
   893      
       
   894      CleanupStack::Pop(pluginConfig);
       
   895 
       
   896     }
       
   897 
       
   898 void COomConfigParser::SetPluginIdlePriorityL(const RAttributeArray& aAttributes)
       
   899     {
       
   900     TUint uid;
       
   901     TInt idleTime;
       
   902     TUint priority;
       
   903 
       
   904     TInt err = KErrNone;
       
   905     
       
   906     // Use the UID from the parent scope
       
   907     uid = iParentUid;
       
   908 
       
   909     err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdleTime, idleTime);
       
   910     
       
   911 #ifdef __WINS__
       
   912     // The tick is 5 times slower on the emulator than on the phone
       
   913     idleTime = idleTime / KEmulatorTickDivisor;
       
   914 #endif
       
   915     
       
   916     if (err != KErrNone)
       
   917         {
       
   918         ConfigError(KOomErrBadOrMissingIdleTimeInPluginIdleRule);
       
   919         }
       
   920     
       
   921     if (err == KErrNone)
       
   922         {
       
   923         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
       
   924         
       
   925         if (err != KErrNone)
       
   926             {
       
   927             ConfigError(KOomErrBadOrMissingPriorityInPluginIdleRule);
       
   928             }
       
   929         }
       
   930     
       
   931     if (err == KErrNone)
       
   932         {
       
   933         COomIdleTimeRule* idleRule = COomIdleTimeRule::NewL(idleTime, priority);
       
   934         CleanupStack::PushL(idleRule);
       
   935         iConfig.AddPluginRuleL(uid, idleRule);
       
   936         CleanupStack::Pop(idleRule);
       
   937         }
       
   938     }
       
   939 
       
   940 void COomConfigParser::SetPluginForegroundAppPriorityL(const RAttributeArray& aAttributes)
       
   941     {
       
   942     TUint uid;
       
   943     TUint targetAppId;
       
   944     TUint priority;
       
   945 
       
   946     TInt err = KErrNone;
       
   947     
       
   948     // Use the UID from the parent scope
       
   949     uid = iParentUid;
       
   950 
       
   951         // Check that we have a priority for the added system plugin action
       
   952         // Specifying a priority is mandatory
       
   953         
       
   954     TPtrC8 targetAppString;
       
   955     err = GetValueFromAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppString);
       
   956     if ((err == KErrNone)
       
   957             && (targetAppString == KOomConfigTargetAppValue)
       
   958             && (iState == EOomParsingStateAppPluginSettings))
       
   959         // If the target app is specified as "TARGET_APP" then we use the target app from the parent entry
       
   960         {
       
   961         targetAppId = iParentTargetApp;
       
   962         }
       
   963     else
       
   964         {
       
   965         err = GetValueFromHexAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppId);
       
   966         if (err != KErrNone)
       
   967             {
       
   968             ConfigError(KOomErrBadOrMissingTargetAppIdInForegroundAppRule);    
       
   969             }
       
   970         }
       
   971      
       
   972     if (err == KErrNone)
       
   973         {
       
   974         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
       
   975         
       
   976         if (err != KErrNone)
       
   977             {
       
   978             ConfigError(KOomErrBadOrMissingPriorityInForegroundAppRule);
       
   979             }
       
   980         }
       
   981     
       
   982     if (err == KErrNone)
       
   983         {
       
   984         COomForegroundRule* foregroundRule = new (ELeave) COomForegroundRule(targetAppId, priority);
       
   985         CleanupStack::PushL(foregroundRule);
       
   986         iConfig.AddPluginRuleL(uid, foregroundRule);
       
   987         CleanupStack::Pop(foregroundRule);
       
   988         }
       
   989     }
       
   990 
       
   991 // Finds an attribute of the given name and gets its value
       
   992 // A value is only valid as long as AAtrributes is valid (and unmodified)
       
   993 // Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise
       
   994 TInt COomConfigParser::GetValueFromAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TPtrC8& aValue)
       
   995     {
       
   996     TInt index = aAttributes.Count();
       
   997     TBool attributeFound = EFalse;
       
   998     while ((index--) && (!attributeFound))
       
   999         {
       
  1000         if (aAttributes[index].Attribute().LocalName().DesC() == aName)
       
  1001             {
       
  1002             attributeFound = ETrue;
       
  1003             aValue.Set(aAttributes[index].Value().DesC());
       
  1004             }
       
  1005         }
       
  1006     
       
  1007     TInt err = KErrNone;
       
  1008     
       
  1009     if (!attributeFound)
       
  1010         err = KErrNotFound;
       
  1011     
       
  1012     return err;
       
  1013     }
       
  1014 
       
  1015 // Finds an attribute of the given name and gets its value (coverting the string hex value to a UInt)
       
  1016 // Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise
       
  1017 // Returns KErrCorrupt if the string is not a valid hex number
       
  1018 TInt COomConfigParser::GetValueFromHexAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue)
       
  1019     {
       
  1020     TPtrC8 hexString;
       
  1021     TInt err = GetValueFromAttributeList(aAttributes, aName, hexString);
       
  1022 
       
  1023     if (hexString == KOomConfigDefaultAppUid)
       
  1024         {
       
  1025         // This is a special case
       
  1026         // When we hit this value in a hex field then we return the default app UID
       
  1027         aValue = KOomDefaultAppId;
       
  1028         }
       
  1029     else if (hexString == KOomConfigDefaultPluginUid)
       
  1030         {
       
  1031         // This is a special case
       
  1032         // When we hit this value in a hex field then we return the default app UID
       
  1033         aValue = KOomDefaultPluginId;
       
  1034         }
       
  1035     else if (hexString == KOomConfigBusyAppUid)
       
  1036         {
       
  1037         aValue = KOomBusyAppId;
       
  1038         }
       
  1039     else if (hexString == KOomConfigHighPriorityAppUid)
       
  1040         {
       
  1041         aValue = KOomHighPriorityAppId;
       
  1042         }
       
  1043     else if (err == KErrNone)
       
  1044         {
       
  1045         TLex8 hexLex(hexString);
       
  1046         err = hexLex.Val(aValue, EHex);
       
  1047         if (err != KErrNone)
       
  1048             err = KErrCorrupt;
       
  1049         }
       
  1050     
       
  1051     return err;
       
  1052     }
       
  1053 
       
  1054 // Finds an attribute of the given name and gets its value (coverting the string decimal value to a UInt)
       
  1055 // Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise
       
  1056 // Returns KErrCorrupt if the string is not a valid decimal number
       
  1057 TInt COomConfigParser::GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue)
       
  1058     {
       
  1059     TPtrC8 decimalString;
       
  1060     TInt err = GetValueFromAttributeList(aAttributes, aName, decimalString);
       
  1061 
       
  1062     if (err == KErrNone)
       
  1063         {
       
  1064         if (decimalString == KOomAttibuteNeverClose)
       
  1065             aValue = KOomPriorityInfinate;
       
  1066         else
       
  1067             {
       
  1068             TLex8 decimalLex(decimalString);
       
  1069             err = decimalLex.Val(aValue, EDecimal);
       
  1070             if (err != KErrNone)
       
  1071                 err = KErrCorrupt;
       
  1072             }
       
  1073         }
       
  1074     
       
  1075     return err;
       
  1076     }
       
  1077 
       
  1078 TInt COomConfigParser::GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TInt& aValue)
       
  1079     {
       
  1080     TUint uintValue;
       
  1081     TInt err = GetValueFromDecimalAttributeList(aAttributes, aName, uintValue);
       
  1082     aValue = uintValue;
       
  1083     return err;
       
  1084     }
       
  1085 
       
  1086 TInt COomConfigParser::GetValueFromBooleanAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TBool& aValue)
       
  1087     {
       
  1088     TPtrC8 ptrValue;
       
  1089     TInt err = GetValueFromAttributeList(aAttributes, aName, ptrValue);
       
  1090     if (err == KErrNone)
       
  1091         {
       
  1092         if (ptrValue == KOomAttributeTrue || ptrValue == KOomAttribute1)
       
  1093             {
       
  1094             aValue = ETrue;
       
  1095             }
       
  1096         else if (ptrValue == KOomAttributeFalse || ptrValue == KOomAttribute0)
       
  1097             {
       
  1098             aValue = EFalse;
       
  1099             }
       
  1100         else
       
  1101             {
       
  1102             err = KErrCorrupt;
       
  1103             }
       
  1104         }
       
  1105     return err;
       
  1106     }
       
  1107 
       
  1108 void COomConfigParser::SetPluginSyncMode(const RAttributeArray& aAttributes, COomRunPluginConfig& aRunPluginConfig)
       
  1109     {
       
  1110     TPtrC8 syncModeString;
       
  1111     TInt err = GetValueFromAttributeList(aAttributes, KOomAttibuteSyncMode, syncModeString);
       
  1112     
       
  1113     if (err == KErrNone)
       
  1114         // If there is no specified sync mode then leave it as the default
       
  1115         {
       
  1116         TOomSyncMode syncMode = EContinue;
       
  1117         
       
  1118         if (syncModeString == KOomConfigSyncModeContinue)
       
  1119             syncMode = EContinueIgnoreMaxBatchSize;
       
  1120         else if (syncModeString == KOomConfigSyncModeCheck)
       
  1121             syncMode = ECheckRam;
       
  1122         else if (syncModeString == KOomConfigSyncModeEstimate)
       
  1123             syncMode = EEstimate;
       
  1124         else
       
  1125             ConfigError(KOomErrInvalidSyncMode);
       
  1126         
       
  1127         if (err == KErrNone)
       
  1128             {
       
  1129             aRunPluginConfig.iSyncMode = syncMode;
       
  1130             }
       
  1131         }
       
  1132     }
       
  1133 
       
  1134 // Check that the current state is as expected
       
  1135 // If not then the specified config error is generated
       
  1136 void COomConfigParser::CheckState(TOomParsingState aExpectedState, TInt aError)
       
  1137     {
       
  1138     if (iState != aExpectedState)
       
  1139         ConfigError(aError);
       
  1140     }
       
  1141 
       
  1142 // Check that the current state is as expected
       
  1143 // If not then the specified config error is generated
       
  1144 // This version checks to ensure that the current state matches either of the passed in states
       
  1145 void COomConfigParser::CheckState(TOomParsingState aExpectedState1, TOomParsingState aExpectedState2, TInt aError)
       
  1146     {
       
  1147     if ((iState != aExpectedState1)
       
  1148             && (iState != aExpectedState2))
       
  1149         ConfigError(aError);
       
  1150     }
       
  1151 
       
  1152 void COomConfigParser::ChangeState(TOomParsingState aState)
       
  1153     {
       
  1154     iState = aState;
       
  1155     }