Fix for N_SE-44446 N_SE-44426
[apps/osp/Call.git] / src / CallEndCallForm.cpp
index 0dffa99..e9b3b80 100644 (file)
@@ -28,6 +28,7 @@
 #include "CallPresentationModel.h"
 #include "CallSceneRegister.h"
 #include "CallTypes.h"
+#include "CallAppControlRequestMgr.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -71,6 +72,7 @@ EndCallForm::EndCallForm(void)
        __pSmallPhotoLabel = null;
        __isMsgAppControlLaunched = false;
        __isContactAppControlLaunched = false;
+       __pAddressBook = null;
 }
 
 EndCallForm::~EndCallForm(void)
@@ -85,6 +87,11 @@ EndCallForm::~EndCallForm(void)
        {
                __pSmallPhotoLabel = null;
        }
+       if (__pAddressBook != null)
+       {
+               delete __pAddressBook;
+               __pAddressBook = null;
+       }
 }
 
 void
@@ -156,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;
@@ -171,6 +183,10 @@ EndCallForm::OnActionPerformed(const Control& source, int actionId)
        {
        case IDA_VOICE_CALL:
        {
+               if(CallAppControlRequestMgr::GetInstance()->IsAppControlRunning() == true)
+               {
+                       return;
+               }
                if (__isMsgAppControlLaunched == true)
                {
                        //AppControl already launched.
@@ -212,11 +228,13 @@ EndCallForm::OnActionPerformed(const Control& source, int actionId)
                        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
@@ -343,13 +361,24 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
 
                //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
@@ -380,13 +409,20 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
 
                //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
@@ -424,6 +460,12 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
        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
@@ -442,6 +484,11 @@ 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);
@@ -483,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
@@ -528,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);
@@ -657,31 +724,7 @@ EndCallForm::OnForeground(void)
                {
                        __pEndCallEventTimer->Start(END_CALL_TIMER_VAL);
                }
-               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;
-               }
-
+               UpdatePersonDetail();
                //notify app control completed
                __isContactAppControlLaunched = false;
                __pCallPresentor->AppControlRequestCompleted();
@@ -706,7 +749,7 @@ EndCallForm::OnForeground(void)
        }
        //Enable all buttons
        Button* pButton = static_cast<Button*>(GetControl(IDC_VIDEOCALL_BUTTON,true));
-       pButton->SetEnabled(true);
+       pButton->SetEnabled(false);
        pButton->Invalidate(true);
        pButton = static_cast<Button*>(GetControl(IDC_VOICECALL_BUTTON,true));
        pButton->SetEnabled(true);
@@ -753,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");
+}