natfw/natfwclient/tsrc/ut_natfwclient/inc/natfwtestplugin.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_NATFWTESTPLUGIN_H
       
    22 #define C_NATFWTESTPLUGIN_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include "natfwpluginapi.h"
       
    26 
       
    27 class CNATFWConnectionHandler;
       
    28 //class MNATFWConnectionMultiplexerIF;
       
    29 //class MNATFWPluginObserver;
       
    30 //class CNATFWCandidate;
       
    31 
       
    32 /**
       
    33  *  Implements NAT Plug-in interface
       
    34  *
       
    35  *  The client uses this interface to send STUN requests. Forwards
       
    36  *  client requests to STUN Connection Handler.
       
    37  *
       
    38  *  @lib stunplugin.lib
       
    39  *  @since S60 v3.2
       
    40  */
       
    41 class CNATFWTestPlugin : public CNATFWPluginApi
       
    42     {
       
    43 
       
    44 public:
       
    45 
       
    46     /**
       
    47      * Creates a new instance of NAT FW Plug-in class.
       
    48      *
       
    49      * @since S60 v3.2
       
    50      * @param aInitParams Initial parameters that will be given to
       
    51      *                    STUN Connection Handler class.
       
    52      * @return A new instance, ownership is transferred.
       
    53      */
       
    54     static CNATFWTestPlugin* NewL( TAny* aInitParams );
       
    55 
       
    56     virtual ~CNATFWTestPlugin();
       
    57 
       
    58     /**
       
    59      * ConnectServerL
       
    60      *
       
    61      * @since   S60 v3.2
       
    62      * @param   aSocketServ         The handle to socket server session
       
    63      * @param   aConnectionName     The unique name of the RConnection
       
    64      * @return  void
       
    65      */
       
    66      void ConnectServerL( const RSocketServ& aSocketServ,
       
    67         const TName& aConnectionName );
       
    68         
       
    69     /**
       
    70      * FetchCandidate
       
    71      *
       
    72      * @since S60 v3.2
       
    73      * @param aStreamId Stream ID
       
    74      * @return void
       
    75      */
       
    76     void FetchCandidateL( TUint aStreamId, TUint aRtoValue,
       
    77         TUint aAddrFamily  );
       
    78     
       
    79     /**
       
    80      * ICE specific function.
       
    81      * Fetches all available candidates for a specified stream in a 
       
    82      * stream collection.
       
    83      *
       
    84      * @since   S60 v3.2
       
    85      * @param   aStreamCollectionId Stream collection identifier
       
    86      * @param   aStreamId           Stream identifier
       
    87      * @param   aComponentId        Component identifier
       
    88      * @param   aAddrFamily         KAFUnspec / KAfInet / KAfInet6
       
    89      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
    90      * operation.
       
    91      */
       
    92     void FetchCandidatesL( TUint aStreamCollectionId,
       
    93         TUint aStreamId, TUint aComponentId, TUint aAddrFamily );
       
    94     
       
    95     /**
       
    96      * Connect
       
    97      *
       
    98      * @since S60 v3.2
       
    99      * @return void
       
   100      */
       
   101     void ConnectL();
       
   102 
       
   103     /**
       
   104      * MNATFWPluginObserver::Notify is called (returned) with stream's
       
   105      * current sending status.
       
   106      *
       
   107      * @since   S60 3.2
       
   108      * @param   aStreamId   The stream identifier
       
   109      * @param   aDestAddr   The address where to send media
       
   110      * @param   aState     The streaming status
       
   111      * @return  void
       
   112      */
       
   113     void SetSendingStateL( TUint aStreamId,
       
   114                             const TInetAddr& aDestAddr,
       
   115                             TNATFWStreamingState aState );
       
   116                             
       
   117     /**
       
   118      * Enables/disables media receiving for the specified local candidate.
       
   119      * 
       
   120      * Only those candidates given with MNATFWPluginObserver callbacks
       
   121      * can be controlled. NATFW stream can have only one active candidate
       
   122      * at a time. In other words, exactly one local candidate can be used
       
   123      * for media delivery in receiving, sending or both directions.
       
   124      * 
       
   125      * MNATFWPluginObserver::Notify is called with event code
       
   126      * EReceivingActivated/EReceivingDeactivated when status change has 
       
   127      * completed. While activated incoming data is delivered to the media
       
   128      * engine.
       
   129      * 
       
   130      * Receiving must be disabled prior to deleting plugin so that all
       
   131      * resources can be freed.
       
   132      * 
       
   133      * Note: If TURN is used media cannot be delivered until remote address
       
   134      * is known.
       
   135      * 
       
   136      * @since   S60 v3.2
       
   137      * @param   aLocalCandidate The local end point for a media
       
   138      * @param   aState          The receiving state
       
   139      */
       
   140     void SetReceivingStateL( const CNATFWCandidate& aLocalCandidate,
       
   141         TNATFWStreamingState aState );
       
   142     
       
   143     /**
       
   144      * Enables/disables media sending from the specified local candidate.
       
   145      * 
       
   146      * Only those candidates given with MNATFWPluginObserver callbacks
       
   147      * can be controlled. NATFW stream can have only one active candidate
       
   148      * at a time. In other words, exactly one local candidate can be used
       
   149      * for media delivery in receiving, sending or both directions.
       
   150      * 
       
   151      * Sending must be disabled prior to deleting plugin so that all
       
   152      * resources can be freed.
       
   153      * 
       
   154      * MNATFWPluginObserver::Notify is called with event code
       
   155      * ESendingActivated/ESendingDeactivated when status change has 
       
   156      * completed. While activated outgoing data from media engine is delivered
       
   157      * to the specified remote address.
       
   158      * 
       
   159      * @since   S60 v3.2
       
   160      * @param   aLocalCandidate The local end point for a media
       
   161      * @param   aState          The sending state
       
   162      * @param   aDestAddr       The remote end point for a media
       
   163      */
       
   164     void SetSendingStateL( const CNATFWCandidate& aLocalCandidate,
       
   165         TNATFWStreamingState aState, const TInetAddr& aDestAddr );
       
   166          
       
   167     /**
       
   168      * ICE specific function.
       
   169      * Updates ICE processing for a session with the candidate pairs selected
       
   170      * by the controlling peer. If ICE processing for a stream is completed, 
       
   171      * update for that is silently ignored.
       
   172      * 
       
   173      * ICE restart is handled by setting new role and credentials and 
       
   174      * re-starting connectivity checks with PerformCandidateChecksL.
       
   175      * 
       
   176      * Adding new streams does not differ from initial operation.
       
   177      * Removing of streams is handled with CloseStreamL.
       
   178      * 
       
   179      * @since   S60 v3.2
       
   180      * @pre     ICE processing is started with PerformConnectivityChecksL
       
   181      * @param   aPeerSelectedPairs  Peer selected candidate pairs
       
   182      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
   183      * operation.
       
   184      * @post    ICE processing is continued with new parameters
       
   185      */
       
   186     void UpdateIceProcessingL( 
       
   187         RPointerArray<CNATFWCandidatePair>& aPeerSelectedPairs );
       
   188 
       
   189     /**
       
   190      * ICE specific function.
       
   191      * Starts to perform connectivity checks.
       
   192      *
       
   193      * @since   S60 v3.2
       
   194      * @param   aRemoteCandidates   Remote candidate array
       
   195      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
   196      * operation.
       
   197      */
       
   198     void PerformConnectivityChecksL( 
       
   199             RPointerArray<CNATFWCandidate>& aRemoteCandidates );
       
   200     
       
   201     /**
       
   202      * ICE specific function.
       
   203      * Updates ICE processing for a session with an updated set of remote
       
   204      * candidates. If ICE processing for a stream is completed, update for
       
   205      * that is silently ignored. New remote candidates will be included in
       
   206      * connectivity tests from this point onwards.
       
   207      * 
       
   208      * ICE restart is handled by setting new role and credentials and 
       
   209      * re-starting connectivity checks with PerformCandidateChecksL.
       
   210      * 
       
   211      * Adding new streams does not differ from initial operation.
       
   212      * Removing of streams is handled with CloseStreamL.
       
   213      * 
       
   214      * @since   S60 v3.2
       
   215      * @pre     ICE processing is started with PerformConnectivityChecksL
       
   216      * @param   aRemoteCands        All remote candidates known currently
       
   217      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
   218      * operation.
       
   219      * @post    ICE processing is continued with new parameters
       
   220      */
       
   221     void UpdateIceProcessingL( 
       
   222         RPointerArray<CNATFWCandidate>& aRemoteCands );
       
   223 
       
   224     
       
   225     /**
       
   226      * ICE specific function.
       
   227      * Sets the role for ICE. In role-conflict situation given role
       
   228      * will be silently changed.
       
   229      *
       
   230      * @since   S60 v3.2
       
   231      * @param   aRole               The role
       
   232      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
   233      * operation.
       
   234      */
       
   235     void SetRoleL( TNATFWIceRole aRole );
       
   236     
       
   237     /**
       
   238      * ICE specific function. 
       
   239      * Sets username fragment and corresponding password for message signing
       
   240      * and authentication with the specified candidate.
       
   241      *
       
   242      * @since   S60 v3.2
       
   243      * @param   aCandidate          The candidate
       
   244      * @param   aCredentials        The credentials
       
   245      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
   246      * operation.
       
   247      */
       
   248     void SetCredentialsL(
       
   249         const CNATFWCandidate& aCandidate,
       
   250         const CNATFWCredentials& aCredentials );
       
   251     
       
   252     /**
       
   253      * Gets identifier for a connection that is associated with the
       
   254      * given local end point.
       
   255      * 
       
   256      * @since   S60 v3.2
       
   257      * @param   aLocalCandidate     The local end point for a media
       
   258      * @param   aConnectionId       Reference to found id
       
   259      */
       
   260     void GetConnectionIdL( 
       
   261         const CNATFWCandidate& aLocalCandidate,
       
   262         TUint& aConnectionId );
       
   263 
       
   264     /**
       
   265      * From CNATFWPluginApi.
       
   266      * Get identifier of the plugin.
       
   267      * 
       
   268      * @since   S60 3.2
       
   269      * @return  Identifier of the plugin
       
   270      */
       
   271     const TDesC8& PluginIdentifier() const;
       
   272     
       
   273 private:
       
   274 
       
   275     CNATFWTestPlugin();
       
   276 
       
   277     void ConstructL( TAny* aInitParams );
       
   278     
       
   279 
       
   280 private: // data
       
   281     
       
   282     
       
   283     /**
       
   284      * Handles connection related actions.
       
   285      * Own.
       
   286      */
       
   287     CNATFWConnectionHandler* iConnectionHandler;
       
   288     
       
   289     /**
       
   290      * Plugin identifier.
       
   291      * Own.
       
   292      */
       
   293     HBufC8* iPluginId;
       
   294     
       
   295     /**
       
   296      * IapId
       
   297      */
       
   298     //TUint iIapId;
       
   299     
       
   300     /**
       
   301      * Domain name
       
   302      * own.
       
   303      */
       
   304     //HBufC8* iDomain;
       
   305     
       
   306     /**
       
   307      * Not own.
       
   308      */
       
   309     //MNATFWConnectionMultiplexerIF* iConnMux;
       
   310     
       
   311     /**
       
   312      * Sends notifications to NAT Plug-in observer.
       
   313      * Not own.
       
   314      */
       
   315     //MNATFWPluginObserver* iPluginObserver;
       
   316     
       
   317     /**
       
   318      * Candidate
       
   319      * own.
       
   320      */
       
   321     //CNATFWCandidate* iCandidate;
       
   322     
       
   323     /**
       
   324      * iStreamId
       
   325      */
       
   326     //TUint iStreamId;
       
   327     
       
   328     //TNATFWStreamingState iStreamingStatus;
       
   329     };
       
   330 
       
   331 #endif // C_NATFWTESTPLUGIN_H