Changeset 116:66d9a0b47016 for wokkel
- Timestamp:
- Oct 17, 2008, 12:14:32 AM (14 years ago)
- Branch:
- wokkel-muc-client-support-24
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/branches/wokkel-muc-client-support-24@110
- Location:
- wokkel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/muc.py
r115 r116 23 23 24 24 # 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' 25 NS_MUC = 'http://jabber.org/protocol/muc' 26 NS_MUC_USER = NS_MUC + '#user' 27 NS_MUC_ADMIN = NS_MUC + '#admin' 28 NS_MUC_OWNER = NS_MUC + '#owner' 29 NS_MUC_ROOMINFO = NS_MUC + '#roominfo' 30 NS_MUC_CONFIG = NS_MUC + '#roomconfig' 31 NS_MUC_REQUEST = NS_MUC + '#request' 32 NS_MUC_REGISTER = NS_MUC + '#register' 33 34 NS_DELAY = 'urn:xmpp:delay' 35 NS_JABBER_DELAY = 'jabber:x:delay' 36 35 37 NS_REQUEST = 'jabber:iq:register' 36 38 … … 53 55 IQ_COMMAND = IQ+'/command' 54 56 55 MUC_ADMIN = IQ_QUERY+'[@xmlns="' + NS_ ADMIN + '"]'56 MUC_OWNER = IQ_QUERY+'[@xmlns="' + NS_ OWNER + '"]'57 MUC_ADMIN = IQ_QUERY+'[@xmlns="' + NS_MUC_ADMIN + '"]' 58 MUC_OWNER = IQ_QUERY+'[@xmlns="' + NS_MUC_OWNER + '"]' 57 59 58 60 MUC_AO = MUC_ADMIN + '|' + MUC_OWNER … … 91 93 """ 92 94 def __init__(self, condition, mucCondition, feature=None, text=None): 93 appCondition = domish.Element((NS , mucCondition))95 appCondition = domish.Element((NS_MUC, mucCondition)) 94 96 if feature: 95 97 appCondition['feature'] = feature … … 129 131 def __init__(self, xs, method='get', fields=[]): 130 132 xmlstream.IQ.__init__(self, xs, method) 131 q = self.addElement((NS_ OWNER, 'query'))133 q = self.addElement((NS_MUC_OWNER, 'query')) 132 134 if method == 'set': 133 135 # build data form 134 form = data_form.Form('submit', formNamespace=NS_ CONFIG)136 form = data_form.Form('submit', formNamespace=NS_MUC_CONFIG) 135 137 q.addChild(form.toElement()) 136 138 … … 155 157 # build data form 156 158 form_type = 'submit' 157 form = data_form.Form(form_type, formNamespace=NS_ REGISTER)159 form = data_form.Form(form_type, formNamespace=NS_MUC_REGISTER) 158 160 q.addChild(form.toElement()) 159 161 … … 178 180 xmlstream.IQ.__init__(self, xs, method) 179 181 180 q = self.addElement((NS_ ADMIN, 'query'))182 q = self.addElement((NS_MUC_ADMIN, 'query')) 181 183 i = q.addElement('item') 182 184 … … 199 201 domish.Element.__init__(self, (None, 'message')) 200 202 self['type'] = 'groupchat' 201 self['to'] = to 203 if isinstance(to, jid.JID): 204 self['to'] = to.userhost() 205 else: 206 self['to'] = to 202 207 if frm: 203 208 self['from'] = frm … … 226 231 PrivateChat.__init__(self, to, body=body, frm=frm) 227 232 del self['type'] # remove type 228 x = self.addElement('x', NS_ USER)233 x = self.addElement('x', NS_MUC_USER) 229 234 invite = x.addElement('invite') 230 235 if full_jid: … … 311 316 xmppim.AvailablePresence.__init__(self, to=to, show=show, statuses=statuses) 312 317 # add muc elements 313 x = self.addElement('x', NS )318 x = self.addElement('x', NS_MUC) 314 319 315 320 … … 325 330 self['from'] = frm 326 331 # add muc elements 327 x = self.addElement('x', NS_ USER)332 x = self.addElement('x', NS_MUC_USER) 328 333 if affiliation: 329 334 x['affiliation'] = affiliation … … 347 352 GroupChat.__init__(self, to=to, frm=frm) 348 353 # build data form 349 form = data_form.Form('submit', formNamespace=NS_ REQUEST)354 form = data_form.Form('submit', formNamespace=NS_MUC_REQUEST) 350 355 form.addField(data_form.Field(var='muc#role', 351 356 value='participant', … … 364 369 self['from'] = frm 365 370 # add muc elements 366 x = self.addElement('x', NS )371 x = self.addElement('x', NS_MUC) 367 372 # add error 368 373 self.addChild(error) … … 476 481 return 477 482 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 480 488 body = unicode(msg.body) 481 489 # grab room -
wokkel/test/test_muc.py
r113 r116 127 127 response.addElement('query', disco.NS_INFO) 128 128 # need to add information to response 129 response.query.addChild(disco.DiscoFeature(muc.NS ))129 response.query.addChild(disco.DiscoFeature(muc.NS_MUC)) 130 130 response.query.addChild(disco.DiscoIdentity(category='conference', 131 131 name='Macbeth Chat Service', … … 343 343 344 344 iq = self.stub.output[-1] 345 345 print iq.toXml() 346 346 self.failUnless(xpath.matches("/iq/query[@xmlns='%s']" % (muc.NS_REQUEST), iq), 'Invalid iq register request') 347 347 348 348 response = toResponse(iq, 'result') 349 349 350 self.stub.send(response) 350 351 return d … … 357 358 m = self.stub.output[-1] 358 359 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') 360 361 361 362 … … 378 379 379 380 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.