Changeset 7748

Show
Ignore:
Timestamp:
01/02/07 03:45:43 (23 months ago)
Author:
asterix
Message:

[misc] handle uri like room_jid?join. see #2133

Location:
trunk/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gajim-remote.py

    r7706 r7748  
    229229                                        ] 
    230230                                ], 
     231                        'handle_uri': [ 
     232                                        _('Handle a xmpp:/ uri'), 
     233                                        [ 
     234                                                (_('uri'), _(''), True), 
     235                                                (_('account'), _(''), False) 
     236                                        ] 
     237                                ], 
     238                        'join_room': [ 
     239                                        _('Join a MUC room'), 
     240                                        [ 
     241                                                (_('room'), _(''), True), 
     242                                                (_('nick'), _(''), False), 
     243                                                (_('password'), _(''), False), 
     244                                                (_('account'), _(''), False) 
     245                                        ] 
     246                                ], 
     247 
    231248                        } 
    232249                if self.argv_len  < 2 or \ 
     
    240257                                print self.compose_help().encode(PREFERRED_ENCODING) 
    241258                        sys.exit(0) 
    242  
     259                if self.command == 'handle_uri': 
     260                        self.handle_uri() 
    243261                self.init_connection() 
    244262                self.check_arguments() 
     
    421439                                        (args[argv_len][0], BASENAME, self.command)) 
    422440 
     441        def handle_uri(self): 
     442                if not sys.argv[2:][0].startswith('xmpp:'): 
     443                        send_error(_('Wrong uri')) 
     444                sys.argv[2] = sys.argv[2][5:] 
     445                uri = sys.argv[2:][0] 
     446                if not '?' in uri: 
     447                        self.command = sys.argv[1] = 'open_chat' 
     448                        return 
     449                (jid, action) = uri.split('?', 1) 
     450                sys.argv[2] = jid 
     451                if action == 'join': 
     452                        self.command = sys.argv[1] = 'join_room' 
     453                        return 
     454                         
     455                sys.exit(0) 
     456 
    423457        def call_remote_method(self): 
    424458                ''' calls self.method with arguments from sys.argv[2:] ''' 
  • trunk/src/gtkgui_helpers.py

    r7712 r7748  
    666666        if path_to_gajim_script: 
    667667                if typ == 'svn': 
    668                         command = path_to_gajim_script + ' open_chat %s' 
     668                        command = path_to_gajim_script + ' handle_uri %s' 
    669669                else: # 'installed' 
    670                         command = 'gajim-remote open_chat %s' 
     670                        command = 'gajim-remote handle_uri %s' 
    671671                 
    672672                # setting for GNOME/Gconf 
  • trunk/src/remote_control.py

    r7714 r7748  
    2222from common import helpers 
    2323from time import time 
    24 from dialogs import AddNewContactWindow, NewChatDialog 
     24from dialogs import AddNewContactWindow, NewChatDialog, JoinGroupchatWindow 
    2525 
    2626from common import dbus_support 
     
    632632                        for acc in gajim.contacts.get_accounts(): 
    633633                                gajim.connections[acc].send_stanza(xml) 
     634 
     635        @dbus.service.method(INTERFACE) 
     636        def join_room(self, *args): 
     637                room_jid, nick, passwd, account = self._get_real_arguments(args, 4) 
     638                if not account: 
     639                        # get the first connected account 
     640                        accounts = gajim.connections.keys() 
     641                        for acct in accounts: 
     642                                if gajim.account_is_connected(acct): 
     643                                        account = acct 
     644                                        break 
     645                        if not account: 
     646                                account = gajim.contacts.get_accounts()[0] 
     647                print account 
     648                if nick is None: 
     649                        nick = '' 
     650                        gajim.interface.instances[account]['join_gc'] = \ 
     651                                        JoinGroupchatWindow(account, room_jid, nick) 
     652                else: 
     653                        gajim.connections[account].join_gc(nick, room_jid, password)