diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index c5a93b4b8..26c7fbf63 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -137,7 +137,8 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): # END __init__ def dispatch(self, event, data): - gajim.interface.dispatch(event, self.name, data) + #gajim.interface.dispatch(event, self.name, data) + gajim.ged.raise_event(event, self.name, data) def _reconnect(self): # Do not try to reco while we are already trying diff --git a/src/gui_interface.py b/src/gui_interface.py index 812aba08a..8e1243264 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -85,6 +85,7 @@ import roster_window import profile_window import config from threading import Thread +from common import ged gajimpaths = common.configpaths.gajimpaths config_filename = gajimpaths['CONFIG_FILE'] @@ -1988,18 +1989,8 @@ class Interface: dialogs.WarningDialog(_('PEP node was not removed'), _('PEP node %(node)s was not removed: %(message)s') % { 'node': data[1], 'message': data[2]}) - - def register_handler(self, event, handler): - if event not in self.handlers: - self.handlers[event] = [] - if handler not in self.handlers[event]: - self.handlers[event].append(handler) - - def unregister_handler(self, event, handler): - self.handlers[event].remove(handler) - - def register_handlers(self): + def create_core_handlers_list(self): self.handlers = { 'ROSTER': [self.handle_event_roster], 'WARNING': [self.handle_event_warning], @@ -2089,22 +2080,18 @@ class Interface: 'JINGLE_DISCONNECTED': [self.handle_event_jingle_disconnected], 'JINGLE_ERROR': [self.handle_event_jingle_error], } - - def dispatch(self, event, account, data): + + def register_core_handlers(self): ''' - Dispatches an network event to the event handlers of this class. - - Return true if it could be dispatched to alteast one handler. + Register core handlers in Global Events Dispatcher (GED). + + This is part of rewriting whole events handling system to use GED. ''' - if event not in self.handlers: - log.warning('Unknown event %s dispatched to GUI: %s' % (event, data)) - return False - else: - log.debug('Event %s distpached to GUI: %s' % (event, data)) - for handler in self.handlers[event]: - handler(account, data) - return len(self.handlers[event]) - + for event_name, event_handlers in self.handlers.iteritems(): + for event_handler in event_handlers: + gajim.ged.register_event_handler(event_name, + ged.CORE, + event_handler) ################################################################################ ### Methods dealing with gajim.events @@ -3142,6 +3129,10 @@ class Interface: pass gobject.timeout_add_seconds(5, remote_init) + # Creating plugin manager + import plugins + gajim.plugin_manager = plugins.PluginManager() + def __init__(self): gajim.interface = self @@ -3235,7 +3226,16 @@ class Interface: self.handle_event_file_error) gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue) gajim.default_session_type = ChatControlSession - self.register_handlers() + + # Creating Global Events Dispatcher + from common import ged + gajim.ged = ged.GlobalEventsDispatcher() + # Creating Network Events Controller + from common import nec + gajim.nec = nec.NetworkEventsController() + self.create_core_handlers_list() + self.register_core_handlers() + if gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'active') \ and gajim.HAVE_ZEROCONF: gajim.connections[gajim.ZEROCONF_ACC_NAME] = \