[gnome-photos/wip/rishi/de-dup: 5/6] share-point-google: Add the shared copy's ID to the original
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/de-dup: 5/6] share-point-google: Add the shared copy's ID to the original
- Date: Wed, 7 Sep 2016 07:40:07 +0000 (UTC)
commit 21be4461d5ba8bd5d1ddd78ef7ea117308fe497e
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Sep 7 09:35:56 2016 +0200
share-point-google: Add the shared copy's ID to the original
https://bugzilla.gnome.org/show_bug.cgi?id=770267
src/photos-share-point-google.c | 84 ++++++++++++++++++++++++++++++++------
1 files changed, 70 insertions(+), 14 deletions(-)
---
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
index 1f9ecae..a986bac 100644
--- a/src/photos-share-point-google.c
+++ b/src/photos-share-point-google.c
@@ -54,6 +54,7 @@ typedef struct _PhotosSharePointGoogleShareData PhotosSharePointGoogleShareData;
struct _PhotosSharePointGoogleShareData
{
+ GDataPicasaWebFile *file_entry;
GDataUploadStream *stream;
PhotosBaseItem *item;
};
@@ -74,6 +75,7 @@ photos_share_point_google_share_data_new (PhotosBaseItem *item)
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_slice_free (PhotosSharePointGoogleShareData, data);
@@ -116,14 +118,13 @@ photos_share_point_google_share_insert_shared_content (GObject *source_object, G
static void
-photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncResult *res, gpointer
user_data)
+photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAsyncResult *res, gpointer
user_data)
{
PhotosSharePointGoogle *self;
GApplication *app;
GCancellable *cancellable;
GError *error;
GTask *task = G_TASK (user_data);
- GDataPicasaWebFile *file_entry = NULL;
GoaAccount *account;
GoaObject *object;
GomMiner *miner;
@@ -139,17 +140,7 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
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)
+ if (!photos_base_item_metadata_add_shared_finish (item, res, &error))
{
g_task_return_error (task, error);
goto out;
@@ -168,7 +159,7 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
account = goa_object_peek_account (object);
account_id = goa_account_get_id (account);
- file_entry_id = gdata_entry_get_id (GDATA_ENTRY (file_entry));
+ 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,
@@ -181,8 +172,73 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
g_object_ref (task));
out:
+ g_object_unref (task);
+}
+
+
+static void
+photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncResult *res, gpointer
user_data)
+{
+ PhotosSharePointGoogle *self;
+ GCancellable *cancellable;
+ GError *error;
+ GTask *task = G_TASK (user_data);
+ 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;
+ 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);
+
+ 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));
+
+ out:
g_clear_object (&file_entry);
g_object_unref (task);
+ g_free (shared_identifier);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]