--- a/libpurple/protocols/simple/simple.c Sun May 17 05:34:38 2020 -0400
+++ b/libpurple/protocols/simple/simple.c Sun May 17 22:03:11 2020 -0400
@@ -605,47 +605,33 @@
-static void sendout_sipmsg(struct simple_account_data *sip, struct sipmsg *msg) {
- GSList *tmp = msg->headers;
- GString *outstr = g_string_new("");
- g_string_append_printf(outstr, "%s %s SIP/2.0\r\n", msg->method, msg->target);
- PurpleKeyValuePair *pair = tmp->data;
- g_string_append_printf(outstr, "%s: %s\r\n", pair->key,
- tmp = g_slist_next(tmp);
- g_string_append_printf(outstr, "\r\n%s", msg->body ? msg->body : "");
- sendout_pkt(sip->gc, outstr->str);
- g_string_free(outstr, TRUE);
-static void send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code,
- const char *text, const char *body) {
- GSList *tmp = msg->headers;
- GString *outstr = g_string_new("");
+send_sip_response(PurpleConnection *gc, struct sipmsg *msg, gint code, + const gchar *text, const gchar *body) /* When sending the acknowlegements and errors, the content length from the original
message is still here, but there is no body; we need to make sure we're sending the
correct content length */
sipmsg_remove_header(msg, "Content-Length");
+ g_clear_pointer(&msg->body, g_free); - sprintf(len, "%" G_GSIZE_FORMAT , strlen(body));
+ msg->bodylen = strlen(body); + sprintf(len, "%d", msg->bodylen); sipmsg_add_header(msg, "Content-Length", len);
+ msg->body = g_strdup(body); sipmsg_add_header(msg, "Content-Length", "0");
- g_string_append_printf(outstr, "SIP/2.0 %d %s\r\n", code, text);
- PurpleKeyValuePair *pair = tmp->data;
- g_string_append_printf(outstr, "%s: %s\r\n", pair->key,
- tmp = g_slist_next(tmp);
- g_string_append_printf(outstr, "\r\n%s", body ? body : "");
- sendout_pkt(gc, outstr->str);
- g_string_free(outstr, TRUE);
+ outstr = sipmsg_to_string(msg, text); + sendout_pkt(gc, outstr); @@ -1022,8 +1008,11 @@
if((currtime - trans->time > 2) && trans->retries == 0) {
- sendout_sipmsg(sip, trans->msg);
+ outstr = sipmsg_to_string(trans->msg, NULL); + sendout_pkt(sip->gc, outstr); @@ -1590,7 +1579,7 @@
sipmsg_remove_header(trans->msg, "Proxy-Authorization");
sipmsg_add_header(trans->msg, "Proxy-Authorization", auth);
- resend = sipmsg_to_string(trans->msg);
+ resend = sipmsg_to_string(trans->msg, NULL); sendout_pkt(sip->gc, resend);
@@ -1634,7 +1623,7 @@
sipmsg_remove_header(trans->msg, "Authorization");
sipmsg_add_header(trans->msg, "Authorization", auth);
- resend = sipmsg_to_string(trans->msg);
+ resend = sipmsg_to_string(trans->msg, NULL); sendout_pkt(sip->gc, resend);
--- a/libpurple/protocols/simple/sipmsg.c Sun May 17 05:34:38 2020 -0400
+++ b/libpurple/protocols/simple/sipmsg.c Sun May 17 22:03:11 2020 -0400
@@ -150,17 +150,20 @@
-char *sipmsg_to_string(const struct sipmsg *msg) {
+sipmsg_to_string(const struct sipmsg *msg, const gchar *status_text) GString *outstr = g_string_new("");
PurpleKeyValuePair *elem;
- g_string_append_printf(outstr, "SIP/2.0 %d Unknown\r\n",
+ g_string_append_printf(outstr, "SIP/2.0 %d %s\r\n", msg->response, + status_text ? status_text : "Unknown"); g_string_append_printf(outstr, "%s %s SIP/2.0\r\n",
msg->method, msg->target);
--- a/libpurple/protocols/simple/sipmsg.h Sun May 17 05:34:38 2020 -0400
+++ b/libpurple/protocols/simple/sipmsg.h Sun May 17 22:03:11 2020 -0400
@@ -39,6 +39,6 @@
const gchar *sipmsg_find_header(struct sipmsg *msg, const gchar *name);
void sipmsg_remove_header(struct sipmsg *msg, const gchar *name);
void sipmsg_print(const struct sipmsg *msg);
-char *sipmsg_to_string(const struct sipmsg *msg);
+gchar *sipmsg_to_string(const struct sipmsg *msg, const gchar *status_text); #endif /* PURPLE_SIMPLE_SIPMSG_H */