natfw/natfwturnplugin/src/natfwturnplugin.cpp
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:    Implements NAT Plug-in interface, which client uses to send
       
    15 *                TURN requests. Forwards client requests to Turn Connection
       
    16 *                Handler.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include "natfwcandidate.h"
       
    24 #include "natfwturnplugin.h"
       
    25 #include "natfwturnconnectionhandler.h"
       
    26 #include "natfwturnpluginlogs.h"
       
    27 
       
    28 _LIT8( KNatPluginIdNokiaTurn, "nokia.turn" );
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // C++ default constructor
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CNATFWTurnPlugin::CNATFWTurnPlugin()
       
    37     {
       
    38 
       
    39     }
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Symbian constructor
       
    44 // Creates NATFWTurnConnectionHandler.
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 void CNATFWTurnPlugin::ConstructL( TAny* aInitParams )
       
    48     {
       
    49     __TURNPLUGIN( "CNATFWTurnPlugin::ConstructL start" )
       
    50 
       
    51     __ASSERT_ALWAYS( aInitParams, User::Leave( KErrArgument ) );
       
    52     
       
    53     iPluginId = KNatPluginIdNokiaTurn().AllocL();
       
    54     
       
    55     CNATFWPluginApi::TNATFWPluginInitParams* initParams =
       
    56         static_cast<CNATFWPluginApi::TNATFWPluginInitParams*>(
       
    57             aInitParams );
       
    58 
       
    59     iTurnConnectionHandler = CNATFWTurnConnectionHandler::NewL(
       
    60         *this, initParams->iObserver );
       
    61 
       
    62     iTurnConnectionHandler->PluginInitializeL( initParams->iIapId,
       
    63                                                initParams->iDomain,
       
    64                                                initParams->iMultiplexer );
       
    65 
       
    66     __TURNPLUGIN( "CNATFWTurnPlugin::ConstructL end" )
       
    67     }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // Symbian constructor
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 CNATFWTurnPlugin* CNATFWTurnPlugin::NewL( TAny* aInitParams )
       
    75     {
       
    76     __TURNPLUGIN( "CNATFWTurnPlugin::NewL" )
       
    77     CNATFWTurnPlugin* self = new ( ELeave ) CNATFWTurnPlugin();
       
    78     CleanupStack::PushL( self );
       
    79     self->ConstructL( aInitParams );
       
    80     CleanupStack::Pop( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // Destructor
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CNATFWTurnPlugin::~CNATFWTurnPlugin()
       
    90     {
       
    91     delete iPluginId;
       
    92     delete iTurnConnectionHandler;
       
    93     }
       
    94 
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // From class CNATFWPluginApi.
       
    98 // CNATFWTurnPlugin::ConnectServerL
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CNATFWTurnPlugin::ConnectServerL( const RSocketServ& aSocketServ,
       
   102     const TName& aConnectionName )
       
   103     {
       
   104     __TURNPLUGIN( "CNATFWTurnPlugin::ConnectServerL start" )
       
   105     
       
   106     iTurnConnectionHandler->ConnectServerL( aSocketServ, aConnectionName );
       
   107     
       
   108     __TURNPLUGIN( "CNATFWTurnPlugin::ConnectServerL end" )
       
   109     }
       
   110 
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // From class CNATFWPluginApi.
       
   114 // CNATFWTurnPlugin::FetchCandidateL
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CNATFWTurnPlugin::FetchCandidateL( TUint aStreamId, TUint aRtoValue,
       
   118     TUint aAddrFamily )
       
   119     {
       
   120     __TURNPLUGIN( "CNATFWTurnPlugin::FetchCandidate start" )
       
   121     
       
   122     iTurnConnectionHandler->FetchCandidateL( aStreamId, aRtoValue,
       
   123         aAddrFamily, KAFUnspec );
       
   124     
       
   125     __TURNPLUGIN( "CNATFWTurnPlugin::FetchCandidate end" )
       
   126     }
       
   127 
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // From class CNATFWPluginApi.
       
   131 // CNATFWTurnPlugin::FetchCandidateL
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CNATFWTurnPlugin::FetchCandidateL( TUint aStreamId, TUint aRtoValue,
       
   135     const TInetAddr& aBaseAddr )
       
   136     {
       
   137     __TURNPLUGIN( "CNATFWTurnPlugin::FetchCandidateL start" )
       
   138     
       
   139     iTurnConnectionHandler->FetchCandidateL( aStreamId, aRtoValue, KAFUnspec,
       
   140         aBaseAddr );
       
   141     
       
   142     __TURNPLUGIN( "CNATFWTurnPlugin::FetchCandidateL end" )
       
   143     }
       
   144 
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // From class CNATFWPluginApi.
       
   148 // CNATFWTurnPlugin::SetReceivingStateL
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CNATFWTurnPlugin::SetReceivingStateL(
       
   152     const CNATFWCandidate& aLocalCandidate,
       
   153     TNATFWStreamingState aState )
       
   154     {
       
   155     __TURNPLUGIN( "CNATFWTurnPlugin::SetReceivingStateL start" )
       
   156     iTurnConnectionHandler->SetReceivingStateL( aLocalCandidate, aState );
       
   157     __TURNPLUGIN( "CNATFWTurnPlugin::SetReceivingStateL start" )
       
   158     }
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // From class CNATFWPluginApi.
       
   163 // CNATFWTurnPlugin::SetSendingStateL
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CNATFWTurnPlugin::SetSendingStateL(
       
   167     const CNATFWCandidate& aLocalCandidate,
       
   168     TNATFWStreamingState aState,
       
   169     const TInetAddr& aDestAddr )
       
   170     {
       
   171     __TURNPLUGIN( "CNATFWTurnPlugin::SetSendingStateL start" )
       
   172     
       
   173     iTurnConnectionHandler->SetSendingStateL( aLocalCandidate, aState,
       
   174         aDestAddr );
       
   175     
       
   176     __TURNPLUGIN( "CNATFWTurnPlugin::SetSendingStateL end" )
       
   177     }
       
   178 
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // From class CNATFWPluginApi.
       
   182 // CNATFWTurnPlugin::GetConnectionIdL
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 void CNATFWTurnPlugin::GetConnectionIdL(
       
   186     const CNATFWCandidate& aLocalCandidate,
       
   187     TUint& aConnectionId )
       
   188     {
       
   189     __TURNPLUGIN( "CNATFWTurnPlugin::GetConnectionIdL start" )
       
   190     iTurnConnectionHandler->GetConnectionIdL( aLocalCandidate,
       
   191         aLocalCandidate.StreamId(), aConnectionId );
       
   192     __TURNPLUGIN( "CNATFWTurnPlugin::GetConnectionIdL end" )
       
   193     }
       
   194 
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // From class CNATFWPluginApi.
       
   198 // CNATFWTurnPlugin::PluginIdentifier
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 const TDesC8& CNATFWTurnPlugin::PluginIdentifier() const
       
   202     {
       
   203     return *iPluginId;
       
   204     }
       
   205 
       
   206 // End of file