|
1 /* |
|
2 * Copyright (c) 2009 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 #include <e32cmn.h> |
|
19 #include "tsproplistener.h" |
|
20 |
|
21 // -------------------------------------------------------------------------- |
|
22 // CTsPropertyListener::CTsPropertyListener |
|
23 // -------------------------------------------------------------------------- |
|
24 // |
|
25 EXPORT_C CTsPropertyListener::CTsPropertyListener( |
|
26 TUid aCategory, TUint aKey, MTsPropertyChangeObserver& aObserver ) |
|
27 : CActive( CActive::EPriorityStandard), |
|
28 iObserver( aObserver ), iCategory( aCategory ), iKey( aKey ) |
|
29 { |
|
30 CActiveScheduler::Add( this ); |
|
31 TInt err = iProperty.Attach( iCategory, iKey ); |
|
32 if ( err == KErrNone ) |
|
33 { |
|
34 iProperty.Subscribe( iStatus ); |
|
35 SetActive(); |
|
36 } |
|
37 } |
|
38 |
|
39 // -------------------------------------------------------------------------- |
|
40 // CTsPropertyListener::~CTsPropertyListener |
|
41 // -------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CTsPropertyListener::~CTsPropertyListener() |
|
44 { |
|
45 Cancel(); |
|
46 iProperty.Close(); |
|
47 } |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // CTsPropertyListener::DoCancel |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 void CTsPropertyListener::DoCancel() |
|
54 { |
|
55 iProperty.Cancel(); |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CTsPropertyListener::RunL |
|
60 // -------------------------------------------------------------------------- |
|
61 // |
|
62 void CTsPropertyListener::RunL() |
|
63 { |
|
64 if ( iStatus.Int() != KErrCancel ) // when cancelling the subscribe it completes with KErrCancel |
|
65 { |
|
66 iObserver.PropertyChanged( iCategory, iKey ); |
|
67 iProperty.Subscribe( iStatus ); |
|
68 SetActive(); |
|
69 } |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CTsPropertyListener::RunError |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CTsPropertyListener::RunError( TInt /*aError*/ ) |
|
77 { |
|
78 iProperty.Subscribe( iStatus ); |
|
79 SetActive(); |
|
80 return KErrNone; |
|
81 } |
|
82 |
|
83 // end of file |