Philipp Hörist pushed to branch master at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/common/client.py
    ... ... @@ -35,6 +35,7 @@ from gajim.common.helpers import get_encryption_method
    35 35
     from gajim.common.helpers import get_custom_host
    
    36 36
     from gajim.common.helpers import get_user_proxy
    
    37 37
     from gajim.common.helpers import warn_about_plain_connection
    
    38
    +from gajim.common.helpers import get_resource
    
    38 39
     
    
    39 40
     from gajim.common.connection_handlers import ConnectionHandlers
    
    40 41
     from gajim.common.connection_handlers_events import OurShowEvent
    
    ... ... @@ -116,7 +117,7 @@ class Client(ConnectionHandlers):
    116 117
             self.connection = self._client
    
    117 118
             self._client.set_domain(self._hostname)
    
    118 119
             self._client.set_username(self._user)
    
    119
    -        self._client.set_resource('test')
    
    120
    +        self._client.set_resource(get_resource(self._account))
    
    120 121
     
    
    121 122
             custom_host = get_custom_host(self._account)
    
    122 123
             if custom_host is not None:
    

  • gajim/common/helpers.py
    ... ... @@ -1565,14 +1565,15 @@ def geo_provider_from_location(lat, lon):
    1565 1565
     
    
    1566 1566
     def get_resource(account):
    
    1567 1567
         resource = app.config.get_per('accounts', account, 'resource')
    
    1568
    -    # All valid resource substitution strings should be added to this hash.
    
    1569
    -    if resource:
    
    1570
    -        rand = ''.join(random.choice(
    
    1571
    -            string.ascii_uppercase + string.digits) for _ in range(8))
    
    1572
    -        resource = Template(resource).safe_substitute(
    
    1573
    -            {'hostname': socket.gethostname(),
    
    1574
    -             'rand': rand})
    
    1575
    -        app.config.set_per('accounts', account, 'resource', resource)
    
    1568
    +    if not resource:
    
    1569
    +        return None
    
    1570
    +
    
    1571
    +    rand = ''.join(random.choice(
    
    1572
    +        string.ascii_uppercase + string.digits) for _ in range(8))
    
    1573
    +    resource = Template(resource).safe_substitute(
    
    1574
    +        {'hostname': socket.gethostname(),
    
    1575
    +         'rand': rand})
    
    1576
    +    app.config.set_per('accounts', account, 'resource', resource)
    
    1576 1577
         return resource
    
    1577 1578
     
    
    1578 1579