Fix N_SE-41043
[apps/osp/Call.git] / src / CallActiveCallForm.cpp
index 5e40ede..13720a7 100644 (file)
@@ -110,6 +110,7 @@ ActiveCallForm::ActiveCallForm(FormType formType)
        __pActiveCallInfo = null;
        __pHeldCallInfo = null;
        __isSwapInProgress = false;
+       __pAddressbook == null;
 }
 
 ActiveCallForm::~ActiveCallForm(void)
@@ -895,6 +896,14 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        //Initialize keypad and buttons
        InitializeCallButtonsPanel();
 
+       AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
+       __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
+       if(__pAddressbook != null)
+       {
+               __pAddressbook->SetAddressbookChangeEventListener(this);
+       }
+
+
        if (__pActiveCallInfo != null)
        {
                delete __pActiveCallInfo;
@@ -1104,6 +1113,10 @@ ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId&
        __DtmfString.Clear();
        CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
        pCallApp->RemoveAppStateChangeListener(*this);
+       if(__pAddressbook != null)
+       {
+               __pAddressbook->SetAddressbookChangeEventListener(null);
+       }
 }
 
 void
@@ -1177,6 +1190,135 @@ ActiveCallForm::HandleConfCallChanged(void)
 }
 
 void
+ActiveCallForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
+{
+       AppLog("Enter");
+       switch (__formType)
+       {
+
+       case FORMTYPE_EMERGENCYOUTGOINGCALL:
+       {
+       }
+       break;
+
+       case FORMTYPE_OUTGOINGCALL:
+       case FORMTYPE_ACTIVECALL:
+       {
+               String pContactNumber;
+               pContactNumber.Append(__pActiveCallInfo->GetContactNumber());
+               Contact* pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
+               if(pContact == null)
+               {
+                       __pActiveCallInfo->ResetContactNumber(null);
+                       __pActiveCallInfo->ResetContactInfo(null);
+
+               }
+               else
+               {
+                       __pActiveCallInfo->SetContactNumber(pContactNumber);
+                       __pActiveCallInfo->SetContactInfo(*pContact);
+               }
+               if(pContact != null)
+               {
+                       delete pContact;
+                       pContact = null;
+               }
+               ShowPersonDetails(pContactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
+       }
+       break;
+
+       case FORMTYPE_EMERGENCYACTIVECALL:
+       {
+       }
+       break;
+
+       case FORMTYPE_MULTIPLECALLS:
+       {
+
+               IListT<AppCallInfo>* pCallsList = __pCallPresentor->GetCallListN();
+               int listCount = pCallsList->GetCount();
+               for(int index = 0; index < listCount; index++)
+               {
+                       AppCallInfo callInfo;
+                       Contact* pContact;
+                       pCallsList->GetAt(index, callInfo);
+                       if(__pActiveCallInfo == null)
+                       {
+                               __pActiveCallInfo = new (std::nothrow) AppCallInfo();
+                       }
+                       *__pActiveCallInfo =  callInfo;
+                       String contactNumber;
+                       contactNumber.Append(__pActiveCallInfo->GetContactNumber());
+                       pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
+                       if(pContact == null)
+                       {
+                               __pActiveCallInfo->ResetContactNumber(null);
+                               __pActiveCallInfo->ResetContactInfo(null);
+
+                       }
+                       else
+                       {
+                               __pActiveCallInfo->SetContactNumber(contactNumber);
+                               __pActiveCallInfo->SetContactInfo(*pContact);
+                       }
+                       if(pContact != null)
+                       {
+                               delete pContact;
+                               pContact = null;
+                       }
+                       if(callInfo.IsOnHold() == false)
+                       {
+                               ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
+                       }
+                       else
+                       {
+                               ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
+                       }
+
+               }
+               if(pCallsList != null)
+               {
+                       delete pCallsList;
+                       pCallsList = null;
+               }
+               //pCallsList = __pCallPresentor->GetCallListN();
+               //update calls state
+               //UpdateMultipleCallScreen(*pCallsList);
+               //delete pCallsList;
+               //pCallsList = null;
+       }
+       break;
+
+       case FORMTYPE_ACTIVECONFCALL:
+       {
+               int participantsCount = __pActiveCallInfo->GetCallerListCount();
+               IListT<AppCallInfo>* pParticipantListCallHandles = __pActiveCallInfo->GetCallerList();
+               for(int listCount = 0; listCount < participantsCount; listCount++)
+               {
+
+               }
+
+       }
+       break;
+
+       default:
+               break;
+       }
+
+
+
+
+       AppLog("Exit");
+}
+
+void
+ActiveCallForm::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
+{
+       //No implementation
+}
+
+
+void
 ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCallInfo>& activeCallsList)
 {
        AppLog("ENTER");
@@ -1332,14 +1474,16 @@ ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCall
 void
 ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, AppCallInfo* pCallInfo)
 {
+       result r = E_FAILURE;
+
        //call individual methods to show contact number, caller name & photo
        ShowPhoneNumber(phoneNumber, contactLblName);
 
        //fetch contact details based on phone number
-       String* pDisplayName = pCallInfo->FetchCallerNameN();
+       String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
        ShowCallerName(*pDisplayName, nameLblName);
 
-       Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
+       Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
        ShowCallerPhoto(pPhotoBitmap, isSecondCaller);
 
        //free resources
@@ -1517,6 +1661,7 @@ ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
                        if (pPhotoLbl)
                        {
                                pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
+                               pPhotoLbl->Invalidate(true);
                        }
                        delete pDefaultPhoto;
                }