[gnome-photos/wip/rishi/handle-urn-changes: 4/4] share-point-google: ...
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/handle-urn-changes: 4/4] share-point-google: ...
- Date: Thu, 8 Sep 2016 12:19:15 +0000 (UTC)
commit 319a72461bd950dd7a6cf9f410bc525e8ccf1f28
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Sep 8 14:18:12 2016 +0200
share-point-google: ...
src/photos-share-point-google.c | 82 ++++++++++++++++++++++++++++++++++++--
1 files changed, 77 insertions(+), 5 deletions(-)
---
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
index a986bac..1fd4771 100644
--- a/src/photos-share-point-google.c
+++ b/src/photos-share-point-google.c
@@ -29,6 +29,8 @@
#include "photos-application.h"
#include "photos-base-item.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"
@@ -39,6 +41,7 @@ struct _PhotosSharePointGoogle
PhotosSharePointOnline parent_instance;
GDataGoaAuthorizer *authorizer;
GDataPicasaWebService *service;
+ PhotosBaseManager *item_mngr;
};
@@ -120,6 +123,34 @@ photos_share_point_google_share_insert_shared_content (GObject *source_object, G
static void
photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAsyncResult *res, gpointer
user_data)
{
+ GError *error;
+ GTask *task = G_TASK (user_data);
+ PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
+
+ 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);
+ g_error_free (error);
+ }
+ else
+ {
+ g_task_return_error (task, error);
+ }
+
+ goto out;
+ }
+
+ out:
+ g_object_unref (task);
+}
+
+
+static void
+photos_share_point_google_share_wait_for_create (GObject *source_object, GAsyncResult *res, gpointer
user_data)
+{
PhotosSharePointGoogle *self;
GApplication *app;
GCancellable *cancellable;
@@ -128,21 +159,31 @@ photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAs
GoaAccount *account;
GoaObject *object;
GomMiner *miner;
- PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
+ PhotosItemManager *item_mngr = PHOTOS_ITEM_MANAGER (source_object);
PhotosSource *source;
PhotosSharePointGoogleShareData *data;
const gchar *account_id;
const gchar *file_entry_id;
- const gchar *item_id;
+ gchar *item_id = 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_metadata_add_shared_finish (item, res, &error))
+ item_id = photos_item_manager_wait_for_create_finish (item_mngr, res, &error);
+ if (error != NULL)
{
- g_task_return_error (task, error);
+ if (g_task_get_completed (task))
+ {
+ g_warning ("Unable to wait for EVENT_CREATED: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ g_task_return_error (task, error);
+ }
+
goto out;
}
@@ -160,7 +201,6 @@ photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAs
account_id = goa_account_get_id (account);
file_entry_id = gdata_entry_get_id (GDATA_ENTRY (data->file_entry));
- item_id = photos_filterable_get_id (PHOTOS_FILTERABLE (data->item));
gom_miner_call_insert_shared_content (miner,
account_id,
@@ -172,6 +212,7 @@ photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAs
g_object_ref (task));
out:
+ g_free (item_id);
g_object_unref (task);
}
@@ -192,6 +233,7 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
const gchar *account_identity;
const gchar *file_entry_id;
const gchar *provider_type;
+ const gchar *uri;
gchar *shared_identifier = NULL;
self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
@@ -218,6 +260,15 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
g_assert_null (data->file_entry);
data->file_entry = g_object_ref (file_entry);
+ g_assert_true (PHOTOS_IS_ITEM_MANAGER (self->item_mngr));
+
+ uri = photos_base_item_get_uri (data->item);
+ photos_item_manager_wait_for_create_async (PHOTOS_ITEM_MANAGER (self->item_mngr),
+ uri,
+ cancellable,
+ photos_share_point_google_share_wait_for_create,
+ g_object_ref (task));
+
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);
@@ -379,8 +430,28 @@ photos_share_point_google_dispose (GObject *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);
}
@@ -392,6 +463,7 @@ photos_share_point_google_class_init (PhotosSharePointGoogleClass *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->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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]