Ejemplo n.º 1
0
        public static Growl.Destinations.DestinationSettingsPanel GetSettingsPanel(Growl.Destinations.ForwardDestination fd)
        {
            IForwardDestinationHandler handler = GetHandler(fd);

            Growl.Destinations.DestinationSettingsPanel panel = handler.GetSettingsPanel(fd);
            return(panel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when a notification is received by GfW.
        /// </summary>
        /// <param name="notification">The notification information</param>
        /// <param name="callbackContext">The callback context.</param>
        /// <param name="requestInfo">The request info.</param>
        /// <param name="isIdle"><c>true</c> if the user is currently idle;<c>false</c> otherwise</param>
        /// <param name="callbackFunction">The function GfW will run if this notification is responded to on the forwarded computer</param>
        /// <remarks>
        /// Unless your forwarder is going to handle socket-style callbacks from the remote computer, you should ignore
        /// the <paramref name="callbackFunction"/> parameter.
        /// </remarks>
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardDestination.ForwardedNotificationCallbackHandler callbackFunction)
        {
            // check for request loop
            if ((notification.ApplicationName == "Notifo") &&
                notification.CustomTextAttributes.ContainsKey("NotifoUsername") &&
                notification.CustomTextAttributes["NotifoUsername"].Equals(this.Username))
            {
                Growl.CoreLibrary.DebugInfo.WriteLine(String.Format("Aborted forwarding due to circular notification (username:{0})", this.Username));
                return;
            }

            try
            {
                WebRequest wr = WebRequest.Create(new Uri("https://api.notifo.com/v1/send_notification"));
                wr.Method = "POST";
                wr.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(this.Username + ":" + this.Apikey)));
                wr.ContentType = "application/x-www-form-urlencoded";
                ((HttpWebRequest)wr).UserAgent = "Growl Notifo Forwarder";

                string body = "msg=" + System.Uri.EscapeDataString(notification.Text);
                body += "&title=" + System.Uri.EscapeDataString(notification.Title);
                body += "&label=" + System.Uri.EscapeDataString(notification.ApplicationName);

                byte[] message = Encoding.ASCII.GetBytes(body);
                wr.GetRequestStream().Write(message, 0, message.Length);
                wr.GetRequestStream().Close();

                WebResponse response = wr.GetResponse();
                response.Close();
            }
            catch (Exception ex)
            {
                string msg = String.Format("Notifo forwarding failed: {0}", ex.Message);
                // System.Windows.Forms.MessageBox.Show(msg);
                // this is an example of writing to the main GfW debug log:
                Growl.CoreLibrary.DebugInfo.WriteLine(msg);
            }
        }
 /// </summary>
 /// <param name="notification">The notification information</param>
 /// <summary>
 /// Called when a notification is received by GfW.
 /// </summary>
 /// <param name="notification">The notification information</param>
 /// <param name="callbackContext">The callback context.</param>
 /// <param name="requestInfo">The request info.</param>
 /// <param name="isIdle"><c>true</c> if the user is currently idle;<c>false</c> otherwise</param>
 /// <param name="callbackFunction">The function GfW will run if this notification is responded to on the forwarded computer</param>
 public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardDestination.ForwardedNotificationCallbackHandler callbackFunction)
 {
     if ((isIdle == false && sendIfIdle == true) || !((int)notification.Priority >= converttolocal(this.selectedpriority)))
       {
        return;
       }
     try
     {
         QuerystringBuilder qsb = new QuerystringBuilder();
         qsb.Add("token", APP_API_KEY);
         qsb.Add("user", api);
         qsb.Add("title", notification.Title);
         qsb.Add("sound", sounds[selectedSound]);
         qsb.Add("message",notification.Text);
         qsb.Add("priority", ConvertNotificationStyle(notification));
         if (selectedSound != 0)
         {
             qsb.Add("sound", sounds[selectedSound]);
         }
         if (device.Length > 0)
         {
             qsb.Add("device", device);
         }
         string data = qsb.ToPostData();
         Growl.CoreLibrary.WebClientEx wc = new Growl.CoreLibrary.WebClientEx();
         using (wc)
         {
             wc.Headers.Add(HttpRequestHeader.UserAgent, "Pushover GfW Plugin/1.0");
             string result = wc.UploadString(DEST, data);
             Console.WriteLine(result);
         }
     }
     catch (Exception ex)
     {
         Growl.CoreLibrary.DebugInfo.WriteLine(String.Format("Pushover forwarding failed: {0}", ex.Message));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Called when a notification is received by GfW.
        /// </summary>
        /// <param name="notification">The notification information</param>
        /// <param name="callbackContext">The callback context.</param>
        /// <param name="requestInfo">The request info.</param>
        /// <param name="isIdle"><c>true</c> if the user is currently idle;<c>false</c> otherwise</param>
        /// <param name="callbackFunction">The function GfW will run if this notification is responded to on the forwarded computer</param>
        /// <remarks>
        /// Unless your forwarder is going to handle socket-style callbacks from the remote computer, you should ignore
        /// the <paramref name="callbackFunction"/> parameter.
        /// </remarks>
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardDestination.ForwardedNotificationCallbackHandler callbackFunction)
        {
            try
            {
                QuerystringBuilder qsb = new QuerystringBuilder();
                qsb.Add("app", notification.ApplicationName);
                qsb.Add("id", notification.ID);
                qsb.Add("type", notification.Name);
                qsb.Add("title", notification.Title);
                qsb.Add("text", notification.Text);
                qsb.Add("sticky", notification.Sticky);
                qsb.Add("priority", (int)notification.Priority);
                qsb.Add("coalescingid", notification.CoalescingID);
                if (notification.CustomTextAttributes != null)
                {
                    foreach (KeyValuePair<string, string> item in notification.CustomTextAttributes)
                    {
                        qsb.Add(item.Key, item.Value);
                    }
                }

                string data = qsb.ToPostData();
                Growl.CoreLibrary.WebClientEx wc = new Growl.CoreLibrary.WebClientEx();
                using (wc)
                {
                    wc.Headers.Add(HttpRequestHeader.UserAgent, "Growl for Windows Webhook Plugin/1.0");
                    string result = wc.UploadString(this.url, data);
                    Console.WriteLine(result);
                }
            }
            catch (Exception ex)
            {
                // this is an example of writing to the main GfW debug log:
                Growl.CoreLibrary.DebugInfo.WriteLine(String.Format("Webhook forwarding failed: {0}", ex.Message));
            }
        }