|
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: Notifier API to listen NWSessionSlot changes. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CPENGNWSESSIONSLOTNOTIFIER2_H |
|
19 #define __CPENGNWSESSIONSLOTNOTIFIER2_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <E32Base.h> |
|
23 #include <PEngPresenceEngineConsts2.h> |
|
24 |
|
25 |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MPEngNWSessionSlotObserver2; |
|
29 class CPEngNWSessionSlotNotifier2Imp; |
|
30 class CPEngNWSessionSlotID2; |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 // CLASS DECLARATION |
|
36 /** |
|
37 * Notifier to receive notifications from |
|
38 * NWSessionSlot events and state changes. |
|
39 * |
|
40 * Notifies from: |
|
41 * - creation / removal of NWSessionSlots |
|
42 * - individual NWSessionSlots events |
|
43 * |
|
44 * For full list of notified events, |
|
45 * see TPEngNWSessionSlotEvent enumeration. |
|
46 * |
|
47 * @lib PEngManager2.lib |
|
48 * @since 3.0 |
|
49 */ |
|
50 class CPEngNWSessionSlotNotifier2 : public CBase |
|
51 { |
|
52 |
|
53 //----------------------------------------------------------------------- |
|
54 public: /* Construction */ |
|
55 |
|
56 /** |
|
57 * Instantiates NWSessionSlotNotifier object. |
|
58 * |
|
59 * Instantiates NWSessionSlotNotifier object and connects it to |
|
60 * PresenceEngine subsystem. If needed PresenceEngine servers |
|
61 * aren't yet running, starts those before returning. |
|
62 * |
|
63 * @param aPriority The priority for |
|
64 * CPEngNWSessionSlotNotifier2 client side active objects. |
|
65 * These active objects are used asynhronously deliver |
|
66 * events to observers. |
|
67 * |
|
68 * @return New CPEngNWSessionSlotNotifier2 instance. |
|
69 */ |
|
70 IMPORT_C static CPEngNWSessionSlotNotifier2* NewL( |
|
71 TInt aPriority = CActive::EPriorityStandard ); |
|
72 |
|
73 IMPORT_C static CPEngNWSessionSlotNotifier2* NewLC( |
|
74 TInt aPriority = CActive::EPriorityStandard ); |
|
75 |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 * Virtual by CBase. |
|
80 * |
|
81 * Destruction |
|
82 * - stops automaticly event notification |
|
83 * - unregisters observers |
|
84 */ |
|
85 ~CPEngNWSessionSlotNotifier2(); |
|
86 |
|
87 |
|
88 private: |
|
89 |
|
90 CPEngNWSessionSlotNotifier2(); |
|
91 |
|
92 |
|
93 |
|
94 //----------------------------------------------------------------------- |
|
95 public: /* NWSessionSlot notifications */ |
|
96 |
|
97 |
|
98 /** |
|
99 * Starts delivering NWSessionSlot notifications. |
|
100 * |
|
101 * Reports either notifications from all NWSessionSlot |
|
102 * events or only those events which match given criterias. |
|
103 * |
|
104 * Possible criterias are: |
|
105 * - NWSessionSlotID: |
|
106 * Reports only those events which NWSessionSlotID |
|
107 * matches given criteria. Match pattern can be |
|
108 * full NWSessionSlotID or wild one. |
|
109 * |
|
110 * - SlotEvent: |
|
111 * Reports only those events which are requested. |
|
112 * |
|
113 * @param aMatchPattern The NWSessionSlotID match pattern to use. |
|
114 * @param aEvents The events to deliver |
|
115 * @return Result: |
|
116 * - KErrNone if succesfully started |
|
117 * - KErrArgument if empty criterias provided |
|
118 * - KErrInUse if notifier already started |
|
119 * - Else one of system wide error codes |
|
120 */ |
|
121 IMPORT_C TInt Start(); |
|
122 IMPORT_C TInt Start( const CPEngNWSessionSlotID2& aMatchPattern ); |
|
123 IMPORT_C TInt Start( const TArray<TPEngNWSessionSlotEvent>& aEvents ); |
|
124 |
|
125 |
|
126 /** |
|
127 * Stops listening sessions slot changes. |
|
128 */ |
|
129 IMPORT_C void Stop(); |
|
130 |
|
131 |
|
132 |
|
133 /** |
|
134 * Checks is the slot notifier started or not. |
|
135 * |
|
136 * @return ETrue if the slot notifier is already started. |
|
137 * EFalse if the slot notifier isn't started. |
|
138 */ |
|
139 IMPORT_C TBool IsActive() const; |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 //----------------------------------------------------------------------- |
|
145 public: /* NWSessionSlot notifications */ |
|
146 |
|
147 |
|
148 /** |
|
149 * Notifies synchronously registered observers |
|
150 * from NWSessionSlot states. |
|
151 * |
|
152 * State notifications are delivered synchronously from all |
|
153 * NWSessionSlots which NWSessionSlotID matches given criteria. |
|
154 * Match string can be full NWSessionSlotID or wild one. |
|
155 * If no matching NWSessionSlot found, returns KErrNotFound. |
|
156 * |
|
157 * Only NWSessionSlot state information is delivered. |
|
158 * Dynamic event and data parts are delivered as empty. |
|
159 * |
|
160 * @param aMatchPattern The NWSessionSlotID match pattern to use. |
|
161 * @return Result: |
|
162 * - KErrNone if succesfully notified observers |
|
163 * - KErrNotFound if no matching NWSessionSlot found |
|
164 * - Else one of system wide error codes |
|
165 */ |
|
166 IMPORT_C TInt PushNWSessionSlotStateToObservers( |
|
167 const CPEngNWSessionSlotID2& aMatchPattern ); |
|
168 |
|
169 |
|
170 |
|
171 /** |
|
172 * Gets NWSessionSlots state. |
|
173 * |
|
174 * @since 3.0 |
|
175 * @param aNWSessionSlotID The session slot ID to identify the |
|
176 * session slot. |
|
177 * @param aState Last state reported from NWSessionSlot. |
|
178 * @return Result: |
|
179 * - KErrNone if state succesfully get. |
|
180 * - Else one of system wide error codes. |
|
181 */ |
|
182 IMPORT_C TInt GetNWSessionSlotState( |
|
183 const CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
184 TPEngNWSessionSlotState& aState ) const; |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 //----------------------------------------------------------------------- |
|
192 public: /* NWSessionSlot event observers */ |
|
193 |
|
194 |
|
195 /** |
|
196 * Registers event observer to be notified from slot changes. |
|
197 * |
|
198 * Registered event observers are notified from |
|
199 * NWSessionSlot events as requested with StartL(). |
|
200 * |
|
201 * @param aObserver The observer to be notified. |
|
202 * @return KErrNone is observer added succesfully. |
|
203 * Else one of the system wide error codes. |
|
204 */ |
|
205 IMPORT_C TInt AddObserver( |
|
206 MPEngNWSessionSlotObserver2& aObserver ); |
|
207 |
|
208 |
|
209 |
|
210 /** |
|
211 * Unregisters session slot event observer. |
|
212 * |
|
213 * @param aObserver The observer to remove. |
|
214 * @return KErrNone is observer removed succesfully. |
|
215 * KErrNotFound if the observer wasn't registered. |
|
216 */ |
|
217 IMPORT_C TInt RemoveObserver( |
|
218 MPEngNWSessionSlotObserver2& aObserver ); |
|
219 |
|
220 |
|
221 |
|
222 //----------------------------------------------------------------------- |
|
223 private: /* Data */ |
|
224 |
|
225 |
|
226 //OWN: Implementation |
|
227 CPEngNWSessionSlotNotifier2Imp* iImp; |
|
228 }; |
|
229 |
|
230 |
|
231 |
|
232 #endif //__CPENGNWSESSIONSLOTNOTIFIER2_H |
|
233 |
|
234 //End of file |
|
235 |
|
236 |
|
237 |
|
238 |