Mercurial > pidgin.yaz
changeset 20919:f48bee915ede
merge of '111659964eabcb60dd83e3598df42b5d4b788a90'
and '5e03fe2d3a1f4d81543aeffc399cf6d05210e16b'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 13 Oct 2007 21:23:54 +0000 |
parents | 8fa6ff212db7 (diff) f34539eb7a61 (current diff) |
children | ef44eb0859fe |
files | |
diffstat | 4 files changed, 50 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/buddy.c Sat Oct 13 15:44:43 2007 +0000 +++ b/libpurple/protocols/bonjour/buddy.c Sat Oct 13 21:23:54 2007 +0000 @@ -62,9 +62,11 @@ } void -set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, uint32_t len){ +set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, guint32 len){ gchar **fld = NULL; + g_return_if_fail(record_key != NULL); + if (!strcmp(record_key, "1st")) fld = &buddy->first; else if(!strcmp(record_key, "email"))
--- a/libpurple/protocols/bonjour/buddy.h Sat Oct 13 15:44:43 2007 +0000 +++ b/libpurple/protocols/bonjour/buddy.h Sat Oct 13 21:23:54 2007 +0000 @@ -83,7 +83,7 @@ /** * Sets a value in the BonjourBuddy struct, destroying the old value */ -void set_bonjour_buddy_value(BonjourBuddy *buddy, const char *record_key, const char *value, uint32_t len); +void set_bonjour_buddy_value(BonjourBuddy *buddy, const char *record_key, const char *value, guint32 len); /** * Check if all the compulsory buddy data is present.
--- a/libpurple/protocols/simple/simple.c Sat Oct 13 15:44:43 2007 +0000 +++ b/libpurple/protocols/simple/simple.c Sat Oct 13 21:23:54 2007 +0000 @@ -80,14 +80,15 @@ 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 @@ 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; @@ -1072,7 +1073,7 @@ static void process_incoming_notify(struct simple_account_data *sip, struct sipmsg *msg) { gchar *from; gchar *fromhdr; - gchar *tmp2; + gchar *basicstatus_data; xmlnode *pidf; xmlnode *basicstatus = NULL, *tuple, *status; gboolean isonline = FALSE; @@ -1085,8 +1086,9 @@ if(!pidf) { purple_debug_info("simple", "process_incoming_notify: no parseable pidf\n"); + purple_prpl_got_user_status(sip->account, from, "offline", NULL); + send_sip_response(sip->gc, msg, 200, "OK", NULL); g_free(from); - send_sip_response(sip->gc, msg, 200, "OK", NULL); return; } @@ -1101,27 +1103,28 @@ return; } - tmp2 = xmlnode_get_data(basicstatus); + basicstatus_data = xmlnode_get_data(basicstatus); - if(!tmp2) { + if(!basicstatus_data) { purple_debug_info("simple", "process_incoming_notify: no basic data found\n"); xmlnode_free(pidf); g_free(from); return; } - if(strstr(tmp2, "open")) { + if(strstr(basicstatus_data, "open")) isonline = TRUE; - } + - g_free(tmp2); - - if(isonline) purple_prpl_got_user_status(sip->account, from, "available", NULL); - else purple_prpl_got_user_status(sip->account, from, "offline", NULL); + if(isonline) + purple_prpl_got_user_status(sip->account, from, "available", NULL); + else + purple_prpl_got_user_status(sip->account, from, "offline", NULL); xmlnode_free(pidf); + g_free(from); + g_free(basicstatus_data); - g_free(from); send_sip_response(sip->gc, msg, 200, "OK", NULL); } @@ -1188,28 +1191,27 @@ 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); @@ -1223,9 +1225,9 @@ 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", @@ -1235,6 +1237,18 @@ 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); @@ -1738,7 +1752,14 @@ 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)
--- a/libpurple/util.c Sat Oct 13 15:44:43 2007 +0000 +++ b/libpurple/util.c Sat Oct 13 21:23:54 2007 +0000 @@ -2565,6 +2565,8 @@ purple_debug_info("util", "Writing file %s\n", filename_full); + g_return_val_if_fail((size >= -1), FALSE); + filename_temp = g_strdup_printf("%s.save", filename_full); /* Remove an old temporary file, if one exists */ @@ -2590,7 +2592,7 @@ } /* Write to file */ - real_size = (size == -1) ? strlen(data) : size; + real_size = (size == -1) ? strlen(data) : (size_t) size; byteswritten = fwrite(data, 1, real_size, file); /* Close file */