annotate src/protocols/irc/irc.c @ 2791:8f6365332a05

[gaim-migrate @ 2804] i hate this shit. i should just stop hacking gaim. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 26 Nov 2001 20:39:54 +0000
parents 428bd24c18c6
children 04f97d65bdc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim - IRC Protocol Plugin
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2290
23c06449ae8e [gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
6 *
23c06449ae8e [gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
7 * A large portion of this was copied more or less directly from X-Chat,
23c06449ae8e [gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
8 * the world's most rocking IRC client. http://www.xchat.org/
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
26 #include <config.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <unistd.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <errno.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <string.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <stdlib.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <stdio.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <time.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <sys/stat.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <ctype.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include "multi.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include "gaim.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include "proxy.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
42 #include "pixmaps/irc_icon.xpm"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #define IRC_BUF_LEN 4096
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
45 #define PDIWORDS 32
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #define USEROPT_SERV 0
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #define USEROPT_PORT 1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 struct irc_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 int fd;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
52 gboolean online;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
53 guint32 timer;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
55 char *rxqueue;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
56 int rxlen;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
57
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
58 GString *str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
59 int bc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
61 char *chantypes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
62 char *chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
63 char *nickmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
64 gboolean six_modes;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
65
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
66 gboolean in_whois;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
67 GString *whois_str;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 static char *irc_name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 return "IRC";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
75 static int irc_write(int fd, char *data, int len)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
76 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
77 debug_printf("IRC C: %s", data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
78 return write(fd, data, len);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
79 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
80
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
81 static struct conversation *irc_find_chat(struct gaim_connection *gc, char *name)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
82 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
83 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
85 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
86 struct conversation *b = bcs->data;
2331
1ea2792b6004 [gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2328
diff changeset
87 if (!g_strcasecmp(b->name, name))
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
88 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
89 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
90 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
91 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
92 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
93
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
94 static struct conversation *irc_find_chat_by_id(struct gaim_connection *gc, int id)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
95 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
96 GSList *bcs = gc->buddy_chats;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
97
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
98 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
99 struct conversation *b = bcs->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
100 if (b->id == id)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
101 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
102 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
103 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
104 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
105 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
106
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
107 static void process_data_init(char *buf, char *cmd, char *word[], char *eol[], gboolean quotes)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
108 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
109 int wordcount = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
110 gboolean space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
111 gboolean quote = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
112 int j = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
113
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
114 word[1] = cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
115 eol[1] = buf;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
116
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
117 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
118 switch (*cmd) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
119 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
120 buf[j] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
121 for (j = wordcount; j < PDIWORDS; j++) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
122 word[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
123 eol[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
124 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
125 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
126 case '"':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
127 if (!quotes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
128 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
129 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
130 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
131 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
132 quote = !quote;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
133 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
134 case ' ':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
135 if (quote) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
136 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
137 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
138 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
139 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
140 if (space)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
141 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
142 buf[j++] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
143 word[wordcount] = &buf[j];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
144 eol[wordcount++] = cmd + 1;
2294
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
145 if (wordcount == PDIWORDS - 1) {
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
146 buf[j] = 0;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
147 return;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
148 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
149 space = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
150 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
151 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
152 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
153 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
154 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
155 cmd++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
156 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
157 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
158
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
159 static void handle_005(struct gaim_connection *gc, char *word[], char *word_eol[])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
160 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
161 int w = 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
162 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
163
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
164 while (w < PDIWORDS && *word[w]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
165 if (!strncmp(word[w], "MODES=", 5)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
166 if (atoi(word[w] + 6) >= 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
167 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
168 } else if (!strncmp(word[w], "CHANTYPES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
169 g_free(id->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
170 id->chantypes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
171 } else if (!strncmp(word[w], "CHANMODES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
172 g_free(id->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
173 id->chanmodes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
174 } else if (!strncmp(word[w], "PREFIX=", 7)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
175 char *pre = strchr(word[w] + 7, ')');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
176 if (pre) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
177 *pre = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
178 g_free(id->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
179 id->nickmodes = g_strdup(word[w] + 8);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
180 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
181 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
182 w++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
183 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
184 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
185
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
186 static char *int_to_col(int c)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
188 switch(c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
189 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
190 return "#ffffff";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
191 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
192 return "#000066";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
193 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
194 return "#006600";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
195 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
196 return "#ff0000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
197 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
198 return "#660000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
199 case 6:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
200 return "#660066";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
201 case 7:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
202 return "#666600";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
203 case 8:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
204 return "#cccc00";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
205 case 9:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
206 return "#33cc33";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
207 case 10:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
208 return "#00acac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
209 case 11:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
210 return "#00ccac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
211 case 12:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
212 return "#0000ff";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
213 case 13:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
214 return "#cc00cc";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
215 case 14:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
216 return "#666666";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
217 case 15:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
218 return "#00ccac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
219 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
220 return "#000000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
221 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
224 static GString *decode_html(char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
226 GString /* oo la la */ *str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
227 char *cur = msg, *end = msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
228 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
229 int fore, back;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
230 while (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
231 switch (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
232 case 02: /* ^B */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
233 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
234 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
235 if (bold)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
236 str = g_string_append(str, "</B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
237 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
238 str = g_string_append(str, "<B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
239 bold = !bold;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
240 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
241 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
242 case 03: /* ^C */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
243 *end++ = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
244 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
245 fore = back = -1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
246 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
247 fore = *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
248 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
249 fore *= 10;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
250 fore += *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
251 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
252 if (*end == ',' && isdigit(end[1])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
253 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
254 back = *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
255 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
256 back *= 10;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
257 back += *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
258 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
259 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
260 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
261 if (fore == -1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
262 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
263 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
264 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
265 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
266 fg = bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
267 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
268 fore %= 16;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
269 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
270 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
271 if (back != -1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
272 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
273 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
274 back %= 16;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
275 str = g_string_append(str, "<FONT BACK=");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
276 str = g_string_append(str, int_to_col(back));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
277 str = g_string_append_c(str, '>');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
278 bg = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
279 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
280 str = g_string_append(str, "<FONT COLOR=");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
281 str = g_string_append(str, int_to_col(fore));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
282 str = g_string_append_c(str, '>');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
283 fg = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
284 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
285 cur = end--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
286 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
287 case 017: /* ^O */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
288 if (!bold && !underline && !fg && !bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
289 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
290 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
291 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
292 if (bold)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
293 str = g_string_append(str, "</B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
294 if (underline)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
295 str = g_string_append(str, "</U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
296 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
297 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
298 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
299 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
300 bold = underline = fg = bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
301 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
302 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
303 case 037: /* ^_ */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
304 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
305 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
306 if (underline)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
307 str = g_string_append(str, "</U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
308 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
309 str = g_string_append(str, "<U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
310 underline = !underline;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
311 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
312 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
313 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
314 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
315 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
316 if (*cur)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
317 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
318 return str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
319 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
321 static void irc_got_im(struct gaim_connection *gc, char *who, char *what, int flags, time_t t)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
322 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
323 GString *str = decode_html(what);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
324 serv_got_im(gc, who, str->str, flags, t);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
325 g_string_free(str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
326 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
327
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
328 static void irc_got_chat_in(struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t t)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
329 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
330 GString *str = decode_html(msg);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
331 serv_got_chat_in(gc, id, who, whisper, str->str, t);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
332 g_string_free(str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
333 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
334
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
335 static void handle_list(struct gaim_connection *gc, char *list)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
336 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
337 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
338 GSList *gr;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
339
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
340 id->str = g_string_append_c(id->str, ' ');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
341 id->str = g_string_append(id->str, list);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
342 id->bc--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
343 if (id->bc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
344 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
345
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
346 g_strdown(id->str->str);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
347 gr = gc->groups;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
348 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
349 GSList *m = ((struct group *)gr->data)->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
350 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
351 struct buddy *b = m->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
352 char *tmp = g_strdup(b->name);
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
353 char *x;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
354 g_strdown(tmp);
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
355 x = strstr(id->str->str, tmp);
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
356 if (!b->present && x)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
357 serv_got_update(gc, b->name, 1, 0, 0, 0, 0, 0);
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
358 else if (b->present && !x)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
359 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
360 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
361 m = m->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
363 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
365 g_string_free(id->str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
366 id->str = g_string_new("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
369 static gboolean irc_request_buddy_update(gpointer data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 {
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
371 struct gaim_connection *gc = data;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
372 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
373 char buf[500];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
374 int n = g_snprintf(buf, sizeof(buf), "ISON");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
376 GSList *gr = gc->groups;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
377 if (!gr || id->bc)
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
378 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
380 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
381 struct group *g = gr->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
382 GSList *m = g->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
383 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
384 struct buddy *b = m->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
385 if (n + strlen(b->name) + 2 > sizeof(buf)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
386 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
387 irc_write(id->fd, buf, n);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
388 id->bc++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
389 n = g_snprintf(buf, sizeof(buf), "ISON");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
390 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
391 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
392 m = m->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
393 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
394 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
396 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
397 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
398 id->bc++;
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
399 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
402 static void handle_names(struct gaim_connection *gc, char *chan, char *names)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
404 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
405 char **buf, **tmp;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
406 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
407 if (*names == ':') names++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
408 buf = g_strsplit(names, " ", -1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
409 for (tmp = buf; *tmp; tmp++)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
410 add_chat_buddy(c, *tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
411 g_strfreev(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
414 static void handle_topic(struct gaim_connection *gc, char *text)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
416 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
417 char *po = strchr(text, ' ');
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
419 if (!po)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
420 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
422 *po = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
423 po += 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
425 if ((c = irc_find_chat(gc, text))) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
426 char buf[IRC_BUF_LEN];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
427 chat_set_topic(c, NULL, po);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
428 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"),
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
429 text, po);
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
430 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL));
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
431 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
434 static gboolean mode_has_arg(struct gaim_connection *gc, char sign, char mode)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
436 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
437 char *cm = id->chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
438 int type = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
440 if (strchr(id->nickmodes, mode))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
441 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
443 while (*cm) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
444 if (*cm == ',')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
445 type++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
446 else if (*cm == mode) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
447 switch (type) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
448 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
449 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
450 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
451 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
452 if (sign == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
453 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
454 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
455 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
456 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
457 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
458 cm++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
461 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
462 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
464 static void irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
465 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
466 struct conversation *c = irc_find_chat(gc, room);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
467 GList *r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
469 if (mode != 'o' && mode != 'v')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
470 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
472 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
473 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
475 r = c->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
476 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
477 gboolean op = FALSE, voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
478 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
479 if (*who == '@') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
480 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
481 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
483 if (*who == '+') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
484 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
485 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
487 if (!strcmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
488 char *tmp, buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
489 if (mode == 'o') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
490 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
491 op = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
492 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
493 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
494 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
495 if (mode == 'v') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
496 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
497 voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
498 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
499 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
500 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
501 tmp = g_strdup(r->data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
502 g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
503 voice ? "+" : "", nick);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
504 rename_chat_buddy(c, tmp, buf);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
505 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
506 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
508 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
509 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
510 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
512 static void handle_mode(struct gaim_connection *gc, char *word[], char *word_eol[], gboolean n324)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
513 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
514 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
515 int offset = n324 ? 4 : 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
516 char *chan = word[offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
517 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
518 char *modes = word[offset + 1];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
519 int len = strlen(word_eol[offset]) - 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
520 char sign = *modes++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
521 int arg = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
522 char *argstr;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
523
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
524 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
525 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
526
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
527 if (word_eol[offset][len] == ' ')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
528 word_eol[offset][len] = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
530 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
531 switch (*modes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
532 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
533 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
534 case '+':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
535 case '-':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
536 sign = *modes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
537 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
538 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
539 if (mode_has_arg(gc, sign, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
540 argstr = word[++arg + offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
541 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
542 argstr = "";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
543 if (strchr(id->nickmodes, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
544 irc_user_mode(gc, chan, sign, *modes, argstr);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
545 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
546 modes++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 }
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
549
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
550 /* Handle our whois stuff here. You know what, I have a sore throat. You know
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
551 * what I think about that? I'm not too pleased with it. Perhaps I should take
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
552 * some medicine, or perhaps I should go to bed? Blah!! */
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
553
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
554 static void handle_whois(struct gaim_connection *gc, char *word[], char *word_eol[], int num)
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
555 {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
556 struct irc_data *id = gc->proto_data;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
557 char tmp[1024];
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
558
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
559 if (!id->in_whois) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
560 id->in_whois = TRUE;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
561 id->whois_str = g_string_new("");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
562 } else {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
563 /* I can't decide if we should have one break or two */
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
564 id->whois_str = g_string_append(id->whois_str, "<BR>");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
565 id->in_whois = TRUE;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
566 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
567
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
568 switch (num) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
569 case 311:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
570 id->whois_str = g_string_append(id->whois_str, "<b>User: </b>");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
571 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
572 case 312:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
573 id->whois_str = g_string_append(id->whois_str, "<b>Server: </b>");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
574 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
575 case 313:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
576 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]);
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
577 id->whois_str = g_string_append(id->whois_str, tmp);
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
578 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
579
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
580 case 317:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
581 id->whois_str = g_string_append(id->whois_str, "<b>Idle Time: </b>");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
582 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
583 case 319:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
584 id->whois_str = g_string_append(id->whois_str, "<b>Channels: </b>");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
585 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
586 default:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
587 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
588 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
589
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
590 if (word_eol[5][0] == ':')
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
591 id->whois_str = g_string_append(id->whois_str, word_eol[5] + 1);
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
592 else
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
593 id->whois_str = g_string_append(id->whois_str, word_eol[5]);
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
594
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
595 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
596
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
597 static void process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
599 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
600 char *text = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
601 int n = atoi(word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
602
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
603 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname)))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
604 text += strlen(gc->displayname) + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
605 if (*text == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
606 text++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
608 switch (n) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
609 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
610 if (!strncmp(word[5], "u2.10", 5))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
611 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
612 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
613 id->six_modes = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
614 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
615 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
616 handle_005(gc, word, word_eol);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
617 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
618 case 301:
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
619 if (id->in_whois) {
2649
f857ae4ddd84 [gaim-migrate @ 2662]
Rob Flynn <gaim@robflynn.com>
parents: 2648
diff changeset
620 id->whois_str = g_string_append(id->whois_str, "<BR><b>Away: </b>");
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
621
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
622 if (word_eol[5][0] == ':')
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
623 id->whois_str = g_string_append(id->whois_str, word_eol[5] + 1);
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
624 else
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
625 id->whois_str = g_string_append(id->whois_str, word_eol[5]);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
626 } else
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
627 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
628 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
629 case 303:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
630 handle_list(gc, &word_eol[4][1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
631 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
632 case 311:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
633 case 312:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
634 case 313:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
635 case 317:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
636 case 319:
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
637 handle_whois(gc, word, word_eol, n);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
638 break;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
639 case 318:
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
640 if (id->in_whois && id->whois_str) {
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
641 GString *str = decode_html(id->whois_str->str);
2791
8f6365332a05 [gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2782
diff changeset
642 g_show_info_text(gc, NULL, 2, str->str, NULL);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
643 g_string_free(str, TRUE);
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
644 g_string_free(id->whois_str, TRUE);
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
645 id->whois_str = NULL;
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
646 id->in_whois = FALSE;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
647 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
648 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
649 case 324:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
650 handle_mode(gc, word, word_eol, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
651 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
652 case 332:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
653 handle_topic(gc, text);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
654 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
655 case 353:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
656 handle_names(gc, word[5], word_eol[6]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
657 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
658 case 376:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
659 irc_request_buddy_update(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
660 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
661 case 401:
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
662 do_error_dialog(_("No such nick/channel"), _("IRC Error"));
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
663 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
664 case 402:
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
665 do_error_dialog(_("No such server"), _("IRC Error"));
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
666 case 431:
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
667 do_error_dialog(_("No nickname given"), _("IRC Error"));
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
668 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
670 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
672 static gboolean is_channel(struct gaim_connection *gc, char *name)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
673 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
674 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
675 if (strchr(id->chantypes, *name))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
676 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
677 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
680 static void irc_rem_chat_bud(struct gaim_connection *gc, char *nick)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
682 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
684 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
685 struct conversation *b = bcs->data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
687 GList *r = b->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
688 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
689 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
690 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
691 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
692 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
693 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
694 if (!g_strcasecmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
695 char *tmp = g_strdup(r->data);
2291
5e35b4c63c2c [gaim-migrate @ 2301]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2290
diff changeset
696 remove_chat_buddy(b, tmp);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
697 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
698 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
699 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
700 r = r->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
702 bcs = bcs->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
706 static void irc_change_name(struct gaim_connection *gc, char *old, char *new)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
707 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
708 GSList *bcs = gc->buddy_chats;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
709 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
711 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
712 struct conversation *b = bcs->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
713
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
714 GList *r = b->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
715 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
716 char *who = r->data;
2292
6625d0755c51 [gaim-migrate @ 2302]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2291
diff changeset
717 int n = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
718 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
719 buf[n++] = *who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
720 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
721 buf[n++] = *who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
722 g_snprintf(buf + n, sizeof(buf) - n, "%s", new);
2312
766603034af8 [gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2310
diff changeset
723 if (!strcmp(who, old)) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
724 char *tmp = g_strdup(r->data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
725 rename_chat_buddy(b, tmp, buf);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
726 r = b->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
727 g_free(tmp);
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2687
diff changeset
728 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
729 } else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
730 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
731 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
732 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
733 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
734 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
736 static void handle_privmsg(struct gaim_connection *gc, char *to, char *nick, char *msg)
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
737 {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
738 if (is_channel(gc, to)) {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
739 struct conversation *c = irc_find_chat(gc, to);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
740 if (!c)
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
741 return;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
742 irc_got_chat_in(gc, c->id, nick, 0, msg, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
743 } else {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
744 char *tmp = g_malloc(strlen(nick) + 2);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
745 g_snprintf(tmp, strlen(nick) + 2, "@%s", nick);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
746 if (find_conversation(tmp))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
747 irc_got_im(gc, tmp, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
748 else {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
749 *tmp = '+';
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
750 if (find_conversation(tmp))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
751 irc_got_im(gc, tmp, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
752 else
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
753 irc_got_im(gc, nick, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
754 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
755 g_free(tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
756 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
757 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
758
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
759 static void handle_ctcp(struct gaim_connection *gc, char *to, char *nick,
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
760 char *msg, char *word[], char *word_eol[])
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
761 {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
762 struct irc_data *id = gc->proto_data;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
763 char buf[IRC_BUF_LEN];
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
764
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
765 if (!g_strncasecmp(msg, "VERSION", 7)) {
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
766 g_snprintf(buf, sizeof(buf), "NOTICE %s :\001VERSION Gaim " VERSION ": The Pimpin "
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
767 "Penguin AIM Clone: " WEBSITE "\001\r\n", nick);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
768 irc_write(id->fd, buf, strlen(buf));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
769 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
770 if (!g_strncasecmp(msg, "ACTION", 6)) {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
771 char *po = strchr(msg + 6, 1);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
772 char *tmp;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
773 if (po) *po = 0;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
774 tmp = g_strconcat("/me", msg + 6, NULL);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
775 handle_privmsg(gc, to, nick, tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
776 g_free(tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
777 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
778 /* XXX should probably write_to_conv or something here */
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
779 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
780
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
781 static gboolean irc_parse(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
783 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
784 gchar outbuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
785 char *word[PDIWORDS], *word_eol[PDIWORDS];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
786 char pdibuf[522];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
787 char *ex, ip[128], nick[128];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
788 char *cmd;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 /* Check for errors */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
792 if (*buf != ':') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
793 if (!strncmp(buf, "NOTICE ", 7))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
794 buf += 7;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
795 if (!strncmp(buf, "PING ", 5)) {
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
796 int r = FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
797 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
798 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
799 hide_login_progress(gc, _("Unable to write"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
800 signoff(gc);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
801 r = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
802 }
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
803 return r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
805 /* XXX doesn't handle ERROR */
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
806 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808
2782
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
809 if (!idata->online) {
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
810 /* Now lets sign ourselves on */
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
811 account_online(gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
812 serv_finish_login(gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
813
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
814 if (bud_list_cache_exists(gc))
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
815 do_import(gc, NULL);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
816
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
817 /* we don't call this now because otherwise some IRC servers might not like us */
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
818 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
819 idata->online = TRUE;
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
820 }
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
821
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
822 buf++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
824 process_data_init(pdibuf, buf, word, word_eol, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
826 if (atoi(word[2])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
827 if (*word_eol[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
828 process_numeric(gc, word, word_eol);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
829 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
832 cmd = word[2];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
834 ex = strchr(pdibuf, '!');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
835 if (!ex) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
836 strncpy(ip, pdibuf, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
837 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
838 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
839 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
840 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
841 strncpy(ip, ex + 1, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
842 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
843 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
844 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
845 if ((ex - pdibuf) < sizeof (nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
846 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
849 if (!strcmp(cmd, "INVITE")) { /* */
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
850 } else if (!strcmp(cmd, "JOIN")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
851 char *chan = *word[3] == ':' ? word[3] + 1 : word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
852 if (!g_strcasecmp(gc->displayname, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
853 static int id = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
854 serv_got_joined_chat(gc, id++, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
855 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
856 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
857 if (c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
858 add_chat_buddy(c, nick);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
860 } else if (!strcmp(cmd, "KICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
861 if (!strcmp(gc->displayname, word[4])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
862 struct conversation *c = irc_find_chat(gc, word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
863 if (!c)
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
864 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
865 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
866 c->gc = NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
867 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s: %s"),
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
868 word[3], *word_eol[5] == ':' ? word_eol[5] + 1: word_eol[5]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
869 do_error_dialog(outbuf, _("IRC Error"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
870 } else
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
871 irc_rem_chat_bud(gc, word[4]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
872 } else if (!strcmp(cmd, "KILL")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
873 } else if (!strcmp(cmd, "MODE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
874 handle_mode(gc, word, word_eol, FALSE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
875 } else if (!strcmp(cmd, "NICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
876 char *new = *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
877 if (!strcmp(gc->displayname, nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
878 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
879 irc_change_name(gc, nick, new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
880 } else if (!strcmp(cmd, "NOTICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
881 if (*word_eol[4] == ':') word_eol[4]++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
882 if (ex)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
883 irc_got_im(gc, nick, word_eol[4], 0, time(NULL));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
884 } else if (!strcmp(cmd, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
885 char *chan = cmd + 5;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
886 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
887 GList *r;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
888 if (*chan == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
889 chan++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
890 if (!(c = irc_find_chat(gc, chan)))
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
891 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
892 if (!strcmp(nick, gc->displayname)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
893 serv_got_chat_left(gc, c->id);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
894 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
896 r = c->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
897 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
898 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
899 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
900 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
901 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
902 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
903 if (!g_strcasecmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
904 char *tmp = g_strdup(r->data);
2291
5e35b4c63c2c [gaim-migrate @ 2301]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2290
diff changeset
905 remove_chat_buddy(c, tmp);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
906 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
907 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
908 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
909 r = r->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
911 } else if (!strcmp(cmd, "PRIVMSG")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
912 char *to, *msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
913 if (!*word[3])
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
914 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
915 to = word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
916 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
917 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
918 if (!g_strncasecmp(msg + 1, "DCC ", 4))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
919 process_data_init(pdibuf, buf, word, word_eol, TRUE);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
920 handle_ctcp(gc, to, nick, msg + 1, word, word_eol);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
921 } else {
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
922 handle_privmsg(gc, to, nick, msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
924 } else if (!strcmp(cmd, "PONG")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
925 } else if (!strcmp(cmd, "QUIT")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
926 irc_rem_chat_bud(gc, nick);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
927 } else if (!strcmp(cmd, "TOPIC")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
928 struct conversation *c = irc_find_chat(gc, word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
929 char *topic = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
930 if (c) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
931 char buf[IRC_BUF_LEN];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
932 chat_set_topic(c, nick, topic);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
933 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"),
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
934 nick, topic);
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
935 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL));
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
936 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
937 } else if (!strcmp(cmd, "WALLOPS")) { /* */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 }
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
939
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
940 return FALSE;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
941 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
942
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
943 static void irc_callback(gpointer data, gint source, GaimInputCondition condition)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
944 {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
945 struct gaim_connection *gc = data;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
946 struct irc_data *idata = gc->proto_data;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
947 int i = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
948 gchar buf[1024];
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
949 gboolean off;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
950
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
951 i = read(idata->fd, buf, 1024);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
952 if (i <= 0) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
953 hide_login_progress(gc, "Read error");
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
954 signoff(gc);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
955 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
956 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
957
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
958 idata->rxqueue = g_realloc(idata->rxqueue, i + idata->rxlen + 1);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
959 memcpy(idata->rxqueue + idata->rxlen, buf, i);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
960 idata->rxlen += i;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
961 idata->rxqueue[idata->rxlen] = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
962
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
963 while (1) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
964 char *d, *e;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
965 int len;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
966
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
967 if (!idata->rxqueue || ((e = strchr(idata->rxqueue, '\n')) == NULL))
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
968 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
969
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
970 len = e - idata->rxqueue + 1;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
971 d = g_strndup(idata->rxqueue, len);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
972 g_strchomp(d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
973 debug_printf("IRC S: %s\n", d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
974
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
975 idata->rxlen -= len;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
976 if (idata->rxlen) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
977 char *tmp = g_strdup(e + 1);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
978 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
979 idata->rxqueue = tmp;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
980 } else {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
981 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
982 idata->rxqueue = NULL;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
983 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
984
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
985 off = irc_parse(gc, d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
986
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
987 g_free(d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
988
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
989 if (off)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
990 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
991 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
994 static void irc_login_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 struct irc_data *idata;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
998 char hostname[256];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
999 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001 if (!g_slist_find(connections, gc)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 close(source);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 idata = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 if (source == -1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 if (idata->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 idata->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1017 gethostname(hostname, sizeof(hostname) - 1);
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1018 hostname[sizeof(hostname) - 1] = 0;
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1019 if (!*hostname)
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1020 g_snprintf(hostname, sizeof(hostname), "localhost");
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1021 g_snprintf(buf, sizeof(buf), "USER %s %s %s :Gaim (%s)\r\n",
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1022 g_get_user_name(), hostname, gc->user->proto_opt[USEROPT_SERV], WEBSITE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1023 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1024 hide_login_progress(gc, "Write error");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1025 signoff(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1026 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1027 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1029 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", gc->username);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1030 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1036 gc->inpa = gaim_input_add(idata->fd, GAIM_INPUT_READ, irc_callback, gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039 static void irc_login(struct aim_user *user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1041 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043 struct gaim_connection *gc = new_gaim_conn(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1046 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1047
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 set_login_progress(gc, 2, buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1051 idata->chantypes = g_strdup("#&!+");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1052 idata->chanmodes = g_strdup("beI,k,l");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1053 idata->nickmodes = g_strdup("ohv");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1054 idata->str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1055
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV],
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 user->proto_opt[USEROPT_PORT][0] ? atoi(user->
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 proto_opt[USEROPT_PORT]) :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 6667, irc_login_callback, gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 if (!user->gc || (idata->fd < 0)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 hide_login_progress(gc, "Unable to create socket");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1067 static void irc_close(struct gaim_connection *gc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1068 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1069 struct irc_data *idata = (struct irc_data *)gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1070 gchar buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1071
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
1072 g_snprintf(buf, sizeof(buf), "QUIT :Download Gaim [%s]\r\n", WEBSITE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1073 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1074
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1075 if (idata->rxqueue)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1076 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1077 idata->rxqueue = NULL;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1078 idata->rxlen = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1079
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1080 g_free(idata->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1081 g_free(idata->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1082 g_free(idata->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1083
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1084 g_string_free(idata->str, TRUE);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1085 if (idata->whois_str)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1086 g_string_free(idata->whois_str, TRUE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1087
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1088 if (idata->timer)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1089 g_source_remove(idata->timer);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1090
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1091 if (gc->inpa)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1092 gaim_input_remove(gc->inpa);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1093
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1094 close(idata->fd);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1095 g_free(gc->proto_data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1096 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1097
2154
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1098 static GList *irc_user_opts()
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 {
2154
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1100 GList *m = NULL;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1101 struct proto_user_opt *puo;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1102
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1103 puo = g_new0(struct proto_user_opt, 1);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1104 puo->label = "Server:";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1105 puo->def = "irc.mozilla.org";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1106 puo->pos = USEROPT_SERV;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1107 m = g_list_append(m, puo);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1108
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1109 puo = g_new0(struct proto_user_opt, 1);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1110 puo->label = "Port:";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1111 puo->def = "6667";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1112 puo->pos = USEROPT_PORT;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1113 m = g_list_append(m, puo);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1114
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1115 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1118 static void set_mode_3(struct gaim_connection *gc, char *who, int sign, int mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1119 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1121 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1122 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1123 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1124 int i = start;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1125
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1126 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1127 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1128 switch (left) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1129 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1130 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1131 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1132 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1133 who, sign, mode, word[i]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1134 i += 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1135 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1136 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1137 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1138 who, sign, mode, mode, word[i], word[i + 1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1139 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1140 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1141 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1142 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1143 who, sign, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1144 word[i], word[i + 1], word[i + 2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1145 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1146 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1147 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1148 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1149 if (left < 3)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1150 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1151 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1154 static void set_mode_6(struct gaim_connection *gc, char *who, int sign, int mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1155 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1157 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1158 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1159 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1160 int i = start;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1162 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1163 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1164 switch (left) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1165 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1166 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1167 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1168 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1169 who, sign, mode, word[i]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1170 i += 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1171 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1172 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1173 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1174 who, sign, mode, mode, word[i], word[i + 1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1175 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1176 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1177 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1178 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1179 who, sign, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1180 word[i], word[i + 1], word[i + 2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1181 i += 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1182 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1183 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1184 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c %s %s %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1185 who, sign, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1186 word[i], word[i + 1], word[i + 2], word[i + 3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1187 i += 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1188 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1189 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1190 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c %s %s %s %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1191 who, sign, mode, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1192 word[i], word[i + 1], word[i + 2],
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1193 word[i + 3], word[i + 4]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1194 i += 5;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1195 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1196 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1197 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c%c %s %s %s %s %s %s\r\n",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1198 who, sign, mode, mode, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1199 word[i], word[i + 1], word[i + 2],
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1200 word[i + 3], word[i + 4], word[i + 5]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1201 i += 6;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1202 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1203 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1204 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1205 if (left < 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1206 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1207 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1208 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1210 static void set_mode(struct gaim_connection *gc, char *who, int sign, int mode, char *word[])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1211 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1212 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1213 int i = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1214
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1215 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1216 if (!*word[i]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1217 if (i == 2)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1218 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1219 if (id->six_modes)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1220 set_mode_6(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1221 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1222 set_mode_3(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1223 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1224 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1225 i++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1226 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1229 static int handle_command(struct gaim_connection *gc, char *who, char *what)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1231 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1232 char pdibuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1233 char *word[PDIWORDS], *word_eol[PDIWORDS];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1234 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1235 if (*what != '/') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1236 unsigned int max = 440 - strlen(who);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1237 char t;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1238 while (strlen(what) > max) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1239 t = what[max];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1240 what[max] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1241 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1242 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1243 what[max] = t;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1244 what = what + max;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1245 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1246 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1247 irc_write(id->fd, buf, strlen(buf));
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1248 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1249 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1250
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1251 what++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1252 process_data_init(pdibuf, what, word, word_eol, TRUE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1254 if (!g_strcasecmp(pdibuf, "ME")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1255 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :\001ACTION %s\001\r\n", who, word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1256 irc_write(id->fd, buf, strlen(buf));
2304
15fb364935ec [gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2303
diff changeset
1257 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1258 } else if (!g_strcasecmp(pdibuf, "TOPIC")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1259 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1260 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1261 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1262 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1263 } else if (!g_strcasecmp(pdibuf, "NICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1264 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1265 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1266 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1267 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1268 } else if (!g_strcasecmp(pdibuf, "OP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1269 set_mode(gc, who, '+', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1270 } else if (!g_strcasecmp(pdibuf, "DEOP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1271 set_mode(gc, who, '-', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1272 } else if (!g_strcasecmp(pdibuf, "VOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1273 set_mode(gc, who, '+', 'v', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1274 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1275 set_mode(gc, who, '-', 'v', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1276 } else if (!g_strcasecmp(pdibuf, "QUOTE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1277 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1278 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1279 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1280 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1281 } else if (!g_strcasecmp(pdibuf, "SAY")) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1282 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1283 return -EINVAL;
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1284 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, word_eol[2]);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1285 irc_write(id->fd, buf, strlen(buf));
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1286 return 1;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1287 } else if (!g_strcasecmp(pdibuf, "MSG")) {
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1288 if (!*word[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1289 return -EINVAL;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1290 if (!*word_eol[3])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1291 return -EINVAL;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1292 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", word[2], word_eol[3]);
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1293 irc_write(id->fd, buf, strlen(buf));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1294 } else if (!g_strcasecmp(pdibuf, "KICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1295 if (!*word[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1296 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1297 if (*word_eol[3])
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
1298 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], word_eol[3]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1299 else
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
1300 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1301 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1302 } else if (!g_strcasecmp(pdibuf, "JOIN")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1303 if (!*word[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1304 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1305 if (*word[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1306 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1307 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1308 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1309 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1310 } else if (!g_strcasecmp(pdibuf, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1311 char *chan = *word[2] ? word[2] : who;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1312 char *reason = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1313 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1314 if (!is_channel(gc, chan))
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1315 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1316 c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1317 g_snprintf(buf, sizeof(buf), "PART %s%s%s\r\n", chan,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1318 *reason ? " :" : "",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1319 *reason ? reason : "");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1320 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1321 if (c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1322 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1323 c->gc = NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1324 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1325 do_error_dialog(buf, _("IRC Part"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1326 }
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1327 } else if (!g_strcasecmp(pdibuf, "WHOIS")) {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1328 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1329 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1330 } else if (!g_strcasecmp(pdibuf, "HELP")) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1331 struct conversation *c = NULL;
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1332 if (is_channel(gc, who)) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1333 c = irc_find_chat(gc, who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1334 } else {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1335 c = find_conversation(who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1336 }
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1337 if (!c)
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1338 return -EINVAL;
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1339 write_to_conv(c, "<B>Currently supported commands:<BR>"
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1340 "JOIN PART TOPIC WHOIS<BR>"
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1341 "OP DEOP VOICE DEVOICE KICK<BR>"
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1342 "NICK ME MSG QUOTE SAY</B>",
2459
a25223b2c29b [gaim-migrate @ 2472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2413
diff changeset
1343 WFLAG_NOLOG, NULL, time(NULL));
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1344 } else {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1345 struct conversation *c = NULL;
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1346 if (is_channel(gc, who)) {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1347 c = irc_find_chat(gc, who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1348 } else {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1349 c = find_conversation(who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1350 }
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1351 if (!c)
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1352 return -EINVAL;
2459
a25223b2c29b [gaim-migrate @ 2472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2413
diff changeset
1353 write_to_conv(c, "<B>Unknown command</B>", WFLAG_NOLOG, NULL, time(NULL));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1354 }
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1355
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1356 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1357 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1359 static int send_msg(struct gaim_connection *gc, char *who, char *what)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1360 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1361 char *cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1362 if (cr) {
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1363 int ret = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1364 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1365 if (cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1366 *cr = 0;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1367 ret = handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1368 if (!cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1369 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1370 what = cr + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1371 if (!*what)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1372 break;
2295
24dc9ce95127 [gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2294
diff changeset
1373 *cr = '\n';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1374 cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1375 }
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1376 return ret;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1377 } else
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1378 return handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1379 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1380
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1381 static int irc_send_im(struct gaim_connection *gc, char *who, char *what, int flags)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1382 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1383 if (*who == '@' || *who == '+')
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1384 return send_msg(gc, who + 1, what);
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1385 return send_msg(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1386 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1387
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1388 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
1389 static void irc_add_buddy(struct gaim_connection *gc, char *who) {}
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
1390 static void irc_remove_buddy(struct gaim_connection *gc, char *who, char *group) {}
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1391
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1392 static GList *irc_chat_info(struct gaim_connection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1394 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1395 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1396
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1397 pce = g_new0(struct proto_chat_entry, 1);
2466
f8eb5f120603 [gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2459
diff changeset
1398 pce->label = _("Channel:");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1399 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1400
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1401 pce = g_new0(struct proto_chat_entry, 1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1402 pce->label = _("Password:");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1403 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1404
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1405 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1408 static void irc_join_chat(struct gaim_connection *gc, GList *data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1409 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1410 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1411 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1412 char *name, *pass;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1413
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1414 if (!data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1415 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1416 name = data->data;
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
1417 if (data->next) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1418 pass = data->next->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1419 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", name, pass);
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
1420 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1421 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1422 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1423 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1424
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1425 static void irc_chat_leave(struct gaim_connection *gc, int id)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1426 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1427 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1428 struct conversation *c = irc_find_chat_by_id(gc, id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1429 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1430
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1431 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1432
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1433 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1434 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1435 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1436
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1437 static int irc_chat_send(struct gaim_connection *gc, int id, char *what)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1438 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1439 struct conversation *c = irc_find_chat_by_id(gc, id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1440 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1441 return -EINVAL;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1442 if (send_msg(gc, c->name, what) > 0)
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1443 serv_got_chat_in(gc, c->id, gc->displayname, 0, what, time(NULL));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1444 return 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1445 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1446
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2466
diff changeset
1447 static GList *irc_away_states(struct gaim_connection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1448 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1449 return g_list_append(NULL, GAIM_AWAY_CUSTOM);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1450 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1454 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1455 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1457 if (gc->away)
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1458 gc->away = NULL;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1459
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1460 if (msg) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1461 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg);
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1462 gc->away = "";
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1463 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1464 g_snprintf(buf, sizeof(buf), "AWAY\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1465 irc_write(idata->fd, buf, strlen(buf));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1468 static char **irc_list_icon(int uc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1470 return irc_icon_xpm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1473 static void irc_get_info(struct gaim_connection *gc, char *who)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1474 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1475 struct irc_data *idata = gc->proto_data;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1476 char buf[IRC_BUF_LEN];
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1477
2633
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1478 if (*who == '@')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1479 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1480 if (*who == '+')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1481 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1482
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1483 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1484 irc_write(idata->fd, buf, strlen(buf));
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1485 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1486
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1487 static GList *irc_buddy_menu(struct gaim_connection *gc, char *who)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1488 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1489 GList *m = NULL;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1490 struct proto_buddy_menu *pbm;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1491
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1492 pbm = g_new0(struct proto_buddy_menu, 1);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1493 pbm->label = _("Get Info");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1494 pbm->callback = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1495 pbm->gc = gc;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1496 m = g_list_append(m, pbm);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1497
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1498 return m;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1499 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1500
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1501 static struct prpl *my_protocol = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1502
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503 void irc_init(struct prpl *ret)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1504 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1505 ret->protocol = PROTO_IRC;
2100
a93aeb6f813d [gaim-migrate @ 2110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
1506 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1507 ret->name = irc_name;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1508 ret->user_opts = irc_user_opts;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1509 ret->list_icon = irc_list_icon;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1510 ret->login = irc_login;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1511 ret->close = irc_close;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1512 ret->send_im = irc_send_im;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
1513 ret->add_buddy = irc_add_buddy;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
1514 ret->remove_buddy = irc_remove_buddy;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
1515 ret->chat_info = irc_chat_info;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1516 ret->join_chat = irc_join_chat;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1517 ret->chat_leave = irc_chat_leave;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1518 ret->chat_send = irc_chat_send;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1519 ret->away_states = irc_away_states;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1520 ret->set_away = irc_set_away;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1521 ret->get_info = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1522 ret->buddy_menu = irc_buddy_menu;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1523 my_protocol = ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1524 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526 #ifndef STATIC
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1527
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528 char *gaim_plugin_init(GModule *handle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1530 load_protocol(irc_init, sizeof(struct prpl));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1531 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1534 void gaim_plugin_remove()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1535 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536 struct prpl *p = find_prpl(PROTO_IRC);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537 if (p == my_protocol)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1538 unload_protocol(p);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1539 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 char *name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543 return "IRC";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 char *description()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 {
2162
a464da684307 [gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2154
diff changeset
1548 return PRPL_DESC("IRC");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1550
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 #endif