comparison libpurple/protocols/msn/slp.c @ 16483:5e47b3427b28

propagate from branch 'im.pidgin.rlaager.gaim_migration' (head dcc40d46afbe3f87cc674e4fb1526ac722bc35cb) to branch 'im.pidgin.pidgin' (head 0ef5b6c44115778e329fd628324124f872f5253b)
author Sean Egan <seanegan@gmail.com>
date Fri, 27 Apr 2007 02:14:44 +0000
parents 4999bbc52881 3be560001d26
children ce049678a67b
comparison
equal deleted inserted replaced
16467:b2044e10915a 16483:5e47b3427b28
246 const char *euf_guid, const char *context) 246 const char *euf_guid, const char *context)
247 { 247 {
248 if (!strcmp(euf_guid, "A4268EEC-FEC5-49E5-95C3-F126696BDBF6")) 248 if (!strcmp(euf_guid, "A4268EEC-FEC5-49E5-95C3-F126696BDBF6"))
249 { 249 {
250 /* Emoticon or UserDisplay */ 250 /* Emoticon or UserDisplay */
251 char *content;
252 gsize len;
251 MsnSlpSession *slpsession; 253 MsnSlpSession *slpsession;
252 MsnSlpLink *slplink; 254 MsnSlpLink *slplink;
253 MsnSlpMessage *slpmsg; 255 MsnSlpMessage *slpmsg;
254 MsnObject *obj; 256 MsnObject *obj;
255 char *msnobj_data; 257 char *msnobj_data;
256 const char *file_name; 258 PurpleStoredImage *img;
257 char *content;
258 gsize len;
259 int type; 259 int type;
260 260
261 /* Send Ok */ 261 /* Send Ok */
262 content = g_strdup_printf("SessionID: %lu\r\n\r\n", 262 content = g_strdup_printf("SessionID: %lu\r\n\r\n",
263 slpcall->session_id); 263 slpcall->session_id);
279 purple_debug_error("msn", "Wrong object?\n"); 279 purple_debug_error("msn", "Wrong object?\n");
280 msn_object_destroy(obj); 280 msn_object_destroy(obj);
281 g_return_if_reached(); 281 g_return_if_reached();
282 } 282 }
283 283
284 file_name = msn_object_get_real_location(obj); 284 img = msn_object_get_image(obj);
285 285 if (img == NULL)
286 if (file_name == NULL)
287 { 286 {
288 purple_debug_error("msn", "Wrong object.\n"); 287 purple_debug_error("msn", "Wrong object.\n");
289 msn_object_destroy(obj); 288 msn_object_destroy(obj);
290 g_return_if_reached(); 289 g_return_if_reached();
291 } 290 }
312 slpmsg->slpsession = slpsession; 311 slpmsg->slpsession = slpsession;
313 slpmsg->flags = 0x20; 312 slpmsg->flags = 0x20;
314 #ifdef MSN_DEBUG_SLP 313 #ifdef MSN_DEBUG_SLP
315 slpmsg->info = "SLP DATA"; 314 slpmsg->info = "SLP DATA";
316 #endif 315 #endif
317 msn_slpmsg_open_file(slpmsg, file_name); 316 msn_slpmsg_set_image(slpmsg, img);
318 msn_slplink_queue_slpmsg(slplink, slpmsg); 317 msn_slplink_queue_slpmsg(slplink, slpmsg);
319 } 318 }
320 else if (!strcmp(euf_guid, "5D3E02AB-6190-11D3-BBBB-00C04F795683")) 319 else if (!strcmp(euf_guid, "5D3E02AB-6190-11D3-BBBB-00C04F795683"))
321 { 320 {
322 /* File Transfer */ 321 /* File Transfer */
868 867
869 buddy = purple_find_buddy(account, msn_object_get_creator(obj)); 868 buddy = purple_find_buddy(account, msn_object_get_creator(obj));
870 if (buddy == NULL) 869 if (buddy == NULL)
871 return FALSE; 870 return FALSE;
872 871
873 old = purple_blist_node_get_string((PurpleBlistNode *)buddy, "icon_checksum"); 872 old = purple_buddy_icons_get_checksum_for_user(buddy);
874 new = msn_object_get_sha1(obj); 873 new = msn_object_get_sha1(obj);
875 874
876 if (new == NULL) 875 if (new == NULL)
877 return FALSE; 876 return FALSE;
878 877
879 /* If the old and new checksums are the same, and the file actually exists, 878 /* If the old and new checksums are the same, and the file actually exists,
880 * then return TRUE */ 879 * then return TRUE */
881 if (old != NULL && !strcmp(old, new) && (purple_buddy_icons_find(account, purple_buddy_get_name(buddy)) != NULL)) 880 if (old != NULL && !strcmp(old, new))
882 return TRUE; 881 return TRUE;
883 882
884 return FALSE; 883 return FALSE;
885 } 884 }
886 885
954 953
955 obj = msn_user_get_object(user); 954 obj = msn_user_get_object(user);
956 955
957 if (obj == NULL) 956 if (obj == NULL)
958 { 957 {
959 /* It seems the user has not set a msnobject */ 958 purple_buddy_icons_set_for_user(account, user->passport, NULL, 0, NULL);
960 GSList *sl, *list;
961
962 list = purple_find_buddies(account, user->passport);
963
964 for (sl = list; sl != NULL; sl = sl->next)
965 {
966 PurpleBuddy *buddy = (PurpleBuddy *)sl->data;
967 if (buddy->icon)
968 purple_blist_node_remove_setting((PurpleBlistNode*)buddy, "icon_checksum");
969 }
970 g_slist_free(list);
971
972 /* TODO: I think we need better buddy icon core functions. */
973 purple_buddy_icons_set_for_user(account, user->passport, NULL, 0);
974
975 return; 959 return;
976 } 960 }
977 961
978 if (!buddy_icon_cached(account->gc, obj)) 962 if (!buddy_icon_cached(account->gc, obj))
979 { 963 {
999 const guchar *data, gsize size) 983 const guchar *data, gsize size)
1000 { 984 {
1001 MsnUserList *userlist; 985 MsnUserList *userlist;
1002 const char *info; 986 const char *info;
1003 PurpleAccount *account; 987 PurpleAccount *account;
1004 GSList *sl, *list;
1005 988
1006 g_return_if_fail(slpcall != NULL); 989 g_return_if_fail(slpcall != NULL);
1007 990
1008 info = slpcall->data_info; 991 info = slpcall->data_info;
1009 #ifdef MSN_DEBUG_UD 992 #ifdef MSN_DEBUG_UD
1011 #endif 994 #endif
1012 995
1013 userlist = slpcall->slplink->session->userlist; 996 userlist = slpcall->slplink->session->userlist;
1014 account = slpcall->slplink->session->account; 997 account = slpcall->slplink->session->account;
1015 998
1016 /* TODO: I think we need better buddy icon core functions. */
1017 purple_buddy_icons_set_for_user(account, slpcall->slplink->remote_user, 999 purple_buddy_icons_set_for_user(account, slpcall->slplink->remote_user,
1018 (void *)data, size); 1000 g_memdup(data, size), size, info);
1019
1020 list = purple_find_buddies(account, slpcall->slplink->remote_user);
1021
1022 for (sl = list; sl != NULL; sl = sl->next)
1023 {
1024 PurpleBuddy *buddy = (PurpleBuddy *)sl->data;
1025 purple_blist_node_set_string((PurpleBlistNode*)buddy, "icon_checksum", info);
1026 }
1027 g_slist_free(list);
1028 1001
1029 #if 0 1002 #if 0
1030 /* Free one window slot */ 1003 /* Free one window slot */
1031 userlist->buddy_icon_window++; 1004 userlist->buddy_icon_window++;
1032 1005
1099 end_user_display, obj); 1072 end_user_display, obj);
1100 } 1073 }
1101 else 1074 else
1102 { 1075 {
1103 MsnObject *my_obj = NULL; 1076 MsnObject *my_obj = NULL;
1104 gchar *data = NULL; 1077 gconstpointer data = NULL;
1105 gsize len = 0; 1078 size_t len = 0;
1106 GSList *sl, *list;
1107 1079
1108 #ifdef MSN_DEBUG_UD 1080 #ifdef MSN_DEBUG_UD
1109 purple_debug_info("msn", "Requesting our own user display\n"); 1081 purple_debug_info("msn", "Requesting our own user display\n");
1110 #endif 1082 #endif
1111 1083
1112 my_obj = msn_user_get_object(session->user); 1084 my_obj = msn_user_get_object(session->user);
1113 1085
1114 if (my_obj != NULL) 1086 if (my_obj != NULL)
1115 { 1087 {
1116 const char *filename = msn_object_get_real_location(my_obj); 1088 PurpleStoredImage *img = msn_object_get_image(my_obj);
1117 1089 data = purple_imgstore_get_data(img);
1118 if (filename != NULL) 1090 len = purple_imgstore_get_size(img);
1119 g_file_get_contents(filename, &data, &len, NULL); 1091 }
1120 } 1092
1121 1093 purple_buddy_icons_set_for_user(account, user->passport, g_memdup(data, len), len, info);
1122 /* TODO: I think we need better buddy icon core functions. */
1123 purple_buddy_icons_set_for_user(account, user->passport, (void *)data, len);
1124 g_free(data);
1125
1126 list = purple_find_buddies(account, user->passport);
1127
1128 for (sl = list; sl != NULL; sl = sl->next)
1129 {
1130 PurpleBuddy *buddy = (PurpleBuddy *)sl->data;
1131 purple_blist_node_set_string((PurpleBlistNode*)buddy, "icon_checksum", info);
1132 }
1133 g_slist_free(list);
1134 1094
1135 /* Free one window slot */ 1095 /* Free one window slot */
1136 session->userlist->buddy_icon_window++; 1096 session->userlist->buddy_icon_window++;
1137 1097
1138 #ifdef MSN_DEBUG_UD 1098 #ifdef MSN_DEBUG_UD