Package plugins :: Module pluginmanager :: Class PluginManager
[hide private]
[frames] | no frames]

Class PluginManager

source code


Main plug-in management class.

Currently:

To Do:
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_plugin_has_entry_in_global_config(self, plugin) source code
 
_create_plugin_entry_in_global_config(self, plugin) source code
 
add_plugin(self, plugin_class)
and adding class from reloaded module or ignoring adding plug-in?
source code
 
add_plugins(self, plugin_classes) source code
 
gui_extension_point(self, gui_extpoint_name, *args)
Invokes all handlers (from plugins) for particular GUI extension point and adds it to collection for further processing (eg.
source code
 
remove_gui_extension_point(self, gui_extpoint_name, *args)
Removes GUI extension point from collection held by PluginManager.
source code
 
_add_gui_extension_point_call_to_list(self, gui_extpoint_name, *args)
Adds GUI extension point call to list of calls.
source code
 
_execute_all_handlers_of_gui_extension_point(self, gui_extpoint_name, *args) source code
 
_register_events_handlers_in_ged(self, plugin) source code
 
_remove_events_handler_from_ged(self, plugin) source code
 
_register_network_events_in_nec(self, plugin) source code
 
_remove_network_events_from_nec(self, plugin) source code
 
activate_plugin(self, plugin) source code
 
deactivate_plugin(self, plugin) source code
 
_deactivate_all_plugins(self) source code
 
_add_gui_extension_points_handlers_from_plugin(self, plugin) source code
 
_handle_all_gui_extension_points_with_plugin(self, plugin) source code
 
_activate_all_plugins(self)
Activates all plugins in plugins.
source code
 
_activate_all_plugins_from_global_config(self) source code
 
_plugin_is_active_in_global_config(self, plugin) source code
 
_set_plugin_active_in_global_config(self, plugin, active=True) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
[] of class objects
scan_dir_for_plugins(path)
Scans given directory for plugin classes.
source code
Class Variables [hide private]
  __metaclass__ = Singleton
Instance Variables [hide private]
[] of class objects plugins
Detected plugin classes.
[] of GajimPlugin based objects active_plugins
Instance objects of active plugins.
  gui_extension_points
Registered GUI extension points.
  gui_extension_points_handlers
Registered handlers of GUI extension points.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

_plugin_has_entry_in_global_config(self, plugin)

source code 
Decorators:
  • @log_calls('PluginManager')

_create_plugin_entry_in_global_config(self, plugin)

source code 
Decorators:
  • @log_calls('PluginManager')

add_plugin(self, plugin_class)

source code 
and adding class from reloaded module or ignoring adding plug-in?
Decorators:
  • @log_calls('PluginManager')

To Do: what about adding plug-ins that are already added? Module reload

add_plugins(self, plugin_classes)

source code 
Decorators:
  • @log_calls('PluginManager')

gui_extension_point(self, gui_extpoint_name, *args)

source code 
Invokes all handlers (from plugins) for particular GUI extension point and adds it to collection for further processing (eg. by plugins not active yet).
Parameters:
  • gui_extpoint_name (unicode) - name of GUI extension point.
  • args (tuple) - parameters to be passed to extension point handlers (typically and object that invokes gui_extension_point; however, this can be practically anything)
Decorators:
  • @log_calls('PluginManager')

To Do: GUI extension points must be documented well - names with parameters that will be passed to handlers (in plugins). Such documentation must be obeyed both in core and in plugins. This is a loosely coupled approach and is pretty natural in Python.

Bug: what if only some handlers are successfully connected? we should revert all those connections that where successfully made. Maybe call 'self._deactivate_plugin()' or sth similar. Looking closer - we only rewrite tuples here. Real check should be made in method that invokes gui_extpoints handlers.

remove_gui_extension_point(self, gui_extpoint_name, *args)

source code 

Removes GUI extension point from collection held by PluginManager.

From this point this particular extension point won't be visible to plugins (eg. it won't invoke any handlers when plugin is activated).

GUI extension point is removed completely (there is no way to recover it from inside PluginManager).

Removal is needed when instance object that given extension point was connect with is destroyed (eg. ChatControl is closed or context menu is hidden).

Each PluginManager.gui_extension_point call should have a call of PluginManager.remove_gui_extension_point related to it.

Parameters:
  • gui_extpoint_name (unicode) - name of GUI extension point.
  • args (tuple) - arguments that PluginManager.gui_extension_point was called with for this extension point. This is used (along with extension point name) to identify element to be removed.
Decorators:
  • @log_calls('PluginManager')

Note: in current implementation different arguments mean different extension points. The same arguments and the same name mean the same extension point.

To Do: instead of using argument to identify which extpoint should be removed, maybe add additional 'id' argument - this would work similar hash in Python objects. 'id' would be calculated based on arguments passed or on anything else (even could be constant). This would give core developers (that add new extpoints) more freedom, but is this necessary?

_add_gui_extension_point_call_to_list(self, gui_extpoint_name, *args)

source code 

Adds GUI extension point call to list of calls.

This is done only if such call hasn't been added already (same extension point name and same arguments).

if they have different name or different arguments.

Parameters:
  • gui_extpoint_name (str) - GUI extension point name used to identify it by plugins.
  • args (tuple) - parameters to be passed to extension point handlers (typically and object that invokes gui_extension_point; however, this can be practically anything)
Decorators:
  • @log_calls('PluginManager')

Note: This is assumption that GUI extension points are different only

_execute_all_handlers_of_gui_extension_point(self, gui_extpoint_name, *args)

source code 
Decorators:
  • @log_calls('PluginManager')

_register_events_handlers_in_ged(self, plugin)

source code 

_remove_events_handler_from_ged(self, plugin)

source code 

_register_network_events_in_nec(self, plugin)

source code 

_remove_network_events_from_nec(self, plugin)

source code 

activate_plugin(self, plugin)

source code 
Parameters:
  • plugin (class object of GajimPlugin subclass) - plugin to be activated
Decorators:
  • @log_calls('PluginManager')

To Do: success checks should be implemented using exceptions. Such control should also be implemented in deactivation. Exceptions should be shown to user inside popup dialog, so the reason for not activating plugin is known.

deactivate_plugin(self, plugin)

source code 

_deactivate_all_plugins(self)

source code 

_add_gui_extension_points_handlers_from_plugin(self, plugin)

source code 
Decorators:
  • @log_calls('PluginManager')

_handle_all_gui_extension_points_with_plugin(self, plugin)

source code 
Decorators:
  • @log_calls('PluginManager')

_activate_all_plugins(self)

source code 

Activates all plugins in plugins.

Activated plugins are appended to active_plugins list.

Decorators:
  • @log_calls('PluginManager')

_activate_all_plugins_from_global_config(self)

source code 

_plugin_is_active_in_global_config(self, plugin)

source code 

_set_plugin_active_in_global_config(self, plugin, active=True)

source code 

scan_dir_for_plugins(path)
Static Method

source code 
Scans given directory for plugin classes.
Parameters:
  • path (unicode) - directory to scan for plugins
Returns: [] of class objects
list of found plugin classes (subclasses of GajimPlugin
Decorators:
  • @log_calls('PluginManager')

Note: currently it only searches for plugin classes in '*.py' files present in given direcotory path (no recursion here)

To Do:
  • add scanning packages
  • add scanning zipped modules

Class Variable Details [hide private]

__metaclass__

Value:
Singleton

Instance Variable Details [hide private]

plugins

Detected plugin classes.

Each class object in list is GajimPlugin subclass.

Type:
[] of class objects

active_plugins

Instance objects of active plugins.

These are object instances of classes held plugins, but only those that were activated.

Type:
[] of GajimPlugin based objects

gui_extension_points

Registered GUI extension points.

gui_extension_points_handlers

Registered handlers of GUI extension points.