*
*/
+#include <net_connection.h>
+#include <dbus/dbus.h>
+#include <gio/gio.h>
+
#include "mh_common_utility.h"
#include "mobile_hotspot.h"
-static mh_popup_type_e popup_type = MH_POPUP_NONE;
-static Evas_Object *popup_content = NULL;
-static char *popup_string = NULL;
-
-static void __one_btn_popup_resp(void *data, Evas_Object *obj, void *event_info)
+void _handle_network_cellular_state_changed_cb(keynode_t *key, void *data)
{
- __MOBILE_AP_FUNC_ENTER__;
-
- if (data == NULL || obj == NULL) {
- ERR("The param is NULL\n");
+ if (key == NULL || data == NULL) {
+ ERR("Parameter is NULL\n");
return;
}
-
mh_appdata_t *ad = (mh_appdata_t *)data;
+ int vconf_key = 0;
- evas_object_del(ad->popup);
- ad->popup = NULL;
-
- DBG("popup_type : %d\n", popup_type);
- switch (popup_type) {
- case MH_POP_USB_CONNECT:
- _update_usb_item(ad, MH_STATE_NONE);
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
- _handle_usb_mode_change);
- break;
-
- case MH_POP_INFORMATION:
- break;
-
- default:
- DBG("Unknown popup_type : %d\n", popup_type);
- break;
- }
-
- __MOBILE_AP_FUNC_EXIT__;
-}
-
-static void __alert_popup_resp(void *data, Evas_Object *obj, void *event_info)
-{
- __MOBILE_AP_FUNC_ENTER__;
-
- if (data == NULL || obj == NULL) {
- ERR("The param is NULL\n");
+ if (vconf_keynode_get_type(key) != VCONF_TYPE_INT) {
+ ERR("Invalid vconf key type\n");
return;
}
- mh_appdata_t *ad = (mh_appdata_t *)data;
-
- evas_object_del(ad->popup);
- ad->popup = NULL;
-
- DBG("popup_type : %d\n", popup_type);
- switch (popup_type) {
- case MH_POP_INFORMATION_WO_BUTTON:
- break;
-
- default:
- DBG("Unknown popup_type : %d\n", popup_type);
- break;
- }
-
- __MOBILE_AP_FUNC_EXIT__;
-}
-
-static void __popup_resp_yes(void *data, Evas_Object *obj, void *event_info)
-{
- __MOBILE_AP_FUNC_ENTER__;
+ vconf_key = vconf_keynode_get_int(key);
+ SDBG("key = %s, value = %d(int)\n",
+ vconf_keynode_get_name(key), vconf_key);
- if (data == NULL || obj == NULL) {
- ERR("The param is NULL\n");
+ if (vconf_key != VCONFKEY_NETWORK_CELLULAR_FLIGHT_MODE)
return;
- }
-
- mh_appdata_t *ad = (mh_appdata_t *)data;
- bool wifi_state;
- int ret = 0;
-
- evas_object_del(ad->popup);
- ad->popup = NULL;
-
- DBG("popup_type : %d\n", popup_type);
- switch (popup_type) {
- case MH_POP_WIFI_ON_CONF:
- wifi_is_activated(&wifi_state);
- if (wifi_state == true) {
- if (_turn_off_wifi(ad) != 0) {
- ERR("_turn_off_wifi is failed\n");
- _update_wifi_item(ad, MH_STATE_NONE);
- }
- } else if (_is_wifi_direct_on() == true) {
- if (_turn_off_wifi_direct(ad) != 0) {
- ERR("_turn_off_wifi_direct is failed\n");
- _update_wifi_item(ad, MH_STATE_NONE);
- }
- } else {
- ret = tethering_enable(ad->handle, TETHERING_TYPE_WIFI);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("wifi tethering on is failed : %d\n", ret);
- _update_wifi_item(ad, MH_STATE_NONE);
- }
- }
- break;
- case MH_POP_WIFI_OFF_CONF:
- ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("wifi tethering off is failed : %d\n", ret);
- _update_wifi_item(ad, MH_STATE_NONE);
- }
- break;
-
- case MH_POP_BT_ON_CONF:
- ret = tethering_enable(ad->handle, TETHERING_TYPE_BT);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("Error enable bt tethering : %d\n", ret);
- _update_bt_item(ad, MH_STATE_NONE);
- }
- break;
-
- case MH_POP_USB_ON_CONF:
- if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) {
- _prepare_popup(MH_POP_USB_CONNECT,
- _("IDS_MOBILEAP_POP_CONNECT_USB_CABLE"));
- _create_popup(ad);
- vconf_notify_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
- _handle_usb_mode_change, (void *)ad);
- break;
- }
-
- _prepare_popup(MH_POP_USB_ON_PREVCONN_CONF,
- _("IDS_MOBILEAP_POP_ENABLING_USB_TETHERING_WILL_DISCONNECT_PREVIOUS_USB_CONNECTION"));
- _create_popup(ad);
- break;
-
- case MH_POP_USB_ON_PREVCONN_CONF:
- ret = tethering_enable(ad->handle, TETHERING_TYPE_USB);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("Error enable usb tethering : %d\n", ret);
- _update_usb_item(ad, MH_STATE_NONE);
- }
- break;
-
- case MH_POP_ENTER_TO_WIFI_SETUP_CONF:
- _update_wifi_item(ad, MH_STATE_PROCESS);
- ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("Wi-Fi tethering off is failed : %d\n", ret);
- _update_wifi_item(ad, MH_STATE_NONE);
- } else
- ad->main.need_recover_wifi_tethering = true;
-
- mh_draw_wifi_setup_view(ad);
- break;
-
- default:
- DBG("Unknown popup_type : %d\n", popup_type);
- break;
- }
-
- __MOBILE_AP_FUNC_EXIT__;
-}
-
-static void __popup_resp_no(void *data, Evas_Object *obj, void *event_info)
-{
- __MOBILE_AP_FUNC_ENTER__;
-
- if (data == NULL || obj == NULL) {
- ERR("The param is NULL\n");
- return;
+ if (ad->popup) {
+ evas_object_del(ad->popup);
+ ad->popup = NULL;
}
-
- mh_appdata_t *ad = (mh_appdata_t *)data;
-
- evas_object_del(ad->popup);
- ad->popup = NULL;
-
- DBG("popup_type : %d\n", popup_type);
- switch (popup_type) {
- case MH_POP_WIFI_ON_CONF:
- _update_wifi_item(ad, MH_STATE_NONE);
- break;
-
- case MH_POP_WIFI_OFF_CONF:
+ if (ad->is_wifi_teth_enabling) {
_update_wifi_item(ad, MH_STATE_NONE);
- break;
-
- case MH_POP_BT_ON_CONF:
+ ad->is_wifi_teth_enabling = false;
+ }
+ if (ad->is_bt_teth_enabling) {
_update_bt_item(ad, MH_STATE_NONE);
- break;
-
- case MH_POP_USB_ON_CONF:
- _update_usb_item(ad, MH_STATE_NONE);
- break;
-
- case MH_POP_USB_ON_PREVCONN_CONF:
+ ad->is_bt_teth_enabling = false;
+ }
+ if (ad->is_usb_teth_enabling) {
_update_usb_item(ad, MH_STATE_NONE);
- break;
-
- case MH_POP_ENTER_TO_WIFI_SETUP_CONF:
- break;
-
- default:
- DBG("Unknown popup_type : %d\n", popup_type);
- break;
+ ad->is_usb_teth_enabling = false;
}
-
- __MOBILE_AP_FUNC_EXIT__;
+ return;
}
-static bool _count_connected_clients_cb(tethering_client_h client, void *user_data)
+void _device_name_changed_cb(keynode_t *key, void *data)
{
- if (user_data == NULL) {
- ERR("user_data is NULL\n");
- return true;
+ if (key == NULL || data == NULL) {
+ ERR("Parameter is NULL\n");
+ return;
}
- int *count = (int *)user_data;
-
- *count += 1;
-
- return true;
-}
-
-void _prepare_popup_with_content(int type, Evas_Object *obj)
-{
- __MOBILE_AP_FUNC_ENTER__;
+ mh_appdata_t *ad = (mh_appdata_t *)data;
+ char *dev_name = NULL;
- if (obj == NULL) {
- ERR("param is NULL\n");
+ if (vconf_keynode_get_type(key) != VCONF_TYPE_STRING) {
+ ERR("Invalid vconf key type\n");
return;
}
-
- popup_type = type;
-
- if (popup_content)
- evas_object_del(popup_content);
- popup_content = obj;
-
- if (popup_string) {
- free(popup_string);
- popup_string = NULL;
+ dev_name = vconf_keynode_get_str(key);
+ if (ad->setup.name_item != NULL) {
+ elm_genlist_item_update(ad->setup.name_item);
}
-
- __MOBILE_AP_FUNC_EXIT__;
-}
-
-void _prepare_popup(int type, const char *str)
-{
- __MOBILE_AP_FUNC_ENTER__;
-
- if (str == NULL) {
- ERR("param is NULL\n");
- return;
+ if (ad->main.help_item != NULL) {
+ elm_genlist_item_update(ad->main.help_item);
}
-
- popup_type = type;
- popup_content = NULL;
-
- if (popup_string)
- free(popup_string);
-
- popup_string = strndup(str, MH_LABEL_LENGTH_MAX);
- if (popup_string == NULL)
- ERR("strndup is failed\n");
-
- __MOBILE_AP_FUNC_EXIT__;
-}
-
-Eina_Bool _create_popup(mh_appdata_t *ad)
-{
- __MOBILE_AP_FUNC_ENTER__;
-
- Evas_Object *btn = NULL;
-
- if (ad == NULL) {
- ERR("The param is NULL\n");
- if (popup_string) {
- free(popup_string);
- popup_string = NULL;
- }
- popup_content = NULL;
-
- return EINA_FALSE;
+ if (ad->rename_popup) {
+ elm_entry_entry_set(ad->rename_entry, dev_name);
+ elm_entry_cursor_end_set(ad->rename_entry);
}
-
- if (ad->popup != NULL) {
- DBG("Pop-up already exists. Delete it.\n");
- evas_object_del(ad->popup);
- ad->popup = NULL;
+ if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
+ _update_wifi_item(ad, MH_STATE_PROCESS);
}
-
- DBG("Create_popup %d\n", popup_type);
- switch (popup_type) {
- case MH_POP_WIFI_ON_CONF:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_OK"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_yes, (void *)ad);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_CANCEL"));
- elm_object_part_content_set(ad->popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_no, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_WIFI_OFF_CONF:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_YES"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_yes, (void *)ad);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_NO"));
- elm_object_part_content_set(ad->popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_no, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_USB_CONNECT:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_CANCEL"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __one_btn_popup_resp, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_BT_ON_CONF:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_OK"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_yes, (void *)ad);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_CANCEL"));
- elm_object_part_content_set(ad->popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_no, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_USB_ON_CONF:
- case MH_POP_USB_ON_PREVCONN_CONF:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_OK"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_yes, (void *)ad);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_CANCEL"));
- elm_object_part_content_set(ad->popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_no, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_INFORMATION:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_POP_CLOSE"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __one_btn_popup_resp, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_INFORMATION_WO_BUTTON:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- elm_popup_timeout_set(ad->popup, MH_POPUP_TIMEOUT);
- evas_object_smart_callback_add(ad->popup, "timeout",
- __alert_popup_resp, (void *)ad);
- evas_object_smart_callback_add(ad->popup, "block,clicked",
- __alert_popup_resp, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
-
- case MH_POP_ENTER_TO_WIFI_SETUP_CONF:
- ad->popup = elm_popup_add(ad->win);
- evas_object_size_hint_weight_set(ad->popup,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- if (popup_content == NULL)
- elm_object_text_set(ad->popup, popup_string);
- else
- elm_object_content_set(ad->popup, popup_content);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_OK"));
- elm_object_part_content_set(ad->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_yes, (void *)ad);
-
- btn = elm_button_add(ad->popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, S_("IDS_COM_SK_CANCEL"));
- elm_object_part_content_set(ad->popup, "button2", btn);
- evas_object_smart_callback_add(btn, "clicked",
- __popup_resp_no, (void *)ad);
-
- evas_object_show(ad->popup);
- break;
- default:
- ERR("Unknown popup_type : %d\n", popup_type);
- break;
- }
-
- if (popup_string) {
- free(popup_string);
- popup_string = NULL;
- }
- popup_content = NULL;
-
- __MOBILE_AP_FUNC_EXIT__;
-
- return EINA_TRUE;
+ return;
}
-void _destroy_popup(mh_appdata_t *ad)
+Evas_Object *_create_progressbar(Evas_Object *parent, const char *style)
{
- __MOBILE_AP_FUNC_ENTER__;
-
- if (ad && ad->popup) {
- evas_object_del(ad->popup);
- ad->popup = NULL;
+ if (parent == NULL || style == NULL) {
+ ERR("Invalid param\n");
+ return NULL;
}
- if (popup_string) {
- free(popup_string);
- popup_string = NULL;
+ Evas_Object *progressbar;
+
+ progressbar = elm_progressbar_add(parent);
+ if (progressbar == NULL) {
+ ERR("progressbar is NULL\n");
+ return NULL;
}
- popup_content = NULL;
- popup_type = MH_POPUP_NONE;
- __MOBILE_AP_FUNC_EXIT__;
+ elm_object_style_set(progressbar, style);
+ elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
+ elm_progressbar_pulse(progressbar, EINA_TRUE);
+ evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(progressbar);
- return;
+ return progressbar;
}
Evas_Object *_create_bg(Evas_Object *parent, const char *style)
return naviframe;
}
-void _handle_usb_mode_change(keynode_t *key, void *data)
+Evas_Object *_create_button(Evas_Object *parent, const char *text, const char *part,
+ Evas_Smart_Cb func, void *user_data)
{
- mh_appdata_t *ad = (mh_appdata_t *)data;
- int vconf_key = 0;
+ if (parent == NULL || text == NULL || part == NULL || func == NULL) {
+ ERR("Invalid param\n");
+ return NULL;
+ }
+
+ Evas_Object *btn;
+
+ btn = elm_button_add(parent);
+ elm_object_style_set(btn, "popup");
+ elm_object_domain_translatable_text_set(btn, PACKAGE, text);
+ elm_object_part_content_set(parent, part, btn);
+ evas_object_smart_callback_add(btn, "clicked", func, user_data);
+ evas_object_show(btn);
+
+ return btn;
+}
+void _handle_mobileap_syspopup_popup_response(keynode_t *key, void *data)
+{
if (!data) {
ERR("The param is NULL\n");
return;
return;
}
+ mh_appdata_t *ad = (mh_appdata_t *)data;
+ int vconf_key = 0;
+
vconf_key = vconf_keynode_get_int(key);
- DBG("vconf_key : %d\n", vconf_key);
- if (vconf_key == SETTING_USB_NONE_MODE) {
- DBG("usb-utilties is processing mode change\n");
+
+ if (vconf_key) {
+ if (vconf_set_int(VCONF_KEY_MOBILEAP_SYSPOPUP_RESPONSE, 0) < 0) {
+ ERR("vconf_set_int is failed\n");
+ }
+ if (ad->type != TETHERING_TYPE_WIFI) {
+ DBG("no need to handle user response\n");
+ return;
+ }
+ if (ad->popup) {
+ evas_object_del(ad->popup);
+ ad->popup = NULL;
+ }
+ if (ad->popup_checkbox) {
+ evas_object_del(ad->popup_checkbox);
+ ad->popup_checkbox = NULL;
+ }
+ if (vconf_key == 1)
+ _update_wifi_item(ad, MH_STATE_NONE);
+ }
+}
+
+void _handle_usb_status_change(keynode_t *key, void *data)
+{
+ int vconf_key = 0;
+
+ if (!data) {
+ ERR("The param is NULL\n");
return;
}
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
- _handle_usb_mode_change);
+ mh_appdata_t *ad = (mh_appdata_t *)data;
- evas_object_del(ad->popup);
- ad->popup = NULL;
+ if (vconf_keynode_get_type(key) != VCONF_TYPE_INT) {
+ ERR("Invalid vconf key\n");
+ return;
+ }
- if (tethering_enable(ad->handle, TETHERING_TYPE_USB) != TETHERING_ERROR_NONE) {
- DBG("Error enable usb tethering\n");
- _update_usb_item(ad, MH_STATE_NONE);
+ vconf_key = vconf_keynode_get_int(key);
+ if (vconf_key == SETTING_USB_NONE_MODE) {
+ return;
+ }
+ if (vconf_key != VCONFKEY_SYSMAN_USB_AVAILABLE) {
+ if (ad->type == TETHERING_TYPE_USB && ad->popup) {
+ evas_object_del(ad->popup);
+ ad->popup = NULL;
+ _update_tethering_item(ad, MH_STATE_NONE);
+ }
+ if (ad->main.usb_item)
+ elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
+ } else {
+ if (ad->main.usb_item)
+ elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
}
}
ERR("vconf_get_int is failed\n");
return 0;
}
-
DBG("%s : %d\n", VCONFKEY_MOBILE_HOTSPOT_MODE, value);
return value;
}
-Eina_Bool _get_no_of_connected_device(tethering_h handle, int *no, tethering_type_e type)
+Eina_Bool _get_no_of_connected_device(mh_appdata_t *ad, int *no, tethering_type_e type)
{
- if (handle == NULL || no == NULL)
- return FALSE;
+ if (ad == NULL) {
+ ERR("Invalid param\n");
+ return EINA_FALSE;
+ }
+
+ if (ad->client_list == NULL) {
+ *no = 0;
+ return EINA_TRUE;
+ }
+
+ GSList *l = NULL;
+ tethering_client_h handle;
+ tethering_type_e type2;
+ tethering_error_e ret;
+ int count = 0;
+
+ for (l = ad->client_list; l != NULL; l = g_slist_next(l) ) {
+ handle = l->data;
+ if (handle == NULL)
+ continue;
+
+ ret = tethering_client_get_tethering_type(handle, &type2);
+ if (ret != TETHERING_ERROR_NONE) {
+ ERR("tethering_client_get_tethering_type is failed [0x%X]\n", ret);
+ continue;
+ }
- tethering_foreach_connected_clients(handle, type,
- _count_connected_clients_cb, (void *)no);
+ if (type != TETHERING_TYPE_ALL && type != type2)
+ continue;
- return TRUE;
+ count++;
+ }
+ *no = count;
+
+ return EINA_TRUE;
}
-Evas_Object *_create_label(Evas_Object *parent, const char *text)
+void _append_list_client_handle(mh_appdata_t *ad, tethering_client_h client)
{
- Evas_Object *label;
+ if (ad == NULL || client == NULL) {
+ ERR("Invalid param\n");
+ return;
+ }
- label = elm_entry_add(parent);
- if (label == NULL) {
- ERR("elm_entry_add is failed\n");
- return NULL;
+ int ret;
+ tethering_client_h handle;
+
+ ret = tethering_client_clone(&handle, client);
+ if (ret != TETHERING_ERROR_NONE) {
+ ERR("Unable to clone client handle");
+ return;
}
- elm_entry_editable_set(label, EINA_FALSE);
- elm_entry_context_menu_disabled_set(label, EINA_TRUE);
- elm_object_text_set(label, text);
+ ad->client_list = g_slist_append(ad->client_list, handle);
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(label);
+ return;
+}
+
+void _release_list_client_handle(mh_appdata_t *ad)
+{
+ if (ad == NULL) {
+ ERR("Invalid param\n");
+ return;
+ }
+
+ if (ad->client_list == NULL)
+ return;
+
+ GSList *l = NULL;
+ tethering_client_h handle;
- return label;
+ for (l = ad->client_list; l != NULL; l = g_slist_next(l) ) {
+ handle = l->data;
+ if (handle == NULL)
+ continue;
+
+ tethering_client_destroy(handle);
+ }
+
+ g_slist_free(ad->client_list);
+ ad->client_list = NULL;
+
+ return;
}
-Evas_Object *_create_slide_title(Evas_Object *parent, const char *text)
+static int __find_mac_address(gconstpointer a, gconstpointer b)
{
- if (parent == NULL || text == NULL)
- return NULL;
+ tethering_client_h handle = (tethering_client_h)a;
+ const char *udn = (const char *)b;
+ char *mac_addr;
+ int ret;
+
+ ret = tethering_client_get_mac_address(handle, &mac_addr);
+ if (ret != TETHERING_ERROR_NONE)
+ return -1;
+
+ ret = g_ascii_strcasecmp(mac_addr, udn);
+
+ if (mac_addr)
+ free(mac_addr);
+
+ return ret;
+}
+
+void _delete_list_client_handle(mh_appdata_t *ad, const char *mac_addr)
+{
+ if (ad == NULL || mac_addr == NULL) {
+ ERR("Invalid param\n");
+ return;
+ }
+
+ GSList *l = NULL;
+ tethering_client_h handle = NULL;
+
+ l = g_slist_find_custom(ad->client_list, mac_addr, __find_mac_address);
+ if (!l) {
+ ERR("Not found\n");
+ return;
+ }
+
+ handle = (tethering_client_h)l->data;
+ ad->client_list = g_slist_delete_link(ad->client_list, l);
+ if (handle == NULL)
+ return;
+
+ tethering_client_destroy(handle);
+ return;
+}
+
+int _get_list_clients_count(mh_appdata_t *ad)
+{
+ int client_list_counts;
+
+ if (ad == NULL) {
+ ERR("Invalid param\n");
+ return 0;
+ }
+
+ client_list_counts = g_slist_length(ad->client_list);
+ if (client_list_counts > TETHERING_WIFI_MAX_CONNECTED_STA) {
+ INFO("client_list_counts = [%d]\n", client_list_counts);
+ return TETHERING_WIFI_MAX_CONNECTED_STA;
+ } else
+ return client_list_counts;
+}
+
+void _get_list_clients_informations(mh_appdata_t *ad)
+{
+ if (ad == NULL) {
+ ERR("Invalid param\n");
+ return;
+ }
+
+ GSList *l = NULL;
+ tethering_client_h handle;
+ int i = 1;
+ int ret;
+ tethering_type_e type = 0;
+ char *name = NULL;
+ char *mac_addr = NULL;
+
+ for (l = ad->client_list; l != NULL; l = g_slist_next(l), i++) {
+ handle = (tethering_client_h)l->data;
+
+ ret = tethering_client_get_name(handle, &name);
+ if (ret != TETHERING_ERROR_NONE)
+ ERR("tethering_client_get_name is failed : %d\n", ret);
+
+ ret = tethering_client_get_mac_address(handle, &mac_addr);
+ if (ret != TETHERING_ERROR_NONE)
+ ERR("tethering_client_get_mac_address is failed : %d\n", ret);
+
+ ret = tethering_client_get_tethering_type(handle, &type);
+ if (ret != TETHERING_ERROR_NONE)
+ ERR("tethering_client_get_tethering_type is failed : %d\n", ret);
+ if (name) {
+ SDBG("Client[%d] : %s\n", i, name);
+ free(name);
+ name = NULL;
+ }
+
+ if (mac_addr) {
+ SDBG("MAC[%d] : %s\n", i, mac_addr);
+ free(mac_addr);
+ mac_addr = NULL;
+ }
+
+ SDBG("Type[%d] : %d\n", i, type);
+ }
+
+ return;
+}
+
+void _free_genlist_item(Elm_Object_Item **item)
+{
+ if (*item == NULL) {
+ return;
+ }
+
+ elm_object_item_del(*item);
+ *item = NULL;
+}
+
+void _free_genlist_itc(Elm_Genlist_Item_Class **itc)
+{
+ if (*itc == NULL) {
+ return;
+ }
+
+ elm_genlist_item_class_free(*itc);
+ *itc = NULL;
+}
+
+int _get_sim_state(void)
+{
+ int value = 0;
+
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &value) < 0) {
+ ERR("vconf_get_int is failed\n");
+ }
+ DBG("%s : %d\n", VCONFKEY_TELEPHONY_SIM_SLOT, value);
+ if (value == VCONFKEY_TELEPHONY_SIM_INSERTED) {
+ return value;
+ }
- Evas_Object *label;
+#if defined TIZEN_DUALSIM_ENABLE
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT2, &value) < 0) {
+ ERR("vconf_get_int is failed\n");;
+ }
+ DBG("%s : %d\n", VCONFKEY_TELEPHONY_SIM_SLOT2, value);
+#endif
- label = elm_label_add(parent);
- elm_object_style_set(label, "naviframe_title");
- elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
- elm_label_wrap_width_set(label, 1);
- elm_label_ellipsis_set(label, EINA_TRUE);
- elm_object_text_set(label, text);
- evas_object_show(label);
+ return value;
+}
- elm_access_object_unregister(label);
- return label;
-}
\ No newline at end of file
+connection_cellular_state_e _get_cellular_state(void)
+{
+ int ret;
+ connection_h handle = NULL;
+ connection_cellular_state_e cellular_state;
+
+ ret = connection_create(&handle);
+ if (ret != CONNECTION_ERROR_NONE) {
+ ERR("Connection create failed");
+ return CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE;
+ }
+ ret = connection_get_cellular_state(handle, &cellular_state);
+ if (ret != CONNECTION_ERROR_NONE) {
+ ERR("connection_get_cellular_state() is failed : %d\n");
+ connection_destroy(handle);
+ return CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE;
+ }
+
+ connection_destroy(handle);
+ return cellular_state;
+}
+
+int _get_checkbox_status(tethering_type_e type)
+{
+ int value = 0;
+ char *vconf_key = NULL;
+
+ if (type == TETHERING_TYPE_WIFI)
+ vconf_key = VCONF_MOBILE_AP_WIFI_POPUP_CHECKBOX_STATUS;
+ else if (type == TETHERING_TYPE_BT)
+ vconf_key = VCONF_MOBILE_AP_BT_POPUP_CHECKBOX_STATUS;
+ else if (type == TETHERING_TYPE_USB)
+ vconf_key = VCONF_MOBILE_AP_USB_POPUP_CHECKBOX_STATUS;
+ else
+ return 0;
+ if (vconf_get_int(vconf_key, &value) < 0) {
+ ERR("vconf_get_int() is failed\n");
+ return 0;
+ }
+ DBG("%s : %d\n", vconf_key, value);
+ return value;
+}
+
+bool _set_checkbox_status(tethering_type_e type, int value)
+{
+ char *vconf_key = NULL;
+
+ if (type == TETHERING_TYPE_WIFI)
+ vconf_key = VCONF_MOBILE_AP_WIFI_POPUP_CHECKBOX_STATUS;
+ else if (type == TETHERING_TYPE_BT)
+ vconf_key = VCONF_MOBILE_AP_BT_POPUP_CHECKBOX_STATUS;
+ else if (type == TETHERING_TYPE_USB)
+ vconf_key = VCONF_MOBILE_AP_USB_POPUP_CHECKBOX_STATUS;
+ else
+ return false;
+
+ if (vconf_set_int(vconf_key, value) < 0) {
+ ERR("vconf_set_int is failed\n");
+ return false;
+ }
+ return true;
+}
+
+bool _set_vconf_prev_wifi_state(bool value)
+{
+ if (vconf_set_bool(VCONF_MOBILE_AP_PREV_WIFI_STATUS, value) < 0) {
+ ERR("vconf_set_bool failed\n");
+ return false;
+ }
+ return true;
+}
+
+bool _get_vconf_prev_wifi_state()
+{
+ int value = 0;
+
+ if (vconf_get_bool(VCONF_MOBILE_AP_PREV_WIFI_STATUS, &value) < 0) {
+ ERR("vconf_get_bool is failed\n");
+ return false;
+ }
+ DBG("%s : %d\n", VCONF_MOBILE_AP_PREV_WIFI_STATUS, value);
+
+ return value ? true : false;
+}
+
+int _send_signal_qp(const char *cmd)
+{
+ DBG("+\n");
+
+ if (cmd == NULL) {
+ ERR("Invalid param");
+ return -1;
+ }
+
+ GDBusConnection *conn = NULL;
+ int ret = 0;
+ GVariant *message = NULL;
+ GError *err = NULL;
+
+ DBG("Sent dbus signal : %s\n", cmd);
+
+ conn = g_bus_get_sync(DBUS_BUS_SYSTEM, NULL, &err);
+ if (err != NULL) {
+ ERR("Failed connection to system bus[%s]", err->message);
+ g_error_free(err);
+ err = NULL;
+ return -1;
+ }
+ message = g_variant_new("(ss)", "wifi_hotspot", cmd);
+ g_dbus_connection_emit_signal(conn, NULL, "/Org/Tizen/Quickpanel",
+ "org.tizen.quickpanel", "ACTIVITY", message, &err);
+ if (err) {
+ ERR("g_dbus_connection_emit_signal is failed and error is %s\n", err->message);
+ g_error_free(err);
+ ret = -1;
+ }
+ g_variant_unref(message);
+
+ if (conn)
+ g_object_unref(conn);
+
+ DBG("-\n");
+ return ret;
+}