[gnome-software/wip/attente/ubuntu-xenial: 6/9] Simplify U1 request call



commit 7e315c3bdf2f48456d4cf239c9ddb7127f0df600
Author: William Hua <william hua canonical com>
Date:   Sun Apr 17 10:05:04 2016 -0400

    Simplify U1 request call

 src/plugins/gs-ubuntuone-dialog.c |   46 ++++++++++++++++---------------------
 1 files changed, 20 insertions(+), 26 deletions(-)
---
diff --git a/src/plugins/gs-ubuntuone-dialog.c b/src/plugins/gs-ubuntuone-dialog.c
index 52132cc..7adfb91 100644
--- a/src/plugins/gs-ubuntuone-dialog.c
+++ b/src/plugins/gs-ubuntuone-dialog.c
@@ -284,6 +284,8 @@ receive_login_response_cb (GsUbuntuoneDialog *self,
 static void
 send_login_request (GsUbuntuoneDialog *self)
 {
+       GVariant *request;
+
        gtk_widget_set_sensitive (self->cancel_button, FALSE);
        gtk_widget_set_sensitive (self->next_button, FALSE);
        gtk_widget_set_sensitive (self->login_radio, FALSE);
@@ -297,34 +299,26 @@ send_login_request (GsUbuntuoneDialog *self)
        show_status (self, _("Signing in…"), FALSE);
 
        if (gtk_entry_get_text_length (GTK_ENTRY (self->passcode_entry)) > 0) {
-               send_request (self,
-                             SOUP_METHOD_POST,
-                             "/api/v2/tokens/oauth",
-                             g_variant_new_parsed ("{"
-                                                   "  'token_name' : <'GNOME Software'>,"
-                                                   "  'email' : <%s>,"
-                                                   "  'password' : <%s>,"
-                                                   "  'otp' : <%s>"
-                                                   "}",
-                                                   gtk_entry_get_text (GTK_ENTRY (self->email_entry)),
-                                                   gtk_entry_get_text (GTK_ENTRY (self->password_entry)),
-                                                   gtk_entry_get_text (GTK_ENTRY (self->passcode_entry))),
-                             receive_login_response_cb,
-                             NULL);
+               request = g_variant_new_parsed ("{"
+                                               "  'token_name' : <'GNOME Software'>,"
+                                               "  'email' : <%s>,"
+                                               "  'password' : <%s>,"
+                                               "  'otp' : <%s>"
+                                               "}",
+                                               gtk_entry_get_text (GTK_ENTRY (self->email_entry)),
+                                               gtk_entry_get_text (GTK_ENTRY (self->password_entry)),
+                                               gtk_entry_get_text (GTK_ENTRY (self->passcode_entry)));
        } else {
-               send_request (self,
-                             SOUP_METHOD_POST,
-                             "/api/v2/tokens/oauth",
-                             g_variant_new_parsed ("{"
-                                                   "  'token_name' : <'GNOME Software'>,"
-                                                   "  'email' : <%s>,"
-                                                   "  'password' : <%s>"
-                                                   "}",
-                                                   gtk_entry_get_text (GTK_ENTRY (self->email_entry)),
-                                                   gtk_entry_get_text (GTK_ENTRY (self->password_entry))),
-                             receive_login_response_cb,
-                             NULL);
+               request = g_variant_new_parsed ("{"
+                                               "  'token_name' : <'GNOME Software'>,"
+                                               "  'email' : <%s>,"
+                                               "  'password' : <%s>"
+                                               "}",
+                                               gtk_entry_get_text (GTK_ENTRY (self->email_entry)),
+                                               gtk_entry_get_text (GTK_ENTRY (self->password_entry)));
        }
+
+       send_request (self, SOUP_METHOD_POST, "/api/v2/tokens/oauth", request, receive_login_response_cb, 
NULL);
 }
 
 static void


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