27 Commits

Author SHA1 Message Date
EnderIce2
bf44bd1076 Updated for SDRSharp 1811 2021-05-10 13:22:46 +03:00
EnderIce2
0b51536839 2021-05-05 08:44:07 +03:00
EnderIce2
4753a7849b 2021-04-30 02:27:41 +03:00
EnderIce2
4913bb45c4 2021-04-30 01:59:24 +03:00
EnderIce2
a1a66c3dd1 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2021-04-29 23:53:59 +03:00
EnderIce2
7d2a7d3dc0 2021-04-29 23:48:16 +03:00
Alex
f9fdaa969e Update LICENSE 2021-04-29 23:17:53 +03:00
Alex
e008886fd7 Update README.md 2021-04-28 17:09:12 +03:00
Alex
071c1071df Update README.md 2021-04-28 16:52:34 +03:00
Alex
e0b304b2a2 Merge pull request #1 from codacy-badger/codacy-badge
Add a Codacy badge to README.md
2021-04-28 16:51:06 +03:00
The Codacy Badger
e67214c4b9 Add Codacy badge 2021-04-28 13:48:25 +00:00
EnderIce2
59fda87954 Code Quality 2021-04-23 21:34:39 +03:00
Alex
54c8969d2b Update README.md 2021-04-23 02:37:56 +03:00
Alex
0cd9bb75fc typo 2021-03-09 08:43:13 +02:00
Alex
d8711ff1bc Update README.md 2020-11-11 01:51:50 +02:00
EnderIce2
ab06d0167b Minor tweak 2020-11-05 19:57:53 +02:00
EnderIce2
ad8cd96c55 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2020-10-26 16:11:43 +02:00
EnderIce2
76d8a1e640 Typo 2020-10-26 16:11:20 +02:00
Alex
85d99f1d0c Adding "Plugin Log" 2020-10-26 09:25:20 +02:00
EnderIce2
131fc8dc10 Merge branch 'master' of https://github.com/EnderIce2/SDR-RPC 2020-10-26 08:42:38 +02:00
EnderIce2
f69b5e623b Fixed showing wrong version 2020-10-26 08:42:26 +02:00
Alex
902086f99a Added emojis 2020-10-26 03:18:22 +02:00
Alex
fb8c9e6c93 Update README.md 2020-10-26 03:13:25 +02:00
Alex
03aad884dd Fixing images 2020-10-26 03:12:27 +02:00
Alex
411f606bfc Add files via upload 2020-10-26 03:08:24 +02:00
Alex
0c844e8ee6 Create README.md 2020-10-26 03:08:03 +02:00
Alex
c7cdd07ba0 Update README.md 2020-10-26 03:01:16 +02:00
16 changed files with 186 additions and 52 deletions

View File

@@ -28,5 +28,8 @@ If applicable, add screenshots to help explain your problem.
- Plugin Version [e.g. 1.2] - Plugin Version [e.g. 1.2]
- SDR# Version [e.g. revision 1770 4698f0a] - SDR# Version [e.g. revision 1770 4698f0a]
**Plugin Log**
A copy of \RPCLogs\DiscordRPCLog_XX.XX.XXXX.log on https://pastebin.com or other copy-paste website.
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

1
.github/MEDIA/README.md vendored Normal file
View File

@@ -0,0 +1 @@
# Files for README.md

View File

@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
SDR-RPC | Plugin for SDRSharp Software adding Discord Rich Presence SDR-RPC | Plugin for SDRSharp Software adding Discord Rich Presence
Copyright (C) 2020 Albu Alexandru Gabriel Copyright (C) 2021 Albu Alexandru Gabriel
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode: notice like this when it starts in an interactive mode:
SDR-RPC Copyright (C) 2020 Albu Alexandru Gabriel SDR-RPC Copyright (C) 2021 Albu Alexandru Gabriel
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.

View File

@@ -8,7 +8,10 @@ namespace EnderIce2.SDRSharpPlugin
public static void WriteToFile(string Message) public static void WriteToFile(string Message)
{ {
if (!SDRSharp.Radio.Utils.GetBooleanSetting("LogRPC", false)) if (!SDRSharp.Radio.Utils.GetBooleanSetting("LogRPC", false))
{
return; return;
}
string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\"; string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\";
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {

View File

@@ -14,17 +14,14 @@ namespace EnderIce2.SDRSharpPlugin
{ {
private const string _displayName = "Discord RPC"; private const string _displayName = "Discord RPC";
private SettingsPanel _controlPanel; private SettingsPanel _controlPanel;
private const LogLevel logLevel = LogLevel.Trace;
private const int discordPipe = -1;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
private static LogLevel logLevel = LogLevel.Trace; bool RPCalreadyLoaded;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
private static int discordPipe = -1;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
bool RPCalreadyLoaded = false;
private ISharpControl _control; private ISharpControl _control;
bool playedBefore = false; bool playedBefore;
private IConfigurationPanelProvider configurationPanelProvider; //private SDRSharp.FrontEnds.SpyServer.ControllerPanel controllerPanel;
private SDRSharp.FrontEnds.SpyServer.ControllerPanel controllerPanel; private TopWindowMessages windowMessages;
public TopWindowMessages windowMessages;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
private RichPresence presence = new RichPresence() private RichPresence presence = new RichPresence()
{ {
@@ -35,39 +32,37 @@ namespace EnderIce2.SDRSharpPlugin
LargeImageKey = "image_large", LargeImageKey = "image_large",
LargeImageText = "SDRSharp", LargeImageText = "SDRSharp",
SmallImageKey = "image_small", SmallImageKey = "image_small",
SmallImageText = $"SDR-RPC plugin v{Assembly.GetEntryAssembly().GetName().Version} by EnderIce2" SmallImageText = $"SDR-RPC plugin v{Assembly.LoadFrom("SDR-RPC.dll").GetName().Version} by EnderIce2" // should show the correct version
} }
}; };
private static DiscordRpcClient client; private DiscordRpcClient client;
private static bool isRunning = true; private bool isRunning = true;
public string DisplayName public string DisplayName => _displayName;
{ public bool HasGui => true;
get { return _displayName; } public UserControl Gui => _controlPanel;
}
public bool HasGui
{
get { return true; }
}
public UserControl Gui
{
get { return _controlPanel; }
}
public void Initialize(ISharpControl control) public void Initialize(ISharpControl control)
{ {
IConfigurationPanelProvider configurationPanelProvider;
if (Utils.GetBooleanSetting("ShowWelcomePage", true)) if (Utils.GetBooleanSetting("ShowWelcomePage", true))
{
new WelcomeForm().ShowDialog(); new WelcomeForm().ShowDialog();
}
_controlPanel = new SettingsPanel(); _controlPanel = new SettingsPanel();
windowMessages = new TopWindowMessages(); // TODO: do something when "EnableRPCInvite" is set to false windowMessages = new TopWindowMessages(); // TODO: do something when "EnableRPCInvite" is set to false
_control = control; _control = control;
try try
{ {
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
_control.RegisterFrontControl(windowMessages, PluginPosition.Top); _control.RegisterFrontControl(windowMessages, PluginPosition.Top);
} }
}
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.ToString()); MessageBox.Show(ex.ToString());
} }
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{ {
presence.Secrets = new Secrets() presence.Secrets = new Secrets()
@@ -81,8 +76,12 @@ namespace EnderIce2.SDRSharpPlugin
Max = 100 Max = 100
}; };
} }
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
windowMessages.Show(); windowMessages.Show();
}
if (Utils.GetBooleanSetting("EnableRPC", true)) if (Utils.GetBooleanSetting("EnableRPC", true))
{ {
if (RPCalreadyLoaded) if (RPCalreadyLoaded)
@@ -91,15 +90,20 @@ namespace EnderIce2.SDRSharpPlugin
return; return;
} }
if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18) if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18)
{
client = new DiscordRpcClient("765213507321856078", pipe: discordPipe) client = new DiscordRpcClient("765213507321856078", pipe: discordPipe)
{ {
Logger = new ConsoleLogger(logLevel, true) Logger = new ConsoleLogger(logLevel, true)
}; };
}
else else
{
client = new DiscordRpcClient(Utils.GetStringSetting("ClientID"), pipe: discordPipe) client = new DiscordRpcClient(Utils.GetStringSetting("ClientID"), pipe: discordPipe)
{ {
Logger = new ConsoleLogger(logLevel, true) Logger = new ConsoleLogger(logLevel, true)
}; };
}
client.RegisterUriScheme(); client.RegisterUriScheme();
client.OnRpcMessage += Client_OnRpcMessage; client.OnRpcMessage += Client_OnRpcMessage;
client.OnPresenceUpdate += Client_OnPresenceUpdate; client.OnPresenceUpdate += Client_OnPresenceUpdate;
@@ -112,29 +116,34 @@ namespace EnderIce2.SDRSharpPlugin
client.OnUnsubscribe += OnUnsubscribe; client.OnUnsubscribe += OnUnsubscribe;
client.OnJoin += OnJoin; client.OnJoin += OnJoin;
client.OnJoinRequested += OnJoinRequested; client.OnJoinRequested += OnJoinRequested;
//client.OnSpectate += OnSpectate;
presence.Timestamps = new Timestamps() presence.Timestamps = new Timestamps()
{ {
Start = DateTime.UtcNow Start = DateTime.UtcNow
}; };
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
client.SetSubscription(EventType.Join | EventType.JoinRequest); client.SetSubscription(EventType.Join | EventType.JoinRequest);
}
client.SetPresence(presence); client.SetPresence(presence);
client.Initialize(); client.Initialize();
try try
{ {
configurationPanelProvider = (IConfigurationPanelProvider)_control.Source; configurationPanelProvider = (IConfigurationPanelProvider)_control.Source;
controllerPanel = (SDRSharp.FrontEnds.SpyServer.ControllerPanel)configurationPanelProvider.Gui; //controllerPanel = (SDRSharp.FrontEnds.SpyServer.ControllerPanel)configurationPanelProvider.Gui;
} }
catch (Exception ex) catch (Exception ex)
{ {
LogWriter.WriteToFile("----> " + ex.ToString()); LogWriter.WriteToFile("----> " + ex);
MessageBox.Show($"Cannot get Spy Server Network address\n\nError:\n{ex}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show($"Cannot get Spy Server Network address\n\nError:\n{ex}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
_ = MainLoop(); _ = MainLoop();
} }
else else
{
_controlPanel.ChangeStatus = "RPC is disabled"; _controlPanel.ChangeStatus = "RPC is disabled";
}
LogWriter.WriteToFile("EOM Initialize"); LogWriter.WriteToFile("EOM Initialize");
} }
private void Client_OnPresenceUpdate(object sender, PresenceMessage args) private void Client_OnPresenceUpdate(object sender, PresenceMessage args)
@@ -209,7 +218,7 @@ namespace EnderIce2.SDRSharpPlugin
{ {
try try
{ {
await Task.Delay(2000); await Task.Delay(2000).ConfigureAwait(false);
isRunning = true; isRunning = true;
LogWriter.WriteToFile($"MainLoop called {isRunning} {client.IsInitialized}"); LogWriter.WriteToFile($"MainLoop called {isRunning} {client.IsInitialized}");
while (client != null && isRunning) while (client != null && isRunning)
@@ -219,9 +228,9 @@ namespace EnderIce2.SDRSharpPlugin
LogWriter.WriteToFile("Setting secret..."); LogWriter.WriteToFile("Setting secret...");
try try
{ {
string sdr_url = "sdr://" + controllerPanel.Host + ":" + controllerPanel.Port + "/"; //string sdr_url = "sdr://" + controllerPanel.Host + ":" + controllerPanel.Port + "/";
LogWriter.WriteToFile(sdr_url); //LogWriter.WriteToFile(sdr_url);
presence.Secrets.JoinSecret = sdr_url; //presence.Secrets.JoinSecret = sdr_url;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -229,7 +238,7 @@ namespace EnderIce2.SDRSharpPlugin
} }
} }
LogWriter.WriteToFile("Waiting 500ms in loop..."); LogWriter.WriteToFile("Waiting 500ms in loop...");
await Task.Delay(500); await Task.Delay(500).ConfigureAwait(false);
if (_control.RdsRadioText != null) if (_control.RdsRadioText != null)
{ {
if (_control.IsPlaying) if (_control.IsPlaying)
@@ -238,7 +247,10 @@ namespace EnderIce2.SDRSharpPlugin
playedBefore = true; playedBefore = true;
} }
else if (!_control.IsPlaying && playedBefore) else if (!_control.IsPlaying && playedBefore)
{
presence.Assets.SmallImageKey = "pause"; presence.Assets.SmallImageKey = "pause";
}
if (!playedBefore) if (!playedBefore)
{ {
presence.Details = "Frequency: Not playing"; presence.Details = "Frequency: Not playing";
@@ -250,23 +262,30 @@ namespace EnderIce2.SDRSharpPlugin
{ {
string space_for_listen_list = " | "; string space_for_listen_list = " | ";
if (!Utils.GetBooleanSetting("EnableRPCInvite", false)) if (!Utils.GetBooleanSetting("EnableRPCInvite", false))
{
space_for_listen_list = ""; space_for_listen_list = "";
}
LogWriter.WriteToFile($"Frequency: {_control.Frequency}"); LogWriter.WriteToFile($"Frequency: {_control.Frequency}");
LogWriter.WriteToFile($"RdsRadioText: {_control.RdsRadioText}"); LogWriter.WriteToFile($"RdsRadioText: {_control.RdsRadioText}");
LogWriter.WriteToFile($"RdsProgramService: {_control.RdsProgramService}"); LogWriter.WriteToFile($"RdsProgramService: {_control.RdsProgramService}");
LogWriter.WriteToFile("Setting presence..."); LogWriter.WriteToFile("Setting presence...");
presence.Details = $"Frequency: {string.Format("{0:#,0,,0 Hz}", _control.Frequency)}"; presence.Details = $"Frequency: {string.Format("{0:#,0,,0 Hz}", _control.Frequency)}";
if (string.IsNullOrWhiteSpace(_control.RdsRadioText + _control.RdsProgramService)) if (string.IsNullOrWhiteSpace(_control.RdsRadioText + _control.RdsProgramService))
{
presence.State = $"RDS: unknown{space_for_listen_list}"; presence.State = $"RDS: unknown{space_for_listen_list}";
}
else else
{
presence.State = $"RDS: {_control.RdsProgramService} - {_control.RdsRadioText}{space_for_listen_list}"; presence.State = $"RDS: {_control.RdsProgramService} - {_control.RdsRadioText}{space_for_listen_list}";
} }
}
catch (Exception ex) catch (Exception ex)
{ {
LogWriter.WriteToFile(ex.ToString()); LogWriter.WriteToFile(ex.ToString());
} }
/* presence.Secrets.JoinSecret = */ /* presence.Secrets.JoinSecret = */
//_control.RegisterFrontControl(Gui, PluginPosition.Top); /* _control.RegisterFrontControl(Gui, PluginPosition.Top); */
} }
try try
{ {
@@ -282,14 +301,18 @@ namespace EnderIce2.SDRSharpPlugin
else else
{ {
LogWriter.WriteToFile("Frequency or Radio Text are null!"); LogWriter.WriteToFile("Frequency or Radio Text are null!");
await Task.Delay(1000); await Task.Delay(1000).ConfigureAwait(false);
} }
} }
if (client == null) if (client == null)
{
_controlPanel.ChangeStatus = "Client was null"; _controlPanel.ChangeStatus = "Client was null";
}
else else
{
_controlPanel.ChangeStatus = "Presence stopped"; _controlPanel.ChangeStatus = "Presence stopped";
} }
}
catch (Exception ex) catch (Exception ex)
{ {
if (ex.Message.Contains("The process cannot access the file")) if (ex.Message.Contains("The process cannot access the file"))

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")] [assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyFileVersion("1.0.0.1")]

View File

@@ -1 +1,86 @@
![GitHub](https://img.shields.io/github/license/EnderIce2/SDR-RPC)
![GitHub All Releases](https://img.shields.io/github/downloads/EnderIce2/SDR-RPC/total)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/EnderIce2/SDR-RPC)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/800cd7ade7ab4aa386f79b5c999a2959)](https://app.codacy.com/gh/EnderIce2/SDR-RPC?utm_source=github.com&utm_medium=referral&utm_content=EnderIce2/SDR-RPC&utm_campaign=Badge_Grade_Settings)
[![CodeFactor](https://www.codefactor.io/repository/github/enderice2/sdr-rpc/badge?s=6ea1f91b515716a019633ad07f7d3138bc136f22)](https://www.codefactor.io/repository/github/enderice2/sdr-rpc)
![Twitter Follow](https://img.shields.io/twitter/follow/enderice22?style=social)
# SDR-RPC # SDR-RPC
SDR-RPC is an [SDRSharp](https://airspy.com/download/) plugin that adds Discord RPC feature in it
---
### ✨Features
- 🎛Enable / Disable
- ✏Showing frequency, play state and RDS almost in realtime
- 🔌Most of the code is made asynchronous
- 📖Logging for troubleshooting problems
- 🔨Easy to install
- 🎧Invite feature (give Spy Server Address or listen using voice chat system) [coming soon]
---
### 🎁How to install
📽Video:
[![](http://img.youtube.com/vi/Otn-xSn_ioI/0.jpg)](http://www.youtube.com/watch?v=Otn-xSn_ioI "")
---
### 🎫Example
📽Video:
[![](http://img.youtube.com/vi/7k02dPqAjBA/0.jpg)](http://www.youtube.com/watch?v=7k02dPqAjBA "")
---
### 💻Building by yourself
1. You need to download this stuff before compiling:
- [Visual Studio 2019](https://visualstudio.microsoft.com/vs/)
- [.NET 4.6](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net46-developer-pack-offline-installer)
- SDRSharp files (for References)
- SDRSharp.exe
- SDRSharp.Common.dll
- SDRSharp.PanView.dll
- SDRSharp.Radio.dll
2. Click "Code" and select "Open with Visual Studio" or "Download ZIP"
![Captură de ecran 2020-10-26 025111.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20025111.png)
3. If you downloaded as ZIP, unzip the archive and double click on "SDRSharpPlugin.DiscordRPC.sln"
4. Build it and move files to SDR# location (if the compile fails try copying Reference files into /bin/Debug or /bin/Release folder)
---
### 👀Setting your custom images on RPC
1. Go to https://discord.com/developers/applications and create your own application
2. Name it "SDRSharp" or something similar
![Captură de ecran 2020-10-26 023639.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20023639.png)
3. Go to Rich Presence > Rich Presence Assets and add your own images with these names:
![Captură de ecran 2020-10-26 023706.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20023706.png)
4. Go back to General Information and copy Client ID
![Captură de ecran 2020-10-26 023915.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20023915.png)
5. Paste the Client ID you copied earlier in plugin textbox from SDRSharp and press the ENTER key
![Captură de ecran 2020-10-26 024024.png](https://raw.githubusercontent.com/EnderIce2/SDR-RPC/master/.github/MEDIA/Captur%C4%83%20de%20ecran%202020-10-26%20024024.png)
6. Restart the SDRSharp and it should be changed with your custom images
---
### 📕TODO List
- Invite people to get Spy Server Address or connecting via voice chat system to listen and having the ability to change the frequency
- Change Settings Panel to WPF User Control
- Add better RDS decoder (if it is even possible)

View File

@@ -46,10 +46,6 @@
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes> <EmbedInteropTypes>False</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="SDRSharp, Version=1.0.0.1765, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Downloads\sdrsharp-x86\SDRSharp.exe</HintPath>
</Reference>
<Reference Include="SDRSharp.Common, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86"> <Reference Include="SDRSharp.Common, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\sdrsharp-x86\SDRSharp.Common.dll</HintPath> <HintPath>..\..\sdrsharp-x86\SDRSharp.Common.dll</HintPath>
@@ -65,6 +61,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Runtime" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
@@ -165,7 +162,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="DiscordAPI\LICENSE.txt" /> <Content Include="DiscordAPI\LICENSE.txt" />
<Content Include="Resgister.txt"> <Content Include="Register.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>

View File

@@ -26,17 +26,31 @@ namespace EnderIce2.SDRSharpPlugin
InitializeComponent(); InitializeComponent();
textBox1.Text = Utils.GetStringSetting("ClientID"); textBox1.Text = Utils.GetStringSetting("ClientID");
if (Utils.GetBooleanSetting("EnableRPC", true)) if (Utils.GetBooleanSetting("EnableRPC", true))
{
checkBox1.Checked = true; checkBox1.Checked = true;
}
else else
{
checkBox1.Checked = false; checkBox1.Checked = false;
}
if (Utils.GetBooleanSetting("LogRPC", false)) if (Utils.GetBooleanSetting("LogRPC", false))
{
checkBox2.Checked = true; checkBox2.Checked = true;
}
else else
{
checkBox2.Checked = false; checkBox2.Checked = false;
}
if (Utils.GetBooleanSetting("EnableRPCInvite", false)) if (Utils.GetBooleanSetting("EnableRPCInvite", false))
{
checkBox3.Checked = true; checkBox3.Checked = true;
}
else else
{
checkBox3.Checked = false; checkBox3.Checked = false;
}
LogWriter.WriteToFile("SettingsPanel loaded"); LogWriter.WriteToFile("SettingsPanel loaded");
} }
@@ -45,7 +59,7 @@ namespace EnderIce2.SDRSharpPlugin
Utils.SaveSetting("EnableRPC", checkBox1.Checked); Utils.SaveSetting("EnableRPC", checkBox1.Checked);
label1.Text = "Restart required"; label1.Text = "Restart required";
LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox1.Checked}"); LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox1.Checked}");
//Utils.GetBooleanSetting("EnableRPC"); /* Utils.GetBooleanSetting("EnableRPC"); */
} }
private void Button1_Click(object sender, EventArgs e) private void Button1_Click(object sender, EventArgs e)
@@ -61,10 +75,15 @@ namespace EnderIce2.SDRSharpPlugin
private void TextBox1_KeyPress(object sender, KeyPressEventArgs e) private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.')) if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
{
e.Handled = true; e.Handled = true;
}
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1)) if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
{
e.Handled = true; e.Handled = true;
} }
}
private async void TextBox1_KeyDown(object sender, KeyEventArgs e) private async void TextBox1_KeyDown(object sender, KeyEventArgs e)
{ {
@@ -73,7 +92,7 @@ namespace EnderIce2.SDRSharpPlugin
Utils.SaveSetting("ClientID", textBox1.Text); Utils.SaveSetting("ClientID", textBox1.Text);
e.Handled = true; e.Handled = true;
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
await Task.Delay(200); await Task.Delay(200).ConfigureAwait(false);
textBox1.Text = Utils.GetStringSetting("ClientID"); textBox1.Text = Utils.GetStringSetting("ClientID");
label1.Text = "Saved."; label1.Text = "Saved.";
} }

View File

@@ -25,8 +25,8 @@ namespace EnderIce2.SDRSharpPlugin
LogWriter.WriteToFile(value); LogWriter.WriteToFile(value);
} }
} }
private bool AnswerA = false; private bool AnswerA;
private bool AnswerD = false; private bool AnswerD;
public async Task<bool> RequestAnswer(DiscordRpcClient client, JoinRequestMessage args) public async Task<bool> RequestAnswer(DiscordRpcClient client, JoinRequestMessage args)
{ {
LogWriter.WriteToFile("Incoming RPC request from " + args.User.Username); LogWriter.WriteToFile("Incoming RPC request from " + args.User.Username);
@@ -37,7 +37,7 @@ namespace EnderIce2.SDRSharpPlugin
{ {
LogWriter.WriteToFile("waiting..."); LogWriter.WriteToFile("waiting...");
Application.DoEvents(); Application.DoEvents();
await Task.Delay(200); await Task.Delay(200).ConfigureAwait(false);
} }
bool tmpansw = AnswerA; bool tmpansw = AnswerA;
LogWriter.WriteToFile($"Client sent an answer. {tmpansw}"); LogWriter.WriteToFile($"Client sent an answer. {tmpansw}");
@@ -46,18 +46,21 @@ namespace EnderIce2.SDRSharpPlugin
AnswerD = false; AnswerD = false;
button1.Visible = false; button1.Visible = false;
button2.Visible = false; button2.Visible = false;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
SetDefaultTextInLabel(tmpansw); SetDefaultTextInLabel(tmpansw);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
return tmpansw; return tmpansw;
} }
private async Task SetDefaultTextInLabel(bool accepted) private async Task SetDefaultTextInLabel(bool accepted)
{ {
if (accepted) if (accepted)
{
ChangeLabel = $"SDR# RPC | Request accepted"; ChangeLabel = $"SDR# RPC | Request accepted";
}
else else
{
ChangeLabel = $"SDR# RPC | Request declined"; ChangeLabel = $"SDR# RPC | Request declined";
await Task.Delay(5000); }
await Task.Delay(5000).ConfigureAwait(false);
ChangeLabel = $"SDR# RPC | Ready"; ChangeLabel = $"SDR# RPC | Ready";
} }
} }