cpw.qulogic.msnp16: cfc6f071: Rename "attribute" to "header" in a bunc...
markdoliner at pidgin.im
markdoliner at pidgin.im
Mon Feb 8 02:46:10 EST 2010
-----------------------------------------------------------------
Revision: cfc6f0716c14de91effabfddaf54017cb7b85171
Ancestor: 3520962576c7e701e6bb00273450e5b40b74da89
Author: markdoliner at pidgin.im
Date: 2010-02-08T07:41:15
Branch: im.pidgin.cpw.qulogic.msnp16
URL: http://d.pidgin.im/viewmtn/revision/info/cfc6f0716c14de91effabfddaf54017cb7b85171
Modified files:
libpurple/protocols/msn/cmdproc.c
libpurple/protocols/msn/msg.c libpurple/protocols/msn/msg.h
libpurple/protocols/msn/msn.c
libpurple/protocols/msn/notification.c
libpurple/protocols/msn/oim.c libpurple/protocols/msn/slp.c
libpurple/protocols/msn/slplink.c
libpurple/protocols/msn/switchboard.c
ChangeLog:
Rename "attribute" to "header" in a bunch of places. The SLP protocol
is fashioned after HTTP. Well, more accurately after SIP. And these
are generally referred to as headers pretty much everywhere.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/cmdproc.c 8588a6864ee7a819600d6871f05745d9224ff2c9
+++ libpurple/protocols/msn/cmdproc.c e4b53cb28f815486d6d5453cdf8029fabf8e09c6
@@ -246,8 +246,8 @@ msn_cmdproc_process_msg(MsnCmdProc *cmdp
const char *messageId = NULL;
/* Multi-part messages */
- if ((messageId = msn_message_get_attr(msg, "Message-ID")) != NULL) {
- const char *chunk_text = msn_message_get_attr(msg, "Chunks");
+ if ((messageId = msn_message_get_header_value(msg, "Message-ID")) != NULL) {
+ const char *chunk_text = msn_message_get_header_value(msg, "Chunks");
guint chunk;
if (chunk_text != NULL) {
chunk = strtol(chunk_text, NULL, 10);
@@ -266,7 +266,7 @@ msn_cmdproc_process_msg(MsnCmdProc *cmdp
}
return;
} else {
- chunk_text = msn_message_get_attr(msg, "Chunk");
+ chunk_text = msn_message_get_header_value(msg, "Chunk");
if (chunk_text != NULL) {
MsnMessage *first = g_hash_table_lookup(cmdproc->multiparts, messageId);
chunk = strtol(chunk_text, NULL, 10);
============================================================
--- libpurple/protocols/msn/msg.c 795b1a623db46112fd23481325996a6714691973
+++ libpurple/protocols/msn/msg.c 41f4b872c3989758c422533860f45b7d98fe6631
@@ -36,7 +36,7 @@ msn_message_new(MsnMsgType type)
if (purple_debug_is_verbose())
purple_debug_info("msn", "message new (%p)(%d)\n", msg, type);
- msg->attr_table = g_hash_table_new_full(g_str_hash, g_str_equal,
+ msg->header_table = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
msn_message_ref(msg);
@@ -64,8 +64,8 @@ msn_message_destroy(MsnMessage *msg)
g_free(msg->content_type);
g_free(msg->charset);
- g_hash_table_destroy(msg->attr_table);
- g_list_free(msg->attr_list);
+ g_hash_table_destroy(msg->header_table);
+ g_list_free(msg->header_list);
g_free(msg);
}
@@ -112,11 +112,11 @@ msn_message_new_plain(const char *messag
msg = msn_message_new(MSN_MSG_TEXT);
msg->retries = 1;
- msn_message_set_attr(msg, "User-Agent", PACKAGE_NAME "/" VERSION);
+ msn_message_set_header(msg, "User-Agent", PACKAGE_NAME "/" VERSION);
msn_message_set_content_type(msg, "text/plain");
msn_message_set_charset(msg, "UTF-8");
msn_message_set_flag(msg, 'A');
- msn_message_set_attr(msg, "X-MMS-IM-Format",
+ msn_message_set_header(msg, "X-MMS-IM-Format",
"FN=Segoe%20UI; EF=; CO=0; CS=1;PF=0");
message_cr = purple_str_add_cr(message);
@@ -133,7 +133,7 @@ msn_message_new_msnslp(void)
msg = msn_message_new(MSN_MSG_SLP);
- msn_message_set_attr(msg, "User-Agent", NULL);
+ msn_message_set_header(msg, "User-Agent", NULL);
msg->msnslp_message = TRUE;
@@ -169,7 +169,7 @@ msn_message_parse_slp_body(MsnMessage *m
g_return_if_reached();
}
- /* Import the header. */
+ /* Extract the binary SLP header */
memcpy(&header, tmp, sizeof(header));
tmp += sizeof(header);
@@ -183,7 +183,7 @@ msn_message_parse_slp_body(MsnMessage *m
msg->msnslp_header.ack_sub_id = GUINT32_FROM_LE(header.ack_sub_id);
msg->msnslp_header.ack_size = GUINT64_FROM_LE(header.ack_size);
- /* Import the body. */
+ /* Extract the body */
body_len = len - (tmp - body);
/* msg->body_len = msg->msnslp_header.length; */
@@ -211,7 +211,7 @@ msn_message_parse_payload(MsnMessage *ms
memcpy(tmp_base, payload, payload_len);
tmp_base[payload_len] = '\0';
- /* Parse the attributes. */
+ /* Find the end of the headers */
end = strstr(tmp, body_dem);
/* TODO? some clients use \r delimiters instead of \r\n, the official client
* doesn't send such messages, but does handle receiving them. We'll just
@@ -222,8 +222,8 @@ msn_message_parse_payload(MsnMessage *ms
}
*end = '\0';
+ /* Split the headers and parse each one */
elems = g_strsplit(tmp, line_dem, 0);
-
for (cur = elems; *cur != NULL; cur++)
{
const char *key, *value;
@@ -240,7 +240,7 @@ msn_message_parse_payload(MsnMessage *ms
if (!strcmp(key, "boundary")) {
char *end = strchr(value, '\"');
*end = '\0';
- msn_message_set_attr(msg, key, value);
+ msn_message_set_header(msg, key, value);
}
g_strfreev(tokens);
@@ -278,12 +278,11 @@ msn_message_parse_payload(MsnMessage *ms
}
else
{
- msn_message_set_attr(msg, key, value);
+ msn_message_set_header(msg, key, value);
}
g_strfreev(tokens);
}
-
g_strfreev(elems);
/* Proceed to the end of the "\r\n\r\n" */
@@ -306,7 +305,7 @@ msn_message_parse_payload(MsnMessage *ms
msg->msnslp_message = TRUE;
- /* Import the header. */
+ /* Extract the binary SLP header */
memcpy(&header, tmp, sizeof(header));
tmp += sizeof(header);
@@ -322,7 +321,7 @@ msn_message_parse_payload(MsnMessage *ms
body_len = payload_len - (tmp - tmp_base) - sizeof(footer);
- /* Import the body. */
+ /* Extract the body */
if (body_len > 0) {
msg->body_len = body_len;
g_free(msg->body);
@@ -332,7 +331,7 @@ msn_message_parse_payload(MsnMessage *ms
tmp += body_len;
}
- /* Import the footer. */
+ /* Extract the footer */
if (body_len >= 0) {
memcpy(&footer, tmp, sizeof(footer));
tmp += sizeof(footer);
@@ -348,7 +347,7 @@ msn_message_parse_payload(MsnMessage *ms
memcpy(msg->body, tmp, msg->body_len);
msg->body[msg->body_len] = '\0';
}
-
+
if ((!content_type || !strcmp(content_type, "text/plain"))
&& msg->charset == NULL) {
char *body = g_convert(msg->body, msg->body_len, "UTF-8",
@@ -454,13 +453,13 @@ msn_message_gen_payload(MsnMessage *msg,
n += strlen(n);
- for (l = msg->attr_list; l != NULL; l = l->next)
+ for (l = msg->header_list; l != NULL; l = l->next)
{
const char *key;
const char *value;
key = l->data;
- value = msn_message_get_attr(msg, key);
+ value = msn_message_get_header_value(msg, key);
g_snprintf(n, end - n, "%s: %s\r\n", key, value);
n += strlen(n);
@@ -610,15 +609,15 @@ void
}
void
-msn_message_set_attr(MsnMessage *msg, const char *attr, const char *value)
+msn_message_set_header(MsnMessage *msg, const char *name, const char *value)
{
const char *temp;
- char *new_attr;
+ char *new_name;
g_return_if_fail(msg != NULL);
- g_return_if_fail(attr != NULL);
+ g_return_if_fail(name != NULL);
- temp = msn_message_get_attr(msg, attr);
+ temp = msn_message_get_header_value(msg, name);
if (value == NULL)
{
@@ -626,37 +625,37 @@ msn_message_set_attr(MsnMessage *msg, co
{
GList *l;
- for (l = msg->attr_list; l != NULL; l = l->next)
+ for (l = msg->header_list; l != NULL; l = l->next)
{
- if (!g_ascii_strcasecmp(l->data, attr))
+ if (!g_ascii_strcasecmp(l->data, name))
{
- msg->attr_list = g_list_remove(msg->attr_list, l->data);
+ msg->header_list = g_list_remove(msg->header_list, l->data);
break;
}
}
- g_hash_table_remove(msg->attr_table, attr);
+ g_hash_table_remove(msg->header_table, name);
}
return;
}
- new_attr = g_strdup(attr);
+ new_name = g_strdup(name);
- g_hash_table_insert(msg->attr_table, new_attr, g_strdup(value));
+ g_hash_table_insert(msg->header_table, new_name, g_strdup(value));
if (temp == NULL)
- msg->attr_list = g_list_append(msg->attr_list, new_attr);
+ msg->header_list = g_list_append(msg->header_list, new_name);
}
const char *
-msn_message_get_attr(const MsnMessage *msg, const char *attr)
+msn_message_get_header_value(const MsnMessage *msg, const char *name)
{
g_return_val_if_fail(msg != NULL, NULL);
- g_return_val_if_fail(attr != NULL, NULL);
+ g_return_val_if_fail(name != NULL, NULL);
- return g_hash_table_lookup(msg->attr_table, attr);
+ return g_hash_table_lookup(msg->header_table, name);
}
GHashTable *
@@ -741,13 +740,13 @@ msn_message_show_readable(MsnMessage *ms
msg->content_type, msg->charset);
}
- for (l = msg->attr_list; l; l = l->next)
+ for (l = msg->header_list; l; l = l->next)
{
char *key;
const char *value;
key = l->data;
- value = msn_message_get_attr(msg, key);
+ value = msn_message_get_header_value(msg, key);
g_string_append_printf(str, "%s: %s\r\n", key, value);
}
@@ -840,13 +839,13 @@ msn_plain_msg(MsnCmdProc *cmdproc, MsnMe
}
#if 0
- if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "User-Agent")) != NULL)
{
purple_debug_misc("msn", "User-Agent = '%s'\n", value);
}
#endif
- if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "X-MMS-IM-Format")) != NULL)
{
char *pre, *post;
@@ -914,7 +913,7 @@ msn_control_msg(MsnCmdProc *cmdproc, Msn
gc = cmdproc->session->account->gc;
passport = msg->remote_user;
- if (msn_message_get_attr(msg, "TypingUser") == NULL)
+ if (msn_message_get_header_value(msg, "TypingUser") == NULL)
return;
if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
============================================================
--- libpurple/protocols/msn/msg.h 463e47046c1a8ee0ed241036878dd579886c66ba
+++ libpurple/protocols/msn/msg.h 3de3f539b888ce0bb26b84a7a8e1f0070bde3f84
@@ -109,8 +109,8 @@ struct _MsnMessage
MsnSlpHeader msnslp_header;
MsnSlpFooter msnslp_footer;
- GHashTable *attr_table;
- GList *attr_list;
+ GHashTable *header_table;
+ GList *header_list;
gboolean ack_ref; /**< A flag that states if this message has
been ref'ed for using it in a callback. */
@@ -295,24 +295,24 @@ const char *msn_message_get_charset(cons
const char *msn_message_get_charset(const MsnMessage *msg);
/**
- * Sets an attribute in a message.
+ * Sets a header in a message.
*
- * @param msg The message.
- * @param attr The attribute name.
- * @param value The attribute value.
+ * @param msg The message.
+ * @param header The header name.
+ * @param value The header value.
*/
-void msn_message_set_attr(MsnMessage *msg, const char *attr,
+void msn_message_set_header(MsnMessage *msg, const char *name,
const char *value);
/**
- * Returns an attribute from a message.
+ * Returns the value of a header from a message.
*
- * @param msg The message.
- * @param attr The attribute.
+ * @param msg The message.
+ * @param header The header value.
*
* @return The value, or @c NULL if not found.
*/
-const char *msn_message_get_attr(const MsnMessage *msg, const char *attr);
+const char *msn_message_get_header_value(const MsnMessage *msg, const char *name);
/**
* Parses the body and returns it in the form of a hashtable.
============================================================
--- libpurple/protocols/msn/msn.c 3c694a65eeb99adb199b3b851b9f18a27808208b
+++ libpurple/protocols/msn/msn.c 22eee3247ab4b1586769091e220f677f2cf6db98
@@ -1399,7 +1399,7 @@ msn_send_im(PurpleConnection *gc, const
msg = msn_message_new_plain(msgtext);
msg->remote_user = g_strdup(who);
- msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
+ msn_message_set_header(msg, "X-MMS-IM-Format", msgformat);
g_free(msgformat);
g_free(msgtext);
@@ -1432,7 +1432,7 @@ msn_send_im(PurpleConnection *gc, const
body_enc = g_markup_escape_text(body_str, -1);
g_free(body_str);
- format = msn_message_get_attr(msg, "X-MMS-IM-Format");
+ format = msn_message_get_header_value(msg, "X-MMS-IM-Format");
msn_parse_format(format, &pre, &post);
body_str = g_strdup_printf("%s%s%s", pre ? pre : "",
body_enc ? body_enc : "", post ? post : "");
@@ -1507,7 +1507,7 @@ msn_send_typing(PurpleConnection *gc, co
msg = msn_message_new(MSN_MSG_TYPING);
msn_message_set_content_type(msg, "text/x-msmsgscontrol");
msn_message_set_flag(msg, 'U');
- msn_message_set_attr(msg, "TypingUser",
+ msn_message_set_header(msg, "TypingUser",
purple_account_get_username(account));
msn_message_set_bin_data(msg, "\r\n", 2);
@@ -1914,7 +1914,7 @@ msn_chat_send(PurpleConnection *gc, int
}
msg = msn_message_new_plain(msgtext);
- msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
+ msn_message_set_header(msg, "X-MMS-IM-Format", msgformat);
smileys = msn_msg_grab_emoticons(msg->body, username);
while (smileys) {
============================================================
--- libpurple/protocols/msn/notification.c e101872d64b2de458363eeeeceb1d92af5e09a6a
+++ libpurple/protocols/msn/notification.c 291c0514a8572a6796acccfc2691472ec784c2fe
@@ -401,7 +401,7 @@ ubm_cmd_post(MsnCmdProc *cmdproc, MsnCom
body = msn_message_get_bin_data(msg, &body_len);
body_enc = g_markup_escape_text(body, body_len);
- if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) {
+ if ((value = msn_message_get_header_value(msg, "X-MMS-IM-Format")) != NULL) {
char *pre, *post;
msn_parse_format(value, &pre, &post);
@@ -415,7 +415,7 @@ ubm_cmd_post(MsnCmdProc *cmdproc, MsnCom
g_free(body_final);
}
if(!strcmp(content_type,"text/x-msmsgscontrol")){
- if(msn_message_get_attr(msg, "TypingUser") != NULL){
+ if(msn_message_get_header_value(msg, "TypingUser") != NULL){
serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
PURPLE_TYPING);
}
@@ -2033,39 +2033,39 @@ profile_msg(MsnCmdProc *cmdproc, MsnMess
/* This isn't an official message. */
return;
- if ((value = msn_message_get_attr(msg, "kv")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "kv")) != NULL)
{
g_free(session->passport_info.kv);
session->passport_info.kv = g_strdup(value);
}
- if ((value = msn_message_get_attr(msg, "sid")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "sid")) != NULL)
{
g_free(session->passport_info.sid);
session->passport_info.sid = g_strdup(value);
}
- if ((value = msn_message_get_attr(msg, "MSPAuth")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "MSPAuth")) != NULL)
{
g_free(session->passport_info.mspauth);
session->passport_info.mspauth = g_strdup(value);
}
- if ((value = msn_message_get_attr(msg, "ClientIP")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "ClientIP")) != NULL)
{
g_free(session->passport_info.client_ip);
session->passport_info.client_ip = g_strdup(value);
}
- if ((value = msn_message_get_attr(msg, "ClientPort")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "ClientPort")) != NULL)
{
session->passport_info.client_port = ntohs(atoi(value));
}
- if ((value = msn_message_get_attr(msg, "LoginTime")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "LoginTime")) != NULL)
session->passport_info.sl = atol(value);
- if ((value = msn_message_get_attr(msg, "EmailEnabled")) != NULL)
+ if ((value = msn_message_get_header_value(msg, "EmailEnabled")) != NULL)
session->passport_info.email_enabled = (gboolean)atol(value);
/*starting retrieve the contact list*/
============================================================
--- libpurple/protocols/msn/oim.c 4e3b96699692c8b11626bb21613d2928eac7db58
+++ libpurple/protocols/msn/oim.c 3e136ef5911a7f3edb95b22cde0e9fb8280086a4
@@ -618,7 +618,7 @@ msn_oim_report_to_user(MsnOimRecvData *r
MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM);
purple_debug_info("msn", "oim body:{%s}\n", message->body);
- boundary = msn_message_get_attr(message, "boundary");
+ boundary = msn_message_get_header_value(message, "boundary");
if (boundary != NULL) {
char *bounds;
@@ -656,7 +656,7 @@ msn_oim_report_to_user(MsnOimRecvData *r
decode_msg = (char *)purple_base64_decode(message->body, &body_len);
}
- from = msn_message_get_attr(message, "X-OIM-originatingSource");
+ from = msn_message_get_header_value(message, "X-OIM-originatingSource");
/* Match number to user's mobile number, FROM is a phone number
if the other side pages you using your phone number */
@@ -671,7 +671,7 @@ msn_oim_report_to_user(MsnOimRecvData *r
if (passport == NULL) {
char *start, *end;
- from = msn_message_get_attr(message, "From");
+ from = msn_message_get_header_value(message, "From");
tokens = g_strsplit(from, " ", 2);
if (tokens[1] != NULL)
@@ -690,7 +690,7 @@ msn_oim_report_to_user(MsnOimRecvData *r
g_strfreev(tokens);
}
- date = msn_message_get_attr(message, "Date");
+ date = msn_message_get_header_value(message, "Date");
stamp = msn_oim_parse_timestamp(date);
purple_debug_info("msn", "oim Date:{%s},passport{%s}\n",
date, passport);
============================================================
--- libpurple/protocols/msn/slp.c 3791d1f2ebc50ec51989809ba3548a65f9cacc84
+++ libpurple/protocols/msn/slp.c b47b40fea415942b39b4085c10e0a277f1189267
@@ -740,6 +740,7 @@ msn_slp_sip_recv(MsnSlpLink *slplink, co
if (!strncmp(body, "INVITE", strlen("INVITE")))
{
+ /* This is an INVITE request */
char *branch;
char *content;
char *content_type;
@@ -783,6 +784,7 @@ msn_slp_sip_recv(MsnSlpLink *slplink, co
}
else if (!strncmp(body, "MSNSLP/1.0 ", strlen("MSNSLP/1.0 ")))
{
+ /* This is a response */
char *content;
char *content_type;
/* Make sure this is "OK" */
@@ -832,6 +834,7 @@ msn_slp_sip_recv(MsnSlpLink *slplink, co
}
else if (!strncmp(body, "BYE", strlen("BYE")))
{
+ /* This is a BYE request */
char *call_id;
call_id = get_token(body, "Call-ID: {", "}");
============================================================
--- libpurple/protocols/msn/slplink.c 590f3cea0e7283cd23d5f8897e11d0630e9e56be
+++ libpurple/protocols/msn/slplink.c 4617ae0c46d48082ffc9fd371e5d9adb04e66040
@@ -390,7 +390,7 @@ msn_slplink_release_slpmsg(MsnSlpLink *s
msg->msnslp_header.total_size = slpmsg->size;
- msn_message_set_attr(msg, "P2P-Dest", slplink->remote_user);
+ msn_message_set_header(msg, "P2P-Dest", slplink->remote_user);
msg->ack_cb = msg_ack;
msg->nak_cb = msg_nak;
============================================================
--- libpurple/protocols/msn/switchboard.c 2ce38bc8feec06072bf4a07a5dc61f8bd38a0fb6
+++ libpurple/protocols/msn/switchboard.c 4ef06caca222d5352c35e570c8fb04eb7fb1c897
@@ -511,7 +511,7 @@ msg_error_helper(MsnCmdProc *cmdproc, Ms
body_enc = g_markup_escape_text(body_str, -1);
g_free(body_str);
- format = msn_message_get_attr(msg, "X-MMS-IM-Format");
+ format = msn_message_get_header_value(msg, "X-MMS-IM-Format");
msn_parse_format(format, &pre, &post);
body_str = g_strdup_printf("%s%s%s", pre ? pre : "",
body_enc ? body_enc : "", post ? post : "");
More information about the Commits
mailing list