Changeset 219:ae8b954e4ed9 for wokkel
- Timestamp:
- Oct 4, 2016, 9:24:05 AM (6 years ago)
- Branch:
- default
- Parents:
- 218:71cba82a4b8b (diff), 216:c458fa7f5f0f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - hg-git-rename-source:
- git
- Location:
- wokkel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/muc.py
r204 r219 1313 1313 user = User(nick, presence.entity) 1314 1314 1315 # Update user status 1315 # Update user data 1316 user.role = presence.role 1317 user.affiliation = presence.affiliation 1316 1318 user.status = presence.status 1317 1319 user.show = presence.show -
wokkel/muc.py
r217 r219 10 10 U{XEP-0045<http://xmpp.org/extensions/xep-0045.html>}. 11 11 """ 12 13 from __future__ import division, absolute_import 14 12 15 from dateutil.tz import tzutc 13 16 14 from zope.interface import implement s17 from zope.interface import implementer 15 18 16 19 from twisted.internet import defer 20 from twisted.python.compat import unicode 21 from twisted.python.constants import Values, ValueConstant 17 22 from twisted.words.protocols.jabber import jid, error, xmlstream 18 23 from twisted.words.xish import domish 19 24 20 25 from wokkel import data_form, generic, iwokkel, xmppim 21 from wokkel.compat import Values, ValueConstant22 26 from wokkel.delay import Delay, DelayMixin 23 27 from wokkel.subprotocols import XMPPHandler … … 65 69 66 70 71 @implementer(iwokkel.IMUCStatuses) 67 72 class Statuses(set): 68 73 """ … … 72 77 L{STATUS_CODE}. Instances of this class provide L{IMUCStatuses}, that 73 78 defines the supported operations. Even though this class currently derives 74 from C{set}, future versions might not. This provides an upgrade path to79 from L{set}, future versions might not. This provides an upgrade path to 75 80 cater for extensible status conditions, as defined in 76 81 U{XEP-0306<http://xmpp.org/extensions/xep-0306.html>}. 77 82 """ 78 implements(iwokkel.IMUCStatuses)79 83 80 84 … … 225 229 226 230 @param reason: Optional reason for the destruction of this room. 227 @type reason: C{unicode}.231 @type reason: L{unicode}. 228 232 229 233 @param alternate: Optional room JID of an alternate venue. … … 231 235 232 236 @param password: Optional password for entering the alternate venue. 233 @type password: C{unicode}237 @type password: L{unicode} 234 238 """ 235 239 … … 274 278 Render into a domish Element. 275 279 276 @param legacyDelay: If C{True} send the delayed delivery information280 @param legacyDelay: If L{True} send the delayed delivery information 277 281 in legacy format. 278 282 """ … … 324 328 (where the character count is the characters of the complete XML 325 329 stanzas, not only their XML character data). 326 @type maxchars: C{int}330 @type maxchars: L{int} 327 331 328 332 @ivar maxstanzas: Limit the total number of messages in the history to "X". 329 @type mazstanzas: C{int}333 @type mazstanzas: L{int} 330 334 331 335 @ivar seconds: Send only the messages received in the last "X" seconds. 332 @type seconds: C{int}336 @type seconds: L{int} 333 337 334 338 @ivar since: Send only the messages received since the datetime specified. … … 392 396 393 397 @ivar affiliation: Affiliation of the entity to the room. 394 @type affiliation: C{unicode}398 @type affiliation: L{unicode} 395 399 396 400 @ivar role: Role of the entity in the room. 397 @type role: C{unicode}401 @type role: L{unicode} 398 402 399 403 @ivar entity: The real JID of the entity this presence is from. … … 405 409 406 410 @ivar nick: The nick name of the entity in the room. 407 @type nick: C{unicode}411 @type nick: L{unicode} 408 412 """ 409 413 … … 546 550 @param timeout: The number of seconds to wait before the deferred is 547 551 timed out. 548 @type timeout: C{int}552 @type timeout: L{int} 549 553 550 554 The deferred object L{defer.Deferred} is returned. … … 592 596 593 597 @param nick: The nick name for the entitity joining the room. 594 @type nick: C{unicode}598 @type nick: L{unicode} 595 599 596 600 @param historyOptions: Options for conversation history sent by the … … 599 603 600 604 @param password: Optional password for the room. 601 @type password: C{unicode}605 @type password: L{unicode} 602 606 603 607 @return: A deferred that fires when the entity is in the room or an … … 625 629 626 630 @param nick: The new nick name within the room. 627 @type nick: C{unicode}631 @type nick: L{unicode} 628 632 """ 629 633 occupantJID = jid.JID(tuple=(roomJID.user, roomJID.host, nick)) … … 643 647 @param show: The availability of the entity. Common values are xa, 644 648 available, etc 645 @type show: C{unicode}649 @type show: L{unicode} 646 650 647 651 @param status: The current status of the entity. 648 @type status: C{unicode}652 @type status: L{unicode} 649 653 """ 650 654 occupantJID = self._roomOccupantMap[roomJID] … … 701 705 702 706 @param subject: The subject you want to set. 703 @type subject: C{unicode}707 @type subject: L{unicode} 704 708 """ 705 709 message = GroupChat(roomJID.userhostJID(), subject=subject) … … 720 724 721 725 @param reason: The reason for the invite. 722 @type reason: C{unicode}726 @type reason: L{unicode} 723 727 """ 724 728 message = InviteMessage(recipient=roomJID, invitee=invitee, … … 752 756 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 753 757 754 @param options: A mapping of field names to values, or C{None} to758 @param options: A mapping of field names to values, or L{None} to 755 759 cancel. 756 @type options: C{dict}760 @type options: L{dict} 757 761 """ 758 762 if options is None: … … 784 788 @param messages: The history to send to the room as an ordered list of 785 789 message, represented by a dictionary with the keys 786 C{'stanza'}, holding the original stanza a787 L{domish.Element}, and C{'timestamp'} with the790 L{'stanza'}, holding the original stanza a 791 L{domish.Element}, and L{'timestamp'} with the 788 792 timestamp. 789 @type messages: C{list} of L{domish.Element}793 @type messages: L{list} of L{domish.Element} 790 794 """ 791 795 … … 819 823 820 824 @return: A deferred that fires with the room's configuration form as 821 a L{data_form.Form} or C{None} if there are no configuration825 a L{data_form.Form} or L{None} if there are no configuration 822 826 options available. 823 827 """ … … 839 843 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 840 844 841 @param options: A mapping of field names to values, or C{None} to845 @param options: A mapping of field names to values, or L{None} to 842 846 cancel. 843 @type options: C{dict}847 @type options: L{dict} 844 848 """ 845 849 if options is None: … … 963 967 964 968 @param entities: The list of entities to change for a room. 965 @type entities: C{list} of969 @type entities: L{list} of 966 970 L{JID<twisted.words.protocols.jabber.jid.JID>} 967 971 968 972 @param affiliation: The affilation to the entities will acquire. 969 @type affiliation: C{unicode}973 @type affiliation: L{unicode} 970 974 971 975 @param sender: The entity sending the request. … … 989 993 990 994 @param nick: The nick name for the user in this room. 991 @type nick: C{unicode}995 @type nick: L{unicode} 992 996 993 997 @param reason: The reason for granting voice to the entity. 994 @type reason: C{unicode}998 @type reason: L{unicode} 995 999 996 1000 @param sender: The entity sending the request. … … 1012 1016 1013 1017 @param nick: The nick name for the user in this room. 1014 @type nick: C{unicode}1018 @type nick: L{unicode} 1015 1019 1016 1020 @param reason: The reason for revoking voice from the entity. 1017 @type reason: C{unicode}1021 @type reason: L{unicode} 1018 1022 1019 1023 @param sender: The entity sending the request. … … 1032 1036 1033 1037 @param nick: The nick name for the user in this room. 1034 @type nick: C{unicode}1038 @type nick: L{unicode} 1035 1039 1036 1040 @param reason: The reason for granting moderation to the entity. 1037 @type reason: C{unicode}1041 @type reason: L{unicode} 1038 1042 1039 1043 @param sender: The entity sending the request. … … 1055 1059 1056 1060 @param reason: The reason for banning the entity. 1057 @type reason: C{unicode}1061 @type reason: L{unicode} 1058 1062 1059 1063 @param sender: The entity sending the request. … … 1072 1076 1073 1077 @param nick: The occupant to be banned. 1074 @type nick: C{unicode}1078 @type nick: L{unicode} 1075 1079 1076 1080 @param reason: The reason given for the kick. 1077 @type reason: C{unicode}1081 @type reason: L{unicode} 1078 1082 1079 1083 @param sender: The entity sending the request. … … 1092 1096 1093 1097 @param reason: The reason for the destruction of the room. 1094 @type reason: C{unicode}1098 @type reason: L{unicode} 1095 1099 1096 1100 @param alternate: The JID of the room suggested as an alternate venue. … … 1132 1136 1133 1137 @ivar nick: The nick name for the client in this room. 1134 @type nick: C{unicode}1138 @type nick: L{unicode} 1135 1139 1136 1140 @ivar occupantJID: The JID of the occupant in the room. Generated from … … 1142 1146 L{MUCClientProtocol.getConfiguration} and 1143 1147 L{MUCClientProtocol.configure}. 1144 @type locked: C{bool}1148 @type locked: L{bool} 1145 1149 """ 1146 1150 … … 1187 1191 1188 1192 @param nick: The nick for the user in the MUC room. 1189 @type nick: C{unicode}1193 @type nick: L{unicode} 1190 1194 """ 1191 1195 return self.roster.get(nick) … … 1204 1208 1205 1209 1210 @implementer(IMUCClient) 1206 1211 class MUCClient(MUCClientProtocol): 1207 1212 """ … … 1213 1218 room. Note that a particular entity can only join a room once 1214 1219 at a time. 1215 @type _rooms: C{dict} 1216 """ 1217 1218 implements(IMUCClient) 1220 @type _rooms: L{dict} 1221 """ 1219 1222 1220 1223 def __init__(self, reactor=None): … … 1402 1405 @type room: L{Room} 1403 1406 1404 @param user: The user that sent the message, or C{None} if it was a1407 @param user: The user that sent the message, or L{None} if it was a 1405 1408 message from the room itself. 1406 1409 @type user: L{User} … … 1423 1426 @type room: L{Room} 1424 1427 1425 @param user: The user that sent the message, or C{None} if it was a1428 @param user: The user that sent the message, or L{None} if it was a 1426 1429 message from the room itself. 1427 1430 @type user: L{User} … … 1442 1445 1443 1446 @param nick: The nick name for the entitity joining the room. 1444 @type nick: C{unicode}1447 @type nick: L{unicode} 1445 1448 1446 1449 @param historyOptions: Options for conversation history sent by the … … 1449 1452 1450 1453 @param password: Optional password for the room. 1451 @type password: C{unicode}1454 @type password: L{unicode} 1452 1455 1453 1456 @return: A deferred that fires with the room when the entity is in the … … 1486 1489 1487 1490 @param nick: The new nick name within the room. 1488 @type nick: C{unicode}1491 @type nick: L{unicode} 1489 1492 """ 1490 1493 def cb(presence): … … 1528 1531 @param show: The availability of the entity. Common values are xa, 1529 1532 available, etc 1530 @type show: C{unicode}1533 @type show: L{unicode} 1531 1534 1532 1535 @param status: The current status of the entity. 1533 @type status: C{unicode}1536 @type status: L{unicode} 1534 1537 """ 1535 1538 room = self._getRoom(roomJID) … … 1547 1550 1548 1551 @param reason: The reason for the destruction of the room. 1549 @type reason: C{unicode}1552 @type reason: L{unicode} 1550 1553 1551 1554 @param alternate: The JID of the room suggested as an alternate venue. -
wokkel/test/test_muc.py
r204 r219 1494 1494 1495 1495 1496 def test_availableReceivedSetsUserRole(self): 1497 """ 1498 The role received in a presence update is stored on the user. 1499 """ 1500 room = self._createRoom() 1501 user = muc.User(self.nick) 1502 room.addUser(user) 1503 self.assertEquals('none', user.role) 1504 1505 xml = u""" 1506 <presence to='%s' from='%s'> 1507 <x xmlns='http://jabber.org/protocol/muc#user'> 1508 <item affiliation='member' role='participant'/> 1509 </x> 1510 </presence> 1511 """ % (self.userJID, self.occupantJID) 1512 self.stub.send(parseXml(xml)) 1513 1514 self.assertEquals('participant', user.role) 1515 1516 1517 def test_availableReceivedSetsUserAffiliation(self): 1518 """ 1519 The affiliation received in a presence update is stored on the user. 1520 """ 1521 room = self._createRoom() 1522 user = muc.User(self.nick) 1523 room.addUser(user) 1524 self.assertEquals('none', user.affiliation) 1525 1526 xml = u""" 1527 <presence to='%s' from='%s'> 1528 <x xmlns='http://jabber.org/protocol/muc#user'> 1529 <item affiliation='member' role='participant'/> 1530 </x> 1531 </presence> 1532 """ % (self.userJID, self.occupantJID) 1533 self.stub.send(parseXml(xml)) 1534 self.assertEquals('member', user.affiliation) 1535 1536 1496 1537 def test_unavailableReceivedEmptySender(self): 1497 1538 """ -
wokkel/test/test_muc.py
r218 r219 6 6 """ 7 7 8 from __future__ import division, absolute_import 9 8 10 from datetime import datetime 9 11 from dateutil.tz import tzutc … … 13 15 from twisted.trial import unittest 14 16 from twisted.internet import defer, task 17 from twisted.python.compat import iteritems, unicode 15 18 from twisted.words.xish import domish, xpath 16 19 from twisted.words.protocols.jabber.jid import JID … … 79 82 } 80 83 81 for code, condition in codes.iteritems():84 for code, condition in iteritems(codes): 82 85 constantName = condition.replace('-', '_').upper() 83 86 self.assertEqual(getattr(muc.STATUS_CODE, constantName), … … 824 827 self.assertNotIdentical(None, nodes, 'Missing query element') 825 828 826 self.assertRaises(StopIteration, n odes[0].elements().next)829 self.assertRaises(StopIteration, next, nodes[0].elements()) 827 830 828 831 xml = u""" … … 970 973 self.assertNotIdentical(None, nodes, 'Missing query element') 971 974 972 self.assertRaises(StopIteration, n odes[0].elements().next)975 self.assertRaises(StopIteration, next, nodes[0].elements()) 973 976 974 977 xml = u"""
Note: See TracChangeset
for help on using the changeset viewer.