[gnome-photos/wip/rishi/online-miners: 14/15] share-point-google




commit ec8bd0b7f0c401f0e72f437d621083975c88471f
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Mar 20 16:08:53 2021 +0100

    share-point-google

 src/photos-share-point-google.c | 46 +++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
index e8c2d0d9..668016c9 100644
--- a/src/photos-share-point-google.c
+++ b/src/photos-share-point-google.c
@@ -29,6 +29,7 @@
 #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 +42,7 @@ struct _PhotosSharePointGoogle
   GDataGoaAuthorizer *authorizer;
   GDataPicasaWebService *service;
   PhotosBaseManager *item_mngr;
+  PhotosOnlineMinerManager *online_miner_manager;
 };
 
 
@@ -132,11 +134,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;
@@ -146,31 +146,28 @@ 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,
+                                                           "photos",
+                                                           data->item_id_after_changes,
+                                                           cancellable,
+                                                           
photos_share_point_google_share_insert_shared_content,
+                                                           g_object_ref (task));
 
  out:
   g_object_unref (task);
@@ -474,6 +471,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);
 }
@@ -502,6 +500,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]