annotate src/protocols/irc/irc.c @ 4692:a81443d3516b

[gaim-migrate @ 5003] Thanks, Ha-King committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 10 Mar 2003 07:21:18 +0000
parents 283fb289c510
children c15e0699acae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim - IRC Protocol Plugin
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2290
23c06449ae8e [gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
6 *
23c06449ae8e [gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
7 * A large portion of this was copied more or less directly from X-Chat,
23c06449ae8e [gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
8 * the world's most rocking IRC client. http://www.xchat.org/
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
26 #include <config.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
28 #ifndef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
29 #include <unistd.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
30 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
31 #include <winsock.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
32 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
33
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
34 #include <fcntl.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <errno.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <string.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include <stdlib.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include <stdio.h>
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3793
diff changeset
39 #include <sys/time.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include <time.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #include <sys/stat.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #include <ctype.h>
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4594
diff changeset
43 #include "gaim.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include "multi.h"
4373
dcc6c130c6d9 [gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4359
diff changeset
45 #include "core.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include "proxy.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
49 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
50 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
51 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
52
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #define IRC_BUF_LEN 4096
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
54 #define PDIWORDS 32
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #define USEROPT_SERV 0
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #define USEROPT_PORT 1
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
58 #define USEROPT_CHARSET 2
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
60 static struct prpl *my_protocol = NULL;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
61
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
62 /* for win32 compatability */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
63 G_MODULE_IMPORT GSList *connections;
4373
dcc6c130c6d9 [gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4359
diff changeset
64 G_MODULE_IMPORT GSList *groups;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
65
4422
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
66 #ifndef INET6_ADDRSTRLEN
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
67 #define INET6_ADDRSTRLEN 46
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
68 #endif
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
69
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
70 /* Datastructs */
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
71 struct dcc_chat
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
72 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
73 struct gaim_connection *gc;
4422
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
74 char ip_address[INET6_ADDRSTRLEN];
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
75 int port;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
76 int fd;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
77 int inpa;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
78 char nick[80];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
79 };
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
80
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
81 struct irc_xfer_data
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
82 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
83 char *ip;
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
84 int port;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
85
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
86 struct irc_data *idata;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
87 };
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
88
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 struct irc_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 int fd;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
91 gboolean online;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
92 guint32 timer;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
94 char *rxqueue;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
95 int rxlen;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
96
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
97 GString *str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
98 int bc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
100 char *chantypes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
101 char *chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
102 char *nickmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
103 gboolean six_modes;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
104
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
105 gboolean in_whois;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
106 gboolean in_list;
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
107 GString *liststr;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
108 GSList *file_transfers;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
111 /* Prototypes */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
112 static void irc_start_chat(struct gaim_connection *gc, char *who);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
113 static void irc_ctcp_clientinfo(struct gaim_connection *gc, char *who);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
114 static void irc_ctcp_userinfo(struct gaim_connection *gc, char *who);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
115 static void irc_ctcp_version(struct gaim_connection *gc, char *who);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
116 static void irc_ctcp_ping(struct gaim_connection *gc, char *who);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
117
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
118 static void irc_send_privmsg(struct gaim_connection *gc, char *who, char *what, gboolean fragment);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
119 static void irc_send_notice(struct gaim_connection *gc, char *who, char *what);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
120
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
121 static char *irc_send_convert(struct gaim_connection *gc, char *string, int maxlen, int *done);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
122 static char *irc_recv_convert(struct gaim_connection *gc, char *string);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
123 static void irc_parse_notice(struct gaim_connection *gc, char *nick, char *ex,
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
124 char *word[], char *word_eol[]);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
125 static void irc_parse_join(struct gaim_connection *gc, char *nick,
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
126 char *word[], char *word_eol[]);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
127 static gboolean irc_parse_part(struct gaim_connection *gc, char *nick, char *cmd,
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
128 char *word[], char *word_eol[]);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
129 static void irc_parse_topic(struct gaim_connection *gc, char *nick,
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
130 char *word[], char *word_eol[]);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
131
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
132 static void dcc_chat_cancel(struct dcc_chat *);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
133
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
134 /* Global variables */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
135 GSList *dcc_chat_list = NULL;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
136
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
137 struct dcc_chat *
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
138 find_dcc_chat (struct gaim_connection *gc, char *nick)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
139 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
140 GSList *tmp;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
141 struct dcc_chat *data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
142 tmp = dcc_chat_list;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
143 while (tmp != NULL)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
144 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
145 data = (struct dcc_chat *) (tmp)->data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
146 if (data
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
147 && data->nick
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
148 && strcmp (nick, data->nick) == 0
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
149 && gc == data->gc)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
150 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
151 return data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
152 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
153 tmp = tmp->next;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
154 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
155 return NULL;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
156 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
157
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
158 static int
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
159 irc_write(int fd, char *data, int len)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
160 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
161 debug_printf("IRC C: %s", data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
162 return write(fd, data, len);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
163 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
164
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
165 static char *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
166 irc_send_convert(struct gaim_connection *gc, char *string, int maxlen, int *done)
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
167 {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
168 char *converted = g_malloc(maxlen + 1);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
169 gchar *inptr = string, *outptr = converted;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
170 int inleft = strlen(string), outleft = maxlen;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
171 GIConv conv;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
172
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
173 conv = g_iconv_open(gc->account->proto_opt[USEROPT_CHARSET], "UTF-8");
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
174 if (g_iconv(conv, &inptr, &inleft, &outptr, &outleft) == -1) {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
175 debug_printf("IRC charset conversion error\n");
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
176 debug_printf("Sending as UTF-8 (this is a hack!)\n");
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
177 g_free(converted);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
178 *done = maxlen;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
179 return(g_strndup(string, maxlen));
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
180 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
181
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
182 *done = strlen(string) - inleft;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
183 *outptr = '\0';
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
184 return(converted);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
185 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
186
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
187 static char *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
188 irc_recv_convert(struct gaim_connection *gc, char *string)
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
189 {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
190 char *utf8;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
191 GError *err = NULL;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
192
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
193 utf8 = g_convert(string, strlen(string), "UTF-8",
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
194 gc->account->proto_opt[USEROPT_CHARSET], NULL, NULL, &err);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
195 if (err) {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
196 debug_printf("IRC recv conversion error: %s\n", err->message);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
197 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)"));
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
198 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
199
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
200 return (utf8);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
201 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
202
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
203 static struct gaim_conversation *
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
204 irc_find_chat(struct gaim_connection *gc, char *name)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
205 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
206 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
208 while (bcs) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
209 struct gaim_conversation *b = bcs->data;
2331
1ea2792b6004 [gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2328
diff changeset
210 if (!g_strcasecmp(b->name, name))
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
211 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
212 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
213 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
214 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
215 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
216
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
217 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
218 process_data_init(char *buf, char *cmd, char *word[], char *eol[], gboolean quotes)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
219 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
220 int wordcount = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
221 gboolean space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
222 gboolean quote = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
223 int j = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
224
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
225 word[1] = cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
226 eol[1] = buf;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
227
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
228 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
229 switch (*cmd) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
230 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
231 buf[j] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
232 for (j = wordcount; j < PDIWORDS; j++) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
233 word[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
234 eol[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
235 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
236 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
237 case '"':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
238 if (!quotes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
239 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
240 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
241 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
242 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
243 quote = !quote;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
244 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
245 case ' ':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
246 if (quote) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
247 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
248 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
249 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
250 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
251 if (space)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
252 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
253 buf[j++] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
254 word[wordcount] = &buf[j];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
255 eol[wordcount++] = cmd + 1;
2294
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
256 if (wordcount == PDIWORDS - 1) {
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
257 buf[j] = 0;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
258 return;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
259 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
260 space = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
261 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
262 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
263 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
264 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
265 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
266 cmd++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
267 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
268 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
269
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
270 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
271 handle_005(struct gaim_connection *gc, char *word[], char *word_eol[])
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
272 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
273 int w = 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
274 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
275
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
276 while (w < PDIWORDS && *word[w]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
277 if (!strncmp(word[w], "MODES=", 5)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
278 if (atoi(word[w] + 6) >= 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
279 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
280 } else if (!strncmp(word[w], "CHANTYPES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
281 g_free(id->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
282 id->chantypes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
283 } else if (!strncmp(word[w], "CHANMODES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
284 g_free(id->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
285 id->chanmodes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
286 } else if (!strncmp(word[w], "PREFIX=", 7)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
287 char *pre = strchr(word[w] + 7, ')');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
288 if (pre) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
289 *pre = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
290 g_free(id->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
291 id->nickmodes = g_strdup(word[w] + 8);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
292 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
293 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
294 w++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
295 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
296 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
297
4221
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
298 static const char *irc_colors[] = {
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
299 "#000000", "#ffffff", "#000066", "#006600",
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
300 "#ff0000", "#660000", "#660066", "#666600",
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
301 "#cccc00", "#33cc33", "#00acac", "#00ccac",
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
302 "#0000ff", "#cc00cc", "#666666", "#00ccac"
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
303 };
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
304
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
305 #define int_to_col(c) (irc_colors[(((c)<0 || (c)> 15)?0:c)])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
307 static GString *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
308 encode_html(char *msg)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
309 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
310 GString *str = g_string_new("");
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
311 char *cur = msg, *end = msg;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
312 gboolean bold = FALSE, underline = FALSE, italics = FALSE;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
313
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
314 while ((end = strchr(cur, '<'))) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
315 *end = 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
316 str = g_string_append(str, cur);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
317 cur = ++end;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
318 if (!g_strncasecmp(cur, "B>", 2)) {
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
319 if (!bold) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
320 bold = TRUE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
321 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
322 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
323 cur = cur + 2;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
324 } else if (!g_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
325 if (!italics) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
326 italics = TRUE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
327 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
328 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
329 cur = cur + 2;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
330 } else if (!g_strncasecmp(cur, "U>", 2)) {
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
331 if (!underline) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
332 underline = TRUE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
333 str = g_string_append_c(str, '\37');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
334 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
335 cur = cur + 2;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
336 } else if (!g_strncasecmp(cur, "/B>", 3)) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
337 if (bold) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
338 bold = FALSE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
339 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
340 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
341 cur = cur + 3;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
342 } else if (!g_strncasecmp(cur, "/I>", 3)) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
343 if (italics) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
344 italics = FALSE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
345 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
346 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
347 cur = cur + 3;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
348 } else if (!g_strncasecmp(cur, "/U>", 3)) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
349 if (underline) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
350 underline = FALSE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
351 str = g_string_append_c(str, '\37');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
352 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
353 cur = cur + 3;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
354 } else {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
355 str = g_string_append_c(str, '<');
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
356 }
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
357
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
358 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
359 str = g_string_append(str, cur);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
360 return str;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
361 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
362
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
363 static GString *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
364 decode_html(char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
366 GString /* oo la la */ *str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
367 char *cur = msg, *end = msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
368 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
369 int fore, back;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
370 while (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
371 switch (*end) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
372 case 02: /* ^B */
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
373 *end = 0;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
374 str = g_string_append(str, cur);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
375 if (bold)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
376 str = g_string_append(str, "</B>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
377 else
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
378 str = g_string_append(str, "<B>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
379 bold = !bold;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
380 cur = end + 1;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
381 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
382 case 03: /* ^C */
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
383 *end++ = 0;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
384 str = g_string_append(str, cur);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
385 fore = back = -1;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
386 if (isdigit(*end)) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
387 fore = *end++ - '0';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
388 if (isdigit(*end)) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
389 fore *= 10;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
390 fore += *end++ - '0';
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
391 }
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
392 if (*end == ',' && isdigit(end[1])) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
393 end++;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
394 back = *end++ - '0';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
395 if (isdigit(*end)) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
396 back *= 10;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
397 back += *end++ - '0';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
398 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
399 }
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
400 }
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
401 if (fore == -1) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
402 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
403 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
404 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
405 str = g_string_append(str, "</FONT>");
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
406 fg = bg = FALSE;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
407 } else {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
408 fore %= 16;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
409 if (fg)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
410 str = g_string_append(str, "</FONT>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
411 if (back != -1) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
412 if (bg)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
413 str = g_string_append(str, "</FONT>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
414 back %= 16;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
415 str = g_string_append(str, "<FONT BACK=");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
416 str = g_string_append(str, int_to_col(back));
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
417 str = g_string_append_c(str, '>');
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
418 bg = TRUE;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
419 }
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
420 str = g_string_append(str, "<FONT COLOR=");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
421 str = g_string_append(str, int_to_col(fore));
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
422 str = g_string_append_c(str, '>');
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
423 fg = TRUE;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
424 }
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
425 cur = end--;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
426 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
427 case 017: /* ^O */
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
428 if (!bold && !underline && !fg && !bg)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
429 break;
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
430 *end = 0;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
431 str = g_string_append(str, cur);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
432 if (bold)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
433 str = g_string_append(str, "</B>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
434 if (underline)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
435 str = g_string_append(str, "</U>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
436 if (fg)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
437 str = g_string_append(str, "</FONT>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
438 if (bg)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
439 str = g_string_append(str, "</FONT>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
440 bold = underline = fg = bg = FALSE;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
441 cur = end + 1;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
442 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
443 case 037: /* ^_ */
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
444 *end = 0;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
445 str = g_string_append(str, cur);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
446 if (underline)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
447 str = g_string_append(str, "</U>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
448 else
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
449 str = g_string_append(str, "<U>");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
450 underline = !underline;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
451 cur = end + 1;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
452 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
453 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
454 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
455 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
456 if (*cur)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
457 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
458 return str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
459 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
461 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
462 irc_got_im(struct gaim_connection *gc, char *who, char *what, int flags, time_t t)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
463 {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
464 char *utf8 = irc_recv_convert(gc, what);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
465 GString *str = decode_html(utf8);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2847
diff changeset
466 serv_got_im(gc, who, str->str, flags, t, -1);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
467 g_string_free(str, TRUE);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
468 g_free(utf8);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
469 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
470
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
471 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
472 dcc_chat_cancel(struct dcc_chat *);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
473
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
474 void
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
475 dcc_chat_in (gpointer data, gint source, GaimInputCondition condition)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
476 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
477 struct dcc_chat *chat = data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
478 gchar buffer[IRC_BUF_LEN];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
479 gchar buf[128];
3793
ed3e19143373 [gaim-migrate @ 3933]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
480 int n = 0;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
481 struct gaim_conversation *convo;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
482 debug_printf("THIS IS TOO MUCH EFFORT\n");
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
483 n = read (chat->fd, buffer, IRC_BUF_LEN);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
484 if (n > 0) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
485
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
486 buffer[n] = 0;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
487 g_strstrip(buffer);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
488
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
489 /* Convert to HTML */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
490 if (strlen(buffer)) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
491 debug_printf ("DCC Message from: %s\n", chat->nick);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
492 irc_got_im(chat->gc, chat->nick, buffer, 0,
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
493 time(NULL));
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
494 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
495 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
496 else {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
497 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"),
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
498 chat->nick);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
499 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account,
4476
62c1e5e656d0 [gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents: 4456
diff changeset
500 chat->nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
501 gaim_conversation_write(convo, NULL, buf, -1, WFLAG_SYSTEM,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
502 time(NULL));
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
503 dcc_chat_cancel (chat);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
504 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
505 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
506
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
507 void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
508 irc_read_dcc_ack (gpointer data, gint source, GaimInputCondition condition) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
509 /* Read ACK Here */
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
510
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
511 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
512
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
513 void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
514 dcc_send_callback (gpointer data, gint source, GaimInputCondition condition) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
515 #if 0
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
516 struct irc_file_transfer *ift = data;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
517 struct sockaddr_in addr;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
518 int len = sizeof(addr);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
519
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
520 addr.sin_family = AF_INET;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
521 addr.sin_port = htons(ift->port);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
522 addr.sin_addr.s_addr = INADDR_ANY;
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
523
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
524 ift->fd = accept(ift->fd, (struct sockaddr *)&addr, &len);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
525 if (!ift->fd) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
526 /* FIXME: Handle this gracefully XXX */
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
527 printf("Something bad happened here, bubba!\n");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
528 return;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
529 }
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
530
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
531 /* ift->awatcher = gaim_input_add(ift->fd, GAIM_INPUT_READ, irc_read_dcc_ack, ift); */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
532
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
533 if (transfer_out_do(ift->xfer, ift->fd, 0)) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
534 gaim_input_remove(ift->watcher);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
535 ift->watcher = 0;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
536 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
537 #endif
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
538 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
539
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
540 void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
541 dcc_chat_callback (gpointer data, gint source, GaimInputCondition condition) {
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
542 struct dcc_chat *chat = data;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
543 struct gaim_conversation *convo;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
544 char buf[IRC_BUF_LEN];
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
545
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
546 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account, chat->nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
547
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
548 chat->fd = source;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
549 g_snprintf (buf, sizeof buf,
4221
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
550 _("DCC Chat with %s established"),
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
551 chat->nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
552 gaim_conversation_write(convo, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
553 debug_printf ("Chat with %s established\n", chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
554 dcc_chat_list = g_slist_append (dcc_chat_list, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
555 gaim_input_remove(chat->inpa);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
556 chat->inpa = gaim_input_add(source, GAIM_INPUT_READ, dcc_chat_in, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
557 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
558
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
559 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
560 irc_got_chat_in(struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t t)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
561 {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
562 char *utf8 = irc_recv_convert(gc, msg);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
563 GString *str = decode_html(utf8);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
564 serv_got_chat_in(gc, id, who, whisper, str->str, t);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
565 g_string_free(str, TRUE);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
566 g_free(utf8);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
567 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
568
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
569 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
570 handle_list(struct gaim_connection *gc, char *list)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
571 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
572 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
573 GSList *gr;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
574
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
575 id->str = g_string_append_c(id->str, ' ');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
576 id->str = g_string_append(id->str, list);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
577 id->bc--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
578 if (id->bc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
579 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
580
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
581 g_strdown(id->str->str);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
582 gr = groups;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
583 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
584 GSList *m = ((struct group *)gr->data)->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
585 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
586 struct buddy *b = m->data;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
587 if(b->account->gc == gc) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
588 char *tmp = g_strdup(b->name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
589 char *x, *l;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
590 g_strdown(tmp);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
591 x = strstr(id->str->str, tmp);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
592 l = x + strlen(b->name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
593 if (x && (*l != ' ' && *l != 0))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
594 x = 0;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
595 if (!b->present && x)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
596 serv_got_update(gc, b->name, 1, 0, 0, 0, 0, 0);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
597 else if (b->present && !x)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
598 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
599 g_free(tmp);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
600 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
601 m = m->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
603 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
605 g_string_free(id->str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
606 id->str = g_string_new("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
609 static gboolean
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
610 irc_request_buddy_update(gpointer data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 {
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
612 struct gaim_connection *gc = data;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
613 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
614 char buf[500];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
615 int n = g_snprintf(buf, sizeof(buf), "ISON");
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
616 gboolean found = FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
618 GSList *gr = groups;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
619 if (!gr || id->bc)
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
620 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
622 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
623 struct group *g = gr->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
624 GSList *m = g->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
625 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
626 struct buddy *b = m->data;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
627 if(b->account->gc == gc) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
628 if (n + strlen(b->name) + 2 > sizeof(buf)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
629 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
630 irc_write(id->fd, buf, n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
631 id->bc++;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
632 n = g_snprintf(buf, sizeof(buf), "ISON");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
633 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4249
diff changeset
634 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name);
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
635
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
636 found = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
637 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
638 m = m->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
639 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
640 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 }
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
642
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
643 if (found) {
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
644 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
645 irc_write(id->fd, buf, strlen(buf));
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
646 id->bc++;
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
647 }
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
648
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
649 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
652 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
653 handle_names(struct gaim_connection *gc, char *chan, char *names)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
655 struct gaim_conversation *c = irc_find_chat(gc, chan);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
656 struct gaim_chat *chat;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
657 char **buf, **tmp;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
658
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
659 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
660 if (*names == ':') names++;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
661
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
662 chat = GAIM_CHAT(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
663
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
664 buf = g_strsplit(names, " ", -1);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
665
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
666 for (tmp = buf; *tmp; tmp++)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
667 gaim_chat_add_user(chat, *tmp, NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
668
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
669 g_strfreev(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
672 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
673 handle_notopic(struct gaim_connection *gc, char *text)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
674 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
675 struct gaim_conversation *c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
676
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
677 if ((c = irc_find_chat(gc, text))) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
678 char buf[IRC_BUF_LEN];
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
679
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
680 g_snprintf(buf, sizeof(buf), _("No topic is set"));
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
681
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
682 gaim_chat_set_topic(GAIM_CHAT(c), NULL, buf);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
683 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
684 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
685
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
686 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
687 handle_topic(struct gaim_connection *gc, char *text)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
689 struct gaim_conversation *c;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
690 char *po = strchr(text, ' ');
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
692 if (!po)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
693 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
695 *po = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
696 po += 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
698 if ((c = irc_find_chat(gc, text))) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
699 char buf[IRC_BUF_LEN];
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
700 gaim_chat_set_topic(GAIM_CHAT(c), NULL, po);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
701 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"),
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
702 text, po);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
703
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
704 gaim_conversation_write(c, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
705 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
708 static gboolean
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
709 mode_has_arg(struct gaim_connection *gc, char sign, char mode)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
711 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
712 char *cm = id->chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
713 int type = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
715 if (strchr(id->nickmodes, mode))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
716 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
718 while (*cm) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
719 if (*cm == ',')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
720 type++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
721 else if (*cm == mode) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
722 switch (type) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
723 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
724 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
725 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
726 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
727 if (sign == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
728 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
729 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
730 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
731 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
732 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
733 cm++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
736 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
737 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
739 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
740 irc_chan_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *argstr, char *who)
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
741 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
742 struct gaim_conversation *c = irc_find_chat(gc, room);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
743 char buf[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
744 char *nick = g_strndup(who, strchr(who, '!') - who);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
745
4221
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
746 g_snprintf(buf, sizeof(buf), _("-:- mode/%s [%c%c %s] by %s"),
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
747 room, sign, mode, strlen(argstr) ? argstr : "",
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
748 nick);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
749 g_free(nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
750
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
751 gaim_conversation_write(c, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
752 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
753
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
754 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
755 irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
756 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
757 struct gaim_conversation *c = irc_find_chat(gc, room);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
758 GList *r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
760 if (mode != 'o' && mode != 'v' && mode != 'h')
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
761 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
763 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
764 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
766 r = gaim_chat_get_users(GAIM_CHAT(c));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
767 while (r) {
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
768 gboolean op = FALSE, halfop = FALSE, voice = FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
769 char *who = r->data;
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
770
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
771 if (*who == '@') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
772 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
773 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 }
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
775
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
776 if (*who == '%') {
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
777 halfop = TRUE;
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
778 who++;
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
779 }
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
780
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
781 if (*who == '+') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
782 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
783 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 }
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
785
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
786 if (!strcmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
787 char *tmp, buf[IRC_BUF_LEN];
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
788
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
789 if (mode == 'o') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
790 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
791 op = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
792 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
793 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
794 }
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
795
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
796 if (mode == 'h') {
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
797 if (sign == '-')
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
798 halfop = FALSE;
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
799 else
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
800 halfop = TRUE;
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
801 }
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
802
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
803 if (mode == 'v') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
804 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
805 voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
806 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
807 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
808 }
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
809
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
810 tmp = g_strdup(r->data);
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
811 g_snprintf(buf, sizeof(buf), "%s%s%s",
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
812 (op ? "@" : (halfop ? "%" : "")),
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
813 voice ? "+" : "", nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
814 gaim_chat_rename_user(GAIM_CHAT(c), tmp, buf);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
815 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
816 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
818 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
819 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
820 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
822 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
823 handle_mode(struct gaim_connection *gc, char *word[], char *word_eol[], gboolean n324)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
824 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
825 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
826 int offset = n324 ? 4 : 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
827 char *chan = word[offset];
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
828 struct gaim_conversation *c = irc_find_chat(gc, chan);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
829 char *modes = word[offset + 1];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
830 int len = strlen(word_eol[offset]) - 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
831 char sign = *modes++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
832 int arg = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
833 char *argstr;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
834 char *who = word[1];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
835
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
836 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
837 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
838
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
839 if (word_eol[offset][len] == ' ')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
840 word_eol[offset][len] = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
842 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
843 switch (*modes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
844 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
845 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
846 case '+':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
847 case '-':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
848 sign = *modes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
849 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
850 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
851 if (mode_has_arg(gc, sign, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
852 argstr = word[++arg + offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
853 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
854 argstr = "";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
855 if (strchr(id->nickmodes, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
856 irc_user_mode(gc, chan, sign, *modes, argstr);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
857 else if (strchr(who, '!'))
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
858 irc_chan_mode(gc, chan, sign, *modes, argstr, who);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
859 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
860 modes++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862 }
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
863
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
864 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
865 handle_version(struct gaim_connection *gc, char *word[], char *word_eol[], int num)
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
866 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
867 struct irc_data *id = gc->proto_data;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
868 GString *str;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
869
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
870 id->liststr = g_string_new("");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
871
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
872 id->liststr = g_string_append(id->liststr, "<b>Version: </b>");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
873 id->liststr = g_string_append(id->liststr, word_eol[4]);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
874
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
875 str = decode_html(id->liststr->str);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
876 g_show_info_text(gc, NULL, 2, str->str, NULL);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
877 g_string_free(str, TRUE);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
878 g_string_free(id->liststr, TRUE);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
879 id->liststr = NULL;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
880 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
881
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
882 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
883 handle_who(struct gaim_connection *gc, char *word[], char *word_eol[], int num)
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
884 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
885 struct irc_data *id = gc->proto_data;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
886 char buf[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
887
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
888 if (!id->in_whois) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
889 id->in_whois = TRUE;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
890 id->liststr = g_string_new("");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
891 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
892
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
893 switch (num) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
894 case 352:
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
895 g_snprintf(buf, sizeof(buf), "<b>%s</b> (%s@%s): %s<br>",
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
896 word[8], word[5], word[6], word_eol[11]);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
897 id->liststr = g_string_append(id->liststr, buf);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
898 break;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
899 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
900 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
901
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
902 /* Handle our whois stuff here. You know what, I have a sore throat. You know
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
903 * what I think about that? I'm not too pleased with it. Perhaps I should take
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
904 * some medicine, or perhaps I should go to bed? Blah!! */
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
905
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
906 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
907 handle_whois(struct gaim_connection *gc, char *word[], char *word_eol[], int num)
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
908 {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
909 struct irc_data *id = gc->proto_data;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
910 char tmp[1024];
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
911
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
912 if (!id->in_whois) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
913 id->in_whois = TRUE;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
914 id->liststr = g_string_new("");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
915 } else {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
916 /* I can't decide if we should have one break or two */
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
917 id->liststr = g_string_append(id->liststr, "<BR>");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
918 id->in_whois = TRUE;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
919 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
920
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
921 switch (num) {
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
922 case 311:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
923 id->liststr = g_string_append(id->liststr, "<b>User: </b>");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
924 break;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
925 case 312:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
926 id->liststr = g_string_append(id->liststr, "<b>Server: </b>");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
927 break;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
928 case 313:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
929 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
930 id->liststr = g_string_append(id->liststr, tmp);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
931 break;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
932 case 314:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
933 id->liststr = g_string_append(id->liststr, "<b>User: </b>");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
934 g_snprintf(tmp, sizeof(tmp), "<b>%s</b> (%s@%s) %s",
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
935 word[4], word[5], word[6], word_eol[8]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
936 id->liststr = g_string_append(id->liststr, tmp);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
937 return;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
938 case 317:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
939 id->liststr = g_string_append(id->liststr, "<b>Idle Time: </b>");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
940 break;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
941 case 319:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
942 id->liststr = g_string_append(id->liststr, "<b>Channels: </b>");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
943 break;
4509
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
944 /* Numeric 320 is used by the freenode irc network for showing
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
945 * that a user is identified to services (Jason Straw <misato@wopn.org>)*/
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
946 case 320:
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
947 g_snprintf(tmp, sizeof(tmp), "%s is an Identified User", word[4]);
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
948 id->liststr = g_string_append(id->liststr, tmp);
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
949 return;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
950 default:
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
951 break;
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
952 }
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
953
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
954 if (word_eol[5][0] == ':')
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
955 id->liststr = g_string_append(id->liststr, word_eol[5] + 1);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
956 /* Nicer idle time output, by jonas@birme.se */
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
957 else if (isdigit(word_eol[5][0])) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
958 time_t idle = atol(word_eol[5]);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
959 time_t signon = atol(strchr(word_eol[5], ' '));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
960
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
961 g_snprintf(tmp, sizeof(tmp),
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
962 "%ld seconds [signon: %s]", (idle / 1000), ctime(&signon));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
963 id->liststr = g_string_append(id->liststr, tmp);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
964 }
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
965 else
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
966 id->liststr = g_string_append(id->liststr, word_eol[5]);
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
967 }
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
968
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
969 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
970 handle_roomlist(struct gaim_connection *gc, char *word[], char *word_eol[])
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
971 {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
972 struct irc_data *id = gc->proto_data;
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
973
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
974 if (!id->in_list) {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
975 id->in_list = TRUE;
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
976 id->liststr = g_string_new("");
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
977 } else {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
978 id->liststr = g_string_append(id->liststr, "<BR>");
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
979 id->in_list = TRUE;
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
980 }
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
981
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
982 id->liststr = g_string_append(id->liststr, word_eol[4]);
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
983 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
984
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
985 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
986 irc_change_nick(void *a, char *b) {
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
987 struct gaim_connection *gc = a;
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
988 struct irc_data *id = gc->proto_data;
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
989 char buf[IRC_BUF_LEN];
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
990 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", b);
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
991 irc_write(id->fd, buf, strlen(buf));
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
992 }
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
993
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
994 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
995 process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
997 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
998 char *text = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
999 int n = atoi(word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1000
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1001 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname)))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1002 text += strlen(gc->displayname) + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1003 if (*text == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1004 text++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1006 /* RPL_ and ERR_ */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1007 switch (n) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1008 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1009 if (!strncmp(word[5], "u2.10", 5))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1010 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1011 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1012 id->six_modes = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1013 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1014 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1015 handle_005(gc, word, word_eol);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1016 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1017 case 301: /* RPL_AWAY */
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1018 if (id->in_whois) {
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1019 id->liststr = g_string_append(id->liststr, "<BR><b>Away: </b>");
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
1020
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
1021 if (word_eol[5][0] == ':')
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1022 id->liststr = g_string_append(id->liststr, word_eol[5] + 1);
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
1023 else
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1024 id->liststr = g_string_append(id->liststr, word_eol[5]);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1025 } else
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1026 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1027 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1028 case 303: /* RPL_ISON */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1029 handle_list(gc, &word_eol[4][1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1030 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1031 case 311: /* RPL_WHOISUSER */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1032 case 312: /* RPL_WHOISSERVER */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1033 case 313: /* RPL_WHOISOPERATOR */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1034 case 314: /* RPL_WHOWASUSER */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1035 case 317: /* RPL_WHOISIDLE */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1036 case 319: /* RPL_WHOISCHANNELS */
4509
cf2f5a1f1e46 [gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1037 case 320: /* FreeNode Identified */
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
1038 handle_whois(gc, word, word_eol, n);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1039 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1040 case 322: /* RPL_LIST */
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1041 handle_roomlist(gc, word, word_eol);
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1042 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1043 case 315: /* RPL_ENDOFWHO */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1044 case 318: /* RPL_ENDOFWHOIS */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1045 case 323: /* RPL_LISTEND */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1046 case 369: /* RPL_ENDOFWHOWAS */
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1047 if ((id->in_whois || id->in_list) && id->liststr) {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1048 GString *str = decode_html(id->liststr->str);
2791
8f6365332a05 [gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2782
diff changeset
1049 g_show_info_text(gc, NULL, 2, str->str, NULL);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1050 g_string_free(str, TRUE);
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1051 g_string_free(id->liststr, TRUE);
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1052 id->liststr = NULL;
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
1053 id->in_whois = FALSE;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1054 id->in_list = FALSE;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1055 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1056 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1057 case 324: /* RPL_CHANNELMODEIS */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1058 handle_mode(gc, word, word_eol, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1059 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1060 case 331: /* RPL_NOTOPIC */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1061 handle_notopic(gc, text);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1062 break;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1063 case 332: /* RPL_TOPIC */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1064 handle_topic(gc, text);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1065 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1066 case 351: /* RPL_VERSION */
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1067 handle_version(gc, word, word_eol, n);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1068 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1069 case 352: /* RPL_WHOREPLY */
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1070 handle_who(gc, word, word_eol, n);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1071 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1072 case 353: /* RPL_NAMREPLY */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1073 handle_names(gc, word[5], word_eol[6]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1074 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1075 case 376: /* RPL_ENDOFMOTD */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1076 irc_request_buddy_update(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1077 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1078 case 382: /* RPL_REHASHING */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1079 do_error_dialog(_("Rehashing server"), _("IRC Operator"), GAIM_ERROR);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1080 break;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1081 case 401: /* ERR_NOSUCHNICK */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1082 do_error_dialog(_("No such nick/channel"), _("IRC Error"), GAIM_ERROR);
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
1083 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1084 case 402: /* ERR_NOSUCHSERVER */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1085 do_error_dialog(_("No such server"), _("IRC Error"), GAIM_ERROR);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1086 case 431: /* ERR_NONICKNAMEGIVEN */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1087 do_error_dialog(_("No nickname given"), _("IRC Error"), GAIM_ERROR);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1088 break;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1089 case 481: /* ERR_NOPRIVILEGES */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1090 do_error_dialog(_("You're not an IRC operator!"), _("IRC Error"), GAIM_ERROR);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1091 break;
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
1092 case 433:
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
1093 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL);
3605
1066e65b1a18 [gaim-migrate @ 3718]
Sean Egan <seanegan@gmail.com>
parents: 3599
diff changeset
1094 break;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1095 default:
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1096 /* Other error messages */
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1097 if (n > 400 && n < 502) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1098 char errmsg[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1099 char *errmsg1 = strrchr(text, ':');
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1100 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1101 if (errmsg)
3536
f4cec5d41a89 [gaim-migrate @ 3610]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
1102 do_error_dialog(errmsg, errmsg1 ? errmsg1+1 : NULL, GAIM_ERROR);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1103 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1104 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1106 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1108 static gboolean
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1109 is_channel(struct gaim_connection *gc, char *name)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1110 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1111 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1112 if (strchr(id->chantypes, *name))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1113 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1114 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1117 static void
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1118 irc_rem_chat_bud(struct gaim_connection *gc, char *nick, struct gaim_conversation *b, char *reason)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1121 struct gaim_chat *chat;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1122
4067
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1123 if (b) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1124 GList *r;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1125
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1126 chat = GAIM_CHAT(b);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1127
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1128 r = gaim_chat_get_users(chat);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1129
4067
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1130 while (r) {
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1131 char *who = r->data;
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1132 if (*who == '@')
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1133 who++;
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
1134 if (*who == '%')
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
1135 who++;
4067
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1136 if (*who == '+')
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1137 who++;
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1138 if (!g_strcasecmp(who, nick)) {
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1139 char *tmp = g_strdup(r->data);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1140 gaim_chat_remove_user(chat, tmp, reason);
4067
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1141 g_free(tmp);
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1142 break;
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1143 }
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1144 r = r->next;
4065
1590dfa0ecba [gaim-migrate @ 4275]
Sean Egan <seanegan@gmail.com>
parents: 3914
diff changeset
1145 }
4067
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1146 } else {
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1147 GSList *bcs = gc->buddy_chats;
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1148 while (bcs) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1149 struct gaim_conversation *bc = bcs->data;
4067
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1150 irc_rem_chat_bud(gc, nick, bc, reason);
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1151 bcs = bcs->next;
bb4aabb9ba53 [gaim-migrate @ 4279]
Sean Egan <seanegan@gmail.com>
parents: 4065
diff changeset
1152 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1156 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1157 irc_change_name(struct gaim_connection *gc, char *old, char *new)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1158 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1159 GSList *bcs = gc->buddy_chats;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1160 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1162 while (bcs) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1163 struct gaim_conversation *b = bcs->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1164 struct gaim_chat *chat;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1165 GList *r;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1166
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1167 chat = GAIM_CHAT(b);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1168
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1169 r = gaim_chat_get_users(chat);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1170
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1171 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1172 char *who = r->data;
2292
6625d0755c51 [gaim-migrate @ 2302]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2291
diff changeset
1173 int n = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1174 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1175 buf[n++] = *who++;
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
1176 if (*who == '%')
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
1177 buf[n++] = *who++;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1178 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1179 buf[n++] = *who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1180 g_snprintf(buf + n, sizeof(buf) - n, "%s", new);
2312
766603034af8 [gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2310
diff changeset
1181 if (!strcmp(who, old)) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1182 char *tmp = g_strdup(r->data);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1183 gaim_chat_rename_user(chat, tmp, buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1184 r = gaim_chat_get_users(chat);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1185 g_free(tmp);
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2687
diff changeset
1186 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1187 } else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1188 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1189 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1190 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1191 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1192 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1194 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1195 handle_privmsg(struct gaim_connection *gc, char *to, char *nick, char *msg)
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1196 {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1197 if (is_channel(gc, to)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1198 struct gaim_conversation *c = irc_find_chat(gc, to);
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1199 if (!c)
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1200 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1201 irc_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(c)),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1202 nick, 0, msg, time(NULL));
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1203 } else {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1204 char *tmp = g_malloc(strlen(nick) + 2);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1205 g_snprintf(tmp, strlen(nick) + 2, "@%s", nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1206 if (gaim_find_conversation(tmp))
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1207 irc_got_im(gc, tmp, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1208 else {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1209 *tmp = '+';
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1210 if (gaim_find_conversation(tmp))
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1211 irc_got_im(gc, tmp, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1212 else
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1213 irc_got_im(gc, nick, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1214 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1215 g_free(tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1216 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1217 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1218
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1219 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1220 dcc_chat_init(struct dcc_chat *data) {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1221 if (g_slist_find(connections, data->gc)) {
4634
d19872836812 [gaim-migrate @ 4941]
Nathan Walp <nwalp@pidgin.im>
parents: 4621
diff changeset
1222 proxy_connect(data->gc->account, data->ip_address, data->port, dcc_chat_callback, data);
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1223 } else {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1224 g_free(data);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1225 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1226 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1227
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1228 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1229 dcc_chat_cancel(struct dcc_chat *data){
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1230 if (g_slist_find(connections, data->gc) && find_dcc_chat(data->gc, data->nick)) {
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1231 dcc_chat_list = g_slist_remove(dcc_chat_list, data);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1232 gaim_input_remove (data->inpa);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1233 close (data->fd);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1234 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1235 g_free(data);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1236 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1237
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1238 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1239 irc_convo_closed(struct gaim_connection *gc, char *who)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1240 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1241 struct dcc_chat *dchat = find_dcc_chat(gc, who);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1242 if (!dchat)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1243 return;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1244
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1245 dcc_chat_cancel(dchat);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1246 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1247
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1248 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1249 irc_xfer_init(struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1250 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1251 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1252
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1253 gaim_xfer_start(xfer, -1, data->ip, data->port);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1254 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1255
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1256 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1257 irc_xfer_end(struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1258 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1259 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1260
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1261 data->idata->file_transfers = g_slist_remove(data->idata->file_transfers,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1262 xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1263
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1264 g_free(data);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1265 xfer->data = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1266 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1267
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1268 static void
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1269 irc_xfer_cancel_send(struct gaim_xfer *xfer)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1270 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1271 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1272
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1273 data->idata->file_transfers = g_slist_remove(data->idata->file_transfers,
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1274 xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1275
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1276 g_free(data);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1277 xfer->data = NULL;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1278 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1279
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1280 static void
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1281 irc_xfer_cancel_recv(struct gaim_xfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1282 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1283 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1284
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1285 data->idata->file_transfers = g_slist_remove(data->idata->file_transfers,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1286 xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1287
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1288 g_free(data);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1289 xfer->data = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1290 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1291
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1292 static void
4594
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4552
diff changeset
1293 irc_xfer_ack(struct gaim_xfer *xfer, const char *buffer, size_t size)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1294 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1295 guint32 pos;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1296
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1297 pos = htonl(gaim_xfer_get_bytes_sent(xfer));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1298
4552
a2f2a717fdf2 [gaim-migrate @ 4832]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
1299 write(xfer->fd, (char *)&pos, 4);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1300 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1301
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1302 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1303 handle_ctcp(struct gaim_connection *gc, char *to, char *nick,
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1304 char *msg, char *word[], char *word_eol[])
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1305 {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1306 struct irc_data *id = gc->proto_data;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1307 char buf[IRC_BUF_LEN];
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1308 char out[IRC_BUF_LEN];
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1309
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1310 if (!g_strncasecmp(msg, "VERSION", 7)) {
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1311 g_snprintf(buf, sizeof(buf), "\001VERSION Gaim " VERSION ": The Penguin Pimpin' "
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1312 "Multi-protocol Messaging Client: " WEBSITE "\001");
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1313 irc_send_notice (gc, nick, buf);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1314 g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1315 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1316 }
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1317 if (!g_strncasecmp(msg, "CLIENTINFO", 10)) {
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1318 g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001");
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1319 irc_send_notice (gc, nick, buf);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1320 g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1321 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1322 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1323 if (!g_strncasecmp(msg, "USERINFO", 8)) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1324 g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1325 irc_send_notice (gc, nick, buf);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1326 g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1327 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1328 }
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1329 if (!g_strncasecmp(msg, "ACTION", 6)) {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1330 char *po = strchr(msg + 6, 1);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1331 char *tmp;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1332 if (po) *po = 0;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1333 tmp = g_strconcat("/me", msg + 6, NULL);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1334 handle_privmsg(gc, to, nick, tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1335 g_free(tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1336 }
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1337 if (!g_strncasecmp(msg, "PING", 4)) {
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1338 g_snprintf(buf, sizeof(buf), "\001%s\001", msg);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1339 irc_send_notice (gc, nick, buf);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1340 g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1341 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1342 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1343 if (!g_strncasecmp(msg, "DCC CHAT", 8)) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1344 char **chat_args = g_strsplit(msg, " ", 5);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1345 char ask[1024];
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1346 struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1347 dccchat->gc = gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1348 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1349 dccchat->port=atoi(chat_args[4]);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1350 g_snprintf(dccchat->nick, sizeof(dccchat->nick), nick);
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1351 g_snprintf(ask, sizeof(ask), _("%s would like to establish a DCC chat"), nick);
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1352 do_ask_dialog(ask, _("This requires a direct connection to be established between the two computers. Messages sent will not pass through the IRC server"), dccchat, _("Connect"), dcc_chat_init, _("Cancel"), dcc_chat_cancel, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1353 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1354
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1355
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1356 if (!g_strncasecmp(msg, "DCC SEND", 8)) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1357 struct gaim_xfer *xfer;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1358 char **send_args;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1359 char *ip, *filename;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1360 struct irc_xfer_data *xfer_data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1361 size_t size;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1362 int port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1363
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1364 send_args = g_strsplit(msg, " ", 6);
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1365 send_args[5][strlen(send_args[5])-1] = 0;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1366
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1367 /* Give these better names. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1368 ip = send_args[3];
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1369 filename = send_args[2];
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1370 size = atoi(send_args[5]);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1371 port = atoi(send_args[4]);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1372
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1373 /* Setup the IRC-specific transfer data. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1374 xfer_data = g_malloc0(sizeof(struct irc_xfer_data));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1375 xfer_data->ip = ip;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1376 xfer_data->port = port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1377 xfer_data->idata = id;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1378
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1379 /* Build the file transfer handle. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1380 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, nick);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1381 xfer->data = xfer_data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1382
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1383 /* Set the info about the incoming file. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1384 gaim_xfer_set_filename(xfer, filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1385 gaim_xfer_set_size(xfer, size);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1386
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1387 g_free(filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1388
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1389 /* Setup our I/O op functions. */
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1390 gaim_xfer_set_init_fnc(xfer, irc_xfer_init);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1391 gaim_xfer_set_end_fnc(xfer, irc_xfer_end);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1392 gaim_xfer_set_cancel_send_fnc(xfer, irc_xfer_cancel_send);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1393 gaim_xfer_set_cancel_recv_fnc(xfer, irc_xfer_cancel_recv);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
1394 gaim_xfer_set_ack_fnc(xfer, irc_xfer_ack);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1395
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1396 /* Keep track of this transfer for later. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1397 id->file_transfers = g_slist_append(id->file_transfers, xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1398
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1399 /* Now perform the request! */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1400 gaim_xfer_request(xfer);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1401 }
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1402
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
1403 /*write_to_conv(c, out, WFLAG_SYSTEM, NULL, time(NULL), -1);*/
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1404 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1405
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1406 static gboolean
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1407 irc_parse(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1409 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1410 gchar outbuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1411 char *word[PDIWORDS], *word_eol[PDIWORDS];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1412 char pdibuf[522];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1413 char *ex, ip[128], nick[128];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1414 char *cmd;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416 /* Check for errors */
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1417
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1418 if (*buf != ':') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1419 if (!strncmp(buf, "NOTICE ", 7))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1420 buf += 7;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1421 if (!strncmp(buf, "PING ", 5)) {
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1422 int r = FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1423 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1424 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1425 hide_login_progress(gc, _("Unable to write"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1426 signoff(gc);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1427 r = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1428 }
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1429 return r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1431 /* XXX doesn't handle ERROR */
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1432 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434
2782
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1435 if (!idata->online) {
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1436 /* Now lets sign ourselves on */
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1437 account_online(gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1438 serv_finish_login(gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1439
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1440 /* we don't call this now because otherwise some IRC servers might not like us */
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1441 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1442 idata->online = TRUE;
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1443 }
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1444
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1445 buf++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1447 process_data_init(pdibuf, buf, word, word_eol, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1449 if (atoi(word[2])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1450 if (*word_eol[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1451 process_numeric(gc, word, word_eol);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1452 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1455 cmd = word[2];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1457 ex = strchr(pdibuf, '!');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1458 if (!ex) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1459 strncpy(ip, pdibuf, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1460 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1461 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1462 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1463 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1464 strncpy(ip, ex + 1, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1465 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1466 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1467 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1468 if ((ex - pdibuf) < sizeof (nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1469 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1472 if (!strcmp(cmd, "INVITE")) {
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1473 char *chan = g_strdup(word[4]);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1474 serv_got_chat_invite(gc, chan + 1, nick, NULL, g_list_append(NULL, chan));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1475 } else if (!strcmp(cmd, "JOIN")) {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1476 irc_parse_join(gc, nick, word, word_eol);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1477 } else if (!strcmp(cmd, "KICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1478 if (!strcmp(gc->displayname, word[4])) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1479 struct gaim_conversation *c = irc_find_chat(gc, word[3]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1480 if (!c)
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1481 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1482 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1483 gaim_conversation_set_account(c, NULL);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1484 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s: %s"),
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1485 word[3], *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1486 do_error_dialog(outbuf, _("IRC Error"), GAIM_ERROR);
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1487 } else {
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1488 char *reason = *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5];
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1489 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1490 struct gaim_conversation *c = irc_find_chat(gc, word[3]);
4065
1590dfa0ecba [gaim-migrate @ 4275]
Sean Egan <seanegan@gmail.com>
parents: 3914
diff changeset
1491 irc_rem_chat_bud(gc, word[4], c, msg);
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1492 g_free(msg);
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1493 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1494 } else if (!strcmp(cmd, "KILL")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1495 } else if (!strcmp(cmd, "MODE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1496 handle_mode(gc, word, word_eol, FALSE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1497 } else if (!strcmp(cmd, "NICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1498 char *new = *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1499 if (!strcmp(gc->displayname, nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1500 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1501 irc_change_name(gc, nick, new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1502 } else if (!strcmp(cmd, "NOTICE")) {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1503 irc_parse_notice(gc, nick, ex, word, word_eol);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1504 } else if (!strcmp(cmd, "PART")) {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1505 if (!irc_parse_part(gc, nick, cmd, word, word_eol))
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1506 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1507 } else if (!strcmp(cmd, "PRIVMSG")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1508 char *to, *msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1509 if (!*word[3])
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1510 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1511 to = word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1512 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1513 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1514 if (!g_strncasecmp(msg + 1, "DCC ", 4))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1515 process_data_init(pdibuf, buf, word, word_eol, TRUE);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1516 handle_ctcp(gc, to, nick, msg + 1, word, word_eol);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1517 } else {
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1518 handle_privmsg(gc, to, nick, msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1519 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1520 } else if (!strcmp(cmd, "PONG")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1521 } else if (!strcmp(cmd, "QUIT")) {
4065
1590dfa0ecba [gaim-migrate @ 4275]
Sean Egan <seanegan@gmail.com>
parents: 3914
diff changeset
1522 irc_rem_chat_bud(gc, nick, irc_find_chat(gc, word[3]), *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1523 } else if (!strcmp(cmd, "TOPIC")) {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1524 irc_parse_topic(gc, nick, word, word_eol);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1525 } else if (!strcmp(cmd, "WALLOPS")) { /* Don't know if a dialog box is the right way? */
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1526 char *msg = strrchr(word_eol[0], ':');
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1527 if (msg)
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1528 do_error_dialog(msg+1, _("IRC Operator"), GAIM_ERROR);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529 }
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1530
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1531 return FALSE;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1532 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1533
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1534 /* CTCP by jonas@birme.se */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1535 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1536 irc_parse_notice(struct gaim_connection *gc, char *nick, char *ex,
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1537 char *word[], char *word_eol[])
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1538 {
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1539 char buf[IRC_BUF_LEN];
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1540
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1541 if (!g_strcasecmp(word[4], ":\001CLIENTINFO")) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1542 char *p = g_strrstr(word_eol[5], "\001");
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1543 *p = 0;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1544 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1545 do_error_dialog(buf, _("CTCP ClientInfo"), GAIM_INFO);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1546
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1547 } else if (!g_strcasecmp(word[4], ":\001USERINFO")) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1548 char *p = g_strrstr(word_eol[5], "\001");
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1549 *p = 0;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1550 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1551 do_error_dialog(buf, _("CTCP UserInfo"), GAIM_INFO);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1552
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1553 } else if (!g_strcasecmp(word[4], ":\001VERSION")) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1554 char *p = g_strrstr(word_eol[5], "\001");
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1555 *p = 0;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1556 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1557 do_error_dialog(buf, _("CTCP Version"), GAIM_INFO);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1558
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1559 } else if (!g_strcasecmp(word[4], ":\001PING")) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1560 char *p = g_strrstr(word_eol[5], "\001");
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1561 struct timeval ping_time;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1562 struct timeval now;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1563 gchar **vector;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1564
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1565 if (p)
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1566 *p = 0;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1567
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1568 vector = g_strsplit(word_eol[5], " ", 2);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1569
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1570 if (gettimeofday(&now, NULL) == 0 && vector != NULL) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1571 if (now.tv_usec - atol(vector[1]) < 0) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1572 ping_time.tv_sec = now.tv_sec - atol(vector[0]) - 1;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1573 ping_time.tv_usec = now.tv_usec - atol(vector[1]) + 1000000;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1574
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1575 } else {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1576 ping_time.tv_sec = now.tv_sec - atol(vector[0]);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1577 ping_time.tv_usec = now.tv_usec - atol(vector[1]);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1578 }
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1579
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1580 g_snprintf(buf, sizeof(buf),
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1581 "CTCP Ping reply from %s: %lu.%.03lu seconds",
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1582 nick, ping_time.tv_sec, (ping_time.tv_usec/1000));
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1583
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1584 do_error_dialog(buf, _("CTCP Ping"), GAIM_INFO);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1585 g_strfreev(vector);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1586 }
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1587 } else {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1588 if (*word_eol[4] == ':') word_eol[4]++;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1589 if (ex)
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1590 irc_got_im(gc, nick, word_eol[4], 0, time(NULL));
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1591 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1592 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1593
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1594 static void
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1595 irc_parse_join(struct gaim_connection *gc, char *nick,
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1596 char *word[], char *word_eol[])
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1597 {
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1598 char *chan = *word[3] == ':' ? word[3] + 1 : word[3];
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1599 static int id = 1;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1600 struct gaim_conversation *c;
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1601 char *hostmask, *p;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1602
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1603 if (!g_strcasecmp(gc->displayname, nick)) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1604 serv_got_joined_chat(gc, id++, chan);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1605 } else {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1606 c = irc_find_chat(gc, chan);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1607 if (c) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1608 hostmask = g_strdup(word[1]);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1609 p = strchr(hostmask, '!');
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1610 if (p) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1611 char *pend = strchr(p, ' ');
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1612 if (pend) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1613 *pend = 0;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1614 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1615
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1616 gaim_chat_add_user(GAIM_CHAT(c), nick, p + 1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1617
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1618 g_free(hostmask);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1619 }
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1620 }
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1621 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1622 }
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1623
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1624 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1625 irc_parse_topic(struct gaim_connection *gc, char *nick,
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1626 char *word[], char *word_eol[])
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1627 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1628 struct gaim_conversation *c = irc_find_chat(gc, word[3]);
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1629 char *topic = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1630 char buf[IRC_BUF_LEN];
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1631
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1632 if (c) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1633 gaim_chat_set_topic(GAIM_CHAT(c), nick, topic);
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1634 g_snprintf(buf, sizeof(buf),
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1635 _("<B>%s has changed the topic to: %s</B>"), nick, topic);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1636
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1637 gaim_conversation_write(c, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1638 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1639 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1640
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1641 static gboolean
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1642 irc_parse_part(struct gaim_connection *gc, char *nick, char *cmd,
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1643 char *word[], char *word_eol[])
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1644 {
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1645 char *chan = cmd + 5;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1646 struct gaim_conversation *c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1647 struct gaim_chat *chat;
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1648 char *reason = word_eol[4];
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1649 GList *r;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1650
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1651 if (*chan == ':')
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1652 chan++;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1653 if (*reason == ':')
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1654 reason++;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1655 if (!(c = irc_find_chat(gc, chan)))
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1656 return FALSE;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1657 if (!strcmp(nick, gc->displayname)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1658 serv_got_chat_left(gc, gaim_chat_get_id(GAIM_CHAT(c)));
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1659 return FALSE;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1660 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1661
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1662 chat = GAIM_CHAT(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1663
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1664 r = gaim_chat_get_users(GAIM_CHAT(c));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1665
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1666 while (r) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1667 char *who = r->data;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1668 if (*who == '@')
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1669 who++;
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
1670 if (*who == '%')
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
1671 who++;
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1672 if (*who == '+')
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1673 who++;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1674 if (!g_strcasecmp(who, nick)) {
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1675 char *tmp = g_strdup(r->data);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1676 gaim_chat_remove_user(chat, tmp, reason);
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1677 g_free(tmp);
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1678 break;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1679 }
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1680 r = r->next;
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1681 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1682 return TRUE;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1683 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1684
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1685 static void
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4115
diff changeset
1686 irc_callback(gpointer data, gint source, GaimInputCondition condition)
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1687 {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1688 struct gaim_connection *gc = data;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1689 struct irc_data *idata = gc->proto_data;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1690 int i = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1691 gchar buf[1024];
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1692 gboolean off;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1693
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1694 i = read(idata->fd, buf, 1024);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1695 if (i <= 0) {
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3063
diff changeset
1696 hide_login_progress_error(gc, "Read error");
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1697 signoff(gc);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1698 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1699 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1700
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1701 idata->rxqueue = g_realloc(idata->rxqueue, i + idata->rxlen + 1);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1702 memcpy(idata->rxqueue + idata->rxlen, buf, i);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1703 idata->rxlen += i;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1704 idata->rxqueue[idata->rxlen] = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1705
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1706 while (1) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1707 char *d, *e;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1708 int len;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1709
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1710 if (!idata->rxqueue || ((e = strchr(idata->rxqueue, '\n')) == NULL))
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1711 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1712
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1713 len = e - idata->rxqueue + 1;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1714 d = g_strndup(idata->rxqueue, len);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1715 g_strchomp(d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1716 debug_printf("IRC S: %s\n", d);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
1717
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1718 /* REMOVE ME BEFORE SUBMIT! */
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1719 /*fprintf(stderr, "IRC S: %s\n", d);*/
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1720
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1721 idata->rxlen -= len;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1722 if (idata->rxlen) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1723 char *tmp = g_strdup(e + 1);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1724 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1725 idata->rxqueue = tmp;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1726 } else {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1727 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1728 idata->rxqueue = NULL;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1729 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1730
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1731 off = irc_parse(gc, d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1732
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1733 g_free(d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1734
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1735 if (off)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1736 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1737 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1738 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1739
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1740 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1741 irc_login_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1742 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1743 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1744 struct irc_data *idata;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1745 char hostname[256];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1746 char buf[IRC_BUF_LEN];
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1747 char *test;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1748 GError *err = NULL;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1749
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750 if (!g_slist_find(connections, gc)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1751 close(source);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1752 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1754
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1755 idata = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1756
4456
1630b1dca931 [gaim-migrate @ 4731]
Sean Egan <seanegan@gmail.com>
parents: 4452
diff changeset
1757 if (source < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1758 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1759 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1760 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1761 }
4452
2afc0f845e74 [gaim-migrate @ 4727]
Sean Egan <seanegan@gmail.com>
parents: 4422
diff changeset
1762 idata->fd = source;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1763
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1764 /* Try a quick conversion to see if the specified encoding is OK */
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1765 test = g_convert("test", strlen("test"), gc->account->proto_opt[USEROPT_CHARSET],
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1766 "UTF-8", NULL, NULL, &err);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1767 if (err) {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1768 debug_printf("Couldn't initialize %s for IRC charset conversion, using ISO-8859-1\n",
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1769 gc->account->proto_opt[USEROPT_CHARSET]);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1770 strcpy(gc->account->proto_opt[USEROPT_CHARSET], "ISO-8859-1");
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1771 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1772
4223
fc909686bbc1 [gaim-migrate @ 4467]
Luke Schierer <lschiere@pidgin.im>
parents: 4221
diff changeset
1773 g_free(test);
fc909686bbc1 [gaim-migrate @ 4467]
Luke Schierer <lschiere@pidgin.im>
parents: 4221
diff changeset
1774
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1775 gethostname(hostname, sizeof(hostname) - 1);
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1776 hostname[sizeof(hostname) - 1] = 0;
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1777 if (!*hostname)
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1778 g_snprintf(hostname, sizeof(hostname), "localhost");
3789
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1779
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1780 if (*gc->account->password) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1781 g_snprintf(buf, sizeof(buf), "PASS %s\r\n", gc->account->password);
3789
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1782
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1783 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1784 hide_login_progress(gc, "Write error");
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1785 signoff(gc);
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1786 return;
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1787 }
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1788 }
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
1789
3562
de3bc24fff02 [gaim-migrate @ 3657]
Luke Schierer <lschiere@pidgin.im>
parents: 3536
diff changeset
1790 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n",
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1791 g_get_user_name(), hostname,
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1792 gc->account->proto_opt[USEROPT_SERV],
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1793 gc->account->alias && strlen(gc->account->alias) ? gc->account->alias : "gaim");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1794 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1795 hide_login_progress(gc, "Write error");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1796 signoff(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1797 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1798 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1799
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1800 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", gc->username);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1801 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1806
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1807 gc->inpa = gaim_input_add(idata->fd, GAIM_INPUT_READ, irc_callback, gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1810 static void
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1811 irc_login(struct gaim_account *account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1812 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1813 char buf[IRC_BUF_LEN];
4422
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
1814 int rc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1816 struct gaim_connection *gc = new_gaim_conn(account);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1817 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1818
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1819 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1820
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1821 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822 set_login_progress(gc, 2, buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1823
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1824 idata->chantypes = g_strdup("#&!+");
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1825 idata->chanmodes = g_strdup("beI,k,lnt");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1826 idata->nickmodes = g_strdup("ohv");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1827 idata->str = g_string_new("");
4422
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
1828 idata->fd = -1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1829
4634
d19872836812 [gaim-migrate @ 4941]
Nathan Walp <nwalp@pidgin.im>
parents: 4621
diff changeset
1830 rc = proxy_connect(account, account->proto_opt[USEROPT_SERV],
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1831 account->proto_opt[USEROPT_PORT][0] ?
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1832 atoi(account->proto_opt[USEROPT_PORT]) : 6667,
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1833 irc_login_callback, gc);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
1834 if (!account->gc || (rc != 0)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835 hide_login_progress(gc, "Unable to create socket");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1836 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1837 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1838 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1839 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1841 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1842 irc_close(struct gaim_connection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1843 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1844 struct irc_data *idata = (struct irc_data *)gc->proto_data;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1845
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1846 gchar buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1847
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1848 if (idata->str->len > 0) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1849 g_snprintf(buf, sizeof(buf), "QUIT :%s\r\n", idata->str->str);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1850 } else {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1851 g_snprintf(buf, sizeof(buf),
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1852 "QUIT :Download Gaim [%s]\r\n", WEBSITE);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1853 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1854 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1855
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1856 if (idata->rxqueue)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1857 g_free(idata->rxqueue);
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1858
3619
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1859 idata->rxqueue = NULL;
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1860 idata->rxlen = 0;
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1861
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1862 /* Kill any existing transfers */
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1863 while (idata->file_transfers) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1864 struct gaim_xfer *xfer;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1865
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1866 xfer = (struct gaim_xfer *)idata->file_transfers->data;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1867
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1868 gaim_xfer_end(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
1869 gaim_xfer_destroy(xfer);
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1870
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1871 idata->file_transfers = idata->file_transfers->next;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1872 }
3619
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1873 idata->file_transfers = NULL;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1874
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1875
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1876 g_free(idata->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1877 g_free(idata->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1878 g_free(idata->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1879
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1880 g_string_free(idata->str, TRUE);
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1881 if (idata->liststr)
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1882 g_string_free(idata->liststr, TRUE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1883
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1884 if (idata->timer)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1885 g_source_remove(idata->timer);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1886
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1887 if (gc->inpa)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1888 gaim_input_remove(gc->inpa);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1889
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1890 close(idata->fd);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1891 g_free(gc->proto_data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1892 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1893
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1894 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1895 set_mode_3(struct gaim_connection *gc, char *who, int sign, int mode,
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1896 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1898 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1899 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1900 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1901 int i = start;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1902
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1903 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1904 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1905 switch (left) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1906 case 0:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1907 return;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1908 case 1:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1909 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1910 who, sign, mode, word[i]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1911 i += 1;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1912 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1913 case 2:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1914 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1915 who, sign, mode, mode, word[i], word[i + 1]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1916 i += 2;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1917 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1918 default:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1919 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1920 who, sign, mode, mode, mode,
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1921 word[i], word[i + 1], word[i + 2]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1922 i += 2;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1923 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1924 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1925 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1926 if (left < 3)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1927 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1928 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1929 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1930
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1931 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1932 set_mode_6(struct gaim_connection *gc, char *who, int sign, int mode,
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1933 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1934 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1935 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1936 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1937 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1938 int i = start;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1939
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1940 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1941 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1942 switch (left) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1943 case 0:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1944 return;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1945 case 1:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1946 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1947 who, sign, mode, word[i]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1948 i += 1;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1949 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1950 case 2:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1951 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1952 who, sign, mode, mode, word[i], word[i + 1]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1953 i += 2;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1954 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1955 case 3:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1956 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1957 who, sign, mode, mode, mode,
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1958 word[i], word[i + 1], word[i + 2]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1959 i += 3;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1960 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1961 case 4:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1962 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c %s %s %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1963 who, sign, mode, mode, mode, mode,
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1964 word[i], word[i + 1], word[i + 2], word[i + 3]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1965 i += 4;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1966 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1967 case 5:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1968 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c %s %s %s %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1969 who, sign, mode, mode, mode, mode, mode,
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1970 word[i], word[i + 1], word[i + 2],
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1971 word[i + 3], word[i + 4]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1972 i += 5;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1973 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1974 default:
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1975 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c%c %s %s %s %s %s %s\r\n",
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1976 who, sign, mode, mode, mode, mode, mode, mode,
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1977 word[i], word[i + 1], word[i + 2],
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1978 word[i + 3], word[i + 4], word[i + 5]);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1979 i += 6;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
1980 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1981 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1982 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1983 if (left < 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1984 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1985 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1986 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1987
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1988 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
1989 set_mode(struct gaim_connection *gc, char *who, int sign, int mode, char *word[])
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1990 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1991 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1992 int i = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1993
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1994 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1995 if (!*word[i]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1996 if (i == 2)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1997 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1998 if (id->six_modes)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1999 set_mode_6(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2000 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2001 set_mode_3(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2002 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2003 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2004 i++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2005 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2008 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2009 set_chan_mode(struct gaim_connection *gc, char *chan, char *mode_str)
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2010 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2011 struct irc_data *id = gc->proto_data;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2012 char buf[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2013
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2014 if ((mode_str[0] == '-') || (mode_str[0] == '+')) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2015 g_snprintf(buf, sizeof(buf), "MODE %s %s\r\n", chan, mode_str);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2016 irc_write(id->fd, buf, strlen(buf));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2017 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2018 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2019
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2020 static int
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2021 handle_command(struct gaim_connection *gc, char *who, char *what)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2022 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2023 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2024 char pdibuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2025 char *word[PDIWORDS], *word_eol[PDIWORDS];
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2026 char *tmp = g_strdup(what);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2027 GString *str = encode_html(tmp);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2028 char *intl;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2029 int len;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2030 struct dcc_chat *dccchat = find_dcc_chat(gc, who);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2031 struct irc_data *id = gc->proto_data;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2032
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2033 g_free(tmp);
3030
e40c30cf7572 [gaim-migrate @ 3043]
Sean Egan <seanegan@gmail.com>
parents: 3029
diff changeset
2034 what = str->str;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2035
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2036 if (*what != '/') {
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2037 if (dccchat) {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2038 intl = irc_send_convert(gc, what, sizeof(buf), &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2039 g_snprintf(buf, sizeof(buf), "%s\r\n", intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2040 g_free(intl);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2041 irc_write(dccchat->fd, buf, strlen(buf));
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2042 g_string_free(str, TRUE);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2043 return 1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2044 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2045 irc_send_privmsg (gc, who, what, TRUE);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2046 g_string_free(str, TRUE);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2047 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2048 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2049
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2050 process_data_init(pdibuf, what + 1, word, word_eol, TRUE);
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2051 g_string_free(str, FALSE);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2052 if (!g_strcasecmp(pdibuf, "ME")) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2053 if (dccchat) {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2054 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2055 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2056 g_free(intl);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2057 irc_write(dccchat->fd, buf, strlen(buf));
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2058 g_free(what);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2059 return 1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2060 }
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2061 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001", word_eol[2]);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2062 irc_send_privmsg (gc, who, buf, FALSE);
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2063 g_free(what);
2304
15fb364935ec [gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2303
diff changeset
2064 return 1;
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2065 } else if (!g_strcasecmp(pdibuf, "INVITE")) {
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2066 char buf[IRC_BUF_LEN];
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2067 g_snprintf(buf, sizeof(buf), "INVITE %s\r\n", word_eol[2]);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2068 irc_write(id->fd, buf, strlen(buf));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2069 } else if (!g_strcasecmp(pdibuf, "TOPIC")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2070 if (!*word_eol[2]) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2071 struct gaim_conversation *c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2072 struct gaim_chat *chat;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2073
3501
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
2074 c = irc_find_chat(gc, who);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2075 chat = GAIM_CHAT(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2076
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2077 g_snprintf(buf, sizeof(buf), _("Topic for %s is %s"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2078 who, (gaim_chat_get_topic(chat)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2079 ? gaim_chat_get_topic(chat)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2080 : "(no topic set)"));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2081
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2082 gaim_conversation_write(c, NULL, buf, -1,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2083 WFLAG_SYSTEM | WFLAG_NOLOG, time(NULL));
3501
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
2084 } else {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2085 /* This could be too long */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2086 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2087 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2088 g_free(intl);
3501
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
2089 irc_write(id->fd, buf, strlen(buf));
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2090 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2091 } else if (!g_strcasecmp(pdibuf, "NICK")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2092 if (!*word_eol[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2093 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2094 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2095 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2096 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2097 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2098 } else if (!g_strcasecmp(pdibuf, "OP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2099 set_mode(gc, who, '+', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2100 } else if (!g_strcasecmp(pdibuf, "DEOP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2101 set_mode(gc, who, '-', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2102 } else if (!g_strcasecmp(pdibuf, "VOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2103 set_mode(gc, who, '+', 'v', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2104 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2105 set_mode(gc, who, '-', 'v', word);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2106 } else if (!g_strcasecmp(pdibuf, "MODE")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2107 char *chan = who;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2108 set_chan_mode(gc, chan, word_eol[2]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2109 } else if (!g_strcasecmp(pdibuf, "QUOTE")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2110 if (!*word_eol[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2111 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2112 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2113 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2114 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2115 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
2116 } else if (!g_strcasecmp(pdibuf, "SAY")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2117 if (!*word_eol[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2118 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2119 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2120 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2121 irc_send_privmsg (gc, who, word_eol[2], TRUE);
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2122 return 1;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
2123 } else if (!g_strcasecmp(pdibuf, "MSG")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2124 if (!*word[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2125 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2126 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2127 }
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2128 if (!*word_eol[3]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2129 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2130 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2131 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2132 irc_send_privmsg (gc, word[2], word_eol[3], TRUE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2133 } else if (!g_strcasecmp(pdibuf, "KICK")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2134 if (!*word[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2135 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2136 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2137 }
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2138 if (*word_eol[3]) {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2139 intl = irc_send_convert(gc, word_eol[3], sizeof(buf), &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2140 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2141 g_free(intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2142 } else
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
2143 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2144 irc_write(id->fd, buf, strlen(buf));
2801
04f97d65bdc1 [gaim-migrate @ 2814]
Rob Flynn <gaim@robflynn.com>
parents: 2791
diff changeset
2145 } else if (!g_strcasecmp(pdibuf, "JOIN") || !g_strcasecmp(pdibuf, "J")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2146 if (!*word[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2147 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2148 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2149 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2150 if (*word[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2151 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2152 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2153 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2154 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2155 } else if (!g_strcasecmp(pdibuf, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2156 char *chan = *word[2] ? word[2] : who;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2157 char *reason = word_eol[3];
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2158 struct gaim_conversation *c;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2159 if (!is_channel(gc, chan)) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2160 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2161 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2162 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2163 c = irc_find_chat(gc, chan);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2164 if (*reason) {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2165 intl = irc_send_convert(gc, reason, sizeof(buf), &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2166 g_snprintf(buf, sizeof(buf), "PART %s :%s\r\n", chan, intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2167 g_free(intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2168 } else
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2169 g_snprintf(buf, sizeof(buf), "PART %s\r\n", chan);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2170 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2171 if (c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2172 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
2173 gaim_conversation_set_account(c, NULL);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2174 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2175 do_error_dialog(buf, _("IRC Part"), GAIM_INFO);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2176 }
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2177 } else if (!g_strcasecmp(pdibuf, "WHOIS")) {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2178 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2179 irc_write(id->fd, buf, strlen(buf));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2180 } else if (!g_strcasecmp(pdibuf, "WHOWAS")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2181 g_snprintf(buf, sizeof(buf), "WHOWAS %s\r\n", word_eol[2]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2182 irc_write(id->fd, buf, strlen(buf));
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
2183 } else if (!g_strcasecmp(pdibuf, "LIST")) {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
2184 g_snprintf(buf, sizeof(buf), "LIST\r\n");
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
2185 irc_write(id->fd, buf, strlen(buf));
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2186 } else if (!g_strcasecmp(pdibuf, "QUIT")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2187 char *reason = word_eol[2];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2188 id->str = g_string_insert(id->str, 0, reason);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2189 do_quit();
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2190 } else if (!g_strcasecmp(pdibuf, "VERSION")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2191 g_snprintf(buf, sizeof(buf), "VERSION\r\n");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2192 irc_write(id->fd, buf, strlen(buf));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2193 } else if (!g_strcasecmp(pdibuf, "W")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2194 g_snprintf(buf, sizeof(buf), "WHO *\r\n");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
2195 irc_write(id->fd, buf, strlen(buf));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2196 } else if (!g_strcasecmp(pdibuf, "REHASH")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2197 g_snprintf(buf, sizeof(buf), "REHASH\r\n");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2198 irc_write(id->fd, buf, strlen(buf));
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2199 } else if (!g_strcasecmp(pdibuf, "RESTART")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2200 g_snprintf(buf, sizeof(buf), "RESTART\r\n");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2201 irc_write(id->fd, buf, strlen(buf));
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2202 } else if (!g_strcasecmp(pdibuf, "CTCP")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2203 if (!g_strcasecmp(word[2], "CLIENTINFO")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2204 if (word[3])
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2205 irc_ctcp_clientinfo(gc, word[3]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2206 } else if (!g_strcasecmp(word[2], "USERINFO")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2207 if (word[3])
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2208 irc_ctcp_userinfo(gc, word[3]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2209 } else if (!g_strcasecmp(word[2], "VERSION")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2210 if (word[3])
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2211 irc_ctcp_version(gc, word[3]);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2212
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2213 } else if (!g_strcasecmp(word[2], "PING")) {
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2214 if (word[3])
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2215 irc_ctcp_ping(gc, word[3]);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2216 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2217 } else if (!g_strcasecmp(pdibuf, "DCC")) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2218 struct gaim_conversation *c = NULL;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2219 if (!g_strcasecmp(word[2], "CHAT")) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2220 if (word[3])
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2221 irc_start_chat(gc, word[3]);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2222
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2223 if (is_channel(gc, who)) {
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2224 c = irc_find_chat(gc, who);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2225 } else {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2226 c = gaim_find_conversation(who);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2227 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2228 if (c) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2229 gaim_conversation_write(c, NULL,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2230 _("<I>Requesting DCC CHAT</I>"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2231 -1, WFLAG_SYSTEM, time(NULL));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2232 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2233 }
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
2234 } else if (!g_strcasecmp(pdibuf, "HELP")) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2235 struct gaim_conversation *c = NULL;
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
2236 if (is_channel(gc, who)) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
2237 c = irc_find_chat(gc, who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
2238 } else {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2239 c = gaim_find_conversation(who);
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
2240 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2241 if (!c) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2242 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2243 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2244 }
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2245 if (!g_strcasecmp(word[2], "OPER")) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2246 gaim_conversation_write(c, NULL,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2247 _("<B>Operator commands:<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2248 "REHASH RESTART</B>"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2249 -1, WFLAG_NOLOG, time(NULL));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2250 } else if (!g_strcasecmp(word[2], "CTCP")) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2251 gaim_conversation_write(c, NULL,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2252 _("<B>CTCP commands:<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2253 "CLIENTINFO <nick><BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2254 "USERINFO <nick><BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2255 "VERSION <nick><BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2256 "PING <nick></B><BR>"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2257 -1, WFLAG_NOLOG, time(NULL));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2258 } else if (!g_strcasecmp(word[2], "DCC")) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2259 gaim_conversation_write(c, NULL,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2260 _("<B>DCC commands:<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2261 "CHAT <nick></B>"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2262 -1, WFLAG_NOLOG, time(NULL));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2263 } else {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2264 gaim_conversation_write(c, NULL,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2265 _("<B>Currently supported commands:<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2266 "WHOIS INVITE NICK LIST<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2267 "JOIN PART TOPIC KICK<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2268 "OP DEOP VOICE DEVOICE<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2269 "ME MSG QUOTE SAY QUIT<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2270 "MODE VERSION W WHOWAS<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2271 "Type /HELP OPER for operator commands<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2272 "Type /HELP CTCP for CTCP commands<BR>"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2273 "Type /HELP DCC for DCC commands"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2274 -1, WFLAG_NOLOG, time(NULL));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2275 }
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2276 } else {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2277 struct gaim_conversation *c = NULL;
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2278 if (is_channel(gc, who)) {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2279 c = irc_find_chat(gc, who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2280 } else {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2281 c = gaim_find_conversation(who);
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2282 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2283 if (!c) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2284 g_free(what);
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
2285 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2286 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2287
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2288 gaim_conversation_write(c, NULL, _("<B>Unknown command</B>"),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2289 -1, WFLAG_NOLOG, time(NULL));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2290 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2291 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2292 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2295 static int
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2296 send_msg(struct gaim_connection *gc, char *who, char *what)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2297 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2298 char *cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2299 if (cr) {
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2300 int ret = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2301 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2302 if (cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2303 *cr = 0;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2304 ret = handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2305 if (!cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2306 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2307 what = cr + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2308 if (!*what)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2309 break;
2295
24dc9ce95127 [gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2294
diff changeset
2310 *cr = '\n';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2311 cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2312 }
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2313 return ret;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2314 } else
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2315 return handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2316 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2317
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2318 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2319 irc_chat_invite(struct gaim_connection *gc, int idn, const char *message, const char *name) {
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2320 char buf[IRC_BUF_LEN];
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2321 struct irc_data *id = gc->proto_data;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2322 struct gaim_conversation *c = gaim_find_chat(gc, idn);
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2323 g_snprintf(buf, sizeof(buf), "INVITE %s %s\r\n", name, c->name);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2324 irc_write(id->fd, buf, strlen(buf));
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2325 }
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2326
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2327 static int
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2328 irc_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2329 {
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
2330 if (*who == '@' || *who == '%' || *who == '+')
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2331 return send_msg(gc, who + 1, what);
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2332 return send_msg(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2333 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2334
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2335 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2336 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2337 irc_add_buddy(struct gaim_connection *gc, const char *who) {}
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2338 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2339 irc_remove_buddy(struct gaim_connection *gc, char *who, char *group) {}
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2340
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2341 static GList *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2342 irc_chat_info(struct gaim_connection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2343 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2344 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2345 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2346
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2347 pce = g_new0(struct proto_chat_entry, 1);
2466
f8eb5f120603 [gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2459
diff changeset
2348 pce->label = _("Channel:");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2349 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2350
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2351 pce = g_new0(struct proto_chat_entry, 1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2352 pce->label = _("Password:");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2353 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2354
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2355 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2358 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2359 irc_join_chat(struct gaim_connection *gc, GList *data)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2360 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2361 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2362 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2363 char *name, *pass;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2364
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2365 if (!data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2366 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2367 name = data->data;
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
2368 if (data->next) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2369 pass = data->next->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2370 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", name, pass);
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
2371 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2372 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2373 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2374 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2375
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2376 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2377 irc_chat_leave(struct gaim_connection *gc, int id)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2378 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2379 struct irc_data *idata = gc->proto_data;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2380 struct gaim_conversation *c = gaim_find_chat(gc, id);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2381 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2382
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2383 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2384
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2385 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2386 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2387 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2388
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2389 static int
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2390 irc_chat_send(struct gaim_connection *gc, int id, char *what)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2391 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2392 struct gaim_conversation *c = gaim_find_chat(gc, id);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2393 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2394 return -EINVAL;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
2395 if (send_msg(gc, c->name, what) > 0)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2396 serv_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(c)),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2397 gc->displayname, 0, what, time(NULL));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2398 return 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2399 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2400
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2401 static GList *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2402 irc_away_states(struct gaim_connection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2403 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2404 return g_list_append(NULL, GAIM_AWAY_CUSTOM);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2405 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2407 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2408 irc_set_away(struct gaim_connection *gc, char *state, char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2410 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2411 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
2413 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
2414 g_free(gc->away);
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
2415 gc->away = NULL;
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
2416 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
2417
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
2418 if (msg) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2419 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
2420 gc->away = g_strdup(msg);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
2421 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2422 g_snprintf(buf, sizeof(buf), "AWAY\r\n");
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
2423
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2424 irc_write(idata->fd, buf, strlen(buf));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2427 static const char *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2428 irc_list_icon(struct gaim_account *a, struct buddy *b)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2430 return "irc";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2433 static int
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2434 getlocalip(char *ip) /* Thanks, libfaim */
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2435 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2436 struct hostent *hptr;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2437 char localhost[129];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2438 long unsigned add;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2439
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2440 /* XXX if available, use getaddrinfo() */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2441 /* XXX allow client to specify which IP to use for multihomed boxes */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2442
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2443 if (gethostname(localhost, 128) < 0)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2444 return -1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2445
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2446 if (!(hptr = gethostbyname(localhost)))
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2447 return -1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2448
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2449 memcpy(&add, hptr->h_addr_list[0], 4);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2450 add = htonl(add);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2451 g_snprintf(ip, 11, "%lu", add);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2452
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2453 return 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2454 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2455
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2456 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2457 dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2458 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2459 struct dcc_chat *chat = data;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2460 struct gaim_conversation *convo;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2461 char buf[128];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2462 struct sockaddr_in addr;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2463 int addrlen = sizeof (addr);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2464 addr.sin_family = AF_INET;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2465 addr.sin_port = htons (chat->port);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2466 addr.sin_addr.s_addr = INADDR_ANY;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2467 chat->fd = accept (chat->fd, (struct sockaddr *) (&addr), &addrlen);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2468 if (!chat->fd) {
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
2469 dcc_chat_cancel (chat);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
2470 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account,
4476
62c1e5e656d0 [gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents: 4456
diff changeset
2471 chat->nick);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2472 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"),
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2473 chat->nick);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2474 gaim_conversation_write(convo, NULL, buf, -1,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2475 WFLAG_SYSTEM, time(NULL));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2476 return;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2477 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2478 chat->inpa =
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2479 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
2480 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account, chat->nick);
4221
9e2336d5bdee [gaim-migrate @ 4465]
Luke Schierer <lschiere@pidgin.im>
parents: 4201
diff changeset
2481 g_snprintf (buf, sizeof buf, _("DCC Chat with %s established"),
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2482 chat->nick);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2483 gaim_conversation_write(convo, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2484 debug_printf ("Chat with %s established\n", chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2485 dcc_chat_list = g_slist_append (dcc_chat_list, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2486 }
3665
7cb6cf20ed7d [gaim-migrate @ 3794]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3633
diff changeset
2487 #if 0
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2488 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2489 irc_ask_send_file(struct gaim_connection *gc, char *destsn) {
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2490 struct irc_data *id = (struct irc_data *)gc->proto_data;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2491 struct irc_file_transfer *ift = g_new0(struct irc_file_transfer, 1);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2492 char *localip = (char *)malloc(12);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2493
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2494 if (getlocalip(localip) == -1) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2495 free(localip);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2496 return;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2497 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2498
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2499 ift->type = IFT_SENDFILE_OUT;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2500 ift->sn = g_strdup(destsn);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2501 ift->gc = gc;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2502 snprintf(ift->ip, sizeof(ift->ip), "%s", localip);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2503 id->file_transfers = g_slist_append(id->file_transfers, ift);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2504
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2505 ift->xfer = transfer_out_add(gc, ift->sn);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2506 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
2507
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2508 static struct
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
2509 irc_file_transfer *find_ift_by_xfer(struct gaim_connection *gc,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
2510 struct file_transfer *xfer) {
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2511
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2512 GSList *g = ((struct irc_data *)gc->proto_data)->file_transfers;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2513 struct irc_file_transfer *f = NULL;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2514
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2515 while (g) {
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2516 f = (struct irc_file_transfer *)g->data;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2517 if (f->xfer == xfer)
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2518 break;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2519 g = g->next;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2520 f = NULL;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2521 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2522
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2523 return f;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2524 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2525
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2526 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2527 irc_file_transfer_data_chunk(struct gaim_connection *gc, struct file_transfer *xfer, const char *data, int len) {
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2528 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2529 guint32 pos;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2530
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2531 ift->cur += len;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2532 pos = htonl(ift->cur);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2533 write(ift->fd, (char *)&pos, 4);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2534
3623
159f624c617d [gaim-migrate @ 3744]
Rob Flynn <gaim@robflynn.com>
parents: 3622
diff changeset
2535 // FIXME: You should check to verify that they received the data when
159f624c617d [gaim-migrate @ 3744]
Rob Flynn <gaim@robflynn.com>
parents: 3622
diff changeset
2536 // you are sending a file ...
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2537 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2538
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2539 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2540 irc_file_transfer_cancel (struct gaim_connection *gc, struct file_transfer *xfer) {
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2541 struct irc_data *id = (struct irc_data *)gc->proto_data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2542 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2543
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2544 printf("Our shit got canceled, yo!\n");
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2545
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2546 /* Remove the FT from our list of transfers */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2547 id->file_transfers = g_slist_remove(id->file_transfers, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2548
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2549 gaim_input_remove(ift->watcher);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2550
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2551 /* Close our FT because we're done */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2552 close(ift->fd);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2553
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2554 g_free(ift->sn);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2555 g_free(ift->name);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2556
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2557 g_free(ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2558 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2559
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2560 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2561 irc_file_transfer_done(struct gaim_connection *gc, struct file_transfer *xfer) {
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2562 struct irc_data *id = (struct irc_data *)gc->proto_data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2563 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2564
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2565
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2566 printf("Our shit be done, yo.\n");
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2567
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2568 /* Remove the FT from our list of transfers */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2569 id->file_transfers = g_slist_remove(id->file_transfers, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2570
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2571 gaim_input_remove(ift->watcher);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2572
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2573 /* Close our FT because we're done */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2574 close(ift->fd);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2575
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2576 g_free(ift->sn);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2577 g_free(ift->name);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2578
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2579 g_free(ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2580 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2581
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2582 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2583 irc_file_transfer_out (struct gaim_connection *gc, struct file_transfer *xfer, const char *name, int totfiles, int totsize) {
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2584 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2585 struct sockaddr_in addr;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2586 char buf[IRC_BUF_LEN];
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2587 int len;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2588
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2589
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2590 ift->fd = socket (AF_INET, SOCK_STREAM, 0);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2591 addr.sin_family = AF_INET;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2592 addr.sin_port = 0;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2593 addr.sin_addr.s_addr = INADDR_ANY;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2594 bind (ift->fd, (struct sockaddr *) &addr, sizeof(addr));
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2595 listen(ift->fd, 1);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2596
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2597 len = sizeof(addr);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2598 getsockname (ift->fd, (struct sockaddr *) &addr, &len);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2599
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2600 ift->port = ntohs(addr.sin_port);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2601
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2602 ift->watcher = gaim_input_add (ift->fd, GAIM_INPUT_READ, dcc_send_callback, ift);
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
2603 printf("watcher is %d\n", ift->watcher);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2604
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2605 snprintf(buf, sizeof(buf), "\001DCC SEND %s %s %d %d\001\n", name, ift->ip, ift->port, totsize);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2606 printf("Trying: %s\n", buf);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2607 irc_send_im (gc, ift->sn, buf, -1, 0);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2608 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2609
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2610 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2611 irc_file_transfer_in(struct gaim_connection *gc,
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2612 struct file_transfer *xfer, int offset) {
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2613
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2614 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2615
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2616 ift->xfer = xfer;
4634
d19872836812 [gaim-migrate @ 4941]
Nathan Walp <nwalp@pidgin.im>
parents: 4621
diff changeset
2617 proxy_connect(gc->account, ift->ip, ift->port, dcc_recv_callback, ift);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2618 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
2619 #endif
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2620
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2621 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2622 irc_ctcp_clientinfo(struct gaim_connection *gc, char *who)
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2623 {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2624 char buf[IRC_BUF_LEN];
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2625
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2626 snprintf (buf, sizeof buf, "\001CLIENTINFO\001");
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2627 irc_send_privmsg(gc, who, buf, FALSE);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2628 }
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2629
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2630 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2631 irc_ctcp_userinfo(struct gaim_connection *gc, char *who)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2632 {
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2633 char buf[IRC_BUF_LEN];
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2634
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2635 snprintf (buf, sizeof buf, "\001USERINFO\001");
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2636 irc_send_privmsg(gc, who, buf, FALSE);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2637 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2638
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2639 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2640 irc_ctcp_version(struct gaim_connection *gc, char *who)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2641 {
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2642 char buf[IRC_BUF_LEN];
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2643
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2644 snprintf (buf, sizeof buf, "\001VERSION\001");
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2645 irc_send_privmsg(gc, who, buf, FALSE);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2646 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2647
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2648 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2649 irc_ctcp_ping(struct gaim_connection *gc, char *who)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2650 {
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2651 char buf[IRC_BUF_LEN];
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2652
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3793
diff changeset
2653 g_snprintf (buf, sizeof(buf), "\001PING %ld\001", time(NULL));
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2654 irc_send_privmsg(gc, who, buf, FALSE);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2655 }
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2656
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2657 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2658 irc_send_notice(struct gaim_connection *gc, char *who, char *what)
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2659 {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2660 char buf[IRC_BUF_LEN], *intl;
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2661 struct irc_data *id = gc->proto_data;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2662 int len;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2663
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2664 intl = irc_send_convert(gc, what, 501, &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2665 g_snprintf(buf, sizeof(buf), "NOTICE %s :%s\r\n", who, intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2666 g_free(intl);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2667 irc_write(id->fd, buf, strlen(buf));
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2668 }
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2669
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2670 /* Don't call this guy with fragment = 1 for anything but straight
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2671 * up privmsgs. (no CTCP/whatever) It's still dangerous for CTCPs
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2672 * (it might not include the trailing \001), but I think this behavior
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2673 * is generally better than not fragmenting at all on lots of our
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2674 * packets. */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2675 /* From RFC2812:
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2676 * IRC messages are always lines of characters terminated with a CR-LF
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2677 * (Carriage Return - Line Feed) pair, and these messages SHALL NOT
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2678 * exceed 512 characters in length, counting all characters including
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2679 * the trailing CR-LF. Thus, there are 510 characters maximum allowed
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2680 * for the command and its parameters. */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2681 /* So apparently that includes all the inter-server crap, which is up
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2682 * to NINETY-THREE chars on dancer, which seems to be a pretty liberal
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2683 * ircd. My rough calculation for now is ":<nick>!~<user>@<host> ",
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2684 * where <host> is a max of an (uncalculated) 63 chars. Thanks to
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2685 * trelane and #freenode for giving a hand here. */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2686 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2687 irc_send_privmsg(struct gaim_connection *gc, char *who, char *what, gboolean fragment)
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2688 {
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2689 char buf[IRC_BUF_LEN], *intl;
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2690 struct irc_data *id = gc->proto_data;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2691 /* 512 - 12 (for PRIVMSG" "" :""\r\n") - namelen - nicklen - 68 */
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4476
diff changeset
2692 int nicklen = (gc->account->alias && strlen(gc->account->alias)) ? strlen(gc->account->alias) : 4;
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2693 int max = 444 - strlen(who) - strlen(g_get_user_name()) - nicklen;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2694
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2695 int len;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2696
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2697 do {
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2698 /* the \001 on CTCPs may cause a problem here for some
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2699 * charsets, but probably not ones people use for IRC. */
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2700 intl = irc_send_convert(gc, what, max, &len);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2701 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2702 g_free(intl);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2703 irc_write(id->fd, buf, strlen(buf));
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2704 what += len;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2705 } while (fragment && strlen(what));
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2706 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2707
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2708 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2709 irc_start_chat(struct gaim_connection *gc, char *who) {
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2710 struct dcc_chat *chat;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2711 int len;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2712 struct sockaddr_in addr;
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2713 char buf[IRC_BUF_LEN];
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2714
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2715 /* Create a socket */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2716 chat = g_new0 (struct dcc_chat, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2717 chat->fd = socket (AF_INET, SOCK_STREAM, 0);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2718 chat->gc = gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2719 g_snprintf (chat->nick, sizeof (chat->nick), "%s", who);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2720 if (chat->fd < 0) {
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
2721 dcc_chat_cancel (chat);
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2722 return;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2723 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2724 addr.sin_family = AF_INET;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2725 addr.sin_port = 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2726 addr.sin_addr.s_addr = INADDR_ANY;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2727 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr));
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2728 listen (chat->fd, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2729 len = sizeof (addr);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2730 getsockname (chat->fd, (struct sockaddr *) &addr, &len);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2731 chat->port = ntohs (addr.sin_port);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2732 getlocalip(chat->ip_address);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2733 chat->inpa =
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2734 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected,
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2735 chat);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
2736 g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n",
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2737 chat->ip_address, chat->port);
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2738 irc_send_im (gc, who, buf, -1, 0);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2739 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2740
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2741 static void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2742 irc_get_info(struct gaim_connection *gc, char *who)
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2743 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2744 struct irc_data *idata = gc->proto_data;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2745 char buf[IRC_BUF_LEN];
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2746
2633
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2747 if (*who == '@')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2748 who++;
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
2749 if (*who == '%')
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4608
diff changeset
2750 who++;
2633
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2751 if (*who == '+')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2752 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2753
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2754 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2755 irc_write(idata->fd, buf, strlen(buf));
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2756 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2757
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2758 static GList *
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2759 irc_buddy_menu(struct gaim_connection *gc, char *who)
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2760 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2761 GList *m = NULL;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2762 struct proto_buddy_menu *pbm;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2763
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2764 pbm = g_new0(struct proto_buddy_menu, 1);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2765 pbm->label = _("Get Info");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2766 pbm->callback = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2767 pbm->gc = gc;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2768 m = g_list_append(m, pbm);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2769
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2770 pbm = g_new0(struct proto_buddy_menu, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2771 pbm->label = _("DCC Chat");
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2772 pbm->callback = irc_start_chat;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2773 pbm->gc = gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2774 m = g_list_append(m, pbm);
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2775 /*
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2776 pbm = g_new0(struct proto_buddy_menu, 1);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2777 pbm->label = _("DCC Send");
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2778 pbm->callback = irc_ask_send_file;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2779 pbm->gc = gc;
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2780 m = g_list_append(m, pbm);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
2781 */
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2782
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2783 pbm = g_new0(struct proto_buddy_menu, 1);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2784 pbm->label = _("CTCP ClientInfo");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2785 pbm->callback = irc_ctcp_clientinfo;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2786 pbm->gc = gc;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2787 m = g_list_append(m, pbm);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2788
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2789 pbm = g_new0(struct proto_buddy_menu, 1);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2790 pbm->label = _("CTCP UserInfo");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2791 pbm->callback = irc_ctcp_userinfo;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2792 pbm->gc = gc;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2793 m = g_list_append(m, pbm);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2794
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2795 pbm = g_new0(struct proto_buddy_menu, 1);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2796 pbm->label = _("CTCP Version");
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2797 pbm->callback = irc_ctcp_version;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2798 pbm->gc = gc;
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2799 m = g_list_append(m, pbm);
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
2800
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2801 pbm = g_new0(struct proto_buddy_menu, 1);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2802 pbm->label = _("CTCP Ping");
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2803 pbm->callback = irc_ctcp_ping;
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2804 pbm->gc = gc;
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2805 m = g_list_append(m, pbm);
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
2806
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2807 return m;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2808 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2809
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2810 G_MODULE_EXPORT void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2811 irc_init(struct prpl *ret)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2812 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2813 struct proto_user_opt *puo;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2814 ret->protocol = PROTO_IRC;
3789
fb519383a058 [gaim-migrate @ 3929]
Rob Flynn <gaim@robflynn.com>
parents: 3751
diff changeset
2815 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL;
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2816 ret->name = g_strdup("IRC");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2817 ret->list_icon = irc_list_icon;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2818 ret->login = irc_login;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2819 ret->close = irc_close;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2820 ret->send_im = irc_send_im;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
2821 ret->add_buddy = irc_add_buddy;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
2822 ret->remove_buddy = irc_remove_buddy;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
2823 ret->chat_info = irc_chat_info;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 ret->join_chat = irc_join_chat;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2825 ret->chat_leave = irc_chat_leave;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2826 ret->chat_send = irc_chat_send;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2827 ret->away_states = irc_away_states;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2828 ret->set_away = irc_set_away;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2829 ret->get_info = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2830 ret->buddy_menu = irc_buddy_menu;
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2831 ret->chat_invite = irc_chat_invite;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2832 ret->convo_closed = irc_convo_closed;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
2833 #if 0
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2834 ret->file_transfer_out = irc_file_transfer_out;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2835 ret->file_transfer_in = irc_file_transfer_in;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2836 ret->file_transfer_data_chunk = irc_file_transfer_data_chunk;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2837 ret->file_transfer_done = irc_file_transfer_done;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2838 ret->file_transfer_cancel =irc_file_transfer_cancel;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
2839 #endif
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2840
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2841 puo = g_new0(struct proto_user_opt, 1);
4115
474265997752 [gaim-migrate @ 4332]
Luke Schierer <lschiere@pidgin.im>
parents: 4111
diff changeset
2842 puo->label = g_strdup(_("Server:"));
3914
9ced82507a79 [gaim-migrate @ 4073]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
2843 puo->def = g_strdup("irc.freenode.net");
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2844 puo->pos = USEROPT_SERV;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2845 ret->user_opts = g_list_append(ret->user_opts, puo);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2846
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2847 puo = g_new0(struct proto_user_opt, 1);
4115
474265997752 [gaim-migrate @ 4332]
Luke Schierer <lschiere@pidgin.im>
parents: 4111
diff changeset
2848 puo->label = g_strdup(_("Port:"));
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2849 puo->def = g_strdup("6667");
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2850 puo->pos = USEROPT_PORT;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2851 ret->user_opts = g_list_append(ret->user_opts, puo);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2852
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2853 puo = g_new0(struct proto_user_opt, 1);
4115
474265997752 [gaim-migrate @ 4332]
Luke Schierer <lschiere@pidgin.im>
parents: 4111
diff changeset
2854 puo->label = g_strdup(_("Encoding:"));
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2855 puo->def = g_strdup("ISO-8859-1");
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2856 puo->pos = USEROPT_CHARSET;
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2857 ret->user_opts = g_list_append(ret->user_opts, puo);
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2858
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2859 my_protocol = ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2860 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2862 #ifndef STATIC
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2863 G_MODULE_EXPORT void
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
2864 gaim_prpl_init(struct prpl* prpl)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2865 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2866 irc_init(prpl);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2867 prpl->plug->desc.api_version = PLUGIN_API_VERSION;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2868 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2870 #endif