diff -r 6bb1b21d2484 -r 2f8f8080a020 phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetnetworkhandler.cpp --- a/phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetnetworkhandler.cpp Fri Apr 16 14:58:25 2010 +0300 +++ b/phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetnetworkhandler.cpp Mon May 03 12:31:11 2010 +0300 @@ -17,13 +17,22 @@ #include #include +#include +#include +#include #include "infowidgetnetworkhandler.h" #include "infowidgetlogging.h" /*! - * InfoWidgetNetworkHandler::InfoWidgetNetworkHandler - */ + \class InfoWidgetNetworkHandler + \brief Handles network specific functionality of + Operator info widget +*/ + +/*! + InfoWidgetNetworkHandler::InfoWidgetNetworkHandler() +*/ InfoWidgetNetworkHandler::InfoWidgetNetworkHandler(QObject *parent) : QObject(parent), @@ -31,6 +40,10 @@ { DPRINT << ": IN"; + // Initialize key + // ToDo: need to check if preference is ON initially + enableMcn(); + CNWSession *session = 0; QT_TRAP_THROWING(session = CreateL(*this, m_nwInfo)); m_nwSession.reset(session); @@ -39,18 +52,70 @@ } /*! - * InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler - */ + InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler() +*/ InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler() { - DPRINT << ": IN"; - - DPRINT << ": OUT"; + DPRINT; + + // Disable MCN setting, + // no display client + disableMcn(); } /*! - * InfoWidgetNetworkHandler::homeZoneTextTag - */ + InfoWidgetNetworkHandler::suspend() +*/ +void InfoWidgetNetworkHandler::suspend() +{ + DPRINT; + disableMcn(); +} + +/*! + InfoWidgetNetworkHandler::suspend() +*/ +void InfoWidgetNetworkHandler::resume() +{ + DPRINT; + enableMcn(); +} + +/*! + InfoWidgetNetworkHandler::serviceProviderName() +*/ +QString InfoWidgetNetworkHandler::serviceProviderName() const +{ + DPRINT; + QString qBuf; + qBuf = QString((QChar*)m_nwInfo.iSPName.Ptr(), + m_nwInfo.iSPName.Length()); + DPRINT << ": serviceProviderName: " << qBuf; + + return qBuf; +} + +/*! + InfoWidgetNetworkHandler::serviceProviderNameDisplayRequired() +*/ +bool InfoWidgetNetworkHandler::serviceProviderNameDisplayRequired() const +{ + DPRINT; + bool displayRequired(true); + + if (m_nwInfo.iServiceProviderNameDisplayReq == + RMobilePhone::KDisplaySPNNotRequired) { + displayRequired = false; + } + DPRINT << ": serviceProviderNameDisplayRequired: " << + displayRequired; + + return displayRequired; +} + +/*! + InfoWidgetNetworkHandler::homeZoneTextTag() +*/ QString InfoWidgetNetworkHandler::homeZoneTextTag() const { DPRINT; @@ -63,8 +128,8 @@ } /*! - * InfoWidgetNetworkHandler::homeZoneIndicatorType - */ + InfoWidgetNetworkHandler::homeZoneIndicatorType() +*/ int InfoWidgetNetworkHandler::homeZoneIndicatorType() const { DPRINT; @@ -75,8 +140,32 @@ } /*! - * InfoWidgetNetworkHandler::mcnName - */ + InfoWidgetNetworkHandler::enableMcn() +*/ +void InfoWidgetNetworkHandler::enableMcn() +{ + DPRINT; + if (!readMcnDisplayState()) { + DPRINT << ": enabling mcn display cenrep"; + writeMcnDisplayState(true); + } +} + +/*! + InfoWidgetNetworkHandler::disableMcn() +*/ +void InfoWidgetNetworkHandler::disableMcn() +{ + DPRINT; + if (readMcnDisplayState()) { + DPRINT << ": disabling mcn display cenrep"; + writeMcnDisplayState(false); + } +} + +/*! + InfoWidgetNetworkHandler::mcnName() +*/ QString InfoWidgetNetworkHandler::mcnName() const { DPRINT; @@ -89,8 +178,8 @@ } /*! - * InfoWidgetNetworkHandler::mcnIndicatorType - */ + InfoWidgetNetworkHandler::mcnIndicatorType() +*/ int InfoWidgetNetworkHandler::mcnIndicatorType() const { DPRINT; @@ -100,78 +189,71 @@ return indicatorType; } + /*! - * InfoWidgetNetworkHandler::logCurrentInfo - */ + InfoWidgetNetworkHandler::networkRegistrationStatus() +*/ +int InfoWidgetNetworkHandler::networkRegistrationStatus() const +{ + DPRINT << ": registration status: " << + static_cast(m_nwInfo.iRegistrationStatus); + + return static_cast(m_nwInfo.iRegistrationStatus); +} + +/*! + InfoWidgetNetworkHandler::isOnline() + + Check if network registration status is registered and + return status accordingly +*/ +bool InfoWidgetNetworkHandler::isOnline() const +{ + bool online(false); + + switch (networkRegistrationStatus()) { + case ENWRegisteredBusy: // Fall through + case ENWRegisteredOnHomeNetwork: // Fall through + case ENWRegisteredRoaming: + online = true; + break; + default: + break; + } + + DPRINT << ": online: " << online; + return online; +} + +/*! + InfoWidgetNetworkHandler::logCurrentInfo() +*/ void InfoWidgetNetworkHandler::logCurrentInfo() { DPRINT << ": IN"; - DPRINT << "iRegistrationStatus " << m_nwInfo.iRegistrationStatus; - DPRINT << "iNetworkMode " << m_nwInfo.iNetworkMode; - DPRINT << "iStatus " << m_nwInfo.iStatus; QString qBuf; - - qBuf = QString((QChar*)m_nwInfo.iCountryCode.Ptr(), - m_nwInfo.iCountryCode.Length()); - DPRINT << "iCountryCode " << qBuf; - - qBuf = QString((QChar*)m_nwInfo.iNetworkId.Ptr(), - m_nwInfo.iNetworkId.Length()); - DPRINT << "iNetworkId " << qBuf; - - qBuf = QString((QChar*)m_nwInfo.iDisplayTag.Ptr(), - m_nwInfo.iDisplayTag.Length()); - DPRINT << "iDisplayTag " << qBuf; - - qBuf = QString((QChar*)m_nwInfo.iShortName.Ptr(), - m_nwInfo.iShortName.Length()); - DPRINT << "iShortName " << qBuf; - - qBuf = QString((QChar*)m_nwInfo.iLongName.Ptr(), - m_nwInfo.iLongName.Length()); - DPRINT << "iLongName " << qBuf; - - DPRINT << "iViagIndicatorType " << m_nwInfo.iViagIndicatorType; - - qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(), - m_nwInfo.iViagTextTag.Length()); - DPRINT << "iViagTextTag " << qBuf; - DPRINT << "iMCNIndicatorType " << m_nwInfo.iMCNIndicatorType; - qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(), m_nwInfo.iMCNName.Length()); DPRINT << "iMCNName " << qBuf; qBuf = QString((QChar*)m_nwInfo.iSPName.Ptr(),m_nwInfo.iSPName.Length()); DPRINT << "iSPName " << qBuf; - DPRINT << "iServiceProviderNameDisplayReq " << m_nwInfo.iServiceProviderNameDisplayReq; - qBuf = QString((QChar*)m_nwInfo.iNPName.Ptr(), m_nwInfo.iNPName.Length()); - DPRINT << "iNPName " << qBuf; - - qBuf = QString((QChar*)m_nwInfo.iOperatorNameInfo.iName.Ptr(), - m_nwInfo.iOperatorNameInfo.iName.Length()); - DPRINT << "iOperatorNameInfo iName" << qBuf; - DPRINT << "iOperatorNameInfo iType" << m_nwInfo.iOperatorNameInfo.iType; - - DPRINT << "iNoServerMode " << m_nwInfo.iNoServerMode; - - DPRINT << "iVoicePrivacyStatus " << m_nwInfo.iVoicePrivacyStatus; - - qBuf = QString((QChar*)m_nwInfo.iPLMNField.Ptr(), - m_nwInfo.iPLMNField.Length()); - DPRINT << "iPLMNField " << qBuf; + DPRINT << "iViagIndicatorType " << m_nwInfo.iViagIndicatorType; + qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(), + m_nwInfo.iViagTextTag.Length()); + DPRINT << "iViagTextTag " << qBuf; DPRINT << ": OUT"; } /*! - * InfoWidgetNetworkHandler::HandleNetworkMessage - */ + InfoWidgetNetworkHandler::HandleNetworkMessage() +*/ void InfoWidgetNetworkHandler::HandleNetworkMessage( const TNWMessages aMessage ) { @@ -179,7 +261,9 @@ bool acceptedMessage = false; switch (aMessage) { - case ENWMessageCurrentCellInfoMessage: + case ENWMessageCurrentCellInfoMessage: // Fall through + case ENWMessageServiceProviderNameChange: // Fall through + case ENWMessageNetworkRegistrationStatusChange: // Fall through acceptedMessage = true; break; default: @@ -198,8 +282,8 @@ } /*! - * InfoWidgetNetworkHandler::HandleNetworkError - */ + InfoWidgetNetworkHandler::HandleNetworkError() +*/ void InfoWidgetNetworkHandler::HandleNetworkError( const TNWOperation aOperation, TInt aErrorCode ) @@ -207,6 +291,18 @@ DPRINT << ": operation: " << aOperation << " error code: " << aErrorCode; + // Reset invalid data + switch (aOperation) { + case MNWMessageObserver::ENWGetServiceProviderName: + m_nwInfo.iServiceProviderNameDisplayReq = + RMobilePhone::KDisplaySPNNotRequired; + m_nwInfo.iSPName.Zero(); + break; + default: + break; + } + + // Emit error signal int result = 0; QT_TRYCATCH_ERROR(result, emit networkError( static_cast(aOperation), static_cast(aErrorCode))); @@ -215,4 +311,54 @@ } } +/*! + InfoWidgetNetworkHandler::writeMcnDisplayState() + + Handler for cenrep key writing +*/ +void InfoWidgetNetworkHandler::writeMcnDisplayState(bool enabled) +{ + DPRINT << ": IN"; + + XQSettingsManager *settingsManager = new XQSettingsManager(0); + XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, + KCRUidNetworkSettings.iUid, KSettingsMcnDisplay); + int value; + if (enabled) { + value = 1; + } else { + value = 0; + } + bool result = settingsManager->writeItemValue(settingsKey, value ); + delete settingsManager; + + DPRINT << ": OUT"; +} + +/*! + InfoWidgetNetworkHandler::readMcnDisplayState() +*/ +bool InfoWidgetNetworkHandler::readMcnDisplayState() +{ + DPRINT << ": IN"; + bool mcnDisplayKeyOn(false); + + XQSettingsManager *settingsManager = new XQSettingsManager(0); + XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, + KCRUidNetworkSettings.iUid, KSettingsMcnDisplay); + bool conversionOk(false); + int value = settingsManager->readItemValue( + settingsKey, + XQSettingsManager::TypeInt).toInt(&conversionOk); + + if (conversionOk && value == 1) { + mcnDisplayKeyOn = true; + } + delete settingsManager; + + DPRINT << ": OUT"; + return mcnDisplayKeyOn; +} + + // End of File.