Fixed recursive appcontrol issue. Fixed Call reject from event injector during answer...
[apps/osp/Call.git] / src / CallEndCallForm.cpp
index 33fbefa..9ce5742 100644 (file)
@@ -212,32 +212,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,60 +242,29 @@ 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);
-
-       }
-       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;
+               requestParameter.Append(pContact->GetRecordId());
+               __isContactAppControlLaunched = __pCallPresentor->LaunchViewContactAppControl(requestParameter, this);
+               delete pContact;
+               pContact = null;
        }
        else
        {
-               __isContactAppControlLaunched = false;
+               //Add To Contact
+               requestParameter.Append(*__pContactNumber);
+               __isContactAppControlLaunched = __pCallPresentor->LaunchAddContactAppControl(requestParameter, this);
        }
-       extraData.RemoveAll(true);
-       if(pContact != null)
+
+       if (__isContactAppControlLaunched == true && __pEndCallEventTimer != null)
        {
-               delete pContact;
-               pContact = null;
+               //cancel EndCallTimer, if AppControl request was success.
+               __pEndCallEventTimer->Cancel();
        }
 }
 
@@ -559,7 +508,6 @@ EndCallForm::ShowThumbnailImage(const Bitmap* pPhotoId,const String& photoLabel)
                delete pBackground;
                delete pShadow;
        }
-
 }
 
 void
@@ -595,6 +543,7 @@ EndCallForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Stri
        {
                //Message AppControl request completed.
                __isMsgAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
        }
        //AppControl completed, goto initial scene if present
        //else exit.
@@ -604,10 +553,8 @@ EndCallForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Stri
 void
 EndCallForm::HandleLastCallCompletion(void)
 {
-
        CallApp* pPhoneApp = (static_cast<CallApp*>(UiApp::GetInstance()));
        pPhoneApp->Terminate();
-
 }
 
 void
@@ -618,25 +565,40 @@ 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)
+               {
+                       Contact* pContact = __pCallPresentor->GetContactN(*__pContactNumber);
+                       //before setting check if the contact is deleted
+                       if(pContact != null)
+                       {
+                               SetContactButtonState(false);
+                               delete pContact;
+                               pContact = null;
+                       }
+                       else
+                       {
+                               SetContactButtonState(true);
+                       }
+               }
+
+               //notify app control completed
+               __isContactAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
        }
-       __isContactAppControlLaunched = false;
 
        if (__isMsgAppControlLaunched == true)
        {
                //Message AppControl request completed.
-               //CallApp* pPhoneApp = (static_cast<CallApp*>(UiApp::GetInstance()));
-               //pPhoneApp->Terminate();
                if(__pEndCallEventTimer != null)
                {
                        __pEndCallEventTimer->Start(2000);
                }
                __isMsgAppControlLaunched = false;
+               __pCallPresentor->AppControlRequestCompleted();
        }
        AppLogDebug("Exit");
 }