diff --git a/SparkleLib/SparkleListener.cs b/SparkleLib/SparkleListener.cs index dab3731d..78c70761 100644 --- a/SparkleLib/SparkleListener.cs +++ b/SparkleLib/SparkleListener.cs @@ -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,14 +48,23 @@ 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) { - // 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 (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"); diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 7055c7a1..e80f17c3 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -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 () {