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