From 91d457332b96d2539c7cd6c4d62b940d6fd5fccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Lazarte=20Kaqui?= Date: Sun, 16 Oct 2011 16:46:37 -0200 Subject: [PATCH] =?UTF-8?q?accepting=20the=20suggestions=20made=20?= =?UTF-8?q?=E2=80=8B=E2=80=8Bby=20hbons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SparkleLib/SparkleListenerBase.cs | 19 ++---------- SparkleLib/SparkleListenerIrc.cs | 49 ++++++++++++++++++------------- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index 93cf1dae..b9293841 100644 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -44,14 +44,6 @@ namespace SparkleLib { string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( folder_name, "announcements_url"); - // Key to turn the channel access more safely. - string key = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( - folder_name, "key"); - - // Identifier to define access in IRC channel when no key is defined - string dangerous_access = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( - folder_name, "dangerous_access"); - if (uri == null) { // This is SparkleShare's centralized notification service. // Don't worry, we only use this server as a backup if you @@ -61,13 +53,6 @@ namespace SparkleLib { uri = "irc://204.62.14.135/"; } - // This action ensures that the Sparkleshare function normally when the key is not defined. - // It is recommended that the user asked a question to see whether or not to allow access - // to the channel without a key. - if (dangerous_access == null) { - dangerous_access = "yes"; - } - Uri announce_uri = new Uri (uri); // We use only one listener per server to keep @@ -89,10 +74,10 @@ namespace SparkleLib { listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); break; case "irc": - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier)); break; default: - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier)); break; } diff --git a/SparkleLib/SparkleListenerIrc.cs b/SparkleLib/SparkleListenerIrc.cs index 91e4cc40..e3235a54 100644 --- a/SparkleLib/SparkleListenerIrc.cs +++ b/SparkleLib/SparkleListenerIrc.cs @@ -29,11 +29,11 @@ namespace SparkleLib { private Thread thread; private IrcClient client; private string nick; - private string key; - private string dangerous_access; + private string announcements_password; + private bool allow_passwordless_join; - public SparkleListenerIrc (Uri server, string folder_identifier, string key, string dangerous_access) : + public SparkleListenerIrc (Uri server, string folder_identifier) : base (server, folder_identifier) { // Try to get a uniqueish nickname @@ -43,11 +43,20 @@ namespace SparkleLib { // with a number, so prefix an alphabetic character this.nick = "s" + this.nick.Substring (0, 7); - // Key to access the channel - this.key = key; + // Key to turn the channel access more safely. + this.announcements_password = + SparkleConfig.DefaultConfig.GetConfigOption ("announcements_password"); - // Allow access to the channel - this.dangerous_access = dangerous_access; + // Identifier to define access in IRC channel when no key is defined + this.allow_passwordless_join = + SparkleConfig.DefaultConfig.GetConfigOption ("allow_passwordless_join"); + + // This action ensures that the Sparkleshare function normally when the key is not defined. + // It is recommended that the user asked a question to see whether or not to allow access + // to the channel without a key. + if (this.allow_passwordless_join == null) { + this.allow_passwordless_join = true + } base.channels.Add ("#" + folder_identifier); @@ -116,16 +125,16 @@ namespace SparkleLib { foreach (string channel in base.channels) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); - if (key != null) { - SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel"); - this.client.RfcJoin (channel, key); - this.client.RfcMode (channel, "+k " + key); + if (this.announcements_password != null) { + SparkleHelpers.DebugInfo ("ListenerIrc", "Password set to access the channel"); + this.client.RfcJoin (channel, this.announcements_password); + this.client.RfcMode (channel, "+k " + this.announcements_password); } else { - if (dangerous_access == "yes") { + if (allow_passwordless_join) { SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access"); this.client.RfcJoin (channel); } else { - SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel change the setting to access"); + SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel, change the setting to access"); } } this.client.RfcMode (channel, "+s"); @@ -155,20 +164,20 @@ namespace SparkleLib { if (IsConnected) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); - if (key != null) { - SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel"); - this.client.RfcJoin (channel, key); - this.client.RfcMode (channel, "+k " + key); + if (this.announcements_password != null) { + SparkleHelpers.DebugInfo ("ListenerIrc", "Password set to access the channel"); + this.client.RfcJoin (channel, this.announcements_password); + this.client.RfcMode (channel, "+k " + this.announcements_password); } else { - if (dangerous_access == "yes") { + if (allow_passwordless_join) { SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access"); this.client.RfcJoin (channel); } else { - SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel change the setting to access"); + SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel, change the setting to access"); } } + this.client.RfcMode (channel, "+s"); } - this.client.RfcMode (channel, "+s"); } }