def leave_room(self, presence, room_jid, nickname): """ Sends 'unavailable'-type presence which leaves client from the room. Fails if user not in room. :param room_jid: JID of room-conference :param nickname: string-type client's nickname in conference """ reciever = internJID(room_jid) assert reciever.bare() in self.roster, 'not in room' reciever.resource = nickname presence = MyElement.makeFromElement(presence) presence = Presence.createFromElement(presence) presence.to = reciever presence.from_ = self.dispatcher.myjid presence.type_ = 'unavailable' msg = ConnectPresence(parent=presence) self.dispatcher.send(msg.parent) del self.roster[reciever.bare()]
def enter_room(self, presence, room_jid, nickname): """ Sends 'available'-type presence which allows client to enter the room. Fails if user already in room. :param room_jid: JID of room-conference :param nickname: string-type client's nickname in conference :param status: string-type client's status message """ reciever = internJID(room_jid) assert reciever.bare() not in self.roster, 'already in room' reciever.resource = nickname presence = MyElement.makeFromElement(presence) presence = Presence.createFromElement(presence) presence.to = reciever presence.from_ = self.dispatcher.myjid msg = ConnectPresence(parent=presence) self.roster[reciever.bare()] = [] self.dispatcher.send(msg.parent)
def clean_set(self, value): if value is None: return EmptyElement() r = MyElement((self.uri, self.xmlnode)) r.content = unicode(value) return r
def clean_set(self, value): if value is not None: r = MyElement((None, self.xmlnode)) r.content = base64.b64encode(unicode(value)) return r