Mercurial > pidgin
comparison libpurple/protocols/irc/cmds.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 79f25bbe69bf |
children | 6447865b2d08 |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file cmds.c | 2 * @file cmds.c |
3 * | 3 * |
4 * gaim | 4 * purple |
5 * | 5 * |
6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | 6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
32 | 32 |
33 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops); | 33 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops); |
34 | 34 |
35 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 35 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
36 { | 36 { |
37 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, target, irc->account); | 37 PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, target, irc->account); |
38 char *buf; | 38 char *buf; |
39 | 39 |
40 if (!convo) | 40 if (!convo) |
41 return 1; | 41 return 1; |
42 | 42 |
43 buf = g_strdup_printf(_("Unknown command: %s"), cmd); | 43 buf = g_strdup_printf(_("Unknown command: %s"), cmd); |
44 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_IM) | 44 if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_IM) |
45 gaim_conv_im_write(GAIM_CONV_IM(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | 45 purple_conv_im_write(PURPLE_CONV_IM(convo), "", buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
46 else | 46 else |
47 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | 47 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
48 g_free(buf); | 48 g_free(buf); |
49 | 49 |
50 return 1; | 50 return 1; |
51 } | 51 } |
52 | 52 |
53 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 53 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
54 { | 54 { |
55 char *buf, *message; | 55 char *buf, *message; |
56 | 56 |
57 if (args[0] && strcmp(cmd, "back")) { | 57 if (args[0] && strcmp(cmd, "back")) { |
58 message = gaim_markup_strip_html(args[0]); | 58 message = purple_markup_strip_html(args[0]); |
59 gaim_util_chrreplace(message, '\n', ' '); | 59 purple_util_chrreplace(message, '\n', ' '); |
60 buf = irc_format(irc, "v:", "AWAY", message); | 60 buf = irc_format(irc, "v:", "AWAY", message); |
61 g_free(message); | 61 g_free(message); |
62 } else { | 62 } else { |
63 buf = irc_format(irc, "v", "AWAY"); | 63 buf = irc_format(irc, "v", "AWAY"); |
64 } | 64 } |
68 return 0; | 68 return 0; |
69 } | 69 } |
70 | 70 |
71 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 71 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
72 { | 72 { |
73 GaimConnection *gc = gaim_account_get_connection(irc->account); | 73 PurpleConnection *gc = purple_account_get_connection(irc->account); |
74 char *action, *escaped, *dst, **newargs; | 74 char *action, *escaped, *dst, **newargs; |
75 const char *src; | 75 const char *src; |
76 GaimConversation *convo; | 76 PurpleConversation *convo; |
77 | 77 |
78 if (!args || !args[0] || !gc) | 78 if (!args || !args[0] || !gc) |
79 return 0; | 79 return 0; |
80 | 80 |
81 action = g_malloc(strlen(args[0]) + 10); | 81 action = g_malloc(strlen(args[0]) + 10); |
105 irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); | 105 irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); |
106 g_free(newargs[0]); | 106 g_free(newargs[0]); |
107 g_free(newargs[1]); | 107 g_free(newargs[1]); |
108 g_free(newargs); | 108 g_free(newargs); |
109 | 109 |
110 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, target, irc->account); | 110 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, target, irc->account); |
111 if (convo) { | 111 if (convo) { |
112 escaped = g_markup_escape_text(args[0], -1); | 112 escaped = g_markup_escape_text(args[0], -1); |
113 action = g_strdup_printf("/me %s", escaped); | 113 action = g_strdup_printf("/me %s", escaped); |
114 g_free(escaped); | 114 g_free(escaped); |
115 if (action[strlen(action) - 1] == '\n') | 115 if (action[strlen(action) - 1] == '\n') |
116 action[strlen(action) - 1] = '\0'; | 116 action[strlen(action) - 1] = '\0'; |
117 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) | 117 if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) |
118 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), | 118 serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), |
119 gaim_connection_get_display_name(gc), | 119 purple_connection_get_display_name(gc), |
120 0, action, time(NULL)); | 120 0, action, time(NULL)); |
121 else | 121 else |
122 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), | 122 purple_conv_im_write(PURPLE_CONV_IM(convo), purple_connection_get_display_name(gc), |
123 action, 0, time(NULL)); | 123 action, 0, time(NULL)); |
124 g_free(action); | 124 g_free(action); |
125 } | 125 } |
126 | 126 |
127 return 1; | 127 return 1; |
174 } | 174 } |
175 | 175 |
176 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 176 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
177 { | 177 { |
178 char *buf; | 178 char *buf; |
179 GaimConversation *convo; | 179 PurpleConversation *convo; |
180 | 180 |
181 if (!args || !args[0]) | 181 if (!args || !args[0]) |
182 return 0; | 182 return 0; |
183 | 183 |
184 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, target, irc->account); | 184 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, target, irc->account); |
185 if (!convo) | 185 if (!convo) |
186 return 0; | 186 return 0; |
187 | 187 |
188 if (args[1]) | 188 if (args[1]) |
189 buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); | 189 buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); |
195 return 0; | 195 return 0; |
196 } | 196 } |
197 | 197 |
198 int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 198 int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
199 { | 199 { |
200 gaim_roomlist_show_with_account(irc->account); | 200 purple_roomlist_show_with_account(irc->account); |
201 | 201 |
202 return 0; | 202 return 0; |
203 } | 203 } |
204 | 204 |
205 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 205 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
206 { | 206 { |
207 GaimConnection *gc; | 207 PurpleConnection *gc; |
208 char *buf; | 208 char *buf; |
209 | 209 |
210 if (!args) | 210 if (!args) |
211 return 0; | 211 return 0; |
212 | 212 |
220 else | 220 else |
221 return 0; | 221 return 0; |
222 } else if (!strcmp(cmd, "umode")) { | 222 } else if (!strcmp(cmd, "umode")) { |
223 if (!args[0]) | 223 if (!args[0]) |
224 return 0; | 224 return 0; |
225 gc = gaim_account_get_connection(irc->account); | 225 gc = purple_account_get_connection(irc->account); |
226 buf = irc_format(irc, "vnv", "MODE", gaim_connection_get_display_name(gc), args[0]); | 226 buf = irc_format(irc, "vnv", "MODE", purple_connection_get_display_name(gc), args[0]); |
227 } else { | 227 } else { |
228 return 0; | 228 return 0; |
229 } | 229 } |
230 | 230 |
231 irc_send(irc, buf); | 231 irc_send(irc, buf); |
281 mode = "v"; | 281 mode = "v"; |
282 } else if (!strcmp(cmd, "devoice")) { | 282 } else if (!strcmp(cmd, "devoice")) { |
283 sign = "-"; | 283 sign = "-"; |
284 mode = "v"; | 284 mode = "v"; |
285 } else { | 285 } else { |
286 gaim_debug(GAIM_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); | 286 purple_debug(PURPLE_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); |
287 return 0; | 287 return 0; |
288 } | 288 } |
289 | 289 |
290 nicks = g_strsplit(args[0], " ", -1); | 290 nicks = g_strsplit(args[0], " ", -1); |
291 | 291 |
378 { | 378 { |
379 char *buf; | 379 char *buf; |
380 | 380 |
381 if (!irc->quitting) { | 381 if (!irc->quitting) { |
382 /* | 382 /* |
383 * Use gaim_account_get_string(irc->account, "quitmsg", IRC_DEFAULT_QUIT) | 383 * Use purple_account_get_string(irc->account, "quitmsg", IRC_DEFAULT_QUIT) |
384 * and uncomment the appropriate account preference in irc.c if we | 384 * and uncomment the appropriate account preference in irc.c if we |
385 * decide we want custom quit messages. | 385 * decide we want custom quit messages. |
386 */ | 386 */ |
387 buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : IRC_DEFAULT_QUIT); | 387 buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : IRC_DEFAULT_QUIT); |
388 irc_send(irc, buf); | 388 irc_send(irc, buf); |
389 g_free(buf); | 389 g_free(buf); |
390 | 390 |
391 irc->quitting = TRUE; | 391 irc->quitting = TRUE; |
392 | 392 |
393 if (!irc->account->disconnecting) | 393 if (!irc->account->disconnecting) |
394 gaim_account_set_status(irc->account, "offline", TRUE, NULL); | 394 purple_account_set_status(irc->account, "offline", TRUE, NULL); |
395 } | 395 } |
396 | 396 |
397 return 0; | 397 return 0; |
398 } | 398 } |
399 | 399 |
411 return 0; | 411 return 0; |
412 } | 412 } |
413 | 413 |
414 int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 414 int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
415 { | 415 { |
416 GaimConversation *convo; | 416 PurpleConversation *convo; |
417 GaimConnection *gc; | 417 PurpleConnection *gc; |
418 | 418 |
419 if (!args || !args[0]) | 419 if (!args || !args[0]) |
420 return 0; | 420 return 0; |
421 | 421 |
422 convo = gaim_conversation_new(GAIM_CONV_TYPE_IM, irc->account, args[0]); | 422 convo = purple_conversation_new(PURPLE_CONV_TYPE_IM, irc->account, args[0]); |
423 gaim_conversation_present(convo); | 423 purple_conversation_present(convo); |
424 | 424 |
425 if (args[1]) { | 425 if (args[1]) { |
426 gc = gaim_account_get_connection(irc->account); | 426 gc = purple_account_get_connection(irc->account); |
427 irc_cmd_privmsg(irc, cmd, target, args); | 427 irc_cmd_privmsg(irc, cmd, target, args); |
428 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), | 428 purple_conv_im_write(PURPLE_CONV_IM(convo), purple_connection_get_display_name(gc), |
429 args[1], GAIM_MESSAGE_SEND, time(NULL)); | 429 args[1], PURPLE_MESSAGE_SEND, time(NULL)); |
430 } | 430 } |
431 | 431 |
432 return 0; | 432 return 0; |
433 } | 433 } |
434 | 434 |
482 | 482 |
483 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | 483 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
484 { | 484 { |
485 char *buf; | 485 char *buf; |
486 const char *topic; | 486 const char *topic; |
487 GaimConversation *convo; | 487 PurpleConversation *convo; |
488 | 488 |
489 if (!args) | 489 if (!args) |
490 return 0; | 490 return 0; |
491 | 491 |
492 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, target, irc->account); | 492 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, target, irc->account); |
493 if (!convo) | 493 if (!convo) |
494 return 0; | 494 return 0; |
495 | 495 |
496 if (!args[0]) { | 496 if (!args[0]) { |
497 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(convo)); | 497 topic = purple_conv_chat_get_topic (PURPLE_CONV_CHAT(convo)); |
498 | 498 |
499 if (topic) { | 499 if (topic) { |
500 char *tmp, *tmp2; | 500 char *tmp, *tmp2; |
501 tmp = g_markup_escape_text(topic, -1); | 501 tmp = g_markup_escape_text(topic, -1); |
502 tmp2 = gaim_markup_linkify(tmp); | 502 tmp2 = purple_markup_linkify(tmp); |
503 buf = g_strdup_printf(_("current topic is: %s"), tmp2); | 503 buf = g_strdup_printf(_("current topic is: %s"), tmp2); |
504 g_free(tmp); | 504 g_free(tmp); |
505 g_free(tmp2); | 505 g_free(tmp2); |
506 } else | 506 } else |
507 buf = g_strdup(_("No topic is set")); | 507 buf = g_strdup(_("No topic is set")); |
508 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), target, buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | 508 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), target, buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
509 g_free(buf); | 509 g_free(buf); |
510 | 510 |
511 return 0; | 511 return 0; |
512 } | 512 } |
513 | 513 |