summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Schierer <lschiere@pidgin.im>2007-10-21 04:42:58 +0000
committerLuke Schierer <lschiere@pidgin.im>2007-10-21 04:42:58 +0000
commit611f2583e1c06d10451699b9934a97e2f59f2f12 (patch)
tree6f2d82c12ebd0e86a81309d201b5699e55d3b623
parent1b0e093edbfc6ba6854377c06db6a665075149a3 (diff)
downloadpidgin-611f2583e1c06d10451699b9934a97e2f59f2f12.tar.gz
applied changes from e9e74094baa29c6f5589385507221a2502b817fb
through ca09db83bd2ae802d4a6d7078a1efdfe9a896cb5
-rw-r--r--libpurple/protocols/simple/simple.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/libpurple/protocols/simple/simple.c b/libpurple/protocols/simple/simple.c
index edb4729124..bd4cf9ad7b 100644
--- a/libpurple/protocols/simple/simple.c
+++ b/libpurple/protocols/simple/simple.c
@@ -80,14 +80,15 @@ static void simple_keep_alive(PurpleConnection *gc) {
static gboolean process_register_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc);
static void send_notify(struct simple_account_data *sip, struct simple_watcher *);
-static void send_publish(struct simple_account_data *sip);
+static void send_open_publish(struct simple_account_data *sip);
+static void send_closed_publish(struct simple_account_data *sip);
static void do_notifies(struct simple_account_data *sip) {
GSList *tmp = sip->watcher;
purple_debug_info("simple", "do_notifies()\n");
if((sip->republish != -1) || sip->republish < time(NULL)) {
if(purple_account_get_bool(sip->account, "dopublish", TRUE)) {
- send_publish(sip);
+ send_open_publish(sip);
}
}
@@ -1020,7 +1021,7 @@ gboolean process_register_response(struct simple_account_data *sip, struct sipms
case 200:
if(sip->registerstatus < SIMPLE_REGISTER_COMPLETE) { /* registered */
if(purple_account_get_bool(sip->account, "dopublish", TRUE)) {
- send_publish(sip);
+ send_open_publish(sip);
}
}
sip->registerstatus = SIMPLE_REGISTER_COMPLETE;
@@ -1186,28 +1187,27 @@ static gchar* gen_xpidf(struct simple_account_data *sip) {
return doc;
}
-
-
-static gchar* gen_pidf(struct simple_account_data *sip) {
+static gchar* gen_pidf(struct simple_account_data *sip, gboolean open) {
gchar *doc = g_strdup_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n"
"xmlns:im=\"urn:ietf:params:xml:ns:pidf:im\"\n"
"entity=\"sip:%s@%s\">\n"
"<tuple id=\"bs35r9f\">\n"
"<status>\n"
- "<basic>open</basic>\n"
+ "<basic>%s</basic>\n"
"</status>\n"
"<note>%s</note>\n"
"</tuple>\n"
"</presence>",
sip->username,
sip->servername,
- sip->status);
+ (open == TRUE) ? "open" : "closed",
+ (open == TRUE) ? sip->status : "");
return doc;
}
static void send_notify(struct simple_account_data *sip, struct simple_watcher *watcher) {
- gchar *doc = watcher->needsxpidf ? gen_xpidf(sip) : gen_pidf(sip);
+ gchar *doc = watcher->needsxpidf ? gen_xpidf(sip) : gen_pidf(sip, TRUE);
gchar *hdr = watcher->needsxpidf ? "Event: presence\r\nContent-Type: application/xpidf+xml\r\n" : "Event: presence\r\nContent-Type: application/pidf+xml\r\n";
send_sip_request(sip->gc, "NOTIFY", watcher->name, watcher->name, hdr, doc, &watcher->dialog, NULL);
g_free(doc);
@@ -1221,9 +1221,9 @@ static gboolean process_publish_response(struct simple_account_data *sip, struct
return TRUE;
}
-static void send_publish(struct simple_account_data *sip) {
+static void send_open_publish(struct simple_account_data *sip) {
gchar *uri = g_strdup_printf("sip:%s@%s", sip->username, sip->servername);
- gchar *doc = gen_pidf(sip);
+ gchar *doc = gen_pidf(sip, TRUE);
send_sip_request(sip->gc, "PUBLISH", uri, uri,
"Expires: 600\r\nEvent: presence\r\n"
"Content-Type: application/pidf+xml\r\n",
@@ -1233,6 +1233,18 @@ static void send_publish(struct simple_account_data *sip) {
g_free(doc);
}
+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",
+ doc, NULL, process_publish_response);
+ /*sip->republish = time(NULL) + 500;*/
+ g_free(uri);
+ g_free(doc);
+}
+
static void process_incoming_subscribe(struct simple_account_data *sip, struct sipmsg *msg) {
const char *from_hdr = sipmsg_find_header(msg, "From");
gchar *from = parse_from(from_hdr);
@@ -1736,7 +1748,14 @@ static void simple_close(PurpleConnection *gc)
if(sip) {
/* unregister */
if (sip->registerstatus == SIMPLE_REGISTER_COMPLETE)
+ {
+ if(purple_account_get_bool(sip->account,
+ "dopublish",
+ TRUE))
+ send_closed_publish(sip);
+
do_register_exp(sip, 0);
+ }
connection_free_all(sip);
if (sip->query_data != NULL)