[gnome-software/wip/temp/ubuntu-xenial-rebased: 324/329] Guard against review server errors
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased: 324/329] Guard against review server errors
- Date: Fri, 29 Apr 2016 14:12:36 +0000 (UTC)
commit 87f4645b1960e7b56911347c1be5586b3cb796ac
Author: William Hua <william hua canonical com>
Date: Thu Apr 28 14:52:30 2016 +0200
Guard against review server errors
src/plugins/gs-ubuntuone-dialog.c | 112 ++++++++++++++++++++-----------------
1 files changed, 60 insertions(+), 52 deletions(-)
---
diff --git a/src/plugins/gs-ubuntuone-dialog.c b/src/plugins/gs-ubuntuone-dialog.c
index 8261de7..7659de8 100644
--- a/src/plugins/gs-ubuntuone-dialog.c
+++ b/src/plugins/gs-ubuntuone-dialog.c
@@ -130,7 +130,9 @@ response_received_cb (SoupSession *session,
NULL);
body = g_bytes_unref_to_data (bytes, &length);
- response = json_gvariant_deserialize_data (body, length, NULL, NULL);
+
+ if (body)
+ response = json_gvariant_deserialize_data (body, length, NULL, NULL);
if (response)
g_variant_ref_sink (response);
@@ -228,65 +230,71 @@ receive_login_response_cb (GsUbuntuoneDialog *self,
reenable_widgets (self);
- switch (status) {
- case SOUP_STATUS_OK:
- case SOUP_STATUS_CREATED:
- g_clear_pointer (&self->token_secret, g_free);
- g_clear_pointer (&self->token_key, g_free);
- g_clear_pointer (&self->consumer_secret, g_free);
- g_clear_pointer (&self->consumer_key, g_free);
-
- g_variant_lookup (response, "consumer_key", "s", &self->consumer_key);
- g_variant_lookup (response, "consumer_secret", "s", &self->consumer_secret);
- g_variant_lookup (response, "token_key", "s", &self->token_key);
- g_variant_lookup (response, "token_secret", "s", &self->token_secret);
+ if (response) {
+ switch (status) {
+ case SOUP_STATUS_OK:
+ case SOUP_STATUS_CREATED:
+ g_clear_pointer (&self->token_secret, g_free);
+ g_clear_pointer (&self->token_key, g_free);
+ g_clear_pointer (&self->consumer_secret, g_free);
+ g_clear_pointer (&self->consumer_key, g_free);
+
+ g_variant_lookup (response, "consumer_key", "s", &self->consumer_key);
+ g_variant_lookup (response, "consumer_secret", "s", &self->consumer_secret);
+ g_variant_lookup (response, "token_key", "s", &self->token_key);
+ g_variant_lookup (response, "token_secret", "s", &self->token_secret);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (self->page_stack), "page-2");
+ update_widgets (self);
+ break;
- gtk_stack_set_visible_child_name (GTK_STACK (self->page_stack), "page-2");
- update_widgets (self);
- break;
+ default:
+ g_variant_lookup (response, "code", "&s", &code);
- default:
- g_variant_lookup (response, "code", "&s", &code);
+ if (!code)
+ code = "";
- if (!code)
- code = "";
+ if (g_str_equal (code, "TWOFACTOR_REQUIRED")) {
+ gtk_stack_set_visible_child_name (GTK_STACK (self->page_stack), "page-1");
+ gtk_widget_grab_focus (self->passcode_entry);
+ update_widgets (self);
+ break;
+ }
- if (g_str_equal (code, "TWOFACTOR_REQUIRED")) {
- gtk_stack_set_visible_child_name (GTK_STACK (self->page_stack), "page-1");
- gtk_widget_grab_focus (self->passcode_entry);
update_widgets (self);
- break;
- }
- update_widgets (self);
+ if (g_str_equal (code, "INVALID_CREDENTIALS")) {
+ show_status (self, _("Incorrect email or password"), TRUE);
+ gtk_widget_grab_focus (self->password_entry);
+ } else if (g_str_equal (code, "ACCOUNT_SUSPENDED")) {
+ show_status (self, _("Account suspended"), TRUE);
+ gtk_widget_grab_focus (self->email_entry);
+ } else if (g_str_equal (code, "ACCOUNT_DEACTIVATED")) {
+ show_status (self, _("Account deactivated"), TRUE);
+ gtk_widget_grab_focus (self->email_entry);
+ } else if (g_str_equal (code, "EMAIL_INVALIDATED")) {
+ show_status (self, _("Email invalidated"), TRUE);
+ gtk_widget_grab_focus (self->email_entry);
+ } else if (g_str_equal (code, "TWOFACTOR_FAILURE")) {
+ show_status (self, _("Two-factor authentication failed"), TRUE);
+ gtk_widget_grab_focus (self->passcode_entry);
+ } else if (g_str_equal (code, "PASSWORD_POLICY_ERROR")) {
+ show_status (self, _("Password reset required"), TRUE);
+ gtk_widget_grab_focus (self->reset_radio);
+ } else if (g_str_equal (code, "TOO_MANY_REQUESTS")) {
+ show_status (self, _("Too many requests"), TRUE);
+ gtk_widget_grab_focus (self->password_entry);
+ } else {
+ show_status (self, _("An error occurred"), TRUE);
+ gtk_widget_grab_focus (self->password_entry);
+ }
- if (g_str_equal (code, "INVALID_CREDENTIALS")) {
- show_status (self, _("Incorrect email or password"), TRUE);
- gtk_widget_grab_focus (self->password_entry);
- } else if (g_str_equal (code, "ACCOUNT_SUSPENDED")) {
- show_status (self, _("Account suspended"), TRUE);
- gtk_widget_grab_focus (self->email_entry);
- } else if (g_str_equal (code, "ACCOUNT_DEACTIVATED")) {
- show_status (self, _("Account deactivated"), TRUE);
- gtk_widget_grab_focus (self->email_entry);
- } else if (g_str_equal (code, "EMAIL_INVALIDATED")) {
- show_status (self, _("Email invalidated"), TRUE);
- gtk_widget_grab_focus (self->email_entry);
- } else if (g_str_equal (code, "TWOFACTOR_FAILURE")) {
- show_status (self, _("Two-factor authentication failed"), TRUE);
- gtk_widget_grab_focus (self->passcode_entry);
- } else if (g_str_equal (code, "PASSWORD_POLICY_ERROR")) {
- show_status (self, _("Password reset required"), TRUE);
- gtk_widget_grab_focus (self->reset_radio);
- } else if (g_str_equal (code, "TOO_MANY_REQUESTS")) {
- show_status (self, _("Too many requests"), TRUE);
- gtk_widget_grab_focus (self->password_entry);
- } else {
- show_status (self, _("An error occurred"), TRUE);
- gtk_widget_grab_focus (self->password_entry);
+ break;
}
-
- break;
+ } else {
+ update_widgets (self);
+ show_status (self, _("An error occurred"), TRUE);
+ gtk_widget_grab_focus (self->password_entry);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]