banshee r3322 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler src/Libraries/Lastfm/Lastfm



Author: ahixon
Date: Mon Feb 25 10:21:21 2008
New Revision: 3322
URL: http://svn.gnome.org/viewvc/banshee?rev=3322&view=rev

Log:
2008-02-25  Alexander Hixon  <hixon alexander mediati org>
    * src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs:
      Attempt to queue the currently playing track when we dispose the 
      service, in case it's scrobbable, but the user quit before hitting
      the next button to send it off to the server. It gets queued until
      next start.
    
    * src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs:
      Fix TrackInfoDisplay by making sure we pass the correct EventMasks so
      that we don't bombard the user with cover art on track change, if the
      user had shown the cover art popup previously in the session. Also 
      fixes hiding the cover art popup after the correct amount of time. 
    
    * src/Libraries/Lastfm/Lastfm/RadioConnection.cs:
    * src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs:
    * src/Libraries/Lastfm/Lastfm/LastfmCore.cs: Remove Account from 
      constructors for RadioConnection and AudioscrobblerConnection.
      Also get the Connections to reference LastfmCore.Account rather
      than keeping track of their own copy.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
   trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
   trunk/banshee/src/Libraries/Lastfm/Lastfm/LastfmCore.cs
   trunk/banshee/src/Libraries/Lastfm/Lastfm/RadioConnection.cs

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs	Mon Feb 25 10:21:21 2008
@@ -110,6 +110,8 @@
                 Gdk.EventMask.VisibilityNotifyMask |
                 Gdk.EventMask.ExposureMask |
                 Gdk.EventMask.PointerMotionMask |
+                Gdk.EventMask.EnterNotifyMask |
+                Gdk.EventMask.LeaveNotifyMask |
                 Events);
             
             Gdk.WindowAttributesType attributes_mask = 

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs	Mon Feb 25 10:21:21 2008
@@ -134,8 +134,16 @@
   
         public void Dispose ()
         {
+            // Try and queue the currently playing track just in case it's queueable
+            // but the user hasn't hit next yet and quit/disposed the service.
+            if (ServiceManager.PlayerEngine.CurrentTrack != null) {
+                Queue (ServiceManager.PlayerEngine.CurrentTrack);
+            }
+            
             ServiceManager.PlayerEngine.EventChanged -= OnPlayerEngineEventChanged;
             
+            // When we stop the connection, queue ends up getting saved too, so the
+            // track we queued earlier should stay until next session.
             connection.Stop ();
         
             action_service.UIManager.RemoveUi (ui_manager_id);

Modified: trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs	(original)
+++ trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs	Mon Feb 25 10:21:21 2008
@@ -61,7 +61,6 @@
         const string SCROBBLER_URL = "http://post.audioscrobbler.com/";;
         const string SCROBBLER_VERSION = "1.2";
 
-        Account account;
         string post_url;
         string session_id = null;
         string now_playing_url;
@@ -90,11 +89,9 @@
         IAsyncResult current_async_result;
         State state;
         
-        internal AudioscrobblerConnection (Account account, IQueue queue)
+        internal AudioscrobblerConnection (IQueue queue)
         {
-            this.account = account;
-            
-            account.Updated += AccountUpdated;
+            LastfmCore.Account.Updated += AccountUpdated;
             
             state = State.IDLE;
             this.queue = queue;
@@ -201,7 +198,9 @@
             /* and address changes in our engine state */
             switch (state) {
             case State.IDLE:
-                if (account.UserName != null && account.CryptedPassword != null && session_id == null) {
+                if (LastfmCore.Account.UserName != null &&
+                    LastfmCore.Account.CryptedPassword != null && session_id == null) {
+                    
                     state = State.NEED_HANDSHAKE;
                 } else {
                     if (queue.Count > 0)
@@ -398,13 +397,14 @@
         void Handshake ()
         {
             string timestamp = UnixTime();
-            string security_token = Hyena.CryptoUtil.Md5Encode (account.CryptedPassword + timestamp);
+            string security_token = Hyena.CryptoUtil.Md5Encode
+                (LastfmCore.Account.CryptedPassword + timestamp);
 
             string uri = String.Format ("{0}?hs=true&p={1}&c={2}&v={3}&u={4}&t={5}&a={6}",
                                         SCROBBLER_URL,
                                         SCROBBLER_VERSION,
                                         CLIENT_ID, CLIENT_VERSION,
-                                        HttpUtility.UrlEncode (account.UserName),
+                                        HttpUtility.UrlEncode (LastfmCore.Account.UserName),
                                         timestamp,
                                         security_token);
 

Modified: trunk/banshee/src/Libraries/Lastfm/Lastfm/LastfmCore.cs
==============================================================================
--- trunk/banshee/src/Libraries/Lastfm/Lastfm/LastfmCore.cs	(original)
+++ trunk/banshee/src/Libraries/Lastfm/Lastfm/LastfmCore.cs	Mon Feb 25 10:21:21 2008
@@ -53,7 +53,7 @@
         public static RadioConnection Radio {
             get {
                 if (radio == null) {
-                    radio = new RadioConnection (LastfmCore.Account);
+                    radio = new RadioConnection ();
                 }
                 
                 return radio;
@@ -75,7 +75,7 @@
                             ("Queue instance must be defined before referencing Audioscrobbler.");
                     }
                     
-                    audioscrobbler = new AudioscrobblerConnection (LastfmCore.Account,queue);
+                    audioscrobbler = new AudioscrobblerConnection (queue);
                 }
                 
                 return audioscrobbler;

Modified: trunk/banshee/src/Libraries/Lastfm/Lastfm/RadioConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Lastfm/Lastfm/RadioConnection.cs	(original)
+++ trunk/banshee/src/Libraries/Lastfm/Lastfm/RadioConnection.cs	Mon Feb 25 10:21:21 2008
@@ -90,11 +90,6 @@
         private bool network_connected = false;
 
         private static Regex station_error_regex = new Regex ("error=(\\d+)", RegexOptions.Compiled);
-
-        private Account account;
-        public Account Account {
-            get { return account; }
-        }
         
         private bool subscriber;
         public bool Subscriber {
@@ -130,19 +125,17 @@
             get { return station; }
         }
 
-        internal RadioConnection (Account account)
+        internal RadioConnection ()
         {
-            this.account = account;
-
             Initialize ();
             State = ConnectionState.Disconnected;
 
-            account.Updated += HandleAccountUpdated;
+            LastfmCore.Account.Updated += HandleAccountUpdated;
         }
 
         public void Dispose ()
         {
-            account.Updated -= HandleAccountUpdated;
+            LastfmCore.Account.Updated -= HandleAccountUpdated;
         }
 
         public void Connect ()
@@ -150,7 +143,7 @@
             if (State == ConnectionState.Connecting || State == ConnectionState.Connected)
                 return;
 
-            if (account.UserName == null || account.CryptedPassword == null) {
+            if (LastfmCore.Account.UserName == null || LastfmCore.Account.CryptedPassword == null) {
                 State = ConnectionState.NoAccount;
                 return;
             }
@@ -272,14 +265,14 @@
                         "http://ws.audioscrobbler.com/radio/handshake.php?version={0}&platform={1}&username={2}&passwordmd5={3}&language={4}&session=324234";,
                         "1.1.1",
                         "linux", // FIXME
-                        account.UserName, account.CryptedPassword,
+                        LastfmCore.Account.UserName, LastfmCore.Account.CryptedPassword,
                         "en" // FIXME
                     ));
 
                     // Set us as connecting, assuming the connection attempt wasn't changed out from under us
                     if (ParseHandshake (new StreamReader (stream).ReadToEnd ()) && session != null) {
                         State = ConnectionState.Connected;
-                        Log.Debug (String.Format ("Logged into Last.fm as {0}", account.UserName), null);
+                        Log.Debug (String.Format ("Logged into Last.fm as {0}", LastfmCore.Account.UserName), null);
                         return;
                     }
                 } catch (Exception e) {
@@ -310,7 +303,7 @@
                             Catalog.GetString ("Either your username or password is invalid."),
                             false
                         );
-                        account.CryptedPassword = null;
+                        LastfmCore.Account.CryptedPassword = null;
                         return false;
                     }
 
@@ -493,8 +486,8 @@
         private LameXmlRpcRequest LastFMXmlRpcRequest (string method)
         {
             string time = UnixTime ();
-            string auth_hash = Hyena.CryptoUtil.Md5Encode (account.CryptedPassword + time);
-            return new LameXmlRpcRequest (method).AddStringParams (account.UserName, time, auth_hash);
+            string auth_hash = Hyena.CryptoUtil.Md5Encode (LastfmCore.Account.CryptedPassword + time);
+            return new LameXmlRpcRequest (method).AddStringParams (LastfmCore.Account.UserName, time, auth_hash);
         }
 
         protected class LameXmlRpcRequest



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