comparison src/protocols/msn/msn.c @ 9510:2aed8d5cda1b

[gaim-migrate @ 10337] wing did some stuff to make get info on yahoo and msn look better, and provide more info on why it can't fetch the profile when it can't. See patch #987609 for a fuller description. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sun, 11 Jul 2004 20:26:02 +0000
parents 7a65fdba750f
children 8b2451878e26
comparison
equal deleted inserted replaced
9509:aecabbe495db 9510:2aed8d5cda1b
70 char *stripped; 70 char *stripped;
71 char *url_buffer; 71 char *url_buffer;
72 GString *s; 72 GString *s;
73 char *photo_url_text; 73 char *photo_url_text;
74 char *tooltip_text; 74 char *tooltip_text;
75 gboolean has_info; 75 const char *title;
76 76
77 } MsnGetInfoStepTwoData; 77 } MsnGetInfoStepTwoData;
78 78
79 static const char * 79 static const char *
80 msn_normalize(const GaimAccount *account, const char *str) 80 msn_normalize(const GaimAccount *account, const char *str)
1140 } 1140 }
1141 1141
1142 static char * 1142 static char *
1143 msn_tooltip_info_text(MsnGetInfoData *info_data) { 1143 msn_tooltip_info_text(MsnGetInfoData *info_data) {
1144 GString *s = g_string_sized_new(80); /* wild guess */ 1144 GString *s = g_string_sized_new(80); /* wild guess */
1145 GString *name;
1145 GaimBuddy *b; 1146 GaimBuddy *b;
1146 1147 const char *p;
1147 g_string_printf(s, _("<b>%s:</b> %s<br>"), _("MSN ID"), info_data->name); 1148
1149 /* Try to not display the MSN screen name as an email address */
1150 p = strrchr(info_data->name, '@');
1151 if (p) {
1152 name = g_string_new_len(info_data->name, p - info_data->name);
1153 g_string_append_printf(name, "&#64;%s", p + 1);
1154 } else { /* This should never happen */
1155 name = g_string_new(info_data->name);
1156 }
1157 g_string_printf(s, "<span style=\"font-size: larger\"><b>%s</b></span><br>",
1158 name->str);
1159 g_string_free(name, TRUE);
1148 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), 1160 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc),
1149 info_data->name); 1161 info_data->name);
1150 1162
1151 if (b) { 1163 if (b) {
1152 char *statustext = msn_tooltip_text(b); 1164 char *statustext = msn_tooltip_text(b);
1155 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); 1167 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext);
1156 g_free(aliastext); 1168 g_free(aliastext);
1157 } 1169 }
1158 if(b->server_alias) { 1170 if(b->server_alias) {
1159 char *nicktext = g_markup_escape_text(b->server_alias, -1); 1171 char *nicktext = g_markup_escape_text(b->server_alias, -1);
1160 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Nickname"), 1172 g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname"));
1173 g_string_append_printf(s, _("<font sml=\"msn\">%s</font><br>"),
1161 nicktext); 1174 nicktext);
1162 g_free(nicktext); 1175 g_free(nicktext);
1163 } 1176 }
1164 if (b->idle > 0) { 1177 if (b->idle > 0) {
1165 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle); 1178 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle);
1212 char buf[1024]; 1225 char buf[1024];
1213 char *tooltip_text = NULL; 1226 char *tooltip_text = NULL;
1214 char *user_url = NULL; 1227 char *user_url = NULL;
1215 gboolean found; 1228 gboolean found;
1216 gboolean has_info = FALSE; 1229 gboolean has_info = FALSE;
1230 const char* title = NULL;
1217 char *url_buffer; 1231 char *url_buffer;
1218 GString *s; 1232 GString *s;
1219 int stripped_len; 1233 int stripped_len;
1220 #if PHOTO_SUPPORT 1234 #if PHOTO_SUPPORT
1221 char *photo_url_text = NULL; 1235 char *photo_url_text = NULL;
1223 #endif 1237 #endif
1224 1238
1225 gaim_debug_info("msn", "In msn_got_info\n"); 1239 gaim_debug_info("msn", "In msn_got_info\n");
1226 1240
1227 tooltip_text = msn_tooltip_info_text(info_data); 1241 tooltip_text = msn_tooltip_info_text(info_data);
1242 title = _("MSN Profile");
1228 1243
1229 if (url_text == NULL || strcmp(url_text, "") == 0) 1244 if (url_text == NULL || strcmp(url_text, "") == 0)
1230 { 1245 {
1231 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", 1246 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>",
1232 tooltip_text, _("Error retrieving profile")); 1247 tooltip_text, _("Error retrieving profile"));
1233 1248
1234 gaim_notify_formatted(info_data->gc, NULL, 1249 gaim_notify_formatted(info_data->gc, NULL,
1235 _("Buddy Information"), NULL, buf, NULL, NULL); 1250 title, NULL, buf, NULL, NULL);
1236 1251
1237 g_free(tooltip_text); 1252 g_free(tooltip_text);
1238 return; 1253 return;
1239 } 1254 }
1240 1255
1468 g_free(user_url); 1483 g_free(user_url);
1469 1484
1470 has_info = TRUE; 1485 has_info = TRUE;
1471 } 1486 }
1472 1487
1473 if (found) { 1488 if (!has_info)
1474 /* put a link to the actual profile URL */ 1489 {
1475 g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL")); 1490 /* MSN doesn't actually distinguish between "unknown member" and
1476 g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", 1491 * a known member with an empty profile. Try to explain this fact.
1477 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); 1492 * Note that if we have a nonempty tooltip_text, we know the user
1478 } 1493 * exists.
1494 */
1495 char *p = strstr(url_buffer, "Unknown Member </TITLE>");
1496 GaimBuddy *b = gaim_find_buddy
1497 (gaim_connection_get_account(info_data->gc), info_data->name);
1498 g_string_append_printf(s, "<br><b>%s</b><br>%s<br><br>",
1499 _("Error retrieving profile"),
1500 ((p && b)?
1501 _("The user has not created a public profile."):
1502 p? _("MSN reported not being able to find the user's profile. "
1503 "This either means that the user does not exist, "
1504 "or that the user exists "
1505 "but has not created a public profile."):
1506 _("Gaim could not find " /* This should never happen */
1507 "any information in the user's profile. "
1508 "The user most likely does not exist.")));
1509 }
1510
1511 /* put a link to the actual profile URL */
1512 g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL"));
1513 g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>",
1514 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name);
1479 1515
1480 /* Finish it off, and show it to them */ 1516 /* Finish it off, and show it to them */
1481 g_string_append(s, "</body></html>\n"); 1517 g_string_append(s, "</body></html>\n");
1482 1518
1483 #if PHOTO_SUPPORT 1519 #if PHOTO_SUPPORT
1488 info2_data->stripped = stripped; 1524 info2_data->stripped = stripped;
1489 info2_data->url_buffer = url_buffer; 1525 info2_data->url_buffer = url_buffer;
1490 info2_data->s = s; 1526 info2_data->s = s;
1491 info2_data->photo_url_text = photo_url_text; 1527 info2_data->photo_url_text = photo_url_text;
1492 info2_data->tooltip_text = tooltip_text; 1528 info2_data->tooltip_text = tooltip_text;
1493 info2_data->has_info = has_info; 1529 info2_data->title = title;
1494 1530
1495 /* Try to put the photo in there too, if there's one */ 1531 /* Try to put the photo in there too, if there's one */
1496 photo_url_text = msn_get_photo_url(url_text); 1532 photo_url_text = msn_get_photo_url(url_text);
1497 if (photo_url_text) { 1533 if (photo_url_text) {
1498 gaim_url_fetch(photo_url_text, FALSE, NULL, FALSE, msn_got_photo, 1534 gaim_url_fetch(photo_url_text, FALSE, NULL, FALSE, msn_got_photo,
1513 char *stripped = info2_data->stripped; 1549 char *stripped = info2_data->stripped;
1514 char *url_buffer = info2_data->url_buffer; 1550 char *url_buffer = info2_data->url_buffer;
1515 GString *s = info2_data->s; 1551 GString *s = info2_data->s;
1516 char *photo_url_text = info2_data->photo_url_text; 1552 char *photo_url_text = info2_data->photo_url_text;
1517 char *tooltip_text = info2_data->tooltip_text; 1553 char *tooltip_text = info2_data->tooltip_text;
1518 gboolean has_info = info2_data->has_info; 1554 const char *title = info2_data->title;
1519 1555
1520 /* Try to put the photo in there too, if there's one and is readable */ 1556 /* Try to put the photo in there too, if there's one and is readable */
1521 if (data && url_text && len != 0) { 1557 if (data && url_text && len != 0) {
1522 if (strstr(url_text, "400 Bad Request") 1558 if (strstr(url_text, "400 Bad Request")
1523 || strstr(url_text, "403 Forbidden") 1559 || strstr(url_text, "403 Forbidden")
1535 } 1571 }
1536 1572
1537 /* We continue here from msn_got_info, as if nothing has happened */ 1573 /* We continue here from msn_got_info, as if nothing has happened */
1538 #endif 1574 #endif
1539 1575
1540 if (has_info) 1576 g_string_prepend(s, tooltip_text);
1541 { 1577 gaim_notify_formatted(info_data->gc, NULL, title,
1542 g_string_prepend(s, tooltip_text); 1578 NULL, s->str, NULL, NULL);
1543 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"),
1544 NULL, s->str, NULL, NULL);
1545 }
1546 else
1547 {
1548 char *p = strstr(url_buffer, "Unknown Member </TITLE>");
1549
1550 /* MSN doesn't actually distinguish between "unknown member" and
1551 * a known member with an empty profile. But if we say unknown
1552 * member, it is at least not worse than reading the actual page.
1553 */
1554 g_string_printf(s, "<html><body>%s<b>%s</b><br></body></html>",
1555 tooltip_text,
1556 (p ? _("Error retrieving profile")
1557 : _("The user's profile is empty.")));
1558
1559 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
1560 s->str, NULL, NULL);
1561 }
1562 1579
1563 g_free(stripped); 1580 g_free(stripped);
1564 g_free(url_buffer); 1581 g_free(url_buffer);
1565 g_string_free(s, TRUE); 1582 g_string_free(s, TRUE);
1566 g_free(tooltip_text); 1583 g_free(tooltip_text);