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