Opened 7 years ago

Closed 6 years ago

#5039 closed enhancement (fixed)

DBus/remote API: add change_status_message() or so

Reported by: Ban Owned by:
Priority: normal Milestone: 0.14
Component: gajim-remote Version: 0.12.1
Severity: normal Keywords: dbus remote
Cc: Blocked By:
Blocking: OS: All

Description

Gajim's remote API messes a method to update status message. The change_status() method is usable but needs a lot of care not to create side effects: e.g. if you use the simplest and naive call

change_status(get_status(), "new status message", "")

Gajim will try to set the status to 'online' (or so) if any of the accounts is online, which is obviously annoying: if an account is offline, Gajim will try to connect it.

Therefore, the caller have to update each account separately in order not to connect disconnected accounts (or more generally, sync status between accounts), which is IMO too much work and DBus calls for something quite common and simple.
The caller have to do something like that:

for account in list_accounts():
  change_status(get_status(account), "new status message", account)

Then, I suggest to add a method such as change_status_message() to the remote API that only changes the status message and not the status itself.

regards,
Colomban

Change History (5)

comment:1 follow-up: Changed 7 years ago by asterix

and what does changing status message of an offline account should do? connect it? (it may have been disconnected previously and you thought it was connected for ex) or do nothing?

comment:2 Changed 7 years ago by thorstenp

for account in list_accounts():
    change_status(get_status(account), "new status message", account)

This code contains a race condition, because the status could have been changed between the call of get_status and change_status.

Instead of adding a new method to the API one could also allow the status parameter in change_status to be empty, so that only the status message (if possible) is changed.

comment:3 in reply to: ↑ 1 Changed 7 years ago by Ban

Replying to asterix:

and what does changing status message of an offline account should do? connect it? (it may have been disconnected previously and you thought it was connected for ex) or do nothing?

I don't think the status message is fully part of the status, just an additional info. Then as AFAIK it is possible to change status message of an offline account, I think the most simplest thing is to update the status of offline accounts too; but having possibility to choose to restrict the message update to a range of status could be cool too (e.g. be able to change only message of online or away accounts).

Well, when I reported this one I was trying to improve the GajimStatus? plugin of Listen because it was doing the "naive" solution I talked about. And as I have more than one Gajim account, but not necessarily all connected at the same time, the "naive" solution connects my disconnected accounts every time the playing song changes. That is, I think to can understand why, really annoying. I think that connecting accounts at status message update is neither an intuitive nor a good solution – and it doesn't give a fix to the problem I encounter.

Replying to thorstenp:

Instead of adding a new method to the API one could also allow the status parameter in change_status to be empty, so that only the status message (if possible) is changed.

Yes, this could be an easy solution. But I think it is not the best one as it doesn't allow selecting for which status update the message (what I talked about above in this message), and it doesn't seems natural to me that the change_status() call doesn't change the status at all.

Regards, Colomban

comment:4 Changed 6 years ago by asterix

You're not exactly right. In XMPP, status message is part of status. It is not possible to send a status message without a status. And no, it's not possible to change the status message of an offline account. So the solution of doing the for loop outside of Gajim is not a so bad solution I think. The other solution is to allow status to be empty and it will do the loop internally. i'll look at that

comment:5 Changed 6 years ago by Yann Leboulanger <asterix@…>

  • Milestone set to 0.14
  • Resolution set to fixed
  • Status changed from new to closed

(In [1eb1facb0e21]) allow to not specify status in gajim-remote change_status to change only status message. Fixes #5039

Note: See TracTickets for help on using tickets.