|
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 * Implements the functionality of the System Agent observer |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 |
|
23 #include <PSVariables.h> |
|
24 #include <coreapplicationuisdomainpskeys.h> |
|
25 |
|
26 #include "CLogsSystemAgent.h" |
|
27 #include "MLogsObserver.h" |
|
28 #include "MLogsCallObserver.h" |
|
29 |
|
30 #include <etel.h> |
|
31 //#include <etelmm.h> |
|
32 #include <mmtsy_names.h> |
|
33 |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CLogsSystemAgent::CLogsSystemAgent |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 CLogsSystemAgent::CLogsSystemAgent( |
|
42 MLogsObserver* aObserver, |
|
43 MLogsCallObserver* aCallObserver ) : |
|
44 CActive( EPriorityStandard ) |
|
45 { |
|
46 iObserver = aObserver; |
|
47 iCallObserver = aCallObserver; |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CLogsSystemAgent::ConstructL |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 void CLogsSystemAgent::ConstructL() |
|
55 { |
|
56 // CActiveScheduler::Add( this ); |
|
57 |
|
58 //Attach to neeeded Publish and Subscribe properties |
|
59 TInt ret = iPropertyGprs.Attach( KUidSystemCategory, KPSUidGprsStatusValue ); //TUid aCategory, TUint aKey |
|
60 User::LeaveIfError( ret ); |
|
61 |
|
62 ret = iPropertyWcdma.Attach( KUidSystemCategory, KPSUidWcdmaStatusValue ); |
|
63 User::LeaveIfError( ret ); |
|
64 |
|
65 // ret = iPropertyCallHandling.Attach( KPSUidTelephonyCallHandling, KTelephonyCallState ); |
|
66 // User::LeaveIfError( ret ); |
|
67 |
|
68 // ret = iPropertyCallStatus.Attach( KPSUidCallState, KPSUidCallStateValue ); |
|
69 // User::LeaveIfError( ret ); |
|
70 |
|
71 //Attach to Supplementary Services Settings |
|
72 User::LeaveIfError( iSSSettings.Open() ); |
|
73 |
|
74 // RunL(); |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CLogsSystemAgent::NewL |
|
79 // ---------------------------------------------------------------------------- |
|
80 // |
|
81 CLogsSystemAgent* CLogsSystemAgent::NewL( |
|
82 MLogsObserver* aObserver, |
|
83 MLogsCallObserver* aCallObserver ) |
|
84 { |
|
85 CLogsSystemAgent* self = new ( ELeave ) CLogsSystemAgent( aObserver, aCallObserver ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop(); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------- |
|
93 // CLogsSystemAgent::~CLogsSystemAgent |
|
94 // ---------------------------------------------------------------------------- |
|
95 // |
|
96 CLogsSystemAgent::~CLogsSystemAgent() |
|
97 { |
|
98 // Cancel(); |
|
99 |
|
100 iPropertyGprs.Close(); |
|
101 iPropertyWcdma.Close(); |
|
102 //iPropertyCallHandling.Close(); |
|
103 //iPropertyCallStatus.Close(); |
|
104 iSSSettings.Close(); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CLogsSystemAgent::AlsSupport |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 TBool CLogsSystemAgent::AlsSupport() |
|
112 { |
|
113 TInt value; |
|
114 |
|
115 if( iSSSettings.Get( ESSSettingsAls, value ) ) |
|
116 { |
|
117 return EFalse; |
|
118 } |
|
119 if( value == ESSSettingsAlsNotSupported ) |
|
120 { |
|
121 return EFalse; |
|
122 } |
|
123 return ETrue; |
|
124 |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CLogsSystemAgent::GprsConnectionActive |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 TBool CLogsSystemAgent::GprsConnectionActive() |
|
132 { |
|
133 if( IsGprs() ) |
|
134 { |
|
135 TInt stateGprs(0); |
|
136 iPropertyGprs.Get( KUidSystemCategory, KPSUidGprsStatusValue, stateGprs ); //TUid aCategory, TUint aKey, TInt& aValue |
|
137 |
|
138 if( stateGprs == EPSGprsContextActive || |
|
139 stateGprs == EPSGprsSuspend || |
|
140 stateGprs == EPSGprsContextActivating || |
|
141 stateGprs == EPSGprsMultibleContextActive ) |
|
142 { |
|
143 return ETrue; |
|
144 } |
|
145 else |
|
146 { |
|
147 return EFalse; |
|
148 } |
|
149 } |
|
150 else |
|
151 { |
|
152 TInt stateWcdma(0); |
|
153 iPropertyWcdma.Get( KUidSystemCategory, KPSUidWcdmaStatusValue, stateWcdma ); |
|
154 |
|
155 if( stateWcdma == EPSWcdmaContextActive || |
|
156 stateWcdma == EPSWcdmaSuspend || |
|
157 stateWcdma == EPSWcdmaContextActivating || |
|
158 stateWcdma == EPSWcdmaMultipleContextActive ) |
|
159 { |
|
160 return ETrue; |
|
161 } |
|
162 else |
|
163 { |
|
164 return EFalse; |
|
165 } |
|
166 } |
|
167 |
|
168 |
|
169 } |
|
170 |
|
171 /***************************************************** |
|
172 TBool CLogsSystemAgent::CallActive( TBool &aValue ) |
|
173 { |
|
174 TInt state(0); |
|
175 TInt ret = iPropertyCallHandling.Get( KPSUidTelephonyCallHandling, KTelephonyCallState, state ); //TUid aCategory, TUint aKey, TInt& aValue |
|
176 |
|
177 //See TelephonyInternalPSKeys.h |
|
178 if( state == EPSTelephonyCallStateConnected ) //This covers voice, video, voip etc call types |
|
179 { |
|
180 aValue = ETrue; |
|
181 } |
|
182 else |
|
183 { |
|
184 aValue = EFalse; |
|
185 } |
|
186 |
|
187 return ret; |
|
188 } |
|
189 *****************************************************/ |
|
190 |
|
191 // ---------------------------------------------------------------------------- |
|
192 // CLogsSystemAgent::IsGprs |
|
193 // ---------------------------------------------------------------------------- |
|
194 // |
|
195 TBool CLogsSystemAgent::IsGprs() |
|
196 { |
|
197 RTelServer telServer; |
|
198 RMobilePhone mobilePhone; |
|
199 TInt error = telServer.Connect(); |
|
200 |
|
201 if( error != KErrNone ) |
|
202 { |
|
203 return ETrue; |
|
204 } |
|
205 error = telServer.LoadPhoneModule( KMmTsyModuleName ); |
|
206 |
|
207 if( error != KErrNone ) |
|
208 { |
|
209 telServer.Close(); |
|
210 return ETrue; |
|
211 } |
|
212 |
|
213 RTelServer::TPhoneInfo phoneInfo; |
|
214 error = telServer.GetPhoneInfo( 0, phoneInfo ); |
|
215 |
|
216 if( error != KErrNone ) |
|
217 { |
|
218 telServer.Close(); |
|
219 return ETrue; |
|
220 } |
|
221 error = mobilePhone.Open( telServer, phoneInfo.iName ); |
|
222 |
|
223 if( error != KErrNone ) |
|
224 { |
|
225 telServer.Close(); |
|
226 return ETrue; |
|
227 } |
|
228 |
|
229 RMobilePhone::TMobilePhoneNetworkMode networkMode = RMobilePhone::ENetworkModeGsm; |
|
230 error = mobilePhone.GetCurrentMode( networkMode ); |
|
231 mobilePhone.Close(); |
|
232 telServer.Close(); |
|
233 |
|
234 if( error == KErrNone && networkMode == RMobilePhone::ENetworkModeWcdma ) |
|
235 { |
|
236 return EFalse; |
|
237 } |
|
238 else |
|
239 { |
|
240 return ETrue; |
|
241 } |
|
242 } |
|
243 |
|
244 |
|
245 //Reset missed Poc call notification |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CLogsSystemAgent::ResetNewMissedPocCalls |
|
248 // ---------------------------------------------------------------------------- |
|
249 // |
|
250 void CLogsSystemAgent::ResetNewMissedPocCalls() |
|
251 { |
|
252 RProperty property; |
|
253 |
|
254 if ( property.Attach( KPSUidCoreApplicationUIs, KCoreAppUIsPoCMissedIndicator ) == KErrNone ) |
|
255 { |
|
256 property.Set( ECoreAppUIsPocMissedIndicatorOff ); |
|
257 property.Close(); |
|
258 } |
|
259 |
|
260 } |
|
261 |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CLogsSystemAgent::SetObserver |
|
265 // ---------------------------------------------------------------------------- |
|
266 // |
|
267 void CLogsSystemAgent::SetObserver( MLogsObserver* /*aObserver*/ ) |
|
268 { |
|
269 } |
|
270 |
|
271 |
|
272 |
|
273 // ---------------------------------------------------------------------------- |
|
274 // CLogsSystemAgent::DoCancel |
|
275 // ---------------------------------------------------------------------------- |
|
276 // |
|
277 void CLogsSystemAgent::DoCancel() |
|
278 { |
|
279 // iProperty.Cancel(); |
|
280 // FLOG( _L("SystemAgent: DoCancel")); |
|
281 } |
|
282 |
|
283 |
|
284 // ---------------------------------------------------------------------------- |
|
285 // CLogsSystemAgent::RunL |
|
286 // ---------------------------------------------------------------------------- |
|
287 // |
|
288 void CLogsSystemAgent::RunL() |
|
289 { |
|
290 //(If telephone status changes need to be observed, below can be added code to call the |
|
291 // iCallObserver->CallStateChangedL similarly as is in 2.8) |
|
292 // |
|
293 // // Resubscribe before processing new value to prevent missing updates |
|
294 // iPropertyCallStatus.Subscribe( iStatus ); |
|
295 // SetActive(); |
|
296 // |
|
297 // // Property updated, try to get new value |
|
298 // TInt state = 0; |
|
299 // |
|
300 // if( iCallObserver && iPropertyCallStatus.Get( state ) == KErrNone ) |
|
301 // { |
|
302 // FLOG_1( _L("SystemAgent: iPropertyCallStatus.Get() %d"), state ); |
|
303 // iCallObserver->CallStateChangedL( state ); //EPSCallStateRinging etc... |
|
304 // } |
|
305 } |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 // End of File |