From 8ec03d822ec2460290364bad77f0168463c490c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Bili=C5=84ski?= Date: Mon, 11 Aug 2008 15:22:56 +0000 Subject: [PATCH] Added Events Dump plugin, that prints out to console info about selected events when they occur. --- plugins/dbus_plugin/plugin.py | 2 +- plugins/events_dump/__init__.py | 1 + plugins/events_dump/plugin.py | 80 +++++++++++++++++++++++++++++++++ src/gajim.py | 12 +++-- src/plugins/pluginmanager.py | 2 +- 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 plugins/events_dump/__init__.py create mode 100644 plugins/events_dump/plugin.py diff --git a/plugins/dbus_plugin/plugin.py b/plugins/dbus_plugin/plugin.py index 8141d83d3..b894a3859 100644 --- a/plugins/dbus_plugin/plugin.py +++ b/plugins/dbus_plugin/plugin.py @@ -109,7 +109,7 @@ Gajim core but uses new events handling system.''' def _generate_handling_method(self, event_name): def handler(self, arg): - print "Handler of event %s called"%(event_name) + #print "Handler of event %s called"%(event_name) if self.signal_object: getattr(self.signal_object, event_name)(get_dbus_struct(arg)) diff --git a/plugins/events_dump/__init__.py b/plugins/events_dump/__init__.py new file mode 100644 index 000000000..fc198d87d --- /dev/null +++ b/plugins/events_dump/__init__.py @@ -0,0 +1 @@ +from plugin import EventsDumpPlugin \ No newline at end of file diff --git a/plugins/events_dump/plugin.py b/plugins/events_dump/plugin.py new file mode 100644 index 000000000..5d1f9bf29 --- /dev/null +++ b/plugins/events_dump/plugin.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +## +## This file is part of Gajim. +## +## Gajim is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation; version 3 only. +## +## Gajim is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Gajim. If not, see . +## +''' +Events Dump plugin. + +Dumps info about selected events to console. + +:author: Mateusz Biliński +:since: 10th August 2008 +:copyright: Copyright (2008) Mateusz Biliński +:license: GPL +''' + +import new +from pprint import pformat + +from plugins import GajimPlugin +from plugins.helpers import log_calls, log +from common import ged + +class EventsDumpPlugin(GajimPlugin): + name = u'Events Dump' + short_name = u'events_dump' + version = u'0.1' + description = u'''Dumps info about selected events to console.''' + authors = [u'Mateusz Biliński '] + homepage = u'http://blog.bilinski.it' + + @log_calls('DBusPlugin') + def init(self): + self.config_dialog = None + #self.gui_extension_points = {} + #self.config_default_values = {} + + self.events_names = ['Roster', 'AccountPresence', 'ContactPresence', + 'ContactAbsence', 'ContactStatus', 'NewMessage', + 'Subscribe', 'Subscribed', 'Unsubscribed', + 'NewAccount', 'VcardInfo', 'LastStatusTime', + 'OsInfo', 'GCPresence', 'GCMessage', 'RosterInfo', + 'NewGmail'] + + self.events_handlers = {} + self._set_handling_methods() + + + def activate(self): + pass + + def deactivate(self): + pass + + def _set_handling_methods(self): + for event_name in self.events_names: + setattr(self, event_name, + new.instancemethod( + self._generate_handling_method(event_name), + self, + EventsDumpPlugin)) + self.events_handlers[event_name] = (ged.POSTCORE, + getattr(self, event_name)) + + def _generate_handling_method(self, event_name): + def handler(self, *args): + print "Event '%s' occured. Arguments: %s"%(event_name, pformat(*args)) + + return handler \ No newline at end of file diff --git a/src/gajim.py b/src/gajim.py index 7b9152646..19f5232c1 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -3344,7 +3344,14 @@ class Interface: self.handle_event_file_rcv_completed, self.handle_event_file_progress) gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue) + + # Creating Global Events Dispatcher + from common import ged + gajim.ged = ged.GlobalEventsDispatcher() + self.register_core_handlers() + self.register_handlers() + if gajim.config.get('enable_zeroconf'): gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME) for account in gajim.config.get_per('accounts'): @@ -3489,10 +3496,7 @@ class Interface: gobject.timeout_add_seconds(gajim.config.get( 'check_idle_every_foo_seconds'), self.read_sleepy) - # Creating Global Events Dispatcher - from common import ged - gajim.ged = ged.GlobalEventsDispatcher() - self.register_core_handlers() + # Creating plugin manager import plugins diff --git a/src/plugins/pluginmanager.py b/src/plugins/pluginmanager.py index 4ee6f20da..23d514a1c 100644 --- a/src/plugins/pluginmanager.py +++ b/src/plugins/pluginmanager.py @@ -202,7 +202,7 @@ class PluginManager(object): ''' if gui_extpoint_name in self.gui_extension_points: - log.debug('Removing GUI extpoint\n name: %s\n args: %s'%(gui_extpoint_name, args)) + #log.debug('Removing GUI extpoint\n name: %s\n args: %s'%(gui_extpoint_name, args)) self.gui_extension_points[gui_extpoint_name].remove(args)