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