|
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 #include "musuipropertywatch.h" |
|
21 #include "musuipropertyobserver.h" |
|
22 #include "mussessionproperties.h" |
|
23 #include "musresourceproperties.h" |
|
24 #include "muslogger.h" // debug logging |
|
25 |
|
26 using namespace NMusSessionApi; |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // Symbian two-phase constructor. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CMusUiPropertyWatch* CMusUiPropertyWatch::NewL( |
|
33 MMusUiPropertyObserver& aObserver, |
|
34 TUid aCategory, |
|
35 const TInt aPropertyName ) |
|
36 { |
|
37 CMusUiPropertyWatch* self = new (ELeave) CMusUiPropertyWatch( |
|
38 aObserver, |
|
39 aCategory, |
|
40 aPropertyName ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // C++ destructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMusUiPropertyWatch::~CMusUiPropertyWatch() |
|
53 { |
|
54 MUS_LOG( "mus: [MUSUI ] -> CMusUiPropertyWatch::~CMusUiPropertyWatch" ); |
|
55 if ( IsActive() ) |
|
56 { |
|
57 Cancel(); |
|
58 } |
|
59 iProperty.Close(); |
|
60 MUS_LOG( "mus: [MUSUI ] <- CMusUiPropertyWatch::~CMusUiPropertyWatch" ); |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // C++ constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CMusUiPropertyWatch::CMusUiPropertyWatch( MMusUiPropertyObserver& aObserver, |
|
69 TUid aCategory, |
|
70 const TInt aPropertyName ) : |
|
71 CActive( EPriorityNormal ), |
|
72 iObserver( aObserver ) |
|
73 { |
|
74 iPropertyCategory = aCategory; |
|
75 iPropertyKey = aPropertyName; |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Symbian second-phase constructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CMusUiPropertyWatch::ConstructL( ) |
|
84 { |
|
85 MUS_LOG( "mus: [MUSUI ] -> CMusUiPropertyWatch::ConstructL" ); |
|
86 User::LeaveIfError( iProperty.Attach( iPropertyCategory, |
|
87 iPropertyKey) ); |
|
88 CActiveScheduler::Add( this ); |
|
89 RunL(); |
|
90 MUS_LOG( "mus: [MUSUI ] <- CMusUiPropertyWatch::ConstructL" ); |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TInt CMusUiPropertyWatch::ReadIntPropertyL( TUint aKey ) |
|
99 { |
|
100 MUS_LOG1( "mus: [MUSUI ] -> CMusUiPropertyWatch::ReadIntPropertyL: aKey: [%d]", |
|
101 aKey ); |
|
102 TInt val; |
|
103 User::LeaveIfError( RProperty::Get( KCategoryUid, |
|
104 aKey, |
|
105 val ) ); |
|
106 MUS_LOG1( "mus: [MUSUI ] <- CMusUiPropertyWatch::ReadIntPropertyL: val: [%d]", |
|
107 val ); |
|
108 return val; |
|
109 } |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 HBufC* CMusUiPropertyWatch::ReadDescPropertyL( TUint aKey ) |
|
117 { |
|
118 MUS_LOG1( "mus: [MUSUI ] -> CMusUiPropertyWatch::ReadDescPropertyL: aKey: [%d]", |
|
119 aKey ); |
|
120 TBuf<RProperty::KMaxPropertySize> buffer; |
|
121 |
|
122 User::LeaveIfError( RProperty::Get( KCategoryUid, |
|
123 aKey, |
|
124 buffer ) ); |
|
125 HBufC* desc = buffer.AllocL(); |
|
126 MUS_LOG_TDESC( "mus: [MUSUI ] <- CMusUiPropertyWatch::ReadDescPropertyL: val: ", |
|
127 (*desc) ); |
|
128 return desc; |
|
129 } |
|
130 |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CMusUiPropertyWatch::DoCancel() |
|
137 { |
|
138 MUS_LOG( "mus: [MUSUI ] -> CMusUiPropertyWatch::DoCancel" ); |
|
139 iProperty.Cancel(); |
|
140 MUS_LOG( "mus: [MUSUI ] <- CMusUiPropertyWatch::DoCancel" ); |
|
141 } |
|
142 |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CMusUiPropertyWatch::RunL() |
|
149 { |
|
150 MUS_LOG( "mus: [MUSUI ] -> CMusUiPropertyWatch::RunL" ); |
|
151 TInt val; |
|
152 |
|
153 User::LeaveIfError( RProperty::Get( iPropertyCategory, |
|
154 iPropertyKey, |
|
155 val ) ); |
|
156 iProperty.Subscribe( iStatus ); |
|
157 SetActive(); |
|
158 |
|
159 iObserver.PropertyChanged( iPropertyKey, val ); |
|
160 |
|
161 MUS_LOG( "mus: [MUSUI ] <- CMusUiPropertyWatch::RunL" ); |
|
162 } |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TInt CMusUiPropertyWatch::RunError( TInt aError ) |
|
170 { |
|
171 MUS_LOG1( "mus: [MUSUI ] -> CMusUiPropertyWatch::RunError [%d]", aError ); |
|
172 iObserver.HandlePropertyError( aError ); |
|
173 MUS_LOG( "mus: [MUSUI ] <- CMusUiPropertyWatch::RunError" ); |
|
174 return KErrNone; |
|
175 } |
|
176 |
|
177 |
|
178 // end of file |