im.pidgin.pidgin: 48bbcb407bad5963f16724d002323b8177036759
datallah at pidgin.im
datallah at pidgin.im
Thu Jan 10 15:30:39 EST 2008
-----------------------------------------------------------------
Revision: 48bbcb407bad5963f16724d002323b8177036759
Ancestor: 1991213a0cb9c2d4b066d5acb8e5b5fb77b1470b
Author: datallah at pidgin.im
Date: 2008-01-10T20:24:58
Branch: im.pidgin.pidgin
Modified files:
libpurple/protocols/simple/simple.c
libpurple/protocols/simple/simple.h
ChangeLog:
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
-------------- next part --------------
============================================================
--- libpurple/protocols/simple/simple.c b5aab5638a5346525fce65579794cce82bb23fc2
+++ libpurple/protocols/simple/simple.c 0b410fae2296d2dff79e4f7495cac1217e766259
@@ -1356,10 +1356,21 @@ static gboolean process_publish_response
}
static gboolean process_publish_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) {
+
+ const gchar *etag = NULL;
+
if(msg->response != 200 && msg->response != 408) {
/* never send again */
sip->republish = -1;
}
+
+ etag = sipmsg_find_header(msg, "SIP-Etag");
+ if (etag) {
+ /* we must store the etag somewhere. */
+ g_free(sip->publish_etag);
+ sip->publish_etag = g_strdup(etag);
+ }
+
return TRUE;
}
@@ -1368,10 +1379,12 @@ static void send_open_publish(struct sim
gchar *uri = g_strdup_printf("sip:%s@%s", sip->username, sip->servername);
gchar *doc = gen_pidf(sip, TRUE);
- add_headers = g_strdup_printf("%s%d%s",
- "Expires: ",
- PUBLISH_EXPIRATION,
- "\r\nEvent: presence\r\n"
+ add_headers = g_strdup_printf("%s%s%s%s%d\r\n%s",
+ sip->publish_etag ? "SIP-If-Match: " : "",
+ sip->publish_etag ? sip->publish_etag : "",
+ sip->publish_etag ? "\r\n" : "",
+ "Expires: ", PUBLISH_EXPIRATION,
+ "Event: presence\r\n"
"Content-Type: application/pidf+xml\r\n");
send_sip_request(sip->gc, "PUBLISH", uri, uri,
@@ -1384,14 +1397,23 @@ static void send_closed_publish(struct s
static void send_closed_publish(struct simple_account_data *sip) {
gchar *uri = g_strdup_printf("sip:%s@%s", sip->username, sip->servername);
- gchar *doc = gen_pidf(sip, FALSE);
- send_sip_request(sip->gc, "PUBLISH", uri, uri,
- "Expires: 600\r\nEvent: presence\r\n"
- "Content-Type: application/pidf+xml\r\n",
+ gchar *add_headers, *doc;
+
+ add_headers = g_strdup_printf("%s%s%s%s",
+ sip->publish_etag ? "SIP-If-Match: " : "",
+ sip->publish_etag ? sip->publish_etag : "",
+ sip->publish_etag ? "\r\n" : "",
+ "Expires: 600\r\n"
+ "Event: presence\r\n"
+ "Content-Type: application/pidf+xml\r\n");
+
+ doc = gen_pidf(sip, FALSE);
+ send_sip_request(sip->gc, "PUBLISH", uri, uri, add_headers,
doc, NULL, process_publish_response);
/*sip->republish = time(NULL) + 500;*/
g_free(uri);
g_free(doc);
+ g_free(add_headers);
}
static void process_incoming_subscribe(struct simple_account_data *sip, struct sipmsg *msg) {
@@ -1948,6 +1970,7 @@ static void simple_close(PurpleConnectio
g_free(sip->proxy.target);
g_free(sip->proxy.realm);
g_free(sip->proxy.digest_session_key);
+ g_free(sip->publish_etag);
if(sip->txbuf)
purple_circ_buffer_destroy(sip->txbuf);
g_free(sip->realhostname);
============================================================
--- libpurple/protocols/simple/simple.h 235560853706243af090ecb164f0759061cace35
+++ libpurple/protocols/simple/simple.h 24f6f70ea74764bc22b2788d37ba1c9eecfa4cc3
@@ -112,6 +112,7 @@ struct simple_account_data {
int registerexpire;
gchar *realhostname;
int realport; /* port and hostname from SRV record */
+ gchar *publish_etag;
};
struct sip_connection {
More information about the Commits
mailing list