Mercurial > pidgin
annotate src/protocols/irc/irc.c @ 3605:1066e65b1a18
[gaim-migrate @ 3718]
I forgot a break; =-O
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Tue, 08 Oct 2002 05:54:12 +0000 |
parents | 5125b1adba03 |
children | 9e776fde2fed |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim - IRC Protocol Plugin | |
3 * | |
4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com> | |
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 | 9 * |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 */ | |
25 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
26 #include <config.h> |
2086 | 27 |
3029 | 28 #include <fcntl.h> |
2086 | 29 #include <unistd.h> |
30 #include <errno.h> | |
31 #include <string.h> | |
32 #include <stdlib.h> | |
33 #include <stdio.h> | |
34 #include <time.h> | |
35 #include <sys/stat.h> | |
36 #include <ctype.h> | |
37 #include "multi.h" | |
38 #include "prpl.h" | |
39 #include "gaim.h" | |
40 #include "proxy.h" | |
41 | |
3580 | 42 #include "pixmaps/protocols/irc/irc_icon.xpm" |
2086 | 43 |
44 #define IRC_BUF_LEN 4096 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
45 #define PDIWORDS 32 |
2086 | 46 |
47 #define USEROPT_SERV 0 | |
48 #define USEROPT_PORT 1 | |
49 | |
3029 | 50 struct dcc_chat |
51 { | |
52 struct gaim_connection *gc; | |
53 char ip_address[12]; | |
54 int port; | |
55 int fd; | |
56 int inpa; | |
57 char nick[80]; | |
58 }; | |
59 | |
60 GSList *dcc_chat_list = NULL; | |
61 | |
2086 | 62 struct irc_data { |
63 int fd; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
64 gboolean online; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
65 guint32 timer; |
2086 | 66 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
67 char *rxqueue; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
68 int rxlen; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
69 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
70 GString *str; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
71 int bc; |
2086 | 72 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
73 char *chantypes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
74 char *chanmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
75 char *nickmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
76 gboolean six_modes; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
77 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
78 gboolean in_whois; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
79 gboolean in_list; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
80 GString *liststr; |
2086 | 81 }; |
82 | |
3029 | 83 struct dcc_chat * |
84 find_dcc_chat (struct gaim_connection *gc, char *nick) | |
85 { | |
86 GSList *tmp; | |
87 struct dcc_chat *data; | |
88 tmp = dcc_chat_list; | |
89 while (tmp != NULL) | |
90 { | |
91 data = (struct dcc_chat *) (tmp)->data; | |
92 if (data | |
93 && data->nick | |
94 && strcmp (nick, data->nick) == 0 | |
95 && gc == data->gc) | |
96 { | |
97 return data; | |
98 } | |
99 tmp = tmp->next; | |
100 } | |
101 return NULL; | |
102 } | |
103 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
104 static int irc_write(int fd, char *data, int len) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
105 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
106 debug_printf("IRC C: %s", data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
107 return write(fd, data, len); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
108 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
109 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
110 static struct conversation *irc_find_chat(struct gaim_connection *gc, char *name) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
111 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
112 GSList *bcs = gc->buddy_chats; |
2086 | 113 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
114 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
115 struct conversation *b = bcs->data; |
2331
1ea2792b6004
[gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2328
diff
changeset
|
116 if (!g_strcasecmp(b->name, name)) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
117 return b; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
118 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
119 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
120 return NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
121 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
122 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
123 static struct conversation *irc_find_chat_by_id(struct gaim_connection *gc, int id) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
124 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
125 GSList *bcs = gc->buddy_chats; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
126 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
127 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
128 struct conversation *b = bcs->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
129 if (b->id == id) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
130 return b; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
131 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
132 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
133 return NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
134 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
135 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
136 static void 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
|
137 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
138 int wordcount = 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
139 gboolean space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
140 gboolean quote = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
141 int j = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
142 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
143 word[1] = cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
144 eol[1] = buf; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
145 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
146 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
147 switch (*cmd) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
148 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
149 buf[j] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
150 for (j = wordcount; j < PDIWORDS; j++) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
151 word[j] = "\000\000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
152 eol[j] = "\000\000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
153 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
154 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
155 case '"': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
156 if (!quotes) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
157 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
158 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
159 break; |
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 quote = !quote; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
162 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
163 case ' ': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
164 if (quote) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
165 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
166 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
167 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
168 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
169 if (space) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
170 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
171 buf[j++] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
172 word[wordcount] = &buf[j]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
173 eol[wordcount++] = cmd + 1; |
2294
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
174 if (wordcount == PDIWORDS - 1) { |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
175 buf[j] = 0; |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
176 return; |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
177 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
178 space = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
179 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
180 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
181 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
182 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
183 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
184 cmd++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
185 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
186 } |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
187 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
188 static void handle_005(struct gaim_connection *gc, char *word[], char *word_eol[]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
189 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
190 int w = 4; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
191 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
192 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
193 while (w < PDIWORDS && *word[w]) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
194 if (!strncmp(word[w], "MODES=", 5)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
195 if (atoi(word[w] + 6) >= 6) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
196 id->six_modes = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
197 } else if (!strncmp(word[w], "CHANTYPES=", 10)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
198 g_free(id->chantypes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
199 id->chantypes = g_strdup(word[w] + 10); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
200 } else if (!strncmp(word[w], "CHANMODES=", 10)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
201 g_free(id->chanmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
202 id->chanmodes = g_strdup(word[w] + 10); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
203 } else if (!strncmp(word[w], "PREFIX=", 7)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
204 char *pre = strchr(word[w] + 7, ')'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
205 if (pre) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
206 *pre = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
207 g_free(id->nickmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
208 id->nickmodes = g_strdup(word[w] + 8); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
209 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
210 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
211 w++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
212 } |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
213 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
214 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
215 static char *int_to_col(int c) |
2086 | 216 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
217 switch(c) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
218 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
219 return "#ffffff"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
220 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
221 return "#000066"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
222 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
223 return "#006600"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
224 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
225 return "#ff0000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
226 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
227 return "#660000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
228 case 6: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
229 return "#660066"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
230 case 7: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
231 return "#666600"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
232 case 8: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
233 return "#cccc00"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
234 case 9: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
235 return "#33cc33"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
236 case 10: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
237 return "#00acac"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
238 case 11: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
239 return "#00ccac"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
240 case 12: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
241 return "#0000ff"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
242 case 13: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
243 return "#cc00cc"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
244 case 14: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
245 return "#666666"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
246 case 15: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
247 return "#00ccac"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
248 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
249 return "#000000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
250 } |
2086 | 251 } |
252 | |
3029 | 253 static GString *encode_html(char *msg) |
254 { | |
255 GString *str = g_string_new(""); | |
256 char *cur = msg, *end = msg; | |
257 gboolean bold = FALSE, underline = FALSE, italics = FALSE; | |
258 | |
259 while ((end = strchr(cur, '<'))) { | |
260 *end = 0; | |
261 str = g_string_append(str, cur); | |
262 cur = ++end; | |
263 if (!g_strncasecmp(cur, "B>", 2)) { | |
3063 | 264 if (!bold) { |
265 bold = TRUE; | |
266 str = g_string_append_c(str, '\2'); | |
267 } | |
3029 | 268 cur = cur + 2; |
269 } else if (!g_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */ | |
3063 | 270 if (!italics) { |
271 italics = TRUE; | |
272 str = g_string_append_c(str, '\2'); | |
273 } | |
3029 | 274 cur = cur + 2; |
275 } else if (!g_strncasecmp(cur, "U>", 2)) { | |
3063 | 276 if (!underline) { |
277 underline = TRUE; | |
278 str = g_string_append_c(str, '\37'); | |
279 } | |
3029 | 280 cur = cur + 2; |
3063 | 281 } else if (!g_strncasecmp(cur, "/B>", 3)) { |
282 if (bold) { | |
283 bold = FALSE; | |
284 str = g_string_append_c(str, '\2'); | |
285 } | |
3029 | 286 cur = cur + 3; |
3063 | 287 } else if (!g_strncasecmp(cur, "/I>", 3)) { |
288 if (italics) { | |
289 italics = FALSE; | |
290 str = g_string_append_c(str, '\2'); | |
291 } | |
3029 | 292 cur = cur + 3; |
3063 | 293 } else if (!g_strncasecmp(cur, "/U>", 3)) { |
294 if (underline) { | |
295 underline = FALSE; | |
296 str = g_string_append_c(str, '\37'); | |
297 } | |
3029 | 298 cur = cur + 3; |
3063 | 299 } else { |
300 str = g_string_append_c(str, '<'); | |
3029 | 301 } |
3063 | 302 |
3029 | 303 } |
304 str = g_string_append(str, cur); | |
305 return str; | |
306 } | |
307 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
308 static GString *decode_html(char *msg) |
2086 | 309 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
310 GString /* oo la la */ *str = g_string_new(""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
311 char *cur = msg, *end = msg; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
312 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
313 int fore, back; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
314 while (*end) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
315 switch (*end) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
316 case 02: /* ^B */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
317 *end = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
318 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
319 if (bold) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
320 str = g_string_append(str, "</B>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
321 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
322 str = g_string_append(str, "<B>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
323 bold = !bold; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
324 cur = end + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
325 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
326 case 03: /* ^C */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
327 *end++ = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
328 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
329 fore = back = -1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
330 if (isdigit(*end)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
331 fore = *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
332 if (isdigit(*end)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
333 fore *= 10; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
334 fore += *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
335 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
336 if (*end == ',' && isdigit(end[1])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
337 end++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
338 back = *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
339 if (isdigit(*end)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
340 back *= 10; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
341 back += *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
342 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
343 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
344 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
345 if (fore == -1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
346 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
347 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
348 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
349 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
350 fg = bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
351 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
352 fore %= 16; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
353 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
354 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
355 if (back != -1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
356 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
357 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
358 back %= 16; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
359 str = g_string_append(str, "<FONT BACK="); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
360 str = g_string_append(str, int_to_col(back)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
361 str = g_string_append_c(str, '>'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
362 bg = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
363 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
364 str = g_string_append(str, "<FONT COLOR="); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
365 str = g_string_append(str, int_to_col(fore)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
366 str = g_string_append_c(str, '>'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
367 fg = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
368 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
369 cur = end--; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
370 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
371 case 017: /* ^O */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
372 if (!bold && !underline && !fg && !bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
373 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
374 *end = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
375 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
376 if (bold) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
377 str = g_string_append(str, "</B>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
378 if (underline) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
379 str = g_string_append(str, "</U>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
380 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
381 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
382 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
383 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
384 bold = underline = fg = bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
385 cur = end + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
386 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
387 case 037: /* ^_ */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
388 *end = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
389 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
390 if (underline) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
391 str = g_string_append(str, "</U>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
392 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
393 str = g_string_append(str, "<U>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
394 underline = !underline; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
395 cur = end + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
396 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
397 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
398 end++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
399 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
400 if (*cur) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
401 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
402 return str; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
403 } |
2086 | 404 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
405 static void irc_got_im(struct gaim_connection *gc, char *who, char *what, int flags, time_t t) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
406 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
407 GString *str = decode_html(what); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
408 serv_got_im(gc, who, str->str, flags, t, -1); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
409 g_string_free(str, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
410 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
411 |
3029 | 412 static void dcc_chat_cancel(void *, struct dcc_chat *); |
413 | |
414 void | |
415 dcc_chat_in (gpointer data, gint source, GaimInputCondition condition) | |
416 { | |
417 struct dcc_chat *chat = data; | |
418 gchar buffer[IRC_BUF_LEN]; | |
419 gchar buf[128]; | |
420 int n = 0, l; | |
421 struct conversation *convo; | |
422 debug_printf("THIS IS TOO MUCH EFFORT\n"); | |
423 n = read (chat->fd, buffer, IRC_BUF_LEN); | |
424 if (n > 0) | |
425 { | |
426 | |
427 /* Strip the terminating \n */ | |
428 l = 0; | |
429 while (buffer[l] && buffer[l] != '\n' && l <= n) | |
430 l++; | |
431 buffer[l] = '\000'; | |
432 | |
433 /* Convert to HTML */ | |
434 debug_printf ("DCC Message from: %s\n", chat->nick); | |
435 irc_got_im(chat->gc, chat->nick, buffer, 0, time(NULL)); | |
436 } | |
437 | |
438 else { | |
439 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"), | |
440 chat->nick); | |
441 convo = new_conversation (chat->nick); | |
442 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | |
443 time ((time_t) NULL), -1); | |
444 dcc_chat_cancel (NULL,chat); | |
445 } | |
446 } | |
447 | |
448 void dcc_chat_callback (gpointer data, gint source, GaimInputCondition condition) { | |
449 struct dcc_chat *chat = data; | |
450 struct conversation *convo = new_conversation (chat->nick); | |
451 char buf[IRC_BUF_LEN]; | |
452 chat->fd = source; | |
453 g_snprintf (buf, sizeof buf, | |
454 "DCC Chat with %s established", | |
455 chat->nick); | |
456 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | |
457 time ((time_t) NULL), -1); | |
458 debug_printf ("Chat with %s established\n", chat->nick); | |
459 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | |
460 gaim_input_remove(chat->inpa); | |
461 chat->inpa = gaim_input_add(source, GAIM_INPUT_READ, dcc_chat_in, chat); | |
462 } | |
463 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
464 static void irc_got_chat_in(struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t t) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
465 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
466 GString *str = decode_html(msg); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
467 serv_got_chat_in(gc, id, who, whisper, str->str, t); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
468 g_string_free(str, TRUE); |
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 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
471 static void handle_list(struct gaim_connection *gc, char *list) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
472 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
473 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
474 GSList *gr; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
475 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
476 id->str = g_string_append_c(id->str, ' '); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
477 id->str = g_string_append(id->str, list); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
478 id->bc--; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
479 if (id->bc) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
480 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
481 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
482 g_strdown(id->str->str); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
483 gr = gc->groups; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
484 while (gr) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
485 GSList *m = ((struct group *)gr->data)->members; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
486 while (m) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
487 struct buddy *b = m->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
488 char *tmp = g_strdup(b->name); |
3028 | 489 char *x, *l; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
490 g_strdown(tmp); |
2310
b2db2a76dcec
[gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
491 x = strstr(id->str->str, tmp); |
3028 | 492 l = x + strlen(b->name); |
493 if (x && (*l != ' ' && *l != 0)) | |
494 x = 0; | |
2310
b2db2a76dcec
[gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
495 if (!b->present && x) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
496 serv_got_update(gc, b->name, 1, 0, 0, 0, 0, 0); |
2310
b2db2a76dcec
[gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
497 else if (b->present && !x) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
498 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
499 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
500 m = m->next; |
2086 | 501 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
502 gr = gr->next; |
2086 | 503 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
504 g_string_free(id->str, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
505 id->str = g_string_new(""); |
2086 | 506 } |
507 | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
508 static gboolean irc_request_buddy_update(gpointer data) |
2086 | 509 { |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
510 struct gaim_connection *gc = data; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
511 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
512 char buf[500]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
513 int n = g_snprintf(buf, sizeof(buf), "ISON"); |
2086 | 514 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
515 GSList *gr = gc->groups; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
516 if (!gr || id->bc) |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
517 return TRUE; |
2086 | 518 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
519 while (gr) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
520 struct group *g = gr->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
521 GSList *m = g->members; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
522 while (m) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
523 struct buddy *b = m->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
524 if (n + strlen(b->name) + 2 > sizeof(buf)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
525 g_snprintf(buf + n, sizeof(buf) - n, "\r\n"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
526 irc_write(id->fd, buf, n); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
527 id->bc++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
528 n = g_snprintf(buf, sizeof(buf), "ISON"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
529 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
530 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
531 m = m->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
532 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
533 gr = gr->next; |
2086 | 534 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
535 g_snprintf(buf + n, sizeof(buf) - n, "\r\n"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
536 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
537 id->bc++; |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
538 return TRUE; |
2086 | 539 } |
540 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
541 static void handle_names(struct gaim_connection *gc, char *chan, char *names) |
2086 | 542 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
543 struct conversation *c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
544 char **buf, **tmp; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
545 if (!c) return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
546 if (*names == ':') names++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
547 buf = g_strsplit(names, " ", -1); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
548 for (tmp = buf; *tmp; tmp++) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
549 add_chat_buddy(c, *tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
550 g_strfreev(buf); |
2086 | 551 } |
552 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
553 static void handle_topic(struct gaim_connection *gc, char *text) |
2086 | 554 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
555 struct conversation *c; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
556 char *po = strchr(text, ' '); |
2086 | 557 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
558 if (!po) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
559 return; |
2086 | 560 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
561 *po = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
562 po += 2; |
2086 | 563 |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
564 if ((c = irc_find_chat(gc, text))) { |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
565 char buf[IRC_BUF_LEN]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
566 chat_set_topic(c, NULL, po); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
567 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"), |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
568 text, po); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
569 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
570 } |
2086 | 571 } |
572 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
573 static gboolean mode_has_arg(struct gaim_connection *gc, char sign, char mode) |
2086 | 574 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
575 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
576 char *cm = id->chanmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
577 int type = 0; |
2086 | 578 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
579 if (strchr(id->nickmodes, mode)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
580 return TRUE; |
2086 | 581 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
582 while (*cm) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
583 if (*cm == ',') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
584 type++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
585 else if (*cm == mode) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
586 switch (type) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
587 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
588 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
589 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
590 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
591 if (sign == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
592 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
593 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
594 return FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
595 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
596 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
597 cm++; |
2086 | 598 } |
599 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
600 return FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
601 } |
2086 | 602 |
3452 | 603 static void irc_chan_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *argstr, char *who) |
604 { | |
605 struct conversation *c = irc_find_chat(gc, room); | |
606 char buf[IRC_BUF_LEN]; | |
607 char *nick = g_strndup(who, strchr(who, '!') - who); | |
608 | |
609 g_snprintf(buf, sizeof(buf), "%s sets mode %c%c %s on %s", | |
610 nick, sign, mode, strlen(argstr) ? argstr : "", | |
611 room); | |
612 g_free(nick); | |
613 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL), -1); | |
614 } | |
615 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
616 static void irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
617 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
618 struct conversation *c = irc_find_chat(gc, room); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
619 GList *r; |
2086 | 620 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
621 if (mode != 'o' && mode != 'v') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
622 return; |
2086 | 623 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
624 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
625 return; |
2086 | 626 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
627 r = c->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
628 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
629 gboolean op = FALSE, voice = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
630 char *who = r->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
631 if (*who == '@') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
632 op = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
633 who++; |
2086 | 634 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
635 if (*who == '+') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
636 voice = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
637 who++; |
2086 | 638 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
639 if (!strcmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
640 char *tmp, buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
641 if (mode == 'o') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
642 if (sign == '-') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
643 op = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
644 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
645 op = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
646 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
647 if (mode == 'v') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
648 if (sign == '-') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
649 voice = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
650 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
651 voice = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
652 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
653 tmp = g_strdup(r->data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
654 g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
655 voice ? "+" : "", nick); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
656 rename_chat_buddy(c, tmp, buf); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
657 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
658 return; |
2086 | 659 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
660 r = r->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
661 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
662 } |
2086 | 663 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
664 static void handle_mode(struct gaim_connection *gc, char *word[], char *word_eol[], gboolean n324) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
665 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
666 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
667 int offset = n324 ? 4 : 3; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
668 char *chan = word[offset]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
669 struct conversation *c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
670 char *modes = word[offset + 1]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
671 int len = strlen(word_eol[offset]) - 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
672 char sign = *modes++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
673 int arg = 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
674 char *argstr; |
3452 | 675 char *who = word[1]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
676 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
677 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
678 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
679 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
680 if (word_eol[offset][len] == ' ') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
681 word_eol[offset][len] = 0; |
2086 | 682 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
683 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
684 switch (*modes) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
685 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
686 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
687 case '+': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
688 case '-': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
689 sign = *modes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
690 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
691 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
692 if (mode_has_arg(gc, sign, *modes)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
693 argstr = word[++arg + offset]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
694 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
695 argstr = ""; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
696 if (strchr(id->nickmodes, *modes)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
697 irc_user_mode(gc, chan, sign, *modes, argstr); |
3452 | 698 else if (strchr(who, '!')) |
699 irc_chan_mode(gc, chan, sign, *modes, argstr, who); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
700 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
701 modes++; |
2086 | 702 } |
703 } | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
704 |
3452 | 705 static void handle_version(struct gaim_connection *gc, char *word[], char *word_eol[], int num) |
706 { | |
707 struct irc_data *id = gc->proto_data; | |
708 GString *str; | |
709 | |
710 id->liststr = g_string_new(""); | |
711 | |
712 id->liststr = g_string_append(id->liststr, "<b>Version: </b>"); | |
713 id->liststr = g_string_append(id->liststr, word_eol[4]); | |
714 | |
715 str = decode_html(id->liststr->str); | |
716 g_show_info_text(gc, NULL, 2, str->str, NULL); | |
717 g_string_free(str, TRUE); | |
718 g_string_free(id->liststr, TRUE); | |
719 id->liststr = NULL; | |
720 } | |
721 | |
722 static void handle_who(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
723 { | |
724 struct irc_data *id = gc->proto_data; | |
725 char buf[IRC_BUF_LEN]; | |
726 | |
727 if (!id->in_whois) { | |
728 id->in_whois = TRUE; | |
729 id->liststr = g_string_new(""); | |
730 } | |
731 | |
732 switch (num) { | |
733 case 352: | |
734 g_snprintf(buf, sizeof(buf), "<b>%s</b> (%s@%s): %s<br>", | |
735 word[8], word[5], word[6], word_eol[11]); | |
736 id->liststr = g_string_append(id->liststr, buf); | |
737 break; | |
738 } | |
739 } | |
740 | |
2648 | 741 /* Handle our whois stuff here. You know what, I have a sore throat. You know |
742 * what I think about that? I'm not too pleased with it. Perhaps I should take | |
743 * some medicine, or perhaps I should go to bed? Blah!! */ | |
744 | |
745 static void handle_whois(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
746 { | |
747 struct irc_data *id = gc->proto_data; | |
748 char tmp[1024]; | |
749 | |
750 if (!id->in_whois) { | |
751 id->in_whois = TRUE; | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
752 id->liststr = g_string_new(""); |
2648 | 753 } else { |
754 /* 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
|
755 id->liststr = g_string_append(id->liststr, "<BR>"); |
2648 | 756 id->in_whois = TRUE; |
757 } | |
758 | |
759 switch (num) { | |
760 case 311: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
761 id->liststr = g_string_append(id->liststr, "<b>User: </b>"); |
2648 | 762 break; |
763 case 312: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
764 id->liststr = g_string_append(id->liststr, "<b>Server: </b>"); |
2648 | 765 break; |
766 case 313: | |
767 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]); | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
768 id->liststr = g_string_append(id->liststr, tmp); |
2648 | 769 break; |
770 | |
771 case 317: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
772 id->liststr = g_string_append(id->liststr, "<b>Idle Time: </b>"); |
2648 | 773 break; |
774 case 319: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
775 id->liststr = g_string_append(id->liststr, "<b>Channels: </b>"); |
2648 | 776 break; |
777 default: | |
778 break; | |
779 } | |
3452 | 780 |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
781 if (word_eol[5][0] == ':') |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
782 id->liststr = g_string_append(id->liststr, word_eol[5] + 1); |
3452 | 783 /* Nicer idle time output, by jonas@birme.se */ |
784 else if (isdigit(word_eol[5][0])) { | |
785 time_t idle = atol(word_eol[5]); | |
786 time_t signon = atol(strchr(word_eol[5], ' ')); | |
787 | |
788 g_snprintf(tmp, sizeof(tmp), | |
789 "%ld seconds [signon: %s]", (idle / 1000), ctime(&signon)); | |
790 id->liststr = g_string_append(id->liststr, tmp); | |
791 } | |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
792 else |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
793 id->liststr = g_string_append(id->liststr, word_eol[5]); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
794 } |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
795 |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
796 static void handle_roomlist(struct gaim_connection *gc, char *word[], char *word_eol[]) |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
797 { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
798 struct irc_data *id = gc->proto_data; |
2648 | 799 |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
800 if (!id->in_list) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
801 id->in_list = TRUE; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
802 id->liststr = g_string_new(""); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
803 } else { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
804 id->liststr = g_string_append(id->liststr, "<BR>"); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
805 id->in_list = TRUE; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
806 } |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
807 |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
808 id->liststr = g_string_append(id->liststr, word_eol[4]); |
2648 | 809 } |
810 | |
3511 | 811 static void irc_change_nick(void *a, char *b) { |
812 struct gaim_connection *gc = a; | |
813 struct irc_data *id = gc->proto_data; | |
814 char buf[IRC_BUF_LEN]; | |
815 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", b); | |
816 irc_write(id->fd, buf, strlen(buf)); | |
817 } | |
818 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
819 static void process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[]) |
2086 | 820 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
821 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
822 char *text = word_eol[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
823 int n = atoi(word[2]); |
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 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname))) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
826 text += strlen(gc->displayname) + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
827 if (*text == ':') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
828 text++; |
2086 | 829 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
830 switch (n) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
831 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
832 if (!strncmp(word[5], "u2.10", 5)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
833 id->six_modes = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
834 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
835 id->six_modes = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
836 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
837 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
838 handle_005(gc, word, word_eol); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
839 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
840 case 301: |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
841 if (id->in_whois) { |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
842 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
|
843 |
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
844 if (word_eol[5][0] == ':') |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
845 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
|
846 else |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
847 id->liststr = g_string_append(id->liststr, word_eol[5]); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
848 } else |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
849 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
|
850 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
851 case 303: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
852 handle_list(gc, &word_eol[4][1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
853 break; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
854 case 311: |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
855 case 312: |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
856 case 313: |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
857 case 317: |
3452 | 858 case 319: |
2648 | 859 handle_whois(gc, word, word_eol, n); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
860 break; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
861 case 322: |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
862 handle_roomlist(gc, word, word_eol); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
863 break; |
3452 | 864 /* End of replies */ |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
865 case 323: |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
866 case 318: |
3452 | 867 case 315: |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
868 if ((id->in_whois || id->in_list) && id->liststr) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
869 GString *str = decode_html(id->liststr->str); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2782
diff
changeset
|
870 g_show_info_text(gc, NULL, 2, str->str, NULL); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
871 g_string_free(str, TRUE); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
872 g_string_free(id->liststr, TRUE); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
873 id->liststr = NULL; |
2652
65a602693286
[gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2651
diff
changeset
|
874 id->in_whois = FALSE; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
875 id->in_list = FALSE; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
876 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
877 break; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
878 case 324: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
879 handle_mode(gc, word, word_eol, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
880 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
881 case 332: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
882 handle_topic(gc, text); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
883 break; |
3452 | 884 case 351: |
885 handle_version(gc, word, word_eol, n); | |
886 break; | |
887 case 352: | |
888 handle_who(gc, word, word_eol, n); | |
889 break; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
890 case 353: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
891 handle_names(gc, word[5], word_eol[6]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
892 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
893 case 376: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
894 irc_request_buddy_update(gc); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
895 break; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
896 case 401: |
3427 | 897 do_error_dialog(_("There is no such nick or channel on this IRC channel."), NULL, GAIM_ERROR); |
2652
65a602693286
[gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2651
diff
changeset
|
898 break; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
899 case 402: |
3427 | 900 do_error_dialog(_("There is no such IRC Server"), NULL, GAIM_ERROR); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
901 case 431: |
3427 | 902 do_error_dialog(_("No IRC nickname given"), NULL, GAIM_ERROR); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
903 break; |
3511 | 904 case 433: |
905 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL); | |
3605 | 906 break; |
3452 | 907 default: |
908 if (n > 400 && n < 502) { | |
909 char errmsg[IRC_BUF_LEN]; | |
910 char *errmsg1 = strrchr(text, ':'); | |
911 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n); | |
912 if (errmsg) | |
3536 | 913 do_error_dialog(errmsg, errmsg1 ? errmsg1+1 : NULL, GAIM_ERROR); |
3452 | 914 } |
915 break; | |
2086 | 916 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
917 } |
2086 | 918 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
919 static gboolean is_channel(struct gaim_connection *gc, char *name) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
920 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
921 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
922 if (strchr(id->chantypes, *name)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
923 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
924 return FALSE; |
2086 | 925 } |
926 | |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
927 static void irc_rem_chat_bud(struct gaim_connection *gc, char *nick, char *reason) |
2086 | 928 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
929 GSList *bcs = gc->buddy_chats; |
2086 | 930 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
931 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
932 struct conversation *b = bcs->data; |
2086 | 933 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
934 GList *r = b->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
935 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
936 char *who = r->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
937 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
938 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
939 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
940 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
941 if (!g_strcasecmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
942 char *tmp = g_strdup(r->data); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
943 remove_chat_buddy(b, tmp, reason); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
944 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
945 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
946 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
947 r = r->next; |
2086 | 948 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
949 bcs = bcs->next; |
2086 | 950 } |
951 } | |
952 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
953 static void irc_change_name(struct gaim_connection *gc, char *old, char *new) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
954 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
955 GSList *bcs = gc->buddy_chats; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
956 char buf[IRC_BUF_LEN]; |
2086 | 957 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
958 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
959 struct conversation *b = bcs->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
960 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
961 GList *r = b->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
962 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
963 char *who = r->data; |
2292
6625d0755c51
[gaim-migrate @ 2302]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2291
diff
changeset
|
964 int n = 0; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
965 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
966 buf[n++] = *who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
967 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
968 buf[n++] = *who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
969 g_snprintf(buf + n, sizeof(buf) - n, "%s", new); |
2312
766603034af8
[gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2310
diff
changeset
|
970 if (!strcmp(who, old)) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
971 char *tmp = g_strdup(r->data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
972 rename_chat_buddy(b, tmp, buf); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
973 r = b->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
974 g_free(tmp); |
2725
f3c094e78609
[gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2687
diff
changeset
|
975 break; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
976 } else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
977 r = r->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
978 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
979 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
980 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
981 } |
2086 | 982 |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
983 static void handle_privmsg(struct gaim_connection *gc, char *to, char *nick, char *msg) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
984 { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
985 if (is_channel(gc, to)) { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
986 struct conversation *c = irc_find_chat(gc, to); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
987 if (!c) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
988 return; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
989 irc_got_chat_in(gc, c->id, nick, 0, msg, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
990 } else { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
991 char *tmp = g_malloc(strlen(nick) + 2); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
992 g_snprintf(tmp, strlen(nick) + 2, "@%s", nick); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
993 if (find_conversation(tmp)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
994 irc_got_im(gc, tmp, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
995 else { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
996 *tmp = '+'; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
997 if (find_conversation(tmp)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
998 irc_got_im(gc, tmp, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
999 else |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1000 irc_got_im(gc, nick, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1001 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1002 g_free(tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1003 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1004 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1005 |
3029 | 1006 static void dcc_chat_init(gpointer obj, struct dcc_chat *data) { |
1007 struct dcc_chat * chat = g_new0(struct dcc_chat, 1); | |
1008 | |
1009 memcpy(chat, data, sizeof(struct dcc_chat)); /* we have to make a new one | |
1010 * because the old one get's freed by | |
1011 * dcc_chat_cancel. */ | |
1012 proxy_connect(chat->ip_address, chat->port, dcc_chat_callback, chat); | |
1013 } | |
1014 | |
1015 static void dcc_chat_cancel(gpointer obj, struct dcc_chat *data){ | |
1016 if (find_dcc_chat(data->gc, data->nick)) { | |
1017 dcc_chat_list = g_slist_remove(dcc_chat_list, data); | |
1018 gaim_input_remove (data->inpa); | |
1019 close (data->fd); | |
1020 } | |
1021 g_free(data); | |
1022 } | |
1023 | |
1024 static void irc_convo_closed(struct gaim_connection *gc, char *who) | |
1025 { | |
1026 struct dcc_chat *dchat = find_dcc_chat(gc, who); | |
1027 if (!dchat) | |
1028 return; | |
1029 | |
1030 dcc_chat_cancel(NULL, dchat); | |
1031 } | |
1032 | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1033 static void handle_ctcp(struct gaim_connection *gc, char *to, char *nick, |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1034 char *msg, char *word[], char *word_eol[]) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1035 { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1036 struct irc_data *id = gc->proto_data; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1037 char buf[IRC_BUF_LEN]; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1038 |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1039 if (!g_strncasecmp(msg, "VERSION", 7)) { |
3245 | 1040 g_snprintf(buf, sizeof(buf), "NOTICE %s :\001VERSION Gaim " VERSION ": The Penguin Pimpin' " |
1041 "Multi-protocol Messaging Client: " WEBSITE "\001\r\n", nick); | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1042 irc_write(id->fd, buf, strlen(buf)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1043 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1044 if (!g_strncasecmp(msg, "ACTION", 6)) { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1045 char *po = strchr(msg + 6, 1); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1046 char *tmp; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1047 if (po) *po = 0; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1048 tmp = g_strconcat("/me", msg + 6, NULL); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1049 handle_privmsg(gc, to, nick, tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1050 g_free(tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1051 } |
3029 | 1052 if (!g_strncasecmp(msg, "DCC CHAT", 8)) { |
1053 char **chat_args = g_strsplit(msg, " ", 5); | |
1054 char ask[1024]; | |
1055 struct dcc_chat * dccchat = g_new0(struct dcc_chat, 1); | |
1056 dccchat->gc = gc; | |
1057 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]); | |
1058 dccchat->port=atoi(chat_args[4]); | |
1059 g_snprintf(dccchat->nick, sizeof(dccchat->nick), nick); | |
1060 g_snprintf(ask, sizeof(ask), _("%s has requested a DCC chat. " | |
1061 "Would you like to establish the direct connection?"), nick); | |
1062 do_ask_dialog(ask, dccchat, dcc_chat_init, dcc_chat_cancel); | |
1063 } | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1064 /* XXX should probably write_to_conv or something here */ |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1065 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1066 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1067 static gboolean irc_parse(struct gaim_connection *gc, char *buf) |
2086 | 1068 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1069 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1070 gchar outbuf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1071 char *word[PDIWORDS], *word_eol[PDIWORDS]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1072 char pdibuf[522]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1073 char *ex, ip[128], nick[128]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1074 char *cmd; |
2086 | 1075 |
1076 /* Check for errors */ | |
3452 | 1077 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1078 if (*buf != ':') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1079 if (!strncmp(buf, "NOTICE ", 7)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1080 buf += 7; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1081 if (!strncmp(buf, "PING ", 5)) { |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1082 int r = FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1083 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1084 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1085 hide_login_progress(gc, _("Unable to write")); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1086 signoff(gc); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1087 r = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1088 } |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1089 return r; |
2086 | 1090 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1091 /* XXX doesn't handle ERROR */ |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1092 return FALSE; |
2086 | 1093 } |
1094 | |
2782
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1095 if (!idata->online) { |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1096 /* Now lets sign ourselves on */ |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1097 account_online(gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1098 serv_finish_login(gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1099 |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1100 if (bud_list_cache_exists(gc)) |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1101 do_import(gc, NULL); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1102 |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1103 /* 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
|
1104 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1105 idata->online = TRUE; |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1106 } |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1107 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1108 buf++; |
2086 | 1109 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1110 process_data_init(pdibuf, buf, word, word_eol, FALSE); |
2086 | 1111 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1112 if (atoi(word[2])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1113 if (*word_eol[3]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1114 process_numeric(gc, word, word_eol); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1115 return FALSE; |
2086 | 1116 } |
1117 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1118 cmd = word[2]; |
2086 | 1119 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1120 ex = strchr(pdibuf, '!'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1121 if (!ex) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1122 strncpy(ip, pdibuf, sizeof(ip)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1123 ip[sizeof(ip)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1124 strncpy(nick, pdibuf, sizeof(nick)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1125 nick[sizeof(nick)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1126 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1127 strncpy(ip, ex + 1, sizeof(ip)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1128 ip[sizeof(ip)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1129 strncpy(nick, pdibuf, sizeof(nick)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1130 nick[sizeof(nick)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1131 if ((ex - pdibuf) < sizeof (nick)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1132 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */ |
2086 | 1133 } |
1134 | |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1135 if (!strcmp(cmd, "INVITE")) { |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1136 char *chan = g_strdup(word[4]); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1137 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
|
1138 } else if (!strcmp(cmd, "JOIN")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1139 char *chan = *word[3] == ':' ? word[3] + 1 : word[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1140 if (!g_strcasecmp(gc->displayname, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1141 static int id = 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1142 serv_got_joined_chat(gc, id++, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1143 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1144 struct conversation *c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1145 if (c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1146 add_chat_buddy(c, nick); |
2086 | 1147 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1148 } else if (!strcmp(cmd, "KICK")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1149 if (!strcmp(gc->displayname, word[4])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1150 struct conversation *c = irc_find_chat(gc, word[3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1151 if (!c) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1152 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1153 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1154 c->gc = NULL; |
3599 | 1155 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s by %s:"), |
1156 word[3], nick); | |
3427 | 1157 do_error_dialog(outbuf, *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5], GAIM_INFO); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1158 } else { |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1159 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
|
1160 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1161 irc_rem_chat_bud(gc, word[4], msg); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1162 g_free(msg); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1163 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1164 } else if (!strcmp(cmd, "KILL")) { /* */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1165 } else if (!strcmp(cmd, "MODE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1166 handle_mode(gc, word, word_eol, FALSE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1167 } else if (!strcmp(cmd, "NICK")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1168 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
|
1169 if (!strcmp(gc->displayname, nick)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1170 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1171 irc_change_name(gc, nick, new); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1172 } else if (!strcmp(cmd, "NOTICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1173 if (*word_eol[4] == ':') word_eol[4]++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1174 if (ex) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1175 irc_got_im(gc, nick, word_eol[4], 0, time(NULL)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1176 } else if (!strcmp(cmd, "PART")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1177 char *chan = cmd + 5; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1178 struct conversation *c; |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1179 char *reason = word_eol[4]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1180 GList *r; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1181 if (*chan == ':') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1182 chan++; |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1183 if (*reason == ':') |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1184 reason++; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1185 if (!(c = irc_find_chat(gc, chan))) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1186 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1187 if (!strcmp(nick, gc->displayname)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1188 serv_got_chat_left(gc, c->id); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1189 return FALSE; |
2086 | 1190 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1191 r = c->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1192 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1193 char *who = r->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1194 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1195 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1196 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1197 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1198 if (!g_strcasecmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1199 char *tmp = g_strdup(r->data); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1200 remove_chat_buddy(c, tmp, reason); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1201 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1202 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1203 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1204 r = r->next; |
2086 | 1205 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1206 } else if (!strcmp(cmd, "PRIVMSG")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1207 char *to, *msg; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1208 if (!*word[3]) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1209 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1210 to = word[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1211 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1212 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */ |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1213 if (!g_strncasecmp(msg + 1, "DCC ", 4)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1214 process_data_init(pdibuf, buf, word, word_eol, TRUE); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1215 handle_ctcp(gc, to, nick, msg + 1, word, word_eol); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1216 } else { |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1217 handle_privmsg(gc, to, nick, msg); |
2086 | 1218 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1219 } else if (!strcmp(cmd, "PONG")) { /* */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1220 } else if (!strcmp(cmd, "QUIT")) { |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1221 irc_rem_chat_bud(gc, nick, *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1222 } else if (!strcmp(cmd, "TOPIC")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1223 struct conversation *c = irc_find_chat(gc, word[3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1224 char *topic = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1225 if (c) { |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1226 char buf[IRC_BUF_LEN]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1227 chat_set_topic(c, nick, topic); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1228 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"), |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1229 nick, topic); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
1230 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1231 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1232 } else if (!strcmp(cmd, "WALLOPS")) { /* */ |
2086 | 1233 } |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1234 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1235 return FALSE; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1236 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1237 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1238 static void irc_callback(gpointer data, gint source, GaimInputCondition condition) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1239 { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1240 struct gaim_connection *gc = data; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1241 struct irc_data *idata = gc->proto_data; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1242 int i = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1243 gchar buf[1024]; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1244 gboolean off; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1245 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1246 i = read(idata->fd, buf, 1024); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1247 if (i <= 0) { |
3074 | 1248 hide_login_progress_error(gc, "Read error"); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1249 signoff(gc); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1250 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1251 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1252 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1253 idata->rxqueue = g_realloc(idata->rxqueue, i + idata->rxlen + 1); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1254 memcpy(idata->rxqueue + idata->rxlen, buf, i); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1255 idata->rxlen += i; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1256 idata->rxqueue[idata->rxlen] = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1257 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1258 while (1) { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1259 char *d, *e; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1260 int len; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1261 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1262 if (!idata->rxqueue || ((e = strchr(idata->rxqueue, '\n')) == NULL)) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1263 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1264 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1265 len = e - idata->rxqueue + 1; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1266 d = g_strndup(idata->rxqueue, len); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1267 g_strchomp(d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1268 debug_printf("IRC S: %s\n", d); |
3452 | 1269 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1270 idata->rxlen -= len; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1271 if (idata->rxlen) { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1272 char *tmp = g_strdup(e + 1); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1273 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1274 idata->rxqueue = tmp; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1275 } else { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1276 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1277 idata->rxqueue = NULL; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1278 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1279 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1280 off = irc_parse(gc, d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1281 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1282 g_free(d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1283 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1284 if (off) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1285 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1286 } |
2086 | 1287 } |
1288 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1289 static void irc_login_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 1290 { |
1291 struct gaim_connection *gc = data; | |
1292 struct irc_data *idata; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1293 char hostname[256]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1294 char buf[IRC_BUF_LEN]; |
2086 | 1295 |
1296 if (!g_slist_find(connections, gc)) { | |
1297 close(source); | |
1298 return; | |
1299 } | |
1300 | |
1301 idata = gc->proto_data; | |
1302 | |
1303 if (source == -1) { | |
1304 hide_login_progress(gc, "Write error"); | |
1305 signoff(gc); | |
1306 return; | |
1307 } | |
1308 | |
1309 if (idata->fd != source) | |
1310 idata->fd = source; | |
1311 | |
2574
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1312 gethostname(hostname, sizeof(hostname) - 1); |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1313 hostname[sizeof(hostname) - 1] = 0; |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1314 if (!*hostname) |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1315 g_snprintf(hostname, sizeof(hostname), "localhost"); |
3562 | 1316 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n", |
3452 | 1317 g_get_user_name(), hostname, |
1318 gc->user->proto_opt[USEROPT_SERV], | |
3575 | 1319 gc->user->alias && strlen(gc->user->alias) ? gc->user->alias : "gaim"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1320 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1321 hide_login_progress(gc, "Write error"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1322 signoff(gc); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1323 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1324 } |
2086 | 1325 |
2574
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1326 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
|
1327 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { |
2086 | 1328 hide_login_progress(gc, "Write error"); |
1329 signoff(gc); | |
1330 return; | |
1331 } | |
1332 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1333 gc->inpa = gaim_input_add(idata->fd, GAIM_INPUT_READ, irc_callback, gc); |
2086 | 1334 } |
1335 | |
1336 static void irc_login(struct aim_user *user) | |
1337 { | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1338 char buf[IRC_BUF_LEN]; |
2086 | 1339 |
1340 struct gaim_connection *gc = new_gaim_conn(user); | |
1341 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); | |
1342 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1343 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1344 |
2086 | 1345 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1346 set_login_progress(gc, 2, buf); | |
1347 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1348 idata->chantypes = g_strdup("#&!+"); |
3452 | 1349 idata->chanmodes = g_strdup("beI,k,lnt"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1350 idata->nickmodes = g_strdup("ohv"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1351 idata->str = g_string_new(""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1352 |
2086 | 1353 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV], |
1354 user->proto_opt[USEROPT_PORT][0] ? atoi(user-> | |
1355 proto_opt[USEROPT_PORT]) : | |
1356 6667, irc_login_callback, gc); | |
1357 if (!user->gc || (idata->fd < 0)) { | |
1358 hide_login_progress(gc, "Unable to create socket"); | |
1359 signoff(gc); | |
1360 return; | |
1361 } | |
1362 } | |
1363 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1364 static void irc_close(struct gaim_connection *gc) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1365 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1366 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1367 gchar buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1368 |
3452 | 1369 if (idata->str->len > 0) { |
1370 g_snprintf(buf, sizeof(buf), "QUIT :%s\r\n", idata->str->str); | |
1371 } else { | |
1372 g_snprintf(buf, sizeof(buf), | |
1373 "QUIT :Download Gaim [%s]\r\n", WEBSITE); | |
1374 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1375 irc_write(idata->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1376 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1377 if (idata->rxqueue) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1378 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1379 idata->rxqueue = NULL; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1380 idata->rxlen = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1381 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1382 g_free(idata->chantypes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1383 g_free(idata->chanmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1384 g_free(idata->nickmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1385 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1386 g_string_free(idata->str, TRUE); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1387 if (idata->liststr) |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1388 g_string_free(idata->liststr, TRUE); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1389 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1390 if (idata->timer) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1391 g_source_remove(idata->timer); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1392 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1393 if (gc->inpa) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1394 gaim_input_remove(gc->inpa); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1395 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1396 close(idata->fd); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1397 g_free(gc->proto_data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1398 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1399 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1400 static void set_mode_3(struct gaim_connection *gc, char *who, int sign, int mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1401 int start, int end, char *word[]) |
2086 | 1402 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1403 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1404 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1405 int left; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1406 int i = start; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1407 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1408 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1409 left = end - i; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1410 switch (left) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1411 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1412 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1413 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1414 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1415 who, sign, mode, word[i]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1416 i += 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1417 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1418 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1419 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1420 who, sign, mode, mode, word[i], word[i + 1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1421 i += 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1422 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1423 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1424 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1425 who, sign, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1426 word[i], word[i + 1], word[i + 2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1427 i += 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1428 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1429 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1430 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1431 if (left < 3) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1432 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1433 } |
2086 | 1434 } |
1435 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1436 static void set_mode_6(struct gaim_connection *gc, char *who, int sign, int mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1437 int start, int end, char *word[]) |
2086 | 1438 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1439 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1440 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1441 int left; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1442 int i = start; |
2086 | 1443 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1444 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1445 left = end - i; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1446 switch (left) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1447 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1448 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1449 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1450 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1451 who, sign, mode, word[i]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1452 i += 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1453 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1454 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1455 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1456 who, sign, mode, mode, word[i], word[i + 1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1457 i += 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1458 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1459 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1460 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1461 who, sign, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1462 word[i], word[i + 1], word[i + 2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1463 i += 3; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1464 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1465 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1466 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c %s %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1467 who, sign, mode, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1468 word[i], word[i + 1], word[i + 2], word[i + 3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1469 i += 4; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1470 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1471 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1472 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c %s %s %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1473 who, sign, mode, mode, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1474 word[i], word[i + 1], word[i + 2], |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1475 word[i + 3], word[i + 4]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1476 i += 5; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1477 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1478 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1479 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c%c %s %s %s %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1480 who, sign, mode, mode, mode, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1481 word[i], word[i + 1], word[i + 2], |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1482 word[i + 3], word[i + 4], word[i + 5]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1483 i += 6; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1484 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1485 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1486 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1487 if (left < 6) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1488 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1489 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1490 } |
2086 | 1491 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1492 static void set_mode(struct gaim_connection *gc, char *who, int sign, int mode, char *word[]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1493 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1494 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1495 int i = 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1496 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1497 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1498 if (!*word[i]) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1499 if (i == 2) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1500 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1501 if (id->six_modes) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1502 set_mode_6(gc, who, sign, mode, 2, i, word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1503 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1504 set_mode_3(gc, who, sign, mode, 2, i, word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1505 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1506 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1507 i++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1508 } |
2086 | 1509 } |
1510 | |
3452 | 1511 static void set_chan_mode(struct gaim_connection *gc, char *chan, char *mode_str) |
1512 { | |
1513 struct irc_data *id = gc->proto_data; | |
1514 char buf[IRC_BUF_LEN]; | |
1515 | |
1516 if ((mode_str[0] == '-') || (mode_str[0] == '+')) { | |
1517 g_snprintf(buf, sizeof(buf), "MODE %s %s\r\n", chan, mode_str); | |
1518 irc_write(id->fd, buf, strlen(buf)); | |
1519 } | |
1520 } | |
1521 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1522 static int handle_command(struct gaim_connection *gc, char *who, char *what) |
2086 | 1523 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1524 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1525 char pdibuf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1526 char *word[PDIWORDS], *word_eol[PDIWORDS]; |
3029 | 1527 char *tmp = g_strdup(what); |
1528 GString *str = encode_html(tmp); | |
1529 struct dcc_chat *dccchat = find_dcc_chat(gc, who); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1530 struct irc_data *id = gc->proto_data; |
3029 | 1531 g_free(tmp); |
3030 | 1532 what = str->str; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1533 if (*what != '/') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1534 unsigned int max = 440 - strlen(who); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1535 char t; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1536 while (strlen(what) > max) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1537 t = what[max]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1538 what[max] = 0; |
3029 | 1539 if (dccchat) { |
3030 | 1540 g_snprintf(buf, sizeof(buf), "%s\r\n", what); |
3029 | 1541 irc_write(dccchat->fd, buf, strlen(buf)); |
1542 g_string_free(str, TRUE); | |
1543 return 1; | |
1544 } | |
3030 | 1545 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1546 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1547 what[max] = t; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1548 what = what + max; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1549 } |
3029 | 1550 if (dccchat) { |
3030 | 1551 g_snprintf(buf, sizeof(buf), "%s\r\n", what); |
3029 | 1552 irc_write(dccchat->fd, buf, strlen(buf)); |
1553 g_string_free(str, TRUE); | |
1554 return 1; | |
1555 } | |
3030 | 1556 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1557 irc_write(id->fd, buf, strlen(buf)); |
3029 | 1558 g_string_free(str, TRUE); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1559 return 1; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1560 } |
3029 | 1561 |
3033 | 1562 process_data_init(pdibuf, what + 1, word, word_eol, TRUE); |
1563 g_string_free(str, FALSE); | |
3029 | 1564 if (!g_strcasecmp(pdibuf, "ME")) { |
1565 if (dccchat) { | |
1566 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", word_eol[2]); | |
1567 irc_write(dccchat->fd, buf, strlen(buf)); | |
3033 | 1568 g_free(what); |
3029 | 1569 return 1; |
1570 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1571 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :\001ACTION %s\001\r\n", who, word_eol[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1572 irc_write(id->fd, buf, strlen(buf)); |
3033 | 1573 g_free(what); |
2304
15fb364935ec
[gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1574 return 1; |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1575 } else if (!g_strcasecmp(pdibuf, "INVITE")) { |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1576 char buf[IRC_BUF_LEN]; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1577 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
|
1578 irc_write(id->fd, buf, strlen(buf)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1579 } else if (!g_strcasecmp(pdibuf, "TOPIC")) { |
3033 | 1580 if (!*word_eol[2]) { |
3501 | 1581 struct conversation *c; |
1582 c = irc_find_chat(gc, who); | |
1583 g_snprintf(buf, sizeof(buf), _("Topic for %s is %s"), who, c->topic ? c->topic : "(no topic set)"); | |
1584 write_to_conv(c, buf, WFLAG_SYSTEM | WFLAG_NOLOG, NULL, time(NULL), -1); | |
1585 } else { | |
1586 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, word_eol[2]); | |
1587 irc_write(id->fd, buf, strlen(buf)); | |
3033 | 1588 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1589 } else if (!g_strcasecmp(pdibuf, "NICK")) { |
3033 | 1590 if (!*word_eol[2]) { |
1591 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1592 return -EINVAL; |
3033 | 1593 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1594 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
|
1595 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1596 } else if (!g_strcasecmp(pdibuf, "OP")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1597 set_mode(gc, who, '+', 'o', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1598 } else if (!g_strcasecmp(pdibuf, "DEOP")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1599 set_mode(gc, who, '-', 'o', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1600 } else if (!g_strcasecmp(pdibuf, "VOICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1601 set_mode(gc, who, '+', 'v', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1602 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1603 set_mode(gc, who, '-', 'v', word); |
3452 | 1604 } else if (!g_strcasecmp(pdibuf, "MODE")) { |
1605 char *chan = who; | |
1606 set_chan_mode(gc, chan, word_eol[2]); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1607 } else if (!g_strcasecmp(pdibuf, "QUOTE")) { |
3033 | 1608 if (!*word_eol[2]) { |
1609 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1610 return -EINVAL; |
3033 | 1611 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1612 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1613 irc_write(id->fd, buf, strlen(buf)); |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1614 } else if (!g_strcasecmp(pdibuf, "SAY")) { |
3033 | 1615 if (!*word_eol[2]) { |
1616 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1617 return -EINVAL; |
3033 | 1618 } |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1619 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, word_eol[2]); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1620 irc_write(id->fd, buf, strlen(buf)); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1621 return 1; |
2302
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
1622 } else if (!g_strcasecmp(pdibuf, "MSG")) { |
3033 | 1623 if (!*word[2]) { |
1624 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1625 return -EINVAL; |
3033 | 1626 } |
1627 if (!*word_eol[3]) { | |
1628 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1629 return -EINVAL; |
3033 | 1630 } |
2302
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
1631 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", word[2], word_eol[3]); |
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
1632 irc_write(id->fd, buf, strlen(buf)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1633 } else if (!g_strcasecmp(pdibuf, "KICK")) { |
3033 | 1634 if (!*word[2]) { |
1635 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1636 return -EINVAL; |
3033 | 1637 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1638 if (*word_eol[3]) |
2298
57da45349e50
[gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2295
diff
changeset
|
1639 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], word_eol[3]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1640 else |
2298
57da45349e50
[gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2295
diff
changeset
|
1641 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
|
1642 irc_write(id->fd, buf, strlen(buf)); |
2801 | 1643 } else if (!g_strcasecmp(pdibuf, "JOIN") || !g_strcasecmp(pdibuf, "J")) { |
3033 | 1644 if (!*word[2]) { |
1645 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1646 return -EINVAL; |
3033 | 1647 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1648 if (*word[3]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1649 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
|
1650 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1651 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1652 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1653 } else if (!g_strcasecmp(pdibuf, "PART")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1654 char *chan = *word[2] ? word[2] : who; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1655 char *reason = word_eol[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1656 struct conversation *c; |
3033 | 1657 if (!is_channel(gc, chan)) { |
1658 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1659 return -EINVAL; |
3033 | 1660 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1661 c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1662 g_snprintf(buf, sizeof(buf), "PART %s%s%s\r\n", chan, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1663 *reason ? " :" : "", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1664 *reason ? reason : ""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1665 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1666 if (c) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1667 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1668 c->gc = NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1669 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); |
3427 | 1670 do_error_dialog(buf, NULL, GAIM_INFO); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1671 } |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1672 } else if (!g_strcasecmp(pdibuf, "WHOIS")) { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1673 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
|
1674 irc_write(id->fd, buf, strlen(buf)); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1675 } else if (!g_strcasecmp(pdibuf, "LIST")) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1676 g_snprintf(buf, sizeof(buf), "LIST\r\n"); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1677 irc_write(id->fd, buf, strlen(buf)); |
3452 | 1678 } else if (!g_strcasecmp(pdibuf, "QUIT")) { |
1679 char *reason = word_eol[2]; | |
1680 id->str = g_string_insert(id->str, 0, reason); | |
1681 do_quit(); | |
1682 } else if (!g_strcasecmp(pdibuf, "VERSION")) { | |
1683 g_snprintf(buf, sizeof(buf), "VERSION\r\n"); | |
1684 irc_write(id->fd, buf, strlen(buf)); | |
1685 } else if (!g_strcasecmp(pdibuf, "W")) { | |
1686 g_snprintf(buf, sizeof(buf), "WHO *\r\n"); | |
1687 irc_write(id->fd, buf, strlen(buf)); | |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1688 } else if (!g_strcasecmp(pdibuf, "HELP")) { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1689 struct conversation *c = NULL; |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1690 if (is_channel(gc, who)) { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1691 c = irc_find_chat(gc, who); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1692 } else { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1693 c = find_conversation(who); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1694 } |
3033 | 1695 if (!c) { |
1696 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1697 return -EINVAL; |
3033 | 1698 } |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1699 write_to_conv(c, "<B>Currently supported commands:<BR>" |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1700 "WHOIS INVITE NICK LIST<BR>" |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1701 "JOIN PART TOPIC KICK<BR>" |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1702 "OP DEOP VOICE DEVOICE<BR>" |
3452 | 1703 "ME MSG QUOTE SAY QUIT<BR>" |
1704 "MODE VERSION W</B>", | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
1705 WFLAG_NOLOG, NULL, time(NULL), -1); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1706 } else { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1707 struct conversation *c = NULL; |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1708 if (is_channel(gc, who)) { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1709 c = irc_find_chat(gc, who); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1710 } else { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1711 c = find_conversation(who); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1712 } |
3033 | 1713 if (!c) { |
1714 g_free(what); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1715 return -EINVAL; |
3033 | 1716 } |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
1717 write_to_conv(c, "<B>Unknown command</B>", WFLAG_NOLOG, NULL, time(NULL), -1); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1718 } |
3033 | 1719 g_free(what); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1720 return 0; |
2086 | 1721 } |
1722 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1723 static int send_msg(struct gaim_connection *gc, char *who, char *what) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1724 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1725 char *cr = strchr(what, '\n'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1726 if (cr) { |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1727 int ret = 0; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1728 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1729 if (cr) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1730 *cr = 0; |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1731 ret = handle_command(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1732 if (!cr) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1733 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1734 what = cr + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1735 if (!*what) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1736 break; |
2295
24dc9ce95127
[gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2294
diff
changeset
|
1737 *cr = '\n'; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1738 cr = strchr(what, '\n'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1739 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1740 return ret; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1741 } else |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1742 return handle_command(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1743 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1744 |
3466 | 1745 static void 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
|
1746 char buf[IRC_BUF_LEN]; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1747 struct irc_data *id = gc->proto_data; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1748 struct conversation *c = irc_find_chat_by_id(gc, idn); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1749 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
|
1750 irc_write(id->fd, buf, strlen(buf)); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1751 } |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1752 |
3033 | 1753 static int 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
|
1754 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1755 if (*who == '@' || *who == '+') |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1756 return send_msg(gc, who + 1, what); |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1757 return send_msg(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1758 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1759 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1760 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */ |
3466 | 1761 static void irc_add_buddy(struct gaim_connection *gc, const char *who) {} |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
1762 static void 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
|
1763 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1764 static GList *irc_chat_info(struct gaim_connection *gc) |
2086 | 1765 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1766 GList *m = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1767 struct proto_chat_entry *pce; |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1768 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1769 pce = g_new0(struct proto_chat_entry, 1); |
2466
f8eb5f120603
[gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2459
diff
changeset
|
1770 pce->label = _("Channel:"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1771 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1772 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1773 pce = g_new0(struct proto_chat_entry, 1); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1774 pce->label = _("Password:"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1775 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1776 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1777 return m; |
2086 | 1778 } |
1779 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1780 static void irc_join_chat(struct gaim_connection *gc, GList *data) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1781 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1782 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1783 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1784 char *name, *pass; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1785 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1786 if (!data) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1787 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1788 name = data->data; |
2299
b5b7dece5249
[gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2298
diff
changeset
|
1789 if (data->next) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1790 pass = data->next->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1791 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
|
1792 } else |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1793 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1794 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1795 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1796 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1797 static void irc_chat_leave(struct gaim_connection *gc, int id) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1798 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1799 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1800 struct conversation *c = irc_find_chat_by_id(gc, id); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1801 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1802 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1803 if (!c) return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1804 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1805 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1806 irc_write(idata->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1807 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1808 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1809 static int irc_chat_send(struct gaim_connection *gc, int id, char *what) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1810 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1811 struct conversation *c = irc_find_chat_by_id(gc, id); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1812 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1813 return -EINVAL; |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1814 if (send_msg(gc, c->name, what) > 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1815 serv_got_chat_in(gc, c->id, gc->displayname, 0, what, time(NULL)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1816 return 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1817 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1818 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2466
diff
changeset
|
1819 static GList *irc_away_states(struct gaim_connection *gc) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1820 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1821 return g_list_append(NULL, GAIM_AWAY_CUSTOM); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1822 } |
2086 | 1823 |
1824 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg) | |
1825 { | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1826 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1827 char buf[IRC_BUF_LEN]; |
2086 | 1828 |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1829 if (gc->away) |
2394
579f8d4347ad
[gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1830 gc->away = NULL; |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1831 |
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1832 if (msg) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1833 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg); |
2394
579f8d4347ad
[gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1834 gc->away = ""; |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1835 } else |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1836 g_snprintf(buf, sizeof(buf), "AWAY\r\n"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1837 irc_write(idata->fd, buf, strlen(buf)); |
2086 | 1838 } |
1839 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1840 static char **irc_list_icon(int uc) |
2086 | 1841 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1842 return irc_icon_xpm; |
2086 | 1843 } |
1844 | |
3029 | 1845 static int getlocalip(char *ip) /* Thanks, libfaim */ |
1846 { | |
1847 struct hostent *hptr; | |
1848 char localhost[129]; | |
1849 long unsigned add; | |
1850 | |
1851 /* XXX if available, use getaddrinfo() */ | |
1852 /* XXX allow client to specify which IP to use for multihomed boxes */ | |
1853 | |
1854 if (gethostname(localhost, 128) < 0) | |
1855 return -1; | |
1856 | |
1857 if (!(hptr = gethostbyname(localhost))) | |
1858 return -1; | |
1859 | |
1860 memcpy(&add, hptr->h_addr_list[0], 4); | |
1861 add = htonl(add); | |
1862 g_snprintf(ip, 11, "%lu", add); | |
1863 | |
1864 return 0; | |
1865 } | |
1866 | |
1867 static void dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition) | |
1868 { | |
1869 struct dcc_chat *chat = data; | |
1870 struct conversation *convo; | |
1871 char buf[128]; | |
1872 struct sockaddr_in addr; | |
1873 int addrlen = sizeof (addr); | |
1874 addr.sin_family = AF_INET; | |
1875 addr.sin_port = htons (chat->port); | |
1876 addr.sin_addr.s_addr = INADDR_ANY; | |
1877 chat->fd = accept (chat->fd, (struct sockaddr *) (&addr), &addrlen); | |
1878 if (!chat->fd) | |
1879 { | |
1880 dcc_chat_cancel (NULL,chat); | |
1881 convo = new_conversation (chat->nick); | |
1882 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"), | |
1883 chat->nick); | |
1884 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | |
1885 time ((time_t) NULL), -1); | |
1886 return; | |
1887 } | |
1888 chat->inpa = | |
1889 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat); | |
1890 convo = new_conversation (chat->nick); | |
1891 g_snprintf (buf, sizeof buf, "DCC Chat with %s established", | |
1892 chat->nick); | |
1893 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, time ((time_t) NULL), -1); | |
1894 debug_printf ("Chat with %s established\n", chat->nick); | |
1895 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | |
1896 } | |
1897 | |
1898 static void irc_start_chat(struct gaim_connection *gc, char *who) { | |
1899 struct dcc_chat *chat; | |
1900 int len; | |
1901 struct sockaddr_in addr; | |
1902 char buf[200]; | |
1903 | |
1904 /* Create a socket */ | |
1905 chat = g_new0 (struct dcc_chat, 1); | |
1906 chat->fd = socket (AF_INET, SOCK_STREAM, 0); | |
1907 chat->gc = gc; | |
1908 g_snprintf (chat->nick, sizeof (chat->nick), "%s", who); | |
1909 if (chat->fd < 0) { | |
1910 dcc_chat_cancel (NULL,chat); | |
1911 return; | |
1912 } | |
1913 addr.sin_family = AF_INET; | |
1914 addr.sin_port = 0; | |
1915 addr.sin_addr.s_addr = INADDR_ANY; | |
1916 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr)); | |
1917 listen (chat->fd, 1); | |
1918 len = sizeof (addr); | |
1919 getsockname (chat->fd, (struct sockaddr *) &addr, &len); | |
1920 chat->port = ntohs (addr.sin_port); | |
1921 getlocalip(chat->ip_address); | |
1922 chat->inpa = | |
1923 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected, | |
1924 chat); | |
1925 snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", | |
1926 chat->ip_address, chat->port); | |
3033 | 1927 irc_send_im (gc, who, buf, -1, 0); |
3029 | 1928 } |
1929 | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1930 static void irc_get_info(struct gaim_connection *gc, char *who) |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1931 { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1932 struct irc_data *idata = gc->proto_data; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1933 char buf[IRC_BUF_LEN]; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1934 |
2633
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
1935 if (*who == '@') |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
1936 who++; |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
1937 if (*who == '+') |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
1938 who++; |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
1939 |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1940 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1941 irc_write(idata->fd, buf, strlen(buf)); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1942 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1943 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1944 static GList *irc_buddy_menu(struct gaim_connection *gc, char *who) |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1945 { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1946 GList *m = NULL; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1947 struct proto_buddy_menu *pbm; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1948 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1949 pbm = g_new0(struct proto_buddy_menu, 1); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1950 pbm->label = _("Get Info"); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1951 pbm->callback = irc_get_info; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1952 pbm->gc = gc; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1953 m = g_list_append(m, pbm); |
3029 | 1954 pbm = g_new0(struct proto_buddy_menu, 1); |
1955 pbm->label = _("DCC Chat"); | |
1956 pbm->callback = irc_start_chat; | |
1957 pbm->gc = gc; | |
1958 m = g_list_append(m, pbm); | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1959 return m; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1960 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1961 |
2086 | 1962 static struct prpl *my_protocol = NULL; |
1963 | |
1964 void irc_init(struct prpl *ret) | |
1965 { | |
3572 | 1966 struct proto_user_opt *puo; |
2086 | 1967 ret->protocol = PROTO_IRC; |
2100
a93aeb6f813d
[gaim-migrate @ 2110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1968 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD; |
3572 | 1969 ret->name = g_strdup("IRC"); |
2086 | 1970 ret->list_icon = irc_list_icon; |
1971 ret->login = irc_login; | |
1972 ret->close = irc_close; | |
1973 ret->send_im = irc_send_im; | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
1974 ret->add_buddy = irc_add_buddy; |
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
1975 ret->remove_buddy = irc_remove_buddy; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
1976 ret->chat_info = irc_chat_info; |
2086 | 1977 ret->join_chat = irc_join_chat; |
1978 ret->chat_leave = irc_chat_leave; | |
1979 ret->chat_send = irc_chat_send; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1980 ret->away_states = irc_away_states; |
2086 | 1981 ret->set_away = irc_set_away; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1982 ret->get_info = irc_get_info; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1983 ret->buddy_menu = irc_buddy_menu; |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1984 ret->chat_invite = irc_chat_invite; |
3029 | 1985 ret->convo_closed = irc_convo_closed; |
3572 | 1986 |
1987 puo = g_new0(struct proto_user_opt, 1); | |
1988 puo->label = g_strdup("Server:"); | |
1989 puo->def = g_strdup("irc.openprojects.net"); | |
1990 puo->pos = USEROPT_SERV; | |
1991 ret->user_opts = g_list_append(ret->user_opts, puo); | |
1992 | |
1993 puo = g_new0(struct proto_user_opt, 1); | |
1994 puo->label = g_strdup("Port:"); | |
1995 puo->def = g_strdup("6667"); | |
1996 puo->pos = USEROPT_PORT; | |
1997 ret->user_opts = g_list_append(ret->user_opts, puo); | |
1998 | |
1999 my_protocol = ret; | |
2086 | 2000 } |
2001 | |
2002 #ifndef STATIC | |
2003 | |
3572 | 2004 void *gaim_prpl_init(struct prpl* prpl) |
2086 | 2005 { |
3572 | 2006 irc_init(prpl); |
2007 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 2008 } |
2009 | |
2010 #endif |