|
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: Household private class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <exception> // must be before e32base.h so uncaught_exception gets defined |
|
19 #include <starterclient.h> |
|
20 #include <telinternalpskeys.h> |
|
21 // <-- QT PHONE START --> |
|
22 //#include <activeidle2domainpskeys.h> |
|
23 #include <QLocale> |
|
24 #include <QTranslator> |
|
25 // <-- QT PHONE END --> |
|
26 #include <telremotepartyinformationpskeys.h> |
|
27 #include <telinformationpskeys.h> |
|
28 #include <UikonInternalPSKeys.h> |
|
29 #include <startupdomainpskeys.h> |
|
30 #include <featmgr.h> // for FeatureManager |
|
31 //#include <phoneui.hrh> |
|
32 #include <hbmainwindow.h> |
|
33 #include "phoneconstants.h" |
|
34 #include "cphonelogger.h" |
|
35 #include "cphonepubsubproxy.h" |
|
36 #include "cphoneqwertyhandler.h" |
|
37 #include "cphoneuicontroller.h" |
|
38 #include "phoneuihousehold_p.h" |
|
39 #include "phoneuiqtviewadapter.h" |
|
40 #include "phoneuiqtview.h" |
|
41 #include "phoneuikeyeventadapter.h" |
|
42 #include "phoneuicommandadapter.h" |
|
43 #include "phonenotecontroller.h" |
|
44 //#include "qtcall.h" |
|
45 |
|
46 PhoneUiHouseHoldPrivate::PhoneUiHouseHoldPrivate(HbMainWindow &window) : |
|
47 iAppsReady (0), iStartupSignalRecoveryId (0), iLightIdleReached (EFalse), |
|
48 iOnScreenDialer (EFalse), iQwertyHandler (0), iPhoneUIController (0), |
|
49 m_window (window) |
|
50 { |
|
51 qDebug("phoneui - Start phoneapp"); |
|
52 |
|
53 TRAPD( error, ConstructL() ); |
|
54 qt_symbian_throwIfError(error); |
|
55 } |
|
56 |
|
57 PhoneUiHouseHoldPrivate::~PhoneUiHouseHoldPrivate() |
|
58 { |
|
59 delete iKeyEventAdapter; |
|
60 delete iCommandAdapter; |
|
61 delete iPhoneUIController; |
|
62 delete iViewAdapter; |
|
63 } |
|
64 |
|
65 TInt PhoneUiHouseHoldPrivate::DoStartupSignalL( TAny* aAny ) |
|
66 { |
|
67 PhoneUiHouseHoldPrivate* appUi = |
|
68 static_cast< PhoneUiHouseHoldPrivate* >( aAny ); |
|
69 |
|
70 return |
|
71 !appUi->iLightIdleReached ? |
|
72 appUi->DoStartupSignalIdleL() : |
|
73 appUi->DoStartupSignalSecurityL(); |
|
74 } |
|
75 |
|
76 TInt PhoneUiHouseHoldPrivate::DoStartupSignalIdleL() |
|
77 { |
|
78 TBool idleReached = EFalse; |
|
79 |
|
80 // <-- QT PHONE START --> |
|
81 // Check if Idle application has been started. |
|
82 const TInt idleUid = 0x20022F35; /*CPhonePubSubProxy::Instance()->Value( |
|
83 KPSUidAiInformation, |
|
84 KActiveIdleUid );*/ |
|
85 // <-- QT PHONE END --> |
|
86 qDebug("phoneui::DoStartupSignalIdleL() idleUID=%d", idleUid); |
|
87 |
|
88 if ( idleUid != 0 && idleUid != KErrNotFound ) |
|
89 { |
|
90 // Idle application has already started |
|
91 if ( !( iAppsReady & EPhoneIdleStartedUp ) ) |
|
92 { |
|
93 qDebug("phoneui::DoStartupSignalIdleL() Idle App started "); |
|
94 iAppsReady += EPhoneIdleStartedUp; |
|
95 |
|
96 // Remove Phone application from Fast Swap Window. |
|
97 // iPhoneViewController->SetHiddenL( ETrue ); |
|
98 |
|
99 // Set Idle's UID to PubSub. |
|
100 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
101 KPSUidUikon, |
|
102 KUikVideoCallTopApp, |
|
103 idleUid ); |
|
104 |
|
105 // <-- QT PHONE START --> |
|
106 // hack to make sure EPhonePhase1Ok is set - to be fixed properly |
|
107 idleReached = true; |
|
108 qDebug("phoneui::DoStartupSignalIdleL() Phone and Idle apps have both been started"); |
|
109 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
110 KPSUidStartup, |
|
111 KPSPhonePhase1Ok, |
|
112 EPhonePhase1Ok ); |
|
113 // <-- QT PHONE END --> |
|
114 } |
|
115 } |
|
116 else |
|
117 { |
|
118 // <-- QT PHONE START --> |
|
119 /*qDebug("phoneui::DoStartupSignalIdleL() NotifyChangeL(KPSUidAiInformation,KActiveIdleUid) "); |
|
120 CPhonePubSubProxy::Instance()->NotifyChangeL( |
|
121 KPSUidAiInformation, |
|
122 KActiveIdleUid, |
|
123 this );*/ |
|
124 // <-- QT PHONE END --> |
|
125 } |
|
126 |
|
127 // <-- QT PHONE START --> |
|
128 /* const TInt current = CPhonePubSubProxy::Instance()->Value( |
|
129 KPSUidStartup, |
|
130 KPSGlobalSystemState ); |
|
131 |
|
132 qDebug("phoneui::DoStartupSignalIdleL() System state=%d ", current); |
|
133 if ( current == ESwStateSelfTestOK || |
|
134 current == ESwStateCriticalPhaseOK ) |
|
135 { |
|
136 // Check that both the Phone and Idle applications are ready |
|
137 idleReached = ( iAppsReady & EPhoneStartedUp ) && |
|
138 ( iAppsReady & EPhoneIdleStartedUp ); |
|
139 |
|
140 if ( idleReached ) |
|
141 { |
|
142 qDebug("phoneui::DoStartupSignalIdleL() Phone and Idle apps have both been started"); |
|
143 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
144 KPSUidStartup, |
|
145 KPSPhonePhase1Ok, |
|
146 EPhonePhase1Ok ); |
|
147 } |
|
148 } |
|
149 else |
|
150 { |
|
151 idleReached = ( iAppsReady & EPhoneIdleStartedUp ) && |
|
152 ( current == ESwStateEmergencyCallsOnly || |
|
153 current == ESwStateNormalRfOn || |
|
154 current == ESwStateNormalRfOff || |
|
155 current == ESwStateNormalBTSap ); |
|
156 |
|
157 |
|
158 } |
|
159 */ |
|
160 // <-- QT PHONE END --> |
|
161 |
|
162 if ( idleReached ) |
|
163 { |
|
164 qDebug("phoneui::DoStartupSignalIdleL() Idle reached!"); |
|
165 // Now err == KErrNone and it means that |
|
166 // we have succeeded in signalling. |
|
167 CPhoneRecoverySystem::Instance()->EnablePreconditionL(); |
|
168 |
|
169 // Update the Phone light idle flag |
|
170 iLightIdleReached = ETrue; |
|
171 |
|
172 // Notify the UI controller that the phone is ready |
|
173 iPhoneUIController->HandlePhoneStartupL(); |
|
174 } |
|
175 else |
|
176 { |
|
177 qDebug("phoneui::DoStartupSignalIdleL() Idle is not reached yet!"); |
|
178 // Idle has not been reached yet. Indicate to the recovery |
|
179 // system that this iteration has failed so that it will |
|
180 // try again at a later time. |
|
181 User::Leave( KErrNotReady ); |
|
182 } |
|
183 |
|
184 return KErrNone; |
|
185 } |
|
186 |
|
187 TInt PhoneUiHouseHoldPrivate::DoStartupSignalSecurityL() |
|
188 { |
|
189 TInt err = KErrNone; |
|
190 return err; |
|
191 } |
|
192 |
|
193 // <-- QT PHONE START --> |
|
194 void PhoneUiHouseHoldPrivate::HandlePropertyChangedL( |
|
195 const TUid& aCategory, const TUint /*aKey*/, const TInt /*aValue*/) |
|
196 { |
|
197 qDebug("phoneui::HandlePropertyChangedL()"); |
|
198 |
|
199 |
|
200 /*if ( aCategory == KPSUidAiInformation ) |
|
201 { |
|
202 // Call state event |
|
203 if ( aKey == KActiveIdleUid ) |
|
204 { |
|
205 |
|
206 TInt idleUid = aValue; |
|
207 |
|
208 // If idle startup is ok. |
|
209 if ( idleUid != 0 ) |
|
210 { |
|
211 // If idle startup is ok for the first time, then recover |
|
212 // the Start signal processing |
|
213 if ( !( iAppsReady & EPhoneIdleStartedUp ) ) |
|
214 { |
|
215 qDebug("phoneui::HandlePropertyChangedL() Idle App started!"); |
|
216 iAppsReady += EPhoneIdleStartedUp; |
|
217 // Try to update the startup signal again |
|
218 CPhoneRecoverySystem::Instance()->RecoverNow( |
|
219 iStartupSignalRecoveryId, |
|
220 CTeleRecoverySystem::EPhonePriorityHigh ); |
|
221 // Remove Phone application from Fast Swap Window. |
|
222 // iPhoneViewController->SetHiddenL( ETrue ); |
|
223 // Set Idle's UID to PubSub. |
|
224 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
225 KPSUidUikon, |
|
226 KUikVideoCallTopApp, |
|
227 idleUid ); |
|
228 } |
|
229 } |
|
230 } |
|
231 }*/ |
|
232 // <-- QT PHONE END --> |
|
233 if ( aCategory == KPSUidStartup ) |
|
234 { |
|
235 |
|
236 const TInt startupState = CPhonePubSubProxy::Instance()->Value( |
|
237 KPSUidStartup, |
|
238 KPSGlobalSystemState ); |
|
239 |
|
240 qDebug("phoneui::HandlePropertyChangedL() StartupState value=%d", startupState ); |
|
241 |
|
242 if ( startupState == ESwStateCriticalPhaseOK || |
|
243 startupState == ESwStateEmergencyCallsOnly || |
|
244 startupState == ESwStateNormalRfOn || |
|
245 startupState == ESwStateNormalRfOff || |
|
246 startupState == ESwStateNormalBTSap ) |
|
247 { |
|
248 qDebug("phoneui::HandlePropertyChangedL() Try to update the startup signal again..." ); |
|
249 // Try to update the startup signal again |
|
250 CPhoneRecoverySystem::Instance()->RecoverNow( |
|
251 iStartupSignalRecoveryId, |
|
252 CTeleRecoverySystem::EPhonePriorityHigh ); |
|
253 } |
|
254 } |
|
255 } |
|
256 |
|
257 void PhoneUiHouseHoldPrivate::ConstructL() |
|
258 { |
|
259 new( ELeave ) CPhoneLogger( KUidPhoneUILoggerSingleton ); |
|
260 FeatureManager::InitializeLibL(); |
|
261 |
|
262 QString locale = QLocale::system ().name (); |
|
263 QTranslator translator; |
|
264 QString path = QString("z:\\resource\\qt\\translations\\"); |
|
265 QString filename = QString("telephone_"); |
|
266 bool ret = translator.load(QString(path + filename + locale)); |
|
267 qDebug() <<"PhoneUiHouseHoldPrivate::ConstructL() translator.load:" <<ret; |
|
268 qApp->installTranslator(&translator); |
|
269 |
|
270 PhoneUIQtView *view = new PhoneUIQtView(m_window); |
|
271 iViewAdapter = new PhoneUIQtViewAdapter(*view); |
|
272 iPhoneUIController = CPhoneUIController::NewL(iViewAdapter); |
|
273 |
|
274 m_window.addView (view); |
|
275 m_window.setCurrentView (view); |
|
276 m_window.scene ()->setFocusItem (view); |
|
277 iQwertyHandler = CPhoneQwertyHandler::NewL(); |
|
278 iKeyEventAdapter = new PhoneUIKeyEventAdapter (*iPhoneUIController); |
|
279 iCommandAdapter = new PhoneUiCommandAdapter (*iPhoneUIController); |
|
280 QObject::connect(view, SIGNAL(dialpadIsAboutToClose()), iViewAdapter, SLOT(dialpadClosed())); |
|
281 QObject::connect(view, SIGNAL(keyReleased(QKeyEvent *)), iViewAdapter, SLOT(keyReleased (QKeyEvent *))); |
|
282 QObject::connect(view, SIGNAL(keyPressed (QKeyEvent *)), iKeyEventAdapter, SLOT(keyPressed (QKeyEvent *))); |
|
283 QObject::connect(view, SIGNAL(keyReleased (QKeyEvent *)), iKeyEventAdapter, SLOT(keyReleased (QKeyEvent *))); |
|
284 QObject::connect(view, SIGNAL(command (int)), iCommandAdapter, SLOT(handleCommand (int)), |
|
285 Qt::QueuedConnection); // async to enable deletion of widget during signal handling |
|
286 |
|
287 QObject::connect(iViewAdapter->noteController(), SIGNAL(command (int)), |
|
288 iCommandAdapter, SLOT(handleCommand (int))); |
|
289 |
|
290 // Disable default Send key functionality in application framework |
|
291 CAknAppUi *appUi = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi()); |
|
292 appUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | |
|
293 CAknAppUiBase::EDisableSendKeyLong ); |
|
294 |
|
295 // CLI Name. |
|
296 TInt err = RProperty::Define( |
|
297 KPSUidTelRemotePartyInformation, |
|
298 KTelCLIName, |
|
299 RProperty::EText, |
|
300 KPhoneReadPolicy, |
|
301 KPhoneWritePolicy ); |
|
302 |
|
303 // CLI Number. |
|
304 err = RProperty::Define( |
|
305 KPSUidTelRemotePartyInformation, |
|
306 KTelCLINumber, |
|
307 RProperty::EText, |
|
308 KPhoneReadPolicy, |
|
309 KPhoneWritePolicy ); |
|
310 |
|
311 // Define the top application system property |
|
312 err = RProperty::Define( |
|
313 KPSUidUikon, |
|
314 KUikVideoCallTopApp, |
|
315 RProperty::EInt, |
|
316 KPhoneReadPolicy, |
|
317 KPhoneWritePolicy ); |
|
318 |
|
319 |
|
320 // Startup event signalling |
|
321 // Define the telephony application system property |
|
322 |
|
323 err = RProperty::Define( |
|
324 KPSUidTelInformation, |
|
325 KTelPhoneUid, |
|
326 RProperty::EInt, |
|
327 KPhoneReadPolicy, |
|
328 KPhoneWritePolicy ); |
|
329 |
|
330 // DefineNewPSKeys: |
|
331 |
|
332 // UID: KPSUidTelInternalInformation: |
|
333 err = RProperty::Define( |
|
334 KPSUidTelInternalInformation, |
|
335 KTelRemotePartyContactInfo, |
|
336 RProperty::EByteArray, |
|
337 KPhoneReadPolicy, |
|
338 KPhoneWritePolicy ); |
|
339 |
|
340 // VT UID. |
|
341 err = RProperty::Define( |
|
342 KPSUidTelInternalInformation, |
|
343 KTelVideoCallUid, |
|
344 RProperty::EInt, |
|
345 KPhoneReadPolicy, |
|
346 KPhoneWritePolicy ); |
|
347 |
|
348 // TELINTERNALPSKEY CHANGE |
|
349 // Move to AudioHandling |
|
350 // UID: KPSUidTelAudioPreference |
|
351 // Call Audio Routing |
|
352 err = RProperty::Define( |
|
353 KPSUidTelAudioPreference, |
|
354 KTelAudioOutput, |
|
355 RProperty::EInt, |
|
356 KPhoneReadPolicyAlwaysPass, |
|
357 KPhoneWritePolicy ); |
|
358 |
|
359 // UID: KPSUidNEInformation |
|
360 err = RProperty::Define( |
|
361 KPSUidNEInformation, |
|
362 KTelNumberEntryInfo, |
|
363 RProperty::EInt, |
|
364 KPhoneReadPolicyAlwaysPass, |
|
365 KPhoneWritePolicy ); |
|
366 |
|
367 |
|
368 // Add DoStartupSignalL to the recovery system |
|
369 iStartupSignalRecoveryId = |
|
370 CPhoneRecoverySystem::Instance()->AddL( |
|
371 TCallBack( DoStartupSignalL, this ), |
|
372 CTeleRecoverySystem::EPhonePriorityHigh, |
|
373 CTeleRecoverySystem::EPhoneStateIdle ); |
|
374 |
|
375 // Call DoStartupSignalL within recovery system |
|
376 const TInt startupState = CPhonePubSubProxy::Instance()->Value( |
|
377 KPSUidStartup, |
|
378 KPSGlobalSystemState ); |
|
379 |
|
380 qDebug("phoneui::main() startupState value=%d", startupState ); |
|
381 |
|
382 if ( startupState == ESwStateCriticalPhaseOK || |
|
383 startupState == ESwStateEmergencyCallsOnly || |
|
384 startupState == ESwStateNormalRfOn || |
|
385 startupState == ESwStateNormalRfOff || |
|
386 startupState == ESwStateNormalBTSap ) |
|
387 { |
|
388 qDebug("phoneui::main() Notify Starter that phone is ready..."); |
|
389 CPhoneRecoverySystem::Instance()->RecoverNow( |
|
390 iStartupSignalRecoveryId, |
|
391 CTeleRecoverySystem::EPhonePriorityHigh ); |
|
392 } |
|
393 else |
|
394 { |
|
395 qDebug("phoneui::main() Startup not ready yet. Start listening..."); |
|
396 CPhonePubSubProxy::Instance()->NotifyChangeL( |
|
397 KPSUidStartup, |
|
398 KPSGlobalSystemState, |
|
399 this ); |
|
400 } |
|
401 |
|
402 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
403 { |
|
404 // Indicate to the system that the Phone has been started |
|
405 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
406 KPSUidTelInformation, |
|
407 KTelPhoneUid, |
|
408 KUidPhoneApplication.iUid ); |
|
409 } |
|
410 |
|
411 // Update the Apps ready flag |
|
412 iAppsReady += EPhoneStartedUp; |
|
413 |
|
414 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) |
|
415 { |
|
416 iOnScreenDialer = ETrue; |
|
417 } |
|
418 } |
|
419 |