libgaim/protocols/msn/msn.c

changeset 15205
f642029b2f97
parent 15192
88aab6305a39
child 15281
5c0b8a2f6b3e
equal deleted inserted replaced
15204:6775ac53169c 15205:f642029b2f97
65 typedef struct 65 typedef struct
66 { 66 {
67 MsnGetInfoData *info_data; 67 MsnGetInfoData *info_data;
68 char *stripped; 68 char *stripped;
69 char *url_buffer; 69 char *url_buffer;
70 GString *s; 70 GaimNotifyUserInfo *user_info;
71 char *photo_url_text; 71 char *photo_url_text;
72 char *tooltip_text;
73 const char *title;
74 72
75 } MsnGetInfoStepTwoData; 73 } MsnGetInfoStepTwoData;
76 74
77 static const char * 75 static const char *
78 msn_normalize(const GaimAccount *account, const char *str) 76 msn_normalize(const GaimAccount *account, const char *str)
531 529
532 return NULL; 530 return NULL;
533 } 531 }
534 532
535 static void 533 static void
536 msn_tooltip_text(GaimBuddy *buddy, GString *str, gboolean full) 534 msn_tooltip_text(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full)
537 { 535 {
538 MsnUser *user; 536 MsnUser *user;
539 GaimPresence *presence = gaim_buddy_get_presence(buddy); 537 GaimPresence *presence = gaim_buddy_get_presence(buddy);
540 GaimStatus *status = gaim_presence_get_active_status(presence); 538 GaimStatus *status = gaim_presence_get_active_status(presence);
541 539
542 user = buddy->proto_data; 540 user = buddy->proto_data;
543 541
542
544 if (gaim_presence_is_online(presence)) 543 if (gaim_presence_is_online(presence))
545 { 544 {
546 g_string_append_printf(str, _("\n<b>%s:</b> %s"), _("Status"), 545 gaim_notify_user_info_add_pair(user_info, _("Status"),
547 gaim_presence_is_idle(presence) ? 546 (gaim_presence_is_idle(presence) ? _("Idle") : gaim_status_get_name(status)));
548 _("Idle") : gaim_status_get_name(status)); 547 }
549 } 548
550
551 if (full && user) 549 if (full && user)
552 { 550 {
553 g_string_append_printf(str, _("\n<b>%s:</b> %s"), _("Has you"), 551 gaim_notify_user_info_add_pair(user_info, _("Has you"),
554 (user->list_op & (1 << MSN_LIST_RL)) ? 552 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No")));
555 _("Yes") : _("No")); 553 }
556 554
557 /* XXX: This is being shown in non-full tooltips because the 555 /* XXX: This is being shown in non-full tooltips because the
558 * XXX: blocked icon overlay isn't always accurate for MSN. 556 * XXX: blocked icon overlay isn't always accurate for MSN.
559 * XXX: This can die as soon as gaim_privacy_check() knows that 557 * XXX: This can die as soon as gaim_privacy_check() knows that
560 * XXX: this prpl always honors both the allow and deny lists. */ 558 * XXX: this prpl always honors both the allow and deny lists. */
561 if (user) 559 if (user)
562 g_string_append_printf(str, _("\n<b>%s:</b> %s"), _("Blocked"), 560 {
563 (user->list_op & (1 << MSN_LIST_BL)) ? 561 gaim_notify_user_info_add_pair(user_info, _("Blocked"),
564 _("Yes") : _("No")); 562 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No")));
565 } 563 }
566 } 564 }
567 565
568 static GList * 566 static GList *
569 msn_status_types(GaimAccount *account) 567 msn_status_types(GaimAccount *account)
1339 { 1337 {
1340 msn_cmdproc_send(cmdproc, "RMG", "%d", group_id); 1338 msn_cmdproc_send(cmdproc, "RMG", "%d", group_id);
1341 } 1339 }
1342 } 1340 }
1343 1341
1344 static char * 1342 /**
1345 msn_tooltip_info_text(MsnGetInfoData *info_data) 1343 * Extract info text from info_data and add it to user_info
1346 { 1344 */
1347 GString *s; 1345 static gboolean
1346 msn_tooltip_extract_info_text(GaimNotifyUserInfo *user_info, MsnGetInfoData *info_data)
1347 {
1348 GaimBuddy *b; 1348 GaimBuddy *b;
1349
1350 s = g_string_sized_new(80); /* wild guess */
1351 1349
1352 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), 1350 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc),
1353 info_data->name); 1351 info_data->name);
1354 1352
1355 if (b) 1353 if (b)
1356 { 1354 {
1357 GString *str = g_string_new("");
1358 char *tmp; 1355 char *tmp;
1359 1356
1360 if (b->alias && b->alias[0]) 1357 if (b->alias && b->alias[0])
1361 { 1358 {
1362 char *aliastext = g_markup_escape_text(b->alias, -1); 1359 char *aliastext = g_markup_escape_text(b->alias, -1);
1363 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); 1360 gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
1364 g_free(aliastext); 1361 g_free(aliastext);
1365 } 1362 }
1366 1363
1367 if (b->server_alias) 1364 if (b->server_alias)
1368 { 1365 {
1369 char *nicktext = g_markup_escape_text(b->server_alias, -1); 1366 char *nicktext = g_markup_escape_text(b->server_alias, -1);
1370 g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname")); 1367 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext);
1371 g_string_append_printf(s, "<font sml=\"msn\">%s</font><br>", 1368 gaim_notify_user_info_add_pair(user_info, _("Nickname"), tmp);
1372 nicktext); 1369 g_free(tmp);
1373 g_free(nicktext); 1370 g_free(nicktext);
1374 } 1371 }
1375 1372
1376 msn_tooltip_text(b, str, TRUE); 1373 /* Add the tooltip information */
1377 tmp = gaim_strreplace((*str->str == '\n' ? str->str + 1 : str->str), 1374 msn_tooltip_text(b, user_info, TRUE);
1378 "\n", "<br>"); 1375
1379 g_string_free(str, TRUE); 1376 return TRUE;
1380 g_string_append_printf(s, "%s<br>", tmp); 1377 }
1381 g_free(tmp); 1378
1382 } 1379 return FALSE;
1383
1384 return g_string_free(s, FALSE);
1385 } 1380 }
1386 1381
1387 #if PHOTO_SUPPORT 1382 #if PHOTO_SUPPORT
1388 1383
1389 static char * 1384 static char *
1417 return g_strdup(gaim_date_format_short(localtime(&t))); 1412 return g_strdup(gaim_date_format_short(localtime(&t)));
1418 } 1413 }
1419 #endif 1414 #endif
1420 1415
1421 #define MSN_GOT_INFO_GET_FIELD(a, b) \ 1416 #define MSN_GOT_INFO_GET_FIELD(a, b) \
1422 found = gaim_markup_extract_info_field(stripped, stripped_len, s, \ 1417 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, \
1423 "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ 1418 "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \
1424 if (found) \ 1419 if (found) \
1425 sect_info = TRUE; 1420 sect_info = TRUE;
1426 1421
1427 static void 1422 static void
1428 msn_got_info(GaimUtilFetchUrlData *url_data, gpointer data, 1423 msn_got_info(GaimUtilFetchUrlData *url_data, gpointer data,
1429 const gchar *url_text, size_t len, const gchar *error_message) 1424 const gchar *url_text, size_t len, const gchar *error_message)
1430 { 1425 {
1431 MsnGetInfoData *info_data = (MsnGetInfoData *)data; 1426 MsnGetInfoData *info_data = (MsnGetInfoData *)data;
1432 char *stripped, *p, *q; 1427 GaimNotifyUserInfo *user_info;
1433 char buf[1024]; 1428 char *stripped, *p, *q, *tmp;
1434 char *tooltip_text;
1435 char *user_url = NULL; 1429 char *user_url = NULL;
1436 gboolean found; 1430 gboolean found;
1431 gboolean has_tooltip_text = FALSE;
1437 gboolean has_info = FALSE; 1432 gboolean has_info = FALSE;
1438 gboolean sect_info = FALSE; 1433 gboolean sect_info = FALSE;
1439 const char* title = NULL; 1434 gboolean has_contact_info = FALSE;
1440 char *url_buffer; 1435 char *url_buffer;
1441 char *personal = NULL;
1442 char *business = NULL;
1443 GString *s, *s2; 1436 GString *s, *s2;
1444 int stripped_len; 1437 int stripped_len;
1445 #if PHOTO_SUPPORT 1438 #if PHOTO_SUPPORT
1446 char *photo_url_text = NULL; 1439 char *photo_url_text = NULL;
1447 MsnGetInfoStepTwoData *info2_data = NULL; 1440 MsnGetInfoStepTwoData *info2_data = NULL;
1456 g_free(info_data->name); 1449 g_free(info_data->name);
1457 g_free(info_data); 1450 g_free(info_data);
1458 return; 1451 return;
1459 } 1452 }
1460 1453
1461 tooltip_text = msn_tooltip_info_text(info_data); 1454 user_info = gaim_notify_user_info_new();
1462 title = _("MSN Profile"); 1455 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data);
1463 1456
1464 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) 1457 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0)
1465 { 1458 {
1466 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", 1459 tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile"));
1467 tooltip_text, _("Error retrieving profile")); 1460 gaim_notify_user_info_add_pair(user_info, NULL, tmp);
1468 1461 g_free(tmp);
1469 gaim_notify_userinfo(info_data->gc, info_data->name, buf, NULL, NULL); 1462
1470 1463 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL);
1471 g_free(tooltip_text); 1464 gaim_notify_user_info_destroy(user_info);
1465
1472 g_free(info_data->name); 1466 g_free(info_data->name);
1473 g_free(info_data); 1467 g_free(info_data);
1474 return; 1468 return;
1475 } 1469 }
1476 1470
1526 1520
1527 /* Gonna re-use the memory we've already got for url_buffer */ 1521 /* Gonna re-use the memory we've already got for url_buffer */
1528 /* No we're not. */ 1522 /* No we're not. */
1529 s = g_string_sized_new(strlen(url_buffer)); 1523 s = g_string_sized_new(strlen(url_buffer));
1530 s2 = g_string_sized_new(strlen(url_buffer)); 1524 s2 = g_string_sized_new(strlen(url_buffer));
1531 1525
1526 /* General section header */
1527 if (has_tooltip_text)
1528 gaim_notify_user_info_add_section_break(user_info);
1529
1530 gaim_notify_user_info_add_section_header(user_info, _("General"));
1531
1532 /* Extract their Name and put it in */ 1532 /* Extract their Name and put it in */
1533 MSN_GOT_INFO_GET_FIELD("Name", _("Name")) 1533 MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
1534 1534
1535 /* General */ 1535 /* General */
1536 MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); 1536 MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname"));
1537 MSN_GOT_INFO_GET_FIELD("Age", _("Age")); 1537 MSN_GOT_INFO_GET_FIELD("Age", _("Age"));
1538 MSN_GOT_INFO_GET_FIELD("Gender", _("Gender")); 1538 MSN_GOT_INFO_GET_FIELD("Gender", _("Gender"));
1539 MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); 1539 MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation"));
1540 MSN_GOT_INFO_GET_FIELD("Location", _("Location")); 1540 MSN_GOT_INFO_GET_FIELD("Location", _("Location"));
1541 1541
1542 /* Extract their Interests and put it in */ 1542 /* Extract their Interests and put it in */
1543 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1543 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info,
1544 "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, 1544 "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0,
1545 "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, 1545 "Undisclosed", _("Hobbies and Interests") /* _("Interests") */,
1546 0, NULL, NULL); 1546 0, NULL, NULL);
1547 1547
1548 if (found) 1548 if (found)
1549 sect_info = TRUE; 1549 sect_info = TRUE;
1550 1550
1551 MSN_GOT_INFO_GET_FIELD("More about me", _("A Little About Me")); 1551 MSN_GOT_INFO_GET_FIELD("More about me", _("A Little About Me"));
1552 1552
1553 if (sect_info) 1553 if (sect_info)
1554 { 1554 {
1555 /* trim off the trailing "<br>\n" */
1556 g_string_truncate(s, strlen(s->str) - 5);
1557 g_string_append_printf(s2, _("%s<b>General</b><br>%s"),
1558 (*tooltip_text) ? "<hr>" : "", s->str);
1559 s = g_string_truncate(s, 0);
1560 has_info = TRUE; 1555 has_info = TRUE;
1561 sect_info = FALSE; 1556 sect_info = FALSE;
1562 } 1557 }
1563 1558 else
1564 1559 {
1560 /* Remove the section header */
1561 gaim_notify_user_info_remove_last_item(user_info);
1562 if (has_tooltip_text)
1563 gaim_notify_user_info_remove_last_item(user_info);
1564 }
1565
1565 /* Social */ 1566 /* Social */
1567 gaim_notify_user_info_add_section_break(user_info);
1568 gaim_notify_user_info_add_section_header(user_info, _("Social"));
1569
1566 MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); 1570 MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status"));
1567 MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests")); 1571 MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests"));
1568 MSN_GOT_INFO_GET_FIELD("Pets", _("Pets")); 1572 MSN_GOT_INFO_GET_FIELD("Pets", _("Pets"));
1569 MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); 1573 MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown"));
1570 MSN_GOT_INFO_GET_FIELD("Places lived", _("Places Lived")); 1574 MSN_GOT_INFO_GET_FIELD("Places lived", _("Places Lived"));
1573 MSN_GOT_INFO_GET_FIELD("Music", _("Music")); 1577 MSN_GOT_INFO_GET_FIELD("Music", _("Music"));
1574 MSN_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote")); 1578 MSN_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote"));
1575 1579
1576 if (sect_info) 1580 if (sect_info)
1577 { 1581 {
1578 g_string_append_printf(s2, _("%s<b>Social</b><br>%s"), has_info ? "<br><hr>" : "", s->str);
1579 s = g_string_truncate(s, 0);
1580 has_info = TRUE; 1582 has_info = TRUE;
1581 sect_info = FALSE; 1583 sect_info = FALSE;
1582 } 1584 }
1585 else
1586 {
1587 /* Remove the section header */
1588 gaim_notify_user_info_remove_last_item(user_info);
1589 gaim_notify_user_info_remove_last_item(user_info);
1590 }
1583 1591
1584 /* Contact Info */ 1592 /* Contact Info */
1585 /* Personal */ 1593 /* Personal */
1594 gaim_notify_user_info_add_section_break(user_info);
1595 gaim_notify_user_info_add_section_header(user_info, _("Contact Info"));
1596 gaim_notify_user_info_add_section_header(user_info, _("Personal"));
1597
1586 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); 1598 MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
1587 MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); 1599 MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other"));
1588 MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); 1600 MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone"));
1589 MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2")); 1601 MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2"));
1590 MSN_GOT_INFO_GET_FIELD("Home address", _("Home Address")); 1602 MSN_GOT_INFO_GET_FIELD("Home address", _("Home Address"));
1596 MSN_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary")); 1608 MSN_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary"));
1597 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); 1609 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes"));
1598 1610
1599 if (sect_info) 1611 if (sect_info)
1600 { 1612 {
1601 personal = g_strdup_printf(_("<br><b>Personal</b><br>%s"), s->str); 1613 has_info = TRUE;
1602 s = g_string_truncate(s, 0);
1603 sect_info = FALSE; 1614 sect_info = FALSE;
1604 has_info = TRUE; 1615 has_contact_info = TRUE;
1616 }
1617 else
1618 {
1619 /* Remove the section header */
1620 gaim_notify_user_info_remove_last_item(user_info);
1605 } 1621 }
1606 1622
1607 /* Business */ 1623 /* Business */
1624 gaim_notify_user_info_add_section_header(user_info, _("Work"));
1608 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); 1625 MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
1609 MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title")); 1626 MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title"));
1610 MSN_GOT_INFO_GET_FIELD("Company", _("Company")); 1627 MSN_GOT_INFO_GET_FIELD("Company", _("Company"));
1611 MSN_GOT_INFO_GET_FIELD("Department", _("Department")); 1628 MSN_GOT_INFO_GET_FIELD("Department", _("Department"));
1612 MSN_GOT_INFO_GET_FIELD("Profession", _("Profession")); 1629 MSN_GOT_INFO_GET_FIELD("Profession", _("Profession"));
1621 MSN_GOT_INFO_GET_FIELD("Start date", _("Start Date")); 1638 MSN_GOT_INFO_GET_FIELD("Start date", _("Start Date"));
1622 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); 1639 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes"));
1623 1640
1624 if (sect_info) 1641 if (sect_info)
1625 { 1642 {
1626 business = g_strdup_printf(_("<br><b>Business</b><br>%s"), s->str); 1643 has_info = TRUE;
1627 s = g_string_truncate(s, 0);
1628 sect_info = FALSE; 1644 sect_info = FALSE;
1629 } 1645 has_contact_info = TRUE;
1630 1646 }
1631 if ((personal != NULL) || (business != NULL)) 1647 else
1632 { 1648 {
1633 /* trim off the trailing "<br>\n" */ 1649 /* Remove the section header */
1634 g_string_truncate(s, strlen(s->str) - 5); 1650 gaim_notify_user_info_remove_last_item(user_info);
1635 1651 }
1636 has_info = TRUE; 1652
1637 g_string_append_printf(s2, _("<hr><b>Contact Info</b>%s%s"), 1653 if (!has_contact_info)
1638 personal ? personal : "", 1654 {
1639 business ? business : ""); 1655 /* Remove the Contact Info section header */
1640 } 1656 gaim_notify_user_info_remove_last_item(user_info);
1641 1657 }
1642 g_free(personal);
1643 g_free(business);
1644 g_string_free(s, TRUE);
1645 s = s2;
1646 1658
1647 #if 0 /* these probably don't show up any more */ 1659 #if 0 /* these probably don't show up any more */
1648 /* 1660 /*
1649 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies 1661 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies
1650 * and Interests', 'Favorite Quote', and 'My Homepage' may or may 1662 * and Interests', 'Favorite Quote', and 'My Homepage' may or may
1766 #endif 1778 #endif
1767 1779
1768 /* If we were able to fetch a homepage url earlier, stick it in there */ 1780 /* If we were able to fetch a homepage url earlier, stick it in there */
1769 if (user_url != NULL) 1781 if (user_url != NULL)
1770 { 1782 {
1771 g_snprintf(buf, sizeof(buf), 1783 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url);
1772 "<b>%s:</b><br><a href=\"%s\">%s</a><br>\n", 1784 gaim_notify_user_info_add_pair(user_info, _("Homepage"), tmp);
1773 _("Homepage"), user_url, user_url); 1785 g_free(tmp);
1774
1775 g_string_append(s, buf);
1776
1777 g_free(user_url); 1786 g_free(user_url);
1778 1787
1779 has_info = TRUE; 1788 has_info = TRUE;
1780 } 1789 }
1781 1790
1790 char *p = strstr(url_buffer, "Unknown Member </TITLE>"); 1799 char *p = strstr(url_buffer, "Unknown Member </TITLE>");
1791 * This might not work for long either ... */ 1800 * This might not work for long either ... */
1792 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); 1801 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\"");
1793 GaimBuddy *b = gaim_find_buddy 1802 GaimBuddy *b = gaim_find_buddy
1794 (gaim_connection_get_account(info_data->gc), info_data->name); 1803 (gaim_connection_get_account(info_data->gc), info_data->name);
1795 g_string_append_printf(s, "<br><b>%s</b><br>%s<br><br>", 1804 gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"),
1796 _("Error retrieving profile"), 1805 ((p && b) ? _("The user has not created a public profile.") :
1797 ((p && b)? 1806 (p ? _("MSN reported not being able to find the user's profile. "
1798 _("The user has not created a public profile."): 1807 "This either means that the user does not exist, "
1799 p? _("MSN reported not being able to find the user's profile. " 1808 "or that the user exists "
1800 "This either means that the user does not exist, " 1809 "but has not created a public profile.") :
1801 "or that the user exists " 1810 _("Gaim could not find " /* This should never happen */
1802 "but has not created a public profile."): 1811 "any information in the user's profile. "
1803 _("Gaim could not find " /* This should never happen */ 1812 "The user most likely does not exist."))));
1804 "any information in the user's profile. " 1813 }
1805 "The user most likely does not exist."))); 1814
1806 }
1807 /* put a link to the actual profile URL */ 1815 /* put a link to the actual profile URL */
1808 g_string_append_printf(s, _("<hr><b>%s:</b> "), _("Profile URL")); 1816 tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>",
1809 g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", 1817 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name);
1810 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); 1818 gaim_notify_user_info_add_pair(user_info, _("Profile URL"), tmp);
1811 1819 g_free(tmp);
1812 /* Finish it off, and show it to them */
1813 g_string_append(s, "</body></html>\n");
1814 1820
1815 #if PHOTO_SUPPORT 1821 #if PHOTO_SUPPORT
1816 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ 1822 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */
1817 photo_url_text = msn_get_photo_url(url_text); 1823 photo_url_text = msn_get_photo_url(url_text);
1818 1824
1819 /* Marshall the existing state */ 1825 /* Marshall the existing state */
1820 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); 1826 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData));
1821 info2_data->info_data = info_data; 1827 info2_data->info_data = info_data;
1822 info2_data->stripped = stripped; 1828 info2_data->stripped = stripped;
1823 info2_data->url_buffer = url_buffer; 1829 info2_data->url_buffer = url_buffer;
1824 info2_data->s = s; 1830 info2_data->user_info = user_info;
1825 info2_data->photo_url_text = photo_url_text; 1831 info2_data->photo_url_text = photo_url_text;
1826 info2_data->tooltip_text = tooltip_text;
1827 info2_data->title = title;
1828 1832
1829 /* Try to put the photo in there too, if there's one */ 1833 /* Try to put the photo in there too, if there's one */
1830 if (photo_url_text) 1834 if (photo_url_text)
1831 { 1835 {
1832 gaim_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, msn_got_photo, 1836 gaim_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, msn_got_photo,
1849 1853
1850 /* Unmarshall the saved state */ 1854 /* Unmarshall the saved state */
1851 MsnGetInfoData *info_data = info2_data->info_data; 1855 MsnGetInfoData *info_data = info2_data->info_data;
1852 char *stripped = info2_data->stripped; 1856 char *stripped = info2_data->stripped;
1853 char *url_buffer = info2_data->url_buffer; 1857 char *url_buffer = info2_data->url_buffer;
1854 GString *s = info2_data->s; 1858 GaimNotifyUserInfo *user_info = info2_data->user_info;
1855 char *photo_url_text = info2_data->photo_url_text; 1859 char *photo_url_text = info2_data->photo_url_text;
1856 char *tooltip_text = info2_data->tooltip_text;
1857 1860
1858 /* Make sure the connection is still valid if we got here by fetching a photo url */ 1861 /* Make sure the connection is still valid if we got here by fetching a photo url */
1859 if (url_text && (error_message != NULL || 1862 if (url_text && (error_message != NULL ||
1860 g_list_find(gaim_connections_get_all(), info_data->gc) == NULL)) 1863 g_list_find(gaim_connections_get_all(), info_data->gc) == NULL))
1861 { 1864 {
1862 gaim_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n"); 1865 gaim_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n");
1863 g_free(stripped); 1866 g_free(stripped);
1864 g_free(url_buffer); 1867 g_free(url_buffer);
1865 g_string_free(s, TRUE); 1868 g_free(user_info);
1866 g_free(tooltip_text);
1867 g_free(info_data->name); 1869 g_free(info_data->name);
1868 g_free(info_data); 1870 g_free(info_data);
1869 g_free(photo_url_text); 1871 g_free(photo_url_text);
1870 g_free(info2_data); 1872 g_free(info2_data);
1871 1873
1887 { 1889 {
1888 char buf[1024]; 1890 char buf[1024];
1889 gaim_debug_info("msn", "%s is %d bytes\n", photo_url_text, len); 1891 gaim_debug_info("msn", "%s is %d bytes\n", photo_url_text, len);
1890 id = gaim_imgstore_add(url_text, len, NULL); 1892 id = gaim_imgstore_add(url_text, len, NULL);
1891 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); 1893 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id);
1892 g_string_prepend(s, buf); 1894 gaim_notify_user_info_prepend_pair(user_info, NULL, buf);
1893 } 1895 }
1894 } 1896 }
1895 1897
1896 /* We continue here from msn_got_info, as if nothing has happened */ 1898 /* We continue here from msn_got_info, as if nothing has happened */
1897 #endif 1899 #endif
1898 1900 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL);
1899 g_string_prepend(s, tooltip_text);
1900 gaim_notify_userinfo(info_data->gc, info_data->name, s->str, NULL, NULL);
1901 1901
1902 g_free(stripped); 1902 g_free(stripped);
1903 g_free(url_buffer); 1903 g_free(url_buffer);
1904 g_string_free(s, TRUE); 1904 gaim_notify_user_info_destroy(user_info);
1905 g_free(tooltip_text);
1906 g_free(info_data->name); 1905 g_free(info_data->name);
1907 g_free(info_data); 1906 g_free(info_data);
1908 #if PHOTO_SUPPORT 1907 #if PHOTO_SUPPORT
1909 g_free(photo_url_text); 1908 g_free(photo_url_text);
1910 g_free(info2_data); 1909 g_free(info2_data);

mercurial