protected void HandleForwarding(Growl.Connector.Notification notification, Growl.Daemon.CallbackInfo callbackInfo, Growl.Connector.RequestInfo requestInfo, List<string> limitToTheseComputers)
        {
            bool limit = (limitToTheseComputers != null);
            foreach (ForwardDestination fc in this.forwards.Values)
            {
                if ((!limit || limitToTheseComputers.Contains(fc.Key)) && (fc.EnabledAndAvailable))
                {
                    try
                    {
                        Growl.Connector.CallbackContext context = null;
                        ForwardDestination.ForwardedNotificationCallbackHandler callback = null;
                        if (callbackInfo != null)
                        {
                            context = callbackInfo.Context;
                            callbackInfo.ForwardedNotificationCallback += new Growl.Daemon.CallbackInfo.ForwardedNotificationCallbackHandler(growl_ForwardedNotificationCallback);
                            callback = new ForwardDestination.ForwardedNotificationCallbackHandler(callbackInfo.HandleCallbackFromForwarder);
                        }

                        requestInfo.SaveHandlingInfo(String.Format("Forwarding to {0} ({1})", fc.Description, fc.AddressDisplay));
                        fc.ForwardNotification(notification, context, requestInfo, this.activityMonitor.IsIdle, callback);
                    }
                    catch
                    {
                        // swallow any exceptions and move on to the next forwarded computer in the list
                        // this way, if one computer configuration is bad (invalid port or whatever), the rest are not affected
                    }
                }
                else
                {
                    requestInfo.SaveHandlingInfo(String.Format("Not forwarded to {0} ({1}) - ({2})", fc.Description, fc.AddressDisplay, (limit ? "disallowed by preferences" : (fc.Enabled ? "offline" : "disabled"))));
                }
            }
        }
        public override void ForwardRegistration(Growl.Connector.Application application, List<Growl.Connector.NotificationType> notificationTypes, Growl.Connector.RequestInfo requestInfo, bool isIdle)
        {
            // IGNORE REGISTRATION NOTIFICATIONS (since we have no way of filtering out already-registered apps at this point)
            //Send(application.Name, Properties.Resources.SystemNotification_AppRegistered_Title, String.Format(Properties.Resources.SystemNotification_AppRegistered_Text, application.Name));

            requestInfo.SaveHandlingInfo("Forwarding to Toasty cancelled - Application Registrations are not forwarded.");
        }
 protected void HandleForwarding(Growl.Connector.Application application, List<Growl.Connector.NotificationType> notificationTypes, Growl.Connector.RequestInfo requestInfo, List<string> limitToTheseComputers)
 {
     bool limit = (limitToTheseComputers != null);
     foreach (ForwardDestination fc in this.forwards.Values)
     {
         if ((!limit || limitToTheseComputers.Contains(fc.Key)) && (fc.EnabledAndAvailable))
         {
             try
             {
                 requestInfo.SaveHandlingInfo(String.Format("Forwarding to {0} ({1})", fc.Description, fc.AddressDisplay));
                 fc.ForwardRegistration(application, notificationTypes, requestInfo, this.activityMonitor.IsIdle);
             }
             catch
             {
                 // swallow any exceptions and move on to the next forwarded computer in the list
                 // this way, if one computer configuration is bad (invalid port or whatever), the rest are not affected
             }
         }
         else
         {
             requestInfo.SaveHandlingInfo(String.Format("Not forwarded to {0} ({1}) - ({2})", fc.Description, fc.AddressDisplay, (limit ? "disallowed by preferences" : (fc.Enabled ? "offline" : "disabled"))));
         }
     }
 }
        private void ShowNotification(Growl.DisplayStyle.Notification notification, Display display, Growl.Daemon.CallbackInfo cbInfo, bool recordInMissedNotifications, Growl.Connector.RequestInfo requestInfo)
        {
            // could be cross-thread, so check for invokerequired
            if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
            {
                MethodInvoker invoker = new MethodInvoker(delegate()
                {
                    ShowNotification(notification, display, cbInfo, recordInMissedNotifications, requestInfo);
                });

                this.synchronizingObject.Invoke(invoker, null);
            }
            else
            {
                if (display == null) display = this.growlDefaultDisplay;

                // if not a system notification and we are paused, dont show
                if (recordInMissedNotifications && paused)
                {
                    display = Display.None;
                    requestInfo.SaveHandlingInfo(String.Format("Not shown - {0}", (paused ? "Paused" : "Idle")));
                }
                else
                {
                    requestInfo.SaveHandlingInfo(String.Format("Displayed using '{0}' {1}", display.Name, (display.IsDefault ? "(" + display.ActualName + ")" : "")));
                }

                display.ProcessNotification(notification, cbInfo, requestInfo);
                this.lastUsedDisplay = display;
            }
        }
 public override void ForwardRegistration(Growl.Connector.Application application, List<Growl.Connector.NotificationType> notificationTypes, Growl.Connector.RequestInfo requestInfo, bool isIdle)
 {
     // IGNORE REGISTRATION NOTIFICATIONS
     requestInfo.SaveHandlingInfo("Forwarding to Email cancelled - Application Registrations are not forwarded.");
 }
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardedNotificationCallbackHandler callbackFunction)
        {
            bool send = true;

            // if a minimum priority is set, check that
            if (this.MinimumPriority != null && this.MinimumPriority.HasValue && notification.Priority < this.MinimumPriority.Value)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Email ({0}) cancelled - Notification priority must be at least '{1}' (was actually '{2}').", this.Description, this.MinimumPriority.Value.ToString(), notification.Priority.ToString()));
                send = false;
            }

            // if only sending when idle, check that
            if (this.OnlyWhenIdle && !isIdle)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Email ({0}) cancelled - Currently only configured to forward when idle", this.Description));
                send = false;
            }

            if (send)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarded to Email '{0}' - Minimum Priority:'{1}', Actual Priority:'{2}'", this.Description, (this.MinimumPriority != null && this.MinimumPriority.HasValue ? this.MinimumPriority.Value.ToString() : "<any>"), notification.Priority.ToString()));

                string format = "Application: {0}\r\n\r\n{1}\r\n\r\n{2}\r\n\r\nSent From: {3} - {4}";
                string message = String.Format(format, notification.ApplicationName, notification.Title, notification.Text, notification.MachineName, DateTime.Now.ToString());
                Send(notification.ApplicationName, notification.Title, notification.Priority, message);
            }
        }
Beispiel #7
0
        private void ShowNotification(Growl.DisplayStyle.Notification notification, Display display, Growl.Daemon.CallbackInfo cbInfo, bool recordInMissedNotifications, Growl.Connector.RequestInfo requestInfo)
        {
            // could be cross-thread, so check for invokerequired
            if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
            {
                MethodInvoker invoker = new MethodInvoker(delegate()
                {
                    ShowNotification(notification, display, cbInfo, recordInMissedNotifications, requestInfo);
                });

                this.synchronizingObject.Invoke(invoker, null);
            }
            else
            {
                if (display == null) display = this.growlDefaultDisplay;

                // check for fullscreen handling
                if (!paused && (this.AutoPauseFullscreen && this.fullscreenHelper.IsFullScreenAppActive()))
                {
                    Utility.WriteDebugInfo("Fullscreen app detected - automatically pausing Growl");
                    ApplicationMain.Program.Pause(true);
                    this.fullscreenHelper.StartChecking();
                }

                // if not a system notification and we are paused, dont show
                if (recordInMissedNotifications && paused)
                {
                    display = Display.None;
                    requestInfo.SaveHandlingInfo(String.Format("Not shown - {0}", (paused ? "Paused" : "Idle")));
                }
                else
                {
                    requestInfo.SaveHandlingInfo(String.Format("Displayed using '{0}' {1}", display.Name, (display.IsDefault ? "(" + display.ActualName + ")" : "")));
                }

                display.ProcessNotification(notification, cbInfo, requestInfo);
                this.lastUsedDisplay = display;
            }
        }