X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FCallPresentationModel.cpp;h=7108c619fab01bd454250fa0acffc8db153e5fcb;hb=968ce47ae7a353e2ad110ef3b64be43d5c9b0b36;hp=32407f61d6dfc1176f00befca0c76711c92d3ace;hpb=8999146614fceea4a08455c1595948c3711cdc71;p=apps%2Fosp%2FCall.git diff --git a/src/CallPresentationModel.cpp b/src/CallPresentationModel.cpp index 32407f6..7108c61 100644 --- a/src/CallPresentationModel.cpp +++ b/src/CallPresentationModel.cpp @@ -39,6 +39,7 @@ using namespace Tizen::Graphics; using namespace Tizen::Media; using namespace Tizen::Social; using namespace Tizen::Ui::Scenes; +using namespace Tizen::Telephony; CallPresentationModel* CallPresentationModel::__pInstance = null; @@ -115,6 +116,10 @@ void CallPresentationModel::DialCall(String& contactNumber, bool isEmergency) { int errorCode = ERROR_NONE; + bool isCallServiceAvailable = false; + NetworkStatus networkStatus; + NetworkManager* pNetworkManager = new NetworkManager(); + result r; //Check if Telephony Manager is initialized TryCatch(__pTelephonyMgr != null, (errorCode = ERROR_TAPI_INIT_FAILED), "TAPI initialization failed"); @@ -124,6 +129,30 @@ CallPresentationModel::DialCall(String& contactNumber, bool isEmergency) __pTelEventListener->HandleTelephonyError(ERROR_FLIGHT_MODE_SET); return; } + //Check if dialing a call is possible - Check if sim is available + if (GetSimInfo() == E_FAILURE) + { + __pTelEventListener->HandleTelephonyError(ERROR_CODE_SIM_INITIALIZATION_FAILED); + return ; + } + + //fetch call service status + r = pNetworkManager->Construct(null); + if (r == E_SUCCESS) + { + r = pNetworkManager->GetNetworkStatus(networkStatus); + if (r == E_SUCCESS) + { + isCallServiceAvailable = networkStatus.IsCallServiceAvailable(); + } + } + delete pNetworkManager; + + if (isCallServiceAvailable == false) + { + __pTelEventListener->HandleTelephonyError(ERROR_DIAL_FAILED); + return ; + } //setup outgoing call errorCode = __pTelephonyMgr->SetupMoCall(contactNumber, isEmergency); TryCatch(errorCode == ERROR_NONE,,"Error occurred while setup MO call"); @@ -383,6 +412,11 @@ bool CallPresentationModel::RejectCall(int callHandle, bool sendMsg, const String& contactNumber) { AppLogDebug("Enter"); + if (sendMsg == true && __pAppControlMgr != null) + { + //launch compose message AppControl + __isMessageAppControlRunning = __pAppControlMgr->LaunchComposeMessageAppControl(*(const_cast(&contactNumber)), this); + } result r = __pTelephonyMgr->AnswerCall(callHandle, false); if (IsFailed(r)) { @@ -390,11 +424,7 @@ CallPresentationModel::RejectCall(int callHandle, bool sendMsg, const String& co return false; } - if (sendMsg == true && __pAppControlMgr != null) - { - //launch compose message AppControl - __isMessageAppControlRunning = __pAppControlMgr->LaunchComposeMessageAppControl(*(const_cast(&contactNumber)), this); - } + AppLogDebug("Exit"); return true; } @@ -468,7 +498,7 @@ CallPresentationModel::AddCall(const String& phoneNumber) ArrayList* pLaunchArgs = null; SceneManager* pSceneManager = SceneManager::GetInstance(); int currentActiveCallCount = GetCurrentCallCount(); - if(currentActiveCallCount <= 1) + if(currentActiveCallCount <= 1 && IsIncomingorDialingCallPresent() == false) { //make an outgoing call with given number String* contactTxt = new (std::nothrow) String(phoneNumber); @@ -585,7 +615,7 @@ CallPresentationModel::HandleCallDisconnected(bool isLastCall, Tizen::Base::Coll //1) Defer from sending call disconnected event to form, in case Msg AppControl is running, //to avoid PhoneApp from going to EndCall form, where it shows for 3 sec. and automatically closes. //2) Do not send call disconnected event to any form, in case an incoming call or dialing call is present. - if (__pTelEventListener != null && __isMessageAppControlRunning == false ) + if (__pTelEventListener != null /*&& __isMessageAppControlRunning == false*/ ) { __pTelEventListener->HandleCallDisconnected(isLastCall, pCallList); } @@ -775,3 +805,45 @@ CallPresentationModel::AppControlRequestCompleted(void) __pAppControlMgr->AppControlRequestCompleted(); } } + +result +CallPresentationModel::GetSimInfo(void) +{ + int mnc; + int mcc; + bool isAvailable; + String spn; + String iccId; + String operatorName; + + SimStateManager simStateManager; + SimInfo simInfo; + + result r = simStateManager.Construct(); + if (IsFailed(r)) + { + return E_FAILURE; + } + + r = simStateManager.GetSimInfo(simInfo); + if (IsFailed(r)) + { + return E_FAILURE; + } + + mnc = simInfo.GetMnc(); + mcc = simInfo.GetMcc(); + spn = simInfo.GetSpn(); + iccId = simInfo.GetIccId(); + operatorName = simInfo.GetOperatorName(); + //Checks whether a SIM card is present in the device or not + isAvailable = simInfo.IsAvailable(); + if(isAvailable == true) + { + return E_SUCCESS; + } + else + { + return E_FAILURE; + } +}