|
1 /* |
|
2 * Copyright (c) 2005 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: For monitoring CS call events from Publish & Subscribe |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CMCEPoCOmaCsCallWatcher.h" |
|
22 #include "MCETestUIDebug.h" |
|
23 |
|
24 // EXTERNAL DATA STRUCTURES |
|
25 |
|
26 // EXTERNAL FUNCTION PROTOTYPES |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // LOCAL CONSTANTS AND MACROS |
|
33 |
|
34 // MODULE DATA STRUCTURES |
|
35 |
|
36 // LOCAL FUNCTION PROTOTYPES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CMCEPoCOmaCSCallWatcher::CMCEPoCOmaCSCallWatcher() |
|
44 // C++ constructor |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CMCEPoCOmaCSCallWatcher::CMCEPoCOmaCSCallWatcher() : |
|
48 CActive( EPriorityStandard ) |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CMCEPoCOmaCSCallWatcher::ConstructL() |
|
54 // Symbian OS default constructor |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CMCEPoCOmaCSCallWatcher::ConstructL( MMcePoCOmaCSStateObserver* aObserver ) |
|
58 { |
|
59 iCsCallNotify = aObserver; |
|
60 |
|
61 // Add this active object to the scheduler. |
|
62 CActiveScheduler::Add( this ); |
|
63 // Attach to the property |
|
64 User::LeaveIfError( iProperty.Attach( KPSUidCtsyCallInformation, |
|
65 KCTsyCallState) ); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CMCEPoCOmaCSCallWatcher::NewL() |
|
70 // Constructs a new entry with given values. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CMCEPoCOmaCSCallWatcher* CMCEPoCOmaCSCallWatcher::NewL( MMcePoCOmaCSStateObserver* aObserver ) |
|
74 { |
|
75 CMCEPoCOmaCSCallWatcher* self = new (ELeave) CMCEPoCOmaCSCallWatcher(); |
|
76 |
|
77 CleanupStack::PushL(self); |
|
78 |
|
79 self->ConstructL( aObserver ); |
|
80 |
|
81 CleanupStack::Pop(); |
|
82 |
|
83 return self; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMCEPoCOmaCSCallWatcher::CMCEPoCOmaCSCallWatcher() |
|
88 // Destructor |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CMCEPoCOmaCSCallWatcher::~CMCEPoCOmaCSCallWatcher() |
|
92 { |
|
93 |
|
94 // Check if object is in active scheduler’s list of active objects |
|
95 if( IsAdded() ) |
|
96 { |
|
97 Deque(); // Cancel outstanding request and remove from active scheduler’s list |
|
98 } |
|
99 |
|
100 // Close handle, call after Deque() !!! |
|
101 // DoCancel() will call iPropeerty.Cancel() |
|
102 iProperty.Close(); |
|
103 |
|
104 // Clear RPointerArray to avoid memory problems |
|
105 //iCsCallNotifyList.Reset(); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CMCEPoCOmaCSCallWatcher::Subscribe() |
|
110 // Starts listening KPSUidCurrentCallValue event |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 TInt CMCEPoCOmaCSCallWatcher::Subscribe() |
|
114 { |
|
115 TInt error = KErrInUse; |
|
116 |
|
117 if( !IsActive() ) |
|
118 { |
|
119 MCE_TESTUI_DEBUG1( "Subscribed to call state monitoring" ); |
|
120 // Request CS Call events |
|
121 iProperty.Subscribe( iStatus ); |
|
122 SetActive(); |
|
123 error = KErrNone; |
|
124 } |
|
125 else |
|
126 { |
|
127 } |
|
128 |
|
129 return error; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMCEPoCOmaCSCallWatcher::StopSubscribe() |
|
134 // Stops listening system agent events |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CMCEPoCOmaCSCallWatcher::StopSubscribe() |
|
138 { |
|
139 Cancel(); // From CActive |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CMCEPoCOmaCSCallWatcher::RunL() |
|
144 // Call all subscribed clients with parameters |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CMCEPoCOmaCSCallWatcher::RunL() |
|
148 { |
|
149 TInt err( KErrNone ); |
|
150 |
|
151 // Check iStatus |
|
152 if( iStatus != KErrNone ) |
|
153 { |
|
154 if( iStatus != KErrCancel ) |
|
155 { |
|
156 Subscribe(); // Subscribe again |
|
157 } |
|
158 |
|
159 return; // There was some error, so don't notify this event to clients |
|
160 } |
|
161 |
|
162 // Subscribing again before getting the current value |
|
163 // improves the chance that concurrent update is not missed |
|
164 Subscribe(); |
|
165 |
|
166 TInt leaveError( KErrNone ); |
|
167 |
|
168 // Get current value |
|
169 TInt value( KErrNone ); |
|
170 iProperty.Get( value ); |
|
171 |
|
172 MCE_TESTUI_DEBUG3("Call state changed to: ", value ); |
|
173 // notify CS observers |
|
174 //for (nextIndex = 0; nextIndex < iCsCallNotifyList.Count(); nextIndex++ ) |
|
175 // { |
|
176 TRAP( err, iCsCallNotify->CsStatusChangedL( |
|
177 TranslateToPoCCsState( (/*TPSTelephonyCallState*/TPSCTsyCallState)value ) ) ); |
|
178 if( err == KErrNoMemory ) |
|
179 { |
|
180 leaveError = err; |
|
181 } |
|
182 |
|
183 //} |
|
184 |
|
185 User::LeaveIfError( leaveError ); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CMCEPoCOmaCSCallWatcher::RunError |
|
190 // Handles errors |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 TInt CMCEPoCOmaCSCallWatcher::RunError( TInt aError ) |
|
194 { |
|
195 if( aError == KErrNoMemory ) |
|
196 { |
|
197 Subscribe(); // Continue subscribe from PubSub |
|
198 return KErrNoMemory; |
|
199 } |
|
200 |
|
201 return KErrNone; |
|
202 } |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CMCEPoCOmaCSCallWatcher::DoCancel() |
|
205 // Cancels event subscribe |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CMCEPoCOmaCSCallWatcher::DoCancel() |
|
209 { |
|
210 iProperty.Cancel(); |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CMCEPoCOmaCSCallWatcher::AddObserverL() |
|
215 // For subscribing CS events |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 /*void CMCEPoCOmaCSCallWatcher::AddObserverL( const MPoCOmaCSStateObserver* aObserver ) |
|
219 { |
|
220 iCsCallNotify = aObserver; |
|
221 |
|
222 Subscribe(); // Subscribe to PubSub events |
|
223 |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CMCEPoCOmaCSCallWatcher::RemoveObserver() |
|
228 // Cancels CS call event listening |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 void CMCEPoCOmaCSCallWatcher::RemoveObserver( const MPoCOmaCSStateObserver* aObserver ) |
|
232 { |
|
233 StopSubscribe(); // Stop subscribing PubSub events |
|
234 } |
|
235 */ |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CMCEPoCOmaCSCallWatcher::CsState() |
|
238 // For having latest status of CS call |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 TPoCOmaCsState CMCEPoCOmaCSCallWatcher::CsState() |
|
242 { |
|
243 TInt value ( KErrNone ); |
|
244 // Get attached value |
|
245 iProperty.Get ( value ); |
|
246 |
|
247 TPoCOmaCsState currentCsState = TranslateToPoCCsState( (/*TPSTelephonyCallState*/ TPSCTsyCallState)value ); |
|
248 |
|
249 return currentCsState; |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CMCEPoCOmaCSCallWatcher::TranslateToPoCCsState() |
|
254 // Translates TSACurrentCall state to TPoCCsState state |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 TPoCOmaCsState CMCEPoCOmaCSCallWatcher::TranslateToPoCCsState( |
|
258 /*TPSTelephonyCallState*/TPSCTsyCallState aPSCsCallState ) |
|
259 { |
|
260 TPoCOmaCsState poCCsState( EPoCOmaCallStateNone ); |
|
261 |
|
262 switch( aPSCsCallState ) |
|
263 { |
|
264 case EPSCTsyCallStateUninitialized: |
|
265 poCCsState = EPoCOmaCallUninitialized; |
|
266 break; |
|
267 |
|
268 case EPSCTsyCallStateNone: |
|
269 poCCsState = EPoCOmaCallStateNone; |
|
270 break; |
|
271 |
|
272 case EPSCTsyCallStateAlerting: |
|
273 poCCsState = EPoCOmaCallStateAlerting; |
|
274 break; |
|
275 |
|
276 case EPSCTsyCallStateRinging: |
|
277 poCCsState = EPoCOmaCallStateRinging; |
|
278 break; |
|
279 |
|
280 case EPSCTsyCallStateDialling: |
|
281 poCCsState = EPoCOmaCallStateDialling; |
|
282 break; |
|
283 |
|
284 case EPSCTsyCallStateAnswering: |
|
285 poCCsState = EPoCOmaCallStateAnswering; |
|
286 break; |
|
287 |
|
288 case EPSCTsyCallStateDisconnecting: |
|
289 poCCsState = EPoCOmaCallStateDisconnecting; |
|
290 break; |
|
291 |
|
292 case EPSCTsyCallStateConnected: |
|
293 poCCsState = EPoCOmaCallStateConnected; |
|
294 break; |
|
295 |
|
296 case EPSCTsyCallStateHold: |
|
297 poCCsState = EPoCOmaCallStateHold; |
|
298 break; |
|
299 |
|
300 default: |
|
301 poCCsState = EPoCOmaCallStateNone; |
|
302 } |
|
303 |
|
304 return poCCsState; |
|
305 } |
|
306 // End of File |
|
307 |