Mercurial > pidgin.yaz
comparison src/protocols/msn/slp.c @ 9860:65b3156f9f48
[gaim-migrate @ 10739]
(21:34:57) shx: and after applying the on of the memleak...
(21:35:15) shx: patch to auto update msn buddy icons
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 25 Aug 2004 01:43:54 +0000 |
parents | d0c196ebe176 |
children | 68561f39acdc |
comparison
equal
deleted
inserted
replaced
9859:42f6b69c9d8e | 9860:65b3156f9f48 |
---|---|
38 const char *type, const char *content); | 38 const char *type, const char *content); |
39 | 39 |
40 static void send_decline(MsnSlpCall *slpcall, const char *branch, | 40 static void send_decline(MsnSlpCall *slpcall, const char *branch, |
41 const char *type, const char *content); | 41 const char *type, const char *content); |
42 | 42 |
43 void msn_request_user_display(MsnUser *user); | |
44 | |
43 /************************************************************************** | 45 /************************************************************************** |
44 * Util | 46 * Util |
45 **************************************************************************/ | 47 **************************************************************************/ |
46 | 48 |
47 char * | 49 char * |
751 msn_slplink_request_object(slplink, smile, got_emoticon, obj); | 753 msn_slplink_request_object(slplink, smile, got_emoticon, obj); |
752 | 754 |
753 g_strfreev(tokens); | 755 g_strfreev(tokens); |
754 } | 756 } |
755 | 757 |
756 void | |
757 got_user_display(MsnSlpCall *slpcall, | |
758 const char *data, long long size) | |
759 { | |
760 const char *info; | |
761 GaimAccount *account; | |
762 GSList *sl; | |
763 | |
764 info = slpcall->data_info; | |
765 gaim_debug_info("msn", "Got User Display: %s\n", info); | |
766 | |
767 account = slpcall->slplink->session->account; | |
768 | |
769 /* TODO: I think we need better buddy icon core functions. */ | |
770 gaim_buddy_icons_set_for_user(account, slpcall->slplink->remote_user, | |
771 (void *)data, size); | |
772 | |
773 sl = gaim_find_buddies(account, slpcall->slplink->remote_user); | |
774 | |
775 for (; sl != NULL; sl = sl->next) | |
776 { | |
777 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
778 gaim_blist_node_set_string((GaimBlistNode*)buddy, "icon_checksum", info); | |
779 } | |
780 } | |
781 | |
782 static gboolean | 758 static gboolean |
783 buddy_icon_cached(GaimConnection *gc, MsnObject *obj) | 759 buddy_icon_cached(GaimConnection *gc, MsnObject *obj) |
784 { | 760 { |
785 GaimAccount *account; | 761 GaimAccount *account; |
786 GaimBuddy *buddy; | 762 GaimBuddy *buddy; |
814 | 790 |
815 return FALSE; | 791 return FALSE; |
816 } | 792 } |
817 | 793 |
818 void | 794 void |
819 msn_request_buddy_icon(GaimConnection *gc, const char *passport) | 795 msn_release_buddy_icon_request(MsnUserList *userlist) |
820 { | 796 { |
797 MsnUser *user; | |
798 | |
799 while (userlist->buddy_icon_window > 0) | |
800 { | |
801 GQueue *queue; | |
802 GaimAccount *account; | |
803 const char *username; | |
804 | |
805 queue = userlist->buddy_icon_requests; | |
806 | |
807 if (g_queue_is_empty(userlist->buddy_icon_requests)) | |
808 break; | |
809 | |
810 user = g_queue_pop_head(queue); | |
811 | |
812 account = userlist->session->account; | |
813 username = user->passport; | |
814 | |
815 msn_request_user_display(user); | |
816 userlist->buddy_icon_window--; | |
817 } | |
818 } | |
819 | |
820 void | |
821 msn_queue_buddy_icon_request(MsnUser *user) | |
822 { | |
823 GaimAccount *account; | |
824 MsnObject *obj; | |
825 GQueue *queue; | |
826 | |
827 account = user->userlist->session->account; | |
828 | |
829 obj = msn_user_get_object(user); | |
830 | |
831 if (obj == NULL) | |
832 { | |
833 /* It seems the user has not set a msnobject */ | |
834 GSList *sl; | |
835 | |
836 /* TODO: I think we need better buddy icon core functions. */ | |
837 gaim_buddy_icons_set_for_user(account, user->passport, NULL, -1); | |
838 | |
839 sl = gaim_find_buddies(account, user->passport); | |
840 | |
841 for (; sl != NULL; sl = sl->next) | |
842 { | |
843 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
844 gaim_blist_node_remove_setting((GaimBlistNode*)buddy, "icon_checksum"); | |
845 } | |
846 | |
847 return; | |
848 } | |
849 | |
850 if (!buddy_icon_cached(account->gc, obj)) | |
851 { | |
852 MsnUserList *userlist; | |
853 | |
854 userlist = user->userlist; | |
855 queue = userlist->buddy_icon_requests; | |
856 | |
857 g_queue_push_tail(queue, user); | |
858 | |
859 if (userlist->buddy_icon_window > 0) | |
860 msn_release_buddy_icon_request(userlist); | |
861 } | |
862 } | |
863 | |
864 void | |
865 got_user_display(MsnSlpCall *slpcall, | |
866 const char *data, long long size) | |
867 { | |
868 const char *info; | |
869 GaimAccount *account; | |
870 GSList *sl; | |
871 | |
872 info = slpcall->data_info; | |
873 gaim_debug_info("msn", "Got User Display: %s\n", info); | |
874 | |
875 account = slpcall->slplink->session->account; | |
876 | |
877 /* TODO: I think we need better buddy icon core functions. */ | |
878 gaim_buddy_icons_set_for_user(account, slpcall->slplink->remote_user, | |
879 (void *)data, size); | |
880 | |
881 sl = gaim_find_buddies(account, slpcall->slplink->remote_user); | |
882 | |
883 for (; sl != NULL; sl = sl->next) | |
884 { | |
885 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
886 gaim_blist_node_set_string((GaimBlistNode*)buddy, "icon_checksum", info); | |
887 } | |
888 | |
889 slpcall->slplink->session->userlist->buddy_icon_window++; | |
890 msn_release_buddy_icon_request(slpcall->slplink->session->userlist); | |
891 } | |
892 | |
893 void | |
894 msn_request_user_display(MsnUser *user) | |
895 { | |
896 GaimAccount *account; | |
821 MsnSession *session; | 897 MsnSession *session; |
822 MsnSlpLink *slplink; | 898 MsnSlpLink *slplink; |
823 MsnUser *user; | |
824 MsnObject *obj; | 899 MsnObject *obj; |
825 const char *info; | 900 const char *info; |
826 | 901 |
827 session = gc->proto_data; | 902 session = user->userlist->session; |
828 | 903 account = session->account; |
829 g_return_if_fail(session->protocol_ver == 9); | 904 |
830 | 905 slplink = msn_session_get_slplink(session, user->passport); |
831 slplink = msn_session_get_slplink(session, passport); | |
832 | |
833 user = msn_userlist_find_user(session->userlist, passport); | |
834 | 906 |
835 obj = msn_user_get_object(user); | 907 obj = msn_user_get_object(user); |
836 | 908 |
837 if (obj == NULL) | |
838 /* It seems the user has not set a msnobject */ | |
839 return; | |
840 | |
841 info = msn_object_get_sha1c(obj); | 909 info = msn_object_get_sha1c(obj); |
842 | 910 |
843 if (!buddy_icon_cached(gc, obj)) | 911 if (g_ascii_strcasecmp(user->passport, |
912 gaim_account_get_username(account))) | |
913 { | |
844 msn_slplink_request_object(slplink, info, got_user_display, obj); | 914 msn_slplink_request_object(slplink, info, got_user_display, obj); |
845 } | 915 } |
916 else | |
917 { | |
918 session->userlist->buddy_icon_window++; | |
919 msn_release_buddy_icon_request(session->userlist); | |
920 } | |
921 } |