comparison src/plugins/plugin_xep_0045.py @ 406:b03b38b20c18

plugin XEP-0045: send error on invalid room jid on _join
author Goffi <goffi@goffi.org>
date Sat, 08 Oct 2011 19:04:28 +0200
parents 10b4f577d0c0
children b4edea06ae12
comparison
equal deleted inserted replaced
405:10b4f577d0c0 406:b03b38b20c18
152 history_options = options["history"] == "True" if options.has_key("history") else None 152 history_options = options["history"] == "True" if options.has_key("history") else None
153 password = options["password"] if options.has_key("password") else None 153 password = options["password"] if options.has_key("password") else None
154 154
155 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile':profile}, errbackKeywords={'profile':profile}) 155 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile':profile}, errbackKeywords={'profile':profile})
156 156
157 def _join(self, room_jid, nick, options={}, profile_key='@DEFAULT@'): 157 def _join(self, room_jid_s, nick, options={}, profile_key='@DEFAULT@'):
158 """join method used by bridge: use the _join method, but doesn't return any deferred""" 158 """join method used by bridge: use the _join method, but doesn't return any deferred"""
159 d = self.join(jid.JID(room_jid), nick, options, profile_key) 159 profile = self.host.memory.getProfileName(profile_key)
160 if not self.__check_profile(profile):
161 return
162 try:
163 room_jid = jid.JID(room_jid_s)
164 except:
165 mess = _("Invalid room jid: %s") % room_jid_s
166 warning(mess)
167 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile)
168 return
169 d = self.join(jid.JID(room_jid), nick, options, profile)
160 d.addErrback(lambda x: warning(_('Error while joining room'))) #TODO: error management + signal in bridge 170 d.addErrback(lambda x: warning(_('Error while joining room'))) #TODO: error management + signal in bridge
161 171
162 def getHandler(self, profile): 172 def getHandler(self, profile):
163 self.clients[profile] = SatMUCClient(self) 173 self.clients[profile] = SatMUCClient(self)
164 return self.clients[profile] 174 return self.clients[profile]