|
1 /* |
|
2 * Copyright (c) 2004 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: Event notifier implementation base |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CIMPSCONNUIPRESEVENTNOTIFIERIMPBASE_H |
|
19 #define __CIMPSCONNUIPRESEVENTNOTIFIERIMPBASE_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <E32Base.h> |
|
23 #include <impspresenceconnectionuiconstsng.h> |
|
24 #include <PEngPresenceEngineConsts2.h> |
|
25 #include "RGenericObserverArray.h" |
|
26 |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class MIMPSConnUiPresenceEventObserver; |
|
30 class CIMPSConnUiPresEventNotifier; |
|
31 class CIMPSConnUiPresEventNotifierImpBase; |
|
32 class CPEngNWSessionSlotID2; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 /** |
|
36 * CIMPSConnUiPresEventNotifierImpBase. |
|
37 * Implements the event notifier |
|
38 * base features. |
|
39 * |
|
40 * @since 2.1 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CIMPSConnUiPresEventNotifierImpBase ) : |
|
43 public CBase, |
|
44 public MGenObserverNotifyMediator < MIMPSConnUiPresenceEventObserver, |
|
45 TIMPSPresenceServiceEvent > |
|
46 { |
|
47 public: //destructor. |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 * Concrete implementation object can be |
|
52 * destroyed using base class. |
|
53 */ |
|
54 ~CIMPSConnUiPresEventNotifierImpBase(); |
|
55 |
|
56 protected: //constructor. |
|
57 |
|
58 /** |
|
59 * C++ constructor. |
|
60 * Takes a reference to implemented interface. |
|
61 * This interface is givent to notified observers. |
|
62 * |
|
63 * @param aInterface The implemented interface. |
|
64 * No ownership taken. |
|
65 */ |
|
66 CIMPSConnUiPresEventNotifierImpBase( CIMPSConnUiPresEventNotifier& aInterface ); |
|
67 |
|
68 |
|
69 public: //Implementation methods for public APIs |
|
70 |
|
71 /** |
|
72 * Implements notify start. |
|
73 * |
|
74 * Implements notify start by making sanity checks |
|
75 * for internal state and calling the virtual template |
|
76 * method DoStartL() to issue real notification. |
|
77 * |
|
78 * StartL() traps internally the DoStartL() call and |
|
79 * if the DoStartL() leaves, the partly constructed |
|
80 * notification service is stopped by calling DoStop(). |
|
81 * |
|
82 * Starting fails if: |
|
83 * - already started |
|
84 * - no observers registered |
|
85 * @since 2.1 |
|
86 */ |
|
87 void StartL(); |
|
88 |
|
89 |
|
90 /** |
|
91 * Implements notify stop. |
|
92 * |
|
93 * If notifier isn't running, does nothing. |
|
94 * If notifier is running, calls the virtual |
|
95 * template method DoStop() to stop the |
|
96 * real notify service. |
|
97 * |
|
98 * @since 2.1 |
|
99 */ |
|
100 void Stop(); |
|
101 |
|
102 |
|
103 /** |
|
104 * Implements add observer. |
|
105 * |
|
106 * @since 2.1 |
|
107 * @param aObserver The observer to add. |
|
108 */ |
|
109 void AddObserverL( MIMPSConnUiPresenceEventObserver* aObserver ); |
|
110 |
|
111 |
|
112 /** |
|
113 * Implements remove observer. |
|
114 * |
|
115 * @since 2.1 |
|
116 * @param aObserver The observer to remove. |
|
117 * @return KErrNone if observer was found, else KErrNotFound. |
|
118 */ |
|
119 TInt RemoveObserver( MIMPSConnUiPresenceEventObserver* aObserver ); |
|
120 |
|
121 |
|
122 /** |
|
123 * Virtual template method to implement service status get. |
|
124 * |
|
125 * @since 2.1 |
|
126 * @return Current service status as application level enumeration. |
|
127 */ |
|
128 virtual const CPEngNWSessionSlotID2* AppServiceStatusL( |
|
129 TIMPSConnectionClient aClient ) = 0; |
|
130 |
|
131 |
|
132 |
|
133 protected: // Template methods for derived implementations |
|
134 |
|
135 /** |
|
136 * Virtual template method to implement |
|
137 * real notify start. |
|
138 * |
|
139 * This method implementation must |
|
140 * requested notification from |
|
141 * all qiven PEC presence events. |
|
142 * |
|
143 * @see CIMPSConnUiPresEventNotifierImp |
|
144 * @see CIMPSConnUiClntFilteredEventNotifierImp |
|
145 * @since 2.1 |
|
146 * |
|
147 * @param aEvents The events where from to |
|
148 * get notifications |
|
149 */ |
|
150 virtual void DoStartL( const TArray<TPEngNWSessionSlotEvent>& aEvents ) = 0; |
|
151 |
|
152 |
|
153 /** |
|
154 * Virtual template method to implement |
|
155 * real notify stop. |
|
156 * |
|
157 * This method implementation must |
|
158 * cancel any previous notification request. |
|
159 * |
|
160 * @see CIMPSConnUiPresEventNotifierImp |
|
161 * @see CIMPSConnUiClntFilteredEventNotifierImp |
|
162 * @since 2.1 |
|
163 */ |
|
164 virtual void DoStop() = 0; |
|
165 |
|
166 |
|
167 |
|
168 protected: // Helper methods for derived implementations |
|
169 |
|
170 /** |
|
171 * This must be called in derived notifier |
|
172 * implementations at the beginning of their |
|
173 * destructor. |
|
174 * |
|
175 * Sets the dying flag on (prevents further starting the |
|
176 * notifier and error and event notifying) Stops the notifier |
|
177 * if running. |
|
178 * |
|
179 * @since 2.1 |
|
180 */ |
|
181 void Dying(); |
|
182 |
|
183 |
|
184 /** |
|
185 * Notifies registered observers from given presence event. |
|
186 * If notifier isn't running, |
|
187 * ignores given presence event. |
|
188 * |
|
189 * @since 2.1 |
|
190 * @param aEvent The event to notify. |
|
191 */ |
|
192 void NotifyObserversFromEvent( const CPEngNWSessionSlotID2& aSessionSlotID, |
|
193 TIMPSConnectionClient aClient, |
|
194 TIMPSPresenceServiceEvent aEvent ); |
|
195 |
|
196 |
|
197 /** |
|
198 * Notifies registered observers from given error. |
|
199 * |
|
200 * If notifier isn't running, ignores given error. |
|
201 * |
|
202 * Before notifying the error, |
|
203 * the notifier.is stopped. (Client can restart |
|
204 * the notifier in the error callback.) |
|
205 * |
|
206 * @since 2.1 |
|
207 * @param aError The error to report. |
|
208 */ |
|
209 void StopAndNotifyObserversFromError( TInt aError ); |
|
210 |
|
211 |
|
212 |
|
213 private: //Notify mediators from MGenObserverNotifyMediator |
|
214 |
|
215 /** |
|
216 * Implements the observer notification. |
|
217 * |
|
218 * @since 2.1 |
|
219 * @param The observer to notify. |
|
220 * @param aNotifyData The structure holding notify data. |
|
221 */ |
|
222 void MediateNotifyL( MIMPSConnUiPresenceEventObserver& aObserverToNotify, |
|
223 TIMPSPresenceServiceEvent& aNotifyData ); |
|
224 |
|
225 |
|
226 /** |
|
227 * Observer notification from error. |
|
228 * |
|
229 * @since 2.1 |
|
230 * @param aObserverToNotify The notified observer which leaved. |
|
231 * @param aLeaveError The propagated leave code. |
|
232 */ |
|
233 void MediateNotifyError( MIMPSConnUiPresenceEventObserver& aObserverToNotify, |
|
234 TInt aLeaveError ); |
|
235 |
|
236 /** |
|
237 * Observer notification from error. |
|
238 * |
|
239 * @since 2.1 |
|
240 * @param aObserverToNotify The notified observer which leaved. |
|
241 * @param aLeaveError The propagated leave code. |
|
242 */ |
|
243 void MediateError( MIMPSConnUiPresenceEventObserver& aObserverToNotify, |
|
244 TInt aError ); |
|
245 |
|
246 private: //Data |
|
247 |
|
248 ///< Reference to owning interface, interface not owned |
|
249 CIMPSConnUiPresEventNotifier& iInterface; |
|
250 |
|
251 ///< Observer array, array owned, observers not |
|
252 RGenericObserverArray < MIMPSConnUiPresenceEventObserver, |
|
253 TIMPSPresenceServiceEvent > iObserverArray; |
|
254 |
|
255 |
|
256 CPEngNWSessionSlotID2* iSessionSlotID; |
|
257 TIMPSConnectionClient iClient; |
|
258 ///< Flags describing the notifier state, owned |
|
259 ///< Flag contents are either EFalse or ETrue |
|
260 TInt8 iStarted; |
|
261 TInt8 iDying; |
|
262 TInt8 iReserved1; |
|
263 TInt8 iReserved2; |
|
264 |
|
265 }; |
|
266 |
|
267 #endif //__CIMPSCONNUIPRESEVENTNOTIFIERIMPBASE_H |
|
268 // End of File |
|
269 |
|
270 |