Exemplo n.º 1
0
        public override void Kill()

        {
            if (this.listener != null)

            {
                this.listener.InvalidUrl -= new EventHandler(listener_InvalidUrl);

                this.listener.Connected -= new EventHandler(listener_Connected);

                this.listener.Disconnected -= new EventHandler(listener_Disconnected);

                this.listener.NotificationReceived -= new EventHandler <NotifyIOListener.NotificationReceivedEventArgs>(listener_NotificationReceived);

                this.listener.Stop();

                this.listener.Dispose();

                this.listener = null;



                string additionalInfo = (this.Enabled ? String.Empty : null);

                ChangeStatus(false, additionalInfo);
            }
        }
Exemplo n.º 2
0
        public override void Subscribe()

        {
            if (this.Enabled && !String.IsNullOrEmpty(this.OutletUrl))

            {
                Kill();



                ChangeStatus(false, Properties.Resources.LiteralString_Status_Connecting);



                this.listener = new NotifyIOListener(this.OutletUrl, null);

                this.listener.InvalidUrl += new EventHandler(listener_InvalidUrl);

                this.listener.Connected += new EventHandler(listener_Connected);

                this.listener.Disconnected += new EventHandler(listener_Disconnected);

                this.listener.NotificationReceived += new EventHandler <NotifyIOListener.NotificationReceivedEventArgs>(listener_NotificationReceived);

                this.listener.Start();
            }
        }
        public override void Kill()
        {
            if (this.listener != null)
            {
                this.listener.InvalidUrl -= new EventHandler(listener_InvalidUrl);
                this.listener.Connected -= new EventHandler(listener_Connected);
                this.listener.Disconnected -= new EventHandler(listener_Disconnected);
                this.listener.NotificationReceived -= new EventHandler<NotifyIOListener.NotificationReceivedEventArgs>(listener_NotificationReceived);
                this.listener.Stop();
                this.listener.Dispose();
                this.listener = null;

                string additionalInfo = (this.Enabled ? String.Empty : null);
                ChangeStatus(false, additionalInfo);
            }
        }
        void listener_NotificationReceived(object sender, NotifyIOListener.NotificationReceivedEventArgs e)
        {
            // register first (TODO: maybe keep a list of already-registered sources?)
            Growl.Connector.Application app = new Growl.Connector.Application(e.Source);
            app.Icon = (String.IsNullOrEmpty(e.Icon) ? e.SourceIcon : e.Icon);
            Register(app, new NotificationType[] { this.nt });

            // wait just a bit to make sure the registration went through (we are on another thread here, so it is ok)
            System.Threading.Thread.Sleep(500);

            // send notification
            Notification n = new Notification(app.Name, this.nt.Name, "", Fixup(e.Title, Properties.Resources.NotifyIO_NotificationType), Fixup(e.Text));
            n.Icon = e.Icon;
            n.Sticky = e.Sticky;
            CallbackContext c = null;
            if (!String.IsNullOrEmpty(e.Link))
            {
                c = new CallbackContext(e.Link);
            }
            Notify(n, c);
        }
        public override void Subscribe()
        {
            if (this.Enabled && !String.IsNullOrEmpty(this.OutletUrl))
            {
                Kill();

                ChangeStatus(false, Properties.Resources.LiteralString_Status_Connecting);

                this.listener = new NotifyIOListener(this.OutletUrl, null);
                this.listener.InvalidUrl += new EventHandler(listener_InvalidUrl);
                this.listener.Connected += new EventHandler(listener_Connected);
                this.listener.Disconnected += new EventHandler(listener_Disconnected);
                this.listener.NotificationReceived += new EventHandler<NotifyIOListener.NotificationReceivedEventArgs>(listener_NotificationReceived);
                this.listener.Start();
            }
        }