[Bug 41743] Receiving an offline message from a contact before the roster arrives makes them show up as 'unknown', not 'offline'
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed Oct 19 20:02:14 CEST 2011
https://bugs.freedesktop.org/show_bug.cgi?id=41743
Will Thompson <will.thompson at collabora.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #52288|0 |1
is obsolete| |
--- Comment #7 from Will Thompson <will.thompson at collabora.co.uk> 2011-10-19 11:02:14 PDT ---
Comment on attachment 52288
--> https://bugs.freedesktop.org/attachment.cgi?id=52288
I don't know how best to describe this patch.
>From 4a7bf6ca56656a684f2138002a79cc4c7f867cd9 Mon Sep 17 00:00:00 2001
>From: Will Thompson <will.thompson at collabora.co.uk>
>Date: Thu, 13 Oct 2011 11:33:08 +0100
>Subject: [PATCH] I don't know how best to describe this patch.
>
>Fixes: <https://bugs.freedesktop.org/show_bug.cgi?id=41743>
>---
> src/roster.c | 24 +++++++++++++++++--
> tests/twisted/presence/initial-contact-presence.py | 12 +++++++++-
> 2 files changed, 32 insertions(+), 4 deletions(-)
>
>diff --git a/src/roster.c b/src/roster.c
>index 8d8c3b7..d7c0527 100644
>--- a/src/roster.c
>+++ b/src/roster.c
>@@ -1398,11 +1398,29 @@ got_roster_iq (GabbleRoster *roster,
> {
> GabbleRosterItem *item = v;
> TpHandle contact = GPOINTER_TO_UINT (k);
>+ GabblePresence *presence = gabble_presence_cache_get (
>+ priv->conn->presence_cache, contact);
>
> if (item->subscribe == TP_SUBSCRIPTION_STATE_YES &&
>- gabble_presence_cache_get (roster->priv->conn->presence_cache,
>- contact) == NULL)
>- g_array_append_val (members, contact);
>+ (presence == NULL || presence->status == GABBLE_PRESENCE_UNKNOWN))
>+ {
>+ /* The contact might be in the presence cache with UNKNOWN
>+ * presence if we've received a message from them before the
>+ * roster arrived: an item is forcibly added to stash the
>+ * nickname which might have been included in the <message/> in
>+ * the presence cache. (This seems like a rather illogical place
>+ * to stash such nicknamesâif anything, they should live in
>+ * GabbleImFactoryâbut there we go.)
>+ *
>+ * So if this is the case, we flip their status to OFFLINE. We
>+ * don't use gabble_presence_update() because we want to signal
>+ * all the unknownâoffline transitions together.
>+ */
>+ if (presence != NULL)
>+ presence->status = GABBLE_PRESENCE_OFFLINE;
>+
>+ g_array_append_val (members, contact);
>+ }
>
> if (item->unsent_edits != NULL)
> edited_items = g_slist_prepend (edited_items, item);
>diff --git a/tests/twisted/presence/initial-contact-presence.py b/tests/twisted/presence/initial-contact-presence.py
>index ab52881..881316c 100644
>--- a/tests/twisted/presence/initial-contact-presence.py
>+++ b/tests/twisted/presence/initial-contact-presence.py
>@@ -8,7 +8,7 @@ This serves as a regression test for
> <https://bugs.freedesktop.org/show_bug.cgi?id=38603>, among other bugs.
> """
>
>-from gabbletest import exec_test, make_presence, sync_stream
>+from gabbletest import exec_test, make_presence, sync_stream, elem
> from servicetest import assertEquals, EventPattern, sync_dbus
>
> import constants as cs
>@@ -58,6 +58,16 @@ def test(q, bus, conn, stream):
> stream.send(make_presence('eve at foo.com'))
> q.expect('dbus-signal', signal='PresencesChanged', args=[{eve: AVAILABLE}])
>
>+ # We also get a message from a contact before we get the roster (presumably
>+ # they sent this while we were offline?). This shouldn't affect the contact
>+ # being reported as offline when we finally do get the roster, but it used
>+ # to: <https://bugs.freedesktop.org/show_bug.cgi?id=41743>.
>+ stream.send(
>+ elem('message', from_='amy at foo.com', type='chat')(
>+ elem('body')(u'why are you never online?')
>+ ))
>+ q.expect('dbus-signal', signal='MessageReceived')
>+
> event.stanza['type'] = 'result'
> event.query.addChild(make_roster_item('amy at foo.com', 'both'))
> event.query.addChild(make_roster_item('bob at foo.com', 'from'))
>--
>1.7.7
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the telepathy-bugs
mailing list