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