natfw/natfwturnplugin/src/tturnplugincallbackinfo.cpp
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 #include "tturnplugincallbackinfo.h"
       
    22 #include "natfwturnpluginlogs.h"
       
    23 
       
    24 #ifdef _DEBUG
       
    25 _LIT16( KPanicArgument, "invalid argument" );
       
    26 #endif
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // TTurnPluginCallbackInfo::TTurnPluginCallbackInfo
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 TTurnPluginCallbackInfo::TTurnPluginCallbackInfo(
       
    33     const CNATFWPluginApi& aTurnPlugin,
       
    34     MNATFWPluginObserver& aObserver,
       
    35     TTurnPluginCallbackInfo::TFunction aFunction, TUint aStreamId,
       
    36     TInt aErrorCode,
       
    37     TAny* aEventData )
       
    38     :
       
    39     iLink(),
       
    40     iTurnPlugin( aTurnPlugin ),
       
    41     iObserver( aObserver ),
       
    42     iFunction( aFunction ),
       
    43     iStreamId( aStreamId ),
       
    44     iErrorCode( aErrorCode ),
       
    45     iEventData( aEventData )
       
    46     {
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // TTurnPluginCallbackInfo::TTurnPluginCallbackInfo
       
    51 // Dummy implementation. Default constructor is declared private and not used.
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 TTurnPluginCallbackInfo::TTurnPluginCallbackInfo() :
       
    55     iLink(),
       
    56     iTurnPlugin( *( CNATFWPluginApi* )0x1 ),
       
    57     iObserver( *( MNATFWPluginObserver* )0x1 ),
       
    58     iFunction( EFetchingEnd ),
       
    59     iStreamId( 0 ),
       
    60     iErrorCode( KErrNone ),
       
    61     iEventData( NULL )
       
    62     {
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // TTurnPluginCallbackInfo::TTurnPluginCallbackInfo
       
    67 // Dummy implementation, as copy constructor is declared private and not used.
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 TTurnPluginCallbackInfo::TTurnPluginCallbackInfo(
       
    71     const TTurnPluginCallbackInfo& /*aCallbackInfo*/ ) :
       
    72     iLink(),
       
    73     iTurnPlugin( *( CNATFWPluginApi* )0x1 ),
       
    74     iObserver( *( MNATFWPluginObserver* )0x1 ),
       
    75     iFunction( EFetchingEnd ),
       
    76     iStreamId( 0 ),
       
    77     iErrorCode( KErrNone ),
       
    78     iEventData( NULL )
       
    79     {
       
    80     }
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // TTurnPluginCallbackInfo::Validate
       
    84 // ----------------------------------------------------------------------------
       
    85 //
       
    86 TBool TTurnPluginCallbackInfo::Validate() const
       
    87     {
       
    88     __TURNPLUGIN( "TurnPluginCallbackInfo::Validate()" )
       
    89     switch ( iFunction )
       
    90         {
       
    91         case EActiveSending:
       
    92         case EDeactiveSending:
       
    93         case EActiveReceiving:
       
    94         case EDeactiveReceiving:
       
    95         case ELocalCandidateFound:
       
    96         case EFetchingEnd:
       
    97             return iStreamId;
       
    98 
       
    99         case EConnectServer:
       
   100             return ETrue;
       
   101             
       
   102         case EError:
       
   103             return iStreamId && ( iErrorCode != KErrNone );
       
   104 
       
   105         default:
       
   106             return EFalse;
       
   107         }
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // TTurnPluginCallbackInfo::Execute
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 void TTurnPluginCallbackInfo::Execute() const
       
   115     {
       
   116     __TURNPLUGIN( "TurnPluginCallbackInfo::Execute() in" )
       
   117     __ASSERT_DEBUG( Validate(),
       
   118         User::Panic( KPanicArgument, KErrArgument ) );
       
   119 
       
   120     switch ( iFunction )
       
   121         {
       
   122         case EConnectServer:        
       
   123             PassEvent( MNATFWPluginObserver::EServerConnected );
       
   124             break;
       
   125                     
       
   126         case EActiveSending:
       
   127             PassEvent( MNATFWPluginObserver::ESendingActivated );
       
   128             break;
       
   129 
       
   130         case EDeactiveSending:
       
   131             PassEvent( MNATFWPluginObserver::ESendingDeactivated );
       
   132             break;
       
   133         
       
   134         case EActiveReceiving:
       
   135             PassEvent( MNATFWPluginObserver::EReceivingActivated );
       
   136             break;
       
   137         
       
   138         case EDeactiveReceiving:
       
   139             PassEvent( MNATFWPluginObserver::EReceivingDeactivated );
       
   140             break;
       
   141         
       
   142         case ELocalCandidateFound:
       
   143             {
       
   144             CNATFWCandidate* candidate =
       
   145                 reinterpret_cast<CNATFWCandidate*>( iEventData );
       
   146             
       
   147             ASSERT( candidate );
       
   148             iObserver.NewLocalCandidateFound( iTurnPlugin, candidate );
       
   149             }
       
   150             break;
       
   151         
       
   152         case EFetchingEnd:
       
   153             PassEvent( MNATFWPluginObserver::EFetchingCompleted );
       
   154             break;
       
   155         
       
   156         case EError:
       
   157             PassError();
       
   158             break;
       
   159         
       
   160         default:
       
   161             ASSERT( EFalse );
       
   162         }
       
   163     
       
   164     __TURNPLUGIN( "TurnPluginCallbackInfo::Execute() out" )
       
   165     }
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // TTurnPluginCallbackInfo::PassEvent
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void TTurnPluginCallbackInfo::PassEvent(
       
   172     MNATFWPluginObserver::TNATFWPluginEvent aEvent ) const
       
   173     {
       
   174     iObserver.Notify( iTurnPlugin, iStreamId, aEvent, iErrorCode );
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // TTurnPluginCallbackInfo::PassError
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void TTurnPluginCallbackInfo::PassError() const
       
   182     {
       
   183     iObserver.Error( iTurnPlugin, iStreamId, iErrorCode );
       
   184     }
       
   185 
       
   186 // End of file