Ticket #4: nateon_get_info.patch
|
File nateon_get_info.patch, 31.6 KB
(added by arcturus, 5 years ago)
|
|
패치, nateon.c / nateon.h
|
-
|
|
|
|
| 21 | 21 | * along with this program; if not, write to the Free Software |
| 22 | 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | 23 | */ |
| 24 | | //#define PHOTO_SUPPORT 1 |
| | 24 | #define PHOTO_SUPPORT 1 |
| 25 | 25 | |
| 26 | 26 | #include <glib.h> |
| 27 | 27 | |
| … |
… |
|
| 44 | 44 | #include "sync.h" |
| 45 | 45 | //#include "slplink.h" |
| 46 | 46 | |
| 47 | | //#if PHOTO_SUPPORT |
| 48 | | //#include "imgstore.h" |
| 49 | | //#endif |
| 50 | | // |
| | 47 | #if PHOTO_SUPPORT |
| | 48 | #include "imgstore.h" |
| | 49 | #endif |
| | 50 | |
| 51 | 51 | //typedef struct |
| 52 | 52 | //{ |
| 53 | 53 | // PurpleConnection *gc; |
| 54 | 54 | // const char *passport; |
| 55 | 55 | // |
| 56 | 56 | //} NateonMobileData; |
| 57 | | // |
| 58 | | //typedef struct |
| 59 | | //{ |
| 60 | | // PurpleConnection *gc; |
| 61 | | // char *name; |
| 62 | | // |
| 63 | | //} NateonGetInfoData; |
| 64 | | // |
| 65 | | //typedef struct |
| 66 | | //{ |
| 67 | | // NateonGetInfoData *info_data; |
| 68 | | // char *stripped; |
| 69 | | // char *url_buffer; |
| 70 | | // GString *s; |
| 71 | | // char *photo_url_text; |
| 72 | | // char *tooltip_text; |
| 73 | | // const char *title; |
| 74 | | // |
| 75 | | //} NateonGetInfoStepTwoData; |
| 76 | 57 | |
| | 58 | typedef struct |
| | 59 | { |
| | 60 | PurpleConnection *gc; |
| | 61 | char *name; |
| | 62 | char *id; |
| | 63 | |
| | 64 | } NateonGetInfoData; |
| | 65 | |
| | 66 | typedef struct |
| | 67 | { |
| | 68 | NateonGetInfoData *info_data; |
| | 69 | char *stripped; |
| | 70 | char *url_buffer; |
| | 71 | PurpleNotifyUserInfo *user_info; |
| | 72 | char *photo_url_text; |
| | 73 | char *photo_frame_url_text; |
| | 74 | |
| | 75 | } NateonGetInfoStepTwoData; |
| | 76 | |
| 77 | 77 | static const char *nateon_normalize(const PurpleAccount *account, const char *str) |
| 78 | 78 | { |
| 79 | 79 | static char buf[BUF_LEN]; |
| … |
… |
|
| 1334 | 1338 | // nateon_cmdproc_send(cmdproc, "RMG", "%d", group_id); |
| 1335 | 1339 | // } |
| 1336 | 1340 | //} |
| 1337 | | // |
| 1338 | | //static char * |
| 1339 | | //nateon_tooltip_info_text(NateonGetInfoData *info_data) |
| 1340 | | //{ |
| 1341 | | // GString *s; |
| 1342 | | // PurpleBuddy *b; |
| 1343 | | // |
| 1344 | | // s = g_string_sized_new(80); /* wild guess */ |
| 1345 | | // |
| 1346 | | // b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
| 1347 | | // info_data->name); |
| 1348 | | // |
| 1349 | | // if (b) |
| 1350 | | // { |
| 1351 | | // PurplePresence *presence; |
| 1352 | | // GString *str = g_string_new(""); |
| 1353 | | // char *tmp; |
| 1354 | | // |
| 1355 | | // presence = purple_buddy_get_presence(b); |
| 1356 | | // |
| 1357 | | // if (b->alias && b->alias[0]) |
| 1358 | | // { |
| 1359 | | // char *aliastext = g_markup_escape_text(b->alias, -1); |
| 1360 | | // g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); |
| 1361 | | // g_free(aliastext); |
| 1362 | | // } |
| 1363 | | // |
| 1364 | | // if (b->server_alias) |
| 1365 | | // { |
| 1366 | | // char *nicktext = g_markup_escape_text(b->server_alias, -1); |
| 1367 | | // g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname")); |
| 1368 | | // g_string_append_printf(s, "<font sml=\"nateon\">%s</font><br>", |
| 1369 | | // nicktext); |
| 1370 | | // g_free(nicktext); |
| 1371 | | // } |
| 1372 | | // |
| 1373 | | // nateon_tooltip_text(b, str, TRUE); |
| 1374 | | // tmp = purple_strreplace((*str->str == '\n' ? str->str + 1 : str->str), |
| 1375 | | // "\n", "<br>"); |
| 1376 | | // g_string_free(str, TRUE); |
| 1377 | | // g_string_append_printf(s, "%s<br>", tmp); |
| 1378 | | // g_free(tmp); |
| 1379 | | // } |
| 1380 | | // |
| 1381 | | // return g_string_free(s, FALSE); |
| 1382 | | //} |
| 1383 | | // |
| 1384 | | //#if PHOTO_SUPPORT |
| 1385 | | // |
| 1386 | | //static char * |
| 1387 | | //nateon_get_photo_url(const char *url_text) |
| 1388 | | //{ |
| 1389 | | // char *p, *q; |
| 1390 | | // |
| 1391 | | // if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) |
| 1392 | | // { |
| 1393 | | // p += strlen(" contactparams:photopreauthurl=\""); |
| 1394 | | // } |
| 1395 | | // |
| 1396 | | // if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL)) |
| 1397 | | // return g_strndup(p, q - p); |
| 1398 | | // |
| 1399 | | // return NULL; |
| 1400 | | //} |
| 1401 | | // |
| 1402 | | //static void nateon_got_photo(void *data, const char *url_text, size_t len); |
| 1403 | | // |
| 1404 | | //#endif |
| 1405 | | // |
| 1406 | | //#if 0 |
| 1407 | | //static char *nateon_info_date_reformat(const char *field, size_t len) |
| 1408 | | //{ |
| 1409 | | // char *tmp = g_strndup(field, len); |
| 1410 | | // time_t t = purple_str_to_time(tmp, FALSE, NULL, NULL, NULL); |
| 1411 | | // |
| 1412 | | // g_free(tmp); |
| 1413 | | // return g_strdup(purple_date_format_short(localtime(&t))); |
| 1414 | | //} |
| 1415 | | //#endif |
| 1416 | | // |
| 1417 | | //#define NATEON_GOT_INFO_GET_FIELD(a, b) \ |
| 1418 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, \ |
| 1419 | | // "\n" a "\t", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ |
| 1420 | | // if (found) \ |
| 1421 | | // sect_info = TRUE; |
| 1422 | | // |
| 1423 | | //static void |
| 1424 | | //nateon_got_info(void *data, const char *url_text, size_t len) |
| 1425 | | //{ |
| 1426 | | // NateonGetInfoData *info_data = (NateonGetInfoData *)data; |
| 1427 | | // char *stripped, *p, *q; |
| 1428 | | // char buf[1024]; |
| 1429 | | // char *tooltip_text; |
| 1430 | | // char *user_url = NULL; |
| 1431 | | // gboolean found; |
| 1432 | | // gboolean has_info = FALSE; |
| 1433 | | // gboolean sect_info = FALSE; |
| 1434 | | // const char* title = NULL; |
| 1435 | | // char *url_buffer; |
| 1436 | | // char *personal = NULL; |
| 1437 | | // char *business = NULL; |
| 1438 | | // GString *s, *s2; |
| 1439 | | // int stripped_len; |
| 1440 | | //#if PHOTO_SUPPORT |
| 1441 | | // char *photo_url_text = NULL; |
| 1442 | | // NateonGetInfoStepTwoData *info2_data = NULL; |
| 1443 | | //#endif |
| 1444 | | // |
| 1445 | | // purple_debug_info("nateon", "In nateon_got_info\n"); |
| 1446 | | // |
| 1447 | | // /* Make sure the connection is still valid */ |
| 1448 | | // if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
| 1449 | | // { |
| 1450 | | // purple_debug_warning("nateon", "invalid connection. ignoring buddy info.\n"); |
| 1451 | | // g_free(info_data->name); |
| 1452 | | // g_free(info_data); |
| 1453 | | // return; |
| 1454 | | // } |
| 1455 | | // |
| 1456 | | // tooltip_text = nateon_tooltip_info_text(info_data); |
| 1457 | | // title = _("NATEON Profile"); |
| 1458 | | // |
| 1459 | | // if (url_text == NULL || strcmp(url_text, "") == 0) |
| 1460 | | // { |
| 1461 | | // g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", |
| 1462 | | // tooltip_text, _("Error retrieving profile")); |
| 1463 | | // |
| 1464 | | // purple_notify_userinfo(info_data->gc, info_data->name, buf, NULL, NULL); |
| 1465 | | // |
| 1466 | | // g_free(tooltip_text); |
| 1467 | | // return; |
| 1468 | | // } |
| 1469 | | // |
| 1470 | | // url_buffer = g_strdup(url_text); |
| 1471 | | // |
| 1472 | | // /* If they have a homepage link, NATEON masks it such that we need to |
| 1473 | | // * fetch the url out before purple_markup_strip_html() nukes it */ |
| 1474 | | // /* I don't think this works with the new spaces profiles - Stu 3/2/06 */ |
| 1475 | | // if ((p = strstr(url_text, |
| 1476 | | // "Take a look at my </font><A class=viewDesc title=\"")) != NULL) |
| 1477 | | // { |
| 1478 | | // p += 50; |
| 1479 | | // |
| 1480 | | // if ((q = strchr(p, '"')) != NULL) |
| 1481 | | // user_url = g_strndup(p, q - p); |
| 1482 | | // } |
| 1483 | | // |
| 1484 | | // /* |
| 1485 | | // * purple_markup_strip_html() doesn't strip out character entities like |
| 1486 | | // * and · |
| 1487 | | // */ |
| 1488 | | // while ((p = strstr(url_buffer, " ")) != NULL) |
| 1489 | | // { |
| 1490 | | // *p = ' '; /* Turn 's into ordinary blanks */ |
| 1491 | | // p += 1; |
| 1492 | | // memmove(p, p + 5, strlen(p + 5)); |
| 1493 | | // url_buffer[strlen(url_buffer) - 5] = '\0'; |
| 1494 | | // } |
| 1495 | | // |
| 1496 | | // while ((p = strstr(url_buffer, "·")) != NULL) |
| 1497 | | // { |
| 1498 | | // memmove(p, p + 6, strlen(p + 6)); |
| 1499 | | // url_buffer[strlen(url_buffer) - 6] = '\0'; |
| 1500 | | // } |
| 1501 | | // |
| 1502 | | // /* Nuke the nasty \r's that just get in the way */ |
| 1503 | | // purple_str_strip_char(url_buffer, '\r'); |
| 1504 | | // |
| 1505 | | // /* NATEON always puts in ' for apostrophes...replace them */ |
| 1506 | | // while ((p = strstr(url_buffer, "'")) != NULL) |
| 1507 | | // { |
| 1508 | | // *p = '\''; |
| 1509 | | // memmove(p + 1, p + 5, strlen(p + 5)); |
| 1510 | | // url_buffer[strlen(url_buffer) - 4] = '\0'; |
| 1511 | | // } |
| 1512 | | // |
| 1513 | | // /* Nuke the html, it's easier than trying to parse the horrid stuff */ |
| 1514 | | // stripped = purple_markup_strip_html(url_buffer); |
| 1515 | | // stripped_len = strlen(stripped); |
| 1516 | | // |
| 1517 | | // purple_debug_misc("nateon", "stripped = %p\n", stripped); |
| 1518 | | // purple_debug_misc("nateon", "url_buffer = %p\n", url_buffer); |
| 1519 | | // |
| 1520 | | // /* Gonna re-use the memory we've already got for url_buffer */ |
| 1521 | | // /* No we're not. */ |
| 1522 | | // s = g_string_sized_new(strlen(url_buffer)); |
| 1523 | | // s2 = g_string_sized_new(strlen(url_buffer)); |
| 1524 | | // |
| 1525 | | // /* Extract their Name and put it in */ |
| 1526 | | // NATEON_GOT_INFO_GET_FIELD("Name", _("Name")) |
| 1527 | | // |
| 1528 | | // /* General */ |
| 1529 | | // NATEON_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); |
| 1530 | | // NATEON_GOT_INFO_GET_FIELD("Age", _("Age")); |
| 1531 | | // NATEON_GOT_INFO_GET_FIELD("Gender", _("Gender")); |
| 1532 | | // NATEON_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); |
| 1533 | | // NATEON_GOT_INFO_GET_FIELD("Location", _("Location")); |
| 1534 | | // |
| 1535 | | // /* Extract their Interests and put it in */ |
| 1536 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1537 | | // "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, |
| 1538 | | // "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, |
| 1539 | | // 0, NULL, NULL); |
| 1540 | | // |
| 1541 | | // if (found) |
| 1542 | | // sect_info = TRUE; |
| 1543 | | // |
| 1544 | | // NATEON_GOT_INFO_GET_FIELD("More about me", _("A Little About Me")); |
| 1545 | | // |
| 1546 | | // if (sect_info) |
| 1547 | | // { |
| 1548 | | // /* trim off the trailing "<br>\n" */ |
| 1549 | | // g_string_truncate(s, strlen(s->str) - 5); |
| 1550 | | // g_string_append_printf(s2, _("%s<b>General</b><br>%s"), |
| 1551 | | // (*tooltip_text) ? "<hr>" : "", s->str); |
| 1552 | | // s = g_string_truncate(s, 0); |
| 1553 | | // has_info = TRUE; |
| 1554 | | // sect_info = FALSE; |
| 1555 | | // } |
| 1556 | | // |
| 1557 | | // |
| 1558 | | // /* Social */ |
| 1559 | | // NATEON_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); |
| 1560 | | // NATEON_GOT_INFO_GET_FIELD("Interested in", _("Interests")); |
| 1561 | | // NATEON_GOT_INFO_GET_FIELD("Pets", _("Pets")); |
| 1562 | | // NATEON_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); |
| 1563 | | // NATEON_GOT_INFO_GET_FIELD("Places lived", _("Places Lived")); |
| 1564 | | // NATEON_GOT_INFO_GET_FIELD("Fashion", _("Fashion")); |
| 1565 | | // NATEON_GOT_INFO_GET_FIELD("Humor", _("Humor")); |
| 1566 | | // NATEON_GOT_INFO_GET_FIELD("Music", _("Music")); |
| 1567 | | // NATEON_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote")); |
| 1568 | | // |
| 1569 | | // if (sect_info) |
| 1570 | | // { |
| 1571 | | // g_string_append_printf(s2, _("%s<b>Social</b><br>%s"), has_info ? "<br><hr>" : "", s->str); |
| 1572 | | // s = g_string_truncate(s, 0); |
| 1573 | | // has_info = TRUE; |
| 1574 | | // sect_info = FALSE; |
| 1575 | | // } |
| 1576 | | // |
| 1577 | | // /* Contact Info */ |
| 1578 | | // /* Personal */ |
| 1579 | | // NATEON_GOT_INFO_GET_FIELD("Name", _("Name")); |
| 1580 | | // NATEON_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); |
| 1581 | | // NATEON_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); |
| 1582 | | // NATEON_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2")); |
| 1583 | | // NATEON_GOT_INFO_GET_FIELD("Home address", _("Home Address")); |
| 1584 | | // NATEON_GOT_INFO_GET_FIELD("Personal Mobile", _("Personal Mobile")); |
| 1585 | | // NATEON_GOT_INFO_GET_FIELD("Home fax", _("Home Fax")); |
| 1586 | | // NATEON_GOT_INFO_GET_FIELD("Personal e-mail", _("Personal E-Mail")); |
| 1587 | | // NATEON_GOT_INFO_GET_FIELD("Personal IM", _("Personal IM")); |
| 1588 | | // NATEON_GOT_INFO_GET_FIELD("Birthday", _("Birthday")); |
| 1589 | | // NATEON_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary")); |
| 1590 | | // NATEON_GOT_INFO_GET_FIELD("Notes", _("Notes")); |
| 1591 | | // |
| 1592 | | // if (sect_info) |
| 1593 | | // { |
| 1594 | | // personal = g_strdup_printf(_("<br><b>Personal</b><br>%s"), s->str); |
| 1595 | | // s = g_string_truncate(s, 0); |
| 1596 | | // sect_info = FALSE; |
| 1597 | | // } |
| 1598 | | // |
| 1599 | | // /* Business */ |
| 1600 | | // NATEON_GOT_INFO_GET_FIELD("Name", _("Name")); |
| 1601 | | // NATEON_GOT_INFO_GET_FIELD("Job title", _("Job Title")); |
| 1602 | | // NATEON_GOT_INFO_GET_FIELD("Company", _("Company")); |
| 1603 | | // NATEON_GOT_INFO_GET_FIELD("Department", _("Department")); |
| 1604 | | // NATEON_GOT_INFO_GET_FIELD("Profession", _("Profession")); |
| 1605 | | // NATEON_GOT_INFO_GET_FIELD("Work phone 1", _("Work Phone")); |
| 1606 | | // NATEON_GOT_INFO_GET_FIELD("Work phone 2", _("Work Phone 2")); |
| 1607 | | // NATEON_GOT_INFO_GET_FIELD("Work address", _("Work Address")); |
| 1608 | | // NATEON_GOT_INFO_GET_FIELD("Work mobile", _("Work Mobile")); |
| 1609 | | // NATEON_GOT_INFO_GET_FIELD("Work pager", _("Work Pager")); |
| 1610 | | // NATEON_GOT_INFO_GET_FIELD("Work fax", _("Work Fax")); |
| 1611 | | // NATEON_GOT_INFO_GET_FIELD("Work e-mail", _("Work E-Mail")); |
| 1612 | | // NATEON_GOT_INFO_GET_FIELD("Work IM", _("Work IM")); |
| 1613 | | // NATEON_GOT_INFO_GET_FIELD("Start date", _("Start Date")); |
| 1614 | | // NATEON_GOT_INFO_GET_FIELD("Notes", _("Notes")); |
| 1615 | | // |
| 1616 | | // if (sect_info) |
| 1617 | | // { |
| 1618 | | // business = g_strdup_printf(_("<br><b>Business</b><br>%s"), s->str); |
| 1619 | | // s = g_string_truncate(s, 0); |
| 1620 | | // sect_info = FALSE; |
| 1621 | | // } |
| 1622 | | // |
| 1623 | | // if ((personal != NULL) || (business != NULL)) |
| 1624 | | // { |
| 1625 | | // /* trim off the trailing "<br>\n" */ |
| 1626 | | // g_string_truncate(s, strlen(s->str) - 5); |
| 1627 | | // |
| 1628 | | // has_info = TRUE; |
| 1629 | | // g_string_append_printf(s2, _("<hr><b>Contact Info</b>%s%s"), |
| 1630 | | // personal ? personal : "", |
| 1631 | | // business ? business : ""); |
| 1632 | | // } |
| 1633 | | // |
| 1634 | | // g_free(personal); |
| 1635 | | // g_free(business); |
| 1636 | | // g_string_free(s, TRUE); |
| 1637 | | // s = s2; |
| 1638 | | // |
| 1639 | | //#if 0 /* these probably don't show up any more */ |
| 1640 | | // /* |
| 1641 | | // * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies |
| 1642 | | // * and Interests', 'Favorite Quote', and 'My Homepage' may or may |
| 1643 | | // * not appear, in any combination. However, they do appear in |
| 1644 | | // * certain order, so we can successively search to pin down the |
| 1645 | | // * distinct values. |
| 1646 | | // */ |
| 1647 | | // |
| 1648 | | // /* Check if they have A Little About Me */ |
| 1649 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1650 | | // " A Little About Me \n\n", 0, "Favorite Things", '\n', NULL, |
| 1651 | | // _("A Little About Me"), 0, NULL, NULL); |
| 1652 | | // |
| 1653 | | // if (!found) |
| 1654 | | // { |
| 1655 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1656 | | // " A Little About Me \n\n", 0, "Hobbies and Interests", '\n', |
| 1657 | | // NULL, _("A Little About Me"), 0, NULL, NULL); |
| 1658 | | // } |
| 1659 | | // |
| 1660 | | // if (!found) |
| 1661 | | // { |
| 1662 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1663 | | // " A Little About Me \n\n", 0, "Favorite Quote", '\n', NULL, |
| 1664 | | // _("A Little About Me"), 0, NULL, NULL); |
| 1665 | | // } |
| 1666 | | // |
| 1667 | | // if (!found) |
| 1668 | | // { |
| 1669 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1670 | | // " A Little About Me \n\n", 0, "My Homepage \n\nTake a look", |
| 1671 | | // '\n', |
| 1672 | | // NULL, _("A Little About Me"), 0, NULL, NULL); |
| 1673 | | // } |
| 1674 | | // |
| 1675 | | // if (!found) |
| 1676 | | // { |
| 1677 | | // purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1678 | | // " A Little About Me \n\n", 0, "last updated", '\n', NULL, |
| 1679 | | // _("A Little About Me"), 0, NULL, NULL); |
| 1680 | | // } |
| 1681 | | // |
| 1682 | | // if (found) |
| 1683 | | // has_info = TRUE; |
| 1684 | | // |
| 1685 | | // /* Check if they have Favorite Things */ |
| 1686 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1687 | | // " Favorite Things \n\n", 0, "Hobbies and Interests", '\n', NULL, |
| 1688 | | // _("Favorite Things"), 0, NULL, NULL); |
| 1689 | | // |
| 1690 | | // if (!found) |
| 1691 | | // { |
| 1692 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1693 | | // " Favorite Things \n\n", 0, "Favorite Quote", '\n', NULL, |
| 1694 | | // _("Favorite Things"), 0, NULL, NULL); |
| 1695 | | // } |
| 1696 | | // |
| 1697 | | // if (!found) |
| 1698 | | // { |
| 1699 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1700 | | // " Favorite Things \n\n", 0, "My Homepage \n\nTake a look", '\n', |
| 1701 | | // NULL, _("Favorite Things"), 0, NULL, NULL); |
| 1702 | | // } |
| 1703 | | // |
| 1704 | | // if (!found) |
| 1705 | | // { |
| 1706 | | // purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1707 | | // " Favorite Things \n\n", 0, "last updated", '\n', NULL, |
| 1708 | | // _("Favorite Things"), 0, NULL, NULL); |
| 1709 | | // } |
| 1710 | | // |
| 1711 | | // if (found) |
| 1712 | | // has_info = TRUE; |
| 1713 | | // |
| 1714 | | // /* Check if they have Hobbies and Interests */ |
| 1715 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1716 | | // " Hobbies and Interests \n\n", 0, "Favorite Quote", '\n', NULL, |
| 1717 | | // _("Hobbies and Interests"), 0, NULL, NULL); |
| 1718 | | // |
| 1719 | | // if (!found) |
| 1720 | | // { |
| 1721 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1722 | | // " Hobbies and Interests \n\n", 0, "My Homepage \n\nTake a look", |
| 1723 | | // '\n', NULL, _("Hobbies and Interests"), 0, NULL, NULL); |
| 1724 | | // } |
| 1725 | | // |
| 1726 | | // if (!found) |
| 1727 | | // { |
| 1728 | | // purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1729 | | // " Hobbies and Interests \n\n", 0, "last updated", '\n', NULL, |
| 1730 | | // _("Hobbies and Interests"), 0, NULL, NULL); |
| 1731 | | // } |
| 1732 | | // |
| 1733 | | // if (found) |
| 1734 | | // has_info = TRUE; |
| 1735 | | // |
| 1736 | | // /* Check if they have Favorite Quote */ |
| 1737 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1738 | | // "Favorite Quote \n\n", 0, "My Homepage \n\nTake a look", '\n', NULL, |
| 1739 | | // _("Favorite Quote"), 0, NULL, NULL); |
| 1740 | | // |
| 1741 | | // if (!found) |
| 1742 | | // { |
| 1743 | | // purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1744 | | // "Favorite Quote \n\n", 0, "last updated", '\n', NULL, |
| 1745 | | // _("Favorite Quote"), 0, NULL, NULL); |
| 1746 | | // } |
| 1747 | | // |
| 1748 | | // if (found) |
| 1749 | | // has_info = TRUE; |
| 1750 | | // |
| 1751 | | // /* Extract the last updated date and put it in */ |
| 1752 | | // found = purple_markup_extract_info_field(stripped, stripped_len, s, |
| 1753 | | // " last updated:", 1, "\n", 0, NULL, _("Last Updated"), 0, |
| 1754 | | // NULL, nateon_info_date_reformat); |
| 1755 | | // |
| 1756 | | // if (found) |
| 1757 | | // has_info = TRUE; |
| 1758 | | //#endif |
| 1759 | | // |
| 1760 | | // /* If we were able to fetch a homepage url earlier, stick it in there */ |
| 1761 | | // if (user_url != NULL) |
| 1762 | | // { |
| 1763 | | // g_snprintf(buf, sizeof(buf), |
| 1764 | | // "<b>%s:</b><br><a href=\"%s\">%s</a><br>\n", |
| 1765 | | // _("Homepage"), user_url, user_url); |
| 1766 | | // |
| 1767 | | // g_string_append(s, buf); |
| 1768 | | // |
| 1769 | | // g_free(user_url); |
| 1770 | | // |
| 1771 | | // has_info = TRUE; |
| 1772 | | // } |
| 1773 | | // |
| 1774 | | // if (!has_info) |
| 1775 | | // { |
| 1776 | | // /* NATEON doesn't actually distinguish between "unknown member" and |
| 1777 | | // * a known member with an empty profile. Try to explain this fact. |
| 1778 | | // * Note that if we have a nonempty tooltip_text, we know the user |
| 1779 | | // * exists. |
| 1780 | | // */ |
| 1781 | | // /* This doesn't work with the new spaces profiles - Stu 3/2/06 |
| 1782 | | // char *p = strstr(url_buffer, "Unknown Member </TITLE>"); |
| 1783 | | // * This might not work for long either ... */ |
| 1784 | | // char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); |
| 1785 | | // PurpleBuddy *b = purple_find_buddy |
| 1786 | | // (purple_connection_get_account(info_data->gc), info_data->name); |
| 1787 | | // g_string_append_printf(s, "<br><b>%s</b><br>%s<br><br>", |
| 1788 | | // _("Error retrieving profile"), |
| 1789 | | // ((p && b)? |
| 1790 | | // _("The user has not created a public profile."): |
| 1791 | | // p? _("NATEON reported not being able to find the user's profile. " |
| 1792 | | // "This either means that the user does not exist, " |
| 1793 | | // "or that the user exists " |
| 1794 | | // "but has not created a public profile."): |
| 1795 | | // _("Purple could not find " /* This should never happen */ |
| 1796 | | // "any information in the user's profile. " |
| 1797 | | // "The user most likely does not exist."))); |
| 1798 | | // } |
| 1799 | | // /* put a link to the actual profile URL */ |
| 1800 | | // g_string_append_printf(s, _("<hr><b>%s:</b> "), _("Profile URL")); |
| 1801 | | // g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", |
| 1802 | | // PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); |
| 1803 | | // |
| 1804 | | // /* Finish it off, and show it to them */ |
| 1805 | | // g_string_append(s, "</body></html>\n"); |
| 1806 | | // |
| 1807 | | //#if PHOTO_SUPPORT |
| 1808 | | // /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ |
| 1809 | | // photo_url_text = nateon_get_photo_url(url_text); |
| 1810 | | // |
| 1811 | | // /* Marshall the existing state */ |
| 1812 | | // info2_data = g_malloc0(sizeof(NateonGetInfoStepTwoData)); |
| 1813 | | // info2_data->info_data = info_data; |
| 1814 | | // info2_data->stripped = stripped; |
| 1815 | | // info2_data->url_buffer = url_buffer; |
| 1816 | | // info2_data->s = s; |
| 1817 | | // info2_data->photo_url_text = photo_url_text; |
| 1818 | | // info2_data->tooltip_text = tooltip_text; |
| 1819 | | // info2_data->title = title; |
| 1820 | | // |
| 1821 | | // /* Try to put the photo in there too, if there's one */ |
| 1822 | | // if (photo_url_text) |
| 1823 | | // { |
| 1824 | | // purple_url_fetch(photo_url_text, FALSE, NULL, FALSE, nateon_got_photo, |
| 1825 | | // info2_data); |
| 1826 | | // } |
| 1827 | | // else |
| 1828 | | // { |
| 1829 | | // /* Emulate a callback */ |
| 1830 | | // nateon_got_photo(info2_data, NULL, 0); |
| 1831 | | // } |
| 1832 | | //} |
| 1833 | | // |
| 1834 | | //static void |
| 1835 | | //nateon_got_photo(void *data, const char *url_text, size_t len) |
| 1836 | | //{ |
| 1837 | | // NateonGetInfoStepTwoData *info2_data = (NateonGetInfoStepTwoData *)data; |
| 1838 | | // int id = -1; |
| 1839 | | // |
| 1840 | | // /* Unmarshall the saved state */ |
| 1841 | | // NateonGetInfoData *info_data = info2_data->info_data; |
| 1842 | | // char *stripped = info2_data->stripped; |
| 1843 | | // char *url_buffer = info2_data->url_buffer; |
| 1844 | | // GString *s = info2_data->s; |
| 1845 | | // char *photo_url_text = info2_data->photo_url_text; |
| 1846 | | // char *tooltip_text = info2_data->tooltip_text; |
| 1847 | | // |
| 1848 | | // /* Make sure the connection is still valid if we got here by fetching a photo url */ |
| 1849 | | // if (url_text && |
| 1850 | | // g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
| 1851 | | // { |
| 1852 | | // purple_debug_warning("nateon", "invalid connection. ignoring buddy photo info.\n"); |
| 1853 | | // g_free(stripped); |
| 1854 | | // g_free(url_buffer); |
| 1855 | | // g_string_free(s, TRUE); |
| 1856 | | // g_free(tooltip_text); |
| 1857 | | // g_free(info_data->name); |
| 1858 | | // g_free(info_data); |
| 1859 | | // g_free(photo_url_text); |
| 1860 | | // g_free(info2_data); |
| 1861 | | // |
| 1862 | | // return; |
| 1863 | | // } |
| 1864 | | // |
| 1865 | | // /* Try to put the photo in there too, if there's one and is readable */ |
| 1866 | | // if (data && url_text && len != 0) |
| 1867 | | // { |
| 1868 | | // if (strstr(url_text, "400 Bad Request") |
| 1869 | | // || strstr(url_text, "403 Forbidden") |
| 1870 | | // || strstr(url_text, "404 Not Found")) |
| 1871 | | // { |
| 1872 | | // |
| 1873 | | // purple_debug_info("nateon", "Error getting %s: %s\n", |
| 1874 | | // photo_url_text, url_text); |
| 1875 | | // } |
| 1876 | | // else |
| 1877 | | // { |
| 1878 | | // char buf[1024]; |
| 1879 | | // purple_debug_info("nateon", "%s is %d bytes\n", photo_url_text, len); |
| 1880 | | // id = purple_imgstore_add(url_text, len, NULL); |
| 1881 | | // g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); |
| 1882 | | // g_string_prepend(s, buf); |
| 1883 | | // } |
| 1884 | | // } |
| 1885 | | // |
| 1886 | | // /* We continue here from nateon_got_info, as if nothing has happened */ |
| 1887 | | //#endif |
| 1888 | | // |
| 1889 | | // g_string_prepend(s, tooltip_text); |
| 1890 | | // purple_notify_userinfo(info_data->gc, info_data->name, s->str, NULL, NULL); |
| 1891 | | // |
| 1892 | | // g_free(stripped); |
| 1893 | | // g_free(url_buffer); |
| 1894 | | // g_string_free(s, TRUE); |
| 1895 | | // g_free(tooltip_text); |
| 1896 | | // g_free(info_data->name); |
| 1897 | | // g_free(info_data); |
| 1898 | | //#if PHOTO_SUPPORT |
| 1899 | | // g_free(photo_url_text); |
| 1900 | | // g_free(info2_data); |
| 1901 | | // if (id != -1) |
| 1902 | | // purple_imgstore_unref(id); |
| 1903 | | //#endif |
| 1904 | | //} |
| 1905 | | // |
| 1906 | | //static void |
| 1907 | | //nateon_get_info(PurpleConnection *gc, const char *name) |
| 1908 | | //{ |
| 1909 | | // NateonGetInfoData *data; |
| 1910 | | // char *url; |
| 1911 | | // |
| 1912 | | // data = g_new0(NateonGetInfoData, 1); |
| 1913 | | // data->gc = gc; |
| 1914 | | // data->name = g_strdup(name); |
| 1915 | | // |
| 1916 | | // url = g_strdup_printf("%s%s", PROFILE_URL, name); |
| 1917 | | // |
| 1918 | | // purple_url_fetch(url, FALSE, |
| 1919 | | // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
| 1920 | | // TRUE, nateon_got_info, data); |
| 1921 | | // |
| 1922 | | // g_free(url); |
| 1923 | | //} |
| 1924 | 1341 | |
| | 1342 | /** |
| | 1343 | * Extract info text from info_data and add it to user_info |
| | 1344 | */ |
| | 1345 | static gboolean |
| | 1346 | nateon_tooltip_extract_info_text(PurpleNotifyUserInfo *user_info, NateonGetInfoData *info_data) |
| | 1347 | { |
| | 1348 | PurpleBuddy *b; |
| | 1349 | |
| | 1350 | b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
| | 1351 | info_data->name); |
| | 1352 | |
| | 1353 | if (b) |
| | 1354 | { |
| | 1355 | char *tmp; |
| | 1356 | |
| | 1357 | if (b->alias && b->alias[0]) |
| | 1358 | { |
| | 1359 | char *aliastext = g_markup_escape_text(b->alias, -1); |
| | 1360 | purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
| | 1361 | g_free(aliastext); |
| | 1362 | } |
| | 1363 | |
| | 1364 | if (b->server_alias) |
| | 1365 | { |
| | 1366 | char *nicktext = g_markup_escape_text(b->server_alias, -1); |
| | 1367 | tmp = g_strdup_printf("<font sml=\"nateon\">%s</font><br>", nicktext); |
| | 1368 | purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
| | 1369 | g_free(tmp); |
| | 1370 | g_free(nicktext); |
| | 1371 | } |
| | 1372 | |
| | 1373 | /* Add the tooltip information */ |
| | 1374 | nateon_tooltip_text(b, user_info, TRUE); |
| | 1375 | |
| | 1376 | return TRUE; |
| | 1377 | } |
| | 1378 | |
| | 1379 | return FALSE; |
| | 1380 | } |
| | 1381 | |
| | 1382 | #if PHOTO_SUPPORT |
| | 1383 | |
| | 1384 | static void nateon_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data, |
| | 1385 | const gchar *url_text, size_t len, const gchar *error_message); |
| | 1386 | static void nateon_got_photo_frame(PurpleUtilFetchUrlData *url_data, gpointer data, |
| | 1387 | const gchar *url_text, size_t len, const gchar *error_message); |
| | 1388 | |
| | 1389 | #endif |
| | 1390 | |
| | 1391 | #define NATEON_GOT_INFO_GET_FIELD(a, b) \ |
| | 1392 | purple_markup_extract_info_field(stripped, stripped_len, user_info, \ |
| | 1393 | " " a "\t", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ |
| | 1394 | |
| | 1395 | static void |
| | 1396 | nateon_got_info(PurpleUtilFetchUrlData *url_data, gpointer data, |
| | 1397 | const gchar *url_text, size_t len, const gchar *error_message) |
| | 1398 | { |
| | 1399 | NateonGetInfoData *info_data = (NateonGetInfoData *)data; |
| | 1400 | PurpleNotifyUserInfo *user_info; |
| | 1401 | char *stripped, *p, *tmp; |
| | 1402 | gboolean has_tooltip_text = FALSE; |
| | 1403 | gboolean has_info = FALSE; |
| | 1404 | char *url_buffer; |
| | 1405 | int stripped_len; |
| | 1406 | #if PHOTO_SUPPORT |
| | 1407 | char *photo_url_text = NULL; |
| | 1408 | char *photo_frame_url_text = NULL; |
| | 1409 | NateonGetInfoStepTwoData *info2_data = NULL; |
| | 1410 | #endif |
| | 1411 | |
| | 1412 | purple_debug_info("nateon", "In nateon_got_info\n"); |
| | 1413 | |
| | 1414 | /* Make sure the connection is still valid */ |
| | 1415 | if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
| | 1416 | { |
| | 1417 | purple_debug_warning("nateon", "invalid connection. ignoring buddy info.\n"); |
| | 1418 | g_free(info_data->name); |
| | 1419 | g_free(info_data); |
| | 1420 | return; |
| | 1421 | } |
| | 1422 | |
| | 1423 | user_info = purple_notify_user_info_new(); |
| | 1424 | has_tooltip_text = nateon_tooltip_extract_info_text(user_info, info_data); |
| | 1425 | |
| | 1426 | if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) |
| | 1427 | { |
| | 1428 | tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); |
| | 1429 | purple_notify_user_info_add_pair(user_info, NULL, tmp); |
| | 1430 | g_free(tmp); |
| | 1431 | |
| | 1432 | purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
| | 1433 | purple_notify_user_info_destroy(user_info); |
| | 1434 | |
| | 1435 | g_free(info_data->name); |
| | 1436 | g_free(info_data); |
| | 1437 | return; |
| | 1438 | } |
| | 1439 | |
| | 1440 | url_buffer = g_strdup(url_text); |
| | 1441 | |
| | 1442 | if ((p = strstr(url_text, |
| | 1443 | "\xec\xa1\xb4\xec\x9e\xac\xed\x95\x98" |
| | 1444 | "\xec\xa7\x80 \xec\x95\x8a\xeb\x8a\x94 " |
| | 1445 | "\xec\x82\xac\xec\x9a\xa9\xec\x9e\x90" |
| | 1446 | "\xec\x9e\x85\xeb\x8b\x88\xeb\x8b\xa4.")) == NULL) |
| | 1447 | { |
| | 1448 | has_info = TRUE; |
| | 1449 | } |
| | 1450 | |
| | 1451 | /* Nuke the html, it's easier than trying to parse the horrid stuff */ |
| | 1452 | stripped = purple_markup_strip_html(url_buffer); |
| | 1453 | stripped_len = strlen(stripped); |
| | 1454 | |
| | 1455 | purple_debug_misc("nateon", "stripped = %p\n", stripped); |
| | 1456 | purple_debug_misc("nateon", "url_buffer = %p\n", url_buffer); |
| | 1457 | |
| | 1458 | /* General section header */ |
| | 1459 | if (has_tooltip_text) |
| | 1460 | purple_notify_user_info_add_section_break(user_info); |
| | 1461 | |
| | 1462 | /* Personal */ |
| | 1463 | purple_notify_user_info_add_section_header(user_info, _("Personal Information")); |
| | 1464 | |
| | 1465 | /* Extract their Name, minihp and put it in */ |
| | 1466 | purple_markup_extract_info_field(stripped, stripped_len, user_info, |
| | 1467 | " \xec\x9d\xb4\xeb\xa6\x84\t", 0, " ", 0, "Undisclosed", _("Name"), 0, NULL, NULL); |
| | 1468 | purple_notify_user_info_remove_last_item(user_info); |
| | 1469 | |
| | 1470 | NATEON_GOT_INFO_GET_FIELD("\xec\x9d\xb4\xeb\xa9\x94\xec\x9d\xbc", _("Email")); |
| | 1471 | NATEON_GOT_INFO_GET_FIELD("\xec\x83\x9d\xec\x9d\xbc", _("Birthday")); |
| | 1472 | NATEON_GOT_INFO_GET_FIELD("\xed\x9c\xb4\xeb\x8c\x80\xed\x8f\xb0", _("Mobile Phone")); |
| | 1473 | NATEON_GOT_INFO_GET_FIELD("\xec\x9e\x90\xea\xb8\xb0\xec\x86\x8c\xea\xb0\x9c", _("A Little About Me")); |
| | 1474 | |
| | 1475 | if (strstr(stripped, "openWindow_minihompy") != NULL) |
| | 1476 | { |
| | 1477 | tmp = g_strdup_printf(NATEON_MINIHP_URL, info_data->id); |
| | 1478 | purple_notify_user_info_add_pair(user_info, _("Homepage"), tmp); |
| | 1479 | g_free(tmp); |
| | 1480 | } |
| | 1481 | |
| | 1482 | |
| | 1483 | if (!has_info) |
| | 1484 | { |
| | 1485 | PurpleBuddy *b = purple_find_buddy |
| | 1486 | (purple_connection_get_account(info_data->gc), info_data->name); |
| | 1487 | purple_notify_user_info_add_pair(user_info, _("Error retrieving profile"), |
| | 1488 | ((p && b) ? _("The user has not created a public profile.") : |
| | 1489 | (p ? _("NATEON reported not being able to find the user's profile. " |
| | 1490 | "This either means that the user does not exist, " |
| | 1491 | "or that the user exists " |
| | 1492 | "but has not created a public profile.") : |
| | 1493 | _("Could not find " /* This should never happen */ |
| | 1494 | "any information in the user's profile. " |
| | 1495 | "The user most likely does not exist.")))); |
| | 1496 | } |
| | 1497 | |
| | 1498 | /* put a link to the actual profile URL */ |
| | 1499 | tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>", |
| | 1500 | NATEON_PROFILE_URL, info_data->id, |
| | 1501 | NATEON_PROFILE_URL, info_data->id); |
| | 1502 | purple_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); |
| | 1503 | g_free(tmp); |
| | 1504 | |
| | 1505 | #if PHOTO_SUPPORT |
| | 1506 | |
| | 1507 | /* Marshall the existing state */ |
| | 1508 | info2_data = g_malloc0(sizeof(NateonGetInfoStepTwoData)); |
| | 1509 | info2_data->info_data = info_data; |
| | 1510 | info2_data->stripped = stripped; |
| | 1511 | info2_data->url_buffer = url_buffer; |
| | 1512 | info2_data->user_info = user_info; |
| | 1513 | |
| | 1514 | /* Try to put the photo in there too, if there's one */ |
| | 1515 | if (strstr(url_text, "openProfileImage") != NULL) |
| | 1516 | { |
| | 1517 | photo_frame_url_text = g_strdup_printf(NATEON_PHOTO_URL, info_data->id); |
| | 1518 | info2_data->photo_frame_url_text = photo_frame_url_text; |
| | 1519 | purple_util_fetch_url(photo_frame_url_text, FALSE, NULL, FALSE, nateon_got_photo_frame, |
| | 1520 | info2_data); |
| | 1521 | } |
| | 1522 | else |
| | 1523 | { |
| | 1524 | /* Emulate a callback */ |
| | 1525 | /* TODO: Huh? */ |
| | 1526 | nateon_got_photo(NULL, info2_data, NULL, 0, NULL); |
| | 1527 | } |
| | 1528 | } |
| | 1529 | |
| | 1530 | static void |
| | 1531 | nateon_got_photo_frame(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
| | 1532 | const gchar *url_text, size_t len, const gchar *error_message) |
| | 1533 | { |
| | 1534 | NateonGetInfoStepTwoData *info2_data = (NateonGetInfoStepTwoData *)user_data; |
| | 1535 | char *p, *q, *tmp, *photo_url_text; |
| | 1536 | |
| | 1537 | if ( (p=strstr(url_text, "/profileimage")) != NULL && (q=strstr(p, "\"")) != NULL) |
| | 1538 | { |
| | 1539 | tmp = g_strndup(p, q - p); |
| | 1540 | photo_url_text = g_strdup_printf("%s%s", NATEON_PROFILE_BASE, tmp); |
| | 1541 | info2_data->photo_url_text = photo_url_text; |
| | 1542 | purple_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, nateon_got_photo, |
| | 1543 | info2_data); |
| | 1544 | g_free(tmp); |
| | 1545 | } |
| | 1546 | else |
| | 1547 | { |
| | 1548 | /* Emulate a callback */ |
| | 1549 | /* TODO: Huh? */ |
| | 1550 | nateon_got_photo(NULL, info2_data, NULL, 0, NULL); |
| | 1551 | } |
| | 1552 | } |
| | 1553 | |
| | 1554 | static void |
| | 1555 | nateon_got_photo(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
| | 1556 | const gchar *url_text, size_t len, const gchar *error_message) |
| | 1557 | { |
| | 1558 | NateonGetInfoStepTwoData *info2_data = (NateonGetInfoStepTwoData *)user_data; |
| | 1559 | int id = -1; |
| | 1560 | |
| | 1561 | /* Unmarshall the saved state */ |
| | 1562 | NateonGetInfoData *info_data = info2_data->info_data; |
| | 1563 | char *stripped = info2_data->stripped; |
| | 1564 | char *url_buffer = info2_data->url_buffer; |
| | 1565 | PurpleNotifyUserInfo *user_info = info2_data->user_info; |
| | 1566 | char *photo_url_text = info2_data->photo_url_text; |
| | 1567 | char *photo_frame_url_text = info2_data->photo_frame_url_text; |
| | 1568 | |
| | 1569 | /* Make sure the connection is still valid if we got here by fetching a photo url */ |
| | 1570 | if (url_text && (error_message != NULL || |
| | 1571 | g_list_find(purple_connections_get_all(), info_data->gc) == NULL)) |
| | 1572 | { |
| | 1573 | purple_debug_warning("nateon", "invalid connection. ignoring buddy photo info.\n"); |
| | 1574 | g_free(stripped); |
| | 1575 | g_free(url_buffer); |
| | 1576 | g_free(user_info); |
| | 1577 | g_free(info_data->name); |
| | 1578 | g_free(info_data); |
| | 1579 | g_free(photo_url_text); |
| | 1580 | g_free(photo_frame_url_text); |
| | 1581 | g_free(info2_data); |
| | 1582 | |
| | 1583 | return; |
| | 1584 | } |
| | 1585 | |
| | 1586 | /* Try to put the photo in there too, if there's one and is readable */ |
| | 1587 | if (user_data && url_text && len != 0) |
| | 1588 | { |
| | 1589 | if (strstr(url_text, "400 Bad Request") |
| | 1590 | || strstr(url_text, "403 Forbidden") |
| | 1591 | || strstr(url_text, "404 Not Found")) |
| | 1592 | { |
| | 1593 | |
| | 1594 | purple_debug_info("nateon", "Error getting %s: %s\n", |
| | 1595 | photo_url_text, url_text); |
| | 1596 | } |
| | 1597 | else |
| | 1598 | { |
| | 1599 | char buf[1024]; |
| | 1600 | purple_debug_info("nateon", "%s is %d bytes\n", photo_url_text, len); |
| | 1601 | id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL); |
| | 1602 | g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); |
| | 1603 | purple_notify_user_info_prepend_pair(user_info, NULL, buf); |
| | 1604 | } |
| | 1605 | } |
| | 1606 | |
| | 1607 | /* We continue here from nateon_got_info, as if nothing has happened */ |
| | 1608 | #endif |
| | 1609 | purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
| | 1610 | |
| | 1611 | g_free(stripped); |
| | 1612 | g_free(url_buffer); |
| | 1613 | purple_notify_user_info_destroy(user_info); |
| | 1614 | g_free(info_data->name); |
| | 1615 | g_free(info_data); |
| | 1616 | #if PHOTO_SUPPORT |
| | 1617 | g_free(photo_url_text); |
| | 1618 | g_free(photo_frame_url_text); |
| | 1619 | g_free(info2_data); |
| | 1620 | if (id != -1) |
| | 1621 | purple_imgstore_unref_by_id(id); |
| | 1622 | #endif |
| | 1623 | } |
| | 1624 | |
| | 1625 | static void |
| | 1626 | nateon_get_info(PurpleConnection *gc, const char *name) |
| | 1627 | { |
| | 1628 | NateonGetInfoData *data; |
| | 1629 | char *url; |
| | 1630 | const char *id; |
| | 1631 | NateonSession *session; |
| | 1632 | |
| | 1633 | data = g_new0(NateonGetInfoData, 1); |
| | 1634 | data->gc = gc; |
| | 1635 | data->name = g_strdup(name); |
| | 1636 | session = gc->proto_data; |
| | 1637 | id = nateon_userlist_find_user_with_name(session->userlist, name)->id; |
| | 1638 | data->id = g_strdup(id); |
| | 1639 | |
| | 1640 | url = g_strdup_printf("%s%s", NATEON_PROFILE_URL, id); |
| | 1641 | |
| | 1642 | purple_util_fetch_url(url, TRUE, |
| | 1643 | "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
| | 1644 | TRUE, nateon_got_info, data); |
| | 1645 | |
| | 1646 | g_free(url); |
| | 1647 | } |
| | 1648 | |
| 1925 | 1649 | static gboolean nateon_load(PurplePlugin *plugin) |
| 1926 | 1650 | { |
| 1927 | 1651 | nateon_notification_init(); |
| … |
… |
|
| 1959 | 1683 | nateon_send_im, /* send_im */ |
| 1960 | 1684 | NULL, /* set_info */ |
| 1961 | 1685 | nateon_send_typing, /* send_typing */ |
| 1962 | | NULL, //nateon_get_info, /* get_info */ |
| | 1686 | nateon_get_info, /* get_info */ |
| 1963 | 1687 | nateon_set_status, /* set_away */ |
| 1964 | 1688 | nateon_set_idle, /* set_idle */ |
| 1965 | 1689 | NULL, /* change_passwd */ |
-
|
|
|
|
| 65 | 65 | #define NATEON_TYPING_RECV_TIMEOUT 6 |
| 66 | 66 | #define NATEON_TYPING_SEND_TIMEOUT 4 |
| 67 | 67 | |
| 68 | | //#define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders" |
| 69 | | //#define PASSPORT_URL "http://lc1.law13.hotmail.passport.com/cgi-bin/dologin?login=" |
| 70 | | //#define PROFILE_URL "http://spaces.msn.com/profile.aspx?mem=" |
| 71 | | // |
| 72 | | //#define USEROPT_HOTMAIL 0 |
| 73 | | // |
| 74 | | //#define BUDDY_ALIAS_MAXLEN 387 |
| 75 | | // |
| 76 | | //#define NATEON_FT_GUID "{5D3E02AB-6190-11d3-BBBB-00C04F795683}" |
| 77 | | // |
| 78 | | //#define NATEON_CLIENTINFO \ |
| 79 | | // "Client-Name: Purple/" VERSION "\r\n" \ |
| 80 | | // "Chat-Logging: Y\r\n" |
| | 68 | #define NATEON_PROFILE_BASE "http://nateonweb.nate.com" |
| | 69 | #define NATEON_PROFILE_URL NATEON_PROFILE_BASE "/client/profile2/view.php?CMN=" |
| | 70 | #define NATEON_PHOTO_URL NATEON_PROFILE_BASE "/client/profile2/getProfileImage.php?CMN=%s" |
| | 71 | #define NATEON_MINIHP_URL NATEON_PROFILE_BASE "/client/profile2/minihompi_send.php?menu=Home&TargetCMN=%s" |
| 81 | 72 | |
| | 73 | /* |
| 82 | 74 | |
| | 75 | #define BUDDY_ALIAS_MAXLEN 387 |
| | 76 | |
| | 77 | #define NATEON_FT_GUID "{5D3E02AB-6190-11d3-BBBB-00C04F795683}" |
| | 78 | |
| | 79 | #define NATEON_CLIENTINFO \ |
| | 80 | "Client-Name: Purple/" VERSION "\r\n" \ |
| | 81 | "Chat-Logging: Y\r\n" |
| | 82 | */ |
| | 83 | |
| | 84 | |
| 83 | 85 | typedef enum |
| 84 | 86 | { |
| 85 | 87 | NATEON_LIST_FL_OP, |
Download in other formats:
|
|