Changeset 9306
- Timestamp:
- 02/05/08 23:13:16 (10 months ago)
- Files:
-
- 1 modified
-
trunk/src/gajim-remote.py (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gajim-remote.py
r8972 r9306 60 60 61 61 def __init__(self): 62 self.argv_len = len(sys.argv) 62 self.argv_len = len(sys.argv) 63 63 # define commands dict. Prototype : 64 64 # { … … 74 74 [ 75 75 #User gets help for the command, specified by this parameter 76 (_('command'), 76 (_('command'), 77 77 _('show help on command'), False) 78 78 ] 79 ], 79 ], 80 80 'toggle_roster_appearance' : [ 81 81 _('Shows or hides the roster window'), 82 82 [] 83 ], 83 ], 84 84 'show_next_pending_event': [ 85 85 _('Pops up a window with the next pending event'), … … 94 94 ] 95 95 96 ], 96 ], 97 97 'list_accounts': [ 98 98 _('Prints a list of registered accounts'), 99 99 [] 100 ], 100 ], 101 101 'change_status': [ 102 102 _('Changes the status of account or accounts'), 103 103 [ 104 104 #offline, online, chat, away, xa, dnd, invisible should not be translated 105 (_('status'), _('one of: offline, online, chat, away, xa, dnd, invisible '), True), 106 (_('message'), _('status message'), False), 105 (_('status'), _('one of: offline, online, chat, away, xa, dnd, invisible '), True), 106 (_('message'), _('status message'), False), 107 107 (_('account'), _('change status of account "account". ' 108 108 'If not specified, try to change status of all accounts that have ' … … 110 110 ] 111 111 ], 112 'open_chat': [ 113 _('Shows the chat dialog so that you can send messages to a contact'), 112 'open_chat': [ 113 _('Shows the chat dialog so that you can send messages to a contact'), 114 114 [ 115 115 ('jid', _('JID of the contact that you want to chat with'), 116 True), 116 True), 117 117 (_('account'), _('if specified, contact is taken from the ' 118 118 'contact list of this account'), False) … … 122 122 _('Sends new chat message to a contact in the roster. Both OpenPGP key ' 123 123 'and account are optional. If you want to set only \'account\', ' 124 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'), 124 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'), 125 125 [ 126 126 ('jid', _('JID of the contact that will receive the message'), True), … … 135 135 _('Sends new single message to a contact in the roster. Both OpenPGP key ' 136 136 'and account are optional. If you want to set only \'account\', ' 137 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'), 137 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'), 138 138 [ 139 139 ('jid', _('JID of the contact that will receive the message'), True), … … 145 145 'using this account'), False), 146 146 ] 147 ], 147 ], 148 148 'send_groupchat_message':[ 149 _('Sends new message to a groupchat you\'ve joined.'), 149 _('Sends new message to a groupchat you\'ve joined.'), 150 150 [ 151 151 ('room_jid', _('JID of the room that will receive the message'), True), … … 156 156 ], 157 157 'contact_info': [ 158 _('Gets detailed info on a contact'), 158 _('Gets detailed info on a contact'), 159 159 [ 160 160 ('jid', _('JID of the contact'), True) … … 162 162 ], 163 163 'account_info': [ 164 _('Gets detailed info on a account'), 164 _('Gets detailed info on a account'), 165 165 [ 166 166 ('account', _('Name of the account'), True) … … 189 189 'prefs_del': [ 190 190 _('Deletes a preference item'), 191 [ 192 (_('key'), _('name of the preference to be deleted'), True) 191 [ 192 (_('key'), _('name of the preference to be deleted'), True) 193 193 ] 194 194 ], … … 200 200 'remove_contact': [ 201 201 _('Removes contact from roster'), 202 [ 202 [ 203 203 ('jid', _('JID of the contact'), True), 204 204 (_('account'), _('if specified, contact is taken from the ' … … 209 209 'add_contact': [ 210 210 _('Adds contact to roster'), 211 [ 211 [ 212 212 (_('jid'), _('JID of the contact'), True), 213 213 (_('account'), _('Adds new contact to this account'), False) … … 227 227 (_('account'), _(''), False) 228 228 ] 229 ], 229 ], 230 230 231 231 'get_unread_msgs_number': [ … … 240 240 ], 241 241 'send_xml': [ 242 _('Sends custom XML'), 242 _('Sends custom XML'), 243 243 [ 244 244 ('xml', _('XML to send'), True), … … 264 264 ] 265 265 ], 266 'check_gajim_running':[ 267 _('Check if Gajim is running'), 268 [] 269 ], 266 270 267 271 } 272 self.sbus = None 268 273 if self.argv_len < 2 or \ 269 274 sys.argv[1] not in self.commands.keys(): # no args or bad args … … 278 283 if self.command == 'handle_uri': 279 284 self.handle_uri() 285 if self.command == 'check_gajim_running': 286 print self.check_gajim_running() 287 sys.exit(0) 280 288 self.init_connection() 281 289 self.check_arguments() … … 324 332 for pref_key in pref_keys: 325 333 result = '%s = %s' % (pref_key, res[pref_key]) 326 if isinstance(result, unicode): 334 if isinstance(result, unicode): 327 335 print result.encode(PREFERRED_ENCODING) 328 336 else: … … 333 341 print unicode(res).encode(PREFERRED_ENCODING) 334 342 343 def check_gajim_running(self): 344 if not self.sbus: 345 try: 346 self.sbus = dbus.SessionBus() 347 except: 348 raise exceptions.SessionBusNotPresent 349 350 test = False 351 if hasattr(self.sbus, 'name_has_owner'): 352 if self.sbus.name_has_owner(SERVICE): 353 test = True 354 elif dbus.dbus_bindings.bus_name_has_owner(self.sbus.get_connection(), 355 SERVICE): 356 test = True 357 return test 358 335 359 def init_connection(self): 336 360 ''' create the onnection to the session dbus, … … 341 365 raise exceptions.SessionBusNotPresent 342 366 367 if not self.check_gajim_running(): 368 send_error(_('It seems Gajim is not running. So you can\'t use gajim-remote.')) 343 369 obj = self.sbus.get_object(SERVICE, OBJ_PATH) 344 370 interface = dbus.Interface(obj, INTERFACE) … … 369 395 command_props = self.commands[command] 370 396 arguments_str = self.make_arguments_row(command_props[1]) 371 str = _('Usage: %s %s %s \n\t %s') % (BASENAME, command, 397 str = _('Usage: %s %s %s \n\t %s') % (BASENAME, command, 372 398 arguments_str, command_props[0]) 373 399 if len(command_props[1]) > 0: … … 384 410 commands.sort() 385 411 for command in commands: 386 str += ' ' + command 412 str += ' ' + command 387 413 for argument in self.commands[command][1]: 388 414 str += ' ' … … 458 484 if args[argv_len][2]: 459 485 send_error(_('Argument "%s" is not specified. \n' 460 'Type "%s help %s" for more info') % 486 'Type "%s help %s" for more info') % 461 487 (args[argv_len][0], BASENAME, self.command)) 462 488 self.arguments = [] … … 486 512 self.command = sys.argv[1] = 'join_room' 487 513 return 488 514 489 515 sys.exit(0) 490 516
