diff --git a/src/common/connection.py b/src/common/connection.py index 7bdbb00b1..fcdd6c93a 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1117,9 +1117,12 @@ class Connection: confs = storage.getTags('conference') urls = storage.getTags('url') 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'), 'jid': conf.getAttr('jid'), - 'autojoin': conf.getAttr('autojoin'), + 'autojoin': autojoin_val, 'password': conf.getTagData('password'), 'nick': conf.getTagData('nick') } diff --git a/src/common/helpers.py b/src/common/helpers.py index baa087eb7..29f3dac66 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -274,3 +274,14 @@ def get_file_path_from_dnd_dropped_uri(uri): elif path.startswith('file:'): # xffm path = path[5:] # 5 is len('file:') 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 + diff --git a/src/config.py b/src/config.py index 794bbf6ab..27a0ad142 100644 --- a/src/config.py +++ b/src/config.py @@ -2500,13 +2500,14 @@ class ManageBookmarksWindow: for bookmark in gajim.connections[account].bookmarks: if bookmark['name'] == '': - #No name was given for this bookmark. - #Use the first part of JID instead... + # No name was given for this bookmark. + # Use the first part of JID instead... name = bookmark['jid'].split("@")[0] bookmark['name'] = name - #Convert '1'/'0' to True/False - autojoin = bool(int(bookmark['autojoin'])) + # make '1', '0', 'true', 'false' (or other) to True/False + autojoin = helpers.from_xs_boolean_to_python_boolean( + bookmark['autojoin']) self.treestore.append( iter, [ account, diff --git a/src/gajim.py b/src/gajim.py index 194a7e17f..cb5985229 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -685,11 +685,11 @@ class Interface: self.remote.raise_signal('RosterInfo', (account, array)) def handle_event_bookmarks(self, account, bms): - #('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}]) - #We received a bookmark item from the server (JEP48) - #Auto join GC windows if neccessary + # ('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}]) + # We received a bookmark item from the server (JEP48) + # Auto join GC windows if neccessary for bm in bms: - if bm['autojoin'] == '1': + if bm['autojoin'] in ('1', 'true'): self.roster.join_gc_room(account, bm['jid'], bm['nick'], bm['password']) self.roster.make_menu()