mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-13 14:05:05 +01:00
gdbusconnection: Move SignalData, SignalSubscriber higher up
Subsequent changes will need to access these data structures from on_worker_message_received(). No functional change here, only moving code around. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
1e648b677f
commit
8dfea5609e
@ -287,6 +287,71 @@ call_destroy_notify (GMainContext *context,
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* All fields are immutable after construction. */
|
||||||
|
gatomicrefcount ref_count;
|
||||||
|
GDBusSignalCallback callback;
|
||||||
|
gpointer user_data;
|
||||||
|
GDestroyNotify user_data_free_func;
|
||||||
|
guint id;
|
||||||
|
GMainContext *context;
|
||||||
|
} SignalSubscriber;
|
||||||
|
|
||||||
|
static SignalSubscriber *
|
||||||
|
signal_subscriber_ref (SignalSubscriber *subscriber)
|
||||||
|
{
|
||||||
|
g_atomic_ref_count_inc (&subscriber->ref_count);
|
||||||
|
return subscriber;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
signal_subscriber_unref (SignalSubscriber *subscriber)
|
||||||
|
{
|
||||||
|
if (g_atomic_ref_count_dec (&subscriber->ref_count))
|
||||||
|
{
|
||||||
|
/* Destroy the user data. It doesn’t matter which thread
|
||||||
|
* signal_subscriber_unref() is called in (or whether it’s called with a
|
||||||
|
* lock held), as call_destroy_notify() always defers to the next
|
||||||
|
* #GMainContext iteration. */
|
||||||
|
call_destroy_notify (subscriber->context,
|
||||||
|
subscriber->user_data_free_func,
|
||||||
|
subscriber->user_data);
|
||||||
|
|
||||||
|
g_main_context_unref (subscriber->context);
|
||||||
|
g_free (subscriber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gchar *rule;
|
||||||
|
gchar *sender;
|
||||||
|
gchar *sender_unique_name; /* if sender is unique or org.freedesktop.DBus, then that name... otherwise blank */
|
||||||
|
gchar *interface_name;
|
||||||
|
gchar *member;
|
||||||
|
gchar *object_path;
|
||||||
|
gchar *arg0;
|
||||||
|
GDBusSignalFlags flags;
|
||||||
|
GPtrArray *subscribers; /* (owned) (element-type SignalSubscriber) */
|
||||||
|
} SignalData;
|
||||||
|
|
||||||
|
static void
|
||||||
|
signal_data_free (SignalData *signal_data)
|
||||||
|
{
|
||||||
|
g_free (signal_data->rule);
|
||||||
|
g_free (signal_data->sender);
|
||||||
|
g_free (signal_data->sender_unique_name);
|
||||||
|
g_free (signal_data->interface_name);
|
||||||
|
g_free (signal_data->member);
|
||||||
|
g_free (signal_data->object_path);
|
||||||
|
g_free (signal_data->arg0);
|
||||||
|
g_ptr_array_unref (signal_data->subscribers);
|
||||||
|
g_free (signal_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#define CONNECTION_ENSURE_LOCK(obj) do { ; } while (FALSE)
|
#define CONNECTION_ENSURE_LOCK(obj) do { ; } while (FALSE)
|
||||||
#else
|
#else
|
||||||
@ -3247,69 +3312,6 @@ g_dbus_connection_remove_filter (GDBusConnection *connection,
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
gchar *rule;
|
|
||||||
gchar *sender;
|
|
||||||
gchar *sender_unique_name; /* if sender is unique or org.freedesktop.DBus, then that name... otherwise blank */
|
|
||||||
gchar *interface_name;
|
|
||||||
gchar *member;
|
|
||||||
gchar *object_path;
|
|
||||||
gchar *arg0;
|
|
||||||
GDBusSignalFlags flags;
|
|
||||||
GPtrArray *subscribers; /* (owned) (element-type SignalSubscriber) */
|
|
||||||
} SignalData;
|
|
||||||
|
|
||||||
static void
|
|
||||||
signal_data_free (SignalData *signal_data)
|
|
||||||
{
|
|
||||||
g_free (signal_data->rule);
|
|
||||||
g_free (signal_data->sender);
|
|
||||||
g_free (signal_data->sender_unique_name);
|
|
||||||
g_free (signal_data->interface_name);
|
|
||||||
g_free (signal_data->member);
|
|
||||||
g_free (signal_data->object_path);
|
|
||||||
g_free (signal_data->arg0);
|
|
||||||
g_ptr_array_unref (signal_data->subscribers);
|
|
||||||
g_free (signal_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/* All fields are immutable after construction. */
|
|
||||||
gatomicrefcount ref_count;
|
|
||||||
GDBusSignalCallback callback;
|
|
||||||
gpointer user_data;
|
|
||||||
GDestroyNotify user_data_free_func;
|
|
||||||
guint id;
|
|
||||||
GMainContext *context;
|
|
||||||
} SignalSubscriber;
|
|
||||||
|
|
||||||
static SignalSubscriber *
|
|
||||||
signal_subscriber_ref (SignalSubscriber *subscriber)
|
|
||||||
{
|
|
||||||
g_atomic_ref_count_inc (&subscriber->ref_count);
|
|
||||||
return subscriber;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
signal_subscriber_unref (SignalSubscriber *subscriber)
|
|
||||||
{
|
|
||||||
if (g_atomic_ref_count_dec (&subscriber->ref_count))
|
|
||||||
{
|
|
||||||
/* Destroy the user data. It doesn’t matter which thread
|
|
||||||
* signal_subscriber_unref() is called in (or whether it’s called with a
|
|
||||||
* lock held), as call_destroy_notify() always defers to the next
|
|
||||||
* #GMainContext iteration. */
|
|
||||||
call_destroy_notify (subscriber->context,
|
|
||||||
subscriber->user_data_free_func,
|
|
||||||
subscriber->user_data);
|
|
||||||
|
|
||||||
g_main_context_unref (subscriber->context);
|
|
||||||
g_free (subscriber);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
args_to_rule (const gchar *sender,
|
args_to_rule (const gchar *sender,
|
||||||
const gchar *interface_name,
|
const gchar *interface_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user