gajim-remote handles ?message in URIs. Fixes #6804, see #2133

Patch based on joeka's one in #6804
This commit is contained in:
Yann Leboulanger 2012-10-04 17:52:28 +02:00
parent f801ecab11
commit b44f13dfca
1 changed files with 33 additions and 21 deletions

View File

@ -544,16 +544,33 @@ class GajimRemote:
if not '?' in uri: if not '?' in uri:
self.command = sys.argv[1] = 'open_chat' self.command = sys.argv[1] = 'open_chat'
return return
if 'body=' in uri: jid, args = uri.split('?', 1)
# Open chat window and paste the text in the input message dialog try:
jid = urllib.unquote(jid)
except UnicodeDecodeError:
pass
args = args.split(';')
action = None
options = {}
if args:
action = args[0]
for arg in args[1:]:
opt = arg.split('=', 1)
if len(opt) != 2:
continue
options[opt[0]] = opt[1]
if action == 'message':
self.command = sys.argv[1] = 'open_chat' self.command = sys.argv[1] = 'open_chat'
message = uri.split('body=') sys.argv[2] = jid
message = message[1].split(';')[0] if 'body' in options:
# Open chat window and paste the text in the input message
# dialog
message = options['body']
try: try:
message = urllib.unquote(message) message = urllib.unquote(message)
except UnicodeDecodeError: except UnicodeDecodeError:
pass pass
sys.argv[2] = uri.split('?')[0]
if len(sys.argv) == 4: if len(sys.argv) == 4:
# jid in the sys.argv # jid in the sys.argv
sys.argv.append(message) sys.argv.append(message)
@ -563,11 +580,6 @@ class GajimRemote:
sys.argv[3] = '' sys.argv[3] = ''
sys.argv[4] = message sys.argv[4] = message
return return
(jid, action) = uri.split('?', 1)
try:
jid = urllib.unquote(jid)
except UnicodeDecodeError:
pass
sys.argv[2] = jid sys.argv[2] = jid
if action == 'join': if action == 'join':
self.command = sys.argv[1] = 'join_room' self.command = sys.argv[1] = 'join_room'
@ -576,7 +588,7 @@ class GajimRemote:
sys.argv.append(sys.argv[3]) sys.argv.append(sys.argv[3])
sys.argv[3] = '' sys.argv[3] = ''
return return
if action.startswith('roster'): if action == 'roster':
# Add contact to roster # Add contact to roster
self.command = sys.argv[1] = 'add_contact' self.command = sys.argv[1] = 'add_contact'
return return