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