glib-aux: rename _nm_dbus_signal_connect{,_data}() to _nm_dbus_proxy_*()

These are helpers for GDBusProxy. I think we should avoid GDBusProxy where possible,
and these functions too. Give the function a more specific name to show that this
is only for the proxy.
This commit is contained in:
Thomas Haller 2022-11-09 15:58:35 +01:00
parent cf6d38177f
commit 6c9018a29e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
4 changed files with 70 additions and 64 deletions

View file

@ -454,11 +454,11 @@ _sim_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data)
priv->sim_proxy = proxy;
/* Watch for custom ofono PropertyChanged signals */
_nm_dbus_signal_connect(priv->sim_proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(sim_property_changed),
self);
_nm_dbus_proxy_signal_connect(priv->sim_proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(sim_property_changed),
self);
g_dbus_proxy_call(priv->sim_proxy,
"GetProperties",
@ -834,11 +834,11 @@ _context_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data)
_LOGD("recieved proxy for %s", g_dbus_proxy_get_object_path(proxy));
octx->proxy = proxy;
_nm_dbus_signal_connect(proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(context_property_changed),
octx);
_nm_dbus_proxy_signal_connect(proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(context_property_changed),
octx);
uuid = _generate_uuid(priv->imsi, g_dbus_proxy_get_object_path(proxy));
g_hash_table_insert(priv->contexts, uuid, octx);
@ -973,23 +973,23 @@ _connman_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data)
priv->connman_proxy = proxy;
_nm_dbus_signal_connect(priv->connman_proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(connman_property_changed),
self);
_nm_dbus_proxy_signal_connect(priv->connman_proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(connman_property_changed),
self);
_nm_dbus_signal_connect(priv->connman_proxy,
"ContextAdded",
G_VARIANT_TYPE("(oa{sv})"),
G_CALLBACK(connman_context_added),
self);
_nm_dbus_proxy_signal_connect(priv->connman_proxy,
"ContextAdded",
G_VARIANT_TYPE("(oa{sv})"),
G_CALLBACK(connman_context_added),
self);
_nm_dbus_signal_connect(priv->connman_proxy,
"ContextRemoved",
G_VARIANT_TYPE("(o)"),
G_CALLBACK(connman_context_removed),
self);
_nm_dbus_proxy_signal_connect(priv->connman_proxy,
"ContextRemoved",
G_VARIANT_TYPE("(o)"),
G_CALLBACK(connman_context_removed),
self);
g_dbus_proxy_call(priv->connman_proxy,
"GetProperties",
@ -1576,11 +1576,11 @@ modem_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data)
priv->modem_proxy = proxy;
_nm_dbus_signal_connect(priv->modem_proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(modem_property_changed),
self);
_nm_dbus_proxy_signal_connect(priv->modem_proxy,
"PropertyChanged",
G_VARIANT_TYPE("(sv)"),
G_CALLBACK(modem_property_changed),
self);
g_dbus_proxy_call(priv->modem_proxy,
"GetProperties",

View file

@ -295,24 +295,24 @@ on_proxy_acquired(GObject *object, GAsyncResult *res, NMSleepMonitor *self)
g_clear_object(&self->cancellable);
#if USE_UPOWER
self->sig_id_1 = _nm_dbus_signal_connect(self->proxy,
"Sleeping",
NULL,
G_CALLBACK(upower_sleeping_cb),
self);
self->sig_id_2 = _nm_dbus_signal_connect(self->proxy,
"Resuming",
NULL,
G_CALLBACK(upower_resuming_cb),
self);
self->sig_id_1 = _nm_dbus_proxy_signal_connect(self->proxy,
"Sleeping",
NULL,
G_CALLBACK(upower_sleeping_cb),
self);
self->sig_id_2 = _nm_dbus_proxy_signal_connect(self->proxy,
"Resuming",
NULL,
G_CALLBACK(upower_resuming_cb),
self);
#else
self->sig_id_1 =
g_signal_connect(self->proxy, "notify::g-name-owner", G_CALLBACK(name_owner_cb), self);
self->sig_id_2 = _nm_dbus_signal_connect(self->proxy,
"PrepareForSleep",
G_VARIANT_TYPE("(b)"),
G_CALLBACK(prepare_for_sleep_cb),
self);
self->sig_id_2 = _nm_dbus_proxy_signal_connect(self->proxy,
"PrepareForSleep",
G_VARIANT_TYPE("(b)"),
G_CALLBACK(prepare_for_sleep_cb),
self);
{
gs_free char *owner = NULL;

View file

@ -633,7 +633,7 @@ dbus_signal_meta_marshal(GClosure *closure,
}
/**
* _nm_dbus_signal_connect_data:
* _nm_dbus_proxy_signal_connect_data:
* @proxy: a #GDBusProxy
* @signal_name: the D-Bus signal to connect to
* @signature: (allow-none): the signal's type signature (must be a tuple)
@ -662,13 +662,13 @@ dbus_signal_meta_marshal(GClosure *closure,
* g_signal_handlers_disconnect_by_data() will work correctly.
*/
gulong
_nm_dbus_signal_connect_data(GDBusProxy *proxy,
const char *signal_name,
const GVariantType *signature,
GCallback c_handler,
gpointer data,
GClosureNotify destroy_data,
GConnectFlags connect_flags)
_nm_dbus_proxy_signal_connect_data(GDBusProxy *proxy,
const char *signal_name,
const GVariantType *signature,
GCallback c_handler,
gpointer data,
GClosureNotify destroy_data,
GConnectFlags connect_flags)
{
NMDBusSignalData *sd;
GClosure *closure;

View file

@ -279,28 +279,34 @@ 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_signal_connect_data(GDBusProxy *proxy,
const char *signal_name,
const GVariantType *signature,
GCallback c_handler,
gpointer data,
GClosureNotify destroy_data,
GConnectFlags connect_flags);
gulong _nm_dbus_proxy_signal_connect_data(GDBusProxy *proxy,
const char *signal_name,
const GVariantType *signature,
GCallback c_handler,
gpointer data,
GClosureNotify destroy_data,
GConnectFlags connect_flags);
/**
* _nm_dbus_signal_connect:
* _nm_dbus_proxy_signal_connect:
* @proxy: a #GDBusProxy
* @signal_name: the D-Bus signal to connect to
* @signature: the signal's type signature (must be a tuple)
* @c_handler: the signal handler function
* @data: (allow-none): data to pass to @c_handler
*
* Simplified version of _nm_dbus_signal_connect_data() with fewer arguments.
* Simplified version of _nm_dbus_proxy_signal_connect_data() with fewer arguments.
*
* Returns: the signal handler ID, as with _nm_signal_connect_data().
*/
#define _nm_dbus_signal_connect(proxy, name, signature, handler, data) \
_nm_dbus_signal_connect_data(proxy, name, signature, handler, data, NULL, (GConnectFlags) 0)
#define _nm_dbus_proxy_signal_connect(proxy, name, signature, handler, data) \
_nm_dbus_proxy_signal_connect_data(proxy, \
name, \
signature, \
handler, \
data, \
NULL, \
(GConnectFlags) 0)
GVariant *_nm_dbus_proxy_call_finish(GDBusProxy *proxy,
GAsyncResult *res,