[lib] Allow disabling of central notification server and fallback to own
This commit is contained in:
parent
e04fbe9cb2
commit
7a722f52be
|
@ -25,6 +25,15 @@ using Meebey.SmartIrc4net;
|
|||
|
||||
namespace SparkleLib {
|
||||
|
||||
public enum NotificationServerType
|
||||
{
|
||||
|
||||
Own,
|
||||
Central
|
||||
|
||||
}
|
||||
|
||||
|
||||
// A persistent connection to the server that
|
||||
// listens for change notifications
|
||||
public class SparkleListener {
|
||||
|
@ -39,15 +48,24 @@ namespace SparkleLib {
|
|||
public readonly string Nick;
|
||||
|
||||
|
||||
public SparkleListener (string server, string folder_name, string user_email)
|
||||
public SparkleListener (string server, string folder_name,
|
||||
string user_email, NotificationServerType type)
|
||||
{
|
||||
|
||||
if (type == NotificationServerType.Own) {
|
||||
|
||||
Server = server;
|
||||
|
||||
} else {
|
||||
|
||||
// This is SparkleShare's centralized notification service.
|
||||
// Don't worry, we only use this server as a backup if you
|
||||
// don't have your own. All data needed to connect is hashed and
|
||||
// we don't store any personal information ever.
|
||||
Server = "204.62.14.135";
|
||||
|
||||
}
|
||||
|
||||
if (!user_email.Equals ("") && user_email != null)
|
||||
Nick = GetSHA1 (folder_name + user_email + "sparkles");
|
||||
else
|
||||
|
|
|
@ -307,7 +307,11 @@ namespace SparkleLib {
|
|||
|
||||
|
||||
// Listen to the irc channel on the server...
|
||||
Listener = new SparkleListener (Domain, RemoteName, UserEmail);
|
||||
if (UsesNotificationCenter)
|
||||
Listener = new SparkleListener (Domain, RemoteName, UserEmail, NotificationServerType.Central);
|
||||
else
|
||||
Listener = new SparkleListener (Domain, RemoteName, UserEmail, NotificationServerType.Own);
|
||||
|
||||
|
||||
// ...fetch remote changes every 60 seconds if that fails
|
||||
RemoteTimer = new Timer () {
|
||||
|
@ -1149,13 +1153,27 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
public static bool IsRepo (string path) {
|
||||
public static bool IsRepo (string path)
|
||||
{
|
||||
|
||||
return System.IO.Directory.Exists (Path.Combine (path, ".git"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public bool UsesNotificationCenter
|
||||
{
|
||||
|
||||
get {
|
||||
|
||||
string file_path = SparkleHelpers.CombineMore (LocalPath, ".git", "disable_notification_center");
|
||||
return !File.Exists (file_path);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Disposes all resourses of this object
|
||||
new public void Dispose ()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue