TizenRefApp-9430 [Call UI] Fix Svace issue 41/152441/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 25 Sep 2017 14:09:13 +0000 (17:09 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Tue, 26 Sep 2017 06:44:08 +0000 (09:44 +0300)
Change-Id: I72ec5c7e31a7ecaa49e038c80934f90370ec37c4

call-ui/helpers.h
call-ui/helpers.hpp
call-ui/model/impl/CallUI.cpp
call-ui/model/impl/ConnectionStateSource.cpp
call-ui/model/impl/ContactInfoProvider.cpp
call-ui/presenters/misc/MoreOptionsPresenter.cpp
call-ui/presenters/misc/RejectMsgPresenter.cpp
call-ui/presenters/pages/KeypadPage.cpp
call-ui/presenters/pages/MainPage.cpp

index 85c104f284c35015ccf634a86a43e8d1178f4bd4..5689ff4dd5a80563480be1701badcba2ec1be8d0 100644 (file)
@@ -29,6 +29,13 @@ namespace callui { namespace util {
 
        template <class FUNC, class ...ARGS>
        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"
index d44e8e0752986827dea4d61d0de8a5fc7ed4244f..356ff1217380610afbca892493540f4689644429 100644 (file)
@@ -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;
+       }
 }}
index 17f42fb639f353036048eb15825e77f70a8f3b34..db4066dbf42e469e1d1566d38f4b7d055bfb81dd 100644 (file)
 
 #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<char *>(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()
index 90444310e5b20a5aa06fe5e9e9840660f5b98544..41d148d3ca7eb6407055861e5f21a8eb0c2fbc04 100644 (file)
@@ -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");
                }
index 370320973f41363e4a507fe2c1149f0db16d8f1a..1db1623678d38071fb00ad0a541348ef25e56f92 100644 (file)
@@ -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<contacts_display_name_source_type_e>(type));
 
                                int count = 0;
@@ -186,7 +187,7 @@ namespace callui {
                return ContactInfo::newInstance(contactId,
                                contactName,
                                contactImagePath,
-                               contactNameSource);
+                               contactNameSrc);
        }
 
 }
index ed6be61424601426227b665ae6791d450586bdeb..f9f6d497887a32389743b86b36463a1723f2c89c 100644 (file)
@@ -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);
                }
 
index dfad3d4647a207e94438f8f43905c92723b08b75..53caa7fc8db2ede9920e504f87d76d721a2e8a86 100644 (file)
@@ -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<void *>(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;
        }
 
index 902284557cab0b93a1364a4950f3ac8e24aa21fe..4033be38e2e57c7a92ab985b1174cb760ad49a03 100644 (file)
@@ -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;
                        }
index 9ae5b495dc2136042761d0f0f44c2345b369f95e..aedabba5fb1114846225be8672bfee827eceadc4 100644 (file)
@@ -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");