accepting the suggestions made by hbons
This commit is contained in:
parent
9a1a7f4626
commit
a3426e5ca5
|
@ -44,14 +44,6 @@ namespace SparkleLib {
|
||||||
string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute (
|
string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute (
|
||||||
folder_name, "announcements_url");
|
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) {
|
if (uri == null) {
|
||||||
// This is SparkleShare's centralized notification service.
|
// This is SparkleShare's centralized notification service.
|
||||||
// Don't worry, we only use this server as a backup if you
|
// 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/";
|
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);
|
Uri announce_uri = new Uri (uri);
|
||||||
|
|
||||||
// We use only one listener per server to keep
|
// We use only one listener per server to keep
|
||||||
|
@ -89,10 +74,10 @@ namespace SparkleLib {
|
||||||
listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier));
|
listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier));
|
||||||
break;
|
break;
|
||||||
case "irc":
|
case "irc":
|
||||||
listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access));
|
listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access));
|
listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@ namespace SparkleLib {
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private IrcClient client;
|
private IrcClient client;
|
||||||
private string nick;
|
private string nick;
|
||||||
private string key;
|
private string announcements_password;
|
||||||
private string dangerous_access;
|
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)
|
base (server, folder_identifier)
|
||||||
{
|
{
|
||||||
// Try to get a uniqueish nickname
|
// Try to get a uniqueish nickname
|
||||||
|
@ -43,11 +43,20 @@ namespace SparkleLib {
|
||||||
// with a number, so prefix an alphabetic character
|
// with a number, so prefix an alphabetic character
|
||||||
this.nick = "s" + this.nick.Substring (0, 7);
|
this.nick = "s" + this.nick.Substring (0, 7);
|
||||||
|
|
||||||
// Key to access the channel
|
// Key to turn the channel access more safely.
|
||||||
this.key = key;
|
this.announcements_password =
|
||||||
|
SparkleConfig.DefaultConfig.GetConfigOption ("announcements_password");
|
||||||
|
|
||||||
// Allow access to the channel
|
// Identifier to define access in IRC channel when no key is defined
|
||||||
this.dangerous_access = dangerous_access;
|
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);
|
base.channels.Add ("#" + folder_identifier);
|
||||||
|
|
||||||
|
@ -116,16 +125,16 @@ namespace SparkleLib {
|
||||||
|
|
||||||
foreach (string channel in base.channels) {
|
foreach (string channel in base.channels) {
|
||||||
SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel);
|
SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel);
|
||||||
if (key != null) {
|
if (this.announcements_password != null) {
|
||||||
SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel");
|
SparkleHelpers.DebugInfo ("ListenerIrc", "Password set to access the channel");
|
||||||
this.client.RfcJoin (channel, key);
|
this.client.RfcJoin (channel, this.announcements_password);
|
||||||
this.client.RfcMode (channel, "+k " + key);
|
this.client.RfcMode (channel, "+k " + this.announcements_password);
|
||||||
} else {
|
} else {
|
||||||
if (dangerous_access == "yes") {
|
if (allow_passwordless_join) {
|
||||||
SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access");
|
SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access");
|
||||||
this.client.RfcJoin (channel);
|
this.client.RfcJoin (channel);
|
||||||
} else {
|
} 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");
|
||||||
|
@ -155,22 +164,22 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (IsConnected) {
|
if (IsConnected) {
|
||||||
SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel);
|
SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel);
|
||||||
if (key != null) {
|
if (this.announcements_password != null) {
|
||||||
SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel");
|
SparkleHelpers.DebugInfo ("ListenerIrc", "Password set to access the channel");
|
||||||
this.client.RfcJoin (channel, key);
|
this.client.RfcJoin (channel, this.announcements_password);
|
||||||
this.client.RfcMode (channel, "+k " + key);
|
this.client.RfcMode (channel, "+k " + this.announcements_password);
|
||||||
} else {
|
} else {
|
||||||
if (dangerous_access == "yes") {
|
if (allow_passwordless_join) {
|
||||||
SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access");
|
SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access");
|
||||||
this.client.RfcJoin (channel);
|
this.client.RfcJoin (channel);
|
||||||
} else {
|
} 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Announce (SparkleAnnouncement announcement)
|
public override void Announce (SparkleAnnouncement announcement)
|
||||||
|
|
Loading…
Reference in a new issue