|
1 /* |
|
2 * =========================================================================== |
|
3 * Name : HgPropListener.cpp |
|
4 * Part of : Hg |
|
5 * Description : Active class to get notifications about changes to a P&S property |
|
6 * |
|
7 * Copyright © 2008 Nokia Corporation. |
|
8 * This material, including documentation and any related |
|
9 * computer programs, is protected by copyright controlled by |
|
10 * Nokia Corporation. All rights are reserved. Copying, |
|
11 * including reproducing, storing, adapting or translating, any |
|
12 * or all of this material requires the prior written consent of |
|
13 * Nokia Corporation. This material also contains confidential |
|
14 * information which may not be disclosed to others without the |
|
15 * prior written consent of Nokia Corporation. |
|
16 * =========================================================================== |
|
17 */ |
|
18 |
|
19 #include <e32cmn.h> |
|
20 |
|
21 #include "hgproplistener.h" |
|
22 |
|
23 EXPORT_C CHgPropertyListener::CHgPropertyListener( |
|
24 TUid aCategory, TUint aKey, MHgPropertyChangeObserver& aObserver ) |
|
25 : CActive( CActive::EPriorityStandard), |
|
26 iObserver( aObserver ), iCategory( aCategory ), iKey( aKey ) |
|
27 { |
|
28 CActiveScheduler::Add( this ); |
|
29 TInt err = iProperty.Attach( iCategory, iKey ); |
|
30 if ( err == KErrNone ) |
|
31 { |
|
32 iProperty.Subscribe( iStatus ); |
|
33 SetActive(); |
|
34 } |
|
35 } |
|
36 |
|
37 EXPORT_C CHgPropertyListener::~CHgPropertyListener() |
|
38 { |
|
39 Cancel(); |
|
40 iProperty.Close(); |
|
41 } |
|
42 |
|
43 void CHgPropertyListener::DoCancel() |
|
44 { |
|
45 iProperty.Cancel(); |
|
46 } |
|
47 |
|
48 void CHgPropertyListener::RunL() |
|
49 { |
|
50 if ( iStatus.Int() != KErrCancel ) // when cancelling the subscribe it completes with KErrCancel |
|
51 { |
|
52 iObserver.PropertyChanged( iCategory, iKey ); |
|
53 iProperty.Subscribe( iStatus ); |
|
54 SetActive(); |
|
55 } |
|
56 } |
|
57 |
|
58 TInt CHgPropertyListener::RunError( TInt /*aError*/ ) |
|
59 { |
|
60 iProperty.Subscribe( iStatus ); |
|
61 SetActive(); |
|
62 return KErrNone; |
|
63 } |
|
64 |
|
65 |
|
66 // end of file |