diff options
author | Juan A. Suarez Romero <jasuarez@igalia.com> | 2011-03-30 20:51:59 +0200 |
---|---|---|
committer | Juan A. Suarez Romero <jasuarez@igalia.com> | 2011-03-30 20:51:59 +0200 |
commit | b3e134061922d742ff0a047c011ecd8d299bcce1 (patch) | |
tree | 0c39efd6fa7bcd9cf78159012f2da2a13ed37436 | |
parent | f446279a514d144846faf15777e34ef2eb3c2b22 (diff) | |
parent | 0cba561d6c6891bb3f1a3ff02e8bad1a6f255ac7 (diff) |
Merge commit 'grilo-0.1.12' into rpm
-rw-r--r-- | NEWS | 16 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | libs/net/Makefile.am | 7 | ||||
-rw-r--r-- | libs/net/grl-net-wc.c | 330 | ||||
-rw-r--r-- | libs/net/grl-net-wc.h | 6 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/data/grl-config.c | 5 | ||||
-rw-r--r-- | src/data/grl-config.h | 4 | ||||
-rw-r--r-- | src/data/grl-data.c | 42 | ||||
-rw-r--r-- | src/data/grl-media-image.c | 171 | ||||
-rw-r--r-- | src/data/grl-media-image.h | 33 | ||||
-rw-r--r-- | src/data/grl-media.c | 33 | ||||
-rw-r--r-- | src/data/grl-media.h | 4 | ||||
-rw-r--r-- | src/data/grl-related-keys.c | 31 | ||||
-rw-r--r-- | src/grl-media-source.c | 2 | ||||
-rw-r--r-- | src/grl-media-source.h | 8 | ||||
-rw-r--r-- | src/grl-metadata-key.c | 65 | ||||
-rw-r--r-- | src/grl-metadata-key.h | 6 | ||||
-rw-r--r-- | src/grl-metadata-source.c | 170 | ||||
-rw-r--r-- | src/grl-metadata-source.h | 4 | ||||
-rw-r--r-- | src/grl-plugin-registry.c | 4 | ||||
-rw-r--r-- | tools/grilo-test-ui/main.c | 14 |
22 files changed, 807 insertions, 158 deletions
@@ -1,3 +1,19 @@ +NEW in 0.1.12 +============= + + * Several fixes and improvements, including fixes for: + * BGO#645542 - grl_metadata_source_set_metadata() broken + * Added support for caching in GrlNet + * Added new metadata keys suited for camera pictures + * Improved GObject Introspection support + + * Contributors to this release: + Juan A. Suarez Romero <jasuarez@igalia.com> + Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com> + Michael Wood <michael.g.wood@linux.intel.com> + Simon Pena <spena@igalia.com> + + NEW in 0.1.11 ============= diff --git a/configure.ac b/configure.ac index a474a03..43d2a17 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ m4_define([prj_name], [grilo]) m4_define([prj_gir_name], [Grilo]) m4_define([grl_major_version], [0]) m4_define([grl_minor_version], [1]) -m4_define([grl_micro_version], [11]) +m4_define([grl_micro_version], [12]) m4_define([prj_version], grl_major_version.grl_minor_version.grl_micro_version) AC_INIT([prj_name], [prj_version]) @@ -117,6 +117,9 @@ PKG_CHECK_MODULES(NET, libsoup-2.4, HAVE_LIBSOUP=yes, HAVE_LIBSOUP=no) +PKG_CHECK_MODULES(NETCACHE, libsoup-2.4 >= 2.33.4, + HAVE_CACHED_LIBSOUP=yes, + HAVE_CACHED_LIBSOUP=no) AC_ARG_ENABLE([grl_net], AS_HELP_STRING([--enable-grl-net], [Enable Grilo Net library (default: auto)]), @@ -134,6 +137,7 @@ AC_ARG_ENABLE([grl_net], ]) AM_CONDITIONAL(BUILD_GRILO_NET, test "x$HAVE_LIBSOUP" = "xyes") +AM_CONDITIONAL(BUILD_GRILO_NET_WITH_CACHE, test "x$HAVE_CACHED_LIBSOUP" = "xyes") # ---------------------------------------------------------- # DEBUG SUPPORT @@ -223,7 +227,7 @@ GTK_DOC_CHECK([1.10],[--flavour no-tmpl]) # GOBJECT-INTROSPECTION # ---------------------------------------------------------- -GOBJECT_INTROSPECTION_CHECK([0.6.7]) +GOBJECT_INTROSPECTION_CHECK([0.9]) # ---------------------------------------------------------- # GETTEXT diff --git a/libs/net/Makefile.am b/libs/net/Makefile.am index d7542fa..206545a 100644 --- a/libs/net/Makefile.am +++ b/libs/net/Makefile.am @@ -5,6 +5,7 @@ # # Copyright (C) 2010 Igalia S.L. All rights reserved. + lib_LTLIBRARIES = libgrlnet-@GRL_MAJORMINOR@.la noinst_PROGRAMS = wc-test @@ -20,6 +21,11 @@ libgrlnet_@GRL_MAJORMINOR@_la_CFLAGS = \ $(DEPS_CFLAGS) \ $(NET_CFLAGS) +if BUILD_GRILO_NET_WITH_CACHE +libgrlnet_@GRL_MAJORMINOR@_la_CFLAGS += \ + -DLIBSOUP_WITH_CACHE +endif + libgrlnet_@GRL_MAJORMINOR@_la_LIBADD = \ $(top_builddir)/src/lib@GRL_NAME@.la \ $(DEPS_LIBS) \ @@ -57,6 +63,7 @@ gir_headers = $(patsubst %,$(srcdir)/%, $(libgrlnet_@GRL_MAJORMINOR@include_HEAD gir_sources = $(patsubst %,$(srcdir)/%, $(libgrlnet_@GRL_MAJORMINOR@_la_SOURCES)) INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --warn-all introspection_sources = \ $(gir_headers) \ diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c index 0b6253f..afb5c36 100644 --- a/libs/net/grl-net-wc.c +++ b/libs/net/grl-net-wc.c @@ -4,6 +4,7 @@ * Contact: Iago Toral Quiroga <itoral@igalia.com> * * Authors: Víctor M. Jáquez L. <vjaquez@igalia.com> + * Juan A. Suarez Romero <jasuarez@igalia.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -35,8 +36,18 @@ #include "config.h" #endif +#include <string.h> #include <libsoup/soup.h> +#ifdef LIBSOUP_WITH_CACHE +/* Using the cache feature requires to use the unstable API */ +#define LIBSOUP_USE_UNSTABLE_REQUEST_API +#define BUFFER_SIZE (50*1024) +#include <libsoup/soup-cache.h> +#include <libsoup/soup-requester.h> +#include <libsoup/soup-request-http.h> +#endif + #include <grilo.h> #include "grl-net-wc.h" @@ -47,6 +58,8 @@ enum { PROP_0, PROP_LOG_LEVEL, PROP_THROTTLING, + PROP_CACHE, + PROP_CACHE_SIZE, }; #define GRL_NET_WC_GET_PRIVATE(object) \ @@ -54,11 +67,24 @@ enum { GRL_TYPE_NET_WC, \ GrlNetWcPrivate)) +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API +static SoupCache *cache = NULL; +static void cache_down(GrlNetWc *self); +#endif + +static guint cache_size; + typedef struct _RequestClosure RequestClosure; struct _GrlNetWcPrivate { SoupSession *session; SoupLoggerLogLevel log_level; +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + SoupRequester *requester; + SoupCache *cache; + gchar *previous_data; +#endif + guint cache_size; guint throttling; GTimeVal last_request; GQueue *pending; /* closure queue for delayed requests */ @@ -72,6 +98,15 @@ struct _RequestClosure { guint source_id; }; +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API +typedef struct { + SoupRequest *request; + gchar *buffer; + gsize length; + gsize offset; +} RequestResult; +#endif + GQuark grl_net_wc_error_quark (void) { @@ -130,6 +165,34 @@ grl_net_wc_class_init (GrlNetWcClass *klass) 0, G_MAXUINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * GrlNetWc::cache + * + * %TRUE if cache must be used. %FALSE otherwise. + */ + g_object_class_install_property (g_klass, + PROP_CACHE, + g_param_spec_boolean ("cache", + "Use cache", + "Use cache", + TRUE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + /** + * GrlNetWc::cache-size + * + * Maximum size of cache, in Mb. Default value is 10Mb. + */ + g_object_class_install_property (g_klass, + PROP_CACHE_SIZE, + g_param_spec_uint ("cache-size", + "Cache size", + "Size of cache in Mb", + 0, G_MAXUINT, 10, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); } static void @@ -141,6 +204,11 @@ grl_net_wc_init (GrlNetWc *wc) wc->priv->session = soup_session_async_new (); wc->priv->pending = g_queue_new (); +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + wc->priv->requester = soup_requester_new(); + soup_session_add_feature (wc->priv->session, + SOUP_SESSION_FEATURE (wc->priv->requester)); +#endif } static void @@ -150,6 +218,11 @@ grl_net_wc_finalize (GObject *object) wc = GRL_NET_WC (object); grl_net_wc_flush_delayed_requests (wc); +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + cache_down (wc); + g_free (wc->priv->previous_data); + g_object_unref (wc->priv->requester); +#endif g_queue_free (wc->priv->pending); g_object_unref (wc->priv->session); @@ -173,6 +246,12 @@ grl_net_wc_set_property (GObject *object, case PROP_THROTTLING: grl_net_wc_set_throttling (wc, g_value_get_uint (value)); break; + case PROP_CACHE: + grl_net_wc_set_cache (wc, g_value_get_boolean (value)); + break; + case PROP_CACHE_SIZE: + grl_net_wc_set_cache_size (wc, g_value_get_uint (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (wc, propid, pspec); } @@ -195,6 +274,16 @@ grl_net_wc_get_property (GObject *object, case PROP_THROTTLING: g_value_set_uint (value, wc->priv->throttling); break; + case PROP_CACHE: +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + g_value_set_boolean (value, wc->priv->cache != NULL); +#else + g_value_set_boolean (value, FALSE); +#endif + break; + case PROP_CACHE_SIZE: + g_value_set_uint (value, wc->priv->cache_size); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (wc, propid, pspec); } @@ -261,6 +350,88 @@ parse_error (guint status, } } +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API +static void +read_async_cb (GObject *source, GAsyncResult *res, gpointer user_data) +{ + GSimpleAsyncResult *result; + RequestResult *rr; + SoupMessage *msg; + GError *error = NULL; + gsize to_read; + gssize s; + + result = G_SIMPLE_ASYNC_RESULT (user_data); + rr = g_simple_async_result_get_op_res_gpointer (result); + + s = g_input_stream_read_finish (G_INPUT_STREAM (source), res, &error); + if (s > 0) { + /* Continue reading */ + rr->offset += s; + to_read = rr->length - rr->offset; + if (!to_read) { + /* Buffer is not enough; we need to assign more space */ + rr->length *= 2; + rr->buffer = g_renew (gchar, rr->buffer, rr->length); + to_read = rr->length - rr->offset; + } + g_input_stream_read_async (G_INPUT_STREAM (source), rr->buffer + rr->offset, to_read, G_PRIORITY_DEFAULT, NULL, read_async_cb, user_data); + return; + } + + /* Put the end of string */ + rr->buffer[rr->offset] = '\0'; + + g_input_stream_close (G_INPUT_STREAM (source), NULL, NULL); + + if (error) { + if (error->code == G_IO_ERROR_CANCELLED) { + g_simple_async_result_set_error (result, GRL_NET_WC_ERROR, + GRL_NET_WC_ERROR_CANCELLED, + "Operation was cancelled"); + } else { + g_simple_async_result_set_error (result, GRL_NET_WC_ERROR, + GRL_NET_WC_ERROR_UNAVAILABLE, + "Data not available"); + } + g_error_free (error); + + g_simple_async_result_complete (result); + return; + } + + msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (rr->request)); + + if (msg) { + if (msg->status_code != SOUP_STATUS_OK) { + parse_error (msg->status_code, + msg->reason_phrase, + msg->response_body->data, + G_SIMPLE_ASYNC_RESULT (user_data)); + g_object_unref (msg); + } + } + + g_simple_async_result_complete (result); +} + +static void +reply_cb (GObject *source, GAsyncResult *res, gpointer user_data) +{ + GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); + RequestResult *rr = g_simple_async_result_get_op_res_gpointer (result); + + GInputStream *in = soup_request_send_finish (rr->request, res, NULL); + rr->length = soup_request_get_content_length (rr->request) + 1; + if (rr->length == 1) { + rr->length = BUFFER_SIZE; + } + rr->buffer = g_new (gchar, rr->length); + g_input_stream_read_async (in, rr->buffer, rr->length, G_PRIORITY_DEFAULT, NULL, read_async_cb, user_data); +} + +#else + static void reply_cb (SoupSession *session, SoupMessage *msg, @@ -299,6 +470,25 @@ message_cancel_cb (GCancellable *cancellable, msg, SOUP_STATUS_CANCELLED); } +#endif + +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API +static void +get_url_now (GrlNetWc *self, + const char *url, + GAsyncResult *result, + GCancellable *cancellable) +{ + RequestResult *rr = g_slice_new0 (RequestResult); + + rr->request = soup_requester_request (self->priv->requester, url, NULL); + g_simple_async_result_set_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result), + rr, + NULL); + soup_request_send_async (rr->request, cancellable, reply_cb, result); +} + +#else static void get_url_now (GrlNetWc *self, @@ -348,6 +538,7 @@ get_url_now (GrlNetWc *self, reply_cb, result); } +#endif static gboolean get_url_delayed (gpointer user_data) @@ -405,16 +596,54 @@ get_url (GrlNetWc *self, } } +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API +static void +update_cache_size () +{ + guint size_in_bytes = cache_size * 1024 * 1024; + soup_cache_set_max_size (cache, size_in_bytes); +} + +static void +cache_down (GrlNetWc *self) +{ + soup_session_remove_feature (self->priv->session, + SOUP_SESSION_FEATURE (self->priv->cache)); + g_object_unref (self->priv->cache); + self->priv->cache = NULL; +} + +static void +cache_up (GrlNetWc *self) +{ + if (!cache) { + gchar *cache_dir = g_build_filename (g_get_user_cache_dir (), + g_get_prgname (), + "grilo", + NULL); + cache = soup_cache_new (cache_dir, SOUP_CACHE_SINGLE_USER); + update_cache_size (); + g_free (cache_dir); + } + + self->priv->cache = g_object_ref (cache); + soup_session_add_feature (self->priv->session, + SOUP_SESSION_FEATURE (self->priv->cache)); +} +#endif + /** * grl_net_wc_new: + * Creates a new #GrlNetWc. * * Returns: a new allocated instance of #GrlNetWc. Do g_object_unref() after * use it. */ GrlNetWc * -grl_net_wc_new (void) +grl_net_wc_new () { - return g_object_new (GRL_TYPE_NET_WC, NULL); + return g_object_new (GRL_TYPE_NET_WC, + NULL); } /** @@ -471,7 +700,6 @@ grl_net_wc_request_finish (GrlNetWc *self, GError **error) { GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (result); - SoupMessage *msg; gboolean ret = TRUE; g_warn_if_fail (g_simple_async_result_get_source_tag (res) == @@ -482,15 +710,40 @@ grl_net_wc_request_finish (GrlNetWc *self, goto end_func; } - msg = (SoupMessage *) g_simple_async_result_get_op_res_gpointer (res); +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + RequestResult *rr = g_simple_async_result_get_op_res_gpointer (res); + + if (self->priv->previous_data) { + g_free (self->priv->previous_data); + } + + self->priv->previous_data = rr->buffer; + + if (content) { + *content = self->priv->previous_data; + } else { + g_free (rr->buffer); + } + + if (length) { + *length = rr->offset; + } + +#else + SoupMessage *msg = (SoupMessage *) g_simple_async_result_get_op_res_gpointer (res); if (content != NULL) *content = (gchar *) msg->response_body->data; - if (length != NULL) *length = (gsize) msg->response_body->length; +#endif end_func: +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + g_object_unref (rr->request); + g_slice_free (RequestResult, rr); +#endif + g_object_unref (res); return ret; } @@ -552,6 +805,73 @@ grl_net_wc_set_throttling (GrlNetWc *self, } /** + * grl_net_wc_set_cache: + * @self: a #GrlNetWc instance + * @use_cache: if cache must be used or not + * + * Sets if cache must be used. Note that this will only work if caching is + * supporting. If sets %TRUE, a new cache will be created. If sets to %FALSE, + * current cache is clean and removed. + * + * Since: 0.1.12 + **/ +void +grl_net_wc_set_cache (GrlNetWc *self, + gboolean use_cache) +{ + g_return_if_fail (GRL_IS_NET_WC (self)); + +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + if (use_cache) { + if (self->priv->cache) { + return; + } + + cache_up (self); + + } else { + if (self->priv->cache) { + cache_down (self); + } + } +#else + GRL_WARNING ("Cache not supported"); +#endif +} + +/** + * grl_net_wc_set_cache_size: + * @self: a #GrlNetWc instance + * @cache_size: size of cache (in Mb) + * + * Sets the new maximum size of cache, in Megabytes. Default value is 10. Using + * 0 means no cache will be done. + * + * Since: 0.1.12 + **/ +void +grl_net_wc_set_cache_size (GrlNetWc *self, + guint size) +{ + g_return_if_fail (GRL_IS_NET_WC (self)); + + if (self->priv->cache_size == size) { + return; + } + + /* Change the global cache size */ + cache_size -= self->priv->cache_size; + self->priv->cache_size = size; + cache_size += self->priv->cache_size; + +#ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API + if (self->priv->cache) { + update_cache_size (); + } +#endif +} + +/** * grl_net_wc_flush_delayed_requests: * @self: a #GrlNetWc instance * diff --git a/libs/net/grl-net-wc.h b/libs/net/grl-net-wc.h index 71dfd72..d8ed1ba 100644 --- a/libs/net/grl-net-wc.h +++ b/libs/net/grl-net-wc.h @@ -129,6 +129,12 @@ void grl_net_wc_set_log_level (GrlNetWc *self, void grl_net_wc_set_throttling (GrlNetWc *self, guint throttling); +void grl_net_wc_set_cache (GrlNetWc *self, + gboolean use_cache); + +void grl_net_wc_set_cache_size (GrlNetWc *self, + guint cache_size); + void grl_net_wc_flush_delayed_requests (GrlNetWc *self); G_END_DECLS diff --git a/src/Makefile.am b/src/Makefile.am index 1b29bdf..036e9e8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -111,7 +111,7 @@ CLEANFILES = -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=$(srcdir)/data # introspection support diff --git a/src/data/grl-config.c b/src/data/grl-config.c index f800765..a022163 100644 --- a/src/data/grl-config.c +++ b/src/data/grl-config.c @@ -297,7 +297,8 @@ grl_config_set_api_key (GrlConfig *config, const gchar *key) /** * grl_config_set_api_key_blob: * @config: the config instance - * @key: the binary API key + * @blob: the binary API key blob + * @size: the size of the blob * * Set the binary API key in the configuration * @@ -485,7 +486,7 @@ grl_config_get_password(GrlConfig *config) /** * grl_config_has_param: * @config: the config instance - * @key: the param + * @param: the param * * Returns: TRUE if @params has a defined value within @config, FALSE * otherwise. diff --git a/src/data/grl-config.h b/src/data/grl-config.h index d37d8b3..2079c93 100644 --- a/src/data/grl-config.h +++ b/src/data/grl-config.h @@ -112,9 +112,9 @@ void grl_config_set_api_token (GrlConfig *config, const gchar *token); void grl_config_set_api_secret (GrlConfig *config, const gchar *secret); -void grl_config_set_username (GrlConfig *config, const gchar *secret); +void grl_config_set_username (GrlConfig *config, const gchar *username); -void grl_config_set_password (GrlConfig *config, const gchar *secret); +void grl_config_set_password (GrlConfig *config, const gchar *password); gchar *grl_config_get_plugin (GrlConfig *config); diff --git a/src/data/grl-data.c b/src/data/grl-data.c index 95ed6bb..6e3461e 100644 --- a/src/data/grl-data.c +++ b/src/data/grl-data.c @@ -205,7 +205,7 @@ grl_data_new (void) /** * grl_data_get: * @data: data to retrieve value - * @key: (type Grl.KeyID): key to look up. + * @key: (type GObject.ParamSpec): key to look up. * * Get the first value from @data associated with @key. * @@ -236,7 +236,7 @@ grl_data_get (GrlData *data, GrlKeyID key) /** * grl_data_set: * @data: data to modify - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @value: the new value * * Sets the first value associated with @key in @data. If key already has a @@ -282,7 +282,7 @@ grl_data_set (GrlData *data, GrlKeyID key, const GValue *value) /** * grl_data_set_string: * @data: data to modify - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @strvalue: the new value * * Sets the first string value associated with @key in @data. If @key already @@ -310,7 +310,7 @@ grl_data_set_string (GrlData *data, /** * grl_data_get_string: * @data: data to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * * Returns the first string value associated with @key from @data. If @key has * no first value, or value is not string, or @key is not in @data, then %NULL @@ -336,7 +336,7 @@ grl_data_get_string (GrlData *data, GrlKeyID key) /** * grl_data_set_int: * @data: data to change - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @intvalue: the new value * * Sets the first int value associated with @key in @data. If @key already has a @@ -356,7 +356,7 @@ grl_data_set_int (GrlData *data, GrlKeyID key, gint intvalue) /** * grl_data_get_int: * @data: data to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * * Returns the first int value associated with @key from @data. If @key has no * first value, or value is not a gint, or @key is not in data, then 0 is @@ -381,7 +381,7 @@ grl_data_get_int (GrlData *data, GrlKeyID key) /** * grl_data_set_float: * @data: data to change - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @floatvalue: the new value * * Sets the first float value associated with @key in @data. If @key already has @@ -401,7 +401,7 @@ grl_data_set_float (GrlData *data, GrlKeyID key, float floatvalue) /** * grl_data_get_float: * @data: data to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * * Returns the first float value associated with @key from @data. If @key has no * first value, or value is not a gfloat, or @key is not in data, then 0 is @@ -426,7 +426,7 @@ grl_data_get_float (GrlData *data, GrlKeyID key) /** * grl_data_set_binary: * @data: data to change - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @buf: buffer holding the data * @size: size of the buffer * @@ -453,7 +453,7 @@ grl_data_set_binary (GrlData *data, GrlKeyID key, const guint8 *buf, gsize size) /** * grl_data_get_binary: * @data: data to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * @size: (out): location to store the buffer size * * Returns the first binary value associated with @key from @data. If @key has @@ -484,7 +484,7 @@ grl_data_get_binary(GrlData *data, GrlKeyID key, gsize *size) /** * grl_data_add: * @data: data to change - * @key: (type Grl.KeyID): key to add + * @key: (type GObject.ParamSpec): key to add * * Adds a new @key to @data, with no value. If key already exists, it does * nothing. @@ -502,7 +502,7 @@ grl_data_add (GrlData *data, GrlKeyID key) /** * grl_data_remove: * @data: data to change - * @key: (type Grl.KeyID): key to remove + * @key: (type GObject.ParamSpec): key to remove * * Removes the first value for @key from @data. If there are other keys related * to @key their values will also be removed from @data. @@ -520,7 +520,7 @@ grl_data_remove (GrlData *data, GrlKeyID key) /** * grl_data_has_key: * @data: data to inspect - * @key: (type Grl.KeyID): key to search + * @key: (type GObject.ParamSpec): key to search * * Checks if @key is in @data. * @@ -549,7 +549,7 @@ grl_data_has_key (GrlData *data, GrlKeyID key) * * Returns a list with keys contained in @data. * - * Returns: (transfer container) (element-type Grl.KeyID): an array with the + * Returns: (transfer container) (element-type GObject.ParamSpec): an array with the * keys. The content of the list should not be modified or freed. Use * g_list_free() when done using the list. * @@ -584,7 +584,7 @@ grl_data_get_keys (GrlData *data) /** * grl_data_key_is_known: * @data: data to inspect - * @key: (type Grl.KeyID): key to search + * @key: (type GObject.ParamSpec): key to search * * Checks if the @key has a first value in @data. * @@ -661,7 +661,7 @@ grl_data_add_related_keys (GrlData *data, /** * grl_data_add_string: * @data: data to append - * @key: (type Grl.KeyID): key to append + * @key: (type GObject.ParamSpec): key to append * @strvalue: the new value * * Appends a new string value for @key in @data. @@ -686,7 +686,7 @@ grl_data_add_string (GrlData *data, /** * grl_data_add_int: * @data: data to append - * @key: (type Grl.KeyID): key to append + * @key: (type GObject.ParamSpec): key to append * @intvalue: the new value * * Appends a new int value for @key in @data. @@ -711,7 +711,7 @@ grl_data_add_int (GrlData *data, /** * grl_data_add_float: * @data: data to append - * @key: (type Grl.KeyID): key to append + * @key: (type GObject.ParamSpec): key to append * @floatvalue: the new value * * Appends a new float value for @key in @data. @@ -736,7 +736,7 @@ grl_data_add_float (GrlData *data, /** * grl_data_add_binary: * @data: data to append - * @key: (type Grl.KeyID): key to append + * @key: (type GObject.ParamSpec): key to append * @buf: the buffer containing the new value * @size: size of buffer * @@ -800,7 +800,7 @@ grl_data_length (GrlData *data, * If user changes any of the values in the related keys, the changes will * become permanent. * - * Returns: a #GrlRelatedKeys. Do not free it. + * Returns: (transfer none): a #GrlRelatedKeys. Do not free it. * * Since: 0.1.10 **/ @@ -1002,7 +1002,7 @@ grl_data_set_related_keys (GrlData *data, * * Makes a deep copy of @data and all its contents. * - * Returns: a new #GrlData. Free it with #g_object_unref. + * Returns: (transfer full): a new #GrlData. Free it with #g_object_unref. * * Since: 0.1.10 **/ diff --git a/src/data/grl-media-image.c b/src/data/grl-media-image.c index 95a4342..12d0993 100644 --- a/src/data/grl-media-image.c +++ b/src/data/grl-media-image.c @@ -288,3 +288,174 @@ grl_media_image_get_url_data_nth (GrlMediaImage *image, return grl_related_keys_get_string (relkeys, GRL_METADATA_KEY_URL); } + +/** + * grl_media_image_get_camera_model: + * @image: the image instance + * + * Returns: model of camera used to take picture + * + * Since: 0.1.12 + */ +const gchar * +grl_media_image_get_camera_model (GrlMediaImage *image) +{ + return grl_data_get_string (GRL_DATA (image), + GRL_METADATA_KEY_CAMERA_MODEL); +} + +/** + * grl_media_set_camera_model: + * @image: the image instance + * @camera_model: model of camera used to take picture + * + * Set the camera_model of the image + * + * Since: 0.1.12 + */ +void +grl_media_image_set_camera_model (GrlMediaImage *image, + const gchar * camera_model) +{ + grl_data_set_string (GRL_DATA (image), + GRL_METADATA_KEY_CAMERA_MODEL, + camera_model); +} + + +/** + * grl_media_image_get_flash_used: + * @image: the image instance + * + * Returns: whether the flash was used + * See + * http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#nmm-Flash + * + * Since: 0.1.12 + */ +const gchar * +grl_media_image_get_flash_used (GrlMediaImage *image) +{ + return grl_data_get_string (GRL_DATA (image), + GRL_METADATA_KEY_FLASH_USED); +} + +/** + * grl_media_set_flash_used: + * @image: the image instance + * @flash_used: whether the flash was used + * + * Set the flash_used of the image + * See + * http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#nmm-Flash + * + * Since: 0.1.12 + */ +void +grl_media_image_set_flash_used (GrlMediaImage *image, + const gchar *flash_used) +{ + grl_data_set_string (GRL_DATA (image), + GRL_METADATA_KEY_FLASH_USED, + flash_used); +} + + +/** + * grl_media_image_get_exposure_time: + * @image: the image instance + * + * Returns: picture's exposure time + * + * Since: 0.1.12 + */ +gfloat +grl_media_image_get_exposure_time (GrlMediaImage *image) +{ + return grl_data_get_float (GRL_DATA (image), + GRL_METADATA_KEY_EXPOSURE_TIME); +} + +/** + * grl_media_set_exposure_time: + * @image: the image instance + * @exposure_time: picture's exposure time + * + * Set the exposure_time of the image + * + * Since: 0.1.12 + */ +void +grl_media_image_set_exposure_time (GrlMediaImage *image, + gfloat exposure_time) +{ + grl_data_set_float (GRL_DATA (image), + GRL_METADATA_KEY_EXPOSURE_TIME, + exposure_time); +} + +/** + * grl_media_image_get_iso_speed: + * @image: the image instance + * + * Returns: picture's iso speed + * + * Since: 0.1.12 + */ +gfloat +grl_media_image_get_iso_speed (GrlMediaImage *image) +{ + return grl_data_get_float (GRL_DATA (image), + GRL_METADATA_KEY_ISO_SPEED); +} + +/** + * grl_media_set_iso_speed: + * @image: the image instance + * @iso_speed: picture's iso speed + * + * Set the iso_speed of the image + * + * Since: 0.1.12 + */ +void +grl_media_image_set_iso_speed (GrlMediaImage *image, + gfloat iso_speed) +{ + grl_data_set_float (GRL_DATA (image), + GRL_METADATA_KEY_ISO_SPEED, + iso_speed); +} + +/** + * grl_media_image_get_orientation: + * @image: the image instance + * + * Returns: degrees clockwise orientation of the picture + * + * Since: 0.1.12 + */ +gint +grl_media_image_get_orientation (GrlMediaImage *image) +{ + return grl_data_get_int (GRL_DATA (image), + GRL_METADATA_KEY_ORIENTATION); +} + +/** + * grl_media_set_orientation: + * @image: the image instance + * @orientation: degrees clockwise orientation of the picture + * + * Set the orientation of the image + * + * Since: 0.1.12 + */ +void +grl_media_image_set_orientation (GrlMediaImage *image, + gint orientation) +{ + grl_data_set_int (GRL_DATA (image), + GRL_METADATA_KEY_ORIENTATION, + orientation % 360); +} diff --git a/src/data/grl-media-image.h b/src/data/grl-media-image.h index f9bc390..e7f46be 100644 --- a/src/data/grl-media-image.h +++ b/src/data/grl-media-image.h @@ -93,8 +93,17 @@ gint grl_media_image_get_width (GrlMediaImage *image); gint grl_media_image_get_height (GrlMediaImage *image); -GType grl_media_image_get_type (void) G_GNUC_CONST; -GrlMedia *grl_media_image_new (void); +const gchar *grl_media_image_get_camera_model (GrlMediaImage *image); + +const gchar *grl_media_image_get_flash_used (GrlMediaImage *image); + +gfloat grl_media_image_get_exposure_time (GrlMediaImage *image); + +gfloat grl_media_image_get_iso_speed (GrlMediaImage *image); + +gint grl_media_image_get_orientation (GrlMediaImage *image); + + void grl_media_image_set_size (GrlMediaImage *image, gint width, gint height); @@ -122,6 +131,26 @@ void grl_media_image_add_url_data (GrlMediaImage *image, gint width, gint height); +void grl_media_image_set_camera_model (GrlMediaImage *image, + const gchar *camera_model); + +void grl_media_image_set_flash_used (GrlMediaImage *image, + const gchar *flash_used); + +void grl_media_image_set_exposure_time (GrlMediaImage *image, + gfloat exposure_time); + +void grl_media_image_set_iso_speed (GrlMediaImage *image, + gfloat iso_speed); + +void grl_media_image_set_orientation (GrlMediaImage *image, + gint orientation); + +GType grl_media_image_get_type (void) G_GNUC_CONST; + +GrlMedia *grl_media_image_new (void); + + G_END_DECLS #endif /* _GRL_MEDIA_IMAGE_H_ */ diff --git a/src/data/grl-media.c b/src/data/grl-media.c index 2b43e5c..80380ee 100644 --- a/src/data/grl-media.c +++ b/src/data/grl-media.c @@ -687,6 +687,24 @@ grl_media_set_date (GrlMedia *media, const gchar *date) } /** + * grl_media_set_creation_date: + * @image: the media + * @creation_date: date when media was created + * + * Set the creation_date of the media + * + * Since: 0.1.12 + */ +void +grl_media_set_creation_date (GrlMedia *media, + const gchar * creation_date) +{ + grl_data_set_string (GRL_DATA (media), + GRL_METADATA_KEY_CREATION_DATE, + creation_date); +} + +/** * grl_media_set_mime: * @media: the media * @mime: the mime type @@ -1116,6 +1134,21 @@ grl_media_get_date (GrlMedia *media) } /** + * grl_media_get_creation_date: + * @image: the media + * + * Returns: date when media was created + * + * Since: 0.1.12 + */ +const gchar * +grl_media_get_creation_date (GrlMedia *media) +{ + return grl_data_get_string (GRL_DATA (media), + GRL_METADATA_KEY_CREATION_DATE); +} + +/** * grl_media_get_mime: * @media: the media object * diff --git a/src/data/grl-media.h b/src/data/grl-media.h index b486556..ed8a3b1 100644 --- a/src/data/grl-media.h +++ b/src/data/grl-media.h @@ -121,6 +121,8 @@ void grl_media_set_duration (GrlMedia *media, gint duration); void grl_media_set_date (GrlMedia *media, const gchar *date); +void grl_media_set_creation_date (GrlMedia *media, const gchar *creation_date); + void grl_media_set_mime (GrlMedia *media, const gchar *mime); void grl_media_set_play_count (GrlMedia *media, gint play_count); @@ -187,6 +189,8 @@ gint grl_media_get_duration (GrlMedia *media); const gchar *grl_media_get_date (GrlMedia *media); +const gchar *grl_media_get_creation_date (GrlMedia *media); + const gchar *grl_media_get_mime (GrlMedia *media); gfloat grl_media_get_rating (GrlMedia *media); diff --git a/src/data/grl-related-keys.c b/src/data/grl-related-keys.c index 440fc7b..5baaa97 100644 --- a/src/data/grl-related-keys.c +++ b/src/data/grl-related-keys.c @@ -195,7 +195,7 @@ grl_related_keys_new_with_keys (GrlKeyID key, /** * grl_related_keys_get: * @relkeys: set of related keys to retrieve value - * @key: (type Grl.KeyID): key to look up. + * @key: (type GObject.ParamSpec): key to look up. * * Get the value associated with @key from @relkeys. If it does not contain any * value, %NULL will be returned. @@ -218,7 +218,7 @@ grl_related_keys_get (GrlRelatedKeys *relkeys, /** * grl_related_keys_set: * @relkeys: set of related keys to modify - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @value: the new value * * Sets the value associated with @key into @relkeys. Old value is freed and @@ -263,7 +263,7 @@ grl_related_keys_set (GrlRelatedKeys *relkeys, /** * grl_related_keys_set_string: * @relkeys: set of related keys to modify - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @strvalue: the new value * * Sets the value associated with @key into @relkeys. @key must have been @@ -290,7 +290,7 @@ grl_related_keys_set_string (GrlRelatedKeys *relkeys, /** * grl_related_keys_get_string: * @relkeys: set of related keys to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * * Returns the value associated with @key from @relkeys. If @key has no value, * or value is not string, or @key is not in @relkeys, then %NULL is returned. @@ -316,7 +316,7 @@ grl_related_keys_get_string (GrlRelatedKeys *relkeys, /** * grl_related_keys_set_int: * @relkeys: set of related keys to change - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @intvalue: the new value * * Sets the value associated with @key into @relkeys. @key must have been @@ -338,7 +338,7 @@ grl_related_keys_set_int (GrlRelatedKeys *relkeys, /** * grl_related_keys_get_int: * @relkeys: set of related keys to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * * Returns the value associated with @key from @relkeys. If @key has no value, * or value is not a gint, or @key is not in @relkeys, then 0 is returned. @@ -363,7 +363,7 @@ grl_related_keys_get_int (GrlRelatedKeys *relkeys, /** * grl_related_keys_set_float: * @relkeys: set of related keys to change - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @floatvalue: the new value * * Sets the value associated with @key into @relkeys. @key must have been @@ -385,7 +385,7 @@ grl_related_keys_set_float (GrlRelatedKeys *relkeys, /** * grl_related_keys_get_float: * @relkeys: set of related keys to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * * Returns the value associated with @key from @relkeys. If @key has no value, * or value is not a gfloat, or @key is not in @relkeys, then 0 is returned. @@ -410,7 +410,7 @@ grl_related_keys_get_float (GrlRelatedKeys *relkeys, /** * grl_related_keys_set_binary: * @relkeys: set of related keys to change - * @key: (type Grl.KeyID): key to change or add + * @key: (type GObject.ParamSpec): key to change or add * @buf: buffer holding the relkeys * @size: size of the buffer * @@ -441,7 +441,7 @@ grl_related_keys_set_binary (GrlRelatedKeys *relkeys, /** * grl_related_keys_get_binary: * @relkeys: set of related keys to inspect - * @key: (type Grl.KeyID): key to use + * @key: (type GObject.ParamSpec): key to use * @size: (out): location to store the buffer size * * Returns the value associated with @key from @relkeys. If @key has no value, @@ -475,7 +475,7 @@ grl_related_keys_get_binary (GrlRelatedKeys *relkeys, /** * grl_related_keys_add: * @relkeys: set of related keys to change - * @key: (type Grl.KeyID): key to add + * @key: (type GObject.ParamSpec): key to add * * Adds a new @key to @relkeys, with no value. If @key already exists, it does * nothing. @@ -494,7 +494,7 @@ grl_related_keys_add (GrlRelatedKeys *relkeys, /** * grl_related_keys_has_key: * @relkeys: set of related keys to inspect - * @key: (type Grl.KeyID): key to search + * @key: (type GObject.ParamSpec): key to search * * Checks if @key is in @relkeys. * @@ -520,7 +520,7 @@ grl_related_keys_has_key (GrlRelatedKeys *relkeys, * %FALSE, only those keys in @relkeys that have actually a value will be * returned. * - * Returns: (transfer container) (element-type Grl.KeyID): an array + * Returns: (transfer container) (element-type GObject.ParamSpec): an array * with the keys. The content of the list should not be modified or freed. Use * g_list_free() when done using the list. * @@ -546,7 +546,7 @@ grl_related_keys_get_keys (GrlRelatedKeys *relkeys, /** * grl_related_keys_key_is_known: * @relkeys: set of related keys to inspect - * @key: (type Grl.KeyID): key to search + * @key: (type GObject.ParamSpec): key to search * * Checks if @key has a value in @relkeys. * @@ -581,7 +581,8 @@ grl_related_keys_key_is_known (GrlRelatedKeys *relkeys, * * Makes a deep copy of @relkeys and its contents. * - * Returns: a new #GrlRelatedKeys. Free it with #g_object_unref. + * Returns: (transfer full): a new #GrlRelatedKeys. + * Free it with #g_object_unref. * * Since: 0.1.10 **/ diff --git a/src/grl-media-source.c b/src/grl-media-source.c index f32346c..12a8cfa 100644 --- a/src/grl-media-source.c +++ b/src/grl-media-source.c @@ -2590,6 +2590,8 @@ grl_media_source_get_media_from_uri (GrlMediaSource *source, * * This method is synchronous. * + * Returns: (transfer full): a filled #GrlMedia + * * Since: 0.1.8 */ GrlMedia * diff --git a/src/grl-media-source.h b/src/grl-media-source.h index 5b71f3c..a37f425 100644 --- a/src/grl-media-source.h +++ b/src/grl-media-source.h @@ -104,7 +104,7 @@ struct _GrlMediaSource { * @remaining: the number of remaining #GrlMedia to process, or * GRL_SOURCE_REMAINING_UNKNOWN if it is unknown * @user_data: user data passed to the used method - * @error: (not-error) (type uint): possible #GError generated at processing + * @error: (type uint): possible #GError generated at processing * * Prototype for the callback passed to the media sources' methods */ @@ -120,7 +120,7 @@ typedef void (*GrlMediaSourceResultCb) (GrlMediaSource *source, * @source: a media source * @media: (transfer full): a data transfer object * @user_data: user data passed to grl_media_source_metadata() - * @error: (not-error) (type uint): possible #GError generated at processing + * @error: (type uint): possible #GError generated at processing * * Prototype for the callback passed to grl_media_source_metadata() */ @@ -135,7 +135,7 @@ typedef void (*GrlMediaSourceMetadataCb) (GrlMediaSource *source, * @parent: The #GrlMediaBox who parents the @media * @media: (transfer full): a data transfer object * @user_data: user data passed to grl_media_source_store() - * @error: (not-error) (type uint): possible #GError generated at processing + * @error: (type uint): possible #GError generated at processing * * Prototype for the callback passed to grl_media_source_store() */ @@ -150,7 +150,7 @@ typedef void (*GrlMediaSourceStoreCb) (GrlMediaSource *source, * @source: a media source * @media: (transfer full): a data transfer object * @user_data: user data passed to grl_media_source_remove() - * @error: (not-error) (type uint): possible #GError generated at processing + * @error: (type uint): possible #GError generated at processing * * Prototype for the callback passed to grl_media_source_remove() */ diff --git a/src/grl-metadata-key.c b/src/grl-metadata-key.c index f2658a6..848186d 100644 --- a/src/grl-metadata-key.c +++ b/src/grl-metadata-key.c @@ -65,6 +65,14 @@ GrlKeyID GRL_METADATA_KEY_SEASON = NULL; GrlKeyID GRL_METADATA_KEY_EPISODE = NULL; GrlKeyID GRL_METADATA_KEY_SHOW = NULL; +GrlKeyID GRL_METADATA_KEY_CREATION_DATE = NULL; + +GrlKeyID GRL_METADATA_KEY_CAMERA_MODEL = NULL; +GrlKeyID GRL_METADATA_KEY_ORIENTATION = NULL; +GrlKeyID GRL_METADATA_KEY_FLASH_USED = NULL; +GrlKeyID GRL_METADATA_KEY_EXPOSURE_TIME = NULL; +GrlKeyID GRL_METADATA_KEY_ISO_SPEED = NULL; + void grl_metadata_key_setup_system_keys (GrlPluginRegistry *registry) { @@ -356,6 +364,63 @@ GRL_METADATA_KEY_STUDIO = G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), NULL); + GRL_METADATA_KEY_CREATION_DATE = + grl_plugin_registry_register_metadata_key (registry, + g_param_spec_string ("creation-date", + "Creation date", + "Creation date", + NULL, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), + NULL); + + GRL_METADATA_KEY_CAMERA_MODEL = + grl_plugin_registry_register_metadata_key (registry, + g_param_spec_string ("camera-model", + "Camera model", + "Name of the camera model used to take the photo", + NULL, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), + NULL); + + GRL_METADATA_KEY_ORIENTATION = + grl_plugin_registry_register_metadata_key (registry, + g_param_spec_int ("orientation", + "Picture orientation", + "Orientation of the photo in degree (clockwise)", + 0, 359, + 0, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), + NULL); + + GRL_METADATA_KEY_FLASH_USED = + grl_plugin_registry_register_metadata_key (registry, + g_param_spec_boolean ("flash-used", + "Flash used", + "Whether or not a flash was used to take that picture", + FALSE, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), + NULL); + + GRL_METADATA_KEY_EXPOSURE_TIME = + grl_plugin_registry_register_metadata_key (registry, + g_param_spec_float ("exposure-time", + "Exposure time", + "Exposure time of the photo in seconds", + 0, G_MAXFLOAT, + 0, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), + NULL); + + GRL_METADATA_KEY_ISO_SPEED = + grl_plugin_registry_register_metadata_key (registry, + g_param_spec_float ("iso-speed", + "ISO speed", + "Photographic film's sensitivity to light as ISO value", + 0, G_MAXFLOAT, + 0, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), + NULL); + /* Create the relations */ grl_plugin_registry_register_metadata_key_relation (registry, GRL_METADATA_KEY_URL, diff --git a/src/grl-metadata-key.h b/src/grl-metadata-key.h index 652d87f..35474a7 100644 --- a/src/grl-metadata-key.h +++ b/src/grl-metadata-key.h @@ -76,6 +76,12 @@ extern GrlKeyID GRL_METADATA_KEY_WIDTH; extern GrlKeyID GRL_METADATA_KEY_SEASON; extern GrlKeyID GRL_METADATA_KEY_EPISODE; extern GrlKeyID GRL_METADATA_KEY_SHOW; +extern GrlKeyID GRL_METADATA_KEY_CREATION_DATE; +extern GrlKeyID GRL_METADATA_KEY_CAMERA_MODEL; +extern GrlKeyID GRL_METADATA_KEY_ORIENTATION; +extern GrlKeyID GRL_METADATA_KEY_FLASH_USED; +extern GrlKeyID GRL_METADATA_KEY_EXPOSURE_TIME; +extern GrlKeyID GRL_METADATA_KEY_ISO_SPEED; const gchar *grl_metadata_key_get_name (GrlKeyID key); diff --git a/src/grl-metadata-source.c b/src/grl-metadata-source.c index c09b314..d37dcc5 100644 --- a/src/grl-metadata-source.c +++ b/src/grl-metadata-source.c @@ -322,11 +322,12 @@ set_metadata_ctl_cb (GrlMetadataSource *source, GRL_CORE_ERROR_SET_METADATA_FAILED, "Some keys could not be written"); } - smctlcb->user_callback (smctlcb->source, - media, - smctlcb->failed_keys, - smctlcb->user_data, - own_error); + if (smctlcb->user_callback) + smctlcb->user_callback (smctlcb->source, + media, + smctlcb->failed_keys, + smctlcb->user_data, + own_error); if (own_error) { g_error_free (own_error); } @@ -440,16 +441,16 @@ analyze_keys_to_write (GrlMetadataSource *source, GList *sources = NULL; GList *sources_iter; - /* 'supported_keys' holds keys that can be written by this source - 'key_list' holds those that must be handled by other sources */ + /* 'key_list' holds keys that can be written by this source + 'unsupportedy_keys' holds those that must be handled by other sources */ GList *key_list = g_list_copy (keys); - GList *supported_keys = + GList *unsupported_keys = grl_metadata_source_filter_writable (source, &key_list, TRUE); - if (supported_keys) { + if (key_list) { map = g_new0 (struct SourceKeyMap, 1); map->source = g_object_ref (source); - map->keys = supported_keys; + map->keys = key_list; maps = g_list_prepend (maps, map); } @@ -458,7 +459,7 @@ analyze_keys_to_write (GrlMetadataSource *source, goto done; } - if (!key_list) { + if (!unsupported_keys) { /* All keys are writable by this source, we are done! */ goto done; } @@ -469,8 +470,7 @@ analyze_keys_to_write (GrlMetadataSource *source, grl_plugin_registry_get_sources_by_operations (registry, GRL_OP_SET_METADATA, TRUE); - - for (sources_iter = sources; key_list && sources_iter; + for (sources_iter = sources; unsupported_keys && sources_iter; sources_iter = g_list_next (sources_iter)) { GrlMetadataSource *_source; @@ -479,20 +479,21 @@ analyze_keys_to_write (GrlMetadataSource *source, continue; } - supported_keys = + key_list = unsupported_keys; + unsupported_keys = grl_metadata_source_filter_writable (_source, &key_list, TRUE); - if (!supported_keys) { + if (!key_list) { continue; } map = g_new0 (struct SourceKeyMap, 1); map->source = g_object_ref (_source); - map->keys = supported_keys; + map->keys = key_list; maps = g_list_prepend (maps, map); } done: - *failed_keys = key_list; + *failed_keys = unsupported_keys; g_list_free (sources); return maps; } @@ -510,41 +511,29 @@ static GList * filter_key_list (GrlMetadataSource *source, GList **keys_to_filter, gboolean return_filtered, - const GList *source_keys) + GList *source_keys) { - GList *iter_source_keys; - GList *iter_keys; - GList *filtered_keys = NULL; - gboolean got_match; - GrlKeyID filtered_key; - - iter_source_keys = (GList *) source_keys; - while (iter_source_keys) { - got_match = FALSE; - iter_keys = *keys_to_filter; - - filtered_key = iter_source_keys->data; - while (!got_match && iter_keys) { - if (iter_keys->data == filtered_key) { - got_match = TRUE; - } - else { - iter_keys = g_list_next (iter_keys); - } - } - - iter_source_keys = g_list_next (iter_source_keys); - - if (got_match) { + GList *iter_keys, *found; + GList *in_source = NULL; + GList *out_source = NULL; + + for (iter_keys = *keys_to_filter; + iter_keys; + iter_keys = g_list_next (iter_keys)) { + found = g_list_find (source_keys, iter_keys->data); + if (found) { + in_source = g_list_prepend (in_source, iter_keys->data); + } else { if (return_filtered) { - filtered_keys = g_list_prepend (filtered_keys, filtered_key); + out_source = g_list_prepend (out_source, iter_keys->data); } - *keys_to_filter = g_list_delete_link (*keys_to_filter, iter_keys); - got_match = FALSE; } } - return filtered_keys; + g_list_free (*keys_to_filter); + *keys_to_filter = g_list_reverse (in_source); + + return g_list_reverse (out_source); } /** @@ -996,13 +985,13 @@ grl_metadata_source_resolve_sync (GrlMetadataSource *source, * @keys: (element-type GObject.ParamSpec) (transfer container) (allow-none) (inout): * the list of keys to filter out * @return_filtered: if %TRUE the return value shall be a new list with - * the matched keys + * the unsupported keys * * Compares the received @keys list with the supported key list by the - * metadata @source, and will delete those keys which are supported. + * metadata @source, and deletes those keys which are not supported. * * Returns: (element-type GObject.ParamSpec) (transfer container): - * if @return_filtered is %TRUE will return the list of intersected keys; + * if @return_filtered is %TRUE will return the list of removed keys; * otherwise %NULL * * Since: 0.1.1 @@ -1013,30 +1002,12 @@ grl_metadata_source_filter_supported (GrlMetadataSource *source, gboolean return_filtered) { const GList *supported_keys; - GList *tmp, *filtered; g_return_val_if_fail (GRL_IS_METADATA_SOURCE (source), NULL); supported_keys = grl_metadata_source_supported_keys (source); - /* - * filter_key_list removes keys found in supported_keys from - * keys and returns the removed keys. However, we want to do - * exactly the opposite: keep the found supported_keys in keys - * and return the list of keys that are non supported. - */ - - filtered = filter_key_list (source, keys, TRUE, supported_keys); - - tmp = *keys; - *keys = filtered; - - if (return_filtered) { - return tmp; - } else { - g_list_free (tmp); - return NULL; - } + return filter_key_list (source, keys, return_filtered, (GList *) supported_keys); } /** @@ -1045,14 +1016,15 @@ grl_metadata_source_filter_supported (GrlMetadataSource *source, * @keys: (element-type GObject.ParamSpec) (transfer container) (allow-none) (inout): * the list of keys to filter out * @return_filtered: if %TRUE the return value shall be a new list with - * the matched keys + * the slow keys * - * Similar to grl_metadata_source_filter_supported() but applied to - * the slow keys in grl_metadata_source_slow_keys() + * This function does the opposite of other filter functions: removes the slow + * keys from @keys. If @return_filtered is %TRUE the removed slow keys are + * returned in a new list. * - * Returns: (element-type GObject.ParamSpec) (transfer container): - * if @return_filtered is %TRUE will return the list of intersected keys; - * otherwise %NULL + * Returns: (element-type GObject.ParamSpec) (transfer container): if + * @return_filtered is %TRUE will return the list of slow keys; otherwise + * %NULL * * Since: 0.1.1 */ @@ -1062,12 +1034,23 @@ grl_metadata_source_filter_slow (GrlMetadataSource *source, gboolean return_filtered) { const GList *slow_keys; + GList *fastest_keys, *tmp; g_return_val_if_fail (GRL_IS_METADATA_SOURCE (source), NULL); slow_keys = grl_metadata_source_slow_keys (source); - return filter_key_list (source, keys, return_filtered, slow_keys); + /* Note that we want to do the opposite */ + fastest_keys = filter_key_list (source, keys, TRUE, (GList *) slow_keys); + tmp = *keys; + *keys = fastest_keys; + + if (!return_filtered) { + g_list_free (tmp); + return NULL; + } else { + return tmp; + } } /** @@ -1076,13 +1059,17 @@ grl_metadata_source_filter_slow (GrlMetadataSource *source, * @keys: (element-type GObject.ParamSpec) (transfer container) (allow-none) (inout): * the list of keys to filter out * @return_filtered: if %TRUE the return value shall be a new list with - * the matched keys + * the non-writable keys * * Similar to grl_metadata_source_filter_supported() but applied to - * the writable keys in grl_metadata_source_writable_keys() + * the writable keys in grl_metadata_source_writable_keys(). + * + * Filter the @keys list keeping only those keys that are writtable in + * @source. If @return_filtered is %TRUE then the removed keys are returned in a + * new list. * * Returns: (element-type GObject.ParamSpec) (transfer container): - * if @return_filtered is %TRUE will return the list of intersected keys; + * if @return_filtered is %TRUE will return the list of non-writtable keys; * otherwise %NULL * * Since: 0.1.4 @@ -1093,35 +1080,17 @@ grl_metadata_source_filter_writable (GrlMetadataSource *source, gboolean return_filtered) { const GList *writable_keys; - GList *filtered; - GList *tmp; g_return_val_if_fail (GRL_IS_METADATA_SOURCE (source), NULL); g_return_val_if_fail (keys != NULL, NULL); writable_keys = grl_metadata_source_writable_keys (source); - /* - * filter_key_list removes keys found in writable_keys from - * keys and returns the removed keys. However, we want to do - * exactly the opposite: keep the found writable_keys in keys - * and return the list of keys that are non writable. - */ - - filtered = filter_key_list (source, keys, TRUE, writable_keys); - - tmp = *keys; - *keys = filtered; - - if (return_filtered) { - return tmp; - } else { - g_list_free (tmp); - return NULL; - } + return filter_key_list (source, keys, return_filtered, (GList *) writable_keys); } /** + * grl_metadata_source_expand_operation_keys: (skip) * Will add to @keys the keys that should be asked to @source when doing an * operation with GRL_RESOLVE_FULL. * The added keys are the keys that will be needed by other sources to obtain @@ -1174,6 +1143,7 @@ grl_metadata_source_expand_operation_keys (GrlMetadataSource *source, } /** + * grl_metadata_source_get_additional_sources: (skip) * Find the sources that should be queried to add @keys to @media. * If @additional_keys is provided, the result may include sources that need * more metadata to be present in @media, the keys corresponding to that @@ -1319,7 +1289,6 @@ grl_metadata_source_set_metadata (GrlMetadataSource *source, GRL_DEBUG ("grl_metadata_source_set_metadata"); g_return_if_fail (GRL_IS_METADATA_SOURCE (source)); - g_return_if_fail (callback != NULL); g_return_if_fail (media != NULL); g_return_if_fail (keys != NULL); g_return_if_fail (grl_metadata_source_supported_operations (source) & @@ -1330,7 +1299,8 @@ grl_metadata_source_set_metadata (GrlMetadataSource *source, error = g_error_new (GRL_CORE_ERROR, GRL_CORE_ERROR_SET_METADATA_FAILED, "None of the specified keys is writable"); - callback (source, media, failed_keys, user_data, error); + if (callback) + callback (source, media, failed_keys, user_data, error); g_error_free (error); g_list_free (failed_keys); return; diff --git a/src/grl-metadata-source.h b/src/grl-metadata-source.h index 2f06667..a2842ad 100644 --- a/src/grl-metadata-source.h +++ b/src/grl-metadata-source.h @@ -113,7 +113,7 @@ struct _GrlMetadataSource { * @source: a metadata source * @media: (transfer full): a #GrlMedia transfer object * @user_data: user data passed to grl_metadata_source_resolve() - * @error: (not-error) (type uint): possible #GError generated when resolving the metadata + * @error: (type uint): possible #GError generated when resolving the metadata * * Prototype for the callback passed to grl_metadata_source_resolve() */ @@ -129,7 +129,7 @@ typedef void (*GrlMetadataSourceResolveCb) (GrlMetadataSource *source, * @failed_keys: (element-type GObject.ParamSpec) (transfer container): #GList of * keys that could not be updated, if any * @user_data: user data passed to grl_metadata_source_set_metadata() - * @error: (not-error) (type uint): possible #GError generated when updating the metadata + * @error: (type uint): possible #GError generated when updating the metadata * * Prototype for the callback passed to grl_metadata_source_set_metadata() */ diff --git a/src/grl-plugin-registry.c b/src/grl-plugin-registry.c index 39b53e3..93f6786 100644 --- a/src/grl-plugin-registry.c +++ b/src/grl-plugin-registry.c @@ -895,8 +895,8 @@ grl_plugin_registry_lookup_metadata_key (GrlPluginRegistry *registry, * * @key is included in that list. * - * Returns: (element-type Grl.KeyID) (transfer-none): a #GList of related - * keys, or @NULL if key is invalid. + * Returns: (element-type GObject.ParamSpec) (transfer none): a #GList of + * related keys, or @NULL if key is invalid. * * Since: 0.1.10 **/ diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c index 186e300..526df4f 100644 --- a/tools/grilo-test-ui/main.c +++ b/tools/grilo-test-ui/main.c @@ -1445,6 +1445,19 @@ set_vimeo_config (void) } static void +set_local_config (void) +{ + GrlConfig *config; + GrlPluginRegistry *registry; + + config = grl_config_new ("grl-local-metadata", NULL); + grl_config_set_boolean (config, "guess-video", TRUE); + + registry = grl_plugin_registry_get_default (); + grl_plugin_registry_add_config (registry, config, NULL); +} + +static void launchers_setup (void) { launchers = g_new0 (UriLaunchers, 1); @@ -1937,6 +1950,7 @@ configure_plugins () set_flickr_config (); set_youtube_config (); set_vimeo_config (); + set_local_config (); } int |