|
1 /* |
|
2 * Copyright (c) 2002 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 * Active object for handling RProperty events |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "McePropertySubscriber.h" |
|
23 |
|
24 // LOCAL CONSTANTS AND MACROS |
|
25 |
|
26 |
|
27 // ================= MEMBER FUNCTIONS ======================= |
|
28 |
|
29 CMcePropertySubscriber::CMcePropertySubscriber( TCallBack aCallBack, RProperty& aProperty ): |
|
30 CActive( EPriorityStandard ), iCallBack( aCallBack ), iProperty( aProperty ) |
|
31 { |
|
32 } |
|
33 |
|
34 void CMcePropertySubscriber::ConstructL() |
|
35 { |
|
36 CActiveScheduler::Add( this ); |
|
37 } |
|
38 |
|
39 CMcePropertySubscriber* CMcePropertySubscriber::NewL( TCallBack aCallBack, RProperty& aProperty ) |
|
40 { |
|
41 CMcePropertySubscriber* self = |
|
42 new (ELeave) CMcePropertySubscriber( |
|
43 aCallBack, aProperty ); |
|
44 |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CMcePropertySubscriber::~CMcePropertySubscriber() |
|
52 { |
|
53 Cancel(); |
|
54 } |
|
55 |
|
56 //------------------------------------------------------------------------------- |
|
57 //CMcePropertySubscriber::SubscribeL() |
|
58 //------------------------------------------------------------------------------- |
|
59 void CMcePropertySubscriber::SubscribeL() |
|
60 { |
|
61 if (!IsActive()) |
|
62 { |
|
63 iProperty.Subscribe( iStatus ); |
|
64 SetActive(); |
|
65 } |
|
66 } |
|
67 |
|
68 //------------------------------------------------------------------------------- |
|
69 //CMcePropertySubscriber::StopSubscribeL() |
|
70 //------------------------------------------------------------------------------- |
|
71 void CMcePropertySubscriber::StopSubscribe() |
|
72 { |
|
73 Cancel(); |
|
74 } |
|
75 |
|
76 //------------------------------------------------------------------------------- |
|
77 //CMcePropertySubscriber::RunL() |
|
78 //------------------------------------------------------------------------------- |
|
79 void CMcePropertySubscriber::RunL() |
|
80 { |
|
81 if ( iStatus.Int() == KErrNone ) |
|
82 { |
|
83 iCallBack.CallBack(); |
|
84 } |
|
85 SubscribeL(); |
|
86 } |
|
87 |
|
88 //------------------------------------------------------------------------------- |
|
89 //CMcePropertySubscriber::DoCancel() |
|
90 //------------------------------------------------------------------------------- |
|
91 void CMcePropertySubscriber::DoCancel() |
|
92 { |
|
93 iProperty.Cancel(); |
|
94 } |
|
95 |
|
96 |