accepting the suggestions made by hbons
This commit is contained in:
parent
a88aea266e
commit
91d457332b
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue