|
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 "irpropertychangeao.h" |
|
19 #include "irpropertyobserver.h" |
|
20 #include "irqlogger.h" |
|
21 |
|
22 CIRPropertyChangeAO::CIRPropertyChangeAO(MIRPropertyChangeObserverInterface* aObserver, const TUid& aCategory, |
|
23 const TUint aKey) : CActive(CActive::EPriorityStandard), iObserver(aObserver), iCategory(aCategory), iKey(aKey) |
|
24 { |
|
25 LOG_METHOD; |
|
26 } |
|
27 |
|
28 void CIRPropertyChangeAO::ConstructL() |
|
29 { |
|
30 LOG_METHOD; |
|
31 User::LeaveIfError(iProperty.Attach(iCategory, iKey)); |
|
32 CActiveScheduler::Add(this); |
|
33 } |
|
34 |
|
35 CIRPropertyChangeAO* CIRPropertyChangeAO::NewL( |
|
36 MIRPropertyChangeObserverInterface* aObserver, const TUid& aCategory, |
|
37 const TUint aKey) |
|
38 { |
|
39 LOG_METHOD; |
|
40 CIRPropertyChangeAO* self = new (ELeave) CIRPropertyChangeAO(aObserver, |
|
41 aCategory, aKey); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 CIRPropertyChangeAO::~CIRPropertyChangeAO() |
|
49 { |
|
50 Cancel(); |
|
51 iProperty.Close(); |
|
52 } |
|
53 |
|
54 void CIRPropertyChangeAO::ActivateL() |
|
55 { |
|
56 if (!IsActive()) |
|
57 { |
|
58 RunL(); |
|
59 } |
|
60 } |
|
61 |
|
62 void CIRPropertyChangeAO::RunL() |
|
63 { |
|
64 LOG_METHOD; |
|
65 |
|
66 if ( KErrNone == iStatus.Int() ) |
|
67 { |
|
68 TInt err = KErrNone; |
|
69 |
|
70 err = iProperty.Get(iValueInt); |
|
71 |
|
72 if ( KErrNone == err ) |
|
73 { |
|
74 iObserver->HandlePropertyChangeL(iCategory, iKey, iValueInt); |
|
75 } |
|
76 else |
|
77 { |
|
78 iObserver->HandlePropertyChangeErrorL(iCategory, iKey, err); |
|
79 } |
|
80 } |
|
81 |
|
82 iProperty.Subscribe(iStatus); |
|
83 SetActive(); |
|
84 |
|
85 //if the iStatus is error, ignore it. |
|
86 } |
|
87 |
|
88 void CIRPropertyChangeAO::DoCancel() |
|
89 { |
|
90 iProperty.Cancel(); |
|
91 } |
|
92 |
|
93 TBool CIRPropertyChangeAO::ValueInt(TInt& aValue) |
|
94 { |
|
95 TInt tempValue = 0; |
|
96 TInt err = iProperty.Get(tempValue); |
|
97 |
|
98 if ( KErrNone == err ) |
|
99 { |
|
100 iValueInt = tempValue; |
|
101 aValue = tempValue; |
|
102 } |
|
103 else |
|
104 { |
|
105 return EFalse; |
|
106 } |
|
107 |
|
108 return ETrue; |
|
109 } |
|
110 |