Add send_groupchat_message to gajim-remote. Fix #2447.
This commit is contained in:
parent
612e468c82
commit
c09b4aaa6c
|
@ -137,6 +137,15 @@ class GajimRemote:
|
||||||
'using this account'), False),
|
'using this account'), False),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'send_groupchat_message':[
|
||||||
|
_('Sends new message to a groupchat you\'ve joined.'),
|
||||||
|
[
|
||||||
|
('room_jid', _('JID of the room that will receive the message'), True),
|
||||||
|
(_('message'), _('message contents'), True),
|
||||||
|
(_('account'), _('if specified, the message will be sent '
|
||||||
|
'using this account'), False),
|
||||||
|
]
|
||||||
|
],
|
||||||
'contact_info': [
|
'contact_info': [
|
||||||
_('Gets detailed info on a contact'),
|
_('Gets detailed info on a contact'),
|
||||||
[
|
[
|
||||||
|
|
|
@ -225,6 +225,31 @@ class SignalObject(dbus.service.Object):
|
||||||
|
|
||||||
return connected_account, contact
|
return connected_account, contact
|
||||||
|
|
||||||
|
def _get_account_for_groupchat(self, account, room_jid):
|
||||||
|
'''get the account which is connected to groupchat (if not given)
|
||||||
|
or check if the given account is connected to the groupchat'''
|
||||||
|
correct_account = None
|
||||||
|
accounts = gajim.contacts.get_accounts()
|
||||||
|
# if there is only one account in roster, take it as default
|
||||||
|
# if user did not ask for account
|
||||||
|
if not account and len(accounts) == 1:
|
||||||
|
account = accounts[0]
|
||||||
|
if account:
|
||||||
|
if gajim.connections[account].connected > 1 and \
|
||||||
|
room_jid in gajim.gc_connected[account] and \
|
||||||
|
gajim.gc_connected[account][room_jid]:
|
||||||
|
# account and groupchat are connected
|
||||||
|
connected_account = account
|
||||||
|
else:
|
||||||
|
for account in accounts:
|
||||||
|
if gajim.connections[account].connected > 1 and \
|
||||||
|
room_jid in gajim.gc_connected[account] and \
|
||||||
|
gajim.gc_connected[account][room_jid]:
|
||||||
|
# account and groupchat are connected
|
||||||
|
connected_account = account
|
||||||
|
break
|
||||||
|
return connected_account
|
||||||
|
|
||||||
@dbus.service.method(INTERFACE, in_signature='sss', out_signature='b')
|
@dbus.service.method(INTERFACE, in_signature='sss', out_signature='b')
|
||||||
def send_file(self, file_path, jid, account):
|
def send_file(self, file_path, jid, account):
|
||||||
'''send file, located at 'file_path' to 'jid', using account
|
'''send file, located at 'file_path' to 'jid', using account
|
||||||
|
@ -271,6 +296,19 @@ class SignalObject(dbus.service.Object):
|
||||||
jid = self._get_real_jid(jid, account)
|
jid = self._get_real_jid(jid, account)
|
||||||
return self._send_message(jid, message, keyID, account, type, subject)
|
return self._send_message(jid, message, keyID, account, type, subject)
|
||||||
|
|
||||||
|
@dbus.service.method(INTERFACE, in_signature='sss', out_signature='b')
|
||||||
|
def send_groupchat_message(self, room_jid, message, account):
|
||||||
|
'''Send 'message' to groupchat 'room_jid',
|
||||||
|
using account (optional) 'account'.'''
|
||||||
|
if not room_jid or not message:
|
||||||
|
return DBUS_BOOLEAN(False)
|
||||||
|
connected_account = self._get_account_for_groupchat(account, room_jid)
|
||||||
|
if connected_account:
|
||||||
|
connection = gajim.connections[connected_account]
|
||||||
|
connection.send_gc_message(room_jid, message)
|
||||||
|
return DBUS_BOOLEAN(True)
|
||||||
|
return DBUS_BOOLEAN(False)
|
||||||
|
|
||||||
@dbus.service.method(INTERFACE, in_signature='ss', out_signature='b')
|
@dbus.service.method(INTERFACE, in_signature='ss', out_signature='b')
|
||||||
def open_chat(self, jid, account):
|
def open_chat(self, jid, account):
|
||||||
'''Shows the tabbed window for new message to 'jid', using account
|
'''Shows the tabbed window for new message to 'jid', using account
|
||||||
|
|
Loading…
Reference in New Issue