|
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_CICENATPLUGINCONTAINER_H |
|
22 #define C_CICENATPLUGINCONTAINER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "mnatfwpluginobserver.h" |
|
26 #include "natfwpluginapi.h" |
|
27 #include "micenatplugineventobs.h" |
|
28 #include "natfwinternaldefs.h" //UNIT_TEST |
|
29 |
|
30 class MNcmConnectionMultiplexer; |
|
31 class CIceSessionData; |
|
32 class CNATFWPluginApi; |
|
33 class TIceNatPluginContainerIter; |
|
34 |
|
35 /** |
|
36 * Container for NAT-protocol plugins. Configures itself; resolves available |
|
37 * plugins based on NAT-settings. Makes possible for different clients to |
|
38 * request different operations on contained plugins. |
|
39 * |
|
40 * @lib icecandidatehandler.dll |
|
41 * @since S60 v3.2 |
|
42 */ |
|
43 class CIceNatPluginContainer |
|
44 : public CBase, public MNATFWPluginObserver |
|
45 { |
|
46 |
|
47 UNIT_TEST( UT_CIceNatPluginContainer ) |
|
48 friend class TIceNatPluginContainerIter; |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * @param aSessionData Interface for querying session data |
|
55 * @param aMultiplexer The multiplexer interface |
|
56 */ |
|
57 static CIceNatPluginContainer* NewL( |
|
58 const CIceSessionData& aSessionData, |
|
59 MNcmConnectionMultiplexer& aMultiplexer ); |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * @param aSessionData Interface for querying session data |
|
64 * @param aMultiplexer The multiplexer interface |
|
65 */ |
|
66 static CIceNatPluginContainer* NewLC( |
|
67 const CIceSessionData& aSessionData, |
|
68 MNcmConnectionMultiplexer& aMultiplexer ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 virtual ~CIceNatPluginContainer(); |
|
74 |
|
75 /** |
|
76 * Connects contained plugins to server. |
|
77 * |
|
78 * @since S60 v3.2 |
|
79 * @param aSocketServ The handle to socket server session |
|
80 * @param aConnectionName The unique name of the RConnection |
|
81 */ |
|
82 void ConnectPluginsL( const RSocketServ& aSocketServ, |
|
83 const TName& aConnectionName ); |
|
84 |
|
85 /** |
|
86 * Returns number of contained plugins. |
|
87 * |
|
88 * @since S60 v3.2 |
|
89 * @return Number of plugins |
|
90 */ |
|
91 TInt Count() const; |
|
92 |
|
93 /** |
|
94 * Registers given observer for specified event. |
|
95 * |
|
96 * @since S60 v3.2 |
|
97 * @param aObserver The observer to be registered |
|
98 * @param aEvent The event for which to register |
|
99 * @leave KErrNoMemory |
|
100 */ |
|
101 void RegObserverForEventL( const MIceNatPluginEventObs& aObserver, |
|
102 MIceNatPluginEventObs::TNatPluginEvent aEvent ); |
|
103 |
|
104 /** |
|
105 * Unregisters given observer for specified event. |
|
106 * |
|
107 * @since S60 v3.2 |
|
108 * @param aObserver The observer to be unregistered |
|
109 * @param aEvent The event for which to unregister |
|
110 */ |
|
111 void UnregObserverForEvent( const MIceNatPluginEventObs& aObserver, |
|
112 MIceNatPluginEventObs::TNatPluginEvent aEvent ); |
|
113 |
|
114 /** |
|
115 * Unregisters given observer for all events. |
|
116 * |
|
117 * @since S60 v3.2 |
|
118 * @param aObserver The observer to be unregistered |
|
119 */ |
|
120 void UnregObserver( const MIceNatPluginEventObs& aObserver ); |
|
121 |
|
122 /** |
|
123 * Releases plugins. |
|
124 * |
|
125 * @since S60 3.2 |
|
126 * @param aRetainRelay Whether relay should be kept up |
|
127 */ |
|
128 void ReleasePlugins( TBool aRetainRelay ); |
|
129 |
|
130 /** |
|
131 * Gets plugin by identifier (e.g. vendor.stun). |
|
132 * |
|
133 * @since S60 3.2 |
|
134 * @param aIdentifier The identifier for the plugin to search |
|
135 * @return NAT plugin |
|
136 */ |
|
137 CNATFWPluginApi* PluginByIdentifier( const TDesC8& aIdentifier ); |
|
138 |
|
139 /** |
|
140 * Gets plugin by type (stun, turn, ice, host). |
|
141 * |
|
142 * @since S60 3.2 |
|
143 * @param aType The type for the plugin to search |
|
144 * @return NAT plugin |
|
145 */ |
|
146 CNATFWPluginApi* PluginByType( const TDesC8& aType ); |
|
147 |
|
148 // from base class MNATFWPluginObserver |
|
149 |
|
150 void Error( const CNATFWPluginApi& aPlugin, |
|
151 TUint aStreamId, TInt aErrorCode ); |
|
152 |
|
153 void Notify( const CNATFWPluginApi& aPlugin, |
|
154 TUint aStreamId, TNATFWPluginEvent aEvent, TInt aErrCode ); |
|
155 |
|
156 void NewCandidatePairFound( const CNATFWPluginApi& aPlugin, |
|
157 CNATFWCandidatePair* aCandidatePair ); |
|
158 |
|
159 void NewLocalCandidateFound( const CNATFWPluginApi& aPlugin, |
|
160 CNATFWCandidate* aLocalCandidate ); |
|
161 |
|
162 private: |
|
163 |
|
164 CIceNatPluginContainer( |
|
165 const CIceSessionData& aSessionData, |
|
166 MNcmConnectionMultiplexer& aMultiplexer ); |
|
167 |
|
168 void ConstructL(); |
|
169 |
|
170 void ResolvePluginsL(); |
|
171 |
|
172 TInt GetConvertedEvent( TNATFWPluginEvent aEvent, |
|
173 MIceNatPluginEventObs::TNatPluginEvent& aConvertedEvent ) const; |
|
174 |
|
175 TPtrC8 ParsePluginType( const TDesC8& aIdentifier ) const; |
|
176 |
|
177 private: // data |
|
178 |
|
179 /** |
|
180 * Initialization parameters for the utility plugins. |
|
181 */ |
|
182 CNATFWPluginApi::TNATFWPluginInitParams iInitParams; |
|
183 |
|
184 /** |
|
185 * Observers indexed by the NAT-plugin events. |
|
186 * Own. |
|
187 */ |
|
188 RPointerArray< RPointerArray<MIceNatPluginEventObs> > iObserversForEvent; |
|
189 |
|
190 /** |
|
191 * NAT protocol plugins. |
|
192 * Own. |
|
193 */ |
|
194 RPointerArray<CNATFWPluginApi> iPlugins; |
|
195 }; |
|
196 |
|
197 #endif // C_CICENATPLUGINCONTAINER_H |