Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/myspace.c @ 17361:4a62ba3baa0c
Change msim_incoming_im_cb() to accept a MsimMessage *. Orthogonality is key.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Mon, 04 Jun 2007 03:55:35 +0000 |
parents | ceba4fc06c41 |
children | 6476a55a9542 |
comparison
equal
deleted
inserted
replaced
17360:ceba4fc06c41 | 17361:4a62ba3baa0c |
---|---|
692 /** | 692 /** |
693 * Callback to handle incoming messages, after resolving userid. | 693 * Callback to handle incoming messages, after resolving userid. |
694 * | 694 * |
695 * @param session | 695 * @param session |
696 * @param userinfo Message from server on user's info, containing UserName. | 696 * @param userinfo Message from server on user's info, containing UserName. |
697 * @param data A gchar * of the incoming instant message's text. | 697 * @param data A MsimMessage * of the incoming message. |
698 */ | 698 */ |
699 void msim_incoming_im_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) | 699 void msim_incoming_im_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
700 { | 700 { |
701 gchar *msg, *username, *body_str; | 701 gchar *username, *body_str; |
702 MsimMessage *msg; | |
702 GHashTable *body; | 703 GHashTable *body; |
703 | 704 |
704 g_return_if_fail(MSIM_SESSION_VALID(session)); | 705 g_return_if_fail(MSIM_SESSION_VALID(session)); |
705 g_return_if_fail(userinfo != NULL); | 706 g_return_if_fail(userinfo != NULL); |
706 | 707 |
709 g_free(body_str); | 710 g_free(body_str); |
710 g_return_if_fail(body != NULL); | 711 g_return_if_fail(body != NULL); |
711 | 712 |
712 username = g_hash_table_lookup(body, "UserName"); | 713 username = g_hash_table_lookup(body, "UserName"); |
713 | 714 |
714 msg = (gchar *)data; | 715 msg = (MsimMessage *)data; |
715 serv_got_im(session->gc, username, msg, PURPLE_MESSAGE_RECV, time(NULL)); | 716 serv_got_im(session->gc, username, msim_msg_get_string(msg, "msg"), PURPLE_MESSAGE_RECV, time(NULL)); |
716 | 717 |
717 /* msim_msg_free(userinfo); */ /* TODO: Should we? */ | 718 /* msim_msg_free(userinfo); */ /* TODO: Should we? */ |
718 g_hash_table_destroy(body); | 719 g_hash_table_destroy(body); |
720 msim_msg_free(msg); | |
719 } | 721 } |
720 | 722 |
721 /** | 723 /** |
722 * Handle an incoming instant message. | 724 * Handle an incoming instant message. |
723 * | 725 * |
727 * @return TRUE if successful. | 729 * @return TRUE if successful. |
728 */ | 730 */ |
729 gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg) | 731 gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg) |
730 { | 732 { |
731 gchar *userid; | 733 gchar *userid; |
732 gchar *msg_text; | |
733 | 734 |
734 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); | 735 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
735 g_return_val_if_fail(msg != NULL, FALSE); | 736 g_return_val_if_fail(msg != NULL, FALSE); |
736 | 737 |
737 /* TODO: where freed? */ | 738 /* TODO: where freed? */ |
738 userid = msim_msg_get_string(msg, "f"); | 739 userid = msim_msg_get_string(msg, "f"); |
739 msg_text = msim_msg_get_string(msg, "msg"); | |
740 | 740 |
741 purple_debug_info("msim", | 741 purple_debug_info("msim", |
742 "msim_incoming_im: got msg <%s> from <%s>, resolving username\n", | 742 "msim_incoming_im: got msg from <%s>, resolving username\n", userid); |
743 msg_text, userid); | |
744 | 743 |
745 /* TODO: don't use callbacks */ | 744 /* TODO: don't use callbacks */ |
746 msim_lookup_user(session, userid, msim_incoming_im_cb, msg_text); | 745 /* msg will be freed in callback */ |
746 msim_lookup_user(session, userid, msim_incoming_im_cb, msim_msg_clone(msg)); | |
747 | 747 |
748 return TRUE; | 748 return TRUE; |
749 } | 749 } |
750 | 750 |
751 /** | 751 /** |