From 42d74e39fa6e5e49eabf09b86838c5affcbb05fe Mon Sep 17 00:00:00 2001 From: Jean-Marie Traissard <jim@lapin.org> Date: Fri, 16 Jun 2006 16:09:46 +0000 Subject: [PATCH] [maciekp] Send single message with gajim-remote, fixes #2026. --- src/gajim-remote.py | 20 +++++++++++++++++--- src/remote_control.py | 24 +++++++++++++++++++++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/gajim-remote.py b/src/gajim-remote.py index 03e64f1f14..0c241db646 100755 --- a/src/gajim-remote.py +++ b/src/gajim-remote.py @@ -126,7 +126,7 @@ class GajimRemote: ] ], 'send_message':[ - _('Sends new message to a contact in the roster. Both OpenPGP key ' + _('Sends new chat message to a contact in the roster. Both OpenPGP key ' 'and account are optional. If you want to set only \'account\', ' 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'), [ @@ -137,6 +137,20 @@ class GajimRemote: (_('account'), _('if specified, the message will be sent ' 'using this account'), False), ] + ], + 'send_single_message':[ + _('Sends new single message to a contact in the roster. Both OpenPGP key ' + 'and account are optional. If you want to set only \'account\', ' + 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'), + [ + ('jid', _('JID of the contact that will receive the message'), True), + (_('subject'), _('message subject'), True), + (_('message'), _('message contents'), True), + (_('pgp key'), _('if specified, the message will be encrypted ' + 'using this public key'), False), + (_('account'), _('if specified, the message will be sent ' + 'using this account'), False), + ] ], 'contact_info': [ _('Gets detailed info on a contact'), @@ -252,8 +266,8 @@ class GajimRemote: def print_result(self, res): ''' Print retrieved result to the output ''' if res is not None: - if self.command in ('open_chat', 'send_message', 'start_chat'): - if self.command == 'send_message': + if self.command in ('open_chat', 'send_message', 'send_single_message', 'start_chat'): + if self.command in ('send_message', 'send_single_message'): self.argv_len -= 2 if res is False: diff --git a/src/remote_control.py b/src/remote_control.py index 8d57c411bd..44f6a04e1a 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -159,6 +159,7 @@ class SignalObject(DbusPrototype): self.change_status, self.open_chat, self.send_message, + self.send_single_message, self.contact_info, self.send_file, self.prefs_list, @@ -251,7 +252,7 @@ class SignalObject(DbusPrototype): def send_message(self, *args): ''' send_message(jid, message, keyID=None, account=None) - send 'message' to 'jid', using account (optional) 'account'. + send chat 'message' to 'jid', using account (optional) 'account'. if keyID is specified, encrypt the message with the pgp key ''' jid, message, keyID, account = self._get_real_arguments(args, 4) if not jid or not message: @@ -267,6 +268,26 @@ class SignalObject(DbusPrototype): return True return False + def send_single_message(self, *args): + ''' send_single_message(jid, subject, message, keyID=None, account=None) + send single 'message' to 'jid', using account (optional) 'account'. + if keyID is specified, encrypt the message with the pgp key ''' + jid, subject, message, keyID, account = self._get_real_arguments(args, 5) + if not jid or not message: + return None # or raise error + if not keyID: + keyID = '' + + connected_account, contact = self.get_account_and_contact(account, jid) + + if connected_account: + connection = gajim.connections[connected_account] + res = connection.send_message(jid, message, keyID, + type='normal', + subject=subject) + return True + return False + def open_chat(self, *args): ''' start_chat(jid, account=None) -> shows the tabbed window for new message to 'jid', using account(optional) 'account' ''' @@ -578,6 +599,7 @@ class SignalObject(DbusPrototype): open_chat = method(INTERFACE)(open_chat) contact_info = method(INTERFACE)(contact_info) send_message = method(INTERFACE)(send_message) + send_single_message = method(INTERFACE)(send_single_message) send_file = method(INTERFACE)(send_file) prefs_list = method(INTERFACE)(prefs_list) prefs_put = method(INTERFACE)(prefs_put) -- GitLab