|
1 /* |
|
2 * Copyright (c) 2005 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 CMCEEVENT_H |
|
22 #define CMCEEVENT_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <mcedefs.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CDesC8Array; |
|
30 class TMceIds; |
|
31 class CMceItcSender; |
|
32 class CMceManager; |
|
33 class CMceEventReceiver; |
|
34 class CMceMsgBase; |
|
35 class TMceEvent; |
|
36 class CMceSession; |
|
37 class CMceRefer; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Base class for MCE events, inherited by both CMceInEvent and CMceOutEvent. |
|
43 * |
|
44 * CMceEvent represents peer-to-peer connection made with remote terminal. |
|
45 * This connection is also known as dialog and it is set up using SIP SUBSCRIBE |
|
46 * method. |
|
47 * |
|
48 * MCE events are typically used for queurying state of some parameter of |
|
49 * remote terminal. The queuried parameter is known as event header. |
|
50 * The changes of this parameter are notified to another terminal by sending |
|
51 * SIP NOTIFY messages. |
|
52 * |
|
53 * The event can be finally terminated by either endpoints. |
|
54 * |
|
55 * If for any reason instance of this class is deleted while in active state, |
|
56 * event is automatically terminated by MCE server. |
|
57 * |
|
58 * @lib mceclient.lib |
|
59 */ |
|
60 class CMceEvent : public CBase |
|
61 { |
|
62 public: // Event states |
|
63 |
|
64 enum TState |
|
65 { |
|
66 EIdle, |
|
67 EPending, |
|
68 EActive, |
|
69 ETerminated |
|
70 }; |
|
71 |
|
72 public: // Constructors and destructors |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 virtual ~CMceEvent(); |
|
78 |
|
79 public: // New functions |
|
80 |
|
81 /** |
|
82 * Terminates the event. |
|
83 * @pre State() == CMceEvent::EActive |
|
84 * @post State() == CMCEvent::EPending |
|
85 * @param aHeaders, additional headers of the message. |
|
86 * The Ownership is transferred. |
|
87 * @param aContentType, the type of the message content. |
|
88 * The ownership is transferred. |
|
89 * @param aContent, the content to be added in the message body. |
|
90 * The ownership is transferred. |
|
91 * @leave KErrNotSupported if event cannot be terminated |
|
92 * (e.g. event attached to a CMceOutRefer) |
|
93 */ |
|
94 IMPORT_C void TerminateL( |
|
95 CDesC8Array* aHeaders = 0, |
|
96 HBufC8* aContentType = 0, |
|
97 HBufC8* aContent = 0 ); |
|
98 |
|
99 /** |
|
100 * Returns the state of the event. |
|
101 * @return The current state of the event |
|
102 */ |
|
103 IMPORT_C TState State() const; |
|
104 |
|
105 /** |
|
106 * Returns the address of the recipient |
|
107 * @return The the address of the recipient |
|
108 */ |
|
109 IMPORT_C const TDesC8& Recipient() const; |
|
110 |
|
111 /** |
|
112 * Returns the address of the originator |
|
113 * @return the address of the Originator |
|
114 */ |
|
115 IMPORT_C const TDesC8& Originator() const; |
|
116 |
|
117 /** |
|
118 * Returns the Event header. |
|
119 * @return the Event header |
|
120 */ |
|
121 IMPORT_C const TDesC8& EventHeader() const; |
|
122 |
|
123 /** |
|
124 * Returns the associated session, if any. |
|
125 * @return CMceSession Associated session, NULL if does not exist. |
|
126 */ |
|
127 IMPORT_C CMceSession* AssociatedSession() const; |
|
128 |
|
129 /** |
|
130 * Returns the associated events, if any. |
|
131 * @return RPointerArray array of associated events, ownership is transferred. |
|
132 */ |
|
133 IMPORT_C RPointerArray< CMceEvent >* AssociatedEventsL() const; |
|
134 |
|
135 /** |
|
136 * Returns the associated refers, if any. |
|
137 * @return RPointerArray array of associated refers, ownership is transferred. |
|
138 */ |
|
139 IMPORT_C RPointerArray< CMceRefer >* AssociatedRefersL() const; |
|
140 |
|
141 public: // New functions, internal |
|
142 |
|
143 /** |
|
144 * ID |
|
145 * @return ID |
|
146 */ |
|
147 TUint32 Id() const; |
|
148 |
|
149 /** |
|
150 * Dialog ID |
|
151 * @return dialog ID |
|
152 */ |
|
153 TUint32 DialogId() const; |
|
154 |
|
155 /** |
|
156 * Gets SIP profile id. |
|
157 * @return profile id. |
|
158 */ |
|
159 TUint32 ProfileId() const; |
|
160 |
|
161 /** |
|
162 * Gets sender for ITC. |
|
163 * @return ITC sender |
|
164 */ |
|
165 CMceItcSender& ITCSender(); |
|
166 |
|
167 /** |
|
168 * Gets manager |
|
169 * @return manager |
|
170 */ |
|
171 CMceManager& Manager(); |
|
172 |
|
173 /** |
|
174 * Gets the type of the event |
|
175 * @return ETrue in InEvent |
|
176 */ |
|
177 virtual TBool IsInEvent() const = 0; |
|
178 |
|
179 |
|
180 public: // New functions, event handling |
|
181 |
|
182 /** |
|
183 * Handles reception of event update |
|
184 * @param aId id of object whose state is needed to be updated |
|
185 */ |
|
186 void EventReceivedL( TMceIds& aId ); |
|
187 |
|
188 /** |
|
189 * Handles reception of event update |
|
190 * @param aId id of object whose state is needed to be updated |
|
191 * @param aMessage the message |
|
192 */ |
|
193 void EventReceivedL( TMceIds& aId, CMceMsgBase& aMessage ); |
|
194 |
|
195 /** |
|
196 * Handles reception of event update |
|
197 * @param aId id of object whose state is needed to be updated |
|
198 * @param aMessage the message |
|
199 * @param aContent the content |
|
200 */ |
|
201 void EventReceivedL( TMceIds& aId, CMceMsgBase& aMessage, HBufC8* aContent ); |
|
202 |
|
203 /** |
|
204 * Handling of error |
|
205 * @param aError the error |
|
206 */ |
|
207 void ErrorOccuredL( TInt aError ); |
|
208 |
|
209 protected: // New functions |
|
210 |
|
211 /** |
|
212 * C++ default constructor. |
|
213 * @param aManager, reference to event manager. |
|
214 * @param aProfileId, id of the sip profile used for the event. |
|
215 * @param aDialogId, |
|
216 * @param aRefreshInterval, |
|
217 */ |
|
218 CMceEvent( CMceManager& aManager, |
|
219 TUint32 aProfileId, |
|
220 TUint32 aDialogId, |
|
221 TUint32 aRefreshInterval ); |
|
222 |
|
223 /** |
|
224 * Prepares ids for ITC |
|
225 * @param aId ITC ids |
|
226 */ |
|
227 void PrepareForITC( TMceIds& aId ); |
|
228 |
|
229 /** |
|
230 * second-phase constructor |
|
231 * @param aEventHeader |
|
232 * @param aRecipient |
|
233 * @param aOriginator |
|
234 * @param aDialogType |
|
235 */ |
|
236 void ConstructL( HBufC8* aEventHeader, |
|
237 HBufC8* aRecipient, |
|
238 HBufC8* aOriginator, |
|
239 TUint32 aDialogType, |
|
240 CDesC8Array* aParams ); |
|
241 |
|
242 |
|
243 private: // New functions, event handling and update |
|
244 |
|
245 /** |
|
246 * Traversal event handler |
|
247 * @param aEvent the event |
|
248 */ |
|
249 void EventReceivedL( TMceEvent& aEvent ); |
|
250 |
|
251 /** |
|
252 * Handles event |
|
253 * @param aEvent the event |
|
254 */ |
|
255 void HandleEventL( TMceEvent& aEvent ); |
|
256 |
|
257 protected: // Data |
|
258 |
|
259 // current event state |
|
260 TState iState; |
|
261 |
|
262 /** |
|
263 * Sender, owned |
|
264 */ |
|
265 CMceItcSender* iSender; |
|
266 |
|
267 /** |
|
268 * Event receiver, owned |
|
269 */ |
|
270 CMceEventReceiver* iReceiver; |
|
271 |
|
272 /** |
|
273 * Event manager,not owned |
|
274 */ |
|
275 CMceManager& iManager; |
|
276 |
|
277 /** |
|
278 * SIP profile id |
|
279 */ |
|
280 TUint32 iProfileId; |
|
281 |
|
282 /** |
|
283 * ID |
|
284 */ |
|
285 TUint32 iId; |
|
286 |
|
287 /** |
|
288 * dialog id |
|
289 */ |
|
290 TUint32 iDialogId; |
|
291 |
|
292 /** |
|
293 * The event header |
|
294 */ |
|
295 HBufC8* iEventHeader; |
|
296 |
|
297 /** |
|
298 * The recipient |
|
299 */ |
|
300 HBufC8* iRecipient; |
|
301 |
|
302 /** |
|
303 * The originator |
|
304 */ |
|
305 HBufC8* iOriginator; |
|
306 |
|
307 /** |
|
308 * The refresh interval |
|
309 */ |
|
310 TUint32 iRefreshInterval; |
|
311 |
|
312 private: // Reserved for future use |
|
313 |
|
314 TAny* iReserved; |
|
315 |
|
316 MCE_UNIT_TEST_DEFS |
|
317 |
|
318 }; |
|
319 |
|
320 #endif |