static void __netconfig_agent_clear_fields(void)
{
- g_byte_array_free(agent.ssid, TRUE);
+ if (agent.ssid)
+ g_byte_array_free(agent.ssid, TRUE);
g_free(agent.name);
g_free(agent.identity);
g_free(agent.passphrase);
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
service, CONNMAN_SERVICE_INTERFACE, "Connect",
NULL, __netconfig_wifi_connect_reply);
- if (reply == TRUE) {
- g_dbus_method_invocation_return_value(context, NULL);
- } else {
+ if (reply != TRUE) {
+ ERR("Fail to connect Wi-Fi");
+ __netconfig_agent_clear_fields();
error = g_error_new(G_DBUS_ERROR,
G_DBUS_ERROR_AUTH_FAILED,
CONNMAN_ERROR_INTERFACE ".InvalidArguments");
g_dbus_method_invocation_return_gerror(context, error);
g_clear_error(&error);
+ return reply;
}
} else {
error = g_error_new(G_DBUS_ERROR,
g_dbus_method_invocation_return_gerror(context, error);
g_clear_error(&error);
+ return reply;
}
- if (reply != TRUE) {
- ERR("Fail to connect Wi-Fi");
-
- __netconfig_agent_clear_fields();
- }
g_variant_iter_free(iter);
net_connman_agent_complete_set_field(connman_agent, context);
}
__netconfig_agent_clear_fields();
- g_variant_unref(out_table);
return updated;
}
}
if (power_save)
- input_args = g_variant_new_string(args_enable);
+ input_args = g_variant_new("(s)", args_enable);
else
- input_args = g_variant_new_string(args_disable);
+ input_args = g_variant_new("(s)", args_disable);
result = netconfig_supplicant_invoke_dbus_method_nonblock(
SUPPLICANT_SERVICE,
else
old_state = power_save;
- g_variant_unref(input_args);
return;
}
return;
}
- ret = g_variant_get_int32(reply);
- if (ret < 0)
- ERR("Failed to set power lock %s with ret %d",
+ if (g_variant_is_of_type(reply, G_VARIANT_TYPE_INT32)) {
+ ret = g_variant_get_int32(reply);
+ if (ret < 0)
+ ERR("Failed to set power lock %s with ret %d",
power_lock == TRUE ? "enable" : "disable", ret);
- else
- old_state = power_lock;
+ else
+ old_state = power_lock;
+ }
g_variant_unref(reply);
DBG("%s", sdata);
}
}
- g_variant_iter_free(next);
}
g_variant_unref(message);