annotate plugins/irc.c @ 1543:352f05feb0d1

[gaim-migrate @ 1553] icq passwords are only 8 chars. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 07 Mar 2001 21:54:31 +0000
parents cac3efeb4d9c
children 7cb0cebd6d87
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
1504
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
615 if ((strstr(buf, " NICK ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
616
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
617 gchar old[128];
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
618 gchar new[128];
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
619
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
620 GList *templist;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
621
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
622 struct irc_channel *channel;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
623 int id;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
624 int j;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
625
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
626 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
627 old[j] = buf[i];
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
628 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
629
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
630 old[j] = '\0';
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
631 i++;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
632
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
633 for (j = 0; buf[i] != ':'; j++, i++) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
634 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
635
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
636 i++;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
637 strcpy(new, buf + i);
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
638
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
639 g_strchomp(new);
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
640
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
641 templist = ((struct irc_data *)gc->proto_data)->channels;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
642
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
643 while (templist) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
644 struct conversation *convo = NULL;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
645 channel = templist->data;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
646
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
647 convo = find_conversation_by_id(gc, channel->id);
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
648
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
649 rename_chat_buddy(convo, old, new);
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
650
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
651 templist = templist->next;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
652 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
653 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
654
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
655 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
656
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
657 gchar u_nick[128];
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
658
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
659 GList *templist;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
660
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
661 struct irc_channel *channel;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
662 int j;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
663
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
664 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
665 u_nick[j] = buf[i];
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
666 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
667
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
668 u_nick[j] = '\0';
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
669
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
670 templist = ((struct irc_data *)gc->proto_data)->channels;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
671
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
672 while (templist) {
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
673 struct conversation *convo = NULL;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
674 channel = templist->data;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
675
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
676 convo = find_conversation_by_id(gc, channel->id);
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
677
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
678 remove_chat_buddy(convo, u_nick);
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
679
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
680 templist = templist->next;
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
681 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
682 }
cac3efeb4d9c [gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
683
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
684 if ((strstr(buf, " PART ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
685
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
686 gchar u_channel[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
687 gchar u_nick[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
688
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
689 struct irc_channel *channel;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
690 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
691 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
692 GList *test = NULL;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
693
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
694 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
695 u_nick[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
696 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
697 u_nick[j] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
698
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
699 i++;
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
700
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
701 for (j = 0; buf[i] != '#'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
702 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
703
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
704 i++;
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
705
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
706 strcpy(u_channel, buf + i);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
707
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
708
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
709 /* 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
710 * 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
711 * old channel stuff. Otherwise,
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
712 * we should just print that someone left */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
713
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
714 channel = find_channel_by_name(gc, u_channel);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
715
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
716 if (!channel) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
717 return;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
718 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
719
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
720 if (g_strcasecmp(u_nick, gc->username) == 0) {
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
721
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
722 /* Looks like we're going to leave the channel for
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
723 * real now. Let's create a valid channel structure
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
724 * and add it to our list */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
725
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
726 serv_got_chat_left(gc, channel->id);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
727
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
728 idata->channels = g_list_remove(idata->channels, channel);
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
729 } else {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
730 struct conversation *convo = NULL;
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
731
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
732 /* Find their conversation window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
733 convo = find_conversation_by_id(gc, channel->id);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
734
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
735 if (!convo) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
736 /* Some how the window doesn't exist.
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
737 * Let's get out of here */
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
738 return;
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
739 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
740
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
741 /* And remove their name */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
742 remove_chat_buddy(convo, u_nick);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
743
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
744 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
745
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
746 /* Go Home! */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
747 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
748 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
749
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
750 if ((strstr(buf, " NOTICE ")) && (buf[0] == ':')) {
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
751 gchar u_nick[128];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
752 gchar u_host[255];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
753 gchar u_command[32];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
754 gchar u_channel[128];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
755 gchar u_message[IRC_BUF_LEN];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
756 int j;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
757 int msgcode = 0;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
758
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
759 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
760 u_nick[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
761 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
762
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
763 u_nick[j] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
764 i++;
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
765
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
766 for (j = 0; buf[i] != ' '; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
767 u_host[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
768 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
769
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
770 u_host[j] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
771 i++;
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
772
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
773 for (j = 0; buf[i] != ' '; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
774 u_command[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
775 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
776
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
777 u_command[j] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
778 i++;
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
779
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
780 for (j = 0; buf[i] != ':'; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
781 u_channel[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
782 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
783
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
784 u_channel[j - 1] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
785 i++;
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
786
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
787
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
788 /* 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
789 strncpy(u_message, buf + i, IRC_BUF_LEN);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
790
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
791 /* 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
792 if (u_message[0] == '\001') {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
793 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
794 /* Someone's triyng to ping us. Let's respond */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
795 gchar u_arg[24];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
796 gchar u_buf[200];
1393
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
797 unsigned long tend= time((time_t *)NULL);
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
798 unsigned long tstart;
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
799
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
800 printf("LA: %s\n", buf);
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
801
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
802 strcpy(u_arg, u_message + 6);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
803 u_arg[strlen(u_arg) - 1] = '\0';
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
804
1393
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
805 tstart = atol(u_arg);
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
806
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
807 g_snprintf(u_buf, sizeof(u_buf), "Ping Reply From %s: [%ld seconds]", u_nick, tend-tstart);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
808
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
809 do_error_dialog(u_buf, "Gaim IRC - Ping Reply");
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
810
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
811 return;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
812 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
813 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
814
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
815 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
816
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
817
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
818 if ((strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
819 gchar u_nick[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
820 gchar u_host[255];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
821 gchar u_command[32];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
822 gchar u_channel[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
823 gchar u_message[IRC_BUF_LEN];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
824 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
825 int msgcode = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
826
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
827 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
828 u_nick[j] = buf[i];
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
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
831 u_nick[j] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
832 i++;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
833
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
834 for (j = 0; buf[i] != ' '; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
835 u_host[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
836 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
837
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
838 u_host[j] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
839 i++;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
840
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
841 for (j = 0; buf[i] != ' '; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
842 u_command[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
843 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
844
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
845 u_command[j] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
846 i++;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
847
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
848 for (j = 0; buf[i] != ':'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
849 u_channel[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
850 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
851
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
852 u_channel[j - 1] = '\0';
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
853 i++;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
854
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
855
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
856 /* 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
857 strncpy(u_message, buf + i, IRC_BUF_LEN);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
858
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
859 /* 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
860 if (u_message[0] == '\001') {
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
861 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) {
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
862 /* Looks like we have a version request. Let
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
863 * us handle it thusly */
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
864
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
865 g_snprintf(buf, IRC_BUF_LEN,
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
866 "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
867 u_nick, '\001', VERSION, '\001');
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
868
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
869 write(idata->fd, buf, strlen(buf));
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
870
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
871 /* And get the heck out of dodge */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
872 return;
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
873 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
874
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
875 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
876 /* Someone's triyng to ping us. Let's respond */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
877 gchar u_arg[24];
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
878
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
879 strcpy(u_arg, u_message + 6);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
880 u_arg[strlen(u_arg) - 1] = '\0';
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
881
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
882 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
883 u_arg, '\001');
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
884
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
885 write(idata->fd, buf, strlen(buf));
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
886
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
887 /* And get the heck out of dodge */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
888 return;
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
889 }
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
890
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
891 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
892 /* 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
893 strcpy(buf, u_message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
894
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
895 strcpy(u_message, "/me ");
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
896 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
897 u_message[j] = buf[i];
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 u_message[j] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
900 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
901 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
902
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
903
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
904 /* 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
905 if (u_channel[0] == '#') {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
906 /* Yup. We have a channel */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
907 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
908
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
909 id = find_id_by_name(gc, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
910 if (id != -1) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
911 serv_got_chat_in(gc, id, u_nick, 0, u_message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
912 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
913 } else {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
914 /* Nope. Let's treat it as a private message */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
915 serv_got_im(gc, u_nick, u_message, 0);
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
918 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
919 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
920
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
921 /* 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
922
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
923 if (strncmp(buf, "PING :", 6) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
924 buf2 = g_strsplit(buf, ":", 1);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
925
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
926 /* Let's build a new response */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
927 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
928 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
929
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
930 /* And clean up after ourselves */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
931 g_strfreev(buf2);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
932
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
933 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
934 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
935
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
936 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
937
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
938 static void irc_close(struct gaim_connection *gc)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
939 {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
940 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
941 GList *chats = idata->channels;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
942 struct irc_channel *cc;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
943
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
944 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
945
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
946 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
947 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
948
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
949 g_free(buf);
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
950
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
951 if (idata->timer)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
952 gtk_timeout_remove(idata->timer);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
953
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
954 while (chats) {
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
955 cc = (struct irc_channel *)chats->data;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
956 g_free(cc->name);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
957 chats = g_list_remove(chats, cc);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
958 g_free(cc);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
959 }
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
960
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
961 if (gc->inpa)
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
962 gdk_input_remove(gc->inpa);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
963
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
964 if (idata->inpa)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
965 gdk_input_remove(idata->inpa);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
966
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
967 close(idata->fd);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
968 g_free(gc->proto_data);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
969 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
970
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
971 static void irc_chat_leave(struct gaim_connection *gc, int id)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
972 {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
973 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
974 struct irc_channel *channel;
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
975 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
976
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
977 channel = find_channel_by_id(gc, id);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
978
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
979 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
980 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
981 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
982
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
983 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
984 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
985
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
986 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
987 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
988
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
989 static void irc_login_callback(gpointer data, gint source, GdkInputCondition condition)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
990 {
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
991 struct gaim_connection *gc = data;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
992 struct irc_data *idata = gc->proto_data;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
993 char buf[4096];
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
994 int len, error = ETIMEDOUT;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
995
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
996 len = sizeof(error);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
997 if (getsockopt(idata->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
998 error = errno;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
999 if (error) {
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1000 hide_login_progress(gc, "Couldn't connect");
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1001 signoff(gc);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1002 return;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1003 }
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1004
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1005 fcntl(idata->fd, F_SETFL, 0);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1006
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1007 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
1008 gc->username, g_get_user_name(), gc->user->proto_opt[0]);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1009
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1010 if (write(idata->fd, buf, strlen(buf)) < 0) {
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1011 hide_login_progress(gc, "Write error");
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1012 signoff(gc);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1013 return;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1014 }
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1015
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1016 gdk_input_remove(idata->inpa);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1017 idata->inpa = 0;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1018
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1019 /* Now lets sign ourselves on */
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1020 account_online(gc);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1021 serv_finish_login(gc);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1022
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1023 if (bud_list_cache_exists(gc))
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1024 do_import(NULL, gc);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1025
1269
677e2c9e8baf [gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1266
diff changeset
1026 /* 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
1027 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
1028 }
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1029
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1030 static void irc_login(struct aim_user *user)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1031 {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1032 int fd;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1033 struct hostent *host;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1034 struct sockaddr_in site;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1035 char buf[4096];
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1036
1089
f0f5c10cce63 [gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1075
diff changeset
1037 struct gaim_connection *gc = new_gaim_conn(user);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1038 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
1039 char c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1040 int i;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1041 int status;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1042
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1043 host = gethostbyname(user->proto_opt[0]);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1044 if (!host) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1045 hide_login_progress(gc, "Unable to resolve hostname");
1115
114cd406b022 [gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1105
diff changeset
1046 signoff(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1047 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1048 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1049
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1050 site.sin_family = AF_INET;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1051 site.sin_addr.s_addr = *(long *)(host->h_addr);
1304
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1052
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1053 if (user->proto_opt[1][0])
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1054 site.sin_port = htons(atoi(user->proto_opt[1]));
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1055 else {
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1056 site.sin_port = htons(6667);
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1057 g_snprintf(user->proto_opt[1], 5, "6667");
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1058 }
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1059
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1060 fd = socket(AF_INET, SOCK_STREAM, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1061 if (fd < 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1062 hide_login_progress(gc, "Unable to create socket");
1115
114cd406b022 [gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1105
diff changeset
1063 signoff(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1064 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1065 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1066
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1067 fcntl(fd, F_SETFL, O_NONBLOCK);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1068 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1069 if ((errno == EINPROGRESS) || (errno == EINTR)) {
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1070 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
1071 } else {
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1072 hide_login_progress(gc, "Unable to connect.");
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1073 signoff(gc);
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1074 return;
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1075 }
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1076 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1077
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1078 idata->fd = fd;
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1079
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1080 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1081 set_login_progress(gc, 2, buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1082
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1083 /* This is where we will attempt to sign on */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1084
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1085 if (!idata->inpa)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1086 irc_login_callback(gc, idata->fd, GDK_INPUT_READ);
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
1087
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1088 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
1089 }
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1090
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1091 static void irc_print_option(GtkEntry * entry, struct aim_user *user)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1092 {
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1093 if (gtk_object_get_user_data(GTK_OBJECT(entry))) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1094 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
1095 gtk_entry_get_text(entry));
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1096 } else {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1097 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
1098 gtk_entry_get_text(entry));
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1099 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1100 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1101
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1102 static void irc_user_opts(GtkWidget * book, struct aim_user *user)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1103 {
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1104 /* so here, we create the new notebook page */
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1105 GtkWidget *vbox;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1106 GtkWidget *hbox;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1107 GtkWidget *label;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1108 GtkWidget *entry;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1109
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1110 vbox = gtk_vbox_new(FALSE, 0);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1111 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
1112 gtk_widget_show(vbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1113
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1114 hbox = gtk_hbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1115 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1116 gtk_widget_show(hbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1117
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1118 label = gtk_label_new("Server:");
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1119 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1120 gtk_widget_show(label);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1121
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1122 entry = gtk_entry_new();
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1123 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
1124 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
1125 if (user->proto_opt[0][0]) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1126 debug_printf("setting text %s\n", user->proto_opt[0]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1127 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1128 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1129 gtk_widget_show(entry);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1130
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1131 hbox = gtk_hbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1132 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1133 gtk_widget_show(hbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1134
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1135 label = gtk_label_new("Port:");
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1136 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1137 gtk_widget_show(label);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1138
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1139 entry = gtk_entry_new();
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1140 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1141 if (user->proto_opt[1][0]) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1142 debug_printf("setting text %s\n", user->proto_opt[1]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1143 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
1144 } else {
7f4302f6fd64 [gaim-migrate @ 1314]
Rob Flynn <gaim@robflynn.com>
parents: 1301
diff changeset
1145 gtk_entry_set_text(GTK_ENTRY(entry), "6667");
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1146 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1147 gtk_object_set_user_data(GTK_OBJECT(entry), user);
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1148 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
1149 gtk_widget_show(entry);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1150 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1151
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1152 static char **irc_list_icon(int uc)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1153 {
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1154 return free_icon_xpm;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1155 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1156
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1157 /* Send out a ping request to the specified user */
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1158 static void irc_send_ping(GtkObject * w, char *who)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1159 {
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1160 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
1161 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1162 char buf[BUF_LEN];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1163
1393
3b5c7f8bb2b5 [gaim-migrate @ 1403]
Rob Flynn <gaim@robflynn.com>
parents: 1304
diff changeset
1164 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001');
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1165
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1166 write(idata->fd, buf, strlen(buf));
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1167 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1168
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1169
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1170 static void irc_buddy_menu(GtkWidget * menu, struct gaim_connection *gc, char *who)
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1171 {
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1172 GtkWidget *button;
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1173
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1174 button = gtk_menu_item_new_with_label("Ping");
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1175 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
1176 gtk_object_set_user_data(GTK_OBJECT(button), gc);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1177 gtk_menu_append(GTK_MENU(menu), button);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1178 gtk_widget_show(button);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1179 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1180
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1181
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1182 static struct prpl *my_protocol = NULL;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1183
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1184 static void irc_init(struct prpl *ret)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1185 {
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1186 ret->protocol = PROTO_IRC;
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1187 ret->name = irc_name;
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1188 ret->list_icon = irc_list_icon;
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1189 ret->buddy_menu = irc_buddy_menu;
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1190 ret->user_opts = irc_user_opts;
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1191 ret->login = irc_login;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1192 ret->close = irc_close;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1193 ret->send_im = irc_send_im;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1194 ret->join_chat = irc_join_chat;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1195 ret->chat_leave = irc_chat_leave;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1196 ret->chat_send = irc_chat_send;
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1197
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1198 my_protocol = ret;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1199 }
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1200
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1201 char *gaim_plugin_init(GModule * handle)
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1202 {
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1394
diff changeset
1203 load_protocol(irc_init, sizeof(struct prpl));
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1204 return NULL;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1205 }
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1206
1266
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1207 void gaim_plugin_remove()
aac04affc65d [gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1265
diff changeset
1208 {
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1209 struct prpl *p = find_prpl(PROTO_IRC);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1210 if (p == my_protocol)
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1211 unload_protocol(p);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1212 }