Fix for 45866
[apps/osp/Call.git] / src / CallActiveCallForm.cpp
index 4c378c5..635a485 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
 //
@@ -109,6 +109,8 @@ ActiveCallForm::ActiveCallForm(FormType formType)
        __pSmallPhotoLabel = null;
        __pActiveCallInfo = null;
        __pHeldCallInfo = null;
+       __isSwapInProgress = false;
+       __pAddressbook = null;
 }
 
 ActiveCallForm::~ActiveCallForm(void)
@@ -215,7 +217,7 @@ ActiveCallForm::ShowDTMFKeypad(void)
                AppLog("DTMF Keypad rect(%d,%d,%d,%d)",rect.x,rect.y,rect.width,rect.height);
                __pDTMFKeypad = new (std::nothrow) DtmfKeyPadPanel();
                __pDTMFKeypad->Initialize(this, rect);
-               AddControl(*__pDTMFKeypad);
+               AddControl(__pDTMFKeypad);
 
                //set layout relation w.r.t call buttons panel
                RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
@@ -275,6 +277,7 @@ ActiveCallForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui
                        {
                                //in Portrait mode it is hidden beneath DTMF Keypad.
                                SetShowStateOnKeypad(false);
+                               DestroyMoreOptionsMenuList();
                        }
                        if(__pDTMFKeypad->GetShowState() == true)
                        {
@@ -299,7 +302,7 @@ ActiveCallForm::HideDTMFKeypad(void)
        {
                __DtmfString = static_cast<EditField*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX))->GetText();
 
-               RemoveControl(*__pDTMFKeypad);
+               RemoveControl(__pDTMFKeypad);
                __pDTMFKeypad = null;
        }
 }
@@ -321,7 +324,7 @@ ActiveCallForm::InitializeCallButtonsPanel(void)
                __pCallButtonsPanel = new (std::nothrow) CallButtonsPanel();
                __pCallButtonsPanel->ConstructPanel(this, __formType);
                __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
-               r = AddControl(*__pCallButtonsPanel);
+               r = AddControl(__pCallButtonsPanel);
        }
 
        RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetPortraitLayoutN());
@@ -453,6 +456,7 @@ ActiveCallForm::SetHoldButtonStatus(bool toHoldCall)
                pHoldBtn->SetActionId(cmdId);
                pHoldBtn->SetNormalBitmap(Point(0, 0),*normalImg);
                pHoldBtn->SetPressedBitmap(Point(0, 0),*pressImg);
+               pHoldBtn->Invalidate(true);
        }
        if (pHoldLbl)
        {
@@ -483,7 +487,7 @@ ActiveCallForm::CreateMoreOptionsMenuList(void)
                pBgPopupArwBmp = null;
 
                // Adds a Label to the Form
-               AddControl(*__pMoreOptionsListAnchor);
+               AddControl(__pMoreOptionsListAnchor);
        }
 
        //create options menu list
@@ -494,7 +498,7 @@ ActiveCallForm::CreateMoreOptionsMenuList(void)
                __pMoreOptionsList->SetItemProvider(*this);
                __pMoreOptionsList->AddListViewItemEventListener(*this);
                //Add option list to the form
-               AddControl(*__pMoreOptionsList);
+               AddControl(__pMoreOptionsList);
        }
        else
        {
@@ -509,14 +513,14 @@ ActiveCallForm::DestroyMoreOptionsMenuList(void)
        if (__pMoreOptionsListAnchor != null)
        {
                //removes and delete the child control
-               RemoveControl(*__pMoreOptionsListAnchor);
+               RemoveControl(__pMoreOptionsListAnchor);
                __pMoreOptionsListAnchor = null;
        }
 
        if (__pMoreOptionsList != null)
        {
                //removes and delete the child control
-               RemoveControl(*__pMoreOptionsList);
+               RemoveControl(__pMoreOptionsList);
                __pMoreOptionsList = null;
        }
 }
@@ -577,6 +581,7 @@ ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
                {
                        //hide only in portrait mode.
                        SetShowStateOnKeypad(false);
+                       DestroyMoreOptionsMenuList();
                }
                //Hide the hold button as it goes behind DTMF keypad
                SetHoldButtonShowState(false);
@@ -729,8 +734,12 @@ ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_SWAP_CALLS:
        {
-               AppAssert(__formType == FORMTYPE_MULTIPLECALLS);
-               __pCallPresentor->SwapCalls();
+               if(IsSwapInProgress() == false)
+               {
+                       AppAssert(__formType == FORMTYPE_MULTIPLECALLS);
+                       __pCallPresentor->SwapCalls();
+                       SetSwapInProgress(true);
+               }
        }
        break;
 
@@ -842,6 +851,18 @@ ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
        }
 }
 
+bool
+ActiveCallForm::IsSwapInProgress(void)
+{
+       return __isSwapInProgress;
+}
+
+void
+ActiveCallForm::SetSwapInProgress(bool progress)
+{
+       __isSwapInProgress = progress;
+}
+
 void
 ActiveCallForm::SetTextToDTMFTextField(const String& dtmfStr)
 {
@@ -878,6 +899,14 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        //Initialize keypad and buttons
        InitializeCallButtonsPanel();
 
+       AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
+       __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
+       if(__pAddressbook != null)
+       {
+               __pAddressbook->SetAddressbookChangeEventListener(this);
+       }
+
+
        if (__pActiveCallInfo != null)
        {
                delete __pActiveCallInfo;
@@ -999,6 +1028,11 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
                        __pCallButtonsPanel->EnableAddCallButton(true);
                }
 
+
+               //bring button on top
+               __pCallButtonsPanel->SetButtonPosition();
+
+
                //show call active time using Timer
                __activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
                ShowTimerInfo(IDC_CALLER1_TIME_LABEL, __pActiveCallInfo->IsOnHold(),__activeCallStartTime);
@@ -1052,6 +1086,10 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
                pArgs = null;
        }
 
+       //update position of call buttons panel
+       Label* pKeysBgLbl = static_cast<Label*>(GetControl(IDC_KEY_BG_LABEL, true));
+       __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
+
        CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
        pCallApp->SetTopMostWindow(false);
 }
@@ -1060,11 +1098,6 @@ void
 ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
 {
        RemoveOrientationEventListener(*this);
-       if (__pCallButtonsPanel != null)
-       {
-               RemoveControl(*__pCallButtonsPanel);
-               __pCallButtonsPanel = null;
-       }
        if (__pActiveCallTimer != null)
        {
                __pActiveCallTimer->Cancel();
@@ -1087,6 +1120,10 @@ ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId&
        __DtmfString.Clear();
        CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
        pCallApp->RemoveAppStateChangeListener(*this);
+       if(__pAddressbook != null)
+       {
+               __pAddressbook->SetAddressbookChangeEventListener(null);
+       }
 }
 
 void
@@ -1160,6 +1197,109 @@ ActiveCallForm::HandleConfCallChanged(void)
 }
 
 void
+ActiveCallForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
+{
+       AppLog("Enter");
+       switch (__formType)
+       {
+
+       case FORMTYPE_OUTGOINGCALL:
+       case FORMTYPE_ACTIVECALL:
+       {
+               String pContactNumber;
+               pContactNumber.Append(__pActiveCallInfo->GetContactNumber());
+               Contact* pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
+               if(pContact == null)
+               {
+                       __pActiveCallInfo->ResetContactNumber(null);
+                       __pActiveCallInfo->ResetContactInfo(null);
+
+               }
+               else
+               {
+                       __pActiveCallInfo->SetContactNumber(pContactNumber);
+                       __pActiveCallInfo->SetContactInfo(*pContact);
+               }
+               if(pContact != null)
+               {
+                       delete pContact;
+                       pContact = null;
+               }
+               ShowPersonDetails(pContactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
+       }
+       break;
+
+       case FORMTYPE_EMERGENCYACTIVECALL:
+       {
+       }
+       break;
+
+       case FORMTYPE_MULTIPLECALLS:
+       {
+
+               IListT<AppCallInfo>* pCallsList = __pCallPresentor->GetCallListN();
+               if(pCallsList != null)
+               {
+                       int listCount = pCallsList->GetCount();
+                       for(int index = 0; index < listCount; index++)
+                       {
+                               AppCallInfo callInfo;
+                               Contact* pContact;
+                               pCallsList->GetAt(index, callInfo);
+                               if(__pActiveCallInfo == null)
+                               {
+                                       __pActiveCallInfo = new (std::nothrow) AppCallInfo();
+                               }
+                               *__pActiveCallInfo =  callInfo;
+                               String contactNumber;
+                               contactNumber.Append(__pActiveCallInfo->GetContactNumber());
+                               pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
+                               if(pContact == null)
+                               {
+                                       __pActiveCallInfo->ResetContactNumber(null);
+                                       __pActiveCallInfo->ResetContactInfo(null);
+
+                               }
+                               else
+                               {
+                                       __pActiveCallInfo->SetContactNumber(contactNumber);
+                                       __pActiveCallInfo->SetContactInfo(*pContact);
+                               }
+                               if(pContact != null)
+                               {
+                                       delete pContact;
+                                       pContact = null;
+                               }
+                               if(callInfo.IsOnHold() == false)
+                               {
+                                       ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
+                               }
+                               else
+                               {
+                                       ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
+                               }
+
+                       }
+
+                       delete pCallsList;
+                       pCallsList = null;
+               }
+       }
+       break;
+       default:
+               break;
+       }
+       AppLog("Exit");
+}
+
+void
+ActiveCallForm::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
+{
+       //No implementation
+}
+
+
+void
 ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCallInfo>& activeCallsList)
 {
        AppLog("ENTER");
@@ -1315,14 +1455,16 @@ ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCall
 void
 ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, AppCallInfo* pCallInfo)
 {
+       result r = E_FAILURE;
+
        //call individual methods to show contact number, caller name & photo
        ShowPhoneNumber(phoneNumber, contactLblName);
 
        //fetch contact details based on phone number
-       String* pDisplayName = pCallInfo->FetchCallerNameN();
+       String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
        ShowCallerName(*pDisplayName, nameLblName);
 
-       Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
+       Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
        ShowCallerPhoto(pPhotoBitmap, isSecondCaller);
 
        //free resources
@@ -1442,7 +1584,7 @@ ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
        //Remove small photo label
        if (__pSmallPhotoLabel != null)
        {
-               RemoveControl(*__pSmallPhotoLabel);
+               RemoveControl(__pSmallPhotoLabel);
                __pSmallPhotoLabel = null;
        }
 
@@ -1500,6 +1642,7 @@ ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
                        if (pPhotoLbl)
                        {
                                pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
+                               pPhotoLbl->Invalidate(true);
                        }
                        delete pDefaultPhoto;
                }
@@ -1544,7 +1687,7 @@ ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
 {
        if (__pSmallPhotoLabel != null)
        {
-               RemoveControl(*__pSmallPhotoLabel);
+               RemoveControl(__pSmallPhotoLabel);
                __pSmallPhotoLabel = null;
        }
        //Draw Small Photo and show on small photo label
@@ -1553,7 +1696,7 @@ ActiveCallForm::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);
 }
 
@@ -1794,7 +1937,8 @@ ActiveCallForm::OnListViewItemStateChanged(ListView& listView, int index, int el
 {
        //Goto conference call list form
        SceneManager* pSceneManager = SceneManager::GetInstance();
-       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST), null);
+       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
+                        SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_KEEP), null);
 }
 
 void