[epiphany/wip/ephy-sync: 83/86] sync-bookmarks: Fix storage collection creation function



commit e47d7c8b0b7d3cf01e4237bfdb60da847595f3fd
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Sat Jul 30 18:30:37 2016 +0300

    sync-bookmarks: Fix storage collection creation function

 src/ephy-sync-bookmarks.c |   44 +++++++++++++++++++-------------------------
 src/ephy-sync-bookmarks.h |    2 +-
 src/prefs-dialog.c        |    2 +-
 3 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/ephy-sync-bookmarks.c b/src/ephy-sync-bookmarks.c
index 876dcbf..62d5b1c 100644
--- a/src/ephy-sync-bookmarks.c
+++ b/src/ephy-sync-bookmarks.c
@@ -19,10 +19,11 @@
 #include "config.h"
 #include "ephy-sync-bookmarks.h"
 
+#include "ephy-shell.h"
 #include "ephy-sync-utils.h"
 
-#define EPHY_BOOKMARKS_DUMMY_BSO       "000000000000"
-#define EPHY_BOOKMARKS_BSO_COLLECTION  "ephy-bookmarks"
+#define EPHY_BOOKMARKS_DUMMY_BSO   "000000000000"
+#define EPHY_BOOKMARKS_COLLECTION  "ephy-bookmarks"
 
 static void
 create_bso_collection_response_cb (SoupSession *session,
@@ -32,7 +33,7 @@ create_bso_collection_response_cb (SoupSession *session,
   EphySyncService *service;
   gchar *endpoint;
 
-  service = EPHY_SYNC_SERVICE (user_data);
+  service = ephy_shell_get_global_sync_service (ephy_shell_get_default ());
 
   /* Status code 412 means the BSO already exists. Since we will delete it
    * anyway, we don't treat this as an error.
@@ -43,41 +44,34 @@ create_bso_collection_response_cb (SoupSession *session,
     return;
   }
 
-  /* The EPHY_BOOKMARKS_BSO_COLLECTION collection is now created. We can safely
+  /* The EPHY_BOOKMARKS_COLLECTION collection is now created. We can safely
    * delete the dummy BSO that we've uploaded. No need to check for response.
    */
-  endpoint = g_strdup_printf ("storage/%s/%s",
-                              EPHY_BOOKMARKS_BSO_COLLECTION,
-                              EPHY_BOOKMARKS_DUMMY_BSO);
-  ephy_sync_service_send_storage_message (service,
-                                          endpoint, SOUP_METHOD_DELETE,
-                                          NULL, -1, -1,
-                                          NULL, NULL);
+  endpoint = g_strdup_printf ("storage/%s/%s", EPHY_BOOKMARKS_COLLECTION, EPHY_BOOKMARKS_DUMMY_BSO);
+  ephy_sync_service_send_storage_message (service, endpoint, SOUP_METHOD_DELETE,
+                                          NULL, -1, -1, NULL, NULL);
   g_free (endpoint);
 }
 
 void
-ephy_sync_bookmarks_create_bso_collection (EphySyncService *service)
+ephy_sync_bookmarks_create_storage_collection (void)
 {
+  EphySyncService *service;
   gchar *endpoint;
-  gchar *bso_json;
+  gchar *bso;
 
-  endpoint = g_strdup_printf ("storage/%s/%s",
-                              EPHY_BOOKMARKS_BSO_COLLECTION,
-                              EPHY_BOOKMARKS_DUMMY_BSO);
-  bso_json = ephy_sync_utils_create_bso_json (EPHY_BOOKMARKS_DUMMY_BSO,
-                                              EPHY_BOOKMARKS_DUMMY_BSO);
+  service = ephy_shell_get_global_sync_service (ephy_shell_get_default ());
+  endpoint = g_strdup_printf ("storage/%s/%s", EPHY_BOOKMARKS_COLLECTION, EPHY_BOOKMARKS_DUMMY_BSO);
+  bso = ephy_sync_utils_create_bso_json (EPHY_BOOKMARKS_DUMMY_BSO, EPHY_BOOKMARKS_DUMMY_BSO);
 
   /* Send a dummy BSO to the Storage Server so it will create the
-   * EPHY_BOOKMARKS_BSO_COLLECTION collection if it doesn't exist already.
+   * EPHY_BOOKMARKS_COLLECTION collection if it doesn't exist already.
    * In the response callback we will delete the dummy BSO.
    */
-  ephy_sync_service_send_storage_message (service,
-                                          endpoint, SOUP_METHOD_PUT,
-                                          bso_json, -1, 0,
-                                          create_bso_collection_response_cb,
-                                          service);
+  ephy_sync_service_send_storage_message (service, endpoint, SOUP_METHOD_PUT,
+                                          bso, -1, 0,
+                                          create_bso_collection_response_cb, NULL);
 
   g_free (endpoint);
-  g_free (bso_json);
+  g_free (bso);
 }
diff --git a/src/ephy-sync-bookmarks.h b/src/ephy-sync-bookmarks.h
index 266c026..f3f72b0 100644
--- a/src/ephy-sync-bookmarks.h
+++ b/src/ephy-sync-bookmarks.h
@@ -25,7 +25,7 @@
 
 G_BEGIN_DECLS
 
-void ephy_sync_bookmarks_create_bso_collection (EphySyncService *service);
+void ephy_sync_bookmarks_create_storage_collection (void);
 
 G_END_DECLS
 
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 65fb9c7..0c667c7 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -297,7 +297,7 @@ server_message_received_cb (WebKitUserContentManager *manager,
                                             NULL);
 
     /* Create our own bookmarks BSO collection on the Storage Server. */
-    ephy_sync_bookmarks_create_bso_collection (service);
+    ephy_sync_bookmarks_create_storage_collection ();
 
     /* Translators: the %s refers to the email of the currently logged in user. */
     gtk_label_set_markup (GTK_LABEL (dialog->sync_sign_out_details),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]