Wrap global gajim.handlers with a dispatch method.

This commit is contained in:
Stephan Erb 2009-10-18 20:53:15 +02:00
parent 57ed1ea8d8
commit 3665c99800
3 changed files with 13 additions and 10 deletions

View File

@ -194,14 +194,9 @@ class Connection(ConnectionHandlers):
self.secret_hmac = str(random.random())[2:] self.secret_hmac = str(random.random())[2:]
# END __init__ # END __init__
def put_event(self, ev):
if ev[0] in gajim.handlers:
log.debug('Sending %s event to GUI: %s' % (ev[0], ev[1:]))
gajim.handlers[ev[0]](self.name, ev[1])
def dispatch(self, event, data): def dispatch(self, event, data):
'''always passes account name as first param''' '''always passes account name as first param'''
self.put_event((event, data)) gajim.interface.dispatch(event, self.name, data)
def _reconnect(self): def _reconnect(self):

View File

@ -137,9 +137,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
# END __init__ # END __init__
def dispatch(self, event, data): def dispatch(self, event, data):
if event in gajim.handlers: gajim.interface.dispatch(event, self.name, data)
gajim.handlers[event](self.name, data)
def _reconnect(self): def _reconnect(self):
# Do not try to reco while we are already trying # Do not try to reco while we are already trying

View File

@ -2359,7 +2359,17 @@ class Interface:
'PUBSUB_NODE_REMOVED': self.handle_event_pubsub_node_removed, 'PUBSUB_NODE_REMOVED': self.handle_event_pubsub_node_removed,
'PUBSUB_NODE_NOT_REMOVED': self.handle_event_pubsub_node_not_removed, 'PUBSUB_NODE_NOT_REMOVED': self.handle_event_pubsub_node_not_removed,
} }
gajim.handlers = self.handlers
def dispatch(self, event, account, data):
'''
Dispatches an network event to the event handlers of this class
'''
if event not in self.handlers:
log.warning('Unknown event %s dispatched to GUI: %s' % (event, data))
else:
log.debug('Event %s distpached to GUI: %s' % (event, data))
self.handlers[event](account, data)
################################################################################ ################################################################################
### Methods dealing with gajim.events ### Methods dealing with gajim.events