Bug 40734 - Delay returning from SetSubject until the server acks or nacks the change
Summary: Delay returning from SetSubject until the server acks or nacks the change
Status: RESOLVED MOVED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: idle (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on: Channel.Iface.Room
Blocks: 36808
  Show dependency treegraph
 
Reported: 2011-09-09 03:28 UTC by Will Thompson
Modified: 2019-12-03 20:09 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
MUCChannel: Queue SetSubject calls and return asynchronously (6.85 KB, patch)
2011-10-27 16:51 UTC, Debarshi Ray
Details | Splinter Review

Description Will Thompson 2011-09-09 03:28:31 UTC
Due to a conflict of interest between DBus.Properties.PropertiesChanged and Telepathy.Properties.PropertiesChanged, change notifications for MUC topics are broken in Idle at the moment.

I propose to fix this by just implementing Subject and getting rid of old properties.

Here is a branch which does so. Currently it doesn't implement RoomConfig for other aspects of room flags, it just stubs them out. More on that story later mayhap.

I've tested it with my Empathy branch at <https://bugzilla.gnome.org/show_bug.cgi?id=658542>, and it seems to work as expected. (Empathy doesn't provide a way to un-set the topic, I noticed.)
Comment 1 Will Thompson 2011-10-12 03:52:59 UTC
I've updated the branch to depend on a version of telepathy-glib which actually includes the necessary generated code.
Comment 2 Simon McVittie 2011-10-12 04:21:05 UTC
> static void _network_member_left(IdleMUCChannel *chan, TpHandle leaver, TpHandle actor, const gchar *message, TpChannelGroupChangeReason reason) {
> -        IdleMUCChannelPrivate *priv = IDLE_MUC_CHANNEL_GET_PRIVATE(chan);
> +        TpBaseChannel *base = TP_BASE_CHANNEL (chan);
> +TpBaseConnection *base_conn = tp_base_channel_get_connection (base);

Indentation needed.

Otherwise looks good.
Comment 3 Debarshi Ray 2011-10-27 07:12:18 UTC
+ send_command (self, cmd);
+ /* FIXME: don't return till we get a reply */
+ tp_svc_channel_interface_subject_return_from_set_subject (context);

Do you want me to fix this? I can, if you are terribly busy or something. :-)
Comment 4 Debarshi Ray 2011-10-27 16:50:01 UTC
(In reply to comment #3)
> + send_command (self, cmd);
> + /* FIXME: don't return till we get a reply */
> + tp_svc_channel_interface_subject_return_from_set_subject (context);
> 
> Do you want me to fix this? I can, if you are terribly busy or something. :-)

I had some free time today, and so I made the SetSubject method not return till we get a reply from the server and implemented a queueing system similar to the RequestContactInfo method so that successive SetSubject calls get queued.

I tried to fix the test case but the following changes don't work:

diff --git a/tests/twisted/channels/muc-channel-topic.py b/tests/twisted/channels/muc-channel-topic.py
index 0b7ccb3..4552895 100644
--- a/tests/twisted/channels/muc-channel-topic.py
+++ b/tests/twisted/channels/muc-channel-topic.py
@@ -37,10 +37,9 @@ def expect_and_check_can_set(q, channel, can_set):
         channel.Properties.Get(CHANNEL_IFACE_SUBJECT, 'CanSet'))
 
     if can_set:
-        # FIXME: this shouldn't return until the server gets back to us with
-        # RPL_TOPIC
-        channel.Subject2.SetSubject('what up')
-        e = q.expect('stream-TOPIC', data=[room, 'what up'])
+        call_async(q, channel.Subject2, 'SetSubject', 'what up')
+        q.expect_many(EventPattern('stream-TOPIC', data=[room, 'what up']),
+                      EventPattern('dbus-return', method='SetSubject'))
     else:
         call_async(q, channel.Subject2, 'SetSubject', 'boo hoo')
         q.expect('dbus-error', method='SetSubject',
@@ -90,8 +89,6 @@ def test(q, bus, conn, stream):
     assertEquals('', subject_props['Actor'])
 
     # Before the topic arrives from the server, check that our API works okay.
-    # FIXME: when we make SetSubject return asynchronously, this will need
-    # revising.
     test_can_set(q, stream, channel)
 
     # We're told the channel's topic, and (in a separte message) who set it and

Wondering what can be wrong.
Comment 5 Debarshi Ray 2011-10-27 16:51:10 UTC
Created attachment 52835 [details] [review]
MUCChannel: Queue SetSubject calls and return asynchronously

Should apply on top of Will's loyal-subjects branch.
Comment 6 Will Thompson 2011-10-28 04:18:44 UTC
Comment on attachment 52835 [details] [review]
MUCChannel: Queue SetSubject calls and return asynchronously

Review of attachment 52835 [details] [review]:
-----------------------------------------------------------------

AFAICT: the server returning an error isn't handled, and nor is the case where the server has truncated the topic. So in either of these cases, a SetSubject() call will never return, and the queued follow-up commands will never return either.

In Gabble, I made SetSubject() return:

• successfully when *any* subject update is received (the protocol doesn't really allow the client to match up the request and the response);
• an error when the server responds with an error (which is a little fiddly to match up, but possible).

Queueing up successive requests is nice to have, but if the channel closes without getting a reply from the server, those method calls will never return either.
Comment 7 Debarshi Ray 2011-10-28 05:15:01 UTC
(In reply to comment #6)
> Comment on attachment 52835 [details] [review] [review]
> MUCChannel: Queue SetSubject calls and return asynchronously
> 
> Review of attachment 52835 [details] [review] [review]:

Thanks for the review.

> -----------------------------------------------------------------
> 
> AFAICT: the server returning an error isn't handled, and nor is the case where
> the server has truncated the topic. So in either of these cases, a SetSubject()
> call will never return, and the queued follow-up commands will never return
> either.
> 
> In Gabble, I made SetSubject() return:
> 
> • successfully when *any* subject update is received (the protocol doesn't
> really allow the client to match up the request and the response);
> • an error when the server responds with an error (which is a little fiddly to
> match up, but possible).

Right. It was a quick hack. I will address these issues.
 
> Queueing up successive requests is nice to have, but if the channel closes
> without getting a reply from the server, those method calls will never return
> either.

Right. I am wondering if the queueing implementation in idle-contact-info.c will have similar problems or not. We free up the queue when the IdleConnection is finalized.
Comment 8 Will Thompson 2011-10-28 09:56:15 UTC
(In reply to comment #2)
> > static void _network_member_left(IdleMUCChannel *chan, TpHandle leaver, TpHandle actor, const gchar *message, TpChannelGroupChangeReason reason) {
> > -        IdleMUCChannelPrivate *priv = IDLE_MUC_CHANNEL_GET_PRIVATE(chan);
> > +        TpBaseChannel *base = TP_BASE_CHANNEL (chan);
> > +TpBaseConnection *base_conn = tp_base_channel_get_connection (base);
> 
> Indentation needed.

Thanks, fixed.

> Otherwise looks good.

I've merged my branch to master, but I'll retitle the bug for the returning-later issue.
Comment 9 GitLab Migration User 2019-12-03 20:09:26 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/telepathy/telepathy-idle/issues/31.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.