Esempio n. 1
0
        bool ErrorHandling(PushbulletFile payload, Action <bool> callback = null)
        {
            if (string.IsNullOrEmpty(payload.file_name))
            {
                LogWarning("File name not given! Please enter one and try again");
                return(false);
            }

            if (string.IsNullOrEmpty(payload.file_url))
            {
                LogWarning("File URL not given! Please enter one and try again");
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Sends a file to the Pushbullet service
        /// </summary>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="fileUrl"></param>
        /// <param name="fileName"></param>
        /// <param name="fileType"></param>
        /// <param name="callback"></param>
        void Pushbullet(string title, string message, string fileUrl, string fileName = "Unnamed", string fileType = "text/plain", Action <bool> callback = null)
        {
            // TODO: Try to detect file type from URL?
            // application/octet-stream
            // image/jpeg
            // image/png
            // text/plain

            var payload = new PushbulletFile {
                title = title, body = message, type = "file", file_url = fileUrl, file_name = fileName, file_type = fileType
            };

            if (!ErrorHandling(payload))
            {
                callback?.Invoke(false);
                return; // TODO: Need to check title and body too...
            }

            WebRequest(pushbulletUrl, payload.QueryString(), callback, pushbulletHeaders);
        }