Changeset 219:ae8b954e4ed9


Ignore:
Timestamp:
Oct 4, 2016, 9:24:05 AM (4 years ago)
Author:
Ralph Meijer <ralphm@…>
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
Message:

Merge branch 'master' into affiliation_role_fix

Location:
wokkel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wokkel/muc.py

    r204 r219  
    13131313            user = User(nick, presence.entity)
    13141314
    1315         # Update user status
     1315        # Update user data
     1316        user.role = presence.role
     1317        user.affiliation = presence.affiliation
    13161318        user.status = presence.status
    13171319        user.show = presence.show
  • wokkel/muc.py

    r217 r219  
    1010U{XEP-0045<http://xmpp.org/extensions/xep-0045.html>}.
    1111"""
     12
     13from __future__ import division, absolute_import
     14
    1215from dateutil.tz import tzutc
    1316
    14 from zope.interface import implements
     17from zope.interface import implementer
    1518
    1619from twisted.internet import defer
     20from twisted.python.compat import unicode
     21from twisted.python.constants import Values, ValueConstant
    1722from twisted.words.protocols.jabber import jid, error, xmlstream
    1823from twisted.words.xish import domish
    1924
    2025from wokkel import data_form, generic, iwokkel, xmppim
    21 from wokkel.compat import Values, ValueConstant
    2226from wokkel.delay import Delay, DelayMixin
    2327from wokkel.subprotocols import XMPPHandler
     
    6569
    6670
     71@implementer(iwokkel.IMUCStatuses)
    6772class Statuses(set):
    6873    """
     
    7277    L{STATUS_CODE}. Instances of this class provide L{IMUCStatuses}, that
    7378    defines the supported operations. Even though this class currently derives
    74     from C{set}, future versions might not. This provides an upgrade path to
     79    from L{set}, future versions might not. This provides an upgrade path to
    7580    cater for extensible status conditions, as defined in
    7681    U{XEP-0306<http://xmpp.org/extensions/xep-0306.html>}.
    7782    """
    78     implements(iwokkel.IMUCStatuses)
    7983
    8084
     
    225229
    226230    @param reason: Optional reason for the destruction of this room.
    227     @type reason: C{unicode}.
     231    @type reason: L{unicode}.
    228232
    229233    @param alternate: Optional room JID of an alternate venue.
     
    231235
    232236    @param password: Optional password for entering the alternate venue.
    233     @type password: C{unicode}
     237    @type password: L{unicode}
    234238    """
    235239
     
    274278        Render into a domish Element.
    275279
    276         @param legacyDelay: If C{True} send the delayed delivery information
     280        @param legacyDelay: If L{True} send the delayed delivery information
    277281        in legacy format.
    278282        """
     
    324328        (where the character count is the characters of the complete XML
    325329        stanzas, not only their XML character data).
    326     @type maxchars: C{int}
     330    @type maxchars: L{int}
    327331
    328332    @ivar maxstanzas: Limit the total number of messages in the history to "X".
    329     @type mazstanzas: C{int}
     333    @type mazstanzas: L{int}
    330334
    331335    @ivar seconds: Send only the messages received in the last "X" seconds.
    332     @type seconds: C{int}
     336    @type seconds: L{int}
    333337
    334338    @ivar since: Send only the messages received since the datetime specified.
     
    392396
    393397    @ivar affiliation: Affiliation of the entity to the room.
    394     @type affiliation: C{unicode}
     398    @type affiliation: L{unicode}
    395399
    396400    @ivar role: Role of the entity in the room.
    397     @type role: C{unicode}
     401    @type role: L{unicode}
    398402
    399403    @ivar entity: The real JID of the entity this presence is from.
     
    405409
    406410    @ivar nick: The nick name of the entity in the room.
    407     @type nick: C{unicode}
     411    @type nick: L{unicode}
    408412    """
    409413
     
    546550        @param timeout: The number of seconds to wait before the deferred is
    547551            timed out.
    548         @type timeout: C{int}
     552        @type timeout: L{int}
    549553
    550554        The deferred object L{defer.Deferred} is returned.
     
    592596
    593597        @param nick: The nick name for the entitity joining the room.
    594         @type nick: C{unicode}
     598        @type nick: L{unicode}
    595599
    596600        @param historyOptions: Options for conversation history sent by the
     
    599603
    600604        @param password: Optional password for the room.
    601         @type password: C{unicode}
     605        @type password: L{unicode}
    602606
    603607        @return: A deferred that fires when the entity is in the room or an
     
    625629
    626630        @param nick: The new nick name within the room.
    627         @type nick: C{unicode}
     631        @type nick: L{unicode}
    628632        """
    629633        occupantJID = jid.JID(tuple=(roomJID.user, roomJID.host, nick))
     
    643647        @param show: The availability of the entity. Common values are xa,
    644648            available, etc
    645         @type show: C{unicode}
     649        @type show: L{unicode}
    646650
    647651        @param status: The current status of the entity.
    648         @type status: C{unicode}
     652        @type status: L{unicode}
    649653        """
    650654        occupantJID = self._roomOccupantMap[roomJID]
     
    701705
    702706        @param subject: The subject you want to set.
    703         @type subject: C{unicode}
     707        @type subject: L{unicode}
    704708        """
    705709        message = GroupChat(roomJID.userhostJID(), subject=subject)
     
    720724
    721725        @param reason: The reason for the invite.
    722         @type reason: C{unicode}
     726        @type reason: L{unicode}
    723727        """
    724728        message = InviteMessage(recipient=roomJID, invitee=invitee,
     
    752756        @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
    753757
    754         @param options: A mapping of field names to values, or C{None} to
     758        @param options: A mapping of field names to values, or L{None} to
    755759            cancel.
    756         @type options: C{dict}
     760        @type options: L{dict}
    757761        """
    758762        if options is None:
     
    784788        @param messages: The history to send to the room as an ordered list of
    785789                         message, represented by a dictionary with the keys
    786                          C{'stanza'}, holding the original stanza a
    787                          L{domish.Element}, and C{'timestamp'} with the
     790                         L{'stanza'}, holding the original stanza a
     791                         L{domish.Element}, and L{'timestamp'} with the
    788792                         timestamp.
    789         @type messages: C{list} of L{domish.Element}
     793        @type messages: L{list} of L{domish.Element}
    790794        """
    791795
     
    819823
    820824        @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 configuration
     825            a L{data_form.Form} or L{None} if there are no configuration
    822826            options available.
    823827        """
     
    839843        @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>}
    840844
    841         @param options: A mapping of field names to values, or C{None} to
     845        @param options: A mapping of field names to values, or L{None} to
    842846            cancel.
    843         @type options: C{dict}
     847        @type options: L{dict}
    844848        """
    845849        if options is None:
     
    963967
    964968        @param entities: The list of entities to change for a room.
    965         @type entities: C{list} of
     969        @type entities: L{list} of
    966970            L{JID<twisted.words.protocols.jabber.jid.JID>}
    967971
    968972        @param affiliation: The affilation to the entities will acquire.
    969         @type affiliation: C{unicode}
     973        @type affiliation: L{unicode}
    970974
    971975        @param sender: The entity sending the request.
     
    989993
    990994        @param nick: The nick name for the user in this room.
    991         @type nick: C{unicode}
     995        @type nick: L{unicode}
    992996
    993997        @param reason: The reason for granting voice to the entity.
    994         @type reason: C{unicode}
     998        @type reason: L{unicode}
    995999
    9961000        @param sender: The entity sending the request.
     
    10121016
    10131017        @param nick: The nick name for the user in this room.
    1014         @type nick: C{unicode}
     1018        @type nick: L{unicode}
    10151019
    10161020        @param reason: The reason for revoking voice from the entity.
    1017         @type reason: C{unicode}
     1021        @type reason: L{unicode}
    10181022
    10191023        @param sender: The entity sending the request.
     
    10321036
    10331037        @param nick: The nick name for the user in this room.
    1034         @type nick: C{unicode}
     1038        @type nick: L{unicode}
    10351039
    10361040        @param reason: The reason for granting moderation to the entity.
    1037         @type reason: C{unicode}
     1041        @type reason: L{unicode}
    10381042
    10391043        @param sender: The entity sending the request.
     
    10551059
    10561060        @param reason: The reason for banning the entity.
    1057         @type reason: C{unicode}
     1061        @type reason: L{unicode}
    10581062
    10591063        @param sender: The entity sending the request.
     
    10721076
    10731077        @param nick: The occupant to be banned.
    1074         @type nick: C{unicode}
     1078        @type nick: L{unicode}
    10751079
    10761080        @param reason: The reason given for the kick.
    1077         @type reason: C{unicode}
     1081        @type reason: L{unicode}
    10781082
    10791083        @param sender: The entity sending the request.
     
    10921096
    10931097        @param reason: The reason for the destruction of the room.
    1094         @type reason: C{unicode}
     1098        @type reason: L{unicode}
    10951099
    10961100        @param alternate: The JID of the room suggested as an alternate venue.
     
    11321136
    11331137    @ivar nick: The nick name for the client in this room.
    1134     @type nick: C{unicode}
     1138    @type nick: L{unicode}
    11351139
    11361140    @ivar occupantJID: The JID of the occupant in the room. Generated from
     
    11421146        L{MUCClientProtocol.getConfiguration} and
    11431147        L{MUCClientProtocol.configure}.
    1144     @type locked: C{bool}
     1148    @type locked: L{bool}
    11451149    """
    11461150
     
    11871191
    11881192        @param nick: The nick for the user in the MUC room.
    1189         @type nick: C{unicode}
     1193        @type nick: L{unicode}
    11901194        """
    11911195        return self.roster.get(nick)
     
    12041208
    12051209
     1210@implementer(IMUCClient)
    12061211class MUCClient(MUCClientProtocol):
    12071212    """
     
    12131218                  room. Note that a particular entity can only join a room once
    12141219                  at a time.
    1215     @type _rooms: C{dict}
    1216     """
    1217 
    1218     implements(IMUCClient)
     1220    @type _rooms: L{dict}
     1221    """
    12191222
    12201223    def __init__(self, reactor=None):
     
    14021405        @type room: L{Room}
    14031406
    1404         @param user: The user that sent the message, or C{None} if it was a
     1407        @param user: The user that sent the message, or L{None} if it was a
    14051408            message from the room itself.
    14061409        @type user: L{User}
     
    14231426        @type room: L{Room}
    14241427
    1425         @param user: The user that sent the message, or C{None} if it was a
     1428        @param user: The user that sent the message, or L{None} if it was a
    14261429            message from the room itself.
    14271430        @type user: L{User}
     
    14421445
    14431446        @param nick: The nick name for the entitity joining the room.
    1444         @type nick: C{unicode}
     1447        @type nick: L{unicode}
    14451448
    14461449        @param historyOptions: Options for conversation history sent by the
     
    14491452
    14501453        @param password: Optional password for the room.
    1451         @type password: C{unicode}
     1454        @type password: L{unicode}
    14521455
    14531456        @return: A deferred that fires with the room when the entity is in the
     
    14861489
    14871490        @param nick: The new nick name within the room.
    1488         @type nick: C{unicode}
     1491        @type nick: L{unicode}
    14891492        """
    14901493        def cb(presence):
     
    15281531        @param show: The availability of the entity. Common values are xa,
    15291532            available, etc
    1530         @type show: C{unicode}
     1533        @type show: L{unicode}
    15311534
    15321535        @param status: The current status of the entity.
    1533         @type status: C{unicode}
     1536        @type status: L{unicode}
    15341537        """
    15351538        room = self._getRoom(roomJID)
     
    15471550
    15481551        @param reason: The reason for the destruction of the room.
    1549         @type reason: C{unicode}
     1552        @type reason: L{unicode}
    15501553
    15511554        @param alternate: The JID of the room suggested as an alternate venue.
  • wokkel/test/test_muc.py

    r204 r219  
    14941494
    14951495
     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
    14961537    def test_unavailableReceivedEmptySender(self):
    14971538        """
  • wokkel/test/test_muc.py

    r218 r219  
    66"""
    77
     8from __future__ import division, absolute_import
     9
    810from datetime import datetime
    911from dateutil.tz import tzutc
     
    1315from twisted.trial import unittest
    1416from twisted.internet import defer, task
     17from twisted.python.compat import iteritems, unicode
    1518from twisted.words.xish import domish, xpath
    1619from twisted.words.protocols.jabber.jid import JID
     
    7982        }
    8083
    81         for code, condition in codes.iteritems():
     84        for code, condition in iteritems(codes):
    8285            constantName = condition.replace('-', '_').upper()
    8386            self.assertEqual(getattr(muc.STATUS_CODE, constantName),
     
    824827        self.assertNotIdentical(None, nodes, 'Missing query element')
    825828
    826         self.assertRaises(StopIteration, nodes[0].elements().next)
     829        self.assertRaises(StopIteration, next, nodes[0].elements())
    827830
    828831        xml = u"""
     
    970973        self.assertNotIdentical(None, nodes, 'Missing query element')
    971974
    972         self.assertRaises(StopIteration, nodes[0].elements().next)
     975        self.assertRaises(StopIteration, next, nodes[0].elements())
    973976
    974977        xml = u"""
Note: See TracChangeset for help on using the changeset viewer.