diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-18 17:14:28 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-18 17:14:28 +0200 |
commit | cb67f9f357769b6a6132d4e260e5885f7cdd2bfa (patch) | |
tree | 5fdb959a0dbad4dd5b266833ad658574656b371d | |
parent | 06519d20a42026638999a88a7efbe57457f86c6f (diff) | |
parent | ba3cfa861786ba3c18f4759aa331b0a25a511b50 (diff) |
Merge branch 'telepathy-glib-0.16'
-rw-r--r-- | telepathy-glib/channel-contacts.c | 20 | ||||
-rw-r--r-- | telepathy-glib/channel-internal.h | 1 | ||||
-rw-r--r-- | tests/dbus/text-channel.c | 48 |
3 files changed, 67 insertions, 2 deletions
diff --git a/telepathy-glib/channel-contacts.c b/telepathy-glib/channel-contacts.c index f5de15bd..01173336 100644 --- a/telepathy-glib/channel-contacts.c +++ b/telepathy-glib/channel-contacts.c @@ -108,6 +108,17 @@ dup_contacts_table (TpChannel *self, return target; } +/* self->priv->group_contact_owners may contain NULL TpContact and + * g_object_unref isn't NULL safe */ +static void +safe_g_object_unref (gpointer data) +{ + if (data == NULL) + return; + + g_object_unref (data); +} + static GHashTable * dup_owners_table (TpChannel *self, GHashTable *source, @@ -117,7 +128,7 @@ dup_owners_table (TpChannel *self, GHashTableIter iter; gpointer key, value; - target = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref); + target = g_hash_table_new_full (NULL, NULL, NULL, safe_g_object_unref); g_hash_table_iter_init (&iter, source); while (g_hash_table_iter_next (&iter, &key, &value)) @@ -484,7 +495,12 @@ _tp_channel_contacts_queue_prepare_finish (TpChannel *self, item = g_simple_async_result_get_op_res_gpointer (simple); if (contacts != NULL) - *contacts = g_ptr_array_ref (item->contacts); + { + if (item->contacts != NULL) + *contacts = g_ptr_array_ref (item->contacts); + else + *contacts = g_ptr_array_new (); + } if (g_simple_async_result_propagate_error (simple, error)) return FALSE; diff --git a/telepathy-glib/channel-internal.h b/telepathy-glib/channel-internal.h index 90af03dd..312dfe63 100644 --- a/telepathy-glib/channel-internal.h +++ b/telepathy-glib/channel-internal.h @@ -82,6 +82,7 @@ struct _TpChannelPrivate { GHashTable *group_members_contacts; GHashTable *group_local_pending_contacts; GHashTable *group_remote_pending_contacts; + /* the TpContact can be NULL if the owner is unknown */ GHashTable *group_contact_owners; gboolean cm_too_old_for_contacts; diff --git a/tests/dbus/text-channel.c b/tests/dbus/text-channel.c index a33292d0..1a64ce2f 100644 --- a/tests/dbus/text-channel.c +++ b/tests/dbus/text-channel.c @@ -923,6 +923,52 @@ test_sent_with_no_sender (Test *test, g_ptr_array_unref (parts); } +static void +test_receive_muc_delivery (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + GQuark features[] = { TP_TEXT_CHANNEL_FEATURE_INCOMING_MESSAGES, 0 }; + GPtrArray *parts; + GHashTable *header; + + g_test_bug ("41929 "); + + /* We have to prepare the pending messages feature to be notified about + * incoming messages */ + tp_proxy_prepare_async (test->channel, features, + proxy_prepare_cb, test); + + g_main_loop_run (test->mainloop); + g_assert_no_error (test->error); + + g_signal_connect (test->channel, "message-received", + G_CALLBACK (message_received_cb), test); + + /* build delivery report */ + parts = g_ptr_array_new_with_free_func ((GDestroyNotify) g_hash_table_unref); + header = tp_asv_new (NULL, NULL); + g_ptr_array_add (parts, header); + + tp_asv_set_uint32 (header, "message-type", + TP_CHANNEL_TEXT_MESSAGE_TYPE_DELIVERY_REPORT); + tp_asv_set_uint32 (header, "pending-message-id", 5); + tp_asv_set_string (header, "message-token", "message_token"); + tp_asv_set_string (header, "delivery-token", "delivery_token"); + tp_asv_set_uint32 (header, "delivery-status", TP_DELIVERY_STATUS_DELIVERED); + + tp_svc_channel_interface_messages_emit_message_received (test->chan_service, + parts); + + test->wait = 1; + g_main_loop_run (test->mainloop); + g_assert_no_error (test->error); + + g_assert_cmpuint (tp_message_get_message_type (test->received_msg), ==, + TP_CHANNEL_TEXT_MESSAGE_TYPE_DELIVERY_REPORT); + + g_ptr_array_unref (parts); +} + int main (int argc, char **argv) @@ -956,6 +1002,8 @@ main (int argc, test_sender_prepared, teardown); g_test_add ("/text-channel/sent-with-no-sender", Test, NULL, setup, test_sent_with_no_sender, teardown); + g_test_add ("/text-channel/receive-muc-delivery", Test, NULL, setup, + test_receive_muc_delivery, teardown); return g_test_run (); } |