comparison src/plugins/plugin_xep_0045.py @ 519:b7577230a7c8

reverted bad commit
author Goffi <goffi@goffi.org>
date Sun, 21 Oct 2012 12:55:27 +0200
parents 75216d94a89d
children 3446ce33247d
comparison
equal deleted inserted replaced
518:75216d94a89d 519:b7577230a7c8
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)
138 129
139 def getRoomsSubjects(self, profile_key='@DEFAULT@'): 130 def getRoomsSubjects(self, profile_key='@DEFAULT@'):
140 """Return received subjects of rooms""" 131 """Return received subjects of rooms"""
141 profile = self.host.memory.getProfileName(profile_key) 132 profile = self.host.memory.getProfileName(profile_key)
142 if not self.__check_profile(profile): 133 if not self.__check_profile(profile):
216 return self.leave(jid.JID(room_jid_s), profile_key) 207 return self.leave(jid.JID(room_jid_s), profile_key)
217 208
218 def getHandler(self, profile): 209 def getHandler(self, profile):
219 self.clients[profile] = SatMUCClient(self) 210 self.clients[profile] = SatMUCClient(self)
220 return self.clients[profile] 211 return self.clients[profile]
212
221 213
222 214
223 class SatMUCClient (muc.MUCClient): 215 class SatMUCClient (muc.MUCClient):
224 #implements(iwokkel.IDisco) 216 #implements(iwokkel.IDisco)
225 217
226 def __init__(self, plugin_parent): 218 def __init__(self, plugin_parent):
227 self.plugin_parent = plugin_parent 219 self.plugin_parent = plugin_parent
228 self.host = plugin_parent.host 220 self.host = plugin_parent.host
229 muc.MUCClient.__init__(self) 221 muc.MUCClient.__init__(self)
230 self.joined_rooms = {} #FIXME: seem to do the same thing as MUCClient's _rooms attribute, must be removed 222 self.joined_rooms = {}
231 self.rec_subjects = {} 223 self.rec_subjects = {}
232 self.__changing_nicks = set() # used to keep trace of who is changing nick, 224 self.__changing_nicks = set() # used to keep trace of who is changing nick,
233 # and to discard userJoinedRoom signal in this case 225 # and to discard userJoinedRoom signal in this case
234 print "init SatMUCClient OK" 226 print "init SatMUCClient OK"
235 227
289 def userChangedNick(self, room, user, new_nick): 281 def userChangedNick(self, room, user, new_nick):
290 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile) 282 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile)
291 283
292 def userUpdatedStatus(self, room, user, show, status): 284 def userUpdatedStatus(self, room, user, show, status):
293 print("FIXME: MUC status not managed yet") 285 print("FIXME: MUC status not managed yet")
294 #FIXME: 286 #FIXME: gof
295 287
296 def receivedSubject(self, room, user, subject): 288 def receivedSubject(self, room, user, subject):
297 debug (_("New subject for room (%(room_id)s): %(subject)s") % {'room_id':room.roomJID.full(),'subject':subject}) 289 debug (_("New subject for room (%(room_id)s): %(subject)s") % {'room_id':room.roomJID.full(),'subject':subject})
298 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) 290 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
299 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) 291 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)