Mercurial > libervia-web
comparison src/browser/sat_browser/dialog.py @ 686:90a5a5af2550
browser_side: let the backend check for the validity of MUC JIDs that come from a user input
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 27 Mar 2015 00:15:42 +0100 |
parents | 9877607c719a |
children | 7a9c7b9f6a28 |
comparison
equal
deleted
inserted
replaced
685:9877607c719a | 686:90a5a5af2550 |
---|---|
19 | 19 |
20 from sat.core.log import getLogger | 20 from sat.core.log import getLogger |
21 log = getLogger(__name__) | 21 log = getLogger(__name__) |
22 | 22 |
23 from constants import Const as C | 23 from constants import Const as C |
24 from sat_frontends.tools.misc import DEFAULT_MUC | |
25 from sat_frontends.tools import jid | 24 from sat_frontends.tools import jid |
26 | 25 |
27 from pyjamas.ui.VerticalPanel import VerticalPanel | 26 from pyjamas.ui.VerticalPanel import VerticalPanel |
28 from pyjamas.ui.Grid import Grid | 27 from pyjamas.ui.Grid import Grid |
29 from pyjamas.ui.HorizontalPanel import HorizontalPanel | 28 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
53 class RoomChooser(Grid): | 52 class RoomChooser(Grid): |
54 """Select a room from the rooms you already joined, or create a new one""" | 53 """Select a room from the rooms you already joined, or create a new one""" |
55 | 54 |
56 GENERATE_MUC = "<use random name>" | 55 GENERATE_MUC = "<use random name>" |
57 | 56 |
58 def __init__(self, host, default_room=DEFAULT_MUC): | 57 def __init__(self, host, default_room=C.DEFAULT_MUC): |
59 """ | 58 """ |
60 | 59 |
61 @param host (SatWebFrontend) | 60 @param host (SatWebFrontend) |
62 """ | 61 """ |
63 Grid.__init__(self, 2, 2, Width='100%') | 62 Grid.__init__(self, 2, 2, Width='100%') |
202 button_panel.addStyleName("marginAuto") | 201 button_panel.addStyleName("marginAuto") |
203 ok_button = Button("OK", self.onOK) | 202 ok_button = Button("OK", self.onOK) |
204 button_panel.add(ok_button) | 203 button_panel.add(ok_button) |
205 button_panel.add(Button("Cancel", self.onCancel)) | 204 button_panel.add(Button("Cancel", self.onCancel)) |
206 | 205 |
207 self.room_panel = RoomChooser(host, "" if visible == (False, True) else DEFAULT_MUC) | 206 self.room_panel = RoomChooser(host, "" if visible == (False, True) else C.DEFAULT_MUC) |
208 self.contact_panel = ContactsChooser(host, nb_contact, ok_button) | 207 self.contact_panel = ContactsChooser(host, nb_contact, ok_button) |
209 | 208 |
210 self.stack_panel = base_panel.ToggleStackPanel(Width="100%") | 209 self.stack_panel = base_panel.ToggleStackPanel(Width="100%") |
211 self.stack_panel.add(self.room_panel, visible=visible[0]) | 210 self.stack_panel.add(self.room_panel, visible=visible[0]) |
212 self.stack_panel.add(self.contact_panel, visible=visible[1]) | 211 self.stack_panel.add(self.contact_panel, visible=visible[1]) |
261 """ | 260 """ |
262 self.contact_panel.refreshOptions(keep_selected=True) | 261 self.contact_panel.refreshOptions(keep_selected=True) |
263 | 262 |
264 def onOK(self, sender): | 263 def onOK(self, sender): |
265 room = self.room # pyjamas issue: you need to use an intermediate variable to access a property's method | 264 room = self.room # pyjamas issue: you need to use an intermediate variable to access a property's method |
266 if room and not room.is_valid(): | |
267 Window.alert('You must enter a room jid in the form room@chat.%s' % self.host._defaultDomain) | |
268 return | |
269 self.hide() | 265 self.hide() |
270 self.callback(room, self.contacts) | 266 self.callback(room, self.contacts) |
271 | 267 |
272 def onCancel(self, sender): | 268 def onCancel(self, sender): |
273 self.hide() | 269 self.hide() |