TizenRefApp-8725 [Call UI] Add possibility to launch Bluetooth Headset settings appli... 50/135150/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 21 Jun 2017 05:42:38 +0000 (08:42 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 21 Jun 2017 05:42:38 +0000 (08:42 +0300)
Change-Id: I2dce006283baa9e3ca586a91305753e654a9b80c

src/common.h
src/helpers.h [new file with mode: 0644]
src/helpers.hpp [new file with mode: 0644]
src/model/BluetoothVolume.cpp
src/presenters/MoreOptionsPresenter.cpp

index 8d0548624b83a0d0bee9821ab1adfebd62326ee4..1d8b345ca382501f35e10b6a56c1bd4b1af908e0 100644 (file)
@@ -28,6 +28,8 @@
 #include "ucl/gui/stdTheme.h"
 #include "ucl/gui/helpers.h"
 
+#include "helpers.h"
+
 #undef UCL_LOG_TAG
 #define UCL_LOG_TAG "CALLUI"
 
diff --git a/src/helpers.h b/src/helpers.h
new file mode 100644 (file)
index 0000000..4bb49d6
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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__
diff --git a/src/helpers.hpp b/src/helpers.hpp
new file mode 100644 (file)
index 0000000..d44e8e0
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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;
+       }
+}}
index 33d22605e648f869bc4afa16035a140e416cc0c7..6fcd6dd23759556f7295a4d1f44d3d89afbaa77a 100644 (file)
@@ -57,8 +57,11 @@ namespace callui {
 
        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;
 
@@ -73,7 +76,8 @@ namespace callui {
                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;
@@ -88,7 +92,8 @@ namespace callui {
        {
                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;
        }
@@ -103,16 +108,16 @@ namespace callui {
        {
                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;
@@ -133,13 +138,15 @@ namespace callui {
                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) {
index e1d4e651497834838d717de41723b655b22a5297..75e7b39bdd5e9ab222307819589ecef07f0534ec 100644 (file)
@@ -19,6 +19,7 @@
 #include <app_control.h>
 
 #include "ucl/gui/Layout.h"
+#include "ucl/appfw/types.h"
 
 #include "model/ICallManager.h"
 #include "model/IHeldCall.h"
@@ -535,7 +536,24 @@ namespace callui {
 
        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)