annotate plugins/irc.c @ 1213:1bdb08cc5d59

[gaim-migrate @ 1223] redid the away msg dialog a bit committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 08 Dec 2000 06:21:44 +0000
parents 4291c96c5096
children 245d040422ce
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
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
46 #include "pixmaps/free_icon.xpm"
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
47
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
48 #define IRC_BUF_LEN 4096
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
49
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
50
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
51 static int chat_id = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
52
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
53 struct irc_channel {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
54 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
55 gchar *name;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
56 };
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
57
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
58 struct irc_data {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
59 int fd;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
60
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
61 int timer;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
62
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
63 int totalblocks;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
64 int recblocks;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
65
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
66 GSList *templist;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
67 GList *channels;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
68 };
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
69
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
70 static char *irc_name() {
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
71 return "IRC";
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
72 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
73
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
74 char *name() {
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
75 return "IRC";
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
76 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
77
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
78 char *description() {
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
79 return "Allows gaim to use the IRC protocol";
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
80 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
81
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
82 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
83 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
84 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
85
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
86 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
87 write(idata->fd, buf, strlen(buf));
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
88
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
89 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
90 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
91
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
92 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
93 struct irc_data *idata = (struct irc_data *)gc->proto_data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
94 struct irc_channel *u;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
95 GSList *temp = idata->templist;
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 /* Loop through our list */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
98
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
99 while (temp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
100 u = (struct irc_channel *)temp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
101 if (g_strcasecmp(u->name, name) == 0) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
102 u->id = status;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
103 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
104 }
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 temp = g_slist_next(temp);
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 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
109 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
110
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
111 void irc_request_buddy_update ( struct gaim_connection *gc ) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
112 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1046
4593605da0e2 [gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1022
diff changeset
113 GSList *grp = gc->groups;
4593605da0e2 [gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1022
diff changeset
114 GSList *person;
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
115 struct group *g;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
116 struct buddy *b;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
117 struct irc_channel *u;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
118 gchar buf[IRC_BUF_LEN+1];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
119
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
120 if (idata->templist != NULL)
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
121 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
122
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
123 idata->recblocks = 0;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
124 idata->totalblocks = 1;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
125
1105
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
126 /* First, let's check to see if we have anyone on our buddylist */
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
127 if (!grp) {
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
128 return;
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
129 }
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
130
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
131 /* Send the first part of our request */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
132 write(idata->fd, "ISON", 4);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
133
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
134 /* Step through our list of groups */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
135 while (grp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
136
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
137 g = (struct group *)grp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
138 person = g->members;
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 while (person) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
141 b = (struct buddy *)person->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
142
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
143 /* 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
144 * but hey, its the exact same data structure. Why should we
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
145 * bother with making another one */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
146
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
147 u = g_new0(struct irc_channel, 1);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
148 u->id = 0; /* Assume by default that they're offline */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
149 u->name = strdup(b->name);
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 write(idata->fd, " ", 1);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
152 write(idata->fd, u->name, strlen(u->name));
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
153 idata->templist = g_slist_append(idata->templist, u);
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 person = person->next;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
156 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
157
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
158 grp = g_slist_next(grp);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
159 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
160 write(idata->fd, "\n", 1);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
161 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
162
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
163
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
164 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
165
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
166 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
167 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
168
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
169 /* 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
170 * To issue a /me command and handle it properly. */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
171
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
172 if ( (g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message)>4)) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
173 /* We have /me!! We have /me!! :-) */
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 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
176 strcpy(temp, message+4);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
177 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
178 g_free(temp);
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 else
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 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
183 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
184
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
185 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
186
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
187 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
188 }
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 int find_id_by_name(struct gaim_connection *gc, char *name) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
191 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
192 GList *templist;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
193 struct irc_channel *channel;
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 templist = ((struct irc_data *)gc->proto_data)->channels;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
196
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
197 while (templist) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
198 channel = (struct irc_channel *)templist->data;
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 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name);
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 if (g_strcasecmp(temp, name) == 0) {
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 return channel->id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
205 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
206
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
207 templist = templist -> next;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
210 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
211
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
212 /* Return -1 if we have no ID */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
213 return -1;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
214 }
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 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
217 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
218 GList *templist;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
219 struct irc_channel *channel;
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 templist = ((struct irc_data *)gc->proto_data)->channels;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
222
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
223 while (templist) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
224 channel = (struct irc_channel *)templist->data;
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 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name);
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 if (g_strcasecmp(temp, name) == 0) {
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 return channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
231 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
232
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
233 templist = templist -> next;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
236 g_free(temp);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
237
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
238 /* If we found nothing, return nothing :-) */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
239 return NULL;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
242 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
243 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
244 struct irc_channel *channel;
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 GList *temp;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
247
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
248 temp = idata->channels;
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 while (temp) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
251 channel = (struct irc_channel *)temp->data;
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 if (channel->id == id) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
254 /* We've found our man */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
255 return channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
256 }
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 temp = temp->next;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
259 }
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
262 /* If we didnt find one, return NULL */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
263 return NULL;
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
266 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
267
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
268 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
269 struct irc_channel *channel = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
270 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
271
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
272 /* First lets get our current channel */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
273 channel = find_channel_by_id(gc, id);
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 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
277 /* 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
278 g_free(buf);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
279 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
280 }
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
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
283 /* 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
284 * To issue a /me command and handle it properly. */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
285
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
286 if ( (g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message)>4)) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
287 /* We have /me!! We have /me!! :-) */
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 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
290 strcpy(temp, message+4);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
291 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
292 g_free(temp);
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 else
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
295 {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
296 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
297 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
298
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
299 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
300
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
301 /* 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
302 serv_got_chat_in(gc, id, gc->username, 0, message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
303
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
304 g_free(buf);
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
305 }
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
306
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
307 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
308 struct irc_data *idata = (struct irc_data *)gc->proto_data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
309 GSList *bc = gc->buddy_chats;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
310 struct conversation *b = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
311
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
312 while (bc) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
313 b = (struct conversation *)bc->data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
314 if (id == b->id) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
315 break;
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 bc = bc->next;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
318 b = NULL;
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 if (!b) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
322 return NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
323 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
324
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
325 return b;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
326 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
327
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
328 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
329 struct irc_data *idata = (struct irc_data *)gc->proto_data;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
330 GSList *bc = gc->buddy_chats;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
331 struct conversation *b = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
332
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
333 while (bc) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
334 b = (struct conversation *)bc->data;
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 (g_strcasecmp(name, b->name) == 0) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
337 break;
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 bc = bc->next;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
340 b = NULL;
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 if (!b) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
344 return NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
345 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
346
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
347 return b;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
348 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
349
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
350
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
351
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
352 void irc_callback ( struct gaim_connection * gc ) {
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 int i = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
355 char c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
356 gchar buf[4096];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
357 gchar **buf2;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
358 int status;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
359 struct irc_data *idata;
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 idata = (struct irc_data *)gc->proto_data;
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 do {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
364 status = recv(idata->fd, &c, 1, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
365
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
366 if (!status)
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
367 {
1105
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
368 return;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
369 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
370 buf[i] = c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
371 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
372 } while (c != '\n');
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
373
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
374 buf[i] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
375
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
376 /* And remove that damned trailing \n */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
377 g_strchomp(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
378
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
379 /* For now, lets display everything to the console too. Im such
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
380 * a bitch */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
381 printf("IRC:'%'s\n", buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
382
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
383
1105
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
384
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
385 /* Check for errors */
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
386
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
387 if (((strstr(buf, "ERROR :") && (!strstr(buf, "PRIVMSG ")) &&
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
388 (!strstr(buf, "NOTICE ")) && (strlen(buf) > 7)))) {
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
389
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
390 gchar *u_errormsg;
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
391
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
392 /* Let's get our error message */
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
393 u_errormsg = strdup(buf + 7);
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
394
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
395 /* We got our error message. Now, let's reaise an
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
396 * error dialog */
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
397
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
398 do_error_dialog(u_errormsg, "Gaim: IRC Error");
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
399
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
400 /* And our necessary garbage collection */
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
401 free(u_errormsg);
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
402 }
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
403
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
404 /* 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
405 * a channel */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
406
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
407 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) &&
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
408 (!strstr(buf, "NOTICE")))) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
409 gchar u_host[255];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
410 gchar u_command[32];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
411 gchar u_channel[128];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
412 gchar u_names[IRC_BUF_LEN + 1];
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
413 struct conversation *convo = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
414 int j;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
415
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
416 for (j = 0, i = 0; buf[i] != ' '; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
417 u_host[j] = buf[i];
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
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
420 u_host[j] = '\0'; i++;
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 for (j = 0; buf[i] != ' '; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
423 u_command[j] = buf[i];
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 u_command[j] = '\0'; i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
427
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
428 for (j = 0; buf[i] != '#'; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
429 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
430 i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
431
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
432 for (j = 0; buf[i] != ':'; j++, i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
433 u_channel[j] = buf[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
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
436 u_channel[j-1] = '\0'; i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
437
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
438 while ((buf[i] == ' ') || (buf[i] == ':')) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
439 i++;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
440 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
441
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
442 strcpy(u_names, buf + i);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
443
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
444 buf2 = g_strsplit(u_names, " ", 0);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
445
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
446 /* Let's get our conversation window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
447 convo = find_conversation_by_name(gc, u_channel);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
448
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
449 if (!convo) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
450 return;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
451 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
452
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
453 /* Now that we've parsed the hell out of this big
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
454 * mess, let's try to split up the names properly */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
455
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
456 for (i = 0; buf2[i] != NULL; i++) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
457 /* We shouldnt play with ourselves */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
458 if (g_strcasecmp(buf2[i], gc->username) != 0) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
459 /* Add the person to the list */
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
460
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
461 /* FIXME: These really should be in alphabetical order and OPS and Voice first */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
462
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
463 add_chat_buddy(convo, buf2[i]);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
464 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
465 }
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
466
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
467 /* And free our pointers */
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
468 g_strfreev (buf2);
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
469
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
470 return;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
471
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
472 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
473
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
474 /* Receive a list of users that are currently online */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
475
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
476 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) &&
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
477 (!strstr(buf, "NOTICE")))) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
478 gchar u_host[255];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
479 gchar u_command[32];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
480 gchar u_names[IRC_BUF_LEN + 1];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
481 int j;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
482
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
483 for (j = 0, i = 0; buf[i] != ' '; j++, i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
484 u_host[j] = buf[i];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
485 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
486
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
487 u_host[j] = '\0'; i++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
488
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
489 for (j = 0; buf[i] != ' '; j++, i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
490 u_command[j] = buf[i];
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
491 }
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 u_command[j] = '\0'; i++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
494
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
495 for (j = 0; buf[i] != ':'; j++, i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
496 /* My Nick */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
497 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
498 i++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
499
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
500 strcpy(u_names, buf + i);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
501
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
502 buf2 = g_strsplit(u_names, " ", 0);
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 /* Now that we've parsed the hell out of this big
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
505 * mess, let's try to split up the names properly */
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 for (i = 0; buf2[i] != NULL; i++) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
508 /* 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
509 * update our temporary gslist accordingly. When we achieve our maximum
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
510 * list of names then we should force an update */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
511
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
512 irc_update_user(gc, buf2[i], 1);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
513 }
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 /* Increase our received blocks counter */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
516 idata->recblocks++;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
517
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
518 /* If we have our total number of blocks */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
519 if (idata->recblocks == idata->totalblocks) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
520 GSList *temp;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
521 struct irc_channel *u;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
522
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
523 /* 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
524 temp = idata->templist;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
525
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
526 /* Loop */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
527 while (temp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
528
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
529 u = temp->data;
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 /* Tell Gaim to bring the person on or off line */
1046
4593605da0e2 [gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1022
diff changeset
532 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
533
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
534 /* Grab the next entry */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
535 temp = g_slist_next(temp);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
536 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
537
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
538 /* And now, let's delete all of our entries */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
539 temp = idata->templist;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
540 while (temp) {
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
541 u = temp->data;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
542 g_free(u->name);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
543 temp = g_slist_remove(temp, u);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
544 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
545
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
546 /* Reset our list */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
547 idata->totalblocks = 0;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
548 idata->recblocks = 0;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
549
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
550 idata->templist = NULL;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
551
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
552 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
553 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
554
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
555 /* And free our pointers */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
556 g_strfreev (buf2);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
557
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
558 return;
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
559
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
560 }
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
561
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
562
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
563 if ( (strstr(buf, " JOIN ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
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 gchar u_channel[128];
1012
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
566 gchar u_nick[128];
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
567
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
568 struct irc_channel *channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
569 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
570 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
571
1012
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
572 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
573 u_nick[j] = buf[i];
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
574 }
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
575
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
576 u_nick[j] = '\0'; i++;
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
577
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
578 for (j = 0; buf[i] != '#'; j++, i++) {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
579 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
580
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
581 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
582
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
583 strcpy(u_channel, buf+i);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
584
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
585 /* Looks like we're going to join the channel for real
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
586 * now. Let's create a valid channel structure and add
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
587 * it to our list. Let's make sure that
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
588 * we are not already in a channel first */
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 channel = find_channel_by_name(gc, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
591
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
592 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
593 chat_id++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
594
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
595 channel = g_new0(struct irc_channel, 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
596
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
597 channel->id = chat_id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
598 channel->name = strdup(u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
599
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
600 idata->channels = g_list_append(idata->channels, channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
601
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
602 serv_got_joined_chat(gc, chat_id, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
603 } else {
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
604 struct conversation *convo = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
605
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
606 /* Someone else joined. Find their conversation
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
607 * window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
608 convo = find_conversation_by_id(gc, channel->id);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
609
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
610 /* And add their name to it */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
611 add_chat_buddy(convo, u_nick);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
612
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
613 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
614
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
615 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
616 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
617
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
618 if ( (strstr(buf, " PART ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
619
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
620 gchar u_channel[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
621 gchar u_nick[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
622
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
623 struct irc_channel *channel;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
624 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
625 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
626 GList *test = NULL;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
627
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
628 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
629 u_nick[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
630 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
631 u_nick[j] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
632
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
633 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
634
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
635 for (j = 0; buf[i] != '#'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
636 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
637
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
638 i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
639
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
640 strcpy(u_channel, buf+i);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
641
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
642
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
643 /* 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
644 * 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
645 * old channel stuff. Otherwise,
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
646 * we should just print that someone left */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
647
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
648 channel = find_channel_by_name(gc, u_channel);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
649
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
650 if (!channel) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
651 return;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
652 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
653
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
654 if (g_strcasecmp(u_nick, gc->username) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
655
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
656 /* Looks like we're going to leave the channel for
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
657 * real now. Let's create a valid channel structure
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
658 * and add it to our list */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
659
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
660 serv_got_chat_left(gc, channel->id);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
661
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
662 idata->channels = g_list_remove(idata->channels, channel);
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
663 } else {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
664 struct conversation *convo = NULL;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
665
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
666 /* Find their conversation window */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
667 convo = find_conversation_by_id(gc, channel->id);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
668
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
669 if (!convo) {
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
670 /* Some how the window doesn't exist.
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
671 * Let's get out of here */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
672 return ;
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
673 }
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
674
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
675 /* And remove their name */
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
676 remove_chat_buddy(convo, u_nick);
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
677
1011
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
1014
bc4f6a535bd9 [gaim-migrate @ 1024]
Rob Flynn <gaim@robflynn.com>
parents: 1012
diff changeset
680 /* Go Home! */
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
681 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
682 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
683
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
684 if ( (strstr(buf, " NOTICE ")) && (buf[0] == ':')) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
685 gchar u_nick[128];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
686 gchar u_host[255];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
687 gchar u_command[32];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
688 gchar u_channel[128];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
689 gchar u_message[IRC_BUF_LEN];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
690 int j;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
691 int msgcode = 0;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
692
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
693 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
694 u_nick[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
695 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
696
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
697 u_nick[j] = '\0'; i++;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
698
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
699 for (j = 0; buf[i] != ' '; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
700 u_host[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
701 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
702
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
703 u_host[j] = '\0'; i++;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
704
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
705 for (j = 0; buf[i] != ' '; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
706 u_command[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
707 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
708
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
709 u_command[j] = '\0'; i++;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
710
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
711 for (j = 0; buf[i] != ':'; j++, i++) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
712 u_channel[j] = buf[i];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
713 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
714
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
715 u_channel[j-1] = '\0'; i++;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
716
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
717
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
718 /* Now that everything is parsed, the rest of this baby must be our message */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
719 strncpy(u_message, buf + i, IRC_BUF_LEN);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
720
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
721 /* Now, lets check the message to see if there's anything special in it */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
722 if (u_message[0] == '\001') {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
723 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
724 /* Someone's triyng to ping us. Let's respond */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
725 gchar u_arg[24];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
726 gchar u_buf[200];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
727
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
728 strcpy(u_arg, u_message + 6);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
729 u_arg[strlen(u_arg)-1] = '\0';
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
730
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
731 /* FIXME: We should keep track of pings we send. We should store
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
732 * the serial # and the time so that we can accurately report which
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
733 * pings are turning, etc */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
734
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
735 g_snprintf(u_buf, sizeof(u_buf), "Ping Reply From %s", u_nick);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
736
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
737 do_error_dialog(u_buf, "Gaim IRC - Ping Reply");
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
738
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
739 return;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
740 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
741 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
742
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
743 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
744
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
745
1012
7e8dcc609b30 [gaim-migrate @ 1022]
Rob Flynn <gaim@robflynn.com>
parents: 1011
diff changeset
746 if ( (strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) {
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
747 gchar u_nick[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
748 gchar u_host[255];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
749 gchar u_command[32];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
750 gchar u_channel[128];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
751 gchar u_message[IRC_BUF_LEN];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
752 int j;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
753 int msgcode = 0;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
754
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
755 for (j = 0, i = 1; buf[i] != '!'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
756 u_nick[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
757 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
758
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
759 u_nick[j] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
760
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
761 for (j = 0; buf[i] != ' '; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
762 u_host[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
763 }
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 u_host[j] = '\0'; i++;
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 for (j = 0; buf[i] != ' '; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
768 u_command[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
769 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
770
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
771 u_command[j] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
772
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
773 for (j = 0; buf[i] != ':'; j++, i++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
774 u_channel[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
775 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
776
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
777 u_channel[j-1] = '\0'; i++;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
778
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
779
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
780 /* 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
781 strncpy(u_message, buf + i, IRC_BUF_LEN);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
782
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
783 /* 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
784 if (u_message[0] == '\001') {
1017
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
785 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) {
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
786 /* Looks like we have a version request. Let
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
787 * us handle it thusly */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
788
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
789 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
790
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
791 write(idata->fd, buf, strlen(buf));
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
792
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
793 /* And get the heck out of dodge */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
794 return;
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
795 }
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
796
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
797 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
798 /* Someone's triyng to ping us. Let's respond */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
799 gchar u_arg[24];
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
800
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
801 strcpy(u_arg, u_message + 6);
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
802 u_arg[strlen(u_arg)-1] = '\0';
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
803
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
804 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
805
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
806 write(idata->fd, buf, strlen(buf));
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
807
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
808 /* And get the heck out of dodge */
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
809 return;
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
810 }
bbd0d51b7d14 [gaim-migrate @ 1027]
Rob Flynn <gaim@robflynn.com>
parents: 1014
diff changeset
811
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
812 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
813 /* 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
814 strcpy(buf, u_message);
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 strcpy(u_message, "/me ");
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
817 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
818 u_message[j] = buf[i];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
819 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
820 u_message[j] = '\0';
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
821 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
822 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
823
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
824
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
825 /* 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
826 if (u_channel[0] == '#') {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
827 /* Yup. We have a channel */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
828 int id;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
829
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
830 id = find_id_by_name(gc, u_channel);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
831 if (id != -1) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
832 serv_got_chat_in(gc, id, u_nick, 0, u_message);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
833 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
834 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
835 else {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
836 /* Nope. Let's treat it as a private message */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
837 serv_got_im(gc, u_nick, u_message, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
838 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
839
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 /* 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
844
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
845 if (strncmp(buf, "PING :", 6) == 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
846 buf2 = g_strsplit(buf, ":", 1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
847
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
848 /* Let's build a new response */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
849 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
850 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
851
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
852 /* And clean up after ourselves */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
853 g_strfreev(buf2);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
854
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
855 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
856 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
857
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 void irc_handler(gpointer data, gint source, GdkInputCondition condition) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
861 irc_callback(data);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
862 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
863
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
864 void irc_close(struct gaim_connection *gc) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
865 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
866 GList *chats = idata->channels;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
867 struct irc_channel *cc;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
868
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
869 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
870
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
871 gtk_timeout_remove(idata->timer);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
872
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
873 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
874 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
875
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
876 g_free(buf);
1021
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
877
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
878 while (chats) {
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
879 cc = (struct irc_channel *)chats->data;
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
880 g_free(cc->name);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
881 chats = g_list_remove(chats, cc);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
882 g_free(cc);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
883 }
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
884
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
885 if (gc->inpa)
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
886 gdk_input_remove(gc->inpa);
90e8714bf95b [gaim-migrate @ 1031]
Rob Flynn <gaim@robflynn.com>
parents: 1019
diff changeset
887
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
888 close(idata->fd);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
889 g_free(gc->proto_data);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
890 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
891
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
892 void irc_chat_leave(struct gaim_connection *gc, int id) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
893 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
894 struct irc_channel *channel;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
895 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN+1);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
896
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
897 channel = find_channel_by_id(gc, id);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
898
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
899 if (!channel) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
900 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
901 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
902
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
903 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
904 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
905
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
906 g_free(buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
907 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
908
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
909 void irc_login(struct aim_user *user) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
910 int fd;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
911 struct hostent *host;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
912 struct sockaddr_in site;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
913 char buf[4096];
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
914
1089
f0f5c10cce63 [gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1075
diff changeset
915 struct gaim_connection *gc = new_gaim_conn(user);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
916 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
917 char c;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
918 int i;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
919 int status;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
920
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
921 set_login_progress(gc, 1, buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
922
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
923 while (gtk_events_pending())
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
924 gtk_main_iteration();
1090
79cdc86ef4c6 [gaim-migrate @ 1100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1089
diff changeset
925 if (!g_slist_find(connections, gc))
79cdc86ef4c6 [gaim-migrate @ 1100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1089
diff changeset
926 return;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
927
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
928 host = gethostbyname(user->proto_opt[0]);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
929 if (!host) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
930 hide_login_progress(gc, "Unable to resolve hostname");
1115
114cd406b022 [gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1105
diff changeset
931 signoff(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
932 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
933 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
934
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
935 site.sin_family = AF_INET;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
936 site.sin_addr.s_addr = *(long *)(host->h_addr);
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
937 site.sin_port = htons(atoi(user->proto_opt[1]));
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
938
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
939 fd = socket(AF_INET, SOCK_STREAM, 0);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
940 if (fd < 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
941 hide_login_progress(gc, "Unable to create socket");
1115
114cd406b022 [gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1105
diff changeset
942 signoff(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
943 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
944 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
945
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
946 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
947 hide_login_progress(gc, "Unable to connect.");
1115
114cd406b022 [gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1105
diff changeset
948 signoff(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
949 return;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
950 }
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
951
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
952 idata->fd = fd;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
953
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
954 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
955 set_login_progress(gc, 2, buf);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
956
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
957 /* This is where we will attempt to sign on */
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
958
1105
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
959 g_snprintf(buf, 4096, "NICK %s\n USER %s localhost %s :GAIM (www.marko.net/gaim)\n", gc->username, getenv("USER"), user->proto_opt[0]);
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
960
c964df5b2a84 [gaim-migrate @ 1115]
Rob Flynn <gaim@robflynn.com>
parents: 1090
diff changeset
961 printf("Sending: %s\n", buf);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
962 write(idata->fd, buf, strlen(buf));
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
963
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
964 /* Now lets sign ourselves on */
1089
f0f5c10cce63 [gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1075
diff changeset
965 account_online(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
966 serv_finish_login(gc);
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
967
1022
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
968 if (bud_list_cache_exists(gc))
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
969 do_import(NULL, gc);
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
970
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
971
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
972 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
973
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
974 /* We want to update our buddlist every 20 seconds */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
975 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
976
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
977 /* But first, let's go ahead and check our list */
d5c022006a60 [gaim-migrate @ 1032]
Rob Flynn <gaim@robflynn.com>
parents: 1021
diff changeset
978 irc_request_buddy_update(gc);
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
979 }
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
980
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
981 static void irc_print_option(GtkEntry *entry, struct aim_user *user) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
982 if (gtk_object_get_user_data(GTK_OBJECT(entry))) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
983 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
984 gtk_entry_get_text(entry));
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
985 } else {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
986 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
987 gtk_entry_get_text(entry));
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
988 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
989 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
990
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
991 static void irc_user_opts(GtkWidget *book, struct aim_user *user) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
992 /* so here, we create the new notebook page */
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
993 GtkWidget *vbox;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
994 GtkWidget *hbox;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
995 GtkWidget *label;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
996 GtkWidget *entry;
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
997
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
998 vbox = gtk_vbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
999 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox,
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1000 gtk_label_new("IRC Options"));
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1001 gtk_widget_show(vbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1002
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1003 hbox = gtk_hbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1004 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1005 gtk_widget_show(hbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1006
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1007 label = gtk_label_new("Server:");
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1008 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1009 gtk_widget_show(label);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1010
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1011 entry = gtk_entry_new();
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1012 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1013 gtk_signal_connect(GTK_OBJECT(entry), "changed",
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1014 GTK_SIGNAL_FUNC(irc_print_option), user);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1015 if (user->proto_opt[0][0]) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1016 debug_printf("setting text %s\n", user->proto_opt[0]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1017 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1018 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1019 gtk_widget_show(entry);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1020
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1021 hbox = gtk_hbox_new(FALSE, 0);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1022 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1023 gtk_widget_show(hbox);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1024
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1025 label = gtk_label_new("Port:");
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1026 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1027 gtk_widget_show(label);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1028
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1029 entry = gtk_entry_new();
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1030 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1031 if (user->proto_opt[1][0]) {
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1032 debug_printf("setting text %s\n", user->proto_opt[1]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1033 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1034 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1035 gtk_object_set_user_data(GTK_OBJECT(entry), user);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1036 gtk_signal_connect(GTK_OBJECT(entry), "changed",
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1037 GTK_SIGNAL_FUNC(irc_print_option), user);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1038 gtk_widget_show(entry);
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1039 }
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1040
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1041 static char **irc_list_icon(int uc) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1042 return free_icon_xpm;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1043 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1044
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1045 /* Send out a ping request to the specified user */
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1046 void irc_send_ping(GtkObject *w, char *who) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1047 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1048 struct irc_data *idata = (struct irc_data *)gc->proto_data;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1049 char buf[BUF_LEN];
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1050 unsigned int serial = 2391271;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1051
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1052 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %d%c\n", who, '\001', serial, '\001');
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1053
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1054 write(idata->fd, buf, strlen(buf));
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1055 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1056
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1057
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1058 static void irc_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) {
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1059 GtkWidget *button;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1060
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1061 button = gtk_menu_item_new_with_label("Ping");
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1062 gtk_signal_connect(GTK_OBJECT(button), "activate",
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1063 GTK_SIGNAL_FUNC(irc_send_ping), who);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1064 gtk_object_set_user_data(GTK_OBJECT(button), gc);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1065 gtk_menu_append(GTK_MENU(menu), button);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1066 gtk_widget_show(button);
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1067 }
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1068
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1069
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1070 static struct prpl *my_protocol = NULL;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1071
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1072 void irc_init(struct prpl *ret) {
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1073 ret->protocol = PROTO_IRC;
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1074 ret->name = irc_name;
1178
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1075 ret->list_icon = irc_list_icon;
4291c96c5096 [gaim-migrate @ 1188]
Rob Flynn <gaim@robflynn.com>
parents: 1134
diff changeset
1076 ret->action_menu = irc_action_menu;
1075
2fe18b2d6105 [gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
1077 ret->user_opts = irc_user_opts;
1008
1b99caffcd98 [gaim-migrate @ 1018]
Rob Flynn <gaim@robflynn.com>
parents: 987
diff changeset
1078 ret->login = irc_login;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1079 ret->close = irc_close;
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1080 ret->send_im = irc_send_im;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1081 ret->set_info = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1082 ret->get_info = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1083 ret->set_away = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1084 ret->get_away_msg = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1085 ret->set_dir = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1086 ret->get_dir = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1087 ret->dir_search = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1088 ret->set_idle = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1089 ret->change_passwd = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1090 ret->add_buddy = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1091 ret->add_buddies = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1092 ret->remove_buddy = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1093 ret->add_permit = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1094 ret->add_deny = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1095 ret->warn = NULL;
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1096 ret->accept_chat = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1097 ret->join_chat = irc_join_chat;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1098 ret->chat_invite = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1099 ret->chat_leave = irc_chat_leave;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1100 ret->chat_whisper = NULL;
1011
4867280dbdc7 [gaim-migrate @ 1021]
Rob Flynn <gaim@robflynn.com>
parents: 1008
diff changeset
1101 ret->chat_send = irc_chat_send;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1102 ret->keepalive = NULL;
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1103
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1104 my_protocol = ret;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1105 }
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1106
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1107 char *gaim_plugin_init(GModule *handle) {
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1108 load_protocol(irc_init);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1109 return NULL;
987
cf6662982b40 [gaim-migrate @ 997]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1110 }
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1111
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1112 void gaim_plugin_remove() {
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1113 struct prpl *p = find_prpl(PROTO_IRC);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1114 if (p == my_protocol)
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1115 unload_protocol(p);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1046
diff changeset
1116 }