From 4753a7849bf10a33abc4ab114a66269ab560d497 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 30 Apr 2021 02:27:41 +0300 Subject: [PATCH] --- MainPlugin.cs | 26 +++++++++++--------------- SettingsPanel.cs | 2 +- TopWindowMessages.cs | 2 -- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/MainPlugin.cs b/MainPlugin.cs index a0461cb..500779b 100644 --- a/MainPlugin.cs +++ b/MainPlugin.cs @@ -37,18 +37,9 @@ namespace EnderIce2.SDRSharpPlugin }; private DiscordRpcClient client; private bool isRunning = true; - public string DisplayName - { - get { return _displayName; } - } - public bool HasGui - { - get { return true; } - } - public UserControl Gui - { - get { return _controlPanel; } - } + public string DisplayName => _displayName; + public bool HasGui => true; + public UserControl Gui => _controlPanel; public void Initialize(ISharpControl control) { IConfigurationPanelProvider configurationPanelProvider; @@ -72,6 +63,7 @@ namespace EnderIce2.SDRSharpPlugin { MessageBox.Show(ex.ToString()); } + if (Utils.GetBooleanSetting("EnableRPCInvite", false)) { presence.Secrets = new Secrets() @@ -85,6 +77,7 @@ namespace EnderIce2.SDRSharpPlugin Max = 100 }; } + if (Utils.GetBooleanSetting("EnableRPCInvite", false)) { windowMessages.Show(); @@ -128,8 +121,12 @@ namespace EnderIce2.SDRSharpPlugin { Start = DateTime.UtcNow }; + if (Utils.GetBooleanSetting("EnableRPCInvite", false)) + { client.SetSubscription(EventType.Join | EventType.JoinRequest); + } + client.SetPresence(presence); client.Initialize(); try @@ -148,7 +145,6 @@ namespace EnderIce2.SDRSharpPlugin { _controlPanel.ChangeStatus = "RPC is disabled"; } - LogWriter.WriteToFile("EOM Initialize"); } private void Client_OnPresenceUpdate(object sender, PresenceMessage args) @@ -243,7 +239,7 @@ namespace EnderIce2.SDRSharpPlugin } } LogWriter.WriteToFile("Waiting 500ms in loop..."); - await Task.Delay(500); + await Task.Delay(500).ConfigureAwait(false); if (_control.RdsRadioText != null) { if (_control.IsPlaying) @@ -287,7 +283,7 @@ namespace EnderIce2.SDRSharpPlugin LogWriter.WriteToFile(ex.ToString()); } /* presence.Secrets.JoinSecret = */ - // TODO: _control.RegisterFrontControl(Gui, PluginPosition.Top); + /* _control.RegisterFrontControl(Gui, PluginPosition.Top); */ } try { diff --git a/SettingsPanel.cs b/SettingsPanel.cs index 50761dd..ce7b0ea 100644 --- a/SettingsPanel.cs +++ b/SettingsPanel.cs @@ -59,7 +59,7 @@ namespace EnderIce2.SDRSharpPlugin Utils.SaveSetting("EnableRPC", checkBox1.Checked); label1.Text = "Restart required"; LogWriter.WriteToFile($"checkbox on SettingsPanel clicked {checkBox1.Checked}"); - // TODO: implement Utils.GetBooleanSetting("EnableRPC"); + /* Utils.GetBooleanSetting("EnableRPC"); */ } private void Button1_Click(object sender, EventArgs e) diff --git a/TopWindowMessages.cs b/TopWindowMessages.cs index a023232..92145a5 100644 --- a/TopWindowMessages.cs +++ b/TopWindowMessages.cs @@ -46,9 +46,7 @@ namespace EnderIce2.SDRSharpPlugin AnswerD = false; button1.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); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed return tmpansw; } private async Task SetDefaultTextInLabel(bool accepted)