diff -r 2eacb6118286 -r ba76fc04e6c2 phoneapp/phoneui2/src/phoneuihousehold_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phoneapp/phoneui2/src/phoneuihousehold_p.cpp Fri Jun 04 10:19:18 2010 +0100 @@ -0,0 +1,376 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Household private class. +* +*/ + +#include // must be before e32base.h so uncaught_exception gets defined +#include +#include +#include +#include +#include +#include +#include +#include +#include // for FeatureManager +#include +#include "phoneconstants.h" +#include "cphonelogger.h" +#include "cphonepubsubproxy.h" +#include "cphoneqwertyhandler.h" +#include "cphoneuicontroller.h" +#include "phoneuihousehold_p.h" +#include "phoneuiqtviewadapter.h" +#include "phoneuiqtview.h" +#include "phoneuikeyeventadapter.h" +#include "phoneuicommandadapter.h" +#include "phonenotecontroller.h" +#include "qtphonelog.h" +#include "cphoneclearblacklist.h" +#include "hbinstance.h" + +PhoneUiHouseHoldPrivate::PhoneUiHouseHoldPrivate(HbMainWindow &window) : + iAppsReady (0), iStartupSignalRecoveryId (0), iLightIdleReached (EFalse), + iOnScreenDialer (EFalse), iQwertyHandler (0), iPhoneUIController (0), + m_window (window) +{ + PHONE_DEBUG("phoneui - Start phoneapp"); + + TRAPD( error, ConstructL() ); + qt_symbian_throwIfError(error); +} + +PhoneUiHouseHoldPrivate::~PhoneUiHouseHoldPrivate() +{ + while (!m_translators.isEmpty()) { + QTranslator *translator = m_translators.takeFirst(); + qApp->removeTranslator(translator); + delete translator; + translator = 0; + } + + delete iKeyEventAdapter; + delete iCommandAdapter; + delete iPhoneUIController; + delete iViewAdapter; +} + +TInt PhoneUiHouseHoldPrivate::DoStartupSignalL( TAny* aAny ) +{ + PhoneUiHouseHoldPrivate* appUi = + static_cast< PhoneUiHouseHoldPrivate* >( aAny ); + + return + !appUi->iLightIdleReached ? + appUi->DoStartupSignalIdleL() : + appUi->DoStartupSignalSecurityL(); +} + +TInt PhoneUiHouseHoldPrivate::DoStartupSignalIdleL() + { + TBool idleReached = EFalse; + + // Check if Idle application has been started. + const TInt idleUid = 0x20022F35; + PHONE_DEBUG2("phoneui::DoStartupSignalIdleL() idleUID=", idleUid); + + if ( idleUid != 0 && idleUid != KErrNotFound ) + { + // Idle application has already started + if ( !( iAppsReady & EPhoneIdleStartedUp ) ) + { + PHONE_DEBUG("phoneui::DoStartupSignalIdleL() Idle App started "); + iAppsReady += EPhoneIdleStartedUp; + + // Remove Phone application from Fast Swap Window. +// iPhoneViewController->SetHiddenL( ETrue ); + + // Set Idle's UID to PubSub. + CPhonePubSubProxy::Instance()->ChangePropertyValue( + KPSUidUikon, + KUikVideoCallTopApp, + idleUid ); + + // hack to make sure EPhonePhase1Ok is set - to be fixed properly + idleReached = true; + PHONE_DEBUG("phoneui::DoStartupSignalIdleL() Phone and Idle apps have both been started"); + CPhonePubSubProxy::Instance()->ChangePropertyValue( + KPSUidStartup, + KPSPhonePhase1Ok, + EPhonePhase1Ok ); + } + } + + if ( idleReached ) + { + PHONE_DEBUG("phoneui::DoStartupSignalIdleL() Idle reached!"); + // Now err == KErrNone and it means that + // we have succeeded in signalling. + CPhoneRecoverySystem::Instance()->EnablePreconditionL(); + + // Update the Phone light idle flag + iLightIdleReached = ETrue; + + // Notify the UI controller that the phone is ready + iPhoneUIController->HandlePhoneStartupL(); + } + else + { + PHONE_DEBUG("phoneui::DoStartupSignalIdleL() Idle is not reached yet!"); + // Idle has not been reached yet. Indicate to the recovery + // system that this iteration has failed so that it will + // try again at a later time. + User::Leave( KErrNotReady ); + } + + return KErrNone; + } + +TInt PhoneUiHouseHoldPrivate::DoStartupSignalSecurityL() + { + TInt err = KErrNone; + return err; + } + +void PhoneUiHouseHoldPrivate::HandlePropertyChangedL( + const TUid& aCategory, const TUint /*aKey*/, const TInt /*aValue*/) +{ + PHONE_DEBUG("phoneui::HandlePropertyChangedL()"); + + if ( aCategory == KPSUidStartup ) + { + + const TInt startupState = CPhonePubSubProxy::Instance()->Value( + KPSUidStartup, + KPSGlobalSystemState ); + + PHONE_DEBUG2("phoneui::HandlePropertyChangedL() StartupState value=%d", startupState ); + + if ( startupState == ESwStateCriticalPhaseOK || + startupState == ESwStateEmergencyCallsOnly || + startupState == ESwStateNormalRfOn || + startupState == ESwStateNormalRfOff || + startupState == ESwStateNormalBTSap ) + { + PHONE_DEBUG("phoneui::HandlePropertyChangedL() Try to update the startup signal again..." ); + // Try to update the startup signal again + CPhoneRecoverySystem::Instance()->RecoverNow( + iStartupSignalRecoveryId, + CTeleRecoverySystem::EPhonePriorityHigh ); + } + } +} + +void PhoneUiHouseHoldPrivate::ConstructL() +{ + new( ELeave ) CPhoneLogger( KUidPhoneUILoggerSingleton ); + FeatureManager::InitializeLibL(); + + QString locale = QLocale::system ().name (); + QTranslator *translator = new QTranslator; + QString path = QString("z:\\resource\\qt\\translations\\"); + + bool translatorLoaded = translator->load(QString(path + "telephone_" + locale)); + PHONE_DEBUG2("PhoneUiHouseHoldPrivate::ConstructL() translator.load:", translatorLoaded); + if (translatorLoaded) { + qApp->installTranslator(translator); + m_translators.append(translator); + }else { + delete translator; + translator = 0; + } + + QTranslator *translator2 = new QTranslator; + translatorLoaded = translator2->load(path + "telephone_cp_" + locale); + if (translatorLoaded) { + qApp->installTranslator(translator2); + m_translators.append(translator2); + } else { + delete translator2; + translator2 = 0; + } + + QTranslator *translator3 = new QTranslator; + translatorLoaded = translator3->load(path + "common_" + locale); + if (translatorLoaded) { + qApp->installTranslator(translator3); + m_translators.append(translator3); + } else { + delete translator3; + translator3 = 0; + } + + PhoneUIQtView *view = new PhoneUIQtView(m_window); + iViewAdapter = new PhoneUIQtViewAdapter(*view); + iPhoneUIController = CPhoneUIController::NewL(iViewAdapter); + + m_window.addView (view); + m_window.setCurrentView (view); + m_window.scene ()->setFocusItem (view); + iQwertyHandler = CPhoneQwertyHandler::NewL(); + iKeyEventAdapter = new PhoneUIKeyEventAdapter (*iPhoneUIController); + iCommandAdapter = new PhoneUiCommandAdapter (*iPhoneUIController); + QObject::connect(view, SIGNAL(dialpadIsAboutToClose()), iViewAdapter, SLOT(dialpadClosed())); + QObject::connect(view, SIGNAL(keyReleased(QKeyEvent *)), iViewAdapter, SLOT(keyReleased (QKeyEvent *))); + QObject::connect(view, SIGNAL(keyPressed (QKeyEvent *)), iKeyEventAdapter, SLOT(keyPressed (QKeyEvent *))); + QObject::connect(view, SIGNAL(keyReleased (QKeyEvent *)), iKeyEventAdapter, SLOT(keyReleased (QKeyEvent *))); + QObject::connect(view, SIGNAL(command (int)), iCommandAdapter, SLOT(handleCommand (int)), + Qt::QueuedConnection); // async to enable deletion of widget during signal handling + QObject::connect(view, SIGNAL(windowActivated()), iViewAdapter, SLOT(handleWindowActivated())); + QObject::connect(view, SIGNAL(windowDeactivated()), iViewAdapter, SLOT(handleWindowDeactivated())); + + QObject::connect(iViewAdapter->noteController(), SIGNAL(command (int)), + iCommandAdapter, SLOT(handleCommand (int))); + + // Disable default Send key functionality in application framework + CAknAppUi *appUi = static_cast(CEikonEnv::Static()->AppUi()); + appUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | + CAknAppUiBase::EDisableSendKeyLong ); + + // CLI Name. + TInt err = RProperty::Define( + KPSUidTelRemotePartyInformation, + KTelCLIName, + RProperty::EText, + KPhoneReadPolicy, + KPhoneWritePolicy ); + + // CLI Number. + err = RProperty::Define( + KPSUidTelRemotePartyInformation, + KTelCLINumber, + RProperty::EText, + KPhoneReadPolicy, + KPhoneWritePolicy ); + + // Define the top application system property + err = RProperty::Define( + KPSUidUikon, + KUikVideoCallTopApp, + RProperty::EInt, + KPhoneReadPolicy, + KPhoneWritePolicy ); + + + // Startup event signalling + // Define the telephony application system property + + err = RProperty::Define( + KPSUidTelInformation, + KTelPhoneUid, + RProperty::EInt, + KPhoneReadPolicy, + KPhoneWritePolicy ); + +// DefineNewPSKeys: + + // UID: KPSUidTelInternalInformation: + err = RProperty::Define( + KPSUidTelInternalInformation, + KTelRemotePartyContactInfo, + RProperty::EByteArray, + KPhoneReadPolicy, + KPhoneWritePolicy ); + + // VT UID. + err = RProperty::Define( + KPSUidTelInternalInformation, + KTelVideoCallUid, + RProperty::EInt, + KPhoneReadPolicy, + KPhoneWritePolicy ); + + // TELINTERNALPSKEY CHANGE + // Move to AudioHandling + // UID: KPSUidTelAudioPreference + // Call Audio Routing + err = RProperty::Define( + KPSUidTelAudioPreference, + KTelAudioOutput, + RProperty::EInt, + KPhoneReadPolicyAlwaysPass, + KPhoneWritePolicy ); + + // UID: KPSUidNEInformation + err = RProperty::Define( + KPSUidNEInformation, + KTelNumberEntryInfo, + RProperty::EInt, + KPhoneReadPolicyAlwaysPass, + KPhoneWritePolicy ); + + + // Add DoStartupSignalL to the recovery system + iStartupSignalRecoveryId = + CPhoneRecoverySystem::Instance()->AddL( + TCallBack( DoStartupSignalL, this ), + CTeleRecoverySystem::EPhonePriorityHigh, + CTeleRecoverySystem::EPhoneStateIdle ); + + // Call DoStartupSignalL within recovery system + const TInt startupState = CPhonePubSubProxy::Instance()->Value( + KPSUidStartup, + KPSGlobalSystemState ); + + PHONE_DEBUG2("phoneui::main() startupState value=", startupState ); + + if ( startupState == ESwStateCriticalPhaseOK || + startupState == ESwStateEmergencyCallsOnly || + startupState == ESwStateNormalRfOn || + startupState == ESwStateNormalRfOff || + startupState == ESwStateNormalBTSap ) + { + PHONE_DEBUG("phoneui::main() Notify Starter that phone is ready..."); + CPhoneRecoverySystem::Instance()->RecoverNow( + iStartupSignalRecoveryId, + CTeleRecoverySystem::EPhonePriorityHigh ); + } + else + { + PHONE_DEBUG("phoneui::main() Startup not ready yet. Start listening..."); + CPhonePubSubProxy::Instance()->NotifyChangeL( + KPSUidStartup, + KPSGlobalSystemState, + this ); + } + + if ( err == KErrNone || err == KErrAlreadyExists ) + { + // Indicate to the system that the Phone has been started + CPhonePubSubProxy::Instance()->ChangePropertyValue( + KPSUidTelInformation, + KTelPhoneUid, + KUidPhoneApplication.iUid ); + } + + // Update the Apps ready flag + iAppsReady += EPhoneStartedUp; + + if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) + { + iOnScreenDialer = ETrue; + } + + HbMainWindow *main = hbInstance->allMainWindows().at(0); + RWindow *win = static_cast(main->effectiveWinId()->DrawableWindow()); + + CEikonEnv* env = CEikonEnv::Static(); + if ( env ) { + env->SetSystem(ETrue); + // Blacklist singleton is initialized here + CPhoneClearBlacklist::CreateL( env->WsSession(), *win); + } +} +