Mercurial > pidgin
comparison libpurple/protocols/msn/slp.c @ 30318:76049fde7ad2
Add support for Url/Url1 in MSN objects, which are used for buddy
icons when you're on the website.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 31 Jul 2010 23:39:40 +0000 |
parents | fc93bc1a546f |
children | 126317248aaa e53f81486d57 |
comparison
equal
deleted
inserted
replaced
30317:ea96292336f0 | 30318:76049fde7ad2 |
---|---|
37 /* seconds to delay between sending buddy icon requests to the server. */ | 37 /* seconds to delay between sending buddy icon requests to the server. */ |
38 #define BUDDY_ICON_DELAY 20 | 38 #define BUDDY_ICON_DELAY 20 |
39 | 39 |
40 static void request_user_display(MsnUser *user); | 40 static void request_user_display(MsnUser *user); |
41 | 41 |
42 typedef struct { | |
43 MsnSession *session; | |
44 const char *remote_user; | |
45 const char *sha1; | |
46 } MsnFetchUserDisplayData; | |
42 | 47 |
43 /************************************************************************** | 48 /************************************************************************** |
44 * Util | 49 * Util |
45 **************************************************************************/ | 50 **************************************************************************/ |
46 | 51 |
1403 userlist->buddy_icon_request_timer = purple_timeout_add_seconds(BUDDY_ICON_DELAY, | 1408 userlist->buddy_icon_request_timer = purple_timeout_add_seconds(BUDDY_ICON_DELAY, |
1404 msn_release_buddy_icon_request_timeout, userlist); | 1409 msn_release_buddy_icon_request_timeout, userlist); |
1405 } | 1410 } |
1406 | 1411 |
1407 static void | 1412 static void |
1413 fetched_user_display(PurpleUtilFetchUrlData *url_data, gpointer user_data, | |
1414 const gchar *url_text, gsize len, const gchar *error_message) | |
1415 { | |
1416 MsnFetchUserDisplayData *data = user_data; | |
1417 MsnSession *session = data->session; | |
1418 | |
1419 session->url_datas = g_slist_remove(session->url_datas, url_data); | |
1420 | |
1421 if (url_text) { | |
1422 purple_buddy_icons_set_for_user(session->account, data->remote_user, | |
1423 g_memdup(url_text, len), len, | |
1424 data->sha1); | |
1425 } | |
1426 | |
1427 end_user_display(NULL, session); | |
1428 | |
1429 g_free(user_data); | |
1430 } | |
1431 | |
1432 static void | |
1408 request_user_display(MsnUser *user) | 1433 request_user_display(MsnUser *user) |
1409 { | 1434 { |
1410 PurpleAccount *account; | 1435 PurpleAccount *account; |
1411 MsnSession *session; | 1436 MsnSession *session; |
1412 MsnSlpLink *slplink; | 1437 MsnSlpLink *slplink; |
1423 info = msn_object_get_sha1(obj); | 1448 info = msn_object_get_sha1(obj); |
1424 | 1449 |
1425 if (g_ascii_strcasecmp(user->passport, | 1450 if (g_ascii_strcasecmp(user->passport, |
1426 purple_account_get_username(account))) | 1451 purple_account_get_username(account))) |
1427 { | 1452 { |
1428 msn_slplink_request_object(slplink, info, got_user_display, | 1453 const char *url = msn_object_get_url1(obj); |
1429 end_user_display, obj); | 1454 if (url) { |
1455 MsnFetchUserDisplayData *data = g_new0(MsnFetchUserDisplayData, 1); | |
1456 PurpleUtilFetchUrlData *url_data; | |
1457 data->session = session; | |
1458 data->remote_user = user->passport; | |
1459 data->sha1 = info; | |
1460 url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE, 200*1024, | |
1461 fetched_user_display, data); | |
1462 session->url_datas = g_slist_prepend(session->url_datas, url_data); | |
1463 } else { | |
1464 msn_slplink_request_object(slplink, info, got_user_display, | |
1465 end_user_display, obj); | |
1466 } | |
1430 } | 1467 } |
1431 else | 1468 else |
1432 { | 1469 { |
1433 MsnObject *my_obj = NULL; | 1470 MsnObject *my_obj = NULL; |
1434 gconstpointer data = NULL; | 1471 gconstpointer data = NULL; |