From 254bd4bdd40fe8b882ff26404b5f50eeceb8ce66 Mon Sep 17 00:00:00 2001 From: Benedikt Bauer Date: Wed, 6 Apr 2016 03:02:33 +0200 Subject: [PATCH] Proper XML comments in Config and Main class --- Plugin_SongPoster/SongPoster.cs | 204 +++++++++++++----- Plugin_SongPoster/SongPoster_Config.cs | 116 +++++----- .../bin/Release/Plugin_SongPoster.dll | Bin 94208 -> 94208 bytes 3 files changed, 212 insertions(+), 108 deletions(-) diff --git a/Plugin_SongPoster/SongPoster.cs b/Plugin_SongPoster/SongPoster.cs index 7072fd0..48fcac3 100644 --- a/Plugin_SongPoster/SongPoster.cs +++ b/Plugin_SongPoster/SongPoster.cs @@ -7,61 +7,97 @@ namespace Plugin_SongPoster { - // This is our main class and entrypoint for RadioDJ + /// + ///This is our main class and entrypoint for RadioDJ + /// public class SongPoster : IPlugin { - // Declaration required for AvailableActions method from IPlugin interface, no idea what that does, though + /// + ///Declaration required for AvailableActions method from IPlugin interface, no idea what that does, though + /// private List MyEvents; - // Reference to the IHost interface by which we interact with the RadioDJ main program + /// + ///Reference to the IHost interface by which we interact with the RadioDJ main program + /// public IHost MyHost; - // This is the class where the actual web requests are sent + /// + ///This is the class where the actual web requests are sent + /// private WebRequester Requester; - // Counter for PlayCount Timer. + /// + ///Counter for PlayCount Timer. + /// private int counter; - // Base time from which to count minutes for the "Time" timer + /// + ///Base time from which to count minutes for the "Time" timer + /// private DateTime startTimer; - // Array of TrackType Strings from RadioDJ + /// + ///Array of TrackType Strings from RadioDJ + /// public string[] trackTypes; - // Array of TrackTypes selected by User + /// + ///Array of TrackTypes selected by User + /// public string[] SelectedTrackTypes; - // Interval (minutes/playcounts) after which a track is sent + /// + ///Interval (minutes/playcounts) after which a track is sent + /// public int Interval; - // Defines the kind of timing for the Interval, either WaitForPlayCount or WaitForTime + /// + ///Defines the kind of timing for the Interval, either WaitForPlayCount or WaitForTime + /// public string Timing; - // Message (Template) to send out + /// + ///Message (Template) to send out + /// public string Message; - // Array of networks to use and send the track info to + /// + ///Array of networks to use and send the track info to + /// public string[] Networks; - // SongPoster Userid + /// + ///SongPoster Userid + /// public string UserId; - // SongPoster Password + /// + ///SongPoster Password + /// public string Password; - // Plugin must be enabled by hand (after configuration) + /// + ///Plugin must be enabled by hand (after configuration) + /// public bool Enabled = false; - // Reference by which Settings are stored and loaded + /// + ///Reference by which Settings are stored and loaded + /// public string PluginFileName; - // Constructor + /// + ///Constructor + /// public SongPoster() { MyEvents = new List(); } - // required by IHost interface, no idea what it's good for + /// + ///required by IHost interface, no idea what it's good for + /// public bool HasActions { get @@ -70,7 +106,9 @@ public bool HasActions } } - // required by IHost interface, we're not interested in what you do with your Playlist + /// + ///required by IHost interface, we're not interested in what you do with your Playlist + /// public bool NotifyOnPlaylistChange { get @@ -79,7 +117,9 @@ public bool NotifyOnPlaylistChange } } - // required by IHost interface, let us know when the current track changes so we can send a message to SongPoster + /// + ///required by IHost interface, let us know when the current track changes so we can send a message to SongPoster + /// public bool NotifyOnTrackChange { get @@ -88,7 +128,9 @@ public bool NotifyOnTrackChange } } - // required by IHost interface, no idea what it's good for + /// + ///required by IHost interface, no idea what it's good for + /// public bool NotifyOnUIChange { get @@ -97,7 +139,9 @@ public bool NotifyOnUIChange } } - // required by IHost interface, Meta Data + /// + ///required by IHost interface, Meta Data + /// public string PluginDescription { get @@ -106,7 +150,9 @@ public string PluginDescription } } - // required by IHost interface, Meta Data + /// + ///required by IHost interface, Meta Data + /// public string PluginName { get @@ -115,7 +161,9 @@ public string PluginName } } - // required by IHost interface, Meta Data + /// + ///required by IHost interface, Meta Data + /// public string PluginTitle { get @@ -124,7 +172,9 @@ public string PluginTitle } } - // required by IHost interface, Meta Data + /// + ///required by IHost interface, Meta Data + /// public string PluginVersion { get @@ -133,7 +183,9 @@ public string PluginVersion } } - // required by IHost interface, no idea what it's good for or what Zones are available at all + /// + ///required by IHost interface, no idea what it's good for or what Zones are available at all + /// public int PluginZone { get @@ -142,43 +194,57 @@ public int PluginZone } } - // required by IHost interface, I think this has to do with the PlayListChange Event + /// + ///required by IHost interface, I think this has to do with the PlayListChange Event + /// public void AddTrack2Plugin(TrackPlayer trackData, long TriggerOn, int Position = -1) { //throw new NotImplementedException(); } - // required by IHost interface, I think this has to do with the PlayListChange Event + /// + ///required by IHost interface, I think this has to do with the PlayListChange Event + /// public void AddTrack2Plugin(int trackID, long TriggerOn, int Position = -1) { //throw new NotImplementedException(); } - // required by IHost interface, I think this has to do with the UIChange Event + /// + ///required by IHost interface, I think this has to do with the UIChange Event + /// public void AssistedStateChanged(bool newState) { //throw new NotImplementedException(); } - // required by IHost interface, I think this has to do with the UIChange Event + /// + ///required by IHost interface, I think this has to do with the UIChange Event + /// public void AutoDJStateChanged(bool newState) { //throw new NotImplementedException(); } - // To be honest: I've got no idea what this does + /// + ///To be honest: I've got no idea what this does + /// public List AvailableActions() { return MyEvents; } - // I don't think you can "close" a plugin without closing RadioDJ + /// + ///I don't think you can "close" a plugin without closing RadioDJ + /// public void Closing() { //throw new NotImplementedException(); } - // Get settings from the XML storage + /// + ///Get settings from the XML storage + /// private void LoadSettings() { string networks = MyHost.GetSetting(PluginFileName, "networks", ""); @@ -193,7 +259,9 @@ private void LoadSettings() SelectedTrackTypes = types.Split(new Char[] { ';' }); } - // Initialize with sensible defaults and load settings + /// + ///Initialize with sensible defaults and load settings + /// public void Initialize(IHost Host) { MyHost = Host; @@ -205,55 +273,73 @@ public void Initialize(IHost Host) trackTypes = Enum.GetNames(typeof(Tracks.TrackTypes)); } - // To be honest: I've got no idea what this does + /// + ///To be honest: I've got no idea what this does + /// public void InputStateChanged(bool newState) { //throw new NotImplementedException(); } - // No Keyboard shortcuts for this plugin + /// + ///No Keyboard shortcuts for this plugin + /// public void KeyDown(object sender, KeyEventArgs e) { //throw new NotImplementedException(); } - // To be honest: I've got no idea what this does + /// + ///To be honest: I've got no idea what this does + /// public UserControl LoadGUI() { return null; } - // required by IHost interface, we're not interested in what you do with your Playlist + /// + ///required by IHost interface, we're not interested in what you do with your Playlist + /// public void PlaylistChanged() { //throw new NotImplementedException(); } - // required by IHost interface, we're not interested in what you do with your Categories + /// + ///required by IHost interface, we're not interested in what you do with your Categories + /// public void ReloadCategories() { //throw new NotImplementedException(); } - // required by IHost interface, we're not interested in what you do with your Language settings + /// + ///required by IHost interface, we're not interested in what you do with your Language settings + /// public void ReloadLanguage() { //throw new NotImplementedException(); } - // To be honest: I've got no idea what this does + /// + ///To be honest: I've got no idea what this does + /// public bool RunAction(string ActionName, string[] args) { return true; } - // Show the About box for this plugin + /// + ///Show the About box for this plugin + /// public void ShowAbout() { MessageBox.Show("\u00a9" + DateTime.Now.Year.ToString() + " Xenzilla", PluginTitle); } - // Show our Config screen + /// + ///Show our Config screen + /// public void ShowConfig() { SongPoster_Config configWindow = new SongPoster_Config(this); @@ -261,7 +347,9 @@ public void ShowConfig() configWindow.Show(); } - // Show our "Main" screen? When is this fired? Is double-clicking the plugin list and clicking the config button different? + /// + ///Show our "Main" screen? When is this fired? Is double-clicking the plugin list and clicking the config button different? + /// public void ShowMain() { SongPoster_Config configWindow = new SongPoster_Config(this); @@ -269,41 +357,43 @@ public void ShowMain() configWindow.Show(); } - // This is where the magic happens. Fired on track change + /// + ///This is where the magic happens. Fired on track change + /// public void TrackChanged(TrackPlayer Player) { - // Check if the plugin is enabled (We trust you to have the config done properly) - // AND - // Current Track's type is part of the user-selected Track types + //Check if the plugin is enabled (We trust you to have the config done properly) + //AND + //Current Track's type is part of the user-selected Track types if (Enabled && (SelectedTrackTypes.Length == 0 || Array.Exists(SelectedTrackTypes, delegate (string s) { return s.Equals(Player.TrackData.TrackType.ToString()); }))) { - // increase counter for PlayCount Timing (if we're on "Time" timing, this won't hurt either. Worst that could happen is the number overflowing) + //increase counter for PlayCount Timing (if we're on "Time" timing, this won't hurt either. Worst that could happen is the number overflowing) counter++; - // compare NOW and startTime + Interval minutes + //compare NOW and startTime + Interval minutes int compareTimes = DateTime.Compare(DateTime.Now, startTimer.AddMinutes(Interval)); - // Send a message if PlayCount counter is greater than the interval + //Send a message if PlayCount counter is greater than the interval if (Timing == "WaitForPlayCount" && counter > Interval) { - // Disable Plugin if the webservice reports a problem + //Disable Plugin if the webservice reports a problem if (!Requester.sendRequest(Player.TrackData, Message, Networks, UserId, Password)) { Enabled = false; } - // reset counter + //reset counter counter = 0; } - // Send message if "Time" comparison results in the NOW time being greater than the base time + interval + //Send message if "Time" comparison results in the NOW time being greater than the base time + interval else if (Timing == "WaitForTime" && compareTimes >= 0) { - // Disable Plugin if the webservice reports a problem + //Disable Plugin if the webservice reports a problem if (!Requester.sendRequest(Player.TrackData, Message, Networks, UserId, Password)) { Enabled = false; } - // reset base time + //reset base time startTimer = DateTime.Now; - // reset counter to prevent integer overflow + //reset counter to prevent integer overflow counter = 0; } } diff --git a/Plugin_SongPoster/SongPoster_Config.cs b/Plugin_SongPoster/SongPoster_Config.cs index 86c3032..095f62e 100644 --- a/Plugin_SongPoster/SongPoster_Config.cs +++ b/Plugin_SongPoster/SongPoster_Config.cs @@ -1,25 +1,30 @@ using System; using System.Text.RegularExpressions; using System.Windows.Forms; -using System.Collections.Generic; namespace Plugin_SongPoster { - // This is our GUI class, called when the Config window is opened + /// + ///This is our GUI class, called when the Config window is opened + /// public partial class SongPoster_Config : Form { - // reference to the Main class + /// + ///reference to the Main class + /// private SongPoster spRef; - // constructor, initialize some form elements with values from the Config storage + /// + ///constructor, initialize some form elements with values from the Config storage + /// public SongPoster_Config(SongPoster sp) { - // Initialize the Window and it's components + //Initialize the Window and it's components InitializeComponent(); spRef = sp; listBoxNetworks1.ClearSelected(); - // select each network in the listBox which has a corresponding entry in the Networks array + //select each network in the listBox which has a corresponding entry in the Networks array foreach (string network in spRef.Networks) { int index = listBoxNetworks1.FindStringExact(network); @@ -29,23 +34,23 @@ public SongPoster_Config(SongPoster sp) } } - // set textbox values and check the Enable Box if the Plugin should run + //set textbox values and check the Enable Box if the Plugin should run textBoxUserId.Text = spRef.UserId; textBoxPassword.Text = spRef.Password; textBoxResult.Text = spRef.Message; - // If timing is WaitForPlayCount, check the corresponding Radio Button + //If timing is WaitForPlayCount, check the corresponding Radio Button if (spRef.Timing == "WaitForPlayCount") { radioButtonWaitForPlayCount.Checked = true; } - // else check the one for WaitForTime + //else check the one for WaitForTime else { radioButtonWaitForTime.Checked = true; } - // set the NumericUpDown Field to the Interval value from config + //set the NumericUpDown Field to the Interval value from config numericUpDownInterval.Value = spRef.Interval; listBoxTrackTypes.DataSource = spRef.trackTypes; @@ -61,12 +66,14 @@ public SongPoster_Config(SongPoster sp) } } - // Handler for the Browse button on the PAL tab + /// + ///Handler for the Browse button on the PAL tab + /// private void buttonBrowse_Click(object sender, EventArgs e) { - // Only handle something if the user successfully picked something, we don't need any handling for the cancel button + //Only handle something if the user successfully picked something, we don't need any handling for the cancel button if (openFileDialogPAL.ShowDialog() != DialogResult.OK) return; - // initialize a few local variables + //initialize a few local variables string message = null; string prefix = null; string postfix = null; @@ -77,41 +84,41 @@ private void buttonBrowse_Click(object sender, EventArgs e) string password = null; string types = null; - // get the selected filename and read the file into a string variable + //get the selected filename and read the file into a string variable string palFileName = openFileDialogPAL.FileName; string palText = System.IO.File.ReadAllText(palFileName); string[] palLines = palText.Split(new[] { '\r', '\n' }); - // set the PAL preview box content + //set the PAL preview box content textBoxPAL.Lines = palLines; - // Regex for parsing the settings from the PAL file + //Regex for parsing the settings from the PAL file Regex r1 = new Regex(@"statusmessage := Song\['(\w+)'\] \+ ' - ' \+ Song\['(\w+)'\];$", RegexOptions.IgnoreCase); Regex r2 = new Regex(@"prefix : String = '(.*)';"); Regex r3 = new Regex(@"prefix : String = '(.*)';"); Regex r4 = new Regex(@"Pos\(Song\['songtype'\],'([A-Z]+)'\)"); - // Timing format is either PAL.WaitForPlayCount(123); or PAL.WaitForTime('+12:34:56'); + //Timing format is either PAL.WaitForPlayCount(123); or PAL.WaitForTime('+12:34:56'); Regex r5 = new Regex(@"PAL.WaitFor(Time|PlayCount)\((?:(\d+)|'\+(\d{2}:\d{2}:\d{2})')\);"); - // URL line 2 may leave out the picture part at the end + //URL line 2 may leave out the picture part at the end Regex r6 = new Regex(@"\+ '(?:twitter|facebook|google)' \+ '/' \+ '(\d+)' \+ '/' \+ '(\d+)' \+ '/' \+ '(.+?)' \+ '/' \+ status(?: \+ '/' \+ picture)?;"); - // count if we found all the settings + //count if we found all the settings int found = 0; foreach (string element in palLines) { - // Only try to match if we haven't found this element yet + //Only try to match if we haven't found this element yet if (string.IsNullOrEmpty(message)) { Match m1 = r1.Match(element); if (m1.Success) { - // grab the matches and enclose them with $ to build RadioDJ template variables + //grab the matches and enclose them with $ to build RadioDJ template variables message = "$" + m1.Groups[1].Value + "$ - $" + m1.Groups[2].Value + "$"; found++; } } - // Only try to match if we haven't found this element yet + //Only try to match if we haven't found this element yet if (string.IsNullOrEmpty(prefix)) { Match m2 = r2.Match(element); @@ -122,7 +129,7 @@ private void buttonBrowse_Click(object sender, EventArgs e) } } - // Only try to match if we haven't found this element yet + //Only try to match if we haven't found this element yet if (string.IsNullOrEmpty(postfix)) { Match m3 = r3.Match(element); @@ -133,7 +140,7 @@ private void buttonBrowse_Click(object sender, EventArgs e) } } - // Only try to match if we haven't found this element yet + //Only try to match if we haven't found this element yet if (string.IsNullOrEmpty(types)) { Match m4 = r4.Match(element); @@ -143,7 +150,7 @@ private void buttonBrowse_Click(object sender, EventArgs e) } } - // Only try to match if we haven't found this element yet + //Only try to match if we haven't found this element yet if (string.IsNullOrEmpty(interval) && string.IsNullOrEmpty(timing)) { Match m5 = r5.Match(element); @@ -155,7 +162,7 @@ private void buttonBrowse_Click(object sender, EventArgs e) } } - // Only try to match if we haven't found this element yet + //Only try to match if we haven't found this element yet if (string.IsNullOrEmpty(scopeid) && string.IsNullOrEmpty(userid) && string.IsNullOrEmpty(password)) { Match m6 = r6.Match(element); @@ -168,29 +175,29 @@ private void buttonBrowse_Click(object sender, EventArgs e) } } - // each match increases the found counter, once we found all 4 setting groups, there's no need to parse the rest of the PAL file anymore + //each match increases the found counter, once we found all 4 setting groups, there's no need to parse the rest of the PAL file anymore if (found >= 5) { break; } } - // set the result textbox to include prefix, message and postfix - just like in SAMBC the 3 are concatenated without any extra whitespace + //set the result textbox to include prefix, message and postfix - just like in SAMBC the 3 are concatenated without any extra whitespace textBoxResult.Text = prefix + message + postfix; - // PlayCount Timing can be applied directly by parsing the interval string into a number + //PlayCount Timing can be applied directly by parsing the interval string into a number if (timing == "PlayCount") { radioButtonWaitForPlayCount.Checked = true; numericUpDownInterval.Value = int.Parse(interval); } - // "Time" Timing is a bit more complex + //"Time" Timing is a bit more complex else { radioButtonWaitForTime.Checked = true; - // split the interval on the : symbol + //split the interval on the : symbol string[] intervalParts = interval.Split(new char[] { ':' }); - // then parse each part into a number, convert each part into minutes and add them up + //then parse each part into a number, convert each part into minutes and add them up numericUpDownInterval.Value = int.Parse(intervalParts[0]) * 60 + int.Parse(intervalParts[1]) + int.Parse(intervalParts[2]) / 60; } @@ -202,45 +209,45 @@ private void buttonBrowse_Click(object sender, EventArgs e) switch (samType) { - // S - Normal song + //S - Normal song case 'S': index = listBoxTrackTypes.FindStringExact("Music"); break; - // I - Station ID + //I - Station ID case 'I': index = listBoxTrackTypes.FindStringExact("Sweeper"); break; - // P - Promo + //P - Promo case 'P': break; - // J - Jingle + //J - Jingle case 'J': index = listBoxTrackTypes.FindStringExact("Jingle"); break; - // A - Advertisement + //A - Advertisement case 'A': index = listBoxTrackTypes.FindStringExact("Commercial"); break; - // N - Syndicated news + //N - Syndicated news case 'N': index = listBoxTrackTypes.FindStringExact("News"); break; - // X - Sound FX + //X - Sound FX case 'X': break; - // C - Unknown content + //C - Unknown content case 'C': index = listBoxTrackTypes.FindStringExact("Other"); break; - // ? - Unknown + //? - Unknown case '?': index = listBoxTrackTypes.FindStringExact("Other"); break; @@ -252,41 +259,45 @@ private void buttonBrowse_Click(object sender, EventArgs e) } } - // set the userId and password fields + //set the userId and password fields textBoxUserId.Text = userid; textBoxPassword.Text = password; - // @ToDo add scopeId field and set that as well - // textBoxScopeId = scopeid; + //@ToDo add scopeId field and set that as well + //textBoxScopeId = scopeid; } - // Close the Window if user clicks cancel + /// + ///Close the Window if user clicks cancel + /// private void buttonClose_Click(object sender, EventArgs e) { Close(); } - // Save settings, then close the Window + /// + ///Save settings, then close the Window + /// private void buttonSave_Click(object sender, EventArgs e) { - // Set message to the parsed result (with optional user modifications) + //Set message to the parsed result (with optional user modifications) spRef.Message = textBoxResult.Text; - // We used "nicer" names for the Networks ListBox, but need the normalized name for sending to SongPoster + //We used "nicer" names for the Networks ListBox, but need the normalized name for sending to SongPoster spRef.Networks = new string[listBoxNetworks1.SelectedItems.Count]; listBoxNetworks1.SelectedItems.CopyTo(spRef.Networks, 0); - // Copy selected items from TrackTypes ListBox to spRef variable + //Copy selected items from TrackTypes ListBox to spRef variable spRef.SelectedTrackTypes = new string[listBoxTrackTypes.SelectedItems.Count]; listBoxTrackTypes.SelectedItems.CopyTo(spRef.SelectedTrackTypes, 0); - // Grab "simple" data from textboxes, radio buttons and numericUpDown fields + //Grab "simple" data from textboxes, radio buttons and numericUpDown fields spRef.UserId = textBoxUserId.Text; spRef.Password = textBoxPassword.Text; spRef.Enabled = checkBoxEnable.Checked; spRef.Timing = radioButtonWaitForPlayCount.Checked ? "WaitForPlayCount" : "WaitForTime"; spRef.Interval = (int)numericUpDownInterval.Value; - // normalize values into strings and save to XML via RadioDJ SaveSetting operation + //normalize values into strings and save to XML via RadioDJ SaveSetting operation spRef.MyHost.SaveSetting(spRef.PluginFileName, "networks", string.Join(";", spRef.Networks)); spRef.MyHost.SaveSetting(spRef.PluginFileName, "UserId", spRef.UserId); spRef.MyHost.SaveSetting(spRef.PluginFileName, "Password", spRef.Password); @@ -299,6 +310,9 @@ private void buttonSave_Click(object sender, EventArgs e) Close(); } + /// + ///setter for global checkBoxEnable Enabled state + /// public void setCheckBoxEnable(bool Enabled) { checkBoxEnable.Checked = Enabled; diff --git a/Plugin_SongPoster/bin/Release/Plugin_SongPoster.dll b/Plugin_SongPoster/bin/Release/Plugin_SongPoster.dll index cbfc887e5f553f52745a2161cdd6fb65bc62f80e..532556c8ef0ffcdac361a21e8ac9505899eb4ce6 100644 GIT binary patch delta 66 zcmV-I0KNZ!;01u-1(1jW_+PP#9#9bZw~mK6S(!zO6a9l1ZXS!XxKQ+t0{CB(uHPCE YVD!Lx08`LNzH