[maciekp] Send single message with gajim-remote, fixes #2026.
This commit is contained in:
parent
f757025e85
commit
42d74e39fa
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue