cmmanager/cmmgr/Plugins/cmpluginvpn/inc/cmpluginvpn.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:  VPN plugin IF implementation class.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef VPN_PLUGIN_INCLUDED
       
    19 #define VPN_PLUGIN_INCLUDED
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <StringLoader.h>
       
    23 #include <in_sock.h>
       
    24 
       
    25 #include <cmpluginbaseeng.h>
       
    26 
       
    27 #include <cmpluginvpndef.h>
       
    28 
       
    29 using namespace CommsDat;
       
    30 
       
    31 class CCDVirtualIAPNextLayerRecord;
       
    32 
       
    33 /**
       
    34  *  VPN Plugin IF implementation class
       
    35  *  @since S60 3.2
       
    36  */
       
    37 NONSHARABLE_CLASS(CCmPluginVpn) : public CCmPluginBaseEng
       
    38     {
       
    39 
       
    40     public:     // Constructors and destructor
       
    41 
       
    42         /**
       
    43         * Two phased constructor. Leaves on failure.
       
    44         * @return The created object.
       
    45         */      
       
    46         static CCmPluginVpn* NewL( TCmPluginInitParam* aInitParam );
       
    47 
       
    48         /**
       
    49         * Destructor.
       
    50         */      
       
    51         virtual ~CCmPluginVpn();
       
    52         
       
    53         virtual CCmPluginBaseEng* CreateInstanceL( TCmPluginInitParam& aInitParam ) const;
       
    54         
       
    55     public: 
       
    56         
       
    57         /**
       
    58         * Gets the value for a TInt attribute.
       
    59         * @param aAttribute Identifies the attribute to be retrived.
       
    60         * @param aValue On completion, contains the requested TInt attribute.
       
    61         * @return None.
       
    62         */
       
    63         virtual TUint32 GetIntAttributeL( const TUint32 aAttribute ) const;
       
    64 
       
    65         /**
       
    66         * Gets the value for a TBool attribute.
       
    67         * @param aAttribute Identifies the attribute to be retrived.
       
    68         * @param aValue On completion, contains the requested TBool attribute.
       
    69         * @return None.
       
    70         */
       
    71         virtual TBool GetBoolAttributeL( const TUint32 aAttribute ) const;
       
    72 
       
    73         /**
       
    74         * Gets the value for a String16 attribute.
       
    75         * @param aAttribute Identifies the attribute to be retrived.
       
    76         * @param aValue On completion, contains the requested TDes16 attribute.
       
    77         * @return None.
       
    78         */
       
    79         virtual HBufC* GetStringAttributeL( const TUint32 aAttribute ) const;
       
    80 
       
    81 		/**
       
    82 		* Gets the value for a String8 attribute.
       
    83 		* @param aAttribute Identifies the attribute to be retrived.
       
    84         * @return copy of the requested attribute. Ownership is passed.
       
    85 		*/
       
    86 		virtual HBufC8* GetString8AttributeL( const TUint32 aAttribute ) const;
       
    87 
       
    88         /**
       
    89         * Sets the value for a TInt attribute.
       
    90         * @param aAttribute Identifies the attribute to be set.
       
    91         * @param aValue The value to be set.
       
    92         * @return None.
       
    93         */
       
    94         virtual void SetIntAttributeL( const TUint32 aAttribute, TUint32 aValue );
       
    95 
       
    96         /**
       
    97         * Sets the value for a TBool attribute.
       
    98         * @param aAttribute Identifies the attribute to be set.
       
    99         * @param aValue The value to be set.
       
   100         * @return None.
       
   101         */
       
   102         virtual void SetBoolAttributeL( const TUint32 aAttribute, TBool aValue );
       
   103 
       
   104         /**
       
   105         * Sets the value for a String16 attribute.
       
   106         * @param aAttribute Identifies the attribute to be set.
       
   107         * @param aValue The value to be set.
       
   108         * @return None.
       
   109         */
       
   110         virtual void SetStringAttributeL( const TUint32 aAttribute, 
       
   111                                           const TDesC16& aValue );
       
   112 
       
   113 		/**
       
   114 		* Sets the value for a String8 attribute.
       
   115 		* @param aAttribute Identifies the attribute to be set.
       
   116 		* @param aValue The value to be set.
       
   117         * @return None.
       
   118 		*/
       
   119 		virtual void SetString8AttributeL( const TUint32 aAttribute, 
       
   120 		                                   const TDesC8& aValue );
       
   121 
       
   122 
       
   123 		void UpdatePolicyNameL();
       
   124 		
       
   125         /**
       
   126         * Puts the currently available bindable destinations into the 
       
   127         * passed array. The array is emptied before appending the values.
       
   128         * It contains only real destinations, no uncategorised 
       
   129         * or any other, created ones (Always ask, DefaultConnection, etc)
       
   130         */
       
   131         void BindableDestinationsL( RArray<TUint32>& aDestinationArray );
       
   132         
       
   133         /**
       
   134         * Change the VPN connection method name when using 
       
   135         * 'Search for WLAN' functionality
       
   136         */
       
   137         HBufC* GenerateVPNPointToWLANNetworkLC(RResourceFile& rf, HBufC*& aName);
       
   138 		
       
   139     public: // From CCmPluginBaseEng        
       
   140 
       
   141         /**
       
   142         * Restore the original value of the attribute from commsdat field.
       
   143         * Base implementation can be used only with attributes 
       
   144         * stored directly in commsdat.
       
   145         * @param aAttribute attribute to be restored
       
   146         */
       
   147         virtual void RestoreAttributeL( const TUint32 aAttribute );
       
   148         
       
   149         /**
       
   150         * Override the load to be able to handle post-processing
       
   151         *
       
   152         */
       
   153         virtual void LoadL( TUint32 aIapId );
       
   154         
       
   155         virtual TBool CanHandleIapIdL( TUint32 aIapId ) const;
       
   156         virtual TBool CanHandleIapIdL( CCDIAPRecord *aIapRecord ) const;
       
   157         
       
   158         virtual TInt RunSettingsL();
       
   159         virtual void LoadServiceSettingL();
       
   160         virtual void LoadAdditionalRecordsL();
       
   161         
       
   162         virtual void UpdateAdditionalRecordsL();
       
   163 
       
   164         virtual TBool InitializeWithUiL( TBool aManuallyConfigure  );
       
   165         
       
   166         virtual void ServiceRecordIdLC( HBufC* &aServiceName, 
       
   167                                         TUint32& aRecordId );
       
   168 
       
   169         virtual void BearerRecordIdLC( HBufC* &aBearerName, 
       
   170                                        TUint32& aRecordId );
       
   171                                        
       
   172         virtual void PrepareToUpdateRecordsL();
       
   173         
       
   174         virtual TBool IsLinkedToIap( TUint32 aIapId );
       
   175         virtual TBool IsLinkedToSnap( TUint32 aSnapId );
       
   176         
       
   177         virtual void CreateNewL();
       
   178 
       
   179         /**
       
   180         * From CCmPluginBaseEng
       
   181         * Deletes additional records, in this case, the WLAN records
       
   182         *
       
   183         * @since S60 3.2
       
   184         */
       
   185         void DeleteAdditionalRecordsL();
       
   186         
       
   187     protected:
       
   188     
       
   189         virtual void AdditionalReset();
       
   190     
       
   191     private: // Constructors
       
   192 
       
   193         /**
       
   194         * Constructor.
       
   195         */      
       
   196         CCmPluginVpn( TCmPluginInitParam* aInitParam );
       
   197 
       
   198         /**
       
   199         * Second phase constructor. Leaves on failure.
       
   200         * @param
       
   201         */      
       
   202         void ConstructL();
       
   203 
       
   204     private:
       
   205     
       
   206         CCDVPNServiceRecord& ServiceRecord() const;
       
   207 
       
   208         TBool ServiceRecordExists() const;
       
   209         
       
   210         virtual void CreateNewServiceRecordL();
       
   211         virtual void CreateAdditionalRecordsL();
       
   212         
       
   213         virtual void UpdateServiceRecordL();
       
   214         
       
   215         /**
       
   216         * Displays a list of installed VPN policies for user selection
       
   217         * and updates the setting
       
   218         *
       
   219         * @since S60 3.2
       
   220         * @return the soft key selection
       
   221         */
       
   222         TBool ShowPolicySelectionDlgL();
       
   223         
       
   224         /**
       
   225         * Shows a dialog for selecting the underlying connection method
       
   226         *
       
   227         * @since S60 3.2
       
   228         * @return ETrue if success
       
   229         */
       
   230         TBool ShowRealConnectionSelectionDlgL();
       
   231         
       
   232         /**
       
   233         * Checks whether there are connection methods or destinations which
       
   234         * the VPN connection method can bind to
       
   235         * 
       
   236         * @since S60 3.2
       
   237         * @return ETrue found
       
   238         */
       
   239         TBool BindableRealConnectionsExistL();
       
   240 
       
   241         void GenerateDefaultCmNameL();  
       
   242         
       
   243         /**
       
   244         * Returns whether the passed destination can be used as an underlying
       
   245         * connection method for this particular CM.
       
   246         * It can be used if it does not points to VPN in any way, directly or
       
   247         * indirectly, it has at least one, non-virtual CM and
       
   248         * it does not links back to our parent destination.
       
   249         * The returned value is a bit field defined in the src file and 
       
   250         * it holds the following informations: 
       
   251         * IsEmpty, ContainsVPN(in any link), LinksBackToPArentDest and
       
   252         * HasNonVirtualCM to be able to decide if it is suitable.
       
   253         * Used only internally.
       
   254         */
       
   255         TUint32 CanDestUsedAsUnderlyingConnectionL( TUint32 aDestinationId );
       
   256 
       
   257 
       
   258         /**
       
   259         * Checks whether the destination/CM passed to it has a VPN connection
       
   260         * up-stream (there is a path from a VPN to this item through indirections).
       
   261         * 
       
   262         * @param aId The id of the destination/connmethod in question.
       
   263         * @param aIsDestination ETrue if the passed id is to be considered 
       
   264         *                       that of a destination, EFalse otherwise.
       
   265         * @return ETrue if this entity is pointed to (in/directly) by a VPN.
       
   266         */
       
   267         TBool HasUpstreamVpnL( TUint32 aId, TBool aIsDestination );
       
   268 
       
   269         /**
       
   270         * Checks and converts the id of the destination if needed
       
   271         * 
       
   272         * @param aDestination the id of the destination
       
   273         * @since S60 5.2
       
   274         * @return the correct id of the destination 
       
   275         *         or leaves with the error code KErrArgument 
       
   276         */                    
       
   277         TInt CheckValidityAndConvertDestinationIdL( TUint32 aDestinationId );
       
   278         
       
   279         /**
       
   280         * Retrieves default APs from the Tier Record of given identifier.
       
   281         * 
       
   282         * @param aTierIdentifier identifier for tier record.
       
   283         * @since S60 5.2
       
   284         * @return an elementid id of the default AP record in tier record. 
       
   285         */                    
       
   286         TMDBElementId DefaultAPRecordL( const TInt aTierIdentifier = KAfInet );
       
   287 
       
   288     public:                
       
   289         /**
       
   290         * Scans aDests for destinations that may be valid parents 
       
   291         * for this plugin and removes those that may not.
       
   292         * @param aDests The array of destination IDs to be filtered.
       
   293         */
       
   294         virtual void FilterPossibleParentsL( RArray<TUint32>& aDests );
       
   295 
       
   296         // finds the parent destination of the connmethod with the given ID
       
   297         TUint32 FindParentDestinationL( TUint32 aCmId );
       
   298         
       
   299     private: // Data
       
   300     
       
   301         CCmPluginBaseEng*       iRealCM;
       
   302         CCDVirtualIAPNextLayerRecord*   iVirtualRecord;
       
   303         TMDBElementId           iVirtualTableId;
       
   304         HBufC*                  iPolicyName;
       
   305         
       
   306         /**
       
   307          * An array of the bindable destinations, 
       
   308          * including (if supported) the uncategorised destation and easy wlan
       
   309          */
       
   310         RArray<TUint32> iBindableMethods;
       
   311     };
       
   312 
       
   313 #endif // VPN_PLUGIN_INCLUDED