'send_message' and 'open_chat' with jid not in
the roster (if multiple accounts) sends error
This commit is contained in:
parent
8d7dac3553
commit
0bde1f52ef
2 changed files with 42 additions and 17 deletions
|
@ -112,11 +112,11 @@ list of this account'), False)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'send_message':[
|
'send_message':[
|
||||||
_('Send new message to a contact in the roster'),
|
_('Send new message to a contact in the roster. Both pgp key and account are optional. If you want to set only \'account\', whitout \'pgp key\', just set \'pgp key\' to \'\'.'),
|
||||||
[
|
[
|
||||||
('jid', _('jid of the contact that will receive the message'), True),
|
('jid', _('jid of the contact that will receive the message'), True),
|
||||||
(_('message'), _('message contents'), True),
|
(_('message'), _('message contents'), True),
|
||||||
(_('keyID'), _('if specified the message will be encrypted using \
|
(_('pgp key'), _('if specified the message will be encrypted using \
|
||||||
this pulic key'), False),
|
this pulic key'), False),
|
||||||
(_('account'), _('if specified the message will be sent using this account'), False),
|
(_('account'), _('if specified the message will be sent using this account'), False),
|
||||||
]
|
]
|
||||||
|
@ -222,6 +222,8 @@ def call_remote_method(method):
|
||||||
res = method(sys.argv[2], sys.argv[3])
|
res = method(sys.argv[2], sys.argv[3])
|
||||||
elif argv_len == 5:
|
elif argv_len == 5:
|
||||||
res = method(sys.argv[2], sys.argv[3], sys.argv[4])
|
res = method(sys.argv[2], sys.argv[3], sys.argv[4])
|
||||||
|
elif argv_len == 6:
|
||||||
|
res = method(sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
|
||||||
return res
|
return res
|
||||||
except:
|
except:
|
||||||
send_error(_('Service not available'))
|
send_error(_('Service not available'))
|
||||||
|
@ -271,9 +273,19 @@ if command == 'contact_info':
|
||||||
|
|
||||||
res = call_remote_method(method)
|
res = call_remote_method(method)
|
||||||
|
|
||||||
|
if res is not None:
|
||||||
if res:
|
if command in ['open_chat', 'send_message']:
|
||||||
print res
|
if command == 'send_message':
|
||||||
|
argv_len -= 2
|
||||||
|
|
||||||
|
if res == False:
|
||||||
|
if argv_len < 4:
|
||||||
|
send_error(_('\'%s\' is not in your roster.\n\
|
||||||
|
Please specify account for sending the message.') % sys.argv[2])
|
||||||
|
else:
|
||||||
|
send_error(_('You have no active account'))
|
||||||
|
elif res is True:
|
||||||
|
print res
|
||||||
|
|
||||||
if command == 'contact_info':
|
if command == 'contact_info':
|
||||||
gobject.timeout_add(5000, gtk_quit) # wait 5 sec maximum
|
gobject.timeout_add(5000, gtk_quit) # wait 5 sec maximum
|
||||||
|
|
|
@ -130,11 +130,16 @@ class SignalObject(DbusPrototype):
|
||||||
if not keyID:
|
if not keyID:
|
||||||
keyID = ''
|
keyID = ''
|
||||||
connected_account = None
|
connected_account = None
|
||||||
if account and \
|
accounts = gajim.contacts.keys()
|
||||||
gajim.connections[account].connected > 1: # account is online
|
|
||||||
connected_account = gajim.connections[account]
|
# if there is only one account in roster, take it as default
|
||||||
|
if not account and len(accounts) == 1:
|
||||||
|
account = accounts[0]
|
||||||
|
if account:
|
||||||
|
if gajim.connections[account].connected > 1: # account is online
|
||||||
|
connected_account = gajim.connections[account]
|
||||||
else:
|
else:
|
||||||
for account in gajim.contacts.keys():
|
for account in accounts:
|
||||||
if gajim.contacts[account].has_key(jid) and \
|
if gajim.contacts[account].has_key(jid) and \
|
||||||
gajim.connections[account].connected > 1: # account is online
|
gajim.connections[account].connected > 1: # account is online
|
||||||
connected_account = gajim.connections[account]
|
connected_account = gajim.connections[account]
|
||||||
|
@ -157,22 +162,30 @@ class SignalObject(DbusPrototype):
|
||||||
accounts = [account]
|
accounts = [account]
|
||||||
else:
|
else:
|
||||||
accounts = gajim.connections.keys()
|
accounts = gajim.connections.keys()
|
||||||
|
if len(accounts) == 1:
|
||||||
|
account = accounts[0]
|
||||||
connected_account = None
|
connected_account = None
|
||||||
for account in accounts:
|
for acct in accounts:
|
||||||
if self.plugin.windows[account]['chats'].has_key(jid) and \
|
if gajim.connections[acct].connected > 1: # account is online
|
||||||
gajim.connections[account].connected > 1: # account is online
|
if self.plugin.windows[acct]['chats'].has_key(jid):
|
||||||
connected_account = account
|
connected_account = acct
|
||||||
break
|
|
||||||
elif gajim.connections[account].connected > 1: # account is online
|
|
||||||
connected_account = account
|
|
||||||
if gajim.contacts[account].has_key(jid):
|
|
||||||
break
|
break
|
||||||
|
# jid is in roster
|
||||||
|
elif gajim.contacts[acct].has_key(jid):
|
||||||
|
connected_account = acct
|
||||||
|
break
|
||||||
|
# we send the message to jid not in roster, because account is specified,
|
||||||
|
# or there is only one account
|
||||||
|
elif account:
|
||||||
|
connected_account = acct
|
||||||
if connected_account:
|
if connected_account:
|
||||||
self.plugin.roster.new_chat_from_jid(connected_account, jid)
|
self.plugin.roster.new_chat_from_jid(connected_account, jid)
|
||||||
# preserve the 'steal focus preservation'
|
# preserve the 'steal focus preservation'
|
||||||
win = self.plugin.windows[connected_account]['chats'][jid].window
|
win = self.plugin.windows[connected_account]['chats'][jid].window
|
||||||
if win.get_property('visible'):
|
if win.get_property('visible'):
|
||||||
win.window.focus()
|
win.window.focus()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def change_status(self, *args, **keywords):
|
def change_status(self, *args, **keywords):
|
||||||
''' change_status(status, message, account). account is optional -
|
''' change_status(status, message, account). account is optional -
|
||||||
|
|
Loading…
Add table
Reference in a new issue