mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 08:18:03 +02:00
glib-aux: drop unused _nm_dbus_connection_call_finish()
This wasn't used. It also doesn't make much sense, because g_dbus_connection_call() accepts a reply type argument. So if you want to check the reply type, you can do so when making the call. That differs from g_dbus_proxy_call(), where this might make some sense and is actually used. While at it, also drop _nm_dbus_typecheck_response() from the header file. It seems not general purpose enough and is not necessarily a great pattern. Because, - for g_dbus_connection_call() you either specify the reply_type when making the call, or you do some more elaborate handling of the result -- not merely _nm_dbus_typecheck_response(). - for g_dbus_proxy_call(), you can use _nm_dbus_proxy_call_finish() to get it, or again, you want some non-trivial type checking.
This commit is contained in:
parent
6c9018a29e
commit
093ea4a10a
2 changed files with 22 additions and 55 deletions
|
|
@ -526,39 +526,6 @@ nm_dbus_connection_call_blocking(NMDBusConnectionCallBlockingData *data, GError
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
|
||||||
* _nm_dbus_typecheck_response:
|
|
||||||
* @response: the #GVariant response to check.
|
|
||||||
* @reply_type: the expected reply type. It may be %NULL to perform no
|
|
||||||
* checking.
|
|
||||||
* @error: (allow-none): the error in case the @reply_type does not match.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE, if @response is of the expected @reply_type.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
_nm_dbus_typecheck_response(GVariant *response, const GVariantType *reply_type, GError **error)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail(response, FALSE);
|
|
||||||
|
|
||||||
if (!reply_type)
|
|
||||||
return TRUE;
|
|
||||||
if (g_variant_is_of_type(response, reply_type))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* This is the same error code that g_dbus_connection_call() returns if
|
|
||||||
* @reply_type doesn't match.
|
|
||||||
*/
|
|
||||||
g_set_error(error,
|
|
||||||
G_IO_ERROR,
|
|
||||||
G_IO_ERROR_INVALID_ARGUMENT,
|
|
||||||
_("Method returned type '%s', but expected '%s'"),
|
|
||||||
g_variant_get_type_string(response),
|
|
||||||
g_variant_type_peek_string(reply_type));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *signal_name;
|
char *signal_name;
|
||||||
const GVariantType *signature;
|
const GVariantType *signature;
|
||||||
|
|
@ -694,6 +661,28 @@ _nm_dbus_proxy_signal_connect_data(GDBusProxy *proxy,
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_nm_dbus_typecheck_response(GVariant *response, const GVariantType *reply_type, GError **error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(response, FALSE);
|
||||||
|
|
||||||
|
if (!reply_type)
|
||||||
|
return TRUE;
|
||||||
|
if (g_variant_is_of_type(response, reply_type))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* This is the same error code that g_dbus_connection_call() returns if
|
||||||
|
* @reply_type doesn't match.
|
||||||
|
*/
|
||||||
|
g_set_error(error,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_INVALID_ARGUMENT,
|
||||||
|
_("Method returned type '%s', but expected '%s'"),
|
||||||
|
g_variant_get_type_string(response),
|
||||||
|
g_variant_type_peek_string(reply_type));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _nm_dbus_proxy_call_finish:
|
* _nm_dbus_proxy_call_finish:
|
||||||
* @proxy: A #GDBusProxy.
|
* @proxy: A #GDBusProxy.
|
||||||
|
|
@ -723,17 +712,3 @@ _nm_dbus_proxy_call_finish(GDBusProxy *proxy,
|
||||||
nm_clear_pointer(&variant, g_variant_unref);
|
nm_clear_pointer(&variant, g_variant_unref);
|
||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant *
|
|
||||||
_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection,
|
|
||||||
GAsyncResult *result,
|
|
||||||
const GVariantType *reply_type,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
GVariant *variant;
|
|
||||||
|
|
||||||
variant = g_dbus_connection_call_finish(dbus_connection, result, error);
|
|
||||||
if (variant && !_nm_dbus_typecheck_response(variant, reply_type, error))
|
|
||||||
nm_clear_pointer(&variant, g_variant_unref);
|
|
||||||
return variant;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -276,9 +276,6 @@ nm_g_variant_tuple_get_u(GVariant *v, guint32 *out_u)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean
|
|
||||||
_nm_dbus_typecheck_response(GVariant *response, const GVariantType *reply_type, GError **error);
|
|
||||||
|
|
||||||
gulong _nm_dbus_proxy_signal_connect_data(GDBusProxy *proxy,
|
gulong _nm_dbus_proxy_signal_connect_data(GDBusProxy *proxy,
|
||||||
const char *signal_name,
|
const char *signal_name,
|
||||||
const GVariantType *signature,
|
const GVariantType *signature,
|
||||||
|
|
@ -313,9 +310,4 @@ GVariant *_nm_dbus_proxy_call_finish(GDBusProxy *proxy,
|
||||||
const GVariantType *reply_type,
|
const GVariantType *reply_type,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
GVariant *_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection,
|
|
||||||
GAsyncResult *result,
|
|
||||||
const GVariantType *reply_type,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
#endif /* __NM_DBUS_AUX_H__ */
|
#endif /* __NM_DBUS_AUX_H__ */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue