From 3dfd547c7a2c02fb0cb26392b683f9e6af6a1c86 Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Thu, 8 Jun 2017 16:09:19 +0300 Subject: [PATCH] TizenRefApp-8645 [Call UI] Implement Voice Mail identify in CallerInfo Change-Id: Ia66bb96f0ebcf8af66ab86ac2229456d8ca79c39 --- inc/model/ICallInfo.h | 1 + inc/presenters/CallInfoPresenter.h | 8 ++-- inc/resources.h | 1 + src/model/CallInfo.cpp | 30 +++++++++++--- src/model/CallInfo.h | 2 + src/presenters/CallInfoPresenter.cpp | 61 +++++++++++++++++++--------- src/resources.cpp | 1 + 7 files changed, 74 insertions(+), 30 deletions(-) diff --git a/inc/model/ICallInfo.h b/inc/model/ICallInfo.h index 7c1d4fd..f0f0ba8 100644 --- a/inc/model/ICallInfo.h +++ b/inc/model/ICallInfo.h @@ -31,6 +31,7 @@ namespace callui { virtual bool isEmergency() const = 0; virtual bool isHDVoice() const = 0; virtual bool isForwarded() const = 0; + virtual bool isVoiceMailNumber() const = 0; virtual int getConferenceMemberCount() const = 0; virtual const ConfMemberList &getConferenceMemberList() const = 0; }; diff --git a/inc/presenters/CallInfoPresenter.h b/inc/presenters/CallInfoPresenter.h index eb86978..eb9a9f3 100644 --- a/inc/presenters/CallInfoPresenter.h +++ b/inc/presenters/CallInfoPresenter.h @@ -66,16 +66,15 @@ namespace callui { ucl::Result updateSubText(); ucl::Result updateMainTxt(); - std::string getNumberSubText(const ICallInfoWCRef &callInfo) const; + std::string getNumberSubText(const ICallInfoSCRef &callInfo) const; std::string getIncomingCallSubText() const; std::string getOutgoingCallSubText() const; std::string getDuringCallSubText() const; std::string getEndCallSubText() const; - std::string generateMainTxt(const ICallInfoWCRef &callInfo); + std::string generateMainTxt(const ICallInfoSCRef &callInfo); - void displayMainTxt(const std::string &text) const; - void displaySubTxt(const std::string &text) const; + void displayMainTxt(const ICallInfoSCRef &info, const std::string &text) const; private: ucl::LayoutSRef m_widget; @@ -87,7 +86,6 @@ namespace callui { ICallInfoSCRef m_heldCallInfo; ICallInfoSCRef m_endCallInfo; CallStatusSRef m_callStatus; - bool m_isEmergency; bool m_isSubTxtEnable; bool m_needModifyCallStatus; }; diff --git a/inc/resources.h b/inc/resources.h index 9fe4910..a6983ee 100644 --- a/inc/resources.h +++ b/inc/resources.h @@ -35,6 +35,7 @@ namespace callui { extern const ucl::TString STR_CONFERENCE_CALL; extern const ucl::TString STR_UNKNOWN; extern const ucl::TString STR_EMERGENCY_CALL; + extern const ucl::TString STR_VOICEMAIL; extern const ucl::TString STR_INCOMING_CALL; extern const ucl::TString STR_DIALING_CALL; diff --git a/src/model/CallInfo.cpp b/src/model/CallInfo.cpp index 7341675..2119de3 100644 --- a/src/model/CallInfo.cpp +++ b/src/model/CallInfo.cpp @@ -67,6 +67,7 @@ namespace callui { m_isEmergency(false), m_isHDVoice(false), m_isForwarded(false), + m_isVoiceMailNumber(false), m_confMemberCount(0) { } @@ -92,31 +93,43 @@ namespace callui { Result CallInfo::prepare(CallClient &client, cm_call_data_h callData) { - Result res = convertCMResult(cm_call_data_get_call_id(callData, &m_callId)); + Result res = convertCMResult( + cm_call_data_get_call_id(callData, &m_callId)); FAIL_RETURN(res, "cm_call_data_get_call_id() failed!"); char *number = nullptr; - res = convertCMResult(cm_call_data_get_call_number(callData, &number)); + res = convertCMResult( + cm_call_data_get_call_number(callData, &number)); FAIL_RETURN(res, "cm_call_data_get_call_number() failed!"); m_phoneNum = nz(number); // XXX: According to documentation it must be free, but it leads to crash // free(number); gboolean isEmergency; - res = convertCMResult(cm_call_data_is_emergency_call(callData, &isEmergency)); + res = convertCMResult( + cm_call_data_is_emergency_call(callData, &isEmergency)); FAIL_RETURN(res, "cm_call_data_is_emergency_call() failed!"); m_isEmergency = isEmergency; int hdIconState = 0; - res = convertCMResult(cm_call_data_get_hd_icon_state(callData, &hdIconState)); + res = convertCMResult( + cm_call_data_get_hd_icon_state(callData, &hdIconState)); FAIL_RETURN(res, "cm_call_data_get_hd_icon_state() failed!"); m_isHDVoice = hdIconState; - res = convertCMResult(cm_call_data_get_start_time(callData, &m_startTime)); + gboolean isVoiceMailNumber; + res = convertCMResult( + cm_call_data_is_voicemail_number(callData, &isVoiceMailNumber)); + FAIL_RETURN(res, "cm_call_data_is_voicemail_number() failed!"); + m_isVoiceMailNumber = isVoiceMailNumber; + + res = convertCMResult( + cm_call_data_get_start_time(callData, &m_startTime)); FAIL_RETURN(res, "cm_call_data_get_start_time() failed!"); int personId = -1; - res = convertCMResult(cm_call_data_get_person_id(callData, &personId)); + res = convertCMResult( + cm_call_data_get_person_id(callData, &personId)); FAIL_RETURN(res, "cm_call_data_get_person_id() failed!"); if (personId >= 0) { @@ -205,6 +218,11 @@ namespace callui { return m_isForwarded; } + bool CallInfo::isVoiceMailNumber() const + { + return m_isVoiceMailNumber; + } + int CallInfo::getConferenceMemberCount() const { return m_confMemberCount; diff --git a/src/model/CallInfo.h b/src/model/CallInfo.h index b3b9aff..5a0d57e 100644 --- a/src/model/CallInfo.h +++ b/src/model/CallInfo.h @@ -39,6 +39,7 @@ namespace callui { virtual bool isEmergency() const override final; virtual bool isHDVoice() const override final; virtual bool isForwarded() const override final; + virtual bool isVoiceMailNumber() const override final; virtual int getConferenceMemberCount() const override final; virtual const ConfMemberList &getConferenceMemberList() const override final; @@ -57,6 +58,7 @@ namespace callui { bool m_isEmergency; bool m_isHDVoice; bool m_isForwarded; + bool m_isVoiceMailNumber; int m_confMemberCount; ConfMemberList m_confMemberList; }; diff --git a/src/presenters/CallInfoPresenter.cpp b/src/presenters/CallInfoPresenter.cpp index 1e49f04..58cef09 100644 --- a/src/presenters/CallInfoPresenter.cpp +++ b/src/presenters/CallInfoPresenter.cpp @@ -126,7 +126,6 @@ namespace callui { CallMode mode): Presenter(rc), m_mode(mode), - m_isEmergency(false), m_isSubTxtEnable(false), m_needModifyCallStatus(false) { @@ -206,7 +205,8 @@ namespace callui { } } - Result CallInfoPresenter::update(CallMode mode, const ICallManagerSRef &cm) + Result CallInfoPresenter::update(CallMode mode, + const ICallManagerSRef &cm) { m_needModifyCallStatus = false; if (mode != m_mode || mode == CallMode::DURING) { @@ -215,13 +215,13 @@ namespace callui { m_mode = mode; initCallInfos(cm); - m_isEmergency = false; m_isSubTxtEnable = false; return update(); } - std::string CallInfoPresenter::getNumberSubText(const ICallInfoWCRef &callInfo) const + std::string CallInfoPresenter::getNumberSubText( + const ICallInfoSCRef &callInfo) const { if (!callInfo) { FAIL_RETURN_VALUE(RES_FAIL, "", "callInfo is NULL!"); @@ -252,7 +252,13 @@ namespace callui { if (displStr.empty()) { displStr = STR_UNKNOWN.translate(); } - return TString{STR_CALL_WITH_PS_WILL_END.translate()}.format(displStr.c_str()); + return TString{STR_CALL_WITH_PS_WILL_END.translate()}. + format(displStr.c_str()); + } + + if (m_incomCallInfo->isVoiceMailNumber() || + m_incomCallInfo->isEmergency()){ + return ""; } return getNumberSubText(m_incomCallInfo); @@ -265,12 +271,14 @@ namespace callui { if (m_heldCallInfo) { return STR_CALL_ON_HOLD.translate(); } else if (confMemberCount > 1) { - return TString{STR_WITH_PD_PEOPLE.translate()}.format(confMemberCount); + return TString{STR_WITH_PD_PEOPLE.translate()}. + format(confMemberCount); } } else if (m_heldCallInfo) { auto confMemberCount = m_heldCallInfo->getConferenceMemberCount(); if (confMemberCount > 1) { - return TString{STR_WITH_PD_PEOPLE.translate()}.format(confMemberCount); + return TString{STR_WITH_PD_PEOPLE.translate()}. + format(confMemberCount); } } else { ELOG("Invalid call data"); @@ -287,7 +295,8 @@ namespace callui { auto confMemberCount = m_endCallInfo->getConferenceMemberCount(); if (confMemberCount > 1) { - return TString{STR_WITH_PD_PEOPLE.translate()}.format(confMemberCount); + return TString{STR_WITH_PD_PEOPLE.translate()}. + format(confMemberCount); } return ""; @@ -312,7 +321,8 @@ namespace callui { label->setText(tmp); elm_label_slide_mode_set(*label, ELM_LABEL_SLIDE_MODE_AUTO); - elm_label_wrap_width_set(*label, ELM_SCALE_SIZE(impl::SUB_TXT_WIDTH)); + elm_label_wrap_width_set(*label, + ELM_SCALE_SIZE(impl::SUB_TXT_WIDTH)); elm_label_slide_duration_set(*label, duration); elm_label_slide_go(*label); @@ -417,7 +427,8 @@ namespace callui { return RES_OK; } - std::string CallInfoPresenter::generateMainTxt(const ICallInfoWCRef &callInfo) + std::string CallInfoPresenter::generateMainTxt( + const ICallInfoSCRef &callInfo) { if (!callInfo) { LOG_RETURN_VALUE(RES_FAIL, "", "callInfo is NULL"); @@ -428,10 +439,13 @@ namespace callui { } if (callInfo->isEmergency()) { - m_isEmergency = true; return STR_EMERGENCY_CALL.translate(); } + if (callInfo->isVoiceMailNumber()) { + return STR_VOICEMAIL.translate(); + } + std::string mainTxt; auto contactInfo = callInfo->getContactInfo(); if (contactInfo) { @@ -447,7 +461,8 @@ namespace callui { return mainTxt; } - void CallInfoPresenter::displayMainTxt(const std::string &text) const + void CallInfoPresenter::displayMainTxt(const ICallInfoSCRef &info, + const std::string &text) const { m_widget->setText(text.c_str(), impl::PART_TXT_MAIN); @@ -463,7 +478,7 @@ namespace callui { m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, impl::SRC_TXT_1LINE); - if (m_isEmergency) { + if (info->isEmergency()) { m_widget->emit(impl::SIGN_EMERGENCY_MODE, impl::SRC_TXT_1LINE); } @@ -500,33 +515,41 @@ namespace callui { Result CallInfoPresenter::updateMainTxt() { std::string mainTxt; + + ICallInfoSCRef info; + switch (m_mode) { case CallMode::INCOMING: - mainTxt = generateMainTxt(m_incomCallInfo); + info = m_incomCallInfo; break; case CallMode::OUTGOING: - mainTxt = generateMainTxt(m_activeCallInfo); + info = m_activeCallInfo; break; case CallMode::DURING: if (m_activeCallInfo) { - mainTxt = generateMainTxt(m_activeCallInfo); + info = m_activeCallInfo; } else if (m_heldCallInfo) { - mainTxt = generateMainTxt(m_heldCallInfo); + info = m_heldCallInfo; } break; case CallMode::END: - mainTxt = generateMainTxt(m_endCallInfo); + info = m_endCallInfo; break; default: LOG_RETURN(RES_FAIL, "Unknown mode"); break; } + if (!info) { + LOG_RETURN(RES_FAIL, "info is NULL"); + } + + mainTxt = generateMainTxt(info); if (mainTxt.empty()) { LOG_RETURN(RES_FAIL, "Main text is empty"); } - displayMainTxt(mainTxt); + displayMainTxt(info, mainTxt); return RES_OK; } diff --git a/src/resources.cpp b/src/resources.cpp index fdd8f18..e2258e7 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -30,6 +30,7 @@ namespace callui { const ucl::TString STR_CONFERENCE_CALL {"Conference call"}; const ucl::TString STR_UNKNOWN {"Unknown"}; const ucl::TString STR_EMERGENCY_CALL {"Emergency call"}; + const ucl::TString STR_VOICEMAIL {"Voicemail"}; const ucl::TString STR_INCOMING_CALL {"Incoming call"}; const ucl::TString STR_DIALING_CALL {"Dialing"}; -- 2.34.1