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