From ff7aa9b7658ae2aa62955296c44b4275c64cfcc5 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 28 Dec 2005 21:15:48 +0000 Subject: [PATCH] gajim-remote now has get_status_message --- src/common/helpers.py | 12 ++++++++++++ src/gajim-remote.py | 8 +++++++- src/remote_control.py | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/common/helpers.py b/src/common/helpers.py index eac8be05a..75fc10ef3 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -496,6 +496,18 @@ def get_global_show(): if connected > maxi: maxi = connected return gajim.SHOW_LIST[maxi] + +def get_global_status(): + maxi = 0 + for account in gajim.connections: + if not gajim.config.get_per('accounts', account, + 'sync_with_global_status'): + continue + connected = gajim.connections[account].connected + if connected > maxi: + maxi = connected + status = gajim.connections[account].status + return status def get_icon_name_to_show(contact, account = None): '''Get the icon name to show in online, away, requested, ...''' diff --git a/src/gajim-remote.py b/src/gajim-remote.py index 9dbe566d1..cc22e2ca7 100755 --- a/src/gajim-remote.py +++ b/src/gajim-remote.py @@ -196,7 +196,13 @@ class GajimRemote: (_('account'), _(''), False) ] ], - + + 'get_status_message': [ + _('Returns current status message(the global one unless account is specified)'), + [ + (_('account'), _(''), False) + ] + ], } if self.argv_len < 2 or \ sys.argv[1] not in self.commands.keys(): # no args or bad args diff --git a/src/remote_control.py b/src/remote_control.py index d1ddcce0c..e6bb2a777 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -107,6 +107,7 @@ class SignalObject(DbusPrototype): self.add_contact, self.remove_contact, self.get_status, + self.get_status_message, ]) def raise_signal(self, signal, arg): @@ -137,6 +138,20 @@ class SignalObject(DbusPrototype): # return show for the given account index = gajim.connections[account].connected return STATUS_LIST[index] + + def get_status_message(self, *args): + '''get_status(account = None) + returns status which is the global one + unless account is given''' + account = self._get_real_arguments(args, 1)[0] + accounts = gajim.contacts.keys() + if not account: + # If user did not ask for account, returns the global status + return str(helpers.get_global_status()) + # return show for the given account + status = gajim.connections[account].status + return str(status) + def send_file(self, *args): '''send_file(file_path, jid, account=None) @@ -488,3 +503,4 @@ class SignalObject(DbusPrototype): remove_contact = method(INTERFACE)(remove_contact) add_contact = method(INTERFACE)(add_contact) get_status = method(INTERFACE)(get_status) + get_status_message = method(INTERFACE)(get_status_message)