#include "ucl/gui/stdTheme.h"
#include "ucl/gui/helpers.h"
+#include "helpers.h"
+
#undef UCL_LOG_TAG
#define UCL_LOG_TAG "CALLUI"
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALLUI_HELPERS_H__
+#define __CALLUI_HELPERS_H__
+
+#include "types.h"
+
+namespace callui { namespace util {
+
+ template <class GETTER, class V, class ...ARGS>
+ ucl::Result get(GETTER &&getter, V &result, ARGS &&...args);
+
+ template <class GETTER, class V, class ...ARGS>
+ ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args);
+
+ template <class FUNC, class ...ARGS>
+ ucl::Result call(FUNC &&func, ARGS &&...args);
+}}
+
+#include "helpers.hpp"
+
+#endif // __CALLUI_HELPERS_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/util/helpers.h"
+#include "ucl/util/logging.h"
+
+namespace callui { namespace util { namespace himpl {
+
+ template <class GETTER, class ...ARGS>
+ inline ucl::Result get(GETTER &&getter, bool optional,
+ std::string &result, ARGS &&...args)
+ {
+ char *value = nullptr;
+ const int ret = getter(std::forward<ARGS>(args)..., &value);
+ if ((ret != 0) || (!optional && ucl::isEmpty(value))) {
+ UCL_ELOG("get() failed: %d", ret);
+ return ucl::RES_FAIL;
+ }
+
+ if (value) {
+ result = value;
+ free(value);
+ } else {
+ result.clear();
+ }
+
+ return ucl::RES_OK;
+ }
+
+ template <class GETTER, class V, class ...ARGS>
+ inline ucl::Result get(GETTER &&getter, bool optional,
+ V &result, ARGS &&...args)
+ {
+ typename std::remove_pointer<decltype(&result)>::type value = {};
+
+ const int ret = getter(std::forward<ARGS>(args)..., &value);
+ if ((ret != 0) || (!optional && !value)) {
+ UCL_ELOG("get() failed: %d", ret);
+ return ucl::RES_FAIL;
+ }
+
+ result = value;
+
+ return ucl::RES_OK;
+ }
+}}}
+
+namespace callui { namespace util {
+
+ template <class GETTER, class V, class ...ARGS>
+ inline ucl::Result get(GETTER &&getter, V &result, ARGS &&...args)
+ {
+ return himpl::get(std::forward<GETTER>(getter), true,
+ result, std::forward<ARGS>(args)...);
+ }
+
+ template <class GETTER, class V, class ...ARGS>
+ inline ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args)
+ {
+ return himpl::get(std::forward<GETTER>(getter), false,
+ result, std::forward<ARGS>(args)...);
+ }
+
+ template <class FUNC, class ...ARGS>
+ inline ucl::Result call(FUNC &&func, ARGS &&...args)
+ {
+ const int ret = func(std::forward<ARGS>(args)...);
+ if (ret != 0) {
+ UCL_ELOG("func() failed: %d", ret);
+ return ucl::RES_FAIL;
+ }
+ return ucl::RES_OK;
+ }
+}}
Result BluetoothVolume::prepare()
{
- if (BT_ERROR_NONE != bt_initialize()) {
- LOG_RETURN(RES_FAIL, "BT initialize failed");
+ auto ret = bt_initialize();
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "BT initialize failed. "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+
}
m_btInitialized = true;
auto vol = 0;
auto ret = bt_ag_get_speaker_gain(&vol);
if (ret != BT_ERROR_NONE) {
- LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed!");
+ LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed. "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
}
DLOG("BT Volume level [%d]", vol);
return vol;
{
auto ret = bt_ag_notify_speaker_gain(volume);
if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed!");
+ LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
}
return RES_OK;
}
{
auto ret = bt_audio_initialize();
if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed. [%d][%s]",
- ret, get_error_message(ret));
+ LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed. ",
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
}
m_btAudioInitialized = true;
ret = bt_ag_set_speaker_gain_changed_cb(
CALLBACK_B(BluetoothVolume::onVolumeChanged), this);
if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed. [%d][%s]",
- ret, get_error_message(ret));
+ LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed. "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
}
return RES_OK;
sound_type_e soundType = SOUND_TYPE_SYSTEM;
auto ret = sound_manager_get_current_sound_type(&soundType);
if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed");
+ LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed. "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
}
bool isSCOOpened = false;
ret = bt_ag_is_sco_opened(&isSCOOpened);
if (ret != BT_ERROR_NONE) {
- LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed");
+ LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed. "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
}
if (isSCOOpened && soundType == SOUND_TYPE_CALL) {
#include <app_control.h>
#include "ucl/gui/Layout.h"
+#include "ucl/appfw/types.h"
#include "model/ICallManager.h"
#include "model/IHeldCall.h"
Result MoreOptionsPresenter::launchBluetoothSettings()
{
- LOG_RETURN(RES_FAIL, "Not implemented");
+ AutoAppCtrl appCtrl;
+
+ FAIL_RETURN(util::getNz(app_control_create, appCtrl),
+ "app_control_create() failed!");
+
+ FAIL_RETURN(util::call(app_control_set_app_id,
+ appCtrl, "org.tizen.bluetooth"),
+ "app_control_set_app_id() failed!");
+
+ FAIL_RETURN(util::call(app_control_add_extra_data,
+ appCtrl, "launch-type", "call"),
+ "app_control_add_extra_data() failed!");
+
+ FAIL_RETURN(util::call(app_control_send_launch_request,
+ appCtrl, nullptr, nullptr),
+ "app_control_send_launch_request() failed!");
+
+ return RES_OK;
}
void MoreOptionsPresenter::unsetPanelContent(const EdjePart &part)