Added Events Dump plugin, that prints out to console info about selected events when they occur.
This commit is contained in:
		
							parent
							
								
									06aee9d2d0
								
							
						
					
					
						commit
						8ec03d822e
					
				
					 5 changed files with 91 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -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))
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								plugins/events_dump/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								plugins/events_dump/__init__.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
from plugin import EventsDumpPlugin
 | 
			
		||||
							
								
								
									
										80
									
								
								plugins/events_dump/plugin.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								plugins/events_dump/plugin.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
##
 | 
			
		||||
'''
 | 
			
		||||
Events Dump plugin.
 | 
			
		||||
 | 
			
		||||
Dumps info about selected events to console. 
 | 
			
		||||
 | 
			
		||||
:author: Mateusz Biliński <mateusz@bilinski.it>
 | 
			
		||||
:since: 10th August 2008
 | 
			
		||||
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
 | 
			
		||||
: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 <mateusz@bilinski.it>']
 | 
			
		||||
	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
 | 
			
		||||
							
								
								
									
										12
									
								
								src/gajim.py
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
		
 | 
			
		||||
				
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue