*
*/
-#include <app.h>
#include <stdio.h>
#include <vconf.h>
#include <stdlib.h>
{
GVariant *reply = NULL;
GVariant *params = NULL;
- GError *error;
- GDBusConnection *connection = NULL;
- connection = netdbus_get_connection();
- if (connection == NULL) {
- ERR("GDBusconnection is NULL");
- return -1;
- }
+ params = g_variant_new("(o)", NETCONFIG_WIFI_PATH);
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "RegisterAgent", params);
- do {
- error = NULL;
- params = g_variant_new("(o)", NETCONFIG_WIFI_PATH);
-
- reply = g_dbus_connection_call_sync(
- connection,
- CONNMAN_SERVICE,
- CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE,
- "RegisterAgent",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- netdbus_get_cancellable(),
- &error);
-
- if (reply == NULL) {
- if (error != NULL) {
- if (g_strcmp0(error->message,
- "GDBus.Error:net.connman.Error.AlreadyExists: Already exists") == 0) {
- break;
- } else {
- ERR("Fail to register agent [%d: %s]",
- error->code, error->message);
- }
-
- g_error_free(error);
- } else
- ERR("Fail to register agent");
- } else
- g_variant_unref(reply);
-
- sleep(1);
- } while (TRUE);
+ if (reply == NULL) {
+ ERR("Fail to register agent");
+ return FALSE;
+ } else
+ g_variant_unref(reply);
INFO("Registered to connman agent successfully");
- return 0;
+ return TRUE;
}
int connman_unregister_agent(void)
name_len = strlen(name);
agent.ssid = g_byte_array_sized_new(name_len);
agent.ssid->len = name_len;
- memcpy(agent.ssid->data, name, name_len);
+ memcpy(agent.ssid->data, name, name_len + 1);
if (identity)
agent.identity = g_strdup(identity);
g_variant_get(fields, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0) {
- g_free(agent.passphrase);
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
agent.passphrase = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
DBG("Field [%s] - []", field);
- } else {
- agent.passphrase = NULL;
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PBC) == 0) {
- agent.wps_pbc = FALSE;
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING) &&
g_strcmp0(g_variant_get_string(value, NULL), "enable") == 0) {
agent.wps_pbc = TRUE;
DBG("Field [%s] - [%d]", field, agent.wps_pbc);
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PIN) == 0) {
- g_free(agent.wps_pin);
- agent.wps_pbc = FALSE;
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
agent.wps_pin = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
DBG("Field [%s] - []", field);
- } else {
- agent.wps_pin = NULL;
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0) {
- g_free(agent.name);
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
agent.name = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
DBG("Field [%s] - []", field);
- } else {
- agent.name = NULL;
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0) {
if (agent.ssid != NULL) {
GByteArray *array = g_byte_array_new();
g_variant_get(value, "ay", &iter1);
- while(g_variant_iter_loop(iter1, "y", &char_value)) {
+ while (g_variant_iter_loop(iter1, "y", &char_value))
g_byte_array_append(array, &char_value, 1);
- }
g_variant_iter_free(iter1);
if (array != NULL && (array->len > 0)) {
agent.ssid = g_byte_array_sized_new(array->len);
}
}
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0) {
- g_free(agent.identity);
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
agent.identity = g_strdup(g_variant_get_string(value, NULL));
updated = TRUE;
DBG("Field [%s] - []", field);
- } else {
- agent.identity = NULL;
}
}
}
service, CONNMAN_SERVICE_INTERFACE, "Connect",
NULL, __netconfig_wifi_connect_reply);
if (reply == TRUE) {
- g_dbus_method_invocation_return_value (context, NULL);
+ g_dbus_method_invocation_return_value(context, NULL);
} else {
error = g_error_new(G_DBUS_ERROR,
G_DBUS_ERROR_AUTH_FAILED,
DBG("Agent fields requested for service: %s", service);
- builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_get(fields, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &field, &r_value)) {
} else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS) == 0 &&
(agent.wps_pbc == TRUE || agent.wps_pin != NULL)) {
if (agent.wps_pbc == TRUE) {
- // Sending empty string for WPS push button method
+ /* Sending empty string for WPS push button method */
g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(""));
updated = TRUE;
agent.ssid != NULL) {
int i = 0;
GVariantBuilder *builder1 = NULL;
- builder1 = g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+ builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
- for (i = 0; i < (agent.ssid->len); i++) {
- g_variant_builder_add (builder1, "y", agent.ssid->data[i]);
- }
+ for (i = 0; i < (agent.ssid->len); i++)
+ g_variant_builder_add(builder1, "y", agent.ssid->data[i]);
g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID, g_variant_builder_end(builder1));
if (builder1 != NULL)
g_variant_iter_free(iter);
- if (NULL == out_table){
+ if (NULL == out_table) {
net_connman_agent_complete_request_input(connman_agent, context, out_table);
return FALSE;
}
if (updated == TRUE)
- g_dbus_method_invocation_return_value (context, out_table);
+ g_dbus_method_invocation_return_value(context, out_table);
else {
GError *error = NULL;
error = g_error_new(G_DBUS_ERROR,
net_connman_agent_complete_report_error(connman_agent, context);
DBG("Agent error for service[%s] - [%s]", service, error);
- // Do something when it failed to make a connection
+ /* Do something when it failed to make a connection */
return ret;
}
#if defined TIZEN_WEARABLE
static gboolean is_portal_msg_shown = FALSE;
-static guint portal_msg_timer = 0;
#endif
struct poll_timer_data {
void* data;
};
-static struct poll_timer_data timer_data =
- {QUERY_FOR_INTERNET_INTERVAL, 0, NULL};
+static struct poll_timer_data timer_data = {
+ QUERY_FOR_INTERNET_INTERVAL, 0, NULL};
static gboolean __check_ignore_portal_list(const char * ssid)
{
DBG("csc string [%s]", def_str);
gchar ** ignore_ap_list = g_strsplit(def_str, ",", 0);
ignore_ap_count = g_strv_length(ignore_ap_list);
- for(i = 0; i < ignore_ap_count; i++) {
+ for (i = 0; i < ignore_ap_count; i++) {
DBG("[%d] - [%s]", i, ignore_ap_list[i]);
if (strncmp(ignore_ap_list[i], ssid, strlen(ssid)) == 0) {
g_strfreev(ignore_ap_list);
return FALSE;
}
-#if defined TIZEN_WEARABLE
-static gboolean __netconfig_display_portal_msg(gpointer data)
-{
- DBG("");
- wc_launch_popup(WC_POPUP_TYPE_CAPTIVE_PORTAL);
-
- netconfig_stop_timer(&portal_msg_timer);
-
- return FALSE;
-}
-#endif
-
static void __netconfig_wifi_portal_login_timer_start(struct poll_timer_data
*data)
{
ignore_portal = __check_ignore_portal_list(ssid);
- if (ignore_portal == TRUE){
+ if (ignore_portal == TRUE) {
net_connman_agent_complete_request_browser(connman_agent, context);
return TRUE;
}
is_monitor_notifier_registered = TRUE;
}
-#if defined TIZEN_WEARABLE
- if (is_portal_msg_shown){
- net_connman_agent_complete_request_browser(connman_agent, context);
- return TRUE;
- }
-
- is_portal_msg_shown = TRUE;
- netconfig_start_timer_seconds(4, __netconfig_display_portal_msg, NULL, &portal_msg_timer);
-#else
ret = netconfig_send_notification_to_net_popup(NETCONFIG_ADD_PORTAL_NOTI, ssid);
-#endif
timer_data.time_elapsed = 0;
__netconfig_wifi_portal_login_timer_start(&timer_data);