[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 {
|
namespace SparkleLib {
|
||||||
|
|
||||||
|
public enum NotificationServerType
|
||||||
|
{
|
||||||
|
|
||||||
|
Own,
|
||||||
|
Central
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// A persistent connection to the server that
|
// A persistent connection to the server that
|
||||||
// listens for change notifications
|
// listens for change notifications
|
||||||
public class SparkleListener {
|
public class SparkleListener {
|
||||||
|
@ -39,14 +48,23 @@ namespace SparkleLib {
|
||||||
public readonly string Nick;
|
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.
|
if (type == NotificationServerType.Own) {
|
||||||
// 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
|
Server = server;
|
||||||
// we don't store any personal information ever.
|
|
||||||
Server = "204.62.14.135";
|
} 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)
|
if (!user_email.Equals ("") && user_email != null)
|
||||||
Nick = GetSHA1 (folder_name + user_email + "sparkles");
|
Nick = GetSHA1 (folder_name + user_email + "sparkles");
|
||||||
|
|
|
@ -307,7 +307,11 @@ namespace SparkleLib {
|
||||||
|
|
||||||
|
|
||||||
// Listen to the irc channel on the server...
|
// 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
|
// ...fetch remote changes every 60 seconds if that fails
|
||||||
RemoteTimer = new Timer () {
|
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"));
|
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
|
// Disposes all resourses of this object
|
||||||
new public void Dispose ()
|
new public void Dispose ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue