Bug 621945 – Filter outgoing messages in GDBusConnection

This patch breaks some rarely-used public API (only known user is
dconf).

This patch is based on work from Peng Huang <shawn.p.huang@gmail.com>.

See https://bugzilla.gnome.org/show_bug.cgi?id=621945

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
David Zeuthen
2010-06-21 16:08:53 -04:00
parent a4cd39e741
commit 45411ccbe3
5 changed files with 130 additions and 31 deletions

View File

@@ -555,20 +555,29 @@ test_connection_signals (void)
typedef struct
{
guint num_handled;
guint num_outgoing;
guint32 serial;
} FilterData;
static gboolean
filter_func (GDBusConnection *connection,
GDBusMessage *message,
gboolean incoming,
gpointer user_data)
{
FilterData *data = user_data;
guint32 reply_serial;
reply_serial = g_dbus_message_get_reply_serial (message);
if (reply_serial == data->serial)
data->num_handled += 1;
if (incoming)
{
reply_serial = g_dbus_message_get_reply_serial (message);
if (reply_serial == data->serial)
data->num_handled += 1;
}
else
{
data->num_outgoing += 1;
}
return FALSE;
}
@@ -638,6 +647,7 @@ test_connection_filter (void)
g_assert (r != NULL);
g_object_unref (r);
g_assert_cmpint (data.num_handled, ==, 3);
g_assert_cmpint (data.num_outgoing, ==, 3);
_g_object_wait_for_single_ref (c);
g_object_unref (c);