#include <plugin/manager.h>
Inheritance diagram for fawkes::PluginManager:
Public Member Functions | |
PluginManager (ThreadCollector *thread_collector, Configuration *config, const char *meta_plugin_prefix) | |
Constructor. | |
~PluginManager () | |
Destructor. | |
virtual void | config_tag_changed (const char *new_tag) |
Called whenever the tag has changed. | |
virtual void | config_value_changed (const char *path, bool is_default, int value) |
Called whenever an int value has changed. | |
virtual void | config_value_changed (const char *path, bool is_default, unsigned int value) |
Called whenever an unsigned int value has changed. | |
virtual void | config_value_changed (const char *path, bool is_default, float value) |
Called whenever an float value has changed. | |
virtual void | config_value_changed (const char *path, bool is_default, bool value) |
Called whenever an boolean value has changed. | |
virtual void | config_value_changed (const char *path, bool is_default, const char *value) |
Called whenever a string value has changed. | |
virtual void | config_comment_changed (const char *path, bool is_default, const char *comment) |
Called whenever a comment has changed. | |
virtual void | config_value_erased (const char *path, bool is_default) |
Called whenever a value has been erased from the config. | |
virtual void | fam_event (const char *filename, unsigned int mask) |
Event has been raised. | |
void | load (const char *plugin_list) |
Load plugin. | |
void | unload (const char *plugin_name) |
Unload plugin. | |
bool | is_loaded (const char *plugin_name) |
Check if plugin is loaded. | |
std::list< std::string > | get_loaded_plugins () |
Get list of loaded plugins. | |
std::list< std::pair< std::string, std::string > > | get_available_plugins () |
Generate list of all available plugins. | |
void | add_listener (PluginManagerListener *listener) |
Add listener. | |
void | remove_listener (PluginManagerListener *listener) |
Remove listener. |
This class provides a manager for the plugins used in fawkes. It can load and unload modules.
Definition at line 52 of file manager.h.
fawkes::PluginManager::PluginManager | ( | ThreadCollector * | thread_collector, | |
Configuration * | config, | |||
const char * | meta_plugin_prefix | |||
) |
Constructor.
thread_collector | thread manager plugin threads will be added to and removed from appropriately. | |
config | Fawkes configuration | |
meta_plugin_prefix | Path prefix for meta plugins |
Definition at line 66 of file manager.cpp.
References fawkes::Configuration::add_change_handler(), and fawkes::LibLogger::log_warn().
fawkes::PluginManager::~PluginManager | ( | ) |
Destructor.
Definition at line 97 of file manager.cpp.
References fawkes::ThreadCollector::force_remove(), fawkes::LockList< Type >::lock(), fawkes::Configuration::rem_change_handler(), fawkes::PluginLoader::unload(), and fawkes::LockList< Type >::unlock().
void fawkes::PluginManager::add_listener | ( | PluginManagerListener * | listener | ) |
Add listener.
Listeners are notified of plugin load and unloda events.
listener | listener to add |
Definition at line 531 of file manager.cpp.
Referenced by fawkes::PluginNetworkHandler::PluginNetworkHandler().
void fawkes::PluginManager::config_comment_changed | ( | const char * | path, | |
bool | is_default, | |||
const char * | comment | |||
) | [virtual] |
Called whenever a comment has changed.
path | path of value | |
is_default | true if modified comment is of a default value, false otherwise | |
comment | new comment |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 429 of file manager.cpp.
void fawkes::PluginManager::config_tag_changed | ( | const char * | new_tag | ) | [virtual] |
Called whenever the tag has changed.
This function can be used to detect when data from another tag has been loaded.
new_tag | new tag |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 396 of file manager.cpp.
void fawkes::PluginManager::config_value_changed | ( | const char * | path, | |
bool | is_default, | |||
const char * | value | |||
) | [virtual] |
Called whenever a string value has changed.
path | path of value | |
is_default | true if modified value is a default value, false otherwise | |
value | new value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 435 of file manager.cpp.
References fawkes::LockList< Type >::lock(), and fawkes::LockList< Type >::unlock().
void fawkes::PluginManager::config_value_changed | ( | const char * | path, | |
bool | is_default, | |||
bool | value | |||
) | [virtual] |
Called whenever an boolean value has changed.
path | path of value | |
is_default | true if modified value is a default value, false otherwise | |
value | new value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 422 of file manager.cpp.
References fawkes::LibLogger::log_warn().
void fawkes::PluginManager::config_value_changed | ( | const char * | path, | |
bool | is_default, | |||
float | value | |||
) | [virtual] |
Called whenever an float value has changed.
path | path of value | |
is_default | true if modified value is a default value, false otherwise | |
value | new value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 415 of file manager.cpp.
References fawkes::LibLogger::log_warn().
void fawkes::PluginManager::config_value_changed | ( | const char * | path, | |
bool | is_default, | |||
unsigned int | value | |||
) | [virtual] |
Called whenever an unsigned int value has changed.
path | path of value | |
is_default | true if modified value is a default value, false otherwise | |
value | new value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 408 of file manager.cpp.
References fawkes::LibLogger::log_warn().
void fawkes::PluginManager::config_value_changed | ( | const char * | path, | |
bool | is_default, | |||
int | value | |||
) | [virtual] |
Called whenever an int value has changed.
path | path of value | |
is_default | true if modified value is a default value, false otherwise | |
value | new value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 401 of file manager.cpp.
References fawkes::LibLogger::log_warn().
void fawkes::PluginManager::config_value_erased | ( | const char * | path, | |
bool | is_default | |||
) | [virtual] |
Called whenever a value has been erased from the config.
path | path of value | |
is_default | true if erased value was a default value, false otherwise |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 456 of file manager.cpp.
References fawkes::LockList< Type >::lock(), and fawkes::LockList< Type >::unlock().
void fawkes::PluginManager::fam_event | ( | const char * | filename, | |
unsigned int | mask | |||
) | [virtual] |
Event has been raised.
filename | name of the file that triggered the event | |
mask | mask indicating the event. Currently inotify event flags are used, see inotify.h. |
Implements fawkes::FamListener.
Definition at line 472 of file manager.cpp.
References fawkes::FamListener::FAM_CREATE, fawkes::FamListener::FAM_DELETE, fawkes::FamListener::FAM_ISDIR, fawkes::FamListener::FAM_MODIFY, fawkes::FamListener::FAM_MOVED_FROM, fawkes::FamListener::FAM_MOVED_TO, fawkes::PluginLoader::get_description(), fawkes::PluginLoader::is_loaded(), fawkes::LockList< Type >::lock(), fawkes::LibLogger::log_info(), fawkes::LibLogger::log_warn(), and fawkes::LockList< Type >::unlock().
std::list< std::pair< std::string, std::string > > fawkes::PluginManager::get_available_plugins | ( | ) |
Generate list of all available plugins.
Definition at line 175 of file manager.cpp.
Referenced by XmlRpcPluginMethods::plugin_list::execute(), and WebviewPluginsRequestProcessor::process_request().
std::list< std::string > fawkes::PluginManager::get_loaded_plugins | ( | ) |
Get list of loaded plugins.
Definition at line 191 of file manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_list::execute().
bool fawkes::PluginManager::is_loaded | ( | const char * | plugin_name | ) |
Check if plugin is loaded.
plugin_name | plugin to check if it is loaded |
Definition at line 215 of file manager.cpp.
References fawkes::PluginLoader::is_loaded().
Referenced by fawkes::PluginNetworkHandler::loop(), and WebviewPluginsRequestProcessor::process_request().
void fawkes::PluginManager::load | ( | const char * | plugin_list | ) |
Load plugin.
The loading is interrupted if any of the plugins does not load properly. The already loaded plugins are *not* unloaded, but kept.
plugin_list | string containing a comma-separated list of plugins to load. The plugin list can contain meta plugins. |
Definition at line 259 of file manager.cpp.
References fawkes::ThreadCollector::add(), fawkes::Exception::append(), fawkes::LockMap< KeyType, ValueType, LessKey >::erase_locked(), fawkes::Configuration::get_string(), fawkes::PluginLoader::load(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::LibLogger::log_info(), fawkes::LockMap< KeyType, ValueType, LessKey >::mutex(), fawkes::Exception::prepend(), fawkes::Plugin::threads(), fawkes::PluginLoader::unload(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_load::execute(), FawkesMainThread::once(), and WebviewPluginsRequestProcessor::process_request().
void fawkes::PluginManager::remove_listener | ( | PluginManagerListener * | listener | ) |
Remove listener.
listener | listener to remove |
Definition at line 544 of file manager.cpp.
Referenced by fawkes::PluginNetworkHandler::~PluginNetworkHandler().
void fawkes::PluginManager::unload | ( | const char * | plugin_name | ) |
Unload plugin.
Note that this method does not allow to pass a list of plugins, but it will only accept a single plugin at a time.
plugin_name | plugin to unload, can be a meta plugin. |
Definition at line 335 of file manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::erase_locked(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::LibLogger::log_error(), fawkes::LibLogger::log_info(), fawkes::ThreadCollector::remove(), fawkes::PluginLoader::unload(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_unload::execute(), and WebviewPluginsRequestProcessor::process_request().