|
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: Base class for event queue manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CUPNPEVENTQUEUEMANAGERBASE_H |
|
20 #define C_CUPNPEVENTQUEUEMANAGERBASE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 |
|
26 #include "upnphttptransaction.h" |
|
27 #include "upnpserviceimplementation.h" |
|
28 #include "upnpeventcontroller.h" |
|
29 #include "upnpsubscriberlibrary.h" |
|
30 |
|
31 |
|
32 const TInt KFirstSubscriberInQueue(0); |
|
33 |
|
34 |
|
35 // CLASS DECLARATION |
|
36 /** |
|
37 * UpnpNonModeratedEventQueueManager |
|
38 * |
|
39 */ |
|
40 NONSHARABLE_CLASS( CUpnpEventQueueManagerBase ): public CBase, public MTransactionObserver |
|
41 { |
|
42 public: |
|
43 // Constructors and destructor |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 ~CUpnpEventQueueManagerBase(); |
|
49 |
|
50 /** |
|
51 * Two-phased constructor |
|
52 * @param aServiceImpl |
|
53 * @param aEventController |
|
54 * $param aSubscriberLibrary |
|
55 */ |
|
56 static CUpnpEventQueueManagerBase * NewL( CUpnpServiceImplementation& aServiceImpl, |
|
57 CUpnpEventController& aEventController, |
|
58 CUpnpSubscriberLibrary* aSubscriberLibrary ); |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 * @param aServiceImpl |
|
63 * @param aEventController |
|
64 * $param aSubscriberLibrary |
|
65 */ |
|
66 static CUpnpEventQueueManagerBase * NewLC( CUpnpServiceImplementation& aServiceImpl, |
|
67 CUpnpEventController& aEventController, |
|
68 CUpnpSubscriberLibrary* aSubscriberLibrary ); |
|
69 |
|
70 public: |
|
71 /* |
|
72 * Trigers event sending, |
|
73 * has to be implemented in delivered class |
|
74 */ |
|
75 virtual void SendEvent() = 0; |
|
76 |
|
77 void UpdateQueue( TInt aPos ); |
|
78 |
|
79 |
|
80 /** from MTransactionObserver*/ |
|
81 public: |
|
82 |
|
83 void TransactionCompletedL( CUpnpHttpTransaction* aCompletedTranscation ); |
|
84 |
|
85 |
|
86 protected: |
|
87 |
|
88 /* |
|
89 * Finishes processing of the event sending queue |
|
90 */ |
|
91 void SendingCompleted(); |
|
92 |
|
93 /* |
|
94 * Sends the event to the next subscriber |
|
95 */ |
|
96 void SendToNextL(); |
|
97 |
|
98 /* |
|
99 * Prepares event message and sends it to given subscriber |
|
100 * @param aSubscriberNo subscriber's position on SubscribersLibrary list |
|
101 */ |
|
102 void PrepareTransactionAndStartSendingL( TInt aSubscriberNo ); |
|
103 |
|
104 /* |
|
105 * Removes subscriber form the SubscriberLibrary, |
|
106 * recognize it by SID releated with event message |
|
107 * @param aCompletedTransaction unsuccesfully completed transaction |
|
108 */ |
|
109 void RemoveInvalidSubscriber( CUpnpHttpTransaction* aCompletedTransacation ); |
|
110 |
|
111 /* |
|
112 * Creates xml message with all evented variables |
|
113 * @aparam aVariableList list with evented variables |
|
114 */ |
|
115 HBufC8* CreateEventL( const RPointerArray<CUpnpStateVariable>& aVariableList ); |
|
116 |
|
117 /* |
|
118 * Adds single variable to message body |
|
119 * @param aBufer message is appended to given buffer |
|
120 * @param aVariable variable which will be added to buffer |
|
121 */ |
|
122 void AddVariableToEventBody( TDes8& aBuffer , CUpnpStateVariable * aVariable ); |
|
123 |
|
124 /* |
|
125 * Clears evented variable list |
|
126 */ |
|
127 void ClearVariables(); |
|
128 |
|
129 /* |
|
130 * Creates event specyfic message, |
|
131 * has to be implemented in delivered class |
|
132 */ |
|
133 virtual TInt FillEventBodyL ( TDes8& aEvent, |
|
134 const RPointerArray<CUpnpStateVariable>& aVariableList ) = 0; |
|
135 |
|
136 /* |
|
137 * Encapsulates event message into http transaction |
|
138 * has to be implemented in delivered class |
|
139 */ |
|
140 virtual CUpnpHttpTransaction* CreateTransactionL( CUpnpHttpMessage* aMessage ) = 0; |
|
141 |
|
142 protected: |
|
143 |
|
144 /** |
|
145 * Constructor for performing 1st stage construction |
|
146 * @param aServiceImpl |
|
147 * @param aEventController |
|
148 * $param aSubscriberLibrary |
|
149 */ |
|
150 CUpnpEventQueueManagerBase ( CUpnpServiceImplementation& iServiceImpl, |
|
151 CUpnpEventController& iEventController, |
|
152 CUpnpSubscriberLibrary* aSubscriberLibrary ); |
|
153 |
|
154 /** |
|
155 * Constructor for performing 2st stage construction |
|
156 */ |
|
157 void BaseConstructL(); |
|
158 |
|
159 protected: |
|
160 |
|
161 /*Points the currently proccesed subscriber */ |
|
162 TInt iCurrentSubscriberIndex; //owned |
|
163 |
|
164 /*Current event message*/ |
|
165 HBufC8* iBody; // owned |
|
166 |
|
167 /*Status flag */ |
|
168 TBool iIsSending; |
|
169 |
|
170 /*Status flag*/ |
|
171 TBool iNewValuesWaitingToBeSend; //owned |
|
172 |
|
173 |
|
174 CUpnpServiceImplementation& iServiceImpl; //not owned |
|
175 |
|
176 CUpnpEventController& iEventController; //not owned |
|
177 |
|
178 CUpnpSubscriberLibrary* iSubscriberLibrary; //not owned |
|
179 }; |
|
180 |
|
181 #endif // C_CUPNPEVENTQUEUEMANAGERBASE_H |
|
182 //end of file |