Changeset 116:66d9a0b47016


Ignore:
Timestamp:
Oct 17, 2008, 12:14:32 AM (13 years ago)
Author:
Christopher Zorn <tofu@…>
Branch:
wokkel-muc-client-support-24
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/branches/wokkel-muc-client-support-24@110
Message:

change namespaces to be consistent

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/muc.py

    r115 r116  
    2323
    2424# Multi User Chat namespaces
    25 NS          = 'http://jabber.org/protocol/muc'
    26 NS_USER     = NS + '#user'
    27 NS_ADMIN    = NS + '#admin'
    28 NS_OWNER    = NS + '#owner'
    29 NS_ROOMINFO = NS + '#roominfo'
    30 NS_CONFIG   = NS + '#roomconfig'
    31 NS_REQUEST  = NS + '#request'
    32 NS_REGISTER = NS + '#register'
    33 
    34 NS_DELAY    = 'urn:xmpp:delay'
     25NS_MUC          = 'http://jabber.org/protocol/muc'
     26NS_MUC_USER     = NS_MUC + '#user'
     27NS_MUC_ADMIN    = NS_MUC + '#admin'
     28NS_MUC_OWNER    = NS_MUC + '#owner'
     29NS_MUC_ROOMINFO = NS_MUC + '#roominfo'
     30NS_MUC_CONFIG   = NS_MUC + '#roomconfig'
     31NS_MUC_REQUEST  = NS_MUC + '#request'
     32NS_MUC_REGISTER = NS_MUC + '#register'
     33
     34NS_DELAY        = 'urn:xmpp:delay'
     35NS_JABBER_DELAY = 'jabber:x:delay'
     36
    3537NS_REQUEST  = 'jabber:iq:register'
    3638
     
    5355IQ_COMMAND   = IQ+'/command'
    5456
    55 MUC_ADMIN = IQ_QUERY+'[@xmlns="' + NS_ADMIN + '"]'
    56 MUC_OWNER = IQ_QUERY+'[@xmlns="' + NS_OWNER + '"]'
     57MUC_ADMIN = IQ_QUERY+'[@xmlns="' + NS_MUC_ADMIN + '"]'
     58MUC_OWNER = IQ_QUERY+'[@xmlns="' + NS_MUC_OWNER + '"]'
    5759
    5860MUC_AO = MUC_ADMIN + '|' + MUC_OWNER
     
    9193    """
    9294    def __init__(self, condition, mucCondition, feature=None, text=None):
    93         appCondition = domish.Element((NS, mucCondition))
     95        appCondition = domish.Element((NS_MUC, mucCondition))
    9496        if feature:
    9597            appCondition['feature'] = feature
     
    129131    def __init__(self, xs, method='get', fields=[]):
    130132        xmlstream.IQ.__init__(self, xs, method)
    131         q = self.addElement((NS_OWNER, 'query'))
     133        q = self.addElement((NS_MUC_OWNER, 'query'))
    132134        if method == 'set':
    133135            # build data form
    134             form = data_form.Form('submit', formNamespace=NS_CONFIG)
     136            form = data_form.Form('submit', formNamespace=NS_MUC_CONFIG)
    135137            q.addChild(form.toElement())
    136138           
     
    155157            # build data form
    156158            form_type = 'submit'       
    157             form = data_form.Form(form_type, formNamespace=NS_REGISTER)
     159            form = data_form.Form(form_type, formNamespace=NS_MUC_REGISTER)
    158160            q.addChild(form.toElement())       
    159161           
     
    178180        xmlstream.IQ.__init__(self, xs, method)
    179181       
    180         q = self.addElement((NS_ADMIN, 'query'))
     182        q = self.addElement((NS_MUC_ADMIN, 'query'))
    181183        i = q.addElement('item')
    182184
     
    199201        domish.Element.__init__(self, (None, 'message'))
    200202        self['type'] = 'groupchat'
    201         self['to']   = to
     203        if isinstance(to, jid.JID):
     204            self['to'] = to.userhost()
     205        else:
     206            self['to'] = to
    202207        if frm:
    203208            self['from'] = frm
     
    226231        PrivateChat.__init__(self, to, body=body, frm=frm)
    227232        del self['type'] # remove type
    228         x = self.addElement('x', NS_USER)
     233        x = self.addElement('x', NS_MUC_USER)
    229234        invite = x.addElement('invite')
    230235        if full_jid:
     
    311316        xmppim.AvailablePresence.__init__(self, to=to, show=show, statuses=statuses)
    312317        # add muc elements
    313         x = self.addElement('x', NS)
     318        x = self.addElement('x', NS_MUC)
    314319
    315320
     
    325330            self['from'] = frm
    326331        # add muc elements
    327         x = self.addElement('x', NS_USER)
     332        x = self.addElement('x', NS_MUC_USER)
    328333        if affiliation:
    329334            x['affiliation'] = affiliation
     
    347352        GroupChat.__init__(self, to=to, frm=frm)
    348353        # build data form
    349         form = data_form.Form('submit', formNamespace=NS_REQUEST)
     354        form = data_form.Form('submit', formNamespace=NS_MUC_REQUEST)
    350355        form.addField(data_form.Field(var='muc#role',
    351356                                      value='participant',
     
    364369            self['from'] = frm
    365370        # add muc elements
    366         x = self.addElement('x', NS)
     371        x = self.addElement('x', NS_MUC)
    367372        # add error
    368373        self.addChild(error)
     
    476481            return
    477482        user = room.getUser(room_jid.resource)
    478 
    479         delay = getattr(msg, 'delay', None)
     483        delay = None
     484        # need to check for delay and x stanzas for delay namespace for backwards compatability
     485        for e in msg.elements():
     486            if e.uri == NS_DELAY or e.uri == NS_JABBER_DELAY:
     487                delay = e
    480488        body  = unicode(msg.body)
    481489        # grab room
  • wokkel/test/test_muc.py

    r113 r116  
    127127        response.addElement('query', disco.NS_INFO)
    128128        # need to add information to response
    129         response.query.addChild(disco.DiscoFeature(muc.NS))
     129        response.query.addChild(disco.DiscoFeature(muc.NS_MUC))
    130130        response.query.addChild(disco.DiscoIdentity(category='conference',
    131131                                                    name='Macbeth Chat Service',
     
    343343
    344344        iq = self.stub.output[-1]
    345        
     345        print iq.toXml()
    346346        self.failUnless(xpath.matches("/iq/query[@xmlns='%s']" % (muc.NS_REQUEST), iq), 'Invalid iq register request')
    347347       
    348348        response = toResponse(iq, 'result')
     349       
    349350        self.stub.send(response)
    350351        return d
     
    357358        m = self.stub.output[-1]
    358359       
    359         self.failUnless(xpath.matches("/message/x[@type='submit']/field/value[text()='%s']" % (muc.NS_REQUEST,), m), 'Invalid voice message stanza')
     360        self.failUnless(xpath.matches("/message/x[@type='submit']/field/value[text()='%s']" % (muc.NS_MUC_REQUEST,), m), 'Invalid voice message stanza')
    360361
    361362
     
    378379
    379380        iq = self.stub.output[-1]
    380         self.failUnless(xpath.matches("/iq/query[@xmlns='%s']/x"% (muc.NS_OWNER,), iq), 'Bad configure request')
    381        
    382         response = toResponse(iq, 'result')
    383         self.stub.send(response)
    384         return d
    385 
    386 
     381        self.failUnless(xpath.matches("/iq/query[@xmlns='%s']/x"% (muc.NS_MUC_OWNER,), iq), 'Bad configure request')
     382       
     383        response = toResponse(iq, 'result')
     384        self.stub.send(response)
     385        return d
     386
     387
Note: See TracChangeset for help on using the changeset viewer.