comparison src/protocols/toc/toc.c @ 6500:8af14f114730

[gaim-migrate @ 7015] Fix a bug where messages containing smilies and other characters that require escaping would not be sent over TOC. My bad. Changed some spaces to tabs in toc.c committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 19 Aug 2003 04:11:40 +0000
parents 5ced8e111473
children 7c14b35bc984
comparison
equal deleted inserted replaced
6499:17a9cdac508e 6500:8af14f114730
69 #define B_ICON_UID "09461346-4C7F-11D1-8222-444553540000" 69 #define B_ICON_UID "09461346-4C7F-11D1-8222-444553540000"
70 #define STOCKS_UID "09461347-4C7F-11D1-8222-444553540000" 70 #define STOCKS_UID "09461347-4C7F-11D1-8222-444553540000"
71 #define FILE_GET_UID "09461348-4C7F-11D1-8222-444553540000" 71 #define FILE_GET_UID "09461348-4C7F-11D1-8222-444553540000"
72 #define GAMES_UID "0946134a-4C7F-11D1-8222-444553540000" 72 #define GAMES_UID "0946134a-4C7F-11D1-8222-444553540000"
73 73
74 #define UC_AOL 0x02 74 #define UC_AOL 0x02
75 #define UC_ADMIN 0x04 75 #define UC_ADMIN 0x04
76 #define UC_UNCONFIRMED 0x08 76 #define UC_UNCONFIRMED 0x08
77 #define UC_NORMAL 0x10 77 #define UC_NORMAL 0x10
78 #define UC_WIRELESS 0x20 78 #define UC_WIRELESS 0x20
79 79
80 struct ft_request { 80 struct ft_request {
81 GaimConnection *gc; 81 GaimConnection *gc;
82 char *user; 82 char *user;
83 char UID[2048]; 83 char UID[2048];
84 char *cookie; 84 char *cookie;
85 char *ip; 85 char *ip;
86 int port; 86 int port;
87 char *message; 87 char *message;
88 char *filename; 88 char *filename;
89 int files; 89 int files;
90 int size; 90 int size;
91 }; 91 };
92 92
93 struct buddy_icon { 93 struct buddy_icon {
94 guint32 hash; 94 guint32 hash;
95 guint32 len; 95 guint32 len;
131 /* The following were added for win32 port - Herman */ 131 /* The following were added for win32 port - Herman */
132 132
133 int toc_write(int fd, const void *buffer, int len) 133 int toc_write(int fd, const void *buffer, int len)
134 { 134 {
135 #ifndef _WIN32 135 #ifndef _WIN32
136 return write(fd, buffer, len); 136 return write(fd, buffer, len);
137 #else 137 #else
138 return send(fd, buffer, len, 0); 138 return send(fd, buffer, len, 0);
139 #endif 139 #endif
140 } 140 }
141 141
142 int toc_read(int fd, void *buffer, int size) 142 int toc_read(int fd, void *buffer, int size)
143 { 143 {
144 #ifndef _WIN32 144 #ifndef _WIN32
145 return read(fd, buffer, size); 145 return read(fd, buffer, size);
146 #else 146 #else
147 return recv(fd, buffer, size, 0); 147 return recv(fd, buffer, size, 0);
148 #endif 148 #endif
149 } 149 }
150 150
151 int toc_soc_close( int fd ) 151 int toc_soc_close( int fd )
152 { 152 {
153 #ifndef _WIN32 153 #ifndef _WIN32
154 return close(fd); 154 return close(fd);
155 #else 155 #else
156 return closesocket(fd); 156 return closesocket(fd);
157 #endif 157 #endif
158 } 158 }
159 159
160 160
161 /* ok. this function used to take username/password, and return 0 on success. 161 /* ok. this function used to take username/password, and return 0 on success.
397 * so we just return here like everything went through fine */ 397 * so we just return here like everything went through fine */
398 return 0; 398 return 0;
399 399
400 if (olen < 0) { 400 if (olen < 0) {
401 escaped = escape_message(buf); 401 escaped = escape_message(buf);
402 len = strlen(buf); 402 len = strlen(escaped);
403 } else { 403 } else {
404 escaped = g_memdup(buf, olen); 404 escaped = g_memdup(buf, olen);
405 len = olen; 405 len = olen;
406 } 406 }
407 407
505 { 505 {
506 int no = atoi(strtok(NULL, ":")); 506 int no = atoi(strtok(NULL, ":"));
507 char *w = strtok(NULL, ":"); 507 char *w = strtok(NULL, ":");
508 static char buf[256]; 508 static char buf[256];
509 509
510 switch(no) { 510 switch(no) {
511 case 69: 511 case 69:
512 g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); 512 g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w);
513 break; 513 break;
514 case 169: 514 case 169:
515 g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); 515 g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w);
516 break; 516 break;
517 case 269: 517 case 269:
518 g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); 518 g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w);
519 break; 519 break;
520 case 901: 520 case 901:
521 g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); 521 g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w);
522 break; 522 break;
523 case 902: 523 case 902:
524 g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); 524 g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w);
525 break; 525 break;
526 case 903: 526 case 903:
527 g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); 527 g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit."));
528 break; 528 break;
529 case 950: 529 case 950:
530 g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); 530 g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w);
531 break; 531 break;
532 case 960: 532 case 960:
533 g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); 533 g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w);
534 break; 534 break;
535 case 961: 535 case 961:
536 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); 536 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w);
537 break; 537 break;
538 case 962: 538 case 962:
539 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); 539 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w);
540 break; 540 break;
541 case 970: 541 case 970:
542 g_snprintf(buf, sizeof(buf), _("Failure.")); 542 g_snprintf(buf, sizeof(buf), _("Failure."));
543 break; 543 break;
544 case 971: 544 case 971:
545 g_snprintf(buf, sizeof(buf), _("Too many matches.")); 545 g_snprintf(buf, sizeof(buf), _("Too many matches."));
546 break; 546 break;
547 case 972: 547 case 972:
548 g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); 548 g_snprintf(buf, sizeof(buf), _("Need more qualifiers."));
549 break; 549 break;
550 case 973: 550 case 973:
551 g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); 551 g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable."));
552 break; 552 break;
553 case 974: 553 case 974:
554 g_snprintf(buf, sizeof(buf), _("Email lookup restricted.")); 554 g_snprintf(buf, sizeof(buf), _("Email lookup restricted."));
555 break; 555 break;
556 case 975: 556 case 975:
557 g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); 557 g_snprintf(buf, sizeof(buf), _("Keyword ignored."));
558 break; 558 break;
559 case 976: 559 case 976:
560 g_snprintf(buf, sizeof(buf), _("No keywords.")); 560 g_snprintf(buf, sizeof(buf), _("No keywords."));
561 break; 561 break;
562 case 977: 562 case 977:
563 g_snprintf(buf, sizeof(buf), _("User has no directory information.")); 563 g_snprintf(buf, sizeof(buf), _("User has no directory information."));
564 /* g_snprintf(buf, sizeof(buf), _("Language not supported.")); */ 564 /* g_snprintf(buf, sizeof(buf), _("Language not supported.")); */
565 break; 565 break;
566 case 978: 566 case 978:
567 g_snprintf(buf, sizeof(buf), _("Country not supported.")); 567 g_snprintf(buf, sizeof(buf), _("Country not supported."));
568 break; 568 break;
569 case 979: 569 case 979:
570 g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); 570 g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w);
571 break; 571 break;
572 case 980: 572 case 980:
573 g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); 573 g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password."));
574 break; 574 break;
575 case 981: 575 case 981:
576 g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); 576 g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable."));
577 break; 577 break;
578 case 982: 578 case 982:
579 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); 579 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in."));
580 break; 580 break;
581 case 983: 581 case 983:
582 g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); 582 g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
583 break; 583 break;
584 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); 584 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w);
585 break; 585 break;
586 default: 586 default:
587 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w); 587 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w);
588 } 588 }
589 589
590 return buf; 590 return buf;
591 } 591 }
592 592
593 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) 593 static void toc_callback(gpointer data, gint source, GaimInputCondition condition)
594 { 594 {
595 GaimConnection *gc = (GaimConnection *)data; 595 GaimConnection *gc = (GaimConnection *)data;
1060 1060
1061 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, int len, int flags) 1061 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, int len, int flags)
1062 { 1062 {
1063 char *buf1, *buf2; 1063 char *buf1, *buf2;
1064 1064
1065 gaim_debug(GAIM_DEBUG_ERROR, "xxx", "1 - Sending message %s\n", message);
1065 buf1 = escape_text(message); 1066 buf1 = escape_text(message);
1066 if (strlen(buf1) + 52 > MSG_LEN) { 1067 if (strlen(buf1) + 52 > MSG_LEN) {
1067 g_free(buf1); 1068 g_free(buf1);
1068 return -E2BIG; 1069 return -E2BIG;
1069 } 1070 }
1070 1071
1072 gaim_debug(GAIM_DEBUG_ERROR, "xxx", "1 - Sending message %s\n", buf1);
1071 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", normalize(name), buf1, 1073 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", normalize(name), buf1,
1072 ((flags & IM_FLAG_AWAY) ? " auto" : "")); 1074 ((flags & IM_FLAG_AWAY) ? " auto" : ""));
1073 g_free(buf1); 1075 g_free(buf1);
1076 gaim_debug(GAIM_DEBUG_ERROR, "xxx", "1 - Sending message %s\n", buf2);
1074 sflap_send(gc, buf2, -1, TYPE_DATA); 1077 sflap_send(gc, buf2, -1, TYPE_DATA);
1075 g_free(buf2); 1078 g_free(buf2);
1076 1079
1077 return 1; 1080 return 1;
1078 } 1081 }
2028 int index = 0; 2031 int index = 0;
2029 while ((index < 4) && (size > 1024)) { 2032 while ((index < 4) && (size > 1024)) {
2030 size /= 1024; 2033 size /= 1024;
2031 index++; 2034 index++;
2032 } 2035 }
2033 g_snprintf(buf, sizeof(buf), 2036 g_snprintf(buf, sizeof(buf),
2034 ngettext( 2037 ngettext(
2035 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", 2038 "%s requests %s to accept %d file: %s (%.2f %s)%s%s",
2036 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", 2039 "%s requests %s to accept %d files: %s (%.2f %s)%s%s",
2037 ft->files), 2040 ft->files),
2038 ft->user, gaim_account_get_username(ft->gc->account), ft->files, 2041 ft->user, gaim_account_get_username(ft->gc->account), ft->files,