Fixed nabi issues 36791 36868 36881 36879 36280 36808 36332
[apps/osp/Call.git] / src / CallEndCallForm.cpp
index 1da349e..ae7ada8 100644 (file)
@@ -64,7 +64,6 @@ EndCallForm::EndCallForm(void)
        __pSmallPhotoLabel = null;
        __isMsgAppControlLaunched = false;
        __isContactAppControlLaunched = false;
-       __isContactPresent = false;
 }
 
 EndCallForm::~EndCallForm(void)
@@ -212,32 +211,12 @@ 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();
-                       }
-                       delete pAc;
+                       //cancel EndCallTimer, if AppControl request was successful.
+                       __pEndCallEventTimer->Cancel();
                }
-
-               extraData.RemoveAll(true);
        }
        break;
 
@@ -262,56 +241,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_VIEW_TYPE_CONTACT), new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT));
-               extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), new (std::nothrow) String(idVal));
-               extraData.Add(new (std::nothrow) String(CONTACTS_ID_KEY), new (std::nothrow) String(idVal));
-               extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_TYPE), new (std::nothrow) String(ITEM_TYPE_PERSON));
-                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));
-               extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_TYPE), new (std::nothrow) String(ITEM_TYPE_CONTACT));
-               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
@@ -347,13 +300,26 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
                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,
@@ -366,6 +332,17 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
                {
                        __pCallButtonsPanel->SetEndCallPanelState(true);
                }
+
+               //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)
+               {
+                       __pCallButtonsPanel->ShowOrHideAddtoContactsButton(true);
+               }
+
        }
        break;
 
@@ -373,7 +350,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);
        }
@@ -384,6 +362,7 @@ EndCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& cu
                delete pArgs;
                pArgs = null;
        }
+       AddOrientationEventListener(*this);
 }
 
 void
@@ -405,6 +384,7 @@ EndCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& ne
        //remove itself as listener
        CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
        pPhoneApp->RemoveAppStateChangeListener(*this);
+       RemoveOrientationEventListener(*this);
 }
 
 result
@@ -414,19 +394,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)
 {
@@ -541,7 +519,6 @@ EndCallForm::ShowThumbnailImage(const Bitmap* pPhotoId,const String& photoLabel)
                delete pBackground;
                delete pShadow;
        }
-
 }
 
 void
@@ -572,10 +549,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.
@@ -585,10 +570,8 @@ EndCallForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Stri
 void
 EndCallForm::HandleLastCallCompletion(void)
 {
-
        CallApp* pPhoneApp = (static_cast<CallApp*>(UiApp::GetInstance()));
        pPhoneApp->Terminate();
-
 }
 
 void
@@ -599,10 +582,57 @@ 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(2000);
+               }
+               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;
+               }
+
+               //notify app control completed
+               __isContactAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
+       }
+       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();
        }
-       __isContactAppControlLaunched = false;
        AppLogDebug("Exit");
 }
 
@@ -615,6 +645,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
@@ -625,7 +656,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)