summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-gnome/recipes-gnome/gnome-online-accounts/files/0001-Update-to-rest-1.0.patch
blob: 4a47fb2dbe50b379f9b16a37df73bdba1c90185c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
From 3c4a6eda580c6e38aeedb63d73ae7b96cc7f9a07 Mon Sep 17 00:00:00 2001
From: Carlos Garcia Campos <cgarcia@igalia.com>
Date: Mon, 7 Jun 2021 16:31:18 +0200
Subject: [PATCH] Update to rest 1.0

Updates to use the rest 1.0 API

Upstream-Status: Inappropriate [rest 1.0 is not released yet]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 configure.ac                       |  2 +-
 src/goabackend/goalastfmprovider.c | 26 +++++++++++++-------------
 src/goabackend/goaoauthprovider.c  | 17 +++++++++++------
 src/goabackend/goarestproxy.h      |  2 --
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1f88bbd..e43303d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,7 +129,7 @@ if test "$enable_backend" != "no"; then
   AC_SUBST(JSON_GLIB_CFLAGS)
   AC_SUBST(JSON_GLIB_LIBS)
 
-  PKG_CHECK_MODULES(REST, [rest-0.7])
+  PKG_CHECK_MODULES(REST, [rest-1.0])
   AC_SUBST(REST_CFLAGS)
   AC_SUBST(REST_LIBS)
 
diff --git a/src/goabackend/goalastfmprovider.c b/src/goabackend/goalastfmprovider.c
index cb9a6f2..a2db037 100644
--- a/src/goabackend/goalastfmprovider.c
+++ b/src/goabackend/goalastfmprovider.c
@@ -483,18 +483,18 @@ add_account_cb (GoaManager *manager, GAsyncResult *res, gpointer user_data)
 
 static void
 check_cb (RestProxyCall *call,
-          const GError *error,
-          GObject *weak_object,
+          GAsyncResult *result,
           gpointer user_data)
 {
   AddAccountData *data = user_data;
   JsonNode *session;
-  JsonParser *parser;
+  JsonParser *parser = NULL;
   JsonObject *json_obj;
   JsonObject *session_obj;
   const gchar *payload;
 
-  parser = NULL;
+  if (!rest_proxy_call_invoke_finish (call, result, &data->error))
+    goto out;
 
   parser = json_parser_new ();
   payload = rest_proxy_call_get_payload (call);
@@ -562,12 +562,12 @@ on_rest_proxy_call_cancelled_cb (GCancellable *cancellable, RestProxyCall *call)
 }
 
 static void
-lastfm_login (GoaProvider                  *provider,
-              const gchar                  *username,
-              const gchar                  *password,
-              GCancellable                 *cancellable,
-              RestProxyCallAsyncCallback   callback,
-              gpointer                     user_data)
+lastfm_login (GoaProvider          *provider,
+              const gchar          *username,
+              const gchar          *password,
+              GCancellable         *cancellable,
+              GAsyncReadyCallback   callback,
+              gpointer              user_data)
 {
   AddAccountData *data = user_data;
   RestProxyCall *call;
@@ -598,7 +598,7 @@ lastfm_login (GoaProvider                  *provider,
   rest_proxy_call_add_param (call, "api_sig", sig_md5);
   rest_proxy_call_add_param (call, "format", "json");
 
-  rest_proxy_call_async (call, callback, NULL, data, &data->error);
+  rest_proxy_call_invoke_async (call, NULL, callback, data);
 
   g_signal_connect (cancellable, "cancelled", G_CALLBACK (on_rest_proxy_call_cancelled_cb), call);
 
@@ -665,7 +665,7 @@ add_account (GoaProvider    *provider,
                 username,
                 password,
                 data.cancellable,
-                (RestProxyCallAsyncCallback) check_cb,
+                (GAsyncReadyCallback) check_cb,
                 &data);
 
   gtk_widget_set_sensitive (data.connect_button, FALSE);
@@ -819,7 +819,7 @@ refresh_account (GoaProvider    *provider,
                 username,
                 password,
                 data.cancellable,
-                (RestProxyCallAsyncCallback) check_cb,
+                (GAsyncReadyCallback) check_cb,
                 &data);
   gtk_widget_set_sensitive (data.connect_button, FALSE);
   gtk_widget_show (data.progress_grid);
diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c
index 0bfab6b..6a69251 100644
--- a/src/goabackend/goaoauthprovider.c
+++ b/src/goabackend/goaoauthprovider.c
@@ -699,9 +699,15 @@ on_web_view_decide_policy (WebKitWebView            *web_view,
 }
 
 static void
-rest_proxy_call_cb (RestProxyCall *call, const GError *error, GObject *weak_object, gpointer user_data)
+rest_proxy_call_cb (GObject *source, GAsyncResult *result, gpointer user_data)
 {
+  RestProxyCall *call = REST_PROXY_CALL (source);
   IdentifyData *data = user_data;
+
+  if (!rest_proxy_call_invoke_finish (call, result, &data->error))
+    {
+      g_prefix_error (&data->error, _("Error getting a Request Token: "));
+    }
   g_main_loop_quit (data->loop);
 }
 
@@ -768,11 +774,7 @@ get_tokens_and_identity (GoaOAuthProvider *provider,
       for (n = 0; request_params[n] != NULL; n += 2)
         rest_proxy_call_add_param (call, request_params[n], request_params[n+1]);
     }
-  if (!rest_proxy_call_async (call, rest_proxy_call_cb, NULL, &data, &data.error))
-    {
-      g_prefix_error (&data.error, _("Error getting a Request Token: "));
-      goto out;
-    }
+  rest_proxy_call_invoke_async (call, NULL, rest_proxy_call_cb, &data);
 
   goa_utils_set_dialog_title (GOA_PROVIDER (provider), dialog, add_account);
 
@@ -794,6 +796,9 @@ get_tokens_and_identity (GoaOAuthProvider *provider,
   g_main_loop_run (data.loop);
   gtk_container_remove (GTK_CONTAINER (grid), spinner);
 
+  if (data.error)
+    goto out;
+
   if (rest_proxy_call_get_status_code (call) != 200)
     {
       gchar *msg;
diff --git a/src/goabackend/goarestproxy.h b/src/goabackend/goarestproxy.h
index 09fb076..4948cb7 100644
--- a/src/goabackend/goarestproxy.h
+++ b/src/goabackend/goarestproxy.h
@@ -27,8 +27,6 @@
 
 G_BEGIN_DECLS
 
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (RestProxy, g_object_unref);
-
 #define GOA_TYPE_REST_PROXY (goa_rest_proxy_get_type ())
 G_DECLARE_FINAL_TYPE (GoaRestProxy, goa_rest_proxy, GOA, REST_PROXY, RestProxy);