private void SendConfirmation(ToastyForwardDestination tfd)
 {
     // always use Emergency priority in case they have it configured to restrict by priority
     Growl.Connector.Notification notification = new Growl.Connector.Notification("Growl", "Toasty Test", null, "Toasty Test", "You have successfully configured Growl to forward notifications to Toasty", Properties.Resources.toasty, false, Growl.Connector.Priority.Emergency, null);
     // always use isIdle in case they have it configured to only send when idle
     tfd.ForwardNotification(notification, null, null, true, null);
 }
Exemplo n.º 2
0
Arquivo: Form1.cs Projeto: yeka/WPanel
        public void growlNotify(string title, string message, ToolTipIcon bicon)
        {
            string basedir = Application.StartupPath + Path.DirectorySeparatorChar + "lib" + Path.DirectorySeparatorChar;
            string icon    = "";

            if (bicon == ToolTipIcon.Info)
            {
                icon = basedir + "Accept.png";
            }
            else if (bicon == ToolTipIcon.Warning)
            {
                icon = basedir + "Warning.png";
            }
            else if (bicon == ToolTipIcon.Error)
            {
                icon = basedir + "Delete.png";
            }
            Growl.Connector.Notification notification = new Growl.Connector.Notification(
                growlapp.Name,                   //application name
                notificationType.Name,           // notification name
                DateTime.Now.Ticks.ToString(),   // id
                title,                           // title
                message,                         // message
                icon,                            // icon, image location
                false,                           // stricky
                Growl.Connector.Priority.Normal, // priority
                ""                               // coalescingID
                );
            growl.Notify(notification);
        }
Exemplo n.º 3
0
 private void SendConfirmation(ProwlForwardDestination pfd)
 {
     // always use Emergency priority in case they have it configured to restrict by priority
     Growl.Connector.Notification notification = new Growl.Connector.Notification(Properties.Resources.SystemNotification_ApplicationName, Properties.Resources.ProwlConfirmation_Title, null, Properties.Resources.ProwlConfirmation_Title, Properties.Resources.ProwlConfirmation_Text, null, false, Growl.Connector.Priority.Emergency, null);
     // always use isIdle in case they have it configured to only send when idle
     pfd.ForwardNotification(notification, null, null, true, null);
 }
 /// <summary>
 /// Triggers a notification
 /// </summary>
 /// <param name="notification">The <see cref="Growl.Connector.Notification"/> to display</param>
 /// <param name="callbackContext">The <see cref="Growl.Connector.CallbackContext"/> of the notification</param>
 protected void Notify(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext)
 {
     if (this.Enabled)
     {
         this.growl.Notify(notification, callbackContext);
     }
 }
 /// <summary>
 /// Triggers a notification
 /// </summary>
 /// <param name="notification">The <see cref="Growl.Connector.Notification"/> to display</param>
 protected void Notify(Growl.Connector.Notification notification)
 {
     if (this.Enabled)
     {
         Notify(notification, null);
     }
 }
        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);
            }
        }
Exemplo n.º 7
0
        private void SendNotification(object info)
        {
            BuildInfo buildInfo = (BuildInfo)info;

            if (Properties.Settings.Default.EnableNotifications)
            {
                int    index = buildInfo.Name.IndexOf('\\');
                string name  = buildInfo.Name;
                if (index > 0)
                {
                    name = name.Substring(0, index);
                }

                string title     = String.Format("Build {0}", (buildInfo.Success ? "succeeded" : "failed"));
                string text      = String.Format("{0} '{1}' {2}.", (buildInfo.IsSolution ? "Solution" : "Project"), name, (buildInfo.Success ? "was built successfully" : "failed to build"));
                byte[] iconBytes = (buildInfo.Success ? this.successIcon : this.failureIcon);
                Growl.CoreLibrary.BinaryData icon = new Growl.CoreLibrary.BinaryData(iconBytes);

                Growl.Connector.NotificationType nt = null;
                if (buildInfo.IsSolution)
                {
                    nt = (buildInfo.Success ? this.ntSolutionSuccess : this.ntSolutionFailed);
                }
                else
                {
                    nt = (buildInfo.Success ? this.ntProjectSuccess : this.ntProjectFailed);
                }

                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, nt.Name, String.Empty, title, text, icon, false, Growl.Connector.Priority.Normal, null);

                this.growl.Notify(notification);
            }
        }
Exemplo n.º 8
0
        void Notify(object iTrack)
        {
            if (!Properties.Settings.Default.DisableNotifications)
            {
                IITTrack song = (IITTrack)iTrack;
                string title = Escape(song.Name);
                string text = String.Format("{0}\n{1}", Escape(song.Artist), Escape(song.Album));
                // this handles streaming radio stations
                if (this.CurrentStreamTitle != null)
                {
                    title = Escape(this.CurrentStreamTitle);
                    text = String.Format("Station: {0}", Escape(song.Name));
                }

                // TODO:
                string artworkFilePath = null;
                byte[] artworkData = null;
                if (song.Artwork != null && song.Artwork.Count > 0)
                {
                    string safeAlbumName = GetSafeFileName(song.Album);
                    string filename = String.Format("{0}.jpg", safeAlbumName);
                    artworkFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename);
                    if (!System.IO.File.Exists(artworkFilePath))
                        song.Artwork[1].SaveArtworkToFile(artworkFilePath);
                    artworkData = System.IO.File.ReadAllBytes(artworkFilePath);
                }

                // old
                if (Properties.Settings.Default.SendUDPNotifications)
                {
                    udpGrowl.Notify(udpNotificationType, title, text, Growl.Connector.Priority.Normal, false);
                }

                // new
                if (Properties.Settings.Default.SendGNTPNotifications)
                {
                    int sourceID;
                    int playlistID;
                    int trackID;
                    int databaseID;
                    song.GetITObjectIDs(out sourceID, out playlistID, out trackID, out databaseID);

                    Growl.Connector.CallbackContext callback = new Growl.Connector.CallbackContext("song", String.Format("{0}|{1}|{2}|{3}", sourceID, playlistID, trackID, databaseID));

                    //Growl.CoreLibrary.Resource albumIcon = artworkFilePath;
                    Growl.CoreLibrary.Resource albumIcon = (artworkData != null ? new Growl.CoreLibrary.BinaryData(artworkData) : null);
                    Growl.Connector.Notification notification = new Growl.Connector.Notification(application.Name, nt1.Name, id, title, text, albumIcon, false, Growl.Connector.Priority.Normal, id);

                    notification.CustomTextAttributes.Add("iTunes-Artist", song.Artist);
                    notification.CustomTextAttributes.Add("iTunes-Album", song.Album);
                    notification.CustomTextAttributes.Add("iTunes-Duration", song.Duration.ToString());
                    notification.CustomTextAttributes.Add("iTunes-PlayedCount", song.PlayedCount.ToString());
                    notification.CustomTextAttributes.Add("iTunes-Genre", song.Genre);
                    notification.CustomTextAttributes.Add("iTunes-Rating", song.Rating.ToString());

                    growl.Notify(notification, callback);
                }
            }
        }
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardedNotificationCallbackHandler callbackFunction)

        {
            Growl.UDPLegacy.NotificationType nt = new Growl.UDPLegacy.NotificationType(notification.Name, true);

            Growl.UDPLegacy.MessageSender netgrowl = new Growl.UDPLegacy.MessageSender(this.IPAddress, this.Port, notification.ApplicationName, this.Password);

            netgrowl.Notify(nt, notification.Title, notification.Text, notification.Priority, notification.Sticky);
        }
        void ThisApplication_Reminder(object item)
        {
            if (Properties.Settings.Default.EnableReminderNotifications)
            {
                string title;
                string reminderMsg;
                string data;
                string type;

                if (item is Outlook.MailItem)
                {
                    Outlook.MailItem reminderMail;
                    reminderMail = (Outlook.MailItem)item;
                    title        = "Outlook Mail Reminder";
                    reminderMsg  = String.Format("{0}\n\nReminder time: {1:t}", reminderMail.Subject, reminderMail.ReminderTime);
                    data         = reminderMail.EntryID;
                    type         = "remindermail";
                }
                else if (item is Outlook.AppointmentItem)
                {
                    Outlook.AppointmentItem reminderAppt;
                    reminderAppt = (Outlook.AppointmentItem)item;
                    title        = "Outlook Appointment Reminder";
                    reminderMsg  = String.Format("{0}\n\nLocation: {1}\nReminder time: {2:t}", reminderAppt.Subject, reminderAppt.Location, reminderAppt.Start);
                    data         = reminderAppt.EntryID;
                    type         = "reminderappointment";
                }
                else if (item is Outlook.TaskItem)
                {
                    Outlook.TaskItem reminderTask;
                    reminderTask = (Outlook.TaskItem)item;
                    title        = "Outlook Task Reminder";
                    reminderMsg  = String.Format("{0}\n\nReminder time: {1:t}", reminderTask.Subject, reminderTask.ReminderTime);
                    data         = reminderTask.EntryID;
                    type         = "remindertask";
                }
                else
                {
                    // Unsupported item
                    return;
                }

                // send to growl
                Growl.Connector.Notification    notification    = new Growl.Connector.Notification(this.application.Name, reminder.Name, String.Empty, title, reminderMsg);
                Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext(data, type);
                growl.Notify(notification, callbackContext);
            }
        }
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardedNotificationCallbackHandler callbackFunction)
        {
            bool send = true;

            if (requestInfo == null)
            {
                requestInfo = new Growl.Connector.RequestInfo();
            }

            // 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 Prowl ({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 (send && this.OnlyWhenIdle && !isIdle)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Prowl ({0}) cancelled - Currently only configured to forward when idle", this.Description));
                send = false;
            }

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

                string text = notification.Text;

                /* NOT YET
                 * // this appends the url from a url callback to the Prowl message (if specified)
                 * // this allows the user to click the url right from their Prowl app
                 * if (callbackInfo != null && callbackInfo.Context != null)
                 * {
                 *  string url = callbackInfo.Context.CallbackUrl;
                 *  if (!String.IsNullOrEmpty(url))
                 *  {
                 *      text += String.Format(" - {0}", url);
                 *  }
                 * }
                 * */

                Send(notification.ApplicationName, notification.Title, text, notification.Priority);
            }
        }
Exemplo n.º 12
0
        public static string getPathToIcon(Growl.Connector.Notification notification)
        {
            string returnValue = "";

            if (notification.Icon.IsSet)
            {
                if (notification.Icon.IsUrl)
                {
                    returnValue = notification.Icon.Url;
                }
                else
                {
                    returnValue = Path.GetTempFileName();
                    System.Drawing.Image Icon = notification.Icon;
                    Icon.Save(returnValue);
                }
            }
            return(returnValue);
        }
Exemplo n.º 13
0
        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 Twitter ({0}) cancelled - Notification priority must be at least '{1}' (was actually '{2}').", this.Username, 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 Twitter ({0}) cancelled - Currently only configured to forward when idle", this.Username));
                send = false;
            }

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

                string message = this.format;
                message = message.Replace(PLACEHOLDER_APPNAME, notification.ApplicationName);
                message = message.Replace(PLACEHOLDER_TITLE, notification.Title);
                message = message.Replace(PLACEHOLDER_TEXT, notification.Text);
                message = message.Replace(PLACEHOLDER_PRIORITY, PrefPriority.GetFriendlyName(notification.Priority));
                message = message.Replace(PLACEHOLDER_SENDER, notification.MachineName);
                //Utility.WriteLine(message);

                // trim
                if (message.Length > 140)
                {
                    message = message.Substring(0, 140);
                }
                //byte[] bytes = System.Text.Encoding.UTF8.GetBytes("status=" + message);
                string data = "status=" + message;

                // send async (using threads instead of async WebClient/HttpWebRequest methods since they seem to have a bug with KeepAlives in infrequent cases)
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendAsync), data);
            }
        }
Exemplo n.º 14
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));
            }
        }
Exemplo n.º 15
0
 private void SendConfirmation(ToastyForwardDestination tfd)
 {
     // always use Emergency priority in case they have it configured to restrict by priority
     Growl.Connector.Notification notification = new Growl.Connector.Notification("Growl", "Toasty Test", null, "Toasty Test", "You have successfully configured Growl to forward notifications to Toasty", Properties.Resources.toasty, false, Growl.Connector.Priority.Emergency, null);
     // always use isIdle in case they have it configured to only send when idle
     tfd.ForwardNotification(notification, null, null, true, null);
 }
        public override void ForwardNotification(Growl.Connector.Notification notification, Growl.Connector.CallbackContext callbackContext, Growl.Connector.RequestInfo requestInfo, bool isIdle, ForwardedNotificationCallbackHandler callbackFunction)
        {
            bool send = true;

            if (requestInfo == null)
            {
                requestInfo = new Growl.Connector.RequestInfo();
            }

            // if this notification originated from Toasty in the first place, dont re-forward it
            if (((notification.ApplicationName == "Toasty") && notification.CustomTextAttributes.ContainsKey("ToastyDeviceID")) && notification.CustomTextAttributes["ToastyDeviceID"].Equals(this.DeviceID, StringComparison.InvariantCultureIgnoreCase))
            {
                requestInfo.HandlingInfo.Add(String.Format("Aborted forwarding due to circular notification (deviceID:{0})", this.DeviceID));
                send = false;
            }

            // if a minimum priority is set, check that
            if (send && this.MinimumPriority != null && this.MinimumPriority.HasValue && notification.Priority < this.MinimumPriority.Value)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Toasty ({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 (send && this.OnlyWhenIdle && !isIdle)
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Toasty ({0}) cancelled - Currently only configured to forward when idle", this.Description));
                send = false;
            }

            // if quiet hours enabled, check that
            if (send && DuringQuietHours())
            {
                requestInfo.SaveHandlingInfo(String.Format("Forwarding to Toasty ({0}) cancelled - Quiet hours enabled on {1} from {2} to {3}. Current time: {4} {5}", this.Description, this.QuietHoursDaysChoice, this.QuietHoursStart.ToShortTimeString(), this.QuietHoursEnd.ToShortTimeString(), DateTime.Now.DayOfWeek, DateTime.Now.ToShortTimeString()));
                send = false;
            }

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

                string url = BuildUrl(NOTIFY_URL_FORMAT, this.DeviceID);

                System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection();
                data.Add("target", this.DeviceID);
                data.Add("sender", notification.ApplicationName);
                data.Add("title", notification.Title);
                data.Add("text", notification.Text);

                byte[] bytes = null;
                if (notification.Icon != null && notification.Icon.IsSet)
                {
                    System.Drawing.Image image = (System.Drawing.Image)notification.Icon;
                    using (image)
                    {
                        bytes = GenerateThumbnail(image, 128, 128);
                    }
                }

                APIRequestInfo info = new APIRequestInfo();
                info.RequestInfo = requestInfo;
                info.Url         = url;
                info.Data        = data;
                info.ImageBytes  = bytes;

                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendAsync), info);
            }
        }
Exemplo n.º 17
0
        void Notify(object iTrack)
        {
            if (!Properties.Settings.Default.DisableNotifications)
            {
                IITTrack song = (IITTrack)iTrack;
                string title = Escape(song.Name);
                string text = String.Format("{0}\n{1}", Escape(song.Artist), Escape(song.Album));
                // this handles streaming radio stations
                if (this.CurrentStreamTitle != null)
                {
                    title = Escape(this.CurrentStreamTitle);
                    text = String.Format("Station: {0}", Escape(song.Name));
                }

                // TODO:
                string artworkFilePath = null;
                byte[] artworkData = null;
                if (song.Artwork != null && song.Artwork.Count > 0)
                {
                    string safeAlbumName = GetSafeFileName(song.Album);
                    string filename = String.Format("{0}.jpg", safeAlbumName);
                    artworkFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename);
                    if (!System.IO.File.Exists(artworkFilePath))
                        song.Artwork[1].SaveArtworkToFile(artworkFilePath);
                    artworkData = System.IO.File.ReadAllBytes(artworkFilePath);
                }

                // old
                if (Properties.Settings.Default.SendUDPNotifications)
                {
                    udpGrowl.Notify(udpNotificationType, title, text, Growl.Connector.Priority.Normal, false);
                }

                // new
                if (Properties.Settings.Default.SendGNTPNotifications)
                {
                    int sourceID;
                    int playlistID;
                    int trackID;
                    int databaseID;
                    song.GetITObjectIDs(out sourceID, out playlistID, out trackID, out databaseID);

                    Growl.Connector.CallbackContext callback = new Growl.Connector.CallbackContext("song", String.Format("{0}|{1}|{2}|{3}", sourceID, playlistID, trackID, databaseID));

                    //Growl.CoreLibrary.Resource albumIcon = artworkFilePath;
                    Growl.CoreLibrary.Resource albumIcon = (artworkData != null ? new Growl.CoreLibrary.BinaryData(artworkData) : null);
                    Growl.Connector.Notification notification = new Growl.Connector.Notification(application.Name, nt1.Name, callback.Data, title, text, albumIcon, false, Growl.Connector.Priority.Normal, null);

                    notification.CustomTextAttributes.Add("iTunes-Artist", song.Artist);
                    notification.CustomTextAttributes.Add("iTunes-Album", song.Album);
                    notification.CustomTextAttributes.Add("iTunes-Duration", song.Duration.ToString());
                    notification.CustomTextAttributes.Add("iTunes-PlayedCount", song.PlayedCount.ToString());
                    notification.CustomTextAttributes.Add("iTunes-Genre", song.Genre);
                    notification.CustomTextAttributes.Add("iTunes-Rating", song.Rating.ToString());

                    growl.Notify(notification, callback);
                }
            }
        }
Exemplo n.º 18
0
 public Notification()
 {
     this.n = new Growl.Connector.Notification(null, null, null, null, null);
 }
Exemplo n.º 19
0
        private void SendNotification(object info)
        {
            BuildInfo buildInfo = (BuildInfo)info;

            if (Properties.Settings.Default.EnableNotifications)
            {
                int index = buildInfo.Name.IndexOf('\\');
                string name = buildInfo.Name;
                if (index > 0) name = name.Substring(0, index);

                string title = String.Format("Build {0}", (buildInfo.Success ? "succeeded" : "failed"));
                string text = String.Format("{0} '{1}' {2}.", (buildInfo.IsSolution ? "Solution" : "Project"), name, (buildInfo.Success ? "was built successfully" : "failed to build"));
                byte[] iconBytes = (buildInfo.Success ? this.successIcon : this.failureIcon);
                Growl.CoreLibrary.BinaryData icon = new Growl.CoreLibrary.BinaryData(iconBytes);

                Growl.Connector.NotificationType nt = null;
                if(buildInfo.IsSolution)
                {
                    nt = (buildInfo.Success ? this.ntSolutionSuccess : this.ntSolutionFailed);
                }
                else
                {
                    nt = (buildInfo.Success ? this.ntProjectSuccess : this.ntProjectFailed);
                }

                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, nt.Name, String.Empty, title, text, icon, false, Growl.Connector.Priority.Normal, null);

                this.growl.Notify(notification);
            }
        }
Exemplo n.º 20
0
 public Notification()
 {
     this.n = new Growl.Connector.Notification(null, null, null, null, null);
 }
Exemplo n.º 21
0
 private void SendConfirmation(ProwlForwardDestination pfd)
 {
     // always use Emergency priority in case they have it configured to restrict by priority
     Growl.Connector.Notification notification = new Growl.Connector.Notification(Properties.Resources.SystemNotification_ApplicationName, Properties.Resources.ProwlConfirmation_Title, null, Properties.Resources.ProwlConfirmation_Title, Properties.Resources.ProwlConfirmation_Text, null, false, Growl.Connector.Priority.Emergency, null);
     // always use isIdle in case they have it configured to only send when idle
     pfd.ForwardNotification(notification, null, null, true, null);
 }
Exemplo n.º 22
0
        void ThisApplication_NewMailEx(string EntryIDCollection)

        {
            if (Properties.Settings.Default.EnableNewMailNotifications)

            {
                if (EntryIDCollection != null)

                {
                    string title = null;

                    string text = null;



                    string[] ids = EntryIDCollection.Split(',');

                    if (ids.Length > 4)

                    {
                        title = "New Mail";

                        text = String.Format("You have {0} new messages", ids.Length);



                        Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, newmail.Name, String.Empty, title, text);

                        Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext("null", "multimessage");

                        growl.Notify(notification, callbackContext);
                    }

                    else

                    {
                        foreach (string id in ids)

                        {
                            object obj = this.Session.GetItemFromID(id.Trim(), Type.Missing);

                            if (obj is Outlook.MailItem)

                            {
                                Outlook.MailItem message = (Outlook.MailItem)obj;

                                string body = message.Body;

                                if (!String.IsNullOrEmpty(body))

                                {
                                    body = body.Replace("\r\n", "\n");

                                    body = (body.Length > 50 ? body.Substring(0, 50) + "..." : body);
                                }



                                // just saving this for future reference

                                //Outlook.MAPIFolder folder = message.Parent as Outlook.MAPIFolder;

                                //Outlook.NameSpace outlookNameSpace = this.GetNamespace("MAPI");

                                //Outlook.MAPIFolder junkFolder = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders..olFolderJunk);



                                title = message.Subject;

                                if (!String.IsNullOrEmpty(title))
                                {
                                    title = title.Trim();
                                }

                                title = (String.IsNullOrEmpty(title) ? "[No Subject]" : message.Subject);

                                text = String.Format("From: {0}\n{1}", message.SenderName, body);



                                Growl.Connector.Priority priority = Growl.Connector.Priority.Normal;

                                if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh)
                                {
                                    priority = Growl.Connector.Priority.High;
                                }

                                else if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow)
                                {
                                    priority = Growl.Connector.Priority.Moderate;
                                }



                                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, newmail.Name, String.Empty, title, text);

                                notification.Priority = priority;

                                Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext(id, "mailmessage");

                                growl.Notify(notification, callbackContext);
                            }

                            else if (obj is Outlook.MeetingItem)

                            {
                                Outlook.MeetingItem message = (Outlook.MeetingItem)obj;

                                string body = message.Body;

                                if (!String.IsNullOrEmpty(body))

                                {
                                    body = body.Replace("\r\n", "\n");

                                    body = (body.Length > 50 ? body.Substring(0, 50) + "..." : body);
                                }



                                title = message.Subject;

                                if (!String.IsNullOrEmpty(title))
                                {
                                    title = title.Trim();
                                }

                                title = (String.IsNullOrEmpty(title) ? "[No Subject]" : message.Subject);

                                text = String.Format("From: {0}\n{1}", message.SenderName, body);



                                Growl.Connector.Priority priority = Growl.Connector.Priority.Normal;

                                if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh)
                                {
                                    priority = Growl.Connector.Priority.High;
                                }

                                else if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow)
                                {
                                    priority = Growl.Connector.Priority.Moderate;
                                }



                                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, newmail.Name, String.Empty, title, text);

                                notification.Priority = priority;

                                Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext(id, "mailmessage");

                                growl.Notify(notification, callbackContext);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
        public List<string> ProcessNotification(Growl.UDPLegacy.NotificationPacket np, string receivedFrom)
        {
            /* THIS METHOD RESENDS THE UDP MESSAGE AS A LOCAL GNTP MESSAGE
            Growl.Connector.Application application = new Growl.Connector.Application(np.ApplicationName);
            Growl.Connector.Notification notification = new Growl.Connector.Notification(np.ApplicationName, np.NotificationType.Name, String.Empty, np.Title, np.Description, null, np.Sticky, np.Priority, null);

            Growl.Connector.GrowlConnector udpToGNTPForwarder = new Growl.Connector.GrowlConnector();
            udpToGNTPForwarder.Password = np.Password;
            udpToGNTPForwarder.EncryptionAlgorithm = Growl.Connector.Cryptography.SymmetricAlgorithmType.PlainText;
            udpToGNTPForwarder.Notify(application, notification);
             * */

            /* THIS METHOD AVOIDS SENDING ANOTHER MESSAGE, BUT TRADES THE DETAILED GNTP LOGGING */
            Growl.Connector.Notification notification = new Growl.Connector.Notification(np.ApplicationName, np.NotificationType.Name, String.Empty, np.Title, np.Description, null, np.Sticky, np.Priority, null);
            Growl.Connector.RequestInfo requestInfo = new Growl.Connector.RequestInfo();
            gntpListener_NotifyReceived(notification, null, requestInfo);
            List<string> extraLogInfo = (requestInfo != null ? requestInfo.HandlingInfo : null);
            return extraLogInfo;
        }
        void ThisApplication_Reminder(object item)
        {
            if (Properties.Settings.Default.EnableReminderNotifications)
            {
                string title;
                string reminderMsg;
                string data;
                string type;

                if (item is Outlook.MailItem)
                {
                    Outlook.MailItem reminderMail;
                    reminderMail = (Outlook.MailItem)item;
                    title = "Outlook Mail Reminder";
                    reminderMsg = String.Format("{0}\n\nReminder time: {1:t}", reminderMail.Subject, reminderMail.ReminderTime);
                    data = reminderMail.EntryID;
                    type = "remindermail";
                }
                else if (item is Outlook.AppointmentItem)
                {
                    Outlook.AppointmentItem reminderAppt;
                    reminderAppt = (Outlook.AppointmentItem)item;
                    title = "Outlook Appointment Reminder";
                    reminderMsg = String.Format("{0}\n\nLocation: {1}\nReminder time: {2:t}", reminderAppt.Subject, reminderAppt.Location, reminderAppt.Start);
                    data = reminderAppt.EntryID;
                    type = "reminderappointment";
                }
                else if (item is Outlook.TaskItem)
                {
                    Outlook.TaskItem reminderTask;
                    reminderTask = (Outlook.TaskItem)item;
                    title = "Outlook Task Reminder";
                    reminderMsg = String.Format("{0}\n\nReminder time: {1:t}", reminderTask.Subject, reminderTask.ReminderTime);
                    data = reminderTask.EntryID;
                    type = "remindertask";
                }
                else
                {
                    // Unsupported item
                    return;
                }

                // send to growl
                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, reminder.Name, String.Empty, title, reminderMsg);
                Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext(data, type);
                growl.Notify(notification, callbackContext);
            }
        }
        void ThisApplication_NewMailEx(string EntryIDCollection)
        {
            if (Properties.Settings.Default.EnableNewMailNotifications)
            {
                if (EntryIDCollection != null)
                {
                    string title = null;
                    string text = null;

                    string[] ids = EntryIDCollection.Split(',');
                    if (ids.Length > 4)
                    {
                        title = "New Mail";
                        text = String.Format("You have {0} new messages", ids.Length);

                        Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, newmail.Name, String.Empty, title, text);
                        Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext("null", "multimessage");
                        growl.Notify(notification, callbackContext);
                    }
                    else
                    {
                        foreach (string id in ids)
                        {
                            object obj = this.Session.GetItemFromID(id.Trim(), Type.Missing);
                            if (obj is Outlook.MailItem)
                            {
                                Outlook.MailItem message = (Outlook.MailItem)obj;
                                string body = message.Body;
                                if (!String.IsNullOrEmpty(body))
                                {
                                    body = body.Replace("\r\n", "\n");
                                    body = (body.Length > 50 ? body.Substring(0, 50) + "..." : body);
                                }

                                // just saving this for future reference
                                //Outlook.MAPIFolder folder = message.Parent as Outlook.MAPIFolder;
                                //Outlook.NameSpace outlookNameSpace = this.GetNamespace("MAPI");
                                //Outlook.MAPIFolder junkFolder = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders..olFolderJunk);

                                title = message.Subject;
                                if (!String.IsNullOrEmpty(title)) title = title.Trim();
                                title = (String.IsNullOrEmpty(title) ? "[No Subject]" : message.Subject);
                                text = String.Format("From: {0}\n{1}", message.SenderName, body);

                                Growl.Connector.Priority priority = Growl.Connector.Priority.Normal;
                                if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh) priority = Growl.Connector.Priority.High;
                                else if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow) priority = Growl.Connector.Priority.Moderate;

                                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, newmail.Name, String.Empty, title, text);
                                notification.Priority = priority;
                                Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext(id, "mailmessage");
                                growl.Notify(notification, callbackContext);
                            }
                            else if (obj is Outlook.MeetingItem)
                            {
                                Outlook.MeetingItem message = (Outlook.MeetingItem)obj;
                                string body = message.Body;
                                if (!String.IsNullOrEmpty(body))
                                {
                                    body = body.Replace("\r\n", "\n");
                                    body = (body.Length > 50 ? body.Substring(0, 50) + "..." : body);
                                }

                                title = message.Subject;
                                if (!String.IsNullOrEmpty(title)) title = title.Trim();
                                title = (String.IsNullOrEmpty(title) ? "[No Subject]" : message.Subject);
                                text = String.Format("From: {0}\n{1}", message.SenderName, body);

                                Growl.Connector.Priority priority = Growl.Connector.Priority.Normal;
                                if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh) priority = Growl.Connector.Priority.High;
                                else if (message.Importance == Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow) priority = Growl.Connector.Priority.Moderate;

                                Growl.Connector.Notification notification = new Growl.Connector.Notification(this.application.Name, newmail.Name, String.Empty, title, text);
                                notification.Priority = priority;
                                Growl.Connector.CallbackContext callbackContext = new Growl.Connector.CallbackContext(id, "mailmessage");
                                growl.Notify(notification, callbackContext);
                            }
                        }
                    }
                }
            }
        }