comparison src/protocols/msn/msn.c @ 7095:c8bf2da398e3

[gaim-migrate @ 7660] html.[ch] is gone. Everything inside was namespaced and put in util.[ch]. One less ugly part of gaim in the tree. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 01 Oct 2003 03:43:18 +0000
parents 2343c3aa1dec
children 7700a28929bd
comparison
equal deleted inserted replaced
7094:2343c3aa1dec 7095:c8bf2da398e3
28 #include "prefs.h" 28 #include "prefs.h"
29 #include "session.h" 29 #include "session.h"
30 #include "state.h" 30 #include "state.h"
31 #include "utils.h" 31 #include "utils.h"
32 #include "multi.h" 32 #include "multi.h"
33 #include "html.h" 33 #include "util.h"
34 34
35 #define BUDDY_ALIAS_MAXLEN 388 35 #define BUDDY_ALIAS_MAXLEN 388
36 36
37 static GaimPlugin *my_protocol = NULL; 37 static GaimPlugin *my_protocol = NULL;
38 38
1234 } 1234 }
1235 1235
1236 url_buffer = g_strdup(url_text); 1236 url_buffer = g_strdup(url_text);
1237 1237
1238 /* If they have a homepage link, MSN masks it such that we need to 1238 /* If they have a homepage link, MSN masks it such that we need to
1239 * fetch the url out before strip_html() nukes it */ 1239 * fetch the url out before gaim_markup_strip_html() nukes it */
1240 if ((p = strstr(url_text, 1240 if ((p = strstr(url_text,
1241 "Take a look at my </font><A class=viewDesc title=\"")) != NULL) 1241 "Take a look at my </font><A class=viewDesc title=\"")) != NULL)
1242 { 1242 {
1243 p += 50; 1243 p += 50;
1244 1244
1245 if ((q = strchr(p, '"')) != NULL) 1245 if ((q = strchr(p, '"')) != NULL)
1246 user_url = g_strndup(p, q - p); 1246 user_url = g_strndup(p, q - p);
1247 } 1247 }
1248 1248
1249 /* 1249 /*
1250 * strip_html() doesn't strip out character entities like &nbsp; 1250 * gaim_markup_strip_html() doesn't strip out character entities like &nbsp;
1251 * and &#183; 1251 * and &#183;
1252 */ 1252 */
1253 while ((p = strstr(url_buffer, "&nbsp;")) != NULL) 1253 while ((p = strstr(url_buffer, "&nbsp;")) != NULL)
1254 { 1254 {
1255 memmove(p, p + 6, strlen(p + 6)); 1255 memmove(p, p + 6, strlen(p + 6));
1276 memmove(p + 1, p + 5, strlen(p + 5)); 1276 memmove(p + 1, p + 5, strlen(p + 5));
1277 url_buffer[strlen(url_buffer) - 4] = '\0'; 1277 url_buffer[strlen(url_buffer) - 4] = '\0';
1278 } 1278 }
1279 1279
1280 /* Nuke the html, it's easier than trying to parse the horrid stuff */ 1280 /* Nuke the html, it's easier than trying to parse the horrid stuff */
1281 stripped = strip_html(url_buffer); 1281 stripped = gaim_markup_strip_html(url_buffer);
1282 1282
1283 /* Gonna re-use the memory we've already got for url_buffer */ 1283 /* Gonna re-use the memory we've already got for url_buffer */
1284 strcpy(url_buffer, "<html><body>\n"); 1284 strcpy(url_buffer, "<html><body>\n");
1285 1285
1286 /* Extract their Name and put it in */ 1286 /* Extract their Name and put it in */
1287 info_extract_field(stripped, url_buffer, "\tName", 0, "\t", '\n', 1287 gaim_markup_extract_info_field(stripped, url_buffer, "\tName", 0, "\t",
1288 "Undisclosed", _("Name"), 0, NULL); 1288 '\n', "Undisclosed", _("Name"), 0, NULL);
1289 1289
1290 /* Extract their Age and put it in */ 1290 /* Extract their Age and put it in */
1291 info_extract_field(stripped, url_buffer, "\tAge", 0, "\t", '\n', 1291 gaim_markup_extract_info_field(stripped, url_buffer, "\tAge", 0, "\t",
1292 "Undisclosed", _("Age"), 0, NULL); 1292 '\n', "Undisclosed", _("Age"), 0, NULL);
1293 1293
1294 /* Extract their Gender and put it in */ 1294 /* Extract their Gender and put it in */
1295 info_extract_field(stripped, url_buffer, "\tGender", 6, "\t", '\n', 1295 gaim_markup_extract_info_field(stripped, url_buffer, "\tGender", 6, "\t",
1296 "Undisclosed", _("Gender"), 0, NULL); 1296 '\n', "Undisclosed", _("Gender"), 0, NULL);
1297 1297
1298 /* Extract their MaritalStatus and put it in */ 1298 /* Extract their MaritalStatus and put it in */
1299 info_extract_field(stripped, url_buffer, "\tMaritalStatus", 0, "\t", '\n', 1299 gaim_markup_extract_info_field(stripped, url_buffer, "\tMaritalStatus",
1300 "Undisclosed", _("Marital Status"), 0, NULL); 1300 0, "\t", '\n', "Undisclosed",
1301 _("Marital Status"), 0, NULL);
1301 1302
1302 /* Extract their Location and put it in */ 1303 /* Extract their Location and put it in */
1303 info_extract_field(stripped, url_buffer, "\tLocation", 0, "\t", '\n', 1304 gaim_markup_extract_info_field(stripped, url_buffer, "\tLocation", 0,
1304 "Undisclosed", _("Location"), 0, NULL); 1305 "\t", '\n', "Undisclosed", _("Location"),
1306 0, NULL);
1305 1307
1306 /* Extract their Occupation and put it in */ 1308 /* Extract their Occupation and put it in */
1307 info_extract_field(stripped, url_buffer, "\t Occupation", 6, "\t", '\n', 1309 gaim_markup_extract_info_field(stripped, url_buffer, "\t Occupation", 6,
1308 "Undisclosed", _("Occupation"), 0, NULL); 1310 "\t", '\n', "Undisclosed", _("Occupation"),
1311 0, NULL);
1309 1312
1310 /* 1313 /*
1311 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies 1314 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies
1312 * and Interests', 'Favorite Quote', and 'My Homepage' may or may 1315 * and Interests', 'Favorite Quote', and 'My Homepage' may or may
1313 * not appear, in any combination. However, they do appear in 1316 * not appear, in any combination. However, they do appear in
1314 * certain order, so we can successively search to pin down the 1317 * certain order, so we can successively search to pin down the
1315 * distinct values. 1318 * distinct values.
1316 */ 1319 */
1317 1320
1318 /* Check if they have A Little About Me */ 1321 /* Check if they have A Little About Me */
1319 found = info_extract_field(stripped, url_buffer, "\tA Little About Me", 1322 found = gaim_markup_extract_info_field(stripped, url_buffer,
1320 1, "Favorite Things", '\n', NULL, 1323 "\tA Little About Me", 1, "Favorite Things", '\n', NULL,
1321 _("A Little About Me"), 0, NULL); 1324 _("A Little About Me"), 0, NULL);
1322 1325
1323 if (!found) 1326 if (!found)
1324 { 1327 {
1325 found = info_extract_field(stripped, url_buffer, 1328 found = gaim_markup_extract_info_field(stripped, url_buffer,
1326 "\tA Little About Me", 1, 1329 "\tA Little About Me", 1, "Hobbies and Interests", '\n',
1327 "Hobbies and Interests", '\n', NULL, 1330 NULL, _("A Little About Me"), 0, NULL);
1328 _("A Little About Me"), 0, NULL);
1329 } 1331 }
1330 1332
1331 if (!found) 1333 if (!found)
1332 { 1334 {
1333 found = info_extract_field(stripped, url_buffer, 1335 found = gaim_markup_extract_info_field(stripped, url_buffer,
1334 "\tA Little About Me", 1, 1336 "\tA Little About Me", 1, "Favorite Quote", '\n', NULL,
1335 "Favorite Quote", '\n', NULL, 1337 _("A Little About Me"), 0, NULL);
1336 _("A Little About Me"), 0, NULL);
1337 } 1338 }
1338 1339
1339 if (!found) 1340 if (!found)
1340 { 1341 {
1341 found = info_extract_field(stripped, url_buffer, 1342 found = gaim_markup_extract_info_field(stripped, url_buffer,
1342 "\tA Little About Me", 1, 1343 "\tA Little About Me", 1, "My Homepage\tTake a look", '\n',
1343 "My Homepage\tTake a look", '\n', NULL, 1344 NULL, _("A Little About Me"), 0, NULL);
1344 _("A Little About Me"), 0, NULL);
1345 } 1345 }
1346 1346
1347 if (!found) 1347 if (!found)
1348 { 1348 {
1349 info_extract_field(stripped, url_buffer, "\tA Little About Me", 1, 1349 gaim_markup_extract_info_field(stripped, url_buffer,
1350 "last updated", '\n', 1350 "\tA Little About Me", 1, "last updated", '\n', NULL,
1351 NULL, _("A Little About Me"), 0, NULL); 1351 _("A Little About Me"), 0, NULL);
1352 } 1352 }
1353 1353
1354 /* Check if they have Favorite Things */ 1354 /* Check if they have Favorite Things */
1355 found = info_extract_field(stripped, url_buffer, "Favorite Things", 1, 1355 found = gaim_markup_extract_info_field(stripped, url_buffer,
1356 "Hobbies and Interests", '\n', NULL, 1356 "Favorite Things", 1, "Hobbies and Interests", '\n', NULL,
1357 _("Favorite Things"), 0, NULL); 1357 _("Favorite Things"), 0, NULL);
1358 1358
1359 if (!found) 1359 if (!found)
1360 { 1360 {
1361 found = info_extract_field(stripped, url_buffer, "Favorite Things", 1, 1361 found = gaim_markup_extract_info_field(stripped, url_buffer,
1362 "Favorite Quote", '\n', NULL, 1362 "Favorite Things", 1, "Favorite Quote", '\n', NULL,
1363 "Favorite Things", 0, NULL); 1363 "Favorite Things", 0, NULL);
1364 } 1364 }
1365 1365
1366 if (!found) 1366 if (!found)
1367 { 1367 {
1368 found = info_extract_field(stripped, url_buffer, "Favorite Things", 1, 1368 found = gaim_markup_extract_info_field(stripped, url_buffer,
1369 "My Homepage\tTake a look", '\n', NULL, 1369 "Favorite Things", 1, "My Homepage\tTake a look", '\n', NULL,
1370 _("Favorite Things"), 0, NULL); 1370 _("Favorite Things"), 0, NULL);
1371 } 1371 }
1372 1372
1373 if (!found) 1373 if (!found)
1374 { 1374 {
1375 info_extract_field(stripped, url_buffer, "Favorite Things", 1, 1375 gaim_markup_extract_info_field(stripped, url_buffer,
1376 "last updated", '\n', NULL, 1376 "Favorite Things", 1, "last updated", '\n', NULL,
1377 _("Favorite Things"), 0, NULL); 1377 _("Favorite Things"), 0, NULL);
1378 } 1378 }
1379 1379
1380 /* Check if they have Hobbies and Interests */ 1380 /* Check if they have Hobbies and Interests */
1381 found = info_extract_field(stripped, url_buffer, "Hobbies and Interests", 1381 found = gaim_markup_extract_info_field(stripped, url_buffer,
1382 1, "Favorite Quote", '\n', NULL, 1382 "Hobbies and Interests", 1, "Favorite Quote", '\n', NULL,
1383 _("Hobbies and Interests"), 0, NULL); 1383 _("Hobbies and Interests"), 0, NULL);
1384 1384
1385 if (!found) 1385 if (!found)
1386 { 1386 {
1387 found = info_extract_field(stripped, url_buffer, 1387 found = gaim_markup_extract_info_field(stripped, url_buffer,
1388 "Hobbies and Interests", 1, 1388 "Hobbies and Interests", 1, "My Homepage\tTake a look",
1389 "My Homepage\tTake a look", '\n', NULL, 1389 '\n', NULL, _("Hobbies and Interests"), 0, NULL);
1390 _("Hobbies and Interests"), 0, NULL);
1391 } 1390 }
1392 1391
1393 if (!found) 1392 if (!found)
1394 { 1393 {
1395 info_extract_field(stripped, url_buffer, "Hobbies and Interests", 1394 gaim_markup_extract_info_field(stripped, url_buffer,
1396 1, "last updated", '\n', NULL, 1395 "Hobbies and Interests", 1, "last updated", '\n', NULL,
1397 _("Hobbies and Interests"), 0, NULL); 1396 _("Hobbies and Interests"), 0, NULL);
1398 } 1397 }
1399 1398
1400 /* Check if they have Favorite Quote */ 1399 /* Check if they have Favorite Quote */
1401 found = info_extract_field(stripped, url_buffer, "Favorite Quote", 1, 1400 found = gaim_markup_extract_info_field(stripped, url_buffer,
1402 "My Homepage\tTake a look", '\n', NULL, 1401 "Favorite Quote", 1, "My Homepage\tTake a look", '\n', NULL,
1403 _("Favorite Quote"), 0, NULL); 1402 _("Favorite Quote"), 0, NULL);
1404 1403
1405 if (!found) 1404 if (!found)
1406 { 1405 {
1407 info_extract_field(stripped, url_buffer, "Favorite Quote", 1, 1406 gaim_markup_extract_info_field(stripped, url_buffer,
1408 "last updated", '\n', NULL, 1407 "Favorite Quote", 1, "last updated", '\n', NULL,
1409 _("Favorite Quote"), 0, NULL); 1408 _("Favorite Quote"), 0, NULL);
1410 } 1409 }
1411 1410
1412 /* Extract the last updated date and put it in */ 1411 /* Extract the last updated date and put it in */
1413 info_extract_field(stripped, url_buffer, "\tlast updated:", 1, "\n", '\n', 1412 gaim_markup_extract_info_field(stripped, url_buffer,
1414 NULL, _("Last Updated"), 0, NULL); 1413 "\tlast updated:", 1, "\n", '\n', NULL, _("Last Updated"),
1414 0, NULL);
1415 1415
1416 /* If we were able to fetch a homepage url earlier, stick it in there */ 1416 /* If we were able to fetch a homepage url earlier, stick it in there */
1417 if (user_url != NULL) 1417 if (user_url != NULL)
1418 { 1418 {
1419 g_snprintf(buf, sizeof(buf), 1419 g_snprintf(buf, sizeof(buf),