From ad7d6e62039a82ed49165dea1f78f00ee4217ff7 Mon Sep 17 00:00:00 2001 From: Amith Kumar Mahale Date: Wed, 12 Jun 2013 20:03:11 +0530 Subject: [PATCH] Fix N_SE-41043 Change-Id: Ib6c95efe11645b1ae020cc23c9b11abb549e49fa Signed-off-by: Amith Kumar Mahale --- inc/CallActiveCallForm.h | 6 +- inc/CallInfo.h | 11 ++++ src/CallActiveCallForm.cpp | 149 ++++++++++++++++++++++++++++++++++++++++++- src/CallEndCallForm.cpp | 4 +- src/CallIncomingCallForm.cpp | 4 +- src/CallInfo.cpp | 149 ++++++++++++++++++++++++++++++++++++++++++- src/CallTelephonyManager.cpp | 31 ++++++++- 7 files changed, 343 insertions(+), 11 deletions(-) diff --git a/inc/CallActiveCallForm.h b/inc/CallActiveCallForm.h index 4584155..8e3782d 100644 --- a/inc/CallActiveCallForm.h +++ b/inc/CallActiveCallForm.h @@ -46,6 +46,7 @@ class ActiveCallForm , public Tizen::Ui::Scenes::ISceneEventListener , public Tizen::Base::Runtime::ITimerEventListener , public Tizen::Ui::IOrientationEventListener + , public Tizen::Social::IAddressbookChangeEventListener { public: ActiveCallForm(FormType formType); @@ -68,7 +69,9 @@ public: void HandleConfCallChanged(void); // Used to update multiple call screen void UpdateMultipleCallScreen(Tizen::Base::Collection::IListT& activeCallsList); - + //IAddressbookChangeEventListener + virtual void OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList); + virtual void OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList); //From IOrientationEventListener virtual void OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus); //From IAppStateChangeListener @@ -137,6 +140,7 @@ private: //Custom Buttons Panel CallButtonsPanel* __pCallButtonsPanel; DtmfKeyPadPanel* __pDTMFKeypad; + Tizen::Social::Addressbook* __pAddressbook; //Option Menu List for conference call Tizen::Ui::Controls::ListView* __pMoreOptionsList; Tizen::Ui::Controls::Label* __pMoreOptionsListAnchor; diff --git a/inc/CallInfo.h b/inc/CallInfo.h index db4efb3..eca5570 100644 --- a/inc/CallInfo.h +++ b/inc/CallInfo.h @@ -25,6 +25,7 @@ #include #include +#include #include "CallTypes.h" /** @@ -64,6 +65,8 @@ public: Tizen::Base::String& GetContactNumber(void); //Set the contact number for the call void SetContactNumber(Tizen::Base::String& contactNumber); + void ResetContactNumber(Tizen::Base::String* contactNumber); + void ResetContactInfo(const Tizen::Social::Contact* contact); //Sets the contact info for the call void SetContactInfo(const Tizen::Social::Contact& contact); //returns contact info if present in contacts db @@ -120,8 +123,16 @@ public: // this funtion fetches the contact person's name. Tizen::Base::String* FetchCallerNameN(void); + //Returns the latest Caller Name for a Number from address book + Tizen::Base::String* FetchLatestCallerNameN(const Tizen::Base::String& phoneNumber); // this funtion fetches the contact person's photo id, if present. Tizen::Graphics::Bitmap* FetchCallerPhotoN(void); + //Returns the latest Caller Photo for a Number from address book + Tizen::Graphics::Bitmap* FetchLatestCallerPhotoN(const Tizen::Base::String& phoneNumber); + //Returns the Contact Matched for the PhoneNumber from address book + Tizen::Social::Contact* FetchContactN(const Tizen::Base::String& phoneNumber); + + private: bool __isConfCall; diff --git a/src/CallActiveCallForm.cpp b/src/CallActiveCallForm.cpp index 5e40ede..13720a7 100644 --- a/src/CallActiveCallForm.cpp +++ b/src/CallActiveCallForm.cpp @@ -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::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* 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* 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& activeCallsList) { AppLog("ENTER"); @@ -1332,14 +1474,16 @@ ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListTFetchCallerNameN(); + 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; } diff --git a/src/CallEndCallForm.cpp b/src/CallEndCallForm.cpp index 54e025a..fdde32e 100644 --- a/src/CallEndCallForm.cpp +++ b/src/CallEndCallForm.cpp @@ -534,7 +534,7 @@ EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblN if(pCallInfo->IsConferenceCall() == false) { //fetch contact details based on phone number - pDisplayName = pCallInfo->FetchCallerNameN(); + pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber); } else { @@ -543,7 +543,7 @@ EndCallForm::ShowPersonDetails(const String& phoneNumber, const String& nameLblN Bitmap* pPhotoBitmap = null; if(pCallInfo->IsConferenceCall() == false) { - pPhotoBitmap = pCallInfo->FetchCallerPhotoN(); + pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber); } //passing an empty string to SetText fails in label, diff --git a/src/CallIncomingCallForm.cpp b/src/CallIncomingCallForm.cpp index 103136a..5800ee2 100644 --- a/src/CallIncomingCallForm.cpp +++ b/src/CallIncomingCallForm.cpp @@ -1012,8 +1012,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 diff --git a/src/CallInfo.cpp b/src/CallInfo.cpp index 8ad4df6..049bcae 100644 --- a/src/CallInfo.cpp +++ b/src/CallInfo.cpp @@ -119,6 +119,31 @@ AppCallInfo::GetContactNumber(void) } void +AppCallInfo::ResetContactNumber(String* contactNumber) +{ + if(contactNumber == null) + { + if (__isConfCall == false) + { + __contactNumber = null; + } + } + +} + +void +AppCallInfo::ResetContactInfo(const Contact* contact) +{ + if(contact == null) + { + if (__pContact != null) + { + delete __pContact; + __pContact = null; + } + } +} +void AppCallInfo::SetContactNumber(String& contactNumber) { if (__isConfCall == false) @@ -323,7 +348,6 @@ String* AppCallInfo::FetchCallerNameN(void) { String displayName(L""); - //get caller name from already fetched contact info if (__pContact != null) { @@ -331,8 +355,8 @@ AppCallInfo::FetchCallerNameN(void) String firstName(L""); String lastName(L""); String middlename(L""); - __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName); - __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName); + __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName); + __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName); __pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, middlename); displayName.Append(firstName + middlename + lastName); @@ -345,6 +369,125 @@ AppCallInfo::FetchCallerNameN(void) return new (std::nothrow) String(displayName); } +Contact* +AppCallInfo::FetchContactN(const Tizen::Base::String& phoneNumber) +{ + Tizen::Social::Contact* pFoundContact = null; + if(__pAddressBook == null) + { + __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN(); + } + IList* pContactList = __pAddressBook->SearchContactsByPhoneNumberN(phoneNumber); + if (pContactList == null || IsFailed(GetLastResult())) + { + return null; + } + + //Fetch the contact's info to be displayed + IEnumerator* pContactEnum = pContactList->GetEnumeratorN(); + while (E_SUCCESS == pContactEnum->MoveNext()) + { + Contact* pContact = static_cast(pContactEnum->GetCurrent()); + + IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); + if (pPhoneNumberList != null) + { + IEnumerator* pPhoneEnum = pPhoneNumberList->GetEnumeratorN(); + while (E_SUCCESS == pPhoneEnum->MoveNext()) + { + PhoneNumber* pPhoneNumber = (PhoneNumber*) pPhoneEnum->GetCurrent(); + //Check if this is the correct contact + if (pPhoneNumber->GetPhoneNumber().Equals(phoneNumber)) + { + //save newly fetched contact info. + pFoundContact = new (std::nothrow) Contact(*pContact); + break; + } + } + delete pPhoneEnum; + pPhoneNumberList->RemoveAll(true); + delete pPhoneNumberList; + } + } + delete pContactEnum; + pContactList->RemoveAll(true); + delete pContactList; + + if(pFoundContact == null) + { + return null; + } + + return pFoundContact; + +} + + +String* +AppCallInfo::FetchLatestCallerNameN(const Tizen::Base::String& phoneNumber) +{ + String displayName(L""); + Tizen::Social::Contact* pContact = null; + //Fetch the contact for a number from address book + pContact = FetchContactN(phoneNumber); + if(pContact != null) + { + String firstName(L""); + String lastName(L""); + String middlename(L""); + pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName); + pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName); + pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, middlename); + displayName.Append(firstName + middlename + lastName); + + if (displayName.IsEmpty() == false) + { + pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName); + } + } + + return new (std::nothrow) String(displayName); + + +} +Bitmap* +AppCallInfo::FetchLatestCallerPhotoN(const Tizen::Base::String& phoneNumber) +{ + result r = E_FAILURE; + Tizen::Social::Contact* pContact = null; + String thumbnailPath; + Bitmap* pThumbnail = null; + pContact = FetchContactN(phoneNumber); + if(pContact != null) + { + pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL,thumbnailPath); + if(thumbnailPath.IsEmpty() == true) + { + IList* pCategoryList = __pAddressBook->GetCategoriesByContactN(pContact->GetRecordId()); + if(pCategoryList != null && pCategoryList->GetCount() > 0) + { + AppLogDebug("Changes to get thumbnail group photo"); + Category* pCategory = static_cast(pCategoryList->GetAt(0)); + thumbnailPath = pCategory->GetThumbnailPath(); + } + } + ImageBuffer thumbnailImageBuffer; + r = thumbnailImageBuffer.Construct(thumbnailPath); + if (r == E_SUCCESS) + { + pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE); + } + + if(pThumbnail != null) + { + return pThumbnail; + } + } + + return null; + +} + Bitmap* AppCallInfo::FetchCallerPhotoN(void) { diff --git a/src/CallTelephonyManager.cpp b/src/CallTelephonyManager.cpp index 0a98f23..65884c6 100644 --- a/src/CallTelephonyManager.cpp +++ b/src/CallTelephonyManager.cpp @@ -337,7 +337,6 @@ result TelephonyManager::EndActiveCall(Long callHandle) { result r = E_FAILURE; - //fetch ended callInfo from active call list AppCallInfo endCall; r = __pActiveCallList->GetValue(callHandle.ToLong(), endCall); @@ -345,6 +344,7 @@ TelephonyManager::EndActiveCall(Long callHandle) { r = EndCall(endCall); } + return r; } @@ -1739,6 +1739,7 @@ TelephonyManager::HandleEndConferenceCallbackResponse(TapiHandle* pHandle, int c AppLog("ENTER"); //This callback comes only if a conference call is ended by user. TelephonyManager* pTelManager = (TelephonyManager*) pUserData; + AppCallInfo heldCall; if (callBackResult == TAPI_CAUSE_SUCCESS && pData != null) { //fetch ended confCall details @@ -1792,6 +1793,24 @@ TelephonyManager::HandleEndConferenceCallbackResponse(TapiHandle* pHandle, int c { //fetch active calls to show appropriate scene pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + r = pCallList->GetAt(0, heldCall); + if (r == E_SUCCESS) + { + //pTelManager->HoldActiveCall(&heldCall, false); + AppCallInfo* pHeldCallInfo = new (std::nothrow) AppCallInfo(); + unsigned int callHandle = heldCall.GetCallHandle()->ToLong(); + //copy state into new callinfo object + *pHeldCallInfo = heldCall; + + //set call to hold state + pHeldCallInfo->SetOnHold(false); + + pTelManager->__pActiveCallList->Remove(callHandle); + //replace old object with new + pTelManager->__pActiveCallList->Add(callHandle, *pHeldCallInfo); + delete pCallList; + pCallList = static_cast*>(pTelManager->__pActiveCallList->GetValuesN()); + } } //notify listener that call is disconnected. pTelManager->__pEventListener->HandleCallDisconnected(isLastCall, *pCallList); @@ -1949,6 +1968,8 @@ bool TelephonyManager::HandleEndNormalActiveCall(AppCallInfo& endCallInfo) { AppLogDebug("Enter"); + result r = E_FAILURE; + AppCallInfo heldCall; // This function gets called only from HandleIdleCallback(), // to handle disconnection of normal active calls. if (endCallInfo.IsConferenceCall() == false) @@ -1971,6 +1992,14 @@ TelephonyManager::HandleEndNormalActiveCall(AppCallInfo& endCallInfo) { //fetch active calls to show appropriate scene pCallList = static_cast*>(__pActiveCallList->GetValuesN()); + //fetch the held call on disconnecting the active call and activate it. + r = pCallList->GetAt(0, heldCall); + if (r == E_SUCCESS) + { + HoldActiveCall(&heldCall, false); + delete pCallList; + pCallList = static_cast*>(__pActiveCallList->GetValuesN()); + } } //Save "End" call info to call log database -- 2.7.4