|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of class CFlowControlChange |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include <e32property.h> |
|
23 |
|
24 #include "LoopbackConfig.h" |
|
25 #include "FlowControlChange.h" |
|
26 |
|
27 CFlowControlChange* CFlowControlChange::NewL(TUint aUnit, MFlowControlChangeCallBack* aCallback) |
|
28 { |
|
29 CFlowControlChange* self = new (ELeave) CFlowControlChange(aUnit, aCallback); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CFlowControlChange::CFlowControlChange(TUint aUnit, MFlowControlChangeCallBack* aCallback) |
|
34 : CActive(EPriorityStandard), iCallback(aCallback), iUnit(aUnit), iFlowControlIsOn(EFalse) |
|
35 { |
|
36 CActiveScheduler::Add(this); |
|
37 |
|
38 TBool flowControlIsOn = EFalse; |
|
39 iProperty.Attach(KUidPSCsyFlowControlCategory, iUnit); |
|
40 iProperty.Subscribe(iStatus); |
|
41 TInt ret = RProperty::Get(KUidPSCsyFlowControlCategory, iUnit, flowControlIsOn); |
|
42 if (ret == KErrNone) |
|
43 iFlowControlIsOn = flowControlIsOn; |
|
44 SetActive(); |
|
45 } |
|
46 |
|
47 CFlowControlChange::~CFlowControlChange() |
|
48 { |
|
49 Cancel(); |
|
50 iProperty.Close(); |
|
51 } |
|
52 |
|
53 /** |
|
54 @return ETrue if flow control is currently on, EFalse if it is not |
|
55 */ |
|
56 TBool CFlowControlChange::FlowControlIsOn() const |
|
57 { |
|
58 return iFlowControlIsOn; |
|
59 } |
|
60 |
|
61 /** |
|
62 Stops listening for changes to flow control |
|
63 */ |
|
64 void CFlowControlChange::DoCancel() |
|
65 { |
|
66 iProperty.Cancel(); |
|
67 } |
|
68 |
|
69 /** |
|
70 Notifies the callback of a change in flow control, and resubscribes to obtain future notifications of property changes |
|
71 */ |
|
72 void CFlowControlChange::RunL() |
|
73 { |
|
74 User::LeaveIfError(KErrNone); // To prevent LeaveScan warning |
|
75 |
|
76 // Resubscribe before retrieving the value so we don't miss any changes |
|
77 TInt status = iStatus.Int(); |
|
78 iProperty.Subscribe(iStatus); |
|
79 SetActive(); |
|
80 |
|
81 TBool flowControlIsOn = EFalse; |
|
82 if(status == KErrNone) |
|
83 { |
|
84 RProperty::Get(KUidPSCsyFlowControlCategory, iUnit, flowControlIsOn); |
|
85 } |
|
86 if (flowControlIsOn != iFlowControlIsOn) |
|
87 { |
|
88 iFlowControlIsOn = flowControlIsOn; |
|
89 if (iFlowControlIsOn) |
|
90 iCallback->StartFlowControl(); |
|
91 else |
|
92 iCallback->StopFlowControl(); |
|
93 } |
|
94 } |
|
95 |