Re: [PATCH 14/15] examples: ported to new APIs using caps and options



Just the indentation. Again, if it is related to tabs / white spaces...
I'm not sure if we should remove all the tabs.

On 02/12/11 19:36, gemont igalia com wrote:
> From: Guillaume Emont <guijemont igalia com>
> 
> ---
>  examples/browsing.c                      |   15 ++++++++++++---
>  examples/efficient-metadata-resolution.c |   25 ++++++++++++++++++++++---
>  examples/multivalues.c                   |   14 ++++++++++++--
>  examples/searching.c                     |   10 ++++++++--
>  4 files changed, 54 insertions(+), 10 deletions(-)
> 
> diff --git a/examples/browsing.c b/examples/browsing.c
> index bd88bd2..674ccb4 100644
> --- a/examples/browsing.c
> +++ b/examples/browsing.c
> @@ -78,24 +78,33 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>       source we find */
>    if (first &&
>        grl_metadata_source_supported_operations (source) & GRL_OP_BROWSE) {
> +    GrlOperationOptions *options;
> +    GrlCaps *caps;
>      first = FALSE;
>      g_debug ("Browsing source: %s", grl_metadata_source_get_name (source));
>      /* Here is how you can browse a source, you have to provide:
>         1) The source you want to browse contents from.
>         2) The container object you want to browse (NULL for the root container)
>         3) A list of metadata keys we are interested in.
> -       4) Flags to control certain aspects of the browse operation.
> +       4) Options to control certain aspects of the browse operation.
>         5) A callback that the framework will invoke for each available result
>         6) User data for the callback
>         It returns an operation identifier that you can use to match results
>         with the corresponding request (we ignore it here) */
> +
> +    caps = grl_metadata_source_get_caps (source, GRL_OP_BROWSE);
> +    options = grl_operation_options_new (caps);
> +    grl_operation_options_set_count (options, 5);
> +    grl_operation_options_set_flags (options, GRL_RESOLVE_IDLE_RELAY);
> +
>      grl_media_source_browse (GRL_MEDIA_SOURCE (source),
>  			     NULL,
>  			     keys,
> -			     0, 5,
> -			     GRL_RESOLVE_IDLE_RELAY,
> +           options,
>  			     browse_cb,
>  			     NULL);
> +    g_object_unref (caps);
> +    g_object_unref (options);
>    }
>  
>    g_list_free (keys);
> diff --git a/examples/efficient-metadata-resolution.c b/examples/efficient-metadata-resolution.c
> index 3dd578e..35757f5 100644
> --- a/examples/efficient-metadata-resolution.c
> +++ b/examples/efficient-metadata-resolution.c
> @@ -55,13 +55,22 @@ search_cb (GrlMediaSource *source,
>      exit (0);
>    } else {
>      g_debug ("URL no available, trying with slow keys now");
> +    GrlOperationOptions *options;
> +    GrlCaps *caps;
>      GList *keys = grl_metadata_key_list_new (GRL_METADATA_KEY_URL, NULL);
> +
> +    caps = grl_metadata_source_get_caps (GRL_METADATA_SOURCE (source),
> +                                         GRL_OP_METADATA);
> +    options = grl_operation_options_new (caps);
> +    grl_operation_options_set_flags (options, GRL_RESOLVE_IDLE_RELAY);
>      grl_media_source_metadata (source,
>  			       media,
>  			       keys,
> -			       GRL_RESOLVE_IDLE_RELAY,
> +			       options,
>  			       metadata_cb,
>  			       NULL);
> +    g_object_unref (caps);
> +    g_object_unref (options);
>      g_list_free (keys);
>    }
>  }
> @@ -71,6 +80,8 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>  {
>    GrlMetadataSource *source = GRL_METADATA_SOURCE (user_data);
>    const gchar *source_id = grl_metadata_source_get_id (source);
> +  GrlCaps *caps;
> +  GrlOperationOptions *options;
>  
>    /* We are looking for one source in particular */
>    if (strcmp (source_id, target_source_id))
> @@ -84,15 +95,23 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>    if (!(grl_metadata_source_supported_operations (source) & GRL_OP_SEARCH))
>      g_error ("Source %s is not searchable!", source_id);
>  
> +  caps = grl_metadata_source_get_caps (source, GRL_OP_SEARCH);
> +  options = grl_operation_options_new (caps);
> +  grl_operation_options_set_count (options, 5);
> +  grl_operation_options_set_flags (options,
> +                                   GRL_RESOLVE_IDLE_RELAY
> +                                   | GRL_RESOLVE_FAST_ONLY);
> +
>    /* Retrieve the first media from the source matching the text "rock" */
>    g_debug ("Searching \"rock\" in \"%s\"", source_id);
>    grl_media_source_search (GRL_MEDIA_SOURCE (source),
>  			   "rock",
>  			   keys,
> -			   0, 1,
> -			   GRL_RESOLVE_IDLE_RELAY | GRL_RESOLVE_FAST_ONLY,
> +         options,

indentation

>  			   search_cb,
>  			   NULL);
> +  g_object_unref (caps);
> +  g_object_unref (options);
>    g_list_free (keys);
>  }
>  
> diff --git a/examples/multivalues.c b/examples/multivalues.c
> index ed5e17c..ecbf816 100644
> --- a/examples/multivalues.c
> +++ b/examples/multivalues.c
> @@ -52,6 +52,8 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>  {
>    const gchar *id;
>    GrlMetadataSource *source = GRL_METADATA_SOURCE (user_data);
> +  GrlCaps *caps;
> +  GrlOperationOptions *options;
>    GList * keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE,
>  					    GRL_METADATA_KEY_URL,
>                                              GRL_METADATA_KEY_MIME,
> @@ -69,15 +71,23 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>    if (strcmp (id, "grl-youtube"))
>      return;
>  
> +  caps = grl_metadata_source_get_caps (source, GRL_OP_SEARCH);
> +  options = grl_operation_options_new (caps);
> +  grl_operation_options_set_skip (options, 0);
> +  grl_operation_options_set_count (options, 5);
> +  grl_operation_options_set_flags (options, GRL_RESOLVE_IDLE_RELAY);
> +
>    g_debug ("Searching \"rock\" in Youtube");
>    grl_media_source_search (GRL_MEDIA_SOURCE (source),
>  			   "rock",
>  			   keys,
> -			   0, 5,
> -			   GRL_RESOLVE_IDLE_RELAY,
> +                           options,

indentation

>  			   search_cb,
>  			   NULL);
>  
> +  g_object_unref (options);
> +  g_object_unref (caps);
> +
>    g_list_free (keys);
>  }
>  
> diff --git a/examples/searching.c b/examples/searching.c
> index c9804ee..45aaa5d 100644
> --- a/examples/searching.c
> +++ b/examples/searching.c
> @@ -49,6 +49,8 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>  {
>    const gchar *id;
>    GrlMetadataSource *source = GRL_METADATA_SOURCE (user_data);
> +  GrlCaps *caps;
> +  GrlOperationOptions *options;
>    GList * keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE,
>  					    GRL_METADATA_KEY_DURATION,
>  					    GRL_METADATA_KEY_CHILDCOUNT,
> @@ -66,12 +68,16 @@ source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
>    if (strcmp (id, "grl-jamendo"))
>      return;
>  
> +  caps = grl_metadata_source_get_caps (source, GRL_OP_SEARCH);
> +  options = grl_operation_options_new (caps);
> +  grl_operation_options_set_count (options, 5);
> +  grl_operation_options_set_flags (options, GRL_RESOLVE_IDLE_RELAY);
> +
>    g_debug ("Searching \"rock\" in Jamendo");
>    grl_media_source_search (GRL_MEDIA_SOURCE (source),
>  			   "rock",
>  			   keys,
> -			   0, 5,
> -			   GRL_RESOLVE_IDLE_RELAY,
> +         options,

Indentation here is wrong

>  			   search_cb,
>  			   NULL);
>  


-- 
Simon Pena <spena igalia com>
Igalia - Free Software Engineering

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]