Fix for Call sate not set properly when there is 1 waiting and 1 active call and...
[apps/osp/Call.git] / src / CallPresentationModel.cpp
index 3da9eed..55b363d 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
@@ -41,6 +41,7 @@ using namespace Tizen::Social;
 using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Telephony;
 using namespace Tizen::Base::Utility;
+using namespace Tizen::Messaging;
 
 CallPresentationModel* CallPresentationModel::__pInstance = null;
 
@@ -55,6 +56,8 @@ CallPresentationModel::CallPresentationModel(void)
        __pNetworkManager = null;
        __psimStateManager = null;
        __psimInfo = null;
+       __pSmsManager = null;
+       __isMessageSendInProgress = false;
 }
 
 CallPresentationModel::~CallPresentationModel(void)
@@ -77,6 +80,11 @@ CallPresentationModel::~CallPresentationModel(void)
                delete __psimInfo;
                __psimInfo = null;
        }
+       if(__pSmsManager != null)
+       {
+               delete __pSmsManager;
+               __pSmsManager = null;
+       }
 }
 
 void
@@ -192,7 +200,7 @@ CallPresentationModel::DialCall(String& contactNumber, bool isEmergency)
        numberEndsWithHash = IfNumberEndsWithHash(contactNumber);
        if(numberEndsWithHash == true)
        {
-               __pTelEventListener->HandleTelephonyError(ERROR_GPRS_NUMBER);
+               __pTelEventListener->HandleTelephonyError(ERROR_USSD_NUMBER);
                return ;
        }
 
@@ -556,7 +564,8 @@ CallPresentationModel::AddCall(const String& phoneNumber)
                {
                        nextScene = IDSCN_SCENE_OUT_EMERGENCYCALL;
                }
-               pSceneManager->GoForward( ForwardSceneTransition( nextScene), pLaunchArgs);
+               pSceneManager->GoForward( ForwardSceneTransition( nextScene,
+                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pLaunchArgs);
 
        }
 }
@@ -646,7 +655,11 @@ CallPresentationModel::HandleCallDisconnected(bool isLastCall, Tizen::Base::Coll
                SetMuteStatus(false);
                if(__pSettingsPresentor != null)
                {
+                       //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
@@ -934,3 +947,50 @@ CallPresentationModel::IsSimAvailable(void)
 
 }
 
+void
+CallPresentationModel::SendMessage(String& strMsg,String& recpientNum)
+{
+       AppLogDebug("Enter");
+       result r;
+       if(__pSmsManager == null)
+       {
+               __pSmsManager = new (std::nothrow) SmsManager();
+               result r = __pSmsManager->Construct(*this);
+               if (IsFailed(r) == true)
+               {
+                       delete __pSmsManager;
+                       __pSmsManager = null;
+                       return;
+               }
+
+       }
+       RecipientList recipient;
+       recipient.Add(RECIPIENT_TYPE_TO,recpientNum);
+       SmsMessage smsMessage;
+       r = smsMessage.SetText(strMsg);
+       if (IsFailed(r) == false)
+       {
+               r = __pSmsManager->Send(smsMessage,recipient,true);
+               if (IsFailed(r) == false)
+               {
+                       __isMessageSendInProgress = true;
+               }
+
+       }
+
+}
+
+bool
+CallPresentationModel::IsMessageSendingInProgress(void)
+{
+       AppLogDebug("Enter %d",__isMessageSendInProgress);
+       return __isMessageSendInProgress;
+}
+
+void
+CallPresentationModel::OnSmsMessageSent(result r)
+{
+       AppLogDebug("Enter");
+       __isMessageSendInProgress = false;
+
+}