From 9b773e6909e2322ddcb05067505a761beec2f3ca Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 9 Feb 2015 12:13:26 +0100 Subject: Change the bookmark interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit move the modulename to bookmark → boookmarks add a bookmarklist class with remove module-level variables do a features check on startup before trying to fetch the bookmarks --- src/core/core.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/core/core.py') diff --git a/src/core/core.py b/src/core/core.py index 807ca0cc..34d733ba 100644 --- a/src/core/core.py +++ b/src/core/core.py @@ -10,7 +10,6 @@ import logging log = logging.getLogger(__name__) import asyncio -import collections import shutil import curses import os @@ -18,22 +17,20 @@ import pipes import sys import time from threading import Event -from datetime import datetime from gettext import gettext as _ from slixmpp.xmlstream.handler import Callback -import bookmark import connection import decorators import events -import fixes import singleton import tabs import theming import timed_events import windows +from bookmarks import BookmarkList from common import safeJID from config import config, firstrun from contact import Contact, Resource @@ -75,6 +72,7 @@ class Core(object): self.keyboard = keyboard.Keyboard() roster.set_node(self.xmpp.client_roster) decorators.refresh_wrapper.core = self + self.bookmarks = BookmarkList() self.paused = False self.event = Event() self.debug = False @@ -311,6 +309,8 @@ class Core(object): theming.update_themes_dir) self.add_configuration_handler("theme", self.on_theme_config_change) + self.add_configuration_handler("use_bookmarks_method", + self.on_bookmarks_method_config_change) self.add_configuration_handler("password", self.on_password_change) self.add_configuration_handler("enable_vertical_tab_list", @@ -351,6 +351,14 @@ class Core(object): for callback in self.configuration_change_handlers[option]: callback(option, value) + def on_bookmarks_method_config_change(self, option, value): + """ + Called when the use_bookmarks_method option changes + """ + if 'value' not in ('pep', 'privatexml'): + return + self.bookmarks.preferred = value + def on_gaps_config_change(self, option, value): """ Called when the option create_gaps is changed. @@ -840,7 +848,7 @@ class Core(object): Returns the nickname associated with a bookmark or the default nickname """ - bm = bookmark.get_by_jid(room_name) + bm = self.bookmarks[room_name] if bm: return bm.nick return self.own_nick @@ -1980,6 +1988,7 @@ class Core(object): on_receipt = handlers.on_receipt on_attention = handlers.on_attention room_error = handlers.room_error + check_bookmark_storage = handlers.check_bookmark_storage outgoing_stanza = handlers.outgoing_stanza incoming_stanza = handlers.incoming_stanza validate_ssl = handlers.validate_ssl -- cgit v1.2.3