Fix for N_SE-44446 N_SE-44426
[apps/osp/Call.git] / src / CallEndCallForm.cpp
index 1fc7e97..e9b3b80 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
 //
@@ -28,6 +28,7 @@
 #include "CallPresentationModel.h"
 #include "CallSceneRegister.h"
 #include "CallTypes.h"
+#include "CallAppControlRequestMgr.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -47,12 +48,19 @@ const int X_PHOTO_LBL = 166;
 const int Y_PHOTO_LBL = 232;
 const int W_PHOTO_LBL = 388;
 const int H_PHOTO_LBL = 388;
+const int END_CALL_TIMER_VAL = 2000;
+const int END_CALL_WAIT_TIMER_VAL = 500;
 static const wchar_t* IDL_END_CALL_FORM = L"IDL_END_CALL_FORM";
 static const wchar_t* IDC_NUMBER1_LABEL = L"IDC_NUMBER1_LABEL";
 static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL";
 static const wchar_t* IDC_KEY_BG_LABEL = L"IDC_KEY_BG_LABEL";
 static const wchar_t* IDC_CALLER1_BIGPHOTO_LABEL = L"IDC_CALLER1_BIGPHOTO_LABEL";
 static const wchar_t* IDB_END_CALL_DEFAULT_ICON = L"C01-1_call_default_caller ID_720x720.png";
+static const wchar_t* IDC_VOICECALL_BUTTON = L"IDC_VOICECALL_BUTTON";
+static const wchar_t* IDC_VIDEOCALL_BUTTON = L"IDC_VIDEOCALL_BUTTON";
+static const wchar_t* IDC_ADD_TO_CONTACT_BUTTON = L"IDC_ADD_TO_CONTACT_BUTTON";
+static const wchar_t* IDC_MSG_BUTTON = L"IDC_MSG_BUTTON";
+
 
 
 EndCallForm::EndCallForm(void)
@@ -64,7 +72,7 @@ EndCallForm::EndCallForm(void)
        __pSmallPhotoLabel = null;
        __isMsgAppControlLaunched = false;
        __isContactAppControlLaunched = false;
-       __isContactPresent = false;
+       __pAddressBook = null;
 }
 
 EndCallForm::~EndCallForm(void)
@@ -77,9 +85,13 @@ EndCallForm::~EndCallForm(void)
        }
        if (__pSmallPhotoLabel != null)
        {
-               RemoveControl(*__pSmallPhotoLabel);
                __pSmallPhotoLabel = null;
        }
+       if (__pAddressBook != null)
+       {
+               delete __pAddressBook;
+               __pAddressBook = null;
+       }
 }
 
 void
@@ -117,7 +129,7 @@ EndCallForm::InitializeCallButtonsPanel(void)
                __pCallButtonsPanel = new (std::nothrow) CallButtonsPanel();
                __pCallButtonsPanel->ConstructPanel(this, FORMTYPE_ENDCALL);
                __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
-               AddControl(*__pCallButtonsPanel);
+               AddControl(__pCallButtonsPanel);
        }
 
        RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetPortraitLayoutN());
@@ -151,6 +163,11 @@ EndCallForm::OnTerminating(void)
 
        if (__pCallPresentor)
        {
+               //Abort any AppControl Request running already to show incoming call screen
+               if (__pCallPresentor->IsAppControlRunning() == true)
+               {
+                       __pCallPresentor->AbortAppControlRequest();
+               }
                __pCallPresentor = null;
        }
        return r;
@@ -166,6 +183,15 @@ EndCallForm::OnActionPerformed(const Control& source, int actionId)
        {
        case IDA_VOICE_CALL:
        {
+               if(CallAppControlRequestMgr::GetInstance()->IsAppControlRunning() == true)
+               {
+                       return;
+               }
+               if (__isMsgAppControlLaunched == true)
+               {
+                       //AppControl already launched.
+                       return;
+               }
                //check if EndCallTimer is running, then cancel it
                if(__pEndCallEventTimer != null)
                {
@@ -182,15 +208,33 @@ EndCallForm::OnActionPerformed(const Control& source, int actionId)
                bool isSimInitialized = __pCallPresentor->CheckSimInitializationIsCompleted();
                if (isSimInitialized)
                {
+                       //Disable all buttons
+                       Button* pButton = static_cast<Button*>(GetControl(IDC_VIDEOCALL_BUTTON,true));
+                       pButton->SetEnabled(false);
+                       pButton->Invalidate(true);
+                       pButton = static_cast<Button*>(GetControl(IDC_VOICECALL_BUTTON,true));
+                       pButton->SetEnabled(false);
+                       pButton->Invalidate(true);
+                       pButton = static_cast<Button*>(GetControl(IDC_ADD_TO_CONTACT_BUTTON,true));
+                       if(pButton->GetShowState() == true)
+                       {
+                               pButton->SetEnabled(false);
+                               pButton->Invalidate(true);
+                       }
+                       pButton = static_cast<Button*>(GetControl(IDC_MSG_BUTTON,true));
+                       pButton->SetEnabled(false);
+                       pButton->Invalidate(true);
                        //Check if dialing an emergency call
                        bool isEmergencyCall = __pCallPresentor->IsEmergencyNumber(*contactTxt, true);
                        if (isEmergencyCall)
                        {
-                               pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact);
+                               pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL,
+                                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pContact);
                        }
                        else
                        {
-                               pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact);
+                               pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL,
+                                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pContact);
                        }
                }
                else
@@ -213,32 +257,25 @@ EndCallForm::OnActionPerformed(const Control& source, int actionId)
                        return;
                }
                //launch message AppControl
-               __isMsgAppControlLaunched = true;
-               result r = E_SUCCESS;
-               HashMap extraData;
-               extraData.Construct();
-
-               extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE));
-               extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(*__pContactNumber));
-
-               AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
-               if (pAc != null)
+               __isMsgAppControlLaunched = __pCallPresentor->LaunchComposeMessageAppControl(*__pContactNumber, this);
+               if (__isMsgAppControlLaunched == true && __pEndCallEventTimer != null)
                {
-                       r = pAc->Start(null, null, &extraData, this);
-                       if(r != E_SUCCESS)
-                       {
-                               //AppControl request failed, reset flag.
-                               __isMsgAppControlLaunched = false;
-                       }
-                       else if (r == E_SUCCESS && __pEndCallEventTimer != null)
+                       //cancel EndCallTimer, if AppControl request was successful.
+                       __pEndCallEventTimer->Cancel();
+                       //Disable the call buttons
+                       Button* pButton = static_cast<Button*>(GetControl(IDC_VIDEOCALL_BUTTON,true));
+                       pButton->SetEnabled(false);
+                       pButton->Invalidate(true);
+                       pButton = static_cast<Button*>(GetControl(IDC_VOICECALL_BUTTON,true));
+                       pButton->SetEnabled(false);
+                       pButton->Invalidate(true);
+                       pButton = static_cast<Button*>(GetControl(IDC_ADD_TO_CONTACT_BUTTON,true));
+                       if(pButton->GetShowState() == true)
                        {
-                               //cancel EndCallTimer, if AppControl request was successful.
-                               __pEndCallEventTimer->Cancel();
+                               pButton->SetEnabled(false);
+                               pButton->Invalidate(true);
                        }
-                       delete pAc;
                }
-
-               extraData.RemoveAll(true);
        }
        break;
 
@@ -251,6 +288,21 @@ EndCallForm::OnActionPerformed(const Control& source, int actionId)
                        return;
                }
                HandleAddToContacts();
+               Button* pButton = static_cast<Button*>(GetControl(IDC_VIDEOCALL_BUTTON,true));
+               pButton->SetEnabled(false);
+               pButton->Invalidate(true);
+               pButton = static_cast<Button*>(GetControl(IDC_VOICECALL_BUTTON,true));
+               pButton->SetEnabled(false);
+               pButton->Invalidate(true);
+               pButton = static_cast<Button*>(GetControl(IDC_ADD_TO_CONTACT_BUTTON,true));
+               if(pButton->GetShowState() == true)
+               {
+                       pButton->SetEnabled(false);
+                       pButton->Invalidate(true);
+               }
+               pButton = static_cast<Button*>(GetControl(IDC_MSG_BUTTON,true));
+               pButton->SetEnabled(false);
+               pButton->Invalidate(true);
        }
        break;
 
@@ -263,52 +315,30 @@ void
 EndCallForm::HandleAddToContacts(void)
 {
        AppLogDebug("Enter");
-       //Launch Contact AppControl
-       __isContactAppControlLaunched = true;
-       Contact* pContact = __pCallPresentor->GetContactN(*__pContactNumber);
-       AppControl* pAc = null;
-       result r = E_SUCCESS;
-       HashMap extraData;
-       extraData.Construct();
 
+       Contact* pContact = __pCallPresentor->GetContactN(*__pContactNumber);
+       //Launch Contact AppControl
+       String requestParameter;
        if (pContact != null)
        {
-               AppLogDebug("View Contact");
                //View Contact
-               String idVal;
-               idVal.Append(pContact->GetRecordId());
-               extraData.Add(new (std::nothrow) String(CONTACTS_VIEW_TYPE), new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT));
-               extraData.Add(new (std::nothrow) String(CONTACTS_ID_KEY), new (std::nothrow) String(idVal));
-                pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_VIEW);
-
+               requestParameter.Append(pContact->GetRecordId());
+               __isContactAppControlLaunched = __pCallPresentor->LaunchViewContactAppControl(requestParameter, this);
+               delete pContact;
+               pContact = null;
        }
        else
        {
-               AppLogDebug("Add Contact");
-               extraData.Add(new (std::nothrow) String(INPUT_TYPE_PHONE), new (std::nothrow) String(*__pContactNumber));
-               pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_ADD);
-
-       }
-       if (pAc != null)
-       {
-               r = pAc->Start(null, null, &extraData, this);
-               if(r != E_SUCCESS)
-               {
-                       //AppControl request failed, reset flag.
-                       __isContactAppControlLaunched = false;
-               }
-               else if (r == E_SUCCESS && __pEndCallEventTimer != null)
-               {
-                       //cancel EndCallTimer, if AppControl request was success.
-                       __pEndCallEventTimer->Cancel();
-               }
-               delete pAc;
+               //Add To Contact
+               requestParameter.Append(*__pContactNumber);
+               __isContactAppControlLaunched = __pCallPresentor->LaunchAddContactAppControl(requestParameter, this);
        }
-       else
+
+       if (__isContactAppControlLaunched == true && __pEndCallEventTimer != null)
        {
-               __isContactAppControlLaunched = false;
+               //cancel EndCallTimer, if AppControl request was success.
+               __pEndCallEventTimer->Cancel();
        }
-       extraData.RemoveAll(true);
 }
 
 void
@@ -327,42 +357,87 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
        case FORMTYPE_ENDCALL:
        {
                //fetch ended call details
-               CallInfo* pEndCall = static_cast<CallInfo*>(pArgs->GetAt(0));
+               AppCallInfo* pEndCall = static_cast<AppCallInfo*>(pArgs->GetAt(0));
 
                //contact number
                __pContactNumber = new (std::nothrow) String();
-               if(pEndCall->GetContactNumber().IsEmpty() == false)
+               if(pEndCall->IsConferenceCall() == false)
                {
-                       __pContactNumber->Append(pEndCall->GetContactNumber());
+                       if(pEndCall->GetContactNumber().IsEmpty() == false)
+                       {
+                               __pContactNumber->Append(pEndCall->GetContactNumber());
+                       }
+                       else
+                       {
+                               __pContactNumber->Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
+                       }
                }
                else
                {
-                       __pContactNumber->Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
+                       String count;
+                       count.Append(pEndCall->GetCallerListCount());
+                       count.Append(" ");
+                       count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
+                       __pContactNumber->Append(count);
                }
 
                //Fetch & show contact person details
                ShowPersonDetails(*__pContactNumber, IDC_CALLER1_LABEL, IDC_CALLER1_BIGPHOTO_LABEL,pEndCall);
                //If call is hidden means contact number is empty,
                //or if call is from known number(i.e present in contacts db), Then do NOT show "Add to Contact" button.
-               if (pEndCall->GetContactInfo() != null || pEndCall->GetContactNumber().IsEmpty() == true)
+               if (pEndCall->GetContactInfo() != null)
                {
-                       SetContactButtonState(false);
+                       //Check if contact is deleted in mean time.
+                       Contact* pContact = __pCallPresentor->GetContactN(pEndCall->GetContactNumber());
+                       //before setting check if the contact is deleted
+                       if(pContact != null)
+                       {
+                               ShowViewContactButton();
+                               delete pContact;
+                               pContact = null;
+                       }
+                       else
+                       {
+                               ShowAddContactButton();
+                       }
                }
                else
                {
-                       SetContactButtonState(true);
+                       //Show AddToContact
+                       ShowAddContactButton();
                }
 
                //Check if call is Emergency call or Hidden call,
                //then disable all button in Call button panel.
-               if (pEndCall->IsEmergency() == true || pEndCall->GetContactNumber().IsEmpty() == true)
+               if(pEndCall->IsConferenceCall() == false)
                {
-                       __pCallButtonsPanel->SetEndCallPanelState(false);
+                       if (pEndCall->IsEmergency() == true || pEndCall->GetContactNumber().IsEmpty() == true)
+                       {
+                               __pCallButtonsPanel->SetEndCallPanelState(false);
+                       }
+                       else
+                       {
+                               __pCallButtonsPanel->SetEndCallPanelState(true);
+                       }
                }
                else
                {
-                       __pCallButtonsPanel->SetEndCallPanelState(true);
+                       __pCallButtonsPanel->SetEndCallPanelState(false);
                }
+
+               //check if we reached the end call form of an outgoing call then don't show add to contacts
+               if(pEndCall->GetCalllogType() == CALL_LOG_TYPE_VOICE_OUTGOING)
+               {
+                       __pCallButtonsPanel->ShowOrHideAddtoContactsButton(false);
+               }
+               else if(pEndCall->GetCalllogType() == CALL_LOG_TYPE_VOICE_INCOMING)
+               {
+                       if(pEndCall->GetContactNumber().IsEmpty() == false)
+                       {
+                               __pCallButtonsPanel->ShowOrHideAddtoContactsButton(true);
+                       }
+               }
+
        }
        break;
 
@@ -370,7 +445,8 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
                break;
        }
 
-       if (__pEndCallEventTimer)
+       //Before starting end call timer check if messaging appcontrol was launched during incoming call
+       if (__pEndCallEventTimer && __pCallPresentor->IsAppControlRunning() == false)
        {
                __pEndCallEventTimer->Start(IDI_APP_END_TIMER);
        }
@@ -381,6 +457,15 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
                delete pArgs;
                pArgs = null;
        }
+       CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
+       pCallApp->SetTopMostWindow(false);
+       AddOrientationEventListener(*this);
+       __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
+       //Add address book listener to listen to contacts changed events
+       if(__pAddressBook != null)
+       {
+               __pAddressBook->SetAddressbookChangeEventListener(this);
+       }
 }
 
 void
@@ -399,9 +484,15 @@ EndCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& ne
        {
                __pSmallPhotoLabel->SetShowState(false);
        }
+       //remove contact change event listener
+       if(__pAddressBook != null)
+       {
+               __pAddressBook->SetAddressbookChangeEventListener(null);
+       }
        //remove itself as listener
        CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
        pPhoneApp->RemoveAppStateChangeListener(*this);
+       RemoveOrientationEventListener(*this);
 }
 
 result
@@ -411,19 +502,17 @@ EndCallForm::OnDraw(void)
 }
 
 void
-EndCallForm::SetContactButtonState(bool showState)
+EndCallForm::ShowViewContactButton(void)
 {
-       __pCallButtonsPanel->SetViewContactButtonStatus(showState);
-       __isContactPresent = !showState;
+       __pCallButtonsPanel->ShowViewContactButton();
 }
 
-bool
-EndCallForm::IsContactPresent(void)
+void
+EndCallForm::ShowAddContactButton(void)
 {
-       return __isContactPresent;
+       __pCallButtonsPanel->ShowAddContactButton();
 }
 
-
 void
 EndCallForm::ShowPhoneNumber(const String& phoneNumber, const String& lblName)
 {
@@ -433,7 +522,7 @@ EndCallForm::ShowPhoneNumber(const String& phoneNumber, const String& lblName)
 }
 
 void
-EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblName, const String& photoLblName, CallInfo* pCallInfo)
+EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblName, const String& photoLblName, AppCallInfo* pCallInfo)
 {
        //show phone number
        ShowPhoneNumber(phoneNumber, IDC_NUMBER1_LABEL);
@@ -441,9 +530,21 @@ EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblN
        Label* pNameLbl = static_cast<Label*>(GetControl(nameLblName));
        Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLblName));
 
-       //fetch contact details based on phone number
-       String* pDisplayName = pCallInfo->FetchCallerNameN();
-       Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
+       String* pDisplayName;
+       if(pCallInfo->IsConferenceCall() == false)
+       {
+               //fetch contact details based on phone number
+               pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
+       }
+       else
+       {
+               pDisplayName = new (std::nothrow) String(AppUtility::GetResourceString(IDS_CONFERENCE_CALL_STRING));
+       }
+       Bitmap* pPhotoBitmap = null;
+       if(pCallInfo->IsConferenceCall() == false)
+       {
+               pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
+       }
 
        //passing an empty string to SetText fails in label,
        //if previously valid text has been set
@@ -486,7 +587,15 @@ EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblN
        else
        {
                //Set Default Photo
-               Bitmap* pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_END_CALL_DEFAULT_ICON,W_PHOTO_LABEL,H_PHOTO_LABEL);
+               Bitmap* pDefaultPhoto = null;
+               if(pCallInfo->IsConferenceCall() == false)
+               {
+                       pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_END_CALL_DEFAULT_ICON,W_PHOTO_LABEL,H_PHOTO_LABEL);
+               }
+               else
+               {
+                       pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
+               }
                if (pDefaultPhoto != null)
                {
                        pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
@@ -538,7 +647,6 @@ EndCallForm::ShowThumbnailImage(const Bitmap* pPhotoId,const String& photoLabel)
                delete pBackground;
                delete pShadow;
        }
-
 }
 
 void
@@ -546,7 +654,7 @@ EndCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
 {
        if (__pSmallPhotoLabel != null)
        {
-               RemoveControl(*__pSmallPhotoLabel);
+               RemoveControl(__pSmallPhotoLabel);
                __pSmallPhotoLabel = null;
        }
        //Draw Small Photo and show on small photo label
@@ -555,7 +663,7 @@ EndCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
        __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
        __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
        // Add a Label to the Form
-       AddControl(*__pSmallPhotoLabel);
+       AddControl(__pSmallPhotoLabel);
        __pSmallPhotoLabel->Invalidate(true);
 }
 
@@ -569,10 +677,18 @@ EndCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
 void
 EndCallForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData)
 {
+       AppLogDebug("Enter");
        if (__isMsgAppControlLaunched == true)
        {
                //Message AppControl request completed.
                __isMsgAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
+       }
+       if(__isContactAppControlLaunched == true)
+       {
+               //notify app control completed
+               __isContactAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
        }
        //AppControl completed, goto initial scene if present
        //else exit.
@@ -582,10 +698,18 @@ EndCallForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Stri
 void
 EndCallForm::HandleLastCallCompletion(void)
 {
-
-       CallApp* pPhoneApp = (static_cast<CallApp*>(UiApp::GetInstance()));
-       pPhoneApp->Terminate();
-
+       //Check if message sending is in progress if yes
+       //wait for it to complete by restarting the timer
+       AppLogDebug("Enter");
+       if(__pCallPresentor->IsMessageSendingInProgress() == true)
+       {
+               __pEndCallEventTimer->Start(END_CALL_WAIT_TIMER_VAL);
+       }
+       else
+       {
+               CallApp* pPhoneApp = (static_cast<CallApp*>(UiApp::GetInstance()));
+               pPhoneApp->Terminate();
+       }
 }
 
 void
@@ -596,10 +720,49 @@ EndCallForm::OnForeground(void)
        //as we do not know if it success or failed.
        if(__isContactAppControlLaunched == true)
        {
-               CallApp* pPhoneApp = (static_cast<CallApp*>(UiApp::GetInstance()));
-               pPhoneApp->Terminate();
+               if(__pEndCallEventTimer != null)
+               {
+                       __pEndCallEventTimer->Start(END_CALL_TIMER_VAL);
+               }
+               UpdatePersonDetail();
+               //notify app control completed
+               __isContactAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
        }
-       __isContactAppControlLaunched = false;
+       else if (__isMsgAppControlLaunched == true)
+       {
+               //Message AppControl request completed.
+               if(__pEndCallEventTimer != null)
+               {
+                       __pEndCallEventTimer->Start(2000);
+               }
+               __isMsgAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
+       }
+       else if(__pCallPresentor->IsAppControlRunning() == true)
+       {
+               if(__pEndCallEventTimer != null)
+               {
+                       __pEndCallEventTimer->Start(2000);
+               }
+               __pCallPresentor->AppControlRequestCompleted();
+       }
+       //Enable all buttons
+       Button* pButton = static_cast<Button*>(GetControl(IDC_VIDEOCALL_BUTTON,true));
+       pButton->SetEnabled(false);
+       pButton->Invalidate(true);
+       pButton = static_cast<Button*>(GetControl(IDC_VOICECALL_BUTTON,true));
+       pButton->SetEnabled(true);
+       pButton->Invalidate(true);
+       pButton = static_cast<Button*>(GetControl(IDC_ADD_TO_CONTACT_BUTTON,true));
+       if(pButton->GetShowState() == true)
+       {
+               pButton->SetEnabled(true);
+               pButton->Invalidate(true);
+       }
+       pButton = static_cast<Button*>(GetControl(IDC_MSG_BUTTON,true));
+       pButton->SetEnabled(true);
+       pButton->Invalidate(true);
        AppLogDebug("Exit");
 }
 
@@ -612,6 +775,7 @@ EndCallForm::OnBackground(void)
 void
 EndCallForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
 {
+       AppLogDebug("Enter");
        if (__pCallButtonsPanel != null)
        {
                //update position of call buttons panel
@@ -622,7 +786,7 @@ EndCallForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::O
                RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetPortraitLayoutN());
                if (pRelativeLayout != null)
                {
-                       pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_TOP_TO_TOP);
+                       //pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_TOP_TO_TOP);
                }
                pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
                if (pRelativeLayout != null)
@@ -632,3 +796,39 @@ EndCallForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::O
                }
        }
 }
+
+void
+EndCallForm::OnContactsChanged(const IList& contactChangeInfoList)
+{
+       UpdatePersonDetail();
+}
+
+void
+EndCallForm::UpdatePersonDetail()
+{
+       AppLog("Enter");
+       if (__pContactNumber != null && __pContactNumber->IsEmpty() == false)
+       {
+               AppCallInfo* ActiveCallInfo = new (std::nothrow) AppCallInfo();
+               ActiveCallInfo->SetContactNumber(*__pContactNumber);
+               Contact* pContact = __pCallPresentor->GetContactN(*__pContactNumber);
+               if (pContact != null)
+               {
+                       ActiveCallInfo->SetContactInfo(*pContact);
+               }
+               //before setting check if the contact is deleted
+               if(pContact != null)
+               {
+                       ShowViewContactButton();
+                       delete pContact;
+                       pContact = null;
+               }
+               else
+               {
+                       ShowAddContactButton();
+               }
+               ShowPersonDetails(*__pContactNumber, IDC_CALLER1_LABEL, IDC_CALLER1_BIGPHOTO_LABEL,ActiveCallInfo);
+               delete ActiveCallInfo;
+       }
+       AppLog("Exit");
+}