[rhythmbox] audioscrobbler: create account login status for connection errors
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: create account login status for connection errors
- Date: Tue, 21 Sep 2010 10:48:35 +0000 (UTC)
commit aa289adb575b2e5af0d8244c9c5e030f3db529bc
Author: Jamie Nicol <jamie thenicols net>
Date: Sat Jun 5 00:47:46 2010 +0100
audioscrobbler: create account login status for connection errors
Occurs when there is an error connecting to last.fm when attempting
to authenticate.
plugins/audioscrobbler/rb-audioscrobbler-account.c | 22 +++++++++++++++++--
plugins/audioscrobbler/rb-audioscrobbler-account.h | 3 +-
.../rb-audioscrobbler-profile-source.c | 7 ++++++
3 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-account.c b/plugins/audioscrobbler/rb-audioscrobbler-account.c
index 9892d32..cc0bd26 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-account.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-account.c
@@ -542,8 +542,14 @@ rb_audioscrobbler_account_got_token_cb (SoupSession *session,
g_strfreev (post_split);
g_free (url);
} else {
- /* failed. go back to being logged out */
- rb_audioscrobbler_account_logout (account);
+ /* failed. report connection error */
+ rb_debug ("connection error attempting to retrieve auth token");
+
+ rb_audioscrobbler_account_cancel_session (account);
+
+ account->priv->login_status = RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_CONNECTION_ERROR;
+ g_signal_emit (account, rb_audioscrobbler_account_signals[LOGIN_STATUS_CHANGED],
+ 0, account->priv->login_status);
}
}
@@ -635,7 +641,7 @@ rb_audioscrobbler_account_got_session_key_cb (SoupSession *session,
account->priv->login_status = RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_IN;
g_signal_emit (account, rb_audioscrobbler_account_signals[LOGIN_STATUS_CHANGED],
0, account->priv->login_status);
- } else {
+ } else if (msg->response_body->length != 0) {
char **pre_split;
char **post_split;
char *error;
@@ -659,6 +665,15 @@ rb_audioscrobbler_account_got_session_key_cb (SoupSession *session,
g_strfreev (pre_split);
g_strfreev (post_split);
g_free (error);
+ } else {
+ /* connection error */
+ rb_debug ("connection error attempting to retrieve session key");
+
+ rb_audioscrobbler_account_cancel_session (account);
+
+ account->priv->login_status = RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_CONNECTION_ERROR;
+ g_signal_emit (account, rb_audioscrobbler_account_signals[LOGIN_STATUS_CHANGED],
+ 0, account->priv->login_status);
}
}
@@ -676,6 +691,7 @@ rb_audioscrobbler_account_login_status_get_type (void)
ENUM_ENTRY (RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGING_IN, "Logging in"),
ENUM_ENTRY (RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_IN, "Logged in"),
ENUM_ENTRY (RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_AUTH_ERROR, "Authentication Error"),
+ ENUM_ENTRY (RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_CONNECTION_ERROR, "Connection Error"),
{ 0, 0, 0 }
};
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-account.h b/plugins/audioscrobbler/rb-audioscrobbler-account.h
index fc56b3d..37b6561 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-account.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-account.h
@@ -39,7 +39,8 @@ typedef enum
RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_OUT,
RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGING_IN,
RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_IN,
- RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_AUTH_ERROR
+ RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_AUTH_ERROR,
+ RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_CONNECTION_ERROR
} RBAudioscrobblerAccountLoginStatus;
GType rb_audioscrobbler_account_login_status_get_type (void);
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index 7070631..e642380 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -245,6 +245,7 @@ rb_audioscrobbler_profile_source_login_bar_response (GtkInfoBar *info_bar,
switch (status) {
case RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_OUT:
case RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_AUTH_ERROR:
+ case RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_CONNECTION_ERROR:
rb_audioscrobbler_account_authenticate (source->priv->account);
break;
case RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGING_IN:
@@ -303,6 +304,12 @@ rb_audioscrobbler_profile_source_login_status_change_cb (RBAudioscrobblerAccount
button_text = g_strdup (_("Login"));
gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->login_bar), GTK_MESSAGE_WARNING);
break;
+ case RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_CONNECTION_ERROR:
+ gtk_widget_show_all (source->priv->login_bar);
+ label_text = g_strdup (_("Connection error. Please try logging in again."));
+ button_text = g_strdup (_("Login"));
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->login_bar), GTK_MESSAGE_WARNING);
+ break;
default:
g_assert_not_reached ();
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]