dbgsrv/coredumpserver/ui/coredumpui/src/coredumpscmdialog.cpp
changeset 0 c6b0df440bee
equal deleted inserted replaced
-1:000000000000 0:c6b0df440bee
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implementation of CConfigureSCMDialog class 
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology 
       
    22  @released
       
    23  @see CCoreDumpFormatter
       
    24 */
       
    25 
       
    26 #include "coredumpui.h"
       
    27 #include "coredumpscmdialog.h"
       
    28 
       
    29 
       
    30 CConfigureSCMDialog::CConfigureSCMDialog(RCoreDumpSession &aCoreDumpSession)
       
    31     : CCoreDumpDialogBase(aCoreDumpSession)
       
    32     {
       
    33     }
       
    34 
       
    35 CConfigureSCMDialog::~CConfigureSCMDialog()
       
    36 	{
       
    37 	iConfs.ResetAndDestroy();
       
    38 	}
       
    39 
       
    40 void CConfigureSCMDialog::PreLayoutDynInitL()
       
    41 	{
       
    42 	UpdateDialogDataL();
       
    43 	}
       
    44 
       
    45 void CConfigureSCMDialog::PostLayoutDynInitL()
       
    46 	{
       
    47 	}
       
    48 
       
    49 void CConfigureSCMDialog::UpdateDialogDataL()
       
    50 	{
       
    51 	// We are loading up edwins as defined in rss file here
       
    52 	// A better approach may be to create the items dynamically if time allows
       
    53 	// example code for this at http://wiki.forum.nokia.com/index.php/Create_Modal_dialog_and_add_controls_dynamically
       
    54 	
       
    55 	//update dialog
       
    56 	RPointerArray<CEikEdwin> edwins;
       
    57 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin0)));
       
    58 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin1)));
       
    59 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin2)));
       
    60 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin3)));
       
    61 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin4)));
       
    62 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin5)));
       
    63 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin6)));
       
    64 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin7)));
       
    65 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin8)));
       
    66 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin9)));
       
    67 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin10)));
       
    68 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin11)));
       
    69 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin12)));
       
    70 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin13)));
       
    71 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin14)));
       
    72 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin15)));
       
    73 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin16)));
       
    74 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin17)));
       
    75 	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin18)));
       
    76 	
       
    77 	for (TInt i = 0; i < edwins.Count(); i++)
       
    78 		{
       
    79 		edwins[i]->SetDimmed(ETrue);
       
    80 		edwins[i]->SetReadOnly(ETrue);
       
    81 		}
       
    82 
       
    83 	RPointerArray<CEikLabel> labels;
       
    84 	labels.Append(static_cast<CEikLabel*>(Control(ELabel0)));  	// 0
       
    85 	labels.Append(static_cast<CEikLabel*>(Control(ELabel1)));  	
       
    86 	labels.Append(static_cast<CEikLabel*>(Control(ELabel2)));	
       
    87 	labels.Append(static_cast<CEikLabel*>(Control(ELabel3)));	
       
    88 	labels.Append(static_cast<CEikLabel*>(Control(ELabel4)));	
       
    89 	labels.Append(static_cast<CEikLabel*>(Control(ELabel5)));	
       
    90 	labels.Append(static_cast<CEikLabel*>(Control(ELabel6)));	
       
    91 	labels.Append(static_cast<CEikLabel*>(Control(ELabel7)));	
       
    92 	labels.Append(static_cast<CEikLabel*>(Control(ELabel8)));	
       
    93 	labels.Append(static_cast<CEikLabel*>(Control(ELabel9)));	
       
    94 	labels.Append(static_cast<CEikLabel*>(Control(ELabel10)));	
       
    95 	labels.Append(static_cast<CEikLabel*>(Control(ELabel11)));	
       
    96 	labels.Append(static_cast<CEikLabel*>(Control(ELabel12)));	
       
    97 	labels.Append(static_cast<CEikLabel*>(Control(ELabel13)));	
       
    98 	labels.Append(static_cast<CEikLabel*>(Control(ELabel14)));	
       
    99 	labels.Append(static_cast<CEikLabel*>(Control(ELabel15)));	
       
   100 	labels.Append(static_cast<CEikLabel*>(Control(ELabel16)));	
       
   101 	labels.Append(static_cast<CEikLabel*>(Control(ELabel17)));	
       
   102 	labels.Append(static_cast<CEikLabel*>(Control(ELabel18)));	
       
   103 
       
   104 	// Read config parameters from CDS
       
   105 	TInt noConfigParams = 0;
       
   106 	iConfs.ResetAndDestroy();
       
   107 	
       
   108     TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
       
   109     if(err != KErrNone)
       
   110         {
       
   111 		TBuf<23> error;
       
   112 		error.Format(_L("Error: %d"), err);
       
   113 		CEikonEnv::InfoWinL(_L("Could not get number of config params!"), error);
       
   114         User::Leave(err);
       
   115         }
       
   116 	TInt control = 0;
       
   117 
       
   118 	for (TInt i = 0; i < noConfigParams; i++)
       
   119 		{
       
   120 		COptionConfig* conf;
       
   121 		conf = iCoreDumpSession.GetConfigParameterL(i);
       
   122 		if (conf->Source()== COptionConfig::ESCMConfig && control < edwins.Count())
       
   123 			{
       
   124 			iConfs.Append(conf);
       
   125 			
       
   126 			TBuf<255> buf = conf->Prompt();
       
   127 			switch (conf->Type())
       
   128 				{
       
   129 				// SCM configuration options are all TInt (TInt priority)
       
   130 				case COptionConfig::ETInt:
       
   131 					{
       
   132 					buf.Append(_L("\n(priority (0-255) "));
       
   133 					TBuf<100> value;
       
   134 					value.Format(_L("%d"), iConfs[control]->Value());
       
   135 					edwins[control]->SetTextL(&value);
       
   136 					// save the edwin in the tag field of option config 
       
   137 					// this will make unloading the data easier
       
   138 					conf->SetTag(edwins[control]);
       
   139 					}
       
   140 					break;
       
   141 				default:
       
   142 					break;
       
   143 				}
       
   144 			labels[control]->SetTextL(buf);
       
   145 			edwins[control]->SetDimmed(EFalse);
       
   146 			edwins[control++]->SetReadOnly(EFalse);
       
   147 			}
       
   148         else
       
   149             {
       
   150             delete conf;
       
   151             }
       
   152 		}
       
   153 	edwins.Close();
       
   154 	labels.Close();
       
   155 	}
       
   156 
       
   157 
       
   158 TBool CConfigureSCMDialog::OkToExitL(TInt aButtonId)
       
   159 	{
       
   160 	
       
   161 	TBool ret = ETrue;
       
   162 	TInt err = KErrNone;
       
   163 	
       
   164 	
       
   165 	// for the scm dialog - each edwin contains an integer value priority 
       
   166 	for (TInt i = 0; i <iConfs.Count(); i++)
       
   167 		{
       
   168 		COptionConfig* conf = iConfs[i];
       
   169 		if(!conf)
       
   170 			{
       
   171 			continue;
       
   172 			}
       
   173 
       
   174 
       
   175 		// retrieve the edwin pointer (saved in iTag member)
       
   176 		CEikEdwin* edwin = (CEikEdwin*) conf->Tag();
       
   177 		if(edwin)
       
   178 			{
       
   179 			HBufC* hBuf = edwin->GetTextInHBufL();
       
   180 			CleanupStack::PushL(hBuf);
       
   181 			//hBuf->Des()
       
   182 			TLex lex(*hBuf);
       
   183 			TInt32 priority;
       
   184 			err = lex.Val(priority);
       
   185 			
       
   186 			if(err != KErrNone)
       
   187 				{
       
   188 				LOG_MSG("  error from lex.Val(conf) -> CConfigureSCMDialog::CEikonEnv::Static()->InfoMsg;" );
       
   189 				CEikonEnv::Static()->InfoMsg(_L("Value must be an integer"));
       
   190 				}			
       
   191 			else if(priority != conf->Value())
       
   192 				{
       
   193 				iConfs[i]->Value(priority);
       
   194 
       
   195 				LOG_MSG4("CConfigureSCMDialog::OkToExitL modifying item uid=%d instance=%d value=%d",
       
   196 						conf->Uid(), conf->Instance(), conf->Value());
       
   197 
       
   198 				
       
   199 				
       
   200 				TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
       
   201 				if( err != KErrNone)
       
   202 					{
       
   203 					CEikonEnv::Static()->InfoMsg(_L("Error changing config param "));
       
   204 					}
       
   205 				
       
   206 				}
       
   207 
       
   208 			CleanupStack::PopAndDestroy(hBuf);
       
   209 			}
       
   210 
       
   211 		}
       
   212 	
       
   213 	return ret;
       
   214 	}