Changeset 119:053b615f0e11 for wokkel
- Timestamp:
- Oct 20, 2008, 9:01:07 PM (14 years ago)
- Branch:
- wokkel-muc-client-support-24
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/branches/wokkel-muc-client-support-24@115
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/muc.py
r118 r119 166 166 167 167 168 class A ffiliationRequest(xmlstream.IQ):169 """ 170 Register room request.168 class AdminRequest(xmlstream.IQ): 169 """ 170 A basic admin iq request 171 171 172 172 @ivar method: Type attribute of the IQ request. Either C{'set'} or C{'get'} 173 173 @type method: C{str} 174 174 175 """ 176 177 def __init__(self, xs, method='get'): 178 xmlstream.IQ.__init__(self, xs, method) 179 q = self.addElement((NS_MUC_ADMIN, 'query')) 180 181 182 class OwnerRequest(xmlstream.IQ): 183 """ 184 A basic owner iq request 185 186 @ivar method: Type attribute of the IQ request. Either C{'set'} or C{'get'} 187 @type method: C{str} 188 189 """ 190 191 def __init__(self, xs, method='get'): 192 xmlstream.IQ.__init__(self, xs, method) 193 q = self.addElement((NS_MUC_OWNER, 'query')) 194 195 196 197 class AffiliationRequest(AdminRequest): 198 """ 199 Register room request. 200 201 @ivar method: Type attribute of the IQ request. Either C{'set'} or C{'get'} 202 @type method: C{str} 203 175 204 @ivar affiliation: The affiliation type to send to room. 176 205 @type affiliation: C{str} … … 179 208 180 209 def __init__(self, xs, method='get', affiliation='none', a_jid=None, reason=None): 181 xmlstream.IQ.__init__(self, xs, method) 182 183 q = self.addElement((NS_MUC_ADMIN, 'query')) 184 i = q.addElement('item') 210 AdminRequest.__init__(self, xs, method) 211 212 i = self.query.addElement('item') 185 213 186 214 i['affiliation'] = affiliation … … 713 741 return d 714 742 715 def _changed Nick(self, d, room_jid, prs):716 """Callback for changing the nick .743 def _changed(self, d, room_jid, prs): 744 """Callback for changing the nick and status. 717 745 """ 718 746 … … 747 775 # add observer for joining the room 748 776 self.xmlstream.addOnetimeObserver(PRESENCE+"[@from='%s']" % (r.entity_id.full()), 749 self._changed Nick, 1, d, room_jid)777 self._changed, 1, d, room_jid) 750 778 751 779 return d … … 768 796 769 797 770 798 def status(self, room_jid, show=None, status=None): 799 """Change user status. 800 801 See: http://xmpp.org/extensions/xep-0045.html#changepres 802 803 @param room_jid: The room jabber/xmpp entity id for the requested configuration form. 804 @type room_jid: L{jid.JID} 805 806 @param show: The availability of the entity. Common values are xa, available, etc 807 @type show: L{unicode} 808 809 @param show: The current status of the entity. 810 @type show: L{unicode} 811 812 """ 813 r = self._getRoom(room_jid) 814 if r is None: 815 raise Exception, 'Room not found' 816 817 p = BasicPresence(to=r.entityId()) 818 if status is not None: 819 p.addElement('status', None, status) 820 821 if show is not None: 822 p.addElement('show', None, show) 823 824 d = self.sendDeferred(p, timeout=DEFER_TIMEOUT) 825 826 # add observer for joining the room 827 self.xmlstream.addOnetimeObserver(PRESENCE+"[@from='%s']" % (r.entity_id.full()), 828 self._changed, 1, d, room_jid) 829 830 return d 771 831 772 832 def _sendMessage(self, msg, children=None): … … 807 867 return iq.send() 808 868 869 def getMemberList(self, room_jid): 870 """ Get a member list from a room. 871 872 @param room_jid: The room jabber/xmpp entity id for the requested member list. 873 @type room_jid: L{jid.JID} 874 875 """ 876 iq = AffiliationRequest(self.xmlstream, 877 method='get', 878 affiliation='member', 879 ) 880 iq['to'] = room_jid.full() 881 return iq.send() 882 883 809 884 def getRegisterForm(self, room): 810 885 """ 886 887 @param room: The room jabber/xmpp entity id for the requested registration form. 888 @type room: L{jid.JID} 889 811 890 """ 812 891 iq = RegisterRequest(self.xmlstream)
Note: See TracChangeset
for help on using the changeset viewer.