changeset 1068:1513511a0586

plugin XEP-0045: room configuration returns a success or failure message
author souliane <souliane@mailoo.org>
date Thu, 12 Jun 2014 18:56:08 +0200
parents f7f15d44fdfa
children 8e1f30aa3975
files src/plugins/plugin_xep_0045.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 <http://www.gnu.org/licenses/>.
 
-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