Fix for N_SE-53496 N_SE-53436 N_SE-53451
[apps/osp/Call.git] / src / CallBaseForm.cpp
index 6f4df3b..c92e90d 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
 //
@@ -19,6 +19,7 @@
  * @brief      Base class for all Call forms
  */
 #include "CallActiveCallForm.h"
+#include "CallIncomingCallForm.h"
 #include "CallBaseForm.h"
 #include "CallInfo.h"
 #include "CallPresentationModel.h"
@@ -63,8 +64,31 @@ BaseForm::OnActionPerformed(const Control& source, int actionId)
 /////////////////////////////////////////////////////////////////
 
 void
-BaseForm::HandleCallConnected(IListT<CallInfo>& pCallList)
+BaseForm::HandleCallConnected(IListT<AppCallInfo>& pCallList)
 {
+       if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
+       {
+               //This scenario will come, if 1 call is disconnected from conf. call having 2 participants.
+               //In this case, if there is any dialing call exists, then ignore.
+               //Else, if there is any incoming call exists, then update call option popup.
+               switch (__formType)
+               {
+               case FORMTYPE_INCOMINGCALL:
+               {
+                       IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
+                       if (pIncomingCallForm != null)
+                       {
+                               pIncomingCallForm->CallDisconnected();
+                       }
+               }
+                       break;
+
+               default:
+                       break;
+               }
+               return;
+       }
+
        SceneManager* pSceneManager = SceneManager::GetInstance();
 
        switch (__formType)
@@ -83,12 +107,12 @@ BaseForm::HandleCallConnected(IListT<CallInfo>& pCallList)
                for (int index = 0; index < noOfCalls; index++)
                {
                        //fetch call info and add to list
-                       CallInfo callInfo;
+                       AppCallInfo callInfo;
                        result r = pCallList.GetAt(index, callInfo);
                        if (r == E_SUCCESS)
                        {
                                //copy call information to new instance
-                               CallInfo* pCaller = new (std::nothrow) CallInfo();
+                               AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
                                *pCaller = callInfo;
                                pCallInfoList->Add(pCaller);
                        }
@@ -97,22 +121,25 @@ BaseForm::HandleCallConnected(IListT<CallInfo>& pCallList)
                if (noOfCalls == 1)
                {
                        //Check if active call is conference call
-                       CallInfo* pActiveCallInfo = static_cast<CallInfo*>(pCallInfoList->GetAt(0));
+                       AppCallInfo* pActiveCallInfo = static_cast<AppCallInfo*>(pCallInfoList->GetAt(0));
                        if(pActiveCallInfo->IsConferenceCall() == true)
                        {
                                //single Conference call - goto active Conf. call form
-                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
+                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
+                                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                        }
                        else
                        {
                                //single active call - goto active call form
-                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
+                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL,
+                                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                        }
                }
                else if(noOfCalls == 2)
                {
                        //goto multiple active call form
-                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
+                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
+                                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                }
        }
        break;
@@ -140,16 +167,17 @@ BaseForm::HandleCallConnected(IListT<CallInfo>& pCallList)
                pCallInfoList->Construct(1);
 
                //fetch call info and add to list
-               CallInfo callInfo;
+               AppCallInfo callInfo;
                result r = pCallList.GetAt(0, callInfo);
                if (r == E_SUCCESS)
                {
                        //copy call information to new instance
-                       CallInfo* pCaller = new (std::nothrow) CallInfo();
+                       AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
                        *pCaller = callInfo;
                        pCallInfoList->Add(pCaller);
                        //single active call - goto active call form
-                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL), pCallInfoList);
+                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL,
+                                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                }
        }
        break;
@@ -160,12 +188,71 @@ BaseForm::HandleCallConnected(IListT<CallInfo>& pCallList)
 }
 
 void
-BaseForm::HandleCallDisconnected(bool isLastCall, IListT<CallInfo>& pCallList)
+BaseForm::HandleCallActive(bool isActive)
+{
+       AppLogDebug("Enter");
+       ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
+       if(pActiveCallForm != null)
+       {
+               pActiveCallForm->OnActiveTelephonyCallback(isActive);
+       }
+}
+
+void
+BaseForm::HandleCallHeld(bool isHeld)
 {
+       AppLogDebug("Enter");
+       ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
+       switch (__formType)
+       {
+       case(FORMTYPE_ACTIVECALL):
+       case(FORMTYPE_ACTIVECONFCALL):
+       case(FORMTYPE_MULTIPLECALLS):
+       {
+               if(pActiveCallForm != null)
+               {
+                       pActiveCallForm->OnHoldTelephonyCallback(isHeld);
+               }
+       }
+       break;
+
+       default:
+               break;
+       }
+}
+
+void
+BaseForm::HandleCallDisconnected(bool isLastCall, IListT<AppCallInfo>& pCurrentActiveCallList)
+{
+       AppLogDebug("Enter");
+       if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
+       {
+               //This scenario will come, if this disconnected call is neither incoming nor dialing call.
+               //In this case, if there is any dialing call exists, then ignore.
+               //Else, if there is any incoming call exists, then update call option popup.
+               AppLogDebug("IsIncomingorDialingCallPresent %d",__formType);
+               switch (__formType)
+               {
+               case FORMTYPE_INCOMINGCALL:
+               {
+                       IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
+                       if (pIncomingCallForm != null)
+                       {
+                               pIncomingCallForm->CallDisconnected();
+                       }
+               }
+                       break;
+
+               default:
+                       break;
+               }
+               return;
+       }
+
        SceneManager* pSceneManager = SceneManager::GetInstance();
        CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
 
-       int callCount = pCallList.GetCount();
+       int callCount = pCurrentActiveCallList.GetCount();
        if (callCount > 0)
        {
                //Ownership - To be deleted in 'OnSceneActivatedN' of next form
@@ -174,35 +261,39 @@ BaseForm::HandleCallDisconnected(bool isLastCall, IListT<CallInfo>& pCallList)
                for (int index = 0; index < callCount; index++)
                {
                        //fetch call info and add to list
-                       CallInfo callInfo;
-                       result r = pCallList.GetAt(index, callInfo);
+                       AppCallInfo callInfo;
+                       result r = pCurrentActiveCallList.GetAt(index, callInfo);
                        if (r == E_SUCCESS)
                        {
                                //copy call information to new instance
-                               CallInfo* pCaller = new (std::nothrow) CallInfo();
+                               AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
                                *pCaller = callInfo;
                                pCallInfoList->Add(pCaller);
                        }
                }
+
                if (callCount == 1)
                {
                        //fetch call info and add to list
-                       CallInfo callInfo;
-                       result r = pCallList.GetAt(0, callInfo);
+                       AppCallInfo callInfo;
+                       result r = pCurrentActiveCallList.GetAt(0, callInfo);
                        if (r == E_SUCCESS)
                        {
                                //copy call information to new instance
-                               CallInfo* pCaller = new (std::nothrow) CallInfo();
+                               AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
                                *pCaller = callInfo;
                                pCallInfoList->Add(pCaller);
                        }
 
                        if (isLastCall == true)
                        {
-                               //goto End Call form if single call. else terminate
-                               if (callInfo.IsConferenceCall() == false)
+                               //list contains 1 last ended call to show EndCall screen.
+                               //goto End Call form if single call was ended else terminate
+                       //      if (callInfo.IsConferenceCall() == false)
+                               if (1)
                                {
-                                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL), pCallInfoList);
+                                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL,
+                                                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                                }
                                else
                                {
@@ -211,34 +302,63 @@ BaseForm::HandleCallDisconnected(bool isLastCall, IListT<CallInfo>& pCallList)
                        }
                        else
                        {
-                               if (pCallList.GetCount() == 1)
+                               //list contains 1 active call
+                               if (pCurrentActiveCallList.GetCount() == 1)
                                {
                                        if (callInfo.IsConferenceCall() == true)
                                        {
-                                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
+                                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
+                                                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                                        }
                                        else
                                        {
                                                //goto Single Active Call form
-                                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
+                                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL,
+                                                               SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                                        }
                                }
                        }
                }
                else
                {
-                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
+                       //multiple active calls are present.
+                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
+                                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
                }
        }
        else
        {
-               pPhoneApp->Terminate();
+               //This is done to show end call form in missed call case also
+               //this was done on request received from HQ to solve a bug in
+               //camera application. In which if a call comes when camera is
+               //running and user disconnects before the ui is shown the camera
+               //application hangs
+               ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+               pCallInfoList->Construct(1);
+               AppCallInfo callInfo;
+               result r = pCurrentActiveCallList.GetAt(0, callInfo);
+               if (r == E_SUCCESS)
+               {
+                       //copy call information to new instance
+                       AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
+                       *pCaller = callInfo;
+                       pCallInfoList->Add(pCaller);
+                       //multiple active calls are present.
+                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL,
+                                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
+
+               }
+               else
+               {
+                       pPhoneApp->Terminate();
+               }
+
        }
 }
 
 
 void
-BaseForm::HandleConferenceCall(CallInfo& pCallInfo)
+BaseForm::HandleConferenceCall(AppCallInfo& pCallInfo)
 {
        SceneManager* pSceneManager = SceneManager::GetInstance();
 
@@ -247,16 +367,17 @@ BaseForm::HandleConferenceCall(CallInfo& pCallInfo)
        pCallInfoList->Construct(1);
 
        //update list to be passed
-       CallInfo* pConfInfo = new (std::nothrow) CallInfo();
+       AppCallInfo* pConfInfo = new (std::nothrow) AppCallInfo();
        *pConfInfo = pCallInfo;
        pCallInfoList->Add(pConfInfo);
 
        //Todo: create screens for single conf call and conf call with another held call
-       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
+       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
+                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
 }
 
 void
-BaseForm::HandleIncomingCall(CallInfo& pCallInfo)
+BaseForm::HandleIncomingCall(AppCallInfo& pCallInfo)
 {
        SceneManager* pSceneManager = SceneManager::GetInstance();
 
@@ -265,15 +386,73 @@ BaseForm::HandleIncomingCall(CallInfo& pCallInfo)
        pCallInfoList->Construct(1);
 
        //update list to be passed
-       CallInfo* pIncomingCall = new (std::nothrow) CallInfo();
+       AppCallInfo* pIncomingCall = new (std::nothrow) AppCallInfo();
        *pIncomingCall = pCallInfo;
        pCallInfoList->Add(pIncomingCall);
 
-       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), pCallInfoList);
+       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL,
+                       SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
 }
 
 void
-BaseForm::HandleCallSwapOccured(IListT<CallInfo>& pCallList)
+BaseForm::HandleConfCallHoldOccured(bool success)
+{
+
+       switch (__formType)
+       {
+       case FORMTYPE_CONFCALLLIST:
+       {
+               ConfCallerListForm* pConfCallerListForm = dynamic_cast<ConfCallerListForm*>(this);
+               if(pConfCallerListForm != null)
+               {
+                       pConfCallerListForm->OnConfCallHoldTelephoneCallBackOccured(success);
+               }
+       }
+       break;
+       case FORMTYPE_ACTIVECONFCALL:
+       {
+               ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
+               if(pActiveCallForm != null)
+               {
+                       pActiveCallForm->OnConfCallHoldTelephonyCallback(success);
+               }
+       }
+       break;
+       default:
+               break;
+       }
+}
+
+void
+BaseForm::HandleConfCallActiveOccured(bool success)
+{
+       switch (__formType)
+       {
+       case FORMTYPE_CONFCALLLIST:
+       {
+               ConfCallerListForm* pConfCallerListForm = dynamic_cast<ConfCallerListForm*>(this);
+               if(pConfCallerListForm != null)
+               {
+                       pConfCallerListForm->OnConfCallActiveTelephoneCallBackOccured(success);
+               }
+       }
+       break;
+       case FORMTYPE_ACTIVECONFCALL:
+       {
+               ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
+               if(pActiveCallForm != null)
+               {
+                       pActiveCallForm->OnConfCallActiveTelephonyCallback(success);
+               }
+       }
+       break;
+       default:
+               break;
+       }
+}
+
+void
+BaseForm::HandleCallSwapOccured(IListT<AppCallInfo>& pCallList)
 {
        int noOfCalls = pCallList.GetCount();
        if(noOfCalls != IDI_MAX_ACTIVE_CALLS && __formType != FORMTYPE_MULTIPLECALLS)
@@ -285,12 +464,37 @@ BaseForm::HandleCallSwapOccured(IListT<CallInfo>& pCallList)
        {
                //update calls state
                pActiveCallForm->UpdateMultipleCallScreen(pCallList);
+               pActiveCallForm->SetSwapInProgress(false);
+
        }
 }
 
 void
 BaseForm::HandleConferenceChange(void)
 {
+       if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
+       {
+               //This scenario will come, if 1 call is disconnected from conf. call having more than 2 participants.
+               //In this case, if there is any dialing call exists, then ignore.
+               //Else, if there is any incoming call exists, then update call option popup.
+               switch (__formType)
+               {
+               case FORMTYPE_INCOMINGCALL:
+               {
+                       IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
+                       if (pIncomingCallForm != null)
+                       {
+                               pIncomingCallForm->CallDisconnected();
+                       }
+               }
+                       break;
+
+               default:
+                       break;
+               }
+               return;
+       }
+
        switch (__formType)
        {
        case FORMTYPE_CONFCALLLIST:
@@ -325,8 +529,8 @@ BaseForm::HandleTelephonyError(int errorCode)
        if (__pErrorMsgPopup == null)
        {
                __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
+               __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
        }
-       __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
 }
 
 void
@@ -348,7 +552,7 @@ BaseForm::HandlePopupClosed(void)
                        if(pPresentor->GetCurrentCallCount() > 0)
                        {
                                //fetch current call list
-                               IListT<CallInfo>* pCurrentCallList = pPresentor->GetCallListN();
+                               IListT<AppCallInfo>* pCurrentCallList = pPresentor->GetCallListN();
                                HandleCallDisconnected(false,*pCurrentCallList);
                                delete pCurrentCallList;
                                pCurrentCallList = null;