[rhythmbox] audioscrobbler: remove scrobbling with password auth support



commit 850a6423e34d0e616769ef2f49d5bf0acfbd3b13
Author: Jamie Nicol <jamie thenicols net>
Date:   Tue Jul 20 12:59:42 2010 +0100

    audioscrobbler: remove scrobbling with password auth support
    
    Didn't need to add this in first place, Libre.fm now supports web service
    auth.

 plugins/audioscrobbler/rb-audioscrobbler.c |   86 ++++++----------------------
 plugins/audioscrobbler/rb-audioscrobbler.h |    5 --
 2 files changed, 17 insertions(+), 74 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler.c b/plugins/audioscrobbler/rb-audioscrobbler.c
index 3e5bb57..8ae5cea 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler.c
@@ -113,7 +113,6 @@ struct _RBAudioscrobblerPrivate
 	gchar *sessionid;
 	gchar *username;
 	gchar *session_key;
-	gchar *password;
 	gchar *submit_url;
 	gchar *nowplaying_url;
 
@@ -190,7 +189,6 @@ enum
 	PROP_SHELL_PLAYER,
 	PROP_USERNAME,
 	PROP_SESSION_KEY,
-	PROP_PASSWORD
 };
 
 enum
@@ -285,14 +283,6 @@ rb_audioscrobbler_class_init (RBAudioscrobblerClass *klass)
 	                                                      NULL,
                                                               G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
-	g_object_class_install_property (object_class,
-	                                 PROP_PASSWORD,
-	                                 g_param_spec_string ("password",
-	                                                      "Password",
-	                                                      "Password used to authenticate the user optionally instead of a session key",
-	                                                      NULL,
-                                                              G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-
 	/**
 	 * RBAudioscrobbler::authentication-error:
 	 * @account: the #RBAudioscrobblerAccount
@@ -350,7 +340,6 @@ rb_audioscrobbler_init (RBAudioscrobbler *audioscrobbler)
 	audioscrobbler->priv->sessionid = g_strdup ("");
 	audioscrobbler->priv->username = NULL;
 	audioscrobbler->priv->session_key = NULL;
-	audioscrobbler->priv->password = NULL;
 	audioscrobbler->priv->submit_url = g_strdup ("");
 	audioscrobbler->priv->nowplaying_url = g_strdup ("");
 }
@@ -420,7 +409,6 @@ rb_audioscrobbler_finalize (GObject *object)
 	g_free (audioscrobbler->priv->sessionid);
 	g_free (audioscrobbler->priv->username);
 	g_free (audioscrobbler->priv->session_key);
-	g_free (audioscrobbler->priv->password);
 	g_free (audioscrobbler->priv->submit_url);
 	g_free (audioscrobbler->priv->nowplaying_url);
 
@@ -449,21 +437,6 @@ rb_audioscrobbler_new (RBAudioscrobblerService *service,
 			     NULL);
 }
 
-/* create a scrobbler which used a password for authentication rather than web auth */
-RBAudioscrobbler *
-rb_audioscrobbler_new_from_password (RBAudioscrobblerService *service,
-                                     RBShellPlayer *shell_player,
-                                     const char *username,
-                                     const char *password)
-{
-	return g_object_new (RB_TYPE_AUDIOSCROBBLER,
-	                     "service", service,
-			     "shell-player", shell_player,
-	                     "username", username,
-	                     "password", password,
-			     NULL);
-}
-
 static void
 rb_audioscrobbler_set_property (GObject *object,
 				guint prop_id,
@@ -490,9 +463,6 @@ rb_audioscrobbler_set_property (GObject *object,
 	case PROP_SESSION_KEY:
 		audioscrobbler->priv->session_key = g_value_dup_string (value);
 		break;
-	case PROP_PASSWORD:
-		audioscrobbler->priv->password = g_value_dup_string (value);
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -853,7 +823,7 @@ rb_audioscrobbler_should_handshake (RBAudioscrobbler *audioscrobbler)
 	 *   - we have waited the appropriate amount of time between
 	 *     handshakes; AND
 	 *   - we have a username; AND
-	 *   - we have a session key OR we have a password
+	 *   - we have a session key
 	 */
 	if (audioscrobbler->priv->handshake) {
 		return FALSE;
@@ -874,11 +844,7 @@ rb_audioscrobbler_should_handshake (RBAudioscrobbler *audioscrobbler)
 
 	if ((audioscrobbler->priv->session_key == NULL) ||
 	    (strcmp (audioscrobbler->priv->session_key, "") == 0)) {
-		if ((audioscrobbler->priv->password == NULL) ||
-		    (strcmp (audioscrobbler->priv->password, "") == 0)) {
-			rb_debug ("No session key or password set");
-			return FALSE;
-		}
+		return FALSE;
 	}
 
 	return TRUE;
@@ -900,39 +866,21 @@ rb_audioscrobbler_do_handshake (RBAudioscrobbler *audioscrobbler)
 	username = soup_uri_encode (audioscrobbler->priv->username, EXTRA_URI_ENCODE_CHARS);
 	timestamp = time (NULL);
 
-	if (audioscrobbler->priv->session_key != NULL) {
-		/* use web services auth */
-		autharg = g_strdup_printf ("%s%d",
-			                   rb_audioscrobbler_service_get_api_secret (audioscrobbler->priv->service),
-			                   timestamp);
-		auth = g_compute_checksum_for_string (G_CHECKSUM_MD5, autharg, -1);
-
-		url = g_strdup_printf ("%s?hs=true&p=%s&c=%s&v=%s&u=%s&t=%d&a=%s&api_key=%s&sk=%s",
-				       rb_audioscrobbler_service_get_scrobbler_url (audioscrobbler->priv->service),
-				       SCROBBLER_VERSION,
-				       CLIENT_ID,
-				       CLIENT_VERSION,
-				       username,
-				       timestamp,
-				       auth,
-			               rb_audioscrobbler_service_get_api_key (audioscrobbler->priv->service),
-			               audioscrobbler->priv->session_key);
-	} else {
-		/* password auth */
-		autharg = g_strdup_printf ("%s%d",
-		                           g_compute_checksum_for_string (G_CHECKSUM_MD5, audioscrobbler->priv->password, 1),
-		                           timestamp);
-		auth = g_compute_checksum_for_string (G_CHECKSUM_MD5, autharg, -1);
-
-		url = g_strdup_printf ("%s?hs=true&p=%s&c=%s&v=%s&u=%s&t=%d&a=%s",
-				       rb_audioscrobbler_service_get_scrobbler_url (audioscrobbler->priv->service),
-				       SCROBBLER_VERSION,
-				       CLIENT_ID,
-				       CLIENT_VERSION,
-				       username,
-				       timestamp,
-				       auth);
-	}
+	autharg = g_strdup_printf ("%s%d",
+		                   rb_audioscrobbler_service_get_api_secret (audioscrobbler->priv->service),
+		                   timestamp);
+	auth = g_compute_checksum_for_string (G_CHECKSUM_MD5, autharg, -1);
+
+	url = g_strdup_printf ("%s?hs=true&p=%s&c=%s&v=%s&u=%s&t=%d&a=%s&api_key=%s&sk=%s",
+			       rb_audioscrobbler_service_get_scrobbler_url (audioscrobbler->priv->service),
+			       SCROBBLER_VERSION,
+			       CLIENT_ID,
+			       CLIENT_VERSION,
+			       username,
+			       timestamp,
+			       auth,
+		               rb_audioscrobbler_service_get_api_key (audioscrobbler->priv->service),
+		               audioscrobbler->priv->session_key);
 
 	g_free (auth);
 	g_free (autharg);
diff --git a/plugins/audioscrobbler/rb-audioscrobbler.h b/plugins/audioscrobbler/rb-audioscrobbler.h
index 98b4dd5..e96fb7e 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler.h
@@ -75,11 +75,6 @@ RBAudioscrobbler *	rb_audioscrobbler_new (RBAudioscrobblerService *service,
                                                const char *username,
                                                const char *session_key);
 
-RBAudioscrobbler *	rb_audioscrobbler_new_from_password (RBAudioscrobblerService *service,
-                                                             RBShellPlayer *shell_player,
-                                                             const char *username,
-                                                             const char *password);
-
 void                    rb_audioscrobbler_statistics_changed (RBAudioscrobbler *audioscrobbler);
 
 



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