Mercurial > pidgin.yaz
diff libpurple/protocols/myspace/message.c @ 17368:3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
(UNTESTED)
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Wed, 06 Jun 2007 02:49:35 +0000 |
parents | d69bcd74c240 |
children | 7abd1eca3d18 |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c Tue Jun 05 05:06:04 2007 +0000 +++ b/libpurple/protocols/myspace/message.c Wed Jun 06 02:49:35 2007 +0000 @@ -25,7 +25,7 @@ static void msim_msg_free_element(gpointer data, gpointer user_data); static void msim_msg_debug_string_element(gpointer data, gpointer user_data); static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, gchar *sep, gchar *begin, gchar *end); -static gchar *msim_msg_element_pack(MsimMessageElement *elem); +static gchar *msim_msg_pack_element_data(MsimMessageElement *elem); static GList *msim_msg_get_node(MsimMessage *msg, gchar *name); static MsimMessage *msim_msg_new_v(va_list argp); @@ -166,7 +166,7 @@ { MsimMessage *new; - if (!old) + if (old == NULL) return NULL; new = msim_msg_new(FALSE); @@ -245,6 +245,8 @@ raw = msim_msg_pack(msg); success = msim_send_raw(session, raw); g_free(raw); + + msim_msg_dump("msim_msg_send()ing %s\n", msg); return success; } @@ -473,7 +475,7 @@ * optimal for human consumption. For example, strings are escaped. Use * msim_msg_get_string() if you want a string, which in some cases is same as this. */ -static gchar *msim_msg_element_pack(MsimMessageElement *elem) +static gchar *msim_msg_pack_element_data(MsimMessageElement *elem) { switch (elem->type) { @@ -482,7 +484,7 @@ case MSIM_TYPE_RAW: /* Not un-escaped - this is a raw element, already escaped if necessary. */ - return (gchar *)elem->data; + return g_strdup((gchar *)elem->data); case MSIM_TYPE_STRING: /* Strings get escaped. msim_escape() creates a new string. */ @@ -498,9 +500,8 @@ } case MSIM_TYPE_BOOLEAN: - /* These strings are not actually used by the wire protocol - * -- see msim_msg_pack_element. */ - return g_strdup(GPOINTER_TO_UINT(elem->data) ? "True" : "False"); + /* Not used by the wire protocol * -- see msim_msg_pack_element. */ + return NULL; case MSIM_TYPE_DICTIONARY: /* TODO: pack using k=v\034k2=v2\034... */ @@ -535,7 +536,15 @@ elem = (MsimMessageElement *)data; items = user_data; - data_string = msim_msg_element_pack(elem); + /* Exclude elements beginning with '_' from packed protocol messages. */ + if (elem->name[0] == '_') + { + **items = g_strdup(""); + ++(*items); + return; + } + + data_string = msim_msg_pack_element_data(elem); switch (elem->type) { @@ -768,7 +777,7 @@ * * @return gchar * The data as a string. Caller must g_free(). * - * Note that msim_msg_element_pack() is similar, but returns a string + * Note that msim_msg_pack_element_data() is similar, but returns a string * for inclusion into a raw protocol string (escaped and everything). * This function unescapes the string for you, if needed. */