Mercurial > pidgin.yaz
comparison src/protocols/irc/irc.c @ 4221:9e2336d5bdee
[gaim-migrate @ 4465]
Nicola's Lichtmaier (niqueco) added _() to irc.c and made a massive switch statement a simple array return
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 07 Jan 2003 14:25:20 +0000 |
parents | 511c2b63caa4 |
children | fc909686bbc1 |
comparison
equal
deleted
inserted
replaced
4220:0cff8ec38935 | 4221:9e2336d5bdee |
---|---|
309 } | 309 } |
310 w++; | 310 w++; |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 static char * | 314 static const char *irc_colors[] = { |
315 int_to_col(int c) | 315 "#000000", "#ffffff", "#000066", "#006600", |
316 { | 316 "#ff0000", "#660000", "#660066", "#666600", |
317 switch(c) { | 317 "#cccc00", "#33cc33", "#00acac", "#00ccac", |
318 case 1: | 318 "#0000ff", "#cc00cc", "#666666", "#00ccac" |
319 return "#ffffff"; | 319 }; |
320 case 2: | 320 |
321 return "#000066"; | 321 #define int_to_col(c) (irc_colors[(((c)<0 || (c)> 15)?0:c)]) |
322 case 3: | |
323 return "#006600"; | |
324 case 4: | |
325 return "#ff0000"; | |
326 case 5: | |
327 return "#660000"; | |
328 case 6: | |
329 return "#660066"; | |
330 case 7: | |
331 return "#666600"; | |
332 case 8: | |
333 return "#cccc00"; | |
334 case 9: | |
335 return "#33cc33"; | |
336 case 10: | |
337 return "#00acac"; | |
338 case 11: | |
339 return "#00ccac"; | |
340 case 12: | |
341 return "#0000ff"; | |
342 case 13: | |
343 return "#cc00cc"; | |
344 case 14: | |
345 return "#666666"; | |
346 case 15: | |
347 return "#00ccac"; | |
348 default: | |
349 return "#000000"; | |
350 } | |
351 } | |
352 | 322 |
353 static GString * | 323 static GString * |
354 encode_html(char *msg) | 324 encode_html(char *msg) |
355 { | 325 { |
356 GString *str = g_string_new(""); | 326 GString *str = g_string_new(""); |
603 struct dcc_chat *chat = data; | 573 struct dcc_chat *chat = data; |
604 struct conversation *convo = new_conversation (chat->nick); | 574 struct conversation *convo = new_conversation (chat->nick); |
605 char buf[IRC_BUF_LEN]; | 575 char buf[IRC_BUF_LEN]; |
606 chat->fd = source; | 576 chat->fd = source; |
607 g_snprintf (buf, sizeof buf, | 577 g_snprintf (buf, sizeof buf, |
608 "DCC Chat with %s established", | 578 _("DCC Chat with %s established"), |
609 chat->nick); | 579 chat->nick); |
610 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | 580 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, |
611 time ((time_t) NULL), -1); | 581 time ((time_t) NULL), -1); |
612 debug_printf ("Chat with %s established\n", chat->nick); | 582 debug_printf ("Chat with %s established\n", chat->nick); |
613 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | 583 dcc_chat_list = g_slist_append (dcc_chat_list, chat); |
778 { | 748 { |
779 struct conversation *c = irc_find_chat(gc, room); | 749 struct conversation *c = irc_find_chat(gc, room); |
780 char buf[IRC_BUF_LEN]; | 750 char buf[IRC_BUF_LEN]; |
781 char *nick = g_strndup(who, strchr(who, '!') - who); | 751 char *nick = g_strndup(who, strchr(who, '!') - who); |
782 | 752 |
783 g_snprintf(buf, sizeof(buf), "-:- mode/%s [%c%c %s] by %s", | 753 g_snprintf(buf, sizeof(buf), _("-:- mode/%s [%c%c %s] by %s"), |
784 room, sign, mode, strlen(argstr) ? argstr : "", | 754 room, sign, mode, strlen(argstr) ? argstr : "", |
785 nick); | 755 nick); |
786 g_free(nick); | 756 g_free(nick); |
787 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL), -1); | 757 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL), -1); |
788 } | 758 } |
2114 c = irc_find_chat(gc, who); | 2084 c = irc_find_chat(gc, who); |
2115 } else { | 2085 } else { |
2116 c = find_conversation(who); | 2086 c = find_conversation(who); |
2117 } | 2087 } |
2118 if (c) { | 2088 if (c) { |
2119 write_to_conv(c, "<I>Requesting DCC CHAT</I>", | 2089 write_to_conv(c, _("<I>Requesting DCC CHAT</I>"), |
2120 WFLAG_SYSTEM, NULL, | 2090 WFLAG_SYSTEM, NULL, |
2121 time(NULL), -1); | 2091 time(NULL), -1); |
2122 } | 2092 } |
2123 } | 2093 } |
2124 } else if (!g_strcasecmp(pdibuf, "HELP")) { | 2094 } else if (!g_strcasecmp(pdibuf, "HELP")) { |
2131 if (!c) { | 2101 if (!c) { |
2132 g_free(what); | 2102 g_free(what); |
2133 return -EINVAL; | 2103 return -EINVAL; |
2134 } | 2104 } |
2135 if (!g_strcasecmp(word[2], "OPER")) { | 2105 if (!g_strcasecmp(word[2], "OPER")) { |
2136 write_to_conv(c, "<B>Operator commands:<BR>" | 2106 write_to_conv(c, _("<B>Operator commands:<BR>" |
2137 "REHASH RESTART</B>", | 2107 "REHASH RESTART</B>"), |
2138 WFLAG_NOLOG, NULL, time(NULL), -1); | 2108 WFLAG_NOLOG, NULL, time(NULL), -1); |
2139 } else if (!g_strcasecmp(word[2], "CTCP")) { | 2109 } else if (!g_strcasecmp(word[2], "CTCP")) { |
2140 write_to_conv(c, "<B>CTCP commands:<BR>" | 2110 write_to_conv(c, _("<B>CTCP commands:<BR>" |
2141 "CLIENTINFO <nick><BR>" | 2111 "CLIENTINFO <nick><BR>" |
2142 "USERINFO <nick><BR>" | 2112 "USERINFO <nick><BR>" |
2143 "VERSION <nick><BR>" | 2113 "VERSION <nick><BR>" |
2144 "PING <nick></B><BR>", | 2114 "PING <nick></B><BR>"), |
2145 WFLAG_NOLOG, NULL, time(NULL), -1); | 2115 WFLAG_NOLOG, NULL, time(NULL), -1); |
2146 } else if (!g_strcasecmp(word[2], "DCC")) { | 2116 } else if (!g_strcasecmp(word[2], "DCC")) { |
2147 write_to_conv(c, "<B>DCC commands:<BR>" | 2117 write_to_conv(c, _("<B>DCC commands:<BR>" |
2148 "CHAT <nick></B>", | 2118 "CHAT <nick></B>"), |
2149 WFLAG_NOLOG, NULL, time(NULL), -1); | 2119 WFLAG_NOLOG, NULL, time(NULL), -1); |
2150 } else { | 2120 } else { |
2151 write_to_conv(c, "<B>Currently supported commands:<BR>" | 2121 write_to_conv(c, _("<B>Currently supported commands:<BR>" |
2152 "WHOIS INVITE NICK LIST<BR>" | 2122 "WHOIS INVITE NICK LIST<BR>" |
2153 "JOIN PART TOPIC KICK<BR>" | 2123 "JOIN PART TOPIC KICK<BR>" |
2154 "OP DEOP VOICE DEVOICE<BR>" | 2124 "OP DEOP VOICE DEVOICE<BR>" |
2155 "ME MSG QUOTE SAY QUIT<BR>" | 2125 "ME MSG QUOTE SAY QUIT<BR>" |
2156 "MODE VERSION W WHOWAS<BR>" | 2126 "MODE VERSION W WHOWAS<BR>" |
2157 "Type /HELP OPER for operator commands<BR>" | 2127 "Type /HELP OPER for operator commands<BR>" |
2158 "Type /HELP CTCP for CTCP commands<BR>" | 2128 "Type /HELP CTCP for CTCP commands<BR>" |
2159 "Type /HELP DCC for DCC commands", | 2129 "Type /HELP DCC for DCC commands"), |
2160 WFLAG_NOLOG, NULL, time(NULL), -1); | 2130 WFLAG_NOLOG, NULL, time(NULL), -1); |
2161 } | 2131 } |
2162 } else { | 2132 } else { |
2163 struct conversation *c = NULL; | 2133 struct conversation *c = NULL; |
2164 if (is_channel(gc, who)) { | 2134 if (is_channel(gc, who)) { |
2168 } | 2138 } |
2169 if (!c) { | 2139 if (!c) { |
2170 g_free(what); | 2140 g_free(what); |
2171 return -EINVAL; | 2141 return -EINVAL; |
2172 } | 2142 } |
2173 write_to_conv(c, "<B>Unknown command</B>", WFLAG_NOLOG, NULL, time(NULL), -1); | 2143 write_to_conv(c, _("<B>Unknown command</B>"), WFLAG_NOLOG, NULL, time(NULL), -1); |
2174 } | 2144 } |
2175 g_free(what); | 2145 g_free(what); |
2176 return 0; | 2146 return 0; |
2177 } | 2147 } |
2178 | 2148 |
2358 return; | 2328 return; |
2359 } | 2329 } |
2360 chat->inpa = | 2330 chat->inpa = |
2361 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat); | 2331 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat); |
2362 convo = new_conversation (chat->nick); | 2332 convo = new_conversation (chat->nick); |
2363 g_snprintf (buf, sizeof buf, "DCC Chat with %s established", | 2333 g_snprintf (buf, sizeof buf, _("DCC Chat with %s established"), |
2364 chat->nick); | 2334 chat->nick); |
2365 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, time ((time_t) NULL), -1); | 2335 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, time ((time_t) NULL), -1); |
2366 debug_printf ("Chat with %s established\n", chat->nick); | 2336 debug_printf ("Chat with %s established\n", chat->nick); |
2367 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | 2337 dcc_chat_list = g_slist_append (dcc_chat_list, chat); |
2368 } | 2338 } |