[gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 276/331] Don't re-prompt for credentials after cancellation



commit 33361f1538ece6460d2d702cef5b658bdab94ef3
Author: William Hua <william hua canonical com>
Date:   Tue Apr 19 08:35:51 2016 -0400

    Don't re-prompt for credentials after cancellation

 src/plugins/gs-plugin-snappy.c    |   11 +++++------
 src/plugins/gs-ubuntu-snapd.c     |   10 +++++++++-
 src/plugins/gs-ubuntu-snapd.h     |    1 +
 src/plugins/gs-ubuntuone-dialog.c |    1 +
 4 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snappy.c b/src/plugins/gs-plugin-snappy.c
index 7dc6ca9..76035f8 100644
--- a/src/plugins/gs-plugin-snappy.c
+++ b/src/plugins/gs-plugin-snappy.c
@@ -131,7 +131,7 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package)
                g_autofree gchar *icon_response = NULL;
                gsize icon_response_length;
 
-               if (send_snapd_request ("GET", icon_url, NULL, TRUE, NULL, TRUE, NULL, NULL, NULL, 
&icon_response, &icon_response_length, NULL)) {
+               if (send_snapd_request ("GET", icon_url, NULL, TRUE, NULL, TRUE, NULL, NULL, NULL, NULL, 
&icon_response, &icon_response_length, NULL)) {
                        g_autoptr(GdkPixbufLoader) loader = NULL;
 
                        loader = gdk_pixbuf_loader_new ();
@@ -199,7 +199,7 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
                g_string_append (path, fields);
        }
        g_ptr_array_free (query_fields, TRUE);
-       if (!send_snapd_request ("GET", path->str, NULL, TRUE, NULL, TRUE, &status_code, &reason_phrase, 
&response_type, &response, NULL, error))
+       if (!send_snapd_request ("GET", path->str, NULL, TRUE, NULL, TRUE, NULL, &status_code, 
&reason_phrase, &response_type, &response, NULL, error))
                return FALSE;
 
        if (status_code != SOUP_STATUS_OK) {
@@ -292,7 +292,7 @@ get_app (GsPlugin *plugin, GsApp *app, GError **error)
        JsonObject *root, *result;
 
        path = g_strdup_printf ("/v2/snaps/%s", gs_app_get_id (app));
-       if (!send_snapd_request ("GET", path, NULL, TRUE, NULL, TRUE, &status_code, &reason_phrase, 
&response_type, &response, NULL, error))
+       if (!send_snapd_request ("GET", path, NULL, TRUE, NULL, TRUE, NULL, &status_code, &reason_phrase, 
&response_type, &response, NULL, error))
                return FALSE;
 
        if (status_code != SOUP_STATUS_OK) {
@@ -391,10 +391,9 @@ send_package_action (GsPlugin *plugin, GsApp *app, const char *id, const gchar *
        const gchar *change_id;
        g_autoptr(GVariant) macaroon = NULL;
 
-       macaroon = gs_ubuntuone_get_macaroon (TRUE, TRUE, NULL);
        content = g_strdup_printf ("{\"action\": \"%s\"}", action);
        path = g_strdup_printf ("/v2/snaps/%s", id);
-       if (!send_snapd_request ("POST", path, content, TRUE, macaroon, TRUE, &status_code, &reason_phrase, 
&response_type, &response, NULL, error))
+       if (!send_snapd_request ("POST", path, content, TRUE, NULL, TRUE, &macaroon, &status_code, 
&reason_phrase, &response_type, &response, NULL, error))
                return FALSE;
 
        if (status_code != SOUP_STATUS_ACCEPTED) {
@@ -423,7 +422,7 @@ send_package_action (GsPlugin *plugin, GsApp *app, const char *id, const gchar *
                        /* Wait for a little bit before polling */
                        g_usleep (100 * 1000);
 
-                       if (!send_snapd_request ("GET", resource_path, NULL, TRUE, macaroon, TRUE,
+                       if (!send_snapd_request ("GET", resource_path, NULL, TRUE, macaroon, TRUE, NULL,
                                                 &status_code, &status_reason_phrase, &status_response_type,
                                                 &status_response, NULL, error)) {
                                return FALSE;
diff --git a/src/plugins/gs-ubuntu-snapd.c b/src/plugins/gs-ubuntu-snapd.c
index 049ffab..708de84 100644
--- a/src/plugins/gs-ubuntu-snapd.c
+++ b/src/plugins/gs-ubuntu-snapd.c
@@ -79,6 +79,7 @@ send_snapd_request (const gchar  *method,
                    gboolean      authenticate,
                    GVariant     *macaroon,
                    gboolean      retry_after_login,
+                   GVariant    **out_macaroon,
                    guint        *status_code,
                    gchar       **reason_phrase,
                    gchar       **response_type,
@@ -188,6 +189,7 @@ send_snapd_request (const gchar  *method,
                                          TRUE,
                                          macaroon,
                                          FALSE,
+                                         NULL,
                                          status_code,
                                          reason_phrase,
                                          response_type,
@@ -195,7 +197,11 @@ send_snapd_request (const gchar  *method,
                                          response_length,
                                          error);
 
-               g_variant_unref (macaroon);
+               if (ret && out_macaroon != NULL) {
+                       *out_macaroon = macaroon;
+               } else {
+                       g_variant_unref (macaroon);
+               }
 
                return ret;
        }
@@ -249,6 +255,8 @@ send_snapd_request (const gchar  *method,
                if (!read_from_snapd (socket, data, n_required - data_length, &data_length, error))
                        return FALSE;
 
+       if (out_macaroon != NULL)
+               *out_macaroon = g_variant_ref (macaroon);
        if (response_type)
                *response_type = g_strdup (soup_message_headers_get_one (headers, "Content-Type"));
        if (response) {
diff --git a/src/plugins/gs-ubuntu-snapd.h b/src/plugins/gs-ubuntu-snapd.h
index 34e8b0c..cbc1e1a 100644
--- a/src/plugins/gs-ubuntu-snapd.h
+++ b/src/plugins/gs-ubuntu-snapd.h
@@ -30,6 +30,7 @@ gboolean send_snapd_request (const gchar  *method,
                             gboolean      authenticate,
                             GVariant     *macaroon,
                             gboolean      retry_after_login,
+                            GVariant    **out_macaroon,
                             guint        *status_code,
                             gchar       **reason_phrase,
                             gchar       **response_type,
diff --git a/src/plugins/gs-ubuntuone-dialog.c b/src/plugins/gs-ubuntuone-dialog.c
index 54d4666..1da752e 100644
--- a/src/plugins/gs-ubuntuone-dialog.c
+++ b/src/plugins/gs-ubuntuone-dialog.c
@@ -415,6 +415,7 @@ send_login_request (GsUbuntuoneDialog *self)
                                        FALSE,
                                        NULL,
                                        FALSE,
+                                       NULL,
                                        &status_code,
                                        &reason_phrase,
                                        &response_type,


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