|
1 /* |
|
2 * Copyright (c) 2007-2009 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 #ifndef FEATURENOTIFIER_H |
|
21 #define FEATURENOTIFIER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32svr.h> |
|
25 #include <babitflags.h> |
|
26 #include <featmgr/featurecmn.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class RFeatMgrClient; |
|
30 |
|
31 // DEFINES |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 /** |
|
38 Class provides a callback interface for handling notifification of |
|
39 changes in features. The client derives a class from this interface |
|
40 and implements the HandleNotifyChange-methods that interest it. |
|
41 |
|
42 Feature Notifier API consists of the classes CFeatureNotifier and |
|
43 MFeatureObserver. TFeatureEntry and TFeatureChangeType are defined |
|
44 in featurecmn.h. |
|
45 @publishedPartner |
|
46 @released |
|
47 */ |
|
48 class MFeatureObserver |
|
49 { |
|
50 public: |
|
51 /** |
|
52 This callback method is used to notify the client about |
|
53 the change in a feature. |
|
54 |
|
55 @param aType Type of the change. |
|
56 @param aFeature The changed feature. Note that although aFeature is a |
|
57 TFeatureEntry object, only the iFeatureID field is set by the server. |
|
58 |
|
59 @see TFeatureChangeType |
|
60 @see TFeatureEntry |
|
61 */ |
|
62 virtual void HandleNotifyChange( TFeatureChangeType aType, TFeatureEntry aFeature ) = 0; |
|
63 |
|
64 /** |
|
65 This callback method is used to notify the client about errors |
|
66 in the CFeatureNotifier. Any error in the notifier causes the notifier |
|
67 to stop handling of notifications. Handling can be restarted with |
|
68 a call to aNotifier->NotifyRequest(), if the error is non-fatal. |
|
69 |
|
70 @param aError One of the Symbian OS error codes. |
|
71 */ |
|
72 virtual void HandleNotifyError( TInt aError ) = 0; |
|
73 }; |
|
74 |
|
75 /** |
|
76 Active object for obtaining notification of changes in features. |
|
77 Feature Notifier automatically resubscribes to the notification and |
|
78 fetches the status and data of the changed feature. |
|
79 |
|
80 Feature Notifier API consists of the classes CFeatureNotifier and |
|
81 MFeatureObserver. The array RFeatureUidArray is defined in featurecmn.h. |
|
82 The user of this class needs to implement MFeatureObserver interface |
|
83 methods to receive notifications. |
|
84 |
|
85 @publishedPartner |
|
86 @released |
|
87 */ |
|
88 NONSHARABLE_CLASS(CFeatureNotifier) : public CActive |
|
89 { |
|
90 public: |
|
91 /** |
|
92 This is a two-phase constructor method that is used to create a new |
|
93 instance for listening to the changes in features. |
|
94 |
|
95 @param aObserver A reference to an observer instance. |
|
96 @return A pointer to a new instance of the CFeatureNotifier class. |
|
97 |
|
98 @leave Any One of the Symbian OS system-wide error codes |
|
99 */ |
|
100 IMPORT_C static CFeatureNotifier* NewL( MFeatureObserver& aObserver ); |
|
101 |
|
102 /** |
|
103 Destructor. |
|
104 */ |
|
105 IMPORT_C ~CFeatureNotifier(); |
|
106 |
|
107 /** |
|
108 This method is used to request notification for one feature. |
|
109 |
|
110 @param aFeature Feature UID. |
|
111 @return KErrAlreadyExists if a notification has already been requested |
|
112 and is outstanding. Otherwise one of the Symbian OS error |
|
113 codes. |
|
114 |
|
115 @see CActive |
|
116 */ |
|
117 IMPORT_C TInt NotifyRequest( TUid aFeature ); |
|
118 |
|
119 /** |
|
120 This method is used to request notification for a subset of features. |
|
121 |
|
122 @param aFeatures A reference to a client owned UID-array |
|
123 of requested features. |
|
124 @return KErrAlreadyExists if a notification has already been requested |
|
125 and is outstanding. Otherwise one of the Symbian OS error codes. |
|
126 |
|
127 @see RFeatureUidArray |
|
128 @see CActive |
|
129 */ |
|
130 IMPORT_C TInt NotifyRequest( RFeatureUidArray& aFeatures ); |
|
131 |
|
132 /** |
|
133 Cancels notification request for one feature. |
|
134 |
|
135 @param aFeatures Feature UID. |
|
136 @return KErrNotFound if the feature does not exist |
|
137 in the list of previously requested features. |
|
138 Otherwise one of the Symbian error codes. |
|
139 */ |
|
140 IMPORT_C TInt NotifyCancel( TUid aFeature ); |
|
141 |
|
142 /** |
|
143 Cancels notification requests for all features. |
|
144 |
|
145 @return One of the Symbian OS system-wide error codes. |
|
146 */ |
|
147 IMPORT_C TInt NotifyCancelAll(); |
|
148 |
|
149 private: |
|
150 /** |
|
151 C++ default constructor. |
|
152 */ |
|
153 CFeatureNotifier(); |
|
154 |
|
155 /** |
|
156 @param aObserver A reference to an observer instance. |
|
157 */ |
|
158 CFeatureNotifier( MFeatureObserver& aObserver ); |
|
159 |
|
160 /** |
|
161 By default Symbian OS constructor is private. |
|
162 */ |
|
163 void ConstructL(); |
|
164 |
|
165 protected: |
|
166 /** |
|
167 Implements CActive. |
|
168 */ |
|
169 void RunL(); |
|
170 |
|
171 /** |
|
172 Implements CActive. |
|
173 @param aError The error returned. |
|
174 @return One of the Symbian OS system-wide error codes. |
|
175 */ |
|
176 TInt RunError( TInt aError ); |
|
177 |
|
178 /** |
|
179 Implements CActive. |
|
180 */ |
|
181 void DoCancel(); |
|
182 |
|
183 private: |
|
184 /** |
|
185 A reference to the callback/observer instance. |
|
186 */ |
|
187 MFeatureObserver& iObserver; |
|
188 |
|
189 /** Holds UID-array of features being requested. */ |
|
190 RFeatureUidArray iFeatures; |
|
191 |
|
192 /** Server sets changed feature before signaling. */ |
|
193 TUid iFeatureChanged; |
|
194 |
|
195 // Feature Manager server client |
|
196 RFeatMgrClient* iFeatMgrClient; |
|
197 |
|
198 |
|
199 public: // @internalComponent APIs |
|
200 // These APIs are for internal testing purposes only. |
|
201 |
|
202 IMPORT_C TInt NumberOfNotifyFeatures(); |
|
203 |
|
204 IMPORT_C TInt CountAllocCells(); |
|
205 }; |
|
206 |
|
207 |
|
208 #endif // FEATURENOTIFIER_H |
|
209 |
|
210 // End of File |