Remove xmpp uri handling from gajim-remote

This commit is contained in:
Philipp Hörist 2017-12-04 17:06:24 +01:00
parent 38944331b3
commit feaf9df0cf
4 changed files with 5 additions and 121 deletions

View File

@ -19,8 +19,6 @@ by D-Bus.
.El .El
.Ss account_info Aq account .Ss account_info Aq account
Gets detailed info on a account Gets detailed info on a account
.Ss add_contact Ao jid Ac Bq account
Adds contact to roster
.Ss change_avatar Ao picture Ac Bq account .Ss change_avatar Ao picture Ac Bq account
Change the avatar Change the avatar
.Ss change_status Bo status Bc Bo message Bc Bq account .Ss change_status Bo status Bc Bo message Bc Bq account
@ -35,18 +33,12 @@ Returns current status (the global one unless account is specified)
Returns current status message (the global one unless account is specified) Returns current status message (the global one unless account is specified)
.Ss get_unread_msgs_number .Ss get_unread_msgs_number
Returns number of unread messages Returns number of unread messages
.Ss handle_uri Ao uri Ac Bo account Bc Bq message
Handle a xmpp:/ uri
.Ss help Bq command .Ss help Bq command
Shows a help on specific command Shows a help on specific command
.Ss join_room Ao room Ac Bo nick Bc Bo password Bc Bq account
Join a MUC room
.Ss list_accounts .Ss list_accounts
Prints a list of registered accounts Prints a list of registered accounts
.Ss list_contacts Bq account .Ss list_contacts Bq account
Prints a list of all contacts in the roster. Each contact appears on a separate line Prints a list of all contacts in the roster. Each contact appears on a separate line
.Ss open_chat Ao jid Ac Bo account Bc Bq message
Shows the chat dialog so that you can send messages to a contact
.Ss prefs_del Aq key .Ss prefs_del Aq key
Deletes a preference item Deletes a preference item
.Ss prefs_list .Ss prefs_list
@ -71,8 +63,6 @@ Sends custom XML
Changes the priority of account or accounts Changes the priority of account or accounts
.Ss show_next_pending_event .Ss show_next_pending_event
Pops up a window with the next pending event Pops up a window with the next pending event
.Ss start_chat Aq account
Opens 'Start Chat' dialog
.Ss toggle_ipython .Ss toggle_ipython
Shows or hides the ipython window Shows or hides the ipython window
.Ss toggle_roster_appearance .Ss toggle_roster_appearance

View File

@ -9,5 +9,4 @@ TryExec=gajim-remote
StartupNotify=false StartupNotify=false
Terminal=false Terminal=false
Type=Application Type=Application
MimeType=x-scheme-handler/xmpp;
NoDisplay=true NoDisplay=true

View File

@ -13,3 +13,4 @@ StartupNotify=true
StartupWMClass=Gajim StartupWMClass=Gajim
Terminal=false Terminal=false
Type=Application Type=Application
MimeType=x-scheme-handler/xmpp;

View File

@ -125,18 +125,6 @@ class GajimRemote:
' "sync with global status" option set'), False) ' "sync with global status" option set'), False)
] ]
], ],
'open_chat': [
_('Shows the chat dialog so that you can send messages to a contact'),
[
('jid', _('JID of the contact that you want to chat with'),
True),
(Q_('?CLI:account'), _('if specified, contact is taken from the '
'contact list of this account'), False),
(Q_('?CLI:message'),
_('message content. The account must be specified or ""'),
False)
]
],
'send_chat_message': [ 'send_chat_message': [
_('Sends new chat 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\', ' 'and account are optional. If you want to set only \'account\', '
@ -225,13 +213,6 @@ class GajimRemote:
] ]
], ],
'add_contact': [
_('Adds contact to roster'),
[
(_('jid'), _('JID of the contact'), True),
(Q_('?CLI:account'), _('Adds new contact to this account'), False)
]
],
'get_status': [ 'get_status': [
_('Returns current status (the global one unless account is specified)'), _('Returns current status (the global one unless account is specified)'),
@ -251,12 +232,7 @@ class GajimRemote:
_('Returns number of unread messages'), _('Returns number of unread messages'),
[ ] [ ]
], ],
'start_chat': [
_('Opens \'Start Chat\' dialog'),
[
(Q_('?CLI:account'), _('Starts chat, using this account'), True)
]
],
'send_xml': [ 'send_xml': [
_('Sends custom XML'), _('Sends custom XML'),
[ [
@ -275,25 +251,7 @@ class GajimRemote:
False) False)
] ]
], ],
'handle_uri': [
_('Handle a xmpp:/ URI'),
[
(Q_('?CLI:uri'), _('URI to handle'), True),
(Q_('?CLI:account'), _('Account in which you want to handle it'),
False),
(Q_('?CLI:message'), _('Message content'), False)
]
],
'join_room': [
_('Join a MUC room'),
[
(Q_('?CLI:room'), _('Room JID'), True),
(Q_('?CLI:nick'), _('Nickname to use'), False),
(Q_('?CLI:password'), _('Password to enter the room'), False),
(Q_('?CLI:account'), _('Account from which you want to enter the '
'room'), False)
]
],
'check_gajim_running': [ 'check_gajim_running': [
_('Check if Gajim is running'), _('Check if Gajim is running'),
[] []
@ -317,8 +275,6 @@ class GajimRemote:
else: else:
print(self.compose_help().encode(PREFERRED_ENCODING)) print(self.compose_help().encode(PREFERRED_ENCODING))
sys.exit(0) sys.exit(0)
if self.command == 'handle_uri':
self.handle_uri()
if self.command == 'check_gajim_running': if self.command == 'check_gajim_running':
print(self.check_gajim_running()) print(self.check_gajim_running())
sys.exit(0) sys.exit(0)
@ -342,10 +298,8 @@ class GajimRemote:
Print retrieved result to the output Print retrieved result to the output
""" """
if res is not None: if res is not None:
if self.command in ('open_chat', 'send_chat_message', if self.command in ('send_chat_message', 'send_single_message'):
'send_single_message', 'start_chat'): self.argv_len -= 2
if self.command in ('send_message', 'send_single_message'):
self.argv_len -= 2
if res is False: if res is False:
if self.argv_len < 4: if self.argv_len < 4:
@ -533,66 +487,6 @@ class GajimRemote:
# add empty string for missing args # add empty string for missing args
self.arguments += ['']*(len(args)-i) self.arguments += ['']*(len(args)-i)
def handle_uri(self):
if len(sys.argv) < 3:
send_error(_('No URI given'))
if not sys.argv[2].startswith('xmpp:'):
send_error(_('Wrong URI'))
sys.argv[2] = sys.argv[2][5:]
uri = sys.argv[2]
if not '?' in uri:
self.command = sys.argv[1] = 'open_chat'
return
jid, args = uri.split('?', 1)
try:
jid = urllib.parse.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'
sys.argv[2] = jid
if 'body' in options:
# Open chat window and paste the text in the input message
# dialog
message = options['body']
try:
message = urllib.parse.unquote(message)
except UnicodeDecodeError:
pass
if len(sys.argv) == 4:
# jid in the sys.argv
sys.argv.append(message)
else:
sys.argv.append('')
sys.argv.append(message)
sys.argv[3] = ''
sys.argv[4] = message
return
sys.argv[2] = jid
if action == 'join':
self.command = sys.argv[1] = 'join_room'
# Move account parameter from position 3 to 5
sys.argv.append('')
sys.argv.append(sys.argv[3])
sys.argv[3] = ''
return
if action == 'roster':
# Add contact to roster
self.command = sys.argv[1] = 'add_contact'
return
sys.exit(0)
def call_remote_method(self): def call_remote_method(self):
""" """
Calls self.method with arguments from sys.argv[2:] Calls self.method with arguments from sys.argv[2:]