comparison libpurple/protocols/msn/notification.c @ 23502:03ade2360ba6

Remove some MSN code duplication in processing messages from Yahoo buddies and fix a typo, I think. I don't have any Yahoo buddies to test this, though.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 23 Jun 2008 00:54:05 +0000
parents 80d09f42b157
children 5c95339855b2
comparison
equal deleted inserted replaced
23501:455a8264e06e 23502:03ade2360ba6
358 { 358 {
359 MsnMessage *msg; 359 MsnMessage *msg;
360 360
361 msg = msn_message_new_from_cmd(cmdproc->session, cmd); 361 msg = msn_message_new_from_cmd(cmdproc->session, cmd);
362 362
363 msn_message_parse_payload(msg, payload, len,MSG_LINE_DEM,MSG_BODY_DEM); 363 msn_message_parse_payload(msg, payload, len, MSG_LINE_DEM, MSG_BODY_DEM);
364 #ifdef MSN_DEBUG_NS 364 #ifdef MSN_DEBUG_NS
365 msn_message_show_readable(msg, "Notification", TRUE); 365 msn_message_show_readable(msg, "Notification", TRUE);
366 #endif 366 #endif
367 367
368 msn_cmdproc_process_msg(cmdproc, msg); 368 msn_cmdproc_process_msg(cmdproc, msg);
372 372
373 static void 373 static void
374 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 374 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
375 { 375 {
376 purple_debug_info("MSNP14","Processing MSG... \n"); 376 purple_debug_info("MSNP14","Processing MSG... \n");
377 if(cmd->payload_len == 0){ 377 if (cmd->payload_len == 0) {
378 return; 378 return;
379 } 379 }
380 /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued 380 /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued
381 * command and we are processing it */ 381 * command and we are processing it */
382 if (cmd->payload == NULL) 382 if (cmd->payload == NULL) {
383 {
384 cmdproc->last_cmd->payload_cb = msg_cmd_post; 383 cmdproc->last_cmd->payload_cb = msg_cmd_post;
385 cmdproc->servconn->payload_len = atoi(cmd->params[2]); 384 cmdproc->servconn->payload_len = atoi(cmd->params[2]);
386 } 385
387 else 386 } else {
388 {
389 g_return_if_fail(cmd->payload_cb != NULL); 387 g_return_if_fail(cmd->payload_cb != NULL);
390 388
391 #if 0 /* glib on win32 doesn't correctly support precision modifiers for a string */ 389 #if 0 /* glib on win32 doesn't correctly support precision modifiers for a string */
392 purple_debug_info("MSNP14", "MSG payload:{%.*s}\n", cmd->payload_len, cmd->payload); 390 purple_debug_info("MSNP14", "MSG payload:{%.*s}\n", cmd->payload_len, cmd->payload);
393 #endif 391 #endif
416 msg->remote_user, type, payload_len); 414 msg->remote_user, type, payload_len);
417 msn_transaction_set_payload(trans, payload, strlen(payload)); 415 msn_transaction_set_payload(trans, payload, strlen(payload));
418 msn_cmdproc_send_trans(cmdproc, trans); 416 msn_cmdproc_send_trans(cmdproc, trans);
419 } 417 }
420 418
419 #if 0
421 static void 420 static void
422 ubm_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, 421 ubm_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload,
423 size_t len) 422 size_t len)
424 { 423 {
425 MsnMessage *msg; 424 MsnMessage *msg;
489 msn_session_report_user(cmdproc->session,user,str,PURPLE_MESSAGE_SYSTEM); 488 msn_session_report_user(cmdproc->session,user,str,PURPLE_MESSAGE_SYSTEM);
490 g_free(str); 489 g_free(str);
491 } 490 }
492 msn_message_destroy(msg); 491 msn_message_destroy(msg);
493 } 492 }
493 #endif
494 494
495 /*Yahoo msg process*/ 495 /*Yahoo msg process*/
496 static void 496 static void
497 ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 497 ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
498 { 498 {
499 purple_debug_info("MSNP14","Processing UBM... \n"); 499 purple_debug_info("MSNP14","Processing UBM... \n");
500 if(cmd->payload_len == 0){ 500 if (cmd->payload_len == 0) {
501 return; 501 return;
502 } 502 }
503 /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued 503 /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued
504 * command and we are processing it */ 504 * command and we are processing it */
505 if (cmd->payload == NULL){ 505 if (cmd->payload == NULL ){
506 cmdproc->last_cmd->payload_cb = ubm_cmd_post; 506 cmdproc->last_cmd->payload_cb = msg_cmd_post;
507 cmdproc->servconn->payload_len = atoi(cmd->params[2]); 507 cmdproc->servconn->payload_len = atoi(cmd->params[4]);
508 }else{ 508 } else {
509 g_return_if_fail(cmd->payload_cb != NULL); 509 g_return_if_fail(cmd->payload_cb != NULL);
510 510
511 purple_debug_info("MSNP14", "UBM payload:{%.*s}\n", (guint)(cmd->payload_len), cmd->payload); 511 purple_debug_info("MSNP14", "UBM payload:{%.*s}\n", (guint)(cmd->payload_len), cmd->payload);
512 ubm_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len); 512 msg_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len);
513 } 513 }
514 } 514 }
515 515
516 /************************************************************************** 516 /**************************************************************************
517 * Challenges 517 * Challenges