sysresmonitoring/oommonitor/src/oomconfigparser.cpp
branchRCL_3
changeset 82 4610cd70c542
parent 58 0818dd463d41
equal deleted inserted replaced
70:739cef680932 82:4610cd70c542
     1 /*
     1 /*
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    35 KOomErrAppSettingsMustComeAfterGlobalSettings,
    35 KOomErrAppSettingsMustComeAfterGlobalSettings,
    36 KOomErrCloseAppSettingsMustComeAfterAppSettings,
    36 KOomErrCloseAppSettingsMustComeAfterAppSettings,
    37 KOomErrAppIdleSettingsMustComeAfterAppCloseSettings,
    37 KOomErrAppIdleSettingsMustComeAfterAppCloseSettings,
    38 KOomErrLowRamErrorInGlobalSettings,
    38 KOomErrLowRamErrorInGlobalSettings,
    39 KOomErrGoodRamErrorInGlobalSettings,
    39 KOomErrGoodRamErrorInGlobalSettings,
    40 KOomErrSwapUsageMonitoredErrorInGlobalSettings,
       
    41 KOomErrLowSwapErrorInGlobalSettings,
       
    42 KOomErrGoodSwapErrorInGlobalSettings,
       
    43 KOomErrMaxCloseErrorInGlobalSettings,
    40 KOomErrMaxCloseErrorInGlobalSettings,
    44 KOomErrDefaultPriorityErrorInGlobalSettings,
    41 KOomErrDefaultPriorityErrorInGlobalSettings,
    45 KOomErrMissingUidFromAppCloseConfig,
    42 KOomErrMissingUidFromAppCloseConfig,
    46 KOomErrMissingPriorityFromAppCloseConfig,
    43 KOomErrMissingPriorityFromAppCloseConfig,
    47 KOomErrMissingSyncModeFromAppCloseConfig,
    44 KOomErrMissingSyncModeFromAppCloseConfig,
   119 _LIT8(KOomConfigForegroundAppPriority, "foreground_app_priority");
   116 _LIT8(KOomConfigForegroundAppPriority, "foreground_app_priority");
   120 
   117 
   121 // Global settings attribute names
   118 // Global settings attribute names
   122 _LIT8(KOomAttributeLowRamThreshold, "low_ram_threshold");
   119 _LIT8(KOomAttributeLowRamThreshold, "low_ram_threshold");
   123 _LIT8(KOomAttributeGoodRamThreshold, "good_ram_threshold");
   120 _LIT8(KOomAttributeGoodRamThreshold, "good_ram_threshold");
   124 _LIT8(KOomAttributeSwapUsageMonitored, "swap_usage_monitored");
       
   125 _LIT8(KOomAttributeLowSwapThreshold, "low_swap_threshold");
       
   126 _LIT8(KOomAttributeGoodSwapThreshold, "good_swap_threshold");
       
   127 _LIT8(KOomAttributeMaxAppCloseBatch, "max_app_close_batch");
   121 _LIT8(KOomAttributeMaxAppCloseBatch, "max_app_close_batch");
   128 _LIT8(KOomAttributeDefaultWaitAfterPlugin, "default_wait_after_plugin");
   122 _LIT8(KOomAttributeDefaultWaitAfterPlugin, "default_wait_after_plugin");
   129 _LIT8(KOomAttributeMaxAppExitTime , "max_app_exit_time");
   123 _LIT8(KOomAttributeMaxAppExitTime , "max_app_exit_time");
   130 
   124 
   131 // System plugins 
   125 // System plugins 
   387             ConfigError(KOomErrGoodRamErrorInGlobalSettings);
   381             ConfigError(KOomErrGoodRamErrorInGlobalSettings);
   388         }
   382         }
   389 
   383 
   390     if (err == KErrNone)
   384     if (err == KErrNone)
   391         {
   385         {
   392         TInt swapUsageMonitored;
       
   393         TInt err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeSwapUsageMonitored, swapUsageMonitored);
       
   394         
       
   395         if (err == KErrNone)
       
   396             iConfig.SetSwapUsageMonitored(swapUsageMonitored);
       
   397         else
       
   398             ConfigError(KOomErrSwapUsageMonitoredErrorInGlobalSettings);
       
   399         }
       
   400     
       
   401     if (err == KErrNone)
       
   402         {
       
   403         TInt defaultLowSwapThreshold;    
       
   404         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, defaultLowSwapThreshold);
       
   405 
       
   406         if (err == KErrNone)
       
   407             iConfig.SetDefaultLowSwapThreshold(defaultLowSwapThreshold * KBytesInMegabyte);
       
   408         else
       
   409             ConfigError(KOomErrLowSwapErrorInGlobalSettings);
       
   410         }
       
   411 
       
   412     if (err == KErrNone)
       
   413         {
       
   414         TInt defaultGoodSwapThreshold;    
       
   415         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, defaultGoodSwapThreshold);
       
   416 
       
   417         if (err == KErrNone)
       
   418             iConfig.SetDefaultGoodSwapThreshold(defaultGoodSwapThreshold * KBytesInMegabyte);
       
   419         else
       
   420             ConfigError(KOomErrGoodSwapErrorInGlobalSettings);
       
   421         }
       
   422     
       
   423     if (err == KErrNone)
       
   424         {
       
   425         TInt defaultMaxCloseAppBatch;    
   386         TInt defaultMaxCloseAppBatch;    
   426         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppCloseBatch, defaultMaxCloseAppBatch);
   387         TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppCloseBatch, defaultMaxCloseAppBatch);
   427 
   388 
   428         if (err == KErrNone)
   389         if (err == KErrNone)
   429             iConfig.SetMaxCloseAppBatch(defaultMaxCloseAppBatch);
   390             iConfig.SetMaxCloseAppBatch(defaultMaxCloseAppBatch);
   516         
   477         
   517         if (err != KErrNone)
   478         if (err != KErrNone)
   518             ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
   479             ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
   519         }
   480         }
   520     
   481     
   521     // Set the app specific swap thresholds (if they exist)
       
   522     // Get the app specific low swap threshold
       
   523     if (err == KErrNone)
       
   524         {
       
   525         TUint lowThreshold;
       
   526         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, lowThreshold);
       
   527         if (err == KErrNone)
       
   528             {
       
   529             appConfig->iLowSwapThreshold = lowThreshold * KBytesInMegabyte;
       
   530             }
       
   531         else if (err == KErrNotFound)
       
   532             err = KErrNone;
       
   533             
       
   534         if (err != KErrNone)
       
   535             ConfigError(KOomErrBadLowThresholdValueForAppConfig);
       
   536         }
       
   537 
       
   538     // Get the app specific good swapthreshold
       
   539     if (err == KErrNone)
       
   540         {
       
   541         TUint goodThreshold;
       
   542         err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, goodThreshold);
       
   543         if (err == KErrNone)
       
   544             {
       
   545             appConfig->iGoodSwapThreshold = goodThreshold * KBytesInMegabyte;
       
   546             }
       
   547         else if (err == KErrNotFound)
       
   548             err = KErrNone;
       
   549             
       
   550         if (err != KErrNone)
       
   551             ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
       
   552         }  
       
   553         
       
   554     // Add the applciation config to the main config
   482     // Add the applciation config to the main config
   555     if ((err == KErrNone) && (appConfig))
   483     if ((err == KErrNone) && (appConfig))
   556         {
   484         {
   557         iConfig.AddApplicationConfigL(appConfig);
   485         iConfig.AddApplicationConfigL(appConfig);
   558         }
   486         }