Thu, 10 Oct 2019 21:14:45 -0400
Use monotonic time for IRC ping messages.
| 6333 | 1 | /** |
| 2 | * @file parse.c | |
| 8351 | 3 | * |
| 15884 | 4 | * purple |
| 6333 | 5 | * |
| 6 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
| 8351 | 7 | * |
| 6333 | 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 | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17409
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6333 | 21 | */ |
| 22 | ||
| 23 | #include "internal.h" | |
| 24 | ||
| 25 | #include "accountopt.h" | |
| 26 | #include "conversation.h" | |
| 27 | #include "notify.h" | |
| 28 | #include "debug.h" | |
| 10258 | 29 | #include "util.h" |
| 9130 | 30 | #include "cmds.h" |
| 6333 | 31 | #include "irc.h" |
| 32 | ||
| 33 | #include <stdio.h> | |
| 34 | #include <stdlib.h> | |
| 35 | #include <ctype.h> | |
| 36 | ||
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
37 | static GSList *cmds = NULL; |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
38 | |
| 6333 | 39 | static char *irc_send_convert(struct irc_conn *irc, const char *string); |
| 40 | static char *irc_recv_convert(struct irc_conn *irc, const char *string); | |
| 41 | ||
| 42 | static void irc_parse_error_cb(struct irc_conn *irc, char *input); | |
| 43 | ||
| 44 | static char *irc_mirc_colors[16] = { | |
| 45 | "white", "black", "blue", "dark green", "red", "brown", "purple", | |
| 46 | "orange", "yellow", "green", "teal", "cyan", "light blue", | |
| 47 | "pink", "grey", "light grey" }; | |
| 48 | ||
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36520
diff
changeset
|
49 | extern PurpleProtocol *_irc_protocol; |
| 14683 | 50 | |
| 6333 | 51 | /*typedef void (*IRCMsgCallback)(struct irc_conn *irc, char *from, char *name, char **args);*/ |
| 52 | static struct _irc_msg { | |
| 53 | char *name; | |
| 54 | char *format; | |
|
35253
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
55 | |
|
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
56 | /** The required parameter count, based on values we use, not protocol |
|
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
57 | * specification. */ |
|
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
58 | int req_cnt; |
|
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
59 | |
| 6333 | 60 | void (*cb)(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 61 | } _irc_msgs[] = { | |
|
35250
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
62 | { "005", "n*", 2, irc_msg_features }, /* Feature list */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
63 | { "251", "n:", 1, irc_msg_luser }, /* Client & Server count */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
64 | { "255", "n:", 1, irc_msg_luser }, /* Client & Server count Mk. II */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
65 | { "301", "nn:", 3, irc_msg_away }, /* User is away */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
66 | { "303", "n:", 2, irc_msg_ison }, /* ISON reply */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
67 | { "311", "nnvvv:", 6, irc_msg_whois }, /* Whois user */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
68 | { "312", "nnv:", 4, irc_msg_whois }, /* Whois server */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
69 | { "313", "nn:", 2, irc_msg_whois }, /* Whois ircop */ |
| 39589 | 70 | { "314", "nnnvv:", 6, irc_msg_whois }, /* Whowas user */ |
| 71 | { "315", "nt:", 0, irc_msg_who }, /* end of WHO channel */ | |
|
35272
d33c29cda7bb
I think 317 actually only requires 3 args. I think the fourth is optional.
Mark Doliner <mark@kingant.net>
parents:
35253
diff
changeset
|
72 | { "317", "nnvv", 3, irc_msg_whois }, /* Whois idle */ |
|
35250
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
73 | { "318", "nt:", 2, irc_msg_endwhois }, /* End of WHOIS */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
74 | { "319", "nn:", 3, irc_msg_whois }, /* Whois channels */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
75 | { "320", "nn:", 2, irc_msg_whois }, /* Whois (fn ident) */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
76 | { "321", "*", 0, irc_msg_list }, /* Start of list */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
77 | { "322", "ncv:", 4, irc_msg_list }, /* List. */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
78 | { "323", ":", 0, irc_msg_list }, /* End of list. */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
79 | { "324", "ncv:", 3, irc_msg_chanmode }, /* Channel modes */ |
| 39589 | 80 | { "330", "nnv:", 4, irc_msg_whois }, /* Whois (fn login) */ |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
81 | { "331", "nc:", 3, irc_msg_topic }, /* No channel topic */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
82 | { "332", "nc:", 3, irc_msg_topic }, /* Channel topic */ |
|
35250
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
83 | { "333", "ncvv", 4, irc_msg_topicinfo }, /* Topic setter stuff */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
84 | { "352", "ncvvvnv:", 8, irc_msg_who }, /* Channel WHO */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
85 | { "353", "nvc:", 4, irc_msg_names }, /* Names list */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
86 | { "366", "nc:", 2, irc_msg_names }, /* End of names */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
87 | { "367", "ncnnv", 3, irc_msg_ban }, /* Ban list */ |
|
6b0e0566af20
IRC: fill required command parameter counts (part 3)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35249
diff
changeset
|
88 | { "368", "nc:", 2, irc_msg_ban }, /* End of ban list */ |
| 39589 | 89 | { "369", "nt:", 2, irc_msg_endwhois }, /* End of WHOWAS */ |
|
35249
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
90 | { "372", "n:", 1, irc_msg_motd }, /* MOTD */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
91 | { "375", "n:", 1, irc_msg_motd }, /* Start MOTD */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
92 | { "376", "n:", 1, irc_msg_motd }, /* End of MOTD */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
93 | { "391", "nv:", 3, irc_msg_time }, /* Time reply */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
94 | { "401", "nt:", 2, irc_msg_nonick }, /* No such nick/chan */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
95 | { "403", "nc:", 2, irc_msg_nochan }, /* No such channel */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
96 | { "404", "nt:", 3, irc_msg_nosend }, /* Cannot send to chan */ |
| 39589 | 97 | { "406", "nt:", 2, irc_msg_nonick }, /* No such nick for WHOWAS */ |
|
35249
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
98 | { "421", "nv:", 2, irc_msg_unknown }, /* Unknown command */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
99 | { "422", "n:", 1, irc_msg_motd }, /* MOTD file missing */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
100 | { "432", "vn:", 0, irc_msg_badnick }, /* Erroneous nickname */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
101 | { "433", "vn:", 2, irc_msg_nickused }, /* Nickname already in use */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
102 | { "437", "nc:", 2, irc_msg_unavailable }, /* Nick/channel is unavailable */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
103 | { "438", "nn:", 3, irc_msg_nochangenick }, /* Nick may not change */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
104 | { "442", "nc:", 3, irc_msg_notinchan }, /* Not in channel */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
105 | { "473", "nc:", 2, irc_msg_inviteonly }, /* Tried to join invite-only */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
106 | { "474", "nc:", 2, irc_msg_banned }, /* Banned from channel */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
107 | { "477", "nc:", 3, irc_msg_regonly }, /* Registration Required */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
108 | { "478", "nct:", 3, irc_msg_banfull }, /* Banlist is full */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
109 | { "482", "nc:", 3, irc_msg_notop }, /* Need to be op to do that */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
110 | { "501", "n:", 2, irc_msg_badmode }, /* Unknown mode flag */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
111 | { "506", "nc:", 3, irc_msg_nosend }, /* Must identify to send */ |
|
5845d9fa7084
IRC: fill required command parameter counts (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35248
diff
changeset
|
112 | { "515", "nc:", 3, irc_msg_regonly }, /* Registration required */ |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
113 | #ifdef HAVE_CYRUS_SASL |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
114 | { "903", "*", 0, irc_msg_authok}, /* SASL auth successful */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
115 | { "904", "*", 0, irc_msg_authtryagain }, /* SASL auth failed, can recover*/ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
116 | { "905", "*", 0, irc_msg_authfail }, /* SASL auth failed */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
117 | { "906", "*", 0, irc_msg_authfail }, /* SASL auth failed */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
118 | { "907", "*", 0, irc_msg_authfail }, /* SASL auth failed */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
119 | { "cap", "vv:", 3, irc_msg_cap }, /* SASL capable */ |
|
38908
86e7c9ca0bcd
irc: handle AUTHENTICATE as a normal command with server prefix
dx <dx@dxzone.com.ar>
parents:
38907
diff
changeset
|
120 | { "authenticate", ":", 1, irc_msg_authenticate }, /* SASL authenticate */ |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
121 | #endif |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
122 | { "invite", "n:", 2, irc_msg_invite }, /* Invited */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
123 | { "join", ":", 1, irc_msg_join }, /* Joined a channel */ |
|
35253
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
124 | { "kick", "cn:", 3, irc_msg_kick }, /* KICK */ |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
125 | { "mode", "tv:", 2, irc_msg_mode }, /* MODE for channel */ |
|
35253
4d9be297d399
Fill in req_cnt for irc_msg_kick and irc_msg_nick.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
126 | { "nick", ":", 1, irc_msg_nick }, /* Nick change */ |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
127 | { "notice", "t:", 2, irc_msg_notice }, /* NOTICE recv */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
128 | { "part", "c:", 1, irc_msg_part }, /* Parted a channel */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
129 | { "ping", ":", 1, irc_msg_ping }, /* Received PING from server */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
130 | { "pong", "v:", 2, irc_msg_pong }, /* Received PONG from server */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
131 | { "privmsg", "t:", 2, irc_msg_privmsg }, /* Received private message */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
132 | { "topic", "c:", 2, irc_msg_topic }, /* TOPIC command */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
133 | { "quit", ":", 1, irc_msg_quit }, /* QUIT notice */ |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35245
diff
changeset
|
134 | { "wallops", ":", 1, irc_msg_wallops }, /* WALLOPS command */ |
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
135 | { NULL, NULL, 0, NULL } |
| 6333 | 136 | }; |
| 137 | ||
| 138 | static struct _irc_user_cmd { | |
| 139 | char *name; | |
| 140 | char *format; | |
| 141 | IRCCmdCallback cb; | |
| 9255 | 142 | char *help; |
| 6333 | 143 | } _irc_cmds[] = { |
| 9255 | 144 | { "action", ":", irc_cmd_ctcp_action, N_("action <action to perform>: Perform an action.") }, |
|
31651
24e136c4c399
Add authserv support to IRC. Need a name to credit tomos with. Fixes #13337.
Tomos Lelong <lelongt@gmail.com>
parents:
31565
diff
changeset
|
145 | { "authserv", ":", irc_cmd_service, N_("authserv: Send a command to authserv") }, |
| 9255 | 146 | { "away", ":", irc_cmd_away, N_("away [message]: Set an away message, or use no message to return from being away.") }, |
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23532
diff
changeset
|
147 | { "ctcp", "t:", irc_cmd_ctcp, N_("ctcp <nick> <msg>: sends ctcp msg to nick.") }, |
| 12013 | 148 | { "chanserv", ":", irc_cmd_service, N_("chanserv: Send a command to chanserv") }, |
| 9258 | 149 | { "deop", ":", irc_cmd_op, N_("deop <nick1> [nick2] ...: Remove channel operator status from someone. You must be a channel operator to do this.") }, |
| 150 | { "devoice", ":", irc_cmd_op, N_("devoice <nick1> [nick2] ...: Remove channel voice status from someone, preventing them from speaking if the channel is moderated (+m). You must be a channel operator to do this.") }, | |
| 151 | { "invite", ":", irc_cmd_invite, N_("invite <nick> [room]: Invite someone to join you in the specified channel, or the current channel.") }, | |
| 9266 | 152 | { "j", "cv", irc_cmd_join, N_("j <room1>[,room2][,...] [key1[,key2][,...]]: Enter one or more channels, optionally providing a channel key for each if needed.") }, |
| 153 | { "join", "cv", irc_cmd_join, N_("join <room1>[,room2][,...] [key1[,key2][,...]]: Enter one or more channels, optionally providing a channel key for each if needed.") }, | |
| 9258 | 154 | { "kick", "n:", irc_cmd_kick, N_("kick <nick> [message]: Remove someone from a channel. You must be a channel operator to do this.") }, |
| 155 | { "list", ":", irc_cmd_list, N_("list: Display a list of chat rooms on the network. <i>Warning, some servers may disconnect you upon doing this.</i>") }, | |
| 9255 | 156 | { "me", ":", irc_cmd_ctcp_action, N_("me <action to perform>: Perform an action.") }, |
| 12013 | 157 | { "memoserv", ":", irc_cmd_service, N_("memoserv: Send a command to memoserv") }, |
|
10609
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
158 | { "mode", ":", irc_cmd_mode, N_("mode <+|-><A-Za-z> <nick|channel>: Set or unset a channel or user mode.") }, |
| 9258 | 159 | { "msg", "t:", irc_cmd_privmsg, N_("msg <nick> <message>: Send a private message to a user (as opposed to a channel).") }, |
| 160 | { "names", "c", irc_cmd_names, N_("names [channel]: List the users currently in a channel.") }, | |
| 9274 | 161 | { "nick", "n", irc_cmd_nick, N_("nick <new nickname>: Change your nickname.") }, |
| 12013 | 162 | { "nickserv", ":", irc_cmd_service, N_("nickserv: Send a command to nickserv") }, |
|
22092
52c00ca73f6f
Added /notice support for IRC. If I didn't do this properly, feel free
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21720
diff
changeset
|
163 | { "notice", "t:", irc_cmd_privmsg, N_("notice <target<: Send a notice to a user or channel.") }, |
| 9258 | 164 | { "op", ":", irc_cmd_op, N_("op <nick1> [nick2] ...: Grant channel operator status to someone. You must be a channel operator to do this.") }, |
| 9255 | 165 | { "operwall", ":", irc_cmd_wallops, N_("operwall <message>: If you don't know what this is, you probably can't use it.") }, |
| 12013 | 166 | { "operserv", ":", irc_cmd_service, N_("operserv: Send a command to operserv") }, |
| 9258 | 167 | { "part", "c:", irc_cmd_part, N_("part [room] [message]: Leave the current channel, or a specified channel, with an optional message.") }, |
| 9255 | 168 | { "ping", "n", irc_cmd_ping, N_("ping [nick]: Asks how much lag a user (or the server if no user specified) has.") }, |
| 9258 | 169 | { "query", "n:", irc_cmd_query, N_("query <nick> <message>: Send a private message to a user (as opposed to a channel).") }, |
| 9255 | 170 | { "quit", ":", irc_cmd_quit, N_("quit [message]: Disconnect from the server, with an optional message.") }, |
| 171 | { "quote", "*", irc_cmd_quote, N_("quote [...]: Send a raw command to the server.") }, | |
| 172 | { "remove", "n:", irc_cmd_remove, N_("remove <nick> [message]: Remove someone from a room. You must be a channel operator to do this.") }, | |
| 10564 | 173 | { "time", "", irc_cmd_time, N_("time: Displays the current local time at the IRC server.") }, |
| 9255 | 174 | { "topic", ":", irc_cmd_topic, N_("topic [new topic]: View or change the channel topic.") }, |
| 175 | { "umode", ":", irc_cmd_mode, N_("umode <+|-><A-Za-z>: Set or unset a user mode.") }, | |
| 13943 | 176 | { "version", ":", irc_cmd_ctcp_version, N_("version [nick]: send CTCP VERSION request to a user") }, |
| 9258 | 177 | { "voice", ":", irc_cmd_op, N_("voice <nick1> [nick2] ...: Grant channel voice status to someone. You must be a channel operator to do this.") }, |
| 9255 | 178 | { "wallops", ":", irc_cmd_wallops, N_("wallops <message>: If you don't know what this is, you probably can't use it.") }, |
|
10609
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
179 | { "whois", "tt", irc_cmd_whois, N_("whois [server] <nick>: Get information on a user.") }, |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
180 | { "whowas", "t", irc_cmd_whowas, N_("whowas <nick>: Get information on a user that has logged off.") }, |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11136
diff
changeset
|
181 | { NULL, NULL, NULL, NULL } |
| 6333 | 182 | }; |
| 183 | ||
| 15884 | 184 | static PurpleCmdRet irc_parse_purple_cmd(PurpleConversation *conv, const gchar *cmd, |
| 9597 | 185 | gchar **args, gchar **error, void *data) |
| 9130 | 186 | { |
| 15884 | 187 | PurpleConnection *gc; |
| 9130 | 188 | struct irc_conn *irc; |
| 189 | struct _irc_user_cmd *cmdent; | |
| 190 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32635
diff
changeset
|
191 | gc = purple_conversation_get_connection(conv); |
| 9130 | 192 | if (!gc) |
| 15884 | 193 | return PURPLE_CMD_RET_FAILED; |
| 9130 | 194 | |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
195 | irc = purple_connection_get_protocol_data(gc); |
| 9130 | 196 | |
| 197 | if ((cmdent = g_hash_table_lookup(irc->cmds, cmd)) == NULL) | |
| 15884 | 198 | return PURPLE_CMD_RET_FAILED; |
| 9130 | 199 | |
| 15884 | 200 | (cmdent->cb)(irc, cmd, purple_conversation_get_name(conv), (const char **)args); |
| 9130 | 201 | |
| 15884 | 202 | return PURPLE_CMD_RET_OK; |
| 9130 | 203 | } |
| 204 | ||
| 205 | static void irc_register_command(struct _irc_user_cmd *c) | |
| 206 | { | |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
207 | PurpleCmdId id; |
| 15884 | 208 | PurpleCmdFlag f; |
| 9130 | 209 | char args[10]; |
| 210 | char *format; | |
|
12316
b4e5d5ea15fd
[gaim-migrate @ 14620]
Richard Laager <rlaager@pidgin.im>
parents:
12282
diff
changeset
|
211 | size_t i; |
| 9130 | 212 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
213 | f = PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PROTOCOL_ONLY |
| 15884 | 214 | | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS; |
| 9130 | 215 | |
| 216 | format = c->format; | |
| 217 | ||
| 218 | for (i = 0; (i < (sizeof(args) - 1)) && *format; i++, format++) | |
| 219 | switch (*format) { | |
| 220 | case 'v': | |
| 221 | case 'n': | |
| 222 | case 'c': | |
| 223 | case 't': | |
| 224 | args[i] = 'w'; | |
| 225 | break; | |
| 226 | case ':': | |
| 227 | case '*': | |
| 228 | args[i] = 's'; | |
| 229 | break; | |
| 230 | } | |
| 231 | ||
| 232 | args[i] = '\0'; | |
| 233 | ||
|
37005
702a601fc2ca
Update protocol IDs in codebase
Ankit Vani <a@nevitus.org>
parents:
36910
diff
changeset
|
234 | id = purple_cmd_register(c->name, args, PURPLE_CMD_P_PROTOCOL, f, "prpl-irc", |
| 15884 | 235 | irc_parse_purple_cmd, _(c->help), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
236 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
| 9130 | 237 | } |
| 238 | ||
| 239 | void irc_register_commands(void) | |
| 240 | { | |
| 241 | struct _irc_user_cmd *c; | |
| 242 | ||
| 243 | for (c = _irc_cmds; c && c->name; c++) | |
| 244 | irc_register_command(c); | |
| 245 | } | |
| 246 | ||
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
247 | void irc_unregister_commands(void) |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
248 | { |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
249 | while (cmds) { |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
250 | PurpleCmdId id = GPOINTER_TO_UINT(cmds->data); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
251 | purple_cmd_unregister(id); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
252 | cmds = g_slist_delete_link(cmds, cmds); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
253 | } |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
254 | } |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
255 | |
| 6333 | 256 | static char *irc_send_convert(struct irc_conn *irc, const char *string) |
| 257 | { | |
| 258 | char *utf8; | |
| 259 | GError *err = NULL; | |
| 10258 | 260 | gchar **encodings; |
| 261 | const gchar *enclist; | |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
262 | |
| 15884 | 263 | enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET); |
| 10258 | 264 | encodings = g_strsplit(enclist, ",", 2); |
| 265 | ||
|
17138
d666ace4a8ac
strcasecmp is post-C89, so use the glib equivalent
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
266 | if (encodings[0] == NULL || !g_ascii_strcasecmp("UTF-8", encodings[0])) { |
| 10278 | 267 | g_strfreev(encodings); |
|
23392
9268a4fc4786
Remove an unnecessary strdup when sending messages over IRC.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22798
diff
changeset
|
268 | return NULL; |
| 10278 | 269 | } |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
270 | |
| 10258 | 271 | utf8 = g_convert(string, strlen(string), encodings[0], "UTF-8", NULL, NULL, &err); |
| 6333 | 272 | if (err) { |
| 15884 | 273 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Send conversion error: %s\n", err->message); |
| 274 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Sending as UTF-8 instead of %s\n", encodings[0]); | |
| 6333 | 275 | utf8 = g_strdup(string); |
| 8954 | 276 | g_error_free(err); |
| 6333 | 277 | } |
| 10258 | 278 | g_strfreev(encodings); |
| 279 | ||
| 6333 | 280 | return utf8; |
| 281 | } | |
| 282 | ||
| 283 | static char *irc_recv_convert(struct irc_conn *irc, const char *string) | |
| 284 | { | |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
285 | char *utf8 = NULL; |
| 10258 | 286 | const gchar *charset, *enclist; |
| 287 | gchar **encodings; | |
|
23906
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23895
diff
changeset
|
288 | gboolean autodetect; |
| 10258 | 289 | int i; |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
290 | |
|
32057
e0abdcaf6fd9
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Ethan Blanton <elb@pidgin.im>
parents:
32047
diff
changeset
|
291 | autodetect = purple_account_get_bool(irc->account, "autodetect_utf8", IRC_DEFAULT_AUTODETECT); |
|
e0abdcaf6fd9
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Ethan Blanton <elb@pidgin.im>
parents:
32047
diff
changeset
|
292 | |
|
e0abdcaf6fd9
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Ethan Blanton <elb@pidgin.im>
parents:
32047
diff
changeset
|
293 | if (autodetect && g_utf8_validate(string, -1, NULL)) { |
|
e0abdcaf6fd9
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Ethan Blanton <elb@pidgin.im>
parents:
32047
diff
changeset
|
294 | return g_strdup(string); |
|
e0abdcaf6fd9
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Ethan Blanton <elb@pidgin.im>
parents:
32047
diff
changeset
|
295 | } |
|
e0abdcaf6fd9
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Ethan Blanton <elb@pidgin.im>
parents:
32047
diff
changeset
|
296 | |
| 15884 | 297 | enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET); |
| 10258 | 298 | encodings = g_strsplit(enclist, ",", -1); |
| 299 | ||
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10278
diff
changeset
|
300 | if (encodings[0] == NULL) { |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10278
diff
changeset
|
301 | g_strfreev(encodings); |
| 15884 | 302 | return purple_utf8_salvage(string); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10278
diff
changeset
|
303 | } |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
304 | |
| 10258 | 305 | for (i = 0; encodings[i] != NULL; i++) { |
| 306 | charset = encodings[i]; | |
| 307 | while (*charset == ' ') | |
| 308 | charset++; | |
| 309 | ||
|
17156
6d4cc0f310d1
More strcasecmp() replacements.
Richard Laager <rlaager@pidgin.im>
parents:
17138
diff
changeset
|
310 | if (!g_ascii_strcasecmp("UTF-8", charset)) { |
|
11726
6f319ff4cea5
[gaim-migrate @ 14017]
Richard Laager <rlaager@pidgin.im>
parents:
11318
diff
changeset
|
311 | if (g_utf8_validate(string, -1, NULL)) |
| 10258 | 312 | utf8 = g_strdup(string); |
| 313 | } else { | |
|
11726
6f319ff4cea5
[gaim-migrate @ 14017]
Richard Laager <rlaager@pidgin.im>
parents:
11318
diff
changeset
|
314 | utf8 = g_convert(string, -1, "UTF-8", charset, NULL, NULL, NULL); |
| 10258 | 315 | } |
| 316 | ||
| 317 | if (utf8) { | |
| 318 | g_strfreev(encodings); | |
| 319 | return utf8; | |
| 320 | } | |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
321 | } |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10278
diff
changeset
|
322 | g_strfreev(encodings); |
|
9644
a9a0dedb52c7
[gaim-migrate @ 10492]
Mark Doliner <markdoliner@pidgin.im>
parents:
9597
diff
changeset
|
323 | |
| 15884 | 324 | return purple_utf8_salvage(string); |
| 6333 | 325 | } |
| 326 | ||
|
20217
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
327 | /* This function is shamelessly stolen from glib--it is an old version of the |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
328 | * private function append_escaped_text, used by g_markup_escape_text, whose |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
329 | * behavior changed in glib 2.12. */ |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
330 | static void irc_append_escaped_text(GString *str, const char *text, gssize length) |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
331 | { |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
332 | const char *p = text; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
333 | const char *end = text + length; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
334 | const char *next = NULL; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
335 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
336 | while(p != end) { |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
337 | next = g_utf8_next_char(p); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
338 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
339 | switch(*p) { |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
340 | case '&': |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
341 | g_string_append(str, "&"); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
342 | break; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
343 | case '<': |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
344 | g_string_append(str, "<"); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
345 | break; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
346 | case '>': |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
347 | g_string_append(str, ">"); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
348 | break; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
349 | case '\'': |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
350 | g_string_append(str, "'"); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
351 | break; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
352 | case '"': |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
353 | g_string_append(str, """); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
354 | break; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
355 | default: |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
356 | g_string_append_len(str, p, next - p); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
357 | break; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
358 | } |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
359 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
360 | p = next; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
361 | } |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
362 | } |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
363 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
364 | /* This function is shamelessly stolen from glib--it is an old version of the |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
365 | * function g_markup_escape_text, whose behavior changed in glib 2.12. */ |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
366 | char *irc_escape_privmsg(const char *text, gssize length) |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
367 | { |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
368 | GString *str; |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
369 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
370 | g_return_val_if_fail(text != NULL, NULL); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
371 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
372 | if(length < 0) |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
373 | length = strlen(text); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
374 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
375 | str = g_string_sized_new(length); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
376 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
377 | irc_append_escaped_text(str, text, length); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
378 | |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
379 | return g_string_free(str, FALSE); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
380 | } |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
381 | |
| 6333 | 382 | /* XXX tag closings are not necessarily correctly nested here! If we |
| 383 | * get a ^O or reach the end of the string and there are open | |
| 384 | * tags, they are closed in a fixed order ... this means, for | |
| 385 | * example, you might see <FONT COLOR="blue">some text <B>with | |
| 386 | * various attributes</FONT></B> (notice that B and FONT overlap | |
| 387 | * and are not cleanly nested). This is imminently fixable but | |
| 388 | * I am not fixing it right now. | |
| 389 | */ | |
| 390 | char *irc_mirc2html(const char *string) | |
| 391 | { | |
| 392 | const char *cur, *end; | |
| 393 | char fg[3] = "\0\0", bg[3] = "\0\0"; | |
| 394 | int fgnum, bgnum; | |
|
12158
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
395 | int font = 0, bold = 0, underline = 0, italic = 0; |
|
28468
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
396 | GString *decoded; |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
397 | |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
398 | if (string == NULL) |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
399 | return NULL; |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
400 | |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
401 | decoded = g_string_sized_new(strlen(string)); |
| 6333 | 402 | |
| 403 | cur = string; | |
| 404 | do { | |
| 6754 | 405 | end = strpbrk(cur, "\002\003\007\017\026\037"); |
| 6333 | 406 | |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35282
diff
changeset
|
407 | decoded = g_string_append_len(decoded, cur, (end ? (gssize)(end - cur) : (gssize)strlen(cur))); |
| 6333 | 408 | cur = end ? end : cur + strlen(cur); |
| 409 | ||
| 410 | switch (*cur) { | |
| 411 | case '\002': | |
| 412 | cur++; | |
| 413 | if (!bold) { | |
| 414 | decoded = g_string_append(decoded, "<B>"); | |
| 415 | bold = TRUE; | |
| 416 | } else { | |
| 417 | decoded = g_string_append(decoded, "</B>"); | |
| 418 | bold = FALSE; | |
| 419 | } | |
| 420 | break; | |
| 421 | case '\003': | |
| 422 | cur++; | |
| 423 | fg[0] = fg[1] = bg[0] = bg[1] = '\0'; | |
| 424 | if (isdigit(*cur)) | |
| 425 | fg[0] = *cur++; | |
| 426 | if (isdigit(*cur)) | |
| 427 | fg[1] = *cur++; | |
| 428 | if (*cur == ',') { | |
| 429 | cur++; | |
| 430 | if (isdigit(*cur)) | |
| 431 | bg[0] = *cur++; | |
| 432 | if (isdigit(*cur)) | |
| 433 | bg[1] = *cur++; | |
| 434 | } | |
| 435 | if (font) { | |
| 436 | decoded = g_string_append(decoded, "</FONT>"); | |
| 437 | font = FALSE; | |
| 438 | } | |
| 439 | ||
| 440 | if (fg[0]) { | |
| 441 | fgnum = atoi(fg); | |
| 442 | if (fgnum < 0 || fgnum > 15) | |
| 443 | continue; | |
| 444 | font = TRUE; | |
| 445 | g_string_append_printf(decoded, "<FONT COLOR=\"%s\"", irc_mirc_colors[fgnum]); | |
| 446 | if (bg[0]) { | |
| 447 | bgnum = atoi(bg); | |
| 448 | if (bgnum >= 0 && bgnum < 16) | |
| 449 | g_string_append_printf(decoded, " BACK=\"%s\"", irc_mirc_colors[bgnum]); | |
| 450 | } | |
| 451 | decoded = g_string_append_c(decoded, '>'); | |
| 452 | } | |
| 453 | break; | |
|
12158
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
454 | case '\011': |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
455 | cur++; |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
456 | if (!italic) { |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
457 | decoded = g_string_append(decoded, "<I>"); |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
458 | italic = TRUE; |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
459 | } else { |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
460 | decoded = g_string_append(decoded, "</I>"); |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
461 | italic = FALSE; |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
462 | } |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
463 | break; |
| 6754 | 464 | case '\037': |
| 465 | cur++; | |
| 466 | if (!underline) { | |
| 467 | decoded = g_string_append(decoded, "<U>"); | |
| 468 | underline = TRUE; | |
| 469 | } else { | |
| 470 | decoded = g_string_append(decoded, "</U>"); | |
| 12282 | 471 | underline = FALSE; |
| 6754 | 472 | } |
| 473 | break; | |
| 6333 | 474 | case '\007': |
| 475 | case '\026': | |
| 476 | cur++; | |
| 477 | break; | |
| 478 | case '\017': | |
| 479 | cur++; | |
| 480 | /* fallthrough */ | |
| 481 | case '\000': | |
| 482 | if (bold) | |
| 6754 | 483 | decoded = g_string_append(decoded, "</B>"); |
|
12158
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
484 | if (italic) |
|
02fcec741f07
[gaim-migrate @ 14459]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12013
diff
changeset
|
485 | decoded = g_string_append(decoded, "</I>"); |
| 6754 | 486 | if (underline) |
| 487 | decoded = g_string_append(decoded, "</U>"); | |
| 6333 | 488 | if (font) |
| 489 | decoded = g_string_append(decoded, "</FONT>"); | |
|
31974
28ac37064cd4
Fix the handling of IRC formatting following mIRC ^O.
Ethan Blanton <elb@pidgin.im>
parents:
31651
diff
changeset
|
490 | bold = italic = underline = font = FALSE; |
| 6333 | 491 | break; |
| 492 | default: | |
| 15884 | 493 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Unexpected mIRC formatting character %d\n", *cur); |
| 6333 | 494 | } |
| 495 | } while (*cur); | |
| 496 | ||
| 497 | return g_string_free(decoded, FALSE); | |
| 498 | } | |
| 499 | ||
| 8529 | 500 | char *irc_mirc2txt (const char *string) |
| 501 | { | |
|
28468
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
502 | char *result; |
| 8529 | 503 | int i, j; |
| 504 | ||
|
28468
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
505 | if (string == NULL) |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
506 | return NULL; |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
507 | |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
508 | result = g_strdup (string); |
|
aa8975185a48
Head irc_mirc2* bugs off at the pass with a NULL check
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
509 | |
| 8529 | 510 | for (i = 0, j = 0; result[i]; i++) { |
| 511 | switch (result[i]) { | |
| 512 | case '\002': | |
| 513 | case '\003': | |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
514 | /* Foreground color */ |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
515 | if (isdigit(result[i + 1])) |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
516 | i++; |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
517 | if (isdigit(result[i + 1])) |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
518 | i++; |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
519 | /* Optional comma and background color */ |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
520 | if (result[i + 1] == ',') { |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
521 | i++; |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
522 | if (isdigit(result[i + 1])) |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
523 | i++; |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
524 | if (isdigit(result[i + 1])) |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
525 | i++; |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
526 | } |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
527 | /* Note that i still points to the last character |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
528 | * of the color selection string. */ |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17156
diff
changeset
|
529 | continue; |
| 8529 | 530 | case '\007': |
| 531 | case '\017': | |
| 532 | case '\026': | |
| 533 | case '\037': | |
| 534 | continue; | |
| 535 | default: | |
| 536 | result[j++] = result[i]; | |
| 537 | } | |
| 538 | } | |
| 11136 | 539 | result[j] = '\0'; |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24574
diff
changeset
|
540 | return result; |
| 8529 | 541 | } |
| 542 | ||
|
24574
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
543 | const char *irc_nick_skip_mode(struct irc_conn *irc, const char *nick) |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
544 | { |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
545 | static const char *default_modes = "@+%&"; |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
546 | const char *mode_chars; |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
547 | |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
548 | mode_chars = irc->mode_chars ? irc->mode_chars : default_modes; |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
549 | |
|
38918
bb3906c14782
irc: fix read out of bounds in irc_nick_skip_mode
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
550 | while (*nick && strchr(mode_chars, *nick) != NULL) |
|
24574
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
551 | nick++; |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
552 | |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
553 | return nick; |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
554 | } |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
555 | |
| 10208 | 556 | gboolean irc_ischannel(const char *string) |
| 557 | { | |
| 558 | return (string[0] == '#' || string[0] == '&'); | |
| 559 | } | |
| 560 | ||
| 6333 | 561 | char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice) |
| 562 | { | |
| 15884 | 563 | PurpleConnection *gc; |
| 6333 | 564 | const char *cur = msg + 1; |
| 565 | char *buf, *ctcp; | |
| 566 | ||
| 6754 | 567 | /* Note that this is NOT correct w.r.t. multiple CTCPs in one |
| 568 | * message and low-level quoting ... but if you want that crap, | |
| 569 | * use a real IRC client. */ | |
| 570 | ||
|
38920
306b7ae2c8a4
irc: Fix write of a single \0 before the start of a buffer in irc_parse_ctcp
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
571 | if (msg[0] != '\001' || msg[1] == '\0' || msg[strlen(msg) - 1] != '\001') |
| 6333 | 572 | return g_strdup(msg); |
| 573 | ||
| 574 | if (!strncmp(cur, "ACTION ", 7)) { | |
| 575 | cur += 7; | |
| 576 | buf = g_strdup_printf("/me %s", cur); | |
| 577 | buf[strlen(buf) - 1] = '\0'; | |
| 578 | return buf; | |
| 579 | } else if (!strncmp(cur, "PING ", 5)) { | |
| 580 | if (notice) { /* reply */ | |
|
40000
0eeff970bcdd
Use monotonic time for IRC ping messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39589
diff
changeset
|
581 | gint64 timestamp; |
| 15884 | 582 | gc = purple_account_get_connection(irc->account); |
| 6333 | 583 | if (!gc) |
| 584 | return NULL; | |
|
40000
0eeff970bcdd
Use monotonic time for IRC ping messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39589
diff
changeset
|
585 | if (sscanf(cur, "PING %" G_GINT64_FORMAT, ×tamp) == 1) { |
|
0eeff970bcdd
Use monotonic time for IRC ping messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39589
diff
changeset
|
586 | buf = g_strdup_printf(_("Reply time from %s: %f seconds"), from, |
|
0eeff970bcdd
Use monotonic time for IRC ping messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39589
diff
changeset
|
587 | (g_get_monotonic_time() - timestamp) / |
|
0eeff970bcdd
Use monotonic time for IRC ping messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39589
diff
changeset
|
588 | (gdouble)G_USEC_PER_SEC); |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
589 | purple_notify_info(gc, _("PONG"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
590 | _("CTCP PING reply"), buf, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
591 | purple_request_cpar_from_connection(gc)); |
|
33809
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
33544
diff
changeset
|
592 | g_free(buf); |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
33544
diff
changeset
|
593 | } else |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
33544
diff
changeset
|
594 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Unable to parse PING timestamp"); |
| 6333 | 595 | return NULL; |
| 596 | } else { | |
| 597 | buf = irc_format(irc, "vt:", "NOTICE", from, msg); | |
| 598 | irc_send(irc, buf); | |
| 599 | g_free(buf); | |
| 600 | } | |
| 601 | } else if (!strncmp(cur, "VERSION", 7) && !notice) { | |
| 15884 | 602 | buf = irc_format(irc, "vt:", "NOTICE", from, "\001VERSION Purple IRC\001"); |
| 6333 | 603 | irc_send(irc, buf); |
| 604 | g_free(buf); | |
| 8351 | 605 | } else if (!strncmp(cur, "DCC SEND ", 9)) { |
| 606 | irc_dccsend_recv(irc, from, msg + 10); | |
| 607 | return NULL; | |
| 6333 | 608 | } |
| 609 | ||
| 610 | ctcp = g_strdup(msg + 1); | |
| 611 | ctcp[strlen(ctcp) - 1] = '\0'; | |
| 612 | buf = g_strdup_printf("Received CTCP '%s' (to %s) from %s", ctcp, to, from); | |
| 613 | g_free(ctcp); | |
| 614 | return buf; | |
| 615 | } | |
| 616 | ||
| 617 | void irc_msg_table_build(struct irc_conn *irc) | |
| 618 | { | |
| 619 | int i; | |
| 620 | ||
| 621 | if (!irc || !irc->msgs) { | |
| 15884 | 622 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Attempt to build a message table on a bogus structure\n"); |
| 6333 | 623 | return; |
| 624 | } | |
| 625 | ||
| 626 | for (i = 0; _irc_msgs[i].name; i++) { | |
| 627 | g_hash_table_insert(irc->msgs, (gpointer)_irc_msgs[i].name, (gpointer)&_irc_msgs[i]); | |
| 628 | } | |
| 629 | } | |
| 630 | ||
| 631 | void irc_cmd_table_build(struct irc_conn *irc) | |
| 632 | { | |
| 633 | int i; | |
| 634 | ||
| 635 | if (!irc || !irc->cmds) { | |
| 15884 | 636 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Attempt to build a command table on a bogus structure\n"); |
| 6333 | 637 | return; |
| 638 | } | |
| 639 | ||
| 640 | for (i = 0; _irc_cmds[i].name ; i++) { | |
| 641 | g_hash_table_insert(irc->cmds, (gpointer)_irc_cmds[i].name, (gpointer)&_irc_cmds[i]); | |
| 642 | } | |
| 643 | } | |
| 644 | ||
| 645 | char *irc_format(struct irc_conn *irc, const char *format, ...) | |
| 646 | { | |
| 647 | GString *string = g_string_new(""); | |
| 648 | char *tok, *tmp; | |
| 649 | const char *cur; | |
| 650 | va_list ap; | |
| 651 | ||
| 652 | va_start(ap, format); | |
| 653 | for (cur = format; *cur; cur++) { | |
| 654 | if (cur != format) | |
| 655 | g_string_append_c(string, ' '); | |
| 656 | ||
| 657 | tok = va_arg(ap, char *); | |
| 658 | switch (*cur) { | |
| 659 | case 'v': | |
| 660 | g_string_append(string, tok); | |
| 661 | break; | |
| 662 | case ':': | |
| 663 | g_string_append_c(string, ':'); | |
| 664 | /* no break! */ | |
| 665 | case 't': | |
| 666 | case 'n': | |
| 667 | case 'c': | |
| 668 | tmp = irc_send_convert(irc, tok); | |
|
23392
9268a4fc4786
Remove an unnecessary strdup when sending messages over IRC.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22798
diff
changeset
|
669 | g_string_append(string, tmp ? tmp : tok); |
| 6333 | 670 | g_free(tmp); |
| 671 | break; | |
| 672 | default: | |
| 15884 | 673 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Invalid format character '%c'\n", *cur); |
| 6333 | 674 | break; |
| 675 | } | |
| 676 | } | |
| 677 | va_end(ap); | |
| 678 | g_string_append(string, "\r\n"); | |
| 679 | return (g_string_free(string, FALSE)); | |
| 680 | } | |
| 681 | ||
| 682 | void irc_parse_msg(struct irc_conn *irc, char *input) | |
| 683 | { | |
| 684 | struct _irc_msg *msgent; | |
| 685 | char *cur, *end, *tmp, *from, *msgname, *fmt, **args, *msg; | |
| 7631 | 686 | guint i; |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
687 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
688 | gboolean fmt_valid; |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
689 | int args_cnt; |
| 6333 | 690 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
691 | irc->recv_time = time(NULL); |
|
14984
aa56a88dc792
[gaim-migrate @ 17694]
Mark Doliner <markdoliner@pidgin.im>
parents:
14683
diff
changeset
|
692 | |
|
aa56a88dc792
[gaim-migrate @ 17694]
Mark Doliner <markdoliner@pidgin.im>
parents:
14683
diff
changeset
|
693 | /* |
|
14996
291304176e0b
[gaim-migrate @ 17706]
Mark Doliner <markdoliner@pidgin.im>
parents:
14995
diff
changeset
|
694 | * The data passed to irc-receiving-text is the raw protocol data. |
|
14995
fc9f51b8f6d5
[gaim-migrate @ 17705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14984
diff
changeset
|
695 | * TODO: It should be passed as an array of bytes and a length |
|
fc9f51b8f6d5
[gaim-migrate @ 17705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14984
diff
changeset
|
696 | * instead of a null terminated string. |
|
14984
aa56a88dc792
[gaim-migrate @ 17694]
Mark Doliner <markdoliner@pidgin.im>
parents:
14683
diff
changeset
|
697 | */ |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
33811
diff
changeset
|
698 | purple_signal_emit(_irc_protocol, "irc-receiving-text", gc, &input); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31229
diff
changeset
|
699 | |
|
38907
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
700 | if (purple_debug_is_verbose()) { |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
701 | char *clean = purple_utf8_salvage(input); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
702 | clean = g_strstrip(clean); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
703 | purple_debug_misc("irc", ">> %s\n", clean); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
704 | g_free(clean); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
705 | } |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
36256
diff
changeset
|
706 | |
| 6333 | 707 | if (!strncmp(input, "PING ", 5)) { |
| 708 | msg = irc_format(irc, "vv", "PONG", input + 5); | |
| 709 | irc_send(irc, msg); | |
| 710 | g_free(msg); | |
| 711 | return; | |
| 712 | } else if (!strncmp(input, "ERROR ", 6)) { | |
| 10154 | 713 | if (g_utf8_validate(input, -1, NULL)) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
714 | purple_connection_take_error(gc, g_error_new( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
715 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
716 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
717 | "%s\n%s", _("Disconnected."), input)); |
| 10154 | 718 | } else |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
719 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
720 | PURPLE_CONNECTION_ERROR, |
| 21279 | 721 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37158
diff
changeset
|
722 | _("Disconnected."))); |
| 6333 | 723 | return; |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
724 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
725 | } else if (!strncmp(input, "AUTHENTICATE ", 13)) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
726 | irc_msg_auth(irc, input + 13); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
727 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32057
diff
changeset
|
728 | #endif |
| 6333 | 729 | } |
| 730 | ||
| 731 | if (input[0] != ':' || (cur = strchr(input, ' ')) == NULL) { | |
| 732 | irc_parse_error_cb(irc, input); | |
| 733 | return; | |
| 734 | } | |
| 735 | ||
| 736 | from = g_strndup(&input[1], cur - &input[1]); | |
| 737 | cur++; | |
| 738 | end = strchr(cur, ' '); | |
| 739 | if (!end) | |
| 740 | end = cur + strlen(cur); | |
| 741 | ||
| 742 | tmp = g_strndup(cur, end - cur); | |
| 743 | msgname = g_ascii_strdown(tmp, -1); | |
| 744 | g_free(tmp); | |
| 745 | ||
| 746 | if ((msgent = g_hash_table_lookup(irc->msgs, msgname)) == NULL) { | |
| 747 | irc_msg_default(irc, "", from, &input); | |
| 748 | g_free(msgname); | |
| 749 | g_free(from); | |
| 750 | return; | |
| 751 | } | |
| 752 | g_free(msgname); | |
| 753 | ||
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
754 | fmt_valid = TRUE; |
| 6333 | 755 | args = g_new0(char *, strlen(msgent->format)); |
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
756 | args_cnt = 0; |
| 6333 | 757 | for (cur = end, fmt = msgent->format, i = 0; fmt[i] && *cur++; i++) { |
| 758 | switch (fmt[i]) { | |
| 759 | case 'v': | |
| 760 | if (!(end = strchr(cur, ' '))) end = cur + strlen(cur); | |
|
32047
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
761 | /* This is a string of unknown encoding which we do not |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
762 | * want to transcode, but it may or may not be valid |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
763 | * UTF-8, so we'll salvage it. If a nick/channel/target |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
764 | * field has inadvertently been marked verbatim, this |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
765 | * could cause weirdness. */ |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
766 | tmp = g_strndup(cur, end - cur); |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
767 | args[i] = purple_utf8_salvage(tmp); |
|
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
768 | g_free(tmp); |
| 6333 | 769 | cur += end - cur; |
| 770 | break; | |
| 771 | case 't': | |
| 772 | case 'n': | |
| 773 | case 'c': | |
| 774 | if (!(end = strchr(cur, ' '))) end = cur + strlen(cur); | |
| 775 | tmp = g_strndup(cur, end - cur); | |
| 776 | args[i] = irc_recv_convert(irc, tmp); | |
| 777 | g_free(tmp); | |
| 778 | cur += end - cur; | |
| 779 | break; | |
| 780 | case ':': | |
| 781 | if (*cur == ':') cur++; | |
| 782 | args[i] = irc_recv_convert(irc, cur); | |
| 783 | cur = cur + strlen(cur); | |
| 784 | break; | |
| 785 | case '*': | |
|
32047
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
786 | /* Ditto 'v' above; we're going to salvage this in case |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
787 | * it leaks past the IRC protocol */ |
|
32047
42d2acf32425
UTF-8 salvage unknown strings in IRC
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
788 | args[i] = purple_utf8_salvage(cur); |
| 6333 | 789 | cur = cur + strlen(cur); |
| 790 | break; | |
| 791 | default: | |
| 15884 | 792 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "invalid message format character '%c'\n", fmt[i]); |
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
793 | fmt_valid = FALSE; |
| 6333 | 794 | break; |
| 795 | } | |
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
796 | if (fmt_valid) |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
797 | args_cnt = i + 1; |
| 6333 | 798 | } |
|
35245
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
799 | if (G_UNLIKELY(!fmt_valid)) { |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
800 | purple_debug_error("irc", "message format was invalid"); |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
801 | } else if (G_LIKELY(args_cnt >= msgent->req_cnt)) { |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
802 | tmp = irc_recv_convert(irc, from); |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
803 | (msgent->cb)(irc, msgent->name, tmp, args); |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
804 | g_free(tmp); |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
805 | } else { |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
806 | purple_debug_error("irc", "args count (%d) doesn't reach " |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
807 | "expected value of %d for the '%s' command", |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
808 | args_cnt, msgent->req_cnt, msgent->name); |
|
a167504359e5
IRC: implement support for required args checking in message parser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33809
diff
changeset
|
809 | } |
| 6333 | 810 | for (i = 0; i < strlen(msgent->format); i++) { |
| 811 | g_free(args[i]); | |
| 812 | } | |
| 813 | g_free(args); | |
| 814 | g_free(from); | |
| 815 | } | |
| 816 | ||
| 817 | static void irc_parse_error_cb(struct irc_conn *irc, char *input) | |
| 818 | { | |
|
23433
0094a64519cb
Make the IRC "unknown message" debugging messages UTF-8 safe.
Ethan Blanton <elb@pidgin.im>
parents:
23392
diff
changeset
|
819 | char *clean; |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24574
diff
changeset
|
820 | /* This really should be escaped somehow that you can tell what |
|
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24574
diff
changeset
|
821 | * the junk was -- but as it is, it can crash glib. */ |
|
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24574
diff
changeset
|
822 | clean = purple_utf8_salvage(input); |
|
23433
0094a64519cb
Make the IRC "unknown message" debugging messages UTF-8 safe.
Ethan Blanton <elb@pidgin.im>
parents:
23392
diff
changeset
|
823 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unrecognized string: %s\n", clean); |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24574
diff
changeset
|
824 | g_free(clean); |
| 6333 | 825 | } |