summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-07 19:48:16 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-07 19:48:16 +0100
commit54962e6796301f6fb57d09f7778ab50f69e35943 (patch)
treec1312f5cdc386970079f776b0477a24da0d9b599 /src/core.py
parent04f103b9e67ccd1de7376be4f7b5156ec425e99c (diff)
parent17e5411d8f050a3c5e5bcd010551eecac96b5911 (diff)
downloadpoezio-54962e6796301f6fb57d09f7778ab50f69e35943.tar.gz
poezio-54962e6796301f6fb57d09f7778ab50f69e35943.tar.bz2
poezio-54962e6796301f6fb57d09f7778ab50f69e35943.tar.xz
poezio-54962e6796301f6fb57d09f7778ab50f69e35943.zip
Merge branch 'plugins' of /home/louiz/git/poezio into plugins
Conflicts: src/core.py
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py60
1 files changed, 3 insertions, 57 deletions
diff --git a/src/core.py b/src/core.py
index aab82768..10e114e0 100644
--- a/src/core.py
+++ b/src/core.py
@@ -33,6 +33,7 @@ import multiuserchat as muc
import tabs
import xhtml
+import events
import pubsub
import windows
import connection
@@ -80,12 +81,6 @@ class Core(object):
User interface using ncurses
"""
- # dict containing the name of the internal events
- # used with the plugins, the key is the name of the event
- # and the value is the number of arguments the handler must take
- internal_events = {
- 'enter': 2,
- }
def __init__(self):
# All uncaught exception are given to this callback, instead
# of being displayed on the screen and exiting the program.
@@ -93,6 +88,7 @@ class Core(object):
self.status = Status(show=None, message='')
sys.excepthook = self.on_exception
self.running = True
+ self.events = events.EventHandler()
self.xmpp = singleton.Singleton(connection.Connection)
self.remote_fifo = None
# a unique buffer used to store global informations
@@ -180,6 +176,7 @@ class Core(object):
self.timed_events = set()
self.connected_events = {}
+
self.autoload_plugins()
def autoload_plugins(self):
@@ -213,57 +210,6 @@ class Core(object):
))
self.refresh_window()
- def connect(self, event, handler):
- """
- Connect an handler to an internal event of poezio
- (eg "enter pressed in a chattab")
- """
- # Fail if the method doesn’t take at least the good number of arguments
- # or if the event is unknown
- if not event in self.internal_events \
- or len(getargspec(handler).args) < self.internal_events[event]:
- return False
-
- module_name = handler.__module__
- if not event in self.connected_events:
- self.connected_events[event] = {}
- if not module_name in self.connected_events[event]:
- self.connected_events[event][module_name] = []
-
- self.connected_events[event][module_name].append(handler)
- return True
-
- def run_event(self, event, **kwargs):
- """
- Call the handlers associated with an event
- """
- if event in self.connected_events:
- for module in self.connected_events[event]:
- for handler in self.connected_events[event][module]:
- try:
- handler(**kwargs)
- except:
- import traceback
- tp = traceback.format_exc()
- module_name = handler.__name__
- log.debug('ERROR: in plugin %s, \n%s' % (module_name, tp))
-
- def disconnect(self, event, handler):
- """
- Disconnect a handler from an event
- """
- if not event in self.internal_events:
- return False
-
- module_name = getmodule(handler).__name__
- if not event in self.connected_events:
- return False
- if not module_name in self.connected_events[event]:
- return False
-
- self.connected_events[event][module_name].remove(handler)
- return True
-
def resize_global_information_win(self):
"""
Resize the global_information_win only once at each resize.