[b7d3cc34] | 1 | /* |
---|
| 2 | * gaim |
---|
| 3 | * |
---|
[f66c701] | 4 | * Some code copyright (C) 2002-2006, Jelmer Vernooij <jelmer@samba.org> |
---|
| 5 | * and the BitlBee team. |
---|
[b7d3cc34] | 6 | * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
---|
| 7 | * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or modify |
---|
| 10 | * it under the terms of the GNU General Public License as published by |
---|
| 11 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | * (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
[6f10697] | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[b7d3cc34] | 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include <errno.h> |
---|
| 26 | #include <ctype.h> |
---|
| 27 | #include <string.h> |
---|
| 28 | #include <stdlib.h> |
---|
| 29 | #include <stdio.h> |
---|
| 30 | #include <time.h> |
---|
| 31 | #include <sys/stat.h> |
---|
| 32 | #include <glib.h> |
---|
| 33 | #include "nogaim.h" |
---|
| 34 | #include "bitlbee.h" |
---|
| 35 | #include "proxy.h" |
---|
[e4d6271] | 36 | #include "sock.h" |
---|
[b7d3cc34] | 37 | |
---|
| 38 | #include "aim.h" |
---|
| 39 | #include "icq.h" |
---|
| 40 | #include "bos.h" |
---|
| 41 | #include "ssi.h" |
---|
| 42 | #include "im.h" |
---|
| 43 | #include "info.h" |
---|
| 44 | #include "buddylist.h" |
---|
| 45 | #include "chat.h" |
---|
| 46 | #include "chatnav.h" |
---|
| 47 | |
---|
| 48 | /* constants to identify proto_opts */ |
---|
| 49 | #define USEROPT_AUTH 0 |
---|
| 50 | #define USEROPT_AUTHPORT 1 |
---|
| 51 | |
---|
[5ebff60] | 52 | #define UC_AOL 0x02 |
---|
| 53 | #define UC_ADMIN 0x04 |
---|
| 54 | #define UC_UNCONFIRMED 0x08 |
---|
| 55 | #define UC_NORMAL 0x10 |
---|
| 56 | #define UC_AB 0x20 |
---|
| 57 | #define UC_WIRELESS 0x40 |
---|
[b7d3cc34] | 58 | |
---|
| 59 | #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
---|
| 60 | |
---|
| 61 | #define OSCAR_GROUP "Friends" |
---|
| 62 | |
---|
[424e663] | 63 | #define BUF_LEN 2048 |
---|
[5ebff60] | 64 | #define BUF_LONG (BUF_LEN * 2) |
---|
[424e663] | 65 | |
---|
[b7d3cc34] | 66 | /* Don't know if support for UTF8 is really working. For now it's UTF16 here. |
---|
| 67 | static int gaim_caps = AIM_CAPS_UTF8; */ |
---|
| 68 | |
---|
[b8ef1b1] | 69 | static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT; |
---|
[5ebff60] | 70 | static guint8 gaim_features[] = { 0x01, 0x01, 0x01, 0x02 }; |
---|
[b7d3cc34] | 71 | |
---|
| 72 | struct oscar_data { |
---|
| 73 | aim_session_t *sess; |
---|
| 74 | aim_conn_t *conn; |
---|
| 75 | |
---|
| 76 | guint cnpa; |
---|
| 77 | guint paspa; |
---|
| 78 | |
---|
| 79 | GSList *create_rooms; |
---|
| 80 | |
---|
| 81 | gboolean conf; |
---|
| 82 | gboolean reqemail; |
---|
| 83 | gboolean setemail; |
---|
| 84 | char *email; |
---|
| 85 | gboolean setnick; |
---|
| 86 | char *newsn; |
---|
| 87 | gboolean chpass; |
---|
| 88 | char *oldp; |
---|
| 89 | char *newp; |
---|
| 90 | |
---|
| 91 | GSList *oscar_chats; |
---|
| 92 | |
---|
[5469952] | 93 | gboolean killme, no_reconnect; |
---|
[b7d3cc34] | 94 | gboolean icq; |
---|
| 95 | GSList *evilhack; |
---|
[5ebff60] | 96 | |
---|
[e64de00] | 97 | GHashTable *ips; |
---|
[b7d3cc34] | 98 | |
---|
| 99 | struct { |
---|
| 100 | guint maxbuddies; /* max users you can watch */ |
---|
| 101 | guint maxwatchers; /* max users who can watch you */ |
---|
| 102 | guint maxpermits; /* max users on permit list */ |
---|
| 103 | guint maxdenies; /* max users on deny list */ |
---|
| 104 | guint maxsiglen; /* max size (bytes) of profile */ |
---|
| 105 | guint maxawaymsglen; /* max size (bytes) of posted away message */ |
---|
| 106 | } rights; |
---|
| 107 | }; |
---|
| 108 | |
---|
| 109 | struct create_room { |
---|
| 110 | char *name; |
---|
| 111 | int exchange; |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | struct chat_connection { |
---|
| 115 | char *name; |
---|
| 116 | char *show; /* AOL did something funny to us */ |
---|
| 117 | guint16 exchange; |
---|
| 118 | guint16 instance; |
---|
| 119 | int fd; /* this is redundant since we have the conn below */ |
---|
| 120 | aim_conn_t *conn; |
---|
| 121 | int inpa; |
---|
| 122 | int id; |
---|
[0da65d5] | 123 | struct im_connection *ic; /* i hate this. */ |
---|
| 124 | struct groupchat *cnv; /* bah. */ |
---|
[b7d3cc34] | 125 | int maxlen; |
---|
| 126 | int maxvis; |
---|
| 127 | }; |
---|
| 128 | |
---|
| 129 | struct ask_direct { |
---|
[0da65d5] | 130 | struct im_connection *ic; |
---|
[b7d3cc34] | 131 | char *sn; |
---|
| 132 | char ip[64]; |
---|
| 133 | guint8 cookie[8]; |
---|
| 134 | }; |
---|
| 135 | |
---|
| 136 | struct icq_auth { |
---|
[0da65d5] | 137 | struct im_connection *ic; |
---|
[b7d3cc34] | 138 | guint32 uin; |
---|
| 139 | }; |
---|
| 140 | |
---|
[5ebff60] | 141 | static char *extract_name(const char *name) |
---|
| 142 | { |
---|
[b7d3cc34] | 143 | char *tmp; |
---|
| 144 | int i, j; |
---|
| 145 | char *x = strchr(name, '-'); |
---|
[5ebff60] | 146 | |
---|
| 147 | if (!x) { |
---|
| 148 | return g_strdup(name); |
---|
| 149 | } |
---|
[b7d3cc34] | 150 | x = strchr(++x, '-'); |
---|
[5ebff60] | 151 | if (!x) { |
---|
| 152 | return g_strdup(name); |
---|
| 153 | } |
---|
[b7d3cc34] | 154 | tmp = g_strdup(++x); |
---|
| 155 | |
---|
| 156 | for (i = 0, j = 0; x[i]; i++) { |
---|
| 157 | char hex[3]; |
---|
| 158 | if (x[i] != '%') { |
---|
| 159 | tmp[j++] = x[i]; |
---|
| 160 | continue; |
---|
| 161 | } |
---|
| 162 | strncpy(hex, x + ++i, 2); hex[2] = 0; |
---|
| 163 | i++; |
---|
[5ebff60] | 164 | tmp[j++] = (char) strtol(hex, NULL, 16); |
---|
[b7d3cc34] | 165 | } |
---|
| 166 | |
---|
| 167 | tmp[j] = 0; |
---|
| 168 | return tmp; |
---|
| 169 | } |
---|
| 170 | |
---|
[0da65d5] | 171 | static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic, |
---|
[5ebff60] | 172 | aim_conn_t *conn) |
---|
| 173 | { |
---|
| 174 | GSList *g = ((struct oscar_data *) ic->proto_data)->oscar_chats; |
---|
[b7d3cc34] | 175 | struct chat_connection *c = NULL; |
---|
| 176 | |
---|
| 177 | while (g) { |
---|
[5ebff60] | 178 | c = (struct chat_connection *) g->data; |
---|
| 179 | if (c->conn == conn) { |
---|
[b7d3cc34] | 180 | break; |
---|
[5ebff60] | 181 | } |
---|
[b7d3cc34] | 182 | g = g->next; |
---|
| 183 | c = NULL; |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | return c; |
---|
| 187 | } |
---|
| 188 | |
---|
[5ebff60] | 189 | static int gaim_parse_auth_resp(aim_session_t *, aim_frame_t *, ...); |
---|
| 190 | static int gaim_parse_login(aim_session_t *, aim_frame_t *, ...); |
---|
| 191 | static int gaim_parse_logout(aim_session_t *, aim_frame_t *, ...); |
---|
| 192 | static int gaim_handle_redirect(aim_session_t *, aim_frame_t *, ...); |
---|
| 193 | static int gaim_parse_oncoming(aim_session_t *, aim_frame_t *, ...); |
---|
| 194 | static int gaim_parse_offgoing(aim_session_t *, aim_frame_t *, ...); |
---|
[b7d3cc34] | 195 | static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); |
---|
[5ebff60] | 196 | static int gaim_parse_misses(aim_session_t *, aim_frame_t *, ...); |
---|
| 197 | static int gaim_parse_motd(aim_session_t *, aim_frame_t *, ...); |
---|
| 198 | static int gaim_chatnav_info(aim_session_t *, aim_frame_t *, ...); |
---|
| 199 | static int gaim_chat_join(aim_session_t *, aim_frame_t *, ...); |
---|
| 200 | static int gaim_chat_leave(aim_session_t *, aim_frame_t *, ...); |
---|
| 201 | static int gaim_chat_info_update(aim_session_t *, aim_frame_t *, ...); |
---|
[b7d3cc34] | 202 | static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
---|
[5ebff60] | 203 | static int gaim_parse_ratechange(aim_session_t *, aim_frame_t *, ...); |
---|
| 204 | static int gaim_bosrights(aim_session_t *, aim_frame_t *, ...); |
---|
| 205 | static int conninitdone_bos(aim_session_t *, aim_frame_t *, ...); |
---|
| 206 | static int conninitdone_admin(aim_session_t *, aim_frame_t *, ...); |
---|
| 207 | static int conninitdone_chat(aim_session_t *, aim_frame_t *, ...); |
---|
| 208 | static int conninitdone_chatnav(aim_session_t *, aim_frame_t *, ...); |
---|
| 209 | static int gaim_parse_msgerr(aim_session_t *, aim_frame_t *, ...); |
---|
[b7d3cc34] | 210 | static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); |
---|
| 211 | static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); |
---|
[5ebff60] | 212 | static int gaim_parse_locerr(aim_session_t *, aim_frame_t *, ...); |
---|
| 213 | static int gaim_icbm_param_info(aim_session_t *, aim_frame_t *, ...); |
---|
| 214 | static int gaim_parse_genericerr(aim_session_t *, aim_frame_t *, ...); |
---|
| 215 | static int gaim_selfinfo(aim_session_t *, aim_frame_t *, ...); |
---|
| 216 | static int gaim_offlinemsg(aim_session_t *, aim_frame_t *, ...); |
---|
| 217 | static int gaim_offlinemsgdone(aim_session_t *, aim_frame_t *, ...); |
---|
| 218 | static int gaim_ssi_parserights(aim_session_t *, aim_frame_t *, ...); |
---|
| 219 | static int gaim_ssi_parselist(aim_session_t *, aim_frame_t *, ...); |
---|
| 220 | static int gaim_ssi_parseack(aim_session_t *, aim_frame_t *, ...); |
---|
| 221 | static int gaim_parsemtn(aim_session_t *, aim_frame_t *, ...); |
---|
| 222 | static int gaim_icqinfo(aim_session_t *, aim_frame_t *, ...); |
---|
| 223 | static int gaim_parseaiminfo(aim_session_t *, aim_frame_t *, ...); |
---|
[b7d3cc34] | 224 | |
---|
| 225 | static char *msgerrreason[] = { |
---|
| 226 | "Invalid error", |
---|
| 227 | "Invalid SNAC", |
---|
| 228 | "Rate to host", |
---|
| 229 | "Rate to client", |
---|
| 230 | "Not logged in", |
---|
| 231 | "Service unavailable", |
---|
| 232 | "Service not defined", |
---|
| 233 | "Obsolete SNAC", |
---|
| 234 | "Not supported by host", |
---|
| 235 | "Not supported by client", |
---|
| 236 | "Refused by client", |
---|
| 237 | "Reply too big", |
---|
| 238 | "Responses lost", |
---|
| 239 | "Request denied", |
---|
| 240 | "Busted SNAC payload", |
---|
| 241 | "Insufficient rights", |
---|
| 242 | "In local permit/deny", |
---|
| 243 | "Too evil (sender)", |
---|
| 244 | "Too evil (receiver)", |
---|
| 245 | "User temporarily unavailable", |
---|
| 246 | "No match", |
---|
| 247 | "List overflow", |
---|
| 248 | "Request ambiguous", |
---|
| 249 | "Queue full", |
---|
| 250 | "Not while on AOL" |
---|
| 251 | }; |
---|
| 252 | static int msgerrreasonlen = 25; |
---|
| 253 | |
---|
[424e663] | 254 | /* Hurray, this function is NOT thread-safe \o/ */ |
---|
| 255 | static char *normalize(const char *s) |
---|
| 256 | { |
---|
| 257 | static char buf[BUF_LEN]; |
---|
| 258 | char *t, *u; |
---|
| 259 | int x = 0; |
---|
| 260 | |
---|
| 261 | g_return_val_if_fail((s != NULL), NULL); |
---|
| 262 | |
---|
[7a2a486] | 263 | u = t = g_ascii_strdown(s, -1); |
---|
[424e663] | 264 | |
---|
| 265 | while (*t && (x < BUF_LEN - 1)) { |
---|
| 266 | if (*t != ' ' && *t != '!') { |
---|
| 267 | buf[x] = *t; |
---|
| 268 | x++; |
---|
| 269 | } |
---|
| 270 | t++; |
---|
| 271 | } |
---|
| 272 | buf[x] = '\0'; |
---|
| 273 | g_free(u); |
---|
| 274 | return buf; |
---|
| 275 | } |
---|
| 276 | |
---|
[ba9edaa] | 277 | static gboolean oscar_callback(gpointer data, gint source, |
---|
[5ebff60] | 278 | b_input_condition condition) |
---|
| 279 | { |
---|
| 280 | aim_conn_t *conn = (aim_conn_t *) data; |
---|
[b7d3cc34] | 281 | aim_session_t *sess = aim_conn_getsess(conn); |
---|
[0da65d5] | 282 | struct im_connection *ic = sess ? sess->aux_data : NULL; |
---|
[b7d3cc34] | 283 | struct oscar_data *odata; |
---|
| 284 | |
---|
[0da65d5] | 285 | if (!ic) { |
---|
| 286 | /* ic is null. we return, else we seg SIGSEG on next line. */ |
---|
[ba9edaa] | 287 | return FALSE; |
---|
[b7d3cc34] | 288 | } |
---|
[5ebff60] | 289 | |
---|
[0da65d5] | 290 | if (!g_slist_find(get_connections(), ic)) { |
---|
[5ebff60] | 291 | /* oh boy. this is probably bad. i guess the only thing we |
---|
[b7d3cc34] | 292 | * can really do is return? */ |
---|
[ba9edaa] | 293 | return FALSE; |
---|
[b7d3cc34] | 294 | } |
---|
| 295 | |
---|
[5ebff60] | 296 | odata = (struct oscar_data *) ic->proto_data; |
---|
[b7d3cc34] | 297 | |
---|
[e046390] | 298 | if (condition & B_EV_IO_READ) { |
---|
[66c57924] | 299 | if (aim_get_command(odata->sess, conn) >= 0) { |
---|
| 300 | aim_rxdispatch(odata->sess); |
---|
[5ebff60] | 301 | if (odata->killme) { |
---|
| 302 | imc_logout(ic, !odata->no_reconnect); |
---|
| 303 | } |
---|
[b7d3cc34] | 304 | } else { |
---|
[66c57924] | 305 | if ((conn->type == AIM_CONN_TYPE_BOS) || |
---|
[5ebff60] | 306 | !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { |
---|
[84b045d] | 307 | imcb_error(ic, _("Disconnected.")); |
---|
[c2fb3809] | 308 | imc_logout(ic, TRUE); |
---|
[66c57924] | 309 | } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
---|
[0da65d5] | 310 | struct chat_connection *c = find_oscar_chat_by_conn(ic, conn); |
---|
[66c57924] | 311 | c->conn = NULL; |
---|
[5ebff60] | 312 | if (c->inpa > 0) { |
---|
[ba9edaa] | 313 | b_event_remove(c->inpa); |
---|
[5ebff60] | 314 | } |
---|
[66c57924] | 315 | c->inpa = 0; |
---|
| 316 | c->fd = -1; |
---|
| 317 | aim_conn_kill(odata->sess, &conn); |
---|
[84b045d] | 318 | imcb_error(sess->aux_data, _("You have been disconnected from chat room %s."), c->name); |
---|
[66c57924] | 319 | } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
---|
[5ebff60] | 320 | if (odata->cnpa > 0) { |
---|
[ba9edaa] | 321 | b_event_remove(odata->cnpa); |
---|
[5ebff60] | 322 | } |
---|
[66c57924] | 323 | odata->cnpa = 0; |
---|
| 324 | while (odata->create_rooms) { |
---|
| 325 | struct create_room *cr = odata->create_rooms->data; |
---|
| 326 | g_free(cr->name); |
---|
| 327 | odata->create_rooms = |
---|
[5ebff60] | 328 | g_slist_remove(odata->create_rooms, cr); |
---|
[66c57924] | 329 | g_free(cr); |
---|
[84b045d] | 330 | imcb_error(sess->aux_data, _("Chat is currently unavailable")); |
---|
[b7d3cc34] | 331 | } |
---|
[66c57924] | 332 | aim_conn_kill(odata->sess, &conn); |
---|
| 333 | } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
---|
[5ebff60] | 334 | if (odata->paspa > 0) { |
---|
[ba9edaa] | 335 | b_event_remove(odata->paspa); |
---|
[5ebff60] | 336 | } |
---|
[66c57924] | 337 | odata->paspa = 0; |
---|
| 338 | aim_conn_kill(odata->sess, &conn); |
---|
| 339 | } else { |
---|
| 340 | aim_conn_kill(odata->sess, &conn); |
---|
[b7d3cc34] | 341 | } |
---|
| 342 | } |
---|
[ba9edaa] | 343 | } else { |
---|
| 344 | /* WTF??? */ |
---|
| 345 | return FALSE; |
---|
[b7d3cc34] | 346 | } |
---|
[5ebff60] | 347 | |
---|
[ba9edaa] | 348 | return TRUE; |
---|
[b7d3cc34] | 349 | } |
---|
| 350 | |
---|
[ba9edaa] | 351 | static gboolean oscar_login_connect(gpointer data, gint source, b_input_condition cond) |
---|
[b7d3cc34] | 352 | { |
---|
[0da65d5] | 353 | struct im_connection *ic = data; |
---|
[b7d3cc34] | 354 | struct oscar_data *odata; |
---|
| 355 | aim_session_t *sess; |
---|
| 356 | aim_conn_t *conn; |
---|
| 357 | |
---|
[0da65d5] | 358 | if (!g_slist_find(get_connections(), ic)) { |
---|
[b7d3cc34] | 359 | closesocket(source); |
---|
[ba9edaa] | 360 | return FALSE; |
---|
[b7d3cc34] | 361 | } |
---|
| 362 | |
---|
[0da65d5] | 363 | odata = ic->proto_data; |
---|
[b7d3cc34] | 364 | sess = odata->sess; |
---|
| 365 | conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
---|
| 366 | |
---|
| 367 | if (source < 0) { |
---|
[84b045d] | 368 | imcb_error(ic, _("Couldn't connect to host")); |
---|
[c2fb3809] | 369 | imc_logout(ic, TRUE); |
---|
[ba9edaa] | 370 | return FALSE; |
---|
[b7d3cc34] | 371 | } |
---|
| 372 | |
---|
| 373 | aim_conn_completeconnect(sess, conn); |
---|
[e046390] | 374 | ic->inpa = b_input_add(conn->fd, B_EV_IO_READ, |
---|
[5ebff60] | 375 | oscar_callback, conn); |
---|
| 376 | |
---|
[ba9edaa] | 377 | return FALSE; |
---|
[b7d3cc34] | 378 | } |
---|
| 379 | |
---|
[0da65d5] | 380 | static void oscar_init(account_t *acc) |
---|
[96863f6] | 381 | { |
---|
| 382 | set_t *s; |
---|
[6b13103] | 383 | gboolean icq = g_ascii_isdigit(acc->user[0]); |
---|
[5ebff60] | 384 | |
---|
[6b96de6] | 385 | if (icq) { |
---|
[545d7c0] | 386 | set_add(&acc->set, "ignore_auth_requests", "false", set_eval_bool, acc); |
---|
[3dc6d86] | 387 | set_add(&acc->set, "old_icq_auth", "false", set_eval_bool, acc); |
---|
[545d7c0] | 388 | } |
---|
[5ebff60] | 389 | |
---|
[6b96de6] | 390 | s = set_add(&acc->set, "server", |
---|
| 391 | icq ? AIM_DEFAULT_LOGIN_SERVER_ICQ |
---|
[5ebff60] | 392 | : AIM_DEFAULT_LOGIN_SERVER_AIM, set_eval_account, acc); |
---|
[bb5ce568] | 393 | s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY; |
---|
[5ebff60] | 394 | |
---|
[6b96de6] | 395 | if (icq) { |
---|
[545d7c0] | 396 | s = set_add(&acc->set, "web_aware", "false", set_eval_bool, acc); |
---|
[d3a672c] | 397 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 398 | } |
---|
[5ebff60] | 399 | |
---|
[17f9522] | 400 | acc->flags |= ACC_FLAG_AWAY_MESSAGE; |
---|
[96863f6] | 401 | } |
---|
| 402 | |
---|
[5ebff60] | 403 | static void oscar_login(account_t *acc) |
---|
| 404 | { |
---|
[b7d3cc34] | 405 | aim_session_t *sess; |
---|
| 406 | aim_conn_t *conn; |
---|
[84b045d] | 407 | struct im_connection *ic = imcb_new(acc); |
---|
[0da65d5] | 408 | struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); |
---|
[b7d3cc34] | 409 | |
---|
[5ebff60] | 410 | if (g_ascii_isdigit(acc->user[0])) { |
---|
[181e47a] | 411 | odata->icq = TRUE; |
---|
[5ebff60] | 412 | } else { |
---|
[6bbb939] | 413 | ic->flags |= OPT_DOES_HTML; |
---|
[5ebff60] | 414 | } |
---|
[b7d3cc34] | 415 | |
---|
| 416 | sess = g_new0(aim_session_t, 1); |
---|
| 417 | |
---|
| 418 | aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); |
---|
| 419 | |
---|
| 420 | /* we need an immediate queue because we don't use a while-loop to |
---|
| 421 | * see if things need to be sent. */ |
---|
| 422 | aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
---|
| 423 | odata->sess = sess; |
---|
[0da65d5] | 424 | sess->aux_data = ic; |
---|
[b7d3cc34] | 425 | |
---|
| 426 | conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
---|
| 427 | if (conn == NULL) { |
---|
[84b045d] | 428 | imcb_error(ic, _("Unable to login to AIM")); |
---|
[c2fb3809] | 429 | imc_logout(ic, TRUE); |
---|
[b7d3cc34] | 430 | return; |
---|
| 431 | } |
---|
[5ebff60] | 432 | |
---|
[84b045d] | 433 | imcb_log(ic, _("Signon: %s"), ic->acc->user); |
---|
[b7d3cc34] | 434 | |
---|
| 435 | aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
---|
| 436 | aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
---|
| 437 | |
---|
| 438 | conn->status |= AIM_CONN_STATUS_INPROGRESS; |
---|
[30ce1ce] | 439 | conn->fd = proxy_connect(set_getstr(&acc->set, "server"), |
---|
| 440 | AIM_LOGIN_PORT, oscar_login_connect, ic); |
---|
[b7d3cc34] | 441 | if (conn->fd < 0) { |
---|
[84b045d] | 442 | imcb_error(ic, _("Couldn't connect to host")); |
---|
[c2fb3809] | 443 | imc_logout(ic, TRUE); |
---|
[b7d3cc34] | 444 | return; |
---|
| 445 | } |
---|
[c2fb3809] | 446 | aim_request_login(sess, conn, ic->acc->user); |
---|
[b7d3cc34] | 447 | } |
---|
| 448 | |
---|
[5ebff60] | 449 | static void oscar_logout(struct im_connection *ic) |
---|
| 450 | { |
---|
| 451 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
| 452 | |
---|
[b7d3cc34] | 453 | while (odata->oscar_chats) { |
---|
| 454 | struct chat_connection *n = odata->oscar_chats->data; |
---|
[5ebff60] | 455 | if (n->inpa > 0) { |
---|
[ba9edaa] | 456 | b_event_remove(n->inpa); |
---|
[5ebff60] | 457 | } |
---|
[b7d3cc34] | 458 | g_free(n->name); |
---|
| 459 | g_free(n->show); |
---|
| 460 | odata->oscar_chats = g_slist_remove(odata->oscar_chats, n); |
---|
| 461 | g_free(n); |
---|
| 462 | } |
---|
| 463 | while (odata->create_rooms) { |
---|
| 464 | struct create_room *cr = odata->create_rooms->data; |
---|
| 465 | g_free(cr->name); |
---|
| 466 | odata->create_rooms = g_slist_remove(odata->create_rooms, cr); |
---|
| 467 | g_free(cr); |
---|
| 468 | } |
---|
[5ebff60] | 469 | if (odata->ips) { |
---|
[e64de00] | 470 | g_hash_table_destroy(odata->ips); |
---|
[5ebff60] | 471 | } |
---|
| 472 | if (odata->email) { |
---|
[b7d3cc34] | 473 | g_free(odata->email); |
---|
[5ebff60] | 474 | } |
---|
| 475 | if (odata->newp) { |
---|
[b7d3cc34] | 476 | g_free(odata->newp); |
---|
[5ebff60] | 477 | } |
---|
| 478 | if (odata->oldp) { |
---|
[b7d3cc34] | 479 | g_free(odata->oldp); |
---|
[5ebff60] | 480 | } |
---|
| 481 | if (ic->inpa > 0) { |
---|
[0da65d5] | 482 | b_event_remove(ic->inpa); |
---|
[5ebff60] | 483 | } |
---|
| 484 | if (odata->cnpa > 0) { |
---|
[ba9edaa] | 485 | b_event_remove(odata->cnpa); |
---|
[5ebff60] | 486 | } |
---|
| 487 | if (odata->paspa > 0) { |
---|
[ba9edaa] | 488 | b_event_remove(odata->paspa); |
---|
[5ebff60] | 489 | } |
---|
[b7d3cc34] | 490 | aim_session_kill(odata->sess); |
---|
| 491 | g_free(odata->sess); |
---|
| 492 | odata->sess = NULL; |
---|
[0da65d5] | 493 | g_free(ic->proto_data); |
---|
| 494 | ic->proto_data = NULL; |
---|
[b7d3cc34] | 495 | } |
---|
| 496 | |
---|
[5ebff60] | 497 | static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) |
---|
| 498 | { |
---|
[0da65d5] | 499 | struct im_connection *ic = data; |
---|
[b7d3cc34] | 500 | struct oscar_data *odata; |
---|
| 501 | aim_session_t *sess; |
---|
| 502 | aim_conn_t *bosconn; |
---|
| 503 | |
---|
[0da65d5] | 504 | if (!g_slist_find(get_connections(), ic)) { |
---|
[b7d3cc34] | 505 | closesocket(source); |
---|
[ba9edaa] | 506 | return FALSE; |
---|
[b7d3cc34] | 507 | } |
---|
| 508 | |
---|
[0da65d5] | 509 | odata = ic->proto_data; |
---|
[b7d3cc34] | 510 | sess = odata->sess; |
---|
| 511 | bosconn = odata->conn; |
---|
| 512 | |
---|
| 513 | if (source < 0) { |
---|
[84b045d] | 514 | imcb_error(ic, _("Could Not Connect")); |
---|
[c2fb3809] | 515 | imc_logout(ic, TRUE); |
---|
[ba9edaa] | 516 | return FALSE; |
---|
[b7d3cc34] | 517 | } |
---|
| 518 | |
---|
| 519 | aim_conn_completeconnect(sess, bosconn); |
---|
[e046390] | 520 | ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ, |
---|
[5ebff60] | 521 | oscar_callback, bosconn); |
---|
[84b045d] | 522 | imcb_log(ic, _("Connection established, cookie sent")); |
---|
[5ebff60] | 523 | |
---|
[ba9edaa] | 524 | return FALSE; |
---|
[b7d3cc34] | 525 | } |
---|
| 526 | |
---|
[5ebff60] | 527 | static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 528 | { |
---|
[b7d3cc34] | 529 | va_list ap; |
---|
| 530 | struct aim_authresp_info *info; |
---|
| 531 | int i; char *host; int port; |
---|
| 532 | aim_conn_t *bosconn; |
---|
| 533 | |
---|
[0da65d5] | 534 | struct im_connection *ic = sess->aux_data; |
---|
[5ebff60] | 535 | struct oscar_data *od = ic->proto_data; |
---|
| 536 | |
---|
[0a3c243] | 537 | port = AIM_LOGIN_PORT; |
---|
[b7d3cc34] | 538 | |
---|
| 539 | va_start(ap, fr); |
---|
| 540 | info = va_arg(ap, struct aim_authresp_info *); |
---|
| 541 | va_end(ap); |
---|
| 542 | |
---|
| 543 | if (info->errorcode || !info->bosip || !info->cookie) { |
---|
| 544 | switch (info->errorcode) { |
---|
| 545 | case 0x05: |
---|
| 546 | /* Incorrect nick/password */ |
---|
[84b045d] | 547 | imcb_error(ic, _("Incorrect nickname or password.")); |
---|
[df61c35a] | 548 | { |
---|
| 549 | int max = od->icq ? 8 : 16; |
---|
[5ebff60] | 550 | if (strlen(ic->acc->pass) > max) { |
---|
[df61c35a] | 551 | imcb_log(ic, "Note that the maximum password " |
---|
| 552 | "length supported by this protocol is " |
---|
| 553 | "%d characters, try logging in using " |
---|
| 554 | "a shorter password.", max); |
---|
[5ebff60] | 555 | } |
---|
[df61c35a] | 556 | } |
---|
[b7d3cc34] | 557 | // plugin_event(event_error, (void *)980, 0, 0, 0); |
---|
| 558 | break; |
---|
| 559 | case 0x11: |
---|
| 560 | /* Suspended account */ |
---|
[84b045d] | 561 | imcb_error(ic, _("Your account is currently suspended.")); |
---|
[b7d3cc34] | 562 | break; |
---|
| 563 | case 0x18: |
---|
| 564 | /* connecting too frequently */ |
---|
[5469952] | 565 | od->no_reconnect = TRUE; |
---|
[5ebff60] | 566 | imcb_error(ic, |
---|
| 567 | _( |
---|
| 568 | "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.")); |
---|
[b7d3cc34] | 569 | break; |
---|
| 570 | case 0x1c: |
---|
| 571 | /* client too old */ |
---|
[84b045d] | 572 | imcb_error(ic, _("The client version you are using is too old. Please upgrade at " WEBSITE)); |
---|
[b7d3cc34] | 573 | break; |
---|
| 574 | default: |
---|
[84b045d] | 575 | imcb_error(ic, _("Authentication Failed")); |
---|
[b7d3cc34] | 576 | break; |
---|
| 577 | } |
---|
| 578 | od->killme = TRUE; |
---|
| 579 | return 1; |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | |
---|
| 583 | aim_conn_kill(sess, &fr->conn); |
---|
| 584 | |
---|
| 585 | bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); |
---|
| 586 | if (bosconn == NULL) { |
---|
[84b045d] | 587 | imcb_error(ic, _("Internal Error")); |
---|
[b7d3cc34] | 588 | od->killme = TRUE; |
---|
| 589 | return 0; |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
---|
| 593 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_RIGHTS, gaim_bosrights, 0); |
---|
| 594 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); |
---|
| 595 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); |
---|
| 596 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
---|
| 597 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
---|
| 598 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); |
---|
| 599 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); |
---|
| 600 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); |
---|
| 601 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); |
---|
| 602 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); |
---|
| 603 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
---|
| 604 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); |
---|
| 605 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); |
---|
| 606 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_PARAMINFO, gaim_icbm_param_info, 0); |
---|
| 607 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_ERROR, gaim_parse_genericerr, 0); |
---|
| 608 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0); |
---|
| 609 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0); |
---|
| 610 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0); |
---|
| 611 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
---|
| 612 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); |
---|
| 613 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
---|
| 614 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
---|
| 615 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); |
---|
| 616 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
---|
| 617 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parseaiminfo, 0); |
---|
[3e1de87] | 618 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parsemtn, 0); |
---|
[5469952] | 619 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_parse_logout, 0); |
---|
[b7d3cc34] | 620 | |
---|
[5ebff60] | 621 | ((struct oscar_data *) ic->proto_data)->conn = bosconn; |
---|
| 622 | for (i = 0; i < (int) strlen(info->bosip); i++) { |
---|
[b7d3cc34] | 623 | if (info->bosip[i] == ':') { |
---|
[5ebff60] | 624 | port = atoi(&(info->bosip[i + 1])); |
---|
[b7d3cc34] | 625 | break; |
---|
| 626 | } |
---|
| 627 | } |
---|
| 628 | host = g_strndup(info->bosip, i); |
---|
| 629 | bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
---|
[0da65d5] | 630 | bosconn->fd = proxy_connect(host, port, oscar_bos_connect, ic); |
---|
[b7d3cc34] | 631 | g_free(host); |
---|
| 632 | if (bosconn->fd < 0) { |
---|
[84b045d] | 633 | imcb_error(ic, _("Could Not Connect")); |
---|
[b7d3cc34] | 634 | od->killme = TRUE; |
---|
| 635 | return 0; |
---|
| 636 | } |
---|
| 637 | aim_sendcookie(sess, bosconn, info->cookie); |
---|
[0da65d5] | 638 | b_event_remove(ic->inpa); |
---|
[b7d3cc34] | 639 | |
---|
| 640 | return 1; |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | /* size of icbmui.ocm, the largest module in AIM 3.5 */ |
---|
| 644 | #define AIM_MAX_FILE_SIZE 98304 |
---|
| 645 | |
---|
[5ebff60] | 646 | static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 647 | { |
---|
[b7d3cc34] | 648 | #if 0 |
---|
[5ebff60] | 649 | struct client_info_s info = { "gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b }; |
---|
[b7d3cc34] | 650 | #else |
---|
| 651 | struct client_info_s info = AIM_CLIENTINFO_KNOWNGOOD; |
---|
| 652 | #endif |
---|
| 653 | char *key; |
---|
| 654 | va_list ap; |
---|
[0da65d5] | 655 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 656 | |
---|
| 657 | va_start(ap, fr); |
---|
| 658 | key = va_arg(ap, char *); |
---|
| 659 | va_end(ap); |
---|
| 660 | |
---|
[c2fb3809] | 661 | aim_send_login(sess, fr->conn, ic->acc->user, ic->acc->pass, &info, key); |
---|
[b7d3cc34] | 662 | |
---|
| 663 | return 1; |
---|
| 664 | } |
---|
| 665 | |
---|
[5ebff60] | 666 | static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 667 | { |
---|
[5469952] | 668 | struct im_connection *ic = sess->aux_data; |
---|
| 669 | struct oscar_data *odata = ic->proto_data; |
---|
| 670 | int code; |
---|
| 671 | va_list ap; |
---|
| 672 | |
---|
| 673 | va_start(ap, fr); |
---|
| 674 | code = va_arg(ap, int); |
---|
| 675 | va_end(ap); |
---|
[5ebff60] | 676 | |
---|
| 677 | imcb_error(ic, "Connection aborted by server: %s", code == 1 ? |
---|
| 678 | "someone else logged in with your account" : |
---|
| 679 | "unknown reason"); |
---|
| 680 | |
---|
[5469952] | 681 | /* Tell BitlBee to disable auto_reconnect if code == 1, since that |
---|
| 682 | means a concurrent login somewhere else. */ |
---|
| 683 | odata->no_reconnect = code == 1; |
---|
[5ebff60] | 684 | |
---|
[5469952] | 685 | /* DO NOT log out here! Just tell the callback to do it. */ |
---|
| 686 | odata->killme = TRUE; |
---|
| 687 | |
---|
| 688 | return 1; |
---|
| 689 | } |
---|
| 690 | |
---|
[5ebff60] | 691 | static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 692 | { |
---|
[0da65d5] | 693 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 694 | struct chat_connection *chatcon; |
---|
[e5abfd4] | 695 | struct groupchat *c = NULL; |
---|
[b7d3cc34] | 696 | static int id = 1; |
---|
| 697 | |
---|
| 698 | aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); |
---|
| 699 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
---|
| 700 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); |
---|
| 701 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); |
---|
| 702 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); |
---|
| 703 | |
---|
| 704 | aim_clientready(sess, fr->conn); |
---|
| 705 | |
---|
[0da65d5] | 706 | chatcon = find_oscar_chat_by_conn(ic, fr->conn); |
---|
[b7d3cc34] | 707 | chatcon->id = id; |
---|
[5ebff60] | 708 | |
---|
[e5abfd4] | 709 | c = bee_chat_by_title(ic->bee, ic, chatcon->show); |
---|
[5ebff60] | 710 | if (c && !c->data) { |
---|
[e5abfd4] | 711 | chatcon->cnv = c; |
---|
[5ebff60] | 712 | } else { |
---|
[75610c3] | 713 | chatcon->cnv = imcb_chat_new(ic, chatcon->show); |
---|
[5ebff60] | 714 | } |
---|
[fa29d093] | 715 | chatcon->cnv->data = chatcon; |
---|
[b7d3cc34] | 716 | |
---|
| 717 | return 1; |
---|
| 718 | } |
---|
| 719 | |
---|
[5ebff60] | 720 | static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 721 | { |
---|
[b7d3cc34] | 722 | |
---|
| 723 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_ERROR, gaim_parse_genericerr, 0); |
---|
| 724 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
---|
| 725 | |
---|
| 726 | aim_clientready(sess, fr->conn); |
---|
| 727 | |
---|
| 728 | aim_chatnav_reqrights(sess, fr->conn); |
---|
| 729 | |
---|
| 730 | return 1; |
---|
| 731 | } |
---|
| 732 | |
---|
[5ebff60] | 733 | static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) |
---|
| 734 | { |
---|
[0da65d5] | 735 | struct im_connection *ic = data; |
---|
[b7d3cc34] | 736 | struct oscar_data *odata; |
---|
| 737 | aim_session_t *sess; |
---|
| 738 | aim_conn_t *tstconn; |
---|
| 739 | |
---|
[0da65d5] | 740 | if (!g_slist_find(get_connections(), ic)) { |
---|
[b7d3cc34] | 741 | closesocket(source); |
---|
[ba9edaa] | 742 | return FALSE; |
---|
[b7d3cc34] | 743 | } |
---|
| 744 | |
---|
[0da65d5] | 745 | odata = ic->proto_data; |
---|
[b7d3cc34] | 746 | sess = odata->sess; |
---|
| 747 | tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
---|
| 748 | |
---|
| 749 | if (source < 0) { |
---|
| 750 | aim_conn_kill(sess, &tstconn); |
---|
[ba9edaa] | 751 | return FALSE; |
---|
[b7d3cc34] | 752 | } |
---|
| 753 | |
---|
| 754 | aim_conn_completeconnect(sess, tstconn); |
---|
[e046390] | 755 | odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ, |
---|
[5ebff60] | 756 | oscar_callback, tstconn); |
---|
| 757 | |
---|
[ba9edaa] | 758 | return FALSE; |
---|
[b7d3cc34] | 759 | } |
---|
| 760 | |
---|
[ba9edaa] | 761 | static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition cond) |
---|
[b7d3cc34] | 762 | { |
---|
[0da65d5] | 763 | struct im_connection *ic = data; |
---|
[b7d3cc34] | 764 | struct oscar_data *odata; |
---|
| 765 | aim_session_t *sess; |
---|
| 766 | aim_conn_t *tstconn; |
---|
| 767 | |
---|
[0da65d5] | 768 | if (!g_slist_find(get_connections(), ic)) { |
---|
[b7d3cc34] | 769 | closesocket(source); |
---|
[ba9edaa] | 770 | return FALSE; |
---|
[b7d3cc34] | 771 | } |
---|
| 772 | |
---|
[0da65d5] | 773 | odata = ic->proto_data; |
---|
[b7d3cc34] | 774 | sess = odata->sess; |
---|
| 775 | tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
---|
| 776 | |
---|
| 777 | if (source < 0) { |
---|
| 778 | aim_conn_kill(sess, &tstconn); |
---|
[ba9edaa] | 779 | return FALSE; |
---|
[b7d3cc34] | 780 | } |
---|
| 781 | |
---|
| 782 | aim_conn_completeconnect(sess, tstconn); |
---|
[e046390] | 783 | odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ, |
---|
[5ebff60] | 784 | oscar_callback, tstconn); |
---|
| 785 | |
---|
[ba9edaa] | 786 | return FALSE; |
---|
[b7d3cc34] | 787 | } |
---|
| 788 | |
---|
[ba9edaa] | 789 | static gboolean oscar_chat_connect(gpointer data, gint source, b_input_condition cond) |
---|
[b7d3cc34] | 790 | { |
---|
| 791 | struct chat_connection *ccon = data; |
---|
[0da65d5] | 792 | struct im_connection *ic = ccon->ic; |
---|
[b7d3cc34] | 793 | struct oscar_data *odata; |
---|
| 794 | aim_session_t *sess; |
---|
| 795 | aim_conn_t *tstconn; |
---|
| 796 | |
---|
[0da65d5] | 797 | if (!g_slist_find(get_connections(), ic)) { |
---|
[b7d3cc34] | 798 | closesocket(source); |
---|
| 799 | g_free(ccon->show); |
---|
| 800 | g_free(ccon->name); |
---|
| 801 | g_free(ccon); |
---|
[ba9edaa] | 802 | return FALSE; |
---|
[b7d3cc34] | 803 | } |
---|
| 804 | |
---|
[0da65d5] | 805 | odata = ic->proto_data; |
---|
[b7d3cc34] | 806 | sess = odata->sess; |
---|
| 807 | tstconn = ccon->conn; |
---|
| 808 | |
---|
| 809 | if (source < 0) { |
---|
| 810 | aim_conn_kill(sess, &tstconn); |
---|
| 811 | g_free(ccon->show); |
---|
| 812 | g_free(ccon->name); |
---|
| 813 | g_free(ccon); |
---|
[ba9edaa] | 814 | return FALSE; |
---|
[b7d3cc34] | 815 | } |
---|
| 816 | |
---|
| 817 | aim_conn_completeconnect(sess, ccon->conn); |
---|
[ba9edaa] | 818 | ccon->inpa = b_input_add(tstconn->fd, |
---|
[5ebff60] | 819 | B_EV_IO_READ, |
---|
| 820 | oscar_callback, tstconn); |
---|
[b7d3cc34] | 821 | odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); |
---|
[5ebff60] | 822 | |
---|
[ba9edaa] | 823 | return FALSE; |
---|
[b7d3cc34] | 824 | } |
---|
| 825 | |
---|
| 826 | /* Hrmph. I don't know how to make this look better. --mid */ |
---|
[5ebff60] | 827 | static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 828 | { |
---|
[b7d3cc34] | 829 | va_list ap; |
---|
| 830 | struct aim_redirect_data *redir; |
---|
[0da65d5] | 831 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 832 | aim_conn_t *tstconn; |
---|
| 833 | int i; |
---|
| 834 | char *host; |
---|
| 835 | int port; |
---|
| 836 | |
---|
| 837 | va_start(ap, fr); |
---|
| 838 | redir = va_arg(ap, struct aim_redirect_data *); |
---|
| 839 | va_end(ap); |
---|
| 840 | |
---|
[0a3c243] | 841 | port = AIM_LOGIN_PORT; |
---|
[5ebff60] | 842 | for (i = 0; i < (int) strlen(redir->ip); i++) { |
---|
[b7d3cc34] | 843 | if (redir->ip[i] == ':') { |
---|
[5ebff60] | 844 | port = atoi(&(redir->ip[i + 1])); |
---|
[b7d3cc34] | 845 | break; |
---|
| 846 | } |
---|
| 847 | } |
---|
| 848 | host = g_strndup(redir->ip, i); |
---|
| 849 | |
---|
[5ebff60] | 850 | switch (redir->group) { |
---|
[b7d3cc34] | 851 | case 0x7: /* Authorizer */ |
---|
| 852 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
---|
| 853 | if (tstconn == NULL) { |
---|
| 854 | g_free(host); |
---|
| 855 | return 1; |
---|
| 856 | } |
---|
[5ebff60] | 857 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, |
---|
| 858 | 0); |
---|
[b7d3cc34] | 859 | // aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
---|
| 860 | // aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); |
---|
| 861 | // aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); |
---|
| 862 | |
---|
| 863 | tstconn->status |= AIM_CONN_STATUS_INPROGRESS; |
---|
[0da65d5] | 864 | tstconn->fd = proxy_connect(host, port, oscar_auth_connect, ic); |
---|
[b7d3cc34] | 865 | if (tstconn->fd < 0) { |
---|
| 866 | aim_conn_kill(sess, &tstconn); |
---|
| 867 | g_free(host); |
---|
| 868 | return 1; |
---|
| 869 | } |
---|
| 870 | aim_sendcookie(sess, tstconn, redir->cookie); |
---|
| 871 | break; |
---|
| 872 | case 0xd: /* ChatNav */ |
---|
| 873 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); |
---|
| 874 | if (tstconn == NULL) { |
---|
| 875 | g_free(host); |
---|
| 876 | return 1; |
---|
| 877 | } |
---|
[5ebff60] | 878 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, |
---|
| 879 | conninitdone_chatnav, 0); |
---|
[b7d3cc34] | 880 | |
---|
| 881 | tstconn->status |= AIM_CONN_STATUS_INPROGRESS; |
---|
[0da65d5] | 882 | tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, ic); |
---|
[b7d3cc34] | 883 | if (tstconn->fd < 0) { |
---|
| 884 | aim_conn_kill(sess, &tstconn); |
---|
| 885 | g_free(host); |
---|
| 886 | return 1; |
---|
| 887 | } |
---|
| 888 | aim_sendcookie(sess, tstconn, redir->cookie); |
---|
| 889 | break; |
---|
| 890 | case 0xe: /* Chat */ |
---|
[5ebff60] | 891 | { |
---|
[b7d3cc34] | 892 | struct chat_connection *ccon; |
---|
| 893 | |
---|
| 894 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
---|
| 895 | if (tstconn == NULL) { |
---|
| 896 | g_free(host); |
---|
| 897 | return 1; |
---|
| 898 | } |
---|
| 899 | |
---|
[5ebff60] | 900 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, |
---|
| 901 | 0); |
---|
[b7d3cc34] | 902 | |
---|
| 903 | ccon = g_new0(struct chat_connection, 1); |
---|
| 904 | ccon->conn = tstconn; |
---|
[0da65d5] | 905 | ccon->ic = ic; |
---|
[b7d3cc34] | 906 | ccon->fd = -1; |
---|
| 907 | ccon->name = g_strdup(redir->chat.room); |
---|
| 908 | ccon->exchange = redir->chat.exchange; |
---|
| 909 | ccon->instance = redir->chat.instance; |
---|
| 910 | ccon->show = extract_name(redir->chat.room); |
---|
[5ebff60] | 911 | |
---|
[b7d3cc34] | 912 | ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
---|
| 913 | ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); |
---|
| 914 | if (ccon->conn->fd < 0) { |
---|
| 915 | aim_conn_kill(sess, &tstconn); |
---|
| 916 | g_free(host); |
---|
| 917 | g_free(ccon->show); |
---|
| 918 | g_free(ccon->name); |
---|
| 919 | g_free(ccon); |
---|
| 920 | return 1; |
---|
| 921 | } |
---|
| 922 | aim_sendcookie(sess, tstconn, redir->cookie); |
---|
[5ebff60] | 923 | } |
---|
| 924 | break; |
---|
[b7d3cc34] | 925 | default: /* huh? */ |
---|
| 926 | break; |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | g_free(host); |
---|
| 930 | return 1; |
---|
| 931 | } |
---|
| 932 | |
---|
[5ebff60] | 933 | static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 934 | { |
---|
[0da65d5] | 935 | struct im_connection *ic = sess->aux_data; |
---|
| 936 | struct oscar_data *od = ic->proto_data; |
---|
[b7d3cc34] | 937 | aim_userinfo_t *info; |
---|
| 938 | time_t time_idle = 0, signon = 0; |
---|
[6bbb939] | 939 | int flags = OPT_LOGGED_IN; |
---|
| 940 | char *tmp, *state_string = NULL; |
---|
[b7d3cc34] | 941 | |
---|
| 942 | va_list ap; |
---|
[5ebff60] | 943 | |
---|
[b7d3cc34] | 944 | va_start(ap, fr); |
---|
| 945 | info = va_arg(ap, aim_userinfo_t *); |
---|
| 946 | va_end(ap); |
---|
| 947 | |
---|
| 948 | if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) { |
---|
[5ebff60] | 949 | if (info->flags & AIM_FLAG_AWAY) { |
---|
[6bbb939] | 950 | flags |= OPT_AWAY; |
---|
[5ebff60] | 951 | } |
---|
[b7d3cc34] | 952 | } |
---|
[5ebff60] | 953 | |
---|
[0ebf919] | 954 | /* Maybe this should be done just for AIM contacts, not sure. */ |
---|
[5ebff60] | 955 | if (info->flags & AIM_FLAG_WIRELESS) { |
---|
[0ebf919] | 956 | flags |= OPT_MOBILE; |
---|
[5ebff60] | 957 | } |
---|
| 958 | |
---|
[b7d3cc34] | 959 | if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
---|
| 960 | if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
---|
[5ebff60] | 961 | (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { |
---|
[6bbb939] | 962 | flags |= OPT_AWAY; |
---|
[b7d3cc34] | 963 | } |
---|
[5ebff60] | 964 | |
---|
| 965 | if (info->icqinfo.status & AIM_ICQ_STATE_DND) { |
---|
[6bbb939] | 966 | state_string = "Do Not Disturb"; |
---|
[5ebff60] | 967 | } else if (info->icqinfo.status & AIM_ICQ_STATE_OUT) { |
---|
[6bbb939] | 968 | state_string = "Not Available"; |
---|
[5ebff60] | 969 | } else if (info->icqinfo.status & AIM_ICQ_STATE_BUSY) { |
---|
[6bbb939] | 970 | state_string = "Occupied"; |
---|
[5ebff60] | 971 | } else if (info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE) { |
---|
[6bbb939] | 972 | state_string = "Invisible"; |
---|
[5ebff60] | 973 | } |
---|
[b7d3cc34] | 974 | } |
---|
| 975 | |
---|
| 976 | if (info->present & AIM_USERINFO_PRESENT_IDLE) { |
---|
| 977 | time(&time_idle); |
---|
[5ebff60] | 978 | time_idle -= info->idletime * 60; |
---|
[b7d3cc34] | 979 | } |
---|
| 980 | |
---|
[5ebff60] | 981 | if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) { |
---|
[b7d3cc34] | 982 | signon = time(NULL) - info->sessionlen; |
---|
[5ebff60] | 983 | } |
---|
[b7d3cc34] | 984 | |
---|
[e64de00] | 985 | if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) { |
---|
| 986 | uint32_t *uin = g_new0(uint32_t, 1); |
---|
[5ebff60] | 987 | |
---|
| 988 | if (od->ips == NULL) { |
---|
[e64de00] | 989 | od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL); |
---|
[5ebff60] | 990 | } |
---|
| 991 | |
---|
| 992 | if (sscanf(info->sn, "%d", uin) == 1) { |
---|
[e64de00] | 993 | g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr); |
---|
[5ebff60] | 994 | } |
---|
[e64de00] | 995 | } |
---|
| 996 | |
---|
[424e663] | 997 | tmp = normalize(info->sn); |
---|
| 998 | imcb_buddy_status(ic, tmp, flags, state_string, NULL); |
---|
[56699f0] | 999 | imcb_buddy_times(ic, tmp, signon, time_idle); |
---|
[424e663] | 1000 | |
---|
[b7d3cc34] | 1001 | |
---|
| 1002 | return 1; |
---|
| 1003 | } |
---|
| 1004 | |
---|
[5ebff60] | 1005 | static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1006 | { |
---|
[b7d3cc34] | 1007 | aim_userinfo_t *info; |
---|
| 1008 | va_list ap; |
---|
[0da65d5] | 1009 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 1010 | |
---|
| 1011 | va_start(ap, fr); |
---|
| 1012 | info = va_arg(ap, aim_userinfo_t *); |
---|
| 1013 | va_end(ap); |
---|
| 1014 | |
---|
[5ebff60] | 1015 | imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL); |
---|
[b7d3cc34] | 1016 | |
---|
| 1017 | return 1; |
---|
| 1018 | } |
---|
| 1019 | |
---|
[5ebff60] | 1020 | static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, |
---|
| 1021 | struct aim_incomingim_ch1_args *args) |
---|
| 1022 | { |
---|
[b7d3cc34] | 1023 | char *tmp = g_malloc(BUF_LONG + 1); |
---|
[0da65d5] | 1024 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 1025 | int flags = 0; |
---|
[5ebff60] | 1026 | |
---|
| 1027 | if (args->icbmflags & AIM_IMFLAGS_AWAY) { |
---|
[6bbb939] | 1028 | flags |= OPT_AWAY; |
---|
[5ebff60] | 1029 | } |
---|
| 1030 | |
---|
[b7d3cc34] | 1031 | if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) { |
---|
| 1032 | char *src; |
---|
[5ebff60] | 1033 | |
---|
| 1034 | if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
---|
[af496d8] | 1035 | src = "UCS-2BE"; |
---|
[5ebff60] | 1036 | } else { |
---|
[b7d3cc34] | 1037 | src = "ISO8859-1"; |
---|
[5ebff60] | 1038 | } |
---|
| 1039 | |
---|
[b7d3cc34] | 1040 | /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */ |
---|
| 1041 | if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) { |
---|
| 1042 | // Successfully converted! |
---|
| 1043 | } else if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
---|
| 1044 | int i; |
---|
[5ebff60] | 1045 | |
---|
[b7d3cc34] | 1046 | for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) { |
---|
| 1047 | unsigned short uni; |
---|
[5ebff60] | 1048 | |
---|
| 1049 | uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i + 1] & 0xff); |
---|
| 1050 | |
---|
[b7d3cc34] | 1051 | if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ |
---|
[5ebff60] | 1052 | g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "%c", uni); |
---|
[b7d3cc34] | 1053 | } else { /* something else, do UNICODE entity */ |
---|
[5ebff60] | 1054 | g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "&#%04x;", uni); |
---|
[b7d3cc34] | 1055 | } |
---|
| 1056 | } |
---|
| 1057 | } else { |
---|
| 1058 | g_snprintf(tmp, BUF_LONG, "%s", args->msg); |
---|
| 1059 | } |
---|
[be68d99] | 1060 | } else if (args->mpmsg.numparts == 0) { |
---|
[b7d3cc34] | 1061 | g_snprintf(tmp, BUF_LONG, "%s", args->msg); |
---|
[be68d99] | 1062 | } else { |
---|
[f774e01] | 1063 | aim_mpmsg_section_t *part; |
---|
[5ebff60] | 1064 | |
---|
[be68d99] | 1065 | *tmp = 0; |
---|
[f774e01] | 1066 | for (part = args->mpmsg.parts; part; part = part->next) { |
---|
| 1067 | if (part->data) { |
---|
[5ebff60] | 1068 | g_strlcat(tmp, (char *) part->data, BUF_LONG); |
---|
[f774e01] | 1069 | g_strlcat(tmp, "\n", BUF_LONG); |
---|
| 1070 | } |
---|
[be68d99] | 1071 | } |
---|
| 1072 | } |
---|
[5ebff60] | 1073 | |
---|
[b7d3cc34] | 1074 | strip_linefeed(tmp); |
---|
[424e663] | 1075 | imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0); |
---|
[b7d3cc34] | 1076 | g_free(tmp); |
---|
[5ebff60] | 1077 | |
---|
[b7d3cc34] | 1078 | return 1; |
---|
| 1079 | } |
---|
| 1080 | |
---|
[9143aeb] | 1081 | void oscar_accept_chat(void *data); |
---|
| 1082 | void oscar_reject_chat(void *data); |
---|
[5ebff60] | 1083 | |
---|
| 1084 | static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, |
---|
| 1085 | struct aim_incomingim_ch2_args *args) |
---|
| 1086 | { |
---|
[0da65d5] | 1087 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 1088 | |
---|
[5ebff60] | 1089 | if (args->status != AIM_RENDEZVOUS_PROPOSE) { |
---|
[b7d3cc34] | 1090 | return 1; |
---|
[5ebff60] | 1091 | } |
---|
[b8ef1b1] | 1092 | |
---|
[b7d3cc34] | 1093 | if (args->reqclass & AIM_CAPS_CHAT) { |
---|
| 1094 | char *name = extract_name(args->info.chat.roominfo.name); |
---|
| 1095 | int *exch = g_new0(int, 1); |
---|
| 1096 | GList *m = NULL; |
---|
[11e090b] | 1097 | char txt[1024]; |
---|
| 1098 | struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); |
---|
| 1099 | |
---|
[b7d3cc34] | 1100 | m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); |
---|
| 1101 | *exch = args->info.chat.roominfo.exchange; |
---|
| 1102 | m = g_list_append(m, exch); |
---|
[b8ef1b1] | 1103 | |
---|
[d4bc2d9] | 1104 | g_snprintf(txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg); |
---|
[b8ef1b1] | 1105 | |
---|
[0da65d5] | 1106 | inv->ic = ic; |
---|
[b8ef1b1] | 1107 | inv->exchange = *exch; |
---|
| 1108 | inv->name = g_strdup(name); |
---|
[5ebff60] | 1109 | |
---|
[d4bc2d9] | 1110 | imcb_ask(ic, txt, inv, oscar_accept_chat, oscar_reject_chat); |
---|
[5ebff60] | 1111 | |
---|
| 1112 | if (name) { |
---|
[b7d3cc34] | 1113 | g_free(name); |
---|
[5ebff60] | 1114 | } |
---|
[d4bc2d9] | 1115 | } else if (args->reqclass & AIM_CAPS_ICQRTF) { |
---|
| 1116 | // TODO: constify |
---|
[5ebff60] | 1117 | char text[strlen(args->info.rtfmsg.rtfmsg) + 1]; |
---|
[2334048] | 1118 | strncpy(text, args->info.rtfmsg.rtfmsg, sizeof(text)); |
---|
[d4bc2d9] | 1119 | imcb_buddy_msg(ic, normalize(userinfo->sn), text, 0, 0); |
---|
[b7d3cc34] | 1120 | } |
---|
[b8ef1b1] | 1121 | |
---|
[b7d3cc34] | 1122 | return 1; |
---|
| 1123 | } |
---|
| 1124 | |
---|
[5ebff60] | 1125 | static void gaim_icq_authgrant(void *data_) |
---|
| 1126 | { |
---|
[9143aeb] | 1127 | struct icq_auth *data = data_; |
---|
[d18db32f] | 1128 | char *uin; |
---|
[5ebff60] | 1129 | struct oscar_data *od = (struct oscar_data *) data->ic->proto_data; |
---|
| 1130 | |
---|
[b7d3cc34] | 1131 | uin = g_strdup_printf("%u", data->uin); |
---|
| 1132 | aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); |
---|
[d18db32f] | 1133 | // char *message = 0; |
---|
[b7d3cc34] | 1134 | // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); |
---|
[81e04e1] | 1135 | imcb_ask_add(data->ic, uin, NULL); |
---|
[5ebff60] | 1136 | |
---|
[b7d3cc34] | 1137 | g_free(uin); |
---|
| 1138 | g_free(data); |
---|
| 1139 | } |
---|
| 1140 | |
---|
[5ebff60] | 1141 | static void gaim_icq_authdeny(void *data_) |
---|
| 1142 | { |
---|
[9143aeb] | 1143 | struct icq_auth *data = data_; |
---|
[b7d3cc34] | 1144 | char *uin, *message; |
---|
[5ebff60] | 1145 | struct oscar_data *od = (struct oscar_data *) data->ic->proto_data; |
---|
| 1146 | |
---|
[b7d3cc34] | 1147 | uin = g_strdup_printf("%u", data->uin); |
---|
| 1148 | message = g_strdup_printf("No reason given."); |
---|
| 1149 | aim_ssi_auth_reply(od->sess, od->conn, uin, 0, ""); |
---|
| 1150 | // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHDENIED, message); |
---|
| 1151 | g_free(message); |
---|
[5ebff60] | 1152 | |
---|
[b7d3cc34] | 1153 | g_free(uin); |
---|
| 1154 | g_free(data); |
---|
| 1155 | } |
---|
| 1156 | |
---|
| 1157 | /* |
---|
| 1158 | * For when other people ask you for authorization |
---|
| 1159 | */ |
---|
[5ebff60] | 1160 | static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) |
---|
| 1161 | { |
---|
[545d7c0] | 1162 | struct icq_auth *data; |
---|
[b7d3cc34] | 1163 | char *reason = NULL; |
---|
| 1164 | char *dialog_msg; |
---|
[545d7c0] | 1165 | |
---|
[5ebff60] | 1166 | if (set_getbool(&ic->acc->set, "ignore_auth_requests")) { |
---|
[545d7c0] | 1167 | return; |
---|
[5ebff60] | 1168 | } |
---|
| 1169 | |
---|
[545d7c0] | 1170 | data = g_new(struct icq_auth, 1); |
---|
| 1171 | |
---|
[5ebff60] | 1172 | if (strlen(msg) > 6) { |
---|
[b7d3cc34] | 1173 | reason = msg + 6; |
---|
[5ebff60] | 1174 | } |
---|
| 1175 | |
---|
| 1176 | dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", |
---|
| 1177 | uin, reason ? reason : "No reason given."); |
---|
[0da65d5] | 1178 | data->ic = ic; |
---|
[b7d3cc34] | 1179 | data->uin = uin; |
---|
[84b045d] | 1180 | imcb_ask(ic, dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny); |
---|
[b7d3cc34] | 1181 | g_free(dialog_msg); |
---|
| 1182 | } |
---|
| 1183 | |
---|
[5ebff60] | 1184 | static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, |
---|
| 1185 | struct aim_incomingim_ch4_args *args) |
---|
| 1186 | { |
---|
[0da65d5] | 1187 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 1188 | |
---|
| 1189 | switch (args->type) { |
---|
[5ebff60] | 1190 | case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */ |
---|
| 1191 | char *uin, *message; |
---|
| 1192 | uin = g_strdup_printf("%u", args->uin); |
---|
| 1193 | message = g_strdup(args->msg); |
---|
| 1194 | strip_linefeed(message); |
---|
| 1195 | imcb_buddy_msg(ic, normalize(uin), message, 0, 0); |
---|
| 1196 | g_free(uin); |
---|
| 1197 | g_free(message); |
---|
| 1198 | } break; |
---|
| 1199 | |
---|
| 1200 | case 0x0004: { /* Someone sent you a URL */ |
---|
| 1201 | char *uin, *message; |
---|
| 1202 | char **m; |
---|
| 1203 | |
---|
| 1204 | uin = g_strdup_printf("%u", args->uin); |
---|
| 1205 | m = g_strsplit(args->msg, "\376", 2); |
---|
| 1206 | |
---|
| 1207 | if ((strlen(m[0]) != 0)) { |
---|
| 1208 | message = g_strjoinv(" -- ", m); |
---|
| 1209 | } else { |
---|
| 1210 | message = m[1]; |
---|
| 1211 | } |
---|
| 1212 | |
---|
| 1213 | strip_linefeed(message); |
---|
| 1214 | imcb_buddy_msg(ic, normalize(uin), message, 0, 0); |
---|
| 1215 | g_free(uin); |
---|
| 1216 | g_free(m); |
---|
| 1217 | g_free(message); |
---|
| 1218 | } break; |
---|
[b7d3cc34] | 1219 | |
---|
[5ebff60] | 1220 | case 0x0006: { /* Someone requested authorization */ |
---|
| 1221 | gaim_icq_authask(ic, args->uin, args->msg); |
---|
| 1222 | } break; |
---|
[b7d3cc34] | 1223 | |
---|
[5ebff60] | 1224 | case 0x0007: { /* Someone has denied you authorization */ |
---|
| 1225 | imcb_log(sess->aux_data, |
---|
| 1226 | "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin, |
---|
| 1227 | args->msg ? args->msg : _("No reason given.")); |
---|
| 1228 | } break; |
---|
[b7d3cc34] | 1229 | |
---|
[5ebff60] | 1230 | case 0x0008: { /* Someone has granted you authorization */ |
---|
| 1231 | imcb_log(sess->aux_data, |
---|
| 1232 | "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin, |
---|
| 1233 | args->msg ? args->msg : _("No reason given.")); |
---|
| 1234 | } break; |
---|
[b7d3cc34] | 1235 | |
---|
[5ebff60] | 1236 | case 0x0012: { |
---|
| 1237 | /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
---|
| 1238 | } break; |
---|
[b7d3cc34] | 1239 | |
---|
[5ebff60] | 1240 | default: {; } break; |
---|
[b7d3cc34] | 1241 | } |
---|
| 1242 | |
---|
| 1243 | return 1; |
---|
| 1244 | } |
---|
[9cb9868] | 1245 | |
---|
[5ebff60] | 1246 | static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1247 | { |
---|
[b7d3cc34] | 1248 | int channel, ret = 0; |
---|
| 1249 | aim_userinfo_t *userinfo; |
---|
| 1250 | va_list ap; |
---|
| 1251 | |
---|
| 1252 | va_start(ap, fr); |
---|
| 1253 | channel = va_arg(ap, int); |
---|
| 1254 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1255 | |
---|
| 1256 | switch (channel) { |
---|
[5ebff60] | 1257 | case 1: { /* standard message */ |
---|
| 1258 | struct aim_incomingim_ch1_args *args; |
---|
| 1259 | args = va_arg(ap, struct aim_incomingim_ch1_args *); |
---|
| 1260 | ret = incomingim_chan1(sess, fr->conn, userinfo, args); |
---|
| 1261 | } break; |
---|
[b7d3cc34] | 1262 | |
---|
[5ebff60] | 1263 | case 2: { /* rendevous */ |
---|
| 1264 | struct aim_incomingim_ch2_args *args; |
---|
| 1265 | args = va_arg(ap, struct aim_incomingim_ch2_args *); |
---|
| 1266 | ret = incomingim_chan2(sess, fr->conn, userinfo, args); |
---|
| 1267 | } break; |
---|
[b7d3cc34] | 1268 | |
---|
[5ebff60] | 1269 | case 4: { /* ICQ */ |
---|
| 1270 | struct aim_incomingim_ch4_args *args; |
---|
| 1271 | args = va_arg(ap, struct aim_incomingim_ch4_args *); |
---|
| 1272 | ret = incomingim_chan4(sess, fr->conn, userinfo, args); |
---|
| 1273 | } break; |
---|
[b7d3cc34] | 1274 | |
---|
[5ebff60] | 1275 | default: {; } break; |
---|
[b7d3cc34] | 1276 | } |
---|
| 1277 | |
---|
| 1278 | va_end(ap); |
---|
| 1279 | |
---|
| 1280 | return ret; |
---|
| 1281 | } |
---|
| 1282 | |
---|
[5ebff60] | 1283 | static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1284 | { |
---|
[b7d3cc34] | 1285 | va_list ap; |
---|
[d18db32f] | 1286 | guint16 nummissed, reason; |
---|
[b7d3cc34] | 1287 | aim_userinfo_t *userinfo; |
---|
| 1288 | |
---|
| 1289 | va_start(ap, fr); |
---|
[d18db32f] | 1290 | va_arg(ap, unsigned int); /* chan */ |
---|
[b7d3cc34] | 1291 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
[5ebff60] | 1292 | nummissed = (guint16) va_arg(ap, unsigned int); |
---|
| 1293 | reason = (guint16) va_arg(ap, unsigned int); |
---|
[b7d3cc34] | 1294 | va_end(ap); |
---|
| 1295 | |
---|
[5ebff60] | 1296 | switch (reason) { |
---|
| 1297 | case 0: |
---|
| 1298 | /* Invalid (0) */ |
---|
| 1299 | imcb_error(sess->aux_data, |
---|
| 1300 | nummissed == 1 ? |
---|
| 1301 | _("You missed %d message from %s because it was invalid.") : |
---|
| 1302 | _("You missed %d messages from %s because they were invalid."), |
---|
| 1303 | nummissed, |
---|
| 1304 | userinfo->sn); |
---|
| 1305 | break; |
---|
| 1306 | case 1: |
---|
| 1307 | /* Message too large */ |
---|
| 1308 | imcb_error(sess->aux_data, |
---|
| 1309 | nummissed == 1 ? |
---|
| 1310 | _("You missed %d message from %s because it was too large.") : |
---|
| 1311 | _("You missed %d messages from %s because they were too large."), |
---|
| 1312 | nummissed, |
---|
| 1313 | userinfo->sn); |
---|
| 1314 | break; |
---|
| 1315 | case 2: |
---|
| 1316 | /* Rate exceeded */ |
---|
| 1317 | imcb_error(sess->aux_data, |
---|
| 1318 | nummissed == 1 ? |
---|
| 1319 | _("You missed %d message from %s because the rate limit has been exceeded.") : |
---|
| 1320 | _("You missed %d messages from %s because the rate limit has been exceeded."), |
---|
| 1321 | nummissed, |
---|
| 1322 | userinfo->sn); |
---|
| 1323 | break; |
---|
| 1324 | case 3: |
---|
| 1325 | /* Evil Sender */ |
---|
| 1326 | imcb_error(sess->aux_data, |
---|
| 1327 | nummissed == 1 ? |
---|
| 1328 | _("You missed %d message from %s because it was too evil.") : |
---|
| 1329 | _("You missed %d messages from %s because they are too evil."), |
---|
| 1330 | nummissed, |
---|
| 1331 | userinfo->sn); |
---|
| 1332 | break; |
---|
| 1333 | case 4: |
---|
| 1334 | /* Evil Receiver */ |
---|
| 1335 | imcb_error(sess->aux_data, |
---|
| 1336 | nummissed == 1 ? |
---|
| 1337 | _("You missed %d message from %s because you are too evil.") : |
---|
| 1338 | _("You missed %d messages from %s because you are too evil."), |
---|
| 1339 | nummissed, |
---|
| 1340 | userinfo->sn); |
---|
| 1341 | break; |
---|
| 1342 | default: |
---|
| 1343 | imcb_error(sess->aux_data, |
---|
| 1344 | nummissed == 1 ? |
---|
| 1345 | _("You missed %d message from %s for unknown reasons.") : |
---|
| 1346 | _("You missed %d messages from %s for unknown reasons."), |
---|
| 1347 | nummissed, |
---|
| 1348 | userinfo->sn); |
---|
| 1349 | break; |
---|
[b7d3cc34] | 1350 | } |
---|
| 1351 | |
---|
| 1352 | return 1; |
---|
| 1353 | } |
---|
| 1354 | |
---|
[5ebff60] | 1355 | static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1356 | { |
---|
[b7d3cc34] | 1357 | va_list ap; |
---|
| 1358 | guint16 reason; |
---|
| 1359 | |
---|
| 1360 | va_start(ap, fr); |
---|
[5ebff60] | 1361 | reason = (guint16) va_arg(ap, unsigned int); |
---|
[b7d3cc34] | 1362 | va_end(ap); |
---|
| 1363 | |
---|
[84b045d] | 1364 | imcb_error(sess->aux_data, _("SNAC threw error: %s"), |
---|
[5ebff60] | 1365 | reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error"); |
---|
[b7d3cc34] | 1366 | |
---|
| 1367 | return 1; |
---|
| 1368 | } |
---|
| 1369 | |
---|
[5ebff60] | 1370 | static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1371 | { |
---|
[b7d3cc34] | 1372 | va_list ap; |
---|
| 1373 | char *destn; |
---|
| 1374 | guint16 reason; |
---|
| 1375 | |
---|
| 1376 | va_start(ap, fr); |
---|
[5ebff60] | 1377 | reason = (guint16) va_arg(ap, unsigned int); |
---|
[b7d3cc34] | 1378 | destn = va_arg(ap, char *); |
---|
| 1379 | va_end(ap); |
---|
| 1380 | |
---|
[84b045d] | 1381 | imcb_error(sess->aux_data, _("Your message to %s did not get sent: %s"), destn, |
---|
[5ebff60] | 1382 | (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); |
---|
[b7d3cc34] | 1383 | |
---|
| 1384 | return 1; |
---|
| 1385 | } |
---|
| 1386 | |
---|
[5ebff60] | 1387 | static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1388 | { |
---|
[b7d3cc34] | 1389 | va_list ap; |
---|
| 1390 | char *destn; |
---|
| 1391 | guint16 reason; |
---|
| 1392 | |
---|
| 1393 | va_start(ap, fr); |
---|
[5ebff60] | 1394 | reason = (guint16) va_arg(ap, unsigned int); |
---|
[b7d3cc34] | 1395 | destn = va_arg(ap, char *); |
---|
| 1396 | va_end(ap); |
---|
| 1397 | |
---|
[84b045d] | 1398 | imcb_error(sess->aux_data, _("User information for %s unavailable: %s"), destn, |
---|
[5ebff60] | 1399 | (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); |
---|
[b7d3cc34] | 1400 | |
---|
| 1401 | return 1; |
---|
| 1402 | } |
---|
| 1403 | |
---|
[5ebff60] | 1404 | static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1405 | { |
---|
[b7d3cc34] | 1406 | guint16 id; |
---|
| 1407 | va_list ap; |
---|
| 1408 | |
---|
| 1409 | va_start(ap, fr); |
---|
[5ebff60] | 1410 | id = (guint16) va_arg(ap, unsigned int); |
---|
[d18db32f] | 1411 | va_arg(ap, char *); /* msg */ |
---|
[b7d3cc34] | 1412 | va_end(ap); |
---|
| 1413 | |
---|
[5ebff60] | 1414 | if (id < 4) { |
---|
[84b045d] | 1415 | imcb_error(sess->aux_data, _("Your connection may be lost.")); |
---|
[5ebff60] | 1416 | } |
---|
[b7d3cc34] | 1417 | |
---|
| 1418 | return 1; |
---|
| 1419 | } |
---|
| 1420 | |
---|
[5ebff60] | 1421 | static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1422 | { |
---|
[b7d3cc34] | 1423 | va_list ap; |
---|
| 1424 | guint16 type; |
---|
[0da65d5] | 1425 | struct im_connection *ic = sess->aux_data; |
---|
[5ebff60] | 1426 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
[b7d3cc34] | 1427 | |
---|
| 1428 | va_start(ap, fr); |
---|
[5ebff60] | 1429 | type = (guint16) va_arg(ap, unsigned int); |
---|
| 1430 | |
---|
| 1431 | switch (type) { |
---|
| 1432 | case 0x0002: { |
---|
| 1433 | va_arg(ap, unsigned int); /* maxrooms */ |
---|
| 1434 | va_arg(ap, int); /* exchangecount */ |
---|
| 1435 | va_arg(ap, struct aim_chat_exchangeinfo *); /* exchanges */ |
---|
| 1436 | va_end(ap); |
---|
| 1437 | |
---|
| 1438 | while (odata->create_rooms) { |
---|
| 1439 | struct create_room *cr = odata->create_rooms->data; |
---|
| 1440 | aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
---|
| 1441 | g_free(cr->name); |
---|
| 1442 | odata->create_rooms = g_slist_remove(odata->create_rooms, cr); |
---|
| 1443 | g_free(cr); |
---|
| 1444 | } |
---|
| 1445 | } |
---|
| 1446 | break; |
---|
| 1447 | case 0x0008: { |
---|
| 1448 | char *ck; |
---|
| 1449 | guint16 instance, exchange; |
---|
| 1450 | |
---|
| 1451 | va_arg(ap, char *); /* fqcn */ |
---|
| 1452 | instance = (guint16) va_arg(ap, unsigned int); |
---|
| 1453 | exchange = (guint16) va_arg(ap, unsigned int); |
---|
| 1454 | va_arg(ap, unsigned int); /* flags */ |
---|
| 1455 | va_arg(ap, guint32); /* createtime */ |
---|
| 1456 | va_arg(ap, unsigned int); /* maxmsglen */ |
---|
| 1457 | va_arg(ap, unsigned int); /* maxoccupancy */ |
---|
| 1458 | va_arg(ap, int); /* createperms */ |
---|
| 1459 | va_arg(ap, unsigned int); /* unknown */ |
---|
| 1460 | va_arg(ap, char *); /* name */ |
---|
| 1461 | ck = va_arg(ap, char *); |
---|
| 1462 | va_end(ap); |
---|
| 1463 | |
---|
| 1464 | aim_chat_join(odata->sess, odata->conn, exchange, ck, instance); |
---|
| 1465 | } |
---|
| 1466 | break; |
---|
| 1467 | default: |
---|
| 1468 | va_end(ap); |
---|
| 1469 | break; |
---|
[b7d3cc34] | 1470 | } |
---|
| 1471 | return 1; |
---|
| 1472 | } |
---|
| 1473 | |
---|
[5ebff60] | 1474 | static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1475 | { |
---|
[b7d3cc34] | 1476 | va_list ap; |
---|
| 1477 | int count, i; |
---|
| 1478 | aim_userinfo_t *info; |
---|
[0da65d5] | 1479 | struct im_connection *g = sess->aux_data; |
---|
[b7d3cc34] | 1480 | |
---|
| 1481 | struct chat_connection *c = NULL; |
---|
| 1482 | |
---|
| 1483 | va_start(ap, fr); |
---|
| 1484 | count = va_arg(ap, int); |
---|
| 1485 | info = va_arg(ap, aim_userinfo_t *); |
---|
| 1486 | va_end(ap); |
---|
| 1487 | |
---|
| 1488 | c = find_oscar_chat_by_conn(g, fr->conn); |
---|
[5ebff60] | 1489 | if (!c) { |
---|
[b7d3cc34] | 1490 | return 1; |
---|
[5ebff60] | 1491 | } |
---|
[b7d3cc34] | 1492 | |
---|
[5ebff60] | 1493 | for (i = 0; i < count; i++) { |
---|
[424e663] | 1494 | imcb_chat_add_buddy(c->cnv, normalize(info[i].sn)); |
---|
[5ebff60] | 1495 | } |
---|
[b7d3cc34] | 1496 | |
---|
| 1497 | return 1; |
---|
| 1498 | } |
---|
| 1499 | |
---|
[5ebff60] | 1500 | static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1501 | { |
---|
[b7d3cc34] | 1502 | va_list ap; |
---|
| 1503 | int count, i; |
---|
| 1504 | aim_userinfo_t *info; |
---|
[0da65d5] | 1505 | struct im_connection *g = sess->aux_data; |
---|
[b7d3cc34] | 1506 | |
---|
| 1507 | struct chat_connection *c = NULL; |
---|
| 1508 | |
---|
| 1509 | va_start(ap, fr); |
---|
| 1510 | count = va_arg(ap, int); |
---|
| 1511 | info = va_arg(ap, aim_userinfo_t *); |
---|
| 1512 | va_end(ap); |
---|
| 1513 | |
---|
| 1514 | c = find_oscar_chat_by_conn(g, fr->conn); |
---|
[5ebff60] | 1515 | if (!c) { |
---|
[b7d3cc34] | 1516 | return 1; |
---|
[5ebff60] | 1517 | } |
---|
[b7d3cc34] | 1518 | |
---|
[5ebff60] | 1519 | for (i = 0; i < count; i++) { |
---|
[424e663] | 1520 | imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL); |
---|
[5ebff60] | 1521 | } |
---|
[b7d3cc34] | 1522 | |
---|
| 1523 | return 1; |
---|
| 1524 | } |
---|
| 1525 | |
---|
[5ebff60] | 1526 | static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1527 | { |
---|
[b7d3cc34] | 1528 | va_list ap; |
---|
[d18db32f] | 1529 | guint16 maxmsglen, maxvisiblemsglen; |
---|
[0da65d5] | 1530 | struct im_connection *ic = sess->aux_data; |
---|
| 1531 | struct chat_connection *ccon = find_oscar_chat_by_conn(ic, fr->conn); |
---|
[b7d3cc34] | 1532 | |
---|
| 1533 | va_start(ap, fr); |
---|
[d18db32f] | 1534 | va_arg(ap, struct aim_chat_roominfo *); /* roominfo */ |
---|
| 1535 | va_arg(ap, char *); /* roomname */ |
---|
| 1536 | va_arg(ap, int); /* usercount */ |
---|
| 1537 | va_arg(ap, aim_userinfo_t *); /* userinfo */ |
---|
| 1538 | va_arg(ap, char *); /* roomdesc */ |
---|
| 1539 | va_arg(ap, int); /* unknown_c9 */ |
---|
| 1540 | va_arg(ap, unsigned long); /* creationtime */ |
---|
[5ebff60] | 1541 | maxmsglen = (guint16) va_arg(ap, int); |
---|
[d18db32f] | 1542 | va_arg(ap, int); /* unknown_d2 */ |
---|
| 1543 | va_arg(ap, int); /* unknown_d5 */ |
---|
[5ebff60] | 1544 | maxvisiblemsglen = (guint16) va_arg(ap, int); |
---|
[b7d3cc34] | 1545 | va_end(ap); |
---|
| 1546 | |
---|
| 1547 | ccon->maxlen = maxmsglen; |
---|
| 1548 | ccon->maxvis = maxvisiblemsglen; |
---|
| 1549 | |
---|
| 1550 | return 1; |
---|
| 1551 | } |
---|
| 1552 | |
---|
[5ebff60] | 1553 | static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1554 | { |
---|
[b7d3cc34] | 1555 | va_list ap; |
---|
| 1556 | aim_userinfo_t *info; |
---|
| 1557 | char *msg; |
---|
[0da65d5] | 1558 | struct im_connection *ic = sess->aux_data; |
---|
| 1559 | struct chat_connection *ccon = find_oscar_chat_by_conn(ic, fr->conn); |
---|
[b7d3cc34] | 1560 | char *tmp; |
---|
| 1561 | |
---|
| 1562 | va_start(ap, fr); |
---|
| 1563 | info = va_arg(ap, aim_userinfo_t *); |
---|
| 1564 | msg = va_arg(ap, char *); |
---|
| 1565 | |
---|
| 1566 | tmp = g_malloc(BUF_LONG); |
---|
| 1567 | g_snprintf(tmp, BUF_LONG, "%s", msg); |
---|
[424e663] | 1568 | imcb_chat_msg(ccon->cnv, normalize(info->sn), tmp, 0, 0); |
---|
[b7d3cc34] | 1569 | g_free(tmp); |
---|
| 1570 | |
---|
| 1571 | return 1; |
---|
| 1572 | } |
---|
| 1573 | |
---|
[5ebff60] | 1574 | static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1575 | { |
---|
[b7d3cc34] | 1576 | #if 0 |
---|
| 1577 | static const char *codes[5] = { |
---|
| 1578 | "invalid", |
---|
[5ebff60] | 1579 | "change", |
---|
| 1580 | "warning", |
---|
| 1581 | "limit", |
---|
| 1582 | "limit cleared", |
---|
[b7d3cc34] | 1583 | }; |
---|
| 1584 | #endif |
---|
| 1585 | va_list ap; |
---|
[d18db32f] | 1586 | guint16 code; |
---|
| 1587 | guint32 windowsize, clear, currentavg; |
---|
[b7d3cc34] | 1588 | |
---|
[5ebff60] | 1589 | va_start(ap, fr); |
---|
| 1590 | code = (guint16) va_arg(ap, unsigned int); |
---|
[d18db32f] | 1591 | va_arg(ap, unsigned int); /* rateclass */ |
---|
[5ebff60] | 1592 | windowsize = (guint32) va_arg(ap, unsigned long); |
---|
| 1593 | clear = (guint32) va_arg(ap, unsigned long); |
---|
[d18db32f] | 1594 | va_arg(ap, unsigned long); /* alert */ |
---|
| 1595 | va_arg(ap, unsigned long); /* limit */ |
---|
| 1596 | va_arg(ap, unsigned long); /* disconnect */ |
---|
[5ebff60] | 1597 | currentavg = (guint32) va_arg(ap, unsigned long); |
---|
[d18db32f] | 1598 | va_arg(ap, unsigned long); /* maxavg */ |
---|
[b7d3cc34] | 1599 | va_end(ap); |
---|
| 1600 | |
---|
| 1601 | /* XXX fix these values */ |
---|
| 1602 | if (code == AIM_RATE_CODE_CHANGE) { |
---|
[5ebff60] | 1603 | if (currentavg >= clear) { |
---|
[b7d3cc34] | 1604 | aim_conn_setlatency(fr->conn, 0); |
---|
[5ebff60] | 1605 | } |
---|
[b7d3cc34] | 1606 | } else if (code == AIM_RATE_CODE_WARNING) { |
---|
[5ebff60] | 1607 | aim_conn_setlatency(fr->conn, windowsize / 4); |
---|
[b7d3cc34] | 1608 | } else if (code == AIM_RATE_CODE_LIMIT) { |
---|
[84b045d] | 1609 | imcb_error(sess->aux_data, _("The last message was not sent because you are over the rate limit. " |
---|
[5ebff60] | 1610 | "Please wait 10 seconds and try again.")); |
---|
| 1611 | aim_conn_setlatency(fr->conn, windowsize / 2); |
---|
[b7d3cc34] | 1612 | } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
---|
| 1613 | aim_conn_setlatency(fr->conn, 0); |
---|
| 1614 | } |
---|
| 1615 | |
---|
| 1616 | return 1; |
---|
| 1617 | } |
---|
| 1618 | |
---|
[5ebff60] | 1619 | static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1620 | { |
---|
[b7d3cc34] | 1621 | return 1; |
---|
| 1622 | } |
---|
| 1623 | |
---|
[5ebff60] | 1624 | static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1625 | { |
---|
[b7d3cc34] | 1626 | |
---|
| 1627 | aim_reqpersonalinfo(sess, fr->conn); |
---|
| 1628 | aim_bos_reqlocaterights(sess, fr->conn); |
---|
| 1629 | aim_bos_reqbuddyrights(sess, fr->conn); |
---|
| 1630 | |
---|
| 1631 | aim_reqicbmparams(sess); |
---|
| 1632 | |
---|
| 1633 | aim_bos_reqrights(sess, fr->conn); |
---|
| 1634 | aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
---|
| 1635 | aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | |
---|
[5ebff60] | 1636 | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); |
---|
[b7d3cc34] | 1637 | |
---|
| 1638 | return 1; |
---|
| 1639 | } |
---|
| 1640 | |
---|
[5ebff60] | 1641 | static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1642 | { |
---|
[0da65d5] | 1643 | struct im_connection *ic = sess->aux_data; |
---|
| 1644 | struct oscar_data *od = ic->proto_data; |
---|
[b7d3cc34] | 1645 | |
---|
| 1646 | aim_clientready(sess, fr->conn); |
---|
| 1647 | |
---|
| 1648 | if (od->chpass) { |
---|
| 1649 | aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
---|
| 1650 | g_free(od->oldp); |
---|
| 1651 | od->oldp = NULL; |
---|
| 1652 | g_free(od->newp); |
---|
| 1653 | od->newp = NULL; |
---|
| 1654 | od->chpass = FALSE; |
---|
| 1655 | } |
---|
| 1656 | if (od->setnick) { |
---|
| 1657 | aim_admin_setnick(sess, fr->conn, od->newsn); |
---|
| 1658 | g_free(od->newsn); |
---|
| 1659 | od->newsn = NULL; |
---|
| 1660 | od->setnick = FALSE; |
---|
| 1661 | } |
---|
| 1662 | if (od->conf) { |
---|
| 1663 | aim_admin_reqconfirm(sess, fr->conn); |
---|
| 1664 | od->conf = FALSE; |
---|
| 1665 | } |
---|
| 1666 | if (od->reqemail) { |
---|
| 1667 | aim_admin_getinfo(sess, fr->conn, 0x0011); |
---|
| 1668 | od->reqemail = FALSE; |
---|
| 1669 | } |
---|
| 1670 | if (od->setemail) { |
---|
| 1671 | aim_admin_setemail(sess, fr->conn, od->email); |
---|
| 1672 | g_free(od->email); |
---|
| 1673 | od->setemail = FALSE; |
---|
| 1674 | } |
---|
| 1675 | |
---|
| 1676 | return 1; |
---|
| 1677 | } |
---|
| 1678 | |
---|
[5ebff60] | 1679 | static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1680 | { |
---|
[b7d3cc34] | 1681 | struct aim_icbmparameters *params; |
---|
| 1682 | va_list ap; |
---|
| 1683 | |
---|
| 1684 | va_start(ap, fr); |
---|
| 1685 | params = va_arg(ap, struct aim_icbmparameters *); |
---|
| 1686 | va_end(ap); |
---|
| 1687 | |
---|
| 1688 | /* Maybe senderwarn and recverwarn should be user preferences... */ |
---|
[3e1de87] | 1689 | params->flags = 0x0000000b; |
---|
[b7d3cc34] | 1690 | params->maxmsglen = 8000; |
---|
| 1691 | params->minmsginterval = 0; |
---|
| 1692 | |
---|
| 1693 | aim_seticbmparam(sess, params); |
---|
| 1694 | |
---|
| 1695 | return 1; |
---|
| 1696 | } |
---|
| 1697 | |
---|
| 1698 | static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1699 | { |
---|
| 1700 | va_list ap; |
---|
| 1701 | guint16 maxsiglen; |
---|
[0da65d5] | 1702 | struct im_connection *ic = sess->aux_data; |
---|
[5ebff60] | 1703 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
[b7d3cc34] | 1704 | |
---|
| 1705 | va_start(ap, fr); |
---|
| 1706 | maxsiglen = va_arg(ap, int); |
---|
| 1707 | va_end(ap); |
---|
| 1708 | |
---|
[5ebff60] | 1709 | odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint) maxsiglen; |
---|
[b7d3cc34] | 1710 | |
---|
[0a3c243] | 1711 | /* FIXME: It seems we're not really using this, and it broke now that |
---|
| 1712 | struct aim_user is dead. |
---|
[0da65d5] | 1713 | aim_bos_setprofile(sess, fr->conn, ic->user->user_info, NULL, gaim_caps); |
---|
[0a3c243] | 1714 | */ |
---|
[5ebff60] | 1715 | |
---|
[b7d3cc34] | 1716 | return 1; |
---|
| 1717 | } |
---|
| 1718 | |
---|
[5ebff60] | 1719 | static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1720 | { |
---|
[b7d3cc34] | 1721 | va_list ap; |
---|
| 1722 | guint16 maxbuddies, maxwatchers; |
---|
[0da65d5] | 1723 | struct im_connection *ic = sess->aux_data; |
---|
[5ebff60] | 1724 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
[b7d3cc34] | 1725 | |
---|
| 1726 | va_start(ap, fr); |
---|
[5ebff60] | 1727 | maxbuddies = (guint16) va_arg(ap, unsigned int); |
---|
| 1728 | maxwatchers = (guint16) va_arg(ap, unsigned int); |
---|
[b7d3cc34] | 1729 | va_end(ap); |
---|
| 1730 | |
---|
[5ebff60] | 1731 | odata->rights.maxbuddies = (guint) maxbuddies; |
---|
| 1732 | odata->rights.maxwatchers = (guint) maxwatchers; |
---|
[b7d3cc34] | 1733 | |
---|
| 1734 | return 1; |
---|
| 1735 | } |
---|
| 1736 | |
---|
[5ebff60] | 1737 | static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1738 | { |
---|
[b7d3cc34] | 1739 | guint16 maxpermits, maxdenies; |
---|
| 1740 | va_list ap; |
---|
[0da65d5] | 1741 | struct im_connection *ic = sess->aux_data; |
---|
[5ebff60] | 1742 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
[b7d3cc34] | 1743 | |
---|
| 1744 | va_start(ap, fr); |
---|
[5ebff60] | 1745 | maxpermits = (guint16) va_arg(ap, unsigned int); |
---|
| 1746 | maxdenies = (guint16) va_arg(ap, unsigned int); |
---|
[b7d3cc34] | 1747 | va_end(ap); |
---|
| 1748 | |
---|
[5ebff60] | 1749 | odata->rights.maxpermits = (guint) maxpermits; |
---|
| 1750 | odata->rights.maxdenies = (guint) maxdenies; |
---|
[b7d3cc34] | 1751 | |
---|
| 1752 | aim_clientready(sess, fr->conn); |
---|
| 1753 | |
---|
| 1754 | aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
---|
| 1755 | |
---|
| 1756 | aim_ssi_reqrights(sess, fr->conn); |
---|
| 1757 | aim_ssi_reqalldata(sess, fr->conn); |
---|
| 1758 | |
---|
| 1759 | return 1; |
---|
| 1760 | } |
---|
| 1761 | |
---|
[5ebff60] | 1762 | static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1763 | { |
---|
[b7d3cc34] | 1764 | va_list ap; |
---|
| 1765 | struct aim_icq_offlinemsg *msg; |
---|
[0da65d5] | 1766 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 1767 | |
---|
| 1768 | va_start(ap, fr); |
---|
| 1769 | msg = va_arg(ap, struct aim_icq_offlinemsg *); |
---|
| 1770 | va_end(ap); |
---|
| 1771 | |
---|
| 1772 | switch (msg->type) { |
---|
[5ebff60] | 1773 | case 0x0001: { /* Basic offline message */ |
---|
| 1774 | char sender[32]; |
---|
| 1775 | char *dialog_msg = g_strdup(msg->msg); |
---|
| 1776 | time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
---|
| 1777 | g_snprintf(sender, sizeof(sender), "%u", msg->sender); |
---|
| 1778 | strip_linefeed(dialog_msg); |
---|
| 1779 | imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); |
---|
| 1780 | g_free(dialog_msg); |
---|
| 1781 | } break; |
---|
| 1782 | |
---|
| 1783 | case 0x0004: { /* Someone sent you a URL */ |
---|
| 1784 | char sender[32]; |
---|
| 1785 | char *dialog_msg; |
---|
| 1786 | char **m; |
---|
| 1787 | |
---|
| 1788 | time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
---|
| 1789 | g_snprintf(sender, sizeof(sender), "%u", msg->sender); |
---|
| 1790 | |
---|
| 1791 | m = g_strsplit(msg->msg, "\376", 2); |
---|
| 1792 | |
---|
| 1793 | if ((strlen(m[0]) != 0)) { |
---|
| 1794 | dialog_msg = g_strjoinv(" -- ", m); |
---|
| 1795 | } else { |
---|
| 1796 | dialog_msg = m[1]; |
---|
[b7d3cc34] | 1797 | } |
---|
[5ebff60] | 1798 | |
---|
| 1799 | strip_linefeed(dialog_msg); |
---|
| 1800 | imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); |
---|
| 1801 | g_free(dialog_msg); |
---|
| 1802 | g_free(m); |
---|
| 1803 | } break; |
---|
| 1804 | |
---|
| 1805 | case 0x0006: { /* Authorization request */ |
---|
| 1806 | gaim_icq_authask(ic, msg->sender, msg->msg); |
---|
| 1807 | } break; |
---|
| 1808 | |
---|
| 1809 | case 0x0007: { /* Someone has denied you authorization */ |
---|
| 1810 | imcb_log(sess->aux_data, |
---|
| 1811 | "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender, |
---|
| 1812 | msg->msg ? msg->msg : _("No reason given.")); |
---|
| 1813 | } break; |
---|
| 1814 | |
---|
| 1815 | case 0x0008: { /* Someone has granted you authorization */ |
---|
| 1816 | imcb_log(sess->aux_data, |
---|
| 1817 | "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender, |
---|
| 1818 | msg->msg ? msg->msg : _("No reason given.")); |
---|
| 1819 | } break; |
---|
| 1820 | |
---|
| 1821 | case 0x0012: { |
---|
| 1822 | /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
---|
| 1823 | } break; |
---|
| 1824 | |
---|
| 1825 | default: {; } |
---|
[b7d3cc34] | 1826 | } |
---|
| 1827 | |
---|
| 1828 | return 1; |
---|
| 1829 | } |
---|
| 1830 | |
---|
| 1831 | static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1832 | { |
---|
| 1833 | aim_icq_ackofflinemsgs(sess); |
---|
| 1834 | return 1; |
---|
| 1835 | } |
---|
| 1836 | |
---|
[5ebff60] | 1837 | static void oscar_keepalive(struct im_connection *ic) |
---|
| 1838 | { |
---|
| 1839 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
| 1840 | |
---|
[b7d3cc34] | 1841 | aim_flap_nop(odata->sess, odata->conn); |
---|
| 1842 | } |
---|
| 1843 | |
---|
[5ebff60] | 1844 | static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags) |
---|
| 1845 | { |
---|
| 1846 | struct oscar_data *odata = (struct oscar_data *) ic->proto_data; |
---|
[0da65d5] | 1847 | int ret = 0, len = strlen(message); |
---|
[5ebff60] | 1848 | |
---|
[6bbb939] | 1849 | if (imflags & OPT_AWAY) { |
---|
[b7d3cc34] | 1850 | ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message); |
---|
| 1851 | } else { |
---|
| 1852 | struct aim_sendimext_args args; |
---|
| 1853 | char *s; |
---|
[5ebff60] | 1854 | |
---|
[b7d3cc34] | 1855 | args.flags = AIM_IMFLAGS_ACK; |
---|
[5ebff60] | 1856 | if (odata->icq) { |
---|
[b7d3cc34] | 1857 | args.flags |= AIM_IMFLAGS_OFFLINE; |
---|
[5ebff60] | 1858 | } |
---|
| 1859 | for (s = message; *s; s++) { |
---|
| 1860 | if (*s & 128) { |
---|
[b7d3cc34] | 1861 | break; |
---|
[5ebff60] | 1862 | } |
---|
| 1863 | } |
---|
| 1864 | |
---|
[b7d3cc34] | 1865 | /* Message contains high ASCII chars, time for some translation! */ |
---|
| 1866 | if (*s) { |
---|
| 1867 | s = g_malloc(BUF_LONG); |
---|
| 1868 | /* Try if we can put it in an ISO8859-1 string first. |
---|
| 1869 | If we can't, fall back to UTF16. */ |
---|
| 1870 | if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { |
---|
| 1871 | args.flags |= AIM_IMFLAGS_ISO_8859_1; |
---|
| 1872 | len = ret; |
---|
[af496d8] | 1873 | } else if ((ret = do_iconv("UTF-8", "UCS-2BE", message, s, len, BUF_LONG)) >= 0) { |
---|
[b7d3cc34] | 1874 | args.flags |= AIM_IMFLAGS_UNICODE; |
---|
| 1875 | len = ret; |
---|
| 1876 | } else { |
---|
| 1877 | /* OOF, translation failed... Oh well.. */ |
---|
[5ebff60] | 1878 | g_free(s); |
---|
[b7d3cc34] | 1879 | s = message; |
---|
| 1880 | } |
---|
| 1881 | } else { |
---|
| 1882 | s = message; |
---|
| 1883 | } |
---|
[5ebff60] | 1884 | |
---|
[b7d3cc34] | 1885 | args.features = gaim_features; |
---|
| 1886 | args.featureslen = sizeof(gaim_features); |
---|
[5ebff60] | 1887 | |
---|
[b7d3cc34] | 1888 | args.destsn = name; |
---|
| 1889 | args.msg = s; |
---|
| 1890 | args.msglen = len; |
---|
[5ebff60] | 1891 | |
---|
[b7d3cc34] | 1892 | ret = aim_send_im_ext(odata->sess, &args); |
---|
[5ebff60] | 1893 | |
---|
[b7d3cc34] | 1894 | if (s != message) { |
---|
| 1895 | g_free(s); |
---|
| 1896 | } |
---|
| 1897 | } |
---|
[5ebff60] | 1898 | if (ret >= 0) { |
---|
[b7d3cc34] | 1899 | return 1; |
---|
[5ebff60] | 1900 | } |
---|
[b7d3cc34] | 1901 | return ret; |
---|
| 1902 | } |
---|
| 1903 | |
---|
[5ebff60] | 1904 | static void oscar_get_info(struct im_connection *g, char *name) |
---|
| 1905 | { |
---|
| 1906 | struct oscar_data *odata = (struct oscar_data *) g->proto_data; |
---|
| 1907 | |
---|
| 1908 | if (odata->icq) { |
---|
[b7d3cc34] | 1909 | aim_icq_getallinfo(odata->sess, name); |
---|
[5ebff60] | 1910 | } else { |
---|
[b7d3cc34] | 1911 | aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); |
---|
| 1912 | aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO); |
---|
| 1913 | } |
---|
| 1914 | } |
---|
| 1915 | |
---|
[0da65d5] | 1916 | static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) |
---|
[b7d3cc34] | 1917 | { |
---|
[5ebff60] | 1918 | if (state == NULL) { |
---|
[68198e9] | 1919 | state = ""; |
---|
[5ebff60] | 1920 | } |
---|
[b7d3cc34] | 1921 | |
---|
| 1922 | if (!g_strcasecmp(state, _("Visible"))) { |
---|
| 1923 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
---|
| 1924 | return; |
---|
| 1925 | } else if (!g_strcasecmp(state, _("Invisible"))) { |
---|
| 1926 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); |
---|
| 1927 | return; |
---|
[17f9522] | 1928 | } else if (message == NULL) { |
---|
| 1929 | message = state; |
---|
| 1930 | } |
---|
[b7d3cc34] | 1931 | |
---|
[5ebff60] | 1932 | if (od->rights.maxawaymsglen == 0) { |
---|
[84b045d] | 1933 | imcb_error(ic, "oscar_set_away_aim called before locate rights received"); |
---|
[5ebff60] | 1934 | } |
---|
[b7d3cc34] | 1935 | |
---|
| 1936 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
---|
| 1937 | |
---|
[c0c43fb] | 1938 | g_free(ic->away); |
---|
[0da65d5] | 1939 | ic->away = NULL; |
---|
[b7d3cc34] | 1940 | |
---|
| 1941 | if (!message) { |
---|
| 1942 | aim_bos_setprofile(od->sess, od->conn, NULL, "", gaim_caps); |
---|
| 1943 | return; |
---|
| 1944 | } |
---|
| 1945 | |
---|
| 1946 | if (strlen(message) > od->rights.maxawaymsglen) { |
---|
[5ebff60] | 1947 | imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating", |
---|
| 1948 | od->rights.maxawaymsglen); |
---|
[b7d3cc34] | 1949 | } |
---|
| 1950 | |
---|
[0da65d5] | 1951 | ic->away = g_strndup(message, od->rights.maxawaymsglen); |
---|
| 1952 | aim_bos_setprofile(od->sess, od->conn, NULL, ic->away, gaim_caps); |
---|
[b7d3cc34] | 1953 | |
---|
| 1954 | return; |
---|
| 1955 | } |
---|
| 1956 | |
---|
[0da65d5] | 1957 | static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) |
---|
[b7d3cc34] | 1958 | { |
---|
[c0c43fb] | 1959 | const char *msg = NULL; |
---|
[b7d3cc34] | 1960 | gboolean no_message = FALSE; |
---|
| 1961 | |
---|
| 1962 | /* clean old states */ |
---|
[c0c43fb] | 1963 | g_free(ic->away); |
---|
| 1964 | ic->away = NULL; |
---|
[b7d3cc34] | 1965 | od->sess->aim_icq_state = 0; |
---|
| 1966 | |
---|
| 1967 | /* if no message, then use an empty message */ |
---|
[c0c43fb] | 1968 | if (message) { |
---|
| 1969 | msg = message; |
---|
| 1970 | } else { |
---|
| 1971 | msg = ""; |
---|
[b7d3cc34] | 1972 | no_message = TRUE; |
---|
[c0c43fb] | 1973 | } |
---|
[b7d3cc34] | 1974 | |
---|
[68198e9] | 1975 | if (state == NULL) { |
---|
[b7d3cc34] | 1976 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
---|
| 1977 | } else if (!g_strcasecmp(state, "Away")) { |
---|
| 1978 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); |
---|
[c0c43fb] | 1979 | ic->away = g_strdup(msg); |
---|
[b7d3cc34] | 1980 | od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY; |
---|
| 1981 | } else if (!g_strcasecmp(state, "Do Not Disturb")) { |
---|
| 1982 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
---|
[c0c43fb] | 1983 | ic->away = g_strdup(msg); |
---|
[b7d3cc34] | 1984 | od->sess->aim_icq_state = AIM_MTYPE_AUTODND; |
---|
| 1985 | } else if (!g_strcasecmp(state, "Not Available")) { |
---|
| 1986 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
---|
[c0c43fb] | 1987 | ic->away = g_strdup(msg); |
---|
[b7d3cc34] | 1988 | od->sess->aim_icq_state = AIM_MTYPE_AUTONA; |
---|
| 1989 | } else if (!g_strcasecmp(state, "Occupied")) { |
---|
| 1990 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
---|
[c0c43fb] | 1991 | ic->away = g_strdup(msg); |
---|
[b7d3cc34] | 1992 | od->sess->aim_icq_state = AIM_MTYPE_AUTOBUSY; |
---|
| 1993 | } else if (!g_strcasecmp(state, "Free For Chat")) { |
---|
| 1994 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT); |
---|
[c0c43fb] | 1995 | ic->away = g_strdup(msg); |
---|
[b7d3cc34] | 1996 | od->sess->aim_icq_state = AIM_MTYPE_AUTOFFC; |
---|
| 1997 | } else if (!g_strcasecmp(state, "Invisible")) { |
---|
| 1998 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); |
---|
[c0c43fb] | 1999 | ic->away = g_strdup(msg); |
---|
[17f9522] | 2000 | } else { |
---|
[5ebff60] | 2001 | if (no_message) { |
---|
[b7d3cc34] | 2002 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
---|
| 2003 | } else { |
---|
| 2004 | aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); |
---|
[c0c43fb] | 2005 | ic->away = g_strdup(msg); |
---|
[b7d3cc34] | 2006 | od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY; |
---|
| 2007 | } |
---|
| 2008 | } |
---|
| 2009 | |
---|
| 2010 | return; |
---|
| 2011 | } |
---|
| 2012 | |
---|
[0da65d5] | 2013 | static void oscar_set_away(struct im_connection *ic, char *state, char *message) |
---|
[b7d3cc34] | 2014 | { |
---|
[5ebff60] | 2015 | struct oscar_data *od = (struct oscar_data *) ic->proto_data; |
---|
[b7d3cc34] | 2016 | |
---|
[c0c43fb] | 2017 | oscar_set_away_aim(ic, od, state, message); |
---|
[5ebff60] | 2018 | if (od->icq) { |
---|
[0da65d5] | 2019 | oscar_set_away_icq(ic, od, state, message); |
---|
[5ebff60] | 2020 | } |
---|
[b7d3cc34] | 2021 | |
---|
| 2022 | return; |
---|
| 2023 | } |
---|
| 2024 | |
---|
[5ebff60] | 2025 | static void oscar_add_buddy(struct im_connection *g, char *name, char *group) |
---|
| 2026 | { |
---|
| 2027 | struct oscar_data *odata = (struct oscar_data *) g->proto_data; |
---|
[42acba1] | 2028 | bee_user_t *bu; |
---|
[5ebff60] | 2029 | |
---|
| 2030 | if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group) { |
---|
[42acba1] | 2031 | aim_ssi_movebuddy(odata->sess, odata->conn, bu->group->name, group, name); |
---|
[5ebff60] | 2032 | } else { |
---|
[42acba1] | 2033 | aim_ssi_addbuddies(odata->sess, odata->conn, group ? : OSCAR_GROUP, &name, 1, 0); |
---|
[5ebff60] | 2034 | } |
---|
[b7d3cc34] | 2035 | } |
---|
| 2036 | |
---|
[5ebff60] | 2037 | static void oscar_remove_buddy(struct im_connection *g, char *name, char *group) |
---|
| 2038 | { |
---|
| 2039 | struct oscar_data *odata = (struct oscar_data *) g->proto_data; |
---|
[b7d3cc34] | 2040 | struct aim_ssi_item *ssigroup; |
---|
[5ebff60] | 2041 | |
---|
| 2042 | while ((ssigroup = |
---|
| 2043 | aim_ssi_itemlist_findparent(odata->sess->ssi.items, |
---|
| 2044 | name)) && |
---|
| 2045 | !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)) { |
---|
| 2046 | ; |
---|
| 2047 | } |
---|
[b7d3cc34] | 2048 | } |
---|
| 2049 | |
---|
[5ebff60] | 2050 | static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 2051 | { |
---|
[b7d3cc34] | 2052 | return 1; |
---|
| 2053 | } |
---|
| 2054 | |
---|
[5ebff60] | 2055 | static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 2056 | { |
---|
[0da65d5] | 2057 | struct im_connection *ic = sess->aux_data; |
---|
[f7d12f7] | 2058 | struct aim_ssi_item *curitem, *curgroup = NULL; |
---|
[b7d3cc34] | 2059 | int tmp; |
---|
[424e663] | 2060 | char *nrm; |
---|
[b7d3cc34] | 2061 | |
---|
| 2062 | /* Add from server list to local list */ |
---|
| 2063 | tmp = 0; |
---|
[5ebff60] | 2064 | for (curitem = sess->ssi.items; curitem; curitem = curitem->next) { |
---|
[fab3d2d] | 2065 | nrm = curitem->name ? normalize(curitem->name) : NULL; |
---|
[5ebff60] | 2066 | |
---|
[b7d3cc34] | 2067 | switch (curitem->type) { |
---|
[5ebff60] | 2068 | case 0x0000: /* Buddy */ |
---|
| 2069 | if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) { |
---|
| 2070 | char *realname = NULL; |
---|
| 2071 | |
---|
| 2072 | if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) { |
---|
| 2073 | realname = aim_gettlv_str(curitem->data, 0x0131, 1); |
---|
[b7d3cc34] | 2074 | } |
---|
| 2075 | |
---|
[5ebff60] | 2076 | imcb_add_buddy(ic, nrm, |
---|
| 2077 | curgroup ? (curgroup->gid == |
---|
| 2078 | curitem->gid ? curgroup->name : NULL) : NULL); |
---|
[5a673f3] | 2079 | |
---|
[5ebff60] | 2080 | if (realname) { |
---|
| 2081 | imcb_buddy_nick_hint(ic, nrm, realname); |
---|
| 2082 | imcb_rename_buddy(ic, nrm, realname); |
---|
| 2083 | g_free(realname); |
---|
[b7d3cc34] | 2084 | } |
---|
[5ebff60] | 2085 | } |
---|
| 2086 | break; |
---|
[b7d3cc34] | 2087 | |
---|
[5ebff60] | 2088 | case 0x0001: /* Group */ |
---|
| 2089 | curgroup = curitem; |
---|
| 2090 | break; |
---|
| 2091 | |
---|
| 2092 | case 0x0002: /* Permit buddy */ |
---|
| 2093 | if (curitem->name) { |
---|
| 2094 | GSList *list; |
---|
| 2095 | for (list = ic->permit; (list && aim_sncmp(curitem->name, list->data)); |
---|
| 2096 | list = list->next) { |
---|
| 2097 | ; |
---|
[b7d3cc34] | 2098 | } |
---|
[5ebff60] | 2099 | if (!list) { |
---|
| 2100 | char *name; |
---|
| 2101 | name = g_strdup(nrm); |
---|
| 2102 | ic->permit = g_slist_append(ic->permit, name); |
---|
| 2103 | tmp++; |
---|
| 2104 | } |
---|
| 2105 | } |
---|
| 2106 | break; |
---|
[b7d3cc34] | 2107 | |
---|
[5ebff60] | 2108 | case 0x0003: /* Deny buddy */ |
---|
| 2109 | if (curitem->name) { |
---|
| 2110 | GSList *list; |
---|
| 2111 | for (list = ic->deny; |
---|
| 2112 | (list && aim_sncmp(curitem->name, list->data)); list = list->next) { |
---|
| 2113 | ; |
---|
[b7d3cc34] | 2114 | } |
---|
[5ebff60] | 2115 | if (!list) { |
---|
| 2116 | char *name; |
---|
| 2117 | name = g_strdup(nrm); |
---|
| 2118 | ic->deny = g_slist_append(ic->deny, name); |
---|
| 2119 | tmp++; |
---|
| 2120 | } |
---|
| 2121 | } |
---|
| 2122 | break; |
---|
[b7d3cc34] | 2123 | |
---|
[5ebff60] | 2124 | case 0x0004: /* Permit/deny setting */ |
---|
| 2125 | if (curitem->data) { |
---|
| 2126 | guint8 permdeny; |
---|
| 2127 | if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) { |
---|
| 2128 | ic->permdeny = permdeny; |
---|
| 2129 | tmp++; |
---|
| 2130 | } |
---|
| 2131 | } |
---|
| 2132 | break; |
---|
| 2133 | |
---|
| 2134 | case 0x0005: /* Presence setting */ |
---|
| 2135 | /* We don't want to change Gaim's setting because it applies to all accounts */ |
---|
| 2136 | break; |
---|
[b7d3cc34] | 2137 | } /* End of switch on curitem->type */ |
---|
| 2138 | } /* End of for loop */ |
---|
| 2139 | |
---|
| 2140 | aim_ssi_enable(sess, fr->conn); |
---|
[5ebff60] | 2141 | |
---|
[b7d3cc34] | 2142 | /* Request offline messages, now that the buddy list is complete. */ |
---|
| 2143 | aim_icq_reqofflinemsgs(sess); |
---|
[5ebff60] | 2144 | |
---|
[b7d3cc34] | 2145 | /* Now that we have a buddy list, we can tell BitlBee that we're online. */ |
---|
[84b045d] | 2146 | imcb_connected(ic); |
---|
[5ebff60] | 2147 | |
---|
[b7d3cc34] | 2148 | return 1; |
---|
| 2149 | } |
---|
| 2150 | |
---|
[5ebff60] | 2151 | static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
[b7d3cc34] | 2152 | { |
---|
| 2153 | aim_snac_t *origsnac; |
---|
| 2154 | va_list ap; |
---|
| 2155 | |
---|
[5ebff60] | 2156 | va_start(ap, fr); |
---|
| 2157 | origsnac = va_arg(ap, aim_snac_t *); |
---|
| 2158 | va_end(ap); |
---|
| 2159 | |
---|
| 2160 | if (origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data) { |
---|
| 2161 | int i, st, count = aim_bstream_empty(&fr->data); |
---|
[b7d3cc34] | 2162 | char *list; |
---|
[5ebff60] | 2163 | |
---|
| 2164 | if (count & 1) { |
---|
[b7d3cc34] | 2165 | /* Hmm, the length should be even... */ |
---|
[5ebff60] | 2166 | imcb_error(sess->aux_data, "Received SSI ACK package with non-even length"); |
---|
| 2167 | return(0); |
---|
[b7d3cc34] | 2168 | } |
---|
| 2169 | count >>= 1; |
---|
[5ebff60] | 2170 | |
---|
[b7d3cc34] | 2171 | list = (char *) origsnac->data; |
---|
[5ebff60] | 2172 | for (i = 0; i < count; i++) { |
---|
| 2173 | struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent(sess->ssi.items, list); |
---|
[42acba1] | 2174 | char *group = ssigroup ? ssigroup->name : NULL; |
---|
[5ebff60] | 2175 | |
---|
| 2176 | st = aimbs_get16(&fr->data); |
---|
| 2177 | if (st == 0x00) { |
---|
| 2178 | imcb_add_buddy(sess->aux_data, normalize(list), group); |
---|
| 2179 | } else if (st == 0x0E) { |
---|
| 2180 | imcb_log(sess->aux_data, |
---|
| 2181 | "Buddy %s can't be added without authorization, requesting authorization", |
---|
| 2182 | list); |
---|
| 2183 | |
---|
| 2184 | aim_ssi_auth_request(sess, fr->conn, list, ""); |
---|
| 2185 | aim_ssi_addbuddies(sess, fr->conn, OSCAR_GROUP, &list, 1, 1); |
---|
| 2186 | } else if (st == 0x0A) { |
---|
| 2187 | imcb_error(sess->aux_data, "Buddy %s is already in your list", list); |
---|
| 2188 | } else { |
---|
| 2189 | imcb_error(sess->aux_data, "Error while adding buddy: 0x%04x", st); |
---|
[f0cb961] | 2190 | } |
---|
[5ebff60] | 2191 | list += strlen(list) + 1; |
---|
[b7d3cc34] | 2192 | } |
---|
| 2193 | } |
---|
[5ebff60] | 2194 | |
---|
| 2195 | return(1); |
---|
[b7d3cc34] | 2196 | } |
---|
| 2197 | |
---|
[5ebff60] | 2198 | static void oscar_add_permit(struct im_connection *ic, char *who) |
---|
| 2199 | { |
---|
| 2200 | struct oscar_data *od = (struct oscar_data *) ic->proto_data; |
---|
| 2201 | |
---|
[b7d3cc34] | 2202 | if (od->icq) { |
---|
| 2203 | aim_ssi_auth_reply(od->sess, od->conn, who, 1, ""); |
---|
| 2204 | } else { |
---|
[5ebff60] | 2205 | if (od->sess->ssi.received_data) { |
---|
[b7d3cc34] | 2206 | aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT); |
---|
[5ebff60] | 2207 | } |
---|
[b7d3cc34] | 2208 | } |
---|
| 2209 | } |
---|
| 2210 | |
---|
[5ebff60] | 2211 | static void oscar_add_deny(struct im_connection *ic, char *who) |
---|
| 2212 | { |
---|
| 2213 | struct oscar_data *od = (struct oscar_data *) ic->proto_data; |
---|
| 2214 | |
---|
[b7d3cc34] | 2215 | if (od->icq) { |
---|
| 2216 | aim_ssi_auth_reply(od->sess, od->conn, who, 0, ""); |
---|
| 2217 | } else { |
---|
[5ebff60] | 2218 | if (od->sess->ssi.received_data) { |
---|
[b7d3cc34] | 2219 | aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY); |
---|
[5ebff60] | 2220 | } |
---|
[b7d3cc34] | 2221 | } |
---|
| 2222 | } |
---|
| 2223 | |
---|
[5ebff60] | 2224 | static void oscar_rem_permit(struct im_connection *ic, char *who) |
---|
| 2225 | { |
---|
| 2226 | struct oscar_data *od = (struct oscar_data *) ic->proto_data; |
---|
| 2227 | |
---|
[b7d3cc34] | 2228 | if (!od->icq) { |
---|
[5ebff60] | 2229 | if (od->sess->ssi.received_data) { |
---|
[b7d3cc34] | 2230 | aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT); |
---|
[5ebff60] | 2231 | } |
---|
[b7d3cc34] | 2232 | } |
---|
| 2233 | } |
---|
| 2234 | |
---|
[5ebff60] | 2235 | static void oscar_rem_deny(struct im_connection *ic, char *who) |
---|
| 2236 | { |
---|
| 2237 | struct oscar_data *od = (struct oscar_data *) ic->proto_data; |
---|
| 2238 | |
---|
[b7d3cc34] | 2239 | if (!od->icq) { |
---|
[5ebff60] | 2240 | if (od->sess->ssi.received_data) { |
---|
[b7d3cc34] | 2241 | aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY); |
---|
[5ebff60] | 2242 | } |
---|
[b7d3cc34] | 2243 | } |
---|
| 2244 | } |
---|
| 2245 | |
---|
[0da65d5] | 2246 | static GList *oscar_away_states(struct im_connection *ic) |
---|
[b7d3cc34] | 2247 | { |
---|
[0da65d5] | 2248 | struct oscar_data *od = ic->proto_data; |
---|
[b7d3cc34] | 2249 | |
---|
[17f9522] | 2250 | if (od->icq) { |
---|
| 2251 | static GList *m = NULL; |
---|
| 2252 | m = g_list_append(m, "Away"); |
---|
| 2253 | m = g_list_append(m, "Do Not Disturb"); |
---|
| 2254 | m = g_list_append(m, "Not Available"); |
---|
| 2255 | m = g_list_append(m, "Occupied"); |
---|
| 2256 | m = g_list_append(m, "Free For Chat"); |
---|
| 2257 | m = g_list_append(m, "Invisible"); |
---|
| 2258 | return m; |
---|
| 2259 | } else { |
---|
| 2260 | static GList *m = NULL; |
---|
| 2261 | m = g_list_append(m, "Away"); |
---|
| 2262 | return m; |
---|
| 2263 | } |
---|
[b7d3cc34] | 2264 | } |
---|
| 2265 | |
---|
| 2266 | static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 2267 | { |
---|
[e64de00] | 2268 | struct im_connection *ic = sess->aux_data; |
---|
| 2269 | struct oscar_data *od = ic->proto_data; |
---|
| 2270 | gchar who[16]; |
---|
| 2271 | GString *str; |
---|
| 2272 | va_list ap; |
---|
| 2273 | struct aim_icq_info *info; |
---|
| 2274 | uint32_t ip; |
---|
| 2275 | |
---|
| 2276 | va_start(ap, fr); |
---|
| 2277 | info = va_arg(ap, struct aim_icq_info *); |
---|
| 2278 | va_end(ap); |
---|
| 2279 | |
---|
[5ebff60] | 2280 | if (!info->uin) { |
---|
[e64de00] | 2281 | return 0; |
---|
[5ebff60] | 2282 | } |
---|
[e64de00] | 2283 | |
---|
| 2284 | str = g_string_sized_new(512); |
---|
| 2285 | g_snprintf(who, sizeof(who), "%u", info->uin); |
---|
| 2286 | |
---|
[5ebff60] | 2287 | g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), |
---|
| 2288 | info->nick ? info->nick : "-"); |
---|
[e64de00] | 2289 | g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first); |
---|
| 2290 | g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last); |
---|
| 2291 | g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email); |
---|
| 2292 | if (info->numaddresses && info->email2) { |
---|
| 2293 | int i; |
---|
| 2294 | for (i = 0; i < info->numaddresses; i++) { |
---|
| 2295 | g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]); |
---|
| 2296 | } |
---|
| 2297 | } |
---|
[5588edf5] | 2298 | if (od->ips && (ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) { |
---|
[e64de00] | 2299 | g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"), |
---|
| 2300 | (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); |
---|
| 2301 | } |
---|
| 2302 | g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile); |
---|
[5ebff60] | 2303 | if (info->gender != 0) { |
---|
| 2304 | g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); |
---|
| 2305 | } |
---|
[e64de00] | 2306 | if (info->birthyear || info->birthmonth || info->birthday) { |
---|
| 2307 | char date[30]; |
---|
| 2308 | struct tm tm; |
---|
[613cc55] | 2309 | memset(&tm, 0, sizeof(struct tm)); |
---|
[5ebff60] | 2310 | tm.tm_mday = (int) info->birthday; |
---|
| 2311 | tm.tm_mon = (int) info->birthmonth - 1; |
---|
| 2312 | tm.tm_year = (int) info->birthyear % 100; |
---|
[e64de00] | 2313 | strftime(date, sizeof(date), "%Y-%m-%d", &tm); |
---|
| 2314 | g_string_append_printf(str, "\n%s: %s", _("Birthday"), date); |
---|
| 2315 | } |
---|
| 2316 | if (info->age) { |
---|
| 2317 | char age[5]; |
---|
| 2318 | g_snprintf(age, sizeof(age), "%hhd", info->age); |
---|
| 2319 | g_string_append_printf(str, "\n%s: %s", _("Age"), age); |
---|
| 2320 | } |
---|
| 2321 | g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage); |
---|
| 2322 | if (info->info && info->info[0]) { |
---|
[5ebff60] | 2323 | g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), |
---|
| 2324 | info->info, _("End of Additional Information")); |
---|
[e64de00] | 2325 | } |
---|
| 2326 | g_string_append_c(str, '\n'); |
---|
[5ebff60] | 2327 | if ((info->homeaddr && |
---|
| 2328 | (info->homeaddr[0])) || |
---|
| 2329 | (info->homecity && |
---|
| 2330 | info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
---|
[e64de00] | 2331 | g_string_append_printf(str, "%s:", _("Home Address")); |
---|
| 2332 | g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr); |
---|
| 2333 | g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity); |
---|
[5ebff60] | 2334 | g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate); |
---|
[e64de00] | 2335 | g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip); |
---|
| 2336 | g_string_append_c(str, '\n'); |
---|
| 2337 | } |
---|
[5ebff60] | 2338 | if ((info->workaddr && |
---|
| 2339 | info->workaddr[0]) || |
---|
| 2340 | (info->workcity && |
---|
| 2341 | info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
---|
[e64de00] | 2342 | g_string_append_printf(str, "%s:", _("Work Address")); |
---|
| 2343 | g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr); |
---|
| 2344 | g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity); |
---|
| 2345 | g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate); |
---|
| 2346 | g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip); |
---|
| 2347 | g_string_append_c(str, '\n'); |
---|
| 2348 | } |
---|
[5ebff60] | 2349 | if ((info->workcompany && |
---|
| 2350 | info->workcompany[0]) || |
---|
| 2351 | (info->workdivision && |
---|
| 2352 | info->workdivision[0]) || |
---|
| 2353 | (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
---|
[e64de00] | 2354 | g_string_append_printf(str, "%s:", _("Work Information")); |
---|
| 2355 | g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany); |
---|
| 2356 | g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision); |
---|
| 2357 | g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition); |
---|
| 2358 | if (info->workwebpage && info->workwebpage[0]) { |
---|
| 2359 | g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage); |
---|
| 2360 | } |
---|
| 2361 | g_string_append_c(str, '\n'); |
---|
| 2362 | } |
---|
| 2363 | |
---|
| 2364 | imcb_log(ic, "%s\n%s", _("User Info"), str->str); |
---|
| 2365 | g_string_free(str, TRUE); |
---|
| 2366 | |
---|
| 2367 | return 1; |
---|
[b7d3cc34] | 2368 | |
---|
| 2369 | } |
---|
| 2370 | |
---|
| 2371 | static char *oscar_encoding_extract(const char *encoding) |
---|
| 2372 | { |
---|
| 2373 | char *ret = NULL; |
---|
| 2374 | char *begin, *end; |
---|
| 2375 | |
---|
| 2376 | g_return_val_if_fail(encoding != NULL, NULL); |
---|
| 2377 | |
---|
| 2378 | /* Make sure encoding begins with charset= */ |
---|
| 2379 | if (strncmp(encoding, "text/plain; charset=", 20) && |
---|
[5ebff60] | 2380 | strncmp(encoding, "text/aolrtf; charset=", 21) && |
---|
| 2381 | strncmp(encoding, "text/x-aolrtf; charset=", 23)) { |
---|
[b7d3cc34] | 2382 | return NULL; |
---|
| 2383 | } |
---|
| 2384 | |
---|
| 2385 | begin = strchr(encoding, '"'); |
---|
| 2386 | end = strrchr(encoding, '"'); |
---|
| 2387 | |
---|
[5ebff60] | 2388 | if ((begin == NULL) || (end == NULL) || (begin >= end)) { |
---|
[b7d3cc34] | 2389 | return NULL; |
---|
[5ebff60] | 2390 | } |
---|
[b7d3cc34] | 2391 | |
---|
[5ebff60] | 2392 | ret = g_strndup(begin + 1, (end - 1) - begin); |
---|
[b7d3cc34] | 2393 | |
---|
| 2394 | return ret; |
---|
| 2395 | } |
---|
| 2396 | |
---|
| 2397 | static char *oscar_encoding_to_utf8(char *encoding, char *text, int textlen) |
---|
| 2398 | { |
---|
| 2399 | char *utf8 = g_new0(char, 8192); |
---|
| 2400 | |
---|
| 2401 | if ((encoding == NULL) || encoding[0] == '\0') { |
---|
| 2402 | /* gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n");*/ |
---|
| 2403 | } else if (!g_strcasecmp(encoding, "iso-8859-1")) { |
---|
| 2404 | do_iconv("iso-8859-1", "UTF-8", text, utf8, textlen, 8192); |
---|
| 2405 | } else if (!g_strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
---|
| 2406 | do_iconv("Windows-1252", "UTF-8", text, utf8, textlen, 8192); |
---|
| 2407 | } else if (!g_strcasecmp(encoding, "unicode-2-0")) { |
---|
| 2408 | do_iconv("UCS-2BE", "UTF-8", text, utf8, textlen, 8192); |
---|
| 2409 | } else if (g_strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
---|
| 2410 | /* gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
---|
| 2411 | "attempting to convert to UTF-8 anyway\n", encoding);*/ |
---|
| 2412 | do_iconv(encoding, "UTF-8", text, utf8, textlen, 8192); |
---|
| 2413 | } |
---|
| 2414 | |
---|
| 2415 | /* |
---|
| 2416 | * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or |
---|
| 2417 | * we have been unable to convert the text to utf-8 from the encoding |
---|
| 2418 | * that was specified. So we assume it's UTF-8 and hope for the best. |
---|
| 2419 | */ |
---|
| 2420 | if (*utf8 == 0) { |
---|
[5ebff60] | 2421 | strncpy(utf8, text, textlen); |
---|
[b7d3cc34] | 2422 | } |
---|
| 2423 | |
---|
| 2424 | return utf8; |
---|
| 2425 | } |
---|
| 2426 | |
---|
| 2427 | static int gaim_parseaiminfo(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 2428 | { |
---|
[0da65d5] | 2429 | struct im_connection *ic = sess->aux_data; |
---|
[b7d3cc34] | 2430 | va_list ap; |
---|
| 2431 | aim_userinfo_t *userinfo; |
---|
| 2432 | guint16 infotype; |
---|
| 2433 | char *text_encoding = NULL, *text = NULL, *extracted_encoding = NULL; |
---|
| 2434 | guint16 text_length; |
---|
| 2435 | char *utf8 = NULL; |
---|
| 2436 | |
---|
| 2437 | va_start(ap, fr); |
---|
| 2438 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 2439 | infotype = va_arg(ap, int); |
---|
| 2440 | text_encoding = va_arg(ap, char*); |
---|
| 2441 | text = va_arg(ap, char*); |
---|
| 2442 | text_length = va_arg(ap, int); |
---|
| 2443 | va_end(ap); |
---|
| 2444 | |
---|
[5ebff60] | 2445 | if (text_encoding) { |
---|
[b7d3cc34] | 2446 | extracted_encoding = oscar_encoding_extract(text_encoding); |
---|
[5ebff60] | 2447 | } |
---|
| 2448 | if (infotype == AIM_GETINFO_GENERALINFO) { |
---|
[b7d3cc34] | 2449 | /*Display idle time*/ |
---|
| 2450 | char buff[256]; |
---|
| 2451 | struct tm idletime; |
---|
[5ebff60] | 2452 | if (userinfo->idletime) { |
---|
[b7d3cc34] | 2453 | memset(&idletime, 0, sizeof(struct tm)); |
---|
| 2454 | idletime.tm_mday = (userinfo->idletime / 60) / 24; |
---|
| 2455 | idletime.tm_hour = (userinfo->idletime / 60) % 24; |
---|
| 2456 | idletime.tm_min = userinfo->idletime % 60; |
---|
| 2457 | idletime.tm_sec = 0; |
---|
| 2458 | strftime(buff, 256, _("%d days %H hours %M minutes"), &idletime); |
---|
[84b045d] | 2459 | imcb_log(ic, "%s: %s", _("Idle Time"), buff); |
---|
[b7d3cc34] | 2460 | } |
---|
[5ebff60] | 2461 | |
---|
| 2462 | if (text) { |
---|
[b7d3cc34] | 2463 | utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length); |
---|
[84b045d] | 2464 | imcb_log(ic, "%s\n%s", _("User Info"), utf8); |
---|
[b7d3cc34] | 2465 | } else { |
---|
[84b045d] | 2466 | imcb_log(ic, _("No user info available.")); |
---|
[b7d3cc34] | 2467 | } |
---|
[5ebff60] | 2468 | } else if (infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) { |
---|
[b7d3cc34] | 2469 | utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length); |
---|
[84b045d] | 2470 | imcb_log(ic, "%s\n%s", _("Away Message"), utf8); |
---|
[b7d3cc34] | 2471 | } |
---|
| 2472 | |
---|
| 2473 | g_free(utf8); |
---|
[5ebff60] | 2474 | |
---|
[b7d3cc34] | 2475 | return 1; |
---|
| 2476 | } |
---|
| 2477 | |
---|
[3e1de87] | 2478 | int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 2479 | { |
---|
[0da65d5] | 2480 | struct im_connection * ic = sess->aux_data; |
---|
[3e1de87] | 2481 | va_list ap; |
---|
[d18db32f] | 2482 | guint16 type2; |
---|
[3e1de87] | 2483 | char * sn; |
---|
| 2484 | |
---|
| 2485 | va_start(ap, fr); |
---|
[d18db32f] | 2486 | va_arg(ap, int); /* type1 */ |
---|
[3e1de87] | 2487 | sn = va_arg(ap, char*); |
---|
| 2488 | type2 = va_arg(ap, int); |
---|
| 2489 | va_end(ap); |
---|
[5ebff60] | 2490 | |
---|
| 2491 | if (type2 == 0x0002) { |
---|
[e7f46c5] | 2492 | /* User is typing */ |
---|
[424e663] | 2493 | imcb_buddy_typing(ic, normalize(sn), OPT_TYPING); |
---|
[5ebff60] | 2494 | } else if (type2 == 0x0001) { |
---|
[e7f46c5] | 2495 | /* User has typed something, but is not actively typing (stale) */ |
---|
[424e663] | 2496 | imcb_buddy_typing(ic, normalize(sn), OPT_THINKING); |
---|
[5ebff60] | 2497 | } else { |
---|
[e7f46c5] | 2498 | /* User has stopped typing */ |
---|
[424e663] | 2499 | imcb_buddy_typing(ic, normalize(sn), 0); |
---|
[e64de00] | 2500 | } |
---|
[5ebff60] | 2501 | |
---|
[3e1de87] | 2502 | return 1; |
---|
| 2503 | } |
---|
| 2504 | |
---|
[0da65d5] | 2505 | int oscar_send_typing(struct im_connection *ic, char * who, int typing) |
---|
[3e1de87] | 2506 | { |
---|
[0da65d5] | 2507 | struct oscar_data *od = ic->proto_data; |
---|
[5ebff60] | 2508 | |
---|
| 2509 | return(aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000)); |
---|
[3e1de87] | 2510 | } |
---|
| 2511 | |
---|
[f6c963b] | 2512 | void oscar_chat_msg(struct groupchat *c, char *message, int msgflags) |
---|
[b8ef1b1] | 2513 | { |
---|
[0da65d5] | 2514 | struct im_connection *ic = c->ic; |
---|
[5ebff60] | 2515 | struct oscar_data * od = (struct oscar_data*) ic->proto_data; |
---|
[b8ef1b1] | 2516 | struct chat_connection * ccon; |
---|
| 2517 | int ret; |
---|
| 2518 | guint8 len = strlen(message); |
---|
[73cf7fd] | 2519 | guint16 flags; |
---|
[b8ef1b1] | 2520 | char *s; |
---|
[5ebff60] | 2521 | |
---|
| 2522 | if (!(ccon = c->data)) { |
---|
[e437366] | 2523 | return; |
---|
[5ebff60] | 2524 | } |
---|
| 2525 | |
---|
| 2526 | for (s = message; *s; s++) { |
---|
| 2527 | if (*s & 128) { |
---|
[b8ef1b1] | 2528 | break; |
---|
[5ebff60] | 2529 | } |
---|
| 2530 | } |
---|
| 2531 | |
---|
[73cf7fd] | 2532 | flags = AIM_CHATFLAGS_NOREFLECT; |
---|
[5ebff60] | 2533 | |
---|
[b8ef1b1] | 2534 | /* Message contains high ASCII chars, time for some translation! */ |
---|
| 2535 | if (*s) { |
---|
| 2536 | s = g_malloc(BUF_LONG); |
---|
| 2537 | /* Try if we can put it in an ISO8859-1 string first. |
---|
| 2538 | If we can't, fall back to UTF16. */ |
---|
| 2539 | if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { |
---|
[73cf7fd] | 2540 | flags |= AIM_CHATFLAGS_ISO_8859_1; |
---|
[b8ef1b1] | 2541 | len = ret; |
---|
[af496d8] | 2542 | } else if ((ret = do_iconv("UTF-8", "UCS-2BE", message, s, len, BUF_LONG)) >= 0) { |
---|
[73cf7fd] | 2543 | flags |= AIM_CHATFLAGS_UNICODE; |
---|
[b8ef1b1] | 2544 | len = ret; |
---|
| 2545 | } else { |
---|
| 2546 | /* OOF, translation failed... Oh well.. */ |
---|
[5ebff60] | 2547 | g_free(s); |
---|
[b8ef1b1] | 2548 | s = message; |
---|
| 2549 | } |
---|
| 2550 | } else { |
---|
| 2551 | s = message; |
---|
| 2552 | } |
---|
[5ebff60] | 2553 | |
---|
[73cf7fd] | 2554 | ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len); |
---|
[5ebff60] | 2555 | |
---|
| 2556 | if (s != message) { |
---|
[b8ef1b1] | 2557 | g_free(s); |
---|
[5ebff60] | 2558 | } |
---|
| 2559 | |
---|
[0da65d5] | 2560 | /* return (ret >= 0); */ |
---|
[b8ef1b1] | 2561 | } |
---|
| 2562 | |
---|
[c058ff9] | 2563 | void oscar_chat_invite(struct groupchat *c, char *who, char *message) |
---|
[b8ef1b1] | 2564 | { |
---|
[0da65d5] | 2565 | struct im_connection *ic = c->ic; |
---|
[5ebff60] | 2566 | struct oscar_data * od = (struct oscar_data *) ic->proto_data; |
---|
[e437366] | 2567 | struct chat_connection *ccon; |
---|
[5ebff60] | 2568 | |
---|
| 2569 | if (!(ccon = c->data)) { |
---|
[e437366] | 2570 | return; |
---|
[5ebff60] | 2571 | } |
---|
| 2572 | |
---|
[b8ef1b1] | 2573 | aim_chat_invite(od->sess, od->conn, who, message ? message : "", |
---|
[5ebff60] | 2574 | ccon->exchange, ccon->name, 0x0); |
---|
[b8ef1b1] | 2575 | } |
---|
| 2576 | |
---|
[0da65d5] | 2577 | void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc) |
---|
[b8ef1b1] | 2578 | { |
---|
[5ebff60] | 2579 | struct oscar_data *od = (struct oscar_data *) ic->proto_data; |
---|
[b8ef1b1] | 2580 | |
---|
| 2581 | /* Notify the conversation window that we've left the chat */ |
---|
[e35d1a1] | 2582 | imcb_chat_free(cc->cnv); |
---|
[b8ef1b1] | 2583 | |
---|
| 2584 | /* Destroy the chat_connection */ |
---|
| 2585 | od->oscar_chats = g_slist_remove(od->oscar_chats, cc); |
---|
[5ebff60] | 2586 | if (cc->inpa > 0) { |
---|
[ba9edaa] | 2587 | b_event_remove(cc->inpa); |
---|
[5ebff60] | 2588 | } |
---|
[b8ef1b1] | 2589 | aim_conn_kill(od->sess, &cc->conn); |
---|
| 2590 | g_free(cc->name); |
---|
| 2591 | g_free(cc->show); |
---|
| 2592 | g_free(cc); |
---|
| 2593 | } |
---|
| 2594 | |
---|
[0da65d5] | 2595 | void oscar_chat_leave(struct groupchat *c) |
---|
[b8ef1b1] | 2596 | { |
---|
[5ebff60] | 2597 | if (!c->data) { |
---|
[e437366] | 2598 | return; |
---|
[5ebff60] | 2599 | } |
---|
[0da65d5] | 2600 | oscar_chat_kill(c->ic, c->data); |
---|
[b8ef1b1] | 2601 | } |
---|
| 2602 | |
---|
[03f3828] | 2603 | struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char *room, |
---|
[5ebff60] | 2604 | const char *nick, const char *password, int exchange_number) |
---|
[b8ef1b1] | 2605 | { |
---|
[5ebff60] | 2606 | struct oscar_data * od = (struct oscar_data *) ic->proto_data; |
---|
[7989d40d] | 2607 | struct groupchat *ret = imcb_chat_new(ic, room); |
---|
[b8ef1b1] | 2608 | aim_conn_t * cur; |
---|
| 2609 | |
---|
[5ebff60] | 2610 | if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
---|
[d18db32f] | 2611 | aim_chatnav_createroom(od->sess, cur, room, exchange_number); |
---|
[5ebff60] | 2612 | |
---|
[7989d40d] | 2613 | return ret; |
---|
[b8ef1b1] | 2614 | } else { |
---|
| 2615 | struct create_room * cr = g_new0(struct create_room, 1); |
---|
[5ebff60] | 2616 | |
---|
[03f3828] | 2617 | cr->exchange = exchange_number; |
---|
[c737ba7] | 2618 | cr->name = g_strdup(room); |
---|
[b8ef1b1] | 2619 | od->create_rooms = g_slist_append(od->create_rooms, cr); |
---|
| 2620 | aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); |
---|
[5ebff60] | 2621 | |
---|
[7989d40d] | 2622 | return ret; |
---|
[b8ef1b1] | 2623 | } |
---|
| 2624 | } |
---|
| 2625 | |
---|
[03f3828] | 2626 | struct groupchat *oscar_chat_join(struct im_connection *ic, const char *room, |
---|
[5ebff60] | 2627 | const char *nick, const char *password, set_t **sets) |
---|
[03f3828] | 2628 | { |
---|
| 2629 | return oscar_chat_join_internal(ic, room, nick, password, set_getint(sets, "exchange_number")); |
---|
| 2630 | } |
---|
| 2631 | |
---|
[0da65d5] | 2632 | struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) |
---|
[b8ef1b1] | 2633 | { |
---|
[5ebff60] | 2634 | struct oscar_data * od = (struct oscar_data *) ic->proto_data; |
---|
[c737ba7] | 2635 | struct groupchat *ret; |
---|
[b8ef1b1] | 2636 | static int chat_id = 0; |
---|
[e437366] | 2637 | char * chatname, *s; |
---|
[5ebff60] | 2638 | |
---|
[6b13103] | 2639 | chatname = g_strdup_printf("%s%s%d", g_ascii_isdigit(*ic->acc->user) ? "icq" : "", |
---|
[75610c3] | 2640 | ic->acc->user, chat_id++); |
---|
[5ebff60] | 2641 | |
---|
| 2642 | for (s = chatname; *s; s++) { |
---|
| 2643 | if (!g_ascii_isalnum(*s)) { |
---|
[e437366] | 2644 | *s = '0'; |
---|
[5ebff60] | 2645 | } |
---|
| 2646 | } |
---|
| 2647 | |
---|
[03f3828] | 2648 | ret = oscar_chat_join_internal(ic, chatname, NULL, NULL, 4); |
---|
[b8ef1b1] | 2649 | aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); |
---|
| 2650 | |
---|
| 2651 | g_free(chatname); |
---|
[5ebff60] | 2652 | |
---|
[b041b52] | 2653 | return ret; |
---|
[b8ef1b1] | 2654 | } |
---|
| 2655 | |
---|
[9143aeb] | 2656 | void oscar_accept_chat(void *data) |
---|
[b8ef1b1] | 2657 | { |
---|
[9143aeb] | 2658 | struct aim_chat_invitation * inv = data; |
---|
[5ebff60] | 2659 | |
---|
[03f3828] | 2660 | oscar_chat_join_internal(inv->ic, inv->name, NULL, NULL, 4); |
---|
[b8ef1b1] | 2661 | g_free(inv->name); |
---|
| 2662 | g_free(inv); |
---|
| 2663 | } |
---|
| 2664 | |
---|
[9143aeb] | 2665 | void oscar_reject_chat(void *data) |
---|
[b8ef1b1] | 2666 | { |
---|
[9143aeb] | 2667 | struct aim_chat_invitation * inv = data; |
---|
[5ebff60] | 2668 | |
---|
[b8ef1b1] | 2669 | g_free(inv->name); |
---|
| 2670 | g_free(inv); |
---|
| 2671 | } |
---|
| 2672 | |
---|
[03f3828] | 2673 | void oscar_chat_add_settings(account_t *acc, set_t **head) |
---|
| 2674 | { |
---|
| 2675 | set_add(head, "exchange_number", "4", set_eval_int, NULL); |
---|
| 2676 | } |
---|
| 2677 | |
---|
| 2678 | void oscar_chat_free_settings(account_t *acc, set_t **head) |
---|
| 2679 | { |
---|
| 2680 | set_del(head, "exchange_number"); |
---|
| 2681 | } |
---|
| 2682 | |
---|
[5ebff60] | 2683 | void oscar_initmodule() |
---|
[7b23afd] | 2684 | { |
---|
| 2685 | struct prpl *ret = g_new0(struct prpl, 1); |
---|
[5ebff60] | 2686 | |
---|
[7b23afd] | 2687 | ret->name = "oscar"; |
---|
[5ebff60] | 2688 | ret->mms = 2343; /* this guess taken from libotr UPGRADING file */ |
---|
[b7d3cc34] | 2689 | ret->away_states = oscar_away_states; |
---|
[0da65d5] | 2690 | ret->init = oscar_init; |
---|
[b7d3cc34] | 2691 | ret->login = oscar_login; |
---|
[0da65d5] | 2692 | ret->keepalive = oscar_keepalive; |
---|
| 2693 | ret->logout = oscar_logout; |
---|
[f6c963b] | 2694 | ret->buddy_msg = oscar_buddy_msg; |
---|
[b7d3cc34] | 2695 | ret->get_info = oscar_get_info; |
---|
| 2696 | ret->set_away = oscar_set_away; |
---|
| 2697 | ret->add_buddy = oscar_add_buddy; |
---|
| 2698 | ret->remove_buddy = oscar_remove_buddy; |
---|
[f6c963b] | 2699 | ret->chat_msg = oscar_chat_msg; |
---|
[b8ef1b1] | 2700 | ret->chat_invite = oscar_chat_invite; |
---|
| 2701 | ret->chat_leave = oscar_chat_leave; |
---|
[0da65d5] | 2702 | ret->chat_with = oscar_chat_with; |
---|
[c737ba7] | 2703 | ret->chat_join = oscar_chat_join; |
---|
[03f3828] | 2704 | ret->chat_add_settings = oscar_chat_add_settings; |
---|
| 2705 | ret->chat_free_settings = oscar_chat_free_settings; |
---|
[b7d3cc34] | 2706 | ret->add_permit = oscar_add_permit; |
---|
| 2707 | ret->add_deny = oscar_add_deny; |
---|
| 2708 | ret->rem_permit = oscar_rem_permit; |
---|
| 2709 | ret->rem_deny = oscar_rem_deny; |
---|
[3e1de87] | 2710 | ret->send_typing = oscar_send_typing; |
---|
[5ebff60] | 2711 | |
---|
[5b52a48] | 2712 | ret->handle_cmp = aim_sncmp; |
---|
[3e1de87] | 2713 | |
---|
[7b23afd] | 2714 | register_protocol(ret); |
---|
[b7d3cc34] | 2715 | } |
---|