- /* Response */
- CtdlLogPrintf(CTDL_DEBUG, "Awaiting response\n");
- if (sock_getln(sock, buf, SIZ) < 0) {
- goto free;
- }
- CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
- if (strncasecmp(buf, "HTTP/1.1 200 OK", strlen("HTTP/1.1 200 OK"))) {
-
- goto free;
+ if (strlen(SOAPMessage) < 0) {
+ char buf[SIZ];
+
+ snprintf(buf, SIZ,
+ "Cannot load template file %s; won't send notification\r\n",
+ file_funambol_msg);
+ CtdlLogPrintf(CTDL_ERR, buf);
+
+ CtdlAideMessage(buf, "External notifier unable to load message template!");
+ goto free;
+ }
+ // Do substitutions
+ help_subst(SOAPMessage, "^notifyuser", user);
+ help_subst(SOAPMessage, "^syncsource", config.c_funambol_source);
+ help_subst(SOAPMessage, "^msgid", msgid);
+ help_subst(SOAPMessage, "^msgnum", msgnumstr);
+
+ curl_easy_setopt(curl, CURLOPT_URL, remoteurl);
+
+ /* pass our list of custom made headers */
+
+ contenttype=(char*) malloc(40+strlen(mimetype));
+ sprintf(contenttype,"Content-Type: %s; charset=utf-8", mimetype);
+
+ headers = curl_slist_append(headers, "SOAPAction: \"\"");
+ headers = curl_slist_append(headers, contenttype);
+
+ /* Now specify the POST binary data */
+
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, SOAPMessage);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(SOAPMessage));
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+ }
+ else {
+ help_subst(remoteurl, "^notifyuser", user);
+ help_subst(remoteurl, "^syncsource", config.c_funambol_source);
+ help_subst(remoteurl, "^msgid", msgid);
+ help_subst(remoteurl, "^msgnum", msgnumstr);
+ curl_easy_setopt(curl, CURLOPT_URL, remoteurl);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);