diff --git a/poezio/bookmarks.py b/poezio/bookmarks.py index 64d7a437..ede45b2e 100644 --- a/poezio/bookmarks.py +++ b/poezio/bookmarks.py @@ -121,9 +121,6 @@ class Bookmark: local = str(self.jid) if self.nick: local += '/%s' % self.nick - local += ':' - if self.password: - config.set_and_save('password', self.password, section=self.jid) return local @functools.singledispatch @@ -162,8 +159,9 @@ class Bookmark: class BookmarkList: def __init__(self): + self.config = config self.bookmarks: List[Bookmark] = [] - preferred = config.getstr('use_bookmarks_method').lower() + preferred = self.config.getstr('use_bookmarks_method').lower() if preferred not in ('pep', 'privatexml'): preferred = 'privatexml' self.preferred = preferred @@ -221,7 +219,7 @@ class BookmarkList: def set_bookmarks_method(self, value: str): if self.available_storage.get(value): self.preferred = value - config.set_and_save('use_bookmarks_method', value) + self.config.set_and_save('use_bookmarks_method', value) async def save_remote(self, xmpp: Connection): """Save the remote bookmarks.""" @@ -237,14 +235,19 @@ class BookmarkList: def save_local(self): """Save the local bookmarks.""" - local = ''.join(bookmark.local() for bookmark in self - if bookmark.method == 'local') - config.set_and_save('rooms', local) + local = [] + for bookmark in self: + if bookmark.method != 'local': + continue + local.append(bookmark.local()) + if bookmark.password: + self.config.set_and_save('password', bookmark.password, section=bookmark.jid) + self.config.set_and_save('rooms', ':'.join(local)) async def save(self, xmpp: Connection, core=None): """Save all the bookmarks.""" self.save_local() - if config.getbool('use_remote_bookmarks'): + if self.config.getbool('use_remote_bookmarks'): try: result = await self.save_remote(xmpp) if core is not None: @@ -292,7 +295,7 @@ class BookmarkList: def get_local(self): """Add the locally stored bookmarks to the list.""" - rooms = config.getlist('rooms') + rooms = self.config.getlist('rooms') if not rooms: return for room in rooms: @@ -306,7 +309,7 @@ class BookmarkList: nick = jid.resource else: nick = None - passwd = config.get_by_tabname( + passwd = self.config.get_by_tabname( 'password', jid.bare, fallback=False) or None b = Bookmark( jid.bare,