[gnome-photos/wip/rishi/online-miners: 21/24] Switch to the in-tree online miners
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/online-miners: 21/24] Switch to the in-tree online miners
- Date: Wed, 24 Mar 2021 01:10:00 +0000 (UTC)
commit c8043937dacedc4f551e770bba141ada7feba8bf
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Mar 20 03:45:55 2021 +0100
Switch to the in-tree online miners
https://gitlab.gnome.org/GNOME/gnome-photos/-/issues/83
src/meson.build | 10 -
src/photos-application.c | 421 ++-----------------------------------
src/photos-application.h | 6 -
src/photos-base-item.h | 3 -
src/photos-facebook-item.c | 3 -
src/photos-flickr-item.c | 3 -
src/photos-gom-miner.xml | 36 ----
src/photos-google-item.c | 3 -
src/photos-indexing-notification.c | 55 +++--
src/photos-media-server-item.c | 3 -
src/photos-share-point-google.c | 50 +++--
11 files changed, 74 insertions(+), 519 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 209e740f..de6ac503 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -342,16 +342,6 @@ gnome_photos_sources += gnome.gdbus_codegen(
autocleanup: 'all',
)
-gom_miner = 'photos-gom-miner'
-
-gnome_photos_sources += gnome.gdbus_codegen(
- gom_miner,
- gom_miner + '.xml',
- interface_prefix: 'org.gnome.OnlineMiners.',
- namespace: 'Gom',
- autocleanup: 'all',
-)
-
mpris_player = 'photos-mpris-player'
gnome_photos_sources += gnome.gdbus_codegen(
diff --git a/src/photos-application.c b/src/photos-application.c
index ec5f0629..e7038289 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -53,6 +53,7 @@
#include "photos-import-dialog.h"
#include "photos-item-manager.h"
#include "photos-main-window.h"
+#include "photos-online-miner-manager.h"
#include "photos-properties-dialog.h"
#include "photos-query.h"
#include "photos-search-context.h"
@@ -76,10 +77,6 @@
struct _PhotosApplication
{
GtkApplication parent_instance;
- GCancellable *create_window_cancellable;
- GHashTable *refresh_miner_ids;
- GList *miners;
- GList *miners_running;
GSettings *bg_settings;
GSettings *ss_settings;
GSimpleAction *blacks_exposure_action;
@@ -124,6 +121,7 @@ struct _PhotosApplication
GtkWidget *main_window;
PhotosBaseManager *shr_pnt_mngr;
PhotosCameraCache *camera_cache;
+ PhotosOnlineMinerManager *online_miner_manager;
PhotosSearchContextState *state;
PhotosSearchProvider *search_provider;
PhotosSelectionController *sel_cntrlr;
@@ -134,22 +132,11 @@ struct _PhotosApplication
gboolean empty_results;
gboolean main_window_deleted;
const gchar *miner_files_name;
- guint create_miners_count;
guint init_fishes_id;
guint use_count;
guint32 activation_timestamp;
- gulong source_added_id;
- gulong source_removed_id;
};
-enum
-{
- MINERS_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
static void photos_application_search_context_iface_init (PhotosSearchContextInterface *iface);
@@ -190,13 +177,6 @@ typedef struct _PhotosApplicationImportWaitForFileData PhotosApplicationImportWa
typedef struct _PhotosApplicationRefreshData PhotosApplicationRefreshData;
typedef struct _PhotosApplicationSetBackgroundData PhotosApplicationSetBackgroundData;
-struct _PhotosApplicationCreateData
-{
- PhotosApplication *application;
- gchar *extension_name;
- gchar *miner_name;
-};
-
struct _PhotosApplicationImportData
{
PhotosApplication *application;
@@ -208,12 +188,6 @@ struct _PhotosApplicationImportData
gint64 ctime_latest;
};
-struct _PhotosApplicationRefreshData
-{
- PhotosApplication *application;
- GomMiner *miner;
-};
-
struct _PhotosApplicationSetBackgroundData
{
PhotosApplication *application;
@@ -222,36 +196,7 @@ struct _PhotosApplicationSetBackgroundData
};
static void photos_application_import_file_copy (GObject *source_object, GAsyncResult *res, gpointer
user_data);
-static void photos_application_refresh_miner_now (PhotosApplication *self, GomMiner *miner);
static void photos_application_start_miners (PhotosApplication *self);
-static void photos_application_start_miners_second (PhotosApplication *self);
-static void photos_application_stop_miners (PhotosApplication *self);
-
-
-static PhotosApplicationCreateData *
-photos_application_create_data_new (PhotosApplication *application,
- const gchar *extension_name,
- const gchar *miner_name)
-{
- PhotosApplicationCreateData *data;
-
- data = g_slice_new0 (PhotosApplicationCreateData);
- g_application_hold (G_APPLICATION (application));
- data->application = application;
- data->extension_name = g_strdup (extension_name);
- data->miner_name = g_strdup (miner_name);
- return data;
-}
-
-
-static void
-photos_application_create_data_free (PhotosApplicationCreateData *data)
-{
- g_application_release (G_APPLICATION (data->application));
- g_free (data->extension_name);
- g_free (data->miner_name);
- g_slice_free (PhotosApplicationCreateData, data);
-}
static PhotosApplicationImportData *
@@ -292,28 +237,6 @@ photos_application_import_data_free (PhotosApplicationImportData *data)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotosApplicationImportData, photos_application_import_data_free);
-static PhotosApplicationRefreshData *
-photos_application_refresh_data_new (PhotosApplication *application, GomMiner *miner)
-{
- PhotosApplicationRefreshData *data;
-
- data = g_slice_new0 (PhotosApplicationRefreshData);
- g_application_hold (G_APPLICATION (application));
- data->application = application;
- data->miner = g_object_ref (miner);
- return data;
-}
-
-
-static void
-photos_application_refresh_data_free (PhotosApplicationRefreshData *data)
-{
- g_application_release (G_APPLICATION (data->application));
- g_object_unref (data->miner);
- g_slice_free (PhotosApplicationRefreshData, data);
-}
-
-
static PhotosApplicationSetBackgroundData *
photos_application_set_background_data_new (PhotosApplication *application, GFile *file, GSettings *settings)
{
@@ -606,100 +529,8 @@ photos_application_delete_event (PhotosApplication *self)
static void
photos_application_destroy (PhotosApplication *self)
{
- GHashTableIter iter;
- gpointer refresh_miner_id_data;
-
self->main_window = NULL;
-
- g_hash_table_iter_init (&iter, self->refresh_miner_ids);
- while (g_hash_table_iter_next (&iter, NULL, &refresh_miner_id_data))
- {
- guint refresh_miner_id = GPOINTER_TO_UINT (refresh_miner_id_data);
- g_source_remove (refresh_miner_id);
- }
-
- g_hash_table_remove_all (self->refresh_miner_ids);
-
- g_cancellable_cancel (self->create_window_cancellable);
- g_clear_object (&self->create_window_cancellable);
- self->create_window_cancellable = g_cancellable_new ();
-
- photos_application_stop_miners (self);
-}
-
-
-static void
-photos_application_gom_miner (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- PhotosApplicationCreateData *data = (PhotosApplicationCreateData *) user_data;
- PhotosApplication *self = data->application;
- g_autoptr (GomMiner) miner = NULL;
-
- {
- g_autoptr (GError) error = NULL;
-
- miner = gom_miner_proxy_new_for_bus_finish (res, &error);
- if (error != NULL)
- {
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- {
- goto out;
- }
- else
- {
- g_warning ("Unable to create GomMiner proxy for %s: %s", data->miner_name, error->message);
- goto maybe_continue;
- }
- }
- }
-
- g_object_set_data_full (G_OBJECT (miner), "provider-type", g_strdup (data->extension_name), g_free);
- self->miners = g_list_prepend (self->miners, g_object_ref (miner));
-
- maybe_continue:
- if (self->create_miners_count == 1)
- photos_application_start_miners_second (self);
-
- out:
- self->create_miners_count--;
- photos_application_create_data_free (data);
-}
-
-
-static void
-photos_application_create_online_miners (PhotosApplication *self)
-{
- GIOExtensionPoint *extension_point;
- GList *extensions;
- GList *l;
-
- extension_point = g_io_extension_point_lookup (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME);
- extensions = g_io_extension_point_get_extensions (extension_point);
- for (l = extensions; l != NULL; l = l->next)
- {
- GIOExtension *extension = (GIOExtension *) l->data;
- PhotosApplicationCreateData *data;
- PhotosBaseItemClass *base_item_class; /* TODO: use g_autoptr */
-
- base_item_class = PHOTOS_BASE_ITEM_CLASS (g_io_extension_ref_class (extension));
- if (base_item_class->miner_name != NULL && base_item_class->miner_object_path != NULL)
- {
- const gchar *extension_name;
-
- extension_name = g_io_extension_get_name (extension);
- data = photos_application_create_data_new (self, extension_name, base_item_class->miner_name);
- gom_miner_proxy_new_for_bus (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- base_item_class->miner_name,
- base_item_class->miner_object_path,
- self->create_window_cancellable,
- photos_application_gom_miner,
- data);
- self->create_miners_count++;
- }
-
- g_type_class_unref (base_item_class);
- }
+ g_clear_object (&self->online_miner_manager);
}
@@ -1737,126 +1568,6 @@ photos_application_properties (PhotosApplication *self)
}
-static gboolean
-photos_application_refresh_miner_timeout (gpointer user_data)
-{
- PhotosApplicationRefreshData *data = (PhotosApplicationRefreshData *) user_data;
- PhotosApplication *self = data->application;
-
- g_hash_table_remove (self->refresh_miner_ids, data->miner);
- photos_application_refresh_miner_now (self, data->miner);
- return G_SOURCE_REMOVE;
-}
-
-
-static void
-photos_application_refresh_db (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
- GList *miner_link;
- g_autoptr (GomMiner) miner = GOM_MINER (source_object);
- PhotosApplicationRefreshData *data;
- const gchar *name;
- gpointer refresh_miner_id_data;
- guint refresh_miner_id;
-
- name = g_dbus_proxy_get_name (G_DBUS_PROXY (miner));
- photos_debug (PHOTOS_DEBUG_NETWORK, "Finished RefreshDB for %s (%p)", name, miner);
-
- refresh_miner_id_data = g_hash_table_lookup (self->refresh_miner_ids, miner);
- g_assert_null (refresh_miner_id_data);
-
- miner_link = g_list_find (self->miners_running, miner);
- g_assert_nonnull (miner_link);
-
- self->miners_running = g_list_remove_link (self->miners_running, miner_link);
- g_signal_emit (self, signals[MINERS_CHANGED], 0, self->miners_running);
-
- {
- g_autoptr (GError) error = NULL;
-
- if (!gom_miner_call_refresh_db_finish (miner, res, &error))
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Unable to update the cache: %s", error->message);
-
- goto out;
- }
- }
-
- data = photos_application_refresh_data_new (self, miner);
- refresh_miner_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
- MINER_REFRESH_TIMEOUT,
- photos_application_refresh_miner_timeout,
- data,
- (GDestroyNotify) photos_application_refresh_data_free);
- g_hash_table_insert (self->refresh_miner_ids, miner, GUINT_TO_POINTER (refresh_miner_id));
-
- photos_debug (PHOTOS_DEBUG_NETWORK, "Added timeout for %s (%p)", name, miner);
-
- out:
- g_application_release (G_APPLICATION (self));
-}
-
-
-static void
-photos_application_refresh_miner_now (PhotosApplication *self, GomMiner *miner)
-{
- GCancellable *cancellable;
- const gchar *const index_types[] = {"photos", NULL};
- const gchar *name;
- gpointer refresh_miner_id_data;
-
- if (g_getenv ("GNOME_PHOTOS_DISABLE_MINERS") != NULL)
- return;
-
- name = g_dbus_proxy_get_name (G_DBUS_PROXY (miner));
-
- if (g_list_find (self->miners_running, miner) != NULL)
- {
- photos_debug (PHOTOS_DEBUG_NETWORK, "Skipped %s (%p): already running", name, miner);
- return;
- }
-
- refresh_miner_id_data = g_hash_table_lookup (self->refresh_miner_ids, miner);
- if (refresh_miner_id_data != NULL)
- {
- guint refresh_miner_id = GPOINTER_TO_UINT (refresh_miner_id_data);
-
- g_source_remove (refresh_miner_id);
- g_hash_table_remove (self->refresh_miner_ids, miner);
- photos_debug (PHOTOS_DEBUG_NETWORK, "Removed timeout for %s (%p)", name, miner);
- }
-
- self->miners_running = g_list_prepend (self->miners_running, g_object_ref (miner));
- g_signal_emit (self, signals[MINERS_CHANGED], 0, self->miners_running);
-
- cancellable = g_cancellable_new ();
- g_object_set_data_full (G_OBJECT (miner), "cancellable", cancellable, g_object_unref);
- g_application_hold (G_APPLICATION (self));
- gom_miner_call_refresh_db (miner, index_types, cancellable, photos_application_refresh_db, self);
-
- photos_debug (PHOTOS_DEBUG_NETWORK, "Called RefreshDB for %s (%p)", name, miner);
-}
-
-
-static void
-photos_application_refresh_miners (PhotosApplication *self)
-{
- GList *l;
-
- for (l = self->miners; l != NULL; l = l->next)
- {
- GomMiner *miner = GOM_MINER (l->data);
- const gchar *provider_type;
-
- provider_type = g_object_get_data (G_OBJECT (miner), "provider-type");
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (self->state->src_mngr),
provider_type))
- photos_application_refresh_miner_now (self, miner);
- }
-}
-
-
static void
photos_application_remote_display_current (PhotosApplication *self)
{
@@ -2233,57 +1944,17 @@ photos_application_start_miners_local (PhotosApplication *self)
static void
photos_application_start_miners (PhotosApplication *self)
{
- photos_application_start_miners_local (self);
- photos_application_create_online_miners (self);
-}
-
-
-static void
-photos_application_start_miners_second (PhotosApplication *self)
-{
- photos_application_refresh_miners (self);
+ g_return_if_fail (self->online_miner_manager == NULL);
- self->source_added_id = g_signal_connect_object (self->state->src_mngr,
- "object-added",
- G_CALLBACK (photos_application_refresh_miners),
- self,
- G_CONNECT_SWAPPED);
- self->source_removed_id = g_signal_connect_object (self->state->src_mngr,
- "object-removed",
- G_CALLBACK (photos_application_refresh_miners),
- self,
- G_CONNECT_SWAPPED);
-}
-
-
-static void
-photos_application_stop_miners (PhotosApplication *self)
-{
- GList *l;
-
- for (l = self->miners_running; l != NULL; l = l->next)
- {
- GomMiner *miner = GOM_MINER (l->data);
- GCancellable *cancellable;
-
- cancellable = g_object_get_data (G_OBJECT (miner), "cancellable");
- g_cancellable_cancel (cancellable);
- }
-
- if (self->source_added_id != 0)
- {
- g_signal_handler_disconnect (self->state->src_mngr, self->source_added_id);
- self->source_added_id = 0;
- }
+ photos_application_start_miners_local (self);
- if (self->source_removed_id != 0)
- {
- g_signal_handler_disconnect (self->state->src_mngr, self->source_removed_id);
- self->source_removed_id = 0;
- }
+ {
+ g_autoptr (GError) error = NULL;
- g_list_free_full (self->miners, g_object_unref);
- self->miners = NULL;
+ self->online_miner_manager = photos_online_miner_manager_dup_singleton (NULL, &error);
+ if (G_UNLIKELY (error != NULL))
+ g_warning ("Unable to create PhotosOnlineMinerManager: %s", error->message);
+ }
}
@@ -2566,21 +2237,15 @@ static void
photos_application_shutdown (GApplication *application)
{
PhotosApplication *self = PHOTOS_APPLICATION (application);
- guint refresh_miner_ids_size;
photos_debug (PHOTOS_DEBUG_APPLICATION, "PhotosApplication::shutdown");
- refresh_miner_ids_size = g_hash_table_size (self->refresh_miner_ids);
- g_assert (refresh_miner_ids_size == 0);
-
if (self->init_fishes_id != 0)
{
g_source_remove (self->init_fishes_id);
self->init_fishes_id = 0;
}
- g_clear_pointer (&self->refresh_miner_ids, g_hash_table_unref);
-
G_APPLICATION_CLASS (photos_application_parent_class)->shutdown (application);
}
@@ -2637,9 +2302,6 @@ photos_application_startup (GApplication *application)
}
}
- self->create_window_cancellable = g_cancellable_new ();
- self->refresh_miner_ids = g_hash_table_new (g_direct_hash, g_direct_equal);
-
self->bg_settings = g_settings_new (DESKTOP_BACKGROUND_SCHEMA);
self->ss_settings = g_settings_new (DESKTOP_SCREENSAVER_SCHEMA);
@@ -2933,21 +2595,9 @@ photos_application_dispose (GObject *object)
{
PhotosApplication *self = PHOTOS_APPLICATION (object);
+ g_assert (self->online_miner_manager == NULL);
g_assert_null (self->search_provider);
- if (self->miners_running != NULL)
- {
- g_list_free_full (self->miners_running, g_object_unref);
- self->miners_running = NULL;
- }
-
- if (self->miners != NULL)
- {
- g_list_free_full (self->miners, g_object_unref);
- self->miners = NULL;
- }
-
- g_clear_object (&self->create_window_cancellable);
g_clear_object (&self->bg_settings);
g_clear_object (&self->ss_settings);
g_clear_object (&self->blacks_exposure_action);
@@ -3012,8 +2662,6 @@ photos_application_finalize (GObject *object)
{
PhotosApplication *self = PHOTOS_APPLICATION (object);
- g_assert (self->create_miners_count == 0);
-
if (g_application_get_is_registered (G_APPLICATION (self)) && !g_application_get_is_remote (G_APPLICATION
(self)))
gegl_exit ();
@@ -3067,17 +2715,6 @@ photos_application_class_init (PhotosApplicationClass *class)
application_class->handle_local_options = photos_application_handle_local_options;
application_class->shutdown = photos_application_shutdown;
application_class->startup = photos_application_startup;
-
- signals[MINERS_CHANGED] = g_signal_new ("miners-changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, /* accumulator */
- NULL, /* accu_data */
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
}
@@ -3120,32 +2757,6 @@ photos_application_get_empty_results (PhotosApplication *self)
}
-GomMiner *
-photos_application_get_miner (PhotosApplication *self, const gchar *provider_type)
-{
- GList *l;
- GomMiner *ret_val = NULL;
-
- g_return_val_if_fail (PHOTOS_IS_APPLICATION (self), NULL);
- g_return_val_if_fail (provider_type != NULL && provider_type[0] != '\0', NULL);
-
- for (l = self->miners; l != NULL; l = l->next)
- {
- GomMiner *miner = GOM_MINER (l->data);
- const gchar *miner_provider_type;
-
- miner_provider_type = g_object_get_data (G_OBJECT (miner), "provider-type");
- if (g_strcmp0 (provider_type, miner_provider_type) == 0)
- {
- ret_val = miner;
- break;
- }
- }
-
- return ret_val;
-}
-
-
const gchar *
photos_application_get_miner_files_name (PhotosApplication *self)
{
@@ -3156,14 +2767,6 @@ photos_application_get_miner_files_name (PhotosApplication *self)
}
-GList *
-photos_application_get_miners_running (PhotosApplication *self)
-{
- g_return_val_if_fail (PHOTOS_IS_APPLICATION (self), NULL);
- return self->miners_running;
-}
-
-
gint
photos_application_get_scale_factor (PhotosApplication *self)
{
diff --git a/src/photos-application.h b/src/photos-application.h
index 6ab6c103..3d5ea1b3 100644
--- a/src/photos-application.h
+++ b/src/photos-application.h
@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
-#include "photos-gom-miner.h"
#include "photos-tracker-miner-files-index.h"
G_BEGIN_DECLS
@@ -39,13 +38,8 @@ TrackerMinerFilesIndex *photos_application_dup_miner_files_index (PhotosApplicat
gboolean photos_application_get_empty_results (PhotosApplication *self);
-GomMiner *photos_application_get_miner (PhotosApplication *self,
- const gchar *provider_type);
-
const gchar *photos_application_get_miner_files_name (PhotosApplication *self);
-GList *photos_application_get_miners_running (PhotosApplication *self);
-
gint photos_application_get_scale_factor (PhotosApplication *self);
void photos_application_hold (PhotosApplication *self);
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index daee3353..9a72d0bc 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -51,9 +51,6 @@ struct _PhotosBaseItemClass
{
GObjectClass parent_class;
- const gchar *miner_name;
- const gchar *miner_object_path;
-
/* virtual methods */
gchar *(*create_filename_fallback) (PhotosBaseItem *self);
gchar *(*create_name_fallback) (PhotosBaseItem *self);
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
index 2a180888..c4ec9128 100644
--- a/src/photos-facebook-item.c
+++ b/src/photos-facebook-item.c
@@ -325,9 +325,6 @@ 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;
diff --git a/src/photos-flickr-item.c b/src/photos-flickr-item.c
index f142e729..901324b8 100644
--- a/src/photos-flickr-item.c
+++ b/src/photos-flickr-item.c
@@ -393,9 +393,6 @@ 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;
diff --git a/src/photos-google-item.c b/src/photos-google-item.c
index 7d4459e9..14ff0467 100644
--- a/src/photos-google-item.c
+++ b/src/photos-google-item.c
@@ -335,9 +335,6 @@ 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;
diff --git a/src/photos-indexing-notification.c b/src/photos-indexing-notification.c
index 49cca10d..a09535c2 100644
--- a/src/photos-indexing-notification.c
+++ b/src/photos-indexing-notification.c
@@ -28,9 +28,10 @@
#include <glib/gi18n.h>
#include "photos-application.h"
-#include "photos-gom-miner.h"
#include "photos-indexing-notification.h"
#include "photos-notification-manager.h"
+#include "photos-online-miner-manager.h"
+#include "photos-online-miner-process.h"
#include "photos-tracker-miner.h"
@@ -42,6 +43,7 @@ struct _PhotosIndexingNotification
GtkWidget *primary_label;
GtkWidget *secondary_label;
GtkWidget *spinner;
+ PhotosOnlineMinerManager *online_miner_manager;
TrackerMiner *miner_files;
gboolean closed;
gboolean on_display;
@@ -139,21 +141,20 @@ static gboolean
photos_indexing_notification_timeout (gpointer user_data)
{
PhotosIndexingNotification *self = PHOTOS_INDEXING_NOTIFICATION (user_data);
- GApplication *app;
GList *miners_running;
- GomMiner *miner = NULL;
+ PhotosOnlineMinerProcess *online_miner = NULL;
const gchar *provider_name = NULL;
g_autofree gchar *primary = NULL;
self->timeout_id = 0;
+ g_return_val_if_fail (self->online_miner_manager != NULL, G_SOURCE_REMOVE);
- app = g_application_get_default ();
- miners_running = photos_application_get_miners_running (PHOTOS_APPLICATION (app));
+ miners_running = photos_online_miner_manager_get_running (self->online_miner_manager);
if (miners_running != NULL && miners_running->next == NULL) /* length == 1 */
- miner = GOM_MINER (miners_running->data);
+ online_miner = PHOTOS_ONLINE_MINER_PROCESS (miners_running->data);
- if (miner != NULL)
- provider_name = gom_miner_get_display_name (miner);
+ if (online_miner != NULL)
+ provider_name = photos_online_miner_process_get_provider_name (online_miner);
if (provider_name != NULL)
{
@@ -174,18 +175,20 @@ photos_indexing_notification_timeout (gpointer user_data)
static void
photos_indexing_notification_update_notification (PhotosIndexingNotification *self, gdouble
miner_files_progress)
{
- GApplication *app;
- GList *miners_running;
gboolean is_indexing_local = FALSE;
gboolean is_indexing_remote = FALSE;
if (miner_files_progress < 1)
is_indexing_local = TRUE;
- app = g_application_get_default ();
- miners_running = photos_application_get_miners_running (PHOTOS_APPLICATION (app));
- if (miners_running != NULL) /* length > 0 */
- is_indexing_remote = TRUE;
+ if (G_LIKELY (self->online_miner_manager != NULL))
+ {
+ GList *miners_running;
+
+ miners_running = photos_online_miner_manager_get_running (self->online_miner_manager);
+ if (miners_running != NULL) /* length > 0 */
+ is_indexing_remote = TRUE;
+ }
if (is_indexing_local)
{
@@ -305,6 +308,7 @@ photos_indexing_notification_dispose (GObject *object)
}
g_clear_object (&self->ntfctn_mngr);
+ g_clear_object (&self->online_miner_manager);
g_clear_object (&self->miner_files);
G_OBJECT_CLASS (photos_indexing_notification_parent_class)->dispose (object);
@@ -359,6 +363,23 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
gtk_container_add (GTK_CONTAINER (self), close);
g_signal_connect_swapped (close, "clicked", G_CALLBACK (photos_indexing_notification_close_clicked), self);
+ {
+ g_autoptr (GError) error = NULL;
+
+ self->online_miner_manager = photos_online_miner_manager_dup_singleton (NULL, &error);
+ if (G_UNLIKELY (error != NULL))
+ g_warning ("Unable to create PhotosOnlineMinerManager: %s", error->message);
+ }
+
+ if (G_LIKELY (self->online_miner_manager != NULL))
+ {
+ g_signal_connect_object (self->online_miner_manager,
+ "changed",
+ G_CALLBACK (photos_indexing_notification_online_miners_changed),
+ self,
+ G_CONNECT_SWAPPED);
+ }
+
/* TODO: should be proxied by the "control" daemon for Flatpaks */
miner_files_name = photos_application_get_miner_files_name (PHOTOS_APPLICATION (app));
tracker_miner_proxy_new_for_bus (G_BUS_TYPE_SESSION,
@@ -368,12 +389,6 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
self->cancellable,
photos_indexing_notification_tracker_miner,
self);
-
- g_signal_connect_object (app,
- "miners-changed",
- G_CALLBACK (photos_indexing_notification_online_miners_changed),
- self,
- G_CONNECT_SWAPPED);
}
diff --git a/src/photos-media-server-item.c b/src/photos-media-server-item.c
index 521ecf4a..175f7807 100644
--- a/src/photos-media-server-item.c
+++ b/src/photos-media-server-item.c
@@ -216,9 +216,6 @@ photos_media_server_item_class_init (PhotosMediaServerItemClass *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.MediaServer";
- base_item_class->miner_object_path = "/org/gnome/OnlineMiners/MediaServer";
-
object_class->constructed = photos_media_server_item_constructed;
object_class->dispose = photos_media_server_item_dispose;
base_item_class->create_filename_fallback = photos_media_server_item_create_filename_fallback;
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
index f0f7e019..6ff16f9f 100644
--- a/src/photos-share-point-google.c
+++ b/src/photos-share-point-google.c
@@ -24,11 +24,11 @@
#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-online-miner-manager.h"
#include "photos-search-context.h"
#include "photos-share-point-google.h"
#include "photos-source.h"
@@ -41,6 +41,7 @@ struct _PhotosSharePointGoogle
GDataGoaAuthorizer *authorizer;
GDataPicasaWebService *service;
PhotosBaseManager *item_mngr;
+ PhotosOnlineMinerManager *online_miner_manager;
};
@@ -112,12 +113,12 @@ static void
photos_share_point_google_share_insert_shared_content (GObject *source_object, GAsyncResult *res, gpointer
user_data)
{
g_autoptr (GTask) task = G_TASK (user_data);
- GomMiner *miner = GOM_MINER (source_object);
+ PhotosOnlineMinerManager *online_miner_manager = PHOTOS_ONLINE_MINER_MANAGER (source_object);
{
g_autoptr (GError) error = NULL;
- if (!gom_miner_call_insert_shared_content_finish (miner, res, &error))
+ if (!photos_online_miner_manager_insert_shared_content_finish (online_miner_manager, res, &error))
{
g_task_return_error (task, g_steal_pointer (&error));
goto out;
@@ -134,11 +135,9 @@ photos_share_point_google_share_insert_shared_content (GObject *source_object, G
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;
@@ -148,31 +147,27 @@ photos_share_point_google_share_metadata_add_shared_second (PhotosSharePointGoog
cancellable = g_task_get_cancellable (task);
data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
- app = g_application_get_default ();
-
- 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);
- provider_type = goa_account_get_provider_type (account);
-
- miner = photos_application_get_miner (PHOTOS_APPLICATION (app), provider_type);
- if (miner == NULL)
+ if (G_UNLIKELY (self->online_miner_manager == NULL))
{
- g_task_return_new_error (task, PHOTOS_ERROR, 0, "Unable to find the %s miner", provider_type);
+ g_task_return_new_error (task, PHOTOS_ERROR, 0, "No OnlineMinerManager, failed to update the cache");
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));
+ provider_type = goa_account_get_provider_type (account);
- 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));
+ photos_online_miner_manager_insert_shared_content_async (self->online_miner_manager,
+ provider_type,
+ account_id,
+ file_entry_id,
+ data->item_id_after_changes,
+ cancellable,
+
photos_share_point_google_share_insert_shared_content,
+ g_object_ref (task));
out:
g_object_unref (task);
@@ -486,6 +481,7 @@ photos_share_point_google_dispose (GObject *object)
g_clear_object (&self->authorizer);
g_clear_object (&self->service);
+ g_clear_object (&self->online_miner_manager);
G_OBJECT_CLASS (photos_share_point_google_parent_class)->dispose (object);
}
@@ -514,6 +510,14 @@ photos_share_point_google_init (PhotosSharePointGoogle *self)
self->item_mngr = state->item_mngr;
g_object_add_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ self->online_miner_manager = photos_online_miner_manager_dup_singleton (NULL, &error);
+ if (G_UNLIKELY (error != NULL))
+ g_warning ("Unable to create PhotosOnlineMinerManager: %s", error->message);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]