Fix for 42792
[apps/osp/Call.git] / src / CallIncomingCallForm.cpp
index fdea3cb..89f486c 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,7 +19,6 @@
  * @brief      Incoming Call form implementation
  */
 #include <FBaseColIList.h>
-#include <FMessaging.h>
 #include "CallIncomingCallForm.h"
 #include "CallAppUtility.h"
 #include "CallSettingsManager.h"
@@ -32,7 +31,6 @@ using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
-using namespace Tizen::Messaging;
 using namespace Tizen::Ui;
 using namespace Tizen::Ui::Animations;
 using namespace Tizen::Ui::Controls;
@@ -138,16 +136,6 @@ const wchar_t* IDI_REJECT_ARROW_VISUAL_ELE_NAME = L"RejectArrowVisEle";
 const wchar_t* IDI_REJECT_FINAL_VISUAL_ELE_NAME = L"RejectFinalVisEle";
 const wchar_t* IDI_ACCEPT_FINAL_VISUAL_ELE_NAME = L"AcceptFinalVisEle";
 
-class SmsListener
-       : public Object
-       , public ISmsListener
-{
-public:
-               void  OnSmsMessageSent(result r)
-               {
-               }
-};
-
 IncomingCallForm::IncomingCallForm(void)
        : BaseForm(FORMTYPE_INCOMINGCALL)
 {
@@ -218,14 +206,7 @@ IncomingCallForm::OnInitializing(void)
        }
        HideRejectPanel();
 
-       //Get Reject list from Settings Manager
-       IMapT<int,String>* pMsgMap = SettingsManager::GetInstance()->GetRejectMessageListN();
-       if(pMsgMap != null)
-       {
-               __pRejectMessageList = pMsgMap->GetValuesN();
-               delete pMsgMap;
-               pMsgMap = null;
-       }
+
        InitializeTableView();
 
        __pAcceptCircle = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
@@ -410,7 +391,6 @@ IncomingCallForm::InitializeFooter(void)
                footerItemCreate.Construct(IDA_CREATE_REJECT_CALL_MESSAGE);
                footerItemCreate.SetText(AppUtility::GetResourceString(IDS_REJECT_MESSAGE_CREATE));
                pFooter->AddItem(footerItemCreate);
-               pFooter->SetBackButton();
                pFooter->SetShowState(false);
        }
 }
@@ -602,7 +582,7 @@ IncomingCallForm::ShowRejectMessagePanel(void)
                        pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
                        pButtonReject->AddActionEventListener(*this);
                        pButtonReject->SetEnabled(true);
-                       pButtonReject->SetFocus();
+                       //pButtonReject->SetFocus();
 
                        ShowRejectMessageFooter();
 
@@ -673,42 +653,12 @@ IncomingCallForm::OnActionPerformed(const Control& source, int actionId)
        case IDA_SEND_REJECT_MSG6:
        {
                __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
-               SmsListener* pSmsListener = new (std::nothrow) SmsListener();
-               SmsManager* pSmsManager = new (std::nothrow) SmsManager();
-               result r = pSmsManager->Construct(*pSmsListener);
-               if (IsFailed(r) == false)
-               {
-                       RecipientList recipient;
-                       recipient.Add(RECIPIENT_TYPE_TO,*__pActiveContactNo);
-                       SmsMessage smsMessage;
-                       String textToBeSent;
-                       //calculate msgIndex
-                       int msgIndex = IDA_SEND_REJECT_MSG1;
-                       msgIndex = actionId - msgIndex;
-                       __pRejectMessageList->GetAt(msgIndex, textToBeSent);
-                       r = smsMessage.SetText(textToBeSent);
-                       if (IsFailed(r) == false)
-                       {
-                               r = pSmsManager->Send(smsMessage,recipient,true);
-                               if (IsFailed(r) == true)
-                               {
-                                       //todo: error message
-                               }
-                       }
-                       else
-                       {
-                               //todo: error message
-                       }
-               }
-               else
-               {
-                       //todo: error message
-               }
-               delete pSmsListener;
-               delete pSmsManager;
-               /*ArrayListT<CallInfo>* pCallList  = static_cast<ArrayListT<CallInfo>*>(__pCallPresentor->GetCallListN());
-               __pCallPresentor->HandleCallConnected(*pCallList);
-               pCallList = null;*/
+               String textToBeSent;
+               //calculate msgIndex
+               int msgIndex = IDA_SEND_REJECT_MSG1;
+               msgIndex = actionId - msgIndex;
+               __pRejectMessageList->GetAt(msgIndex, textToBeSent);
+               __pCallPresentor->SendMessage(textToBeSent,*__pActiveContactNo);
        }
        break;
 
@@ -721,6 +671,28 @@ void
 IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId,    const SceneId& currentSceneId, IList* pArgs)
 {
        AddOrientationEventListener(*this);
+       //Get Reject list from Settings Manager
+       IMapT<int,String>* pMsgMap = SettingsManager::GetInstance()->GetRejectMessageListN();
+       if(pMsgMap != null)
+       {
+               if (__pRejectMessageList != null)
+               {
+                       delete __pRejectMessageList;
+                       __pRejectMessageList = null;
+               }
+               __pRejectMessageList = pMsgMap->GetValuesN();
+               delete pMsgMap;
+               pMsgMap = null;
+       }
+       //No reject messages
+       else
+       {
+               if (__pRejectMessageList != null)
+               {
+                       delete __pRejectMessageList;
+                       __pRejectMessageList = null;
+               }
+       }
        //listen to Foreground events
        CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
        pPhoneApp->AddAppStateChangeListener(*this);
@@ -729,6 +701,12 @@ IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId,        const SceneI
                __pCallPresentor = CallPresentationModel::GetInstance();
        }
        __pCallPresentor->SetTelEventListener(this);
+       //Abort any AppControl Request running already to show incoming call screen
+       if (__pCallPresentor->IsAppControlRunning() == true)
+       {
+               __pCallPresentor->AbortAppControlRequest();
+       }
+
        HideRejectPanel();
 
        if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
@@ -826,6 +804,10 @@ IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId,        const SceneI
                pButtonRejectMessage->AddActionEventListener(*this);
        }
 
+       //This called here to handle the case when incoming call comes when
+       // add call is in foreground.
+       //__pCallPresentor->OnAppForeground();
+
 }
 
 void
@@ -868,7 +850,6 @@ IncomingCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneI
 
        }
        CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
-       pCallApp->SetTopMostWindow(false);
        pCallApp->RemoveAppStateChangeListener(*this);
 }
 
@@ -971,7 +952,7 @@ IncomingCallForm::CreateItem(int itemIndex, int itemWidth)
        pMsgLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
        pMsgLbl->SetTextConfig(FONT_SIZE_MSG_TXT, LABEL_TEXT_STYLE_NORMAL);
        pMsgLbl->SetTextColor(COLOR_LIST_TEXT_NORMAL);
-       pItem->AddControl(*pMsgLbl);
+       pItem->AddControl(pMsgLbl);
 
        //Send Button
        if(isShowSendButton == true)
@@ -1036,8 +1017,8 @@ IncomingCallForm::ShowPersonDetails(const String& phoneNumber, const String& con
        SetTextToLabel(phoneNumber, contactLblName);
 
        //fetch contact details based on phone number
-       String* pDisplayName = pCallInfo->FetchCallerNameN();
-       Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
+       String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
+       Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
        ShowCallerPhoto(pPhotoBitmap);
 
        //free resources
@@ -1286,7 +1267,7 @@ IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const St
 void
 IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
 {
-       __pCallPresentor->StopAlert();
+       //__pCallPresentor->StopAlert();
        if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET)
        {
                Rectangle rect = source.GetBounds();
@@ -1594,7 +1575,8 @@ IncomingCallForm::OnOrientationChanged(const Control& source, OrientationStatus
 void
 IncomingCallForm::OnForeground(void)
 {
-       __pCallPresentor->OnAppForeground();
+       AppLogDebug("Enter");
+//     __pCallPresentor->OnAppForeground();
 }
 
 void