accesspointcontrol/apcontrollistplugin/inc/apcontrollistapiwrapper.h
branchRCL_3
changeset 58 83ca720e2b9a
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 * 		 Wrapper class for asyncron calls in RMyPhone and RMyCustomAPI.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef APCONTROLLISTAPIWRAPPER_H
       
    20 #define APCONTROLLISTAPIWRAPPER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <rmmcustomapi.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CAPControlListPlugin;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 /**
       
    31 *  Wrapper class for asyncron calls in RMyPhone and RMyCustomAPI.
       
    32 */
       
    33 class CAPControlListAPIWrapper : public CActive
       
    34 	{
       
    35 	private: 
       
    36 		// Enum for the states checked in RunL()
       
    37 		enum TRequestType { EGetACLStatus, EAddAPN, EAddAPNSecurity, 
       
    38 		                    ERemoveAPN, ERemoveAPNSecurity, EActivateACL, 
       
    39 							EActivateACLSecurity, EDeactivateACL, 
       
    40 							EDeactivateACLSecurity, EReadData, 
       
    41 							EEnumerateAPN, ENoRequest};
       
    42 
       
    43     public:  
       
    44     	// Constructor and destructor
       
    45     	    			
       
    46         /**
       
    47         * Constructor.
       
    48         * @param aPlugin reference to the view
       
    49         * @param aPriority priority for CActive
       
    50         */
       
    51 		CAPControlListAPIWrapper(CAPControlListPlugin& aPlugin,
       
    52 									TInt aPriority = EPriorityStandard );
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56 		~CAPControlListAPIWrapper();
       
    57 		
       
    58         // New functions     
       
    59           
       
    60         /**
       
    61         * Initialises iPhone and iCustomAPI members. 
       
    62         * Uses User::WaitForRequest
       
    63         * because we need to know the ACL status before Visible() is called.
       
    64         */
       
    65 		void ConstructL();
       
    66 		
       
    67 		// Primary functions for the API calls
       
    68 		// These are the functions for which security check is necessary.
       
    69 		// If the security was already checked they call the correspondig
       
    70 		// secondary function. If the security wasn't already checked they
       
    71 		// call the asyncron security check and let RunL call the correspondig
       
    72 		// secondary function when the security check is finished.
       
    73         /**
       
    74         * Add APN to the ACL list
       
    75         */
       
    76 		void AddAPNL();		
       
    77         /**
       
    78         * Remove APN from the ACL list which is currently selected in the
       
    79         * listbox.
       
    80         */
       
    81 		void RemoveAPN();		
       
    82         /**
       
    83         * Activates the ACL list
       
    84         */
       
    85 		void ActivateACL();
       
    86         /**
       
    87         * Deactivates the ACL list
       
    88         */
       
    89 		void DeActivateACL();
       
    90 				
       
    91         /**
       
    92         * Gets the ACL status then reads the ACL list.
       
    93         * If this call is succesfull then RunL calls EnumerateAPN 
       
    94         * then it calls DoReadData
       
    95         */
       
    96 		void ReadData();
       
    97 		
       
    98         /**
       
    99         * Method for checking if plugin should be visible and used in 
       
   100         * the Connection settings.
       
   101         * @return ETrue if plugin should be visible.
       
   102         * @return EFalse if plugin should not be visible.
       
   103         */
       
   104 		TBool Visible() const;
       
   105 		
       
   106         /**
       
   107         * Method for checking if the ACL list is enabled or not. 
       
   108         * @return ETrue if the ACL list is enabled.
       
   109         * @return EFalse if the ACL list is not enabled.
       
   110         */
       
   111 		TBool Enabled() const;
       
   112 		
       
   113         /**
       
   114       	* Calls RMyPhone::NotifyIccAccessCapsChange
       
   115         * Used by CAPControlListCapsChange class. This function is nescessary
       
   116         * since iPhone is a private member.
       
   117         */
       
   118 		void NotifyIccAccessCapsChange(TRequestStatus& aReqStatus, 
       
   119 														TUint32& aCaps);				
       
   120         /**
       
   121       	* Calls RTelSubSessionBase::CancelAsyncRequest
       
   122         * Used by CAPControlListCapsChange class. This function is nescessary
       
   123         * since iPhone is a private member.
       
   124         */
       
   125         void CancelNotify(); 
       
   126 				
       
   127         // Functions from CActive
       
   128         /**
       
   129         * Closes API in case of Cancel() 
       
   130         */
       
   131 		void DoCancel();		
       
   132         /**
       
   133         * Handles asynchronous function completion 
       
   134         */
       
   135 		void RunL(); 
       
   136 		/** 
       
   137 		* Shows SIM card error note in error cases
       
   138 		*/
       
   139 		void ShowSimCardErrorNoteL();
       
   140 		
       
   141 	private:
       
   142         // New functions
       
   143         
       
   144         /**
       
   145 		* Called from one of the primary functions for the API calls
       
   146         * Calls RMmCustomAPI::CheckSecurityCode asyncron call. This functon is
       
   147         * called only once.
       
   148         * @param aRequest We need this to set the state so we'll know in RunL
       
   149         * which primary function called it.
       
   150         */
       
   151 		void SecurityCheck( TRequestType aRequest ); 
       
   152 		
       
   153 		// Secondary functions for the API calls		
       
   154         /**
       
   155         * Secondary function for AddAPNL().Makes the asyncron call to 
       
   156         * add an APN to the ACL list.
       
   157         * If the security was already checked it is called from AddAPNL.
       
   158         * If the security was not checked it is called from the RunL()
       
   159         * when RunL() is called for RMmCustomAPI::CheckSecurityCode()
       
   160         */
       
   161 		void DoAddAPNL();		
       
   162         /**
       
   163         * Secondary function for RemoveAPN().Makes the asyncron call to 
       
   164         * remove an APN from the ACL list.
       
   165         * If the security was already checked it is called from AddAPNL.
       
   166         * If the security was not checked it is called from the RunL()
       
   167         * when RunL() is called for RMmCustomAPI::CheckSecurityCode()
       
   168         */
       
   169 		void DoRemoveAPN();
       
   170         /**
       
   171         * Secondary function for ActivateACL() and DeActivateACL().Makes the 
       
   172         * asyncron call to SetACLStatus either EAclStatusEnabled or
       
   173         * EAclStatusDisabled.
       
   174         * If the security was already checked it is called from ActivateACL()
       
   175         * or DeActivateACL().
       
   176         * If the security was not checked it is called from the RunL()
       
   177         * when RunL() is called for RMmCustomAPI::CheckSecurityCode()
       
   178         * @param aAclStatus the status we want to set.
       
   179         */
       
   180 		void SetACLStatus( const RMobilePhone::TAPNControlListServiceStatus 
       
   181 		                                        aAPNControlListServiceStatus );
       
   182 		
       
   183         /**
       
   184         * Reads the ACL list. 
       
   185         * Gets the number of items with an asyncron call. The actual reading
       
   186         * of the APNs happens in DoReadData()
       
   187         */
       
   188 		void EnumerateAPN();
       
   189 		
       
   190         /**
       
   191         * Reads an APN entry from the ACL list and puts it in the listbox. 
       
   192         * Called from RunL() when RunL() after ReadData() was called. It is
       
   193         * called iSize times. 
       
   194         */
       
   195 		void DoReadData();
       
   196 
       
   197         /**
       
   198         * Case EReadData in RunL 
       
   199         * Code removed from RunL to make it's size smaller
       
   200         */
       
   201 		void FinishReadDataL();
       
   202 		
       
   203 	    /**
       
   204 	     * From CActive, handles leaves from RunL.
       
   205 	     * @param aLeaveCode The leave code.
       
   206 	     */
       
   207 	    TInt RunError( TInt aLeaveCode );
       
   208 		
       
   209 	private: // Data
       
   210 		
       
   211         //@var reference to the view
       
   212 		CAPControlListPlugin&			iPlugin;
       
   213 	
       
   214 		// API objects
       
   215         //@var RTelServer object for the ACL API
       
   216 		RTelServer 						iServer;	
       
   217         //@var RMobilePhone object for the ACL API
       
   218 		RMobilePhone 					iPhone;
       
   219         //@var RMmCustomAPI object for the ACL API
       
   220 		RMmCustomAPI 					iCustomAPI;
       
   221 
       
   222         //@var state to store which is the current request
       
   223 		TRequestType iRequest;
       
   224 		
       
   225         //@var  ACL status
       
   226 		RMobilePhone::TAPNControlListServiceStatus		iAclStatus;   
       
   227 		
       
   228         //@var phone is online
       
   229 		TBool 							iConnAllowed;
       
   230 		
       
   231         //@var security checked
       
   232 		TBool 							iSecurityChecked;
       
   233 		
       
   234         //@var AP Name from the user input ( AddAPN2L() )
       
   235 		HBufC* 							iAPN;
       
   236 
       
   237 		//members for reading data ( ReadData() ReadData2() )
       
   238         //@var AP Name in the form expected by the API
       
   239 		RMobilePhone::TAPNEntryV3 		iApn;
       
   240         //@var iApn packaged
       
   241 		RMobilePhone::TAPNEntryV3Pckg 	iApnPKG;
       
   242         //@var size of the ACL list
       
   243 		TUint32 						iSize;
       
   244         //@var index of item currently read from the ACL list 
       
   245 		TUint32 						iIndex;
       
   246 		
       
   247 		TBool                           iSimCardError;
       
   248 	} ;
       
   249 
       
   250 #endif
       
   251 
       
   252 // End of file