/// <summary>
 /// Called when a notification that has been forwarded triggers a callback from the forwarded destination.
 /// </summary>
 /// <param name="response">The <see cref="Response"/> from the forwarded destination</param>
 /// <param name="callbackData">The <see cref="CallbackData"/></param>
 protected void OnForwardNotificationCallback(Response response, CallbackData callbackData)
 {
     if (this.ForwardedNotificationCallback != null)
     {
         this.ForwardedNotificationCallback(response, callbackData);
     }
 }
Example #2
0
        void growl_NotificationCallback(Growl.Connector.Response response, Growl.Connector.CallbackData callbackData)

        {
            CallbackData cd = new CallbackData(callbackData);

            OnCallback(cd);
        }
        /// <summary>
        /// Parses a response message and returns the corresponding <see cref="Response"/> object, returning the list of parsed headers as well.
        /// </summary>
        /// <param name="message">The entire GNTP response message</param>
        /// <param name="context">If this is a CALLBACK response, returns the <see cref="CallbackData"/> associated with the response; otherwise <c>null</c></param>
        /// <param name="headers">Contains the list of parsed headers</param>
        /// <returns><see cref="Response"/>The <see cref="Response"/> represented by the message</returns>
        public Response Parse(string message, out CallbackData context, out HeaderCollection headers)
        {
            context = null;
            headers = null;
            Response response = Parse(message, out headers);
            context = response.CallbackData;

            return response;
        }
        void growl_NotificationCallback(Response response, CallbackData callbackData, object state)
        {
            if (callbackData != null)
            {
                if (callbackData.Result == Growl.CoreLibrary.CallbackResult.CLICK)
                {
                    string[] data = callbackData.Data.Split(CALLBACK_DATA_SEPARATOR.ToCharArray());
                    IntPtr hWnd = new IntPtr(Convert.ToInt32(data[0]));
                    uint msg = Convert.ToUInt32(data[1]);
                    IntPtr wparam = new IntPtr(Convert.ToInt32(data[2]));
                    IntPtr lparam = new IntPtr(Convert.ToInt32(data[3]));

                    Win32.SendMessage(hWnd, msg, wparam, lparam);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Creates a new <see cref="CallbackData"/> from a list of headers
        /// </summary>
        /// <param name="headers">The <see cref="HeaderCollection"/> used to populate the object</param>
        /// <returns><see cref="CallbackData"/></returns>
        public new static CallbackData FromHeaders(HeaderCollection headers)
        {
            try
            {
                CallbackDataBase baseObj = CallbackDataBase.FromHeaders(headers);
                CallbackResult result = CallbackResult.TIMEDOUT;

                string resultString = headers.GetHeaderStringValue(Header.NOTIFICATION_CALLBACK_RESULT, true);
                if(!String.IsNullOrEmpty(resultString))
                    result = (CallbackResult)Enum.Parse(typeof(CallbackResult), resultString, true);

                string notificationID = headers.GetHeaderStringValue(Header.NOTIFICATION_ID, false);

                CallbackData context = new CallbackData(baseObj.Data, baseObj.Type, result, notificationID);

                return context;
            }
            catch
            {
                return null;
            }
        }
Example #6
0
        /// <summary>

        /// Creates a new <see cref="CallbackData"/> from a list of headers

        /// </summary>

        /// <param name="headers">The <see cref="HeaderCollection"/> used to populate the object</param>

        /// <returns><see cref="CallbackData"/></returns>

        public new static CallbackData FromHeaders(HeaderCollection headers)

        {
            try

            {
                CallbackDataBase baseObj = CallbackDataBase.FromHeaders(headers);

                CallbackResult result = CallbackResult.TIMEDOUT;



                string resultString = headers.GetHeaderStringValue(Header.NOTIFICATION_CALLBACK_RESULT, true);

                if (!String.IsNullOrEmpty(resultString))
                {
                    result = (CallbackResult)Enum.Parse(typeof(CallbackResult), resultString, true);
                }



                string notificationID = headers.GetHeaderStringValue(Header.NOTIFICATION_ID, false);



                CallbackData context = new CallbackData(baseObj.Data, baseObj.Type, result, notificationID);



                return(context);
            }

            catch

            {
                return(null);
            }
        }
Example #7
0
 private static void growl_notification_callback(Growl.Connector.Response response, Growl.Connector.CallbackData callbackData, object state)
 {
     if ((callbackData.Result == Growl.CoreLibrary.CallbackResult.CLICK) && callbackData.Type.Contains("Cannot hear anything"))
     {
         OnOperation(Operation.Show);
     }
 }
 /// <summary>
 /// Parses a response message and returns the corresponding <see cref="Response"/> object
 /// </summary>
 /// <param name="message">The entire GNTP response message</param>
 /// <param name="context">If this is a CALLBACK response, returns the <see cref="CallbackData"/> associated with the response; otherwise <c>null</c></param>
 /// <returns><see cref="Response"/>The <see cref="Response"/> represented by the message</returns>
 public Response Parse(string message, out CallbackData context)
 {
     HeaderCollection headers;
     return Parse(message, out context, out headers);
 }
Example #9
0
        /// <summary>
        /// Sets any properties from a collection of header values
        /// </summary>
        /// <param name="headers">The <see cref="HeaderCollection"/> of header values</param>
        /// <param name="isCallback">Indicates if this is a callback response</param>
        internal void SetAttributesFromHeaders(HeaderCollection headers, bool isCallback)
        {
            if (isCallback)
            {
                CallbackData callbackData = CallbackData.FromHeaders(headers);
                this.callbackData = callbackData;
            }

            this.requestData = RequestData.FromHeaders(headers);

            SetInhertiedAttributesFromHeaders(this, headers);
        }
Example #10
0
 /// <summary>
 /// Sets the <see cref="CallbackData"/> for this response
 /// </summary>
 /// <param name="notificationID">The ID of the notification making the callback</param>
 /// <param name="callbackContext">The <see cref="CallbackContext"/> of the request</param>
 /// <param name="callbackResult">The <see cref="CallbackResult"/> (clicked, closed)</param>
 public void SetCallbackData(string notificationID, CallbackContext callbackContext, CallbackResult callbackResult)
 {
     if (callbackContext != null)
     {
         CallbackData cd = new CallbackData(callbackContext.Data, callbackContext.Type, callbackResult, notificationID);
         this.callbackData = cd;
     }
 }
Example #11
0
 void growl_NotificationCallback(Response response, CallbackData callbackContext, object state)
 {
     string s = String.Format("CALLBACK RECEIVED: {0} - {1} - {2} - {3}", callbackContext.NotificationID, callbackContext.Data, callbackContext.Type, callbackContext.Result);
     InvokeWrite(s);
 }
Example #12
0
 void Forwarder_NotificationCallback(Response response, CallbackData callbackData, object state)
 {
     this.OnForwardedNotificationCallback(response, callbackData);
 }
Example #13
0
 private void growl_NotificationCallback(Response response, CallbackData callbackData, object state)
 {
     _isNotificationActive = false;
     //string text = String.Format("Response Type: {0}\r\nNotification ID: {1}\r\nCallback Data: {2}\r\nCallback Data Type: {3}\r\n", callbackData.Result, callbackData.NotificationID, callbackData.Data, callbackData.Type);
     //MessageBox.Show(text, "Callback received", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
 }
Example #14
0
 static void GrowlNotificationCallback(Response response, CallbackData callbackData)
 {
     //string text = String.Format("Response Type: {0}\r\nNotification ID: {1}\r\nCallback Data: {2}\r\nCallback Data Type: {3}\r\n", callbackData.Result, callbackData.NotificationID, callbackData.Data, callbackData.Type);
     //MessageBox.Show(text, "Callback received", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
 }
        /// <summary>
        /// Parses a response message and returns the corresponding <see cref="Response"/> object
        /// </summary>
        /// <param name="message">The entire GNTP response message</param>
        /// <param name="context">If this is a CALLBACK response, returns the <see cref="CallbackData"/> associated with the response; otherwise <c>null</c></param>
        /// <returns><see cref="Response"/>The <see cref="Response"/> represented by the message</returns>
        public Response Parse(string message, out CallbackData context)
        {
            HeaderCollection headers;

            return(Parse(message, out context, out headers));
        }
Example #16
0
        protected void OnForwardedNotificationCallback(Growl.Connector.Response response, Growl.Connector.CallbackData callbackData)

        {
            if (this.ForwardedNotificationCallback != null)

            {
                this.ForwardedNotificationCallback(response, callbackData);
            }
        }
Example #17
0
        void growl_NotificationCallback(Response response, CallbackData callbackContext, object state)
        {
            switch (callbackContext.Result)
            {
                case Growl.CoreLibrary.CallbackResult.CLICK:
                    if (callbackContext.Data == "OPEN_URL")
                    {
                        Notification notification = state as Notification;

                        string url = notification.CustomTextAttributes["url"];
                        if (url != null && url.Substring(0, 4) == "http")
                        {
                            Process.Start(url);
                        }
                    }
                    break;

                case Growl.CoreLibrary.CallbackResult.CLOSE:
                    break;
                case Growl.CoreLibrary.CallbackResult.TIMEDOUT:
                    break;
            }
        }
Example #18
0
 private static void GrowlNotificationCallback(Response response, CallbackData callbackdata)
 {
     SaveChangesToFile(String.Format("Response Type: {0}\r\nNotification ID: {1}\r\nCallback Data: {2}\r\nCallback Data Type: {3}\r\n", callbackdata.Result, callbackdata.NotificationID, callbackdata.Data, callbackdata.Type));
 }
Example #19
0
        /*
        /// <summary>
        /// Gets the url-formatted callback data that is to be sent for url callbacks.
        /// </summary>
        /// <param name="result">The <see cref="CallbackResult"/> indicating the user action</param>
        /// <returns>string - querystring/post format</returns>
        public string GetUrlCallbackData(CallbackResult result)
        {
            string data = null;
            if (this.Context != null)
            {
                UrlCallbackTarget target = this.Context.GetUrlCallbackTarget();
                if (target != null)
                {
                    data = String.Format("notification-id={0}&notification-callback-result={1}&notification-callback-context={2}&notification-callback-context-type={3}", HttpUtility.UrlEncode(this.notificationID), HttpUtility.UrlEncode(result.ToString()), HttpUtility.UrlEncode(this.Context.Data), HttpUtility.UrlEncode(this.Context.Type));
                }
            }
            return data;
        }
         * */

        /// <summary>
        /// Handles the callback from a forwarder.
        /// </summary>
        /// <param name="response">The <see cref="Response"/> from the forwarder</param>
        /// <param name="callbackData">The <see cref="CallbackData"/></param>
        public void HandleCallbackFromForwarder(Response response, CallbackData callbackData)
        {
            this.RequestInfo.SaveHandlingInfo(String.Format("Was responded to on {0} - Action: {1}", response.MachineName, callbackData.Result));

            if (this.ForwardedNotificationCallback != null)
            {
                this.ForwardedNotificationCallback(response, callbackData, this);
            }
        }
 /// <summary>
 /// Called when an 'CALLBACK' response occurs.
 /// </summary>
 /// <param name="response">The <see cref="Response"/></param>
 /// <param name="callbackData">The <see cref="CallbackData"/></param>
 /// <param name="state">An optional state object that will be passed into the response events associated with this request</param>
 protected void OnNotificationCallback(Response response, CallbackData callbackData, object state)
 {
     if (callbackData != null && callbackData.Data != null && this.NotificationCallback != null)
     {
         this.NotificationCallback(response, callbackData, state);
     }
 }
Example #21
0
 private static void ConnectorOnNotificationCallback(Response response, CallbackData callbackData, object state)
 {
     Process.Start(callbackData.Data);
 }