Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0045.py @ 743:5a131930348d
plugin XEP-0045: remove redondant errback from _join
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 28 Nov 2013 21:27:18 +0100 |
parents | 03744d9ebc13 |
children | bfabeedbf32e |
comparison
equal
deleted
inserted
replaced
742:03744d9ebc13 | 743:5a131930348d |
---|---|
103 """Called when something is going wrong when joining the room""" | 103 """Called when something is going wrong when joining the room""" |
104 if hasattr(failure.value, "condition") and failure.value.condition == 'conflict': | 104 if hasattr(failure.value, "condition") and failure.value.condition == 'conflict': |
105 # we have a nickname conflict, we try again with "_" suffixed to current nickname | 105 # we have a nickname conflict, we try again with "_" suffixed to current nickname |
106 nick += '_' | 106 nick += '_' |
107 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile]) | 107 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile]) |
108 mess = _("Error when joining the room %s" % room_jid.userhost()) | 108 mess = _("Error while joining the room %s" % room_jid.userhost()) |
109 error(mess) | 109 error(mess) |
110 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) | 110 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) |
111 raise failure | 111 raise failure |
112 | 112 |
113 def getRoomsJoined(self, profile_key='@DEFAULT@'): | 113 def getRoomsJoined(self, profile_key='@DEFAULT@'): |
233 | 233 |
234 history_options = options["history"] == "True" if "history" in options else None | 234 history_options = options["history"] == "True" if "history" in options else None |
235 password = options["password"] if "password" in options else None | 235 password = options["password"] if "password" in options else None |
236 | 236 |
237 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile]) | 237 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile]) |
238 # FIXME: how to set the cancel method on the Deferred created by wokkel? | |
239 # This happens when the room is not reachable, e.g. no internet connection: | |
240 # > /usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py(480)_startRunCallbacks() | |
241 # -> raise AlreadyCalledError(extra) | |
238 | 242 |
239 def _join(self, room_jid_s, nick, options={}, profile_key='@DEFAULT@'): | 243 def _join(self, room_jid_s, nick, options={}, profile_key='@DEFAULT@'): |
240 """join method used by bridge: use the _join method, but doesn't return any deferred | 244 """join method used by bridge: use the join method, but doesn't return any deferred |
241 @return the room userhost (given value or unique generated name) | 245 @return the room userhost (given value or unique generated name) |
242 """ | 246 """ |
243 profile = self.host.memory.getProfileName(profile_key) | 247 profile = self.host.memory.getProfileName(profile_key) |
244 if not self.__check_profile(profile): | 248 if not self.__check_profile(profile): |
245 return | 249 return |
251 mess = _("Invalid room jid: %s") % room_jid_s | 255 mess = _("Invalid room jid: %s") % room_jid_s |
252 warning(mess) | 256 warning(mess) |
253 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) | 257 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) |
254 return | 258 return |
255 d = self.join(room_jid, nick, options, profile) | 259 d = self.join(room_jid, nick, options, profile) |
256 d.addErrback(lambda x: warning(_('Error while joining room'))) # TODO: error management + signal in bridge | 260 # TODO: error management + signal in bridge |
257 return room_jid_s | 261 return room_jid_s |
258 | 262 |
259 def nick(self, room_jid, nick, profile_key): | 263 def nick(self, room_jid, nick, profile_key): |
260 profile = self.host.memory.getProfileName(profile_key) | 264 profile = self.host.memory.getProfileName(profile_key) |
261 if not self.__check_profile(profile): | 265 if not self.__check_profile(profile): |
370 | 374 |
371 def receivedSubject(self, room, user, subject): | 375 def receivedSubject(self, room, user, subject): |
372 debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject}) | 376 debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject}) |
373 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) | 377 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) |
374 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) | 378 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) |
375 | |
376 #def connectionInitialized(self): | |
377 #pass | |
378 | |
379 #def getDiscoInfo(self, requestor, target, nodeIdentifier=''): | |
380 #return [disco.DiscoFeature(NS_VCARD)] | |
381 | |
382 #def getDiscoItems(self, requestor, target, nodeIdentifier=''): | |
383 #return [] |