From 034204d3d8d1a32b1a20e50697c5f81db6fb20cf Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 31 Aug 2012 23:14:16 +0200 Subject: Initial plugin manager --- src/uca-plugin-manager.c | 260 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 src/uca-plugin-manager.c (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c new file mode 100644 index 0000000..7788678 --- /dev/null +++ b/src/uca-plugin-manager.c @@ -0,0 +1,260 @@ +/** + * SECTION:uca-plugin-manager + * @Short_description: Load an #UcaFilter from a shared object + * @Title: UcaPluginManager + * + * The plugin manager opens shared object modules searched for in locations + * specified with uca_plugin_manager_add_paths(). An #UcaFilter can be + * instantiated with uca_plugin_manager_get_filter() with a one-to-one mapping + * between filter name xyz and module name libfilterxyz.so. Any errors are + * reported as one of #UcaPluginManagerError codes. + */ +#include +#include "uca-plugin-manager.h" + +G_DEFINE_TYPE (UcaPluginManager, uca_plugin_manager, G_TYPE_OBJECT) + +#define UCA_PLUGIN_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_PLUGIN_MANAGER, UcaPluginManagerPrivate)) + +struct _UcaPluginManagerPrivate { + GList *search_paths; +}; + +/** + * UcaPluginManagerError: + * @UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND: The module could not be found + * @UCA_PLUGIN_MANAGER_ERROR_MODULE_OPEN: Module could not be opened + * @UCA_PLUGIN_MANAGER_ERROR_SYMBOL_NOT_FOUND: Necessary entry symbol was not + * found + * + * Possible errors that uca_plugin_manager_get_filter() can return. + */ +GQuark +uca_plugin_manager_error_quark (void) +{ + return g_quark_from_static_string ("uca-plugin-manager-error-quark"); +} + +/** + * uca_plugin_manager_new: + * @config: (allow-none): A #UcaConfiguration object or %NULL. + * + * Create a plugin manager object to instantiate filter objects. When a config + * object is passed to the constructor, its search-path property is added to the + * internal search paths. + * + * Return value: A new plugin manager object. + */ +UcaPluginManager * +uca_plugin_manager_new () +{ + return UCA_PLUGIN_MANAGER (g_object_new (UCA_TYPE_PLUGIN_MANAGER, NULL)); +} + +void +uca_plugin_manager_add_path (UcaPluginManager *manager, + const gchar *path) +{ + g_return_if_fail (UCA_IS_PLUGIN_MANAGER (manager)); + + if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { + UcaPluginManagerPrivate *priv; + + priv = manager->priv; + priv->search_paths = g_list_append (priv->search_paths, + g_strdup (path)); + } +} + +static GList * +get_camera_names_from_directory (const gchar *path) +{ + static const gchar *pattern_string = "libuca([A-Za-z]+)"; + GRegex *pattern; + GDir *dir; + GList *result = NULL; + + pattern = g_regex_new (pattern_string, 0, 0, NULL); + dir = g_dir_open (path, 0, NULL); + + if (dir != NULL) { + GMatchInfo *match_info = NULL; + const gchar *name = g_dir_read_name (dir); + + while (name != NULL) { + g_regex_match (pattern, name, 0, &match_info); + + if (g_match_info_matches (match_info)) { + gchar *word = g_match_info_fetch (match_info, 1); + result = g_list_append (result, word); + } + + name = g_dir_read_name (dir); + } + } + + return result; +} + +GList * +uca_plugin_manager_get_available_cameras (UcaPluginManager *manager) +{ + UcaPluginManagerPrivate *priv; + GList *camera_names; + + g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager), NULL); + + priv = manager->priv; + + for (GList *it = g_list_first (priv->search_paths); it != NULL; it = g_list_next (it)) { + camera_names = g_list_concat (camera_names, + get_camera_names_from_directory ((const gchar*) it->data)); + } + + return camera_names; +} + +UcaCamera * +uca_plugin_manager_new_camera (UcaPluginManager *manager, + const gchar *name, + GError **error) +{ + return NULL; +} + +/** + * uca_plugin_manager_get_filter: + * @manager: A #UcaPluginManager + * @name: Name of the plugin. + * @error: return location for a GError or %NULL + * + * Load a #UcaFilter module and return an instance. The shared object name must + * be * constructed as "libfilter@name.so". + * + * Returns: (transfer none) (allow-none): #UcaFilter or %NULL if module cannot be found + * + * Since: 0.2, the error parameter is available + */ +/* UcaFilter * */ +/* uca_plugin_manager_get_filter (UcaPluginManager *manager, const gchar *name, GError **error) */ +/* { */ +/* g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager) && (name != NULL), NULL); */ +/* UcaPluginManagerPrivate *priv = UCA_PLUGIN_MANAGER_GET_PRIVATE (manager); */ +/* UcaFilter *filter; */ +/* GetFilterFunc *func = NULL; */ +/* GModule *module = NULL; */ +/* gchar *module_name = NULL; */ +/* const gchar *entry_symbol_name = "uca_filter_plugin_new"; */ + +/* func = g_hash_table_lookup (priv->filter_funcs, name); */ + +/* if (func == NULL) { */ +/* module_name = g_strdup_printf ("libucafilter%s.so", name); */ +/* gchar *path = plugin_manager_get_path (priv, module_name); */ + +/* if (path == NULL) { */ +/* g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND, */ +/* "Module %s not found", module_name); */ +/* goto handle_error; */ +/* } */ + +/* module = g_module_open (path, G_MODULE_BIND_LAZY); */ +/* g_free (path); */ + +/* if (!module) { */ +/* g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_OPEN, */ +/* "Module %s could not be opened: %s", module_name, g_module_error ()); */ +/* goto handle_error; */ +/* } */ + +/* func = g_malloc0 (sizeof (GetFilterFunc)); */ + +/* if (!g_module_symbol (module, entry_symbol_name, (gpointer *) func)) { */ +/* g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_SYMBOL_NOT_FOUND, */ +/* "%s is not exported by module %s: %s", entry_symbol_name, module_name, g_module_error ()); */ +/* g_free (func); */ + +/* if (!g_module_close (module)) */ +/* g_warning ("%s", g_module_error ()); */ + +/* goto handle_error; */ +/* } */ + +/* priv->modules = g_slist_append (priv->modules, module); */ +/* g_hash_table_insert (priv->filter_funcs, g_strdup (name), func); */ +/* g_free (module_name); */ +/* } */ + +/* filter = (*func) (); */ +/* uca_filter_set_plugin_name (filter, name); */ +/* g_message ("UcaPluginManager: Created %s-%p", name, (gpointer) filter); */ + +/* return filter; */ + +/* handle_error: */ +/* g_free (module_name); */ +/* return NULL; */ +/* } */ + +static void +uca_plugin_manager_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +uca_plugin_manager_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +uca_plugin_manager_dispose (GObject *object) +{ + G_OBJECT_CLASS (uca_plugin_manager_parent_class)->dispose (object); +} + +static void +uca_plugin_manager_finalize (GObject *object) +{ + UcaPluginManagerPrivate *priv = UCA_PLUGIN_MANAGER_GET_PRIVATE (object); + + g_list_foreach (priv->search_paths, (GFunc) g_free, NULL); + g_list_free (priv->search_paths); + + G_OBJECT_CLASS (uca_plugin_manager_parent_class)->finalize (object); +} + +static void +uca_plugin_manager_class_init (UcaPluginManagerClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->get_property = uca_plugin_manager_get_property; + gobject_class->set_property = uca_plugin_manager_set_property; + gobject_class->dispose = uca_plugin_manager_dispose; + gobject_class->finalize = uca_plugin_manager_finalize; + + g_type_class_add_private (klass, sizeof (UcaPluginManagerPrivate)); +} + +static void +uca_plugin_manager_init (UcaPluginManager *manager) +{ + UcaPluginManagerPrivate *priv; + + manager->priv = priv = UCA_PLUGIN_MANAGER_GET_PRIVATE (manager); + priv->search_paths = NULL; + + uca_plugin_manager_add_path (manager, "/usr/lib/uca"); + uca_plugin_manager_add_path (manager, "/usr/lib64/uca"); + uca_plugin_manager_add_path (manager, "/usr/local/lib/uca"); + uca_plugin_manager_add_path (manager, "/usr/local/lib64/uca"); +} -- cgit v1.2.3 From af00a17308fd17ea454021649a36f2f397a6da2b Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 19 Sep 2012 15:59:57 +0200 Subject: Fix segfault --- src/uca-plugin-manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index 7788678..bb27215 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -86,7 +86,9 @@ get_camera_names_from_directory (const gchar *path) if (g_match_info_matches (match_info)) { gchar *word = g_match_info_fetch (match_info, 1); - result = g_list_append (result, word); + + if (word != NULL) + result = g_list_append (result, word); } name = g_dir_read_name (dir); @@ -100,7 +102,7 @@ GList * uca_plugin_manager_get_available_cameras (UcaPluginManager *manager) { UcaPluginManagerPrivate *priv; - GList *camera_names; + GList *camera_names = NULL; g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager), NULL); -- cgit v1.2.3 From 90f0d4f6fa74111f38c9aedf31ecb740bc0ddf97 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 19 Sep 2012 16:05:46 +0200 Subject: Add path from UCA_CAMERA_PATH environment variable --- src/uca-plugin-manager.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index bb27215..61e43f8 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -8,6 +8,9 @@ * instantiated with uca_plugin_manager_get_filter() with a one-to-one mapping * between filter name xyz and module name libfilterxyz.so. Any errors are * reported as one of #UcaPluginManagerError codes. + * + * By default, any path listed in the %UCA_CAMERA_PATH environment variable is + * added to the search path. */ #include #include "uca-plugin-manager.h" @@ -251,10 +254,16 @@ static void uca_plugin_manager_init (UcaPluginManager *manager) { UcaPluginManagerPrivate *priv; + const gchar *uca_camera_path; manager->priv = priv = UCA_PLUGIN_MANAGER_GET_PRIVATE (manager); priv->search_paths = NULL; + uca_camera_path = g_getenv ("UCA_CAMERA_PATH"); + + if (uca_camera_path != NULL) + uca_plugin_manager_add_path (manager, uca_camera_path); + uca_plugin_manager_add_path (manager, "/usr/lib/uca"); uca_plugin_manager_add_path (manager, "/usr/lib64/uca"); uca_plugin_manager_add_path (manager, "/usr/local/lib/uca"); -- cgit v1.2.3 From 6dd3229337aa1920d266fbd2c4001fb7c65f5cf1 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 19 Sep 2012 18:04:32 +0200 Subject: Make most cameras plugins --- src/uca-plugin-manager.c | 217 +++++++++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 93 deletions(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index 61e43f8..c044a4a 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -23,6 +23,10 @@ struct _UcaPluginManagerPrivate { GList *search_paths; }; +static const gchar *MODULE_PATTERN = "libuca([A-Za-z]+)"; + +typedef UcaCamera * (*GetCameraFunc) (GError **error); + /** * UcaPluginManagerError: * @UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND: The module could not be found @@ -70,30 +74,24 @@ uca_plugin_manager_add_path (UcaPluginManager *manager, } static GList * -get_camera_names_from_directory (const gchar *path) +get_camera_module_paths (const gchar *path) { - static const gchar *pattern_string = "libuca([A-Za-z]+)"; - GRegex *pattern; + GRegex *pattern; GDir *dir; GList *result = NULL; - - pattern = g_regex_new (pattern_string, 0, 0, NULL); + + pattern = g_regex_new (MODULE_PATTERN, 0, 0, NULL); dir = g_dir_open (path, 0, NULL); if (dir != NULL) { GMatchInfo *match_info = NULL; - const gchar *name = g_dir_read_name (dir); + const gchar *name = g_dir_read_name (dir); while (name != NULL) { - g_regex_match (pattern, name, 0, &match_info); - - if (g_match_info_matches (match_info)) { - gchar *word = g_match_info_fetch (match_info, 1); - - if (word != NULL) - result = g_list_append (result, word); - } + if (g_regex_match (pattern, name, 0, &match_info)) + result = g_list_append (result, g_build_filename (path, name, NULL)); + g_match_info_free (match_info); name = g_dir_read_name (dir); } } @@ -101,105 +99,138 @@ get_camera_names_from_directory (const gchar *path) return result; } +static GList * +scan_search_paths (GList *search_paths) +{ + GList *camera_paths = NULL; + + for (GList *it = g_list_first (search_paths); it != NULL; it = g_list_next (it)) { + camera_paths = g_list_concat (camera_paths, + get_camera_module_paths ((const gchar*) it->data)); + } + + return camera_paths; +} + +static void +transform_camera_module_path_to_name (gchar *path, GList **result) +{ + GRegex *pattern; + GMatchInfo *match_info; + + pattern = g_regex_new (MODULE_PATTERN, 0, 0, NULL); + g_regex_match (pattern, path, 0, &match_info); + + *result = g_list_append (*result, g_match_info_fetch (match_info, 1)); + g_match_info_free (match_info); +} + +static void +g_list_free_full (GList *list) +{ + g_list_foreach (list, (GFunc) g_free, NULL); + g_list_free (list); +} + GList * uca_plugin_manager_get_available_cameras (UcaPluginManager *manager) { UcaPluginManagerPrivate *priv; + GList *camera_paths; GList *camera_names = NULL; g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager), NULL); priv = manager->priv; + camera_paths = scan_search_paths (priv->search_paths); - for (GList *it = g_list_first (priv->search_paths); it != NULL; it = g_list_next (it)) { - camera_names = g_list_concat (camera_names, - get_camera_names_from_directory ((const gchar*) it->data)); - } + g_list_foreach (camera_paths, (GFunc) transform_camera_module_path_to_name, &camera_names); + g_list_free_full (camera_paths); return camera_names; } +static gchar * +find_camera_module_path (GList *search_paths, const gchar *name) +{ + gchar *result = NULL; + GList *paths; + + paths = scan_search_paths (search_paths); + + for (GList *it = g_list_first (paths); it != NULL; it = g_list_next (it)) { + gchar *path = (gchar *) it->data; + gchar *basename = g_path_get_basename ((gchar *) path); + + if (g_strrstr (basename, name)) { + result = g_strdup (path); + g_free (basename); + break; + } + + g_free (basename); + } + + g_list_free_full (paths); + return result; +} + UcaCamera * uca_plugin_manager_new_camera (UcaPluginManager *manager, const gchar *name, GError **error) { - return NULL; -} + UcaPluginManagerPrivate *priv; + UcaCamera *camera; + GModule *module; + GetCameraFunc *func; + gchar *module_path; + GError *tmp_error = NULL; -/** - * uca_plugin_manager_get_filter: - * @manager: A #UcaPluginManager - * @name: Name of the plugin. - * @error: return location for a GError or %NULL - * - * Load a #UcaFilter module and return an instance. The shared object name must - * be * constructed as "libfilter@name.so". - * - * Returns: (transfer none) (allow-none): #UcaFilter or %NULL if module cannot be found - * - * Since: 0.2, the error parameter is available - */ -/* UcaFilter * */ -/* uca_plugin_manager_get_filter (UcaPluginManager *manager, const gchar *name, GError **error) */ -/* { */ -/* g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager) && (name != NULL), NULL); */ -/* UcaPluginManagerPrivate *priv = UCA_PLUGIN_MANAGER_GET_PRIVATE (manager); */ -/* UcaFilter *filter; */ -/* GetFilterFunc *func = NULL; */ -/* GModule *module = NULL; */ -/* gchar *module_name = NULL; */ -/* const gchar *entry_symbol_name = "uca_filter_plugin_new"; */ - -/* func = g_hash_table_lookup (priv->filter_funcs, name); */ - -/* if (func == NULL) { */ -/* module_name = g_strdup_printf ("libucafilter%s.so", name); */ -/* gchar *path = plugin_manager_get_path (priv, module_name); */ - -/* if (path == NULL) { */ -/* g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND, */ -/* "Module %s not found", module_name); */ -/* goto handle_error; */ -/* } */ - -/* module = g_module_open (path, G_MODULE_BIND_LAZY); */ -/* g_free (path); */ - -/* if (!module) { */ -/* g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_OPEN, */ -/* "Module %s could not be opened: %s", module_name, g_module_error ()); */ -/* goto handle_error; */ -/* } */ - -/* func = g_malloc0 (sizeof (GetFilterFunc)); */ - -/* if (!g_module_symbol (module, entry_symbol_name, (gpointer *) func)) { */ -/* g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_SYMBOL_NOT_FOUND, */ -/* "%s is not exported by module %s: %s", entry_symbol_name, module_name, g_module_error ()); */ -/* g_free (func); */ - -/* if (!g_module_close (module)) */ -/* g_warning ("%s", g_module_error ()); */ - -/* goto handle_error; */ -/* } */ - -/* priv->modules = g_slist_append (priv->modules, module); */ -/* g_hash_table_insert (priv->filter_funcs, g_strdup (name), func); */ -/* g_free (module_name); */ -/* } */ - -/* filter = (*func) (); */ -/* uca_filter_set_plugin_name (filter, name); */ -/* g_message ("UcaPluginManager: Created %s-%p", name, (gpointer) filter); */ - -/* return filter; */ - -/* handle_error: */ -/* g_free (module_name); */ -/* return NULL; */ -/* } */ + const gchar *symbol_name = "uca_camera_impl_new"; + + g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager) && (name != NULL), NULL); + + priv = manager->priv; + module_path = find_camera_module_path (priv->search_paths, name); + + if (module_path == NULL) { + g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND, + "Camera module `%s' not found", name); + return NULL; + } + + module = g_module_open (module_path, G_MODULE_BIND_LAZY); + g_free (module_path); + + if (!module) { + g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_OPEN, + "Camera module `%s' could not be opened: %s", name, g_module_error ()); + return NULL; + } + + func = g_malloc0 (sizeof (GetCameraFunc)); + + if (!g_module_symbol (module, symbol_name, (gpointer *) func)) { + g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_SYMBOL_NOT_FOUND, + "%s", g_module_error ()); + g_free (func); + + if (!g_module_close (module)) + g_warning ("%s", g_module_error ()); + + return NULL; + } + + camera = (*func) (&tmp_error); + + if (tmp_error != NULL) { + g_propagate_error (error, tmp_error); + return NULL; + } + + return camera; +} static void uca_plugin_manager_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -- cgit v1.2.3 From 94459e5838c8923a0820135c4915976958dde2ed Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 20 Sep 2012 18:32:08 +0200 Subject: Add docstrings --- src/uca-plugin-manager.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index c044a4a..fdfb59f 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -4,13 +4,16 @@ * @Title: UcaPluginManager * * The plugin manager opens shared object modules searched for in locations - * specified with uca_plugin_manager_add_paths(). An #UcaFilter can be - * instantiated with uca_plugin_manager_get_filter() with a one-to-one mapping - * between filter name xyz and module name libfilterxyz.so. Any errors are - * reported as one of #UcaPluginManagerError codes. + * specified with uca_plugin_manager_add_path(). A #UcaCamera can be + * instantiated with uca_plugin_manager_new_camera() with a one-to-one mapping + * between filter name xyz and module name libucaxyz.so. Any errors are reported + * as one of #UcaPluginManagerError codes. To get a list of available camera + * names call uca_plugin_manager_get_available_cameras(). * * By default, any path listed in the %UCA_CAMERA_PATH environment variable is * added to the search path. + * + * @Since: 1.1 */ #include #include "uca-plugin-manager.h" @@ -58,6 +61,13 @@ uca_plugin_manager_new () return UCA_PLUGIN_MANAGER (g_object_new (UCA_TYPE_PLUGIN_MANAGER, NULL)); } +/** + * uca_plugin_manager_add_path: + * @manager: A #UcaPluginManager + * @path: Path to look for camera modules + * + * Add a search path to the plugin manager. + */ void uca_plugin_manager_add_path (UcaPluginManager *manager, const gchar *path) @@ -132,6 +142,15 @@ g_list_free_full (GList *list) g_list_free (list); } +/** + * uca_plugin_manager_get_available_cameras: + * + * @manager: A #UcaPluginManager + * + * Return: A list with strings of available camera names. You have to free the + * individual strings with g_list_foreach(list, (GFunc) g_free, NULL) and the + * list itself with g_list_free. + */ GList * uca_plugin_manager_get_available_cameras (UcaPluginManager *manager) { @@ -175,6 +194,12 @@ find_camera_module_path (GList *search_paths, const gchar *name) return result; } +/** + * uca_plugin_manager_new_camera: + * @manager: A #UcaPluginManager + * @name: Name of the camera module, that maps to libuca.so + * @error: Location for a #GError + */ UcaCamera * uca_plugin_manager_new_camera (UcaPluginManager *manager, const gchar *name, -- cgit v1.2.3 From 2c770ee3fe040186602aeadd62a5d256724e1105 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 21 Sep 2012 11:46:46 +0200 Subject: Rename g_list_free_full to list_free_full This got really implemented with GLib 2.28, so the names clash. --- src/uca-plugin-manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index fdfb59f..5678e83 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -136,7 +136,7 @@ transform_camera_module_path_to_name (gchar *path, GList **result) } static void -g_list_free_full (GList *list) +list_free_full (GList *list) { g_list_foreach (list, (GFunc) g_free, NULL); g_list_free (list); @@ -164,7 +164,7 @@ uca_plugin_manager_get_available_cameras (UcaPluginManager *manager) camera_paths = scan_search_paths (priv->search_paths); g_list_foreach (camera_paths, (GFunc) transform_camera_module_path_to_name, &camera_names); - g_list_free_full (camera_paths); + list_free_full (camera_paths); return camera_names; } @@ -190,7 +190,7 @@ find_camera_module_path (GList *search_paths, const gchar *name) g_free (basename); } - g_list_free_full (paths); + list_free_full (paths); return result; } -- cgit v1.2.3 From b3dbedeec78a55802565a3824ab52188e8b9bd4d Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 8 Oct 2012 14:38:16 +0200 Subject: Generate introspection files Unfortunately, the gir tools recognize anything with $PREFIX_new_$SUFFIX as some kind of constructor. This means that we have to rename uca_plugin_manager_new_camera() to uca_plugin_manager_get_camera(). --- src/uca-plugin-manager.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index 5678e83..cb7e518 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -49,9 +49,7 @@ uca_plugin_manager_error_quark (void) * uca_plugin_manager_new: * @config: (allow-none): A #UcaConfiguration object or %NULL. * - * Create a plugin manager object to instantiate filter objects. When a config - * object is passed to the constructor, its search-path property is added to the - * internal search paths. + * Create a plugin manager object to instantiate camera objects. * * Return value: A new plugin manager object. */ @@ -147,9 +145,10 @@ list_free_full (GList *list) * * @manager: A #UcaPluginManager * - * Return: A list with strings of available camera names. You have to free the - * individual strings with g_list_foreach(list, (GFunc) g_free, NULL) and the - * list itself with g_list_free. + * Returns: (element-type utf8) (transfer full): A list with strings of + * available camera names. You have to free the individual strings with + * g_list_foreach(list, (GFunc) g_free, NULL) and the list itself with + * g_list_free. */ GList * uca_plugin_manager_get_available_cameras (UcaPluginManager *manager) @@ -201,7 +200,7 @@ find_camera_module_path (GList *search_paths, const gchar *name) * @error: Location for a #GError */ UcaCamera * -uca_plugin_manager_new_camera (UcaPluginManager *manager, +uca_plugin_manager_get_camera (UcaPluginManager *manager, const gchar *name, GError **error) { -- cgit v1.2.3 From b72daf9dbba95a208a4fb84e5b1c629d64a72c00 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 9 Oct 2012 16:05:20 +0200 Subject: Fix #151: Rename trigger enum value --- src/uca-plugin-manager.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index cb7e518..373ccb2 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -1,3 +1,20 @@ +/* Copyright (C) 2012 Matthias Vogelgesang + (Karlsruhe Institute of Technology) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + This library 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 Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., 51 + Franklin St, Fifth Floor, Boston, MA 02110, USA */ + /** * SECTION:uca-plugin-manager * @Short_description: Load an #UcaFilter from a shared object @@ -47,7 +64,6 @@ uca_plugin_manager_error_quark (void) /** * uca_plugin_manager_new: - * @config: (allow-none): A #UcaConfiguration object or %NULL. * * Create a plugin manager object to instantiate camera objects. * @@ -142,10 +158,9 @@ list_free_full (GList *list) /** * uca_plugin_manager_get_available_cameras: - * * @manager: A #UcaPluginManager * - * Returns: (element-type utf8) (transfer full): A list with strings of + * Return value: (element-type utf8) (transfer full): A list with strings of * available camera names. You have to free the individual strings with * g_list_foreach(list, (GFunc) g_free, NULL) and the list itself with * g_list_free. -- cgit v1.2.3 From 7fe0adeb842c3aa47b380a9290465b1250025878 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 19 Oct 2012 10:39:40 +0200 Subject: Update uca_plugin_manager_get_camera annotation --- src/uca-plugin-manager.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/uca-plugin-manager.c') diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index 373ccb2..e99f478 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -209,10 +209,14 @@ find_camera_module_path (GList *search_paths, const gchar *name) } /** - * uca_plugin_manager_new_camera: + * uca_plugin_manager_get_camera: * @manager: A #UcaPluginManager * @name: Name of the camera module, that maps to libuca.so * @error: Location for a #GError + * + * Create a new camera instance with camera @name. + * + * Returns: (transfer full): A new #UcaCamera object. */ UcaCamera * uca_plugin_manager_get_camera (UcaPluginManager *manager, -- cgit v1.2.3