bool moments_get_visible(void);
bool moments_get_is_on_initialization(void);
bool moments_check_is_3g_device(void);
+bool moments_check_is_bt_device(void);
+bool moments_check_is_connected_remotely(void);
+bool moments_check_is_with_phone_via_bluetooth(void);
+bool moments_check_is_call_fwd_enable(void);
+bool moments_check_is_music_enable(void);
void moments_init(Evas_Object *win, Evas_Object *bg_scroller);
void moments_fini(void);
static void __set_state_stand_alone(void);
static void __set_state_3g_with_phone_connection(void);
static void __set_state_bt_with_phone_connection(void);
-static bool __is_stand_alone(void);
-static bool __is_with_phone(void);
-static bool __is_with_bt_device(void);
+static void __bluetooth_state_changed_cb(keynode_t *node, void *user_data);
const char *controls_btn_group_name[MOMENTS_CONTROLS_BTN_TYPE_MAX] = {
s_info.control_layout = control_layout;
+ vconf_notify_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __bluetooth_state_changed_cb, NULL);
return control_layout;
}
void moments_control_view_destroy(void)
{
+ vconf_ignore_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __bluetooth_state_changed_cb);
if (s_info.control_layout) {
/*FIXME : unset*/
evas_object_del(s_info.control_layout);
}
+static void __bluetooth_state_changed_cb(keynode_t *node, void *user_data)
+{
+
+ moments_control_init();
+ moments_view_update();
+}
static void __update_control_state(void)
{
- if (__is_with_bt_device()) __set_state_bt_with_phone_connection();
- else if (__is_with_phone()) __set_state_3g_with_phone_connection();
- else if (__is_stand_alone()) __set_state_stand_alone();
+ if (moments_check_is_bt_device()) __set_state_bt_with_phone_connection();
+ else if (moments_check_is_with_phone_via_bluetooth()) __set_state_3g_with_phone_connection();
+ else __set_state_stand_alone();
}
static int move_count = 0;
if (move_count < 10) {
control_info_t *btn_info = (control_info_t *)data;
- if (btn_info != NULL) btn_info->pressed(NULL, NULL, NULL, NULL);
+ if (btn_info != NULL && btn_info->pressed != NULL) btn_info->pressed(NULL, NULL, NULL, NULL);
}
move_count = 0;
control_info_t *flight_mode_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_FLIGHT_MODE);
moments_control_push_to_button_list(flight_mode_button);
- control_info_t *call_forwarding_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_CALL_FORWARDING);
- moments_control_push_to_button_list(call_forwarding_button);
+ if (moments_check_is_call_fwd_enable()) {
+ control_info_t *call_forwarding_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_CALL_FORWARDING);
+ moments_control_push_to_button_list(call_forwarding_button);
+ }
- control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
- moments_control_push_to_button_list(music_button);
+ if (moments_check_is_music_enable()) {
+ control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
+ moments_control_push_to_button_list(music_button);
+ }
}
static void __set_state_bt_with_phone_connection(void)
control_info_t *flight_mode_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_FLIGHT_MODE);
moments_control_push_to_button_list(flight_mode_button);
- control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
- moments_control_push_to_button_list(music_button);
-}
-
-static bool __is_stand_alone(void)
-{
- return !__is_with_phone();
-}
-
-static bool __is_with_phone(void)
-{
- return false;
-}
-
-static bool __is_with_bt_device(void)
-{
- return !moments_check_is_3g_device();
+ if (moments_check_is_music_enable()) {
+ control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
+ moments_control_push_to_button_list(music_button);
+ }
}
-
#include "test.h"
#if TEST_MODE
Eina_List *__t__get_moments_control_button_list(void)
#include <net_connection.h>
#include <runtime_info.h>
#include <vconf.h>
+#include <package_manager.h>
#include "log.h"
#include "moments/moments.h"
#include "scroller.h"
#include "key.h"
#include "common_conf.h"
+#include "app_log.h"
static struct __manager_s {
Evas_Object *win;
};
static telephony_handle_list_s handle_list;
+#define MUSIC_PKG_NAME "org.tizen.w-music-player"
static key_cb_ret_e __back_key_cb(void *data);
static void __initialize_status_view(void);
return is_3g;
}
+bool moments_check_is_bt_device(void)
+{
+ return !moments_check_is_3g_device();
+}
+
+bool moments_check_is_connected_remotely(void)
+{
+ return false; /* FIXME - Not supported */
+}
+
+bool moments_check_is_with_phone_via_bluetooth(void)
+{
+ int is_bt_enable = 0;
+
+ if (vconf_get_int(VCONFKEY_BT_STATUS, &is_bt_enable) != 0) {
+ _E("Failed to get vconfkey : %s", VCONFKEY_BT_STATUS);
+ return false;
+ }
+
+ if (is_bt_enable) {
+ int sap_connected = 0;
+ if (vconf_get_int(VCONFKEY_WMS_WMANAGER_CONNECTED, &sap_connected) < 0) {
+ _E("Failed to get vconfkey : %s", VCONFKEY_WMS_WMANAGER_CONNECTED);
+ return false;
+ }
+
+ if (sap_connected) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool moments_check_is_call_fwd_enable(void)
+{
+ return true;
+ int status = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, &status) < 0) {
+ _E("Failed to get vconfkey : %s", VCONFKEY_TELEPHONY_CALL_FORWARD_STATE);
+ return false;
+ }
+ return status;
+}
+
+bool moments_check_is_music_enable(void)
+{
+ return true;
+ package_info_h package_info = NULL;
+
+ if (package_info_create(MUSIC_PKG_NAME, &package_info) != PACKAGE_MANAGER_ERROR_NONE) {
+ _E("Failed to get music-player info");
+ return false;
+ }
+
+ package_info_destroy(package_info);
+
+ return true;
+}
+
bool moments_get_is_on_initialization(void)
{
return s_info.on_initialization;
static Evas_Object *__create_base_size_setter(Evas_Object *base_layout);
static Evas_Object *__create_center_layout(Evas_Object *base_layout);
static void __adjust_content_alpha(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void __set_center_contents(void);
+static void __set_center_contents(moments_connection_status_e status);
static void __put_down(void);
static void __freeze_touch_event(void);
}
-void moments_view_update()
-{
- __set_center_contents();
-}
-
void moments_view_put_down(void)
{
_D("%s", __func__);
__put_down();
}
+
+void moments_view_update(void)
+{
+ if (moments_check_is_with_phone_via_bluetooth()) __set_center_contents(MOMENTS_CONNECTION_STATUS_CONNECTED_BLUETOOTH);
+ else if (moments_check_is_connected_remotely()) __set_center_contents(MOMENTS_CONNECTION_STATUS_CONNECTED_REMOTELY);
+ else __set_center_contents(MOMENTS_CONNECTION_STATUS_STANDALONE);
+
+}
+
Evas_Object *moments_view_get_base_window(void)
{
return s_info.win;
}
-static void __set_center_contents()
+void __set_center_contents(moments_connection_status_e status)
{
- elm_layout_file_set(s_info.center_layout, util_get_res_file_path(CENTER_LAYOUT_EDJE), center_layout_group_name[connection_status]);
+ connection_status = status;
+ elm_layout_file_set(s_info.center_layout, util_get_res_file_path(CENTER_LAYOUT_EDJE), center_layout_group_name[status]);
//elm_object_part_text_set(center_layout, CENTER_STATUS_TEXT, "Connected<br/>via Bluetooth");
//elm_object_part_text_set(center_layout, CENTER_PLMN_TEXT, "PLMN/SPN");
void __t__set_connection_status(int status)
{
- connection_status = status;
+ __set_center_contents(status);
+}
+
+int __t__get_connection_status(void)
+{
+ return connection_status;
}
void __t__pull_down_complete_cb(void)
static struct {
unit_group_t * group;
+ moments_connection_status_e current_connection_status;
} s_info = {
.group = NULL,
+ .current_connection_status = MOMENTS_CONNECTION_STATUS_STANDALONE,
};
extern const char *center_layout_group_name[MOMENTS_CONNECTION_STATUS_MAX];
TEST_GROUP_SET_UP_DONE(0.6, s_info.group);
}
+ s_info.current_connection_status = __t__get_connection_status();
__t__pull_down_complete_cb();
TEST_GROUP_SET_UP_DONE(0.05, s_info.group);
}
static void __group_tear_down(void)
{
- __t__set_connection_status(MOMENTS_CONNECTION_STATUS_STANDALONE);
-
- moments_view_update();
+ __t__set_connection_status(s_info.current_connection_status);
if (moments_get_visible()) {
moments_hide();
int connection_status = (int)data;
__t__set_connection_status((int)connection_status);
- moments_view_update();
TEST_CASE_CONTINUE(0.6, __continue_check_center_layout, data);
}
for (i = 0; i < total; i++) {
button = eina_list_nth(button_list, i);
+ if ((!moments_check_is_call_fwd_enable() && button->index == MOMENTS_CONTROLS_CALL_FORWARDING) ||
+ (!moments_check_is_music_enable() && button->index == MOMENTS_CONTROLS_MUSIC_PLAYER)) {
+ continue;
+ }
+
TEST_ASSERT_TRUE(button != NULL);
TEST_ASSERT_TRUE(evas_object_visible_get(button->button_layout));
extern int __t__get_control_layout_alpha(int layout_bottom);
extern int __t__get_center_layout_alpha(int layout_bottom);
extern void __t__set_connection_status(int status);
+extern int __t__get_connection_status(void);
extern Eina_List *__t__get_moments_control_button_list(void);
extern void __t__update_control_state(void);
extern void __t__update_control_view(void);