|
1 /** @file |
|
2 * Copyright (c) 2008-2008 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: Encapsulates http client for eventing |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CUPNPEVENTCONTROLLER_H |
|
21 #define C_CUPNPEVENTCONTROLLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32cmn.h> |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 |
|
28 #include "upnphttpclientengine.h" |
|
29 #include "upnphttptransaction.h" |
|
30 #include "upnpsubscriberlibraryelement.h" |
|
31 #include "upnpserviceimplementation.h" |
|
32 #include "upnpsubscriberlibraryobserver.h" |
|
33 |
|
34 |
|
35 // FORWARD DECLARATION |
|
36 class CUpnpEventQueueManagerBase; |
|
37 class CUpnpStateVariable; |
|
38 class CUpnpSubscriberLibrary; |
|
39 |
|
40 _LIT8(KGenaPropertyStart, |
|
41 "<e:property><"); |
|
42 _LIT8(KGenaPropertyEnd, |
|
43 "></e:property>"); |
|
44 _LIT8(KGenaPropertysetEnd, |
|
45 "</e:propertyset>"); |
|
46 _LIT8(KOpenBracket, "<"); |
|
47 _LIT8(KCloseBracket, ">"); |
|
48 _LIT8(KGenaXml, |
|
49 "<?xml version=\"1.0\" encoding=\"utf-8\"?>"); |
|
50 _LIT8(KGenaPropertysetStart, |
|
51 "<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">"); |
|
52 _LIT8( KYes, "yes" ); |
|
53 |
|
54 |
|
55 static const TInt KMessageTimeout = 5000000;//5 sec |
|
56 const TInt KMaxEventRate = 5000000; |
|
57 |
|
58 |
|
59 // CLASS DECLARATION |
|
60 /** |
|
61 * An interface to Subscriber Library. |
|
62 * |
|
63 * @since Series60 2.6 |
|
64 */ |
|
65 class MTransactionObserver |
|
66 { |
|
67 |
|
68 public: |
|
69 /** |
|
70 * A virtual function to be implemented in derived classes. |
|
71 * It is called after completed transaction |
|
72 * @param aComletedTransaction just completed transaction |
|
73 * @since Series60 3.2 |
|
74 */ |
|
75 virtual void TransactionCompletedL( CUpnpHttpTransaction* aCompletedTranscation ) = 0; |
|
76 |
|
77 }; |
|
78 |
|
79 |
|
80 |
|
81 /** |
|
82 * This class handles event releated issues |
|
83 * |
|
84 * |
|
85 * @since Series60 3.2 |
|
86 */ |
|
87 NONSHARABLE_CLASS( CUpnpEventController ): public CBase, |
|
88 public MUpnpHttpClientObserver, |
|
89 public MUpnpSubscriberLibraryObserver |
|
90 { |
|
91 public: |
|
92 // Constructors and destructor |
|
93 |
|
94 /** |
|
95 * Destructor. |
|
96 */ |
|
97 ~CUpnpEventController(); |
|
98 |
|
99 /** |
|
100 * Two-phased constructor. |
|
101 */ |
|
102 static CUpnpEventController* NewL( CUpnpServiceImplementation& aServiceImpl ); |
|
103 |
|
104 /** |
|
105 * Two-phased constructor. |
|
106 */ |
|
107 static CUpnpEventController* NewLC( CUpnpServiceImplementation& aServiceImpl ); |
|
108 |
|
109 public: |
|
110 /** |
|
111 * Sends inital event |
|
112 */ |
|
113 void SendInitialNotification( ); |
|
114 |
|
115 /** |
|
116 * Sends non-modereted event |
|
117 */ |
|
118 void SendNonModeratedNotification( ); |
|
119 |
|
120 /** |
|
121 * Sends moderated event |
|
122 */ |
|
123 void SendModeratedNotification(); |
|
124 |
|
125 /** |
|
126 * Sends message using httpclient |
|
127 * @param aTransaction encapsulated httpmessage with event |
|
128 */ |
|
129 void SendTransactionL( CUpnpHttpTransaction* aTranscation ); |
|
130 |
|
131 /** |
|
132 * Handle subscribe/resubscribe messages |
|
133 * @param aMessage http request |
|
134 */ |
|
135 void SubscribeL( CUpnpGenaMessage* aMessage ); |
|
136 |
|
137 /** |
|
138 * Handle unsubscribe messages |
|
139 * @param aMessage http request |
|
140 */ |
|
141 void UnSubscribeL( CUpnpGenaMessage* aMessage ); |
|
142 |
|
143 /** |
|
144 * Handle unsubscribe messages |
|
145 * @return TInt number of subscribers |
|
146 */ |
|
147 TInt SubscribersAmount(); |
|
148 |
|
149 |
|
150 /*from MUpnpHttpClientObserver*/ |
|
151 public: |
|
152 /** |
|
153 * Imlements completed transaction handling |
|
154 * @param comleted transaction |
|
155 */ |
|
156 void ClientResponseRecivedLD( CUpnpHttpTransaction& aEndedTransaction ); |
|
157 |
|
158 /*from MUpnpSubscriberLibraryObserver*/ |
|
159 public: |
|
160 |
|
161 /** |
|
162 * |
|
163 * @return all evented state variables |
|
164 */ |
|
165 RPointerArray<CUpnpStateVariable>& EventedStateVariables(); |
|
166 |
|
167 /** |
|
168 * Resume processing after removing subscriber |
|
169 * @param aSubscriber just removed subscriber |
|
170 * @param removed subscriber position in SubscriberLibrary |
|
171 */ |
|
172 void SubscriberRemoved( CUpnpSubscriberLibraryElement* aSubscriber ,TInt aPos ); |
|
173 |
|
174 private: |
|
175 |
|
176 /** |
|
177 * Constructor for performing 1st stage construction |
|
178 */ |
|
179 CUpnpEventController( CUpnpServiceImplementation& aServiceImpl ); |
|
180 |
|
181 /** |
|
182 * Constructor for performing 2nd stage construction |
|
183 */ |
|
184 void ConstructL(); |
|
185 |
|
186 |
|
187 private: |
|
188 /* |
|
189 * Cancel all pending transaction related wih particular subscriber |
|
190 * @param aSid SID uniqe subscriber id |
|
191 */ |
|
192 void CancelInvalidSessions( const TDesC8& aSid ); |
|
193 |
|
194 /* |
|
195 * Checks if unsubscribe message has all header |
|
196 * @param aMessage message to be checked |
|
197 * return validation status |
|
198 */ |
|
199 TUpnpErrorCode CheckHeaders( CUpnpGenaMessage* aMessage ); |
|
200 |
|
201 /* |
|
202 * Generates a SID number for given, new subscriber |
|
203 * @param aSubscriber new subscriber |
|
204 */ |
|
205 void GenerateSidL( CUpnpSubscriberLibraryElement* aSubscriber ); |
|
206 |
|
207 /* |
|
208 * Creates timeout header |
|
209 * @param aTimeout timeout value |
|
210 * @return header descriptor "Second-'aTimeout'" |
|
211 */ |
|
212 HBufC8* TimerHeaderLC( const TDesC8& aTimeout ); |
|
213 |
|
214 private: |
|
215 |
|
216 /** Http engine*/ |
|
217 CUpnpHttpClientEngine* iHttpEngine; //owned |
|
218 |
|
219 /** Store all pending transaction*/ |
|
220 RPointerArray<CUpnpHttpTransaction> iPendingTransactions; //owned |
|
221 |
|
222 |
|
223 CUpnpServiceImplementation& iServiceImpl; //not owned |
|
224 |
|
225 /**Non-moderated event queue manager */ |
|
226 CUpnpEventQueueManagerBase* iNonModQueue; //owned |
|
227 |
|
228 /**Moderated event queue manager */ |
|
229 CUpnpEventQueueManagerBase* iModQueue; //owned |
|
230 |
|
231 /**Initial event queue manager */ |
|
232 CUpnpEventQueueManagerBase* iInitialEventQueue; //owned |
|
233 |
|
234 /**Store information about subscribers*/ |
|
235 CUpnpSubscriberLibrary* iSubscriberLibrary; //owned |
|
236 }; |
|
237 |
|
238 #endif // C_CUPNPEVENTCONTROLLER_H |
|
239 //end of file |