|
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: An implementation class for receiving Mediator events. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef MEDIATOREVENTCONSUMERBODY_H |
|
19 #define MEDIATOREVENTCONSUMERBODY_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include "MediatorEventConsumer.h" |
|
24 #include "MediatorServerClient.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 |
|
28 |
|
29 // CLASS DECLARATION |
|
30 |
|
31 /** |
|
32 * A class used for receiving Mediator Service events. |
|
33 * |
|
34 * @lib MediatorClient.lib |
|
35 * @since S60 3.1 |
|
36 */ |
|
37 NONSHARABLE_CLASS(CMediatorEventConsumerBody) : public CActive |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 * |
|
44 * @param aObserver mediator event observer |
|
45 * @return a new CMediatorEventConsumerBody instance |
|
46 */ |
|
47 static CMediatorEventConsumerBody* NewL( |
|
48 MMediatorEventObserver* aObserver ); |
|
49 |
|
50 /** |
|
51 * Destructor. |
|
52 */ |
|
53 virtual ~CMediatorEventConsumerBody(); |
|
54 |
|
55 public: // Event subscribtion |
|
56 |
|
57 /** |
|
58 * Subscribe an event list. Raised events from the list will be |
|
59 * delivered via the observer interface. |
|
60 * |
|
61 * @since S60 3.1 |
|
62 * @param aDomain The identifier of the domain. |
|
63 * @param aCategory The identifier of the category. |
|
64 * @param aEvents The list of events. |
|
65 * @return TInt an error value. |
|
66 */ |
|
67 TInt SubscribeEvent( TUid aDomain, |
|
68 TUid aCategory, |
|
69 const REventList& aEvents ); |
|
70 |
|
71 /** |
|
72 * Subscribe an event. Raised events will be |
|
73 * delivered via the observer interface. |
|
74 * |
|
75 * @since S60 3.1 |
|
76 * @param aDomain The identifier of the domain. |
|
77 * @param aCategory The identifier of the category. |
|
78 * @param aEventId The identifier of the event. |
|
79 * @param aVersion Version information of the event |
|
80 * @return TInt an error value. |
|
81 */ |
|
82 TInt SubscribeEvent( TUid aDomain, |
|
83 TUid aCategory, |
|
84 TInt aEventId, |
|
85 TVersion aVersion ); |
|
86 |
|
87 /** |
|
88 * Unsubscribe event list. |
|
89 * |
|
90 * @since S60 3.1 |
|
91 * @param aDomain The identifier of the domain. |
|
92 * @param aCategory The identifier of the category. |
|
93 * @param aEvents The list of events |
|
94 * @return TInt an error value. |
|
95 */ |
|
96 TInt UnsubscribeEvent( TUid aDomain, |
|
97 TUid aCategory, |
|
98 const REventList& aEvents ); |
|
99 |
|
100 /** |
|
101 * Unsubscribe an event. |
|
102 * |
|
103 * @since S60 3.1 |
|
104 * @param aDomain The identifier of the domain. |
|
105 * @param aCategory The identifier of the category. |
|
106 * @param aEventId The identifier of the event. |
|
107 * @return TInt an error value. |
|
108 */ |
|
109 TInt UnsubscribeEvent( TUid aDomain, |
|
110 TUid aCategory, |
|
111 TInt aEventId ); |
|
112 |
|
113 private: // From CActive |
|
114 |
|
115 /** |
|
116 * From CActive::RunL |
|
117 */ |
|
118 void RunL(); |
|
119 |
|
120 /** |
|
121 * From CActive::DoCancel() |
|
122 */ |
|
123 void DoCancel(); |
|
124 |
|
125 private: // New functions |
|
126 |
|
127 /** |
|
128 * Starts event receiving. |
|
129 * |
|
130 * @since S60 3.1 |
|
131 * @return none. |
|
132 */ |
|
133 void StartEventReceiving(); |
|
134 |
|
135 /** |
|
136 * Re-init return data buffer |
|
137 * |
|
138 * @since S60 3.1 |
|
139 * @param aSize size of the buffer |
|
140 * @return None. |
|
141 */ |
|
142 void ResetDataBufferL( TInt aSize ); |
|
143 |
|
144 private: |
|
145 |
|
146 /** |
|
147 * C++ default constructor. |
|
148 * |
|
149 * @param aObserver mediator event observer |
|
150 */ |
|
151 CMediatorEventConsumerBody( MMediatorEventObserver* aObserver ); |
|
152 |
|
153 /** |
|
154 * By default Symbian 2nd phase constructor is private. |
|
155 */ |
|
156 void ConstructL(); |
|
157 |
|
158 private: // Data |
|
159 |
|
160 // A session class to mediator server |
|
161 RMediatorServer iMediatorServer; |
|
162 |
|
163 // Observer for event callbacks (not owned) |
|
164 MMediatorEventObserver* iObserver; |
|
165 |
|
166 // Domain/Category cata for incoming event |
|
167 TMediatorCategory iCategory; |
|
168 TMediatorCategoryRetBuffer iCategoryBuffer; |
|
169 |
|
170 // Event Id data |
|
171 MediatorService::TEvent iEvent; |
|
172 TEventRetBuffer iEventBuffer; |
|
173 |
|
174 // Event data to be received |
|
175 HBufC8* iEventData; |
|
176 // Pointer to event data. |
|
177 TPtr8 iEventDataPtr; |
|
178 |
|
179 // Stores information whether destructor has been called, checked in RunL |
|
180 TBool* iDestroyed; |
|
181 |
|
182 }; |
|
183 |
|
184 #endif // MEDIATOREVENTCONSUMERBODY_H |
|
185 |
|
186 // End of File |