mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 23:30:13 +01:00
libnm, core: use typechecked proxy_call methods
This commit is contained in:
parent
9668bfd682
commit
9926ba376a
7 changed files with 55 additions and 61 deletions
|
|
@ -512,7 +512,8 @@ create_async_got_property (GObject *proxy, GAsyncResult *result, gpointer user_d
|
|||
GError *error = NULL;
|
||||
GType type;
|
||||
|
||||
ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result, &error);
|
||||
ret = _nm_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result,
|
||||
G_VARIANT_TYPE ("(v)"), &error);
|
||||
if (ret) {
|
||||
g_variant_get (ret, "(v)", &value);
|
||||
type = type_data->type_func (value);
|
||||
|
|
@ -520,8 +521,8 @@ create_async_got_property (GObject *proxy, GAsyncResult *result, gpointer user_d
|
|||
g_variant_unref (ret);
|
||||
} else {
|
||||
dbgmsg ("Could not fetch property '%s' of interface '%s' on %s: %s\n",
|
||||
type_data->property, type_data->interface, async_data->path,
|
||||
error->message);
|
||||
type_data->property, type_data->interface, async_data->path,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
type = G_TYPE_INVALID;
|
||||
}
|
||||
|
|
@ -1148,11 +1149,12 @@ _nm_object_reload_properties (NMObject *object, GError **error)
|
|||
|
||||
g_hash_table_iter_init (&iter, priv->proxies);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *) &interface, (gpointer *) &proxy)) {
|
||||
ret = g_dbus_proxy_call_sync (priv->properties_proxy,
|
||||
"GetAll",
|
||||
g_variant_new ("(s)", interface),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL, error);
|
||||
ret = _nm_dbus_proxy_call_sync (priv->properties_proxy,
|
||||
"GetAll",
|
||||
g_variant_new ("(s)", interface),
|
||||
G_VARIANT_TYPE ("(a{sv})"),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL, error);
|
||||
if (!ret) {
|
||||
if (error && *error)
|
||||
g_dbus_error_strip_remote_error (*error);
|
||||
|
|
@ -1195,11 +1197,12 @@ _nm_object_reload_property (NMObject *object,
|
|||
if (!NM_OBJECT_GET_PRIVATE (object)->nm_running)
|
||||
return;
|
||||
|
||||
ret = g_dbus_proxy_call_sync (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
|
||||
"Get",
|
||||
g_variant_new ("(ss)", interface, prop_name),
|
||||
G_DBUS_CALL_FLAGS_NONE, 15000,
|
||||
NULL, &err);
|
||||
ret = _nm_dbus_proxy_call_sync (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
|
||||
"Get",
|
||||
g_variant_new ("(ss)", interface, prop_name),
|
||||
G_VARIANT_TYPE ("(v)"),
|
||||
G_DBUS_CALL_FLAGS_NONE, 15000,
|
||||
NULL, &err);
|
||||
if (!ret) {
|
||||
dbgmsg ("%s: Error getting '%s' for %s: (%d) %s\n",
|
||||
__func__,
|
||||
|
|
@ -1297,7 +1300,9 @@ reload_got_properties (GObject *proxy,
|
|||
GVariant *ret, *props;
|
||||
GError *error = NULL;
|
||||
|
||||
ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result, &error);
|
||||
ret = _nm_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result,
|
||||
G_VARIANT_TYPE ("(a{sv})"),
|
||||
&error);
|
||||
if (ret) {
|
||||
g_variant_get (ret, "(@a{sv})", &props);
|
||||
process_properties_changed (object, props, FALSE);
|
||||
|
|
|
|||
|
|
@ -881,27 +881,21 @@ get_properties_cb_4 (GObject *source_object, GAsyncResult *res, gpointer user_da
|
|||
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
GError *err = NULL;
|
||||
GVariant *v_properties, *v_dict;
|
||||
GVariantType *v_type;
|
||||
|
||||
v_properties = g_dbus_proxy_call_finish (priv->proxy, res, &err);
|
||||
v_properties = _nm_dbus_proxy_call_finish (priv->proxy, res,
|
||||
G_VARIANT_TYPE ("(@a{sv})"),
|
||||
&err);
|
||||
if (!v_properties) {
|
||||
nm_log_warn (LOGD_BT, "bluez[%s] error getting device properties: %s",
|
||||
priv->path, err && err->message ? err->message : "(unknown)");
|
||||
priv->path, err->message);
|
||||
g_error_free (err);
|
||||
g_signal_emit (self, signals[INITIALIZED], 0, FALSE);
|
||||
goto END;
|
||||
}
|
||||
|
||||
v_type = g_variant_type_new ("(a{sv})");
|
||||
if (g_variant_is_of_type (v_properties, v_type)) {
|
||||
v_dict = g_variant_get_child_value (v_properties, 0);
|
||||
_set_properties (self, v_dict);
|
||||
g_variant_unref (v_dict);
|
||||
} else {
|
||||
nm_log_warn (LOGD_BT, "bluez[%s] GetProperties returns unexpected result of type %s", priv->path, g_variant_get_type_string (v_properties));
|
||||
}
|
||||
g_variant_type_free (v_type);
|
||||
|
||||
v_dict = g_variant_get_child_value (v_properties, 0);
|
||||
_set_properties (self, v_dict);
|
||||
g_variant_unref (v_dict);
|
||||
g_variant_unref (v_properties);
|
||||
|
||||
/* Check if any connections match this device */
|
||||
|
|
@ -910,7 +904,6 @@ get_properties_cb_4 (GObject *source_object, GAsyncResult *res, gpointer user_da
|
|||
priv->initialized = TRUE;
|
||||
g_signal_emit (self, signals[INITIALIZED], 0, TRUE);
|
||||
|
||||
|
||||
check_emit_usable (self);
|
||||
|
||||
END:
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@
|
|||
#include "nm-bluez-common.h"
|
||||
#include "nm-connection-provider.h"
|
||||
#include "nm-device-bt.h"
|
||||
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
typedef struct {
|
||||
int bluez_version;
|
||||
|
|
@ -276,8 +275,8 @@ check_bluez_and_try_setup_do_introspect (GObject *source_object,
|
|||
|
||||
g_clear_object (&priv->async_cancellable);
|
||||
|
||||
result = g_dbus_proxy_call_finish (priv->introspect_proxy, res, &error);
|
||||
|
||||
result = _nm_dbus_proxy_call_finish (priv->introspect_proxy, res,
|
||||
G_VARIANT_TYPE ("(s)"), &error);
|
||||
if (!result) {
|
||||
char *reason2 = g_strdup_printf ("introspect failed with %s", error->message);
|
||||
check_bluez_and_try_setup_final_step (self, 0, reason2);
|
||||
|
|
|
|||
|
|
@ -200,8 +200,9 @@ get_managed_objects_cb (GDBusProxy *proxy,
|
|||
GError *error = NULL;
|
||||
const char *path;
|
||||
|
||||
variant = g_dbus_proxy_call_finish (proxy, res, &error);
|
||||
|
||||
variant = _nm_dbus_proxy_call_finish (proxy, res,
|
||||
G_VARIANT_TYPE ("(a{oa{sa{sv}}})"),
|
||||
&error);
|
||||
if (!variant) {
|
||||
if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD))
|
||||
nm_log_warn (LOGD_BT, "Couldn't get managed objects: not running Bluez5?");
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ check_authorization_cb (GDBusProxy *proxy,
|
|||
GVariant *value;
|
||||
GError *error = NULL;
|
||||
|
||||
value = g_dbus_proxy_call_finish (proxy, res, &error);
|
||||
value = _nm_dbus_proxy_call_finish (proxy, res, G_VARIANT_TYPE ("((bba{ss}))"), &error);
|
||||
if (value == NULL) {
|
||||
if (data->cancellation_id != NULL &&
|
||||
(!g_dbus_error_is_remote_error (error) &&
|
||||
|
|
@ -201,18 +201,15 @@ check_authorization_cb (GDBusProxy *proxy,
|
|||
error->message);
|
||||
g_error_free (error);
|
||||
} else {
|
||||
GVariant *result_value;
|
||||
CheckAuthorizationResult *result;
|
||||
|
||||
result = g_new0 (CheckAuthorizationResult, 1);
|
||||
|
||||
result_value = g_variant_get_child_value (value, 0);
|
||||
g_variant_get (result_value,
|
||||
"(bb@a{ss})",
|
||||
g_variant_get (value,
|
||||
"((bb@a{ss}))",
|
||||
&result->is_authorized,
|
||||
&result->is_challenge,
|
||||
NULL);
|
||||
g_variant_unref (result_value);
|
||||
g_variant_unref (value);
|
||||
|
||||
_LOGD ("call[%u]: CheckAuthorization succeeded: (is_authorized=%d, is_challenge=%d)", data->call_id, result->is_authorized, result->is_challenge);
|
||||
|
|
|
|||
|
|
@ -477,14 +477,16 @@ iface_check_ap_mode_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_d
|
|||
const char *data;
|
||||
|
||||
/* The ProbeRequest method only exists if AP mode has been enabled */
|
||||
variant = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
||||
G_VARIANT_TYPE ("(s)"),
|
||||
&error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
|
||||
if (variant && g_variant_is_of_type (variant, G_VARIANT_TYPE ("(s)"))) {
|
||||
if (variant) {
|
||||
g_variant_get (variant, "(&s)", &data);
|
||||
if (strstr (data, "ProbeRequest"))
|
||||
priv->ap_support = AP_SUPPORT_YES;
|
||||
|
|
@ -691,19 +693,20 @@ interface_get_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|||
NMSupplicantInterfacePrivate *priv;
|
||||
gs_unref_variant GVariant *variant = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
char *path;
|
||||
const char *path;
|
||||
|
||||
variant = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
||||
G_VARIANT_TYPE ("(o)"),
|
||||
&error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
|
||||
if (variant && g_variant_is_of_type (variant, G_VARIANT_TYPE ("(o)"))) {
|
||||
g_variant_get (variant, "(o)", &path);
|
||||
if (variant) {
|
||||
g_variant_get (variant, "(&o)", &path);
|
||||
interface_add_done (self, path);
|
||||
g_free (path);
|
||||
} else {
|
||||
nm_log_err (LOGD_SUPPLICANT, "(%s): error getting interface: %s", priv->dev, error->message);
|
||||
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
||||
|
|
@ -717,19 +720,20 @@ interface_add_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|||
NMSupplicantInterfacePrivate *priv;
|
||||
gs_free_error GError *error = NULL;
|
||||
gs_unref_variant GVariant *variant = NULL;
|
||||
char *path;
|
||||
const char *path;
|
||||
|
||||
variant = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
||||
G_VARIANT_TYPE ("(o)"),
|
||||
&error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
|
||||
if (variant && g_variant_is_of_type (variant, G_VARIANT_TYPE ("(o)"))) {
|
||||
g_variant_get (variant, "(o)", &path);
|
||||
if (variant) {
|
||||
g_variant_get (variant, "(&o)", &path);
|
||||
interface_add_done (self, path);
|
||||
g_free (path);
|
||||
} else if (_dbus_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) {
|
||||
/* Interface already added, just get its object path */
|
||||
g_dbus_proxy_call (priv->wpas_proxy,
|
||||
|
|
@ -988,19 +992,15 @@ add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|||
const char *blob_name;
|
||||
GByteArray *blob_data;
|
||||
|
||||
reply = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||
reply = _nm_dbus_proxy_call_finish (proxy, result,
|
||||
G_VARIANT_TYPE ("(o)"),
|
||||
&error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
|
||||
if (reply && !g_variant_is_of_type (reply, G_VARIANT_TYPE ("(o)"))) {
|
||||
error = g_error_new (NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
|
||||
"Unexpected AddNetwork reply type %s",
|
||||
g_variant_get_type_string (reply));
|
||||
}
|
||||
|
||||
g_free (priv->net_path);
|
||||
priv->net_path = NULL;
|
||||
|
||||
|
|
@ -1011,7 +1011,6 @@ add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|||
}
|
||||
|
||||
g_variant_get (reply, "(o)", &priv->net_path);
|
||||
g_assert (priv->net_path);
|
||||
|
||||
/* Send blobs first; otherwise jump to selecting the network */
|
||||
blobs = nm_supplicant_config_get_blobs (priv->cfg);
|
||||
|
|
|
|||
|
|
@ -1851,7 +1851,7 @@ plugin_need_secrets_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_d
|
|||
gs_free_error GError *error = NULL;
|
||||
const char *setting_name;
|
||||
|
||||
reply = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||
reply = _nm_dbus_proxy_call_finish (proxy, result, G_VARIANT_TYPE ("(s)"), &error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue