void display_NotificationCallback(Growl.Daemon.CallbackInfo cbInfo, Growl.CoreLibrary.CallbackResult result) { if (this.gntpListener != null && cbInfo != null && cbInfo.Context != null) { cbInfo.RequestInfo.SaveHandlingInfo(String.Format("Was responded to on {0} - Action: {1}", Environment.MachineName, result)); Growl.Connector.Response response = new Growl.Connector.Response(); response.SetCallbackData(cbInfo.NotificationID, cbInfo.Context, result); if (cbInfo.ShouldKeepConnectionOpen()) { this.gntpListener.WriteResponse(cbInfo, response); } else { string url = cbInfo.Context.CallbackUrl; if (!String.IsNullOrEmpty(url)) { // this will only fire on CLICK since that is the more expected behavior // NOTE: there is probably a huge security risk by doing this (for now, I am relying on UriBuilder to protect us from from other types of commands) if (result == Growl.CoreLibrary.CallbackResult.CLICK) { try { System.UriBuilder ub = new UriBuilder(url); // do this in another thread so the Process.Start doesnt block ThreadPool.QueueUserWorkItem(new WaitCallback(OpenUrl), ub.Uri.AbsoluteUri); } catch { // TODO: this is temporary (and thus not localized either) // LOCALIZE: SendSystemNotification("Callback failure", String.Format("An application requested a callback via url, but the url was invalid. The url was: {0}", url)); } } } } } }
Response server_NotifyReceived(Notification notification, Growl.Daemon.CallbackInfo callbackInfo, Growl.Connector.RequestInfo requestInfo) { Response response = new Response(); if (callbackInfo != null) { if (callbackInfo.ShouldKeepConnectionOpen()) { response.SetCallbackData(notification.ID, callbackInfo.Context, Growl.CoreLibrary.CallbackResult.CLICK); // simulate a wait System.Threading.Thread.Sleep(5000); } else { string url = callbackInfo.Context.CallbackUrl; server_ServerMessage(null, Growl.Daemon.GrowlServer.LogMessageType.Information, url); } } //Console.WriteLine("notification response"); return response; }