securitydialogs/SecUi/Src/SecUiAutoLockSettingPage.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #include <AknQueryDialog.h>
    22 #include <AknQueryDialog.h>
    23 #include "SecUiAutoLockSettingPage.h"
    23 #include "SecUiAutoLockSettingPage.h"
    24 #include "secui.hrh"
    24 #include "secui.hrh"
    25 #include <featmgr.h>
    25 #include <featmgr.h>
    26 
    26 /**
    27 
    27 *CAutolockQuery used in autolock period query
       
    28 */
       
    29 class CAutolockQuery
       
    30 	: public CAknNumberQueryDialog
       
    31 	{
       
    32 	public: // Constructors and destructors
       
    33 		/**
       
    34 		* C++ constructor.
       
    35 		*/
       
    36 		CAutolockQuery(TInt& aNumber,const TTone aTone = ENoTone);
       
    37 	protected: // From base classes
       
    38 		/**
       
    39 		* From CCAknNumberQueryDialog 
       
    40 		*/
       
    41 		void PreLayoutDynInitL();
       
    42 	};
    28 //
    43 //
    29 // ----------------------------------------------------------
    44 // ----------------------------------------------------------
    30 // CAutoLockSettingPage::CAutoLockSettingPage()
    45 // CAutoLockSettingPage::CAutoLockSettingPage()
    31 // C++ default constructor
    46 // C++ default constructor
    32 // ----------------------------------------------------------
    47 // ----------------------------------------------------------
    33 // 
    48 // 
    34 CAutoLockSettingPage::CAutoLockSettingPage(TInt aResourceId, TInt& aCurrentSelectionItem, CDesCArrayFlat* aItemArray, TInt& aAutoLockValue) : 
    49 CAutoLockSettingPage::CAutoLockSettingPage(TInt aResourceId, TInt& aCurrentSelectionItem, CDesCArrayFlat* aItemArray, TInt& aAutoLockValue) : 
    35 					CBase(),iAutoLockValue(aAutoLockValue)
    50 					CAknRadioButtonSettingPage(aResourceId, aCurrentSelectionItem, aItemArray),iAutoLockValue(aAutoLockValue)
    36 
    51 
    37 	{
    52 	{
       
    53         iOriginalIndex = aCurrentSelectionItem;
    38 	}
    54 	}
    39 
    55 
    40 //
    56 //
    41 // ----------------------------------------------------------
    57 // ----------------------------------------------------------
    42 // CAutoLockSettingPage::ConstructL()
    58 // CAutoLockSettingPage::ConstructL()
    43 // Symbian OS default constructor
    59 // Symbian OS default constructor
    44 // ----------------------------------------------------------
    60 // ----------------------------------------------------------
    45 // 
    61 // 
    46 void CAutoLockSettingPage::ConstructL()
    62 void CAutoLockSettingPage::ConstructL()
    47 	{
    63 	{
       
    64 	CAknRadioButtonSettingPage::ConstructL();
       
    65 	const TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
       
    66 	FeatureManager::InitializeLibL();
    48 	}
    67 	}
    49 
    68 
    50 //
    69 //
    51 // ----------------------------------------------------------
    70 // ----------------------------------------------------------
    52 // CAutoLockSettingPage::CAutoLockSettingPage()
    71 // CAutoLockSettingPage::CAutoLockSettingPage()
    53 // Destructor
    72 // Destructor
    54 // ----------------------------------------------------------
    73 // ----------------------------------------------------------
    55 // 
    74 // 
    56 CAutoLockSettingPage::~CAutoLockSettingPage()
    75 CAutoLockSettingPage::~CAutoLockSettingPage()
    57 	{
    76 	{
       
    77 	FeatureManager::UnInitializeLib();
    58 	}
    78 	}
    59 
    79 
    60 //
    80 //
    61 // ----------------------------------------------------------
    81 // ----------------------------------------------------------
    62 // CAutoLockSettingPage::ProcessCommandL()
    82 // CAutoLockSettingPage::ProcessCommandL()
    63 // 
    83 // 
    64 // ----------------------------------------------------------
    84 // ----------------------------------------------------------
    65 // 
    85 // 
    66 void CAutoLockSettingPage::ProcessCommandL(TInt aCommandId)
    86 void CAutoLockSettingPage::ProcessCommandL(TInt aCommandId)
    67 	{
    87 	{
    68 	
    88 	TInt cur = ListBoxControl()->CurrentItemIndex();
       
    89 	// Respond to softkey events
       
    90 
       
    91 	switch (aCommandId)
       
    92 		{
       
    93 		case EAknSoftkeySelect:
       
    94 		case EAknSoftkeyOk:
       
    95 			// autolock off
       
    96 			if (cur == 0)
       
    97 				{
       
    98 				iAutoLockValue = 0;
       
    99 				if(iOriginalIndex == 0)
       
   100 				    { //User re-selected "Autolock off"; no use in changing lock setting
       
   101 				        AttemptExitL(EFalse);
       
   102 				    }
       
   103 				else
       
   104 				    {
       
   105 				        AttemptExitL(ETrue);
       
   106 				    }
       
   107 				
       
   108 				}
       
   109 			// user defined
       
   110 			if (cur == 1)
       
   111 				{
       
   112 				CAutolockQuery* dlg = new (ELeave) CAutolockQuery(iAutoLockValue);
       
   113 				dlg->PrepareLC(R_AUTOLOCK_TIME_QUERY);
       
   114 				if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
   115 				{
       
   116 				//set min and max values from SCP server to the dialog.
       
   117 				TInt minimum = 0;
       
   118 				if(iMaximum <= 0) //maximum value has not been defined; default value used instead.
       
   119 				    iMaximum = 1440;
       
   120 				dlg->SetMinimumAndMaximum(minimum, iMaximum);
       
   121 			}
       
   122 				if(dlg->RunLD())
       
   123 					{
       
   124 					AttemptExitL(ETrue);
       
   125 					}
       
   126 				else
       
   127 					AttemptExitL(EFalse);
       
   128 				}
       
   129 			break;
       
   130 
       
   131 		default:
       
   132 			CAknSettingPage::ProcessCommandL(aCommandId);
       
   133 			break;
       
   134 		}
       
   135 
    69 	}
   136 	}
    70 //
   137 //
    71 // ----------------------------------------------------------
   138 // ----------------------------------------------------------
    72 // CAutoLockSettingPage::SetPeriodMaximumValue()
   139 // CAutoLockSettingPage::SetPeriodMaximumValue()
    73 // 
   140 // 
    74 // ----------------------------------------------------------
   141 // ----------------------------------------------------------
    75 // 
   142 // 
    76 void CAutoLockSettingPage::SetPeriodMaximumValue(TInt aMaximumValue)
   143 void CAutoLockSettingPage::SetPeriodMaximumValue(TInt aMaximumValue)
    77 	{
   144 	{
       
   145 	if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
   146 	{
       
   147 		iMaximum = aMaximumValue;
       
   148 }
    78 	}
   149 	}
    79 	
   150 	
    80 //---------------------------------------------------------------------------------------
   151 //---------------------------------------------------------------------------------------
    81 // CAutoLockSettingPage::HandlePointerEventL()
   152 // CAutoLockSettingPage::HandlePointerEventL()
    82 // Passes pointer events to CAknRadioButtonSettingPage
   153 // Passes pointer events to CAknRadioButtonSettingPage
    84 //---------------------------------------------------------------------------------------
   155 //---------------------------------------------------------------------------------------
    85 //
   156 //
    86 
   157 
    87 void CAutoLockSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   158 void CAutoLockSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    88     {
   159     {
    89     }
   160     if ( AknLayoutUtils::PenEnabled() )
       
   161         {
       
   162         	TInt cur = ListBoxControl()->CurrentItemIndex();
       
   163          	CAknRadioButtonSettingPage::HandlePointerEventL(aPointerEvent);
       
   164          	//only take into account the "Up" event. Otherwise we'll end up having 2 dialogs.
       
   165          	if(aPointerEvent.iType == TPointerEvent::EButton1Up)
       
   166          	{
       
   167 
       
   168          	    //only react to the event if the pen is actually inside the dialog.
       
   169          	    if(ListBoxControl()->Rect().Contains(aPointerEvent.iPosition))
       
   170          	        {
       
   171          	            // autolock off
       
   172         				if (cur == 0)
       
   173         					{
       
   174         					    iAutoLockValue = 0;
       
   175         						if(iOriginalIndex == 0)
       
   176                 				    { //User re-selected "Autolock off"; no use in changing lock setting
       
   177                 				        AttemptExitL(EFalse);
       
   178                 				    }
       
   179                 				else
       
   180                 				    {
       
   181                 				        AttemptExitL(ETrue);
       
   182                 				    }
       
   183         					}
       
   184         				// user defined
       
   185         				if (cur == 1)
       
   186         					{
       
   187         					CAutolockQuery* dlg = new (ELeave) CAutolockQuery(iAutoLockValue);
       
   188 						dlg->PrepareLC(R_AUTOLOCK_TIME_QUERY);
       
   189 					if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
   190 					{
       
   191         					//set min and max values from SCP server to the dialog.
       
   192         					TInt minimum = 0;			
       
   193 				          if(iMaximum <= 0) //maximum value has not been defined; default value used instead.
       
   194 				            iMaximum = 1440;        						
       
   195         					dlg->SetMinimumAndMaximum(minimum, iMaximum);
       
   196 				}
       
   197         					if(dlg->RunLD())
       
   198         						{
       
   199         						AttemptExitL(ETrue);
       
   200         						}
       
   201         					else
       
   202         						AttemptExitL(EFalse);
       
   203          	        }
       
   204          		
       
   205 				}
       
   206 		    }
       
   207          	}
       
   208         }
       
   209 //
       
   210 // ---------------------------------------------------------
       
   211 // CAutolockQuery::CAutolockQuery()
       
   212 // 
       
   213 // ---------------------------------------------------------
       
   214 //
       
   215 CAutolockQuery::CAutolockQuery(TInt& aNumber,const TTone aTone)
       
   216 	: CAknNumberQueryDialog( aNumber, aTone)
       
   217 	{
       
   218 	}
       
   219 	
       
   220 //
       
   221 // ---------------------------------------------------------
       
   222 // CAutolockQuery::PreLayoutDynInitL()
       
   223 // 
       
   224 // ---------------------------------------------------------
       
   225 //
       
   226 void CAutolockQuery::PreLayoutDynInitL()
       
   227 	{
       
   228 	CAknNumberQueryDialog::PreLayoutDynInitL();
       
   229 	if (iNumber == 0)
       
   230 		{
       
   231 		MakeLeftSoftkeyVisible(EFalse);
       
   232 		}
       
   233 	}
       
   234     
    90 // End of file
   235 // End of file
    91 
   236