annotate plugins/irc.c @ 1090:79cdc86ef4c6

[gaim-migrate @ 1100] necessary checks committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 13 Nov 2000 02:59:23 +0000
parents f0f5c10cce63
children c964df5b2a84
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>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <string.h>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <stdlib.h>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <stdio.h>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include <time.h>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include <sys/socket.h>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #include <sys/stat.h>
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 #include "multi.h"
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #include "prpl.h"
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 #include "gaim.h"
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 #include "gnome_applet_mgr.h"
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 #include "pixmaps/cancel.xpm"
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 #include "pixmaps/ok.xpm"
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
46 #define IRC_BUF_LEN 4096
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
47
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
48
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
49 static int chat_id = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
50
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
51 struct irc_channel {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
52 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
53 gchar *name;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
56 struct irc_data {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
57 int fd;
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
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
68 static char *irc_name() {
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
69 return "IRC";
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
70 }
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 char *name() {
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
73 return "IRC";
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
74 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
75
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
76 char *description() {
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
77 return "Allows gaim to use the IRC protocol";
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
78 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
79
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
80 void irc_join_chat( struct gaim_connection *gc, int id, char *name) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
81 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
82 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
83
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
84 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
85 write(idata->fd, buf, strlen(buf));
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
86
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
87 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
88 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
89
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
90 void irc_update_user (struct gaim_connection *gc, char *name, int status) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
91 struct irc_data *idata = (struct irc_data *)gc->proto_data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
92 struct irc_channel *u;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
93 GSList *temp = idata->templist;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
94
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
95 /* Loop through our list */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
96
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
97 while (temp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
98 u = (struct irc_channel *)temp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
99 if (g_strcasecmp(u->name, name) == 0) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
100 u->id = status;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
101 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
102 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
103
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
104 temp = g_slist_next(temp);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
105 }
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 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
108
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
109 void irc_request_buddy_update ( struct gaim_connection *gc ) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
110 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1046
4593605da0e2 [gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1022
diff changeset
111 GSList *grp = gc->groups;
4593605da0e2 [gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1022
diff changeset
112 GSList *person;
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
113 struct group *g;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
114 struct buddy *b;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
115 struct irc_channel *u;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
116 gchar buf[IRC_BUF_LEN+1];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
117
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
118 if (idata->templist != NULL)
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
119 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
120
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
121 idata->recblocks = 0;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
122 idata->totalblocks = 1;
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 /* Send the first part of our request */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
125 write(idata->fd, "ISON", 4);
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 /* Step through our list of groups */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
128 while (grp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
129
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
130 g = (struct group *)grp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
131 person = g->members;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
132
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
133 while (person) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
134 b = (struct buddy *)person->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
135
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
136 /* 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
137 * but hey, its the exact same data structure. Why should we
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
138 * bother with making another one */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
139
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
140 u = g_new0(struct irc_channel, 1);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
141 u->id = 0; /* Assume by default that they're offline */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
142 u->name = strdup(b->name);
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 write(idata->fd, " ", 1);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
145 write(idata->fd, u->name, strlen(u->name));
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
146 idata->templist = g_slist_append(idata->templist, u);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
147
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
148 person = person->next;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
149 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
150
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
151 grp = g_slist_next(grp);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
152 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
153 write(idata->fd, "\n", 1);
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
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
156
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
157 void irc_send_im( struct gaim_connection *gc, char *who, char *message, int away) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
158
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
159 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
160 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
161
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
162 /* 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
163 * To issue a /me command and handle it properly. */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
164
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
165 if ( (g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message)>4)) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
166 /* We have /me!! We have /me!! :-) */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
167
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
168 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
169 strcpy(temp, message+4);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
170 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
171 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
172 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
173 else
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
174 {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
175 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
176 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
177
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
178 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
179
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
180 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
181 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
182
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
183 int find_id_by_name(struct gaim_connection *gc, char *name) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
184 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
185 GList *templist;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
186 struct irc_channel *channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
187
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
188 templist = ((struct irc_data *)gc->proto_data)->channels;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
189
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
190 while (templist) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
191 channel = (struct irc_channel *)templist->data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
192
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
193 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
194
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
195 if (g_strcasecmp(temp, name) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
196 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
197 return channel->id;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
200 templist = templist -> next;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
201 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
202
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
203 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
204
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
205 /* Return -1 if we have no ID */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
206 return -1;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
207 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
208
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
209 struct irc_channel * find_channel_by_name(struct gaim_connection *gc, char *name) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
210 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
211 GList *templist;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
212 struct irc_channel *channel;
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 templist = ((struct irc_data *)gc->proto_data)->channels;
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 while (templist) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
217 channel = (struct irc_channel *)templist->data;
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 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
220
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
221 if (g_strcasecmp(temp, name) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
222 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
223 return channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
224 }
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 = templist -> next;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
229 g_free(temp);
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 /* If we found nothing, return nothing :-) */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
232 return NULL;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
233 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
234
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
235 struct irc_channel * find_channel_by_id (struct gaim_connection *gc, int id) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
236 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
237 struct irc_channel *channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
238
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
239 GList *temp;
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 temp = idata->channels;
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 while (temp) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
244 channel = (struct irc_channel *)temp->data;
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 if (channel->id == id) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
247 /* We've found our man */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
248 return channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
249 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
250
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
251 temp = temp->next;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
252 }
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
255 /* If we didnt find one, return NULL */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
256 return NULL;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
257 }
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 void irc_chat_send( struct gaim_connection *gc, int id, char *message) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
260
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
261 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
262 struct irc_channel *channel = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
263 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
264
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
265 /* First lets get our current channel */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
266 channel = find_channel_by_id(gc, id);
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
269 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
270 /* 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
271 g_free(buf);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
272 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
273 }
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
276 /* 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
277 * To issue a /me command and handle it properly. */
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 if ( (g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message)>4)) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
280 /* We have /me!! We have /me!! :-) */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
281
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
282 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
283 strcpy(temp, message+4);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
284 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%cACTION %s%c\n", channel->name, '\001', temp, '\001');
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
285 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
286 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
287 else
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
288 {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
289 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
290 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
291
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
292 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
293
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
294 /* 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
295 serv_got_chat_in(gc, id, gc->username, 0, message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
296
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
297 g_free(buf);
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
298 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
299
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
300 struct conversation * find_conversation_by_id( struct gaim_connection * gc, int id) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
301 struct irc_data *idata = (struct irc_data *)gc->proto_data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
302 GSList *bc = gc->buddy_chats;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
303 struct conversation *b = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
304
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
305 while (bc) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
306 b = (struct conversation *)bc->data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
307 if (id == b->id) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
308 break;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
309 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
310 bc = bc->next;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
311 b = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
312 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
313
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
314 if (!b) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
315 return NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
316 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
317
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
318 return b;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
319 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
320
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
321 struct conversation * find_conversation_by_name( struct gaim_connection * gc, char *name) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
322 struct irc_data *idata = (struct irc_data *)gc->proto_data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
323 GSList *bc = gc->buddy_chats;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
324 struct conversation *b = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
325
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
326 while (bc) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
327 b = (struct conversation *)bc->data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
328
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
329 if (g_strcasecmp(name, b->name) == 0) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
330 break;
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 bc = bc->next;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
333 b = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
334 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
335
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
336 if (!b) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
337 return NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
338 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
339
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
340 return b;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
341 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
342
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
343
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
344
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
345 void irc_callback ( struct gaim_connection * gc ) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
346
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
347 int i = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
348 char c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
349 gchar buf[4096];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
350 gchar **buf2;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
351 int status;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
352 struct irc_data *idata;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
353
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
354 idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
355
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
356 do {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
357 status = recv(idata->fd, &c, 1, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
358
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
359 if (!status)
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
360 {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
361 exit(1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
362 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
363 buf[i] = c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
364 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
365 } while (c != '\n');
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
366
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
367 buf[i] = '\0';
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 /* And remove that damned trailing \n */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
370 g_strchomp(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
371
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
372 /* For now, lets display everything to the console too. Im such
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
373 * a bitch */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
374 printf("IRC:'%'s\n", buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
375
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
376
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
377 /* 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
378 * a channel */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
379
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
380 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) &&
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
381 (!strstr(buf, "NOTICE")))) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
382 gchar u_host[255];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
383 gchar u_command[32];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
384 gchar u_channel[128];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
385 gchar u_names[IRC_BUF_LEN + 1];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
386 struct conversation *convo = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
387 int j;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
388
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
389 for (j = 0, i = 0; buf[i] != ' '; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
390 u_host[j] = buf[i];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
391 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
392
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
393 u_host[j] = '\0'; i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
394
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
395 for (j = 0; buf[i] != ' '; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
396 u_command[j] = buf[i];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
397 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
398
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
399 u_command[j] = '\0'; i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
400
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
401 for (j = 0; buf[i] != '#'; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
402 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
403 i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
404
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
405 for (j = 0; buf[i] != ':'; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
406 u_channel[j] = buf[i];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
407 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
408
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
409 u_channel[j-1] = '\0'; i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
410
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
411 while ((buf[i] == ' ') || (buf[i] == ':')) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
412 i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
413 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
414
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
415 strcpy(u_names, buf + i);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
416
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
417 buf2 = g_strsplit(u_names, " ", 0);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
418
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
419 /* Let's get our conversation window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
420 convo = find_conversation_by_name(gc, u_channel);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
421
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
422 if (!convo) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
423 return;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
424 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
425
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
426 /* Now that we've parsed the hell out of this big
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
427 * mess, let's try to split up the names properly */
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 for (i = 0; buf2[i] != NULL; i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
430 /* We shouldnt play with ourselves */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
431 if (g_strcasecmp(buf2[i], gc->username) != 0) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
432 /* Add the person to the list */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
433 add_chat_buddy(convo, buf2[i]);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
434 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
435 }
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
436
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
437 /* And free our pointers */
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
438 g_strfreev (buf2);
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
439
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
440 return;
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 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
443
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
444 /* Receive a list of users that are currently online */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
445
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
446 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) &&
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
447 (!strstr(buf, "NOTICE")))) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
448 gchar u_host[255];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
449 gchar u_command[32];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
450 gchar u_names[IRC_BUF_LEN + 1];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
451 int j;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
452
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
453 for (j = 0, i = 0; buf[i] != ' '; j++, i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
454 u_host[j] = buf[i];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
455 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
456
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
457 u_host[j] = '\0'; i++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
458
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
459 for (j = 0; buf[i] != ' '; j++, i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
460 u_command[j] = buf[i];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
461 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
462
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
463 u_command[j] = '\0'; i++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
464
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
465 for (j = 0; buf[i] != ':'; j++, i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
466 /* My Nick */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
467 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
468 i++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
469
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
470 strcpy(u_names, buf + i);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
471
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
472 buf2 = g_strsplit(u_names, " ", 0);
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 /* Now that we've parsed the hell out of this big
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
475 * mess, let's try to split up the names properly */
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 for (i = 0; buf2[i] != NULL; i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
478 /* 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
479 * update our temporary gslist accordingly. When we achieve our maximum
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
480 * list of names then we should force an update */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
481
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
482 irc_update_user(gc, buf2[i], 1);
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
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
485 /* Increase our received blocks counter */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
486 idata->recblocks++;
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 /* If we have our total number of blocks */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
489 if (idata->recblocks == idata->totalblocks) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
490 GSList *temp;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
491 struct irc_channel *u;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
492
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
493 /* 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
494 temp = idata->templist;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
495
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
496 /* Loop */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
497 while (temp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
498
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
499 u = temp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
500
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
501 /* Tell Gaim to bring the person on or off line */
1046
4593605da0e2 [gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1022
diff changeset
502 serv_got_update(gc, u->name, u->id, 0, 0, 0, 0, 0);
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
503
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
504 /* Grab the next entry */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
505 temp = g_slist_next(temp);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
506 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
507
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
508 /* And now, let's delete all of our entries */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
509 temp = idata->templist;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
510 while (temp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
511 u = temp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
512 g_free(u->name);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
513 temp = g_slist_remove(temp, u);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
514 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
515
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
516 /* Reset our list */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
517 idata->totalblocks = 0;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
518 idata->recblocks = 0;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
519
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
520 idata->templist = NULL;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
521
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
522 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
523 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
524
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
525 /* And free our pointers */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
526 g_strfreev (buf2);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
527
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
528 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
529
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
530 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
531
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
532
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
533 if ( (strstr(buf, " JOIN ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
534
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
535 gchar u_channel[128];
1012
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
536 gchar u_nick[128];
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
537
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
538 struct irc_channel *channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
539 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
540 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
541
1012
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
542 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
543 u_nick[j] = buf[i];
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
544 }
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
545
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
546 u_nick[j] = '\0'; i++;
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
547
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
548 for (j = 0; buf[i] != '#'; j++, i++) {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
549 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
550
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
551 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
552
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
553 strcpy(u_channel, buf+i);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
554
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
555 /* Looks like we're going to join the channel for real
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
556 * now. Let's create a valid channel structure and add
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
557 * it to our list. Let's make sure that
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
558 * we are not already in a channel first */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
559
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
560 channel = find_channel_by_name(gc, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
561
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
562 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
563 chat_id++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
564
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
565 channel = g_new0(struct irc_channel, 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
566
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
567 channel->id = chat_id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
568 channel->name = strdup(u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
569
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
570 idata->channels = g_list_append(idata->channels, channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
571
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
572 serv_got_joined_chat(gc, chat_id, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
573 } else {
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
574 struct conversation *convo = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
575
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
576 /* Someone else joined. Find their conversation
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
577 * window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
578 convo = find_conversation_by_id(gc, channel->id);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
579
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
580 /* And add their name to it */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
581 add_chat_buddy(convo, u_nick);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
582
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
583 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
584
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
585 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
586 }
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 ( (strstr(buf, " PART ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
589
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
590 gchar u_channel[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
591 gchar u_nick[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
592
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
593 struct irc_channel *channel;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
594 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
595 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
596 GList *test = NULL;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
597
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
598 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
599 u_nick[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
600 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
601 u_nick[j] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
602
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
603 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
604
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
605 for (j = 0; buf[i] != '#'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
606 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
607
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
608 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
609
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
610 strcpy(u_channel, buf+i);
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
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
613 /* 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
614 * 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
615 * old channel stuff. Otherwise,
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
616 * we should just print that someone left */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
617
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
618 channel = find_channel_by_name(gc, u_channel);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
619
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
620 if (!channel) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
621 return;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
622 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
623
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
624 if (g_strcasecmp(u_nick, gc->username) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
625
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
626 /* Looks like we're going to leave the channel for
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
627 * real now. Let's create a valid channel structure
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
628 * and add it to our list */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
629
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
630 serv_got_chat_left(gc, channel->id);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
631
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
632 idata->channels = g_list_remove(idata->channels, channel);
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
633 } else {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
634 struct conversation *convo = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
635
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
636 /* Find their conversation window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
637 convo = find_conversation_by_id(gc, channel->id);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
638
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
639 if (!convo) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
640 /* Some how the window doesn't exist.
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
641 * Let's get out of here */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
642 return ;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
643 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
644
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
645 /* And remove their name */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
646 remove_chat_buddy(convo, u_nick);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
647
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
648 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
649
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
650 /* Go Home! */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
651 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
652 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
653
1012
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
654 if ( (strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
655 gchar u_nick[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
656 gchar u_host[255];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
657 gchar u_command[32];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
658 gchar u_channel[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
659 gchar u_message[IRC_BUF_LEN];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
660 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
661 int msgcode = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
662
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
663 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
664 u_nick[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
665 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
666
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
667 u_nick[j] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
668
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
669 for (j = 0; buf[i] != ' '; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
670 u_host[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
671 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
672
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
673 u_host[j] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
674
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
675 for (j = 0; buf[i] != ' '; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
676 u_command[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
677 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
678
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
679 u_command[j] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
680
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
681 for (j = 0; buf[i] != ':'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
682 u_channel[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
683 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
684
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
685 u_channel[j-1] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
686
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
687
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
688 /* 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
689 strncpy(u_message, buf + i, IRC_BUF_LEN);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
690
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
691 /* 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
692 if (u_message[0] == '\001') {
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
693 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) {
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
694 /* Looks like we have a version request. Let
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
695 * us handle it thusly */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
696
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
697 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cVERSION GAIM %s:The Pimpin Penguin AIM Clone:www.marko.net/gaim%c\n", u_nick, '\001', VERSION, '\001');
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
698
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
699 write(idata->fd, buf, strlen(buf));
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
700
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
701 /* And get the heck out of dodge */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
702 return;
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
703 }
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
704
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
705 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
706 /* Someone's triyng to ping us. Let's respond */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
707 gchar u_arg[24];
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
708
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
709 strcpy(u_arg, u_message + 6);
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
710 u_arg[strlen(u_arg)-1] = '\0';
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
711
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
712 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cPING %s%c\n", u_nick, '\001', u_arg, '\001');
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
713
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
714 write(idata->fd, buf, strlen(buf));
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
715
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
716 /* And get the heck out of dodge */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
717 return;
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
718 }
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
719
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
720 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
721 /* 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
722 strcpy(buf, u_message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
723
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
724 strcpy(u_message, "/me ");
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
725 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
726 u_message[j] = buf[i];
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 u_message[j] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
729 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
730 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
731
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
732
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
733 /* 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
734 if (u_channel[0] == '#') {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
735 /* Yup. We have a channel */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
736 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
737
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
738 id = find_id_by_name(gc, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
739 if (id != -1) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
740 serv_got_chat_in(gc, id, u_nick, 0, u_message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
741 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
742 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
743 else {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
744 /* Nope. Let's treat it as a private message */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
745 serv_got_im(gc, u_nick, u_message, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
746 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
747
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
748 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
749 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
750
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
751 /* 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
752
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
753 if (strncmp(buf, "PING :", 6) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
754 buf2 = g_strsplit(buf, ":", 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
755
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
756 /* Let's build a new response */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
757 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
758 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
759
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
760 /* And clean up after ourselves */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
761 g_strfreev(buf2);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
762
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
763 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
764 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
765
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
766 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
767
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
768 void irc_handler(gpointer data, gint source, GdkInputCondition condition) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
769 irc_callback(data);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
770 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
771
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
772 void irc_close(struct gaim_connection *gc) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
773 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
774 GList *chats = idata->channels;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
775 struct irc_channel *cc;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
776
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
777 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
778
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
779 gtk_timeout_remove(idata->timer);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
780
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
781 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
782 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
783
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
784 g_free(buf);
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
785
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
786 while (chats) {
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
787 cc = (struct irc_channel *)chats->data;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
788 g_free(cc->name);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
789 chats = g_list_remove(chats, cc);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
790 g_free(cc);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
791 }
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
792
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
793 if (gc->inpa)
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
794 gdk_input_remove(gc->inpa);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
795
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
796 close(idata->fd);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
797 g_free(gc->proto_data);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
798 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
799
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
800 void irc_chat_leave(struct gaim_connection *gc, int id) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
801 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
802 struct irc_channel *channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
803 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
804
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
805 channel = find_channel_by_id(gc, id);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
806
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
807 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
808 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
809 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
810
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
811 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
812 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
813
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
814 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
815 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
816
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
817 void irc_login(struct aim_user *user) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
818 int fd;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
819 struct hostent *host;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
820 struct sockaddr_in site;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
821 char buf[4096];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
822
1089
f0f5c10cce63 [gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1075
diff changeset
823 struct gaim_connection *gc = new_gaim_conn(user);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
824 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
825 char c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
826 int i;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
827 int status;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
828
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
829 set_login_progress(gc, 1, buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
830
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
831 while (gtk_events_pending())
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
832 gtk_main_iteration();
1090
79cdc86ef4c6 [gaim-migrate @ 1100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1089
diff changeset
833 if (!g_slist_find(connections, gc))
79cdc86ef4c6 [gaim-migrate @ 1100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1089
diff changeset
834 return;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
835
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
836 host = gethostbyname(user->proto_opt[0]);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
837 if (!host) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
838 hide_login_progress(gc, "Unable to resolve hostname");
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
839 destroy_gaim_conn(gc);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
840 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
841 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
842
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
843 site.sin_family = AF_INET;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
844 site.sin_addr.s_addr = *(long *)(host->h_addr);
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
845 site.sin_port = htons(atoi(user->proto_opt[1]));
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
846
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
847 fd = socket(AF_INET, SOCK_STREAM, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
848 if (fd < 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
849 hide_login_progress(gc, "Unable to create socket");
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
850 destroy_gaim_conn(gc);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
851 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
852 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
853
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
854 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
855 hide_login_progress(gc, "Unable to connect.");
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
856 destroy_gaim_conn(gc);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
857 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
858 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
859
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
860 idata->fd = fd;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
861
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
862 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
863 set_login_progress(gc, 2, buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
864
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
865 /* This is where we will attempt to sign on */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
866
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
867 /* FIXME: This should be their servername, not their username. im just lazy right now */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
868
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
869 g_snprintf(buf, 4096, "NICK %s\nUSER %s localhost %s :GAIM (www.marko.net/gaim)\n", gc->username, gc->username, gc->username);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
870 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
871
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
872
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
873 /* Now lets sign ourselves on */
1089
f0f5c10cce63 [gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1075
diff changeset
874 account_online(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
875 serv_finish_login(gc);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
876
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
877 if (bud_list_cache_exists(gc))
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
878 do_import(NULL, gc);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
879
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
880
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
881 gc->inpa = gdk_input_add(idata->fd, GDK_INPUT_READ, irc_handler, gc);
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
882
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
883 /* We want to update our buddlist every 20 seconds */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
884 idata->timer = gtk_timeout_add(20000, (GtkFunction)irc_request_buddy_update, gc);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
885
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
886 /* But first, let's go ahead and check our list */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
887 irc_request_buddy_update(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
888 }
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
889
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
890 static void irc_print_option(GtkEntry *entry, struct aim_user *user) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
891 if (gtk_object_get_user_data(GTK_OBJECT(entry))) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
892 g_snprintf(user->proto_opt[1], sizeof(user->proto_opt[1]), "%s",
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
893 gtk_entry_get_text(entry));
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
894 } else {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
895 g_snprintf(user->proto_opt[0], sizeof(user->proto_opt[0]), "%s",
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
896 gtk_entry_get_text(entry));
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
897 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
898 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
899
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
900 static void irc_user_opts(GtkWidget *book, struct aim_user *user) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
901 /* so here, we create the new notebook page */
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
902 GtkWidget *vbox;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
903 GtkWidget *hbox;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
904 GtkWidget *label;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
905 GtkWidget *entry;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
906
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
907 vbox = gtk_vbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
908 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox,
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
909 gtk_label_new("IRC Options"));
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
910 gtk_widget_show(vbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
911
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
912 hbox = gtk_hbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
913 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
914 gtk_widget_show(hbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
915
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
916 label = gtk_label_new("Server:");
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
917 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
918 gtk_widget_show(label);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
919
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
920 entry = gtk_entry_new();
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
921 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
922 gtk_signal_connect(GTK_OBJECT(entry), "changed",
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
923 GTK_SIGNAL_FUNC(irc_print_option), user);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
924 if (user->proto_opt[0][0]) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
925 debug_printf("setting text %s\n", user->proto_opt[0]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
926 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
927 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
928 gtk_widget_show(entry);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
929
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
930 hbox = gtk_hbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
931 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
932 gtk_widget_show(hbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
933
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
934 label = gtk_label_new("Port:");
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
935 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
936 gtk_widget_show(label);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
937
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
938 entry = gtk_entry_new();
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
939 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
940 if (user->proto_opt[1][0]) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
941 debug_printf("setting text %s\n", user->proto_opt[1]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
942 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
943 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
944 gtk_object_set_user_data(GTK_OBJECT(entry), user);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
945 gtk_signal_connect(GTK_OBJECT(entry), "changed",
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
946 GTK_SIGNAL_FUNC(irc_print_option), user);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
947 gtk_widget_show(entry);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
948 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
949
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
950 static struct prpl *my_protocol = NULL;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
951
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
952 void irc_init(struct prpl *ret) {
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
953 ret->protocol = PROTO_IRC;
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
954 ret->name = irc_name;
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
955 ret->user_opts = irc_user_opts;
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
956 ret->login = irc_login;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
957 ret->close = irc_close;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
958 ret->send_im = irc_send_im;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
959 ret->set_info = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
960 ret->get_info = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
961 ret->set_away = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
962 ret->get_away_msg = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
963 ret->set_dir = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
964 ret->get_dir = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
965 ret->dir_search = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
966 ret->set_idle = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
967 ret->change_passwd = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
968 ret->add_buddy = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
969 ret->add_buddies = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
970 ret->remove_buddy = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
971 ret->add_permit = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
972 ret->add_deny = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
973 ret->warn = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
974 ret->accept_chat = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
975 ret->join_chat = irc_join_chat;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
976 ret->chat_invite = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
977 ret->chat_leave = irc_chat_leave;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
978 ret->chat_whisper = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
979 ret->chat_send = irc_chat_send;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
980 ret->keepalive = NULL;
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
981
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
982 my_protocol = ret;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
983 }
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
984
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
985 char *gaim_plugin_init(GModule *handle) {
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
986 load_protocol(irc_init);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
987 return NULL;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
988 }
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
989
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
990 void gaim_plugin_remove() {
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
991 struct prpl *p = find_prpl(PROTO_IRC);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
992 if (p == my_protocol)
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
993 unload_protocol(p);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
994 }