public SparkleListenerIrc(string server, string folder_identifier, NotificationServerType type)
            : base(server, folder_identifier, type)
        {
            base.server = server;

            // Try to get a uniqueish nickname
            this.nick = SHA1 (DateTime.Now.ToString ("ffffff") + "sparkles");

            // Most irc servers don't allow nicknames starting
            // with a number, so prefix an alphabetic character
            this.nick = "s" + this.nick.Substring (0, 7);

            base.channels.Add ("#" + folder_identifier);

            this.client = new IrcClient () {
                PingTimeout  = 180,
                PingInterval = 90
            };

            this.client.OnConnected += delegate {
                base.is_connecting = false;
                OnConnected ();
            };

            this.client.OnDisconnected += delegate {
                OnDisconnected ();
            };

            this.client.OnChannelMessage += delegate (object o, IrcEventArgs args) {
                string message = args.Data.Message.Trim ();
                string folder_id = args.Data.Channel.Substring (1); // remove the starting hash
                OnRemoteChange (new SparkleAnnouncement (folder_id, message));
            };
        }
Esempio n. 2
0
        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 (!String.IsNullOrEmpty(user_email))
            {
                Nick = SHA1(folder_name + user_email + "sparkles");
            }
            else
            {
                Nick = SHA1(DateTime.Now.ToString() + "sparkles");
            }

            Nick    = "s" + Nick.Substring(0, 7);
            Channel = "#" + SHA1(server + folder_name + "sparkles");

            Client = new IrcClient()
            {
                PingTimeout  = 180,
                PingInterval = 90
            };
        }
Esempio n. 3
0
        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
                Nick = GetSHA1 (DateTime.Now.ToString () + "sparkles");

            Nick    = "s" + Nick.Substring (0, 7);
            Channel = "#" + GetSHA1 (server + folder_name + "sparkles");

            Client = new IrcClient () {
                PingTimeout          = 180,
                PingInterval         = 90
            };
        }
 public SparkleListenerBase(string server, string folder_identifier, NotificationServerType type)
 {
 }
        public static SparkleListenerIrc CreateIrcListener(string server, string folder_identifier,
                                                            NotificationServerType type)
        {
            if (listeners == null)
                listeners = new List<SparkleListenerBase> ();

            // 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
            if (type == NotificationServerType.Central)
                server = "204.62.14.135";

            foreach (SparkleListenerBase listener in listeners) {
                if (listener.Server.Equals (server)) {
                    SparkleHelpers.DebugInfo ("ListenerFactory", "Refered to existing listener for " + server);
                    listener.AlsoListenTo (folder_identifier);
                    return (SparkleListenerIrc) listener;
                }
            }

            SparkleHelpers.DebugInfo ("ListenerFactory", "Issued new listener for " + server);
            listeners.Add (new SparkleListenerIrc (server, folder_identifier, type));
            return (SparkleListenerIrc) listeners [listeners.Count - 1];
        }