improve manage bookmark jid handling. Fixes #7547

This commit is contained in:
Yann Leboulanger 2013-11-11 13:37:16 +01:00
parent 190bb38faf
commit 7d72b8089a
1 changed files with 16 additions and 5 deletions

View File

@ -3244,7 +3244,8 @@ class ManageBookmarksWindow:
self.server_entry = self.xml.get_object('server_entry') self.server_entry = self.xml.get_object('server_entry')
self.server_entry.connect('changed', self.on_server_entry_changed) self.server_entry.connect('changed', self.on_server_entry_changed)
self.room_entry = self.xml.get_object('room_entry') self.room_entry = self.xml.get_object('room_entry')
self.room_entry.connect('changed', self.on_room_entry_changed) self.room_entry_changed_id = self.room_entry.connect('changed',
self.on_room_entry_changed)
self.pass_entry = self.xml.get_object('pass_entry') self.pass_entry = self.xml.get_object('pass_entry')
self.pass_entry.connect('changed', self.on_pass_entry_changed) self.pass_entry.connect('changed', self.on_pass_entry_changed)
self.autojoin_checkbutton = self.xml.get_object('autojoin_checkbutton') self.autojoin_checkbutton = self.xml.get_object('autojoin_checkbutton')
@ -3385,7 +3386,9 @@ class ManageBookmarksWindow:
self.title_entry.set_text(model[iter_][1]) self.title_entry.set_text(model[iter_][1])
room_jid = model[iter_][2] room_jid = model[iter_][2]
(room, server) = room_jid.split('@') (room, server) = room_jid.split('@')
self.room_entry.handler_block(self.room_entry_changed_id)
self.room_entry.set_text(room) self.room_entry.set_text(room)
self.room_entry.handler_unblock(self.room_entry_changed_id)
self.server_entry.set_text(server) self.server_entry.set_text(server)
self.autojoin_checkbutton.set_active(model[iter_][3]) self.autojoin_checkbutton.set_active(model[iter_][3])
@ -3437,13 +3440,17 @@ class ManageBookmarksWindow:
if not iter_: if not iter_:
return return
server = widget.get_text() server = widget.get_text()
if not server:
return
if '@' in server: if '@' in server:
dialogs.ErrorDialog(_('Invalid server'), dialogs.ErrorDialog(_('Invalid server'),
_('Character not allowed'), transient_for=self.window) _('Character not allowed'), transient_for=self.window)
widget.set_text(server.replace('@', '')) widget.set_text(server.replace('@', ''))
room_jid = self.room_entry.get_text().strip() + '@' + \ room = self.room_entry.get_text().strip()
server.strip() if not room:
return
room_jid = room + '@' + server.strip()
try: try:
room_jid = helpers.parse_jid(room_jid) room_jid = helpers.parse_jid(room_jid)
except helpers.InvalidFormat as e: except helpers.InvalidFormat as e:
@ -3458,14 +3465,18 @@ class ManageBookmarksWindow:
if not iter_: if not iter_:
return return
room = widget.get_text() room = widget.get_text()
if not room:
return
if '@' in room: if '@' in room:
room, server = room.split('@', 1) room, server = room.split('@', 1)
widget.set_text(room) widget.set_text(room)
if server: if server:
self.server_entry.set_text(server) self.server_entry.set_text(server)
self.server_entry.grab_focus() self.server_entry.grab_focus()
room_jid = room.strip() + '@' + \ server = self.server_entry.get_text().strip()
self.server_entry.get_text().strip() if not server:
return
room_jid = room.strip() + '@' + server
try: try:
room_jid = helpers.parse_jid(room_jid) room_jid = helpers.parse_jid(room_jid)
except helpers.InvalidFormat: except helpers.InvalidFormat: