annotate src/protocols/irc/irc.c @ 2650:0425dbe29272

[gaim-migrate @ 2663] This is shorter... committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 01 Nov 2001 06:46:31 +0000
parents f857ae4ddd84
children f84dcbcfba4b
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
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
55 GString *str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
56 int bc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
58 char *chantypes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
59 char *chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
60 char *nickmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
61 gboolean six_modes;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
62
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
63 gboolean in_whois;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
64 GString *whois_str;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 static char *irc_name()
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 return "IRC";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
72 static int irc_write(int fd, char *data, int len)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
73 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
74 debug_printf("IRC C: %s", data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
75 return write(fd, data, 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
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
78 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
79 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
80 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
82 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
83 struct conversation *b = bcs->data;
2331
1ea2792b6004 [gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2328
diff changeset
84 if (!g_strcasecmp(b->name, name))
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
85 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
86 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
87 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
88 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
89 }
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 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
92 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
93 GSList *bcs = gc->buddy_chats;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
94
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
95 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
96 struct conversation *b = bcs->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
97 if (b->id == id)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
98 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
99 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
100 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
101 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
102 }
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 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
105 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
106 int wordcount = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
107 gboolean space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
108 gboolean quote = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
109 int j = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
110
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
111 word[1] = cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
112 eol[1] = buf;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
113
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
114 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
115 switch (*cmd) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
116 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
117 buf[j] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
118 for (j = wordcount; j < PDIWORDS; j++) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
119 word[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
120 eol[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
121 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
122 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
123 case '"':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
124 if (!quotes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
125 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
126 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
127 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
128 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
129 quote = !quote;
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 case ' ':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
132 if (quote) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
133 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
134 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
135 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
136 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
137 if (space)
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 buf[j++] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
140 word[wordcount] = &buf[j];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
141 eol[wordcount++] = cmd + 1;
2294
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
142 if (wordcount == PDIWORDS - 1) {
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
143 buf[j] = 0;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
144 return;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
145 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
146 space = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
147 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
148 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
149 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
150 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
151 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
152 cmd++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
153 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
154 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
155
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
156 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
157 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
158 int w = 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
159 struct irc_data *id = gc->proto_data;
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 while (w < PDIWORDS && *word[w]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
162 if (!strncmp(word[w], "MODES=", 5)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
163 if (atoi(word[w] + 6) >= 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
164 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
165 } else if (!strncmp(word[w], "CHANTYPES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
166 g_free(id->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
167 id->chantypes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
168 } else if (!strncmp(word[w], "CHANMODES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
169 g_free(id->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
170 id->chanmodes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
171 } else if (!strncmp(word[w], "PREFIX=", 7)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
172 char *pre = strchr(word[w] + 7, ')');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
173 if (pre) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
174 *pre = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
175 g_free(id->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
176 id->nickmodes = g_strdup(word[w] + 8);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
177 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
178 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
179 w++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
180 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
181 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
182
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
183 static char *int_to_col(int c)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
185 switch(c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
186 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
187 return "#ffffff";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
188 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
189 return "#000066";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
190 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
191 return "#006600";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
192 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
193 return "#ff0000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
194 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
195 return "#660000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
196 case 6:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
197 return "#660066";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
198 case 7:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
199 return "#666600";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
200 case 8:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
201 return "#cccc00";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
202 case 9:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
203 return "#33cc33";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
204 case 10:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
205 return "#00acac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
206 case 11:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
207 return "#00ccac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
208 case 12:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
209 return "#0000ff";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
210 case 13:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
211 return "#cc00cc";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
212 case 14:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
213 return "#666666";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
214 case 15:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
215 return "#00ccac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
216 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
217 return "#000000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
218 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
221 static GString *decode_html(char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
223 GString /* oo la la */ *str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
224 char *cur = msg, *end = msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
225 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
226 int fore, back;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
227 while (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
228 switch (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
229 case 02: /* ^B */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
230 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
231 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
232 if (bold)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
233 str = g_string_append(str, "</B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
234 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
235 str = g_string_append(str, "<B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
236 bold = !bold;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
237 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
238 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
239 case 03: /* ^C */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
240 *end++ = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
241 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
242 fore = back = -1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
243 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
244 fore = *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
245 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
246 fore *= 10;
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 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
249 if (*end == ',' && isdigit(end[1])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
250 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
251 back = *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
252 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
253 back *= 10;
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 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
256 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
257 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
258 if (fore == -1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
259 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
260 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
261 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
262 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
263 fg = bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
264 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
265 fore %= 16;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
266 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
267 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
268 if (back != -1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
269 if (bg)
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 back %= 16;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
272 str = g_string_append(str, "<FONT BACK=");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
273 str = g_string_append(str, int_to_col(back));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
274 str = g_string_append_c(str, '>');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
275 bg = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
276 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
277 str = g_string_append(str, "<FONT COLOR=");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
278 str = g_string_append(str, int_to_col(fore));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
279 str = g_string_append_c(str, '>');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
280 fg = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
281 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
282 cur = end--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
283 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
284 case 017: /* ^O */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
285 if (!bold && !underline && !fg && !bg)
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 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
288 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
289 if (bold)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
290 str = g_string_append(str, "</B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
291 if (underline)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
292 str = g_string_append(str, "</U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
293 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
294 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
295 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
296 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
297 bold = underline = fg = bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
298 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
299 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
300 case 037: /* ^_ */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
301 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
302 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
303 if (underline)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
304 str = g_string_append(str, "</U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
305 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
306 str = g_string_append(str, "<U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
307 underline = !underline;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
308 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
309 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
310 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
311 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
312 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
313 if (*cur)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
314 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
315 return str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
316 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
318 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
319 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
320 GString *str = decode_html(what);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
321 serv_got_im(gc, who, str->str, flags, t);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
322 g_string_free(str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
323 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
324
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
325 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
326 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
327 GString *str = decode_html(msg);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
328 serv_got_chat_in(gc, id, who, whisper, str->str, t);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
329 g_string_free(str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
330 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
331
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
332 static void handle_list(struct gaim_connection *gc, char *list)
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 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
335 GSList *gr;
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 id->str = g_string_append_c(id->str, ' ');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
338 id->str = g_string_append(id->str, list);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
339 id->bc--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
340 if (id->bc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
341 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
342
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
343 g_strdown(id->str->str);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
344 gr = gc->groups;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
345 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
346 GSList *m = ((struct group *)gr->data)->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
347 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
348 struct buddy *b = m->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
349 char *tmp = g_strdup(b->name);
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
350 char *x;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
351 g_strdown(tmp);
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
352 x = strstr(id->str->str, tmp);
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
353 if (!b->present && x)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
354 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
355 else if (b->present && !x)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
356 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
357 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
358 m = m->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
360 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
362 g_string_free(id->str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
363 id->str = g_string_new("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
366 static gboolean irc_request_buddy_update(gpointer data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 {
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
368 struct gaim_connection *gc = data;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
369 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
370 char buf[500];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
371 int n = g_snprintf(buf, sizeof(buf), "ISON");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
373 GSList *gr = gc->groups;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
374 if (!gr || id->bc)
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
375 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
377 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
378 struct group *g = gr->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
379 GSList *m = g->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
380 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
381 struct buddy *b = m->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
382 if (n + strlen(b->name) + 2 > sizeof(buf)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
383 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
384 irc_write(id->fd, buf, n);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
385 id->bc++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
386 n = g_snprintf(buf, sizeof(buf), "ISON");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
387 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
388 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
389 m = m->next;
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 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
393 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
394 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
395 id->bc++;
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
396 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
399 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
400 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
401 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
402 char **buf, **tmp;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
403 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
404 if (*names == ':') names++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
405 buf = g_strsplit(names, " ", -1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
406 for (tmp = buf; *tmp; tmp++)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
407 add_chat_buddy(c, *tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
408 g_strfreev(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
411 static void handle_topic(struct gaim_connection *gc, char *text)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
413 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
414 char *po = strchr(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 if (!po)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
417 return;
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 *po = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
420 po += 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
422 if ((c = irc_find_chat(gc, text))) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
423 char buf[IRC_BUF_LEN];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
424 chat_set_topic(c, NULL, po);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
425 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
426 text, po);
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
427 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL));
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
428 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
431 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
432 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
433 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
434 char *cm = id->chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
435 int type = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
437 if (strchr(id->nickmodes, mode))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
438 return TRUE;
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 while (*cm) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
441 if (*cm == ',')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
442 type++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
443 else if (*cm == mode) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
444 switch (type) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
445 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
446 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
447 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
448 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
449 if (sign == '+')
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 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
452 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
453 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
454 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
455 cm++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
458 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
459 }
2086
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 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
462 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
463 struct conversation *c = irc_find_chat(gc, room);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
464 GList *r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
466 if (mode != 'o' && mode != 'v')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
467 return;
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 (!c)
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 r = c->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
473 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
474 gboolean op = FALSE, voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
475 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
476 if (*who == '@') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
477 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
478 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
480 if (*who == '+') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
481 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
482 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
484 if (!strcmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
485 char *tmp, buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
486 if (mode == 'o') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
487 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
488 op = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
489 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
490 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
491 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
492 if (mode == 'v') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
493 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
494 voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
495 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
496 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
497 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
498 tmp = g_strdup(r->data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
499 g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
500 voice ? "+" : "", nick);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
501 rename_chat_buddy(c, tmp, buf);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
502 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
503 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
505 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
506 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
507 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
509 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
510 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
511 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
512 int offset = n324 ? 4 : 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
513 char *chan = word[offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
514 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
515 char *modes = word[offset + 1];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
516 int len = strlen(word_eol[offset]) - 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
517 char sign = *modes++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
518 int arg = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
519 char *argstr;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
520
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
521 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
522 return;
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 (word_eol[offset][len] == ' ')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
525 word_eol[offset][len] = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
527 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
528 switch (*modes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
529 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
530 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
531 case '+':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
532 case '-':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
533 sign = *modes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
534 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
535 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
536 if (mode_has_arg(gc, sign, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
537 argstr = word[++arg + offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
538 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
539 argstr = "";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
540 if (strchr(id->nickmodes, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
541 irc_user_mode(gc, chan, sign, *modes, argstr);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
542 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
543 modes++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 }
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
546
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
547 /* 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
548 * 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
549 * some medicine, or perhaps I should go to bed? Blah!! */
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
550
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
551 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
552 {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
553 struct irc_data *id = gc->proto_data;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
554 char tmp[1024];
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 if (!id->in_whois) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
557 id->in_whois = TRUE;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
558 id->whois_str = g_string_new("");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
559 } else {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
560 /* 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
561 id->whois_str = g_string_append(id->whois_str, "<BR>");
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
562 id->in_whois = TRUE;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
563 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
564
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
565 switch (num) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
566 case 311:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
567 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
568 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
569 case 312:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
570 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
571 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
572 case 313:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
573 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
574 id->whois_str = g_string_append(id->whois_str, tmp);
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
575 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
576
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
577 case 317:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
578 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
579 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
580 case 319:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
581 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
582 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
583 default:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
584 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
585 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
586
2650
0425dbe29272 [gaim-migrate @ 2663]
Rob Flynn <gaim@robflynn.com>
parents: 2649
diff changeset
587 id->whois_str = g_string_append(id->whois_str, word_eol[5] + (word_eol[5][0]==':'));
2648
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 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
590
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
591 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
592 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
593 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
594 char *text = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
595 int n = atoi(word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
596
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
597 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname)))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
598 text += strlen(gc->displayname) + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
599 if (*text == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
600 text++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
602 switch (n) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
603 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
604 if (!strncmp(word[5], "u2.10", 5))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
605 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
606 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
607 id->six_modes = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
608 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
609 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
610 handle_005(gc, word, word_eol);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
611 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
612 case 301:
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
613 if (id->in_whois) {
2649
f857ae4ddd84 [gaim-migrate @ 2662]
Rob Flynn <gaim@robflynn.com>
parents: 2648
diff changeset
614 id->whois_str = g_string_append(id->whois_str, "<BR><b>Away: </b>");
2650
0425dbe29272 [gaim-migrate @ 2663]
Rob Flynn <gaim@robflynn.com>
parents: 2649
diff changeset
615 id->whois_str = g_string_append(id->whois_str, word_eol[5] + (word_eol[5][0]==':'));
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
616 } else
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
617 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
618 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
619 case 303:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
620 handle_list(gc, &word_eol[4][1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
621 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
622 case 311:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
623 case 312:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
624 case 313:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
625 case 317:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
626 case 319:
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
627 handle_whois(gc, word, word_eol, n);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
628 break;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
629 case 318:
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
630 /*
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
631 id->whois_str = g_string_append(id->whois_str, "<BR><BR>");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
632 id->whois_str = g_string_append(id->whois_str, word_eol[4]);
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
633 */
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
634
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
635 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
636 GString *str = decode_html(id->whois_str->str);
2620
a1b708ee93af [gaim-migrate @ 2633]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2619
diff changeset
637 g_show_info_text(str->str, NULL);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
638 g_string_free(str, TRUE);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
639 }
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
640
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
641 g_string_free(id->whois_str, TRUE);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
642 id->whois_str = NULL;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
643 id->in_whois = FALSE;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
644 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
645 case 324:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
646 handle_mode(gc, word, word_eol, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
647 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
648 case 332:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
649 handle_topic(gc, text);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
650 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
651 case 353:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
652 handle_names(gc, word[5], word_eol[6]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
653 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
654 case 376:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
655 irc_request_buddy_update(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
656 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
657 case 401:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
658 case 402:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
659 case 431:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
660 if (!id->in_whois) {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
661 id->in_whois = TRUE;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
662 id->whois_str = g_string_new("");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
663 } else {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
664 id->whois_str = g_string_append(id->whois_str, "<BR><BR>");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
665 id->in_whois = TRUE;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
666 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
667 id->whois_str = g_string_append(id->whois_str, word_eol[4]);
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);
2312
766603034af8 [gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2310
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
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
781 static void irc_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 struct gaim_connection *gc = data;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
784 struct irc_data *idata = gc->proto_data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 int i = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
786 gchar d[IRC_BUF_LEN], *buf = d;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
787 gchar outbuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
788 char *word[PDIWORDS], *word_eol[PDIWORDS];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
789 char pdibuf[522];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
790 char *ex, ip[128], nick[128];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
791 char *cmd;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
793 if (!idata->online) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
794 /* Now lets sign ourselves on */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
795 account_online(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
796 serv_finish_login(gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
798 if (bud_list_cache_exists(gc))
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2339
diff changeset
799 do_import(gc, NULL);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
800
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
801 /* we don't call this now because otherwise some IRC servers might not like us */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
802 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
803 idata->online = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
804 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 do {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
807 if (read(idata->fd, buf + i, 1) <= 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 hide_login_progress(gc, "Read error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 } while (buf[i++] != '\n');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814 buf[--i] = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 g_strchomp(buf);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
816 debug_printf("IRC S: %s\n", buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 /* Check for errors */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
820 if (*buf != ':') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
821 if (!strncmp(buf, "NOTICE ", 7))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
822 buf += 7;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
823 if (!strncmp(buf, "PING ", 5)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
824 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
825 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
826 hide_login_progress(gc, _("Unable to write"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
827 signoff(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
828 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
829 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
831 /* XXX doesn't handle ERROR */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
835 buf++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
837 process_data_init(pdibuf, buf, word, word_eol, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
839 if (atoi(word[2])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
840 if (*word_eol[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
841 process_numeric(gc, word, word_eol);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
845 cmd = word[2];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
847 ex = strchr(pdibuf, '!');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
848 if (!ex) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
849 strncpy(ip, pdibuf, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
850 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
851 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
852 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
853 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
854 strncpy(ip, ex + 1, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
855 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
856 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
857 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
858 if ((ex - pdibuf) < sizeof (nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
859 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
862 if (!strcmp(cmd, "INVITE")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
863 } else if (!strcmp(cmd, "JOIN")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
864 char *chan = *word[3] == ':' ? word[3] + 1 : word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
865 if (!g_strcasecmp(gc->displayname, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
866 static int id = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
867 serv_got_joined_chat(gc, id++, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
868 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
869 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
870 if (c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
871 add_chat_buddy(c, nick);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
873 } else if (!strcmp(cmd, "KICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
874 if (!strcmp(gc->displayname, word[4])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
875 struct conversation *c = irc_find_chat(gc, word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
876 if (!c)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 return;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
878 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
879 c->gc = NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
880 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
881 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
882 do_error_dialog(outbuf, _("IRC Error"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
883 } else
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
884 irc_rem_chat_bud(gc, word[4]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
885 } else if (!strcmp(cmd, "KILL")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
886 } else if (!strcmp(cmd, "MODE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
887 handle_mode(gc, word, word_eol, FALSE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
888 } else if (!strcmp(cmd, "NICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
889 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
890 if (!strcmp(gc->displayname, nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
891 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
892 irc_change_name(gc, nick, new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
893 } else if (!strcmp(cmd, "NOTICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
894 if (*word_eol[4] == ':') word_eol[4]++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
895 if (ex)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
896 irc_got_im(gc, nick, word_eol[4], 0, time(NULL));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
897 } else if (!strcmp(cmd, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
898 char *chan = cmd + 5;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
899 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
900 GList *r;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
901 if (*chan == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
902 chan++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
903 if (!(c = irc_find_chat(gc, chan)))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
904 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
905 if (!strcmp(nick, gc->displayname)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
906 serv_got_chat_left(gc, c->id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
907 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
909 r = c->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
910 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
911 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
912 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
913 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
914 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
915 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
916 if (!g_strcasecmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
917 char *tmp = g_strdup(r->data);
2291
5e35b4c63c2c [gaim-migrate @ 2301]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2290
diff changeset
918 remove_chat_buddy(c, tmp);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
919 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
920 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
921 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
922 r = r->next;
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, "PRIVMSG")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
925 char *to, *msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
926 if (!*word[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
927 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
928 to = word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
929 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
930 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
931 if (!g_strncasecmp(msg + 1, "DCC ", 4))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
932 process_data_init(pdibuf, buf, word, word_eol, TRUE);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
933 handle_ctcp(gc, to, nick, msg + 1, word, word_eol);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
934 } else {
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
935 handle_privmsg(gc, to, nick, msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
937 } else if (!strcmp(cmd, "PONG")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
938 } else if (!strcmp(cmd, "QUIT")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
939 irc_rem_chat_bud(gc, nick);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
940 } else if (!strcmp(cmd, "TOPIC")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
941 struct conversation *c = irc_find_chat(gc, word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
942 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
943 if (c) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
944 char buf[IRC_BUF_LEN];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
945 chat_set_topic(c, nick, topic);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
946 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
947 nick, topic);
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
948 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL));
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
949 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
950 } else if (!strcmp(cmd, "WALLOPS")) { /* */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
954 static void irc_login_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
957 struct irc_data *idata;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
958 char hostname[256];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
959 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 if (!g_slist_find(connections, gc)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 close(source);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 idata = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 if (source == -1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 if (idata->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 idata->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
977 gethostname(hostname, sizeof(hostname) - 1);
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
978 hostname[sizeof(hostname) - 1] = 0;
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
979 if (!*hostname)
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
980 g_snprintf(hostname, sizeof(hostname), "localhost");
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
981 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
982 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
983 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
984 hide_login_progress(gc, "Write error");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
985 signoff(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
986 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
987 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
989 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
990 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
996 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
997 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999 static void irc_login(struct aim_user *user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1001 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 struct gaim_connection *gc = new_gaim_conn(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 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
1005
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1006 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1007
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 set_login_progress(gc, 2, buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1011 idata->chantypes = g_strdup("#&!+");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1012 idata->chanmodes = g_strdup("beI,k,l");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1013 idata->nickmodes = g_strdup("ohv");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1014 idata->str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1015
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV],
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 user->proto_opt[USEROPT_PORT][0] ? atoi(user->
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018 proto_opt[USEROPT_PORT]) :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 6667, irc_login_callback, gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020 if (!user->gc || (idata->fd < 0)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 hide_login_progress(gc, "Unable to create socket");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1027 static void irc_close(struct gaim_connection *gc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1028 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1029 struct irc_data *idata = (struct irc_data *)gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1030 gchar buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1031
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
1032 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
1033 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1034
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1035 g_free(idata->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1036 g_free(idata->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1037 g_free(idata->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1038
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1039 g_string_free(idata->str, TRUE);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1040 if (idata->whois_str)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1041 g_string_free(idata->whois_str, TRUE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1042
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1043 if (idata->timer)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1044 g_source_remove(idata->timer);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1045
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1046 if (gc->inpa)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1047 gaim_input_remove(gc->inpa);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1048
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1049 close(idata->fd);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1050 g_free(gc->proto_data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1051 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1052
2154
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1053 static GList *irc_user_opts()
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 {
2154
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1055 GList *m = NULL;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1056 struct proto_user_opt *puo;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1057
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1058 puo = g_new0(struct proto_user_opt, 1);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1059 puo->label = "Server:";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1060 puo->def = "irc.mozilla.org";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1061 puo->pos = USEROPT_SERV;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1062 m = g_list_append(m, puo);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1063
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1064 puo = g_new0(struct proto_user_opt, 1);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1065 puo->label = "Port:";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1066 puo->def = "6667";
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1067 puo->pos = USEROPT_PORT;
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1068 m = g_list_append(m, puo);
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1069
cff133e0ec0c [gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2147
diff changeset
1070 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1073 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
1074 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1076 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1077 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1078 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1079 int i = start;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1080
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1081 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1082 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1083 switch (left) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1084 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1085 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1086 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1087 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
1088 who, sign, mode, word[i]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1089 i += 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1090 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1091 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1092 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
1093 who, sign, mode, mode, word[i], word[i + 1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1094 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1095 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1096 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1097 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
1098 who, sign, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1099 word[i], word[i + 1], word[i + 2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1100 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1101 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1102 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1103 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1104 if (left < 3)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1105 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1106 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1109 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
1110 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1112 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1113 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1114 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1115 int i = start;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1117 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1118 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1119 switch (left) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1120 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1121 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1122 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1123 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
1124 who, sign, mode, word[i]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1125 i += 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1126 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1127 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1128 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
1129 who, sign, mode, mode, word[i], word[i + 1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1130 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1131 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1132 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1133 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
1134 who, sign, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1135 word[i], word[i + 1], word[i + 2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1136 i += 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1137 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1138 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1139 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
1140 who, sign, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1141 word[i], word[i + 1], word[i + 2], word[i + 3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1142 i += 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1143 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1144 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1145 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
1146 who, sign, mode, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1147 word[i], word[i + 1], word[i + 2],
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1148 word[i + 3], word[i + 4]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1149 i += 5;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1150 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1151 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1152 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
1153 who, sign, mode, mode, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1154 word[i], word[i + 1], word[i + 2],
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1155 word[i + 3], word[i + 4], word[i + 5]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1156 i += 6;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1157 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1158 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1159 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1160 if (left < 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1161 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1162 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1163 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1165 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
1166 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1167 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1168 int i = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1169
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1170 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1171 if (!*word[i]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1172 if (i == 2)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1173 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1174 if (id->six_modes)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1175 set_mode_6(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1176 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1177 set_mode_3(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1178 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1179 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1180 i++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1181 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1184 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
1185 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1186 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1187 char pdibuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1188 char *word[PDIWORDS], *word_eol[PDIWORDS];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1189 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1190 if (*what != '/') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1191 unsigned int max = 440 - strlen(who);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1192 char t;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1193 while (strlen(what) > max) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1194 t = what[max];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1195 what[max] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1196 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
1197 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1198 what[max] = t;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1199 what = what + max;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1200 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1201 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
1202 irc_write(id->fd, buf, strlen(buf));
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1203 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1204 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1205
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1206 what++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1207 process_data_init(pdibuf, what, word, word_eol, TRUE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1209 if (!g_strcasecmp(pdibuf, "ME")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1210 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
1211 irc_write(id->fd, buf, strlen(buf));
2304
15fb364935ec [gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2303
diff changeset
1212 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1213 } else if (!g_strcasecmp(pdibuf, "TOPIC")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1214 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1215 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1216 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
1217 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1218 } else if (!g_strcasecmp(pdibuf, "NICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1219 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1220 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1221 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
1222 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1223 } else if (!g_strcasecmp(pdibuf, "OP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1224 set_mode(gc, who, '+', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1225 } else if (!g_strcasecmp(pdibuf, "DEOP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1226 set_mode(gc, who, '-', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1227 } else if (!g_strcasecmp(pdibuf, "VOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1228 set_mode(gc, who, '+', 'v', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1229 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1230 set_mode(gc, who, '-', 'v', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1231 } else if (!g_strcasecmp(pdibuf, "QUOTE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1232 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1233 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1234 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1235 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1236 } else if (!g_strcasecmp(pdibuf, "SAY")) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1237 if (!*word_eol[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1238 return -EINVAL;
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1239 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
1240 irc_write(id->fd, buf, strlen(buf));
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1241 return 1;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1242 } else if (!g_strcasecmp(pdibuf, "MSG")) {
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1243 if (!*word[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1244 return -EINVAL;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1245 if (!*word_eol[3])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1246 return -EINVAL;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1247 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
1248 irc_write(id->fd, buf, strlen(buf));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1249 } else if (!g_strcasecmp(pdibuf, "KICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1250 if (!*word[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1251 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1252 if (*word_eol[3])
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
1253 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
1254 else
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
1255 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
1256 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1257 } else if (!g_strcasecmp(pdibuf, "JOIN")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1258 if (!*word[2])
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1259 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1260 if (*word[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1261 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
1262 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1263 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1264 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1265 } else if (!g_strcasecmp(pdibuf, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1266 char *chan = *word[2] ? word[2] : who;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1267 char *reason = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1268 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1269 if (!is_channel(gc, chan))
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1270 return -EINVAL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1271 c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1272 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
1273 *reason ? " :" : "",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1274 *reason ? reason : "");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1275 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1276 if (c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1277 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1278 c->gc = NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1279 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1280 do_error_dialog(buf, _("IRC Part"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1281 }
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1282 } else if (!g_strcasecmp(pdibuf, "WHOIS")) {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1283 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
1284 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1285 } else if (!g_strcasecmp(pdibuf, "HELP")) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1286 struct conversation *c = NULL;
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1287 if (is_channel(gc, who)) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1288 c = irc_find_chat(gc, who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1289 } else {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1290 c = find_conversation(who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1291 }
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1292 if (!c)
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1293 return -EINVAL;
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1294 write_to_conv(c, "<B>Currently supported commands:<BR>"
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1295 "JOIN PART TOPIC WHOIS<BR>"
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1296 "OP DEOP VOICE DEVOICE KICK<BR>"
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1297 "NICK ME MSG QUOTE SAY</B>",
2459
a25223b2c29b [gaim-migrate @ 2472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2413
diff changeset
1298 WFLAG_NOLOG, NULL, time(NULL));
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1299 } else {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1300 struct conversation *c = NULL;
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1301 if (is_channel(gc, who)) {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1302 c = irc_find_chat(gc, who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1303 } else {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1304 c = find_conversation(who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1305 }
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1306 if (!c)
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1307 return -EINVAL;
2459
a25223b2c29b [gaim-migrate @ 2472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2413
diff changeset
1308 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
1309 }
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1310
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1311 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1314 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
1315 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1316 char *cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1317 if (cr) {
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1318 int ret = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1319 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1320 if (cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1321 *cr = 0;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1322 ret = handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1323 if (!cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1324 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1325 what = cr + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1326 if (!*what)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1327 break;
2295
24dc9ce95127 [gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2294
diff changeset
1328 *cr = '\n';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1329 cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1330 }
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1331 return ret;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1332 } else
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1333 return handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1334 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1335
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1336 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
1337 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1338 if (*who == '@' || *who == '+')
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1339 return send_msg(gc, who + 1, what);
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1340 return send_msg(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1341 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1342
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1343 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1344 static void irc_fake_buddy(struct gaim_connection *gc, char *who) {}
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1345
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1346 static GList *irc_chat_info(struct gaim_connection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1348 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1349 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1350
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1351 pce = g_new0(struct proto_chat_entry, 1);
2466
f8eb5f120603 [gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2459
diff changeset
1352 pce->label = _("Channel:");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1353 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1354
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1355 pce = g_new0(struct proto_chat_entry, 1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1356 pce->label = _("Password:");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1357 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1358
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1359 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1361
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1362 static void irc_join_chat(struct gaim_connection *gc, GList *data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1363 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1364 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1365 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1366 char *name, *pass;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1367
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1368 if (!data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1369 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1370 name = data->data;
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
1371 if (data->next) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1372 pass = data->next->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1373 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
1374 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1375 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1376 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1377 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1378
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1379 static void irc_chat_leave(struct gaim_connection *gc, int id)
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 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1382 struct conversation *c = irc_find_chat_by_id(gc, id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1383 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1384
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1385 if (!c) return;
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 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1388 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1389 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1390
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1391 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
1392 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1393 struct conversation *c = irc_find_chat_by_id(gc, id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1394 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1395 return -EINVAL;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1396 if (send_msg(gc, c->name, what) > 0)
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1397 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
1398 return 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1399 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1400
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2466
diff changeset
1401 static GList *irc_away_states(struct gaim_connection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1402 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1403 return g_list_append(NULL, GAIM_AWAY_CUSTOM);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1404 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1405
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 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
1407 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1408 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1409 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1411 if (gc->away)
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1412 gc->away = NULL;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1413
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1414 if (msg) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1415 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg);
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1416 gc->away = "";
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1417 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1418 g_snprintf(buf, sizeof(buf), "AWAY\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1419 irc_write(idata->fd, buf, strlen(buf));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1422 static char **irc_list_icon(int uc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1424 return irc_icon_xpm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1427 static void irc_get_info(struct gaim_connection *gc, char *who)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1428 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1429 struct irc_data *idata = gc->proto_data;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1430 char buf[IRC_BUF_LEN];
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1431
2633
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1432 if (*who == '@')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1433 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1434 if (*who == '+')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1435 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
1436
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1437 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1438 irc_write(idata->fd, buf, strlen(buf));
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1439 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1440
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1441 static GList *irc_buddy_menu(struct gaim_connection *gc, char *who)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1442 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1443 GList *m = NULL;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1444 struct proto_buddy_menu *pbm;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1445
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1446 pbm = g_new0(struct proto_buddy_menu, 1);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1447 pbm->label = _("Get Info");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1448 pbm->callback = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1449 pbm->gc = gc;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1450 m = g_list_append(m, pbm);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1451
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1452 return m;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1453 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1454
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1455 static struct prpl *my_protocol = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457 void irc_init(struct prpl *ret)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459 ret->protocol = PROTO_IRC;
2100
a93aeb6f813d [gaim-migrate @ 2110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
1460 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461 ret->name = irc_name;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1462 ret->user_opts = irc_user_opts;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1463 ret->list_icon = irc_list_icon;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1464 ret->login = irc_login;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 ret->close = irc_close;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466 ret->send_im = irc_send_im;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1467 ret->add_buddy = irc_fake_buddy;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1468 ret->remove_buddy = irc_fake_buddy;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
1469 ret->chat_info = irc_chat_info;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 ret->join_chat = irc_join_chat;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 ret->chat_leave = irc_chat_leave;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472 ret->chat_send = irc_chat_send;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1473 ret->away_states = irc_away_states;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1474 ret->set_away = irc_set_away;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1475 ret->get_info = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1476 ret->buddy_menu = irc_buddy_menu;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1477 my_protocol = ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1478 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480 #ifndef STATIC
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1481
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1482 char *gaim_plugin_init(GModule *handle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484 load_protocol(irc_init, sizeof(struct prpl));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1486 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1487
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1488 void gaim_plugin_remove()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1490 struct prpl *p = find_prpl(PROTO_IRC);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491 if (p == my_protocol)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1492 unload_protocol(p);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1493 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1494
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1495 char *name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1496 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1497 return "IRC";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1498 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1499
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1500 char *description()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1501 {
2162
a464da684307 [gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2154
diff changeset
1502 return PRPL_DESC("IRC");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503 }
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 #endif