|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef MUSUIPROPERTYWATCH_H |
|
21 #define MUSUIPROPERTYWATCH_H |
|
22 |
|
23 #include "musunittesting.h" |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <e32property.h> |
|
27 |
|
28 class MMusUiPropertyObserver; |
|
29 |
|
30 class CMusUiPropertyWatch : public CActive |
|
31 { |
|
32 |
|
33 MUS_UNITTEST( UT_CMusUiPropertyWatch; ) |
|
34 |
|
35 public: // constructors and destructor |
|
36 |
|
37 /** |
|
38 * Two-phased constructor. Leaves on failure. |
|
39 * @return The constructed CMusUiPropertyWatch object. |
|
40 */ |
|
41 static CMusUiPropertyWatch* NewL( MMusUiPropertyObserver& aObserver, |
|
42 TUid aCategory, |
|
43 const TInt aPropertyName ); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 ~CMusUiPropertyWatch(); |
|
49 |
|
50 private: |
|
51 |
|
52 /** |
|
53 * C++ constructor. |
|
54 */ |
|
55 CMusUiPropertyWatch( MMusUiPropertyObserver& aObserver, |
|
56 TUid aCategory, |
|
57 const TInt aPropertyName ); |
|
58 |
|
59 /** |
|
60 * Symbian 2nd-phase constructor. |
|
61 * @leave If return value of RProperty::Attach != KErrNone, e.q. KErrNoMemory |
|
62 * or one of the system wide error codes if RunL() leaves |
|
63 */ |
|
64 void ConstructL(); |
|
65 |
|
66 |
|
67 public: // new functions |
|
68 |
|
69 /** |
|
70 * Reads a P&S integer value from the category KCategoryUid |
|
71 * @pre P&S value has to be defined. |
|
72 * @leave One of the system wide error codes, if RProperty::Get() |
|
73 * returns an error value. |
|
74 * @param aKey Name of the P&S Key, which value should be read |
|
75 * @returns The integer value of the P&S Key. |
|
76 */ |
|
77 static TInt ReadIntPropertyL( TUint aKey ); |
|
78 |
|
79 /** |
|
80 * Reads a P&S descriptor value from the category KCategoryUid |
|
81 * @pre P&S value has to be defined. |
|
82 * @leave One of the system wide error codes, if RProperty::Get() |
|
83 * returns an error value or if descriptor AllocL() leaves. |
|
84 * @param aKey Name of the P&S Key, which value should be read |
|
85 * @returns The descriptor value of the P&S Key. |
|
86 * Ownership is transferred |
|
87 */ |
|
88 static HBufC* ReadDescPropertyL( TUint aKey ); |
|
89 |
|
90 |
|
91 private: // functions from base class CActive |
|
92 |
|
93 /** |
|
94 * |
|
95 */ |
|
96 void DoCancel(); |
|
97 |
|
98 /** |
|
99 * Reads a P&S integer value from the category KCategoryUid |
|
100 * and starts to monitor changes in the property value. |
|
101 * Calls observer function for read property values. |
|
102 * @pre P&S value has to be defined as an integer. |
|
103 * @leave One of the system wide error codes, if RProperty::Get() |
|
104 * returns an error value. |
|
105 */ |
|
106 void RunL(); |
|
107 |
|
108 /** |
|
109 * |
|
110 */ |
|
111 TInt RunError(TInt aError); |
|
112 |
|
113 private: // Data |
|
114 |
|
115 RProperty iProperty; |
|
116 |
|
117 TUid iPropertyCategory; |
|
118 |
|
119 TUint iPropertyKey; |
|
120 |
|
121 MMusUiPropertyObserver& iObserver; |
|
122 |
|
123 }; |
|
124 |
|
125 #endif // MUSUIPROPERTYWATCH_H |
|
126 |
|
127 // end of file |