Fix for N_SE-52935 N_SE-52866
[apps/osp/Call.git] / src / CallPresentationModel.cpp
index 890bddf..04220e0 100644 (file)
 #include <FApp.h>
 #include <FUi.h>
 #include <FMedia.h>
+#include <FShell.h>
 #include "CallApp.h"
 #include "CallAppControlRequestMgr.h"
 #include "CallActiveCallForm.h"
+#include "CallAppUtility.h"
 #include "CallInfo.h"
 #include "CallPresentationModel.h"
 #include "CallSettingsPresentationModel.h"
@@ -42,6 +44,7 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Telephony;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Messaging;
+using namespace Tizen::Shell;
 
 CallPresentationModel* CallPresentationModel::__pInstance = null;
 
@@ -58,10 +61,12 @@ CallPresentationModel::CallPresentationModel(void)
        __psimInfo = null;
        __pSmsManager = null;
        __isMessageSendInProgress = false;
+       __pNotificationManager = null;
 }
 
 CallPresentationModel::~CallPresentationModel(void)
 {
+       AppControl::StopAppControlResponseListener(this);
        __pTelephonyMgr = null;
        __pSettingsPresentor = null;
        __pAppControlMgr =null;
@@ -131,6 +136,8 @@ CallPresentationModel::Construct(void)
        __pAppControlMgr = CallAppControlRequestMgr::GetInstance();
        __pNetworkManager = new (std::nothrow)NetworkManager();
        __pNetworkManager->Construct(null);
+       __pNotificationManager = new (std::nothrow) Tizen::Shell::NotificationManager;
+       __pNotificationManager->Construct();
        GetSimInfo();
        return E_SUCCESS;
 }
@@ -200,7 +207,7 @@ CallPresentationModel::DialCall(String& contactNumber, bool isEmergency)
        numberEndsWithHash = IfNumberEndsWithHash(contactNumber);
        if(numberEndsWithHash == true)
        {
-               __pTelEventListener->HandleTelephonyError(ERROR_GPRS_NUMBER);
+               __pTelEventListener->HandleTelephonyError(ERROR_USSD_NUMBER);
                return ;
        }
 
@@ -462,7 +469,7 @@ CallPresentationModel::GetCallListN(void)
 bool
 CallPresentationModel::RejectCall(int callHandle, bool sendMsg, const String& contactNumber)
 {
-       AppLogDebug("Enter");
+       AppLogDebug("Enter %d",callHandle);
        if (sendMsg == true && __pAppControlMgr != null)
        {
                //launch compose message AppControl
@@ -565,7 +572,7 @@ CallPresentationModel::AddCall(const String& phoneNumber)
                        nextScene = IDSCN_SCENE_OUT_EMERGENCYCALL;
                }
                pSceneManager->GoForward( ForwardSceneTransition( nextScene,
-                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pLaunchArgs);
+                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pLaunchArgs);
 
        }
 }
@@ -594,6 +601,17 @@ CallPresentationModel::IsEmergencyNumber(const Tizen::Base::String& phoneNumber,
 }
 
 void
+CallPresentationModel::ResumeAlert(AppCallInfo& incomingCallInfo)
+{
+       //Adding incoming call sate setting here
+       if(__pSettingsPresentor != null)
+       {
+               __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_CONNECTING);
+       }
+       __pTelephonyMgr->ResumeAlert(incomingCallInfo);
+}
+
+void
 CallPresentationModel::StartAlert(AppCallInfo& incomingCallInfo)
 {
        //Adding incoming call sate setting here
@@ -604,6 +622,12 @@ CallPresentationModel::StartAlert(AppCallInfo& incomingCallInfo)
        __pTelephonyMgr->StartAlert(incomingCallInfo);
 }
 
+AppCallInfo*
+CallPresentationModel::GetIncomingCallHandle()
+{
+       return __pTelephonyMgr->GetIncomingCallHandle();
+}
+
 void
 CallPresentationModel::StopAlert(void)
 {
@@ -641,7 +665,28 @@ CallPresentationModel::HandleCallConnected(Tizen::Base::Collection::IListT<AppCa
        }
        if(__pSettingsPresentor != null)
        {
-               __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE);
+               if(IsIncomingorDialingCallPresent() == false)
+               {
+                       __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE);
+               }
+       }
+}
+
+void
+CallPresentationModel::HandleCallActive(bool isActive)
+{
+       if (__pTelEventListener != null)
+       {
+               __pTelEventListener->HandleCallActive(isActive);
+       }
+}
+
+void
+CallPresentationModel::HandleCallHeld(bool isHeld)
+{
+       if (__pTelEventListener != null)
+       {
+               __pTelEventListener->HandleCallHeld(isHeld);
        }
 }
 
@@ -655,14 +700,21 @@ CallPresentationModel::HandleCallDisconnected(bool isLastCall, Tizen::Base::Coll
                SetMuteStatus(false);
                if(__pSettingsPresentor != null)
                {
-                       __pSettingsPresentor->SetCallState(CALL_STATE_CALL_OFF);
+                       //Check if there is a incoming call or dialing call present before setting the status
+                       if(IsIncomingorDialingCallPresent() == false)
+                       {
+                               __pSettingsPresentor->SetCallState(CALL_STATE_CALL_OFF);
+                       }
                }
        }
        else
        {
                if(__pSettingsPresentor != null)
                {
-                       __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE);
+                       if(IsIncomingorDialingCallPresent() == false)
+                       {
+                               __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE);
+                       }
                }
        }
        //1) Defer from sending call disconnected event to form, in case Msg AppControl is running,
@@ -690,6 +742,24 @@ CallPresentationModel::HandleIncomingCall(AppCallInfo& pCallInfo)
 }
 
 void
+CallPresentationModel::HandleConfCallHoldOccured(bool success)
+{
+       if (__pTelEventListener != null)
+       {
+               __pTelEventListener->HandleConfCallHoldOccured(success);
+       }
+}
+
+void
+CallPresentationModel::HandleConfCallActiveOccured(bool success)
+{
+       if (__pTelEventListener != null)
+       {
+               __pTelEventListener->HandleConfCallActiveOccured(success);
+       }
+}
+
+void
 CallPresentationModel::HandleCallSwapOccured(Tizen::Base::Collection::IListT<AppCallInfo>& pCallList)
 {
        if (__pTelEventListener != null)
@@ -971,9 +1041,42 @@ CallPresentationModel::SendMessage(String& strMsg,String& recpientNum)
                {
                        __isMessageSendInProgress = true;
                }
+               else
+               {
+                       AppLogDebug("%s",GetErrorMessage(r));
+                       ShowSMSErrorNotification();
+               }
+
+       }
+
+}
+
+void
+CallPresentationModel::ShowSMSErrorNotification(void)
+{
+       NotificationRequest request;
+       String alertString = AppUtility::GetResourceString(IDS_MESSAGE_SENDING_FAILED);
+       request.SetAlertText(L" ");
+       request.SetTitleText(L"\n"+alertString);
+       request.SetNotificationStyle(NOTIFICATION_STYLE_NORMAL);
+       request.SetNotificationCountText(alertString.GetLength());
 
+
+       String resourcePath = App::GetInstance()->GetAppSharedPath() + L"res/";
+
+       String iconPath = resourcePath + L"messages.png";
+       request.SetIconFilePath(iconPath);
+
+       int badgeNumber = __pNotificationManager->GetBadgeNumber();
+       ++badgeNumber;
+       if (badgeNumber <= 0)
+       {
+               badgeNumber = 1;
        }
+       request.SetBadgeNumber(badgeNumber);
 
+       __pNotificationManager->Notify(request);
+       __pNotificationManager->RemoveNotification();
 }
 
 bool