annotate plugins/irc.c @ 1342:84aef77f0add

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