Mercurial > pidgin
comparison src/protocols/toc/toc.c @ 7107:9220c7490cd1
[gaim-migrate @ 7672]
This is a big one: normalize() -> gaim_normalize, linkify_text() ->
gaim_markup_linkify(), gaim_get_size_string() -> gaim_str_size_to_units(),
and moved clean_pid() to main.c.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Wed, 01 Oct 2003 06:17:28 +0000 |
| parents | c8bf2da398e3 |
| children | 943085b0ff8b |
comparison
equal
deleted
inserted
replaced
| 7106:db6bd3e794d8 | 7107:9220c7490cd1 |
|---|---|
| 632 if (username[0] >= '0' && username[0] <= '9') | 632 if (username[0] >= '0' && username[0] <= '9') |
| 633 password = g_strndup(gaim_account_get_password(gc->account), 8); | 633 password = g_strndup(gaim_account_get_password(gc->account), 8); |
| 634 else | 634 else |
| 635 password = g_strdup(gaim_account_get_password(gc->account)); | 635 password = g_strdup(gaim_account_get_password(gc->account)); |
| 636 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | 636 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 637 AUTH_HOST, AUTH_PORT, normalize(username), | 637 AUTH_HOST, AUTH_PORT, gaim_normalize(username), |
| 638 roast_password(password), LANGUAGE, REVISION); | 638 roast_password(password), LANGUAGE, REVISION); |
| 639 g_free(password); | 639 g_free(password); |
| 640 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | 640 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 641 gaim_connection_error(gc, _("Disconnected.")); | 641 gaim_connection_error(gc, _("Disconnected.")); |
| 642 return; | 642 return; |
| 700 "got SIGN_ON but not PAUSE!\n"); | 700 "got SIGN_ON but not PAUSE!\n"); |
| 701 else { | 701 else { |
| 702 tdt->state = STATE_ONLINE; | 702 tdt->state = STATE_ONLINE; |
| 703 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | 703 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 704 AUTH_HOST, AUTH_PORT, | 704 AUTH_HOST, AUTH_PORT, |
| 705 normalize(gaim_account_get_username(gc->account)), | 705 gaim_normalize(gaim_account_get_username(gc->account)), |
| 706 roast_password(gaim_account_get_password(gc->account)), | 706 roast_password(gaim_account_get_password(gc->account)), |
| 707 LANGUAGE, REVISION); | 707 LANGUAGE, REVISION); |
| 708 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | 708 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 709 gaim_connection_error(gc, _("Disconnected.")); | 709 gaim_connection_error(gc, _("Disconnected.")); |
| 710 return; | 710 return; |
| 777 time(&time_idle); | 777 time(&time_idle); |
| 778 time_idle -= idle * 60; | 778 time_idle -= idle * 60; |
| 779 } else | 779 } else |
| 780 time_idle = 0; | 780 time_idle = 0; |
| 781 | 781 |
| 782 tmp = g_strdup(normalize(gaim_account_get_username(gc->account))); | 782 tmp = g_strdup(gaim_normalize(gaim_account_get_username(gc->account))); |
| 783 if (!strcmp(tmp, normalize(c))) | 783 if (!strcmp(tmp, gaim_normalize(c))) |
| 784 gaim_connection_set_display_name(gc, c); | 784 gaim_connection_set_display_name(gc, c); |
| 785 g_free(tmp); | 785 g_free(tmp); |
| 786 | 786 |
| 787 serv_got_update(gc, c, logged, evil, signon, time_idle, type); | 787 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
| 788 } else if (!g_ascii_strcasecmp(c, "ERROR")) { | 788 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
| 1065 buf1 = escape_text(message); | 1065 buf1 = escape_text(message); |
| 1066 if (strlen(buf1) + 52 > MSG_LEN) { | 1066 if (strlen(buf1) + 52 > MSG_LEN) { |
| 1067 g_free(buf1); | 1067 g_free(buf1); |
| 1068 return -E2BIG; | 1068 return -E2BIG; |
| 1069 } | 1069 } |
| 1070 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", normalize(name), buf1, | 1070 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(name), buf1, |
| 1071 ((flags & GAIM_IM_AUTO_RESP) ? " auto" : "")); | 1071 ((flags & GAIM_IM_AUTO_RESP) ? " auto" : "")); |
| 1072 g_free(buf1); | 1072 g_free(buf1); |
| 1073 #else | 1073 #else |
| 1074 /* This doesn't work yet. See the comments below for details */ | 1074 /* This doesn't work yet. See the comments below for details */ |
| 1075 buf1 = gaim_strreplace(message, "\"", "\\\""); | 1075 buf1 = gaim_strreplace(message, "\"", "\\\""); |
| 1089 if (strlen(buf1) + 52 > MSG_LEN) { | 1089 if (strlen(buf1) + 52 > MSG_LEN) { |
| 1090 g_free(buf1); | 1090 g_free(buf1); |
| 1091 return -E2BIG; | 1091 return -E2BIG; |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", normalize(name), buf1, | 1094 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(name), buf1, |
| 1095 ((flags & GAIM_IM_AUTO_RESP) ? "auto" : "")); | 1095 ((flags & GAIM_IM_AUTO_RESP) ? "auto" : "")); |
| 1096 g_free(buf1); | 1096 g_free(buf1); |
| 1097 #endif | 1097 #endif |
| 1098 | 1098 |
| 1099 sflap_send(gc, buf2, -1, TYPE_DATA); | 1099 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 static void toc_get_info(GaimConnection *g, const char *name) | 1114 static void toc_get_info(GaimConnection *g, const char *name) |
| 1115 { | 1115 { |
| 1116 char buf[BUF_LEN * 2]; | 1116 char buf[BUF_LEN * 2]; |
| 1117 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | 1117 g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(name)); |
| 1118 sflap_send(g, buf, -1, TYPE_DATA); | 1118 sflap_send(g, buf, -1, TYPE_DATA); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 static void toc_get_dir(GaimConnection *g, const char *name) | 1121 static void toc_get_dir(GaimConnection *g, const char *name) |
| 1122 { | 1122 { |
| 1123 char buf[BUF_LEN * 2]; | 1123 char buf[BUF_LEN * 2]; |
| 1124 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | 1124 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", gaim_normalize(name)); |
| 1125 sflap_send(g, buf, -1, TYPE_DATA); | 1125 sflap_send(g, buf, -1, TYPE_DATA); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, | 1128 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 1129 const char *maiden, const char *city, const char *state, const char *country, int web) | 1129 const char *maiden, const char *city, const char *state, const char *country, int web) |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 static void toc_add_buddy(GaimConnection *g, const char *name, GaimGroup *group) | 1187 static void toc_add_buddy(GaimConnection *g, const char *name, GaimGroup *group) |
| 1188 { | 1188 { |
| 1189 char buf[BUF_LEN * 2]; | 1189 char buf[BUF_LEN * 2]; |
| 1190 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | 1190 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(name)); |
| 1191 sflap_send(g, buf, -1, TYPE_DATA); | 1191 sflap_send(g, buf, -1, TYPE_DATA); |
| 1192 toc_set_config(g); | 1192 toc_set_config(g); |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 static void toc_add_buddies(GaimConnection *g, GList *buddies) | 1195 static void toc_add_buddies(GaimConnection *g, GList *buddies) |
| 1197 char buf[BUF_LEN * 2]; | 1197 char buf[BUF_LEN * 2]; |
| 1198 int n; | 1198 int n; |
| 1199 | 1199 |
| 1200 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1200 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1201 while (buddies) { | 1201 while (buddies) { |
| 1202 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { | 1202 if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { |
| 1203 sflap_send(g, buf, -1, TYPE_DATA); | 1203 sflap_send(g, buf, -1, TYPE_DATA); |
| 1204 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1204 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1205 } | 1205 } |
| 1206 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | 1206 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); |
| 1207 buddies = buddies->next; | 1207 buddies = buddies->next; |
| 1208 } | 1208 } |
| 1209 sflap_send(g, buf, -1, TYPE_DATA); | 1209 sflap_send(g, buf, -1, TYPE_DATA); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 static void toc_remove_buddy(GaimConnection *g, const char *name, const char *group) | 1212 static void toc_remove_buddy(GaimConnection *g, const char *name, const char *group) |
| 1213 { | 1213 { |
| 1214 char buf[BUF_LEN * 2]; | 1214 char buf[BUF_LEN * 2]; |
| 1215 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | 1215 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(name)); |
| 1216 sflap_send(g, buf, -1, TYPE_DATA); | 1216 sflap_send(g, buf, -1, TYPE_DATA); |
| 1217 toc_set_config(g); | 1217 toc_set_config(g); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) | 1220 static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) |
| 1222 char buf[BUF_LEN * 2]; | 1222 char buf[BUF_LEN * 2]; |
| 1223 int n; | 1223 int n; |
| 1224 | 1224 |
| 1225 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1225 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 1226 while (buddies) { | 1226 while (buddies) { |
| 1227 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { | 1227 if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { |
| 1228 sflap_send(g, buf, -1, TYPE_DATA); | 1228 sflap_send(g, buf, -1, TYPE_DATA); |
| 1229 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1229 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 1230 } | 1230 } |
| 1231 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | 1231 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); |
| 1232 buddies = buddies->next; | 1232 buddies = buddies->next; |
| 1233 } | 1233 } |
| 1234 sflap_send(g, buf, -1, TYPE_DATA); | 1234 sflap_send(g, buf, -1, TYPE_DATA); |
| 1235 toc_set_config(g); | 1235 toc_set_config(g); |
| 1236 } | 1236 } |
| 1291 | 1291 |
| 1292 static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) | 1292 static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) |
| 1293 { | 1293 { |
| 1294 char buf[BUF_LONG]; | 1294 char buf[BUF_LONG]; |
| 1295 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, | 1295 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
| 1296 message ? message : "", normalize(name)); | 1296 message ? message : "", gaim_normalize(name)); |
| 1297 sflap_send(g, buf, -1, TYPE_DATA); | 1297 sflap_send(g, buf, -1, TYPE_DATA); |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 static void toc_chat_leave(GaimConnection *g, int id) | 1300 static void toc_chat_leave(GaimConnection *g, int id) |
| 1301 { | 1301 { |
| 1326 | 1326 |
| 1327 static void toc_chat_whisper(GaimConnection *g, int id, const char *who, const char *message) | 1327 static void toc_chat_whisper(GaimConnection *g, int id, const char *who, const char *message) |
| 1328 { | 1328 { |
| 1329 char *buf1, *buf2; | 1329 char *buf1, *buf2; |
| 1330 buf1 = escape_text(message); | 1330 buf1 = escape_text(message); |
| 1331 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, normalize(who), buf1); | 1331 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(who), buf1); |
| 1332 g_free(buf1); | 1332 g_free(buf1); |
| 1333 sflap_send(g, buf2, -1, TYPE_DATA); | 1333 sflap_send(g, buf2, -1, TYPE_DATA); |
| 1334 g_free(buf2); | 1334 g_free(buf2); |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1409 static void toc_add_permit(GaimConnection *gc, const char *who) | 1409 static void toc_add_permit(GaimConnection *gc, const char *who) |
| 1410 { | 1410 { |
| 1411 char buf2[BUF_LEN * 2]; | 1411 char buf2[BUF_LEN * 2]; |
| 1412 if (gc->account->perm_deny != 3) | 1412 if (gc->account->perm_deny != 3) |
| 1413 return; | 1413 return; |
| 1414 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who)); | 1414 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(who)); |
| 1415 sflap_send(gc, buf2, -1, TYPE_DATA); | 1415 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1416 toc_set_config(gc); | 1416 toc_set_config(gc); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 static void toc_add_deny(GaimConnection *gc, const char *who) | 1419 static void toc_add_deny(GaimConnection *gc, const char *who) |
| 1420 { | 1420 { |
| 1421 char buf2[BUF_LEN * 2]; | 1421 char buf2[BUF_LEN * 2]; |
| 1422 if (gc->account->perm_deny != 4) | 1422 if (gc->account->perm_deny != 4) |
| 1423 return; | 1423 return; |
| 1424 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who)); | 1424 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(who)); |
| 1425 sflap_send(gc, buf2, -1, TYPE_DATA); | 1425 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1426 toc_set_config(gc); | 1426 toc_set_config(gc); |
| 1427 } | 1427 } |
| 1428 | 1428 |
| 1429 static void toc_set_permit_deny(GaimConnection *gc) | 1429 static void toc_set_permit_deny(GaimConnection *gc) |
| 1456 sflap_send(gc, buf2, -1, TYPE_DATA); | 1456 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1457 | 1457 |
| 1458 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1458 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
| 1459 list = gc->account->permit; | 1459 list = gc->account->permit; |
| 1460 while (list) { | 1460 while (list) { |
| 1461 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); | 1461 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); |
| 1462 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | 1462 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1463 sflap_send(gc, buf2, -1, TYPE_DATA); | 1463 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1464 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1464 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
| 1465 } | 1465 } |
| 1466 list = list->next; | 1466 list = list->next; |
| 1474 sflap_send(gc, buf2, -1, TYPE_DATA); | 1474 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1475 | 1475 |
| 1476 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | 1476 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); |
| 1477 list = gc->account->deny; | 1477 list = gc->account->deny; |
| 1478 while (list) { | 1478 while (list) { |
| 1479 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); | 1479 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); |
| 1480 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | 1480 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1481 sflap_send(gc, buf2, -1, TYPE_DATA); | 1481 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1482 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | 1482 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); |
| 1483 } | 1483 } |
| 1484 list = list->next; | 1484 list = list->next; |
