Changeset 160:33ef849a77d8 for wokkel/muc.py
- Timestamp:
- Jan 8, 2012, 9:26:02 AM (10 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/muc.py
r156 r160 8 8 9 9 This protocol is specified in 10 U{XEP-0045<http:// www.xmpp.org/extensions/xep-0045.html>}.10 U{XEP-0045<http://xmpp.org/extensions/xep-0045.html>}. 11 11 """ 12 12 from dateutil.tz import tzutc … … 18 18 from twisted.words.xish import domish 19 19 20 from wokkel import data_form, generic, xmppim 20 from wokkel import data_form, generic, iwokkel, xmppim 21 from wokkel.compat import Values, ValueConstant 21 22 from wokkel.delay import Delay, DelayMixin 22 23 from wokkel.subprotocols import XMPPHandler … … 41 42 42 43 DEFER_TIMEOUT = 30 # basic timeout is 30 seconds 44 45 class STATUS_CODE(Values): 46 REALJID_PUBLIC = ValueConstant(100) 47 AFFILIATION_CHANGED = ValueConstant(101) 48 UNAVAILABLE_SHOWN = ValueConstant(102) 49 UNAVAILABLE_NOT_SHOWN = ValueConstant(103) 50 CONFIGURATION_CHANGED = ValueConstant(104) 51 SELF_PRESENCE = ValueConstant(110) 52 LOGGING_ENABLED = ValueConstant(170) 53 LOGGING_DISABLED = ValueConstant(171) 54 NON_ANONYMOUS = ValueConstant(172) 55 SEMI_ANONYMOUS = ValueConstant(173) 56 FULLY_ANONYMOUS = ValueConstant(174) 57 ROOM_CREATED = ValueConstant(201) 58 NICK_ASSIGNED = ValueConstant(210) 59 BANNED = ValueConstant(301) 60 NEW_NICK = ValueConstant(303) 61 KICKED = ValueConstant(307) 62 REMOVED_AFFILIATION = ValueConstant(321) 63 REMOVED_MEMBERSHIP = ValueConstant(322) 64 REMOVED_SHUTDOWN = ValueConstant(332) 65 66 67 class Statuses(set): 68 """ 69 Container of MUC status conditions. 70 71 This is currently implemented as a set of constant values from 72 L{STATUS_CODE}. Instances of this class provide L{IMUCStatuses}, that 73 defines the supported operations. Even though this class currently derives 74 from C{set}, future versions might not. This provides an upgrade path to 75 cater for extensible status conditions, as defined in 76 U{XEP-0306<http://xmpp.org/extensions/xep-0306.html>}. 77 """ 78 implements(iwokkel.IMUCStatuses) 43 79 44 80 … … 354 390 """ 355 391 Availability presence sent from MUC service to client. 392 393 @ivar affiliation: Affiliation of the entity to the room. 394 @type affiliation: C{unicode} 395 396 @ivar role: Role of the entity in the room. 397 @type role: C{unicode} 398 399 @ivar entity: The real JID of the entity this presence is from. 400 @type entity: L{jid.JID} 401 402 @ivar mucStatuses: Set of one or more status codes from L{STATUS_CODE}. 403 See L{Statuses} for usage notes. 404 @type mucStatuses: L{Statuses} 405 406 @ivar nick: The nick name of the entity in the room. 407 @type nick: C{unicode} 356 408 """ 357 409 … … 361 413 nick = None 362 414 363 statusCodes = None415 mucStatuses = None 364 416 365 417 childParsers = {(NS_MUC_USER, 'x'): '_childParser_mucUser'} 366 418 419 def __init__(self, *args, **kwargs): 420 self.mucStatuses = Statuses() 421 xmppim.AvailabilityPresence.__init__(self, *args, **kwargs) 422 423 367 424 def _childParser_mucUser(self, element): 368 statusCodes = set() 369 425 """ 426 Parse the MUC user extension element. 427 """ 370 428 for child in element.elements(): 371 429 if child.uri != NS_MUC_USER: … … 374 432 elif child.name == 'status': 375 433 try: 376 statusCode = int(child.getAttribute('code')) 434 value = int(child.getAttribute('code')) 435 statusCode = STATUS_CODE.lookupByValue(value) 377 436 except (TypeError, ValueError): 378 437 continue 379 438 380 s tatusCodes.add(statusCode)439 self.mucStatuses.add(statusCode) 381 440 382 441 elif child.name == 'item': … … 393 452 # TODO: destroy 394 453 395 if statusCodes:396 self.statusCodes = statusCodes397 454 398 455
Note: See TracChangeset
for help on using the changeset viewer.