diff -r ae8abd0db65c -r e32024264ebb cellular/telephonysettings/xqbindings/psetwrapper/src/psetcallbarringwrapper_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cellular/telephonysettings/xqbindings/psetwrapper/src/psetcallbarringwrapper_p.cpp Fri Apr 16 15:31:58 2010 +0300 @@ -0,0 +1,438 @@ +/* + * 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: + * + */ + +#include +#include +#include "psetcallbarringwrapper.h" +#include "psetcallbarringwrapper_p.h" +#include "logging.h" + +TServiceGroup convertServiceGroup(PsServiceGroup serviceGroup) +{ + TServiceGroup convertedType = EServiceGroupVoice; + switch (serviceGroup) { + case ServiceGroupVoice: + convertedType = EServiceGroupVoice; + break; + case ServiceGroupData: + convertedType = EServiceGroupData; + break; + case ServiceGroupFax: + convertedType = EServiceGroupFax; + break; + case ServiceGroupAllTeleservices: + convertedType = EServiceGroupAllTeleservices; + break; + default: + break; + } + + return convertedType; +} + +PSetCallBarringWrapper::BarringType convertBarringType( + TBarringProgram barringType) +{ + PSetCallBarringWrapper::BarringType convertedType = + PSetCallBarringWrapper::BarringTypeAllBarrings; + switch (barringType) { + case EBarringTypeAllBarrings: + convertedType = PSetCallBarringWrapper::BarringTypeAllBarrings; + break; + case EBarringTypeAllOutgoing: + convertedType = PSetCallBarringWrapper::BarringTypeAllOutgoing; + break; + case EBarringTypeOutgoingInternational: + convertedType = PSetCallBarringWrapper::BarringTypeOutgoingInternational; + break; + case EBarringTypeOutgoingInternationalExceptToHomeCountry: + convertedType = PSetCallBarringWrapper:: + BarringTypeOutgoingInternationalExceptToHomeCountry; + break; + case EBarringTypeAllIncoming: + convertedType = PSetCallBarringWrapper::BarringTypeAllIncoming; + break; + case EBarringTypeIncomingWhenRoaming: + convertedType = PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming; + break; + case EBarringTypeAllServices: + convertedType = PSetCallBarringWrapper::BarringTypeAllServices; + break; + case EBarringTypeAllOutgoingServices: + convertedType = PSetCallBarringWrapper::BarringTypeAllOutgoingServices; + break; + case EBarringTypeAllIncomingServices: + convertedType = PSetCallBarringWrapper::BarringTypeAllIncomingServices; + break; + default: + break; + } + + return convertedType; +} + +TBarringProgram convertBarringType( + PSetCallBarringWrapper::BarringType barringType) +{ + TBarringProgram convertedType = EBarringTypeAllBarrings; + switch (barringType) { + case PSetCallBarringWrapper::BarringTypeAllBarrings: + convertedType = EBarringTypeAllBarrings; + break; + case PSetCallBarringWrapper::BarringTypeAllOutgoing: + convertedType = EBarringTypeAllOutgoing; + break; + case PSetCallBarringWrapper::BarringTypeOutgoingInternational: + convertedType = EBarringTypeOutgoingInternational; + break; + case PSetCallBarringWrapper:: + BarringTypeOutgoingInternationalExceptToHomeCountry: + convertedType + = EBarringTypeOutgoingInternationalExceptToHomeCountry; + break; + case PSetCallBarringWrapper::BarringTypeAllIncoming: + convertedType = EBarringTypeAllIncoming; + break; + case PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming: + convertedType = EBarringTypeIncomingWhenRoaming; + break; + case PSetCallBarringWrapper::BarringTypeAllServices: + convertedType = EBarringTypeAllServices; + break; + case PSetCallBarringWrapper::BarringTypeAllOutgoingServices: + convertedType = EBarringTypeAllOutgoingServices; + break; + case PSetCallBarringWrapper::BarringTypeAllIncomingServices: + convertedType = EBarringTypeAllIncomingServices; + break; + default: + break; + } + + return convertedType; +} + + +PSetCallBarringWrapper::BarringStatus convertBarringStatus( + TBarringStatus status) +{ + PSetCallBarringWrapper::BarringStatus convertedType = + PSetCallBarringWrapper::BarringStatusUnknown; + switch (status) { + case EBarringStatusActive: + convertedType = PSetCallBarringWrapper::BarringStatusActive; + break; + case EBarringStatusInactive: + convertedType = PSetCallBarringWrapper::BarringStatusInactive; + break; + case EBarringStatusNotProvisioned: + convertedType = + PSetCallBarringWrapper::BarringStatusNotProvisioned; + break; + case EBarringStatusUnavailable: + convertedType = PSetCallBarringWrapper::BarringStatusUnavailable; + break; + case EBarringStatusUnknown: + default: + convertedType = PSetCallBarringWrapper::BarringStatusUnknown; + break; + } + + return convertedType; +} + + +/*! + PSetCallBarringWrapperPrivate::PSetCallBarringWrapperPrivate + */ +PSetCallBarringWrapperPrivate::PSetCallBarringWrapperPrivate( + PSetCallBarringWrapper &owner, CPsetContainer &psetContainer) + : + m_owner(owner), + m_callBarring(NULL), + m_currentRequest(RequestNone), + m_barringError(PSetCallBarringWrapper::BarringErrorNone), + m_barringStatus(PSetCallBarringWrapper::BarringStatusUnknown), + m_barringType(PSetCallBarringWrapper::BarringTypeAllBarrings), + m_plural(false) +{ + DPRINT; + + QT_TRAP_THROWING( + m_callBarring = psetContainer.CreateCBObjectL(*this) + ) + + m_callBarring->SetRequestObserver(this); +} + + +/*! + PSetCallBarringWrapperPrivate::~PSetCallBarringWrapperPrivate + */ +PSetCallBarringWrapperPrivate::~PSetCallBarringWrapperPrivate() +{ + DPRINT; + + delete m_callBarring; +} + + +/*! + PSetCallBarringWrapperPrivate::barringStatus + */ +void PSetCallBarringWrapperPrivate::barringStatus( + PsServiceGroup serviceGroup, + PSetCallBarringWrapper::BarringType barringType) +{ + DPRINT; + + TServiceGroup convertedServiceGroup = convertServiceGroup(serviceGroup); + TBarringProgram convertedBarringType = convertBarringType(barringType); + + QT_TRAP_THROWING(m_callBarring->GetBarringStatusL( + convertedServiceGroup, convertedBarringType) + ) + + m_currentRequest = RequestBarringStatus; +} + + +/*! + PSetCallBarringWrapperPrivate::enableBarring + */ +void PSetCallBarringWrapperPrivate::enableBarring( + PsServiceGroup serviceGroup, + PSetCallBarringWrapper::BarringType barringType, + QString barringPassword) +{ + DPRINT; + + TCallBarringSetting setting; + setting.iType = convertBarringType(barringType); + setting.iSetting = EActivateBarring; + setting.iServiceGroup = convertServiceGroup(serviceGroup); + setting.iPassword.Copy(barringPassword.utf16()); + + TBasicServiceGroups serviceGroups = EAllTeleAndBearer; + QT_TRAP_THROWING( + m_callBarring->SetBarringL(setting, serviceGroups); + ) + + m_currentRequest = RequestEnableBarring; +} + + +/*! + PSetCallBarringWrapperPrivate::disableBarring + */ +void PSetCallBarringWrapperPrivate::disableBarring( + PsServiceGroup serviceGroup, + PSetCallBarringWrapper::BarringType barringType, + QString barringPassword) +{ + DPRINT; + + TCallBarringSetting setting; + setting.iType = convertBarringType(barringType); + setting.iSetting = ECancelBarring; + setting.iServiceGroup = convertServiceGroup(serviceGroup); + setting.iPassword.Copy(barringPassword.utf16()); + + TBasicServiceGroups serviceGroups = EAllTeleAndBearer; + QT_TRAP_THROWING( + m_callBarring->SetBarringL(setting, serviceGroups); + ) + + m_currentRequest = RequestDisableBarring; +} + + +/*! + From MPsetBarringObserver. + PSetCallBarringWrapperPrivate::HandleBarringModeChangedL + */ +void PSetCallBarringWrapperPrivate::HandleBarringModeChangedL( + TBarringProgram aType, + TBarringStatus aStatus, + TBool aPlural ) +{ + DPRINT; + Q_ASSERT(RequestEnableBarring == m_currentRequest || + RequestDisableBarring == m_currentRequest); + + m_barringType = convertBarringType(aType); + m_barringError = PSetCallBarringWrapper::BarringErrorNone; + m_barringStatus = convertBarringStatus(aStatus); + m_plural = static_cast(aPlural); +} + + +/*! + From MPsetBarringObserver. + PSetCallBarringWrapperPrivate::HandleBarringModeStatusL + */ +void PSetCallBarringWrapperPrivate::HandleBarringModeStatusL( + TUint8 aBsc[KPSetNumberOfBsc], + TBarringStatus aStatus ) +{ + DPRINT; + Q_ASSERT(RequestBarringStatus == m_currentRequest); + + m_barringError = PSetCallBarringWrapper::BarringErrorNone; + QT_TRYCATCH_LEAVING( + int index = 0; + unsigned char groupIdCandidate = aBsc[index]; + while ((groupIdCandidate + != static_cast(KPSetUnusedValue))) { + m_basicServiceGroupIds << groupIdCandidate; + groupIdCandidate = aBsc[++index]; + } + ) + m_barringStatus = convertBarringStatus(aStatus); +} + + +/*! + From MPsetBarringObserver. + PSetCallBarringWrapperPrivate::HandleBarringErrorL + */ +void PSetCallBarringWrapperPrivate::HandleBarringErrorL( + TInt aReason ) +{ + DPRINT; + Q_UNUSED(aReason) + + m_barringError = aReason; + m_basicServiceGroupIds.clear(); + m_barringStatus = PSetCallBarringWrapper::BarringStatusUnknown; + m_plural = false; +} + + +/*! + From MPsetBarringObserver. + PSetCallBarringWrapperPrivate::HandleCBRequestingL + */ +void PSetCallBarringWrapperPrivate::HandleCBRequestingL( + TBool aTrue, + TBool aInterrupted ) +{ + DPRINT; + + Q_UNUSED(aTrue) + Q_UNUSED(aInterrupted) +} + + +/*! + From MPsetBarringObserver. + PSetCallBarringWrapperPrivate::SetEngineContact + */ +void PSetCallBarringWrapperPrivate::SetEngineContact( + MPsetCallBarring* aBarringEngine ) +{ + DPRINT; + + Q_UNUSED(aBarringEngine) +} + + +/*! + From MPsetBarringObserver. + PSetCallBarringWrapperPrivate::CbPasswordChangedL + */ +void PSetCallBarringWrapperPrivate::CbPasswordChangedL( + TBool aSuccess ) +{ + DPRINT; + + Q_UNUSED(aSuccess) +} + + +/*! + From MPsetRequestObserver. + PSetCallBarringWrapperPrivate::RequestComplete + */ +void PSetCallBarringWrapperPrivate::RequestComplete() +{ + DPRINT; + Q_ASSERT(RequestNone != m_currentRequest); + BarringRequest completedRequest = m_currentRequest; + m_currentRequest = RequestNone; + + switch (completedRequest) + { + case RequestBarringStatus: + { + int errorCode = 0; + QT_TRYCATCH_ERROR( errorCode, + emit m_owner.barringStatusRequestCompleted( + m_barringError, + m_basicServiceGroupIds, + m_barringStatus); + ) + DPRINT << "RequestBarringStatus ERROR:" << errorCode; + break; + } + + case RequestEnableBarring: + { + int errorCode = 0; + QT_TRYCATCH_ERROR( errorCode, + emit m_owner.enableBarringRequestCompleted( + m_barringError, + m_barringType, + m_barringStatus, + m_plural); + ) + DPRINT << "RequestEnableBarring ERROR:" << errorCode; + break; + } + + case RequestDisableBarring: + { + int errorCode = 0; + QT_TRYCATCH_ERROR( errorCode, + emit m_owner.disableBarringRequestCompleted( + m_barringError, + m_barringType, + m_barringStatus, + m_plural); + ) + DPRINT << "RequestDisableBarring ERROR:" << errorCode; + break; + } + default: + break; + } +} + + +/*! + From MPsetRequestObserver. + PSetCallBarringWrapperPrivate::RequestStatusChanged + */ +void PSetCallBarringWrapperPrivate::RequestStatusChanged( + TInt aNewStatus) +{ + DPRINT; + Q_UNUSED(aNewStatus) + Q_ASSERT(RequestNone != m_currentRequest); +} + +// End of File.