comparison src/plugins/plugin_xep_0045.py @ 518:75216d94a89d

primitivus: fixed messages order in chat window
author Goffi <goffi@goffi.org>
date Sun, 21 Oct 2012 12:03:29 +0200
parents 29b5ef129488
children b7577230a7c8
comparison
equal deleted inserted replaced
517:59b32c04e105 518:75216d94a89d
124 @return: nick or empty string in case of error""" 124 @return: nick or empty string in case of error"""
125 profile = self.host.memory.getProfileName(profile_key) 125 profile = self.host.memory.getProfileName(profile_key)
126 if not self.__check_profile(profile) or not self.clients[profile].joined_rooms.has_key(room_jid_s): 126 if not self.__check_profile(profile) or not self.clients[profile].joined_rooms.has_key(room_jid_s):
127 return '' 127 return ''
128 return self.clients[profile].joined_rooms[room_jid_s].nick 128 return self.clients[profile].joined_rooms[room_jid_s].nick
129
130 def isNickInRoom(self, room_jid, nick, profile):
131 """Tell if a nick is currently present in a room"""
132 profile = self.host.memory.getProfileName(profile_key)
133 if not self.__check_profile(profile):
134 raise exceptions.UnknownProfileError("Unknown or disconnected profile")
135 if not self.clients[profile].joined_rooms.has_key(room_jid.userhost()):
136 raise UnknownRoom("This room has not been joined")
137 return self.clients[profile].joined_rooms[room_jid.userhost()].inRoster(nick)
129 138
130 def getRoomsSubjects(self, profile_key='@DEFAULT@'): 139 def getRoomsSubjects(self, profile_key='@DEFAULT@'):
131 """Return received subjects of rooms""" 140 """Return received subjects of rooms"""
132 profile = self.host.memory.getProfileName(profile_key) 141 profile = self.host.memory.getProfileName(profile_key)
133 if not self.__check_profile(profile): 142 if not self.__check_profile(profile):
207 return self.leave(jid.JID(room_jid_s), profile_key) 216 return self.leave(jid.JID(room_jid_s), profile_key)
208 217
209 def getHandler(self, profile): 218 def getHandler(self, profile):
210 self.clients[profile] = SatMUCClient(self) 219 self.clients[profile] = SatMUCClient(self)
211 return self.clients[profile] 220 return self.clients[profile]
212
213 221
214 222
215 class SatMUCClient (muc.MUCClient): 223 class SatMUCClient (muc.MUCClient):
216 #implements(iwokkel.IDisco) 224 #implements(iwokkel.IDisco)
217 225
218 def __init__(self, plugin_parent): 226 def __init__(self, plugin_parent):
219 self.plugin_parent = plugin_parent 227 self.plugin_parent = plugin_parent
220 self.host = plugin_parent.host 228 self.host = plugin_parent.host
221 muc.MUCClient.__init__(self) 229 muc.MUCClient.__init__(self)
222 self.joined_rooms = {} 230 self.joined_rooms = {} #FIXME: seem to do the same thing as MUCClient's _rooms attribute, must be removed
223 self.rec_subjects = {} 231 self.rec_subjects = {}
224 self.__changing_nicks = set() # used to keep trace of who is changing nick, 232 self.__changing_nicks = set() # used to keep trace of who is changing nick,
225 # and to discard userJoinedRoom signal in this case 233 # and to discard userJoinedRoom signal in this case
226 print "init SatMUCClient OK" 234 print "init SatMUCClient OK"
227 235
281 def userChangedNick(self, room, user, new_nick): 289 def userChangedNick(self, room, user, new_nick):
282 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile) 290 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile)
283 291
284 def userUpdatedStatus(self, room, user, show, status): 292 def userUpdatedStatus(self, room, user, show, status):
285 print("FIXME: MUC status not managed yet") 293 print("FIXME: MUC status not managed yet")
286 #FIXME: gof 294 #FIXME:
287 295
288 def receivedSubject(self, room, user, subject): 296 def receivedSubject(self, room, user, subject):
289 debug (_("New subject for room (%(room_id)s): %(subject)s") % {'room_id':room.roomJID.full(),'subject':subject}) 297 debug (_("New subject for room (%(room_id)s): %(subject)s") % {'room_id':room.roomJID.full(),'subject':subject})
290 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) 298 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
291 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) 299 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)