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