summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIago Toral Quiroga <itoral@igalia.com>2010-03-12 09:03:18 +0100
committerIago Toral Quiroga <itoral@igalia.com>2010-03-12 09:03:18 +0100
commit91c93e1d68d5f518103d04e979ff3008f35b3e22 (patch)
treeee76e6132bd8ede595711abd49cecd3fd29ea7b2
parentb01908ba3741696f4460c36fe4ca2dc84622869f (diff)
downloadgrilo-91c93e1d68d5f518103d04e979ff3008f35b3e22.tar.gz
[core] Added a flags parameter to the set_metadata() API to allow
the user to select whether he wants to restrict the operation to the particular source he is using, or spread the operation among all available plugins if necessary.
-rw-r--r--src/grl-metadata-source.c12
-rw-r--r--src/grl-metadata-source.h13
2 files changed, 23 insertions, 2 deletions
diff --git a/src/grl-metadata-source.c b/src/grl-metadata-source.c
index 1c42473..b120609 100644
--- a/src/grl-metadata-source.c
+++ b/src/grl-metadata-source.c
@@ -393,6 +393,7 @@ set_metadata_idle (gpointer user_data)
static GList *
analyze_keys_to_write (GrlMetadataSource *source,
GList *keys,
+ guint flags,
GList **failed_keys)
{
GList *maps = NULL;
@@ -413,9 +414,14 @@ analyze_keys_to_write (GrlMetadataSource *source,
maps = g_list_prepend (maps, map);
}
+ if (!(flags & GRL_WRITE_FULL)) {
+ /* We are only interested in using this source, we are done! */
+ goto done;
+ }
+
if (!key_list) {
/* All keys are writable by this source, we are done! */
- return maps;
+ goto done;
}
/* Check if other sources can write the missing keys */
@@ -445,6 +451,7 @@ analyze_keys_to_write (GrlMetadataSource *source,
maps = g_list_prepend (maps, map);
}
+ done:
*failed_keys = key_list;
return maps;
}
@@ -985,6 +992,7 @@ void
grl_metadata_source_set_metadata (GrlMetadataSource *source,
GrlMedia *media,
GList *keys,
+ guint flags,
GrlMetadataSourceSetMetadataCb callback,
gpointer user_data)
{
@@ -1002,7 +1010,7 @@ grl_metadata_source_set_metadata (GrlMetadataSource *source,
g_return_if_fail (grl_metadata_source_supported_operations (source) &
GRL_OP_SET_METADATA);
- keymaps = analyze_keys_to_write (source, keys, &failed_keys);
+ keymaps = analyze_keys_to_write (source, keys, flags, &failed_keys);
if (!keymaps) {
error = g_error_new (GRL_ERROR,
GRL_ERROR_SET_METADATA_FAILED,
diff --git a/src/grl-metadata-source.h b/src/grl-metadata-source.h
index 1d62d4d..6c99721 100644
--- a/src/grl-metadata-source.h
+++ b/src/grl-metadata-source.h
@@ -74,6 +74,17 @@ typedef enum {
GRL_RESOLVE_FAST_ONLY = (1 << 2), /* Only resolve fast metadata keys */
} GrlMetadataResolutionFlags;
+/**
+ * GrlMetadataWritingFlags:
+ * @GRL_WRITE_NORMAL: Normal mode.
+ * @GRL_WRITE_FULL: Try other plugins if necessary.
+ *
+ * Flags for metadata writing operations.
+ */
+typedef enum {
+ GRL_WRITE_NORMAL = 0, /* Normal mode */
+ GRL_WRITE_FULL = (1 << 0), /* Try other plugins if necessary */
+} GrlMetadataWritingFlags;
/* GrlMetadataSource object */
@@ -160,6 +171,7 @@ typedef struct {
GrlMetadataSource *source;
GrlMedia *media;
GList *keys;
+ guint flags;
GrlMetadataSourceSetMetadataCb callback;
gpointer user_data;
GList *failed_keys;
@@ -270,6 +282,7 @@ void grl_metadata_source_resolve (GrlMetadataSource *source,
void grl_metadata_source_set_metadata (GrlMetadataSource *source,
GrlMedia *media,
GList *keys,
+ guint flags,
GrlMetadataSourceSetMetadataCb callback,
gpointer user_data);