This commit is contained in:
Hylke Bons 2011-10-17 19:43:05 +02:00
commit 59d4a7367f

View file

@ -29,6 +29,8 @@ namespace SparkleLib {
private Thread thread;
private IrcClient client;
private string nick;
private string announcements_password;
private bool allow_passwordless_join;
public SparkleListenerIrc (Uri server, string folder_identifier) :
@ -41,6 +43,21 @@ namespace SparkleLib {
// with a number, so prefix an alphabetic character
this.nick = "s" + this.nick.Substring (0, 7);
// Key to turn the channel access more safely.
this.announcements_password =
SparkleConfig.DefaultConfig.GetConfigOption ("announcements_password");
// 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);
this.client = new IrcClient () {
@ -108,7 +125,18 @@ namespace SparkleLib {
foreach (string channel in base.channels) {
SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel);
this.client.RfcJoin (channel);
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 (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");
}
}
this.client.RfcMode (channel, "+s");
}
@ -136,7 +164,18 @@ namespace SparkleLib {
if (IsConnected) {
SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel);
this.client.RfcJoin (channel);
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 (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");
}
}
this.client.RfcMode (channel, "+s");
}
}