annotate src/protocols/irc/irc.c @ 3665:7cb6cf20ed7d

[gaim-migrate @ 3794] fixed warnings committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Sun, 13 Oct 2002 16:35:14 +0000
parents c084394b86de
children c1254110070a
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
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
28 #ifndef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
29 #include <unistd.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
30 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
31 #include <winsock.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
32 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
33
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
34 #include <fcntl.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <errno.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <string.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include <stdlib.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include <stdio.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include <time.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include <sys/stat.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #include <ctype.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #include "multi.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include "gaim.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #include "proxy.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
47 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
48 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
49 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
50
3580
8e4e3eacb45e [gaim-migrate @ 3682]
Sean Egan <seanegan@gmail.com>
parents: 3575
diff changeset
51 #include "pixmaps/protocols/irc/irc_icon.xpm"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #define IRC_BUF_LEN 4096
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
54 #define PDIWORDS 32
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #define USEROPT_SERV 0
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #define USEROPT_PORT 1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
59 /* for win32 compatability */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
60 G_MODULE_IMPORT GSList *connections;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
61
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
62
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
63 struct dcc_chat
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
64 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
65 struct gaim_connection *gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
66 char ip_address[12];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
67 int port;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
68 int fd;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
69 int inpa;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
70 char nick[80];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
71 };
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
72
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
73 struct irc_file_transfer {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
74 enum { IFT_SENDFILE_IN, IFT_SENDFILE_OUT } type;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
75 struct file_transfer *xfer;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
76 char *sn;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
77 char *name;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
78 int len;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
79 int watcher;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
80 int awatcher;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
81 char ip[12];
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
82 int port;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
83 int fd;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
84 int cur;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
85 struct gaim_connection *gc;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
86 };
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
87
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
88 GSList *dcc_chat_list = NULL;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
89
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 struct irc_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 int fd;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
92 gboolean online;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
93 guint32 timer;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
95 char *rxqueue;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
96 int rxlen;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
97
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
98 GString *str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
99 int bc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
101 char *chantypes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
102 char *chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
103 char *nickmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
104 gboolean six_modes;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
105
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
106 gboolean in_whois;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
107 gboolean in_list;
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
108 GString *liststr;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
109 GSList *file_transfers;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
112 struct dcc_chat *
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
113 find_dcc_chat (struct gaim_connection *gc, char *nick)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
114 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
115 GSList *tmp;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
116 struct dcc_chat *data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
117 tmp = dcc_chat_list;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
118 while (tmp != NULL)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
119 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
120 data = (struct dcc_chat *) (tmp)->data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
121 if (data
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
122 && data->nick
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
123 && strcmp (nick, data->nick) == 0
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
124 && gc == data->gc)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
125 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
126 return data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
127 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
128 tmp = tmp->next;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
129 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
130 return NULL;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
131 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
132
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
133 static int irc_write(int fd, char *data, int len)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
134 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
135 debug_printf("IRC C: %s", data);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
136 #ifndef _WIN32
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
137 return write(fd, data, len);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
138 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
139 return send(fd, data, len, 0);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
140 #endif
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
141 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
142
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
143 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
144 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
145 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
147 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
148 struct conversation *b = bcs->data;
2331
1ea2792b6004 [gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2328
diff changeset
149 if (!g_strcasecmp(b->name, name))
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
150 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
151 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
152 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
153 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
154 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
155
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
156 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
157 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
158 GSList *bcs = gc->buddy_chats;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
159
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
160 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
161 struct conversation *b = bcs->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
162 if (b->id == id)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
163 return b;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
164 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
165 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
166 return NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
167 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
168
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
169 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
170 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
171 int wordcount = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
172 gboolean space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
173 gboolean quote = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
174 int j = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
175
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
176 word[1] = cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
177 eol[1] = buf;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
178
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
179 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
180 switch (*cmd) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
181 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
182 buf[j] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
183 for (j = wordcount; j < PDIWORDS; j++) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
184 word[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
185 eol[j] = "\000\000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
186 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
187 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
188 case '"':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
189 if (!quotes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
190 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
191 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
192 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
193 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
194 quote = !quote;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
195 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
196 case ' ':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
197 if (quote) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
198 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
199 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
200 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
201 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
202 if (space)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
203 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
204 buf[j++] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
205 word[wordcount] = &buf[j];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
206 eol[wordcount++] = cmd + 1;
2294
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
207 if (wordcount == PDIWORDS - 1) {
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
208 buf[j] = 0;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
209 return;
b6c6603a8915 [gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2293
diff changeset
210 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
211 space = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
212 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
213 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
214 space = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
215 buf[j++] = *cmd;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
216 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
217 cmd++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
218 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
219 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
220
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
221 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
222 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
223 int w = 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
224 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
225
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
226 while (w < PDIWORDS && *word[w]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
227 if (!strncmp(word[w], "MODES=", 5)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
228 if (atoi(word[w] + 6) >= 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
229 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
230 } else if (!strncmp(word[w], "CHANTYPES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
231 g_free(id->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
232 id->chantypes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
233 } else if (!strncmp(word[w], "CHANMODES=", 10)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
234 g_free(id->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
235 id->chanmodes = g_strdup(word[w] + 10);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
236 } else if (!strncmp(word[w], "PREFIX=", 7)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
237 char *pre = strchr(word[w] + 7, ')');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
238 if (pre) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
239 *pre = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
240 g_free(id->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
241 id->nickmodes = g_strdup(word[w] + 8);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
242 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
243 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
244 w++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
245 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
246 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
247
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
248 static char *int_to_col(int c)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
250 switch(c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
251 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
252 return "#ffffff";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
253 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
254 return "#000066";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
255 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
256 return "#006600";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
257 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
258 return "#ff0000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
259 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
260 return "#660000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
261 case 6:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
262 return "#660066";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
263 case 7:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
264 return "#666600";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
265 case 8:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
266 return "#cccc00";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
267 case 9:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
268 return "#33cc33";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
269 case 10:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
270 return "#00acac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
271 case 11:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
272 return "#00ccac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
273 case 12:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
274 return "#0000ff";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
275 case 13:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
276 return "#cc00cc";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
277 case 14:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
278 return "#666666";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
279 case 15:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
280 return "#00ccac";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
281 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
282 return "#000000";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
283 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
286 static GString *encode_html(char *msg)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
287 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
288 GString *str = g_string_new("");
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
289 char *cur = msg, *end = msg;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
290 gboolean bold = FALSE, underline = FALSE, italics = FALSE;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
291
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
292 while ((end = strchr(cur, '<'))) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
293 *end = 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
294 str = g_string_append(str, cur);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
295 cur = ++end;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
296 if (!g_strncasecmp(cur, "B>", 2)) {
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
297 if (!bold) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
298 bold = TRUE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
299 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
300 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
301 cur = cur + 2;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
302 } else if (!g_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
303 if (!italics) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
304 italics = TRUE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
305 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
306 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
307 cur = cur + 2;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
308 } else if (!g_strncasecmp(cur, "U>", 2)) {
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
309 if (!underline) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
310 underline = TRUE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
311 str = g_string_append_c(str, '\37');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
312 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
313 cur = cur + 2;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
314 } else if (!g_strncasecmp(cur, "/B>", 3)) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
315 if (bold) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
316 bold = FALSE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
317 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
318 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
319 cur = cur + 3;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
320 } else if (!g_strncasecmp(cur, "/I>", 3)) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
321 if (italics) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
322 italics = FALSE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
323 str = g_string_append_c(str, '\2');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
324 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
325 cur = cur + 3;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
326 } else if (!g_strncasecmp(cur, "/U>", 3)) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
327 if (underline) {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
328 underline = FALSE;
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
329 str = g_string_append_c(str, '\37');
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
330 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
331 cur = cur + 3;
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
332 } else {
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
333 str = g_string_append_c(str, '<');
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
334 }
3063
22c84cbcd5a6 [gaim-migrate @ 3077]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
335
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
336 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
337 str = g_string_append(str, cur);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
338 return str;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
339 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
340
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
341 static GString *decode_html(char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
343 GString /* oo la la */ *str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
344 char *cur = msg, *end = msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
345 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
346 int fore, back;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
347 while (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
348 switch (*end) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
349 case 02: /* ^B */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
350 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
351 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
352 if (bold)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
353 str = g_string_append(str, "</B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
354 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
355 str = g_string_append(str, "<B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
356 bold = !bold;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
357 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
358 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
359 case 03: /* ^C */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
360 *end++ = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
361 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
362 fore = back = -1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
363 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
364 fore = *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
365 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
366 fore *= 10;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
367 fore += *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
368 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
369 if (*end == ',' && isdigit(end[1])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
370 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
371 back = *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
372 if (isdigit(*end)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
373 back *= 10;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
374 back += *end++ - '0';
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
375 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
376 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
377 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
378 if (fore == -1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
379 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
380 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
381 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
382 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
383 fg = bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
384 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
385 fore %= 16;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
386 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
387 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
388 if (back != -1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
389 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
390 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
391 back %= 16;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
392 str = g_string_append(str, "<FONT BACK=");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
393 str = g_string_append(str, int_to_col(back));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
394 str = g_string_append_c(str, '>');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
395 bg = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
396 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
397 str = g_string_append(str, "<FONT COLOR=");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
398 str = g_string_append(str, int_to_col(fore));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
399 str = g_string_append_c(str, '>');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
400 fg = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
401 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
402 cur = end--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
403 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
404 case 017: /* ^O */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
405 if (!bold && !underline && !fg && !bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
406 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
407 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
408 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
409 if (bold)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
410 str = g_string_append(str, "</B>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
411 if (underline)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
412 str = g_string_append(str, "</U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
413 if (fg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
414 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
415 if (bg)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
416 str = g_string_append(str, "</FONT>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
417 bold = underline = fg = bg = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
418 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
419 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
420 case 037: /* ^_ */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
421 *end = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
422 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
423 if (underline)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
424 str = g_string_append(str, "</U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
425 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
426 str = g_string_append(str, "<U>");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
427 underline = !underline;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
428 cur = end + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
429 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
430 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
431 end++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
432 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
433 if (*cur)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
434 str = g_string_append(str, cur);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
435 return str;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
436 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
438 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
439 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
440 GString *str = decode_html(what);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2847
diff changeset
441 serv_got_im(gc, who, str->str, flags, t, -1);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
442 g_string_free(str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
443 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
444
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
445 static void dcc_chat_cancel(void *, struct dcc_chat *);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
446
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
447 void
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
448 dcc_chat_in (gpointer data, gint source, GaimInputCondition condition)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
449 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
450 struct dcc_chat *chat = data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
451 gchar buffer[IRC_BUF_LEN];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
452 gchar buf[128];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
453 int n = 0, l;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
454 struct conversation *convo;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
455 debug_printf("THIS IS TOO MUCH EFFORT\n");
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
456 #ifndef _WIN32
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
457 n = read (chat->fd, buffer, IRC_BUF_LEN);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
458 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
459 n = recv (chat->fd, buffer, IRC_BUF_LEN, 0);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
460 #endif
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
461 if (n > 0)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
462 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
463
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
464 /* Strip the terminating \n */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
465 l = 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
466 while (buffer[l] && buffer[l] != '\n' && l <= n)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
467 l++;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
468 buffer[l] = '\000';
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
469
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
470 /* Convert to HTML */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
471 debug_printf ("DCC Message from: %s\n", chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
472 irc_got_im(chat->gc, chat->nick, buffer, 0, time(NULL));
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
473 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
474
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
475 else {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
476 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"),
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
477 chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
478 convo = new_conversation (chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
479 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL,
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
480 time ((time_t) NULL), -1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
481 dcc_chat_cancel (NULL,chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
482 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
483 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
484
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
485 static void irc_file_transfer_do(struct gaim_connection *gc, struct irc_file_transfer *ift) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
486 /* Ok, we better be receiving some crap here boyeee */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
487 if (transfer_in_do(ift->xfer, ift->fd, ift->name, ift->len)) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
488 gaim_input_remove(ift->watcher);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
489 ift->watcher = 0;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
490 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
491 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
492
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
493
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
494 void irc_read_dcc_ack (gpointer data, gint source, GaimInputCondition condition) {
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
495 /* Read ACK Here */
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
496
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
497 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
498
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
499 void dcc_send_callback (gpointer data, gint source, GaimInputCondition condition) {
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
500 struct irc_file_transfer *ift = data;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
501 struct sockaddr_in addr;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
502 int len = sizeof(addr);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
503
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
504 addr.sin_family = AF_INET;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
505 addr.sin_port = htons(ift->port);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
506 addr.sin_addr.s_addr = INADDR_ANY;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
507
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
508 ift->fd = accept(ift->fd, (struct sockaddr *)&addr, &len);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
509 if (!ift->fd) {
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
510 /* FIXME: Handle this gracefully XXX */
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
511 printf("Something bad happened here, bubba!\n");
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
512 return;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
513 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
514
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
515 /* ift->awatcher = gaim_input_add(ift->fd, GAIM_INPUT_READ, irc_read_dcc_ack, ift); */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
516
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
517 if (transfer_out_do(ift->xfer, ift->fd, 0)) {
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
518 gaim_input_remove(ift->watcher);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
519 ift->watcher = 0;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
520 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
521 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
522
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
523 void dcc_recv_callback (gpointer data, gint source, GaimInputCondition condition) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
524 struct irc_file_transfer *ift = data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
525
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
526 ift->fd = source;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
527 irc_file_transfer_do(ift->gc, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
528 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
529
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
530 void dcc_chat_callback (gpointer data, gint source, GaimInputCondition condition) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
531 struct dcc_chat *chat = data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
532 struct conversation *convo = new_conversation (chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
533 char buf[IRC_BUF_LEN];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
534 chat->fd = source;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
535 g_snprintf (buf, sizeof buf,
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
536 "DCC Chat with %s established",
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
537 chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
538 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL,
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
539 time ((time_t) NULL), -1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
540 debug_printf ("Chat with %s established\n", chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
541 dcc_chat_list = g_slist_append (dcc_chat_list, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
542 gaim_input_remove(chat->inpa);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
543 chat->inpa = gaim_input_add(source, GAIM_INPUT_READ, dcc_chat_in, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
544 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
545
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
546 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
547 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
548 GString *str = decode_html(msg);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
549 serv_got_chat_in(gc, id, who, whisper, str->str, t);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
550 g_string_free(str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
551 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
552
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
553 static void handle_list(struct gaim_connection *gc, char *list)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
554 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
555 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
556 GSList *gr;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
557
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
558 id->str = g_string_append_c(id->str, ' ');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
559 id->str = g_string_append(id->str, list);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
560 id->bc--;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
561 if (id->bc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
562 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
563
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
564 g_strdown(id->str->str);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
565 gr = gc->groups;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
566 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
567 GSList *m = ((struct group *)gr->data)->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
568 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
569 struct buddy *b = m->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
570 char *tmp = g_strdup(b->name);
3028
0e6577e8bd1d [gaim-migrate @ 3041]
Sean Egan <seanegan@gmail.com>
parents: 2918
diff changeset
571 char *x, *l;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
572 g_strdown(tmp);
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
573 x = strstr(id->str->str, tmp);
3028
0e6577e8bd1d [gaim-migrate @ 3041]
Sean Egan <seanegan@gmail.com>
parents: 2918
diff changeset
574 l = x + strlen(b->name);
0e6577e8bd1d [gaim-migrate @ 3041]
Sean Egan <seanegan@gmail.com>
parents: 2918
diff changeset
575 if (x && (*l != ' ' && *l != 0))
0e6577e8bd1d [gaim-migrate @ 3041]
Sean Egan <seanegan@gmail.com>
parents: 2918
diff changeset
576 x = 0;
2310
b2db2a76dcec [gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2305
diff changeset
577 if (!b->present && x)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
578 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
579 else if (b->present && !x)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
580 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
581 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
582 m = m->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
584 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
586 g_string_free(id->str, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
587 id->str = g_string_new("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
590 static gboolean irc_request_buddy_update(gpointer data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591 {
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
592 struct gaim_connection *gc = data;
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 buf[500];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
595 int n = g_snprintf(buf, sizeof(buf), "ISON");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
597 GSList *gr = gc->groups;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
598 if (!gr || id->bc)
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
599 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
601 while (gr) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
602 struct group *g = gr->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
603 GSList *m = g->members;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
604 while (m) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
605 struct buddy *b = m->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
606 if (n + strlen(b->name) + 2 > sizeof(buf)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
607 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
608 irc_write(id->fd, buf, n);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
609 id->bc++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
610 n = g_snprintf(buf, sizeof(buf), "ISON");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
611 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
612 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
613 m = m->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
614 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
615 gr = gr->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
617 g_snprintf(buf + n, sizeof(buf) - n, "\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
618 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
619 id->bc++;
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
620 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
623 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
624 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
625 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
626 char **buf, **tmp;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
627 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
628 if (*names == ':') names++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
629 buf = g_strsplit(names, " ", -1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
630 for (tmp = buf; *tmp; tmp++)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
631 add_chat_buddy(c, *tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
632 g_strfreev(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
635 static void handle_topic(struct gaim_connection *gc, char *text)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
637 struct conversation *c;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
638 char *po = strchr(text, ' ');
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
640 if (!po)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
641 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
643 *po = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
644 po += 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
646 if ((c = irc_find_chat(gc, text))) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
647 char buf[IRC_BUF_LEN];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
648 chat_set_topic(c, NULL, po);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
649 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
650 text, po);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2847
diff changeset
651 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL), -1);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
652 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
655 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
656 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
657 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
658 char *cm = id->chanmodes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
659 int type = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
661 if (strchr(id->nickmodes, mode))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
662 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
664 while (*cm) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
665 if (*cm == ',')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
666 type++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
667 else if (*cm == mode) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
668 switch (type) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
669 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
670 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
671 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
672 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
673 if (sign == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
674 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
675 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
676 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
677 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
678 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
679 cm++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680 }
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 return FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
683 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
685 static void irc_chan_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *argstr, char *who)
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
686 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
687 struct conversation *c = irc_find_chat(gc, room);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
688 char buf[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
689 char *nick = g_strndup(who, strchr(who, '!') - who);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
690
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
691 g_snprintf(buf, sizeof(buf), "%s sets mode %c%c %s on %s",
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
692 nick, sign, mode, strlen(argstr) ? argstr : "",
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
693 room);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
694 g_free(nick);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
695 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL), -1);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
696 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
697
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
698 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
699 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
700 struct conversation *c = irc_find_chat(gc, room);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
701 GList *r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
703 if (mode != 'o' && mode != 'v')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
704 return;
2086
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 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
707 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
709 r = c->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
710 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
711 gboolean op = FALSE, voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
712 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
713 if (*who == '@') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
714 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
715 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
717 if (*who == '+') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
718 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
719 who++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
721 if (!strcmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
722 char *tmp, buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
723 if (mode == 'o') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
724 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
725 op = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
726 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
727 op = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
728 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
729 if (mode == 'v') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
730 if (sign == '-')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
731 voice = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
732 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
733 voice = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
734 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
735 tmp = g_strdup(r->data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
736 g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
737 voice ? "+" : "", nick);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
738 rename_chat_buddy(c, tmp, buf);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
739 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
740 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
742 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
743 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
744 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
746 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
747 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
748 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
749 int offset = n324 ? 4 : 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
750 char *chan = word[offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
751 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
752 char *modes = word[offset + 1];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
753 int len = strlen(word_eol[offset]) - 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
754 char sign = *modes++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
755 int arg = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
756 char *argstr;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
757 char *who = word[1];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
758
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
759 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
760 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
761
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
762 if (word_eol[offset][len] == ' ')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
763 word_eol[offset][len] = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
765 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
766 switch (*modes) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
767 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
768 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
769 case '+':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
770 case '-':
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
771 sign = *modes;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
772 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
773 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
774 if (mode_has_arg(gc, sign, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
775 argstr = word[++arg + offset];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
776 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
777 argstr = "";
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
778 if (strchr(id->nickmodes, *modes))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
779 irc_user_mode(gc, chan, sign, *modes, argstr);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
780 else if (strchr(who, '!'))
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
781 irc_chan_mode(gc, chan, sign, *modes, argstr, who);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
782 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
783 modes++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 }
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
786
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
787 static void handle_version(struct gaim_connection *gc, char *word[], char *word_eol[], int num)
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
788 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
789 struct irc_data *id = gc->proto_data;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
790 GString *str;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
791
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
792 id->liststr = g_string_new("");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
793
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
794 id->liststr = g_string_append(id->liststr, "<b>Version: </b>");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
795 id->liststr = g_string_append(id->liststr, word_eol[4]);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
796
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
797 str = decode_html(id->liststr->str);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
798 g_show_info_text(gc, NULL, 2, str->str, NULL);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
799 g_string_free(str, TRUE);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
800 g_string_free(id->liststr, TRUE);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
801 id->liststr = NULL;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
802 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
803
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
804 static void handle_who(struct gaim_connection *gc, char *word[], char *word_eol[], int num)
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
805 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
806 struct irc_data *id = gc->proto_data;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
807 char buf[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
808
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
809 if (!id->in_whois) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
810 id->in_whois = TRUE;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
811 id->liststr = g_string_new("");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
812 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
813
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
814 switch (num) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
815 case 352:
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
816 g_snprintf(buf, sizeof(buf), "<b>%s</b> (%s@%s): %s<br>",
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
817 word[8], word[5], word[6], word_eol[11]);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
818 id->liststr = g_string_append(id->liststr, buf);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
819 break;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
820 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
821 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
822
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
823 /* 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
824 * 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
825 * some medicine, or perhaps I should go to bed? Blah!! */
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
826
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
827 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
828 {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
829 struct irc_data *id = gc->proto_data;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
830 char tmp[1024];
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
831
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
832 if (!id->in_whois) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
833 id->in_whois = TRUE;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
834 id->liststr = g_string_new("");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
835 } else {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
836 /* I can't decide if we should have one break or two */
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
837 id->liststr = g_string_append(id->liststr, "<BR>");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
838 id->in_whois = TRUE;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
839 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
840
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
841 switch (num) {
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
842 case 311:
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
843 id->liststr = g_string_append(id->liststr, "<b>User: </b>");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
844 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
845 case 312:
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
846 id->liststr = g_string_append(id->liststr, "<b>Server: </b>");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
847 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
848 case 313:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
849 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]);
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
850 id->liststr = g_string_append(id->liststr, tmp);
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
851 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
852
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
853 case 317:
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
854 id->liststr = g_string_append(id->liststr, "<b>Idle Time: </b>");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
855 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
856 case 319:
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
857 id->liststr = g_string_append(id->liststr, "<b>Channels: </b>");
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
858 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
859 default:
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
860 break;
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
861 }
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
862
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
863 if (word_eol[5][0] == ':')
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
864 id->liststr = g_string_append(id->liststr, word_eol[5] + 1);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
865 /* Nicer idle time output, by jonas@birme.se */
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
866 else if (isdigit(word_eol[5][0])) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
867 time_t idle = atol(word_eol[5]);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
868 time_t signon = atol(strchr(word_eol[5], ' '));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
869
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
870 g_snprintf(tmp, sizeof(tmp),
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
871 "%ld seconds [signon: %s]", (idle / 1000), ctime(&signon));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
872 id->liststr = g_string_append(id->liststr, tmp);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
873 }
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
874 else
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
875 id->liststr = g_string_append(id->liststr, word_eol[5]);
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
876 }
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
877
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
878 static void handle_roomlist(struct gaim_connection *gc, char *word[], char *word_eol[])
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
879 {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
880 struct irc_data *id = gc->proto_data;
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
881
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
882 if (!id->in_list) {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
883 id->in_list = TRUE;
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
884 id->liststr = g_string_new("");
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
885 } else {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
886 id->liststr = g_string_append(id->liststr, "<BR>");
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
887 id->in_list = TRUE;
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
888 }
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
889
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
890 id->liststr = g_string_append(id->liststr, word_eol[4]);
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
891 }
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
892
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
893 static void irc_change_nick(void *a, char *b) {
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
894 struct gaim_connection *gc = a;
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
895 struct irc_data *id = gc->proto_data;
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
896 char buf[IRC_BUF_LEN];
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
897 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", b);
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
898 irc_write(id->fd, buf, strlen(buf));
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
899 }
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
900
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
901 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
902 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
903 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
904 char *text = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
905 int n = atoi(word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
906
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
907 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname)))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
908 text += strlen(gc->displayname) + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
909 if (*text == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
910 text++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
912 switch (n) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
913 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
914 if (!strncmp(word[5], "u2.10", 5))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
915 id->six_modes = TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
916 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
917 id->six_modes = FALSE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
918 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
919 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
920 handle_005(gc, word, word_eol);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
921 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
922 case 301:
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
923 if (id->in_whois) {
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
924 id->liststr = g_string_append(id->liststr, "<BR><b>Away: </b>");
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
925
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
926 if (word_eol[5][0] == ':')
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
927 id->liststr = g_string_append(id->liststr, word_eol[5] + 1);
2651
f84dcbcfba4b [gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2650
diff changeset
928 else
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
929 id->liststr = g_string_append(id->liststr, word_eol[5]);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
930 } else
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
931 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
932 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
933 case 303:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
934 handle_list(gc, &word_eol[4][1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
935 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
936 case 311:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
937 case 312:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
938 case 313:
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
939 case 317:
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
940 case 319:
2648
4036f6d47737 [gaim-migrate @ 2661]
Rob Flynn <gaim@robflynn.com>
parents: 2633
diff changeset
941 handle_whois(gc, word, word_eol, n);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
942 break;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
943 case 322:
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
944 handle_roomlist(gc, word, word_eol);
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
945 break;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
946 /* End of replies */
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
947 case 323:
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
948 case 318:
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
949 case 315:
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
950 if ((id->in_whois || id->in_list) && id->liststr) {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
951 GString *str = decode_html(id->liststr->str);
2791
8f6365332a05 [gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2782
diff changeset
952 g_show_info_text(gc, NULL, 2, str->str, NULL);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
953 g_string_free(str, TRUE);
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
954 g_string_free(id->liststr, TRUE);
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
955 id->liststr = NULL;
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
956 id->in_whois = FALSE;
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
957 id->in_list = FALSE;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
958 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
959 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
960 case 324:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
961 handle_mode(gc, word, word_eol, TRUE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
962 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
963 case 332:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
964 handle_topic(gc, text);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
965 break;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
966 case 351:
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
967 handle_version(gc, word, word_eol, n);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
968 break;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
969 case 352:
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
970 handle_who(gc, word, word_eol, n);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
971 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
972 case 353:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
973 handle_names(gc, word[5], word_eol[6]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
974 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
975 case 376:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
976 irc_request_buddy_update(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
977 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
978 case 401:
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3306
diff changeset
979 do_error_dialog(_("There is no such nick or channel on this IRC channel."), NULL, GAIM_ERROR);
2652
65a602693286 [gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2651
diff changeset
980 break;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
981 case 402:
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3306
diff changeset
982 do_error_dialog(_("There is no such IRC Server"), NULL, GAIM_ERROR);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
983 case 431:
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3306
diff changeset
984 do_error_dialog(_("No IRC nickname given"), NULL, GAIM_ERROR);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
985 break;
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
986 case 433:
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
987 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL);
3605
1066e65b1a18 [gaim-migrate @ 3718]
Sean Egan <seanegan@gmail.com>
parents: 3599
diff changeset
988 break;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
989 default:
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
990 if (n > 400 && n < 502) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
991 char errmsg[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
992 char *errmsg1 = strrchr(text, ':');
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
993 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
994 if (errmsg)
3536
f4cec5d41a89 [gaim-migrate @ 3610]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
995 do_error_dialog(errmsg, errmsg1 ? errmsg1+1 : NULL, GAIM_ERROR);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
996 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
997 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
999 }
2086
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 static gboolean is_channel(struct gaim_connection *gc, char *name)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1002 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1003 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1004 if (strchr(id->chantypes, *name))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1005 return TRUE;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1006 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1009 static void irc_rem_chat_bud(struct gaim_connection *gc, char *nick, char *reason)
2086
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 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1013 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1014 struct conversation *b = bcs->data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1016 GList *r = b->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1017 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1018 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1019 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1020 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1021 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1022 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1023 if (!g_strcasecmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1024 char *tmp = g_strdup(r->data);
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1025 remove_chat_buddy(b, tmp, reason);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1026 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1027 break;
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 r = r->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1031 bcs = bcs->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1035 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
1036 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1037 GSList *bcs = gc->buddy_chats;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1038 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1040 while (bcs) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1041 struct conversation *b = bcs->data;
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 GList *r = b->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1044 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1045 char *who = r->data;
2292
6625d0755c51 [gaim-migrate @ 2302]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2291
diff changeset
1046 int n = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1047 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1048 buf[n++] = *who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1049 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1050 buf[n++] = *who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1051 g_snprintf(buf + n, sizeof(buf) - n, "%s", new);
2312
766603034af8 [gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2310
diff changeset
1052 if (!strcmp(who, old)) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1053 char *tmp = g_strdup(r->data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1054 rename_chat_buddy(b, tmp, buf);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1055 r = b->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1056 g_free(tmp);
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2687
diff changeset
1057 break;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1058 } else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1059 r = r->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1060 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1061 bcs = bcs->next;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1062 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1063 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1065 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
1066 {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1067 if (is_channel(gc, to)) {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1068 struct conversation *c = irc_find_chat(gc, to);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1069 if (!c)
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1070 return;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1071 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
1072 } else {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1073 char *tmp = g_malloc(strlen(nick) + 2);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1074 g_snprintf(tmp, strlen(nick) + 2, "@%s", nick);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1075 if (find_conversation(tmp))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1076 irc_got_im(gc, tmp, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1077 else {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1078 *tmp = '+';
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1079 if (find_conversation(tmp))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1080 irc_got_im(gc, tmp, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1081 else
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1082 irc_got_im(gc, nick, msg, 0, time(NULL));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1083 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1084 g_free(tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1085 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1086 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1087
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1088 static void dcc_chat_init(gpointer obj, struct dcc_chat *data) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1089 struct dcc_chat * chat = g_new0(struct dcc_chat, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1090
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1091 memcpy(chat, data, sizeof(struct dcc_chat)); /* we have to make a new one
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1092 * because the old one get's freed by
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1093 * dcc_chat_cancel. */
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1094
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1095 printf("ONE MORE TIME: %s:%d\n", chat->ip_address, chat->port);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1096 proxy_connect(chat->ip_address, chat->port, dcc_chat_callback, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1097 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1098
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1099 static void dcc_chat_cancel(gpointer obj, struct dcc_chat *data){
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1100 if (find_dcc_chat(data->gc, data->nick)) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1101 dcc_chat_list = g_slist_remove(dcc_chat_list, data);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1102 gaim_input_remove (data->inpa);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1103 close (data->fd);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1104 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1105 g_free(data);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1106 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1107
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1108 static void irc_convo_closed(struct gaim_connection *gc, char *who)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1109 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1110 struct dcc_chat *dchat = find_dcc_chat(gc, who);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1111 if (!dchat)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1112 return;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1113
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1114 dcc_chat_cancel(NULL, dchat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1115 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1116
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1117 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
1118 char *msg, char *word[], char *word_eol[])
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1119 {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1120 struct irc_data *id = gc->proto_data;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1121 char buf[IRC_BUF_LEN];
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1122
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1123 if (!g_strncasecmp(msg, "VERSION", 7)) {
3245
01c000f003db [gaim-migrate @ 3263]
Sean Egan <seanegan@gmail.com>
parents: 3235
diff changeset
1124 g_snprintf(buf, sizeof(buf), "NOTICE %s :\001VERSION Gaim " VERSION ": The Penguin Pimpin' "
01c000f003db [gaim-migrate @ 3263]
Sean Egan <seanegan@gmail.com>
parents: 3235
diff changeset
1125 "Multi-protocol Messaging Client: " WEBSITE "\001\r\n", nick);
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1126 irc_write(id->fd, buf, strlen(buf));
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1127 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1128 if (!g_strncasecmp(msg, "ACTION", 6)) {
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1129 char *po = strchr(msg + 6, 1);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1130 char *tmp;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1131 if (po) *po = 0;
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1132 tmp = g_strconcat("/me", msg + 6, NULL);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1133 handle_privmsg(gc, to, nick, tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1134 g_free(tmp);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1135 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1136 if (!g_strncasecmp(msg, "DCC CHAT", 8)) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1137 char **chat_args = g_strsplit(msg, " ", 5);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1138 char ask[1024];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1139 struct dcc_chat * dccchat = g_new0(struct dcc_chat, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1140 dccchat->gc = gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1141 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1142 printf("DCC CHAT DEBUG CRAP: %s\n", dccchat->ip_address);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1143 dccchat->port=atoi(chat_args[4]);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1144 g_snprintf(dccchat->nick, sizeof(dccchat->nick), nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1145 g_snprintf(ask, sizeof(ask), _("%s has requested a DCC chat. "
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1146 "Would you like to establish the direct connection?"), nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1147 do_ask_dialog(ask, dccchat, dcc_chat_init, dcc_chat_cancel);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1148 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1149
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1150
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1151 if (!g_strncasecmp(msg, "DCC SEND", 8)) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1152 struct irc_file_transfer *ift = g_new0(struct irc_file_transfer, 1);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1153 char **send_args = g_strsplit(msg, " ", 6);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1154 send_args[5][strlen(send_args[5])-1] = 0;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1155
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1156 ift->type = IFT_SENDFILE_IN;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1157 ift->sn = g_strdup(nick);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1158 ift->gc = gc;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1159 g_snprintf(ift->ip, sizeof(ift->ip), send_args[3]);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1160 ift->port = atoi(send_args[4]);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1161 ift->len = atoi(send_args[5]);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1162 ift->name = g_strdup(send_args[2]);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1163 ift->cur = 0;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1164
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1165 id->file_transfers = g_slist_append(id->file_transfers, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1166
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1167 ift->xfer = transfer_in_add(gc, nick, ift->name, ift->len, 1, NULL);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1168 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
1169
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1170 /* XXX should probably write_to_conv or something here */
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1171 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1172
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1173 static gboolean irc_parse(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1175 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1176 gchar outbuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1177 char *word[PDIWORDS], *word_eol[PDIWORDS];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1178 char pdibuf[522];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1179 char *ex, ip[128], nick[128];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1180 char *cmd;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 /* Check for errors */
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1183
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1184 if (*buf != ':') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1185 if (!strncmp(buf, "NOTICE ", 7))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1186 buf += 7;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1187 if (!strncmp(buf, "PING ", 5)) {
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1188 int r = FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1189 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1190 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1191 hide_login_progress(gc, _("Unable to write"));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1192 signoff(gc);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1193 r = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1194 }
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1195 return r;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1197 /* XXX doesn't handle ERROR */
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1198 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200
2782
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1201 if (!idata->online) {
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1202 /* Now lets sign ourselves on */
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1203 account_online(gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1204 serv_finish_login(gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1205
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1206 if (bud_list_cache_exists(gc))
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1207 do_import(gc, NULL);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1208
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1209 /* we don't call this now because otherwise some IRC servers might not like us */
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1210 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc);
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1211 idata->online = TRUE;
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1212 }
428bd24c18c6 [gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1213
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1214 buf++;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1216 process_data_init(pdibuf, buf, word, word_eol, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1218 if (atoi(word[2])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1219 if (*word_eol[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1220 process_numeric(gc, word, word_eol);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1221 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1224 cmd = word[2];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1226 ex = strchr(pdibuf, '!');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1227 if (!ex) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1228 strncpy(ip, pdibuf, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1229 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1230 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1231 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1232 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1233 strncpy(ip, ex + 1, sizeof(ip));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1234 ip[sizeof(ip)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1235 strncpy(nick, pdibuf, sizeof(nick));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1236 nick[sizeof(nick)-1] = 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1237 if ((ex - pdibuf) < sizeof (nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1238 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1241 if (!strcmp(cmd, "INVITE")) {
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1242 char *chan = g_strdup(word[4]);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1243 serv_got_chat_invite(gc, chan + 1, nick, NULL, g_list_append(NULL, chan));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1244 } else if (!strcmp(cmd, "JOIN")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1245 char *chan = *word[3] == ':' ? word[3] + 1 : word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1246 if (!g_strcasecmp(gc->displayname, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1247 static int id = 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1248 serv_got_joined_chat(gc, id++, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1249 } else {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1250 struct conversation *c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1251 if (c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1252 add_chat_buddy(c, nick);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1254 } else if (!strcmp(cmd, "KICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1255 if (!strcmp(gc->displayname, word[4])) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1256 struct conversation *c = irc_find_chat(gc, word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1257 if (!c)
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1258 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1259 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1260 c->gc = NULL;
3599
5125b1adba03 [gaim-migrate @ 3701]
Sean Egan <seanegan@gmail.com>
parents: 3580
diff changeset
1261 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s by %s:"),
5125b1adba03 [gaim-migrate @ 3701]
Sean Egan <seanegan@gmail.com>
parents: 3580
diff changeset
1262 word[3], nick);
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3306
diff changeset
1263 do_error_dialog(outbuf, *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5], GAIM_INFO);
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1264 } else {
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1265 char *reason = *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5];
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1266 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason);
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1267 irc_rem_chat_bud(gc, word[4], msg);
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1268 g_free(msg);
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1269 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1270 } else if (!strcmp(cmd, "KILL")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1271 } else if (!strcmp(cmd, "MODE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1272 handle_mode(gc, word, word_eol, FALSE);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1273 } else if (!strcmp(cmd, "NICK")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1274 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
1275 if (!strcmp(gc->displayname, nick))
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1276 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1277 irc_change_name(gc, nick, new);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1278 } else if (!strcmp(cmd, "NOTICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1279 if (*word_eol[4] == ':') word_eol[4]++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1280 if (ex)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1281 irc_got_im(gc, nick, word_eol[4], 0, time(NULL));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1282 } else if (!strcmp(cmd, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1283 char *chan = cmd + 5;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1284 struct conversation *c;
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1285 char *reason = word_eol[4];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1286 GList *r;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1287 if (*chan == ':')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1288 chan++;
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1289 if (*reason == ':')
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1290 reason++;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1291 if (!(c = irc_find_chat(gc, chan)))
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1292 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1293 if (!strcmp(nick, gc->displayname)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1294 serv_got_chat_left(gc, c->id);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1295 return FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1297 r = c->in_room;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1298 while (r) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1299 char *who = r->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1300 if (*who == '@')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1301 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1302 if (*who == '+')
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1303 who++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1304 if (!g_strcasecmp(who, nick)) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1305 char *tmp = g_strdup(r->data);
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1306 remove_chat_buddy(c, tmp, reason);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1307 g_free(tmp);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1308 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1309 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1310 r = r->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1312 } else if (!strcmp(cmd, "PRIVMSG")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1313 char *to, *msg;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1314 if (!*word[3])
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1315 return FALSE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1316 to = word[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1317 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1318 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1319 if (!g_strncasecmp(msg + 1, "DCC ", 4))
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1320 process_data_init(pdibuf, buf, word, word_eol, TRUE);
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1321 handle_ctcp(gc, to, nick, msg + 1, word, word_eol);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1322 } else {
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
1323 handle_privmsg(gc, to, nick, msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1325 } else if (!strcmp(cmd, "PONG")) { /* */
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1326 } else if (!strcmp(cmd, "QUIT")) {
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2801
diff changeset
1327 irc_rem_chat_bud(gc, nick, *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1328 } else if (!strcmp(cmd, "TOPIC")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1329 struct conversation *c = irc_find_chat(gc, word[3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1330 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
1331 if (c) {
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
1332 char buf[IRC_BUF_LEN];
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1333 chat_set_topic(c, nick, topic);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
1334 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
1335 nick, topic);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2847
diff changeset
1336 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL), -1);
2328
14c8df9cc75f [gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2312
diff changeset
1337 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1338 } else if (!strcmp(cmd, "WALLOPS")) { /* */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339 }
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1340
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1341 return FALSE;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1342 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1343
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1344 static void irc_callback(gpointer data, gint source, GaimInputCondition condition)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1345 {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1346 struct gaim_connection *gc = data;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1347 struct irc_data *idata = gc->proto_data;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1348 int i = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1349 gchar buf[1024];
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1350 gboolean off;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1351
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1352 #ifndef _WIN32
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1353 i = read(idata->fd, buf, 1024);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1354 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1355 i = recv(idata->fd, buf, 1024, 0);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1356 #endif
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1357 if (i <= 0) {
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3063
diff changeset
1358 hide_login_progress_error(gc, "Read error");
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1359 signoff(gc);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1360 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1361 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1362
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1363 idata->rxqueue = g_realloc(idata->rxqueue, i + idata->rxlen + 1);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1364 memcpy(idata->rxqueue + idata->rxlen, buf, i);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1365 idata->rxlen += i;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1366 idata->rxqueue[idata->rxlen] = 0;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1367
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1368 while (1) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1369 char *d, *e;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1370 int len;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1371
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1372 if (!idata->rxqueue || ((e = strchr(idata->rxqueue, '\n')) == NULL))
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1373 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1374
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1375 len = e - idata->rxqueue + 1;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1376 d = g_strndup(idata->rxqueue, len);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1377 g_strchomp(d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1378 debug_printf("IRC S: %s\n", d);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1379
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1380 idata->rxlen -= len;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1381 if (idata->rxlen) {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1382 char *tmp = g_strdup(e + 1);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1383 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1384 idata->rxqueue = tmp;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1385 } else {
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1386 g_free(idata->rxqueue);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1387 idata->rxqueue = NULL;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1388 }
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1389
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1390 off = irc_parse(gc, d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1391
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1392 g_free(d);
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1393
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1394 if (off)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1395 return;
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1396 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1397 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1399 static void irc_login_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 struct irc_data *idata;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1403 char hostname[256];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1404 char buf[IRC_BUF_LEN];
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 if (!g_slist_find(connections, gc)) {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1407 #ifndef _WIN32
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408 close(source);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1409 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1410 closesocket(source);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1411 #endif
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 idata = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1417 if (source == -1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 if (idata->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 idata->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1426 gethostname(hostname, sizeof(hostname) - 1);
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1427 hostname[sizeof(hostname) - 1] = 0;
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1428 if (!*hostname)
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1429 g_snprintf(hostname, sizeof(hostname), "localhost");
3562
de3bc24fff02 [gaim-migrate @ 3657]
Luke Schierer <lschiere@pidgin.im>
parents: 3536
diff changeset
1430 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n",
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1431 g_get_user_name(), hostname,
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1432 gc->user->proto_opt[USEROPT_SERV],
3575
0a60fd3905b1 [gaim-migrate @ 3674]
Luke Schierer <lschiere@pidgin.im>
parents: 3572
diff changeset
1433 gc->user->alias && strlen(gc->user->alias) ? gc->user->alias : "gaim");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1434 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1435 hide_login_progress(gc, "Write error");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1436 signoff(gc);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1437 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1438 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439
2574
3526c5581f92 [gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
1440 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
1441 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1442 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1447 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
1448 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450 static void irc_login(struct aim_user *user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1452 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454 struct gaim_connection *gc = new_gaim_conn(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1455 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
1456
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1457 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1458
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1460 set_login_progress(gc, 2, buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1462 idata->chantypes = g_strdup("#&!+");
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1463 idata->chanmodes = g_strdup("beI,k,lnt");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1464 idata->nickmodes = g_strdup("ohv");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1465 idata->str = g_string_new("");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1466
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV],
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 user->proto_opt[USEROPT_PORT][0] ? atoi(user->
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 proto_opt[USEROPT_PORT]) :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 6667, irc_login_callback, gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 if (!user->gc || (idata->fd < 0)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472 hide_login_progress(gc, "Unable to create socket");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1474 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1475 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1476 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1477
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1478 static void irc_close(struct gaim_connection *gc)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1479 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1480 struct irc_data *idata = (struct irc_data *)gc->proto_data;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1481
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1482 gchar buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1483
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1484 if (idata->str->len > 0) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1485 g_snprintf(buf, sizeof(buf), "QUIT :%s\r\n", idata->str->str);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1486 } else {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1487 g_snprintf(buf, sizeof(buf),
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1488 "QUIT :Download Gaim [%s]\r\n", WEBSITE);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1489 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1490 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1491
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1492 if (idata->rxqueue)
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1493 g_free(idata->rxqueue);
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1494
3619
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1495 idata->rxqueue = NULL;
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1496 idata->rxlen = 0;
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1497
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1498 /* Kill any existing transfers */
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1499 while (idata->file_transfers) {
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1500 struct irc_file_transfer *ift = (struct irc_file_transfer *)idata->file_transfers->data;
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1501
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1502 g_free(ift->sn);
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1503 g_free(ift->name);
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1504 gaim_input_remove(ift->watcher);
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1505
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1506 close(ift->fd);
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1507
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1508 idata->file_transfers = idata->file_transfers->next;
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1509 }
3619
a19850d6e718 [gaim-migrate @ 3733]
Rob Flynn <gaim@robflynn.com>
parents: 3618
diff changeset
1510 idata->file_transfers = NULL;
3618
6b12659dfd70 [gaim-migrate @ 3732]
Rob Flynn <gaim@robflynn.com>
parents: 3616
diff changeset
1511
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1512
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1513 g_free(idata->chantypes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1514 g_free(idata->chanmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1515 g_free(idata->nickmodes);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1516
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1517 g_string_free(idata->str, TRUE);
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1518 if (idata->liststr)
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1519 g_string_free(idata->liststr, TRUE);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1520
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1521 if (idata->timer)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1522 g_source_remove(idata->timer);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1523
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1524 if (gc->inpa)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1525 gaim_input_remove(gc->inpa);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1526
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1527 #ifndef _WIN32
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1528 close(idata->fd);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1529 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1530 closesocket(idata->fd);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
1531 #endif
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1532 g_free(gc->proto_data);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1533 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1534
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1535 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
1536 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1538 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1539 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1540 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1541 int i = start;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1542
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1543 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1544 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1545 switch (left) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1546 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1547 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1548 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1549 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
1550 who, sign, mode, word[i]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1551 i += 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1552 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1553 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1554 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
1555 who, sign, mode, mode, word[i], word[i + 1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1556 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1557 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1558 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1559 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
1560 who, sign, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1561 word[i], word[i + 1], word[i + 2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1562 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1563 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1564 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1565 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1566 if (left < 3)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1567 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1568 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1569 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1570
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1571 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
1572 int start, int end, char *word[])
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1574 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1575 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1576 int left;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1577 int i = start;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1578
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1579 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1580 left = end - i;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1581 switch (left) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1582 case 0:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1583 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1584 case 1:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1585 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
1586 who, sign, mode, word[i]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1587 i += 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1588 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1589 case 2:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1590 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
1591 who, sign, mode, mode, word[i], word[i + 1]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1592 i += 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1593 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1594 case 3:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1595 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
1596 who, sign, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1597 word[i], word[i + 1], word[i + 2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1598 i += 3;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1599 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1600 case 4:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1601 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
1602 who, sign, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1603 word[i], word[i + 1], word[i + 2], word[i + 3]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1604 i += 4;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1605 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1606 case 5:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1607 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
1608 who, sign, mode, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1609 word[i], word[i + 1], word[i + 2],
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1610 word[i + 3], word[i + 4]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1611 i += 5;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1612 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1613 default:
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1614 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
1615 who, sign, mode, mode, mode, mode, mode, mode,
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1616 word[i], word[i + 1], word[i + 2],
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1617 word[i + 3], word[i + 4], word[i + 5]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1618 i += 6;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1619 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1620 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1621 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1622 if (left < 6)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1623 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1624 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1625 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1626
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1627 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
1628 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1629 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1630 int i = 2;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1631
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1632 while (1) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1633 if (!*word[i]) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1634 if (i == 2)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1635 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1636 if (id->six_modes)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1637 set_mode_6(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1638 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1639 set_mode_3(gc, who, sign, mode, 2, i, word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1640 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1641 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1642 i++;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1643 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1644 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1645
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1646 static void set_chan_mode(struct gaim_connection *gc, char *chan, char *mode_str)
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1647 {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1648 struct irc_data *id = gc->proto_data;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1649 char buf[IRC_BUF_LEN];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1650
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1651 if ((mode_str[0] == '-') || (mode_str[0] == '+')) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1652 g_snprintf(buf, sizeof(buf), "MODE %s %s\r\n", chan, mode_str);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1653 irc_write(id->fd, buf, strlen(buf));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1654 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1655 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1656
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1657 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
1658 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1659 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1660 char pdibuf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1661 char *word[PDIWORDS], *word_eol[PDIWORDS];
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1662 char *tmp = g_strdup(what);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1663 GString *str = encode_html(tmp);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1664 struct dcc_chat *dccchat = find_dcc_chat(gc, who);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1665 struct irc_data *id = gc->proto_data;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1666 g_free(tmp);
3030
e40c30cf7572 [gaim-migrate @ 3043]
Sean Egan <seanegan@gmail.com>
parents: 3029
diff changeset
1667 what = str->str;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1668 if (*what != '/') {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1669 unsigned int max = 440 - strlen(who);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1670 char t;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1671 while (strlen(what) > max) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1672 t = what[max];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1673 what[max] = 0;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1674 if (dccchat) {
3030
e40c30cf7572 [gaim-migrate @ 3043]
Sean Egan <seanegan@gmail.com>
parents: 3029
diff changeset
1675 g_snprintf(buf, sizeof(buf), "%s\r\n", what);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1676 irc_write(dccchat->fd, buf, strlen(buf));
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1677 g_string_free(str, TRUE);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1678 return 1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1679 }
3030
e40c30cf7572 [gaim-migrate @ 3043]
Sean Egan <seanegan@gmail.com>
parents: 3029
diff changeset
1680 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1681 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1682 what[max] = t;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1683 what = what + max;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1684 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1685 if (dccchat) {
3030
e40c30cf7572 [gaim-migrate @ 3043]
Sean Egan <seanegan@gmail.com>
parents: 3029
diff changeset
1686 g_snprintf(buf, sizeof(buf), "%s\r\n", what);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1687 irc_write(dccchat->fd, buf, strlen(buf));
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1688 g_string_free(str, TRUE);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1689 return 1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1690 }
3030
e40c30cf7572 [gaim-migrate @ 3043]
Sean Egan <seanegan@gmail.com>
parents: 3029
diff changeset
1691 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1692 irc_write(id->fd, buf, strlen(buf));
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1693 g_string_free(str, TRUE);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1694 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1695 }
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1696
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1697 process_data_init(pdibuf, what + 1, word, word_eol, TRUE);
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1698 g_string_free(str, FALSE);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1699 if (!g_strcasecmp(pdibuf, "ME")) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1700 if (dccchat) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1701 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", word_eol[2]);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1702 irc_write(dccchat->fd, buf, strlen(buf));
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1703 g_free(what);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1704 return 1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1705 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1706 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
1707 irc_write(id->fd, buf, strlen(buf));
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1708 g_free(what);
2304
15fb364935ec [gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2303
diff changeset
1709 return 1;
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1710 } else if (!g_strcasecmp(pdibuf, "INVITE")) {
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1711 char buf[IRC_BUF_LEN];
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1712 g_snprintf(buf, sizeof(buf), "INVITE %s\r\n", word_eol[2]);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1713 irc_write(id->fd, buf, strlen(buf));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1714 } else if (!g_strcasecmp(pdibuf, "TOPIC")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1715 if (!*word_eol[2]) {
3501
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1716 struct conversation *c;
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1717 c = irc_find_chat(gc, who);
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1718 g_snprintf(buf, sizeof(buf), _("Topic for %s is %s"), who, c->topic ? c->topic : "(no topic set)");
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1719 write_to_conv(c, buf, WFLAG_SYSTEM | WFLAG_NOLOG, NULL, time(NULL), -1);
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1720 } else {
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1721 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, word_eol[2]);
3335ef5fbecc [gaim-migrate @ 3564]
Luke Schierer <lschiere@pidgin.im>
parents: 3466
diff changeset
1722 irc_write(id->fd, buf, strlen(buf));
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1723 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1724 } else if (!g_strcasecmp(pdibuf, "NICK")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1725 if (!*word_eol[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1726 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1727 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1728 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1729 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
1730 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1731 } else if (!g_strcasecmp(pdibuf, "OP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1732 set_mode(gc, who, '+', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1733 } else if (!g_strcasecmp(pdibuf, "DEOP")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1734 set_mode(gc, who, '-', 'o', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1735 } else if (!g_strcasecmp(pdibuf, "VOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1736 set_mode(gc, who, '+', 'v', word);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1737 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1738 set_mode(gc, who, '-', 'v', word);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1739 } else if (!g_strcasecmp(pdibuf, "MODE")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1740 char *chan = who;
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1741 set_chan_mode(gc, chan, word_eol[2]);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1742 } else if (!g_strcasecmp(pdibuf, "QUOTE")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1743 if (!*word_eol[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1744 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1745 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1746 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1747 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1748 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1749 } else if (!g_strcasecmp(pdibuf, "SAY")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1750 if (!*word_eol[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1751 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1752 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1753 }
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1754 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
1755 irc_write(id->fd, buf, strlen(buf));
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1756 return 1;
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1757 } else if (!g_strcasecmp(pdibuf, "MSG")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1758 if (!*word[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1759 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1760 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1761 }
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1762 if (!*word_eol[3]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1763 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1764 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1765 }
2302
722a912562a0 [gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2301
diff changeset
1766 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
1767 irc_write(id->fd, buf, strlen(buf));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1768 } else if (!g_strcasecmp(pdibuf, "KICK")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1769 if (!*word[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1770 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1771 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1772 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1773 if (*word_eol[3])
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
1774 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
1775 else
2298
57da45349e50 [gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2295
diff changeset
1776 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
1777 irc_write(id->fd, buf, strlen(buf));
2801
04f97d65bdc1 [gaim-migrate @ 2814]
Rob Flynn <gaim@robflynn.com>
parents: 2791
diff changeset
1778 } else if (!g_strcasecmp(pdibuf, "JOIN") || !g_strcasecmp(pdibuf, "J")) {
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1779 if (!*word[2]) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1780 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1781 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1782 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1783 if (*word[3])
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1784 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
1785 else
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1786 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1787 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1788 } else if (!g_strcasecmp(pdibuf, "PART")) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1789 char *chan = *word[2] ? word[2] : who;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1790 char *reason = word_eol[3];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1791 struct conversation *c;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1792 if (!is_channel(gc, chan)) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1793 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1794 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1795 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1796 c = irc_find_chat(gc, chan);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1797 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
1798 *reason ? " :" : "",
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1799 *reason ? reason : "");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1800 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1801 if (c) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1802 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1803 c->gc = NULL;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1804 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan);
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3306
diff changeset
1805 do_error_dialog(buf, NULL, GAIM_INFO);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1806 }
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1807 } else if (!g_strcasecmp(pdibuf, "WHOIS")) {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
1808 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
1809 irc_write(id->fd, buf, strlen(buf));
2829
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1810 } else if (!g_strcasecmp(pdibuf, "LIST")) {
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1811 g_snprintf(buf, sizeof(buf), "LIST\r\n");
e3f98544eae0 [gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
1812 irc_write(id->fd, buf, strlen(buf));
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1813 } else if (!g_strcasecmp(pdibuf, "QUIT")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1814 char *reason = word_eol[2];
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1815 id->str = g_string_insert(id->str, 0, reason);
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1816 do_quit();
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1817 } else if (!g_strcasecmp(pdibuf, "VERSION")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1818 g_snprintf(buf, sizeof(buf), "VERSION\r\n");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1819 irc_write(id->fd, buf, strlen(buf));
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1820 } else if (!g_strcasecmp(pdibuf, "W")) {
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1821 g_snprintf(buf, sizeof(buf), "WHO *\r\n");
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1822 irc_write(id->fd, buf, strlen(buf));
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1823 } else if (!g_strcasecmp(pdibuf, "HELP")) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1824 struct conversation *c = NULL;
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1825 if (is_channel(gc, who)) {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1826 c = irc_find_chat(gc, who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1827 } else {
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1828 c = find_conversation(who);
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1829 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1830 if (!c) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1831 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1832 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1833 }
2301
171d11fb37b9 [gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2299
diff changeset
1834 write_to_conv(c, "<B>Currently supported commands:<BR>"
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1835 "WHOIS INVITE NICK LIST<BR>"
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1836 "JOIN PART TOPIC KICK<BR>"
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1837 "OP DEOP VOICE DEVOICE<BR>"
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1838 "ME MSG QUOTE SAY QUIT<BR>"
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1839 "MODE VERSION W</B>",
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2847
diff changeset
1840 WFLAG_NOLOG, NULL, time(NULL), -1);
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1841 } else {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1842 struct conversation *c = NULL;
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1843 if (is_channel(gc, who)) {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1844 c = irc_find_chat(gc, who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1845 } else {
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1846 c = find_conversation(who);
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1847 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1848 if (!c) {
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1849 g_free(what);
2305
0371b905baef [gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2304
diff changeset
1850 return -EINVAL;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1851 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2847
diff changeset
1852 write_to_conv(c, "<B>Unknown command</B>", WFLAG_NOLOG, NULL, time(NULL), -1);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1853 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1854 g_free(what);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1855 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1856 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1857
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1858 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
1859 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1860 char *cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1861 if (cr) {
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1862 int ret = 0;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1863 while (TRUE) {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1864 if (cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1865 *cr = 0;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1866 ret = handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1867 if (!cr)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1868 break;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1869 what = cr + 1;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1870 if (!*what)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1871 break;
2295
24dc9ce95127 [gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2294
diff changeset
1872 *cr = '\n';
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1873 cr = strchr(what, '\n');
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1874 }
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1875 return ret;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1876 } else
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1877 return handle_command(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1878 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1879
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3452
diff changeset
1880 static void irc_chat_invite(struct gaim_connection *gc, int idn, const char *message, const char *name) {
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1881 char buf[IRC_BUF_LEN];
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1882 struct irc_data *id = gc->proto_data;
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1883 struct conversation *c = irc_find_chat_by_id(gc, idn);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1884 g_snprintf(buf, sizeof(buf), "INVITE %s %s\r\n", name, c->name);
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1885 irc_write(id->fd, buf, strlen(buf));
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1886 }
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
1887
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
1888 static int irc_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1889 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1890 if (*who == '@' || *who == '+')
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1891 return send_msg(gc, who + 1, what);
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1892 return send_msg(gc, who, what);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1893 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1894
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1895 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3452
diff changeset
1896 static void irc_add_buddy(struct gaim_connection *gc, const char *who) {}
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
1897 static void irc_remove_buddy(struct gaim_connection *gc, char *who, char *group) {}
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1898
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1899 static GList *irc_chat_info(struct gaim_connection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1900 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1901 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1902 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1903
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1904 pce = g_new0(struct proto_chat_entry, 1);
2466
f8eb5f120603 [gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2459
diff changeset
1905 pce->label = _("Channel:");
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1906 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1907
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1908 pce = g_new0(struct proto_chat_entry, 1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1909 pce->label = _("Password:");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1910 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1911
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1912 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1913 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1914
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1915 static void irc_join_chat(struct gaim_connection *gc, GList *data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1916 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1917 struct irc_data *id = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1918 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1919 char *name, *pass;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1920
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1921 if (!data)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1922 return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1923 name = data->data;
2299
b5b7dece5249 [gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2298
diff changeset
1924 if (data->next) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1925 pass = data->next->data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1926 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
1927 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1928 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1929 irc_write(id->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1930 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1931
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1932 static void irc_chat_leave(struct gaim_connection *gc, int id)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1933 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1934 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1935 struct conversation *c = irc_find_chat_by_id(gc, id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1936 char buf[IRC_BUF_LEN];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1937
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1938 if (!c) return;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1939
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1940 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1941 irc_write(idata->fd, buf, strlen(buf));
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1942 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1943
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1944 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
1945 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1946 struct conversation *c = irc_find_chat_by_id(gc, id);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1947 if (!c)
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1948 return -EINVAL;
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1949 if (send_msg(gc, c->name, what) > 0)
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2302
diff changeset
1950 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
1951 return 0;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1952 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1953
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2466
diff changeset
1954 static GList *irc_away_states(struct gaim_connection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1955 {
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1956 return g_list_append(NULL, GAIM_AWAY_CUSTOM);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1957 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1958
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1959 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
1960 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1961 struct irc_data *idata = gc->proto_data;
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1962 char buf[IRC_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1964 if (gc->away)
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1965 gc->away = NULL;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1966
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1967 if (msg) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1968 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg);
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1969 gc->away = "";
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1970 } else
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1971 g_snprintf(buf, sizeof(buf), "AWAY\r\n");
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1972 irc_write(idata->fd, buf, strlen(buf));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1975 static char **irc_list_icon(int uc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976 {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1977 return irc_icon_xpm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1980 static int getlocalip(char *ip) /* Thanks, libfaim */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1981 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1982 struct hostent *hptr;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1983 char localhost[129];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1984 long unsigned add;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1985
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1986 /* XXX if available, use getaddrinfo() */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1987 /* XXX allow client to specify which IP to use for multihomed boxes */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1988
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1989 if (gethostname(localhost, 128) < 0)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1990 return -1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1991
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1992 if (!(hptr = gethostbyname(localhost)))
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1993 return -1;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1994
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1995 memcpy(&add, hptr->h_addr_list[0], 4);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1996 add = htonl(add);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1997 g_snprintf(ip, 11, "%lu", add);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1998
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
1999 return 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2000 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2001
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2002 static void dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2003 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2004 struct dcc_chat *chat = data;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2005 struct conversation *convo;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2006 char buf[128];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2007 struct sockaddr_in addr;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2008 int addrlen = sizeof (addr);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2009 addr.sin_family = AF_INET;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2010 addr.sin_port = htons (chat->port);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2011 addr.sin_addr.s_addr = INADDR_ANY;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2012 chat->fd = accept (chat->fd, (struct sockaddr *) (&addr), &addrlen);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2013 if (!chat->fd)
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2014 {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2015 dcc_chat_cancel (NULL,chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2016 convo = new_conversation (chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2017 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"),
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2018 chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2019 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL,
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2020 time ((time_t) NULL), -1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2021 return;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2022 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2023 chat->inpa =
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2024 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2025 convo = new_conversation (chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2026 g_snprintf (buf, sizeof buf, "DCC Chat with %s established",
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2027 chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2028 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, time ((time_t) NULL), -1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2029 debug_printf ("Chat with %s established\n", chat->nick);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2030 dcc_chat_list = g_slist_append (dcc_chat_list, chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2031 }
3665
7cb6cf20ed7d [gaim-migrate @ 3794]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3633
diff changeset
2032 #if 0
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2033 static void irc_ask_send_file(struct gaim_connection *gc, char *destsn) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2034 struct irc_data *id = (struct irc_data *)gc->proto_data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2035 struct irc_file_transfer *ift = g_new0(struct irc_file_transfer, 1);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2036 char *localip = (char *)malloc(12);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2037
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2038 if (getlocalip(localip) == -1) {
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2039 free(localip);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2040 return;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2041 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2042
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2043 ift->type = IFT_SENDFILE_OUT;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2044 ift->sn = g_strdup(destsn);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2045 ift->gc = gc;
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2046 snprintf(ift->ip, sizeof(ift->ip), "%s", localip);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2047 id->file_transfers = g_slist_append(id->file_transfers, ift);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2048
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2049 ift->xfer = transfer_out_add(gc, ift->sn);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2050 }
3665
7cb6cf20ed7d [gaim-migrate @ 3794]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3633
diff changeset
2051 #endif
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2052 static struct irc_file_transfer *find_ift_by_xfer(struct gaim_connection *gc,
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2053 struct file_transfer *xfer) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2054
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2055 GSList *g = ((struct irc_data *)gc->proto_data)->file_transfers;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2056 struct irc_file_transfer *f = NULL;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2057
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2058 while (g) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2059 f = (struct irc_file_transfer *)g->data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2060 if (f->xfer == xfer)
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2061 break;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2062 g = g->next;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2063 f = NULL;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2064 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2065
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2066 return f;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2067 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2068
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2069 static void irc_file_transfer_data_chunk(struct gaim_connection *gc, struct file_transfer *xfer, const char *data, int len) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2070 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2071 guint32 pos;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2072
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2073 ift->cur += len;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2074 pos = htonl(ift->cur);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2075 write(ift->fd, (char *)&pos, 4);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2076
3623
159f624c617d [gaim-migrate @ 3744]
Rob Flynn <gaim@robflynn.com>
parents: 3622
diff changeset
2077 // FIXME: You should check to verify that they received the data when
159f624c617d [gaim-migrate @ 3744]
Rob Flynn <gaim@robflynn.com>
parents: 3622
diff changeset
2078 // you are sending a file ...
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2079 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2080
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2081 static void irc_file_transfer_cancel (struct gaim_connection *gc, struct file_transfer *xfer) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2082 struct irc_data *id = (struct irc_data *)gc->proto_data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2083 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2084
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2085 printf("Our shit got canceled, yo!\n");
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2086
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2087 /* Remove the FT from our list of transfers */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2088 id->file_transfers = g_slist_remove(id->file_transfers, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2089
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2090 gaim_input_remove(ift->watcher);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2091
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2092 /* Close our FT because we're done */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2093 close(ift->fd);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2094
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2095 g_free(ift->sn);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2096 g_free(ift->name);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2097
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2098 g_free(ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2099 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2100
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2101 static void irc_file_transfer_done(struct gaim_connection *gc, struct file_transfer *xfer) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2102 struct irc_data *id = (struct irc_data *)gc->proto_data;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2103 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2104
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2105
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2106 printf("Our shit be done, yo.\n");
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2107
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2108 /* Remove the FT from our list of transfers */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2109 id->file_transfers = g_slist_remove(id->file_transfers, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2110
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2111 gaim_input_remove(ift->watcher);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2112
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2113 /* Close our FT because we're done */
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2114 close(ift->fd);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2115
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2116 g_free(ift->sn);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2117 g_free(ift->name);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2118
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2119 g_free(ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2120 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2121
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2122 static void irc_file_transfer_out (struct gaim_connection *gc, struct file_transfer *xfer, const char *name, int totfiles, int totsize) {
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2123 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2124 struct sockaddr_in addr;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2125 char buf[IRC_BUF_LEN];
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2126 int len;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2127
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2128
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2129 ift->fd = socket (AF_INET, SOCK_STREAM, 0);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2130 addr.sin_family = AF_INET;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2131 addr.sin_port = 0;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2132 addr.sin_addr.s_addr = INADDR_ANY;
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2133 bind (ift->fd, (struct sockaddr *) &addr, sizeof(addr));
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2134 listen(ift->fd, 1);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2135
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2136 len = sizeof(addr);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2137 getsockname (ift->fd, (struct sockaddr *) &addr, &len);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2138
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2139 ift->port = ntohs(addr.sin_port);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2140
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2141 ift->watcher = gaim_input_add (ift->fd, GAIM_INPUT_READ, dcc_send_callback, ift);
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
2142 printf("watcher is %d\n", ift->watcher);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2143
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2144 snprintf(buf, sizeof(buf), "\001DCC SEND %s %s %d %d\001\n", name, ift->ip, ift->port, totsize);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2145 printf("Trying: %s\n", buf);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2146 irc_send_im (gc, ift->sn, buf, -1, 0);
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2147 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2148
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2149 static void irc_file_transfer_in(struct gaim_connection *gc,
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2150 struct file_transfer *xfer, int offset) {
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2151
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2152 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2153
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2154 ift->xfer = xfer;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2155 proxy_connect(ift->ip, ift->port, dcc_recv_callback, ift);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2156 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2157
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2158 static void irc_start_chat(struct gaim_connection *gc, char *who) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2159 struct dcc_chat *chat;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2160 int len;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2161 struct sockaddr_in addr;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2162 char buf[200];
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2163
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2164 /* Create a socket */
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2165 chat = g_new0 (struct dcc_chat, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2166 chat->fd = socket (AF_INET, SOCK_STREAM, 0);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2167 chat->gc = gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2168 g_snprintf (chat->nick, sizeof (chat->nick), "%s", who);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2169 if (chat->fd < 0) {
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2170 dcc_chat_cancel (NULL,chat);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2171 return;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2172 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2173 addr.sin_family = AF_INET;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2174 addr.sin_port = 0;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2175 addr.sin_addr.s_addr = INADDR_ANY;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2176 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr));
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2177 listen (chat->fd, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2178 len = sizeof (addr);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2179 getsockname (chat->fd, (struct sockaddr *) &addr, &len);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2180 chat->port = ntohs (addr.sin_port);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2181 getlocalip(chat->ip_address);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2182 chat->inpa =
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2183 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected,
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2184 chat);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
2185 g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n",
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2186 chat->ip_address, chat->port);
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3030
diff changeset
2187 irc_send_im (gc, who, buf, -1, 0);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2188 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2189
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2190 static void irc_get_info(struct gaim_connection *gc, char *who)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2191 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2192 struct irc_data *idata = gc->proto_data;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2193 char buf[IRC_BUF_LEN];
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2194
2633
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2195 if (*who == '@')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2196 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2197 if (*who == '+')
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2198 who++;
b740a33875c3 [gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2620
diff changeset
2199
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2200 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2201 irc_write(idata->fd, buf, strlen(buf));
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2202 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2203
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2204 static GList *irc_buddy_menu(struct gaim_connection *gc, char *who)
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2205 {
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2206 GList *m = NULL;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2207 struct proto_buddy_menu *pbm;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2208
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2209 pbm = g_new0(struct proto_buddy_menu, 1);
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2210 pbm->label = _("Get Info");
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2211 pbm->callback = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2212 pbm->gc = gc;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2213 m = g_list_append(m, pbm);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2214
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2215 pbm = g_new0(struct proto_buddy_menu, 1);
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2216 pbm->label = _("DCC Chat");
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2217 pbm->callback = irc_start_chat;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2218 pbm->gc = gc;
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2219 m = g_list_append(m, pbm);
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
2220 /*
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2221 pbm = g_new0(struct proto_buddy_menu, 1);
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2222 pbm->label = _("DCC Send");
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2223 pbm->callback = irc_ask_send_file;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2224 pbm->gc = gc;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2225 m = g_list_append(m, pbm);
3633
c084394b86de [gaim-migrate @ 3756]
Rob Flynn <gaim@robflynn.com>
parents: 3630
diff changeset
2226 */
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2227 return m;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2228 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2229
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2230 static struct prpl *my_protocol = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
2232 G_MODULE_EXPORT void irc_init(struct prpl *ret)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2234 struct proto_user_opt *puo;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235 ret->protocol = PROTO_IRC;
2100
a93aeb6f813d [gaim-migrate @ 2110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
2236 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD;
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2237 ret->name = g_strdup("IRC");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238 ret->list_icon = irc_list_icon;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 ret->login = irc_login;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240 ret->close = irc_close;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 ret->send_im = irc_send_im;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
2242 ret->add_buddy = irc_add_buddy;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2652
diff changeset
2243 ret->remove_buddy = irc_remove_buddy;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
2244 ret->chat_info = irc_chat_info;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2245 ret->join_chat = irc_join_chat;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2246 ret->chat_leave = irc_chat_leave;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247 ret->chat_send = irc_chat_send;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2248 ret->away_states = irc_away_states;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249 ret->set_away = irc_set_away;
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2250 ret->get_info = irc_get_info;
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
2251 ret->buddy_menu = irc_buddy_menu;
2847
e49bd1479edd [gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2831
diff changeset
2252 ret->chat_invite = irc_chat_invite;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
2253 ret->convo_closed = irc_convo_closed;
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
2254 ret->file_transfer_out = irc_file_transfer_out;
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2255 ret->file_transfer_in = irc_file_transfer_in;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2256 ret->file_transfer_data_chunk = irc_file_transfer_data_chunk;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2257 ret->file_transfer_done = irc_file_transfer_done;
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2258 ret->file_transfer_cancel =irc_file_transfer_cancel;
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2259
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2260 puo = g_new0(struct proto_user_opt, 1);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2261 puo->label = g_strdup("Server:");
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2262 puo->def = g_strdup("irc.openprojects.net");
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2263 puo->pos = USEROPT_SERV;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2264 ret->user_opts = g_list_append(ret->user_opts, puo);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2265
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2266 puo = g_new0(struct proto_user_opt, 1);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2267 puo->label = g_strdup("Port:");
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2268 puo->def = g_strdup("6667");
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2269 puo->pos = USEROPT_PORT;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2270 ret->user_opts = g_list_append(ret->user_opts, puo);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2271
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
2272 my_protocol = ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 #ifndef STATIC
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3623
diff changeset
2276 G_MODULE_EXPORT void gaim_prpl_init(struct prpl* prpl)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2278 irc_init(prpl);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3569
diff changeset
2279 prpl->plug->desc.api_version = PLUGIN_API_VERSION;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282 #endif