|
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: Handler for message observers on multiplexer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_CNCMCONNECTIONOBSERVERHANDLER_H |
|
22 #define C_CNCMCONNECTIONOBSERVERHANDLER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 #include "ncmconnectionmultiplexer.hrh" |
|
27 #include "natfwconnectivityapidefs.h" |
|
28 |
|
29 class MNcmConnectionObserver; |
|
30 class MNcmIncomingConnectionObserver; |
|
31 class MNcmOutgoingConnectionObserver; |
|
32 class MNcmMessageObserver; |
|
33 class TInetAddr; |
|
34 class CNcmMediaSource; |
|
35 class MNcmSourceObserver; |
|
36 |
|
37 /** |
|
38 * Handler for connection observers on multiplexer |
|
39 * |
|
40 * Allows registration of connection observers and revealing messages for |
|
41 * those. Additionally connection notifications can be provided for observers |
|
42 * |
|
43 * @lib connectionmux.lib |
|
44 * @since S60 v3.2 |
|
45 */ |
|
46 NONSHARABLE_CLASS( CNcmConnectionObserverHandler ) : public CBase |
|
47 { |
|
48 |
|
49 public: |
|
50 |
|
51 static CNcmConnectionObserverHandler* NewL(); |
|
52 |
|
53 static CNcmConnectionObserverHandler* NewLC(); |
|
54 |
|
55 virtual ~CNcmConnectionObserverHandler(); |
|
56 |
|
57 /** |
|
58 * Registers object to observe outgoing connections |
|
59 * |
|
60 * @since S60 v3.2 |
|
61 * @param aOutgoingConnectionObserver Observer to be registered |
|
62 * @return void |
|
63 */ |
|
64 void RegisterOutgoingConnectionObserverL( |
|
65 const MNcmOutgoingConnectionObserver& aOutgoingConnectionObserver ); |
|
66 |
|
67 /** |
|
68 * Registers object to observe incoming connections |
|
69 * |
|
70 * @since S60 v3.2 |
|
71 * @param aIncomingConnectionObserver Observer to be registered |
|
72 * @return void |
|
73 */ |
|
74 void RegisterIncomingConnectionObserverL( |
|
75 const MNcmIncomingConnectionObserver& aIncomingConnectionObserver ); |
|
76 |
|
77 /** |
|
78 * Removes object from observing outgoing connections |
|
79 * |
|
80 * @since S60 v3.2 |
|
81 * @param aOutgoingConnectionObserver Observer to be unregistered |
|
82 * @return void |
|
83 */ |
|
84 void UnregisterOutgoingConnectionObserverL( |
|
85 const MNcmOutgoingConnectionObserver& aOutgoingConnectionObserver ); |
|
86 |
|
87 /** |
|
88 * Removes object from observing incoming connections |
|
89 * |
|
90 * @since S60 v3.2 |
|
91 * @param aIncomingConnectionObserver Observer to be unregistered |
|
92 * @return void |
|
93 */ |
|
94 void UnregisterIncomingConnectionObserverL( |
|
95 const MNcmIncomingConnectionObserver& aIncomingConnectionObserver ); |
|
96 |
|
97 /** |
|
98 * Registers object to observe connection notifies. |
|
99 * |
|
100 * @since S60 v3.2 |
|
101 * @param aConnectionObserver Observer to be registered |
|
102 * @return void |
|
103 */ |
|
104 void RegisterConnectionObserverL( |
|
105 const MNcmConnectionObserver& aConnectionObserver ); |
|
106 |
|
107 /** |
|
108 * Removes object from observing connection notifies. |
|
109 * |
|
110 * @since S60 v3.2 |
|
111 * @param aConnectionObserver Message observer to be unregistered |
|
112 * @return void |
|
113 */ |
|
114 void UnregisterConnectionObserverL( |
|
115 const MNcmConnectionObserver& aConnectionObserver ); |
|
116 |
|
117 |
|
118 /** |
|
119 * Registers an observer for receive incoming and outgoing message |
|
120 * notifications. All notifications are offered first to this observer. |
|
121 * There can be only one registered observer at a time. |
|
122 * Message observer is allowed to make modifications to offered |
|
123 * messages. |
|
124 * |
|
125 * @since S60 v3.2 |
|
126 * @param aMessageObserver Message observer to be registered |
|
127 * @return void |
|
128 */ |
|
129 void RegisterMessageObserver( MNcmMessageObserver& aMessageObserver ); |
|
130 |
|
131 /** |
|
132 * Unregisters an observer for receiving incoming and outgoing message |
|
133 * notifications. |
|
134 * |
|
135 * @since S60 v3.2 |
|
136 * @param aMessageObserver Observer to be unregistered |
|
137 * @return void |
|
138 */ |
|
139 void UnregisterMessageObserver( |
|
140 const MNcmMessageObserver& aMessageObserver ); |
|
141 |
|
142 /** |
|
143 * Reveal incoming message for observing objects and see if they |
|
144 * consumed it |
|
145 * |
|
146 * @since S60 v3.2 |
|
147 * @param aStreamId The ID identifying stream |
|
148 * @param aMessage Message is a reference to heap buffer |
|
149 * which can be rewritten by message |
|
150 * observers |
|
151 * @param aLocalAddr A local address. |
|
152 * @param aFromAddr A remote source address. |
|
153 * @return ETrue if observer found message useful, |
|
154 * EFalse otherwise |
|
155 */ |
|
156 TBool RevealIncomingMessageL( TUint aStreamId, HBufC8 *&aMessage, |
|
157 const TInetAddr& aLocalAddr, const TInetAddr& aFromAddr ); |
|
158 |
|
159 /** |
|
160 * Reveal outgoing message for observing objects and see if they consumed |
|
161 * it |
|
162 * |
|
163 * @since S60 v3.2 |
|
164 * @param aStreamId The ID identifying stream |
|
165 * @param aConnectionId The ID identifying connection |
|
166 * @param aMessage Message is a reference to heap buffer |
|
167 * which can be rewritten by message |
|
168 * @param aDestinationAddress Destination address |
|
169 * @return ETrue if observer found message useful, |
|
170 * EFalse otherwise |
|
171 */ |
|
172 TBool RevealOutgoingMessageL( TUint aStreamId, TUint aConnectionId, |
|
173 HBufC8 *&aMessage, const TInetAddr& aDestinationAddress ); |
|
174 |
|
175 /** |
|
176 * Make notify to observing objects |
|
177 * it |
|
178 * |
|
179 * @since S60 v3.2 |
|
180 * @param aStreamId The ID identifying stream |
|
181 * @param aConnectionId The ID identifying connection |
|
182 * @param aType Type of notify |
|
183 * @param aError Error code |
|
184 * @return void |
|
185 */ |
|
186 void ConnectionNotify( TUint aStreamId, TUint aConnectionId, |
|
187 TMultiplexerConnectionNotifyType aType, TInt aError ); |
|
188 |
|
189 /** |
|
190 * Register media source |
|
191 * |
|
192 * @since S60 v3.2 |
|
193 * @param aMediaSource The media source |
|
194 * @return void |
|
195 */ |
|
196 void RegisterMediaSourceL( CNcmMediaSource* aMediaSource ); |
|
197 |
|
198 /** |
|
199 * Register media source observer |
|
200 * |
|
201 * @since S60 v3.2 |
|
202 * @param aMediaSourceObserver The media source observer |
|
203 * @return void |
|
204 */ |
|
205 void RegisterMediaSourceObserver( |
|
206 MNcmSourceObserver& aMediaSourceObserver ); |
|
207 |
|
208 /** |
|
209 * Unregister media source observer |
|
210 * |
|
211 * @since S60 v3.2 |
|
212 * @param aMediaSourceObserver The media source observer |
|
213 * @return void |
|
214 */ |
|
215 void UnregisterMediaSourceObserver( |
|
216 const MNcmSourceObserver& aMediaSourceObserver ); |
|
217 |
|
218 /** |
|
219 * Enables/disables receiving |
|
220 * |
|
221 * @since S60 v3.2 |
|
222 * @param aState The receiving state |
|
223 * @return void |
|
224 */ |
|
225 void SetReceivingState( TNATFWStreamingState aState ); |
|
226 |
|
227 private: |
|
228 |
|
229 CNcmConnectionObserverHandler(); |
|
230 |
|
231 TBool IsDuplicatePacket( const TDesC8& aMessage, TBool& aIsStunMessage ); |
|
232 |
|
233 private: // data |
|
234 |
|
235 /** |
|
236 * Messaging observers for outgoing connections |
|
237 */ |
|
238 RPointerArray<MNcmOutgoingConnectionObserver> iOutgoingObservers; |
|
239 |
|
240 /** |
|
241 * Messaging observers for incoming connections |
|
242 */ |
|
243 RPointerArray<MNcmIncomingConnectionObserver> iIncomingObservers; |
|
244 |
|
245 /** |
|
246 * Messaging observers for connection notifies. |
|
247 */ |
|
248 RPointerArray<MNcmConnectionObserver> iConnectionObservers; |
|
249 |
|
250 /** |
|
251 * Media source |
|
252 * Own. |
|
253 */ |
|
254 CNcmMediaSource* iMediaSource; |
|
255 |
|
256 /** |
|
257 * Message observer. |
|
258 * Not own. |
|
259 */ |
|
260 MNcmMessageObserver* iMessageObserver; |
|
261 |
|
262 /** |
|
263 * Hashes calculated from received packets. Used to filter replicated |
|
264 * packets. |
|
265 */ |
|
266 RArray<TUint> iLatestHashes; |
|
267 }; |
|
268 |
|
269 #endif // C_CNCMCONNECTIONOBSERVERHANDLER_H |