Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 2347:182a4f8b1333
[gaim-migrate @ 2360]
Sorry rob. I just don't think that you should be committing what you know is half-complete code, and allow users to access it. We can't be recommending to people to be using CVS instead of releases and then add things that we know beforehand are buggy or incomplete. Also I don't think that you've implemented it properly: More than just Oscar have buddy icons (though Jabber is reworking their buddy icon stuff) and so it shouldn't be protocol-specific like this; also it should apply to the aim_user and not the gaim_connection, and you should be able to set it while you're not online, which means it should go in the Modify Account dialog and not the Protocol Actions dialog, with an OPT_PROTO_BUDDY_ICON flag so that the dialog knows whether or not the buddy icon can be set.
Also, you broke -Wall.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 22 Sep 2001 10:08:19 +0000 |
parents | 19ea44f74a88 |
children | d6d3d2e6d625 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
24 #include <config.h> |
2086 | 25 #endif |
26 | |
27 | |
28 #include <netdb.h> | |
29 #include <unistd.h> | |
30 #include <errno.h> | |
31 #include <netinet/in.h> | |
32 #include <arpa/inet.h> | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | |
39 #include "multi.h" | |
40 #include "prpl.h" | |
41 #include "gaim.h" | |
42 #include "aim.h" | |
43 #include "proxy.h" | |
44 | |
45 /*#include "pixmaps/cancel.xpm"*/ | |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
46 #include "pixmaps/ab.xpm" |
2086 | 47 #include "pixmaps/admin_icon.xpm" |
48 #include "pixmaps/aol_icon.xpm" | |
49 #include "pixmaps/away_icon.xpm" | |
50 #include "pixmaps/dt_icon.xpm" | |
51 #include "pixmaps/free_icon.xpm" | |
52 | |
53 /* constants to identify proto_opts */ | |
54 #define USEROPT_AUTH 0 | |
55 #define USEROPT_AUTHPORT 1 | |
56 | |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
57 #define UC_AB 32 |
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
58 |
2086 | 59 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
60 | |
61 static int gaim_caps = AIM_CAPS_CHAT | | |
62 AIM_CAPS_BUDDYICON | | |
63 AIM_CAPS_IMIMAGE; | |
2308
a90be9567452
[gaim-migrate @ 2318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
64 static fu8_t gaim_features[] = {0x01, 0x01, 0x01, 0x02}; |
2086 | 65 |
66 struct oscar_data { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
67 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
68 aim_conn_t *conn; |
2086 | 69 |
70 guint cnpa; | |
71 guint paspa; | |
72 | |
73 int create_exchange; | |
74 char *create_name; | |
75 | |
76 gboolean conf; | |
77 gboolean reqemail; | |
78 gboolean chpass; | |
79 char *oldp; | |
80 char *newp; | |
81 | |
82 GSList *oscar_chats; | |
83 GSList *direct_ims; | |
84 GSList *hasicons; | |
85 | |
86 gboolean killme; | |
87 }; | |
88 | |
89 struct chat_connection { | |
90 char *name; | |
91 char *show; /* AOL did something funny to us */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
92 fu16_t exchange; /* XXX should have instance here too */ |
2086 | 93 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
94 aim_conn_t *conn; |
2086 | 95 int inpa; |
96 int id; | |
97 struct gaim_connection *gc; /* i hate this. */ | |
98 struct conversation *cnv; /* bah. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
99 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
100 int maxvis; |
2086 | 101 }; |
102 | |
103 struct direct_im { | |
104 struct gaim_connection *gc; | |
105 char name[80]; | |
106 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
107 aim_conn_t *conn; |
2086 | 108 }; |
109 | |
110 struct ask_direct { | |
111 struct gaim_connection *gc; | |
112 char *sn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
113 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
114 fu8_t cookie[8]; |
2086 | 115 }; |
116 | |
117 struct icon_req { | |
118 char *user; | |
119 time_t timestamp; | |
2196
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2194
diff
changeset
|
120 unsigned long length; |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2172
diff
changeset
|
121 unsigned long checksum; |
2086 | 122 gboolean request; |
123 }; | |
124 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
125 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { |
2086 | 126 GSList *d = od->direct_ims; |
127 char *n = g_strdup(normalize(who)); | |
128 struct direct_im *m = NULL; | |
129 | |
130 while (d) { | |
131 m = (struct direct_im *)d->data; | |
132 if (!strcmp(n, normalize(m->name))) | |
133 break; | |
134 m = NULL; | |
135 d = d->next; | |
136 } | |
137 | |
138 g_free(n); | |
139 return m; | |
140 } | |
141 | |
142 static char *extract_name(char *name) { | |
143 char *tmp; | |
144 int i, j; | |
145 char *x = strchr(name, '-'); | |
146 if (!x) return NULL; | |
147 x = strchr(++x, '-'); | |
148 if (!x) return NULL; | |
149 tmp = g_strdup(++x); | |
150 | |
151 for (i = 0, j = 0; x[i]; i++) { | |
152 if (x[i] != '%') | |
153 tmp[j++] = x[i]; | |
154 else { | |
155 char hex[3]; | |
156 hex[0] = x[++i]; | |
157 hex[1] = x[++i]; | |
158 hex[2] = 0; | |
159 sscanf(hex, "%x", (int *)&tmp[j++]); | |
160 } | |
161 } | |
162 | |
163 tmp[j] = 0; | |
164 return tmp; | |
165 } | |
166 | |
167 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { | |
168 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; | |
169 struct chat_connection *c = NULL; | |
170 if (gc->protocol != PROTO_OSCAR) return NULL; | |
171 | |
172 while (g) { | |
173 c = (struct chat_connection *)g->data; | |
174 if (c->id == id) | |
175 break; | |
176 g = g->next; | |
177 c = NULL; | |
178 } | |
179 | |
180 return c; | |
181 } | |
182 | |
183 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
184 aim_conn_t *conn) { |
2086 | 185 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
186 struct chat_connection *c = NULL; | |
187 | |
188 while (g) { | |
189 c = (struct chat_connection *)g->data; | |
190 if (c->conn == conn) | |
191 break; | |
192 g = g->next; | |
193 c = NULL; | |
194 } | |
195 | |
196 return c; | |
197 } | |
198 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
199 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
200 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
201 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
202 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
203 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
204 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
205 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
206 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
207 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
208 static int gaim_parse_user_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
209 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
210 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
211 static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
212 static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
213 static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
214 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
215 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
216 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
217 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
218 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
219 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
220 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
221 static int rateresp_bos (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
222 static int rateresp_auth (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
223 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
224 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
225 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
226 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
227 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
228 static int gaim_memrequest (aim_session_t *, aim_frame_t*, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
229 static int server_ready_bos (aim_session_t *, aim_frame_t*, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
230 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
231 static int gaim_directim_initiate (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
232 static int gaim_directim_incoming (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
233 static int gaim_directim_typing (aim_session_t *, aim_frame_t *, ...); |
2086 | 234 |
235 static char *msgerrreason[] = { | |
236 "Invalid error", | |
237 "Invalid SNAC", | |
238 "Rate to host", | |
239 "Rate to client", | |
240 "Not logged in", | |
241 "Service unavailable", | |
242 "Service not defined", | |
243 "Obsolete SNAC", | |
244 "Not supported by host", | |
245 "Not supported by client", | |
246 "Refused by client", | |
247 "Reply too big", | |
248 "Responses lost", | |
249 "Request denied", | |
250 "Busted SNAC payload", | |
251 "Insufficient rights", | |
252 "In local permit/deny", | |
253 "Too evil (sender)", | |
254 "Too evil (receiver)", | |
255 "User temporarily unavailable", | |
256 "No match", | |
257 "List overflow", | |
258 "Request ambiguous", | |
259 "Queue full", | |
260 "Not while on AOL" | |
261 }; | |
262 static int msgerrreasonlen = 25; | |
263 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
264 static void gaim_directim_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
265 struct gaim_connection *gc = sess->aux_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
266 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
267 struct conversation *cnv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
268 struct direct_im *dim; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
269 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
270 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
271 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
272 sn = g_strdup(aim_directim_getsn(conn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
273 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
274 debug_printf("%s disconnected Direct IM.\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
275 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
276 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
277 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
278 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
279 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
280 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
281 if ((cnv = find_conversation(sn))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
282 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
283 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
284 g_free(dim); /* I guess? I don't see it anywhere else... -- mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
285 g_free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
286 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
287 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
288 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
289 |
2086 | 290 static void oscar_callback(gpointer data, gint source, |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
291 GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
292 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
293 aim_session_t *sess = aim_conn_getsess(conn); |
2086 | 294 struct gaim_connection *gc = sess ? sess->aux_data : NULL; |
295 struct oscar_data *odata; | |
296 | |
297 if (!gc) { | |
298 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
299 debug_printf("oscar callback for closed connection (1).\n"); | |
300 return; | |
301 } | |
302 | |
303 odata = (struct oscar_data *)gc->proto_data; | |
304 | |
305 if (!g_slist_find(connections, gc)) { | |
306 /* oh boy. this is probably bad. i guess the only thing we | |
307 * can really do is return? */ | |
308 debug_printf("oscar callback for closed connection (2).\n"); | |
309 return; | |
310 } | |
311 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
312 if (condition & GAIM_INPUT_READ) { |
2086 | 313 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { |
314 debug_printf("got information on rendezvous\n"); | |
315 if (aim_handlerendconnect(odata->sess, conn) < 0) { | |
316 debug_printf(_("connection error (rend)\n")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
317 aim_conn_kill(odata->sess, &conn); |
2086 | 318 } |
319 } else { | |
320 if (aim_get_command(odata->sess, conn) >= 0) { | |
321 aim_rxdispatch(odata->sess); | |
322 if (odata->killme) | |
323 signoff(gc); | |
324 } else { | |
325 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
326 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { | |
327 debug_printf(_("major connection error\n")); | |
328 hide_login_progress(gc, _("Disconnected.")); | |
329 signoff(gc); | |
330 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
331 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
332 char buf[BUF_LONG]; | |
333 debug_printf("disconnected from chat room %s\n", c->name); | |
334 c->conn = NULL; | |
335 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
336 gaim_input_remove(c->inpa); |
2086 | 337 c->inpa = 0; |
338 c->fd = -1; | |
339 aim_conn_kill(odata->sess, &conn); | |
340 sprintf(buf, _("You have been disconnected from chat room %s."), c->name); | |
341 do_error_dialog(buf, _("Chat Error!")); | |
342 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
343 if (odata->cnpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
344 gaim_input_remove(odata->cnpa); |
2086 | 345 odata->cnpa = 0; |
346 debug_printf("removing chatnav input watcher\n"); | |
347 if (odata->create_exchange) { | |
348 odata->create_exchange = 0; | |
349 g_free(odata->create_name); | |
350 odata->create_name = NULL; | |
351 do_error_dialog(_("Chat is currently unavailable"), | |
352 _("Gaim - Chat")); | |
353 } | |
354 aim_conn_kill(odata->sess, &conn); | |
355 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
356 if (odata->paspa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
357 gaim_input_remove(odata->paspa); |
2086 | 358 odata->paspa = 0; |
359 debug_printf("removing authconn input watcher\n"); | |
360 aim_conn_kill(odata->sess, &conn); | |
361 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
362 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
363 gaim_directim_disconnect(odata->sess, conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
364 else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
365 debug_printf("No handler for rendezvous disconnect (%d).\n", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
366 source); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
367 } |
2086 | 368 aim_conn_kill(odata->sess, &conn); |
369 } else { | |
370 debug_printf("holy crap! generic connection error! %d\n", | |
371 conn->type); | |
372 aim_conn_kill(odata->sess, &conn); | |
373 } | |
374 } | |
375 } | |
376 } | |
377 } | |
378 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
379 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
2086 | 380 char *s = g_strdup_vprintf(format, va); |
381 char buf[256]; | |
382 char *t; | |
383 struct gaim_connection *gc = sess->aux_data; | |
384 | |
385 g_snprintf(buf, sizeof(buf), "%s %d: ", gc->username, level); | |
386 t = g_strconcat(buf, s, NULL); | |
387 debug_printf(t); | |
388 if (t[strlen(t)-1] != '\n') | |
389 debug_printf("\n"); | |
390 g_free(t); | |
391 g_free(s); | |
392 } | |
393 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
394 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 395 { |
396 struct gaim_connection *gc = data; | |
397 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
398 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
399 aim_conn_t *conn; |
2086 | 400 |
401 if (!g_slist_find(connections, gc)) { | |
402 close(source); | |
403 return; | |
404 } | |
405 | |
406 odata = gc->proto_data; | |
407 sess = odata->sess; | |
408 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
409 | |
410 if (source < 0) { | |
411 hide_login_progress(gc, _("Couldn't connect to host")); | |
412 signoff(gc); | |
413 return; | |
414 } | |
415 | |
416 aim_conn_completeconnect(sess, conn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
417 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, |
2086 | 418 oscar_callback, conn); |
419 debug_printf(_("Password sent, waiting for response\n")); | |
420 } | |
421 | |
422 static void oscar_login(struct aim_user *user) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
423 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
424 aim_conn_t *conn; |
2086 | 425 char buf[256]; |
426 struct gaim_connection *gc = new_gaim_conn(user); | |
427 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); | |
428 odata->create_exchange = 0; | |
429 | |
430 debug_printf(_("Logging in %s\n"), user->username); | |
431 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
432 sess = g_new0(aim_session_t, 1); |
2086 | 433 |
434 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
435 aim_setdebuggingcb(sess, oscar_debug); | |
436 | |
437 /* we need an immediate queue because we don't use a while-loop to | |
438 * see if things need to be sent. */ | |
439 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
440 odata->sess = sess; | |
441 sess->aux_data = gc; | |
442 | |
443 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
444 if (conn == NULL) { | |
445 debug_printf(_("internal connection error\n")); | |
446 hide_login_progress(gc, _("Unable to login to AIM")); | |
447 signoff(gc); | |
448 return; | |
449 } | |
450 | |
451 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | |
452 set_login_progress(gc, 2, buf); | |
453 | |
454 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); | |
455 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
456 | |
457 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
458 conn->fd = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? | |
459 user->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, | |
460 user->proto_opt[USEROPT_AUTHPORT][0] ? | |
461 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
462 oscar_login_connect, gc); | |
463 if (conn->fd < 0) { | |
464 hide_login_progress(gc, _("Couldn't connect to host")); | |
465 signoff(gc); | |
466 return; | |
467 } | |
468 aim_request_login(sess, conn, gc->username); | |
469 } | |
470 | |
471 static void oscar_close(struct gaim_connection *gc) { | |
472 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
473 if (gc->protocol != PROTO_OSCAR) return; | |
474 | |
475 while (odata->oscar_chats) { | |
476 struct chat_connection *n = odata->oscar_chats->data; | |
477 if (n->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
478 gaim_input_remove(n->inpa); |
2086 | 479 g_free(n->name); |
480 g_free(n->show); | |
481 odata->oscar_chats = g_slist_remove(odata->oscar_chats, n); | |
482 g_free(n); | |
483 } | |
484 while (odata->direct_ims) { | |
485 struct direct_im *n = odata->direct_ims->data; | |
486 if (n->watcher > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
487 gaim_input_remove(n->watcher); |
2086 | 488 odata->direct_ims = g_slist_remove(odata->direct_ims, n); |
489 g_free(n); | |
490 } | |
491 while (odata->hasicons) { | |
492 struct icon_req *n = odata->hasicons->data; | |
493 g_free(n->user); | |
494 odata->hasicons = g_slist_remove(odata->hasicons, n); | |
495 g_free(n); | |
496 } | |
497 if (gc->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
498 gaim_input_remove(gc->inpa); |
2086 | 499 if (odata->cnpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
500 gaim_input_remove(odata->cnpa); |
2086 | 501 if (odata->paspa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
502 gaim_input_remove(odata->paspa); |
2086 | 503 aim_session_kill(odata->sess); |
504 g_free(odata->sess); | |
505 odata->sess = NULL; | |
506 g_free(gc->proto_data); | |
507 gc->proto_data = NULL; | |
508 debug_printf(_("Signed off.\n")); | |
509 } | |
510 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
511 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 512 struct gaim_connection *gc = data; |
513 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
514 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
515 aim_conn_t *bosconn; |
2086 | 516 |
517 if (!g_slist_find(connections, gc)) { | |
518 close(source); | |
519 return; | |
520 } | |
521 | |
522 odata = gc->proto_data; | |
523 sess = odata->sess; | |
524 bosconn = odata->conn; | |
525 | |
526 if (source < 0) { | |
527 hide_login_progress(gc, _("Could Not Connect")); | |
528 signoff(gc); | |
529 return; | |
530 } | |
531 | |
532 aim_conn_completeconnect(sess, bosconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
533 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, |
2086 | 534 oscar_callback, bosconn); |
535 set_login_progress(gc, 4, _("Connection established, cookie sent")); | |
536 } | |
537 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
538 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 539 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
540 aim_conn_t *bosconn = NULL; |
2086 | 541 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
542 fu8_t *cookie = NULL; |
2086 | 543 int errorcode = 0, regstatus = 0; |
544 int latestbuild = 0, latestbetabuild = 0; | |
545 char *latestrelease = NULL, *latestbeta = NULL; | |
546 char *latestreleaseurl = NULL, *latestbetaurl = NULL; | |
547 char *latestreleaseinfo = NULL, *latestbetainfo = NULL; | |
548 int i; char *host; int port; | |
549 struct aim_user *user; | |
550 | |
551 struct gaim_connection *gc = sess->aux_data; | |
552 struct oscar_data *od = gc->proto_data; | |
553 user = gc->user; | |
554 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
555 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
556 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
557 va_start(ap, fr); |
2086 | 558 sn = va_arg(ap, char *); |
559 errorcode = va_arg(ap, int); | |
560 errurl = va_arg(ap, char *); | |
561 regstatus = va_arg(ap, int); | |
562 email = va_arg(ap, char *); | |
563 bosip = va_arg(ap, char *); | |
564 cookie = va_arg(ap, unsigned char *); | |
565 | |
566 latestrelease = va_arg(ap, char *); | |
567 latestbuild = va_arg(ap, int); | |
568 latestreleaseurl = va_arg(ap, char *); | |
569 latestreleaseinfo = va_arg(ap, char *); | |
570 | |
571 latestbeta = va_arg(ap, char *); | |
572 latestbetabuild = va_arg(ap, int); | |
573 latestbetaurl = va_arg(ap, char *); | |
574 latestbetainfo = va_arg(ap, char *); | |
575 | |
576 va_end(ap); | |
577 | |
578 debug_printf("inside auth_resp (Screen name: %s)\n", sn); | |
579 | |
580 if (errorcode || !bosip || !cookie) { | |
581 switch (errorcode) { | |
582 case 0x05: | |
583 /* Incorrect nick/password */ | |
584 hide_login_progress(gc, _("Incorrect nickname or password.")); | |
585 plugin_event(event_error, (void *)980, 0, 0, 0); | |
586 break; | |
587 case 0x11: | |
588 /* Suspended account */ | |
589 hide_login_progress(gc, _("Your account is currently suspended.")); | |
590 break; | |
591 case 0x18: | |
592 /* connecting too frequently */ | |
593 hide_login_progress(gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); | |
594 plugin_event(event_error, (void *)983, 0, 0, 0); | |
595 break; | |
596 case 0x1c: | |
597 /* client too old */ | |
598 hide_login_progress(gc, _("The client version you are using is too old. Please upgrade at " WEBSITE)); | |
599 plugin_event(event_error, (void *)989, 0, 0, 0); | |
600 break; | |
601 default: | |
602 hide_login_progress(gc, _("Authentication Failed")); | |
603 break; | |
604 } | |
605 debug_printf("Login Error Code 0x%04x\n", errorcode); | |
606 debug_printf("Error URL: %s\n", errurl); | |
607 od->killme = TRUE; | |
608 return 1; | |
609 } | |
610 | |
611 | |
612 debug_printf("Reg status: %2d\n", regstatus); | |
613 if (email) { | |
614 debug_printf("Email: %s\n", email); | |
615 } else { | |
616 debug_printf("Email is NULL\n"); | |
617 } | |
618 debug_printf("BOSIP: %s\n", bosip); | |
619 if (latestbeta) | |
620 debug_printf("Latest WinAIM beta version %s, build %d, at %s (%s)\n", | |
621 latestbeta, latestbetabuild, latestbetaurl, latestbetainfo); | |
622 if (latestrelease) | |
623 debug_printf("Latest WinAIM released version %s, build %d, at %s (%s)\n", | |
624 latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo); | |
625 debug_printf("Closing auth connection...\n"); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
626 aim_conn_kill(sess, &fr->conn); |
2086 | 627 |
628 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
629 if (bosconn == NULL) { | |
630 hide_login_progress(gc, _("Internal Error")); | |
631 od->killme = TRUE; | |
632 return 0; | |
633 } | |
634 | |
635 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
636 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, rateresp_bos, 0); /* rate info */ |
2086 | 637 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
638 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, server_ready_bos, 0); |
2086 | 639 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0); |
640 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
641 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); | |
642 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
643 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
644 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
645 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
646 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
647 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); | |
648 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
649 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
650 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
651 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
652 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); | |
653 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
654 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
655 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 656 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
657 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
658 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
659 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
660 | |
661 ((struct oscar_data *)gc->proto_data)->conn = bosconn; | |
662 for (i = 0; i < (int)strlen(bosip); i++) { | |
663 if (bosip[i] == ':') { | |
664 port = atoi(&(bosip[i+1])); | |
665 break; | |
666 } | |
667 } | |
668 host = g_strndup(bosip, i); | |
669 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
670 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, gc); | |
671 g_free(host); | |
672 if (bosconn->fd < 0) { | |
673 hide_login_progress(gc, _("Could Not Connect")); | |
674 od->killme = TRUE; | |
675 return 0; | |
676 } | |
677 aim_auth_sendcookie(sess, bosconn, cookie); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
678 gaim_input_remove(gc->inpa); |
2086 | 679 return 1; |
680 } | |
681 | |
682 struct pieceofcrap { | |
683 struct gaim_connection *gc; | |
684 unsigned long offset; | |
685 unsigned long len; | |
686 char *modname; | |
687 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
688 aim_conn_t *conn; |
2086 | 689 unsigned int inpa; |
690 }; | |
691 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
692 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 693 { |
694 struct pieceofcrap *pos = data; | |
695 struct oscar_data *od = pos->gc->proto_data; | |
696 char in = '\0'; | |
697 int x = 0; | |
698 unsigned char m[17]; | |
699 | |
700 while (read(pos->fd, &in, 1) == 1) { | |
701 if (in == '\n') | |
702 x++; | |
703 else if (in != '\r') | |
704 x = 0; | |
705 if (x == 2) | |
706 break; | |
707 in = '\0'; | |
708 } | |
709 if (in != '\n') { | |
710 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
711 " You may be disconnected shortly.", "Login Error"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
712 gaim_input_remove(pos->inpa); |
2086 | 713 close(pos->fd); |
714 g_free(pos); | |
715 return; | |
716 } | |
717 read(pos->fd, m, 16); | |
718 m[16] = '\0'; | |
719 debug_printf("Sending hash: "); | |
720 for (x = 0; x < 16; x++) | |
721 debug_printf("%02x ", (unsigned char)m[x]); | |
722 debug_printf("\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
723 gaim_input_remove(pos->inpa); |
2086 | 724 close(pos->fd); |
725 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
726 g_free(pos); | |
727 } | |
728 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
729 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 730 struct pieceofcrap *pos = data; |
731 char buf[BUF_LONG]; | |
732 | |
733 if (source < 0) { | |
734 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
735 " You may be disconnected shortly.", "Login Error"); | |
736 if (pos->modname) | |
737 g_free(pos->modname); | |
738 g_free(pos); | |
739 return; | |
740 } | |
741 | |
742 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
743 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
744 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
745 write(pos->fd, buf, strlen(buf)); | |
746 if (pos->modname) | |
747 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
748 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 749 return; |
750 } | |
751 | |
752 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
753 #define AIM_MAX_FILE_SIZE 98304 | |
754 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
755 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 756 va_list ap; |
757 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
758 fu32_t offset, len; |
2086 | 759 char *modname; |
760 int fd; | |
761 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
762 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
763 offset = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
764 len = (fu32_t)va_arg(ap, unsigned long); |
2086 | 765 modname = va_arg(ap, char *); |
766 va_end(ap); | |
767 | |
768 debug_printf("offset: %d, len: %d, file: %s\n", offset, len, modname ? modname : "aim.exe"); | |
769 if (len == 0) { | |
770 debug_printf("len is 0, hashing NULL\n"); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
771 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 772 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
773 return 1; | |
774 } | |
775 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
776 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
777 char *buf; | |
778 int i = 8; | |
779 if (modname) | |
780 i += strlen(modname); | |
781 buf = g_malloc(i); | |
782 i = 0; | |
783 if (modname) { | |
784 memcpy(buf, modname, strlen(modname)); | |
785 i += strlen(modname); | |
786 } | |
787 buf[i++] = offset & 0xff; | |
788 buf[i++] = (offset >> 8) & 0xff; | |
789 buf[i++] = (offset >> 16) & 0xff; | |
790 buf[i++] = (offset >> 24) & 0xff; | |
791 buf[i++] = len & 0xff; | |
792 buf[i++] = (len >> 8) & 0xff; | |
793 buf[i++] = (len >> 16) & 0xff; | |
794 buf[i++] = (len >> 24) & 0xff; | |
795 debug_printf("len + offset is invalid, hashing request\n"); | |
796 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | |
797 g_free(buf); | |
798 return 1; | |
799 } | |
800 */ | |
801 | |
802 pos = g_new0(struct pieceofcrap, 1); | |
803 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
804 pos->conn = fr->conn; |
2086 | 805 |
806 pos->offset = offset; | |
807 pos->len = len; | |
808 pos->modname = modname ? g_strdup(modname) : NULL; | |
809 | |
810 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos); | |
811 if (fd < 0) { | |
812 if (pos->modname) | |
813 g_free(pos->modname); | |
814 g_free(pos); | |
815 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
816 " You may be disconnected shortly.", "Login Error"); | |
817 } | |
818 pos->fd = fd; | |
819 | |
820 return 1; | |
821 } | |
822 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
823 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 824 #if 0 |
825 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
826 #else | |
827 struct client_info_s info = AIM_CLIENTINFO_KNOWNGOOD; | |
828 #endif | |
829 char *key; | |
830 va_list ap; | |
831 struct gaim_connection *gc = sess->aux_data; | |
832 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
833 va_start(ap, fr); |
2086 | 834 key = va_arg(ap, char *); |
835 va_end(ap); | |
836 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
837 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
838 |
2086 | 839 return 1; |
840 } | |
841 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
842 static int server_ready_auth(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 843 struct gaim_connection *gc = sess->aux_data; |
844 struct oscar_data *od = gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
845 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
846 aim_auth_setversions(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
847 aim_bos_reqrate(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
848 debug_printf("done with AUTH ServerReady\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
849 if (od->chpass) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
850 debug_printf("changing password\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
851 aim_auth_changepasswd(sess, fr->conn, od->newp, od->oldp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
852 g_free(od->oldp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
853 g_free(od->newp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
854 od->chpass = FALSE; |
2086 | 855 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
856 if (od->conf) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
857 debug_printf("confirming account\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
858 aim_auth_reqconfirm(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
859 od->conf = FALSE; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
860 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
861 if (od->reqemail) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
862 debug_printf("requesting email\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
863 aim_auth_getinfo(sess, fr->conn, 0x0011); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
864 od->reqemail = FALSE; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
865 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
866 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
867 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
868 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
869 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
870 static int server_ready_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
871 aim_setversions(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
872 aim_bos_reqrate(sess, fr->conn); /* request rate info */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
873 debug_printf("done with BOS ServerReady\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
874 |
2086 | 875 return 1; |
876 } | |
877 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
878 static int server_ready_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
879 debug_printf("chatnav: got server ready\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
880 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
881 aim_bos_reqrate(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
882 aim_bos_ackrateresp(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
883 aim_chatnav_clientready(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
884 aim_chatnav_reqrights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
885 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
886 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
887 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
888 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
889 static int server_ready_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
890 struct gaim_connection *gc = sess->aux_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
891 struct chat_connection *chatcon; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
892 static int id = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
893 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
894 debug_printf("chat: got server ready\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
895 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
896 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
897 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
898 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
899 aim_bos_reqrate(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
900 aim_bos_ackrateresp(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
901 aim_chat_clientready(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
902 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
903 chatcon->id = id; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
904 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
905 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
906 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
907 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
908 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
909 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 910 struct gaim_connection *gc = data; |
911 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
912 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
913 aim_conn_t *tstconn; |
2086 | 914 |
915 if (!g_slist_find(connections, gc)) { | |
916 close(source); | |
917 return; | |
918 } | |
919 | |
920 odata = gc->proto_data; | |
921 sess = odata->sess; | |
922 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); | |
923 | |
924 if (source < 0) { | |
925 aim_conn_kill(sess, &tstconn); | |
926 debug_printf("unable to connect to chatnav server\n"); | |
927 return; | |
928 } | |
929 | |
930 aim_conn_completeconnect(sess, tstconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
931 odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
932 oscar_callback, tstconn); |
2086 | 933 debug_printf("chatnav: connected\n"); |
934 } | |
935 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
936 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 937 { |
938 struct gaim_connection *gc = data; | |
939 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
940 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
941 aim_conn_t *tstconn; |
2086 | 942 |
943 if (!g_slist_find(connections, gc)) { | |
944 close(source); | |
945 return; | |
946 } | |
947 | |
948 odata = gc->proto_data; | |
949 sess = odata->sess; | |
950 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
951 | |
952 if (source < 0) { | |
953 aim_conn_kill(sess, &tstconn); | |
954 debug_printf("unable to connect to authorizer\n"); | |
955 return; | |
956 } | |
957 | |
958 aim_conn_completeconnect(sess, tstconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
959 odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
2086 | 960 oscar_callback, tstconn); |
961 debug_printf("chatnav: connected\n"); | |
962 } | |
963 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
964 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 965 { |
966 struct chat_connection *ccon = data; | |
967 struct gaim_connection *gc = ccon->gc; | |
968 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
969 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
970 aim_conn_t *tstconn; |
2086 | 971 |
972 if (!g_slist_find(connections, gc)) { | |
973 close(source); | |
974 g_free(ccon->show); | |
975 g_free(ccon->name); | |
976 g_free(ccon); | |
977 return; | |
978 } | |
979 | |
980 odata = gc->proto_data; | |
981 sess = odata->sess; | |
982 tstconn = ccon->conn; | |
983 | |
984 if (source < 0) { | |
985 aim_conn_kill(sess, &tstconn); | |
986 g_free(ccon->show); | |
987 g_free(ccon->name); | |
988 g_free(ccon); | |
989 return; | |
990 } | |
991 | |
992 aim_conn_completeconnect(sess, ccon->conn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
993 ccon->inpa = gaim_input_add(tstconn->fd, |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
994 GAIM_INPUT_READ, |
2086 | 995 oscar_callback, tstconn); |
996 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | |
997 aim_chat_attachname(tstconn, ccon->name); | |
998 } | |
999 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1000 /* Hrmph. I don't know how to make this look better. --mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1001 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1002 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1003 fu16_t serviceid; |
2086 | 1004 char *ip; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1005 fu8_t *cookie; |
2086 | 1006 struct gaim_connection *gc = sess->aux_data; |
1007 struct aim_user *user = gc->user; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1008 aim_conn_t *tstconn; |
2086 | 1009 int i; |
1010 char *host; | |
1011 int port; | |
1012 | |
1013 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
1014 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
1015 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1016 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1017 serviceid = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1018 ip = va_arg(ap, char *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1019 cookie = (fu8_t *)va_arg(ap, unsigned char *); |
2086 | 1020 |
1021 for (i = 0; i < (int)strlen(ip); i++) { | |
1022 if (ip[i] == ':') { | |
1023 port = atoi(&(ip[i+1])); | |
1024 break; | |
1025 } | |
1026 } | |
1027 host = g_strndup(ip, i); | |
1028 | |
1029 switch(serviceid) { | |
1030 case 0x7: /* Authorizer */ | |
1031 debug_printf("Reconnecting with authorizor...\n"); | |
1032 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1033 if (tstconn == NULL) { | |
1034 debug_printf("unable to reconnect with authorizer\n"); | |
1035 g_free(host); | |
1036 return 1; | |
1037 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1038 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, server_ready_auth, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1039 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, rateresp_auth, 0); |
2086 | 1040 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
1041 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
1042 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
1043 | |
1044 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1045 tstconn->fd = proxy_connect(host, port, oscar_auth_connect, gc); | |
1046 if (tstconn->fd < 0) { | |
1047 aim_conn_kill(sess, &tstconn); | |
1048 debug_printf("unable to reconnect with authorizer\n"); | |
1049 g_free(host); | |
1050 return 1; | |
1051 } | |
1052 aim_auth_sendcookie(sess, tstconn, cookie); | |
1053 break; | |
1054 case 0xd: /* ChatNav */ | |
1055 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1056 if (tstconn == NULL) { | |
1057 debug_printf("unable to connect to chatnav server\n"); | |
1058 g_free(host); | |
1059 return 1; | |
1060 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1061 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, server_ready_chatnav, 0); |
2086 | 1062 |
1063 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1064 tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, gc); | |
1065 if (tstconn->fd < 0) { | |
1066 aim_conn_kill(sess, &tstconn); | |
1067 debug_printf("unable to connect to chatnav server\n"); | |
1068 g_free(host); | |
1069 return 1; | |
1070 } | |
1071 aim_auth_sendcookie(sess, tstconn, cookie); | |
1072 break; | |
1073 case 0xe: /* Chat */ | |
1074 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1075 char *roomname; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1076 fu16_t exchange; |
2086 | 1077 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1078 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1079 roomname = va_arg(ap, char *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1080 exchange = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1081 |
2086 | 1082 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1083 if (tstconn == NULL) { | |
1084 debug_printf("unable to connect to chat server\n"); | |
1085 g_free(host); | |
1086 return 1; | |
1087 } | |
1088 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1089 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, server_ready_chat, 0); |
2086 | 1090 ccon = g_new0(struct chat_connection, 1); |
1091 ccon->conn = tstconn; | |
1092 ccon->gc = gc; | |
1093 ccon->fd = -1; | |
1094 ccon->name = g_strdup(roomname); | |
1095 ccon->exchange = exchange; | |
1096 ccon->show = extract_name(roomname); | |
1097 | |
1098 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1099 ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); | |
1100 if (ccon->conn->fd < 0) { | |
1101 aim_conn_kill(sess, &tstconn); | |
1102 debug_printf("unable to connect to chat server\n"); | |
1103 g_free(host); | |
1104 g_free(ccon->show); | |
1105 g_free(ccon->name); | |
1106 g_free(ccon); | |
1107 return 1; | |
1108 } | |
1109 aim_auth_sendcookie(sess, tstconn, cookie); | |
1110 debug_printf("Connected to chat room %s exchange %d\n", roomname, exchange); | |
1111 } | |
1112 break; | |
1113 default: /* huh? */ | |
1114 debug_printf("got redirect for unknown service 0x%04x\n", serviceid); | |
1115 break; | |
1116 } | |
1117 | |
1118 va_end(ap); | |
1119 | |
1120 g_free(host); | |
1121 return 1; | |
1122 } | |
1123 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1124 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1125 struct aim_userinfo_s *info; |
1126 time_t time_idle; | |
1127 int type = 0; | |
1128 struct gaim_connection *gc = sess->aux_data; | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1129 char *tmp; |
2086 | 1130 |
1131 va_list ap; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1132 va_start(ap, fr); |
2086 | 1133 info = va_arg(ap, struct aim_userinfo_s *); |
1134 va_end(ap); | |
1135 | |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1136 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1137 type |= UC_AB; |
2086 | 1138 if (info->flags & AIM_FLAG_UNCONFIRMED) |
1139 type |= UC_UNCONFIRMED; | |
2288
b41c88001ab5
[gaim-migrate @ 2298]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2277
diff
changeset
|
1140 if (info->flags & AIM_FLAG_ADMINISTRATOR) |
2086 | 1141 type |= UC_ADMIN; |
2288
b41c88001ab5
[gaim-migrate @ 2298]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2277
diff
changeset
|
1142 if (info->flags & AIM_FLAG_AOL) |
2086 | 1143 type |= UC_AOL; |
2288
b41c88001ab5
[gaim-migrate @ 2298]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2277
diff
changeset
|
1144 if (info->flags & AIM_FLAG_FREE) |
2086 | 1145 type |= UC_NORMAL; |
1146 if (info->flags & AIM_FLAG_AWAY) | |
1147 type |= UC_UNAVAILABLE; | |
1148 | |
1149 if (info->idletime) { | |
1150 time(&time_idle); | |
1151 time_idle -= info->idletime*60; | |
1152 } else | |
1153 time_idle = 0; | |
1154 | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1155 tmp = g_strdup(normalize(gc->username)); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1156 if (!strcmp(tmp, normalize(info->sn))) |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1157 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1158 g_free(tmp); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1159 |
2086 | 1160 serv_got_update(gc, info->sn, 1, info->warnlevel/10, info->onlinesince, |
1161 time_idle, type, info->capabilities); | |
1162 | |
1163 return 1; | |
1164 } | |
1165 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1166 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1167 struct aim_userinfo_s *info; |
1168 va_list ap; | |
1169 struct gaim_connection *gc = sess->aux_data; | |
1170 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1171 va_start(ap, fr); |
2086 | 1172 info = va_arg(ap, struct aim_userinfo_s *); |
1173 va_end(ap); | |
1174 | |
1175 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0, 0); | |
1176 | |
1177 return 1; | |
1178 } | |
1179 | |
1180 static void cancel_direct_im(gpointer w, struct ask_direct *d) { | |
1181 debug_printf("Freeing DirectIM prompts.\n"); | |
1182 | |
1183 g_free(d->sn); | |
1184 g_free(d); | |
1185 } | |
1186 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1187 static void oscar_directim_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1188 struct direct_im *dim = data; |
1189 struct gaim_connection *gc = dim->gc; | |
1190 struct oscar_data *od = gc->proto_data; | |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
1191 struct conversation *cnv; |
2086 | 1192 char buf[256]; |
1193 | |
1194 if (!g_slist_find(connections, gc)) { | |
1195 g_free(dim); | |
1196 return; | |
1197 } | |
1198 | |
1199 if (source < 0) { | |
1200 g_free(dim); | |
1201 return; | |
1202 } | |
1203 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1204 if (dim->conn->fd != source) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1205 dim->conn->fd = source; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1206 |
2086 | 1207 aim_conn_completeconnect(od->sess, dim->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1208 if (!(cnv = find_conversation(dim->name))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1209 cnv = new_conversation(dim->name); |
2086 | 1210 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
1211 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
2086 | 1212 |
1213 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1214 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1215 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 1216 oscar_callback, dim->conn); |
1217 } | |
1218 | |
1219 static int accept_direct_im(gpointer w, struct ask_direct *d) { | |
1220 struct gaim_connection *gc = d->gc; | |
1221 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1222 struct direct_im *dim; | |
1223 char *host; int port = FAIM_LOGIN_PORT; | |
1224 int i; | |
1225 | |
1226 debug_printf("Accepted DirectIM.\n"); | |
1227 | |
1228 dim = find_direct_im(od, d->sn); | |
1229 if (dim) { | |
1230 cancel_direct_im(w, d); /* 40 */ | |
1231 return TRUE; | |
1232 } | |
1233 dim = g_new0(struct direct_im, 1); | |
1234 dim->gc = d->gc; | |
1235 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
1236 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1237 dim->conn = aim_directim_connect(od->sess, d->sn, NULL, d->cookie); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1238 if (!dim->conn) { |
2086 | 1239 g_free(dim); |
1240 cancel_direct_im(w, d); | |
1241 return TRUE; | |
1242 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1243 |
2086 | 1244 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
1245 gaim_directim_incoming, 0); | |
1246 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1247 gaim_directim_typing, 0); | |
1248 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1249 for (i = 0; i < (int)strlen(d->ip); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1250 if (d->ip[i] == ':') { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1251 port = atoi(&(d->ip[i+1])); |
2086 | 1252 break; |
1253 } | |
1254 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1255 host = g_strndup(d->ip, i); |
2086 | 1256 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
1257 dim->conn->fd = proxy_connect(host, port, oscar_directim_callback, dim); | |
1258 g_free(host); | |
1259 if (dim->conn->fd < 0) { | |
1260 aim_conn_kill(od->sess, &dim->conn); | |
1261 g_free(dim); | |
1262 cancel_direct_im(w, d); | |
1263 return TRUE; | |
1264 } | |
1265 | |
1266 cancel_direct_im(w, d); | |
1267 | |
1268 return TRUE; | |
1269 } | |
1270 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1271 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, struct aim_incomingim_ch1_args *args) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1272 char *tmp = g_malloc(BUF_LONG); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1273 struct gaim_connection *gc = sess->aux_data; |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1274 int flags = 0; |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1275 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1276 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1277 flags |= IM_FLAG_AWAY; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1278 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1279 if (args->icbmflags & AIM_IMFLAGS_HASICON) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1280 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1281 struct icon_req *ir = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1282 GSList *h = od->hasicons; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1283 char *who = normalize(userinfo->sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1284 debug_printf("%s has an icon\n", userinfo->sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1285 while (h) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1286 ir = h->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1287 if (!strcmp(ir->user, who)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1288 break; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1289 h = h->next; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1290 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1291 if (!h) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1292 ir = g_new0(struct icon_req, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1293 ir->user = g_strdup(who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1294 od->hasicons = g_slist_append(od->hasicons, ir); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1295 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1296 if ((args->iconlen != ir->length) || |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1297 (args->iconsum != ir->checksum) || |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1298 (args->iconstamp != ir->timestamp)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1299 ir->request = TRUE; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1300 ir->length = args->iconlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1301 ir->checksum = args->iconsum; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1302 ir->timestamp = args->iconstamp; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1303 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1304 |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1305 if (gc->user->iconfile[0] && (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1306 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1307 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1308 |
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1309 if (!stat(gc->user->iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1310 char *buf = g_malloc(st.st_size); |
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1311 file = fopen(gc->user->iconfile, "r"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1312 if (file) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1313 fread(buf, 1, st.st_size, file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1314 debug_printf("Sending buddy icon to %d\n", userinfo->sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1315 aim_send_icon(sess, conn, userinfo->sn, buf, st.st_size, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1316 st.st_mtime, aim_iconsum(buf, st.st_size)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1317 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1318 } else |
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1319 debug_printf("Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1320 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1321 } else |
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1322 debug_printf("Can't stat buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1323 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1324 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1325 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1326 * Quickly convert it to eight bit format, replacing |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1327 * non-ASCII UNICODE characters with their equivelent |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1328 * HTML entity. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1329 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1330 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1331 int i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1332 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1333 for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1334 unsigned short uni; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1335 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1336 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1337 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1338 if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1339 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1340 g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "%c", uni); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1341 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1342 } else { /* something else, do UNICODE entity */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1343 g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1344 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1345 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1346 } else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1347 g_snprintf(tmp, BUF_LONG, "%s", args->msg); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1348 |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1349 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1350 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1351 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1352 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1353 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1354 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1355 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, struct aim_incomingim_ch2_args *args) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1356 struct gaim_connection *gc = sess->aux_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1357 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1358 if (args->reqclass & AIM_CAPS_CHAT) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1359 char *name = extract_name(args->info.chat.roominfo.name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1360 int *exch = g_new0(int, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1361 GList *m = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1362 m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1363 *exch = args->info.chat.roominfo.exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1364 m = g_list_append(m, exch); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1365 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1366 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1367 userinfo->sn, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1368 args->info.chat.msg, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1369 m); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1370 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1371 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1372 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1373 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1374 } else if (args->reqclass & AIM_CAPS_VOICE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1375 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1376 set_icon_data(gc, normalize(userinfo->sn), args->info.icon.icon, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1377 args->info.icon.length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1378 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1379 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1380 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1381 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1382 debug_printf("%s received direct im request from %s (%s)\n", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1383 gc->username, userinfo->sn, args->info.imimage.ip); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1384 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1385 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1386 d->sn = g_strdup(userinfo->sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1387 strncpy(d->ip, args->info.imimage.ip, sizeof(d->ip)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1388 memcpy(d->cookie, args->cookie, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1389 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1390 userinfo->sn, gc->username); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1391 do_ask_dialog(buf, d, accept_direct_im, cancel_direct_im); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1392 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1393 debug_printf("Unknown reqclass %d\n", args->reqclass); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1394 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1395 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1396 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1397 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1398 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1399 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1400 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1401 int channel, ret = 0; |
2086 | 1402 struct aim_userinfo_s *userinfo; |
1403 va_list ap; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1404 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1405 va_start(ap, fr); |
2086 | 1406 channel = va_arg(ap, int); |
1407 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
1408 | |
1409 /* channel 1: standard message */ | |
1410 if (channel == 1) { | |
1411 struct aim_incomingim_ch1_args *args; | |
1412 | |
1413 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1414 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1415 ret = incomingim_chan1(sess, fr->conn, userinfo, args); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1416 |
2086 | 1417 } else if (channel == 2) { |
1418 struct aim_incomingim_ch2_args *args; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1419 |
2086 | 1420 args = va_arg(ap, struct aim_incomingim_ch2_args *); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1421 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1422 ret = incomingim_chan2(sess, fr->conn, userinfo, args); |
2086 | 1423 } |
1424 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1425 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1426 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1427 return ret; |
2086 | 1428 } |
1429 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1430 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1431 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1432 fu16_t chan, nummissed, reason; |
2086 | 1433 struct aim_userinfo_s *userinfo; |
1434 char buf[1024]; | |
1435 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1436 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1437 chan = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1438 userinfo = va_arg(ap, struct aim_userinfo_s *); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1439 nummissed = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1440 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1441 va_end(ap); |
1442 | |
1443 switch(reason) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1444 case 0: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1445 /* Invalid (0) */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1446 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1447 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1448 _("You missed %d message%s from %s because %s invalid."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1449 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1450 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1451 nummissed == 1 ? "it was" : "they were", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1452 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1453 break; |
2086 | 1454 case 1: |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1455 /* Message too large */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1456 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1457 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1458 _("You missed %d message%s from %s because %s too large."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1459 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1460 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1461 nummissed == 1 ? "it was" : "they were", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1462 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1463 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1464 case 2: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1465 /* Rate exceeded */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1466 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1467 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1468 _("You missed %d message%s from %s because the rate limit has been exceeded."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1469 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1470 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1471 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1472 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1473 case 3: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1474 /* Evil Sender */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1475 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1476 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1477 _("You missed %d message%s from %s because they are too evil."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1478 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1479 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1480 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1481 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1482 case 4: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1483 /* Evil Receiver */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1484 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1485 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1486 _("You missed %d message%s from %s because you are too evil."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1487 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1488 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1489 userinfo->sn); |
2086 | 1490 break; |
1491 default: | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1492 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1493 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1494 _("You missed %d message%s from %s for unknown reasons."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1495 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1496 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1497 userinfo->sn); |
2086 | 1498 break; |
1499 } | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1500 do_error_dialog(buf, _("Gaim - Error")); |
2086 | 1501 |
1502 return 1; | |
1503 } | |
1504 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1505 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1506 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1507 fu16_t reason; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1508 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1509 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1510 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1511 va_end(ap); |
1512 | |
1513 debug_printf("snac threw error (reason 0x%04x: %s\n", reason, | |
1514 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); | |
1515 | |
1516 return 1; | |
1517 } | |
1518 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1519 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1520 va_list ap; |
1521 char *destn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1522 fu16_t reason; |
2086 | 1523 char buf[1024]; |
1524 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1525 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1526 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1527 destn = va_arg(ap, char *); |
1528 va_end(ap); | |
1529 | |
1530 sprintf(buf, _("Your message to %s did not get sent: %s"), destn, | |
1531 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); | |
1532 do_error_dialog(buf, _("Gaim - Error")); | |
1533 | |
1534 return 1; | |
1535 } | |
1536 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1537 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1538 va_list ap; |
1539 char *destn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1540 fu16_t reason; |
2086 | 1541 char buf[1024]; |
1542 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1543 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1544 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1545 destn = va_arg(ap, char *); |
1546 va_end(ap); | |
1547 | |
1548 sprintf(buf, _("User information for %s unavailable: %s"), destn, | |
1549 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); | |
1550 do_error_dialog(buf, _("Gaim - Error")); | |
1551 | |
1552 return 1; | |
1553 } | |
1554 | |
1555 static char *images(int flags) { | |
1556 static char buf[1024]; | |
1557 g_snprintf(buf, sizeof(buf), "%s%s%s%s", | |
1558 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", | |
1559 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
1560 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", | |
1561 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : ""); | |
1562 return buf; | |
1563 } | |
1564 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1565 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1566 struct aim_userinfo_s *info; |
1567 char *prof_enc = NULL, *prof = NULL; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1568 fu16_t infotype; |
2086 | 1569 char buf[BUF_LONG]; |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1570 char legend[BUF_LONG]; |
2086 | 1571 struct gaim_connection *gc = sess->aux_data; |
1572 va_list ap; | |
1573 char *asc; | |
1574 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1575 va_start(ap, fr); |
2086 | 1576 info = va_arg(ap, struct aim_userinfo_s *); |
1577 prof_enc = va_arg(ap, char *); | |
1578 prof = va_arg(ap, char *); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1579 infotype = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1580 va_end(ap); |
1581 | |
1582 if (info->membersince) | |
1583 asc = g_strdup_printf("Member Since : <B>%s</B><BR>\n", | |
1584 asctime(localtime(&info->membersince))); | |
1585 else | |
1586 asc = g_strdup(""); | |
1587 | |
1588 g_snprintf(buf, sizeof buf, | |
1589 _("Username : <B>%s</B> %s <BR>\n" | |
1590 "%s" | |
1591 "Warning Level : <B>%d %%</B><BR>\n" | |
1592 "Online Since : <B>%s</B><BR>\n" | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1593 "Idle Minutes : <B>%d</B>\n<BR>\n<HR><BR>\n"), |
2086 | 1594 info->sn, images(info->flags), |
1595 asc, | |
1596 info->warnlevel/10, | |
1597 asctime(localtime(&info->onlinesince)), | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1598 info->idletime); |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1599 g_snprintf(legend, sizeof legend, |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1600 _("<br><BODY BGCOLOR=WHITE><hr><I>Legend:</I><br><br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1601 "<IMG SRC=\"free_icon.gif\"> : Normal AIM User<br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1602 "<IMG SRC=\"aol_icon.gif\"> : AOL User <br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1603 "<IMG SRC=\"dt_icon.gif\"> : Trial AIM User <br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1604 "<IMG SRC=\"admin_icon.gif\"> : Administrator")); |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1605 g_show_info_text(buf, |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1606 (prof && strlen(prof)) ? |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1607 away_subs(prof, gc->username) |
2086 | 1608 : |
1609 (infotype == AIM_GETINFO_GENERALINFO ? | |
1610 _("<i>No Information Provided</i>") : | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1611 _("<i>User has no away message</i>")), |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1612 legend, |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1613 NULL); |
2086 | 1614 |
1615 g_free(asc); | |
1616 | |
1617 return 1; | |
1618 } | |
1619 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1620 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1621 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1622 fu16_t id; |
2086 | 1623 va_list ap; |
1624 char buildbuf[150]; | |
1625 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1626 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1627 id = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1628 msg = va_arg(ap, char *); |
1629 va_end(ap); | |
1630 | |
1631 aim_getbuildstring(buildbuf, sizeof(buildbuf)); | |
1632 | |
1633 debug_printf("MOTD: %s (%d)\n", msg ? msg : "Unknown", id); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1634 debug_printf("Gaim %s / libfaim %s\n", VERSION, buildbuf); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1635 if (id < 4) |
2086 | 1636 do_error_dialog(_("Your connection may be lost."), |
1637 _("AOL error")); | |
1638 | |
1639 return 1; | |
1640 } | |
1641 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1642 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1643 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1644 fu16_t type; |
2086 | 1645 struct gaim_connection *gc = sess->aux_data; |
1646 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
1647 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1648 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1649 type = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1650 |
1651 switch(type) { | |
1652 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1653 fu8_t maxrooms; |
2086 | 1654 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1655 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1656 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1657 maxrooms = (fu8_t)va_arg(ap, unsigned int); |
2086 | 1658 exchangecount = va_arg(ap, int); |
1659 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
1660 va_end(ap); | |
1661 | |
1662 debug_printf("chat info: Chat Rights:\n"); | |
1663 debug_printf("chat info: \tMax Concurrent Rooms: %d\n", maxrooms); | |
1664 debug_printf("chat info: \tExchange List: (%d total)\n", exchangecount); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1665 for (i = 0; i < exchangecount; i++) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1666 debug_printf("chat info: \t\t%d\n", exchanges[i].number); |
2086 | 1667 if (odata->create_exchange) { |
1668 debug_printf("creating room %s\n", odata->create_name); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1669 aim_chatnav_createroom(sess, fr->conn, odata->create_name, |
2086 | 1670 odata->create_exchange); |
1671 odata->create_exchange = 0; | |
1672 g_free(odata->create_name); | |
1673 odata->create_name = NULL; | |
1674 } | |
1675 } | |
1676 break; | |
1677 case 0x0008: { | |
1678 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1679 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1680 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1681 fu32_t createtime; |
2086 | 1682 |
1683 fqcn = va_arg(ap, char *); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1684 instance = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1685 exchange = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1686 flags = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1687 createtime = va_arg(ap, fu32_t); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1688 maxmsglen = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1689 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1690 createperms = (fu8_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1691 unknown = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1692 name = va_arg(ap, char *); |
1693 ck = va_arg(ap, char *); | |
1694 va_end(ap); | |
1695 | |
1696 debug_printf("created room: %s %d %d %d %lu %d %d %d %d %s %s\n", | |
1697 fqcn, | |
1698 exchange, instance, flags, | |
1699 createtime, | |
1700 maxmsglen, maxoccupancy, createperms, unknown, | |
1701 name, ck); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1702 aim_chat_join(odata->sess, odata->conn, exchange, ck, instance); |
2086 | 1703 } |
1704 break; | |
1705 default: | |
1706 va_end(ap); | |
1707 debug_printf("chatnav info: unknown type (%04x)\n", type); | |
1708 break; | |
1709 } | |
1710 return 1; | |
1711 } | |
1712 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1713 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1714 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1715 int count, i; |
2086 | 1716 struct aim_userinfo_s *info; |
1717 struct gaim_connection *g = sess->aux_data; | |
1718 | |
1719 struct chat_connection *c = NULL; | |
1720 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1721 va_start(ap, fr); |
2086 | 1722 count = va_arg(ap, int); |
1723 info = va_arg(ap, struct aim_userinfo_s *); | |
1724 va_end(ap); | |
1725 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1726 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 1727 if (!c) |
1728 return 1; | |
1729 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1730 for (i = 0; i < count; i++) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1731 add_chat_buddy(c->cnv, info[i].sn); |
2086 | 1732 |
1733 return 1; | |
1734 } | |
1735 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1736 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1737 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1738 int count, i; |
2086 | 1739 struct aim_userinfo_s *info; |
1740 struct gaim_connection *g = sess->aux_data; | |
1741 | |
1742 struct chat_connection *c = NULL; | |
1743 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1744 va_start(ap, fr); |
2086 | 1745 count = va_arg(ap, int); |
1746 info = va_arg(ap, struct aim_userinfo_s *); | |
1747 va_end(ap); | |
1748 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1749 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 1750 if (!c) |
1751 return 1; | |
1752 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1753 for (i = 0; i < count; i++) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1754 remove_chat_buddy(c->cnv, info[i].sn); |
2086 | 1755 |
1756 return 1; | |
1757 } | |
1758 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1759 static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1760 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1761 struct aim_userinfo_s *userinfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1762 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1763 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1764 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1765 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1766 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1767 fu32_t creationtime; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1768 struct gaim_connection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1769 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1770 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1771 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1772 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1773 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1774 usercount= va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1775 userinfo = va_arg(ap, struct aim_userinfo_s *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1776 roomdesc = va_arg(ap, char *); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1777 unknown_c9 = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1778 creationtime = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1779 maxmsglen = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1780 unknown_d2 = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1781 unknown_d5 = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1782 maxvisiblemsglen = (fu16_t)va_arg(ap, int); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1783 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1784 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1785 debug_printf("inside chat_info_update (maxmsglen = %d, maxvislen = %d)\n", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1786 maxmsglen, maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1787 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1788 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1789 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1790 |
2086 | 1791 return 1; |
1792 } | |
1793 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1794 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1795 va_list ap; |
1796 struct aim_userinfo_s *info; | |
1797 char *msg; | |
1798 struct gaim_connection *gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1799 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
2086 | 1800 char *tmp; |
1801 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1802 va_start(ap, fr); |
2086 | 1803 info = va_arg(ap, struct aim_userinfo_s *); |
1804 msg = va_arg(ap, char *); | |
1805 | |
1806 tmp = g_malloc(BUF_LONG); | |
1807 g_snprintf(tmp, BUF_LONG, "%s", msg); | |
1808 serv_got_chat_in(gc, ccon->id, info->sn, 0, tmp, time((time_t)NULL)); | |
1809 g_free(tmp); | |
1810 | |
1811 return 1; | |
1812 } | |
1813 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1814 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1815 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1816 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1817 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1818 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1819 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1820 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1821 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1822 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1823 type = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1824 sn = va_arg(ap, char *); |
1825 va_end(ap); | |
1826 | |
1827 debug_printf("Sent message to %s.\n", sn); | |
1828 | |
1829 return 1; | |
1830 } | |
1831 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1832 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1833 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1834 "invalid", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1835 "change", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1836 "warning", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1837 "limit", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1838 "limit cleared", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1839 }; |
2086 | 1840 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1841 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1842 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1843 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1844 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1845 code = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1846 rateclass= (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1847 windowsize = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1848 clear = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1849 alert = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1850 limit = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1851 disconnect = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1852 currentavg = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1853 maxavg = (fu32_t)va_arg(ap, unsigned long); |
2086 | 1854 va_end(ap); |
1855 | |
1856 debug_printf("rate %s (paramid 0x%04lx): curavg = %ld, maxavg = %ld, alert at %ld, " | |
1857 "clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)\n", | |
1858 (code < 5) ? codes[code] : codes[0], | |
1859 rateclass, | |
1860 currentavg, maxavg, | |
1861 alert, clear, | |
1862 limit, disconnect, | |
1863 windowsize); | |
1864 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1865 /* XXX fix these values */ |
2086 | 1866 if (code == AIM_RATE_CODE_CHANGE) { |
1867 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1868 aim_conn_setlatency(fr->conn, 0); |
2086 | 1869 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1870 aim_conn_setlatency(fr->conn, windowsize/4); |
2086 | 1871 } else if (code == AIM_RATE_CODE_LIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1872 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 1873 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1874 aim_conn_setlatency(fr->conn, 0); |
2086 | 1875 } |
1876 | |
1877 return 1; | |
1878 } | |
1879 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1880 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1881 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1882 fu16_t newevil; |
2086 | 1883 struct aim_userinfo_s *userinfo; |
1884 struct gaim_connection *gc = sess->aux_data; | |
1885 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1886 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1887 newevil = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1888 userinfo = va_arg(ap, struct aim_userinfo_s *); |
1889 va_end(ap); | |
1890 | |
1891 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, newevil / 10); | |
1892 | |
1893 return 1; | |
1894 } | |
1895 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1896 static int rateresp_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1897 struct gaim_connection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1898 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1899 aim_bos_ackrateresp(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1900 aim_bos_reqpersonalinfo(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1901 aim_bos_reqlocaterights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1902 aim_bos_setprofile(sess, fr->conn, gc->user->user_info, NULL, gaim_caps); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1903 aim_bos_reqbuddyrights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1904 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1905 account_online(gc); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1906 serv_finish_login(gc); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1907 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1908 if (bud_list_cache_exists(gc)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1909 do_import(NULL, gc); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1910 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1911 debug_printf("buddy list loaded\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1912 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1913 aim_reqicbmparams(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1914 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1915 aim_bos_reqrights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1916 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1917 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1918 AIM_PRIVFLAGS_ALLOWMEMBERSINCE); |
2086 | 1919 |
1920 return 1; | |
1921 } | |
1922 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1923 static int rateresp_auth(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1924 aim_bos_ackrateresp(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1925 aim_auth_clientready(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1926 debug_printf("connected to auth (admin)\n"); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1927 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1928 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1929 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1930 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1931 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1932 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1933 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1934 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1935 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1936 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1937 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1938 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1939 debug_printf("ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, " |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1940 "max sender evil = %f, max receiver evil = %f, min msg interval = %ld\n", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1941 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1942 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1943 params->minmsginterval); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1944 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1945 /* Maybe senderwarn and recverwarn should be user preferences... */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1946 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1947 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1948 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1949 aim_seticbmparam(sess, fr->conn, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1950 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1951 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1952 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1953 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1954 /* XXX this is frivelous... do you really want to know this info? */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1955 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1956 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1957 fu16_t maxbuddies, maxwatchers; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1958 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1959 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1960 maxbuddies = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1961 maxwatchers = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1962 va_end(ap); |
1963 | |
1964 debug_printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); | |
1965 | |
1966 return 1; | |
1967 } | |
1968 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1969 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1970 fu16_t maxpermits, maxdenies; |
2086 | 1971 va_list ap; |
1972 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1973 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1974 maxpermits = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1975 maxdenies = (fu16_t)va_arg(ap, unsigned int); |
2086 | 1976 va_end(ap); |
1977 | |
1978 debug_printf("BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); | |
1979 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1980 aim_bos_clientready(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1981 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1982 aim_bos_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
2086 | 1983 |
1984 return 1; | |
1985 } | |
1986 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1987 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1988 va_list ap; |
1989 char *address, *SNs; | |
1990 int i, num; | |
1991 char *buf; | |
1992 int at = 0, len; | |
1993 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1994 va_start(ap, fr); |
2086 | 1995 address = va_arg(ap, char *); |
1996 num = va_arg(ap, int); | |
1997 SNs = va_arg(ap, char *); | |
1998 va_end(ap); | |
1999 | |
2000 len = num * (MAXSNLEN + 1) + 1024; | |
2001 buf = g_malloc(len); | |
2002 at += g_snprintf(buf + at, len - at, "<B>%s has the following screen names:</B><BR>", address); | |
2003 for (i = 0; i < num; i++) | |
2004 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
2005 g_show_info_text(buf, NULL); |
2086 | 2006 g_free(buf); |
2007 | |
2008 return 1; | |
2009 } | |
2010 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2011 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2012 va_list ap; |
2013 char *address; | |
2014 char buf[BUF_LONG]; | |
2015 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2016 va_start(ap, fr); |
2086 | 2017 address = va_arg(ap, char *); |
2018 va_end(ap); | |
2019 | |
2020 g_snprintf(buf, sizeof(buf), "No results found for email address %s", address); | |
2021 do_error_dialog(buf, _("Error")); | |
2022 | |
2023 return 1; | |
2024 } | |
2025 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2026 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2027 fu16_t status; |
2086 | 2028 va_list ap; |
2029 char msg[256]; | |
2030 struct gaim_connection *gc = sess->aux_data; | |
2031 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2032 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2033 status = (fu16_t)va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 2034 va_end(ap); |
2035 | |
2036 debug_printf("account confirmation returned status 0x%04x (%s)\n", status, | |
2037 status ? "email sent" : "unknown"); | |
2038 if (status) { | |
2039 g_snprintf(msg, sizeof(msg), "You should receive an email asking to confirm %s.", | |
2040 gc->username); | |
2041 do_error_dialog(msg, "Confirm"); | |
2042 } | |
2043 | |
2044 return 1; | |
2045 } | |
2046 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2047 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2048 int change, str; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2049 fu16_t perms, type, length; |
2086 | 2050 char *val; |
2051 va_list ap; | |
2052 char buf[BUF_LONG]; | |
2053 struct gaim_connection *gc = sess->aux_data; | |
2054 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2055 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2056 change = va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2057 perms = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2058 type = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2059 length = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2060 val = va_arg(ap, char *); |
2061 str = va_arg(ap, int); | |
2062 va_end(ap); | |
2063 | |
2064 debug_printf("info%s: perms = %d, type = %x, length = %d, val = %s\n", | |
2065 change ? " change" : "", perms, type, length, str ? val : "(not string)"); | |
2066 | |
2067 if ((type == 0x0011) && str) { | |
2068 g_snprintf(buf, sizeof(buf), "The email address for %s is %s", gc->username, val); | |
2069 do_error_dialog(buf, "Email"); | |
2070 } | |
2071 | |
2072 return 1; | |
2073 } | |
2074 | |
2075 static void oscar_keepalive(struct gaim_connection *gc) { | |
2076 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
2077 aim_flap_nop(odata->sess, odata->conn); | |
2078 } | |
2079 | |
2080 static char *oscar_name() { | |
2081 return "Oscar"; | |
2082 } | |
2083 | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2205
diff
changeset
|
2084 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int imflags) { |
2086 | 2085 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
2086 struct direct_im *dim = find_direct_im(odata, name); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2087 int ret = 0; |
2086 | 2088 if (dim) { |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2089 ret = aim_send_im_direct(odata->sess, dim->conn, message); |
2086 | 2090 } else { |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2205
diff
changeset
|
2091 if (imflags & IM_FLAG_AWAY) |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2092 ret = aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message); |
2086 | 2093 else { |
2197
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2094 struct aim_sendimext_args args; |
2086 | 2095 GSList *h = odata->hasicons; |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
2096 struct icon_req *ir = NULL; |
2086 | 2097 char *who = normalize(name); |
2197
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2098 struct stat st; |
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
2099 |
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
2100 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
2101 |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2102 args.features = gaim_features; |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2103 args.featureslen = sizeof(gaim_features); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2104 |
2086 | 2105 while (h) { |
2106 ir = h->data; | |
2107 if (ir->request && !strcmp(who, ir->user)) | |
2108 break; | |
2109 h = h->next; | |
2110 } | |
2111 if (h) { | |
2112 ir->request = FALSE; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2113 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
2086 | 2114 debug_printf("sending buddy icon request with message\n"); |
2115 } | |
2197
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2116 |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2117 if (gc->user->iconfile[0] && !stat(gc->user->iconfile, &st)) { |
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
2118 FILE *file = fopen(gc->user->iconfile, "r"); |
2197
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2119 if (file) { |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2120 char *buf = g_malloc(st.st_size); |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2121 fread(buf, 1, st.st_size, file); |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2122 |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2123 args.iconlen = st.st_size; |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2124 args.iconsum = aim_iconsum(buf, st.st_size); |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2125 args.iconstamp = st.st_mtime; |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2126 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2127 args.flags |= AIM_IMFLAGS_HASICON; |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2128 debug_printf("Claiming to have an icon.\n"); |
2197
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2129 |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2130 fclose(file); |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2131 g_free(buf); |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2132 } |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2133 } |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2134 |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2135 args.destsn = name; |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2136 args.msg = message; |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2137 args.msglen = strlen(message); |
8f1ca76e46f5
[gaim-migrate @ 2207]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2138 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2139 ret = aim_send_im_ext(odata->sess, odata->conn, &args); |
2086 | 2140 } |
2141 } | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2142 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2143 return 1; |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
2144 return ret; |
2086 | 2145 } |
2146 | |
2147 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
2148 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2149 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO); | |
2150 } | |
2151 | |
2152 static void oscar_get_away_msg(struct gaim_connection *g, char *name) { | |
2153 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2154 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); | |
2155 } | |
2156 | |
2157 static void oscar_set_dir(struct gaim_connection *g, char *first, char *middle, char *last, | |
2158 char *maiden, char *city, char *state, char *country, int web) { | |
2159 /* FIXME : some of these things are wrong, but i'm lazy */ | |
2160 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2161 aim_setdirectoryinfo(odata->sess, odata->conn, first, middle, last, | |
2162 maiden, NULL, NULL, city, state, NULL, 0, web); | |
2163 } | |
2164 | |
2165 | |
2166 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
2167 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2168 aim_bos_setidle(odata->sess, odata->conn, time); | |
2169 } | |
2170 | |
2171 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
2172 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2173 char inforeal[1025], away[1025]; | |
2174 g_snprintf(inforeal, sizeof(inforeal), "%s", info); | |
2175 if (g->away) | |
2176 g_snprintf(away, sizeof(away), "%s", g->away); | |
2177 if (strlen(info) > 1024) | |
2178 do_error_dialog("Maximum info length (1024) exceeded, truncating", "Info Too Long"); | |
2179 aim_bos_setprofile(odata->sess, odata->conn, inforeal, g->away ? NULL : "", gaim_caps); | |
2180 } | |
2181 | |
2182 static void oscar_set_away(struct gaim_connection *g, char *state, char *message) { | |
2183 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2184 char info[1025], away[1025]; | |
2185 g_snprintf(info, sizeof(info), "%s", g->user->user_info); | |
2186 if (message) | |
2187 g_snprintf(away, sizeof(away), "%s", message); | |
2188 aim_bos_setprofile(odata->sess, odata->conn, NULL, message ? away : "", gaim_caps); | |
2189 if (g->away) | |
2190 g_free (g->away); | |
2191 g->away = NULL; | |
2192 if (message) { | |
2193 if (strlen(message) > 1024) | |
2194 do_error_dialog("Maximum away length (1024) exceeded, truncating", | |
2195 "Info Too Long"); | |
2196 g->away = g_strdup (message); | |
2197 } | |
2198 } | |
2199 | |
2200 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { | |
2201 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2113 | 2202 aim_send_warning(odata->sess, odata->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 2203 } |
2204 | |
2205 static void oscar_dir_search(struct gaim_connection *g, char *first, char *middle, char *last, | |
2206 char *maiden, char *city, char *state, char *country, char *email) { | |
2207 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2208 if (strlen(email)) | |
2209 aim_usersearch_address(odata->sess, odata->conn, email); | |
2210 } | |
2211 | |
2212 static void oscar_add_buddy(struct gaim_connection *g, char *name) { | |
2213 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2214 aim_add_buddy(odata->sess, odata->conn, name); | |
2215 } | |
2216 | |
2217 static void oscar_add_buddies(struct gaim_connection *g, GList *buddies) { | |
2218 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2219 char buf[MSG_LEN]; | |
2220 int n = 0; | |
2221 while (buddies) { | |
2222 if (n > MSG_LEN - 18) { | |
2223 aim_bos_setbuddylist(odata->sess, odata->conn, buf); | |
2224 n = 0; | |
2225 } | |
2226 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); | |
2227 buddies = buddies->next; | |
2228 } | |
2229 aim_bos_setbuddylist(odata->sess, odata->conn, buf); | |
2230 } | |
2231 | |
2232 static void oscar_remove_buddy(struct gaim_connection *g, char *name) { | |
2233 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2234 aim_remove_buddy(odata->sess, odata->conn, name); | |
2235 } | |
2236 | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2237 static GList *oscar_chat_info(struct gaim_connection *gc) { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2238 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2239 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2240 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2241 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2242 pce->label = _("Join what group:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2243 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2244 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2245 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2246 pce->label = _("Exchange:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2247 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2248 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2249 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2250 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2251 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2252 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2253 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2254 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2255 static void oscar_join_chat(struct gaim_connection *g, GList *data) { |
2086 | 2256 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2257 aim_conn_t *cur; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2258 char *name; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2259 int *exchange; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2260 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2261 if (!data || !data->next) |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2262 return; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2263 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2264 name = data->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2265 exchange = data->next->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2266 |
2086 | 2267 debug_printf("Attempting to join chat room %s.\n", name); |
2268 if ((cur = aim_getconn_type(odata->sess, AIM_CONN_TYPE_CHATNAV))) { | |
2269 debug_printf("chatnav exists, creating room\n"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2270 aim_chatnav_createroom(odata->sess, cur, name, *exchange); |
2086 | 2271 } else { |
2272 /* this gets tricky */ | |
2273 debug_printf("chatnav does not exist, opening chatnav\n"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2274 odata->create_exchange = *exchange; |
2086 | 2275 odata->create_name = g_strdup(name); |
2276 aim_bos_reqservice(odata->sess, odata->conn, AIM_CONN_TYPE_CHATNAV); | |
2277 } | |
2278 } | |
2279 | |
2280 static void oscar_chat_invite(struct gaim_connection *g, int id, char *message, char *name) { | |
2281 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2282 struct chat_connection *ccon = find_oscar_chat(g, id); | |
2283 | |
2284 if (!ccon) | |
2285 return; | |
2286 | |
2287 aim_chat_invite(odata->sess, odata->conn, name, message ? message : "", | |
2288 ccon->exchange, ccon->name, 0x0); | |
2289 } | |
2290 | |
2291 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
2292 struct oscar_data *odata = g ? (struct oscar_data *)g->proto_data : NULL; | |
2293 GSList *bcs = g->buddy_chats; | |
2294 struct conversation *b = NULL; | |
2295 struct chat_connection *c = NULL; | |
2296 int count = 0; | |
2297 | |
2298 while (bcs) { | |
2299 count++; | |
2300 b = (struct conversation *)bcs->data; | |
2301 if (id == b->id) | |
2302 break; | |
2303 bcs = bcs->next; | |
2304 b = NULL; | |
2305 } | |
2306 | |
2307 if (!b) | |
2308 return; | |
2309 | |
2310 debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count); | |
2311 | |
2312 c = find_oscar_chat(g, b->id); | |
2313 if (c != NULL) { | |
2314 if (odata) | |
2315 odata->oscar_chats = g_slist_remove(odata->oscar_chats, c); | |
2316 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2317 gaim_input_remove(c->inpa); |
2086 | 2318 if (g && odata->sess) |
2319 aim_conn_kill(odata->sess, &c->conn); | |
2320 g_free(c->name); | |
2321 g_free(c->show); | |
2322 g_free(c); | |
2323 } | |
2324 /* we do this because with Oscar it doesn't tell us we left */ | |
2325 serv_got_chat_left(g, b->id); | |
2326 } | |
2327 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2328 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
2086 | 2329 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2330 GSList *bcs = g->buddy_chats; | |
2331 struct conversation *b = NULL; | |
2332 struct chat_connection *c = NULL; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2333 char *buf, *buf2; |
2086 | 2334 int i, j; |
2335 | |
2336 while (bcs) { | |
2337 b = (struct conversation *)bcs->data; | |
2338 if (id == b->id) | |
2339 break; | |
2340 bcs = bcs->next; | |
2341 b = NULL; | |
2342 } | |
2343 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2344 return -EINVAL; |
2086 | 2345 |
2346 bcs = odata->oscar_chats; | |
2347 while (bcs) { | |
2348 c = (struct chat_connection *)bcs->data; | |
2349 if (b == c->cnv) | |
2350 break; | |
2351 bcs = bcs->next; | |
2352 c = NULL; | |
2353 } | |
2354 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2355 return -EINVAL; |
2086 | 2356 |
2357 buf = g_malloc(strlen(message) * 4 + 1); | |
2358 for (i = 0, j = 0; i < strlen(message); i++) { | |
2359 if (message[i] == '\n') { | |
2360 buf[j++] = '<'; | |
2361 buf[j++] = 'B'; | |
2362 buf[j++] = 'R'; | |
2363 buf[j++] = '>'; | |
2364 } else { | |
2365 buf[j++] = message[i]; | |
2366 } | |
2367 } | |
2368 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2369 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2370 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2371 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2372 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2373 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2374 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2375 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2376 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2377 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2378 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2379 |
2086 | 2380 aim_chat_send_im(odata->sess, c->conn, 0, buf, strlen(buf)); |
2381 g_free(buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2382 return 0; |
2086 | 2383 } |
2384 | |
2385 static char **oscar_list_icon(int uc) { | |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
2386 if (uc & UC_AB) |
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
2387 return (char **)ab_xpm; |
2086 | 2388 if (uc & UC_UNAVAILABLE) |
2389 return (char **)away_icon_xpm; | |
2390 if (uc & UC_AOL) | |
2391 return (char **)aol_icon_xpm; | |
2392 if (uc & UC_ADMIN) | |
2393 return (char **)admin_icon_xpm; | |
2394 if (uc & UC_UNCONFIRMED) | |
2395 return (char **)dt_icon_xpm; | |
2297
a0f6ead876ca
[gaim-migrate @ 2307]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2288
diff
changeset
|
2396 if (uc & UC_NORMAL) |
a0f6ead876ca
[gaim-migrate @ 2307]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2288
diff
changeset
|
2397 return (char **)free_icon_xpm; |
2086 | 2398 return NULL; |
2399 } | |
2400 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2401 static int gaim_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2402 va_list ap; |
2403 struct gaim_connection *gc = sess->aux_data; | |
2404 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2405 aim_conn_t *newconn, *listenerconn; |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
2406 struct conversation *cnv; |
2086 | 2407 struct direct_im *dim; |
2408 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2409 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2410 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2411 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2412 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2413 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 2414 va_end(ap); |
2415 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2416 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2417 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2418 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2419 sn = g_strdup(aim_directim_getsn(newconn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2420 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2421 debug_printf("DirectIM: initiate success to %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2422 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2423 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2424 if (!(cnv = find_conversation(sn))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2425 cnv = new_conversation(sn); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2426 gaim_input_remove(dim->watcher); |
2086 | 2427 dim->conn = newconn; |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2428 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 2429 oscar_callback, dim->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2430 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2431 g_free(sn); |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
2432 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
2086 | 2433 |
2434 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
2435 gaim_directim_incoming, 0); | |
2436 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
2437 gaim_directim_typing, 0); | |
2438 | |
2439 return 1; | |
2440 } | |
2441 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2442 static int gaim_directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2443 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2444 char *msg, *sn; |
2086 | 2445 struct gaim_connection *gc = sess->aux_data; |
2446 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2447 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2448 sn = va_arg(ap, char *); |
2086 | 2449 msg = va_arg(ap, char *); |
2450 va_end(ap); | |
2451 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2452 debug_printf("Got DirectIM message from %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2453 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2454 serv_got_im(gc, sn, msg, 0, time((time_t)NULL)); |
2086 | 2455 |
2456 return 1; | |
2457 } | |
2458 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2459 static int gaim_directim_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2460 va_list ap; |
2461 char *sn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2462 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2463 va_start(ap, fr); |
2086 | 2464 sn = va_arg(ap, char *); |
2465 va_end(ap); | |
2466 | |
2467 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2468 debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); |
2086 | 2469 |
2470 return 1; | |
2471 } | |
2472 | |
2473 struct ask_do_dir_im { | |
2474 char *who; | |
2475 struct gaim_connection *gc; | |
2476 }; | |
2477 | |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
2478 static void oscar_cancel_direct_im(gpointer obj, struct ask_do_dir_im *data) { |
2086 | 2479 g_free(data); |
2480 } | |
2481 | |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
2482 static void oscar_direct_im(gpointer obj, struct ask_do_dir_im *data) { |
2086 | 2483 struct gaim_connection *gc = data->gc; |
2484 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2485 struct direct_im *dim; | |
2486 | |
2487 dim = find_direct_im(od, data->who); | |
2488 if (dim) { | |
2489 do_error_dialog("Direct IM request already pending.", "Unable"); | |
2490 return; | |
2491 } | |
2492 dim = g_new0(struct direct_im, 1); | |
2493 dim->gc = gc; | |
2494 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
2495 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2496 dim->conn = aim_directim_initiate(od->sess, od->conn, data->who); |
2086 | 2497 if (dim->conn != NULL) { |
2498 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2499 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 2500 oscar_callback, dim->conn); |
2501 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, | |
2502 gaim_directim_initiate, 0); | |
2503 } else { | |
2504 do_error_dialog(_("Unable to open Direct IM"), _("Error")); | |
2505 g_free(dim); | |
2506 } | |
2507 } | |
2508 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2509 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
2086 | 2510 char buf[BUF_LONG]; |
2511 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | |
2512 data->who = who; | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2513 data->gc = gc; |
2086 | 2514 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s." |
2515 " Doing this will let them see your IP address, and may be" | |
2516 " a security risk. Do you wish to continue?"), who); | |
2517 do_ask_dialog(buf, data, oscar_direct_im, oscar_cancel_direct_im); | |
2518 } | |
2519 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2520 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2521 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2522 struct proto_buddy_menu *pbm; |
2086 | 2523 char *n = g_strdup(normalize(gc->username)); |
2524 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2525 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2526 pbm->label = _("Get Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2527 pbm->callback = oscar_get_info; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2528 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2529 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2530 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2531 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2532 pbm->label = _("Get Away Msg"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2533 pbm->callback = oscar_get_away_msg; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2534 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2535 m = g_list_append(m, pbm); |
2086 | 2536 |
2537 if (strcmp(n, normalize(who))) { | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2538 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2539 pbm->label = _("Direct IM"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2540 pbm->callback = oscar_ask_direct_im; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2541 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2542 m = g_list_append(m, pbm); |
2086 | 2543 } |
2544 g_free(n); | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2545 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2546 return m; |
2086 | 2547 } |
2548 | |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2549 static GList *oscar_user_opts() |
2086 | 2550 { |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2551 GList *m = NULL; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2552 struct proto_user_opt *puo; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2553 |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2554 puo = g_new0(struct proto_user_opt, 1); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2555 puo->label = "Auth Host:"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2556 puo->def = "login.oscar.aol.com"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2557 puo->pos = USEROPT_AUTH; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2558 m = g_list_append(m, puo); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2559 |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2560 puo = g_new0(struct proto_user_opt, 1); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2561 puo->label = "Auth Port:"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2562 puo->def = "5190"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2563 puo->pos = USEROPT_AUTHPORT; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2564 m = g_list_append(m, puo); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2565 |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2566 return m; |
2086 | 2567 } |
2568 | |
2569 static void oscar_set_permit_deny(struct gaim_connection *gc) { | |
2570 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2571 GSList *list; | |
2572 char buf[MAXMSGLEN]; | |
2573 int at; | |
2574 | |
2575 switch(gc->permdeny) { | |
2576 case 1: | |
2577 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username); | |
2578 break; | |
2579 case 2: | |
2580 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username); | |
2581 break; | |
2582 case 3: | |
2583 list = gc->permit; | |
2584 at = 0; | |
2585 while (list) { | |
2586 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
2587 list = list->next; | |
2588 } | |
2589 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
2590 break; | |
2591 case 4: | |
2592 list = gc->deny; | |
2593 at = 0; | |
2594 while (list) { | |
2595 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
2596 list = list->next; | |
2597 } | |
2598 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
2599 break; | |
2600 default: | |
2601 break; | |
2602 } | |
2603 } | |
2604 | |
2605 static void oscar_add_permit(struct gaim_connection *gc, char *who) { | |
2606 if (gc->permdeny != 3) return; | |
2607 oscar_set_permit_deny(gc); | |
2608 } | |
2609 | |
2610 static void oscar_add_deny(struct gaim_connection *gc, char *who) { | |
2611 if (gc->permdeny != 4) return; | |
2612 oscar_set_permit_deny(gc); | |
2613 } | |
2614 | |
2615 static void oscar_rem_permit(struct gaim_connection *gc, char *who) { | |
2616 if (gc->permdeny != 3) return; | |
2617 oscar_set_permit_deny(gc); | |
2618 } | |
2619 | |
2620 static void oscar_rem_deny(struct gaim_connection *gc, char *who) { | |
2621 if (gc->permdeny != 4) return; | |
2622 oscar_set_permit_deny(gc); | |
2623 } | |
2624 | |
2625 static GList *oscar_away_states() | |
2626 { | |
2627 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | |
2628 } | |
2629 | |
2630 static void oscar_do_action(struct gaim_connection *gc, char *act) | |
2631 { | |
2632 struct oscar_data *od = gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2633 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
2086 | 2634 |
2635 if (!strcmp(act, "Set User Info")) { | |
2636 show_set_info(gc); | |
2637 } else if (!strcmp(act, "Change Password")) { | |
2638 show_change_passwd(gc); | |
2639 } else if (!strcmp(act, "Confirm Account")) { | |
2640 if (!conn) { | |
2641 od->conf = TRUE; | |
2642 aim_bos_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
2643 } else | |
2644 aim_auth_reqconfirm(od->sess, conn); | |
2645 } else if (!strcmp(act, "Change Email")) { | |
2646 } else if (!strcmp(act, "Display Current Registered Address")) { | |
2647 if (!conn) { | |
2648 od->reqemail = TRUE; | |
2649 aim_bos_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
2650 } else | |
2651 aim_auth_getinfo(od->sess, conn, 0x11); | |
2652 } else if (!strcmp(act, "Search for Buddy by Email")) { | |
2653 show_find_email(gc); | |
2654 } | |
2655 } | |
2656 | |
2657 static GList *oscar_actions() | |
2658 { | |
2659 GList *m = NULL; | |
2660 | |
2661 m = g_list_append(m, "Set User Info"); | |
2662 m = g_list_append(m, NULL); | |
2663 m = g_list_append(m, "Change Password"); | |
2664 m = g_list_append(m, "Confirm Account"); | |
2665 /* | |
2666 m = g_list_append(m, "Change Email"); | |
2667 */ | |
2668 m = g_list_append(m, "Display Current Registered Address"); | |
2669 m = g_list_append(m, NULL); | |
2670 m = g_list_append(m, "Search for Buddy by Email"); | |
2671 | |
2672 return m; | |
2673 } | |
2674 | |
2675 static void oscar_change_passwd(struct gaim_connection *gc, char *old, char *new) | |
2676 { | |
2677 struct oscar_data *od = gc->proto_data; | |
2678 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
2679 od->chpass = TRUE; | |
2680 od->oldp = g_strdup(old); | |
2681 od->newp = g_strdup(new); | |
2682 aim_bos_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
2683 } else { | |
2684 aim_auth_changepasswd(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), | |
2685 new, old); | |
2686 } | |
2687 } | |
2688 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2689 static void oscar_convo_closed(struct gaim_connection *gc, char *who) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2690 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2691 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2692 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2693 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2694 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2695 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2696 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2697 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2698 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2699 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2700 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2701 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2702 |
2086 | 2703 static struct prpl *my_protocol = NULL; |
2704 | |
2705 void oscar_init(struct prpl *ret) { | |
2706 ret->protocol = PROTO_OSCAR; | |
2707 ret->options = OPT_PROTO_HTML | OPT_PROTO_CORRECT_TIME; | |
2708 ret->name = oscar_name; | |
2709 ret->list_icon = oscar_list_icon; | |
2710 ret->away_states = oscar_away_states; | |
2711 ret->actions = oscar_actions; | |
2712 ret->do_action = oscar_do_action; | |
2713 ret->buddy_menu = oscar_buddy_menu; | |
2714 ret->user_opts = oscar_user_opts; | |
2715 ret->login = oscar_login; | |
2716 ret->close = oscar_close; | |
2717 ret->send_im = oscar_send_im; | |
2718 ret->set_info = oscar_set_info; | |
2719 ret->get_info = oscar_get_info; | |
2720 ret->set_away = oscar_set_away; | |
2721 ret->set_dir = oscar_set_dir; | |
2722 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
2723 ret->dir_search = oscar_dir_search; | |
2724 ret->set_idle = oscar_set_idle; | |
2725 ret->change_passwd = oscar_change_passwd; | |
2726 ret->add_buddy = oscar_add_buddy; | |
2727 ret->add_buddies = oscar_add_buddies; | |
2728 ret->remove_buddy = oscar_remove_buddy; | |
2729 ret->add_permit = oscar_add_permit; | |
2730 ret->add_deny = oscar_add_deny; | |
2731 ret->rem_permit = oscar_rem_permit; | |
2732 ret->rem_deny = oscar_rem_deny; | |
2733 ret->set_permit_deny = oscar_set_permit_deny; | |
2734 ret->warn = oscar_warn; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
2735 ret->chat_info = oscar_chat_info; |
2086 | 2736 ret->join_chat = oscar_join_chat; |
2737 ret->chat_invite = oscar_chat_invite; | |
2738 ret->chat_leave = oscar_chat_leave; | |
2739 ret->chat_whisper = NULL; | |
2740 ret->chat_send = oscar_chat_send; | |
2741 ret->keepalive = oscar_keepalive; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2742 ret->convo_closed = oscar_convo_closed; |
2086 | 2743 |
2744 my_protocol = ret; | |
2745 } | |
2746 | |
2747 #ifndef STATIC | |
2748 | |
2749 char *gaim_plugin_init(GModule *handle) | |
2750 { | |
2751 load_protocol(oscar_init, sizeof(struct prpl)); | |
2752 return NULL; | |
2753 } | |
2754 | |
2755 void gaim_plugin_remove() | |
2756 { | |
2757 struct prpl *p = find_prpl(PROTO_OSCAR); | |
2758 if (p == my_protocol) | |
2759 unload_protocol(p); | |
2760 } | |
2761 | |
2762 char *name() | |
2763 { | |
2764 return "Oscar"; | |
2765 } | |
2766 | |
2767 char *description() | |
2768 { | |
2162
a464da684307
[gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2154
diff
changeset
|
2769 return PRPL_DESC("Oscar"); |
2086 | 2770 } |
2771 | |
2772 #endif |