Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Beta 3.1 - Various bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
zkhcohen committed Apr 11, 2021
1 parent 1460a63 commit 7c3b1a3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 92 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ CHANGE LOG:

Release 2.0: Improved performance. Removed 500 album restriction. Added automatic prompt to re-authenticate if computer resumes from sleep.
Release 2.0.2: Fixed error log spam.
Beta 3.1: Upgraded all API methods to 6.x.x spec. Implemented PKCE auth method with token persistence and automatic renewal. General speed improvements.
Release 3.0.5: Upgraded all API methods to 6.x.x spec. Implemented PKCE auth method with token persistence and automatic renewal. General speed improvements.
Beta 3.1: Bug fixes for network disconnections, refreshing, various other things.
Binary file modified Plugins/SpotifyAPI.Web.Auth.dll
Binary file not shown.
Binary file modified Plugins/SpotifyAPI.Web.dll
Binary file not shown.
Binary file modified Plugins/mb_Spotify-Plugin.dll
Binary file not shown.
53 changes: 7 additions & 46 deletions Source Files/PanelInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ public partial class Plugin
private PluginInfo about = new PluginInfo();
private Control panel;
public int panelHeight;
private static string _searchTerm;
private static string _searchTerm, _path;
private bool _runOnce = true;
Font largeBold, smallRegular, smallBold;
private RSACryptoServiceProvider _rsaKey;

// Create a new CspParameters object to specify a key container.
CspParameters _cspParams = new CspParameters();

public PluginInfo Initialise(IntPtr apiInterfacePtr)
Expand All @@ -34,23 +32,17 @@ public PluginInfo Initialise(IntPtr apiInterfacePtr)
about.TargetApplication = "Spotify Plugin";
about.Type = PluginType.PanelView;
about.VersionMajor = 3;
about.VersionMinor = 0;
about.Revision = 5;
about.VersionMinor = 1;
about.Revision = 0;
about.MinInterfaceVersion = MinInterfaceVersion;
about.MinApiRevision = MinApiRevision;
about.ReceiveNotifications = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);
about.ConfigurationPanelHeight = 0;

_path = mbApiInterface.Setting_GetPersistentStoragePath() + "token.xml";

_cspParams.KeyContainerName = "SPOTIFY_XML_ENC_RSA_KEY";

// Create a new RSA key and save it in the container. This key will encrypt
// a symmetric key, which will then be encrypted in the XML document.
_rsaKey = new RSACryptoServiceProvider(_cspParams);

//SystemEvents.PowerModeChanged += OnPowerChange;

return about;
}

Expand All @@ -59,7 +51,6 @@ public int OnDockablePanelCreated(Control panel)

float dpiScaling = 0;


largeBold = new Font(panel.Font.FontFamily, 9, FontStyle.Bold);
smallRegular = new Font(panel.Font.FontFamily, 8);
smallBold = new Font(panel.Font.FontFamily, 8, FontStyle.Bold);
Expand All @@ -69,21 +60,20 @@ public int OnDockablePanelCreated(Control panel)

this.panel = panel;
panelHeight = Convert.ToInt32(145 * dpiScaling);

return panelHeight;

}

public string Truncate(string text, Font font)
{

if (TextRenderer.MeasureText(text + "...", font).Width < panel.Width)
{

return text;

}
else
{

int i = text.Length;
while (TextRenderer.MeasureText(text + "...", font).Width > panel.Width)
{
Expand All @@ -110,14 +100,13 @@ private void DrawPanel(object sender, PaintEventArgs e)
{
SpotifyWebAuth();
_trackMissing = 1;
mbApiInterface.MB_RefreshPanels();
panel.Invalidate();
_runOnce = false;
}

// re-draws when file is found?
if (_auth == 1 && _trackMissing != 1)
{
//MessageBox.Show("Drawing.");

TextRenderer.DrawText(e.Graphics, _title, largeBold, new Point(5, 10), text1);
TextRenderer.DrawText(e.Graphics, _artist, smallRegular, new Point(5, 30), text1);
Expand Down Expand Up @@ -162,16 +151,11 @@ private void DrawPanel(object sender, PaintEventArgs e)
}
else if (_auth == 1 && _trackMissing == 1)
{

//MessageBox.Show("Drawing.");
TextRenderer.DrawText(e.Graphics, "No Track Found!", new Font(panel.Font.FontFamily, 12), new Point(5, 70), text1);

}
else if (_auth == 0)
{
//MessageBox.Show("Drawing.");
TextRenderer.DrawText(e.Graphics, "Please Click Here to \nAuthenticate Spotify.", new Font(panel.Font.FontFamily, 14), new Point(4, 50), text1);

}

}
Expand All @@ -188,23 +172,12 @@ public List<ToolStripItem> GetMenuItems()
return list;
}

//private void OnPowerChange(object s, PowerModeChangedEventArgs e)
//{
// switch (e.Mode)
// {
// case PowerModes.Resume:

// _auth = 0;

// break;
// }
//}

public void reAuthSpotify(object sender, EventArgs e)
{
File.Delete(_path);
SpotifyWebAuth();
_trackMissing = 1;
mbApiInterface.MB_RefreshPanels();
panel.Invalidate();
}

Expand All @@ -220,7 +193,6 @@ private void PanelClick(object sender, EventArgs e)
_trackMissing = 1;

panel.Invalidate();
//panel.Paint += DrawPanel;

}
else if (_auth == 1 && me.Button == System.Windows.Forms.MouseButtons.Left)
Expand All @@ -238,13 +210,11 @@ private void PanelClick(object sender, EventArgs e)
{
UnfollowArtist();
panel.Invalidate();
//panel.Paint += DrawPanel;
}
else
{
FollowArtist();
panel.Invalidate();
//panel.Paint += DrawPanel;
}

}
Expand All @@ -255,13 +225,11 @@ private void PanelClick(object sender, EventArgs e)
{
RemoveAlbum();
panel.Invalidate();
//panel.Paint += DrawPanel;
}
else
{
SaveAlbum();
panel.Invalidate();
//panel.Paint += DrawPanel;
}

}
Expand All @@ -272,21 +240,17 @@ private void PanelClick(object sender, EventArgs e)
{
RemoveTrack();
panel.Invalidate();
//panel.Paint += DrawPanel;
}
else
{
SaveTrack();
panel.Invalidate();
//panel.Paint += DrawPanel;
}

}


}


}

public async void ReceiveNotification(string sourceFileUrl, NotificationType type)
Expand All @@ -308,7 +272,6 @@ public async void ReceiveNotification(string sourceFileUrl, NotificationType typ
}

panel.Invalidate();

break;

}
Expand All @@ -321,12 +284,10 @@ public bool Configure(IntPtr panelHandle)

public void SaveSettings()
{

}

public void Close(PluginCloseReason reason)
{
//SystemEvents.PowerModeChanged -= OnPowerChange;
}

public void Uninstall()
Expand Down
4 changes: 2 additions & 2 deletions Source Files/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.5.0")]
[assembly: AssemblyFileVersion("3.0.5.0")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.0.0")]
Loading

0 comments on commit 7c3b1a3

Please sign in to comment.