From 042ade55dab52356eaacc84f2a5e794f733945aa Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 13 Jan 2011 17:09:17 -0500 Subject: [PATCH] Added configurable message title to send_message() Also abstracted out app name to object-level CString rather than building it every time send_message() is executed. --- notifo.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/notifo.cpp b/notifo.cpp index de796e3..3a23491 100644 --- a/notifo.cpp +++ b/notifo.cpp @@ -26,6 +26,9 @@ class CNotifoMod : public CModule { protected: + // Application name + CString app; + // Too lazy to add CString("\r\n\") everywhere CString crlf; @@ -43,6 +46,7 @@ class CNotifoMod : public CModule public: MODCONSTRUCTOR(CNotifoMod) { + app = "ZNC"; crlf = "\r\n"; #if DEBUG_HOST @@ -79,8 +83,9 @@ class CNotifoMod : public CModule * username and API secret using the 'set' command. * * @param message Message to be sent to the user + * @param title Message title to use */ - void send_message(const CString& message) + void send_message(const CString& message, const CString& title="New Message") { // BASIC auth style CString auth = notifo_username + CString(":") + notifo_secret; @@ -88,8 +93,8 @@ class CNotifoMod : public CModule // POST body parameters for the request CString post = "to=" + urlencode(notifo_username); post += "&msg=" + urlencode(message); - post += "&label=" + urlencode(CString("ZNC")); - post += "&title=" + urlencode(CString("New Message")); + post += "&label=" + urlencode(app); + post += "&title=" + urlencode(title); post += "&uri=" + urlencode(CString("http://notifo.leetcode.net/")); // Request headers and POST body