|
|
From ec6ed17f9e55b73e7bf42cf9e119d6c2504e58ba Mon Sep 17 00:00:00 2001
|
|
|
From: Debarshi Ray <debarshir@gnome.org>
|
|
|
Date: Fri, 23 Apr 2021 02:54:59 +0200
|
|
|
Subject: [PATCH] Remove Facebook, Flickr and Google support
|
|
|
|
|
|
In theory, support for Facebook, Flickr and Google is still desired.
|
|
|
However, right now Facebook and Google are completely broken, and the
|
|
|
Grilo code used for Flickr support has code quality issues.
|
|
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1913641
|
|
|
---
|
|
|
meson.build | 3 -
|
|
|
src/meson.build | 7 -
|
|
|
src/photos-application.c | 24 --
|
|
|
src/photos-facebook-item.c | 339 ---------------------
|
|
|
src/photos-facebook-item.h | 36 ---
|
|
|
src/photos-flickr-item.c | 407 -------------------------
|
|
|
src/photos-flickr-item.h | 35 ---
|
|
|
src/photos-google-item.c | 349 ---------------------
|
|
|
src/photos-google-item.h | 36 ---
|
|
|
src/photos-share-point-google.c | 516 --------------------------------
|
|
|
src/photos-share-point-google.h | 35 ---
|
|
|
src/photos-utils.c | 8 -
|
|
|
12 files changed, 1795 deletions(-)
|
|
|
delete mode 100644 src/photos-facebook-item.c
|
|
|
delete mode 100644 src/photos-facebook-item.h
|
|
|
delete mode 100644 src/photos-flickr-item.c
|
|
|
delete mode 100644 src/photos-flickr-item.h
|
|
|
delete mode 100644 src/photos-google-item.c
|
|
|
delete mode 100644 src/photos-google-item.h
|
|
|
delete mode 100644 src/photos-share-point-google.c
|
|
|
delete mode 100644 src/photos-share-point-google.h
|
|
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
index ee1ca0dd3080..0d8ca768da1d 100644
|
|
|
--- a/meson.build
|
|
|
+++ b/meson.build
|
|
|
@@ -166,13 +166,10 @@ goa_dep = dependency('goa-1.0', version: '>= 3.8.0')
|
|
|
config_h.set('GOA_API_IS_SUBJECT_TO_CHANGE', true)
|
|
|
|
|
|
gobject_dep = dependency('gobject-2.0')
|
|
|
-grilo_dep = dependency('grilo-0.3', version: '>= 0.3.5')
|
|
|
gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas')
|
|
|
gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.16')
|
|
|
gtk_unix_print_dep = dependency('gtk+-unix-print-3.0')
|
|
|
libdazzle_dep = dependency('libdazzle-1.0', version: '>= 3.26.0')
|
|
|
-libgdata_dep = dependency('libgdata', version: '>= 0.17.13')
|
|
|
-libgfgraph_dep = dependency('libgfbgraph-0.2', version: '>= 0.2.1')
|
|
|
libhandy_dep = dependency ('libhandy-1', version: '>= 1.1.90')
|
|
|
libjpeg_dep = dependency('libjpeg')
|
|
|
libpng_dep = dependency('libpng16')
|
|
|
diff --git a/src/meson.build b/src/meson.build
|
|
|
index 154f7d528814..becaa9cb480f 100644
|
|
|
--- a/src/meson.build
|
|
|
+++ b/src/meson.build
|
|
|
@@ -130,15 +130,12 @@ sources = common_sources + files(
|
|
|
'photos-embed.c',
|
|
|
'photos-empty-results-box.c',
|
|
|
'photos-error-box.c',
|
|
|
- 'photos-facebook-item.c',
|
|
|
'photos-fetch-collection-state-job.c',
|
|
|
'photos-fetch-collections-job.c',
|
|
|
'photos-fetch-ids-job.c',
|
|
|
'photos-fetch-metas-job.c',
|
|
|
'photos-filterable.c',
|
|
|
- 'photos-flickr-item.c',
|
|
|
'photos-gesture-zoom.c',
|
|
|
- 'photos-google-item.c',
|
|
|
'photos-image-view.c',
|
|
|
'photos-image-view-helper.c',
|
|
|
'photos-import-dialog.c',
|
|
|
@@ -188,7 +185,6 @@ sources = common_sources + files(
|
|
|
'photos-share-notification.c',
|
|
|
'photos-share-point.c',
|
|
|
'photos-share-point-email.c',
|
|
|
- 'photos-share-point-google.c',
|
|
|
'photos-share-point-manager.c',
|
|
|
'photos-share-point-online.c',
|
|
|
'photos-single-item-job.c',
|
|
|
@@ -387,13 +383,10 @@ deps = common_deps + [
|
|
|
geocode_glib_dep,
|
|
|
gexiv_dep,
|
|
|
goa_dep,
|
|
|
- grilo_dep,
|
|
|
gsettings_desktop_schemas_dep,
|
|
|
gtk_dep,
|
|
|
gtk_unix_print_dep,
|
|
|
libgd_dep,
|
|
|
- libgdata_dep,
|
|
|
- libgfgraph_dep,
|
|
|
libhandy_dep,
|
|
|
m_dep,
|
|
|
tracker_sparql_dep,
|
|
|
diff --git a/src/photos-application.c b/src/photos-application.c
|
|
|
index 9017fd3ef621..83ec1ad65916 100644
|
|
|
--- a/src/photos-application.c
|
|
|
+++ b/src/photos-application.c
|
|
|
@@ -35,7 +35,6 @@
|
|
|
#include <gio/gio.h>
|
|
|
#include <glib.h>
|
|
|
#include <glib/gi18n.h>
|
|
|
-#include <grilo.h>
|
|
|
#include <handy.h>
|
|
|
#include <tracker-sparql.h>
|
|
|
|
|
|
@@ -2586,11 +2585,9 @@ static void
|
|
|
photos_application_startup (GApplication *application)
|
|
|
{
|
|
|
PhotosApplication *self = PHOTOS_APPLICATION (application);
|
|
|
- GrlRegistry *registry;
|
|
|
GtkIconTheme *icon_theme;
|
|
|
GtkSettings *settings;
|
|
|
GVariant *state;
|
|
|
- gboolean grl_plugins_loaded;
|
|
|
const gchar *delete_accels[3] = {"Delete", "KP_Delete", NULL};
|
|
|
const gchar *edit_accels[2] = {"<Primary>e", NULL};
|
|
|
const gchar *fullscreen_accels[2] = {"F11", NULL};
|
|
|
@@ -2613,27 +2610,6 @@ photos_application_startup (GApplication *application)
|
|
|
|
|
|
photos_gegl_init ();
|
|
|
|
|
|
- grl_init (NULL, NULL);
|
|
|
- registry = grl_registry_get_default ();
|
|
|
-
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- grl_plugins_loaded = grl_registry_load_all_plugins (registry, FALSE, &error);
|
|
|
- if (error != NULL)
|
|
|
- g_warning ("Unable to load Grilo plugins: %s", error->message);
|
|
|
- }
|
|
|
-
|
|
|
- if (grl_plugins_loaded)
|
|
|
- {
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- if (!grl_registry_activate_plugin_by_id (registry, "grl-flickr", &error))
|
|
|
- g_warning ("Unable to activate Grilo's Flickr plugin: %s", error->message);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
self->create_window_cancellable = g_cancellable_new ();
|
|
|
self->refresh_miner_ids = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
|
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
|
|
|
deleted file mode 100644
|
|
|
index 9053550a0409..000000000000
|
|
|
--- a/src/photos-facebook-item.c
|
|
|
+++ /dev/null
|
|
|
@@ -1,339 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2013 Álvaro Peña
|
|
|
- * Copyright © 2014 – 2019 Red Hat, Inc.
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-/* Based on code from:
|
|
|
- * + Documents
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-#include "config.h"
|
|
|
-
|
|
|
-#include <gfbgraph/gfbgraph.h>
|
|
|
-#include <gfbgraph/gfbgraph-goa-authorizer.h>
|
|
|
-#include <gio/gio.h>
|
|
|
-#include <glib.h>
|
|
|
-#include <glib/gi18n.h>
|
|
|
-#include <goa/goa.h>
|
|
|
-
|
|
|
-#include "photos-base-manager.h"
|
|
|
-#include "photos-debug.h"
|
|
|
-#include "photos-error.h"
|
|
|
-#include "photos-facebook-item.h"
|
|
|
-#include "photos-search-context.h"
|
|
|
-#include "photos-source.h"
|
|
|
-#include "photos-utils.h"
|
|
|
-
|
|
|
-
|
|
|
-struct _PhotosFacebookItem
|
|
|
-{
|
|
|
- PhotosBaseItem parent_instance;
|
|
|
- PhotosBaseManager *src_mngr;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-G_DEFINE_TYPE_WITH_CODE (PhotosFacebookItem, photos_facebook_item, PHOTOS_TYPE_BASE_ITEM,
|
|
|
- photos_utils_ensure_extension_points ();
|
|
|
- g_io_extension_point_implement (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME,
|
|
|
- g_define_type_id,
|
|
|
- "facebook",
|
|
|
- 0));
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_facebook_item_create_filename_fallback (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- const gchar *const facebook_prefix = "facebook:";
|
|
|
- const gchar *identifier;
|
|
|
- const gchar *mime_type;
|
|
|
- g_autofree gchar *extension = NULL;
|
|
|
- gchar *ret_val;
|
|
|
- gsize prefix_len;
|
|
|
-
|
|
|
- prefix_len = strlen (facebook_prefix);
|
|
|
- identifier = photos_base_item_get_identifier (item) + prefix_len;
|
|
|
- mime_type = photos_base_item_get_mime_type (item);
|
|
|
- extension = photos_utils_get_extension_from_mime_type (mime_type);
|
|
|
- if (extension == NULL)
|
|
|
- extension = g_strdup ("tmp");
|
|
|
-
|
|
|
- ret_val = g_strdup_printf ("%s.%s", identifier, extension);
|
|
|
-
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_facebook_item_create_name_fallback (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosFacebookItem *self = PHOTOS_FACEBOOK_ITEM (item);
|
|
|
- g_autoptr (GDateTime) date_modified = NULL;
|
|
|
- const gchar *provider_name;
|
|
|
- g_autofree gchar *date_modified_str = NULL;
|
|
|
- gchar *ret_val;
|
|
|
- gint64 mtime;
|
|
|
-
|
|
|
- provider_name = photos_utils_get_provider_name (self->src_mngr, item);
|
|
|
-
|
|
|
- mtime = photos_base_item_get_mtime (item);
|
|
|
- date_modified = g_date_time_new_from_unix_local (mtime);
|
|
|
- date_modified_str = g_date_time_format (date_modified, "%x");
|
|
|
-
|
|
|
- /* Translators: this is the fallback title in the form
|
|
|
- * "Facebook — 2nd January 2013".
|
|
|
- */
|
|
|
- ret_val = g_strdup_printf (_("%s — %s"), provider_name, date_modified_str);
|
|
|
-
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GFBGraphPhoto *
|
|
|
-photos_facebook_get_gfbgraph_photo (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- PhotosFacebookItem *self = PHOTOS_FACEBOOK_ITEM (item);
|
|
|
- GFBGraphGoaAuthorizer *authorizer = NULL; /* TODO: use g_autoptr */
|
|
|
- GFBGraphPhoto *photo = NULL;
|
|
|
- GoaObject *object;
|
|
|
- PhotosSource *source;
|
|
|
- const gchar *const facebook_prefix = "facebook:";
|
|
|
- const gchar *identifier;
|
|
|
- const gchar *resource_urn;
|
|
|
- gsize prefix_len;
|
|
|
-
|
|
|
- resource_urn = photos_base_item_get_resource_urn (item);
|
|
|
- source = PHOTOS_SOURCE (photos_base_manager_get_object_by_id (self->src_mngr, resource_urn));
|
|
|
- object = photos_source_get_goa_object (source);
|
|
|
- authorizer = gfbgraph_goa_authorizer_new (object);
|
|
|
-
|
|
|
- if (!gfbgraph_authorizer_refresh_authorization (GFBGRAPH_AUTHORIZER (authorizer), cancellable, error))
|
|
|
- goto out;
|
|
|
-
|
|
|
- prefix_len = strlen (facebook_prefix);
|
|
|
- identifier = photos_base_item_get_identifier (item) + prefix_len;
|
|
|
- photo = gfbgraph_photo_new_from_id (GFBGRAPH_AUTHORIZER (authorizer), identifier, error);
|
|
|
-
|
|
|
- out:
|
|
|
- g_clear_object (&authorizer);
|
|
|
- return photo;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gboolean
|
|
|
-photos_facebook_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- g_autoptr (GFile) local_file = NULL;
|
|
|
- g_autoptr (GFile) remote_file = NULL;
|
|
|
- GFBGraphPhoto *photo = NULL; /* TODO: use g_autoptr */
|
|
|
- const GFBGraphPhotoImage *thumbnail_image;
|
|
|
- gboolean ret_val = FALSE;
|
|
|
- const gchar *uri;
|
|
|
- g_autofree gchar *local_dir = NULL;
|
|
|
- g_autofree gchar *local_path = NULL;
|
|
|
- gint64 height;
|
|
|
- gint64 width;
|
|
|
- guint size;
|
|
|
-
|
|
|
- photo = photos_facebook_get_gfbgraph_photo (item, cancellable, error);
|
|
|
- if (photo == NULL)
|
|
|
- goto out;
|
|
|
-
|
|
|
- size = (guint) photos_utils_get_icon_size ();
|
|
|
- thumbnail_image = gfbgraph_photo_get_image_near_width (photo, size);
|
|
|
- if (thumbnail_image == NULL)
|
|
|
- {
|
|
|
- g_set_error (error, PHOTOS_ERROR, 0, "Failed to find an image for the thumbnail");
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- remote_file = g_file_new_for_uri (thumbnail_image->source);
|
|
|
-
|
|
|
- local_path = photos_base_item_create_thumbnail_path (item);
|
|
|
- local_file = g_file_new_for_path (local_path);
|
|
|
- local_dir = g_path_get_dirname (local_path);
|
|
|
- g_mkdir_with_parents (local_dir, 0700);
|
|
|
-
|
|
|
- uri = photos_base_item_get_uri (item);
|
|
|
-
|
|
|
- height = photos_base_item_get_height (item);
|
|
|
- width = photos_base_item_get_width (item);
|
|
|
-
|
|
|
- photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Facebook to %s", thumbnail_image->source, local_path);
|
|
|
- if (!photos_utils_file_copy_as_thumbnail (remote_file,
|
|
|
- local_file,
|
|
|
- uri,
|
|
|
- height,
|
|
|
- width,
|
|
|
- cancellable,
|
|
|
- error))
|
|
|
- goto out;
|
|
|
-
|
|
|
- ret_val = TRUE;
|
|
|
-
|
|
|
- out:
|
|
|
- g_clear_object (&photo);
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GFile *
|
|
|
-photos_facebook_item_download (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- GFile *ret_val = NULL;
|
|
|
- g_autoptr (GFile) local_file = NULL;
|
|
|
- g_autoptr (GFile) remote_file = NULL;
|
|
|
- GFBGraphPhoto *photo = NULL; /* TODO: use g_autoptr */
|
|
|
- const GFBGraphPhotoImage *higher_image;
|
|
|
- const gchar *cache_dir;
|
|
|
- const gchar *local_filename;
|
|
|
- g_autofree gchar *local_dir = NULL;
|
|
|
- g_autofree gchar *local_path = NULL;
|
|
|
-
|
|
|
- cache_dir = g_get_user_cache_dir ();
|
|
|
- local_dir = g_build_filename (cache_dir, PACKAGE_TARNAME, "facebook", NULL);
|
|
|
- g_mkdir_with_parents (local_dir, 0700);
|
|
|
-
|
|
|
- local_filename = photos_base_item_get_filename (item);
|
|
|
- local_path = g_build_filename (local_dir, local_filename, NULL);
|
|
|
- local_file = g_file_new_for_path (local_path);
|
|
|
- if (g_file_test (local_path, G_FILE_TEST_EXISTS))
|
|
|
- goto end;
|
|
|
-
|
|
|
- photo = photos_facebook_get_gfbgraph_photo (item, cancellable, error);
|
|
|
- if (photo == NULL)
|
|
|
- goto out;
|
|
|
-
|
|
|
- higher_image = gfbgraph_photo_get_image_hires (photo);
|
|
|
- if (higher_image == NULL)
|
|
|
- {
|
|
|
- g_set_error (error, PHOTOS_ERROR, 0, "Failed to find a high resolution image");
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- remote_file = g_file_new_for_uri (higher_image->source);
|
|
|
-
|
|
|
- photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Facebook to %s", higher_image->source, local_path);
|
|
|
- if (!g_file_copy (remote_file,
|
|
|
- local_file,
|
|
|
- G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
|
|
|
- cancellable,
|
|
|
- NULL,
|
|
|
- NULL,
|
|
|
- error))
|
|
|
- {
|
|
|
- g_file_delete (local_file, NULL, NULL);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- end:
|
|
|
- ret_val = g_object_ref (local_file);
|
|
|
-
|
|
|
- out:
|
|
|
- g_clear_object (&photo);
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GtkWidget *
|
|
|
-photos_facebook_item_get_source_widget (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosFacebookItem *self = PHOTOS_FACEBOOK_ITEM (item);
|
|
|
- GtkWidget *source_widget;
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- name = photos_utils_get_provider_name (self->src_mngr, item);
|
|
|
- source_widget = gtk_link_button_new_with_label ("https://www.facebook.com/", name);
|
|
|
- gtk_widget_set_halign (source_widget, GTK_ALIGN_START);
|
|
|
-
|
|
|
- return source_widget;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/* TODO */
|
|
|
-static void
|
|
|
-photos_facebook_item_open (PhotosBaseItem *item, GtkWindow *parent, guint32 timestamp)
|
|
|
-{
|
|
|
- const gchar *facebook_uri;
|
|
|
-
|
|
|
- facebook_uri = photos_base_item_get_uri (item);
|
|
|
-
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- gtk_show_uri_on_window (parent, facebook_uri, timestamp, &error);
|
|
|
- if (error != NULL)
|
|
|
- g_warning ("Unable to show URI %s: %s", facebook_uri, error->message);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_facebook_item_constructed (GObject *object)
|
|
|
-{
|
|
|
- PhotosFacebookItem *self = PHOTOS_FACEBOOK_ITEM (object);
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_facebook_item_parent_class)->constructed (object);
|
|
|
-
|
|
|
- name = photos_utils_get_provider_name (self->src_mngr, PHOTOS_BASE_ITEM (self));
|
|
|
- photos_base_item_set_default_app_name (PHOTOS_BASE_ITEM (self), name);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_facebook_item_dispose (GObject *object)
|
|
|
-{
|
|
|
- PhotosFacebookItem *self = PHOTOS_FACEBOOK_ITEM (object);
|
|
|
-
|
|
|
- g_clear_object (&self->src_mngr);
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_facebook_item_parent_class)->dispose (object);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_facebook_item_init (PhotosFacebookItem *self)
|
|
|
-{
|
|
|
- GApplication *app;
|
|
|
- PhotosSearchContextState *state;
|
|
|
-
|
|
|
- app = g_application_get_default ();
|
|
|
- state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
|
|
|
-
|
|
|
- self->src_mngr = g_object_ref (state->src_mngr);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_facebook_item_class_init (PhotosFacebookItemClass *class)
|
|
|
-{
|
|
|
- GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
- PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
|
|
|
-
|
|
|
- base_item_class->miner_name = "org.gnome.OnlineMiners.Facebook";
|
|
|
- base_item_class->miner_object_path = "/org/gnome/OnlineMiners/Facebook";
|
|
|
-
|
|
|
- object_class->constructed = photos_facebook_item_constructed;
|
|
|
- object_class->dispose = photos_facebook_item_dispose;
|
|
|
- base_item_class->create_filename_fallback = photos_facebook_item_create_filename_fallback;
|
|
|
- base_item_class->create_name_fallback = photos_facebook_item_create_name_fallback;
|
|
|
- base_item_class->create_thumbnail = photos_facebook_item_create_thumbnail;
|
|
|
- base_item_class->download = photos_facebook_item_download;
|
|
|
- base_item_class->get_source_widget = photos_facebook_item_get_source_widget;
|
|
|
- base_item_class->open = photos_facebook_item_open;
|
|
|
-}
|
|
|
diff --git a/src/photos-facebook-item.h b/src/photos-facebook-item.h
|
|
|
deleted file mode 100644
|
|
|
index 7d4a4924769b..000000000000
|
|
|
--- a/src/photos-facebook-item.h
|
|
|
+++ /dev/null
|
|
|
@@ -1,36 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2013 Álvaro Peña
|
|
|
- * Copyright © 2016 – 2019 Red Hat, Inc.
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-/* Based on code from:
|
|
|
- * + Documents
|
|
|
- */
|
|
|
-
|
|
|
-#ifndef PHOTOS_FACEBOOK_ITEM_H
|
|
|
-#define PHOTOS_FACEBOOK_ITEM_H
|
|
|
-
|
|
|
-#include "photos-base-item.h"
|
|
|
-
|
|
|
-G_BEGIN_DECLS
|
|
|
-
|
|
|
-#define PHOTOS_TYPE_FACEBOOK_ITEM (photos_facebook_item_get_type ())
|
|
|
-G_DECLARE_FINAL_TYPE (PhotosFacebookItem, photos_facebook_item, PHOTOS, FACEBOOK_ITEM, PhotosBaseItem);
|
|
|
-
|
|
|
-G_END_DECLS
|
|
|
-
|
|
|
-#endif /* PHOTOS_FACEBOOK_ITEM_H */
|
|
|
diff --git a/src/photos-flickr-item.c b/src/photos-flickr-item.c
|
|
|
deleted file mode 100644
|
|
|
index b9f81d7c04c5..000000000000
|
|
|
--- a/src/photos-flickr-item.c
|
|
|
+++ /dev/null
|
|
|
@@ -1,407 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2013 – 2019 Red Hat, Inc.
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-/* Based on code from:
|
|
|
- * + Documents
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-#include "config.h"
|
|
|
-
|
|
|
-#include <string.h>
|
|
|
-
|
|
|
-#include <gio/gio.h>
|
|
|
-#include <glib.h>
|
|
|
-#include <glib/gi18n.h>
|
|
|
-#include <goa/goa.h>
|
|
|
-#include <grilo.h>
|
|
|
-
|
|
|
-#include "photos-base-manager.h"
|
|
|
-#include "photos-debug.h"
|
|
|
-#include "photos-error.h"
|
|
|
-#include "photos-flickr-item.h"
|
|
|
-#include "photos-search-context.h"
|
|
|
-#include "photos-source.h"
|
|
|
-#include "photos-utils.h"
|
|
|
-
|
|
|
-
|
|
|
-struct _PhotosFlickrItem
|
|
|
-{
|
|
|
- PhotosBaseItem parent_instance;
|
|
|
- PhotosBaseManager *src_mngr;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-G_DEFINE_TYPE_WITH_CODE (PhotosFlickrItem, photos_flickr_item, PHOTOS_TYPE_BASE_ITEM,
|
|
|
- photos_utils_ensure_extension_points ();
|
|
|
- g_io_extension_point_implement (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME,
|
|
|
- g_define_type_id,
|
|
|
- "flickr",
|
|
|
- 0));
|
|
|
-
|
|
|
-
|
|
|
-typedef struct _PhotosFlickrItemSyncData PhotosFlickrItemSyncData;
|
|
|
-
|
|
|
-struct _PhotosFlickrItemSyncData
|
|
|
-{
|
|
|
- GError **error;
|
|
|
- GMainLoop *loop;
|
|
|
- gboolean op_res;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_flickr_item_create_filename_fallback (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- g_autoptr (GFile) file = NULL;
|
|
|
- const gchar *uri;
|
|
|
- gchar *ret_val;
|
|
|
-
|
|
|
- uri = photos_base_item_get_uri (item);
|
|
|
- file = g_file_new_for_uri (uri);
|
|
|
- ret_val = g_file_get_basename (file);
|
|
|
-
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_flickr_item_create_name_fallback (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosFlickrItem *self = PHOTOS_FLICKR_ITEM (item);
|
|
|
- g_autoptr (GDateTime) date_modified = NULL;
|
|
|
- const gchar *provider_name;
|
|
|
- g_autofree gchar *date_modified_str = NULL;
|
|
|
- gchar *ret_val;
|
|
|
- gint64 mtime;
|
|
|
-
|
|
|
- provider_name = photos_utils_get_provider_name (self->src_mngr, item);
|
|
|
-
|
|
|
- mtime = photos_base_item_get_mtime (item);
|
|
|
- date_modified = g_date_time_new_from_unix_local (mtime);
|
|
|
- date_modified_str = g_date_time_format (date_modified, "%x");
|
|
|
-
|
|
|
- /* Translators: this is the fallback title in the form
|
|
|
- * "Facebook — 2nd January 2013".
|
|
|
- */
|
|
|
- ret_val = g_strdup_printf (_("%s — %s"), provider_name, date_modified_str);
|
|
|
-
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GrlOperationOptions *
|
|
|
-photos_flickr_item_get_grl_options (GrlSource *source)
|
|
|
-{
|
|
|
- GrlCaps *caps;
|
|
|
- GrlOperationOptions *options;
|
|
|
-
|
|
|
- caps = grl_source_get_caps (source, GRL_OP_RESOLVE);
|
|
|
- options = grl_operation_options_new (caps);
|
|
|
- return options;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_flickr_item_source_resolve (GrlSource *source,
|
|
|
- guint operation_id,
|
|
|
- GrlMedia *media,
|
|
|
- gpointer user_data,
|
|
|
- const GError *error)
|
|
|
-{
|
|
|
- PhotosFlickrItemSyncData *data = (PhotosFlickrItemSyncData *) user_data;
|
|
|
-
|
|
|
- if (error != NULL)
|
|
|
- {
|
|
|
- if (data->error != NULL)
|
|
|
- *(data->error) = g_error_copy (error);
|
|
|
- data->op_res = FALSE;
|
|
|
- }
|
|
|
- else
|
|
|
- data->op_res = TRUE;
|
|
|
-
|
|
|
- g_main_loop_quit (data->loop);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gboolean
|
|
|
-photos_flickr_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- PhotosFlickrItemSyncData data;
|
|
|
- g_autoptr (GFile) local_file = NULL;
|
|
|
- g_autoptr (GFile) remote_file = NULL;
|
|
|
- g_autoptr (GList) keys = NULL;
|
|
|
- g_autoptr (GMainContext) context = NULL;
|
|
|
- g_autoptr (GrlMedia) media = NULL;
|
|
|
- g_autoptr (GrlOperationOptions) options = NULL;
|
|
|
- GrlRegistry *registry;
|
|
|
- GrlSource *source;
|
|
|
- gboolean ret_val = FALSE;
|
|
|
- const gchar *const flickr_prefix = "flickr:";
|
|
|
- const gchar *const resource_prefix = "gd:goa-account:";
|
|
|
- const gchar *flickr_id;
|
|
|
- const gchar *goa_id;
|
|
|
- const gchar *identifier;
|
|
|
- const gchar *resource_urn;
|
|
|
- const gchar *thumbnail_uri;
|
|
|
- const gchar *uri;
|
|
|
- g_autofree gchar *grilo_id = NULL;
|
|
|
- g_autofree gchar *local_dir = NULL;
|
|
|
- g_autofree gchar *local_path = NULL;
|
|
|
- gint64 height;
|
|
|
- gint64 width;
|
|
|
- gsize prefix_len;
|
|
|
-
|
|
|
- data.error = error;
|
|
|
- data.loop = NULL;
|
|
|
-
|
|
|
- prefix_len = strlen (flickr_prefix);
|
|
|
- identifier = photos_base_item_get_identifier (item);
|
|
|
- if (strlen (identifier) <= prefix_len || !g_str_has_prefix (identifier, flickr_prefix))
|
|
|
- {
|
|
|
- g_set_error (error,
|
|
|
- PHOTOS_ERROR,
|
|
|
- 0,
|
|
|
- "Invalid nao:identifier for Flickr item %s",
|
|
|
- identifier);
|
|
|
- goto out;
|
|
|
- }
|
|
|
- flickr_id = identifier + prefix_len;
|
|
|
-
|
|
|
- prefix_len = strlen (resource_prefix);
|
|
|
- resource_urn = photos_base_item_get_resource_urn (item);
|
|
|
- if (strlen (resource_urn) <= prefix_len || !g_str_has_prefix (resource_urn, resource_prefix))
|
|
|
- {
|
|
|
- g_set_error (error,
|
|
|
- PHOTOS_ERROR,
|
|
|
- 0,
|
|
|
- "Invalid nie:dataSource for Flickr item %s",
|
|
|
- resource_urn);
|
|
|
- goto out;
|
|
|
- }
|
|
|
- goa_id = resource_urn + prefix_len;
|
|
|
-
|
|
|
- grilo_id = g_strdup_printf ("grl-flickr-%s", goa_id);
|
|
|
- registry = grl_registry_get_default ();
|
|
|
- source = grl_registry_lookup_source (registry, grilo_id);
|
|
|
- if (source == NULL)
|
|
|
- {
|
|
|
- g_set_error (error,
|
|
|
- PHOTOS_ERROR,
|
|
|
- 0,
|
|
|
- "Failed to find a GrlSource for %s",
|
|
|
- grilo_id);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- media = grl_media_new ();
|
|
|
- grl_media_set_id (media, flickr_id);
|
|
|
-
|
|
|
- keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, GRL_METADATA_KEY_INVALID);
|
|
|
- options = photos_flickr_item_get_grl_options (source);
|
|
|
-
|
|
|
- context = g_main_context_new ();
|
|
|
- g_main_context_push_thread_default (context);
|
|
|
- data.loop = g_main_loop_new (context, FALSE);
|
|
|
-
|
|
|
- grl_source_resolve (source, media, keys, options, photos_flickr_item_source_resolve, &data);
|
|
|
- g_main_loop_run (data.loop);
|
|
|
- g_main_context_pop_thread_default (context);
|
|
|
-
|
|
|
- if (!data.op_res)
|
|
|
- goto out;
|
|
|
-
|
|
|
- thumbnail_uri = grl_media_get_thumbnail (media);
|
|
|
- remote_file = g_file_new_for_uri (thumbnail_uri);
|
|
|
-
|
|
|
- local_path = photos_base_item_create_thumbnail_path (item);
|
|
|
- local_file = g_file_new_for_path (local_path);
|
|
|
- local_dir = g_path_get_dirname (local_path);
|
|
|
- g_mkdir_with_parents (local_dir, 0700);
|
|
|
-
|
|
|
- uri = photos_base_item_get_uri (item);
|
|
|
-
|
|
|
- height = photos_base_item_get_height (item);
|
|
|
- width = photos_base_item_get_width (item);
|
|
|
-
|
|
|
- photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Flickr to %s", thumbnail_uri, local_path);
|
|
|
- if (!photos_utils_file_copy_as_thumbnail (remote_file,
|
|
|
- local_file,
|
|
|
- uri,
|
|
|
- height,
|
|
|
- width,
|
|
|
- cancellable,
|
|
|
- error))
|
|
|
- goto out;
|
|
|
-
|
|
|
- ret_val = TRUE;
|
|
|
-
|
|
|
- out:
|
|
|
- if (data.loop != NULL)
|
|
|
- g_main_loop_unref (data.loop);
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GFile *
|
|
|
-photos_flickr_item_download (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- GFile *ret_val = NULL;
|
|
|
- g_autoptr (GFile) local_file = NULL;
|
|
|
- g_autoptr (GFile) remote_file = NULL;
|
|
|
- const gchar *cache_dir;
|
|
|
- const gchar *local_filename;
|
|
|
- const gchar *uri;
|
|
|
- g_autofree gchar *local_dir = NULL;
|
|
|
- g_autofree gchar *local_path = NULL;
|
|
|
-
|
|
|
- uri = photos_base_item_get_uri (item);
|
|
|
- remote_file = g_file_new_for_uri (uri);
|
|
|
- cache_dir = g_get_user_cache_dir ();
|
|
|
-
|
|
|
- local_dir = g_build_filename (cache_dir, PACKAGE_TARNAME, "flickr", NULL);
|
|
|
- g_mkdir_with_parents (local_dir, 0700);
|
|
|
-
|
|
|
- local_filename = photos_base_item_get_filename (item);
|
|
|
- local_path = g_build_filename (local_dir, local_filename, NULL);
|
|
|
- local_file = g_file_new_for_path (local_path);
|
|
|
-
|
|
|
- if (!g_file_test (local_path, G_FILE_TEST_EXISTS))
|
|
|
- {
|
|
|
- photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Flickr to %s", uri, local_path);
|
|
|
- if (!g_file_copy (remote_file,
|
|
|
- local_file,
|
|
|
- G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
|
|
|
- cancellable,
|
|
|
- NULL,
|
|
|
- NULL,
|
|
|
- error))
|
|
|
- {
|
|
|
- g_file_delete (local_file, NULL, NULL);
|
|
|
- goto out;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ret_val = g_object_ref (local_file);
|
|
|
-
|
|
|
- out:
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GtkWidget *
|
|
|
-photos_flickr_item_get_source_widget (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosFlickrItem *self = PHOTOS_FLICKR_ITEM (item);
|
|
|
- GtkWidget *source_widget;
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- name = photos_utils_get_provider_name (self->src_mngr, item);
|
|
|
- source_widget = gtk_link_button_new_with_label ("https://www.flickr.com/", name);
|
|
|
- gtk_widget_set_halign (source_widget, GTK_ALIGN_START);
|
|
|
-
|
|
|
- return source_widget;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_flickr_item_open (PhotosBaseItem *item, GtkWindow *parent, guint32 timestamp)
|
|
|
-{
|
|
|
- PhotosFlickrItem *self = PHOTOS_FLICKR_ITEM (item);
|
|
|
- GoaAccount *account;
|
|
|
- GoaObject *object;
|
|
|
- PhotosSource *source;
|
|
|
- const gchar *identifier;
|
|
|
- const gchar *identity;
|
|
|
- const gchar *resource_urn;
|
|
|
- g_autofree gchar *flickr_uri = NULL;
|
|
|
-
|
|
|
- identifier = photos_base_item_get_identifier (item) + strlen ("flickr:");
|
|
|
-
|
|
|
- resource_urn = photos_base_item_get_resource_urn (item);
|
|
|
- source = PHOTOS_SOURCE (photos_base_manager_get_object_by_id (self->src_mngr, resource_urn));
|
|
|
- object = photos_source_get_goa_object (source);
|
|
|
- account = goa_object_peek_account (object);
|
|
|
- identity = goa_account_get_identity (account);
|
|
|
-
|
|
|
- flickr_uri = g_strdup_printf ("https://www.flickr.com/photos/%s/%s", identity, identifier);
|
|
|
-
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- if (!gtk_show_uri_on_window (parent, flickr_uri, timestamp, &error))
|
|
|
- g_warning ("Unable to show URI %s: %s", flickr_uri, error->message);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_flickr_item_constructed (GObject *object)
|
|
|
-{
|
|
|
- PhotosFlickrItem *self = PHOTOS_FLICKR_ITEM (object);
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_flickr_item_parent_class)->constructed (object);
|
|
|
-
|
|
|
- name = photos_utils_get_provider_name (self->src_mngr, PHOTOS_BASE_ITEM (self));
|
|
|
- photos_base_item_set_default_app_name (PHOTOS_BASE_ITEM (self), name);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_flickr_item_dispose (GObject *object)
|
|
|
-{
|
|
|
- PhotosFlickrItem *self = PHOTOS_FLICKR_ITEM (object);
|
|
|
-
|
|
|
- g_clear_object (&self->src_mngr);
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_flickr_item_parent_class)->dispose (object);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_flickr_item_init (PhotosFlickrItem *self)
|
|
|
-{
|
|
|
- GApplication *app;
|
|
|
- PhotosSearchContextState *state;
|
|
|
-
|
|
|
- app = g_application_get_default ();
|
|
|
- state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
|
|
|
-
|
|
|
- self->src_mngr = g_object_ref (state->src_mngr);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_flickr_item_class_init (PhotosFlickrItemClass *class)
|
|
|
-{
|
|
|
- GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
- PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
|
|
|
-
|
|
|
- base_item_class->miner_name = "org.gnome.OnlineMiners.Flickr";
|
|
|
- base_item_class->miner_object_path = "/org/gnome/OnlineMiners/Flickr";
|
|
|
-
|
|
|
- object_class->constructed = photos_flickr_item_constructed;
|
|
|
- object_class->dispose = photos_flickr_item_dispose;
|
|
|
- base_item_class->create_filename_fallback = photos_flickr_item_create_filename_fallback;
|
|
|
- base_item_class->create_name_fallback = photos_flickr_item_create_name_fallback;
|
|
|
- base_item_class->create_thumbnail = photos_flickr_item_create_thumbnail;
|
|
|
- base_item_class->download = photos_flickr_item_download;
|
|
|
- base_item_class->get_source_widget = photos_flickr_item_get_source_widget;
|
|
|
- base_item_class->open = photos_flickr_item_open;
|
|
|
-}
|
|
|
diff --git a/src/photos-flickr-item.h b/src/photos-flickr-item.h
|
|
|
deleted file mode 100644
|
|
|
index cd130844bce2..000000000000
|
|
|
--- a/src/photos-flickr-item.h
|
|
|
+++ /dev/null
|
|
|
@@ -1,35 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2012 – 2019 Red Hat, Inc.
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-/* Based on code from:
|
|
|
- * + Documents
|
|
|
- */
|
|
|
-
|
|
|
-#ifndef PHOTOS_FLICKR_ITEM_H
|
|
|
-#define PHOTOS_FLICKR_ITEM_H
|
|
|
-
|
|
|
-#include "photos-base-item.h"
|
|
|
-
|
|
|
-G_BEGIN_DECLS
|
|
|
-
|
|
|
-#define PHOTOS_TYPE_FLICKR_ITEM (photos_flickr_item_get_type ())
|
|
|
-G_DECLARE_FINAL_TYPE (PhotosFlickrItem, photos_flickr_item, PHOTOS, FLICKR_ITEM, PhotosBaseItem);
|
|
|
-
|
|
|
-G_END_DECLS
|
|
|
-
|
|
|
-#endif /* PHOTOS_LOCAL_ITEM_H */
|
|
|
diff --git a/src/photos-google-item.c b/src/photos-google-item.c
|
|
|
deleted file mode 100644
|
|
|
index 5737f958b7a5..000000000000
|
|
|
--- a/src/photos-google-item.c
|
|
|
+++ /dev/null
|
|
|
@@ -1,349 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2014 – 2019 Red Hat, Inc.
|
|
|
- * Copyright © 2014 Saurav Agarwalla
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-/* Based on code from:
|
|
|
- * + Documents
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-#include "config.h"
|
|
|
-
|
|
|
-#include <gdata/gdata.h>
|
|
|
-#include <gio/gio.h>
|
|
|
-#include <glib.h>
|
|
|
-#include <glib/gi18n.h>
|
|
|
-
|
|
|
-#include "photos-base-manager.h"
|
|
|
-#include "photos-debug.h"
|
|
|
-#include "photos-error.h"
|
|
|
-#include "photos-google-item.h"
|
|
|
-#include "photos-search-context.h"
|
|
|
-#include "photos-source.h"
|
|
|
-#include "photos-utils.h"
|
|
|
-
|
|
|
-
|
|
|
-struct _PhotosGoogleItem
|
|
|
-{
|
|
|
- PhotosBaseItem parent_instance;
|
|
|
- PhotosBaseManager *src_mngr;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-G_DEFINE_TYPE_WITH_CODE (PhotosGoogleItem, photos_google_item, PHOTOS_TYPE_BASE_ITEM,
|
|
|
- photos_utils_ensure_extension_points ();
|
|
|
- g_io_extension_point_implement (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME,
|
|
|
- g_define_type_id,
|
|
|
- "google",
|
|
|
- 0));
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_google_item_create_filename_fallback (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- const gchar *identifier;
|
|
|
- const gchar *mime_type;
|
|
|
- gchar *ret_val;
|
|
|
- g_autofree gchar *extension = NULL;
|
|
|
- g_autofree gchar *identifier_hash = NULL;
|
|
|
-
|
|
|
- identifier = photos_base_item_get_identifier (item);
|
|
|
- identifier_hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1, identifier, -1);
|
|
|
-
|
|
|
- mime_type = photos_base_item_get_mime_type (item);
|
|
|
- extension = photos_utils_get_extension_from_mime_type (mime_type);
|
|
|
- if (extension == NULL)
|
|
|
- extension = g_strdup ("tmp");
|
|
|
-
|
|
|
- ret_val = g_strdup_printf ("%s.%s", identifier_hash, extension);
|
|
|
-
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_google_item_create_name_fallback (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosGoogleItem *self = PHOTOS_GOOGLE_ITEM (item);
|
|
|
- g_autoptr (GDateTime) date_modified = NULL;
|
|
|
- const gchar *provider_name;
|
|
|
- gchar *ret_val;
|
|
|
- g_autofree gchar *date_modified_str = NULL;
|
|
|
- gint64 mtime;
|
|
|
-
|
|
|
- provider_name = photos_utils_get_provider_name (self->src_mngr, item);
|
|
|
-
|
|
|
- mtime = photos_base_item_get_mtime (item);
|
|
|
- date_modified = g_date_time_new_from_unix_local (mtime);
|
|
|
- date_modified_str = g_date_time_format (date_modified, "%x");
|
|
|
-
|
|
|
- /* Translators: this is the fallback title in the form
|
|
|
- * "Facebook — 2nd January 2013".
|
|
|
- */
|
|
|
- ret_val = g_strdup_printf (_("%s — %s"), provider_name, date_modified_str);
|
|
|
-
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GDataEntry *
|
|
|
-photos_google_get_picasaweb_file (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- PhotosGoogleItem *self = PHOTOS_GOOGLE_ITEM (item);
|
|
|
- PhotosSource *source;
|
|
|
- GDataAuthorizationDomain *authorization_domain;
|
|
|
- GDataEntry *entry;
|
|
|
- g_autoptr (GDataGoaAuthorizer) authorizer = NULL;
|
|
|
- g_autoptr (GDataPicasaWebQuery) query = NULL;
|
|
|
- g_autoptr (GDataPicasaWebService) service = NULL;
|
|
|
- const gchar *identifier;
|
|
|
- const gchar *resource_urn;
|
|
|
-
|
|
|
- resource_urn = photos_base_item_get_resource_urn (item);
|
|
|
- source = PHOTOS_SOURCE (photos_base_manager_get_object_by_id (self->src_mngr, resource_urn));
|
|
|
- authorizer = gdata_goa_authorizer_new (photos_source_get_goa_object (source));
|
|
|
- identifier = photos_base_item_get_identifier (item) + strlen ("google:picasaweb:");
|
|
|
- service = gdata_picasaweb_service_new (GDATA_AUTHORIZER (authorizer));
|
|
|
- authorization_domain = gdata_picasaweb_service_get_primary_authorization_domain ();
|
|
|
-
|
|
|
- query = gdata_picasaweb_query_new (NULL);
|
|
|
- gdata_picasaweb_query_set_image_size (query, "d");
|
|
|
-
|
|
|
- entry = gdata_service_query_single_entry (GDATA_SERVICE (service),
|
|
|
- authorization_domain,
|
|
|
- identifier,
|
|
|
- GDATA_QUERY (query),
|
|
|
- GDATA_TYPE_PICASAWEB_FILE,
|
|
|
- cancellable,
|
|
|
- error);
|
|
|
-
|
|
|
- return entry;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gboolean
|
|
|
-photos_google_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- g_autoptr (GFile) local_file = NULL;
|
|
|
- g_autoptr (GFile) remote_file = NULL;
|
|
|
- GList *l;
|
|
|
- GList *thumbnails;
|
|
|
- g_autoptr (GDataEntry) entry = NULL;
|
|
|
- GDataMediaThumbnail *thumbnail = NULL;
|
|
|
- gboolean ret_val = FALSE;
|
|
|
- const gchar *thumbnail_uri;
|
|
|
- const gchar *uri;
|
|
|
- g_autofree gchar *local_dir = NULL;
|
|
|
- g_autofree gchar *local_path = NULL;
|
|
|
- gint64 height;
|
|
|
- gint64 width;
|
|
|
- guint max_width = 0;
|
|
|
- guint current_width;
|
|
|
-
|
|
|
- entry = photos_google_get_picasaweb_file (item, cancellable, error);
|
|
|
- if (entry == NULL)
|
|
|
- goto out;
|
|
|
-
|
|
|
- thumbnails = gdata_picasaweb_file_get_thumbnails (GDATA_PICASAWEB_FILE (entry));
|
|
|
- if (thumbnails == NULL)
|
|
|
- {
|
|
|
- g_set_error (error, PHOTOS_ERROR, 0, "Failed to find an image for the thumbnail");
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- for (l = thumbnails; l != NULL; l = l->next)
|
|
|
- {
|
|
|
- current_width = gdata_media_thumbnail_get_width (GDATA_MEDIA_THUMBNAIL (l->data));
|
|
|
- if (current_width > max_width)
|
|
|
- {
|
|
|
- max_width = current_width;
|
|
|
- thumbnail = GDATA_MEDIA_THUMBNAIL (l->data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- thumbnail_uri = gdata_media_thumbnail_get_uri (thumbnail);
|
|
|
- remote_file = g_file_new_for_uri (thumbnail_uri);
|
|
|
-
|
|
|
- local_path = photos_base_item_create_thumbnail_path (item);
|
|
|
- local_file = g_file_new_for_path (local_path);
|
|
|
- local_dir = g_path_get_dirname (local_path);
|
|
|
- g_mkdir_with_parents (local_dir, 0700);
|
|
|
-
|
|
|
- uri = photos_base_item_get_uri (item);
|
|
|
-
|
|
|
- height = photos_base_item_get_height (item);
|
|
|
- width = photos_base_item_get_width (item);
|
|
|
-
|
|
|
- photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Google to %s", thumbnail_uri, local_path);
|
|
|
- if (!photos_utils_file_copy_as_thumbnail (remote_file,
|
|
|
- local_file,
|
|
|
- uri,
|
|
|
- height,
|
|
|
- width,
|
|
|
- cancellable,
|
|
|
- error))
|
|
|
- goto out;
|
|
|
-
|
|
|
- ret_val = TRUE;
|
|
|
-
|
|
|
- out:
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GFile *
|
|
|
-photos_google_item_download (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
|
|
|
-{
|
|
|
- GFile *ret_val = NULL;
|
|
|
- g_autoptr (GFile) local_file = NULL;
|
|
|
- g_autoptr (GFile) remote_file = NULL;
|
|
|
- g_autoptr (GDataEntry) entry = NULL;
|
|
|
- const gchar *cache_dir;
|
|
|
- const gchar *local_filename;
|
|
|
- const gchar *uri;
|
|
|
- g_autofree gchar *local_dir = NULL;
|
|
|
- g_autofree gchar *local_path = NULL;
|
|
|
-
|
|
|
- cache_dir = g_get_user_cache_dir ();
|
|
|
- local_dir = g_build_filename (cache_dir, PACKAGE_TARNAME, "google", NULL);
|
|
|
- g_mkdir_with_parents (local_dir, 0700);
|
|
|
-
|
|
|
- local_filename = photos_base_item_get_filename (item);
|
|
|
- local_path = g_build_filename (local_dir, local_filename, NULL);
|
|
|
- local_file = g_file_new_for_path (local_path);
|
|
|
- if (g_file_test (local_path, G_FILE_TEST_EXISTS))
|
|
|
- goto end;
|
|
|
-
|
|
|
- entry = photos_google_get_picasaweb_file (item, cancellable, error);
|
|
|
- if (entry == NULL)
|
|
|
- goto out;
|
|
|
-
|
|
|
- uri = gdata_entry_get_content_uri (entry);
|
|
|
- remote_file = g_file_new_for_uri (uri);
|
|
|
-
|
|
|
- photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Google to %s", uri, local_path);
|
|
|
- if (!g_file_copy (remote_file,
|
|
|
- local_file,
|
|
|
- G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
|
|
|
- cancellable,
|
|
|
- NULL,
|
|
|
- NULL,
|
|
|
- error))
|
|
|
- {
|
|
|
- g_file_delete (local_file, NULL, NULL);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- end:
|
|
|
- ret_val = g_object_ref (local_file);
|
|
|
-
|
|
|
- out:
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GtkWidget *
|
|
|
-photos_google_item_get_source_widget (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosGoogleItem *self = PHOTOS_GOOGLE_ITEM (item);
|
|
|
- GtkWidget *source_widget;
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- name = photos_utils_get_provider_name (self->src_mngr, item);
|
|
|
- source_widget = gtk_link_button_new_with_label ("https://photos.google.com/", name);
|
|
|
- gtk_widget_set_halign (source_widget, GTK_ALIGN_START);
|
|
|
-
|
|
|
- return source_widget;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/* NOTE: For private photos, opening the URI in a browser results in a
|
|
|
- * 'Sorry, that page was not found.' if the user is not logged in with the respective account
|
|
|
- */
|
|
|
-static void
|
|
|
-photos_google_item_open (PhotosBaseItem *item, GtkWindow *parent, guint32 timestamp)
|
|
|
-{
|
|
|
- const gchar *google_uri;
|
|
|
-
|
|
|
- google_uri = photos_base_item_get_uri (item);
|
|
|
-
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- gtk_show_uri_on_window (parent, google_uri, timestamp, &error);
|
|
|
- if (error != NULL)
|
|
|
- g_warning ("Unable to show URI %s: %s", google_uri, error->message);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_google_item_constructed (GObject *object)
|
|
|
-{
|
|
|
- PhotosGoogleItem *self = PHOTOS_GOOGLE_ITEM (object);
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_google_item_parent_class)->constructed (object);
|
|
|
-
|
|
|
- name = photos_utils_get_provider_name (self->src_mngr, PHOTOS_BASE_ITEM (self));
|
|
|
- photos_base_item_set_default_app_name (PHOTOS_BASE_ITEM (self), name);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_google_item_dispose (GObject *object)
|
|
|
-{
|
|
|
- PhotosGoogleItem *self = PHOTOS_GOOGLE_ITEM (object);
|
|
|
-
|
|
|
- g_clear_object (&self->src_mngr);
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_google_item_parent_class)->dispose (object);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_google_item_init (PhotosGoogleItem *self)
|
|
|
-{
|
|
|
- GApplication *app;
|
|
|
- PhotosSearchContextState *state;
|
|
|
-
|
|
|
- app = g_application_get_default ();
|
|
|
- state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
|
|
|
-
|
|
|
- self->src_mngr = g_object_ref (state->src_mngr);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_google_item_class_init (PhotosGoogleItemClass *class)
|
|
|
-{
|
|
|
- GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
- PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
|
|
|
-
|
|
|
- base_item_class->miner_name = "org.gnome.OnlineMiners.GData";
|
|
|
- base_item_class->miner_object_path = "/org/gnome/OnlineMiners/GData";
|
|
|
-
|
|
|
- object_class->constructed = photos_google_item_constructed;
|
|
|
- object_class->dispose = photos_google_item_dispose;
|
|
|
- base_item_class->create_filename_fallback = photos_google_item_create_filename_fallback;
|
|
|
- base_item_class->create_name_fallback = photos_google_item_create_name_fallback;
|
|
|
- base_item_class->create_thumbnail = photos_google_item_create_thumbnail;
|
|
|
- base_item_class->download = photos_google_item_download;
|
|
|
- base_item_class->get_source_widget = photos_google_item_get_source_widget;
|
|
|
- base_item_class->open = photos_google_item_open;
|
|
|
-}
|
|
|
diff --git a/src/photos-google-item.h b/src/photos-google-item.h
|
|
|
deleted file mode 100644
|
|
|
index 644098e3c095..000000000000
|
|
|
--- a/src/photos-google-item.h
|
|
|
+++ /dev/null
|
|
|
@@ -1,36 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2016 – 2019 Red Hat, Inc.
|
|
|
- * Copyright © 2014 Saurav Agarwalla
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-/* Based on code from:
|
|
|
- * + Documents
|
|
|
- */
|
|
|
-
|
|
|
-#ifndef PHOTOS_GOOGLE_ITEM_H
|
|
|
-#define PHOTOS_GOOGLE_ITEM_H
|
|
|
-
|
|
|
-#include "photos-base-item.h"
|
|
|
-
|
|
|
-G_BEGIN_DECLS
|
|
|
-
|
|
|
-#define PHOTOS_TYPE_GOOGLE_ITEM (photos_google_item_get_type ())
|
|
|
-G_DECLARE_FINAL_TYPE (PhotosGoogleItem, photos_google_item, PHOTOS, GOOGLE_ITEM, PhotosBaseItem);
|
|
|
-
|
|
|
-G_END_DECLS
|
|
|
-
|
|
|
-#endif /* PHOTOS_GOOGLE_ITEM_H */
|
|
|
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
|
|
|
deleted file mode 100644
|
|
|
index 6cc6d55d882e..000000000000
|
|
|
--- a/src/photos-share-point-google.c
|
|
|
+++ /dev/null
|
|
|
@@ -1,516 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2016 – 2020 Red Hat, Inc.
|
|
|
- * Copyright © 2016 Umang Jain
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-#include "config.h"
|
|
|
-
|
|
|
-#include <gio/gio.h>
|
|
|
-#include <gdata/gdata.h>
|
|
|
-#include <glib/gi18n.h>
|
|
|
-
|
|
|
-#include "photos-application.h"
|
|
|
-#include "photos-base-item.h"
|
|
|
-#include "photos-error.h"
|
|
|
-#include "photos-filterable.h"
|
|
|
-#include "photos-item-manager.h"
|
|
|
-#include "photos-search-context.h"
|
|
|
-#include "photos-share-point-google.h"
|
|
|
-#include "photos-source.h"
|
|
|
-#include "photos-utils.h"
|
|
|
-
|
|
|
-
|
|
|
-struct _PhotosSharePointGoogle
|
|
|
-{
|
|
|
- PhotosSharePointOnline parent_instance;
|
|
|
- GDataGoaAuthorizer *authorizer;
|
|
|
- GDataPicasaWebService *service;
|
|
|
- PhotosBaseManager *item_mngr;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-G_DEFINE_TYPE_WITH_CODE (PhotosSharePointGoogle, photos_share_point_google, PHOTOS_TYPE_SHARE_POINT_ONLINE,
|
|
|
- photos_utils_ensure_extension_points ();
|
|
|
- g_io_extension_point_implement (PHOTOS_SHARE_POINT_ONLINE_EXTENSION_POINT_NAME,
|
|
|
- g_define_type_id,
|
|
|
- "google",
|
|
|
- 0));
|
|
|
-
|
|
|
-
|
|
|
-typedef struct _PhotosSharePointGoogleShareData PhotosSharePointGoogleShareData;
|
|
|
-
|
|
|
-struct _PhotosSharePointGoogleShareData
|
|
|
-{
|
|
|
- GDataPicasaWebFile *file_entry;
|
|
|
- GDataUploadStream *stream;
|
|
|
- PhotosBaseItem *item;
|
|
|
- gchar *item_id_after_changes;
|
|
|
- guint pending_async_calls;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-static PhotosSharePointGoogleShareData *
|
|
|
-photos_share_point_google_share_data_new (PhotosBaseItem *item)
|
|
|
-{
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
-
|
|
|
- data = g_slice_new0 (PhotosSharePointGoogleShareData);
|
|
|
- data->item = g_object_ref (item);
|
|
|
-
|
|
|
- return data;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_data_free (PhotosSharePointGoogleShareData *data)
|
|
|
-{
|
|
|
- g_clear_object (&data->file_entry);
|
|
|
- g_clear_object (&data->stream);
|
|
|
- g_clear_object (&data->item);
|
|
|
- g_free (data->item_id_after_changes);
|
|
|
- g_slice_free (PhotosSharePointGoogleShareData, data);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gboolean
|
|
|
-photos_share_point_google_needs_notification (PhotosSharePoint *share_point)
|
|
|
-{
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gchar *
|
|
|
-photos_share_point_google_parse_error (PhotosSharePoint *self, GError *error)
|
|
|
-{
|
|
|
- gchar *msg;
|
|
|
-
|
|
|
- if (g_error_matches (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED))
|
|
|
- msg = g_strdup (_("Failed to upload photo: Service not authorized"));
|
|
|
- else
|
|
|
- msg = g_strdup (_("Failed to upload photo"));
|
|
|
-
|
|
|
- return msg;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_insert_shared_content (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
|
|
-{
|
|
|
- GError *error;
|
|
|
- g_autoptr (GTask) task = G_TASK (user_data);
|
|
|
- GomMiner *miner = GOM_MINER (source_object);
|
|
|
-
|
|
|
- error = NULL;
|
|
|
- if (!gom_miner_call_insert_shared_content_finish (miner, res, &error))
|
|
|
- {
|
|
|
- g_task_return_error (task, error);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- g_task_return_boolean (task, TRUE);
|
|
|
-
|
|
|
- out:
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_metadata_add_shared_second (PhotosSharePointGoogle *self, GTask *task)
|
|
|
-{
|
|
|
- GApplication *app;
|
|
|
- GCancellable *cancellable;
|
|
|
- GoaAccount *account;
|
|
|
- GoaObject *object;
|
|
|
- GomMiner *miner;
|
|
|
- PhotosSource *source;
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
- const gchar *account_id;
|
|
|
- const gchar *file_entry_id;
|
|
|
-
|
|
|
- cancellable = g_task_get_cancellable (task);
|
|
|
- data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
|
|
|
-
|
|
|
- app = g_application_get_default ();
|
|
|
- miner = photos_application_get_miner (PHOTOS_APPLICATION (app), "google");
|
|
|
- if (miner == NULL)
|
|
|
- {
|
|
|
- g_task_return_new_error (task, PHOTOS_ERROR, 0, "Unable to find the google miner");
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- source = photos_share_point_online_get_source (PHOTOS_SHARE_POINT_ONLINE (self));
|
|
|
- object = photos_source_get_goa_object (source);
|
|
|
- account = goa_object_peek_account (object);
|
|
|
- account_id = goa_account_get_id (account);
|
|
|
-
|
|
|
- file_entry_id = gdata_entry_get_id (GDATA_ENTRY (data->file_entry));
|
|
|
-
|
|
|
- gom_miner_call_insert_shared_content (miner,
|
|
|
- account_id,
|
|
|
- file_entry_id,
|
|
|
- "photos",
|
|
|
- data->item_id_after_changes,
|
|
|
- cancellable,
|
|
|
- photos_share_point_google_share_insert_shared_content,
|
|
|
- g_object_ref (task));
|
|
|
-
|
|
|
- out:
|
|
|
- g_object_unref (task);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self;
|
|
|
- g_autoptr (GTask) task = G_TASK (user_data);
|
|
|
- PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
-
|
|
|
- self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
|
|
|
- data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
|
|
|
-
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- if (!photos_base_item_metadata_add_shared_finish (item, res, &error))
|
|
|
- {
|
|
|
- if (g_task_get_completed (task))
|
|
|
- g_warning ("Unable to add shared metadata: %s", error->message);
|
|
|
- else
|
|
|
- g_task_return_error (task, g_steal_pointer (&error));
|
|
|
-
|
|
|
- goto out;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- data->pending_async_calls--;
|
|
|
- if (data->pending_async_calls == 0)
|
|
|
- photos_share_point_google_share_metadata_add_shared_second (self, g_object_ref (task));
|
|
|
-
|
|
|
- out:
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_wait_for_changes (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self;
|
|
|
- g_autoptr (GTask) task = G_TASK (user_data);
|
|
|
- PhotosItemManager *item_mngr = PHOTOS_ITEM_MANAGER (source_object);
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
- g_autofree gchar *item_id_after_changes = NULL;
|
|
|
-
|
|
|
- self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
|
|
|
- data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
|
|
|
-
|
|
|
- {
|
|
|
- g_autoptr (GError) error = NULL;
|
|
|
-
|
|
|
- item_id_after_changes = photos_item_manager_wait_for_changes_finish (item_mngr, res, &error);
|
|
|
- if (error != NULL)
|
|
|
- {
|
|
|
- if (g_task_get_completed (task))
|
|
|
- g_warning ("Unable to detect changes: %s", error->message);
|
|
|
- else
|
|
|
- g_task_return_error (task, g_steal_pointer (&error));
|
|
|
-
|
|
|
- goto out;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- g_assert_null (data->item_id_after_changes);
|
|
|
- data->item_id_after_changes = g_steal_pointer (&item_id_after_changes);
|
|
|
-
|
|
|
- data->pending_async_calls--;
|
|
|
- if (data->pending_async_calls == 0)
|
|
|
- photos_share_point_google_share_metadata_add_shared_second (self, g_object_ref (task));
|
|
|
-
|
|
|
- out:
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self;
|
|
|
- GCancellable *cancellable;
|
|
|
- GError *error;
|
|
|
- g_autoptr (GTask) task = G_TASK (user_data);
|
|
|
- g_autoptr (GDataPicasaWebFile) file_entry = NULL;
|
|
|
- GoaAccount *account;
|
|
|
- GoaObject *object;
|
|
|
- PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
|
|
|
- PhotosSource *source;
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
- const gchar *account_identity;
|
|
|
- const gchar *file_entry_id;
|
|
|
- const gchar *provider_type;
|
|
|
- g_autofree gchar *shared_identifier = NULL;
|
|
|
-
|
|
|
- self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
|
|
|
- cancellable = g_task_get_cancellable (task);
|
|
|
- data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
|
|
|
-
|
|
|
- error = NULL;
|
|
|
- if (!photos_base_item_save_to_stream_finish (item, res, &error))
|
|
|
- {
|
|
|
- g_task_return_error (task, error);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- error = NULL;
|
|
|
- file_entry = gdata_picasaweb_service_finish_file_upload (GDATA_PICASAWEB_SERVICE (self->service),
|
|
|
- data->stream,
|
|
|
- &error);
|
|
|
- if (error != NULL)
|
|
|
- {
|
|
|
- g_task_return_error (task, error);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- g_assert_null (data->file_entry);
|
|
|
- data->file_entry = g_object_ref (file_entry);
|
|
|
-
|
|
|
- g_assert_true (PHOTOS_IS_ITEM_MANAGER (self->item_mngr));
|
|
|
-
|
|
|
- /* Tracker might detect the atomic update done by GExiv2 as a 'delete'
|
|
|
- * followed by 'create'. If that happens the URN will change. We
|
|
|
- * have to deal with that by waiting for TrackerChangeMonitor to
|
|
|
- * emit changes-pending for the BaseItem that we are interested in,
|
|
|
- * and using the new URN, if any.
|
|
|
- *
|
|
|
- * See https://bugzilla.gnome.org/show_bug.cgi?id=771042
|
|
|
- */
|
|
|
- photos_item_manager_wait_for_changes_async (PHOTOS_ITEM_MANAGER (self->item_mngr),
|
|
|
- data->item,
|
|
|
- cancellable,
|
|
|
- photos_share_point_google_share_wait_for_changes,
|
|
|
- g_object_ref (task));
|
|
|
- data->pending_async_calls++;
|
|
|
-
|
|
|
- source = photos_share_point_online_get_source (PHOTOS_SHARE_POINT_ONLINE (self));
|
|
|
- object = photos_source_get_goa_object (source);
|
|
|
- account = goa_object_peek_account (object);
|
|
|
- account_identity = goa_account_get_identity (account);
|
|
|
- provider_type = goa_account_get_provider_type (account);
|
|
|
-
|
|
|
- file_entry_id = gdata_entry_get_id (GDATA_ENTRY (file_entry));
|
|
|
- shared_identifier = g_strconcat ("google:picasaweb:", file_entry_id, NULL);
|
|
|
-
|
|
|
- photos_base_item_metadata_add_shared_async (data->item,
|
|
|
- provider_type,
|
|
|
- account_identity,
|
|
|
- shared_identifier,
|
|
|
- cancellable,
|
|
|
- photos_share_point_google_share_metadata_add_shared,
|
|
|
- g_object_ref (task));
|
|
|
- data->pending_async_calls++;
|
|
|
-
|
|
|
- out:
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_refresh_authorization (GObject *source_object,
|
|
|
- GAsyncResult *res,
|
|
|
- gpointer user_data)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self;
|
|
|
- GCancellable *cancellable;
|
|
|
- GError *error;
|
|
|
- g_autoptr (GTask) task = G_TASK (user_data);
|
|
|
- GDataAuthorizer *authorizer = GDATA_AUTHORIZER (source_object);
|
|
|
- g_autoptr (GDataPicasaWebFile) file_entry = NULL;
|
|
|
- g_autoptr (GDataUploadStream) stream = NULL;
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
- const gchar *filename;
|
|
|
- const gchar *mime_type;
|
|
|
- const gchar *name;
|
|
|
-
|
|
|
- self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
|
|
|
- cancellable = g_task_get_cancellable (task);
|
|
|
- data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
|
|
|
-
|
|
|
- error = NULL;
|
|
|
- if (!gdata_authorizer_refresh_authorization_finish (authorizer, res, &error))
|
|
|
- {
|
|
|
- g_task_return_error (task, error);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- file_entry = gdata_picasaweb_file_new (NULL);
|
|
|
- name = photos_base_item_get_name_with_fallback (data->item);
|
|
|
- gdata_entry_set_title (GDATA_ENTRY (file_entry), name);
|
|
|
-
|
|
|
- filename = photos_base_item_get_filename (data->item);
|
|
|
- mime_type = photos_base_item_get_mime_type (data->item);
|
|
|
-
|
|
|
- error = NULL;
|
|
|
- stream = gdata_picasaweb_service_upload_file (self->service,
|
|
|
- NULL,
|
|
|
- file_entry,
|
|
|
- filename,
|
|
|
- mime_type,
|
|
|
- cancellable,
|
|
|
- &error);
|
|
|
- if (error != NULL)
|
|
|
- {
|
|
|
- g_task_return_error (task, error);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- g_assert_null (data->stream);
|
|
|
- data->stream = g_object_ref (stream);
|
|
|
-
|
|
|
- photos_base_item_save_to_stream_async (data->item,
|
|
|
- G_OUTPUT_STREAM (stream),
|
|
|
- 1.0,
|
|
|
- cancellable,
|
|
|
- photos_share_point_google_share_save_to_stream,
|
|
|
- g_object_ref (task));
|
|
|
-
|
|
|
- out:
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_share_async (PhotosSharePoint *share_point,
|
|
|
- PhotosBaseItem *item,
|
|
|
- GCancellable *cancellable,
|
|
|
- GAsyncReadyCallback callback,
|
|
|
- gpointer user_data)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self = PHOTOS_SHARE_POINT_GOOGLE (share_point);
|
|
|
- g_autoptr (GTask) task = NULL;
|
|
|
- PhotosSharePointGoogleShareData *data;
|
|
|
-
|
|
|
- data = photos_share_point_google_share_data_new (item);
|
|
|
-
|
|
|
- task = g_task_new (self, cancellable, callback, user_data);
|
|
|
- g_task_set_source_tag (task, photos_share_point_google_share_async);
|
|
|
- g_task_set_task_data (task, data, (GDestroyNotify) photos_share_point_google_share_data_free);
|
|
|
-
|
|
|
- gdata_authorizer_refresh_authorization_async (GDATA_AUTHORIZER (self->authorizer),
|
|
|
- cancellable,
|
|
|
- photos_share_point_google_share_refresh_authorization,
|
|
|
- g_object_ref (task));
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static gboolean
|
|
|
-photos_share_point_google_share_finish (PhotosSharePoint *share_point,
|
|
|
- GAsyncResult *res,
|
|
|
- gchar **out_uri,
|
|
|
- GError **error)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self = PHOTOS_SHARE_POINT_GOOGLE (share_point);
|
|
|
- GTask *task;
|
|
|
- gboolean ret_val = FALSE;
|
|
|
-
|
|
|
- g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
|
|
- task = G_TASK (res);
|
|
|
-
|
|
|
- g_return_val_if_fail (g_task_get_source_tag (task) == photos_share_point_google_share_async, FALSE);
|
|
|
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
-
|
|
|
- if (!g_task_propagate_boolean (task, error))
|
|
|
- goto out;
|
|
|
-
|
|
|
- ret_val = TRUE;
|
|
|
-
|
|
|
- if (out_uri != NULL)
|
|
|
- *out_uri = g_strdup ("https://photos.google.com/");
|
|
|
-
|
|
|
- out:
|
|
|
- return ret_val;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_constructed (GObject *object)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self = PHOTOS_SHARE_POINT_GOOGLE (object);
|
|
|
- PhotosSource *source;
|
|
|
- GoaObject *goa_object;
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_share_point_google_parent_class)->constructed (object);
|
|
|
-
|
|
|
- source = photos_share_point_online_get_source (PHOTOS_SHARE_POINT_ONLINE (self));
|
|
|
- goa_object = photos_source_get_goa_object (source);
|
|
|
- self->authorizer = gdata_goa_authorizer_new (goa_object);
|
|
|
- self->service = gdata_picasaweb_service_new (GDATA_AUTHORIZER (self->authorizer));
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_dispose (GObject *object)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self = PHOTOS_SHARE_POINT_GOOGLE (object);
|
|
|
-
|
|
|
- g_clear_object (&self->authorizer);
|
|
|
- g_clear_object (&self->service);
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_share_point_google_parent_class)->dispose (object);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_finalize (GObject *object)
|
|
|
-{
|
|
|
- PhotosSharePointGoogle *self = PHOTOS_SHARE_POINT_GOOGLE (object);
|
|
|
-
|
|
|
- if (self->item_mngr != NULL)
|
|
|
- g_object_remove_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
|
|
|
-
|
|
|
- G_OBJECT_CLASS (photos_share_point_google_parent_class)->finalize (object);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_init (PhotosSharePointGoogle *self)
|
|
|
-{
|
|
|
- GApplication *app;
|
|
|
- PhotosSearchContextState *state;
|
|
|
-
|
|
|
- app = g_application_get_default ();
|
|
|
- state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
|
|
|
-
|
|
|
- self->item_mngr = state->item_mngr;
|
|
|
- g_object_add_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void
|
|
|
-photos_share_point_google_class_init (PhotosSharePointGoogleClass *class)
|
|
|
-{
|
|
|
- GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
- PhotosSharePointClass *share_point_class = PHOTOS_SHARE_POINT_CLASS (class);
|
|
|
-
|
|
|
- object_class->constructed = photos_share_point_google_constructed;
|
|
|
- object_class->dispose = photos_share_point_google_dispose;
|
|
|
- object_class->finalize = photos_share_point_google_finalize;
|
|
|
- share_point_class->needs_notification = photos_share_point_google_needs_notification;
|
|
|
- share_point_class->parse_error = photos_share_point_google_parse_error;
|
|
|
- share_point_class->share_async = photos_share_point_google_share_async;
|
|
|
- share_point_class->share_finish = photos_share_point_google_share_finish;
|
|
|
-}
|
|
|
diff --git a/src/photos-share-point-google.h b/src/photos-share-point-google.h
|
|
|
deleted file mode 100644
|
|
|
index f229f7ed05a6..000000000000
|
|
|
--- a/src/photos-share-point-google.h
|
|
|
+++ /dev/null
|
|
|
@@ -1,35 +0,0 @@
|
|
|
-/*
|
|
|
- * Photos - access, organize and share your photos on GNOME
|
|
|
- * Copyright © 2016 Umang Jain
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program 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 General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-#ifndef PHOTOS_SHARE_POINT_GOOGLE_H
|
|
|
-#define PHOTOS_SHARE_POINT_GOOGLE_H
|
|
|
-
|
|
|
-#include "photos-share-point-online.h"
|
|
|
-
|
|
|
-G_BEGIN_DECLS
|
|
|
-
|
|
|
-#define PHOTOS_TYPE_SHARE_POINT_GOOGLE (photos_share_point_google_get_type ())
|
|
|
-G_DECLARE_FINAL_TYPE (PhotosSharePointGoogle,
|
|
|
- photos_share_point_google,
|
|
|
- PHOTOS,
|
|
|
- SHARE_POINT_GOOGLE,
|
|
|
- PhotosSharePointOnline);
|
|
|
-
|
|
|
-G_END_DECLS
|
|
|
-
|
|
|
-#endif /* PHOTOS_SHARE_POINT_GOOGLE_H */
|
|
|
diff --git a/src/photos-utils.c b/src/photos-utils.c
|
|
|
index 5cfddaa5f845..b9e3f4131985 100644
|
|
|
--- a/src/photos-utils.c
|
|
|
+++ b/src/photos-utils.c
|
|
|
@@ -37,10 +37,7 @@
|
|
|
#include "photos-device-item.h"
|
|
|
#include "photos-enums.h"
|
|
|
#include "photos-error.h"
|
|
|
-#include "photos-facebook-item.h"
|
|
|
-#include "photos-flickr-item.h"
|
|
|
#include "photos-gegl.h"
|
|
|
-#include "photos-google-item.h"
|
|
|
#include "photos-local-item.h"
|
|
|
#include "photos-media-server-item.h"
|
|
|
#include "photos-offset-collection-view-controller.h"
|
|
|
@@ -52,7 +49,6 @@
|
|
|
#include "photos-query.h"
|
|
|
#include "photos-share-point.h"
|
|
|
#include "photos-share-point-email.h"
|
|
|
-#include "photos-share-point-google.h"
|
|
|
#include "photos-share-point-online.h"
|
|
|
#include "photos-source.h"
|
|
|
#include "photos-thumbnail-factory.h"
|
|
|
@@ -719,14 +715,10 @@ photos_utils_ensure_builtins (void)
|
|
|
if (g_once_init_enter (&once_init_value))
|
|
|
{
|
|
|
g_type_ensure (PHOTOS_TYPE_DEVICE_ITEM);
|
|
|
- g_type_ensure (PHOTOS_TYPE_FACEBOOK_ITEM);
|
|
|
- g_type_ensure (PHOTOS_TYPE_FLICKR_ITEM);
|
|
|
- g_type_ensure (PHOTOS_TYPE_GOOGLE_ITEM);
|
|
|
g_type_ensure (PHOTOS_TYPE_LOCAL_ITEM);
|
|
|
g_type_ensure (PHOTOS_TYPE_MEDIA_SERVER_ITEM);
|
|
|
|
|
|
g_type_ensure (PHOTOS_TYPE_SHARE_POINT_EMAIL);
|
|
|
- g_type_ensure (PHOTOS_TYPE_SHARE_POINT_GOOGLE);
|
|
|
|
|
|
g_type_ensure (PHOTOS_TYPE_TOOL_COLORS);
|
|
|
g_type_ensure (PHOTOS_TYPE_TOOL_CROP);
|
|
|
--
|
|
|
2.30.2
|
|
|
|