author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:16:48 +0300 | |
changeset 77 | 2be0b271d017 |
parent 37 | ba76fc04e6c2 |
permissions | -rw-r--r-- |
37 | 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: Proxy for the connection to central repository. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef __CPHONECENREPPROXY_H |
|
20 |
#define __CPHONECENREPPROXY_H |
|
21 |
||
22 |
// INCLUDES |
|
23 |
#include <coemain.h> |
|
24 |
#include <e32base.h> |
|
25 |
#include <centralrepository.h> |
|
26 |
#include <cenrepnotifyhandler.h> |
|
27 |
||
28 |
// CONSTANTS |
|
29 |
class MPhoneCenRepObserver; |
|
30 |
class CPhoneCenRepEventHandler; |
|
31 |
||
32 |
// FORWARD DECLARATIONS |
|
33 |
class TPhoneCmdParamAppInfo; |
|
34 |
||
35 |
/** |
|
36 |
* CPhoneCenRepProxy is an API used as proxy for phone application to get/set |
|
37 |
* and observe central repository settings. |
|
38 |
* |
|
39 |
* How to get some setting? |
|
40 |
* --------------------------- |
|
41 |
* example code: |
|
42 |
* TBuf<100> value; |
|
43 |
* CPhoneCenRepProxy::Instance()->GetString( uid, key, value ); |
|
44 |
* |
|
45 |
* uid and key should be retrieved from <Module Name>InternalCRKeys.h |
|
46 |
* |
|
47 |
* How to set any settings |
|
48 |
* -------------------------------------- |
|
49 |
* example code: |
|
50 |
* TInt value = 10; |
|
51 |
* CPhoneCenRepProxy::Instance()->SetInt( uid, key, value ); |
|
52 |
* |
|
53 |
* How to observe any settings |
|
54 |
* -------------------------------------- |
|
55 |
* example code: |
|
56 |
* |
|
57 |
* class CPhoneSomeManager : private MPhoneCenRepObserver |
|
58 |
* { |
|
59 |
* ... |
|
60 |
* virtual void HandleCenRepChangeL( |
|
61 |
* const TUid& aUid, |
|
62 |
* const TUint aId ); |
|
63 |
* .... |
|
64 |
* } |
|
65 |
* |
|
66 |
* CPhoneSomeManager::SomeFunctionL |
|
67 |
* { |
|
68 |
* CPhoneCenRepProxy::Instance()->NotifyChangeL( uid1, id1, this ); |
|
69 |
* |
|
70 |
* CPhoneCenRepProxy::Instance()->NotifyChangeL( uid2, id2, this ); |
|
71 |
* } |
|
72 |
* |
|
73 |
* CPhoneSomeManager::HandleCenRepChangeL( |
|
74 |
* const TUid& aUid, |
|
75 |
* const TUint aId ) |
|
76 |
* { |
|
77 |
* switch( aId ) |
|
78 |
* { |
|
79 |
* case ESetting1: |
|
80 |
* .... //do something |
|
81 |
* case ESetting2: |
|
82 |
* .... //do something |
|
83 |
* default: |
|
84 |
* .... //panic in debug |
|
85 |
* } |
|
86 |
* } |
|
87 |
* |
|
88 |
* //The CancelAllNotifies() should be always called before destroy the object |
|
89 |
* CPhoneSomeManager::~CPhoneSomeManager() |
|
90 |
* { |
|
91 |
* CPhoneCenRepProxy::Instance()->CancelAllNotifies( this ); |
|
92 |
* } |
|
93 |
* |
|
94 |
*/ |
|
95 |
||
96 |
||
97 |
// CLASS DECLARATION |
|
98 |
||
99 |
class CPhoneCenRepProxy : |
|
100 |
public CCoeStatic |
|
101 |
{ |
|
102 |
public: // Constructors and destructor |
|
103 |
||
104 |
/** |
|
105 |
* First call initializes the singleton object. Subsequent calls return |
|
106 |
* created instance. |
|
107 |
* @return the created instance. |
|
108 |
*/ |
|
109 |
IMPORT_C static CPhoneCenRepProxy* Instance(); |
|
110 |
||
111 |
/** |
|
112 |
* Destructor. |
|
113 |
*/ |
|
114 |
IMPORT_C virtual ~CPhoneCenRepProxy(); |
|
115 |
||
116 |
public: // New Functions |
|
117 |
||
118 |
/** |
|
119 |
* Cancel all requests by the observer. This function should always be |
|
120 |
* call before an object is destroyed. During shutdown, this singleton |
|
121 |
* may be deleted before the classes that observe it. If this happens, the |
|
122 |
* routine will just return since of requests have already been cancelled. |
|
123 |
* @param aObserver |
|
124 |
*/ |
|
125 |
IMPORT_C static void CancelAllNotifies( |
|
126 |
MPhoneCenRepObserver* aObserver ); |
|
127 |
||
128 |
/** |
|
129 |
* Set integer value of setting |
|
130 |
* @param aUid identifing the central repository UID. |
|
131 |
* @param aId central repository ID. |
|
132 |
* @param aValue the value associated with the central repository ID |
|
133 |
*/ |
|
134 |
IMPORT_C TInt SetInt( |
|
135 |
const TUid& aUid, |
|
136 |
const TUint aId, |
|
137 |
const TInt aValue ); |
|
138 |
||
139 |
/** |
|
140 |
* Set string value of setting |
|
141 |
* @param aUid identifing the central repository UID. |
|
142 |
* @param aId central repository ID. |
|
143 |
* @param aValue the value associated with the central repository ID |
|
144 |
* @return refer to SharedDataClient.h for detail explanation |
|
145 |
*/ |
|
146 |
IMPORT_C TInt SetString( |
|
147 |
const TUid& aUid, |
|
148 |
const TUint aId, |
|
149 |
const TDesC& aValue ); |
|
150 |
||
151 |
/** |
|
152 |
* Set real value of setting |
|
153 |
* @param aUid identifing the central repository UID. |
|
154 |
* @param aId central repository ID. |
|
155 |
* @param aValue the value associated with the central repository ID |
|
156 |
*/ |
|
157 |
IMPORT_C TInt SetReal( |
|
158 |
const TUid& aUid, |
|
159 |
const TUint aId, |
|
160 |
const TReal aValue ); |
|
161 |
||
162 |
/** |
|
163 |
* Get integer value of setting |
|
164 |
* @param aUid identifing the central repository UID. |
|
165 |
* @param aId central repository ID. |
|
166 |
* @param aValue the value associated with the central repository ID |
|
167 |
*/ |
|
168 |
IMPORT_C TInt GetInt( |
|
169 |
const TUid& aUid, |
|
170 |
const TUint aId, |
|
171 |
TInt& aValue ) const; |
|
172 |
||
173 |
/** |
|
174 |
* Get string value of setting |
|
175 |
* @param aUid identifing the central repository UID. |
|
176 |
* @param aId central repository ID. |
|
177 |
* @param aValue the value associated with the central repository ID |
|
178 |
*/ |
|
179 |
IMPORT_C TInt GetString( |
|
180 |
const TUid& aUid, |
|
181 |
const TUint aId, |
|
182 |
TDes& aValue ) const; |
|
183 |
||
184 |
/** |
|
185 |
* Get real value of setting |
|
186 |
* @param aUid identifing the central repository UID. |
|
187 |
* @param aId central repository ID. |
|
188 |
* @param aValue the value associated with the central repository ID |
|
189 |
*/ |
|
190 |
IMPORT_C TInt GetReal( |
|
191 |
const TUid& aUid, |
|
192 |
const TUint aId, |
|
193 |
TReal& aValue ) const; |
|
194 |
||
195 |
/** |
|
196 |
* Notify the change of the setting |
|
197 |
* @param aUid identifing the central repository UID. |
|
198 |
* @param aId central repository ID. |
|
199 |
* @param aObserver The pointer to the observer to handle the change |
|
200 |
* notification |
|
201 |
*/ |
|
202 |
IMPORT_C void NotifyChangeL( |
|
203 |
const TUid& aUid, |
|
204 |
const TUint aId, |
|
205 |
MPhoneCenRepObserver* aObserver ); |
|
206 |
||
207 |
/** |
|
208 |
* Cancel request. If you don't want to receive notification of the |
|
209 |
* setting you issued before, call this function. |
|
210 |
* @param aObserver The observer that have issued request before |
|
211 |
* @param aId The setting which is to be canceled |
|
212 |
*/ |
|
213 |
IMPORT_C void CancelNotify( |
|
214 |
MPhoneCenRepObserver* aObserver, |
|
215 |
const TUint aId ); |
|
216 |
||
217 |
/** |
|
218 |
* Return boolean value that states whether or not |
|
219 |
* the indicated feature is supported. |
|
220 |
* @param aFeatureId the feature that is inspected (see values from |
|
221 |
* TelephonyVariant.hrh) |
|
222 |
* @return whether or not the feature is supported. |
|
223 |
*/ |
|
224 |
IMPORT_C TBool IsTelephonyFeatureSupported( const TInt aFeatureId ); |
|
225 |
||
226 |
/** |
|
227 |
* Return boolean value that states whether or not |
|
228 |
* the indicated feature is supported. |
|
229 |
* @param aFeatureId the feature that is inspected (see values from |
|
230 |
* PhoneUIVariant.hrh) |
|
231 |
* @return whether or not the feature is supported. |
|
232 |
*/ |
|
233 |
IMPORT_C TBool IsPhoneUIFeatureSupported( const TInt aFeatureId ); |
|
234 |
||
235 |
/** |
|
236 |
* Get keys from given value range |
|
237 |
* @param aUid identifing the central repository UID. |
|
238 |
* @param aPartial partial key to be found |
|
239 |
* @param aMask mask for partial key |
|
240 |
* @param aValues reference to array object for found keys |
|
241 |
* @return KErrNone if successful, system wide error code otherwise. |
|
242 |
*/ |
|
243 |
IMPORT_C TInt Find( |
|
244 |
const TUid& aUid, |
|
245 |
const TUint32 aPartial, |
|
246 |
const TUint32 aMask, |
|
247 |
RArray<TUint32>& aValues ) const; |
|
248 |
||
249 |
/** |
|
250 |
* Fetches values from central repository |
|
251 |
* @param aAppInfo reference to object containing info for |
|
252 |
* application launching |
|
253 |
* @param aCode ascii value of the pressed key |
|
254 |
* @param aAppParam application parameter |
|
255 |
* @param aValuesFetched ETrue if values fetched ok |
|
256 |
*/ |
|
257 |
IMPORT_C void FetchValuesFromCenRepL( TPhoneCmdParamAppInfo& aAppInfo, |
|
258 |
TKeyCode aCode, |
|
259 |
HBufC8* aAppParam, TBool& aValuesFetched ); |
|
260 |
||
261 |
||
262 |
public: // New methods |
|
263 |
||
264 |
/** |
|
265 |
* Handle notifications from central repository observers |
|
266 |
* @param aUid identifing the central repository UID. |
|
267 |
* @param aId central repository ID. |
|
268 |
*/ |
|
269 |
void HandleNotify( |
|
270 |
const TUid& aUid, |
|
271 |
const TUint aId ); |
|
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
272 |
|
37 | 273 |
private: |
274 |
||
275 |
/** |
|
276 |
* Two-phased constructor. |
|
277 |
* @return new instance. |
|
278 |
*/ |
|
279 |
static CPhoneCenRepProxy* NewL(); |
|
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
280 |
|
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
281 |
protected: |
37 | 282 |
/** |
283 |
* C++ default constructor. |
|
284 |
*/ |
|
77
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
285 |
CPhoneCenRepProxy(); |
2be0b271d017
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
286 |
|
37 | 287 |
/** |
288 |
* By default Symbian OS constructor is private. |
|
289 |
*/ |
|
290 |
void ConstructL(); |
|
291 |
||
292 |
private: |
|
293 |
||
294 |
/** |
|
295 |
* Find the observer for specific setting on aUid and aId |
|
296 |
* @param aUid identifing the central repository UID. |
|
297 |
* @param aId central repository ID. |
|
298 |
* @param aFromIndex find next observer interested in this setting after |
|
299 |
* aIndex |
|
300 |
* @return The index of the observer if it's found and KErrNotFound if |
|
301 |
* not |
|
302 |
*/ |
|
303 |
TInt FindByUidId( |
|
304 |
const TUid& aUid, |
|
305 |
const TUint aId, |
|
306 |
TInt aFromIndex = 0 ); |
|
307 |
||
308 |
/** |
|
309 |
* Find the specific Observer |
|
310 |
* @param aObserver The pointer of the observer |
|
311 |
* @param aId central repository ID. |
|
312 |
* @return The index in iObserverArray. KErrNotFound if can't find the |
|
313 |
specific observer |
|
314 |
*/ |
|
315 |
TInt FindByObserverId( |
|
316 |
const MPhoneCenRepObserver* aObserver, |
|
317 |
const TUint aId ); |
|
318 |
||
319 |
/** |
|
320 |
* Finds observer by uid, key and observer. |
|
321 |
* @param aUid identifing the central repository UID. |
|
322 |
* @param aId central repository ID. |
|
323 |
* @param aObserver The pointer of the observer |
|
324 |
*/ |
|
325 |
TInt FindByUidIdObserver( |
|
326 |
const TUid& aUid, |
|
327 |
const TUint aId, |
|
328 |
MPhoneCenRepObserver* aObserver ); |
|
329 |
||
330 |
/** |
|
331 |
* Returns Telephony variant read-only data. |
|
332 |
* @return error code. |
|
333 |
*/ |
|
334 |
TInt GetTelephonyVariantData(); |
|
335 |
||
336 |
/** |
|
337 |
* Returns PhoneUI variant read-only data. |
|
338 |
* @return error code. |
|
339 |
*/ |
|
340 |
TInt GetPhoneUIVariantData(); |
|
341 |
||
342 |
/** |
|
343 |
* Cancel all request by the observer. |
|
344 |
* @param aObserver |
|
345 |
*/ |
|
346 |
void CancelAllObserverNotifies( MPhoneCenRepObserver* aObserver ); |
|
347 |
||
348 |
/** |
|
349 |
* Cancel all requests from all observers. |
|
350 |
*/ |
|
351 |
void CancelAllNotifies(); |
|
352 |
||
353 |
private: // Data |
|
354 |
||
355 |
// Defines information of one observer. |
|
356 |
class TCenRepObserverTag |
|
357 |
{ |
|
358 |
public: |
|
359 |
TUid iUid; |
|
360 |
TUint iId; |
|
361 |
MPhoneCenRepObserver* iObserver; |
|
362 |
}; |
|
363 |
||
364 |
// Owned array of observers. |
|
365 |
CArrayFixFlat<TCenRepObserverTag>* iObserverArray; |
|
366 |
||
367 |
// Central Repository event handlers. |
|
368 |
CPhoneCenRepEventHandler* iCenRepAccessoryEventHandler; |
|
369 |
CPhoneCenRepEventHandler* iCenRepNetworkEventHandler; |
|
370 |
CPhoneCenRepEventHandler* iCenRepThemesEventHandler; |
|
371 |
CPhoneCenRepEventHandler* iCenRepLanguageEventHandler; |
|
372 |
CPhoneCenRepEventHandler* iCenRepQwertyEventHandler; |
|
373 |
CPhoneCenRepEventHandler* iCenRepKDRMHelperEventHandler; |
|
374 |
||
375 |
//Local Telephony variant read-only data. |
|
376 |
TInt iTelephonyVariantReadOnlyValues; |
|
377 |
||
378 |
//Local PhoneUI variant read-only data. |
|
379 |
TInt iPhoneUIVariantReadOnlyValues; |
|
380 |
}; |
|
381 |
||
382 |
#endif // __CPHONECENREPPROXY_H |
|
383 |
||
384 |
// End of File |