From c6f66fc47d2d434c34dd84d446f081389015785b Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 11 Aug 2022 16:17:52 +0200 Subject: [PATCH] Drop flickr plugin: It pulls soup2 grilo dmap plugin pulls libsoup2 which is incompatible with gnome-online-accounts. So let us drop the whole grilo dependency by losing the flickr feature. See https://bugzilla.redhat.com/show_bug.cgi?id=2117520 --- flatpak/org.gnome.Photos.json | 59 ----- meson.build | 1 - src/meson.build | 2 - src/photos-application.c | 24 -- src/photos-flickr-item.c | 407 ---------------------------------- src/photos-flickr-item.h | 35 --- src/photos-utils.c | 2 - 7 files changed, 530 deletions(-) delete mode 100644 src/photos-flickr-item.c delete mode 100644 src/photos-flickr-item.h diff --git a/flatpak/org.gnome.Photos.json b/flatpak/org.gnome.Photos.json index ebbddf6e..3eceebe0 100644 --- a/flatpak/org.gnome.Photos.json +++ b/flatpak/org.gnome.Photos.json @@ -204,65 +204,6 @@ } ] }, - { - "name": "grilo", - "buildsystem": "meson", - "cleanup": [ - "/bin" - ], - "config-opts": [ - "-Denable-introspection=false", - "-Denable-grl-net=true", - "-Denable-grl-pls=false", - "-Denable-gtk-doc=false", - "-Denable-test-ui=false", - "-Denable-vala=false" - ], - "sources": [ - { - "type": "git", - "url": "https://gitlab.gnome.org/GNOME/grilo.git" - } - ] - }, - { - "name": "grilo-plugins", - "buildsystem": "meson", - "cleanup": [ - "/include", - "/share/help" - ], - "config-opts": [ - "-Denable-bookmarks=no", - "-Denable-chromaprint=no", - "-Denable-dleyna=no", - "-Denable-dmap=no", - "-Denable-filesystem=no", - "-Denable-flickr=yes", - "-Denable-freebox=no", - "-Denable-gravatar=no", - "-Denable-local-metadata=no", - "-Denable-lua-factory=no", - "-Denable-magnatune=no", - "-Denable-metadata-store=no", - "-Denable-opensubtitles=no", - "-Denable-optical-media=no", - "-Denable-podcasts=no", - "-Denable-raitv=no", - "-Denable-shoutcast=no", - "-Denable-thetvdb=no", - "-Denable-tmdb=no", - "-Denable-tracker=no", - "-Denable-youtube=no", - "--wrap-mode=nofallback" - ], - "sources": [ - { - "type": "git", - "url": "https://gitlab.gnome.org/GNOME/grilo-plugins.git" - } - ] - }, { "name": "tracker-miners", "buildsystem": "meson", diff --git a/meson.build b/meson.build index 37470335..78492693 100644 --- a/meson.build +++ b/meson.build @@ -168,7 +168,6 @@ 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') diff --git a/src/meson.build b/src/meson.build index 77b1bbc0..27cfb658 100644 --- a/src/meson.build +++ b/src/meson.build @@ -122,7 +122,6 @@ gnome_photos_sources = files( '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', @@ -379,7 +378,6 @@ deps = [ glib_dep, goa_dep, gobject_dep, - grilo_dep, gsettings_desktop_schemas_dep, gtk_dep, gtk_unix_print_dep, diff --git a/src/photos-application.c b/src/photos-application.c index 162c9ffa..fd1bc3fa 100644 --- a/src/photos-application.c +++ b/src/photos-application.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -2507,11 +2506,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] = {"e", NULL}; const gchar *fullscreen_accels[2] = {"F11", NULL}; @@ -2534,27 +2531,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-flickr-item.c b/src/photos-flickr-item.c deleted file mode 100644 index f142e729..00000000 --- a/src/photos-flickr-item.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Photos - access, organize and share your photos on GNOME - * Copyright © 2013 – 2021 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 . - */ - -/* Based on code from: - * + Documents - */ - - -#include "config.h" - -#include - -#include -#include -#include -#include -#include - -#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 e7a3b466..00000000 --- a/src/photos-flickr-item.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Photos - access, organize and share your photos on GNOME - * Copyright © 2012 – 2021 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 . - */ - -/* 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-utils.c b/src/photos-utils.c index a57493dc..845fda22 100644 --- a/src/photos-utils.c +++ b/src/photos-utils.c @@ -37,7 +37,6 @@ #include "photos-device-item.h" #include "photos-enums.h" #include "photos-error.h" -#include "photos-flickr-item.h" #include "photos-gegl.h" #include "photos-google-item.h" #include "photos-local-item.h" @@ -716,7 +715,6 @@ 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_FLICKR_ITEM); //g_type_ensure (PHOTOS_TYPE_GOOGLE_ITEM); g_type_ensure (PHOTOS_TYPE_LOCAL_ITEM); g_type_ensure (PHOTOS_TYPE_MEDIA_SERVER_ITEM); -- GitLab