Mercurial > pidgin.yaz
changeset 23559:7e16d193bb57
Get rid of that whole msn_set_payload_len thing and correctly set the
cmd->payload_len in each command handler callback. This should take
care of that CAL 3 error and a few sporadic "unhandled commands" I saw
while testing HTTP method.
References #5377.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Wed, 09 Jul 2008 01:46:10 +0000 |
parents | cab5420c3879 |
children | 02b91dbf738d b1457c51da46 |
files | libpurple/protocols/msn/command.c libpurple/protocols/msn/notification.c libpurple/protocols/msn/switchboard.c |
diffstat | 3 files changed, 37 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/command.c Wed Jul 09 00:32:18 2008 +0000 +++ b/libpurple/protocols/msn/command.c Wed Jul 09 01:46:10 2008 +0000 @@ -36,57 +36,6 @@ return TRUE; } -/* - * check the command is the command with payload content - * if it is return TRUE - * else return FALSE - */ -static gboolean -msn_check_payload_cmd(const char *str) -{ - g_return_val_if_fail(str != NULL, FALSE); - - if((!strcmp(str,"ADL")) || - (!strcmp(str,"GCF")) || - (!strcmp(str,"SG")) || - (!strcmp(str,"MSG")) || - (!strcmp(str,"RML")) || - (!strcmp(str,"UBX")) || - (!strcmp(str,"UBN")) || - (!strcmp(str,"UUM")) || - (!strcmp(str,"UBM")) || - (!strcmp(str,"FQY")) || - (!strcmp(str,"UUN")) || - (!strcmp(str,"UUX")) || - (!strcmp(str,"IPG")) || - (is_num(str))){ - return TRUE; - } - - return FALSE; -} - -/* - * set command Payload length - */ -static gboolean -msn_set_payload_len(MsnCommand *cmd) -{ - char *param; - int len = 0; - gboolean has_payload = FALSE; - - if (msn_check_payload_cmd(cmd->command) && (cmd->param_count > 0)){ - param = cmd->params[cmd->param_count - 1]; - len = is_num(param) ? atoi(param) : 0; - has_payload = TRUE; - } - - cmd->payload_len = len; - - return has_payload; -} - MsnCommand * msn_command_from_string(const char *string) { @@ -124,11 +73,6 @@ cmd->trId = 0; } - /* khc: Huh! */ - /*add payload Length checking*/ - if (msn_set_payload_len(cmd)) - purple_debug_info("MSNP14","get payload len:%" G_GSIZE_FORMAT "\n", cmd->payload_len); - msn_command_ref(cmd); return cmd;
--- a/libpurple/protocols/msn/notification.c Wed Jul 09 00:32:18 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Wed Jul 09 01:46:10 2008 +0000 @@ -376,14 +376,12 @@ msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { purple_debug_info("MSNP14","Processing MSG... \n"); - if (cmd->payload_len == 0) { - return; - } + /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued * command and we are processing it */ if (cmd->payload == NULL) { cmdproc->last_cmd->payload_cb = msg_cmd_post; - cmdproc->servconn->payload_len = atoi(cmd->params[2]); + cmd->payload_len = atoi(cmd->params[2]); } else { g_return_if_fail(cmd->payload_cb != NULL); @@ -499,14 +497,12 @@ ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { purple_debug_info("MSNP14","Processing UBM... \n"); - if (cmd->payload_len == 0) { - return; - } + /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued * command and we are processing it */ - if (cmd->payload == NULL ){ - cmdproc->last_cmd->payload_cb = msg_cmd_post; - cmdproc->servconn->payload_len = atoi(cmd->params[4]); + if (cmd->payload == NULL) { + cmdproc->last_cmd->payload_cb = msg_cmd_post; + cmd->payload_len = atoi(cmd->params[4]); } else { g_return_if_fail(cmd->payload_cb != NULL); @@ -771,11 +767,12 @@ session = cmdproc->session; - if ( !strcmp(cmd->params[1], "OK")) { + if (!strcmp(cmd->params[1], "OK")) { /* ADL ack */ msn_session_finish_login(session); } else { cmdproc->last_cmd->payload_cb = adl_cmd_parse; + cmd->payload_len = atoi(cmd->params[1]); } return; @@ -814,24 +811,23 @@ { purple_debug_info("MSNP14","Process FQY\n"); cmdproc->last_cmd->payload_cb = fqy_cmd_post; + cmd->payload_len = atoi(cmd->params[1]); +} + +static void +rml_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, + size_t len) +{ + if (payload != NULL) + purple_debug_info("msn", "Received RML:\n%s\n", payload); } static void rml_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { -#if 0 - MsnTransaction *trans; - char * payload; -#endif - purple_debug_info("MSNP14","Process RML\n"); -#if 0 - trans = msn_transaction_new(cmdproc, "RML",""); - - msn_transaction_set_payload(trans, payload, strlen(payload)); - - msn_cmdproc_send_trans(cmdproc, trans); -#endif + cmd->payload_len = atoi(cmd->params[1]); + cmdproc->last_cmd->payload_cb = rml_cmd_post; } static void @@ -1098,7 +1094,7 @@ static void ipg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { - cmdproc->servconn->payload_len = atoi(cmd->params[0]); + cmd->payload_len = atoi(cmd->params[0]); cmdproc->last_cmd->payload_cb = ipg_cmd_post; } @@ -1640,8 +1636,9 @@ gcf_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { purple_debug_info("MSNP14","Processing GCF command\n"); + cmdproc->last_cmd->payload_cb = gcf_cmd_post; - return; + cmd->payload_len = atoi(cmd->params[1]); } static void @@ -1697,16 +1694,25 @@ ubx_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { purple_debug_misc("MSNP14","UBX received.\n"); - if(cmd->payload_len == 0){ - return; - } cmdproc->last_cmd->payload_cb = ubx_cmd_post; + cmd->payload_len = atoi(cmd->params[2]); +} + +static void +uux_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, + size_t len) +{ + /* Do Nothing, right now. */ + if (payload != NULL) + purple_debug_info("msn", "UUX payload:\n%s\n", payload); } static void uux_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { - purple_debug_misc("MSNP14","UUX received.\n"); + purple_debug_misc("msn", "UUX received.\n"); + cmdproc->last_cmd->payload_cb = uux_cmd_post; + cmd->payload_len = atoi(cmd->params[1]); } /**************************************************************************
--- a/libpurple/protocols/msn/switchboard.c Wed Jul 09 00:32:18 2008 +0000 +++ b/libpurple/protocols/msn/switchboard.c Wed Jul 09 01:46:10 2008 +0000 @@ -752,7 +752,7 @@ static void msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { - cmdproc->servconn->payload_len = atoi(cmd->params[2]); + cmd->payload_len = atoi(cmd->params[2]); cmdproc->last_cmd->payload_cb = msg_cmd_post; } @@ -760,7 +760,7 @@ ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { purple_debug_misc("MSNP14","get UBM...\n"); - cmdproc->servconn->payload_len = atoi(cmd->params[4]); + cmd->payload_len = atoi(cmd->params[4]); cmdproc->last_cmd->payload_cb = msg_cmd_post; }