From: Kyle Fuller Date: Mon, 1 Jul 2013 19:26:09 +0000 (+0100) Subject: Parse push endpoint from device X-Git-Tag: 1.0.0~26 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=c18c085b54b09f271b3df5b5a51b7fd8679a7a04;p=znc-palaver.git Parse push endpoint from device --- diff --git a/palaver.cpp b/palaver.cpp index 1dcc205..c5af7db 100644 --- a/palaver.cpp +++ b/palaver.cpp @@ -289,11 +289,26 @@ public: #pragma mark - Notifications void SendNotification(CModule& module, const CString& sSender, const CString& sNotification, const CChan *pChannel) { - // todo parse from m_sPushEndpoint - bool bUseTLS = true; - CString sHostname = "api.palaverapp.com"; - unsigned short uPort = 443; - CString sPath = "/1/push"; + unsigned short uPort = 80; + + CString sPushEndpoint = GetPushEndpoint(); + CString sScheme = sPushEndpoint.Token(0, false, "://"); + CString sTemp = sPushEndpoint.Token(1, true, "://"); + CString sAddress = sTemp.Token(0, false, "/"); + + CString sHostname = sAddress.Token(0, false, ":"); + CString sPort = sAddress.Token(1, true, ":"); + CString sPath = "/" + sTemp.Token(1, true, "/"); + + if (sPort.empty()) { + if (sScheme.Equals("https")) { + uPort = 443; + } else if (sScheme.Equals("http")) { + uPort = 80; + } + } else { + uPort = sPort.ToUShort(); + } CString sJSON = "{"; sJSON += "\"message\": \"" + sNotification.Replace_n("\"", "\\\"") + "\"";