xs:boolean is '0', '1', 'true', 'false'. so update bookmark to handle the last two

This commit is contained in:
Nikos Kouremenos 2005-08-18 19:06:24 +00:00
parent c5a389f687
commit bd0a5230d9
4 changed files with 24 additions and 9 deletions

View File

@ -1117,9 +1117,12 @@ class Connection:
confs = storage.getTags('conference') confs = storage.getTags('conference')
urls = storage.getTags('url') urls = storage.getTags('url')
for conf in confs: for conf in confs:
autojoin_val = conf.getAttr('autojoin')
if autojoin_val is None: # not there (it's optional)
autojoin_val == False
bm = { 'name': conf.getAttr('name'), bm = { 'name': conf.getAttr('name'),
'jid': conf.getAttr('jid'), 'jid': conf.getAttr('jid'),
'autojoin': conf.getAttr('autojoin'), 'autojoin': autojoin_val,
'password': conf.getTagData('password'), 'password': conf.getTagData('password'),
'nick': conf.getTagData('nick') } 'nick': conf.getTagData('nick') }

View File

@ -274,3 +274,14 @@ def get_file_path_from_dnd_dropped_uri(uri):
elif path.startswith('file:'): # xffm elif path.startswith('file:'): # xffm
path = path[5:] # 5 is len('file:') path = path[5:] # 5 is len('file:')
return path return path
def from_xs_boolean_to_python_boolean(value):
# this is xs:boolean so 'true','false','1','0'
# convert those to True/False (python booleans)
if val in ('1', 'true'):
val = True
else: # '0', 'false' or anything else
val = False
return val

View File

@ -2500,13 +2500,14 @@ class ManageBookmarksWindow:
for bookmark in gajim.connections[account].bookmarks: for bookmark in gajim.connections[account].bookmarks:
if bookmark['name'] == '': if bookmark['name'] == '':
#No name was given for this bookmark. # No name was given for this bookmark.
#Use the first part of JID instead... # Use the first part of JID instead...
name = bookmark['jid'].split("@")[0] name = bookmark['jid'].split("@")[0]
bookmark['name'] = name bookmark['name'] = name
#Convert '1'/'0' to True/False # make '1', '0', 'true', 'false' (or other) to True/False
autojoin = bool(int(bookmark['autojoin'])) autojoin = helpers.from_xs_boolean_to_python_boolean(
bookmark['autojoin'])
self.treestore.append( iter, [ self.treestore.append( iter, [
account, account,

View File

@ -685,11 +685,11 @@ class Interface:
self.remote.raise_signal('RosterInfo', (account, array)) self.remote.raise_signal('RosterInfo', (account, array))
def handle_event_bookmarks(self, account, bms): def handle_event_bookmarks(self, account, bms):
#('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}]) # ('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}])
#We received a bookmark item from the server (JEP48) # We received a bookmark item from the server (JEP48)
#Auto join GC windows if neccessary # Auto join GC windows if neccessary
for bm in bms: for bm in bms:
if bm['autojoin'] == '1': if bm['autojoin'] in ('1', 'true'):
self.roster.join_gc_room(account, bm['jid'], bm['nick'], self.roster.join_gc_room(account, bm['jid'], bm['nick'],
bm['password']) bm['password'])
self.roster.make_menu() self.roster.make_menu()