Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

1 changed file:

Changes:

  • nbxmpp/protocol.py
    ... ... @@ -57,7 +57,7 @@ NS_CHATMARKERS = 'urn:xmpp:chat-markers:0' # XEP-0333
    57 57
     NS_CHATSTATES     = 'http://jabber.org/protocol/chatstates'           # XEP-0085
    
    58 58
     NS_CHATTING       = 'http://jabber.org/protocol/chatting'             # XEP-0194
    
    59 59
     NS_CLIENT         = 'jabber:client'
    
    60
    -NS_CONDITIONS     = 'urn:xmpp:muc:conditions:0'                       # XEP-0306
    
    60
    +NS_CONDITIONS     = 'urn:xmpp:muc:conditions:1'                       # XEP-0306
    
    61 61
     NS_COMMANDS       = 'http://jabber.org/protocol/commands'
    
    62 62
     NS_COMPONENT_ACCEPT = 'jabber:component:accept'
    
    63 63
     NS_COMPONENT_1    = 'http://jabberd.jabberstudio.org/ns/component/1.0'
    
    ... ... @@ -473,6 +473,28 @@ _errorcodes = {
    473 473
         'cancel': 'invalid-from'
    
    474 474
     }
    
    475 475
     
    
    476
    +_status_conditions = {
    
    477
    +    'realjid-public': 100,
    
    478
    +    'affiliation-changed': 101,
    
    479
    +    'unavailable-shown': 102,
    
    480
    +    'unavailable-not-shown': 103,
    
    481
    +    'configuration-changed': 104,
    
    482
    +    'self-presence': 110,
    
    483
    +    'logging-enabled': 170,
    
    484
    +    'logging-disabled': 171,
    
    485
    +    'non-anonymous': 172,
    
    486
    +    'semi-anonymous': 173,
    
    487
    +    'fully-anonymous': 174,
    
    488
    +    'room-created': 201,
    
    489
    +    'nick-assigned': 210,
    
    490
    +    'banned': 301,
    
    491
    +    'new-nick': 303,
    
    492
    +    'kicked': 307,
    
    493
    +    'removed-affiliation': 321,
    
    494
    +    'removed-membership': 322,
    
    495
    +    'removed-shutdown': 332,
    
    496
    +}
    
    497
    +
    
    476 498
     STREAM_NOT_AUTHORIZED = 'urn:ietf:params:xml:ns:xmpp-streams not-authorized'
    
    477 499
     STREAM_REMOTE_CONNECTION_FAILED = 'urn:ietf:params:xml:ns:xmpp-streams remote-connection-failed'
    
    478 500
     SASL_MECHANISM_TOO_WEAK = 'urn:ietf:params:xml:ns:xmpp-sasl mechanism-too-weak'
    
    ... ... @@ -939,16 +961,21 @@ class Protocol(Node):
    939 961
             """
    
    940 962
             return self.getTagAttr('error', 'code')
    
    941 963
     
    
    942
    -    def getStatusConditions(self):
    
    964
    +    def getStatusConditions(self, as_code=False):
    
    943 965
             """
    
    944 966
             Return the status conditions list as defined in XEP-0306.
    
    945 967
             """
    
    946
    -        conds = []
    
    947
    -        condtag = self.getTag('conditions', namespace=NS_CONDITIONS)
    
    948
    -        if condtag:
    
    949
    -            for tag in condtag.getChildren():
    
    950
    -                conds.append(tag.getName())
    
    951
    -        return conds
    
    968
    +        result = set()
    
    969
    +        status_tags = self.getTags('status')
    
    970
    +        for status in status_tags:
    
    971
    +            if as_code:
    
    972
    +                code = status.getAttr('code')
    
    973
    +                if code is not None:
    
    974
    +                    result.add(code)
    
    975
    +            else:
    
    976
    +                for condition in status.getChildren():
    
    977
    +                    result.add(condition.getName())
    
    978
    +        return list(result)
    
    952 979
     
    
    953 980
         def setError(self, error, code=None):
    
    954 981
             """