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"
}
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;
+ }
}}
#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;
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()
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");
}
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;
std::string contactName;
std::string contactImagePath;
- ContactNameSourceType contactNameSource;
+ ContactNameSourceType contactNameSrc = ContactNameSourceType::INVALID;
contacts_filter_h filter = nullptr;
contacts_list_h list = nullptr;
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;
return ContactInfo::newInstance(contactId,
contactName,
contactImagePath,
- contactNameSource);
+ contactNameSrc);
}
}
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()
{
}
m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
MoreOptionsPresenter::onAtspiHighlight, asWeak(*this)));
- if (m_panelLy) {
+ if (m_fakeAo) {
m_atspiHelper->registerWidget(*m_fakeAo);
}
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;
}
constexpr EoDataKey BTN_DATA_KEY {"btnData"};
- enum {
- KEYPAD_BTN_MAX_COUNT = 13
- };
-
enum class OperationType {
DTMF,
VOLUME
EdjePart swlPart;
};
- static ButtonInfo buttonsInfo[KEYPAD_BTN_MAX_COUNT] =
+ static ButtonInfo buttonsInfo[] =
{
{ OperationType::DTMF, "1",
ElmStyle {"callui/keypad_one"}, EdjePart {"swl.one"} },
{ OperationType::VOLUME, "",
ElmStyle {"callui/keypad_speaker"}, EdjePart {"swl.speaker"} }
};
+
+ const int KEYPAD_BTN_MAX_COUNT = sizeof(buttonsInfo)/sizeof(buttonsInfo[0]);
+
}}}
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;
}
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");