Sat, 25 Jun 2011 02:42:08 +0000
Fix races between irc_send_raw() and normal prpl-internal sends.
Fixes #14263
| 6333 | 1 | /** |
| 2 | * @file irc.h | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12210
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
| 6333 | 5 | * |
| 6 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12210
diff
changeset
|
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:
16993
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6333 | 21 | */ |
| 22 | ||
| 15884 | 23 | #ifndef _PURPLE_IRC_H |
| 24 | #define _PURPLE_IRC_H | |
| 6333 | 25 | |
| 26 | #include <glib.h> | |
| 27 | ||
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13943
diff
changeset
|
28 | #include "circbuffer.h" |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12013
diff
changeset
|
29 | #include "ft.h" |
| 8114 | 30 | #include "roomlist.h" |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10208
diff
changeset
|
31 | #include "sslconn.h" |
| 6333 | 32 | |
| 33 | #define IRC_DEFAULT_SERVER "irc.freenode.net" | |
| 34 | #define IRC_DEFAULT_PORT 6667 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10208
diff
changeset
|
35 | #define IRC_DEFAULT_SSL_PORT 994 |
| 6333 | 36 | |
| 37 | #define IRC_DEFAULT_CHARSET "UTF-8" | |
|
23906
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23895
diff
changeset
|
38 | #define IRC_DEFAULT_AUTODETECT FALSE |
| 15884 | 39 | #define IRC_DEFAULT_ALIAS "purple" |
| 6333 | 40 | |
| 11763 | 41 | #define IRC_DEFAULT_QUIT "Leaving." |
| 11073 | 42 | |
| 6333 | 43 | #define IRC_INITIAL_BUFSIZE 1024 |
| 44 | ||
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
45 | #define IRC_NAMES_FLAG "irc-namelist" |
|
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
46 | |
| 8351 | 47 | |
| 6333 | 48 | enum { IRC_USEROPT_SERVER, IRC_USEROPT_PORT, IRC_USEROPT_CHARSET }; |
| 49 | enum irc_state { IRC_STATE_NEW, IRC_STATE_ESTABLISHED }; | |
| 50 | ||
| 51 | struct irc_conn { | |
| 15884 | 52 | PurpleAccount *account; |
| 6333 | 53 | GHashTable *msgs; |
| 54 | GHashTable *cmds; | |
| 55 | char *server; | |
| 56 | int fd; | |
| 57 | guint timer; | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
58 | guint who_channel_timer; |
| 6333 | 59 | GHashTable *buddies; |
| 60 | ||
|
21736
8de85200908d
applied changes from 5dc4cf40c038206bcf06fe7407e1e308b0264e32
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20217
diff
changeset
|
61 | gboolean ison_outstanding; |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
28118
diff
changeset
|
62 | GList *buddies_outstanding; |
|
21736
8de85200908d
applied changes from 5dc4cf40c038206bcf06fe7407e1e308b0264e32
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20217
diff
changeset
|
63 | |
| 6333 | 64 | char *inbuf; |
| 65 | int inbuflen; | |
| 66 | int inbufused; | |
| 67 | ||
| 68 | GString *motd; | |
| 69 | GString *names; | |
| 70 | struct _whois { | |
| 71 | char *nick; | |
| 72 | char *away; | |
| 73 | char *userhost; | |
| 74 | char *name; | |
| 75 | char *server; | |
| 76 | char *serverinfo; | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24574
diff
changeset
|
77 | GString *channels; |
| 6333 | 78 | int ircop; |
| 79 | int identified; | |
| 80 | int idle; | |
| 81 | time_t signon; | |
| 82 | } whois; | |
| 15884 | 83 | PurpleRoomlist *roomlist; |
| 84 | PurpleSslConnection *gsc; | |
| 9440 | 85 | |
| 86 | gboolean quitting; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12210
diff
changeset
|
87 | |
| 15884 | 88 | PurpleCircBuffer *outbuf; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12210
diff
changeset
|
89 | guint writeh; |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14324
diff
changeset
|
90 | |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14324
diff
changeset
|
91 | time_t recv_time; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
92 | |
|
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
93 | char *mode_chars; |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22798
diff
changeset
|
94 | char *reqnick; |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22798
diff
changeset
|
95 | gboolean nickused; |
| 6333 | 96 | }; |
| 97 | ||
| 98 | struct irc_buddy { | |
| 99 | char *name; | |
| 100 | gboolean online; | |
| 101 | gboolean flag; | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
28118
diff
changeset
|
102 | gboolean new_online_status; |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
25703
diff
changeset
|
103 | int ref; |
| 6333 | 104 | }; |
| 105 | ||
| 106 | typedef int (*IRCCmdCallback) (struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 107 | ||
| 108 | int irc_send(struct irc_conn *irc, const char *buf); | |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31565
diff
changeset
|
109 | int irc_send_len(struct irc_conn *irc, const char *buf, int len); |
| 6333 | 110 | gboolean irc_blist_timeout(struct irc_conn *irc); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
111 | gboolean irc_who_channel_timeout(struct irc_conn *irc); |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
28118
diff
changeset
|
112 | void irc_buddy_query(struct irc_conn *irc); |
| 6333 | 113 | |
|
20217
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
114 | char *irc_escape_privmsg(const char *text, gssize length); |
|
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
115 | |
| 6333 | 116 | char *irc_mirc2html(const char *string); |
| 8529 | 117 | char *irc_mirc2txt(const char *string); |
| 6333 | 118 | |
|
24574
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
119 | const char *irc_nick_skip_mode(struct irc_conn *irc, const char *string); |
|
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
120 | |
| 10208 | 121 | gboolean irc_ischannel(const char *string); |
| 122 | ||
| 9130 | 123 | void irc_register_commands(void); |
| 6333 | 124 | void irc_msg_table_build(struct irc_conn *irc); |
| 125 | void irc_parse_msg(struct irc_conn *irc, char *input); | |
| 126 | char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice); | |
| 127 | char *irc_format(struct irc_conn *irc, const char *format, ...); | |
| 128 | ||
| 129 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 130 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 131 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 10633 | 132 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args); |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
21736
diff
changeset
|
133 | void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args); |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10633
diff
changeset
|
134 | void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 135 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 136 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 137 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args); | |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15435
diff
changeset
|
138 | void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 139 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 140 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 141 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 142 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 143 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 8114 | 144 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
145 | void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 146 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 147 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 148 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 149 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 150 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 7877 | 151 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 152 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6718 | 153 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 154 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 155 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 156 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 157 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 158 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 159 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 160 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 161 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args); | |
|
16993
536c1485c139
Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents:
16474
diff
changeset
|
162 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6714 | 163 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 10564 | 164 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 165 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
166 | void irc_msg_unavailable(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 167 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 168 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 169 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args); | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
170 | void irc_msg_who(struct irc_conn *irc, const char *name, const char *from, char **args); |
| 6333 | 171 | |
| 172 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args); | |
| 173 | ||
| 174 | void irc_cmd_table_build(struct irc_conn *irc); | |
| 175 | ||
| 176 | int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 177 | int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
178 | int irc_cmd_ctcp(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 6333 | 179 | int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 13943 | 180 | int irc_cmd_ctcp_version(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 6333 | 181 | int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 182 | int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 183 | int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 8114 | 184 | int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 6333 | 185 | int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 186 | int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 187 | int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 188 | int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 189 | int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 190 | int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 191 | int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 192 | int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 193 | int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 194 | int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 195 | int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
|
12210
d7e2c9f73e16
[gaim-migrate @ 14512]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
196 | int irc_cmd_service(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 10564 | 197 | int irc_cmd_time(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 6333 | 198 | int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 199 | int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
| 200 | int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args); | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
201 | int irc_cmd_whowas(struct irc_conn *irc, const char *cmd, const char *target, const char **args); |
| 6333 | 202 | |
| 15884 | 203 | PurpleXfer *irc_dccsend_new_xfer(PurpleConnection *gc, const char *who); |
| 204 | void irc_dccsend_send_file(PurpleConnection *gc, const char *who, const char *file); | |
| 8351 | 205 | void irc_dccsend_recv(struct irc_conn *irc, const char *from, const char *msg); |
| 15884 | 206 | #endif /* _PURPLE_IRC_H */ |