# HG changeset patch # User souliane # Date 1402592168 -7200 # Node ID 1513511a0586497cd25b8e74806782b2c2834442 # Parent f7f15d44fdfa4bfde28ec1b2401034bf3f2baf70 plugin XEP-0045: room configuration returns a success or failure message diff -r f7f15d44fdfa -r 1513511a0586 src/plugins/plugin_xep_0045.py --- a/src/plugins/plugin_xep_0045.py Thu Jun 12 18:19:55 2014 +0200 +++ b/src/plugins/plugin_xep_0045.py Thu Jun 12 18:56:08 2014 +0200 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from sat.core.i18n import _ +from sat.core.i18n import _, D_ from sat.core.constants import Const as C from sat.core.log import getLogger log = getLogger(__name__) @@ -124,9 +124,9 @@ # we have a nickname conflict, we try again with "_" suffixed to current nickname nick += '_' 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]) - mess = _("Error while joining the room %s" % room_jid.userhost()) + mess = D_("Error while joining the room %s" % room_jid.userhost()) log.error(mess) - self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) + self.host.bridge.newAlert(mess, D_("Group chat error"), "ERROR", profile) raise failure def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE): @@ -206,7 +206,7 @@ if not self.__check_profile(profile): raise exceptions.ProfileUnknownError("Unknown or disconnected profile") if room_jid.userhost() not in self.clients[profile].joined_rooms: - raise UnknownRoom("This room has not been joined") + raise UnknownRoom(D_("This room has not been joined")) def config2XMLUI(result): if not result: @@ -225,13 +225,16 @@ try: session_data = self._sessions.profileGet(raw_data["session_id"], profile) except KeyError: - log.warning ("session id doesn't exist, session has probably expired") - # TODO: send error dialog - return defer.succeed({}) + log.warning(D_("Session ID doesn't exist, session has probably expired.")) + _dialog = xml_tools.XMLUI('popup', title=D_('Room configuration failed')) + _dialog.addText(D_("Session ID doesn't exist, session has probably expired.")) + return defer.succeed({'xmlui': _dialog.toXml()}) data = xml_tools.XMLUIResult2DataFormResult(raw_data) d = self.clients[profile].configure(session_data['room_jid'], data) - d.addCallback(lambda ignore: {}) + _dialog = xml_tools.XMLUI('popup', title=D_('Room configuration succeed')) + _dialog.addText(D_("The new settings have been saved.")) + d.addCallback(lambda ignore: {'xmlui': _dialog.toXml()}) del self._sessions[raw_data["session_id"]] return d