public static PrefPriority[] GetList(bool allowDefault) { int i = 0; int c = 5; if (allowDefault) { c++; } PrefPriority[] arr = new PrefPriority[c]; if (allowDefault) { arr[i++] = Default; } arr[i++] = Emergency; arr[i++] = High; arr[i++] = Normal; arr[i++] = Low; arr[i++] = VeryLow; return(arr); }
public override bool Equals(object obj) { PrefPriority p = obj as PrefPriority; if (p != null) { return(this.priority == p.priority); } else { return(base.Equals(obj)); } }
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); } }
public static PrefPriority[] GetList(bool allowDefault) { int i = 0; int c = 5; if (allowDefault) c++; PrefPriority[] arr = new PrefPriority[c]; if (allowDefault) { arr[i++] = Default; } arr[i++] = Emergency; arr[i++] = High; arr[i++] = Normal; arr[i++] = Low; arr[i++] = VeryLow; return arr; }
public object GetRealObject(StreamingContext context) { return(PrefPriority.GetByValue(this.priority)); }