Top |
enum | GrlRank |
struct | GrlRegistry |
struct | GrlRegistryClass |
struct | GrlPluginDescriptor |
#define | GRL_PLUGIN_LIST_VAR |
#define | GRL_PLUGIN_PATH_VAR |
#define | GRL_PLUGIN_RANKS_VAR |
The registry holds the metadata of a set of plugins.
The GrlRegistry object is a list of plugins and some functions for dealing with them. Each GrlPlugin is matched 1-1 with a file on disk, and may or may not be loaded a given time. There only can be a single instance of GrlRegistry (singleton pattern).
A GrlPlugin can hold several data GrlSource sources, and GrlRegistry shall register each one of them.
gboolean grl_registry_add_config (GrlRegistry *registry
,GrlConfig *config
,GError **error
);
Add a configuration for a plugin/source.
registry |
the registry instance |
|
config |
a configuration set. |
[transfer full] |
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_add_config_from_file (GrlRegistry *registry
,const gchar *config_file
,GError **error
);
Load plugin configurations from a .ini-like config file.
registry |
the registry instance |
|
config_file |
a key-value file containing the configuration |
|
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_add_config_from_resource (GrlRegistry *registry
,const gchar *resource_path
,GError **error
);
Load plugin configurations from a .ini-like resource file.
registry |
the registry instance |
|
resource_path |
a key-value file containing the configuration |
|
error |
error return location or |
Since: 0.2.8
void grl_registry_add_directory (GrlRegistry *registry
,const gchar *path
);
Set this path as part of default paths to load plugins.
Since: 0.2.0
GrlRegistry *
grl_registry_get_default (void
);
As the registry is designed to work as a singleton, this method is in charge of creating the only instance or returned it if it is already in memory.
Since: 0.2.0
GList *
grl_registry_get_metadata_keys (GrlRegistry *registry
);
Returns a list with all registered keys in system.
a GList with all the available
GrlKeyIDs. The content of the list should not be modified or freed.
Use g_list_free()
when done using the list.
[transfer container][element-type GrlKeyID]
Since: 0.2.0
GList * grl_registry_get_plugins (GrlRegistry *registry
,gboolean only_loaded
);
This function will return all the available plugins in the registry
.
If only_loaded
is TRUE
, the plugin list will contain only plugins that are
loaded.
registry |
the registry instance |
|
only_loaded |
whether the returned list shall include only loaded plugins |
a GList of
available GrlPlugins. The content of the list should not be modified
or freed. Use g_list_free()
when done using the list.
[element-type GrlPlugin][transfer container]
Since: 0.2.0
GList * grl_registry_get_sources (GrlRegistry *registry
,gboolean ranked
);
This function will return all the available sources in the registry
.
If ranked
is TRUE
, the source list will be ordered by rank.
registry |
the registry instance |
|
ranked |
whether the returned list shall be returned ordered by rank |
a GList of
available GrlSources. The content of the list should not be
modified or freed. Use g_list_free()
when done using the list.
[element-type GrlSource][transfer container]
Since: 0.2.0
GList * grl_registry_get_sources_by_operations (GrlRegistry *registry
,GrlSupportedOps ops
,gboolean ranked
);
Give an array of all the available sources in the registry
capable of
perform the operations requested in ops
.
If ranked
is TRUE
, the source list will be ordered by rank.
registry |
the registry instance |
|
ops |
a bitwise mangle of the requested operations. |
|
ranked |
whether the returned list shall be returned ordered by rank |
a GList of
available GrlSources. The content of the list should not be
modified or freed. Use g_list_free()
when done using the list.
[element-type GrlSource][transfer container]
Since: 0.2.0
gboolean grl_registry_load_all_plugins (GrlRegistry *registry
,gboolean activate
,GError **error
);
Load all the modules available in the default directory path.
The default directory path can be changed through the environment
variable GRL_PLUGIN_PATH
and it can contain several paths separated
by ":"
registry |
the registry instance |
|
activate |
|
|
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_load_plugin (GrlRegistry *registry
,const gchar *library_filename
,GError **error
);
Loads a module from shared object file stored in path
registry |
the registry instance |
|
library_filename |
the path to the so file |
|
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_load_plugin_directory (GrlRegistry *registry
,const gchar *path
,GError **error
);
Loads a set of modules from directory in path
which contains
a group shared object files.
registry |
the registry instance |
|
path |
the path to the directory |
|
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_load_plugin_from_desc (GrlRegistry *registry
,GrlPluginDescriptor *plugin_desc
,GError **error
);
Loads the grilo plugin defined by plugin_desc
. This is
used to load plugins that aren't shared libraries, and are
built into applications.
Example 1.
static GrlPluginDescriptor descriptor = { .plugin_id = "grl-example", .plugin_init = grl_example_plugin_init, }; grl_registry_load_plugin_from_desc (registry, &descriptor, &error);
[skip]
registry |
the registry instance |
|
plugin_desc |
the GrlPluginDescriptor for the plugin |
|
error |
error return location or |
Since: 0.3.0
GrlKeyID grl_registry_lookup_metadata_key (GrlRegistry *registry
,const gchar *key_name
);
Look up for the metadata key with name key_name
.
Since: 0.2.0
const gchar * grl_registry_lookup_metadata_key_desc (GrlRegistry *registry
,GrlKeyID key
);
Returns key
description.
Since: 0.2.0
const gchar * grl_registry_lookup_metadata_key_name (GrlRegistry *registry
,GrlKeyID key
);
Returns key
name.
Since: 0.2.0
const GList * grl_registry_lookup_metadata_key_relation (GrlRegistry *registry
,GrlKeyID key
);
Look up the list of keys that have a relation with key
.
key
is included in that list.
Since: 0.2.0
GType grl_registry_lookup_metadata_key_type (GrlRegistry *registry
,GrlKeyID key
);
Returns key
expected value type.
Since: 0.2.0
GrlPlugin * grl_registry_lookup_plugin (GrlRegistry *registry
,const gchar *plugin_id
);
This function will search and retrieve a plugin given its identifier.
Since: 0.2.0
GrlSource * grl_registry_lookup_source (GrlRegistry *registry
,const gchar *source_id
);
This function will search and retrieve a source given its identifier.
Since: 0.2.0
gboolean grl_registry_metadata_key_validate (GrlRegistry *registry
,GrlKeyID key
,GValue *value
);
Validates value
content complies with the key specification. That is, it has
the expected type, and value are within the range specified in key (for
integer values).
Since: 0.2.0
GrlKeyID grl_registry_register_metadata_key (GrlRegistry *registry
,GParamSpec *param_spec
,GrlKeyID bind_key
,GError **error
);
Registers a new metadata key, creating a relation between the new key and
bind_key
.
Two keys are related when the values of both keys are somehow related.
One example of a relation would be the one between the URI of a media resource and its mime-type: they are both tied together and one does not make sense without the other.
Relations between keys allow the framework to provide all the data that is somehow related when any of the related keys are requested.
registry |
The plugin registry |
|
param_spec |
The definition of the key to register. |
[transfer full] |
bind_key |
The key the new key is bind to, or GRL_METADATA_KEY_INVALID if it is not bound. |
|
error |
error return location or |
Since: 0.3.0
gboolean grl_registry_register_source (GrlRegistry *registry
,GrlPlugin *plugin
,GrlSource *source
,GError **error
);
Register a source
in the registry
with the given plugin
information
registry |
the registry instance |
|
plugin |
the plugin which owns the source |
|
source |
the source to register. |
[transfer full] |
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_unload_plugin (GrlRegistry *registry
,const gchar *plugin_id
,GError **error
);
Unload from memory a module identified by plugin_id
. This means call the
module's deinit function.
registry |
the registry instance |
|
plugin_id |
the identifier of the plugin |
|
error |
error return location or |
Since: 0.2.0
gboolean grl_registry_unregister_source (GrlRegistry *registry
,GrlSource *source
,GError **error
);
Removes the source
from the registry
hash table
registry |
the registry instance |
|
source |
the source to unregister |
|
error |
error return location or |
Since: 0.2.0
Source priority ranks. Defines the order in which the resolver (or similar rank-picking mechanisms) will choose this source over an alternative one with the same function.
These constants serve as a rough guidance for defining the rank of a GrlSource. Any value is valid, including values bigger than GRL_RANK_HIGHEST.
struct GrlRegistryClass { GObjectClass parent_class; };
Grilo Registry class. Dynamic loader of plugins.
struct GrlPluginDescriptor { gint major_version; gint minor_version; gchar *id; gchar *name; gchar *description; gchar *author; gchar *version; gchar *license; gchar *site; GrlPluginInitFunc init; GrlPluginDeinitFunc deinit; GrlPluginRegisterKeysFunc register_keys; };
This structure is used for the module loader
the major version number of core that plugin was compiled for |
||
the minor version number of core that plugin was compiled for |
||
the plugin identifier |
||
name of plugin |
||
description of plugin |
||
author of plugin |
||
version of plugin |
||
license of plugin |
||
URL to provider of plugin |
||
Since: 0.3.0
“metadata-key-added”
signalvoid user_function (GrlRegistry *registry, gchar *key, gpointer user_data)
Signals that a new metadata key has been registered.
registry |
the registry |
|
key |
the name of the new key added |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
Since: 0.2.10
“source-added”
signalvoid user_function (GrlRegistry *registry, GrlSource *source, gpointer user_data)
Signals that a source has been added to the registry.
registry |
the registry |
|
source |
the source that has been added |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
Since: 0.2.0
“source-removed”
signalvoid user_function (GrlRegistry *registry, GrlSource *source, gpointer user_data)
Signals that a source has been removed from the registry.
registry |
the registry |
|
source |
the source that has been removed |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
Since: 0.2.0