|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Notifies the changes in publish and suscripe properties. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CSatPSChangeNotifier.h" |
|
22 #include "MSatSystemStateObserver.h" |
|
23 #include "Panic.h" |
|
24 #include "SatLog.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CSatPSChangeNotifier::CSatPSChangeNotifier |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CSatPSChangeNotifier::CSatPSChangeNotifier( |
|
35 const TUid& aPropertyKey, |
|
36 TUint aPropertyValue, |
|
37 MSatSystemStateObserver& aObserver, |
|
38 TInt aNotifyValue ) : |
|
39 CActive( EPriorityStandard ), |
|
40 iObserver( aObserver ), |
|
41 iPSKey( aPropertyKey ), |
|
42 iPSValue( aPropertyValue ), |
|
43 iNotifyValue( aNotifyValue ) |
|
44 { |
|
45 LOG( SIMPLE, |
|
46 "SATSYSTEMSTATE: CSatPSChangeNotifier::CSatPSChangeNotifier calling" ) |
|
47 // Log parameters |
|
48 LOG2( NORMAL, |
|
49 "SATSYSTEMSTATE: CSatPSChangeNotifier::CSatPSChangeNotifier PS Uid: %d", |
|
50 aPropertyKey ) |
|
51 LOG2( NORMAL, |
|
52 "SATSYSTEMSTATE: CSatPSChangeNotifier::CSatPSChangeNotifier PS Key: %d", |
|
53 aPropertyValue ) |
|
54 LOG2( NORMAL, |
|
55 "SATSYSTEMSTATE: CSatPSChangeNotifier::CSatPSChangeNotifier Needed \ |
|
56 value: %d ", aNotifyValue ) |
|
57 |
|
58 CActiveScheduler::Add( this ); |
|
59 |
|
60 LOG( SIMPLE, |
|
61 "SATSYSTEMSTATE: CSatPSChangeNotifier::CSatPSChangeNotifier exiting" ) |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CSatPSChangeNotifier::NewL |
|
66 // Two-phased constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CSatPSChangeNotifier* CSatPSChangeNotifier::NewL( |
|
70 const TUid& aPropertyKey, |
|
71 TUint aPropertyValue, |
|
72 MSatSystemStateObserver& aObserver, |
|
73 TInt aNotifyValue ) |
|
74 { |
|
75 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::NewL calling" ) |
|
76 |
|
77 CSatPSChangeNotifier* self = |
|
78 new( ELeave ) CSatPSChangeNotifier( |
|
79 aPropertyKey, aPropertyValue, aObserver, aNotifyValue ); |
|
80 |
|
81 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::NewL exiting" ) |
|
82 return self; |
|
83 } |
|
84 |
|
85 |
|
86 // Destructor |
|
87 CSatPSChangeNotifier::~CSatPSChangeNotifier() |
|
88 { |
|
89 LOG( SIMPLE, |
|
90 "SATSYSTEMSTATE: CSatPSChangeNotifier::~CSatPSChangeNotifier calling" ) |
|
91 |
|
92 Cancel(); |
|
93 iPSClient.Close(); |
|
94 |
|
95 LOG( SIMPLE, |
|
96 "SATSYSTEMSTATE: CSatPSChangeNotifier::~CSatPSChangeNotifier exiting" ) |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CSatPSChangeNotifier::NotifyChangeL |
|
101 // Issues notification request. |
|
102 // (other items were commented in a header). |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CSatPSChangeNotifier::NotifyChangeL() |
|
106 { |
|
107 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::NotifyChangeL calling" ) |
|
108 |
|
109 __ASSERT_ALWAYS( !IsActive(), Panic( ESatSystemStateAllReadyActive ) ); |
|
110 User::LeaveIfError( iPSClient.Attach( iPSKey, iPSValue ) ); |
|
111 Activate(); |
|
112 |
|
113 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::NotifyChangeL exiting" ) |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CSatPSChangeNotifier::CancelNotify |
|
118 // Cancels outstanding request. |
|
119 // (other items were commented in a header). |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CSatPSChangeNotifier::CancelNotify() |
|
123 { |
|
124 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::CancelNotify calling" ) |
|
125 |
|
126 Cancel(); |
|
127 |
|
128 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::CancelNotify exiting" ) |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CSatPSChangeNotifier::DoCancel |
|
133 // (other items were commented in a header). |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CSatPSChangeNotifier::DoCancel() |
|
137 { |
|
138 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::DoCancel calling" ) |
|
139 |
|
140 iPSClient.Cancel(); |
|
141 |
|
142 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::DoCancel exiting" ) |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CSatPSChangeNotifier::RunL |
|
147 // Activates the request again and calls the observer. |
|
148 // (other items were commented in a header). |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CSatPSChangeNotifier::RunL() |
|
152 { |
|
153 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::RunL calling" ) |
|
154 // Makes sure that all the changes are notified. |
|
155 LOG2( SIMPLE, "SATSYSTEMSTATE: Failed: %i", iStatus.Int() ) |
|
156 if ( KErrNone == iStatus.Int() ) |
|
157 { |
|
158 NotifyChangeL(); |
|
159 |
|
160 // Check the value |
|
161 TInt value = KNotifyValueNotSet; |
|
162 |
|
163 // Get the value from P&S |
|
164 RProperty::Get( iPSKey, iPSValue, value ); |
|
165 |
|
166 // If notify value is set, check the value before notifying observer |
|
167 if ( KNotifyValueNotSet != iNotifyValue ) |
|
168 { |
|
169 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::RunL \ |
|
170 KNotifyValueNotSet != iNotifyValue" ) |
|
171 // If changed P&S value is same as notify value, notify observer |
|
172 if ( value == iNotifyValue ) |
|
173 { |
|
174 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::RunL \ |
|
175 value == iNotifyValue" ) |
|
176 iObserver.StateChanged(); |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::RunL \ |
|
182 KNotifyValueNotSet == iNotifyValue" ) |
|
183 // Notify value not specified -> Send the changed value |
|
184 iObserver.StateChanged( value ); |
|
185 } |
|
186 } |
|
187 else if ( KErrCancel == iStatus.Int() ) |
|
188 { |
|
189 Activate(); |
|
190 } |
|
191 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::RunL exiting" ) |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CSatPSChangeNotifier::Activate |
|
196 // (other items were commented in a header). |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CSatPSChangeNotifier::Activate() |
|
200 { |
|
201 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::Activate calling" ) |
|
202 |
|
203 iPSClient.Subscribe( iStatus ); |
|
204 SetActive(); |
|
205 |
|
206 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::Activate exiting" ) |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CSatPSChangeNotifier::GetValueInt |
|
211 // (other items were commented in a header). |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CSatPSChangeNotifier::GetValueInt() |
|
215 { |
|
216 LOG( SIMPLE, "SATSYSTEMSTATE: CSatPSChangeNotifier::GetValueInt calling" ) |
|
217 |
|
218 // Gets the value from P&S. |
|
219 TInt value( KNotifyValueNotSet ); |
|
220 RProperty::Get( iPSKey, iPSValue, value ); |
|
221 |
|
222 LOG2( SIMPLE, |
|
223 "SATSYSTEMSTATE: CSatPSChangeNotifier::GetValueInt exiting %i", |
|
224 value ) |
|
225 return value; |
|
226 } |
|
227 |
|
228 // End of File |