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