summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-11-09 16:00:57 +0100
committerThomas Haller <thaller@redhat.com>2022-11-14 08:05:58 +0100
commit093ea4a10aa182d0fcbf900cabb7f85ea2bab281 (patch)
tree0163656d445f25a86a6a76c8354e27a814b00f39
parent6c9018a29e9a19332946a56cca9e4a6f04833a7b (diff)
downloadNetworkManager-093ea4a10aa182d0fcbf900cabb7f85ea2bab281.tar.gz
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.
-rw-r--r--src/libnm-glib-aux/nm-dbus-aux.c69
-rw-r--r--src/libnm-glib-aux/nm-dbus-aux.h8
2 files changed, 22 insertions, 55 deletions
diff --git a/src/libnm-glib-aux/nm-dbus-aux.c b/src/libnm-glib-aux/nm-dbus-aux.c
index be1444a01e..4ad8a111b6 100644
--- a/src/libnm-glib-aux/nm-dbus-aux.c
+++ b/src/libnm-glib-aux/nm-dbus-aux.c
@@ -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 {
char *signal_name;
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:
* @proxy: A #GDBusProxy.
@@ -723,17 +712,3 @@ _nm_dbus_proxy_call_finish(GDBusProxy *proxy,
nm_clear_pointer(&variant, g_variant_unref);
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;
-}
diff --git a/src/libnm-glib-aux/nm-dbus-aux.h b/src/libnm-glib-aux/nm-dbus-aux.h
index e3e3349546..5db79c08f7 100644
--- a/src/libnm-glib-aux/nm-dbus-aux.h
+++ b/src/libnm-glib-aux/nm-dbus-aux.h
@@ -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,
const char *signal_name,
const GVariantType *signature,
@@ -313,9 +310,4 @@ GVariant *_nm_dbus_proxy_call_finish(GDBusProxy *proxy,
const GVariantType *reply_type,
GError **error);
-GVariant *_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection,
- GAsyncResult *result,
- const GVariantType *reply_type,
- GError **error);
-
#endif /* __NM_DBUS_AUX_H__ */