comparison src/gaimrc.c @ 5211:0241d6b6702d

[gaim-migrate @ 5581] Wrote a new debugging API, and of course core/ui split it. Debug statements can now have debug levels and categories, for future filtering of stuff, and color highlighting. It's nifty, m'kay? committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 26 Apr 2003 06:46:08 +0000
parents fefad67de2c7
children d635e8fe2fba
comparison
equal deleted inserted replaced
5210:39bb2a35f8d9 5211:0241d6b6702d
469 { 469 {
470 GList *pnc; 470 GList *pnc;
471 struct gaim_pounce *pounce; 471 struct gaim_pounce *pounce;
472 struct gaim_gtkpounce_data *pounce_data; 472 struct gaim_gtkpounce_data *pounce_data;
473 473
474 debug_printf("*** Writing pounces.\n");
475
476 fprintf(f, "pounce {\n"); 474 fprintf(f, "pounce {\n");
477 475
478 for (pnc = gaim_get_pounces(); pnc != NULL; pnc = pnc->next) { 476 for (pnc = gaim_get_pounces(); pnc != NULL; pnc = pnc->next) {
479 char *str1, *str2, *str3, *str4; 477 char *str1, *str2, *str3, *str4;
480 struct gaim_account *account; 478 struct gaim_account *account;
791 if (strcmp(p->option, "user")==0 || 789 if (strcmp(p->option, "user")==0 ||
792 strcmp(p->option, "current_user")==0) { 790 strcmp(p->option, "current_user")==0) {
793 if((account=gaimrc_read_user(f))!=NULL) 791 if((account=gaimrc_read_user(f))!=NULL)
794 gaim_accounts = g_slist_append(gaim_accounts, account); 792 gaim_accounts = g_slist_append(gaim_accounts, account);
795 else { 793 else {
796 debug_printf("Error reading in users from .gaimrc\n"); 794 gaim_debug(GAIM_DEBUG_ERROR, "gaimrc",
795 "Error reading in users from .gaimrc\n");
797 return; 796 return;
798 } 797 }
799 } 798 }
800 } 799 }
801 } 800 }
1150 1149
1151 host[0] = '\0'; 1150 host[0] = '\0';
1152 user[0] = '\0'; 1151 user[0] = '\0';
1153 pass[0] = '\0'; 1152 pass[0] = '\0';
1154 1153
1155 debug_printf("gaimrc_parse_proxy_uri(%s)\n", proxy); 1154 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
1155 "gaimrc_parse_proxy_uri(%s)\n", proxy);
1156 1156
1157 if ((c = strchr(proxy, ':')) == NULL) 1157 if ((c = strchr(proxy, ':')) == NULL)
1158 { 1158 {
1159 debug_printf("no uri detected\n"); 1159 gaim_debug(GAIM_DEBUG_ERROR, "gaimrc",
1160 "No URI detected.\n");
1160 /* No URI detected. */ 1161 /* No URI detected. */
1161 return FALSE; 1162 return FALSE;
1162 } 1163 }
1163 1164
1164 len = c - proxy; 1165 len = c - proxy;
1166 if (!strncmp(proxy, "http://", len + 3)) 1167 if (!strncmp(proxy, "http://", len + 3))
1167 global_proxy_info.proxytype = PROXY_HTTP; 1168 global_proxy_info.proxytype = PROXY_HTTP;
1168 else 1169 else
1169 return FALSE; 1170 return FALSE;
1170 1171
1171 debug_printf("found http proxy\n"); 1172 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "Found HTTP proxy.\n");
1172 /* Get past "://" */ 1173 /* Get past "://" */
1173 c += 3; 1174 c += 3;
1174 1175
1175 debug_printf("looking at %s\n", c); 1176 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "Looking at %s\n", c);
1176 1177
1177 for (;;) 1178 for (;;)
1178 { 1179 {
1179 *buffer = '\0'; 1180 *buffer = '\0';
1180 d = buffer; 1181 d = buffer;
1232 else 1233 else
1233 *global_proxy_info.proxypass = '\0'; 1234 *global_proxy_info.proxypass = '\0';
1234 1235
1235 global_proxy_info.proxyport = port; 1236 global_proxy_info.proxyport = port;
1236 1237
1237 debug_printf("host '%s'\nuser '%s'\npassword '%s'\nport %d\n", 1238 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
1238 global_proxy_info.proxyhost, global_proxy_info.proxyuser, 1239 "Host: '%s', User: '%s', Password: '%s', Port: %d\n",
1239 global_proxy_info.proxypass, global_proxy_info.proxyport); 1240 global_proxy_info.proxyhost, global_proxy_info.proxyuser,
1241 global_proxy_info.proxypass, global_proxy_info.proxyport);
1240 1242
1241 return TRUE; 1243 return TRUE;
1242 } 1244 }
1243 1245
1244 static void gaimrc_read_proxy(FILE *f) 1246 static void gaimrc_read_proxy(FILE *f)
1247 struct parse parse_buffer; 1249 struct parse parse_buffer;
1248 struct parse *p; 1250 struct parse *p;
1249 1251
1250 buf[0] = 0; 1252 buf[0] = 0;
1251 global_proxy_info.proxyhost[0] = 0; 1253 global_proxy_info.proxyhost[0] = 0;
1252 debug_printf("gaimrc_read_proxy\n"); 1254 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "gaimrc_read_proxy\n");
1253 1255
1254 while (buf[0] != '}') { 1256 while (buf[0] != '}') {
1255 if (buf[0] == '#') 1257 if (buf[0] == '#')
1256 continue; 1258 continue;
1257 1259
1261 p = parse_line(buf, &parse_buffer); 1263 p = parse_line(buf, &parse_buffer);
1262 1264
1263 if (!strcmp(p->option, "host")) { 1265 if (!strcmp(p->option, "host")) {
1264 g_snprintf(global_proxy_info.proxyhost, 1266 g_snprintf(global_proxy_info.proxyhost,
1265 sizeof(global_proxy_info.proxyhost), "%s", p->value[0]); 1267 sizeof(global_proxy_info.proxyhost), "%s", p->value[0]);
1266 debug_printf("set proxyhost %s\n", global_proxy_info.proxyhost); 1268 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
1269 "Set proxyhost %s\n", global_proxy_info.proxyhost);
1267 } else if (!strcmp(p->option, "port")) { 1270 } else if (!strcmp(p->option, "port")) {
1268 global_proxy_info.proxyport = atoi(p->value[0]); 1271 global_proxy_info.proxyport = atoi(p->value[0]);
1269 } else if (!strcmp(p->option, "type")) { 1272 } else if (!strcmp(p->option, "type")) {
1270 global_proxy_info.proxytype = atoi(p->value[0]); 1273 global_proxy_info.proxytype = atoi(p->value[0]);
1271 } else if (!strcmp(p->option, "user")) { 1274 } else if (!strcmp(p->option, "user")) {
1457 void load_prefs() 1460 void load_prefs()
1458 { 1461 {
1459 FILE *f; 1462 FILE *f;
1460 char buf[1024]; 1463 char buf[1024];
1461 int ver = 0; 1464 int ver = 0;
1462 debug_printf("load_prefs\n"); 1465
1466 gaim_debug(GAIM_DEBUG_INFO, "gaimrc", "Loading preferences.\n");
1463 1467
1464 if (is_saving_prefs) { 1468 if (is_saving_prefs) {
1465 request_load_prefs = 1; 1469 request_load_prefs = 1;
1466 debug_printf("currently saving, will request load\n"); 1470 gaim_debug(GAIM_DEBUG_INFO, "gaimrc",
1471 "Currently saving. Will request load.\n");
1467 return; 1472 return;
1468 } 1473 }
1469 1474
1470 if (opt_rcfile_arg) 1475 if (opt_rcfile_arg)
1471 g_snprintf(buf, sizeof(buf), "%s", opt_rcfile_arg); 1476 g_snprintf(buf, sizeof(buf), "%s", opt_rcfile_arg);
1476 return; 1481 return;
1477 } 1482 }
1478 1483
1479 if ((f = fopen(buf, "r"))) { 1484 if ((f = fopen(buf, "r"))) {
1480 is_loading_prefs = 1; 1485 is_loading_prefs = 1;
1481 debug_printf("start load_prefs\n"); 1486 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "start load_prefs\n");
1482 fgets(buf, sizeof(buf), f); 1487 fgets(buf, sizeof(buf), f);
1483 sscanf(buf, "# .gaimrc v%d", &ver); 1488 sscanf(buf, "# .gaimrc v%d", &ver);
1484 if ((ver <= 3) || (buf[0] != '#')) 1489 if ((ver <= 3) || (buf[0] != '#'))
1485 set_defaults(); 1490 set_defaults();
1486 1491
1487 while (!feof(f)) { 1492 while (!feof(f)) {
1488 int tag = gaimrc_parse_tag(f); 1493 int tag = gaimrc_parse_tag(f);
1489 debug_printf("starting read tag %d\n", tag); 1494 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
1495 "starting read tag %d\n", tag);
1490 switch (tag) { 1496 switch (tag) {
1491 case -1: 1497 case -1:
1492 /* Let the loop end, EOF */ 1498 /* Let the loop end, EOF */
1493 break; 1499 break;
1494 case 0: 1500 case 0:
1515 break; 1521 break;
1516 default: 1522 default:
1517 /* NOOP */ 1523 /* NOOP */
1518 break; 1524 break;
1519 } 1525 }
1520 debug_printf("ending read tag %d\n", tag); 1526 gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
1527 "ending read tag %d\n", tag);
1521 } 1528 }
1522 fclose(f); 1529 fclose(f);
1523 is_loading_prefs = 0; 1530 is_loading_prefs = 0;
1524 debug_printf("end load_prefs\n"); 1531 gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "end load_prefs\n");
1525 if (request_save_prefs) { 1532 if (request_save_prefs) {
1526 debug_printf("saving prefs on request\n"); 1533 gaim_debug(GAIM_DEBUG_INFO, "gaimrc",
1534 "Saving preferences on request\n");
1527 save_prefs(); 1535 save_prefs();
1528 request_save_prefs = 0; 1536 request_save_prefs = 0;
1529 } 1537 }
1530 } else if (opt_rcfile_arg) { 1538 } else if (opt_rcfile_arg) {
1531 g_snprintf(buf, sizeof(buf), _("Could not open config file %s."), opt_rcfile_arg); 1539 g_snprintf(buf, sizeof(buf), _("Could not open config file %s."), opt_rcfile_arg);
1543 { 1551 {
1544 FILE *f; 1552 FILE *f;
1545 gchar *filename; 1553 gchar *filename;
1546 gchar *filename_temp; 1554 gchar *filename_temp;
1547 1555
1548 debug_printf("enter save_prefs\n"); 1556 gaim_debug(GAIM_DEBUG_INFO, "gaimrc", "Entering save_prefs\n");
1549 if (!prefs_initial_load) 1557 if (!prefs_initial_load)
1550 return; 1558 return;
1551 1559
1552 if (is_loading_prefs) { 1560 if (is_loading_prefs) {
1553 request_save_prefs = 1; 1561 request_save_prefs = 1;
1554 debug_printf("currently loading, will request save\n"); 1562 gaim_debug(GAIM_DEBUG_INFO, "gaimrc",
1563 "Currently loading. Will request save.\n");
1555 return; 1564 return;
1556 } 1565 }
1557 1566
1558 if (opt_rcfile_arg) 1567 if (opt_rcfile_arg)
1559 filename = g_build_filename(opt_rcfile_arg, NULL); 1568 filename = g_build_filename(opt_rcfile_arg, NULL);
1577 gaimrc_write_plugins(f); 1586 gaimrc_write_plugins(f);
1578 1587
1579 gaimrc_write_proxy(f); 1588 gaimrc_write_proxy(f);
1580 fclose(f); 1589 fclose(f);
1581 if (rename(filename_temp, filename) < 0) 1590 if (rename(filename_temp, filename) < 0)
1582 debug_printf("error renaming %s to %s\n", filename_temp, filename); 1591 gaim_debug(GAIM_DEBUG_ERROR, "gaimrc",
1592 "Error renaming %s to %s\n", filename_temp, filename);
1583 is_saving_prefs = 0; 1593 is_saving_prefs = 0;
1584 } else 1594 } else
1585 debug_printf("error opening %s\n", filename_temp); 1595 gaim_debug(GAIM_DEBUG_ERROR, "gaimrc",
1596 "Error opening %s\n", filename_temp);
1586 1597
1587 if (request_load_prefs) { 1598 if (request_load_prefs) {
1588 debug_printf("loading prefs on request\n"); 1599 gaim_debug(GAIM_DEBUG_INFO, "gaimrc",
1600 "Loading preferences on request.\n");
1589 load_prefs(); 1601 load_prefs();
1590 request_load_prefs = 0; 1602 request_load_prefs = 0;
1591 } 1603 }
1592 1604
1593 g_free(filename); 1605 g_free(filename);
1594 g_free(filename_temp); 1606 g_free(filename_temp);
1595 debug_printf("exit save_prefs\n"); 1607
1608 gaim_debug(GAIM_DEBUG_INFO, "gaimrc", "Exiting save_prefs\n");
1596 } 1609 }
1597 1610
1598 1611
1599 /* This function is called by g_slist_insert_sorted to compare the item 1612 /* This function is called by g_slist_insert_sorted to compare the item
1600 * being compared to the rest of the items on the list. 1613 * being compared to the rest of the items on the list.
1617 { 1630 {
1618 GList *l; 1631 GList *l;
1619 struct pounce_placeholder *ph; 1632 struct pounce_placeholder *ph;
1620 struct gaim_pounce *pounce; 1633 struct gaim_pounce *pounce;
1621 struct gaim_account *account; 1634 struct gaim_account *account;
1622
1623 debug_printf("*** Loading pounces...\n");
1624 1635
1625 for (l = buddy_pounces; l != NULL; l = l->next) { 1636 for (l = buddy_pounces; l != NULL; l = l->next) {
1626 GaimPounceEvent events = GAIM_POUNCE_NONE; 1637 GaimPounceEvent events = GAIM_POUNCE_NONE;
1627 GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE; 1638 GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE;
1628 ph = (struct pounce_placeholder *)l->data; 1639 ph = (struct pounce_placeholder *)l->data;