Mercurial > pidgin
comparison src/protocols/toc/toc.c @ 7261:1930e3d00ecd
[gaim-migrate @ 7838]
prpl-specific normalize is back, after my crusade to kill it.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 14 Oct 2003 05:07:39 +0000 |
parents | bf630f7dfdcd |
children | 08c9d0dcf906 |
comparison
equal
deleted
inserted
replaced
7260:49839c4cbb1c | 7261:1930e3d00ecd |
---|---|
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, gaim_normalize(username), | 637 AUTH_HOST, AUTH_PORT, gaim_normalize(gc->account, 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 gaim_normalize(gaim_account_get_username(gc->account)), | 705 gaim_normalize(gc->account, 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(gaim_normalize(gaim_account_get_username(gc->account))); | 782 tmp = g_strdup(gaim_normalize(gc->account, gaim_account_get_username(gc->account))); |
783 if (!strcmp(tmp, gaim_normalize(c))) | 783 if (!strcmp(tmp, gaim_normalize(gc->account, 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", gaim_normalize(name), buf1, | 1070 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(gc->account, name), buf1, |
1071 ((flags & GAIM_CONV_IM_AUTO_RESP) ? " auto" : "")); | 1071 ((flags & GAIM_CONV_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", gaim_normalize(name), buf1, | 1094 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(gc->account, name), buf1, |
1095 ((flags & GAIM_CONV_IM_AUTO_RESP) ? "auto" : "")); | 1095 ((flags & GAIM_CONV_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); |
1109 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); | 1109 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
1110 sflap_send(gc, snd, -1, TYPE_DATA); | 1110 sflap_send(gc, snd, -1, TYPE_DATA); |
1111 g_free(buf); | 1111 g_free(buf); |
1112 } | 1112 } |
1113 | 1113 |
1114 static void toc_get_info(GaimConnection *g, const char *name) | 1114 static void toc_get_info(GaimConnection *gc, 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", gaim_normalize(name)); | 1117 g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(gc->account, name)); |
1118 sflap_send(g, buf, -1, TYPE_DATA); | 1118 sflap_send(gc, 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 *gc, 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", gaim_normalize(name)); | 1124 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", gaim_normalize(gc->account, name)); |
1125 sflap_send(g, buf, -1, TYPE_DATA); | 1125 sflap_send(gc, 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) |
1130 { | 1130 { |
1182 char buf[BUF_LEN * 2]; | 1182 char buf[BUF_LEN * 2]; |
1183 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | 1183 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); |
1184 sflap_send(g, buf, -1, TYPE_DATA); | 1184 sflap_send(g, buf, -1, TYPE_DATA); |
1185 } | 1185 } |
1186 | 1186 |
1187 static void toc_add_buddy(GaimConnection *g, const char *name, GaimGroup *group) | 1187 static void |
1188 toc_add_buddy(GaimConnection *gc, const char *name, GaimGroup *group) | |
1188 { | 1189 { |
1189 char buf[BUF_LEN * 2]; | 1190 char buf[BUF_LEN * 2]; |
1190 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(name)); | 1191 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, name)); |
1191 sflap_send(g, buf, -1, TYPE_DATA); | 1192 sflap_send(gc, buf, -1, TYPE_DATA); |
1192 toc_set_config(g); | 1193 toc_set_config(gc); |
1193 } | 1194 } |
1194 | 1195 |
1195 static void toc_add_buddies(GaimConnection *g, GList *buddies) | 1196 static void toc_add_buddies(GaimConnection *gc, GList *buddies) |
1196 { | 1197 { |
1197 char buf[BUF_LEN * 2]; | 1198 char buf[BUF_LEN * 2]; |
1198 int n; | 1199 int n; |
1199 | 1200 |
1200 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1201 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
1201 while (buddies) { | 1202 while (buddies) { |
1202 if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { | 1203 if (strlen(gaim_normalize(gc->account, buddies->data)) + n + 32 > MSG_LEN) { |
1203 sflap_send(g, buf, -1, TYPE_DATA); | 1204 sflap_send(gc, buf, -1, TYPE_DATA); |
1204 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1205 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
1205 } | 1206 } |
1206 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); | 1207 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddies->data)); |
1207 buddies = buddies->next; | 1208 buddies = buddies->next; |
1208 } | 1209 } |
1209 sflap_send(g, buf, -1, TYPE_DATA); | 1210 sflap_send(gc, buf, -1, TYPE_DATA); |
1210 } | 1211 } |
1211 | 1212 |
1212 static void toc_remove_buddy(GaimConnection *g, const char *name, const char *group) | 1213 static void toc_remove_buddy(GaimConnection *gc, const char *name, const char *group) |
1213 { | 1214 { |
1214 char buf[BUF_LEN * 2]; | 1215 char buf[BUF_LEN * 2]; |
1215 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(name)); | 1216 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, name)); |
1216 sflap_send(g, buf, -1, TYPE_DATA); | 1217 sflap_send(gc, buf, -1, TYPE_DATA); |
1217 toc_set_config(g); | 1218 toc_set_config(gc); |
1218 } | 1219 } |
1219 | 1220 |
1220 static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) | 1221 static void toc_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) |
1221 { | 1222 { |
1222 char buf[BUF_LEN * 2]; | 1223 char buf[BUF_LEN * 2]; |
1223 int n; | 1224 int n; |
1224 | 1225 |
1225 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1226 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
1226 while (buddies) { | 1227 while (buddies) { |
1227 if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { | 1228 if (strlen(gaim_normalize(gc->account, buddies->data)) + n + 32 > MSG_LEN) { |
1228 sflap_send(g, buf, -1, TYPE_DATA); | 1229 sflap_send(gc, buf, -1, TYPE_DATA); |
1229 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1230 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
1230 } | 1231 } |
1231 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); | 1232 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddies->data)); |
1232 buddies = buddies->next; | 1233 buddies = buddies->next; |
1233 } | 1234 } |
1234 sflap_send(g, buf, -1, TYPE_DATA); | 1235 sflap_send(gc, buf, -1, TYPE_DATA); |
1235 toc_set_config(g); | 1236 toc_set_config(gc); |
1236 } | 1237 } |
1237 | 1238 |
1238 static void toc_set_idle(GaimConnection *g, int time) | 1239 static void toc_set_idle(GaimConnection *g, int time) |
1239 { | 1240 { |
1240 char buf[BUF_LEN * 2]; | 1241 char buf[BUF_LEN * 2]; |
1287 } | 1288 } |
1288 | 1289 |
1289 sflap_send(g, buf, -1, TYPE_DATA); | 1290 sflap_send(g, buf, -1, TYPE_DATA); |
1290 } | 1291 } |
1291 | 1292 |
1292 static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) | 1293 static void toc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) |
1293 { | 1294 { |
1294 char buf[BUF_LONG]; | 1295 char buf[BUF_LONG]; |
1295 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, | 1296 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
1296 message ? message : "", gaim_normalize(name)); | 1297 message ? message : "", gaim_normalize(gc->account, name)); |
1297 sflap_send(g, buf, -1, TYPE_DATA); | 1298 sflap_send(gc, buf, -1, TYPE_DATA); |
1298 } | 1299 } |
1299 | 1300 |
1300 static void toc_chat_leave(GaimConnection *g, int id) | 1301 static void toc_chat_leave(GaimConnection *g, int id) |
1301 { | 1302 { |
1302 GSList *bcs = g->buddy_chats; | 1303 GSList *bcs = g->buddy_chats; |
1322 g_snprintf(buf, 255, "toc_chat_leave %d", id); | 1323 g_snprintf(buf, 255, "toc_chat_leave %d", id); |
1323 sflap_send(g, buf, -1, TYPE_DATA); | 1324 sflap_send(g, buf, -1, TYPE_DATA); |
1324 } | 1325 } |
1325 } | 1326 } |
1326 | 1327 |
1327 static void toc_chat_whisper(GaimConnection *g, int id, const char *who, const char *message) | 1328 static void toc_chat_whisper(GaimConnection *gc, int id, const char *who, const char *message) |
1328 { | 1329 { |
1329 char *buf1, *buf2; | 1330 char *buf1, *buf2; |
1330 buf1 = escape_text(message); | 1331 buf1 = escape_text(message); |
1331 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(who), buf1); | 1332 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(gc->account, who), buf1); |
1332 g_free(buf1); | 1333 g_free(buf1); |
1333 sflap_send(g, buf2, -1, TYPE_DATA); | 1334 sflap_send(gc, buf2, -1, TYPE_DATA); |
1334 g_free(buf2); | 1335 g_free(buf2); |
1335 } | 1336 } |
1336 | 1337 |
1337 static int toc_chat_send(GaimConnection *g, int id, const char *message) | 1338 static int toc_chat_send(GaimConnection *g, int id, const char *message) |
1338 { | 1339 { |
1409 static void toc_add_permit(GaimConnection *gc, const char *who) | 1410 static void toc_add_permit(GaimConnection *gc, const char *who) |
1410 { | 1411 { |
1411 char buf2[BUF_LEN * 2]; | 1412 char buf2[BUF_LEN * 2]; |
1412 if (gc->account->perm_deny != 3) | 1413 if (gc->account->perm_deny != 3) |
1413 return; | 1414 return; |
1414 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(who)); | 1415 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(gc->account, who)); |
1415 sflap_send(gc, buf2, -1, TYPE_DATA); | 1416 sflap_send(gc, buf2, -1, TYPE_DATA); |
1416 toc_set_config(gc); | 1417 toc_set_config(gc); |
1417 } | 1418 } |
1418 | 1419 |
1419 static void toc_add_deny(GaimConnection *gc, const char *who) | 1420 static void toc_add_deny(GaimConnection *gc, const char *who) |
1420 { | 1421 { |
1421 char buf2[BUF_LEN * 2]; | 1422 char buf2[BUF_LEN * 2]; |
1422 if (gc->account->perm_deny != 4) | 1423 if (gc->account->perm_deny != 4) |
1423 return; | 1424 return; |
1424 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(who)); | 1425 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(gc->account, who)); |
1425 sflap_send(gc, buf2, -1, TYPE_DATA); | 1426 sflap_send(gc, buf2, -1, TYPE_DATA); |
1426 toc_set_config(gc); | 1427 toc_set_config(gc); |
1427 } | 1428 } |
1428 | 1429 |
1429 static void toc_set_permit_deny(GaimConnection *gc) | 1430 static void toc_set_permit_deny(GaimConnection *gc) |
1456 sflap_send(gc, buf2, -1, TYPE_DATA); | 1457 sflap_send(gc, buf2, -1, TYPE_DATA); |
1457 | 1458 |
1458 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1459 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
1459 list = gc->account->permit; | 1460 list = gc->account->permit; |
1460 while (list) { | 1461 while (list) { |
1461 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); | 1462 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); |
1462 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | 1463 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
1463 sflap_send(gc, buf2, -1, TYPE_DATA); | 1464 sflap_send(gc, buf2, -1, TYPE_DATA); |
1464 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1465 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
1465 } | 1466 } |
1466 list = list->next; | 1467 list = list->next; |
1474 sflap_send(gc, buf2, -1, TYPE_DATA); | 1475 sflap_send(gc, buf2, -1, TYPE_DATA); |
1475 | 1476 |
1476 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | 1477 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); |
1477 list = gc->account->deny; | 1478 list = gc->account->deny; |
1478 while (list) { | 1479 while (list) { |
1479 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); | 1480 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); |
1480 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | 1481 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
1481 sflap_send(gc, buf2, -1, TYPE_DATA); | 1482 sflap_send(gc, buf2, -1, TYPE_DATA); |
1482 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | 1483 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); |
1483 } | 1484 } |
1484 list = list->next; | 1485 list = list->next; |