Changeset 114:a2a47e4df6d5


Ignore:
Timestamp:
Oct 8, 2008, 8:48:32 PM (13 years ago)
Author:
Christopher Zorn <tofu@…>
Branch:
wokkel-muc-client-support-24
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/branches/wokkel-muc-client-support-24@84
Message:

add event for user leaving a room

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/muc.py

    r113 r114  
    273273        self.server = server
    274274        self.nick   = nick
    275         self.status = None
     275        self.status = 0
    276276
    277277        self.entity_id = jid.internJID(name+'@'+server+'/'+nick)
     
    297297        return self.roster.get(nick.lower())
    298298
     299    def removeUser(self, user):
     300        if self.inRoster(user):
     301            del self.roster[user.nick.lower()]
    299302       
    300303
     
    383386        # add history
    384387
     388
    385389    def _setRoom(self, room):
    386         self.rooms[room.entity_id.full().lower()] = room
     390        self.rooms[room.entity_id.userhost().lower()] = room
    387391
    388392    def _getRoom(self, room_jid):
    389         return self.rooms.get(room_jid.full().lower())
     393        return self.rooms.get(room_jid.userhost().lower())
    390394
    391395    def _removeRoom(self, room_jid):
    392         if self.rooms.has_key(room_jid.full().lower()):
    393             del self.rooms[room_jid.full().lower()]
     396        if self.rooms.has_key(room_jid.userhost().lower()):
     397            del self.rooms[room_jid.userhost().lower()]
    394398
    395399
     
    400404            return
    401405        room_jid = jid.internJID(prs.getAttribute('from', ''))
    402 
     406        self._userLeavesRoom(room_jid)
    403407
    404408    def _onPresenceError(self, prs):
     
    408412            return
    409413        room_jid = jid.internJID(prs.getAttribute('from', ''))
    410 
    411 
     414        # add an error hook here?
     415        self._userLeavesRoom(room_jid)
     416
     417    def _userLeavesRoom(self, room_jid):
     418        room = self._getRoom(room_jid)
     419        if room is None:
     420            # not in the room yet
     421            return
     422        # check if user is in roster
     423        user = room.getUser(room_jid.resource)
     424        if user is None:
     425            return
     426        if room.inRoster(user):
     427            room.removeUser(user)
     428            self.userLeftRoom(room, user)
     429       
    412430    def _onXPresence(self, prs):
    413431        """
     
    535553        pass
    536554
     555    def userLeftRoom(self, room, user):
     556        """User has left a room
     557        """
     558        pass
     559
    537560
    538561    def userUserUpdatedStatus(self, room, user, show, status):
Note: See TracChangeset for help on using the changeset viewer.