Mercurial > pidgin
annotate plugins/irc.c @ 1831:1b61db419774
[gaim-migrate @ 1841]
hi rob! (just a few cleanups, irc passes -Wall :) )
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 09 May 2001 21:14:13 +0000 |
parents | 1e0613d9526b |
children | 1d137dde946f |
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> | |
39 #include "multi.h" | |
40 #include "prpl.h" | |
41 #include "gaim.h" | |
42 | |
1178 | 43 #include "pixmaps/free_icon.xpm" |
44 | |
1011 | 45 #define IRC_BUF_LEN 4096 |
46 | |
1022 | 47 |
1011 | 48 static int chat_id = 0; |
49 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
50 struct irc_channel { |
1011 | 51 int id; |
52 gchar *name; | |
53 }; | |
54 | |
55 struct irc_data { | |
56 int fd; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
57 int inpa; /* used for non-block logins */ |
1011 | 58 |
1022 | 59 int timer; |
60 | |
61 int totalblocks; | |
62 int recblocks; | |
63 | |
64 GSList *templist; | |
1011 | 65 GList *channels; |
66 }; | |
67 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
68 static char *irc_name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
69 { |
1008 | 70 return "IRC"; |
71 } | |
72 | |
1675 | 73 static void irc_get_info(struct gaim_connection *gc, char *who); |
74 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
75 char *name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
76 { |
1008 | 77 return "IRC"; |
78 } | |
79 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
80 char *description() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
81 { |
1008 | 82 return "Allows gaim to use the IRC protocol"; |
83 } | |
84 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
85 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
|
86 { |
1011 | 87 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
88 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 89 |
90 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name); | |
91 write(idata->fd, buf, strlen(buf)); | |
1742 | 92 write(idata->fd, buf, strlen(buf)); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
93 |
1011 | 94 g_free(buf); |
95 } | |
96 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
97 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
|
98 { |
1022 | 99 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
100 struct irc_channel *u; | |
101 GSList *temp = idata->templist; | |
102 | |
103 /* Loop through our list */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
104 |
1022 | 105 while (temp) { |
106 u = (struct irc_channel *)temp->data; | |
107 if (g_strcasecmp(u->name, name) == 0) { | |
108 u->id = status; | |
109 return; | |
110 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
111 |
1022 | 112 temp = g_slist_next(temp); |
113 } | |
114 return; | |
115 } | |
116 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
117 static void irc_request_buddy_update(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
118 { |
1022 | 119 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1046
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
120 GSList *grp = gc->groups; |
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
121 GSList *person; |
1022 | 122 struct group *g; |
123 struct buddy *b; | |
124 struct irc_channel *u; | |
125 | |
126 if (idata->templist != NULL) | |
127 return; | |
128 | |
129 idata->recblocks = 0; | |
130 idata->totalblocks = 1; | |
131 | |
1105 | 132 /* First, let's check to see if we have anyone on our buddylist */ |
133 if (!grp) { | |
134 return; | |
135 } | |
136 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
137 /* Send the first part of our request */ |
1022 | 138 write(idata->fd, "ISON", 4); |
139 | |
140 /* Step through our list of groups */ | |
141 while (grp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
142 |
1022 | 143 g = (struct group *)grp->data; |
144 person = g->members; | |
145 | |
146 while (person) { | |
147 b = (struct buddy *)person->data; | |
148 | |
149 /* We will store our buddy info here. I know, this is cheap | |
150 * but hey, its the exact same data structure. Why should we | |
151 * bother with making another one */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
152 |
1022 | 153 u = g_new0(struct irc_channel, 1); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
154 u->id = 0; /* Assume by default that they're offline */ |
1022 | 155 u->name = strdup(b->name); |
156 | |
157 write(idata->fd, " ", 1); | |
158 write(idata->fd, u->name, strlen(u->name)); | |
159 idata->templist = g_slist_append(idata->templist, u); | |
160 | |
161 person = person->next; | |
162 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
163 |
1022 | 164 grp = g_slist_next(grp); |
165 } | |
166 write(idata->fd, "\n", 1); | |
167 } | |
168 | |
169 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
170 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
|
171 { |
1011 | 172 |
1742 | 173 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
174 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 175 |
176 /* Before we actually send this, we should check to see if they're trying | |
1674 | 177 * To issue a command and handle it properly. */ |
1011 | 178 |
1674 | 179 if (message[0] == '/') |
180 { | |
181 /* I'll change the implementation of this a little later :-) */ | |
182 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
183 /* We have /me!! We have /me!! :-) */ | |
1011 | 184 |
1674 | 185 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
186 strcpy(temp, message + 4); | |
187 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%cACTION %s%c\n", who, '\001', temp, '\001'); | |
188 g_free(temp); | |
189 } | |
1675 | 190 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { |
191 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
192 strcpy(temp, message + 7); | |
193 irc_get_info(gc, temp); | |
194 g_free(temp); | |
195 | |
196 return; | |
197 } | |
198 | |
1674 | 199 } |
200 else { | |
1011 | 201 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%s\n", who, message); |
202 } | |
203 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
204 write(idata->fd, buf, strlen(buf)); |
1011 | 205 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
206 g_free(buf); |
1011 | 207 } |
208 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
209 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
|
210 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
211 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 212 GList *templist; |
213 struct irc_channel *channel; | |
214 | |
215 templist = ((struct irc_data *)gc->proto_data)->channels; | |
216 | |
217 while (templist) { | |
218 channel = (struct irc_channel *)templist->data; | |
219 | |
220 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name); | |
221 | |
222 if (g_strcasecmp(temp, name) == 0) { | |
223 g_free(temp); | |
224 return channel->id; | |
225 } | |
226 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
227 templist = templist->next; |
1011 | 228 } |
229 | |
230 g_free(temp); | |
231 | |
232 /* Return -1 if we have no ID */ | |
233 return -1; | |
234 } | |
235 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
236 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
|
237 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
238 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 239 GList *templist; |
240 struct irc_channel *channel; | |
241 | |
242 templist = ((struct irc_data *)gc->proto_data)->channels; | |
243 | |
244 while (templist) { | |
245 channel = (struct irc_channel *)templist->data; | |
246 | |
247 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name); | |
248 | |
249 if (g_strcasecmp(temp, name) == 0) { | |
250 g_free(temp); | |
251 return channel; | |
252 } | |
253 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
254 templist = templist->next; |
1011 | 255 } |
256 | |
257 g_free(temp); | |
258 | |
259 /* If we found nothing, return nothing :-) */ | |
260 return NULL; | |
261 } | |
262 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
263 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
|
264 { |
1011 | 265 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
266 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
267 |
1011 | 268 GList *temp; |
269 | |
270 temp = idata->channels; | |
271 | |
272 while (temp) { | |
273 channel = (struct irc_channel *)temp->data; | |
274 | |
275 if (channel->id == id) { | |
276 /* We've found our man */ | |
277 return channel; | |
278 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
279 |
1011 | 280 temp = temp->next; |
281 } | |
282 | |
283 | |
284 /* If we didnt find one, return NULL */ | |
285 return NULL; | |
286 } | |
287 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
288 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
|
289 { |
1011 | 290 |
1742 | 291 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 292 struct irc_channel *channel = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
293 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1742 | 294 char **kick; |
295 gboolean is_command = FALSE; | |
1011 | 296 /* First lets get our current channel */ |
297 channel = find_channel_by_id(gc, id); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
298 |
1011 | 299 |
300 if (!channel) { | |
301 /* If for some reason we've lost our channel, let's bolt */ | |
1021 | 302 g_free(buf); |
1011 | 303 return; |
304 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
305 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
306 |
1011 | 307 /* Before we actually send this, we should check to see if they're trying |
1675 | 308 * To issue a command and handle it properly. */ |
1011 | 309 |
1675 | 310 if (message[0] == '/') |
1742 | 311 { |
312 | |
313 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
314 /* We have /me!! We have /me!! :-) */ | |
315 | |
316 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
317 strcpy(temp, message + 4); | |
318 | |
319 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%cACTION %s%c\n", channel->name, '\001', temp, | |
320 '\001'); | |
321 g_free(temp); | |
322 } | |
323 else if ((g_strncasecmp(message, "/op ", 4) == 0) && (strlen(message) > 4)) { | |
324 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
325 strcpy(temp, message + 4); | |
326 | |
327 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s +o %s\n", channel->name, temp); | |
328 | |
329 g_free(temp); | |
330 is_command = TRUE; | |
331 | |
332 } | |
333 else if ((g_strncasecmp(message, "/deop ", 6) == 0) && (strlen(message) > 6)) { | |
334 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
335 strcpy(temp, message + 6); | |
336 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s -o %s\n", channel->name, temp); | |
337 | |
338 g_free(temp); | |
339 is_command = TRUE; | |
1675 | 340 } |
1742 | 341 |
342 else if ((g_strncasecmp(message, "/voice ", 7) == 0) && (strlen(message) > 7)) { | |
343 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
344 strcpy(temp, message + 7); | |
345 | |
346 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s +v %s\n", channel->name, temp); | |
347 | |
348 g_free(temp); | |
349 is_command = TRUE; | |
350 | |
351 } | |
352 else if ((g_strncasecmp(message, "/devoice ", 9) == 0) && (strlen(message) > 9)) { | |
353 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
354 strcpy(temp, message + 6); | |
355 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s -v %s\n", channel->name, temp); | |
356 | |
357 g_free(temp); | |
358 is_command = TRUE; | |
359 } | |
360 else if ((g_strncasecmp(message, "/mode ", 6) == 0) && (strlen(message) > 6)) { | |
361 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
362 strcpy(temp, message + 6); | |
363 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s %s\n", channel->name, temp); | |
364 g_free(temp); | |
365 is_command = TRUE; | |
366 } | |
367 | |
368 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { | |
369 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
370 | |
371 strcpy(temp, message + 7); | |
372 irc_get_info(gc, temp); | |
373 g_free(temp); | |
374 | |
375 | |
376 } | |
377 | |
378 else if (!g_strncasecmp(message, "/raw ", 5) && (strlen(message) > 5)){ | |
379 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
380 strcpy(temp, message + 5); | |
381 g_snprintf(buf, IRC_BUF_LEN, "%s\r\n", temp); | |
382 g_free(temp); | |
383 is_command = TRUE; | |
384 } | |
1675 | 385 |
1742 | 386 else if (!g_strncasecmp(message, "/quote ", 7) && (strlen(message) >7)) { |
387 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
388 strcpy(temp, message + 7); | |
389 g_snprintf(buf, IRC_BUF_LEN, "%s\r\n", temp); | |
390 g_free(temp); | |
391 is_command = TRUE; | |
392 } | |
393 | |
394 else if (!g_strncasecmp(message, "/kick ", 6) && (strlen(message) > 6)) { | |
395 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
396 strcpy(temp, message + 6); | |
397 kick = g_strsplit(temp, " ", 2); | |
398 g_snprintf(buf, IRC_BUF_LEN, "KICK #%s %s :%s\r\n", channel->name, kick[0], kick[1]); | |
399 g_free(temp); | |
400 is_command = TRUE; | |
401 } | |
402 | |
403 /* FIXME: I'll go back in and grab this later. -- Rob */ | |
404 /* | |
405 I THOUGHT THIS WOULD WORK, BUT I WAS WRONG. WOULD SOMEONE KINDLY FIX IT? | |
1675 | 406 |
1742 | 407 |
408 else if (!g_strncasecmp(message, "/help", 5)) { | |
409 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
410 strcpy(temp, message + 5); | |
411 if (temp == "") { | |
412 | |
413 serv_got_chat_in(gc, id, "gAIM", 0, "Available Commands:"); | |
414 serv_got_chat_in(gc, id, "gAIM", 0, " "); | |
415 serv_got_chat_in(gc, id, "gAIM", 0, "<b>op voice kick </b>"); | |
416 serv_got_chat_in(gc, id, "gAIM", 0, "<b>deop devoice whois</b>"); | |
417 serv_got_chat_in(gc, id, "gAIM", 0, "<b>me raw quote</b>"); | |
418 serv_got_chat_in(gc, id, "gAIM", 0, "<b>mode</b>"); | |
419 } | |
420 else { | |
421 serv_got_chat_in(gc, id, "gAIM", 0, "Usage: "); | |
422 if (temp == "op") | |
423 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/op <nick></b> - Gives operator status to user."); | |
424 else if (temp == "deop") | |
425 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/deop <nick></b> - Removes operator status from user."); | |
426 else if (temp == "me") | |
427 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/me <action></b> - Sends an action to the channel."); | |
428 else if (temp == "mode") | |
429 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."); | |
430 else if (temp == "voice") | |
431 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/voice <nick></b> - Gives voice status to user."); | |
432 else if (temp == "devoice") | |
433 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/devoice <nick></b> - Removes voice status from user."); | |
434 else if (temp == "raw") | |
435 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/raw <text></b> - Sends raw text to the server."); | |
436 else if (temp == "kick") | |
437 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/kick [<comment>]</b> - Kicks a user out of the channel."); | |
438 else if (temp == "whois") | |
439 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/whois <nick></b> - Gets information about user."); | |
440 else if (temp == "quote") | |
441 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/raw <text></b> - Sends raw text to the server."); | |
442 else | |
443 serv_got_chat_in(gc, id, "gAIM", 0, "No such command."); | |
444 } | |
445 | |
446 g_free(temp); | |
447 is_command = TRUE; | |
448 } | |
449 */ | |
450 | |
451 } | |
452 | |
1675 | 453 else { |
1742 | 454 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%s\n", channel->name, message); |
455 | |
456 } | |
457 | |
458 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
459 write(idata->fd, buf, strlen(buf)); |
1742 | 460 |
1011 | 461 /* Since AIM expects us to receive the message we send, we gotta fake it */ |
1742 | 462 if (is_command==FALSE) |
1764 | 463 serv_got_chat_in(gc, id, gc->username, 0, message, time((time_t)NULL)); |
1742 | 464 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
465 g_free(buf); |
1742 | 466 |
467 | |
1008 | 468 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
469 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
|
470 { |
1014 | 471 GSList *bc = gc->buddy_chats; |
472 struct conversation *b = NULL; | |
473 | |
474 while (bc) { | |
475 b = (struct conversation *)bc->data; | |
476 if (id == b->id) { | |
477 break; | |
478 } | |
479 bc = bc->next; | |
480 b = NULL; | |
481 } | |
482 | |
483 if (!b) { | |
484 return NULL; | |
485 } | |
486 | |
487 return b; | |
488 } | |
489 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
490 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
|
491 { |
1014 | 492 GSList *bc = gc->buddy_chats; |
493 struct conversation *b = NULL; | |
494 | |
495 while (bc) { | |
496 b = (struct conversation *)bc->data; | |
497 | |
498 if (g_strcasecmp(name, b->name) == 0) { | |
499 break; | |
500 } | |
501 bc = bc->next; | |
502 b = NULL; | |
503 } | |
504 | |
505 if (!b) { | |
506 return NULL; | |
507 } | |
508 | |
509 return b; | |
510 } | |
511 | |
512 | |
513 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
514 static void irc_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
515 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
516 struct gaim_connection *gc = data; |
1011 | 517 int i = 0; |
518 gchar buf[4096]; | |
519 gchar **buf2; | |
520 struct irc_data *idata; | |
1742 | 521 |
522 idata = (struct irc_data *)gc->proto_data; | |
1011 | 523 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
524 |
1011 | 525 do { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
526 if (read(idata->fd, buf + i, 1) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
527 hide_login_progress(gc, "Read error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
528 signoff(gc); |
1105 | 529 return; |
1011 | 530 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
531 } while (buf[i++] != '\n'); |
1011 | 532 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
533 buf[--i] = '\0'; |
1301 | 534 g_strchomp(buf); |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
535 g_print("%s\n", buf); |
1105 | 536 |
537 /* Check for errors */ | |
538 | |
539 if (((strstr(buf, "ERROR :") && (!strstr(buf, "PRIVMSG ")) && | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
540 (!strstr(buf, "NOTICE ")) && (strlen(buf) > 7)))) { |
1105 | 541 |
542 gchar *u_errormsg; | |
543 | |
544 /* Let's get our error message */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
545 u_errormsg = g_strdup(buf + 7); |
1105 | 546 |
547 /* We got our error message. Now, let's reaise an | |
548 * error dialog */ | |
549 | |
550 do_error_dialog(u_errormsg, "Gaim: IRC Error"); | |
551 | |
552 /* And our necessary garbage collection */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
553 g_free(u_errormsg); |
1105 | 554 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
555 |
1673 | 556 /* This should be a whois response. I only care about the first (311) one. I might do |
557 * the other's later. They're boring. */ | |
558 | |
559 if (((strstr(buf, " 311 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
560 char **res; | |
561 | |
562 res = g_strsplit(buf, " ", 7); | |
563 | |
564 if (!strcmp(res[1], "311")) | |
565 { | |
566 char buf[8192]; | |
567 | |
568 g_snprintf(buf, 4096, "<b>Nick:</b> %s<br>" | |
569 "<b>Host:</b> %s@%s<br>" | |
570 "<b>Name:</b> %s<br>", res[3], res[4], res[5], res[7]+1); | |
571 | |
572 g_show_info_text(buf); | |
573 } | |
574 | |
575 g_strfreev(res); | |
576 } | |
577 | |
1676 | 578 /* Autoresponse to an away message */ |
579 if (((strstr(buf, " 301 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
580 char **res; | |
581 | |
582 res = g_strsplit(buf, " ", 5); | |
583 | |
584 if (!strcmp(res[1], "301")) | |
1764 | 585 serv_got_im(gc, res[3], res[4] + 1, 1, time((time_t)NULL)); |
1676 | 586 |
587 g_strfreev(res); | |
588 } | |
589 | |
1014 | 590 /* Parse the list of names that we receive when we first sign on to |
591 * a channel */ | |
592 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
593 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1014 | 594 gchar u_host[255]; |
595 gchar u_command[32]; | |
596 gchar u_channel[128]; | |
597 gchar u_names[IRC_BUF_LEN + 1]; | |
598 struct conversation *convo = NULL; | |
599 int j; | |
600 | |
601 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
602 u_host[j] = buf[i]; | |
603 } | |
604 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
605 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
606 i++; |
1014 | 607 |
608 for (j = 0; buf[i] != ' '; j++, i++) { | |
609 u_command[j] = buf[i]; | |
610 } | |
611 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
612 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
613 i++; |
1014 | 614 |
615 for (j = 0; buf[i] != '#'; j++, i++) { | |
616 } | |
617 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
618 |
1014 | 619 for (j = 0; buf[i] != ':'; j++, i++) { |
620 u_channel[j] = buf[i]; | |
621 } | |
622 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
623 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
624 i++; |
1014 | 625 |
626 while ((buf[i] == ' ') || (buf[i] == ':')) { | |
627 i++; | |
628 } | |
629 | |
630 strcpy(u_names, buf + i); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
631 |
1014 | 632 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
633 |
1014 | 634 /* Let's get our conversation window */ |
635 convo = find_conversation_by_name(gc, u_channel); | |
636 | |
637 if (!convo) { | |
638 return; | |
639 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
640 |
1014 | 641 /* Now that we've parsed the hell out of this big |
642 * mess, let's try to split up the names properly */ | |
643 | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
644 for (i = 0; buf2[i] != NULL; i++) |
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
645 add_chat_buddy(convo, buf2[i]); |
1021 | 646 |
647 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
648 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
649 |
1014 | 650 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
651 |
1014 | 652 } |
653 | |
1022 | 654 /* Receive a list of users that are currently online */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
655 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
656 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1022 | 657 gchar u_host[255]; |
658 gchar u_command[32]; | |
659 gchar u_names[IRC_BUF_LEN + 1]; | |
660 int j; | |
661 | |
662 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
663 u_host[j] = buf[i]; | |
664 } | |
665 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
666 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
667 i++; |
1022 | 668 |
669 for (j = 0; buf[i] != ' '; j++, i++) { | |
670 u_command[j] = buf[i]; | |
671 } | |
672 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
673 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
674 i++; |
1022 | 675 |
676 for (j = 0; buf[i] != ':'; j++, i++) { | |
677 /* My Nick */ | |
678 } | |
679 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
680 |
1022 | 681 strcpy(u_names, buf + i); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
682 |
1022 | 683 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
684 |
1022 | 685 /* Now that we've parsed the hell out of this big |
686 * mess, let's try to split up the names properly */ | |
687 | |
688 for (i = 0; buf2[i] != NULL; i++) { | |
689 /* If we have a name here then our buddy is online. We should | |
690 * update our temporary gslist accordingly. When we achieve our maximum | |
691 * list of names then we should force an update */ | |
692 | |
693 irc_update_user(gc, buf2[i], 1); | |
694 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
695 |
1022 | 696 /* Increase our received blocks counter */ |
697 idata->recblocks++; | |
698 | |
699 /* If we have our total number of blocks */ | |
700 if (idata->recblocks == idata->totalblocks) { | |
701 GSList *temp; | |
702 struct irc_channel *u; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
703 |
1022 | 704 /* Let's grab our list of people and bring them all on or off line */ |
705 temp = idata->templist; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
706 |
1022 | 707 /* Loop */ |
708 while (temp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
709 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
710 u = temp->data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
711 |
1022 | 712 /* Tell Gaim to bring the person on or off line */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
713 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
|
714 |
1022 | 715 /* Grab the next entry */ |
716 temp = g_slist_next(temp); | |
717 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
718 |
1022 | 719 /* And now, let's delete all of our entries */ |
720 temp = idata->templist; | |
721 while (temp) { | |
722 u = temp->data; | |
723 g_free(u->name); | |
724 temp = g_slist_remove(temp, u); | |
725 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
726 |
1022 | 727 /* Reset our list */ |
728 idata->totalblocks = 0; | |
729 idata->recblocks = 0; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
730 |
1022 | 731 idata->templist = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
732 |
1022 | 733 return; |
734 } | |
735 | |
736 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
737 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
738 |
1022 | 739 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
740 |
1022 | 741 } |
742 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
743 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
744 if ((strstr(buf, " JOIN ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 745 |
746 gchar u_channel[128]; | |
1012 | 747 gchar u_nick[128]; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
748 |
1011 | 749 struct irc_channel *channel; |
750 int j; | |
751 | |
1012 | 752 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
753 u_nick[j] = buf[i]; | |
754 } | |
755 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
756 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
757 i++; |
1012 | 758 |
759 for (j = 0; buf[i] != '#'; j++, i++) { | |
1011 | 760 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
761 |
1011 | 762 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
763 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
764 strcpy(u_channel, buf + i); |
1011 | 765 |
1301 | 766 g_strchomp(u_channel); |
767 | |
1014 | 768 /* Looks like we're going to join the channel for real |
769 * now. Let's create a valid channel structure and add | |
770 * it to our list. Let's make sure that | |
1011 | 771 * we are not already in a channel first */ |
772 | |
773 channel = find_channel_by_name(gc, u_channel); | |
774 | |
775 if (!channel) { | |
1301 | 776 |
1011 | 777 chat_id++; |
778 | |
779 channel = g_new0(struct irc_channel, 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
780 |
1011 | 781 channel->id = chat_id; |
782 channel->name = strdup(u_channel); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
783 |
1011 | 784 idata->channels = g_list_append(idata->channels, channel); |
785 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
786 serv_got_joined_chat(gc, chat_id, u_channel); |
1011 | 787 } else { |
1014 | 788 struct conversation *convo = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
789 |
1014 | 790 /* Someone else joined. Find their conversation |
791 * window */ | |
792 convo = find_conversation_by_id(gc, channel->id); | |
793 | |
794 /* And add their name to it */ | |
795 add_chat_buddy(convo, u_nick); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
796 |
1011 | 797 } |
798 | |
799 return; | |
800 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
801 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
802 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
|
803 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
804 gchar old[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
805 gchar new[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
806 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
807 GList *templist; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
808 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
809 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
810 int j; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
811 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
812 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
813 old[j] = buf[i]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
814 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
815 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
816 old[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
817 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
818 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
819 for (j = 0; buf[i] != ':'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
820 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
821 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
822 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
823 strcpy(new, buf + i); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
824 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
825 g_strchomp(new); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
826 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
827 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
828 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
829 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
830 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
831 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
832 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
833 convo = find_conversation_by_id(gc, channel->id); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
834 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
835 rename_chat_buddy(convo, old, new); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
836 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
837 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
838 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
839 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
840 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
841 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (strstr(buf, "!")) && (!strstr(buf, " NOTICE "))) { |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
842 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
843 gchar u_nick[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
844 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
845 GList *templist; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
846 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
847 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
848 int j; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
849 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
850 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
851 u_nick[j] = buf[i]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
852 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
853 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
854 u_nick[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
855 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
856 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
857 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
858 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
859 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
860 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
861 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
862 convo = find_conversation_by_id(gc, channel->id); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
863 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
864 remove_chat_buddy(convo, u_nick); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
865 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
866 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
867 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
868 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
869 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
870 if ((strstr(buf, " PART ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 871 |
872 gchar u_channel[128]; | |
873 gchar u_nick[128]; | |
874 | |
1021 | 875 struct irc_channel *channel; |
1011 | 876 int j; |
877 | |
878 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
879 u_nick[j] = buf[i]; | |
880 } | |
881 u_nick[j] = '\0'; | |
882 | |
883 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
884 |
1011 | 885 for (j = 0; buf[i] != '#'; j++, i++) { |
886 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
887 |
1011 | 888 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
889 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
890 strcpy(u_channel, buf + i); |
1011 | 891 |
892 | |
1014 | 893 /* Now, lets check to see if it was US that was leaving. |
894 * If so, do the correct thing by closing up all of our | |
895 * old channel stuff. Otherwise, | |
1011 | 896 * we should just print that someone left */ |
897 | |
1014 | 898 channel = find_channel_by_name(gc, u_channel); |
899 | |
900 if (!channel) { | |
901 return; | |
902 } | |
903 | |
1011 | 904 if (g_strcasecmp(u_nick, gc->username) == 0) { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
905 |
1014 | 906 /* Looks like we're going to leave the channel for |
907 * real now. Let's create a valid channel structure | |
908 * and add it to our list */ | |
1011 | 909 |
910 serv_got_chat_left(gc, channel->id); | |
911 | |
912 idata->channels = g_list_remove(idata->channels, channel); | |
1014 | 913 } else { |
914 struct conversation *convo = NULL; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
915 |
1014 | 916 /* Find their conversation window */ |
917 convo = find_conversation_by_id(gc, channel->id); | |
918 | |
919 if (!convo) { | |
920 /* Some how the window doesn't exist. | |
921 * Let's get out of here */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
922 return; |
1014 | 923 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
924 |
1014 | 925 /* And remove their name */ |
926 remove_chat_buddy(convo, u_nick); | |
927 | |
1011 | 928 } |
929 | |
1014 | 930 /* Go Home! */ |
1011 | 931 return; |
932 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
933 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
934 if ((strstr(buf, " NOTICE ")) && (buf[0] == ':')) { |
1178 | 935 gchar u_nick[128]; |
936 gchar u_host[255]; | |
937 gchar u_command[32]; | |
938 gchar u_channel[128]; | |
939 gchar u_message[IRC_BUF_LEN]; | |
940 int j; | |
941 | |
942 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
943 u_nick[j] = buf[i]; | |
944 } | |
945 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
946 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
947 i++; |
1178 | 948 |
949 for (j = 0; buf[i] != ' '; j++, i++) { | |
950 u_host[j] = buf[i]; | |
951 } | |
952 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
953 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
954 i++; |
1178 | 955 |
956 for (j = 0; buf[i] != ' '; j++, i++) { | |
957 u_command[j] = buf[i]; | |
958 } | |
959 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
960 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
961 i++; |
1178 | 962 |
963 for (j = 0; buf[i] != ':'; j++, i++) { | |
964 u_channel[j] = buf[i]; | |
965 } | |
966 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
967 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
968 i++; |
1178 | 969 |
970 | |
971 /* Now that everything is parsed, the rest of this baby must be our message */ | |
972 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
973 | |
974 /* Now, lets check the message to see if there's anything special in it */ | |
975 if (u_message[0] == '\001') { | |
976 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
977 /* Someone's triyng to ping us. Let's respond */ | |
978 gchar u_arg[24]; | |
979 gchar u_buf[200]; | |
1393 | 980 unsigned long tend= time((time_t *)NULL); |
981 unsigned long tstart; | |
982 | |
983 printf("LA: %s\n", buf); | |
1178 | 984 |
985 strcpy(u_arg, u_message + 6); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
986 u_arg[strlen(u_arg) - 1] = '\0'; |
1178 | 987 |
1393 | 988 tstart = atol(u_arg); |
989 | |
990 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
|
991 |
1178 | 992 do_error_dialog(u_buf, "Gaim IRC - Ping Reply"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
993 |
1178 | 994 return; |
995 } | |
996 } | |
997 | |
998 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
999 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1000 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1001 if ((strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) { |
1011 | 1002 gchar u_nick[128]; |
1003 gchar u_host[255]; | |
1004 gchar u_command[32]; | |
1005 gchar u_channel[128]; | |
1006 gchar u_message[IRC_BUF_LEN]; | |
1007 int j; | |
1008 | |
1009 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
1010 u_nick[j] = buf[i]; | |
1011 } | |
1012 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1013 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1014 i++; |
1011 | 1015 |
1016 for (j = 0; buf[i] != ' '; j++, i++) { | |
1017 u_host[j] = buf[i]; | |
1018 } | |
1019 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1020 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1021 i++; |
1011 | 1022 |
1023 for (j = 0; buf[i] != ' '; j++, i++) { | |
1024 u_command[j] = buf[i]; | |
1025 } | |
1026 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1027 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1028 i++; |
1011 | 1029 |
1030 for (j = 0; buf[i] != ':'; j++, i++) { | |
1031 u_channel[j] = buf[i]; | |
1032 } | |
1033 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1034 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1035 i++; |
1011 | 1036 |
1037 | |
1038 /* Now that everything is parsed, the rest of this baby must be our message */ | |
1039 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1040 |
1011 | 1041 /* Now, lets check the message to see if there's anything special in it */ |
1042 if (u_message[0] == '\001') { | |
1017 | 1043 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) { |
1044 /* Looks like we have a version request. Let | |
1045 * us handle it thusly */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1046 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1047 g_snprintf(buf, IRC_BUF_LEN, |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1048 "NOTICE %s :%cVERSION GAIM %s:The Pimpin Penguin AIM Clone:www.marko.net/gaim%c\n", |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1049 u_nick, '\001', VERSION, '\001'); |
1017 | 1050 |
1051 write(idata->fd, buf, strlen(buf)); | |
1052 | |
1053 /* And get the heck out of dodge */ | |
1054 return; | |
1055 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1056 |
1017 | 1057 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { |
1058 /* Someone's triyng to ping us. Let's respond */ | |
1059 gchar u_arg[24]; | |
1060 | |
1061 strcpy(u_arg, u_message + 6); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1062 u_arg[strlen(u_arg) - 1] = '\0'; |
1017 | 1063 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1064 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cPING %s%c\n", u_nick, '\001', |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1065 u_arg, '\001'); |
1017 | 1066 |
1067 write(idata->fd, buf, strlen(buf)); | |
1068 | |
1069 /* And get the heck out of dodge */ | |
1070 return; | |
1071 } | |
1072 | |
1011 | 1073 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) { |
1074 /* Looks like we have an action. Let's parse it a little */ | |
1075 strcpy(buf, u_message); | |
1076 | |
1077 strcpy(u_message, "/me "); | |
1078 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) { | |
1079 u_message[j] = buf[i]; | |
1080 } | |
1081 u_message[j] = '\0'; | |
1082 } | |
1083 } | |
1084 | |
1085 | |
1086 /* Let's check to see if we have a channel on our hands */ | |
1087 if (u_channel[0] == '#') { | |
1088 /* Yup. We have a channel */ | |
1089 int id; | |
1090 | |
1091 id = find_id_by_name(gc, u_channel); | |
1092 if (id != -1) { | |
1764 | 1093 serv_got_chat_in(gc, id, u_nick, 0, u_message, time((time_t)NULL)); |
1011 | 1094 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1095 } else { |
1011 | 1096 /* Nope. Let's treat it as a private message */ |
1764 | 1097 serv_got_im(gc, u_nick, u_message, 0, time((time_t)NULL)); |
1011 | 1098 } |
1099 | |
1100 return; | |
1101 } | |
1102 | |
1103 /* Let's parse PING requests so that we wont get booted for inactivity */ | |
1104 | |
1105 if (strncmp(buf, "PING :", 6) == 0) { | |
1106 buf2 = g_strsplit(buf, ":", 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1107 |
1011 | 1108 /* Let's build a new response */ |
1109 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]); | |
1110 write(idata->fd, buf, strlen(buf)); | |
1111 | |
1112 /* And clean up after ourselves */ | |
1113 g_strfreev(buf2); | |
1114 | |
1115 return; | |
1116 } | |
1117 | |
1118 } | |
1119 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1120 static void irc_close(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1121 { |
1011 | 1122 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 1123 GList *chats = idata->channels; |
1124 struct irc_channel *cc; | |
1125 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1126 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN); |
1011 | 1127 |
1021 | 1128 g_snprintf(buf, IRC_BUF_LEN, "QUIT :Download GAIM [www.marko.net/gaim]\n"); |
1011 | 1129 write(idata->fd, buf, strlen(buf)); |
1130 | |
1131 g_free(buf); | |
1021 | 1132 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1133 if (idata->timer) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1134 gtk_timeout_remove(idata->timer); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1135 |
1021 | 1136 while (chats) { |
1137 cc = (struct irc_channel *)chats->data; | |
1138 g_free(cc->name); | |
1139 chats = g_list_remove(chats, cc); | |
1140 g_free(cc); | |
1141 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1142 |
1021 | 1143 if (gc->inpa) |
1144 gdk_input_remove(gc->inpa); | |
1145 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1146 if (idata->inpa) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1147 gdk_input_remove(idata->inpa); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1148 |
1011 | 1149 close(idata->fd); |
1150 g_free(gc->proto_data); | |
1151 } | |
1152 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1153 static void irc_chat_leave(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1154 { |
1011 | 1155 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1156 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1157 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1158 |
1011 | 1159 channel = find_channel_by_id(gc, id); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1160 |
1011 | 1161 if (!channel) { |
1162 return; | |
1163 } | |
1164 | |
1165 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name); | |
1166 write(idata->fd, buf, strlen(buf)); | |
1167 | |
1168 g_free(buf); | |
1169 } | |
1170 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1171 static void irc_login_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1172 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1173 struct gaim_connection *gc = data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1174 struct irc_data *idata = gc->proto_data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1175 char buf[4096]; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1176 int len, error = ETIMEDOUT; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1177 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1178 len = sizeof(error); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1179 if (getsockopt(idata->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1180 error = errno; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1181 if (error) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1182 hide_login_progress(gc, "Couldn't connect"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1183 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1184 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1185 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1186 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1187 fcntl(idata->fd, F_SETFL, 0); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1188 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1189 g_snprintf(buf, 4096, "NICK %s\n USER %s localhost %s :GAIM (www.marko.net/gaim)\n", |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1190 gc->username, g_get_user_name(), gc->user->proto_opt[0]); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1191 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1192 if (write(idata->fd, buf, strlen(buf)) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1193 hide_login_progress(gc, "Write error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1194 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1195 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1196 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1197 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1198 gdk_input_remove(idata->inpa); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1199 idata->inpa = 0; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1200 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1201 /* Now lets sign ourselves on */ |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1202 account_online(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1203 serv_finish_login(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1204 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1205 if (bud_list_cache_exists(gc)) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1206 do_import(NULL, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1207 |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
1208 /* 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
|
1209 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
|
1210 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1211 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1212 static void irc_login(struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1213 { |
1011 | 1214 int fd; |
1215 struct hostent *host; | |
1216 struct sockaddr_in site; | |
1217 char buf[4096]; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1218 |
1089
f0f5c10cce63
[gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1075
diff
changeset
|
1219 struct gaim_connection *gc = new_gaim_conn(user); |
1011 | 1220 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
1221 | |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1222 host = gethostbyname(user->proto_opt[0]); |
1011 | 1223 if (!host) { |
1224 hide_login_progress(gc, "Unable to resolve hostname"); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
1225 signoff(gc); |
1011 | 1226 return; |
1227 } | |
1228 | |
1229 site.sin_family = AF_INET; | |
1230 site.sin_addr.s_addr = *(long *)(host->h_addr); | |
1304 | 1231 |
1232 if (user->proto_opt[1][0]) | |
1233 site.sin_port = htons(atoi(user->proto_opt[1])); | |
1234 else { | |
1235 site.sin_port = htons(6667); | |
1236 g_snprintf(user->proto_opt[1], 5, "6667"); | |
1237 } | |
1011 | 1238 |
1239 fd = socket(AF_INET, SOCK_STREAM, 0); | |
1240 if (fd < 0) { | |
1241 hide_login_progress(gc, "Unable to create socket"); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
1242 signoff(gc); |
1011 | 1243 return; |
1244 } | |
1245 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1246 fcntl(fd, F_SETFL, O_NONBLOCK); |
1011 | 1247 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1248 if ((errno == EINPROGRESS) || (errno == EINTR)) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1249 idata->inpa = gdk_input_add(idata->fd, GDK_INPUT_WRITE, irc_login_callback, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1250 } else { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1251 hide_login_progress(gc, "Unable to connect."); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1252 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1253 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1254 } |
1011 | 1255 } |
1256 | |
1257 idata->fd = fd; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1258 |
1011 | 1259 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1260 set_login_progress(gc, 2, buf); | |
1261 | |
1262 /* This is where we will attempt to sign on */ | |
1263 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1264 if (!idata->inpa) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1265 irc_login_callback(gc, idata->fd, GDK_INPUT_READ); |
1022 | 1266 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1267 gc->inpa = gdk_input_add(idata->fd, GDK_INPUT_READ, irc_callback, gc); |
1011 | 1268 } |
1008 | 1269 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1270 static void irc_print_option(GtkEntry * entry, struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1271 { |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1272 if (gtk_object_get_user_data(GTK_OBJECT(entry))) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1273 g_snprintf(user->proto_opt[1], sizeof(user->proto_opt[1]), "%s", |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1274 gtk_entry_get_text(entry)); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1275 } else { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1276 g_snprintf(user->proto_opt[0], sizeof(user->proto_opt[0]), "%s", |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1277 gtk_entry_get_text(entry)); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1278 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1279 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1280 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1281 static void irc_user_opts(GtkWidget * book, struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1282 { |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1283 /* so here, we create the new notebook page */ |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1284 GtkWidget *vbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1285 GtkWidget *hbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1286 GtkWidget *label; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1287 GtkWidget *entry; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1288 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1289 vbox = gtk_vbox_new(FALSE, 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1290 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
|
1291 gtk_widget_show(vbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1292 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1293 hbox = gtk_hbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1294 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1295 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1296 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1297 label = gtk_label_new("Server:"); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1298 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1299 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1300 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1301 entry = gtk_entry_new(); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1302 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1303 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1304 if (user->proto_opt[0][0]) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1305 debug_printf("setting text %s\n", user->proto_opt[0]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1306 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1307 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1308 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1309 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1310 hbox = gtk_hbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1311 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1312 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1313 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1314 label = gtk_label_new("Port:"); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1315 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1316 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1317 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1318 entry = gtk_entry_new(); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1319 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1320 if (user->proto_opt[1][0]) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1321 debug_printf("setting text %s\n", user->proto_opt[1]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1322 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]); |
1304 | 1323 } else { |
1324 gtk_entry_set_text(GTK_ENTRY(entry), "6667"); | |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1325 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1326 gtk_object_set_user_data(GTK_OBJECT(entry), user); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1327 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1328 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1329 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1330 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1331 static char **irc_list_icon(int uc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1332 { |
1178 | 1333 return free_icon_xpm; |
1334 } | |
1335 | |
1336 /* Send out a ping request to the specified user */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1337 static void irc_send_ping(GtkObject * w, char *who) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1338 { |
1178 | 1339 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); |
1340 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1341 char buf[BUF_LEN]; | |
1342 | |
1393 | 1343 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001'); |
1178 | 1344 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1345 write(idata->fd, buf, strlen(buf)); |
1178 | 1346 } |
1347 | |
1673 | 1348 /* Do a whois check on someone :-) */ |
1349 static void irc_get_info(struct gaim_connection *gc, char *who) | |
1350 { | |
1351 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1352 char buf[BUF_LEN]; | |
1353 | |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1354 if (((who[0] == '@') || (who[0] == '+')) && (strlen(who)>1)) |
1673 | 1355 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1); |
1356 else | |
1357 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who); | |
1358 write(idata->fd, buf, strlen(buf)); | |
1359 } | |
1360 | |
1361 static void irc_send_whois(GtkObject * w, char *who) | |
1362 { | |
1363 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); | |
1364 irc_get_info(gc, who); | |
1365 } | |
1178 | 1366 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1367 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
|
1368 { |
1178 | 1369 GtkWidget *button; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1370 |
1178 | 1371 button = gtk_menu_item_new_with_label("Ping"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1372 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_ping), who); |
1178 | 1373 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
1374 gtk_menu_append(GTK_MENU(menu), button); | |
1375 gtk_widget_show(button); | |
1673 | 1376 |
1377 button = gtk_menu_item_new_with_label("Whois"); | |
1378 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_whois), who); | |
1379 gtk_object_set_user_data(GTK_OBJECT(button), gc); | |
1380 gtk_menu_append(GTK_MENU(menu), button); | |
1381 gtk_widget_show(button); | |
1178 | 1382 } |
1383 | |
1384 | |
1676 | 1385 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg) |
1386 { | |
1387 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1388 char buf[BUF_LEN]; | |
1389 | |
1390 if (msg) | |
1391 g_snprintf(buf, BUF_LEN, "AWAY :%s\n", msg); | |
1392 else | |
1393 g_snprintf(buf, BUF_LEN, "AWAY\n"); | |
1394 | |
1395 write(idata->fd, buf, strlen(buf)); | |
1396 } | |
1397 | |
1678 | 1398 static void irc_fake_buddy(struct gaim_connection *gc, char *who) |
1399 { | |
1400 /* Heh, there is no buddy list. We fake it. | |
1401 * I just need this here so the add and remove buttons will | |
1402 * show up */ | |
1403 } | |
1404 | |
1405 | |
1406 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1407 static struct prpl *my_protocol = NULL; |
987 | 1408 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1409 static void irc_init(struct prpl *ret) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1410 { |
1008 | 1411 ret->protocol = PROTO_IRC; |
1412 ret->name = irc_name; | |
1178 | 1413 ret->list_icon = irc_list_icon; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1414 ret->buddy_menu = irc_buddy_menu; |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1415 ret->user_opts = irc_user_opts; |
1008 | 1416 ret->login = irc_login; |
1011 | 1417 ret->close = irc_close; |
1418 ret->send_im = irc_send_im; | |
1419 ret->join_chat = irc_join_chat; | |
1420 ret->chat_leave = irc_chat_leave; | |
1421 ret->chat_send = irc_chat_send; | |
1673 | 1422 ret->get_info = irc_get_info; |
1676 | 1423 ret->set_away = irc_set_away; |
1678 | 1424 ret->add_buddy = irc_fake_buddy; |
1425 ret->remove_buddy = irc_fake_buddy; | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1426 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1427 my_protocol = ret; |
987 | 1428 } |
1429 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1430 char *gaim_plugin_init(GModule * handle) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1431 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1394
diff
changeset
|
1432 load_protocol(irc_init, sizeof(struct prpl)); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1433 return NULL; |
987 | 1434 } |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1435 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1436 void gaim_plugin_remove() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1437 { |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1438 struct prpl *p = find_prpl(PROTO_IRC); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1439 if (p == my_protocol) |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1440 unload_protocol(p); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1441 } |