*/
typedef void (*tethering_data_usage_cb)(tethering_error_e result, unsigned long long received_data, unsigned long long sent_data, void *user_data);
+/**
+ * @brief Called when the security type of Wi-Fi tethering is changed
+ * @param[in] changed_type The changed security type of Wi-Fi tethering
+ * @param[in] user_data The user data passed from the register function
+ * @see tethering_wifi_set_security_type_changed_cb()
+ * @see tethering_wifi_unset_security_type_changed_cb()
+ */
+typedef void (*tethering_wifi_security_type_changed_cb)(tethering_wifi_security_type_e changed_type, void *user_data);
+
+/**
+ * @brief Called when the visibility of SSID is changed
+ * @param[in] changed_visible The changed visibility of SSID
+ * @param[in] user_data The user data passed from the register function
+ * @see tethering_wifi_set_ssid_visibility_changed_cb()
+ * @see tethering_wifi_unset_ssid_visibility_changed_cb()
+ */
+typedef void (*tethering_wifi_ssid_visibility_changed_cb)(bool changed_visible, void *user_data);
+
+/**
+ * @brief Called when the passphrase of Wi-Fi tethering is changed
+ * @param[in] user_data The user data passed from the register function
+ * @see tethering_wifi_set_passphrase_changed_cb()
+ * @see tethering_wifi_unset_passphrase_changed_cb()
+ */
+typedef void (*tethering_wifi_passphrase_changed_cb)(void *user_data);
+
/**
* @brief Creates the handle of tethering.
* @remarks The @a tethering must be released tethering_destroy() by you.
*/
int tethering_unset_connection_state_changed_cb(tethering_h tethering, tethering_type_e type);
+/**
+ * @brief Registers the callback function called when the security type of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_unset_security_type_changed_cb()
+ */
+int tethering_wifi_set_security_type_changed_cb(tethering_h tethering, tethering_wifi_security_type_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function called when the security type of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] type The type of tethering
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_set_security_type_changed_cb()
+ */
+int tethering_wifi_unset_security_type_changed_cb(tethering_h tethering);
+
+/**
+ * @brief Registers the callback function called when the visibility of SSID is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_unset_ssid_visibility_changed_cb_cb()
+ */
+int tethering_wifi_set_ssid_visibility_changed_cb(tethering_h tethering, tethering_wifi_ssid_visibility_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function called when the visibility of SSID is changed.
+ * @param[in] tethering The handle of tethering
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_set_ssid_visibility_changed_cb()
+ */
+int tethering_wifi_unset_ssid_visibility_changed_cb(tethering_h tethering);
+
+/**
+ * @brief Registers the callback function called when the passphrase of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_unset_passphrase_changed_cb()
+ */
+int tethering_wifi_set_passphrase_changed_cb(tethering_h tethering, tethering_wifi_passphrase_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function called when the passphrase of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_set_passphrase_changed_cb()
+ */
+int tethering_wifi_unset_passphrase_changed_cb(tethering_h tethering);
+
/**
* @}
*/
static void __handle_no_data_timeout(DBusGProxy *proxy, const char *value_name, gpointer user_data);
static void __handle_low_battery_mode(DBusGProxy *proxy, const char *value_name, gpointer user_data);
static void __handle_flight_mode(DBusGProxy *proxy, const char *value_name, gpointer user_data);
+static void __handle_security_type_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data);
+static void __handle_ssid_visibility_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data);
+static void __handle_passphrase_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data);
static __tethering_sig_t sigs[] = {
{SIGNAL_NAME_NET_CLOSED, __handle_net_closed},
{SIGNAL_NAME_NO_DATA_TIMEOUT, __handle_no_data_timeout},
{SIGNAL_NAME_LOW_BATTERY_MODE, __handle_low_battery_mode},
{SIGNAL_NAME_FLIGHT_MODE, __handle_flight_mode},
+ {SIGNAL_NAME_SECURITY_TYPE_CHANGED, __handle_security_type_changed},
+ {SIGNAL_NAME_SSID_VISIBILITY_CHANGED, __handle_ssid_visibility_changed},
+ {SIGNAL_NAME_PASSPHRASE_CHANGED, __handle_passphrase_changed},
{"", NULL}};
static bool __any_tethering_is_enabled(tethering_h tethering)
}
}
+static void __handle_security_type_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data)
+{
+ DBG("+\n");
+
+ _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)user_data;
+ tethering_wifi_security_type_changed_cb scb = NULL;
+ void *data = NULL;
+ tethering_wifi_security_type_e security_type;
+
+ scb = th->security_type_changed_cb;
+ if (scb == NULL)
+ return;
+
+ data = th->security_type_user_data;
+ if (g_strcmp0(value_name, TETHERING_WIFI_SECURITY_TYPE_OPEN_STR) == 0)
+ security_type = TETHERING_WIFI_SECURITY_TYPE_NONE;
+ else if (g_strcmp0(value_name, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR) == 0)
+ security_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
+ else {
+ ERR("Unknown security type : %s\n", value_name);
+ return;
+ }
+
+ scb(security_type, data);
+
+ return;
+}
+
+static void __handle_ssid_visibility_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data)
+{
+ DBG("+\n");
+
+ _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)user_data;
+ tethering_wifi_ssid_visibility_changed_cb scb = NULL;
+ void *data = NULL;
+ bool visible = false;
+
+ scb = th->ssid_visibility_changed_cb;
+ if (scb == NULL)
+ return;
+
+ data = th->ssid_visibility_user_data;
+ if (g_strcmp0(value_name, SIGNAL_MSG_SSID_VISIBLE) == 0)
+ visible = true;
+
+ scb(visible, data);
+
+ return;
+}
+
+static void __handle_passphrase_changed(DBusGProxy *proxy, const char *value_name, gpointer user_data)
+{
+ DBG("+\n");
+
+ _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)user_data;
+ tethering_wifi_passphrase_changed_cb pcb = NULL;
+ void *data = NULL;
+
+ pcb = th->passphrase_changed_cb;
+ if (pcb == NULL)
+ return;
+
+ data = th->passphrase_user_data;
+
+ pcb(data);
+
+ return;
+}
+
static void __cfm_cb(DBusGProxy *remoteobj, guint event, guint info,
GError *g_error, gpointer user_data)
{
{
_retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+ tethering_h tethering = (tethering_h)user_data;
+ __tethering_h *th = (__tethering_h *)tethering;
+ DBusGProxy *proxy = th->client_bus_proxy;
+
if (error) {
ERR("DBus fail [%s]\n", error->message);
g_error_free(error);
}
+ dbus_g_proxy_connect_signal(proxy, SIGNAL_NAME_SECURITY_TYPE_CHANGED,
+ G_CALLBACK(__handle_security_type_changed),
+ (gpointer)tethering, NULL);
+
return;
}
{
_retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+ tethering_h tethering = (tethering_h)user_data;
+ __tethering_h *th = (__tethering_h *)tethering;
+ DBusGProxy *proxy = th->client_bus_proxy;
+
if (error) {
ERR("DBus fail [%s]\n", error->message);
g_error_free(error);
}
+ dbus_g_proxy_connect_signal(proxy, SIGNAL_NAME_SSID_VISIBILITY_CHANGED,
+ G_CALLBACK(__handle_ssid_visibility_changed),
+ (gpointer)tethering, NULL);
+
return;
}
{
_retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+ tethering_h tethering = (tethering_h)user_data;
+ __tethering_h *th = (__tethering_h *)tethering;
+ DBusGProxy *proxy = th->client_bus_proxy;
+
if (error) {
ERR("DBus fail [%s]\n", error->message);
g_error_free(error);
}
+ dbus_g_proxy_connect_signal(proxy, SIGNAL_NAME_PASSPHRASE_CHANGED,
+ G_CALLBACK(__handle_passphrase_changed),
+ (gpointer)tethering, NULL);
+
return;
}
return TETHERING_ERROR_NONE;
}
+/**
+ * @brief Registers the callback function called when the security type of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_unset_security_type_changed_cb()
+ */
+API int tethering_wifi_set_security_type_changed_cb(tethering_h tethering, tethering_wifi_security_type_changed_cb callback, void *user_data)
+{
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+ _retvm_if(callback == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(callback) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+
+ th->security_type_changed_cb = callback;
+ th->security_type_user_data = user_data;
+
+ return TETHERING_ERROR_NONE;
+
+}
+
+/**
+ * @brief Unregisters the callback function called when the security type of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] type The type of tethering
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_set_security_type_changed_cb()
+ */
+API int tethering_wifi_unset_security_type_changed_cb(tethering_h tethering)
+{
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+
+ th->security_type_changed_cb = NULL;
+ th->security_type_user_data = NULL;
+
+ return TETHERING_ERROR_NONE;
+}
+
+/**
+ * @brief Registers the callback function called when the visibility of SSID is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_unset_ssid_visibility_changed_cb_cb()
+ */
+API int tethering_wifi_set_ssid_visibility_changed_cb(tethering_h tethering, tethering_wifi_ssid_visibility_changed_cb callback, void *user_data)
+{
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+ _retvm_if(callback == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(callback) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+
+ th->ssid_visibility_changed_cb = callback;
+ th->ssid_visibility_user_data = user_data;
+
+ return TETHERING_ERROR_NONE;
+}
+
+/**
+ * @brief Unregisters the callback function called when the visibility of SSID is changed.
+ * @param[in] tethering The handle of tethering
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_set_ssid_visibility_changed_cb()
+ */
+API int tethering_wifi_unset_ssid_visibility_changed_cb(tethering_h tethering)
+{
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+
+ th->ssid_visibility_changed_cb = NULL;
+ th->ssid_visibility_user_data = NULL;
+
+ return TETHERING_ERROR_NONE;
+}
+
+/**
+ * @brief Registers the callback function called when the passphrase of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_unset_passphrase_changed_cb()
+ */
+API int tethering_wifi_set_passphrase_changed_cb(tethering_h tethering, tethering_wifi_passphrase_changed_cb callback, void *user_data)
+{
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+ _retvm_if(callback == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(callback) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+
+ th->passphrase_changed_cb = callback;
+ th->passphrase_user_data = user_data;
+
+ return TETHERING_ERROR_NONE;
+}
+
+/**
+ * @brief Unregisters the callback function called when the passphrase of Wi-Fi tethering is changed.
+ * @param[in] tethering The handle of tethering
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see tethering_wifi_set_passphrase_changed_cb()
+ */
+API int tethering_wifi_unset_passphrase_changed_cb(tethering_h tethering)
+{
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+
+ th->passphrase_changed_cb = NULL;
+ th->passphrase_user_data = NULL;
+
+ return TETHERING_ERROR_NONE;
+}
+
/**
* @brief Sets the security type of Wi-Fi tethering.
* @remarks You must set this value when Wi-Fi tethering is disabled.
return TETHERING_ERROR_INVALID_PARAMETER;
}
+ dbus_g_proxy_disconnect_signal(proxy, SIGNAL_NAME_SECURITY_TYPE_CHANGED,
+ G_CALLBACK(__handle_security_type_changed),
+ (gpointer)tethering);
+
com_samsung_mobileap_set_wifi_tethering_security_type_async(proxy, type_str,
__wifi_set_security_type_cb, (gpointer)tethering);
else
hide_mode = VCONFKEY_MOBILE_AP_HIDE_ON;
+ dbus_g_proxy_disconnect_signal(proxy, SIGNAL_NAME_SSID_VISIBILITY_CHANGED,
+ G_CALLBACK(__handle_ssid_visibility_changed),
+ (gpointer)tethering);
+
com_samsung_mobileap_set_wifi_tethering_hide_mode_async(proxy, hide_mode,
__wifi_set_ssid_visibility_cb, (gpointer)tethering);
__tethering_h *th = (__tethering_h *)tethering;
DBusGProxy *proxy = th->client_bus_proxy;
+ dbus_g_proxy_disconnect_signal(proxy, SIGNAL_NAME_PASSPHRASE_CHANGED,
+ G_CALLBACK(__handle_passphrase_changed),
+ (gpointer)tethering);
com_samsung_mobileap_set_wifi_tethering_passphrase_async(proxy,
passphrase, strlen(passphrase),
tethering_enabled_cb enabled_cb;
tethering_disabled_cb disabled_cb;
tethering_connection_state_changed_cb changed_cb;
+ tethering_wifi_security_type_changed_cb security_type_changed_cb;
+ tethering_wifi_ssid_visibility_changed_cb ssid_visibility_changed_cb;
+ tethering_wifi_passphrase_changed_cb passphrase_changed_cb;
} __tethering_cbs;
static GMainLoop *mainloop = NULL;
g_print("tethering_set_connection_state_changed_cb is failed\n");
}
+ ret = tethering_wifi_set_security_type_changed_cb(th,
+ cbs->security_type_changed_cb, user_data);
+ if (__is_err(ret) == true) {
+ g_print("tethering_wifi_set_security_type_changed_cb is failed\n");
+ }
+
+ ret = tethering_wifi_set_ssid_visibility_changed_cb(th,
+ cbs->ssid_visibility_changed_cb, user_data);
+ if (__is_err(ret) == true) {
+ g_print("tethering_wifi_set_ssid_visibility_changed_cb is failed\n");
+ }
+
+ ret = tethering_wifi_set_passphrase_changed_cb(th,
+ cbs->passphrase_changed_cb, user_data);
+ if (__is_err(ret) == true) {
+ g_print("tethering_wifi_set_passphrase_changed_cb is failed\n");
+ }
+
return;
}
g_print("tethering_unset_connection_state_changed_cb is failed\n");
}
+ ret = tethering_wifi_unset_security_type_changed_cb(th);
+ if (__is_err(ret) == true) {
+ g_print("tethering_wifi_unset_security_type_changed_cb is failed\n");
+ }
+
+ ret = tethering_wifi_unset_ssid_visibility_changed_cb(th);
+ if (__is_err(ret) == true) {
+ g_print("tethering_wifi_unset_ssid_visibility_changed_cb is failed\n");
+ }
+
+ ret = tethering_wifi_unset_passphrase_changed_cb(th);
+ if (__is_err(ret) == true) {
+ g_print("tethering_wifi_unset_passphrase_changed_cb is failed\n");
+ }
+
return;
}
/* Continue iteration */
return true;
}
+
+static void __security_type_changed_cb(tethering_wifi_security_type_e changed_type, void *user_data)
+{
+ g_print("Wi-Fi Tethering Security type is changed to [%s]\n",
+ changed_type == TETHERING_WIFI_SECURITY_TYPE_NONE ?
+ "open" : "wpa2-psk");
+ return;
+}
+
+static void __ssid_visibility_changed_cb(bool changed_visible, void *user_data)
+{
+ g_print("SSID visibility for Wi-Fi tethering changed to [%s]\n",
+ changed_visible ? "visible" : "invisible");
+ return;
+}
+
+static void __passphrase_changed_cb(void *user_data)
+{
+ g_print("Wi-Fi Tethering passphrase is changed\n");
+ return;
+}
/* End of tethering callbacks */
static void __enable_tethering(tethering_h th, tethering_type_e type)
tethering_h th = NULL;
GIOChannel *stdin_channel = NULL;
tethering_error_e ret = TETHERING_ERROR_NONE;
- __tethering_cbs cbs = {__enabled_cb, __disabled_cb, __connection_state_changed_cb};
+ __tethering_cbs cbs = {
+ __enabled_cb, __disabled_cb,
+ __connection_state_changed_cb, __security_type_changed_cb,
+ __ssid_visibility_changed_cb, __passphrase_changed_cb};
g_type_init();