33
33
signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application
35
35
from common import exceptions
36
from common import i18n
36
from common import i18n # This installs _() function
39
39
PREFERRED_ENCODING = locale.getpreferredencoding()
117
114
'"sync with global status" option set'), False)
118
_('Changes the priority of account or accounts'),
120
(_('priority'), _('priority you want to give to the account'),
122
(_('account'), _('change the priority of the given account. '
123
'If not specified, change status of all accounts that have'
124
' "sync with global status" option set'), False)
121
128
_('Shows the chat dialog so that you can send messages to a contact'),
123
130
('jid', _('JID of the contact that you want to chat with'),
125
132
(_('account'), _('if specified, contact is taken from the '
126
'contact list of this account'), False)
133
'contact list of this account'), False),
135
_('message content. The account must be specified or ""'),
129
139
'send_chat_message':[
261
271
(_('uri'), _('URI to handle'), True),
262
272
(_('account'), _('Account in which you want to handle it'),
274
(_('message'), _('Message content'), False)
389
400
def make_arguments_row(self, args):
390
401
''' return arguments list. Mandatory arguments are enclosed with:
391
402
'<', '>', optional arguments - with '[', ']' '''
393
for argument in args:
406
s += ' <' + arg[0] + '>'
408
s += ' [' + arg[0] + ']'
406
411
def help_on_command(self, command):
407
412
''' return help message for a given command '''
408
413
if command in self.commands:
409
414
command_props = self.commands[command]
410
415
arguments_str = self.make_arguments_row(command_props[1])
411
str = _('Usage: %(basename)s %(command)s %(arguments)s \n\t %(help)s')\
416
str_ = _('Usage: %(basename)s %(command)s %(arguments)s \n\t %(help)s')\
412
417
% {'basename': BASENAME, 'command': command,
413
418
'arguments': arguments_str, 'help': command_props[0]}
414
419
if len(command_props[1]) > 0:
415
str += '\n\n' + _('Arguments:') + '\n'
420
str_ += '\n\n' + _('Arguments:') + '\n'
416
421
for argument in command_props[1]:
417
str += ' ' + argument[0] + ' - ' + argument[1] + '\n'
422
str_ += ' ' + argument[0] + ' - ' + argument[1] + '\n'
419
424
send_error(_('%s not found') % command)
421
426
def compose_help(self):
422
427
''' print usage, and list available commands '''
423
str = _('Usage: %s command [arguments]\nCommand is one of:\n' ) % BASENAME
424
commands = sorted(self.commands.keys())
425
for command in commands:
427
for argument in self.commands[command][1]:
428
s = _('Usage: %s command [arguments]\nCommand is one of:\n' ) % BASENAME
429
for command in sorted(self.commands):
431
for arg in self.commands[command][1]:
433
s += ' <' + arg[0] + '>'
435
s += ' [' + arg[0] + ']'
441
439
def print_info(self, level, prop_dict, encode_return = False):
442
440
''' return formated string from data structure '''
522
520
if not '?' in uri:
523
521
self.command = sys.argv[1] = 'open_chat'
524
# Open chat window and paste the text in the input message dialog
525
self.command = sys.argv[1] = 'open_chat'
526
message = uri.split('body=')
527
message = message[1].split(';')[0]
529
message = urllib.unquote(message)
530
except UnicodeDecodeError:
532
sys.argv[2] = uri.split('?')[0]
533
if len(sys.argv) == 4:
534
# jid in the sys.argv
535
sys.argv.append(message)
538
sys.argv.append(message)
540
sys.argv[4] = message
525
542
(jid, action) = uri.split('?', 1)
527
544
jid = urllib.unquote(jid)