|
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: Implementation for controlling S60 device lights. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <HtiLogging.h> |
|
21 #include "HtiPropertySubscriber.h" |
|
22 |
|
23 // CONSTANTS |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CHtiPropertySubscriber::CHtiPropertySubscriber |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CHtiPropertySubscriber::CHtiPropertySubscriber( TCallBack aCallBack, |
|
32 RProperty& aProperty) : CActive( EPriorityNormal ), |
|
33 iCallBack( aCallBack ), |
|
34 iProperty( aProperty ) |
|
35 { |
|
36 HTI_LOG_TEXT( "CHtiPropertySubscriber construct" ); |
|
37 CActiveScheduler::Add( this ); |
|
38 } |
|
39 |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CHtiPropertySubscriber::~CHtiPropertySubscriber |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CHtiPropertySubscriber::~CHtiPropertySubscriber() |
|
46 { |
|
47 HTI_LOG_TEXT( "CHtiPropertySubscriber destroy" ); |
|
48 Cancel(); |
|
49 } |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CHtiPropertySubscriber::Subscribe |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CHtiPropertySubscriber::Subscribe() |
|
57 { |
|
58 if ( !IsActive() ) |
|
59 { |
|
60 iProperty.Subscribe( iStatus ); |
|
61 SetActive(); |
|
62 } |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CHtiPropertySubscriber::Unsubscribe |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CHtiPropertySubscriber::Unsubscribe() |
|
71 { |
|
72 Cancel(); |
|
73 } |
|
74 |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CHtiPropertySubscriber::RunL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CHtiPropertySubscriber::RunL() |
|
81 { |
|
82 if ( iStatus.Int() == KErrNone ) |
|
83 { |
|
84 iCallBack.CallBack(); |
|
85 Subscribe(); |
|
86 } |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CHtiPropertySubscriber::DoCancel |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CHtiPropertySubscriber::DoCancel() |
|
95 { |
|
96 iProperty.Cancel(); |
|
97 } |
|
98 |
|
99 |
|
100 // End of file |