From: Igor Olshevskyi Date: Mon, 25 Sep 2017 14:09:13 +0000 (+0300) Subject: TizenRefApp-9430 [Call UI] Fix Svace issue X-Git-Tag: submit/tizen_4.0/20171018.080056~9^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e53fb2fb1261a31bfa5790d1bf800d6f2213a1c;p=profile%2Fwearable%2Fapps%2Fnative%2Fcall-ui.git TizenRefApp-9430 [Call UI] Fix Svace issue Change-Id: I72ec5c7e31a7ecaa49e038c80934f90370ec37c4 --- diff --git a/call-ui/helpers.h b/call-ui/helpers.h index 85c104f..5689ff4 100644 --- a/call-ui/helpers.h +++ b/call-ui/helpers.h @@ -29,6 +29,13 @@ namespace callui { namespace util { template ucl::Result call(FUNC &&func, ARGS &&...args); + + // String helpers // + + bool beginsWith(const std::string &str, const std::string &prefix, + bool caseSensitive = true); + bool removePrefix(std::string &str, const std::string &prefix, + bool caseSensitive = true); }} #include "helpers.hpp" diff --git a/call-ui/helpers.hpp b/call-ui/helpers.hpp index d44e8e0..356ff12 100644 --- a/call-ui/helpers.hpp +++ b/call-ui/helpers.hpp @@ -84,4 +84,25 @@ namespace callui { namespace util { } return ucl::RES_OK; } + + // String helpers // + + inline bool beginsWith(const std::string &str, const std::string &prefix, + bool caseSensitive) + { + if (caseSensitive) { + return (str.compare(0, prefix.size(), prefix) == 0); + } + return (strncasecmp(str.c_str(), prefix.c_str(), prefix.size()) == 0); + } + + inline bool removePrefix(std::string &str, const std::string &prefix, + bool caseSensitive) + { + if (beginsWith(str, prefix, caseSensitive)) { + str = str.substr(prefix.size()); + return true; + } + return false; + } }} diff --git a/call-ui/model/impl/CallUI.cpp b/call-ui/model/impl/CallUI.cpp index 17f42fb..db4066d 100644 --- a/call-ui/model/impl/CallUI.cpp +++ b/call-ui/model/impl/CallUI.cpp @@ -27,6 +27,12 @@ #include "common.h" +namespace callui { namespace { namespace impl { + + const std::string URI_PREFIX_TEL {"tel:"}; + const std::string URI_INCOMING_CALL {"MT"}; +}}} + namespace callui { using namespace ucl; @@ -47,67 +53,34 @@ namespace callui { FAIL_RETURN(RES_INVALID_ARGUMENTS, "appControl is NULL"); } - Result ret = RES_FAIL; - - char *operation = nullptr; - int res = app_control_get_operation(appControl, &operation); - if (res != APP_CONTROL_ERROR_NONE) { - LOG_RETURN(RES_FAIL, "app_control_get_operation() failed!"); - } - if (!operation) { - LOG_RETURN(RES_FAIL, "operation is NULL!"); + std::string operation; + FAIL_RETURN(util::getNz(app_control_get_operation, + operation, appControl), + "app_control_get_uri() failed!"); + if (operation != APP_CONTROL_OPERATION_CALL) { + LOG_RETURN(RES_FAIL, "Wrong operation [%s]!", operation.c_str()); } - char *uri = nullptr; - res = app_control_get_uri(appControl, &uri); - if (res != APP_CONTROL_ERROR_NONE) { - free(operation); - LOG_RETURN(RES_FAIL, "app_control_get_uri() failed!"); - } - if (!uri) { - free(operation); - LOG_RETURN(RES_FAIL, "uri is NULL!"); + std::string uri; + FAIL_RETURN(util::getNz(app_control_get_uri, + uri, appControl), + "app_control_get_uri() failed!"); + if (!util::beginsWith(uri, impl::URI_PREFIX_TEL, false)) { + LOG_RETURN(RES_FAIL, "Wrong uri [%s]!", operation.c_str()); } - if (strcmp(operation, APP_CONTROL_OPERATION_CALL) || strncmp(uri, "tel:", 4)) { - free(operation); - free(uri); - LOG_RETURN(RES_FAIL, "Not processed operation!"); + util::removePrefix(uri, impl::URI_PREFIX_TEL, false); + if (uri.empty()) { + LOG_RETURN(RES_FAIL, "Uri data is empty!"); } - char *tmp = nullptr; - if (!strncmp(uri, "tel:MT", 6)) { - res = app_control_get_extra_data(appControl, "sim_slot", &tmp); - if (res != APP_CONTROL_ERROR_NONE) { - ELOG("app_control_get_extra_data() failed!"); - } - if (!tmp) { - free(operation); - free(uri); - LOG_RETURN(RES_FAIL, "Sim slot is NULL!"); - } - DLOG("Sim slot [%s]", tmp); - free(tmp); - - ret = m_callManager->processIncomingCall(); - - } else { - tmp = static_cast(uri + 4); - DLOG("number [%s]", tmp); - - if (!tmp) { - free(operation); - free(uri); - LOG_RETURN(RES_FAIL, "number is NULL"); - } - - ret = m_callManager->processOutgoingCall(tmp); + if (uri == impl::URI_INCOMING_CALL) { + DLOG("Start process Incoming call request"); + return m_callManager->processIncomingCall(); } - free(operation); - free(uri); - - return ret; + DLOG("Start process Outgoing call [%s] request", uri.c_str()); + return m_callManager->processOutgoingCall(uri); } Result CallUI::prepare() diff --git a/call-ui/model/impl/ConnectionStateSource.cpp b/call-ui/model/impl/ConnectionStateSource.cpp index 9044431..41d148d 100644 --- a/call-ui/model/impl/ConnectionStateSource.cpp +++ b/call-ui/model/impl/ConnectionStateSource.cpp @@ -252,60 +252,83 @@ namespace callui { Result ConnectionStateSource::addSysStateCallbacks() { // CONNECTION - int res = vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + int res = vconf_notify_key_changed( + VCONFKEY_WIFI_STRENGTH, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_WIFI_STATE, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_TELEPHONY_FLIGHT_MODE, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_DNET_STATE, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_DNET_STATE, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_PSTYPE, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_TELEPHONY_PSTYPE, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_TELEPHONY_SVCTYPE, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_TELEPHONY_SIM_SLOT, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA, - CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA, + CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), + this); + if (res != 0) { + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + } // PACKET - res = vconf_notify_key_changed(VCONFKEY_PACKET_STATE, - CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_PACKET_STATE, + CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } - res = vconf_notify_key_changed(VCONFKEY_WIFI_TRANSFER_STATE, - CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this); + res = vconf_notify_key_changed( + VCONFKEY_WIFI_TRANSFER_STATE, + CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), + this); if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); } diff --git a/call-ui/model/impl/ContactInfoProvider.cpp b/call-ui/model/impl/ContactInfoProvider.cpp index 3703209..1db1623 100644 --- a/call-ui/model/impl/ContactInfoProvider.cpp +++ b/call-ui/model/impl/ContactInfoProvider.cpp @@ -26,7 +26,8 @@ namespace callui { namespace { namespace impl { using namespace ucl; - inline ContactNameSourceType convertContactNameSourceType(contacts_display_name_source_type_e cdbType) + inline ContactNameSourceType convertContactNameSourceType( + contacts_display_name_source_type_e cdbType) { switch (cdbType) { case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID: return ContactNameSourceType::INVALID; @@ -84,7 +85,7 @@ namespace callui { std::string contactName; std::string contactImagePath; - ContactNameSourceType contactNameSource; + ContactNameSourceType contactNameSrc = ContactNameSourceType::INVALID; contacts_filter_h filter = nullptr; contacts_list_h list = nullptr; @@ -153,7 +154,7 @@ namespace callui { int type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID; contacts_record_get_int(record, _contacts_contact.display_source_type, &type); - contactNameSource = impl::convertContactNameSourceType( + contactNameSrc = impl::convertContactNameSourceType( static_cast(type)); int count = 0; @@ -186,7 +187,7 @@ namespace callui { return ContactInfo::newInstance(contactId, contactName, contactImagePath, - contactNameSource); + contactNameSrc); } } diff --git a/call-ui/presenters/misc/MoreOptionsPresenter.cpp b/call-ui/presenters/misc/MoreOptionsPresenter.cpp index ed6be61..f9f6d49 100644 --- a/call-ui/presenters/misc/MoreOptionsPresenter.cpp +++ b/call-ui/presenters/misc/MoreOptionsPresenter.cpp @@ -117,11 +117,12 @@ namespace callui { const ICallManagerSRef &cm, const ISoundManagerSRef &sm, const NaviframeSRef &navi): - GuiPresenter(rc), - m_cm(cm), - m_sm(sm), - m_navi(navi), - m_timer(nullptr) + GuiPresenter(rc), + m_cm(cm), + m_sm(sm), + m_navi(navi), + m_timer(nullptr), + m_duration() { } @@ -541,7 +542,7 @@ namespace callui { m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE( MoreOptionsPresenter::onAtspiHighlight, asWeak(*this))); - if (m_panelLy) { + if (m_fakeAo) { m_atspiHelper->registerWidget(*m_fakeAo); } diff --git a/call-ui/presenters/misc/RejectMsgPresenter.cpp b/call-ui/presenters/misc/RejectMsgPresenter.cpp index dfad3d4..53caa7f 100644 --- a/call-ui/presenters/misc/RejectMsgPresenter.cpp +++ b/call-ui/presenters/misc/RejectMsgPresenter.cpp @@ -417,22 +417,19 @@ namespace callui { delete rm; }); - auto *rmItem = new RejectMsgItem(rm); - if (!rmItem) { - LOG_RETURN(RES_FAIL, "Create RejectMsgItem failed!"); - } - + auto rmItem = ucl::util::makeUnique(new RejectMsgItem(rm)); auto *item = elm_genlist_item_append(*m_genlist, &textItc, - static_cast(rmItem), + rmItem.get(), nullptr, ELM_GENLIST_ITEM_NONE, CALLBACK_A(RejectMsgPresenter::onGenlistItemClickedCb), this); if (!item) { - delete rmItem; LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!"); } + rmItem.release(); + return RES_OK; } diff --git a/call-ui/presenters/pages/KeypadPage.cpp b/call-ui/presenters/pages/KeypadPage.cpp index 9022845..4033be3 100644 --- a/call-ui/presenters/pages/KeypadPage.cpp +++ b/call-ui/presenters/pages/KeypadPage.cpp @@ -34,10 +34,6 @@ namespace callui { namespace { namespace impl { constexpr EoDataKey BTN_DATA_KEY {"btnData"}; - enum { - KEYPAD_BTN_MAX_COUNT = 13 - }; - enum class OperationType { DTMF, VOLUME @@ -50,7 +46,7 @@ namespace callui { namespace { namespace impl { EdjePart swlPart; }; - static ButtonInfo buttonsInfo[KEYPAD_BTN_MAX_COUNT] = + static ButtonInfo buttonsInfo[] = { { OperationType::DTMF, "1", ElmStyle {"callui/keypad_one"}, EdjePart {"swl.one"} }, @@ -79,6 +75,9 @@ namespace callui { namespace { namespace impl { { OperationType::VOLUME, "", ElmStyle {"callui/keypad_speaker"}, EdjePart {"swl.speaker"} } }; + + const int KEYPAD_BTN_MAX_COUNT = sizeof(buttonsInfo)/sizeof(buttonsInfo[0]); + }}} namespace callui { @@ -629,11 +628,11 @@ namespace callui { auto vcIncrVolumeBtn = m_vc->getIncreaseBtn(); auto vcVolumeValueAo = m_vc->getValueTxtAo(); - if (ao == *firstBtn) { + if (firstBtn && ao == *firstBtn) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { return nullptr; } - } else if (ao == *lastBtn) { + } else if (lastBtn && ao == *lastBtn) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { return nullptr; } diff --git a/call-ui/presenters/pages/MainPage.cpp b/call-ui/presenters/pages/MainPage.cpp index 9ae5b49..aedabba 100644 --- a/call-ui/presenters/pages/MainPage.cpp +++ b/call-ui/presenters/pages/MainPage.cpp @@ -941,27 +941,15 @@ namespace callui { DLOG("vcLayout is NULL"); } else { m_atspiHelper->registerWidget(*vcLayout); - } - auto vcDecrVolumeBtn = m_accessoryPrs->getVolumeControlDecreaseBtn(); - if (!vcDecrVolumeBtn) { - DLOG("vcDecrVolumeBtn is NULL"); - } else { - m_atspiHelper->registerWidget(*vcDecrVolumeBtn); - } + m_atspiHelper->registerWidget(*m_accessoryPrs-> + getVolumeControlDecreaseBtn()); - auto vcIncrVolumeBtn = m_accessoryPrs->getVolumeControlIncreaseBtn(); - if (!vcIncrVolumeBtn) { - DLOG("vcIncrVolumeBtn is NULL"); - } else { - m_atspiHelper->registerWidget(*vcIncrVolumeBtn); - } + m_atspiHelper->registerWidget(*m_accessoryPrs-> + getVolumeControlIncreaseBtn()); - auto vcVolumeValueAo = m_accessoryPrs->getVolumeControlValueTxtAo(); - if (!vcVolumeValueAo) { - DLOG("vcVolumeValueAo is NULL"); - } else { - m_atspiHelper->registerWidget(*vcVolumeValueAo); + m_atspiHelper->registerWidget(*m_accessoryPrs-> + getVolumeControlValueTxtAo()); } DLOG("EXIT");