|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: defines MessageHandlerSession class |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_CUPNPMESSAGEHANDLERSESSION_H |
|
19 #define C_CUPNPMESSAGEHANDLERSESSION_H |
|
20 |
|
21 // INCLUDES |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "upnpmessagehandler.h" |
|
26 #include "upnpcommonstructs.h" |
|
27 #include "upnpmhcommon.h" |
|
28 #include "upnpmessagehandlerobserver.h" |
|
29 |
|
30 static const TInt KMaxUuidLength=43; |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 class CUpnpHttpMessage; |
|
34 class MMessageHandlerObserver; |
|
35 class CUpnpMessageHandler; |
|
36 class CUpnpMessageHandlerEngine; |
|
37 |
|
38 #ifdef RD_UPNP_REMOTE_ACCESS |
|
39 class CUpnpIPFiltering; |
|
40 #endif |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 An instance of class CUpnpMessageHandlerSession is created for each client |
|
46 */ |
|
47 |
|
48 class CUpnpMessageHandlerSession : public CSession2, |
|
49 public MMessageHandlerObserver |
|
50 { |
|
51 |
|
52 public: |
|
53 // New methods |
|
54 |
|
55 /** |
|
56 Create a CUpnpMessageHandlerSession object using two phase construction, |
|
57 and return a pointer to the created object |
|
58 @param aClient client's thread |
|
59 @param aServer the message handler server |
|
60 @param aEngine the message handler engine |
|
61 @param aHandle the message handler thread log handle |
|
62 @result pointer to new session |
|
63 */ |
|
64 static CUpnpMessageHandlerSession* NewL( CUpnpMessageHandler& aServer, |
|
65 CUpnpMessageHandlerEngine& aEngine ); |
|
66 |
|
67 /** |
|
68 Create a CUpnpMessageHandlerSession object using two phase construction, |
|
69 and return a pointer to the created object |
|
70 (leaving a pointer to the object on the cleanup stack) |
|
71 @param aClient client's thread |
|
72 @param aServer the message handler server |
|
73 @param anEngine the message handler engine |
|
74 @param aHandle the message handler thread log handle |
|
75 @result pointer to new session |
|
76 */ |
|
77 static CUpnpMessageHandlerSession* NewLC( CUpnpMessageHandler& aServer, |
|
78 CUpnpMessageHandlerEngine& anEngine ); |
|
79 |
|
80 /** |
|
81 Destroy the object and release all memory objects |
|
82 */ |
|
83 virtual ~CUpnpMessageHandlerSession(); |
|
84 |
|
85 /** |
|
86 Callback method |
|
87 @result None |
|
88 */ |
|
89 void DeviceListChangeL(); |
|
90 |
|
91 /** |
|
92 Cancells outstanding requests |
|
93 @result None |
|
94 */ |
|
95 void CancelPendingRequests(); |
|
96 |
|
97 public: |
|
98 // From CSession |
|
99 TInt EventStartSsdpL(); |
|
100 |
|
101 /** |
|
102 Called after a service request from client; from class CSession |
|
103 @param aMessage message from client (containing requested operation and any data) |
|
104 @result None. |
|
105 */ |
|
106 void ServiceL( const RMessage2& aMessage ); |
|
107 |
|
108 private: |
|
109 // New methods |
|
110 |
|
111 /** |
|
112 Is Ssdp stateted ? |
|
113 */ |
|
114 void EventCheckErrorL( const RMessage2& aMessage ); |
|
115 |
|
116 /** |
|
117 Perform the first phase of two phase construction |
|
118 @param aServer the message handler server |
|
119 @param aEngine the message handler engine |
|
120 @param aHandle the message handler thread log handle |
|
121 @result None. |
|
122 */ |
|
123 CUpnpMessageHandlerSession( CUpnpMessageHandler& aServer, |
|
124 CUpnpMessageHandlerEngine& anEngine ); |
|
125 |
|
126 /** |
|
127 Perform the second phase construction of a CUpnpMessageHandlerSession object |
|
128 @result None. |
|
129 */ |
|
130 void ConstructL(); |
|
131 |
|
132 /** |
|
133 Causes the client thread to panic |
|
134 @param panic code |
|
135 */ |
|
136 void PanicClient( const RMessage2& aMessage, TInt aPanic ) const; |
|
137 |
|
138 private: |
|
139 |
|
140 // functions for various events from client |
|
141 |
|
142 /** |
|
143 This function is called when a dispatcher has requested that a local device |
|
144 should be added to the device library. |
|
145 @param aMessage The inter-process message we've got |
|
146 @result None. |
|
147 */ |
|
148 void EventAddLocalDeviceL( const RMessage2& aMessage ); |
|
149 |
|
150 /** |
|
151 This function is called when a dispatcher has requested that a local device |
|
152 should be removed from the device library. |
|
153 @param aMessage The inter-process message we've got |
|
154 @result None. |
|
155 */ |
|
156 void EventRemoveLocalDeviceL( const RMessage2& aMessage, TBool aSilent ); |
|
157 |
|
158 /** |
|
159 This function is called when a dispatcher has requested that a local control point |
|
160 should be added. |
|
161 */ |
|
162 void EventAddLocalControlPoint( const RMessage2& aMessage ); |
|
163 |
|
164 /** |
|
165 This function is called when a dispatcher has requested that a local control point |
|
166 should be removed. |
|
167 */ |
|
168 void EventRemoveLocalControlPoint( const RMessage2& aMessage ); |
|
169 |
|
170 /** |
|
171 This function is called when a dispatcher has requested that device notifications |
|
172 should not be filtered by ssdp server. |
|
173 */ |
|
174 void EventStopFilteringDeviceL( const RMessage2& aMessage ); |
|
175 |
|
176 /** |
|
177 This function is called when a dispatcher has requested that it would like |
|
178 to get a list of updated devices. This is the second phase of device list update. |
|
179 @param aMessage The inter-process message we've got |
|
180 @result None. |
|
181 */ |
|
182 void EventGetDeviceListL( const RMessage2& aMessage ); |
|
183 |
|
184 /** |
|
185 This function is called when a dispatcher has requested that it would like |
|
186 to get the actual list of updated devices; this is the first phase of device |
|
187 list update. |
|
188 @param aMessage The inter-process message we've got |
|
189 @result None. |
|
190 */ |
|
191 void EventGetDeviceListSizeL( const RMessage2& aMessage ); |
|
192 |
|
193 /** |
|
194 This function is called when a dispatcher has requested that it would like |
|
195 to get the id of the active iap. |
|
196 @param aMessage The inter-process message we've got |
|
197 @result None. |
|
198 */ |
|
199 void EventActiveIapL( const RMessage2& aMessage ) const; |
|
200 |
|
201 /** |
|
202 This function is called when a dispatcher has requested that a ssdp search should be done. |
|
203 @param aMessage The inter-process message we've got |
|
204 @result None. |
|
205 */ |
|
206 void EventSsdpSearchL( const RMessage2& aMessage ); |
|
207 |
|
208 void CompletePendingRequest(); |
|
209 |
|
210 void CopyMessage( RMessage2& aMessage ); |
|
211 |
|
212 void EventAddFilterAddrByIpL( const RMessage2& aMessage ); |
|
213 void EventAddFilterAddrByHostnameL( const RMessage2& aMessage ); |
|
214 void EventRemoveFilterAddrByIpL( const RMessage2& aMessage ); |
|
215 void EventRemoveFilterAddrByHostnameL( const RMessage2& aMessage ); |
|
216 void EventRemoveAllIPsAddressesL( const RMessage2& aMessage ); |
|
217 TBool EventIsIPAddressAllowedL( const RMessage2& aMessage ); |
|
218 void EventSubscriveIPListChanges( RMessage2& aMessage ); |
|
219 void EventCancelIPListSubscription( const RMessage2& aMessage ); |
|
220 void EventGetIPFilterListL( const RMessage2& aMessage ); |
|
221 void IPListChange();//from observer |
|
222 |
|
223 private: |
|
224 |
|
225 /* @var iAwaitingUpdateDevices This pointer is used temporarily during device list updates */ |
|
226 TUpnpDevice* iAwaitingUpdateDevices; |
|
227 |
|
228 /* @var iAwaitingUpdateServices This pointer is used temporarily during device list updates */ |
|
229 TUpnpService* iAwaitingUpdateServices; |
|
230 |
|
231 /* @var iSize A variable that is used temporarily during device list updates */ |
|
232 TUpnpGetDeviceListSize iSize; |
|
233 |
|
234 /* @var iServer Reference to the server (message handler) */ |
|
235 CUpnpMessageHandler& iMessageHandler; |
|
236 |
|
237 /* @var iEngine Reference to the message handler engine */ |
|
238 CUpnpMessageHandlerEngine& iEngine; |
|
239 |
|
240 // @var iDeviceListSizeMessage Reference to a DeviceListSizeMessage used for responding as device list is updated. |
|
241 // IMPORTANT: This variable is not owned by this module |
|
242 RMessage2 iDeviceListSizeMessage; |
|
243 |
|
244 #ifdef RD_UPNP_REMOTE_ACCESS |
|
245 /*******IPFiltering*************/ |
|
246 RMessage2 iIPListSizeMessage; |
|
247 TInt iSeqNo; |
|
248 /*******************************/ |
|
249 #endif |
|
250 |
|
251 TBool iMoreNewDevices; |
|
252 TBool iDeviceListSizeRequested; |
|
253 TInt iOldId; |
|
254 |
|
255 /* @var iAddedDevices Devices that have been added thru this Message Handler session. If the session |
|
256 is disconnected, devices added thru this session are also removed. This array contains the UUIDs |
|
257 of devices added. */ |
|
258 CDesC8ArrayFlat iAddedDevices; |
|
259 }; |
|
260 |
|
261 #endif // C_CUPNPMESSAGEHANDLERSESSION_H |