![]() |
![]() |
![]() |
Grilo Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Signals |
#include <grilo.h> struct GrlRegistry; struct GrlRegistryClass; struct GrlPluginDescriptor; #define GRL_PLUGIN_LIST_VAR #define GRL_PLUGIN_PATH_VAR #define GRL_PLUGIN_RANKS_VAR #define GRL_PLUGIN_REGISTER (init, deinit, id) gboolean grl_registry_add_config (GrlRegistry *registry
,GrlConfig *config
,GError **error
); gboolean grl_registry_add_config_from_file (GrlRegistry *registry
,const gchar *config_file
,GError **error
); void grl_registry_add_directory (GrlRegistry *registry
,const gchar *path
); GrlRegistry * grl_registry_get_default (void
); GList * grl_registry_get_metadata_keys (GrlRegistry *registry
); GList * grl_registry_get_plugins (GrlRegistry *registry
,gboolean only_loaded
); GList * grl_registry_get_sources (GrlRegistry *registry
,gboolean ranked
); GList * grl_registry_get_sources_by_operations (GrlRegistry *registry
,GrlSupportedOps ops
,gboolean ranked
); gboolean grl_registry_load_all_plugins (GrlRegistry *registry
,GError **error
); gboolean grl_registry_load_plugin (GrlRegistry *registry
,const gchar *library_filename
,GError **error
); gboolean grl_registry_load_plugin_by_id (GrlRegistry *registry
,const gchar *plugin_id
,GError **error
); gboolean grl_registry_load_plugin_directory (GrlRegistry *registry
,const gchar *path
,GError **error
); GrlKeyID grl_registry_lookup_metadata_key (GrlRegistry *registry
,const gchar *key_name
); const gchar * grl_registry_lookup_metadata_key_desc (GrlRegistry *registry
,GrlKeyID key
); const gchar * grl_registry_lookup_metadata_key_name (GrlRegistry *registry
,GrlKeyID key
); const GList * grl_registry_lookup_metadata_key_relation (GrlRegistry *registry
,GrlKeyID key
); GType grl_registry_lookup_metadata_key_type (GrlRegistry *registry
,GrlKeyID key
); GrlPlugin * grl_registry_lookup_plugin (GrlRegistry *registry
,const gchar *plugin_id
); GrlSource * grl_registry_lookup_source (GrlRegistry *registry
,const gchar *source_id
); gboolean grl_registry_metadata_key_validate (GrlRegistry *registry
,GrlKeyID key
,GValue *value
); GrlKeyID grl_registry_register_metadata_key (GrlRegistry *registry
,GParamSpec *param_spec
,GError **error
); void grl_registry_register_metadata_key_relation (GrlRegistry *registry
,GrlKeyID key1
,GrlKeyID key2
); gboolean grl_registry_register_source (GrlRegistry *registry
,GrlPlugin *plugin
,GrlSource *source
,GError **error
); gboolean grl_registry_unload_plugin (GrlRegistry *registry
,const gchar *plugin_id
,GError **error
); gboolean grl_registry_unregister_source (GrlRegistry *registry
,GrlSource *source
,GError **error
);
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.
struct GrlRegistryClass { GObjectClass parent_class; };
Grilo Registry class. Dynamic loader of plugins.
struct GrlPluginDescriptor { gchar *plugin_id; gboolean (*plugin_init) (GrlRegistry *, GrlPlugin *, GList *); void (*plugin_deinit) (GrlPlugin *); GModule *module; };
This structure is used for the module loader
the module identifier | |
the module initialization. It shall instantiate the GrlPlugins provided | |
function to execute when the registry needs to dispose the module. | |
the GModule instance. |
#define GRL_PLUGIN_REGISTER(init, \ deinit, \ id)
Define the boilerplate for loadable modules. Defines a new module descriptor which provides a set of GrlPlugins
|
the module initialization. It shall instantiate the GrlPlugins provided |
|
function to execute when the registry needs to dispose the module. [allow-none] |
|
the module identifier |
gboolean grl_registry_add_config (GrlRegistry *registry
,GrlConfig *config
,GError **error
);
Add a configuration for a plugin/source.
|
the registry instance |
|
a configuration set. [transfer full] |
|
error return location or NULL to ignore |
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.
|
the registry instance |
|
a key-value file containing the configuration |
|
error return location or NULL to ignore |
Returns : |
TRUE on success |
Since 0.2.0
void grl_registry_add_directory (GrlRegistry *registry
,const gchar *path
);
Set this path as part of default paths to load plugins.
|
the registry instance |
|
a path with 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.
Returns : |
a new or an already created instance of the registry. It is NOT MT-safe. [transfer none] |
Since 0.2.0
GList * grl_registry_get_metadata_keys (GrlRegistry *registry
);
Returns a list with all registered keys in system.
|
the registry instance |
Returns : |
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.
|
the registry instance |
|
whether the returned list shall include only loaded plugins |
Returns : |
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 Grl.Plugin][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.
|
the registry instance |
|
whether the returned list shall be returned ordered by rank |
Returns : |
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 Grl.Source][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.
|
the registry instance |
|
a bitwise mangle of the requested operations. |
|
whether the returned list shall be returned ordered by rank |
Returns : |
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 Grl.Source][transfer container]
|
Since 0.2.0
gboolean grl_registry_load_all_plugins (GrlRegistry *registry
,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 ":"
|
the registry instance |
|
error return location or NULL to ignore |
Returns : |
FALSE % is all the configured plugin paths are invalid,
TRUE % otherwise. |
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
|
the registry instance |
|
the path to the so file |
|
error return location or NULL to ignore |
Returns : |
TRUE if the module is loaded correctly |
Since 0.2.0
gboolean grl_registry_load_plugin_by_id (GrlRegistry *registry
,const gchar *plugin_id
,GError **error
);
Loads plugin identified by plugin_id
.
This requires the XML plugin information file to define a "module" key with the name of the module that provides the plugin or the absolute path of the actual module file.
|
the registry instance |
|
plugin identifier |
|
error return location or NULL to ignore |
Returns : |
TRUE if the plugin is loaded correctly |
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.
|
the registry instance |
|
the path to the directory |
|
error return location or NULL to ignore |
Returns : |
TRUE if the directory is valid. |
Since 0.2.0
GrlKeyID grl_registry_lookup_metadata_key (GrlRegistry *registry
,const gchar *key_name
);
Look up for the metadata key with name key_name
.
|
the registry instance |
|
the key name |
Returns : |
The metadata key, or GRL_METADATA_KEY_INVALID if not found |
Since 0.2.0
const gchar * grl_registry_lookup_metadata_key_desc (GrlRegistry *registry
,GrlKeyID key
);
Returns key
description.
|
the registry instance |
|
a metadata key |
Returns : |
metadata key description, or NULL if not found |
Since 0.2.0
const gchar * grl_registry_lookup_metadata_key_name (GrlRegistry *registry
,GrlKeyID key
);
Returns key
name.
|
the registry instance |
|
a metadata key |
Returns : |
metadata key name, or NULL if not found |
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.
|
the registry instance |
|
a metadata key |
Returns : |
a GList of
related keys, or NULL if key is invalid. [element-type GrlKeyID][transfer none]
|
Since 0.2.0
GType grl_registry_lookup_metadata_key_type (GrlRegistry *registry
,GrlKeyID key
);
Returns key
expected value type.
|
the registry instance |
|
a metadata key |
Returns : |
metadata key type, or G_TYPE_INVALID if not found |
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.
|
the registry instance |
|
the id of a plugin |
Returns : |
The plugin found. [transfer none] |
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.
|
the registry instance |
|
the id of a source |
Returns : |
The source found. [transfer none] |
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).
|
the registry instance |
|
a metadata key |
|
value to be validate |
Returns : |
TRUE if complies |
Since 0.2.0
GrlKeyID grl_registry_register_metadata_key (GrlRegistry *registry
,GParamSpec *param_spec
,GError **error
);
Registers a metadata key
|
The plugin registry |
|
The definition of the key to register |
|
error return location or NULL to ignore |
Returns : |
The GrlKeyID registered. |
Since 0.2.0
void grl_registry_register_metadata_key_relation (GrlRegistry *registry
,GrlKeyID key1
,GrlKeyID key2
);
Creates a relation between key1
and key2
, meaning that 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.
|
the plugin registry |
|
key involved in relationship |
|
key involved in relationship |
Since 0.2.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
|
the registry instance |
|
the plugin which owns the source |
|
the source to register |
|
error return location or NULL to ignore |
Returns : |
TRUE if success, FALSE % otherwise. |
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.
|
the registry instance |
|
the identifier of the plugin |
|
error return location or NULL to ignore |
Returns : |
TRUE % on success. |
Since 0.2.0
gboolean grl_registry_unregister_source (GrlRegistry *registry
,GrlSource *source
,GError **error
);
Removes the source
from the registry
hash table
|
the registry instance |
|
the source to unregister |
|
error return location or NULL to ignore |
Returns : |
TRUE if success, FALSE % otherwise. |
Since 0.2.0
"source-added"
signalvoid user_function (GrlRegistry *registry,
GrlSource *source,
gpointer user_data) : Action
Signals that a source has been added to the registry.
|
the registry |
|
the source that has been added |
|
user data set when the signal handler was connected. |
Since 0.2.0
"source-removed"
signalvoid user_function (GrlRegistry *registry,
GrlSource *source,
gpointer user_data) : Action
Signals that a source has been removed from the registry.
|
the registry |
|
the source that has been removed |
|
user data set when the signal handler was connected. |
Since 0.2.0