tizen2.1 code merge
[apps/osp/Call.git] / src / CallActiveCallForm.cpp
index 469527e..5e40ede 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
 //
@@ -22,6 +22,7 @@
 #include <FUi.h>
 #include <FMedia.h>
 #include <FSystem.h>
+#include <FShell.h>
 #include "CallActiveCallForm.h"
 #include "CallButtonsPanel.h"
 #include "CallInfo.h"
@@ -30,6 +31,7 @@
 #include "CallPresentationModel.h"
 #include "CallSceneRegister.h"
 #include "CallTypes.h"
+#include "CallApp.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -42,6 +44,7 @@ using namespace Tizen::System;
 using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
+using namespace Tizen::Shell;
 
 //constants
 const int IDI_MAX_SECONDS = 60;
@@ -106,6 +109,7 @@ ActiveCallForm::ActiveCallForm(FormType formType)
        __pSmallPhotoLabel = null;
        __pActiveCallInfo = null;
        __pHeldCallInfo = null;
+       __isSwapInProgress = false;
 }
 
 ActiveCallForm::~ActiveCallForm(void)
@@ -198,12 +202,12 @@ ActiveCallForm::ShowDTMFKeypad(void)
        {
                //update rect according to client screen area
                Rectangle rect(0, 0, 0, 0);
-               if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
+               if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
                {
                        rect.width = GetClientAreaBounds().width;
                        rect.height = GetClientAreaBounds().height - __pCallButtonsPanel->GetHeight();
                }
-               else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
+               else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
                {
                        rect.height = GetClientAreaBounds().height;
                        rect.width = GetClientAreaBounds().width - __pCallButtonsPanel->GetWidth();
@@ -212,7 +216,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());
@@ -262,12 +266,13 @@ ActiveCallForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui
                //change orientation of DTMF Keypad, if it is visible.
                if (__pDTMFKeypad != null)
                {
-                       if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE)
+                       if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
                        {
                                //in landscape mode, caller info is visible.
                                SetShowStateOnKeypad(true);
+                               SetHoldButtonShowState(false);
                        }
-                       else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT)
+                       else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
                        {
                                //in Portrait mode it is hidden beneath DTMF Keypad.
                                SetShowStateOnKeypad(false);
@@ -295,7 +300,7 @@ ActiveCallForm::HideDTMFKeypad(void)
        {
                __DtmfString = static_cast<EditField*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX))->GetText();
 
-               RemoveControl(*__pDTMFKeypad);
+               RemoveControl(__pDTMFKeypad);
                __pDTMFKeypad = null;
        }
 }
@@ -317,7 +322,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());
@@ -479,7 +484,7 @@ ActiveCallForm::CreateMoreOptionsMenuList(void)
                pBgPopupArwBmp = null;
 
                // Adds a Label to the Form
-               AddControl(*__pMoreOptionsListAnchor);
+               AddControl(__pMoreOptionsListAnchor);
        }
 
        //create options menu list
@@ -490,7 +495,7 @@ ActiveCallForm::CreateMoreOptionsMenuList(void)
                __pMoreOptionsList->SetItemProvider(*this);
                __pMoreOptionsList->AddListViewItemEventListener(*this);
                //Add option list to the form
-               AddControl(*__pMoreOptionsList);
+               AddControl(__pMoreOptionsList);
        }
        else
        {
@@ -505,14 +510,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;
        }
 }
@@ -569,11 +574,13 @@ ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_OPEN_NUMKEYPAD:
        {
-               if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
+               if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
                {
                        //hide only in portrait mode.
-               SetShowStateOnKeypad(false);
+                       SetShowStateOnKeypad(false);
                }
+               //Hide the hold button as it goes behind DTMF keypad
+               SetHoldButtonShowState(false);
                ShowDTMFKeypad();
                __pCallButtonsPanel->SetKeypadButtonState(IDA_CLOSE_NUMKEYPAD);
        }
@@ -592,15 +599,7 @@ ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
                //switch to Dialer Form to make an call
                if(__pCallPresentor->GetCurrentCallCount() == 1)
                {
-/*             ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
-               pArgs->Construct();
-               String* formType = new (std::nothrow) String();
-               formType->Append(__formType);
-               pArgs->Add(formType);
-               pSceneManager->GoForward( ForwardSceneTransition(IDSCN_DIALER, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
-                               SCENE_HISTORY_OPTION_NO_HISTORY), pArgs);*/
-                       __pCallPresentor->LaunchDialAppControl();
-
+               __pCallPresentor->LaunchDialAppControl();
                }
        }
        break;
@@ -731,8 +730,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;
 
@@ -844,6 +847,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)
 {
@@ -874,6 +889,9 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        __pCallPresentor->SetTelEventListener(this);
        AddOrientationEventListener(*this);
 
+       CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
+       pPhoneApp->AddAppStateChangeListener(*this);
+
        //Initialize keypad and buttons
        InitializeCallButtonsPanel();
 
@@ -1008,6 +1026,17 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
                break;
        }
 
+       if(__formType == FORMTYPE_ACTIVECALL || __formType == FORMTYPE_EMERGENCYACTIVECALL ||
+                       __formType == FORMTYPE_MULTIPLECALLS || __formType == FORMTYPE_ACTIVECONFCALL)
+       {
+               //Unlock the phone if its locked
+               if(LockManager::GetInstance()->IsLocked())
+               {
+                       AppLogDebug("Phone Locked");
+                       LockManager::GetInstance()->Unlock();
+               }
+       }
+
        //Hide DTMFKeypad, if visible and show caller info
        HideDTMFKeypad();
        SetShowStateOnKeypad(true);
@@ -1039,6 +1068,9 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
                delete pArgs;
                pArgs = null;
        }
+
+       CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
+       pCallApp->SetTopMostWindow(false);
 }
 
 void
@@ -1047,7 +1079,7 @@ ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId&
        RemoveOrientationEventListener(*this);
        if (__pCallButtonsPanel != null)
        {
-               RemoveControl(*__pCallButtonsPanel);
+               RemoveControl(__pCallButtonsPanel);
                __pCallButtonsPanel = null;
        }
        if (__pActiveCallTimer != null)
@@ -1070,6 +1102,8 @@ ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId&
                __pMoreOptionsList->SetShowState(false);
        }
        __DtmfString.Clear();
+       CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
+       pCallApp->RemoveAppStateChangeListener(*this);
 }
 
 void
@@ -1425,7 +1459,7 @@ ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
        //Remove small photo label
        if (__pSmallPhotoLabel != null)
        {
-               RemoveControl(*__pSmallPhotoLabel);
+               RemoveControl(__pSmallPhotoLabel);
                __pSmallPhotoLabel = null;
        }
 
@@ -1527,7 +1561,7 @@ ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
 {
        if (__pSmallPhotoLabel != null)
        {
-               RemoveControl(*__pSmallPhotoLabel);
+               RemoveControl(__pSmallPhotoLabel);
                __pSmallPhotoLabel = null;
        }
        //Draw Small Photo and show on small photo label
@@ -1536,7 +1570,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);
 }
 
@@ -1602,6 +1636,21 @@ ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long lo
 }
 
 void
+ActiveCallForm::SetHoldButtonShowState(bool showState)
+{
+       Label* pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
+       if(pLblControl != null)
+       {
+               pLblControl->SetShowState(showState);
+       }
+       Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
+       if(pButtonControl != null)
+       {
+               pButtonControl->SetShowState(showState);
+       }
+}
+
+void
 ActiveCallForm::SetShowStateOnKeypad(bool showState)
 {
        Label* pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
@@ -1623,10 +1672,7 @@ ActiveCallForm::SetShowStateOnKeypad(bool showState)
                pLblControl->SetShowState(showState);
                pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
                pLblControl->SetShowState(showState);
-               pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
-               pLblControl->SetShowState(showState);
-               Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
-               pButtonControl->SetShowState(showState);
+               SetHoldButtonShowState(showState);
        }
        break;
 
@@ -1663,11 +1709,8 @@ ActiveCallForm::SetShowStateOnKeypad(bool showState)
        {
                pLblControl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
                pLblControl->SetShowState(showState);
-               pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
-               pLblControl->SetShowState(showState);
-               Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
-               pButtonControl->SetShowState(showState);
-               pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
+               SetHoldButtonShowState(showState);
+               Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
                pButtonControl->SetShowState(showState);
        }
        break;
@@ -1768,7 +1811,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_DESTROY), null);
 }
 
 void
@@ -1851,3 +1895,10 @@ ActiveCallForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
        delete pItem;
        return true;
 }
+
+void
+ActiveCallForm::OnForeground(void)
+{
+       AppLogDebug("Enter");
+       __pCallPresentor->OnAppForeground();
+}