natplugins/natpcliprovisioningnatfwadapter/inc/natfwtraversaladapter.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 - 2007 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:  Main implementation of NAT/FW Traversal adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CNATFWTRAVERSALADAPTER_H
       
    20 #define CNATFWTRAVERSALADAPTER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <CWPAdapter.h>
       
    24 #include <MWPContextExtension.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CWPCharacteristic;
       
    28 class CNATFWDomainSpecificItem;
       
    29 class CNATFWIAPSpecificItem;
       
    30 class CWPNATFWItem;
       
    31 class CWPStunServerItem;
       
    32 class CWPTurnServerItem;
       
    33 
       
    34 /**
       
    35 * Main implementation of NAT/FW Traversal adapter
       
    36 * @since S60 v3.1
       
    37 */
       
    38 class CNATFWTraversalAdapter :  public CWPAdapter, public MWPContextExtension
       
    39     {
       
    40     public:  // Constructors and destructor
       
    41 
       
    42         /**
       
    43          * Two-phased constructor.
       
    44          */
       
    45         static CNATFWTraversalAdapter* NewL();
       
    46         
       
    47         /**
       
    48          * Destructor.
       
    49          */
       
    50         virtual ~CNATFWTraversalAdapter();
       
    51 
       
    52     public: // Methods from base classes 
       
    53   
       
    54         /**
       
    55          * From CWPAdapter
       
    56          * @since Series60 3.1.
       
    57          * Returns the number of the summary lines to be shown in 
       
    58          * BIO control.
       
    59          * @return Quantity of items (NAT/FW settings items).
       
    60          */
       
    61         TInt  ItemCount() const;
       
    62 
       
    63         /**
       
    64          * From CWPAdapter
       
    65          * @since S60 v3.1.
       
    66          * Getter for the summary text of the NAT/FW item (NAT/FW settings) 
       
    67          * located in the array. Text is shown to the user in 
       
    68          * opened configuration message.
       
    69          * @param aIndex. Location of the NAT/FW item.
       
    70          * @return Summary title.
       
    71          */
       
    72         const TDesC16& SummaryTitle( TInt aIndex ) const;
       
    73 
       
    74         /**
       
    75          * From CWPAdapter
       
    76          * @since S60 v3.1.
       
    77          * Getter for the summary text of the NAT/FW item 
       
    78          * located in the array. Text is shown to the user in 
       
    79          * opened configuration message.
       
    80          * @param aIndex. Location of the NAT/FW item.
       
    81          * @return Summary text.
       
    82          */
       
    83         const TDesC16& SummaryText( TInt aIndex ) const;
       
    84 
       
    85         /**
       
    86          * From CWPAdapter
       
    87          * @since S60 v3.1.
       
    88          * Saves NAT/FW item (NAT/FW settings) located in array.
       
    89          * @param aIndex. Location of the NAT/FW item to be saved.
       
    90          */
       
    91         void SaveL( TInt aIndex );
       
    92 
       
    93         /**
       
    94          * From CWPAdapter
       
    95          * @since S60 v3.1.
       
    96          * Query if the NAT/FW item on place pointed by parameter can 
       
    97          * be set as default.
       
    98          * @param aIndex. Location of the NAT/FW item to be queried.
       
    99          * @return TBool.
       
   100          */
       
   101         TBool CanSetAsDefault( TInt aIndex ) const;
       
   102     
       
   103         /**
       
   104          * From CWPAdapter
       
   105          * @since S60 v3.1.
       
   106          * Sets the NAT/FW item on place pointed by parameter as default.
       
   107          * @param aIndex. Location of the NAT/FW item to be queried.
       
   108          */
       
   109         void SetAsDefaultL( TInt aIndex );
       
   110 
       
   111         /**
       
   112          * From CWPAdapter
       
   113          * @since S60 v3.1.
       
   114          * Query for the detail information about the NAT/FW settings. 
       
   115          * MWPPairVisitor is used for retrieving the details of a single 
       
   116          * setting entry. This is not supported feature as in the other 
       
   117          * adapters in the framework.
       
   118          * @param aItem.
       
   119          * @param aVisitor.
       
   120          * @return TInt. 
       
   121          */
       
   122         TInt DetailsL( TInt aItem, MWPPairVisitor& aVisitor );
       
   123 
       
   124         /**
       
   125          * From MWPVisitor
       
   126          * @since S60 v3.1.
       
   127          * Visit method. Visits the adapter. Adapter then checks from the 
       
   128          * aCharacteristic if the data is targetet to it and acts according to 
       
   129          * that.
       
   130          * @param aCharacteristic.
       
   131          */
       
   132         void VisitL( CWPCharacteristic& aCharacteristic );		
       
   133 
       
   134         /**
       
   135          * From MWPVisitor
       
   136          * @since S60 v3.1.
       
   137          * Visit method. Visits the adapter. Method set the iAppId value.
       
   138          * @param aParameter.
       
   139          */
       
   140         void VisitL( CWPParameter& aParameter );		
       
   141 
       
   142         /**
       
   143          * From MWPVisitor
       
   144          * @since S60 v3.1.
       
   145          * Visit method. Visits the adapter. Adapter checks from the 
       
   146          * aParameter if the link is targetet to it and acts according to 
       
   147          * that. IAP bound to the NAT/FW access point specific settings is 
       
   148          * handled with help of this method.
       
   149          * @param aParameter.
       
   150          */
       
   151         void VisitLinkL( CWPCharacteristic& aLink );
       
   152             
       
   153         /**
       
   154          * From CWPAdapter
       
   155          * Informs the adapters of the saved settings.
       
   156          * @since S60 v3.1.
       
   157          * @param aAppIdOfSavingItem. UID of the adapter component. 
       
   158          * @param aAppRef. APPREF of the saved settings.
       
   159          * @param aStorageIdValue. Value that identifies the settings in 
       
   160          *        its storage.
       
   161          * @param aIsLastOfItsType. If the settings saved is the last of 
       
   162          *        its kind, the value of the parameter is ETrue (or 1, because 
       
   163          *        the TBool type does not work correctly via interface class 
       
   164          *        definition (based on information from MVC documentation).
       
   165          */
       
   166         void SettingsSavedL ( const TDesC8& aAppIdOfSavingItem,
       
   167             const TDesC8& aAppRef, const TDesC8& aStorageIdValue );
       
   168 
       
   169         /**
       
   170          * From CWPAdapter
       
   171          * @since S60 v3.1.
       
   172          * Lets the adapters know when the saving has been finalized in 
       
   173          * viewpoint of the provisioning framework. The adapters can make 
       
   174          * finalization of saving the settings after receiving this call.
       
   175          */
       
   176         void SavingFinalizedL();
       
   177         
       
   178         /**
       
   179          * From CWPAdapter
       
   180          * @since S60 v3.1.
       
   181          * Gets the saving information from the adapter that has saved settings.
       
   182          * @param aIndex. Index of the previously saved item.
       
   183          * @param aSavingInfo.
       
   184          * @param aIsLastOfItsType. Adapter can tell to the framework if 
       
   185          * the saved item was the last one of its type.
       
   186          */
       
   187         void GetSavingInfoL( TInt aIndex, RPointerArray<HBufC8> &aSavingInfo );
       
   188 
       
   189         /**
       
   190          * From MWPContextExtension.
       
   191          * Returns a pointer to a context extension.
       
   192          * @param aExtension Contains a pointer to MWPContextExtension if supported
       
   193          * @return KErrNotSupported if not supported, KErrNone otherwise
       
   194          */
       
   195         TInt ContextExtension( MWPContextExtension*& aExtension );
       
   196 
       
   197         /**
       
   198          * From MWPContextExtension.
       
   199          * Returns the data used for saving.
       
   200          * @param aIndex The index of the data
       
   201          * @return The data. Ownership is transferred.
       
   202          */
       
   203         const TDesC8& SaveDataL( TInt aIndex ) const;
       
   204 
       
   205         /**
       
   206          * From CWPAdapter
       
   207          * Deletes a saved item.
       
   208          * @since S60 v3.1.
       
   209          * @param aSaveData The data used for saving
       
   210          */
       
   211         void DeleteL( const TDesC8& aSaveData );
       
   212 
       
   213         /**
       
   214          * Returns the UID of the adapter.
       
   215          * @return UID
       
   216          */
       
   217         TUint32 Uid() const;
       
   218         
       
   219         /**
       
   220          * Converts descriptor to TInt.
       
   221          * @param aDes Value to be converted.
       
   222          * @return Converted value.
       
   223          */
       
   224         TInt DesToInt( const TDesC8& aDes );
       
   225         
       
   226         /**
       
   227          * Converts descriptor to TUint
       
   228          * @param aDes Value to be converted.
       
   229          * @return Converted value.
       
   230          */
       
   231         TUint DesToTUint( const TDesC8& aDes );
       
   232        
       
   233     private:
       
   234 
       
   235         /**
       
   236         * C++ default constructor.
       
   237         */
       
   238         CNATFWTraversalAdapter();
       
   239 
       
   240         /**
       
   241         * By default Symbian 2nd phase constructor is private.
       
   242         */
       
   243         void ConstructL();
       
   244 
       
   245         /**
       
   246          * Gets IAP ID according to WAP ID.
       
   247          * @since S60 3.2
       
   248          * @param aWapId WAP ID of access point.
       
   249          * @return IAP ID of access point
       
   250          */
       
   251         TUint32 IapIdFromWapIdL( TUint32 aWapId );
       
   252 
       
   253     private: // Data
       
   254     
       
   255         /**
       
   256          * Current NATFW domain specific data. Ownership is transferred to
       
   257          * CWPNATFWItem.
       
   258          * Not own.
       
   259          */ 
       
   260         CNATFWDomainSpecificItem* iCurrentDomainItem;
       
   261         
       
   262         /**
       
   263          * Current NATFW iap specific data. Ownership is transferred to 
       
   264          * CWPNATFWItem.
       
   265          * Not own.
       
   266          */
       
   267         CNATFWIAPSpecificItem* iCurrentIapItem;
       
   268         
       
   269         /**
       
   270          * Current NATFW item setting data.
       
   271          * Own.
       
   272          */
       
   273         CWPNATFWItem* iCurrentNATFWItem;
       
   274         
       
   275         /**
       
   276          * The application id of the current characteristic. 
       
   277          * Not own.
       
   278          */
       
   279         TPtrC iAppID;
       
   280  
       
   281 	    /**
       
   282          * Default name for NAT/FW settings. Value is read from the resource file.
       
   283          * Own.
       
   284          */
       
   285         HBufC* iDefaultName;
       
   286 
       
   287         /**
       
   288          * Title for NAT/FW settings. Value is read from the resource file.
       
   289          * Own.
       
   290          */
       
   291         HBufC* iTitle;
       
   292 
       
   293         /**
       
   294          * Holds the received NAT/FW item data.
       
   295          * Own.
       
   296          */
       
   297         RPointerArray<CWPNATFWItem> iDatas;
       
   298 
       
   299         /**
       
   300          * For telling whether it is OK to set NW parameters.
       
   301          */
       
   302         TBool iCharacteristicNw;
       
   303 
       
   304         /**
       
   305          * For telling whether it is OK to set ICE parameters.
       
   306          */
       
   307         TBool iCharacteristicIce;
       
   308 
       
   309         /**
       
   310          * For telling whether it is OK to set TURN parameters.
       
   311          */
       
   312         TBool iCharacteristicTurn;
       
   313 
       
   314         /**
       
   315          * For telling whether it is OK to set NATIAP parameters.
       
   316          */
       
   317         TBool iCharacteristicNatIap;
       
   318 
       
   319         /**
       
   320          * For telling whether it is OK to set TURNSERVER parameters.
       
   321          */
       
   322         TBool iCharacteristicTurnServer;
       
   323 
       
   324         /**
       
   325          * For telling whether it is OK to set ADDITIONALSTUN parameters.
       
   326          */
       
   327         TBool iCharacteristicAdditionalStun;
       
   328 
       
   329         /**
       
   330          * Current STUN server item. Ownership is transferred to 
       
   331          * CWPNATFWDomainSpecificItem.
       
   332          * Not own.
       
   333          */
       
   334         CWPStunServerItem* iCurrentStunServer;
       
   335 
       
   336         /**
       
   337          * Current TURN server item. Ownership is transferred to 
       
   338          * CWPNATFWDomainSpecificItem.
       
   339          * Not own.
       
   340          */
       
   341         CWPTurnServerItem* iCurrentTurnServer;
       
   342 
       
   343         /**
       
   344          * For EUnit testing. Uncomment when running tests.
       
   345          */
       
   346         //friend class T_NATFWTraversalAdapter;
       
   347     };
       
   348 
       
   349 #endif      // CNATFWTRAVERSALADAPTER_H
       
   350             
       
   351 // End of File