Exemplo n.º 1
0
        private void Send(string applicationName, string title, string text, Growl.Connector.Priority priority)

        {
            // data

            System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection();

            data.Add("apikey", this.APIKey);

            //data.Add("providerkey", "");

            data.Add("priority", ((int)priority).ToString());

            data.Add("application", applicationName);

            data.Add("event", title);

            data.Add("description", text);



            // send async (using threads instead of async WebClient methods since they seem to have a bug with KeepAlives in infrequent cases)

            System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendAsync), data);
        }
        private void Send(string appName, string subject, Growl.Connector.Priority priority, string message)

        {
            System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();

            m.To.Add(this.to);

            m.From = new System.Net.Mail.MailAddress(this.FromAddress, appName);

            m.Subject = subject;

            m.Body = message;

            m.Priority = GetMessagePriority(priority);

            m.Sender = new System.Net.Mail.MailAddress("*****@*****.**", "Growl for Windows");

            m.Headers.Add("X-Growl-Origin-Application", appName);



            // send the email using another thread (since the Smtp.SendAsync seems to be flakey)

            System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendAsync), m);
        }
Exemplo n.º 3
0
 public virtual Growl.Connector.Priority Priority(Growl.Connector.Priority requestedPriority)
 {
     if (this.preferences.PrefPriority.IsDefault)
     {
         return(requestedPriority);
     }
     else
     {
         return(this.preferences.PrefPriority.Priority.Value);
     }
 }
 private System.Net.Mail.MailPriority GetMessagePriority(Growl.Connector.Priority priority)
 {
     System.Net.Mail.MailPriority messagePriority = System.Net.Mail.MailPriority.Normal;
     if (priority == Growl.Connector.Priority.Emergency)
     {
         messagePriority = System.Net.Mail.MailPriority.High;
     }
     else if (priority == Growl.Connector.Priority.VeryLow)
     {
         messagePriority = System.Net.Mail.MailPriority.Low;
     }
     return(messagePriority);
 }
Exemplo n.º 5
0
        /// <summary>

        /// Sends a notification, setting all available parameters

        /// </summary>

        /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification</param>

        /// <param name="title">The title of the notification</param>

        /// <param name="description">The description or extended information of the notifications</param>

        /// <param name="priority">The <see cref="Priority"/> of the notification</param>

        /// <param name="sticky"><c>true</c> to request that the notification is sticky, <c>false</c> to request the notification be not sticky</param>

        public void Notify(NotificationType notificationType, string title, string description, Growl.Connector.Priority priority, bool sticky)

        {
            NotificationPacket packet = new NotificationPacket(protocolVersion, this.applicationName, this.password, notificationType, title, description, priority, sticky);

            Send(packet);
        }
Exemplo n.º 6
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);
                            }
                        }
                    }
                }
            }
        }