|
1 /* |
|
2 * Copyright (c) 2010 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: Listens to given P&S key and notifies |
|
15 * observer whenever the value changes. |
|
16 */ |
|
17 |
|
18 |
|
19 #include "sysapganpropertylistener.h" |
|
20 |
|
21 // ======== MEMBER FUNCTIONS ======== |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // C++ constructor |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 CSysApGanPropertyListener::CSysApGanPropertyListener( |
|
28 RProperty& aProperty, |
|
29 MSysApGanPropertyObserver& aObserver ) : |
|
30 CActive( CActive::EPriorityStandard ), |
|
31 iObserver( aObserver ), |
|
32 iProperty( aProperty ) |
|
33 { |
|
34 CActiveScheduler::Add( this ); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // Static constructor. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CSysApGanPropertyListener* CSysApGanPropertyListener::NewL( |
|
42 RProperty& aProperty, |
|
43 MSysApGanPropertyObserver& aObserver ) |
|
44 { |
|
45 CSysApGanPropertyListener* self = |
|
46 new ( ELeave ) CSysApGanPropertyListener( aProperty, aObserver ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Destructor. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CSysApGanPropertyListener::~CSysApGanPropertyListener() |
|
55 { |
|
56 Cancel(); // Cancel any request, if outstanding |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Subscribe for property value changes. |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CSysApGanPropertyListener::Subscribe() |
|
64 { |
|
65 // Cancel any outstanding request |
|
66 Cancel(); |
|
67 |
|
68 iProperty.Subscribe( iStatus ); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Property value changed. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CSysApGanPropertyListener::RunL() |
|
77 { |
|
78 // Notify the observer. |
|
79 iObserver.PropertyEvent( *this, iStatus.Int() ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Subscription cancelled. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CSysApGanPropertyListener::DoCancel() |
|
87 { |
|
88 iProperty.Cancel(); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Error in RunL. |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CSysApGanPropertyListener::RunError( TInt /*aError*/ ) |
|
96 { |
|
97 // ignore error |
|
98 return KErrNone; |
|
99 } |