Mercurial > pidgin
annotate plugins/irc.c @ 1875:c0a69f90d662
[gaim-migrate @ 1885]
The default IRC port would be a good one to use. :-)
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Tue, 22 May 2001 00:18:33 +0000 |
parents | 466fc4ada7cb |
children | a02584b98823 |
rev | line source |
---|---|
987 | 1 /* |
2 * gaim - IRC Protocol Plugin | |
3 * | |
1672 | 4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com> |
987 | 5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
23 #include "../config.h" | |
24 | |
25 | |
26 #include <netdb.h> | |
27 #include <gtk/gtk.h> | |
28 #include <unistd.h> | |
29 #include <errno.h> | |
30 #include <netinet/in.h> | |
31 #include <arpa/inet.h> | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
32 #include <fcntl.h> |
987 | 33 #include <string.h> |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | |
1864
5cb89cf24f45
[gaim-migrate @ 1874]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1848
diff
changeset
|
39 #include <ctype.h> |
987 | 40 #include "multi.h" |
41 #include "prpl.h" | |
42 #include "gaim.h" | |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
43 #include "proxy.h" |
987 | 44 |
1178 | 45 #include "pixmaps/free_icon.xpm" |
46 | |
1011 | 47 #define IRC_BUF_LEN 4096 |
48 | |
1022 | 49 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
50 #define USEROPT_SERV 0 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
51 #define USEROPT_PORT 1 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
52 #define USEROPT_PROXYSERV 2 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
53 #define USEROPT_PROXYPORT 3 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
54 #define USEROPT_PROXYTYPE 4 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
55 #define USEROPT_USER 5 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
56 #define USEROPT_PASS 6 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
57 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
58 |
1011 | 59 static int chat_id = 0; |
60 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
61 struct irc_channel { |
1011 | 62 int id; |
63 gchar *name; | |
64 }; | |
65 | |
66 struct irc_data { | |
67 int fd; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
68 int inpa; /* used for non-block logins */ |
1011 | 69 |
1022 | 70 int timer; |
71 | |
72 int totalblocks; | |
73 int recblocks; | |
74 | |
75 GSList *templist; | |
1011 | 76 GList *channels; |
77 }; | |
78 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
79 static char *irc_name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
80 { |
1008 | 81 return "IRC"; |
82 } | |
83 | |
1675 | 84 static void irc_get_info(struct gaim_connection *gc, char *who); |
85 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
86 char *name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
87 { |
1008 | 88 return "IRC"; |
89 } | |
90 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
91 char *description() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
92 { |
1008 | 93 return "Allows gaim to use the IRC protocol"; |
94 } | |
95 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
96 static void irc_join_chat(struct gaim_connection *gc, int id, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
97 { |
1011 | 98 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
99 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 100 |
101 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name); | |
102 write(idata->fd, buf, strlen(buf)); | |
1742 | 103 write(idata->fd, buf, strlen(buf)); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
104 |
1011 | 105 g_free(buf); |
106 } | |
107 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
108 static void irc_update_user(struct gaim_connection *gc, char *name, int status) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
109 { |
1022 | 110 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
111 struct irc_channel *u; | |
112 GSList *temp = idata->templist; | |
113 | |
114 /* Loop through our list */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
115 |
1022 | 116 while (temp) { |
117 u = (struct irc_channel *)temp->data; | |
118 if (g_strcasecmp(u->name, name) == 0) { | |
119 u->id = status; | |
120 return; | |
121 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
122 |
1022 | 123 temp = g_slist_next(temp); |
124 } | |
125 return; | |
126 } | |
127 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
128 static void irc_request_buddy_update(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
129 { |
1022 | 130 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1046
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
131 GSList *grp = gc->groups; |
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
132 GSList *person; |
1022 | 133 struct group *g; |
134 struct buddy *b; | |
135 struct irc_channel *u; | |
136 | |
137 if (idata->templist != NULL) | |
138 return; | |
139 | |
140 idata->recblocks = 0; | |
141 idata->totalblocks = 1; | |
142 | |
1105 | 143 /* First, let's check to see if we have anyone on our buddylist */ |
144 if (!grp) { | |
145 return; | |
146 } | |
147 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
148 /* Send the first part of our request */ |
1022 | 149 write(idata->fd, "ISON", 4); |
150 | |
151 /* Step through our list of groups */ | |
152 while (grp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
153 |
1022 | 154 g = (struct group *)grp->data; |
155 person = g->members; | |
156 | |
157 while (person) { | |
158 b = (struct buddy *)person->data; | |
159 | |
160 /* We will store our buddy info here. I know, this is cheap | |
161 * but hey, its the exact same data structure. Why should we | |
162 * bother with making another one */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
163 |
1022 | 164 u = g_new0(struct irc_channel, 1); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
165 u->id = 0; /* Assume by default that they're offline */ |
1022 | 166 u->name = strdup(b->name); |
167 | |
168 write(idata->fd, " ", 1); | |
169 write(idata->fd, u->name, strlen(u->name)); | |
170 idata->templist = g_slist_append(idata->templist, u); | |
171 | |
172 person = person->next; | |
173 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
174 |
1022 | 175 grp = g_slist_next(grp); |
176 } | |
177 write(idata->fd, "\n", 1); | |
178 } | |
179 | |
180 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
181 static void irc_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
182 { |
1011 | 183 |
1742 | 184 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
185 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 186 |
1847 | 187 if (who[0] == '@' || who[0] == '+') { |
188 | |
189 /* If the user trys to msg an op or a voice from the channel, the convo will try | |
190 * to send it to @nick or +nick... needless to say, this is undesirable. | |
191 */ | |
192 who++; | |
193 } | |
194 | |
1011 | 195 /* Before we actually send this, we should check to see if they're trying |
1674 | 196 * To issue a command and handle it properly. */ |
1011 | 197 |
1674 | 198 if (message[0] == '/') |
199 { | |
200 /* I'll change the implementation of this a little later :-) */ | |
201 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
202 /* We have /me!! We have /me!! :-) */ | |
1011 | 203 |
1674 | 204 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
205 strcpy(temp, message + 4); | |
206 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%cACTION %s%c\n", who, '\001', temp, '\001'); | |
207 g_free(temp); | |
208 } | |
1675 | 209 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { |
210 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
211 strcpy(temp, message + 7); | |
212 irc_get_info(gc, temp); | |
213 g_free(temp); | |
214 | |
215 return; | |
216 } | |
217 | |
1674 | 218 } |
219 else { | |
1011 | 220 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%s\n", who, message); |
221 } | |
222 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
223 write(idata->fd, buf, strlen(buf)); |
1011 | 224 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
225 g_free(buf); |
1011 | 226 } |
227 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
228 static int find_id_by_name(struct gaim_connection *gc, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
229 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
230 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 231 GList *templist; |
232 struct irc_channel *channel; | |
233 | |
234 templist = ((struct irc_data *)gc->proto_data)->channels; | |
235 | |
236 while (templist) { | |
237 channel = (struct irc_channel *)templist->data; | |
238 | |
239 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name); | |
240 | |
241 if (g_strcasecmp(temp, name) == 0) { | |
242 g_free(temp); | |
243 return channel->id; | |
244 } | |
245 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
246 templist = templist->next; |
1011 | 247 } |
248 | |
249 g_free(temp); | |
250 | |
251 /* Return -1 if we have no ID */ | |
252 return -1; | |
253 } | |
254 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
255 static struct irc_channel *find_channel_by_name(struct gaim_connection *gc, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
256 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
257 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 258 GList *templist; |
259 struct irc_channel *channel; | |
260 | |
261 templist = ((struct irc_data *)gc->proto_data)->channels; | |
262 | |
263 while (templist) { | |
264 channel = (struct irc_channel *)templist->data; | |
265 | |
266 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name); | |
267 | |
268 if (g_strcasecmp(temp, name) == 0) { | |
269 g_free(temp); | |
270 return channel; | |
271 } | |
272 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
273 templist = templist->next; |
1011 | 274 } |
275 | |
276 g_free(temp); | |
277 | |
278 /* If we found nothing, return nothing :-) */ | |
279 return NULL; | |
280 } | |
281 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
282 static struct irc_channel *find_channel_by_id(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
283 { |
1011 | 284 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
285 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
286 |
1011 | 287 GList *temp; |
288 | |
289 temp = idata->channels; | |
290 | |
291 while (temp) { | |
292 channel = (struct irc_channel *)temp->data; | |
293 | |
294 if (channel->id == id) { | |
295 /* We've found our man */ | |
296 return channel; | |
297 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
298 |
1011 | 299 temp = temp->next; |
300 } | |
301 | |
302 | |
303 /* If we didnt find one, return NULL */ | |
304 return NULL; | |
305 } | |
306 | |
1847 | 307 static void irc_chat_leave(struct gaim_connection *gc, int id); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
308 static void irc_chat_send(struct gaim_connection *gc, int id, char *message) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
309 { |
1011 | 310 |
1742 | 311 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 312 struct irc_channel *channel = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
313 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1742 | 314 char **kick; |
315 gboolean is_command = FALSE; | |
1011 | 316 /* First lets get our current channel */ |
317 channel = find_channel_by_id(gc, id); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
318 |
1011 | 319 |
320 if (!channel) { | |
321 /* If for some reason we've lost our channel, let's bolt */ | |
1021 | 322 g_free(buf); |
1011 | 323 return; |
324 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
325 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
326 |
1011 | 327 /* Before we actually send this, we should check to see if they're trying |
1675 | 328 * To issue a command and handle it properly. */ |
1011 | 329 |
1675 | 330 if (message[0] == '/') |
1742 | 331 { |
332 | |
333 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
334 /* We have /me!! We have /me!! :-) */ | |
335 | |
336 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
337 strcpy(temp, message + 4); | |
338 | |
339 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%cACTION %s%c\n", channel->name, '\001', temp, | |
340 '\001'); | |
341 g_free(temp); | |
342 } | |
343 else if ((g_strncasecmp(message, "/op ", 4) == 0) && (strlen(message) > 4)) { | |
344 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
345 strcpy(temp, message + 4); | |
346 | |
347 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s +o %s\n", channel->name, temp); | |
348 | |
349 g_free(temp); | |
350 is_command = TRUE; | |
351 | |
352 } | |
353 else if ((g_strncasecmp(message, "/deop ", 6) == 0) && (strlen(message) > 6)) { | |
354 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
355 strcpy(temp, message + 6); | |
356 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s -o %s\n", channel->name, temp); | |
357 | |
358 g_free(temp); | |
359 is_command = TRUE; | |
1675 | 360 } |
1742 | 361 |
362 else if ((g_strncasecmp(message, "/voice ", 7) == 0) && (strlen(message) > 7)) { | |
363 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
364 strcpy(temp, message + 7); | |
365 | |
366 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s +v %s\n", channel->name, temp); | |
367 | |
368 g_free(temp); | |
369 is_command = TRUE; | |
370 | |
371 } | |
372 else if ((g_strncasecmp(message, "/devoice ", 9) == 0) && (strlen(message) > 9)) { | |
373 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
374 strcpy(temp, message + 6); | |
375 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s -v %s\n", channel->name, temp); | |
376 | |
377 g_free(temp); | |
378 is_command = TRUE; | |
379 } | |
380 else if ((g_strncasecmp(message, "/mode ", 6) == 0) && (strlen(message) > 6)) { | |
381 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
382 strcpy(temp, message + 6); | |
383 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s %s\n", channel->name, temp); | |
384 g_free(temp); | |
385 is_command = TRUE; | |
386 } | |
387 | |
388 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { | |
389 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
390 | |
391 strcpy(temp, message + 7); | |
392 irc_get_info(gc, temp); | |
393 g_free(temp); | |
1847 | 394 is_command = TRUE; |
1742 | 395 |
396 } | |
397 | |
1847 | 398 else if (!g_strncasecmp(message, "/part", 5) && (strlen(message) == 5)) { |
399 | |
400 /* If I'm not mistaken, the chat_leave command was coded under the | |
401 * pretense that it would only occur when someone closed the window. | |
402 * For this reason, the /part command will not close the window. Nor | |
403 * will the window close when the user is /kicked. I'll let you decide | |
404 * the best way to fix it--I'd imagine it'd just be a little line like | |
405 * if (convo) close (convo), but I'll let you decide where to put it. | |
406 */ | |
407 | |
408 irc_chat_leave(gc, id); | |
409 is_command = TRUE; | |
410 return; | |
411 | |
412 | |
413 } | |
414 | |
415 else if (!g_strncasecmp(message, "/join ", 6) && (strlen(message) > 6)) { | |
416 | |
417 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
418 | |
419 strcpy(temp, message + 6); | |
420 | |
421 | |
422 irc_join_chat(gc, 0, temp); | |
423 g_free(temp); | |
424 is_command = TRUE; | |
425 return; | |
426 } | |
427 | |
1742 | 428 else if (!g_strncasecmp(message, "/raw ", 5) && (strlen(message) > 5)){ |
429 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
430 strcpy(temp, message + 5); | |
431 g_snprintf(buf, IRC_BUF_LEN, "%s\r\n", temp); | |
432 g_free(temp); | |
433 is_command = TRUE; | |
434 } | |
1847 | 435 |
1742 | 436 else if (!g_strncasecmp(message, "/quote ", 7) && (strlen(message) >7)) { |
437 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
438 strcpy(temp, message + 7); | |
439 g_snprintf(buf, IRC_BUF_LEN, "%s\r\n", temp); | |
440 g_free(temp); | |
441 is_command = TRUE; | |
442 } | |
443 | |
444 else if (!g_strncasecmp(message, "/kick ", 6) && (strlen(message) > 6)) { | |
445 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
446 strcpy(temp, message + 6); | |
447 kick = g_strsplit(temp, " ", 2); | |
448 g_snprintf(buf, IRC_BUF_LEN, "KICK #%s %s :%s\r\n", channel->name, kick[0], kick[1]); | |
449 g_free(temp); | |
450 is_command = TRUE; | |
451 } | |
452 | |
453 /* FIXME: I'll go back in and grab this later. -- Rob */ | |
454 /* | |
455 I THOUGHT THIS WOULD WORK, BUT I WAS WRONG. WOULD SOMEONE KINDLY FIX IT? | |
1675 | 456 |
1742 | 457 |
458 else if (!g_strncasecmp(message, "/help", 5)) { | |
459 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
460 strcpy(temp, message + 5); | |
461 if (temp == "") { | |
462 | |
463 serv_got_chat_in(gc, id, "gAIM", 0, "Available Commands:"); | |
464 serv_got_chat_in(gc, id, "gAIM", 0, " "); | |
465 serv_got_chat_in(gc, id, "gAIM", 0, "<b>op voice kick </b>"); | |
466 serv_got_chat_in(gc, id, "gAIM", 0, "<b>deop devoice whois</b>"); | |
467 serv_got_chat_in(gc, id, "gAIM", 0, "<b>me raw quote</b>"); | |
468 serv_got_chat_in(gc, id, "gAIM", 0, "<b>mode</b>"); | |
469 } | |
470 else { | |
471 serv_got_chat_in(gc, id, "gAIM", 0, "Usage: "); | |
472 if (temp == "op") | |
473 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/op <nick></b> - Gives operator status to user."); | |
474 else if (temp == "deop") | |
475 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/deop <nick></b> - Removes operator status from user."); | |
476 else if (temp == "me") | |
477 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/me <action></b> - Sends an action to the channel."); | |
478 else if (temp == "mode") | |
479 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/mode {[+|-}|o|p|s|i|t|n|b|v} [<limit][<nick>][<ban mask]</b> - Changes channel and user modes."); | |
480 else if (temp == "voice") | |
481 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/voice <nick></b> - Gives voice status to user."); | |
482 else if (temp == "devoice") | |
483 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/devoice <nick></b> - Removes voice status from user."); | |
484 else if (temp == "raw") | |
485 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/raw <text></b> - Sends raw text to the server."); | |
486 else if (temp == "kick") | |
487 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/kick [<comment>]</b> - Kicks a user out of the channel."); | |
488 else if (temp == "whois") | |
489 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/whois <nick></b> - Gets information about user."); | |
490 else if (temp == "quote") | |
491 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/raw <text></b> - Sends raw text to the server."); | |
492 else | |
493 serv_got_chat_in(gc, id, "gAIM", 0, "No such command."); | |
494 } | |
495 | |
496 g_free(temp); | |
497 is_command = TRUE; | |
498 } | |
499 */ | |
500 | |
501 } | |
502 | |
1675 | 503 else { |
1742 | 504 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%s\n", channel->name, message); |
505 | |
506 } | |
507 | |
508 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
509 write(idata->fd, buf, strlen(buf)); |
1742 | 510 |
1011 | 511 /* Since AIM expects us to receive the message we send, we gotta fake it */ |
1742 | 512 if (is_command==FALSE) |
1764 | 513 serv_got_chat_in(gc, id, gc->username, 0, message, time((time_t)NULL)); |
1742 | 514 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
515 g_free(buf); |
1742 | 516 |
517 | |
1008 | 518 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
519 static struct conversation *find_conversation_by_id(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
520 { |
1014 | 521 GSList *bc = gc->buddy_chats; |
522 struct conversation *b = NULL; | |
523 | |
524 while (bc) { | |
525 b = (struct conversation *)bc->data; | |
526 if (id == b->id) { | |
527 break; | |
528 } | |
529 bc = bc->next; | |
530 b = NULL; | |
531 } | |
532 | |
533 if (!b) { | |
534 return NULL; | |
535 } | |
536 | |
537 return b; | |
538 } | |
539 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
540 static struct conversation *find_conversation_by_name(struct gaim_connection *gc, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
541 { |
1014 | 542 GSList *bc = gc->buddy_chats; |
543 struct conversation *b = NULL; | |
544 | |
545 while (bc) { | |
546 b = (struct conversation *)bc->data; | |
547 | |
548 if (g_strcasecmp(name, b->name) == 0) { | |
549 break; | |
550 } | |
551 bc = bc->next; | |
552 b = NULL; | |
553 } | |
554 | |
555 if (!b) { | |
556 return NULL; | |
557 } | |
558 | |
559 return b; | |
560 } | |
561 | |
562 | |
563 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
564 static void irc_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
565 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
566 struct gaim_connection *gc = data; |
1011 | 567 int i = 0; |
568 gchar buf[4096]; | |
569 gchar **buf2; | |
570 struct irc_data *idata; | |
1742 | 571 |
572 idata = (struct irc_data *)gc->proto_data; | |
1011 | 573 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
574 |
1011 | 575 do { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
576 if (read(idata->fd, buf + i, 1) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
577 hide_login_progress(gc, "Read error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
578 signoff(gc); |
1105 | 579 return; |
1011 | 580 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
581 } while (buf[i++] != '\n'); |
1011 | 582 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
583 buf[--i] = '\0'; |
1301 | 584 g_strchomp(buf); |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
585 g_print("%s\n", buf); |
1105 | 586 |
587 /* Check for errors */ | |
588 | |
589 if (((strstr(buf, "ERROR :") && (!strstr(buf, "PRIVMSG ")) && | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
590 (!strstr(buf, "NOTICE ")) && (strlen(buf) > 7)))) { |
1105 | 591 |
592 gchar *u_errormsg; | |
593 | |
594 /* Let's get our error message */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
595 u_errormsg = g_strdup(buf + 7); |
1105 | 596 |
597 /* We got our error message. Now, let's reaise an | |
598 * error dialog */ | |
599 | |
600 do_error_dialog(u_errormsg, "Gaim: IRC Error"); | |
601 | |
602 /* And our necessary garbage collection */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
603 g_free(u_errormsg); |
1847 | 604 return; |
1105 | 605 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
606 |
1673 | 607 /* This should be a whois response. I only care about the first (311) one. I might do |
608 * the other's later. They're boring. */ | |
609 | |
610 if (((strstr(buf, " 311 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
611 char **res; | |
612 | |
613 res = g_strsplit(buf, " ", 7); | |
614 | |
615 if (!strcmp(res[1], "311")) | |
616 { | |
617 char buf[8192]; | |
618 | |
619 g_snprintf(buf, 4096, "<b>Nick:</b> %s<br>" | |
620 "<b>Host:</b> %s@%s<br>" | |
621 "<b>Name:</b> %s<br>", res[3], res[4], res[5], res[7]+1); | |
622 | |
623 g_show_info_text(buf); | |
624 } | |
625 | |
626 g_strfreev(res); | |
1847 | 627 return; |
1673 | 628 } |
629 | |
1676 | 630 /* Autoresponse to an away message */ |
631 if (((strstr(buf, " 301 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
632 char **res; | |
633 | |
634 res = g_strsplit(buf, " ", 5); | |
635 | |
636 if (!strcmp(res[1], "301")) | |
1764 | 637 serv_got_im(gc, res[3], res[4] + 1, 1, time((time_t)NULL)); |
1676 | 638 |
639 g_strfreev(res); | |
1847 | 640 return; |
1676 | 641 } |
642 | |
1014 | 643 /* Parse the list of names that we receive when we first sign on to |
644 * a channel */ | |
645 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
646 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1014 | 647 gchar u_host[255]; |
648 gchar u_command[32]; | |
649 gchar u_channel[128]; | |
650 gchar u_names[IRC_BUF_LEN + 1]; | |
651 struct conversation *convo = NULL; | |
652 int j; | |
653 | |
654 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
655 u_host[j] = buf[i]; | |
656 } | |
657 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
658 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
659 i++; |
1014 | 660 |
661 for (j = 0; buf[i] != ' '; j++, i++) { | |
662 u_command[j] = buf[i]; | |
663 } | |
664 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
665 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
666 i++; |
1014 | 667 |
668 for (j = 0; buf[i] != '#'; j++, i++) { | |
669 } | |
670 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
671 |
1014 | 672 for (j = 0; buf[i] != ':'; j++, i++) { |
673 u_channel[j] = buf[i]; | |
674 } | |
675 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
676 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
677 i++; |
1014 | 678 |
679 while ((buf[i] == ' ') || (buf[i] == ':')) { | |
680 i++; | |
681 } | |
682 | |
683 strcpy(u_names, buf + i); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
684 |
1014 | 685 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
686 |
1014 | 687 /* Let's get our conversation window */ |
688 convo = find_conversation_by_name(gc, u_channel); | |
689 | |
690 if (!convo) { | |
691 return; | |
692 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
693 |
1014 | 694 /* Now that we've parsed the hell out of this big |
695 * mess, let's try to split up the names properly */ | |
696 | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
697 for (i = 0; buf2[i] != NULL; i++) |
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
698 add_chat_buddy(convo, buf2[i]); |
1021 | 699 |
700 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
701 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
702 |
1014 | 703 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
704 |
1014 | 705 } |
706 | |
1022 | 707 /* Receive a list of users that are currently online */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
708 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
709 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1022 | 710 gchar u_host[255]; |
711 gchar u_command[32]; | |
712 gchar u_names[IRC_BUF_LEN + 1]; | |
713 int j; | |
714 | |
715 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
716 u_host[j] = buf[i]; | |
717 } | |
718 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
719 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
720 i++; |
1022 | 721 |
722 for (j = 0; buf[i] != ' '; j++, i++) { | |
723 u_command[j] = buf[i]; | |
724 } | |
725 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
726 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
727 i++; |
1022 | 728 |
729 for (j = 0; buf[i] != ':'; j++, i++) { | |
730 /* My Nick */ | |
731 } | |
732 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
733 |
1022 | 734 strcpy(u_names, buf + i); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
735 |
1022 | 736 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
737 |
1022 | 738 /* Now that we've parsed the hell out of this big |
739 * mess, let's try to split up the names properly */ | |
740 | |
741 for (i = 0; buf2[i] != NULL; i++) { | |
742 /* If we have a name here then our buddy is online. We should | |
743 * update our temporary gslist accordingly. When we achieve our maximum | |
744 * list of names then we should force an update */ | |
745 | |
746 irc_update_user(gc, buf2[i], 1); | |
747 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
748 |
1022 | 749 /* Increase our received blocks counter */ |
750 idata->recblocks++; | |
751 | |
752 /* If we have our total number of blocks */ | |
753 if (idata->recblocks == idata->totalblocks) { | |
754 GSList *temp; | |
755 struct irc_channel *u; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
756 |
1022 | 757 /* Let's grab our list of people and bring them all on or off line */ |
758 temp = idata->templist; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
759 |
1022 | 760 /* Loop */ |
761 while (temp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
762 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
763 u = temp->data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
764 |
1022 | 765 /* Tell Gaim to bring the person on or off line */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
766 serv_got_update(gc, u->name, u->id, 0, 0, 0, 0, 0); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
767 |
1022 | 768 /* Grab the next entry */ |
769 temp = g_slist_next(temp); | |
770 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
771 |
1022 | 772 /* And now, let's delete all of our entries */ |
773 temp = idata->templist; | |
774 while (temp) { | |
775 u = temp->data; | |
776 g_free(u->name); | |
777 temp = g_slist_remove(temp, u); | |
778 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
779 |
1022 | 780 /* Reset our list */ |
781 idata->totalblocks = 0; | |
782 idata->recblocks = 0; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
783 |
1022 | 784 idata->templist = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
785 |
1022 | 786 return; |
787 } | |
788 | |
789 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
790 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
791 |
1022 | 792 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
793 |
1022 | 794 } |
795 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
796 |
1847 | 797 if ((strstr(buf, " MODE ")) && (strstr(buf, "!")) && (strstr(buf, "+v") || strstr(buf, "-v") || strstr(buf, "-o") || strstr(buf, "+o")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
798 | |
799 gchar u_channel[128]; | |
800 gchar u_nick[128]; | |
801 | |
802 gchar u_mode[5]; | |
803 char **people; | |
804 gchar *temp, *temp_new; | |
805 | |
806 | |
807 struct irc_channel *channel; | |
808 int j; | |
809 temp = NULL; | |
810 temp_new = NULL; | |
811 | |
812 | |
813 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
814 u_nick[j] = buf[i]; | |
815 } | |
816 u_nick[j] = '\0'; | |
817 i++; | |
818 | |
819 for (j = 0; buf[i] != '#'; j++, i++) { | |
820 } | |
821 i++; | |
822 | |
823 for (j = 0; buf[i] != ' '; j++, i++) { | |
824 u_channel[j] = buf[i]; | |
825 } | |
826 | |
827 u_channel[j] = '\0'; | |
828 i++; | |
829 | |
830 for (j = 0; buf[i] != ' '; j++, i++) { | |
831 u_mode[j] = buf[i]; | |
832 } | |
833 u_mode[j] = '\0'; | |
834 i++; | |
835 | |
836 | |
837 | |
838 | |
839 people = g_strsplit(buf + i, " ", 3); | |
840 | |
841 | |
842 | |
843 channel = find_channel_by_name(gc, u_channel); | |
844 | |
845 if (!channel) { | |
846 return; | |
847 } | |
848 | |
849 for (j = 0; j < strlen(u_mode) - 1 ; j++) | |
850 { | |
851 | |
852 | |
853 struct conversation *convo = NULL; | |
854 convo = find_conversation_by_id(gc, channel->id); | |
855 | |
856 | |
857 | |
1848 | 858 temp = (gchar *)g_malloc(strlen(people[j]) + 3); |
859 temp_new = (gchar *)g_malloc(strlen(people[j]) + 3); | |
1847 | 860 g_snprintf(temp, strlen(people[j]) + 2, "@%s", people[j]); |
861 | |
862 if (u_mode[1] == 'v' && u_mode[0] == '+') { | |
863 g_snprintf(temp_new, strlen(people[j]) + 2, "+%s", people[j]); | |
864 } | |
865 else if (u_mode[1] == 'o' && u_mode[0] == '+') { | |
866 g_snprintf(temp_new, strlen(people[j]) + 2, "@%s", people[j]); | |
867 } | |
868 | |
869 else if (u_mode[0] == '-') { | |
870 g_snprintf(temp_new, strlen(people[j]) + 1, "%s", people[j]); | |
871 } | |
872 | |
873 | |
874 | |
875 rename_chat_buddy(convo, temp, temp_new); | |
876 g_snprintf(temp, strlen(people[j]) + 2, "+%s", people[j]); | |
877 rename_chat_buddy(convo, temp, temp_new); | |
878 | |
879 rename_chat_buddy(convo, people[j], temp_new); | |
880 | |
881 | |
882 | |
883 | |
884 | |
885 } | |
886 if (temp) | |
887 g_free(temp); | |
888 if (temp_new) | |
889 g_free(temp_new); | |
890 | |
891 return; | |
892 } | |
893 | |
894 | |
895 if ((strstr(buf, " KICK ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | |
896 gchar u_channel[128]; | |
897 gchar u_nick[128]; | |
898 gchar u_comment[128]; | |
899 gchar u_who[128]; | |
900 | |
901 int id; | |
902 | |
903 gchar *temp; | |
904 | |
905 | |
906 | |
907 struct irc_channel *channel; | |
908 int j; | |
909 | |
910 temp = NULL; | |
911 | |
912 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
913 u_nick[j] = buf[i]; | |
914 } | |
915 u_nick[j] = '\0'; | |
916 i++; | |
917 | |
918 for (j = 0; buf[i] != '#'; j++, i++) { | |
919 } | |
920 i++; | |
921 | |
922 for (j = 0; buf[i] != ' '; j++, i++) { | |
923 u_channel[j] = buf[i]; | |
924 } | |
925 | |
926 u_channel[j] = '\0'; | |
927 i++; | |
928 | |
929 for (j = 0; buf[i] != ' '; j++, i++) { | |
930 u_who[j] = buf[i]; | |
931 } | |
932 u_who[j] = '\0'; | |
933 i++; | |
934 i++; | |
935 strcpy(u_comment, buf + i); | |
936 g_strchomp(u_comment); | |
937 | |
938 channel = find_channel_by_name(gc, u_channel); | |
939 | |
940 if (!channel) { | |
941 return; | |
942 } | |
943 | |
944 | |
945 id = find_id_by_name(gc, u_channel); | |
946 | |
947 | |
948 if (g_strcasecmp(u_nick, gc->username) == 0) { | |
949 | |
950 /* It looks like you've been naughty! */ | |
951 | |
952 serv_got_chat_left(gc, channel->id); | |
953 | |
954 idata->channels = g_list_remove(idata->channels, channel); | |
955 } | |
956 else { | |
957 struct conversation *convo = NULL; | |
958 | |
959 /* Find their conversation window */ | |
960 convo = find_conversation_by_id(gc, channel->id); | |
961 | |
962 if (!convo) { | |
963 /* Some how the window doesn't exist. | |
964 * Let's get out of here */ | |
965 return; | |
966 } | |
967 | |
968 /* And remove their name */ | |
969 /* If the person is an op or voice, this won't work. | |
970 * so we'll just do a nice hack and remove nick and | |
971 * @nick and +nick. Truly wasteful. | |
972 */ | |
973 | |
1848 | 974 temp = (gchar *) g_malloc(strlen(u_who) + 3); |
1847 | 975 g_snprintf(temp, strlen(u_who) + 2, "@%s", u_who); |
976 remove_chat_buddy(convo, temp); | |
1848 | 977 g_free(temp); |
978 temp = (gchar *) g_malloc(strlen(u_who) + 3); | |
1847 | 979 g_snprintf(temp, strlen(u_who) + 2, "+%s", u_who); |
980 remove_chat_buddy(convo, temp); | |
981 remove_chat_buddy(convo, u_who); | |
982 | |
1848 | 983 g_free(temp); |
1847 | 984 |
985 } | |
986 | |
987 /* Go Home! */ | |
988 return; | |
989 } | |
990 | |
991 | |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
992 if ((strstr(buf, " JOIN ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 993 |
994 gchar u_channel[128]; | |
1012 | 995 gchar u_nick[128]; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
996 |
1011 | 997 struct irc_channel *channel; |
998 int j; | |
999 | |
1012 | 1000 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
1001 u_nick[j] = buf[i]; | |
1002 } | |
1003 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1004 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1005 i++; |
1012 | 1006 |
1007 for (j = 0; buf[i] != '#'; j++, i++) { | |
1011 | 1008 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1009 |
1011 | 1010 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1011 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1012 strcpy(u_channel, buf + i); |
1011 | 1013 |
1301 | 1014 g_strchomp(u_channel); |
1015 | |
1014 | 1016 /* Looks like we're going to join the channel for real |
1017 * now. Let's create a valid channel structure and add | |
1018 * it to our list. Let's make sure that | |
1011 | 1019 * we are not already in a channel first */ |
1020 | |
1021 channel = find_channel_by_name(gc, u_channel); | |
1022 | |
1023 if (!channel) { | |
1301 | 1024 |
1011 | 1025 chat_id++; |
1026 | |
1027 channel = g_new0(struct irc_channel, 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1028 |
1011 | 1029 channel->id = chat_id; |
1030 channel->name = strdup(u_channel); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1031 |
1011 | 1032 idata->channels = g_list_append(idata->channels, channel); |
1033 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1034 serv_got_joined_chat(gc, chat_id, u_channel); |
1011 | 1035 } else { |
1014 | 1036 struct conversation *convo = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1037 |
1014 | 1038 /* Someone else joined. Find their conversation |
1039 * window */ | |
1040 convo = find_conversation_by_id(gc, channel->id); | |
1041 | |
1042 /* And add their name to it */ | |
1043 add_chat_buddy(convo, u_nick); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1044 |
1011 | 1045 } |
1046 | |
1047 return; | |
1048 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1049 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1050 if ((strstr(buf, " NICK ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1051 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1052 gchar old[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1053 gchar new[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1054 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1055 GList *templist; |
1847 | 1056 gchar *temp, *temp_new; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1057 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1058 int j; |
1847 | 1059 temp = temp_new = NULL; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1060 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1061 old[j] = buf[i]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1062 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1063 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1064 old[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1065 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1066 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1067 for (j = 0; buf[i] != ':'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1068 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1069 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1070 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1071 strcpy(new, buf + i); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1072 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1073 g_strchomp(new); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1074 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1075 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1076 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1077 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1078 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1079 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1080 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1081 convo = find_conversation_by_id(gc, channel->id); |
1847 | 1082 |
1083 /* If the person is an op or voice, this won't work. | |
1084 * so we'll just do a nice hack and rename nick and | |
1085 * @nick and +nick. Truly wasteful. | |
1086 */ | |
1087 | |
1088 temp = (gchar *)g_malloc(strlen(old) + 5); | |
1089 temp_new = (gchar *)g_malloc(strlen(new) + 5); | |
1090 g_snprintf(temp_new, strlen(new) + 2, "@%s", new); | |
1091 g_snprintf(temp, strlen(old) + 2, "@%s", old); | |
1092 rename_chat_buddy(convo, temp, temp_new); | |
1093 g_snprintf(temp, strlen(old) + 2, "+%s", old); | |
1094 g_snprintf(temp_new, strlen(new) + 2, "+%s", new); | |
1095 rename_chat_buddy(convo, temp, temp_new); | |
1096 rename_chat_buddy(convo, old, new); | |
1097 if (temp) | |
1098 g_free(temp); | |
1099 if (temp_new) | |
1100 g_free(temp_new); | |
1101 | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1102 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1103 } |
1847 | 1104 return; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1105 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1106 |
1847 | 1107 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1108 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (strstr(buf, "!")) && (!strstr(buf, " NOTICE "))) { |
1847 | 1109 |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1110 gchar u_nick[128]; |
1847 | 1111 gchar *temp; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1112 GList *templist; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1113 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1114 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1115 int j; |
1847 | 1116 |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1117 |
1847 | 1118 temp = NULL; |
1119 for (j = 0, i = 1 ; buf[i] != '!'; j++, i++) { | |
1120 u_nick[j] = buf[i]; | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1121 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1122 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1123 u_nick[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1124 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1125 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1126 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1127 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1128 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1129 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1130 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1131 convo = find_conversation_by_id(gc, channel->id); |
1847 | 1132 |
1133 /* If the person is an op or voice, this won't work. | |
1134 * so we'll just do a nice hack and remove nick and | |
1135 * @nick and +nick. Truly wasteful. | |
1136 */ | |
1137 | |
1138 temp = (gchar *) g_malloc(strlen(u_nick) + 2); | |
1139 g_snprintf(temp, strlen(u_nick) + 2, "@%s", u_nick); | |
1140 remove_chat_buddy(convo, temp); | |
1848 | 1141 g_free(temp); |
1142 temp = (gchar *) g_malloc(strlen(u_nick) + 2); | |
1847 | 1143 g_snprintf(temp, strlen(u_nick) + 2, "+%s", u_nick); |
1144 remove_chat_buddy(convo, temp); | |
1145 remove_chat_buddy(convo, u_nick); | |
1146 | |
1147 | |
1148 | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1149 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1150 } |
1847 | 1151 |
1848 | 1152 g_free(temp); |
1847 | 1153 |
1154 return; | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1155 } |
1847 | 1156 |
1157 | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1158 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1159 if ((strstr(buf, " PART ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 1160 |
1847 | 1161 gchar u_channel[128]; |
1011 | 1162 gchar u_nick[128]; |
1847 | 1163 gchar *temp; |
1021 | 1164 struct irc_channel *channel; |
1011 | 1165 int j; |
1847 | 1166 temp = NULL; |
1011 | 1167 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
1168 u_nick[j] = buf[i]; | |
1169 } | |
1170 u_nick[j] = '\0'; | |
1171 | |
1172 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1173 |
1011 | 1174 for (j = 0; buf[i] != '#'; j++, i++) { |
1175 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1176 |
1011 | 1177 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1178 |
1847 | 1179 for (j = 0; buf[i] != ' '; j++, i++) { |
1180 if (buf[i] == '\0') { | |
1181 break; | |
1182 } | |
1183 u_channel[j] = buf[i]; | |
1184 } | |
1185 u_channel[j] = '\0'; | |
1186 | |
1187 /* Now, lets check to see if it was US that was leaving. | |
1014 | 1188 * If so, do the correct thing by closing up all of our |
1189 * old channel stuff. Otherwise, | |
1011 | 1190 * we should just print that someone left */ |
1191 | |
1014 | 1192 channel = find_channel_by_name(gc, u_channel); |
1193 | |
1194 if (!channel) { | |
1847 | 1195 return; |
1014 | 1196 } |
1847 | 1197 |
1011 | 1198 if (g_strcasecmp(u_nick, gc->username) == 0) { |
1848 | 1199 |
1200 /* Looks like we're going to leave the channel for | |
1201 * real now. Let's create a valid channel structure | |
1202 * and add it to our list */ | |
1203 | |
1204 serv_got_chat_left(gc, channel->id); | |
1205 | |
1206 idata->channels = g_list_remove(idata->channels, channel); | |
1207 } | |
1208 else { | |
1209 struct conversation *convo = NULL; | |
1210 | |
1211 /* Find their conversation window */ | |
1212 convo = find_conversation_by_id(gc, channel->id); | |
1213 | |
1214 if (!convo) { | |
1014 | 1215 /* Some how the window doesn't exist. |
1216 * Let's get out of here */ | |
1848 | 1217 return; |
1218 } | |
1219 | |
1220 /* And remove their name */ | |
1221 /* If the person is an op or voice, this won't work. | |
1222 * so we'll just do a nice hack and remove nick and | |
1223 * @nick and +nick. Truly wasteful. | |
1224 */ | |
1225 | |
1226 temp = (gchar *) g_malloc(strlen(u_nick) + 3); | |
1227 g_snprintf(temp, strlen(u_nick) + 2, "@%s", u_nick); | |
1228 remove_chat_buddy(convo, temp); | |
1229 g_free(temp); | |
1230 temp = (gchar *) g_malloc(strlen(u_nick) + 3); | |
1231 g_snprintf(temp, strlen(u_nick) + 2, "+%s", u_nick); | |
1232 remove_chat_buddy(convo, temp); | |
1233 g_free(temp); | |
1234 remove_chat_buddy(convo, u_nick); | |
1235 | |
1236 | |
1011 | 1237 } |
1848 | 1238 |
1014 | 1239 /* Go Home! */ |
1011 | 1240 return; |
1241 } | |
1848 | 1242 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1243 if ((strstr(buf, " NOTICE ")) && (buf[0] == ':')) { |
1178 | 1244 gchar u_nick[128]; |
1245 gchar u_host[255]; | |
1246 gchar u_command[32]; | |
1247 gchar u_channel[128]; | |
1248 gchar u_message[IRC_BUF_LEN]; | |
1249 int j; | |
1250 | |
1251 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
1252 u_nick[j] = buf[i]; | |
1253 } | |
1254 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1255 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1256 i++; |
1178 | 1257 |
1258 for (j = 0; buf[i] != ' '; j++, i++) { | |
1259 u_host[j] = buf[i]; | |
1260 } | |
1261 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1262 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1263 i++; |
1178 | 1264 |
1265 for (j = 0; buf[i] != ' '; j++, i++) { | |
1266 u_command[j] = buf[i]; | |
1267 } | |
1268 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1269 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1270 i++; |
1178 | 1271 |
1272 for (j = 0; buf[i] != ':'; j++, i++) { | |
1273 u_channel[j] = buf[i]; | |
1274 } | |
1275 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1276 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1277 i++; |
1178 | 1278 |
1279 | |
1280 /* Now that everything is parsed, the rest of this baby must be our message */ | |
1281 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
1282 | |
1283 /* Now, lets check the message to see if there's anything special in it */ | |
1284 if (u_message[0] == '\001') { | |
1285 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
1286 /* Someone's triyng to ping us. Let's respond */ | |
1287 gchar u_arg[24]; | |
1288 gchar u_buf[200]; | |
1393 | 1289 unsigned long tend= time((time_t *)NULL); |
1290 unsigned long tstart; | |
1291 | |
1292 printf("LA: %s\n", buf); | |
1178 | 1293 |
1294 strcpy(u_arg, u_message + 6); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1295 u_arg[strlen(u_arg) - 1] = '\0'; |
1178 | 1296 |
1393 | 1297 tstart = atol(u_arg); |
1298 | |
1299 g_snprintf(u_buf, sizeof(u_buf), "Ping Reply From %s: [%ld seconds]", u_nick, tend-tstart); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1300 |
1178 | 1301 do_error_dialog(u_buf, "Gaim IRC - Ping Reply"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1302 |
1178 | 1303 return; |
1304 } | |
1305 } | |
1306 | |
1307 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1308 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1309 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1310 if ((strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) { |
1847 | 1311 gchar u_nick[128]; |
1312 gchar u_host[255]; | |
1313 gchar u_command[32]; | |
1314 gchar u_channel[128]; | |
1315 gchar u_message[IRC_BUF_LEN]; | |
1848 | 1316 gboolean is_closing; |
1317 | |
1847 | 1318 int j; |
1319 | |
1320 | |
1321 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
1322 u_nick[j] = buf[i]; | |
1323 } | |
1324 | |
1325 u_nick[j] = '\0'; | |
1326 i++; | |
1327 | |
1328 for (j = 0; buf[i] != ' '; j++, i++) { | |
1329 u_host[j] = buf[i]; | |
1330 } | |
1331 | |
1332 u_host[j] = '\0'; | |
1333 i++; | |
1334 | |
1335 for (j = 0; buf[i] != ' '; j++, i++) { | |
1336 u_command[j] = buf[i]; | |
1337 } | |
1338 | |
1339 u_command[j] = '\0'; | |
1340 i++; | |
1341 | |
1342 for (j = 0; buf[i] != ':'; j++, i++) { | |
1343 u_channel[j] = buf[i]; | |
1344 } | |
1345 | |
1346 u_channel[j - 1] = '\0'; | |
1347 i++; | |
1348 | |
1349 | |
1350 /* Now that everything is parsed, the rest of this baby must be our message */ | |
1351 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
1352 | |
1353 /* Now, lets check the message to see if there's anything special in it */ | |
1354 if (u_message[0] == '\001') { | |
1355 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) { | |
1017 | 1356 /* Looks like we have a version request. Let |
1357 * us handle it thusly */ | |
1847 | 1358 |
1359 g_snprintf(buf, IRC_BUF_LEN, | |
1360 "NOTICE %s :%cVERSION GAIM %s:The Pimpin Penguin AIM Clone:%s%c\n", | |
1361 u_nick, '\001', VERSION, WEBSITE, '\001'); | |
1362 | |
1363 write(idata->fd, buf, strlen(buf)); | |
1364 | |
1017 | 1365 /* And get the heck out of dodge */ |
1847 | 1366 return; |
1367 } | |
1368 | |
1369 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
1017 | 1370 /* Someone's triyng to ping us. Let's respond */ |
1847 | 1371 gchar u_arg[24]; |
1372 | |
1373 strcpy(u_arg, u_message + 6); | |
1374 u_arg[strlen(u_arg) - 1] = '\0'; | |
1375 | |
1376 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cPING %s%c\n", u_nick, '\001', | |
1377 u_arg, '\001'); | |
1378 | |
1379 write(idata->fd, buf, strlen(buf)); | |
1380 | |
1017 | 1381 /* And get the heck out of dodge */ |
1847 | 1382 return; |
1383 } | |
1384 | |
1385 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) { | |
1011 | 1386 /* Looks like we have an action. Let's parse it a little */ |
1847 | 1387 strcpy(buf, u_message); |
1388 | |
1389 strcpy(u_message, "/me "); | |
1390 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) { | |
1391 u_message[j] = buf[i]; | |
1392 } | |
1393 u_message[j] = '\0'; | |
1394 } | |
1395 } | |
1011 | 1396 |
1397 | |
1847 | 1398 /* OK, It is a chat or IM message. Here, let's translate the IRC formatting into |
1399 * good ol' fashioned gtkimhtml style hypertext markup. */ | |
1400 | |
1848 | 1401 |
1402 is_closing = FALSE; | |
1403 | |
1847 | 1404 while(strchr(u_message, '\002')) { // \002 = ^B |
1405 gchar *current; | |
1406 gchar *temp, *free_here; | |
1407 | |
1408 | |
1409 temp = g_strdup(strchr(u_message, '\002')); | |
1410 free_here = temp; | |
1411 temp++; | |
1412 | |
1413 current = strchr(u_message, '\002'); | |
1414 *current = '<'; | |
1415 current++; | |
1848 | 1416 if (is_closing) { |
1417 *current = '/'; | |
1418 current++; | |
1419 } | |
1847 | 1420 *current = 'b'; |
1421 current++; | |
1422 *current = '>'; | |
1423 current++; | |
1424 | |
1425 | |
1426 while (*temp != '\0') { | |
1427 *current = *temp; | |
1428 current++; | |
1429 temp++; | |
1430 } | |
1431 *current = '\0'; | |
1432 g_free(free_here); | |
1433 | |
1848 | 1434 is_closing = !is_closing; |
1847 | 1435 } |
1848 | 1436 |
1437 is_closing = FALSE; | |
1847 | 1438 while(strchr(u_message, '\037')) { // \037 = ^_ |
1439 gchar *current; | |
1440 gchar *temp, *free_here; | |
1441 | |
1442 | |
1443 temp = g_strdup(strchr(u_message, '\037')); | |
1444 free_here = temp; | |
1445 temp++; | |
1446 | |
1447 current = strchr(u_message, '\037'); | |
1448 *current = '<'; | |
1449 current++; | |
1848 | 1450 if (is_closing) { |
1451 *current = '/'; | |
1452 current++; | |
1453 } | |
1847 | 1454 *current = 'u'; |
1455 current++; | |
1456 *current = '>'; | |
1457 current++; | |
1458 | |
1459 | |
1460 while (*temp != '\0') { | |
1461 *current = *temp; | |
1462 current++; | |
1463 temp++; | |
1464 } | |
1465 *current = '\0'; | |
1848 | 1466 g_free(free_here); |
1467 is_closing = !is_closing; | |
1468 | |
1469 } | |
1470 | |
1471 while(strchr(u_message, '\003')) { // \003 = ^C | |
1472 | |
1473 /* This is color formatting. IRC uses its own weird little system | |
1474 * that we must translate to HTML. */ | |
1475 | |
1476 | |
1477 /* The format is something like this: | |
1478 * ^C5 or ^C5,3 | |
1479 * The number before the comma is the foreground color, after is the | |
1480 * background color. Either number can be 1 or two digits. | |
1481 */ | |
1482 | |
1483 gchar *current; | |
1484 gchar *temp, *free_here; | |
1485 gchar *font_tag, *body_tag; | |
1486 int fg_color, bg_color; | |
1487 | |
1488 temp = g_strdup(strchr(u_message, '\003')); | |
1489 free_here = temp; | |
1490 temp++; | |
1491 | |
1492 fg_color = bg_color = -1; | |
1493 body_tag = font_tag = ""; | |
1494 | |
1495 /* Parsing the color information: */ | |
1496 do { | |
1497 if (!isdigit(*temp)) break; // This translates to </font> | |
1498 fg_color = (int)(*temp - 48); | |
1499 temp++; | |
1500 if (isdigit(*temp)) { | |
1501 fg_color = (fg_color * 10) + (int)(*temp - 48); | |
1502 temp++; | |
1503 } | |
1504 if (*temp != ',') break; | |
1505 temp++; | |
1506 if (!isdigit(*temp)) break; // This translates to </font> | |
1507 bg_color = (int)(*temp - 48); | |
1508 temp++; | |
1509 if (isdigit(*temp)) { | |
1510 bg_color = (bg_color * 10) + (int)(*temp - 48); | |
1511 temp++; | |
1512 } | |
1513 }while (FALSE); | |
1514 | |
1515 if (fg_color > 15) | |
1516 fg_color = fg_color % 16; | |
1517 if (bg_color > 15) | |
1518 bg_color = bg_color % 16; | |
1519 | |
1520 switch (fg_color) { | |
1521 case -1: | |
1522 font_tag = "</font></body>"; | |
1523 break; | |
1524 case 0: // WHITE | |
1525 font_tag = "<font color=\"#ffffff\">"; | |
1526 /* If no background color is specified, we're going to make it black anyway. | |
1527 * That's probably what the sender anticipated the background color to be. | |
1528 * White on white would be illegible. | |
1529 */ | |
1530 if (bg_color == -1) { | |
1531 body_tag = "<body bgcolor=\"#000000\">"; | |
1532 } | |
1533 break; | |
1534 case 1: // BLACK | |
1535 font_tag = "<font color=\"#000000\">"; | |
1536 break; | |
1537 case 2: // NAVY BLUE | |
1538 font_tag = "<font color=\"#000066\">"; | |
1539 break; | |
1540 case 3: // GREEN | |
1541 font_tag = "<font color=\"#006600\">"; | |
1542 break; | |
1543 case 4: // RED | |
1544 font_tag = "<font color=\"#ff0000\">"; | |
1545 break; | |
1546 case 5: // MAROON | |
1547 font_tag = "<font color=\"#660000\">"; | |
1548 break; | |
1549 case 6: // PURPLE | |
1550 font_tag = "<font color=\"#660066\">"; | |
1551 break; | |
1552 case 7: // DISGUSTING PUKE COLOR | |
1553 font_tag = "<font color=\"#666600\">"; | |
1554 break; | |
1555 case 8: // YELLOW | |
1556 font_tag = "<font color=\"#cccc00\">"; | |
1557 break; | |
1558 case 9: // LIGHT GREEN | |
1559 font_tag = "<font color=\"#33cc33\">"; | |
1560 break; | |
1561 case 10: // TEAL | |
1562 font_tag = "<font color=\"#00acac\">"; | |
1563 break; | |
1564 case 11: // CYAN | |
1565 font_tag = "<font color=\"#00ccac\">"; | |
1566 break; | |
1567 case 12: // BLUE | |
1568 font_tag = "<font color=\"#0000ff\">"; | |
1569 break; | |
1570 case 13: // PINK | |
1571 font_tag = "<font color=\"#cc00cc\">"; | |
1572 break; | |
1573 case 14: // GREY | |
1574 font_tag = "<font color=\"#666666\">"; | |
1575 break; | |
1576 case 15: // SILVER | |
1577 font_tag = "<font color=\"#00ccac\">"; | |
1578 break; | |
1579 } | |
1580 | |
1581 switch (bg_color) { | |
1582 case 0: // WHITE | |
1583 body_tag = "<body bgcolor=\"#ffffff\">"; | |
1584 break; | |
1585 case 1: // BLACK | |
1586 body_tag = "<body bgcolor=\"#000000\">"; | |
1587 break; | |
1588 case 2: // NAVY BLUE | |
1589 body_tag = "<body bgcolor=\"#000066\">"; | |
1590 break; | |
1591 case 3: // GREEN | |
1592 body_tag = "<body bgcolor=\"#006600\">"; | |
1593 break; | |
1594 case 4: // RED | |
1595 body_tag = "<body bgcolor=\"#ff0000\">"; | |
1596 break; | |
1597 case 5: // MAROON | |
1598 body_tag = "<body bgcolor=\"#660000\">"; | |
1599 break; | |
1600 case 6: // PURPLE | |
1601 body_tag = "<body bgcolor=\"#660066\">"; | |
1602 break; | |
1603 case 7: // DISGUSTING PUKE COLOR | |
1604 body_tag = "<body bgcolor=\"#666600\">"; | |
1605 break; | |
1606 case 8: // YELLOW | |
1607 body_tag = "<body bgcolor=\"#cccc00\">"; | |
1608 break; | |
1609 case 9: // LIGHT GREEN | |
1610 body_tag = "<body bgcolor=\"#33cc33\">"; | |
1611 break; | |
1612 case 10: // TEAL | |
1613 body_tag = "<body bgcolor=\"#00acac\">"; | |
1614 break; | |
1615 case 11: // CYAN | |
1616 body_tag = "<body bgcolor=\"#00ccac\">"; | |
1617 break; | |
1618 case 12: // BLUE | |
1619 body_tag = "<body bgcolor=\"#0000ff\">"; | |
1620 break; | |
1621 case 13: // PINK | |
1622 body_tag = "<body bgcolor=\"#cc00cc\">"; | |
1623 break; | |
1624 case 14: // GREY | |
1625 body_tag = "<body bgcolor=\"#666666\">"; | |
1626 break; | |
1627 case 15: // SILVER | |
1628 body_tag = "<body bgcolor=\"#00ccac\">"; | |
1629 break; | |
1630 } | |
1631 | |
1632 current = strchr(u_message, '\003'); | |
1633 | |
1634 while (*body_tag != '\0') { | |
1635 *current = *body_tag; | |
1636 current++; | |
1637 body_tag++; | |
1638 } | |
1639 | |
1640 while (*font_tag != '\0') { | |
1641 *current = *font_tag; | |
1642 current++; | |
1643 font_tag++; | |
1644 } | |
1645 | |
1646 while (*temp != '\0') { | |
1647 *current = *temp; | |
1648 current++; | |
1649 temp++; | |
1650 } | |
1651 *current = '\0'; | |
1652 g_free(free_here); | |
1653 is_closing = !is_closing; | |
1654 | |
1847 | 1655 } |
1011 | 1656 |
1847 | 1657 while(strchr(u_message, '\017')) { // \017 = ^O |
1658 gchar *current; | |
1659 gchar *temp, *free_here; | |
1660 | |
1661 | |
1662 temp = g_strdup(strchr(u_message, '\017')); | |
1663 free_here = temp; | |
1664 temp++; | |
1665 | |
1666 current = strchr(u_message, '\017'); | |
1667 *current = '<'; | |
1668 current++; | |
1669 *current = '/'; | |
1670 current++; | |
1671 *current = 'b'; | |
1672 current++; | |
1673 *current = '>'; | |
1674 current++; | |
1675 *current = '<'; | |
1676 current++; | |
1677 *current = '/'; | |
1678 current++; | |
1679 *current = 'u'; | |
1680 current++; | |
1681 *current = '>'; | |
1682 current++; | |
1683 | |
1684 while (*temp != '\0') { | |
1685 *current = *temp; | |
1686 current++; | |
1687 temp++; | |
1688 } | |
1689 *current = '\0'; | |
1690 g_free(free_here); | |
1691 } | |
1692 | |
1693 /* Let's check to see if we have a channel on our hands */ | |
1694 if (u_channel[0] == '#') { | |
1695 /* Yup. We have a channel */ | |
1696 int id; | |
1697 | |
1698 id = find_id_by_name(gc, u_channel); | |
1699 if (id != -1) { | |
1700 serv_got_chat_in(gc, id, u_nick, 0, u_message, time((time_t)NULL)); | |
1701 | |
1702 } | |
1703 | |
1704 } else { | |
1705 /* Nope. Let's treat it as a private message */ | |
1706 | |
1707 gchar *temp; | |
1708 temp = NULL; | |
1709 | |
1710 temp = (gchar *) g_malloc(strlen(u_nick) + 5); | |
1711 g_snprintf(temp, strlen(u_nick) + 2, "@%s", u_nick); | |
1712 | |
1713 | |
1714 /* If I get a message from SeanEgn, and I already have a window | |
1715 * open for him as @SeanEgn or +SeanEgn, this will keep it in the | |
1716 * same window. Unfortunately, if SeanEgn loses his op status | |
1717 * (a sad thing indeed), the messages will still appear to come from | |
1718 * @SeanEgn, until that convo is closed. | |
1719 */ | |
1720 | |
1721 if (find_conversation(temp)){ | |
1722 serv_got_im(gc, temp, u_message, 0, time((time_t)NULL)); | |
1848 | 1723 g_free(temp); |
1724 return; | |
1847 | 1725 } |
1726 else { | |
1727 g_snprintf(temp, strlen(u_nick) + 2, "+%s", u_nick); | |
1728 if (find_conversation(temp)) { | |
1729 serv_got_im(gc, temp, u_message, 0, time((time_t)NULL)); | |
1848 | 1730 g_free(temp); |
1731 return; | |
1847 | 1732 } |
1733 else { | |
1734 g_free(temp); | |
1735 serv_got_im(gc, u_nick, u_message, 0, time((time_t)NULL)); | |
1848 | 1736 return; |
1847 | 1737 } |
1738 } | |
1739 } | |
1740 | |
1741 return; | |
1011 | 1742 } |
1847 | 1743 |
1011 | 1744 /* Let's parse PING requests so that we wont get booted for inactivity */ |
1745 | |
1746 if (strncmp(buf, "PING :", 6) == 0) { | |
1747 buf2 = g_strsplit(buf, ":", 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1748 |
1011 | 1749 /* Let's build a new response */ |
1750 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]); | |
1751 write(idata->fd, buf, strlen(buf)); | |
1752 | |
1753 /* And clean up after ourselves */ | |
1754 g_strfreev(buf2); | |
1755 | |
1756 return; | |
1757 } | |
1758 | |
1759 } | |
1760 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1761 static void irc_close(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1762 { |
1011 | 1763 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 1764 GList *chats = idata->channels; |
1765 struct irc_channel *cc; | |
1766 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1767 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN); |
1011 | 1768 |
1847 | 1769 g_snprintf(buf, IRC_BUF_LEN, "QUIT :Download GAIM [%s]\n", WEBSITE); |
1011 | 1770 write(idata->fd, buf, strlen(buf)); |
1771 | |
1772 g_free(buf); | |
1021 | 1773 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1774 if (idata->timer) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1775 gtk_timeout_remove(idata->timer); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1776 |
1021 | 1777 while (chats) { |
1778 cc = (struct irc_channel *)chats->data; | |
1779 g_free(cc->name); | |
1780 chats = g_list_remove(chats, cc); | |
1781 g_free(cc); | |
1782 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1783 |
1021 | 1784 if (gc->inpa) |
1785 gdk_input_remove(gc->inpa); | |
1786 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1787 if (idata->inpa) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1788 gdk_input_remove(idata->inpa); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1789 |
1011 | 1790 close(idata->fd); |
1791 g_free(gc->proto_data); | |
1792 } | |
1793 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1794 static void irc_chat_leave(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1795 { |
1011 | 1796 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1797 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1798 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1799 |
1011 | 1800 channel = find_channel_by_id(gc, id); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1801 |
1011 | 1802 if (!channel) { |
1803 return; | |
1804 } | |
1805 | |
1806 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name); | |
1807 write(idata->fd, buf, strlen(buf)); | |
1808 | |
1809 g_free(buf); | |
1810 } | |
1811 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1812 static void irc_login_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1813 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1814 struct gaim_connection *gc = data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1815 struct irc_data *idata = gc->proto_data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1816 char buf[4096]; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1817 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1818 if (source == -1) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1819 hide_login_progress(gc, "Write error"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1820 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1821 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1822 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1823 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1824 if (idata->fd == 0) |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1825 idata->fd = source; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1826 |
1847 | 1827 g_snprintf(buf, 4096, "NICK %s\n USER %s localhost %s :GAIM (%s)\n", |
1828 gc->username, g_get_user_name(), gc->user->proto_opt[USEROPT_SERV], WEBSITE); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1829 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1830 if (write(idata->fd, buf, strlen(buf)) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1831 hide_login_progress(gc, "Write error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1832 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1833 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1834 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1835 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1836 idata->inpa = gdk_input_add(idata->fd, GDK_INPUT_READ, irc_callback, gc); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1837 idata->inpa = 0; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1838 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1839 /* Now lets sign ourselves on */ |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1840 account_online(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1841 serv_finish_login(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1842 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1843 if (bud_list_cache_exists(gc)) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1844 do_import(NULL, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1845 |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
1846 /* we don't call this now because otherwise some IRC servers might not like us */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1847 idata->timer = gtk_timeout_add(20000, (GtkFunction)irc_request_buddy_update, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1848 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1849 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1850 static void irc_login(struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1851 { |
1011 | 1852 char buf[4096]; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1853 |
1089
f0f5c10cce63
[gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1075
diff
changeset
|
1854 struct gaim_connection *gc = new_gaim_conn(user); |
1011 | 1855 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
1856 | |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1857 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1858 set_login_progress(gc, 2, buf); |
1011 | 1859 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1860 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1861 user->proto_opt[USEROPT_PORT][0] ? atoi(user->proto_opt[USEROPT_PORT]) : 6667, |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1862 user->proto_opt[USEROPT_PROXYSERV], atoi(user->proto_opt[USEROPT_PROXYPORT]), |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1863 atoi(user->proto_opt[USEROPT_PROXYTYPE]), |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1864 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1865 irc_login_callback, gc); |
1866
466fc4ada7cb
[gaim-migrate @ 1876]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1866 if (!user->gc || (idata->fd < 0)) { |
1011 | 1867 hide_login_progress(gc, "Unable to create socket"); |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
1868 signoff(gc); |
1011 | 1869 return; |
1870 } | |
1871 } | |
1008 | 1872 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1873 static void irc_print_option(GtkEntry *entry, struct aim_user *user) |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1874 { |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1875 int entrynum; |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1876 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1877 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1878 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1879 if (entrynum == USEROPT_SERV) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1880 g_snprintf(user->proto_opt[USEROPT_SERV], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1881 sizeof(user->proto_opt[USEROPT_SERV]), "%s", gtk_entry_get_text(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1882 } else if (entrynum == USEROPT_PORT) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1883 g_snprintf(user->proto_opt[USEROPT_PORT], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1884 sizeof(user->proto_opt[USEROPT_PORT]), "%s", gtk_entry_get_text(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1885 } else if (entrynum == USEROPT_PROXYSERV) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1886 g_snprintf(user->proto_opt[USEROPT_PROXYSERV], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1887 sizeof(user->proto_opt[USEROPT_PROXYSERV]), "%s", gtk_entry_get_text(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1888 } else if (entrynum == USEROPT_PROXYPORT) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1889 g_snprintf(user->proto_opt[USEROPT_PROXYPORT], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1890 sizeof(user->proto_opt[USEROPT_PROXYPORT]), "%s", gtk_entry_get_text(entry)); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1891 } else if (entrynum == USEROPT_USER) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1892 g_snprintf(user->proto_opt[USEROPT_USER], |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1893 sizeof(user->proto_opt[USEROPT_USER]), "%s", gtk_entry_get_text(entry)); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1894 } else if (entrynum == USEROPT_PASS) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1895 g_snprintf(user->proto_opt[USEROPT_PASS], |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1896 sizeof(user->proto_opt[USEROPT_PASS]), "%s", gtk_entry_get_text(entry)); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1897 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1898 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1899 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1900 static void irc_print_optionrad(GtkRadioButton * entry, struct aim_user *user) |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1901 { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1902 int entrynum; |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1903 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1904 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1905 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1906 g_snprintf(user->proto_opt[USEROPT_PROXYTYPE], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1907 sizeof(user->proto_opt[USEROPT_PROXYTYPE]), "%d", entrynum); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1908 } |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1909 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1910 static void irc_user_opts(GtkWidget * book, struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1911 { |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1912 /* so here, we create the new notebook page */ |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1913 GtkWidget *vbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1914 GtkWidget *hbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1915 GtkWidget *label; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1916 GtkWidget *entry; |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1917 GtkWidget *first, *opt; |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1918 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1919 vbox = gtk_vbox_new(FALSE, 5); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1920 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1921 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("IRC Options")); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1922 gtk_widget_show(vbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1923 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1924 hbox = gtk_hbox_new(FALSE, 5); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1925 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1926 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1927 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1928 label = gtk_label_new("Server:"); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1929 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1930 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1931 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1932 entry = gtk_entry_new(); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1933 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1934 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_SERV); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1935 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1936 if (user->proto_opt[USEROPT_SERV][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1937 debug_printf("setting text %s\n", user->proto_opt[USEROPT_SERV]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1938 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_SERV]); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1939 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1940 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1941 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1942 hbox = gtk_hbox_new(FALSE, 0); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1943 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1944 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1945 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1946 label = gtk_label_new("Port:"); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1947 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1948 gtk_widget_show(label); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1949 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1950 entry = gtk_entry_new(); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1951 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1952 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PORT); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1953 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1954 if (user->proto_opt[USEROPT_PORT][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1955 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PORT]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1956 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PORT]); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1957 } else |
1875 | 1958 gtk_entry_set_text(GTK_ENTRY(entry), "6667"); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1959 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1960 gtk_widget_show(entry); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1961 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1962 hbox = gtk_hbox_new(TRUE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1963 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1964 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1965 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1966 first = gtk_radio_button_new_with_label(NULL, "No proxy"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1967 gtk_box_pack_start(GTK_BOX(hbox), first, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1968 gtk_object_set_user_data(GTK_OBJECT(first), (void *)PROXY_NONE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1969 gtk_signal_connect(GTK_OBJECT(first), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1970 gtk_widget_show(first); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1971 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_NONE) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1972 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(first), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1973 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1974 opt = |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1975 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 4"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1976 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1977 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS4); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1978 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1979 gtk_widget_show(opt); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1980 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS4) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1981 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1982 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1983 hbox = gtk_hbox_new(TRUE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1984 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1985 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1986 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1987 opt = |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1988 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 5"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1989 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1990 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS5); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1991 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1992 gtk_widget_show(opt); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1993 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS5) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1994 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1995 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1996 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "HTTP"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1997 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1998 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_HTTP); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1999 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2000 gtk_widget_show(opt); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2001 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_HTTP) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2002 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2003 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2004 hbox = gtk_hbox_new(FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2005 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2006 gtk_widget_show(hbox); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2007 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2008 label = gtk_label_new("Proxy Host:"); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2009 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2010 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2011 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2012 entry = gtk_entry_new(); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2013 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2014 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYSERV); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2015 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2016 if (user->proto_opt[USEROPT_PROXYSERV][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2017 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYSERV]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2018 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYSERV]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2019 } |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2020 gtk_widget_show(entry); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2021 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2022 hbox = gtk_hbox_new(FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2023 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2024 gtk_widget_show(hbox); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2025 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2026 label = gtk_label_new("Proxy Port:"); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2027 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2028 gtk_widget_show(label); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2029 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2030 entry = gtk_entry_new(); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2031 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2032 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYPORT); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2033 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2034 if (user->proto_opt[USEROPT_PROXYPORT][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2035 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYPORT]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2036 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYPORT]); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2037 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2038 gtk_widget_show(entry); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2039 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2040 hbox = gtk_hbox_new(FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2041 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2042 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2043 |
1844
9845deede1e9
[gaim-migrate @ 1854]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1843
diff
changeset
|
2044 label = gtk_label_new("Proxy User:"); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2045 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2046 gtk_widget_show(label); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2047 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2048 entry = gtk_entry_new(); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2049 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2050 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_USER); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2051 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2052 if (user->proto_opt[USEROPT_USER][0]) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2053 debug_printf("setting text %s\n", user->proto_opt[USEROPT_USER]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2054 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_USER]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2055 } |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2056 gtk_widget_show(entry); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2057 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2058 hbox = gtk_hbox_new(FALSE, 5); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2059 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2060 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2061 |
1844
9845deede1e9
[gaim-migrate @ 1854]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1843
diff
changeset
|
2062 label = gtk_label_new("Proxy Password:"); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2063 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2064 gtk_widget_show(label); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2065 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2066 entry = gtk_entry_new(); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2067 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2068 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2069 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PASS); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2070 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2071 if (user->proto_opt[USEROPT_PASS][0]) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2072 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PASS]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2073 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PASS]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2074 } |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2075 gtk_widget_show(entry); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2076 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2077 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2078 static char **irc_list_icon(int uc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2079 { |
1178 | 2080 return free_icon_xpm; |
2081 } | |
2082 | |
2083 /* Send out a ping request to the specified user */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2084 static void irc_send_ping(GtkObject * w, char *who) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2085 { |
1178 | 2086 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); |
2087 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
2088 char buf[BUF_LEN]; | |
2089 | |
1393 | 2090 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001'); |
1178 | 2091 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2092 write(idata->fd, buf, strlen(buf)); |
1178 | 2093 } |
2094 | |
1673 | 2095 /* Do a whois check on someone :-) */ |
2096 static void irc_get_info(struct gaim_connection *gc, char *who) | |
2097 { | |
2098 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
2099 char buf[BUF_LEN]; | |
2100 | |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
2101 if (((who[0] == '@') || (who[0] == '+')) && (strlen(who)>1)) |
1673 | 2102 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1); |
2103 else | |
2104 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who); | |
2105 write(idata->fd, buf, strlen(buf)); | |
2106 } | |
2107 | |
2108 static void irc_send_whois(GtkObject * w, char *who) | |
2109 { | |
2110 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); | |
2111 irc_get_info(gc, who); | |
2112 } | |
1178 | 2113 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2114 static void irc_buddy_menu(GtkWidget * menu, struct gaim_connection *gc, char *who) |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2115 { |
1178 | 2116 GtkWidget *button; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2117 |
1178 | 2118 button = gtk_menu_item_new_with_label("Ping"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2119 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_ping), who); |
1178 | 2120 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
2121 gtk_menu_append(GTK_MENU(menu), button); | |
2122 gtk_widget_show(button); | |
1673 | 2123 |
2124 button = gtk_menu_item_new_with_label("Whois"); | |
2125 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_whois), who); | |
2126 gtk_object_set_user_data(GTK_OBJECT(button), gc); | |
2127 gtk_menu_append(GTK_MENU(menu), button); | |
2128 gtk_widget_show(button); | |
1178 | 2129 } |
2130 | |
2131 | |
1676 | 2132 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg) |
2133 { | |
2134 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
2135 char buf[BUF_LEN]; | |
2136 | |
2137 if (msg) | |
2138 g_snprintf(buf, BUF_LEN, "AWAY :%s\n", msg); | |
2139 else | |
2140 g_snprintf(buf, BUF_LEN, "AWAY\n"); | |
2141 | |
2142 write(idata->fd, buf, strlen(buf)); | |
2143 } | |
2144 | |
1678 | 2145 static void irc_fake_buddy(struct gaim_connection *gc, char *who) |
2146 { | |
2147 /* Heh, there is no buddy list. We fake it. | |
2148 * I just need this here so the add and remove buttons will | |
2149 * show up */ | |
2150 } | |
2151 | |
2152 | |
2153 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2154 static struct prpl *my_protocol = NULL; |
987 | 2155 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2156 static void irc_init(struct prpl *ret) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2157 { |
1008 | 2158 ret->protocol = PROTO_IRC; |
2159 ret->name = irc_name; | |
1178 | 2160 ret->list_icon = irc_list_icon; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2161 ret->buddy_menu = irc_buddy_menu; |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2162 ret->user_opts = irc_user_opts; |
1008 | 2163 ret->login = irc_login; |
1011 | 2164 ret->close = irc_close; |
2165 ret->send_im = irc_send_im; | |
2166 ret->join_chat = irc_join_chat; | |
2167 ret->chat_leave = irc_chat_leave; | |
2168 ret->chat_send = irc_chat_send; | |
1673 | 2169 ret->get_info = irc_get_info; |
1676 | 2170 ret->set_away = irc_set_away; |
1678 | 2171 ret->add_buddy = irc_fake_buddy; |
2172 ret->remove_buddy = irc_fake_buddy; | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2173 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2174 my_protocol = ret; |
987 | 2175 } |
2176 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2177 char *gaim_plugin_init(GModule * handle) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2178 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1394
diff
changeset
|
2179 load_protocol(irc_init, sizeof(struct prpl)); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2180 return NULL; |
987 | 2181 } |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2182 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2183 void gaim_plugin_remove() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2184 { |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2185 struct prpl *p = find_prpl(PROTO_IRC); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2186 if (p == my_protocol) |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2187 unload_protocol(p); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2188 } |