|
1 /* |
|
2 * Copyright (c) 2007 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: This is the implementation of the CallAudioControlProperty class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CallAudioControlCommon.h" |
|
20 #include "CallAudioControlProperty.h" |
|
21 #include "CallAudioControlImpl.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CCallAudioControlProperty::NewL |
|
25 // |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CCallAudioControlProperty* CCallAudioControlProperty::NewL( |
|
29 CCallAudioControlImpl* aImplParent, const TUid aUid, |
|
30 const TUint32 aKey, TAction aAction) |
|
31 { |
|
32 CCallAudioControlProperty* self = |
|
33 new (ELeave) CCallAudioControlProperty(); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(aImplParent, aUid, aKey, aAction); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CCallAudioControlProperty::CCallAudioControlProperty |
|
42 // C++ constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CCallAudioControlProperty::CCallAudioControlProperty() : |
|
46 CActive(EPriorityNormal) // , iSubscribed(EFalse) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CCallAudioControlProperty::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CCallAudioControlProperty::ConstructL( |
|
56 CCallAudioControlImpl* aImplParent, const TUid aUid, |
|
57 const TUint32 aKey, TAction aAction) |
|
58 { |
|
59 CAC_TRACE1(_L("CCallAudioControlProperty::ConstructL enter")); |
|
60 iImplParent = aImplParent; |
|
61 iAction = aAction; |
|
62 //Attach to P&S variable: |
|
63 User::LeaveIfError(iProperty.Attach(aUid, aKey)); |
|
64 CActiveScheduler::Add(this); |
|
65 CAC_TRACE1(_L("CCallAudioControlProperty::ConstructL exit")); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CCallAudioControlProperty::DestructL |
|
70 // Destructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CCallAudioControlProperty::~CCallAudioControlProperty() |
|
74 { |
|
75 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::~CCallAudioControlProperty enter"),this); |
|
76 // Cancel possibly outstanding asynchronous requests |
|
77 Cancel(); |
|
78 // Release the property handle |
|
79 iProperty.Close(); |
|
80 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::~CCallAudioControlProperty exit"),this); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // CCallAudioControlProperty::Subscribe |
|
85 // ?implementation_description |
|
86 // (other items were commented in a header). |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 void CCallAudioControlProperty::Subscribe() |
|
90 { |
|
91 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::Subscribe"),this); |
|
92 if (!IsActive()) |
|
93 { |
|
94 iProperty.Subscribe(iStatus); |
|
95 SetActive(); |
|
96 } |
|
97 // iSubscribed = ETrue; |
|
98 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::Subscribe: SetActive..."),this); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CCallAudioControlProperty::Unsubscribe |
|
103 // ?implementation_description |
|
104 // (other items were commented in a header). |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 void CCallAudioControlProperty::Unsubscribe() |
|
108 { |
|
109 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::Unsubscribe"),this); |
|
110 iProperty.Cancel(); |
|
111 Cancel(); |
|
112 // iSubscribed = EFalse; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CCallAudioControlProperty::Get |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CCallAudioControlProperty::Get(TInt& aValue) |
|
120 { |
|
121 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::Get"), this); |
|
122 TInt error = iProperty.Get(aValue); |
|
123 return error; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CCallAudioControlProperty::Set |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CCallAudioControlProperty::Set(TInt aValue) |
|
131 { |
|
132 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::Set"), this); |
|
133 TInt error = iProperty.Set(aValue); |
|
134 return error; |
|
135 } |
|
136 |
|
137 // |
|
138 // Methods required for CActive |
|
139 // |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CCallAudioControlProperty::DoCancel |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CCallAudioControlProperty::DoCancel() |
|
145 { |
|
146 iProperty.Cancel(); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CCallAudioControlProperty::RunL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CCallAudioControlProperty::RunL() |
|
154 { |
|
155 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::RunL enter"), this); |
|
156 TInt value; |
|
157 TInt err(KErrNone); |
|
158 |
|
159 if ( iStatus.Int() != KErrCancel ) |
|
160 { |
|
161 // Set self up for future notifications: |
|
162 // iSubscribed = EFalse; |
|
163 Subscribe(); |
|
164 |
|
165 err = iProperty.Get(value); |
|
166 |
|
167 if (err != KErrNone) |
|
168 { |
|
169 CAC_TRACE3(_L("CCallAudioControlProperty[%x]::RunL ERROR From Get: %d"), this, err); |
|
170 } |
|
171 else |
|
172 { |
|
173 CAC_TRACE2(_L("RunL: New value = %d..."), value); |
|
174 // Notify CallAudioControl of change: |
|
175 if (iImplParent != NULL) |
|
176 { |
|
177 CAC_TRACE1(_L("RunL: Calling NotifyL on CACImpl...")); |
|
178 iImplParent->NotifyL(iAction, err, value); |
|
179 } |
|
180 } |
|
181 } |
|
182 CAC_TRACE2(_L("CCallAudioControlProperty[%x]::RunL exit"), this); |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CCallAudioControlProperty::RunError |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 TInt CCallAudioControlProperty::RunError() |
|
190 { |
|
191 return KErrNone; |
|
192 } |
|
193 |
|
194 // End of file |
|
195 |