[gnome-photos/wip/facebook] facebook: retrieve the higher resolution image for the detailed view.
- From: Álvaro Peña <alvaropg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/facebook] facebook: retrieve the higher resolution image for the detailed view.
- Date: Mon, 26 Aug 2013 17:38:57 +0000 (UTC)
commit f976ddafa88fcbb4aac166871580f3cc0a2839d1
Author: Álvaro Peña <alvaropg gmail com>
Date: Mon Aug 26 19:38:13 2013 +0200
facebook: retrieve the higher resolution image for the detailed view.
src/photos-facebook-item.c | 78 +++++++++++++++++++++++++++-----------------
1 files changed, 48 insertions(+), 30 deletions(-)
---
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
index cf25524..509fd27 100644
--- a/src/photos-facebook-item.c
+++ b/src/photos-facebook-item.c
@@ -125,42 +125,60 @@ photos_facebook_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cance
return ret_val;
}
-
static gchar *
photos_facebook_item_download (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
{
- const gchar *uri, *identifier;
+ GFBGraphPhoto *photo;
+ GFBGraphPhotoImage *higher_image;
+ const gchar *identifier;
gchar *local_dir, *filename, *local_filename;
GFile *local_file, *remote_file;
- uri = photos_base_item_get_uri (item);
- remote_file = g_file_new_for_uri (uri);
-
- /* Local path */
- local_dir = g_build_filename (g_get_user_cache_dir (), PACKAGE_TARNAME, "facebook", NULL);
- g_mkdir_with_parents (local_dir, 0700);
-
- /* Local filename */
- identifier = photos_base_item_get_identifier (item) + strlen("facebook:photos:");
- filename = g_strdup_printf ("%s.jpeg", identifier);
- local_filename = g_build_filename (local_dir, filename, NULL);
-
- local_file = g_file_new_for_path (local_filename);
-
- g_debug ("Downloading %s from Facebook to %s", uri, local_filename);
- if (!g_file_copy (remote_file,
- local_file,
- G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
- cancellable,
- NULL,
- NULL,
- error))
- g_warning ("Failed downloading %s from Facebook to %s\n", uri, local_filename);
-
- g_free (filename);
- g_free (local_dir);
- g_clear_object (&local_file);
- g_clear_object (&remote_file);
+ photo = photos_facebook_get_gfbgraph_photo (item, cancellable, error);
+ if (photo == NULL)
+ {
+ g_error ("Can't get the photo from the Facebook Graph\n");
+ }
+ else
+ {
+ higher_image = gfbgraph_photo_get_image_hires (photo);
+ if (higher_image == NULL)
+ {
+ g_error ("Cant' get the higher photo size from Facebook.\n");
+ }
+ else
+ {
+ remote_file = g_file_new_for_uri (higher_image->source);
+
+ /* Local path */
+ local_dir = g_build_filename (g_get_user_cache_dir (), PACKAGE_TARNAME, "facebook", NULL);
+ g_mkdir_with_parents (local_dir, 0700);
+
+ /* Local filename */
+ identifier = photos_base_item_get_identifier (item) + strlen("facebook:photos:");
+ filename = g_strdup_printf ("%s.jpeg", identifier);
+ local_filename = g_build_filename (local_dir, filename, NULL);
+
+ local_file = g_file_new_for_path (local_filename);
+
+ g_debug ("Downloading %s from Facebook to %s", higher_image->source, local_filename);
+ if (!g_file_copy (remote_file,
+ local_file,
+ G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
+ cancellable,
+ NULL,
+ NULL,
+ error))
+ g_warning ("Failed downloading %s from Facebook to %s\n", higher_image->source, local_filename);
+
+ g_free (filename);
+ g_free (local_dir);
+ g_clear_object (&local_file);
+ g_clear_object (&remote_file);
+ }
+
+ g_clear_object (&photo);
+ }
return local_filename;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]