Changeset 5ebff60 for protocols/oscar/oscar.c
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/oscar.c
raf359b4 r5ebff60 50 50 #define USEROPT_AUTHPORT 1 51 51 52 #define UC_AOL 53 #define UC_ADMIN 54 #define UC_UNCONFIRMED 55 #define UC_NORMAL 56 #define UC_AB 57 #define UC_WIRELESS 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 58 58 59 59 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" … … 62 62 63 63 #define BUF_LEN 2048 64 #define BUF_LONG ( BUF_LEN * 2)64 #define BUF_LONG (BUF_LEN * 2) 65 65 66 66 /* Don't know if support for UTF8 is really working. For now it's UTF16 here. … … 68 68 69 69 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT; 70 static guint8 gaim_features[] = { 0x01, 0x01, 0x01, 0x02};70 static guint8 gaim_features[] = { 0x01, 0x01, 0x01, 0x02 }; 71 71 72 72 struct oscar_data { … … 94 94 gboolean icq; 95 95 GSList *evilhack; 96 96 97 97 GHashTable *ips; 98 98 … … 139 139 }; 140 140 141 static char *extract_name(const char *name) { 141 static char *extract_name(const char *name) 142 { 142 143 char *tmp; 143 144 int i, j; 144 145 char *x = strchr(name, '-'); 145 if (!x) return g_strdup(name); 146 147 if (!x) { 148 return g_strdup(name); 149 } 146 150 x = strchr(++x, '-'); 147 if (!x) return g_strdup(name); 151 if (!x) { 152 return g_strdup(name); 153 } 148 154 tmp = g_strdup(++x); 149 155 … … 156 162 strncpy(hex, x + ++i, 2); hex[2] = 0; 157 163 i++; 158 tmp[j++] = (char) strtol(hex, NULL, 16);164 tmp[j++] = (char) strtol(hex, NULL, 16); 159 165 } 160 166 … … 164 170 165 171 static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic, 166 aim_conn_t *conn) { 167 GSList *g = ((struct oscar_data *)ic->proto_data)->oscar_chats; 172 aim_conn_t *conn) 173 { 174 GSList *g = ((struct oscar_data *) ic->proto_data)->oscar_chats; 168 175 struct chat_connection *c = NULL; 169 176 170 177 while (g) { 171 c = (struct chat_connection *) g->data;172 if (c->conn == conn) 178 c = (struct chat_connection *) g->data; 179 if (c->conn == conn) { 173 180 break; 181 } 174 182 g = g->next; 175 183 c = NULL; … … 179 187 } 180 188 181 static int gaim_parse_auth_resp 182 static int gaim_parse_login 183 static int gaim_parse_logout 184 static int gaim_handle_redirect 185 static int gaim_parse_oncoming 186 static int gaim_parse_offgoing 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 *, ...); 187 195 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); 188 static int gaim_parse_misses 189 static int gaim_parse_motd 190 static int gaim_chatnav_info 191 static int gaim_chat_join 192 static int gaim_chat_leave 193 static int gaim_chat_info_update 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 *, ...); 194 202 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); 195 static int gaim_parse_ratechange 196 static int gaim_bosrights 197 static int conninitdone_bos 198 static int conninitdone_admin 199 static int conninitdone_chat 200 static int conninitdone_chatnav 201 static int gaim_parse_msgerr 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 *, ...); 202 210 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); 203 211 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); 204 static int gaim_parse_locerr 205 static int gaim_icbm_param_info 206 static int gaim_parse_genericerr 207 static int gaim_selfinfo 208 static int gaim_offlinemsg 209 static int gaim_offlinemsgdone 210 static int gaim_ssi_parserights 211 static int gaim_ssi_parselist 212 static int gaim_ssi_parseack 213 static int gaim_parsemtn 214 static int gaim_icqinfo 215 static int gaim_parseaiminfo 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 *, ...); 216 224 217 225 static char *msgerrreason[] = { … … 268 276 269 277 static gboolean oscar_callback(gpointer data, gint source, 270 b_input_condition condition) { 271 aim_conn_t *conn = (aim_conn_t *)data; 278 b_input_condition condition) 279 { 280 aim_conn_t *conn = (aim_conn_t *) data; 272 281 aim_session_t *sess = aim_conn_getsess(conn); 273 282 struct im_connection *ic = sess ? sess->aux_data : NULL; … … 278 287 return FALSE; 279 288 } 280 289 281 290 if (!g_slist_find(get_connections(), ic)) { 282 /* oh boy. this is probably bad. i guess the only thing we 291 /* oh boy. this is probably bad. i guess the only thing we 283 292 * can really do is return? */ 284 293 return FALSE; 285 294 } 286 295 287 odata = (struct oscar_data *) ic->proto_data;296 odata = (struct oscar_data *) ic->proto_data; 288 297 289 298 if (condition & B_EV_IO_READ) { 290 299 if (aim_get_command(odata->sess, conn) >= 0) { 291 300 aim_rxdispatch(odata->sess); 292 if (odata->killme) 293 imc_logout(ic, !odata->no_reconnect); 301 if (odata->killme) { 302 imc_logout(ic, !odata->no_reconnect); 303 } 294 304 } else { 295 305 if ((conn->type == AIM_CONN_TYPE_BOS) || 296 306 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { 297 307 imcb_error(ic, _("Disconnected.")); 298 308 imc_logout(ic, TRUE); … … 300 310 struct chat_connection *c = find_oscar_chat_by_conn(ic, conn); 301 311 c->conn = NULL; 302 if (c->inpa > 0) 312 if (c->inpa > 0) { 303 313 b_event_remove(c->inpa); 314 } 304 315 c->inpa = 0; 305 316 c->fd = -1; … … 307 318 imcb_error(sess->aux_data, _("You have been disconnected from chat room %s."), c->name); 308 319 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { 309 if (odata->cnpa > 0) 320 if (odata->cnpa > 0) { 310 321 b_event_remove(odata->cnpa); 322 } 311 323 odata->cnpa = 0; 312 324 while (odata->create_rooms) { … … 314 326 g_free(cr->name); 315 327 odata->create_rooms = 316 328 g_slist_remove(odata->create_rooms, cr); 317 329 g_free(cr); 318 330 imcb_error(sess->aux_data, _("Chat is currently unavailable")); … … 320 332 aim_conn_kill(odata->sess, &conn); 321 333 } else if (conn->type == AIM_CONN_TYPE_AUTH) { 322 if (odata->paspa > 0) 334 if (odata->paspa > 0) { 323 335 b_event_remove(odata->paspa); 336 } 324 337 odata->paspa = 0; 325 338 aim_conn_kill(odata->sess, &conn); … … 332 345 return FALSE; 333 346 } 334 347 335 348 return TRUE; 336 349 } … … 360 373 aim_conn_completeconnect(sess, conn); 361 374 ic->inpa = b_input_add(conn->fd, B_EV_IO_READ, 362 363 375 oscar_callback, conn); 376 364 377 return FALSE; 365 378 } … … 369 382 set_t *s; 370 383 gboolean icq = g_ascii_isdigit(acc->user[0]); 371 384 372 385 if (icq) { 373 386 set_add(&acc->set, "ignore_auth_requests", "false", set_eval_bool, acc); 374 387 set_add(&acc->set, "old_icq_auth", "false", set_eval_bool, acc); 375 388 } 376 389 377 390 s = set_add(&acc->set, "server", 378 391 icq ? AIM_DEFAULT_LOGIN_SERVER_ICQ 379 392 : AIM_DEFAULT_LOGIN_SERVER_AIM, set_eval_account, acc); 380 393 s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 381 394 382 395 if (icq) { 383 396 s = set_add(&acc->set, "web_aware", "false", set_eval_bool, acc); 384 397 s->flags |= ACC_SET_OFFLINE_ONLY; 385 398 } 386 399 387 400 acc->flags |= ACC_FLAG_AWAY_MESSAGE; 388 401 } 389 402 390 static void oscar_login(account_t *acc) { 403 static void oscar_login(account_t *acc) 404 { 391 405 aim_session_t *sess; 392 406 aim_conn_t *conn; … … 394 408 struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); 395 409 396 if (g_ascii_isdigit(acc->user[0])) 410 if (g_ascii_isdigit(acc->user[0])) { 397 411 odata->icq = TRUE; 398 else412 } else { 399 413 ic->flags |= OPT_DOES_HTML; 414 } 400 415 401 416 sess = g_new0(aim_session_t, 1); … … 415 430 return; 416 431 } 417 432 418 433 imcb_log(ic, _("Signon: %s"), ic->acc->user); 419 434 … … 432 447 } 433 448 434 static void oscar_logout(struct im_connection *ic) { 435 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 436 449 static void oscar_logout(struct im_connection *ic) 450 { 451 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 452 437 453 while (odata->oscar_chats) { 438 454 struct chat_connection *n = odata->oscar_chats->data; 439 if (n->inpa > 0) 455 if (n->inpa > 0) { 440 456 b_event_remove(n->inpa); 457 } 441 458 g_free(n->name); 442 459 g_free(n->show); … … 450 467 g_free(cr); 451 468 } 452 if (odata->ips) 469 if (odata->ips) { 453 470 g_hash_table_destroy(odata->ips); 454 if (odata->email) 471 } 472 if (odata->email) { 455 473 g_free(odata->email); 456 if (odata->newp) 474 } 475 if (odata->newp) { 457 476 g_free(odata->newp); 458 if (odata->oldp) 477 } 478 if (odata->oldp) { 459 479 g_free(odata->oldp); 460 if (ic->inpa > 0) 480 } 481 if (ic->inpa > 0) { 461 482 b_event_remove(ic->inpa); 462 if (odata->cnpa > 0) 483 } 484 if (odata->cnpa > 0) { 463 485 b_event_remove(odata->cnpa); 464 if (odata->paspa > 0) 486 } 487 if (odata->paspa > 0) { 465 488 b_event_remove(odata->paspa); 489 } 466 490 aim_session_kill(odata->sess); 467 491 g_free(odata->sess); … … 471 495 } 472 496 473 static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) { 497 static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) 498 { 474 499 struct im_connection *ic = data; 475 500 struct oscar_data *odata; … … 494 519 aim_conn_completeconnect(sess, bosconn); 495 520 ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ, 496 521 oscar_callback, bosconn); 497 522 imcb_log(ic, _("Connection established, cookie sent")); 498 523 499 524 return FALSE; 500 525 } 501 526 502 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { 527 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) 528 { 503 529 va_list ap; 504 530 struct aim_authresp_info *info; … … 507 533 508 534 struct im_connection *ic = sess->aux_data; 509 struct oscar_data *od = ic->proto_data; 535 struct oscar_data *od = ic->proto_data; 536 510 537 port = AIM_LOGIN_PORT; 511 538 … … 521 548 { 522 549 int max = od->icq ? 8 : 16; 523 if (strlen(ic->acc->pass) > max) 550 if (strlen(ic->acc->pass) > max) { 524 551 imcb_log(ic, "Note that the maximum password " 525 552 "length supported by this protocol is " 526 553 "%d characters, try logging in using " 527 554 "a shorter password.", max); 555 } 528 556 } 529 557 // plugin_event(event_error, (void *)980, 0, 0, 0); … … 536 564 /* connecting too frequently */ 537 565 od->no_reconnect = TRUE; 538 imcb_error(ic, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); 566 imcb_error(ic, 567 _( 568 "You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); 539 569 break; 540 570 case 0x1c: … … 589 619 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_parse_logout, 0); 590 620 591 ((struct oscar_data *) ic->proto_data)->conn = bosconn;592 for (i = 0; i < (int) strlen(info->bosip); i++) {621 ((struct oscar_data *) ic->proto_data)->conn = bosconn; 622 for (i = 0; i < (int) strlen(info->bosip); i++) { 593 623 if (info->bosip[i] == ':') { 594 port = atoi(&(info->bosip[i +1]));624 port = atoi(&(info->bosip[i + 1])); 595 625 break; 596 626 } … … 614 644 #define AIM_MAX_FILE_SIZE 98304 615 645 616 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { 646 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) 647 { 617 648 #if 0 618 struct client_info_s info = { "gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b};649 struct client_info_s info = { "gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b }; 619 650 #else 620 651 struct client_info_s info = AIM_CLIENTINFO_KNOWNGOOD; … … 633 664 } 634 665 635 static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) { 666 static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) 667 { 636 668 struct im_connection *ic = sess->aux_data; 637 669 struct oscar_data *odata = ic->proto_data; … … 642 674 code = va_arg(ap, int); 643 675 va_end(ap); 644 645 imcb_error( 646 647 "unknown reason");648 676 677 imcb_error(ic, "Connection aborted by server: %s", code == 1 ? 678 "someone else logged in with your account" : 679 "unknown reason"); 680 649 681 /* Tell BitlBee to disable auto_reconnect if code == 1, since that 650 682 means a concurrent login somewhere else. */ 651 683 odata->no_reconnect = code == 1; 652 684 653 685 /* DO NOT log out here! Just tell the callback to do it. */ 654 686 odata->killme = TRUE; … … 657 689 } 658 690 659 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { 691 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) 692 { 660 693 struct im_connection *ic = sess->aux_data; 661 694 struct chat_connection *chatcon; … … 673 706 chatcon = find_oscar_chat_by_conn(ic, fr->conn); 674 707 chatcon->id = id; 675 708 676 709 c = bee_chat_by_title(ic->bee, ic, chatcon->show); 677 if (c && !c->data) 710 if (c && !c->data) { 678 711 chatcon->cnv = c; 679 else712 } else { 680 713 chatcon->cnv = imcb_chat_new(ic, chatcon->show); 714 } 681 715 chatcon->cnv->data = chatcon; 682 716 … … 684 718 } 685 719 686 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { 720 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) 721 { 687 722 688 723 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_ERROR, gaim_parse_genericerr, 0); … … 696 731 } 697 732 698 static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) { 733 static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) 734 { 699 735 struct im_connection *ic = data; 700 736 struct oscar_data *odata; … … 718 754 aim_conn_completeconnect(sess, tstconn); 719 755 odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ, 720 721 756 oscar_callback, tstconn); 757 722 758 return FALSE; 723 759 } … … 746 782 aim_conn_completeconnect(sess, tstconn); 747 783 odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ, 748 749 784 oscar_callback, tstconn); 785 750 786 return FALSE; 751 787 } … … 781 817 aim_conn_completeconnect(sess, ccon->conn); 782 818 ccon->inpa = b_input_add(tstconn->fd, 783 784 819 B_EV_IO_READ, 820 oscar_callback, tstconn); 785 821 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); 786 822 787 823 return FALSE; 788 824 } 789 825 790 826 /* Hrmph. I don't know how to make this look better. --mid */ 791 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { 827 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) 828 { 792 829 va_list ap; 793 830 struct aim_redirect_data *redir; … … 803 840 804 841 port = AIM_LOGIN_PORT; 805 for (i = 0; i < (int) strlen(redir->ip); i++) {842 for (i = 0; i < (int) strlen(redir->ip); i++) { 806 843 if (redir->ip[i] == ':') { 807 port = atoi(&(redir->ip[i +1]));844 port = atoi(&(redir->ip[i + 1])); 808 845 break; 809 846 } … … 811 848 host = g_strndup(redir->ip, i); 812 849 813 switch (redir->group) {850 switch (redir->group) { 814 851 case 0x7: /* Authorizer */ 815 852 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); … … 818 855 return 1; 819 856 } 820 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); 857 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 858 0); 821 859 // aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); 822 860 // aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); … … 838 876 return 1; 839 877 } 840 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); 878 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, 879 conninitdone_chatnav, 0); 841 880 842 881 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; … … 850 889 break; 851 890 case 0xe: /* Chat */ 852 891 { 853 892 struct chat_connection *ccon; 854 893 … … 859 898 } 860 899 861 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); 900 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 901 0); 862 902 863 903 ccon = g_new0(struct chat_connection, 1); … … 869 909 ccon->instance = redir->chat.instance; 870 910 ccon->show = extract_name(redir->chat.room); 871 911 872 912 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; 873 913 ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); … … 881 921 } 882 922 aim_sendcookie(sess, tstconn, redir->cookie); 883 884 923 } 924 break; 885 925 default: /* huh? */ 886 926 break; … … 891 931 } 892 932 893 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { 933 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) 934 { 894 935 struct im_connection *ic = sess->aux_data; 895 936 struct oscar_data *od = ic->proto_data; … … 900 941 901 942 va_list ap; 943 902 944 va_start(ap, fr); 903 945 info = va_arg(ap, aim_userinfo_t *); … … 905 947 906 948 if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) { 907 if (info->flags & AIM_FLAG_AWAY) 949 if (info->flags & AIM_FLAG_AWAY) { 908 950 flags |= OPT_AWAY; 909 } 910 951 } 952 } 953 911 954 /* Maybe this should be done just for AIM contacts, not sure. */ 912 if (info->flags & AIM_FLAG_WIRELESS) 955 if (info->flags & AIM_FLAG_WIRELESS) { 913 956 flags |= OPT_MOBILE; 914 957 } 958 915 959 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { 916 960 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && 917 961 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { 918 962 flags |= OPT_AWAY; 919 963 } 920 921 if ( info->icqinfo.status & AIM_ICQ_STATE_DND )964 965 if (info->icqinfo.status & AIM_ICQ_STATE_DND) { 922 966 state_string = "Do Not Disturb"; 923 else if( info->icqinfo.status & AIM_ICQ_STATE_OUT )967 } else if (info->icqinfo.status & AIM_ICQ_STATE_OUT) { 924 968 state_string = "Not Available"; 925 else if( info->icqinfo.status & AIM_ICQ_STATE_BUSY )969 } else if (info->icqinfo.status & AIM_ICQ_STATE_BUSY) { 926 970 state_string = "Occupied"; 927 else if( info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE )971 } else if (info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE) { 928 972 state_string = "Invisible"; 973 } 929 974 } 930 975 931 976 if (info->present & AIM_USERINFO_PRESENT_IDLE) { 932 977 time(&time_idle); 933 time_idle -= info->idletime *60;934 } 935 936 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) 978 time_idle -= info->idletime * 60; 979 } 980 981 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) { 937 982 signon = time(NULL) - info->sessionlen; 983 } 938 984 939 985 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) { 940 986 uint32_t *uin = g_new0(uint32_t, 1); 941 942 if (od->ips == NULL) 987 988 if (od->ips == NULL) { 943 989 od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL); 944 945 if (sscanf(info->sn, "%d", uin) == 1) 990 } 991 992 if (sscanf(info->sn, "%d", uin) == 1) { 946 993 g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr); 994 } 947 995 } 948 996 … … 955 1003 } 956 1004 957 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { 1005 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) 1006 { 958 1007 aim_userinfo_t *info; 959 1008 va_list ap; … … 964 1013 va_end(ap); 965 1014 966 imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL ); 967 968 return 1; 969 } 970 971 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { 1015 imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL); 1016 1017 return 1; 1018 } 1019 1020 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, 1021 struct aim_incomingim_ch1_args *args) 1022 { 972 1023 char *tmp = g_malloc(BUF_LONG + 1); 973 1024 struct im_connection *ic = sess->aux_data; 974 1025 int flags = 0; 975 976 if (args->icbmflags & AIM_IMFLAGS_AWAY) 1026 1027 if (args->icbmflags & AIM_IMFLAGS_AWAY) { 977 1028 flags |= OPT_AWAY; 978 1029 } 1030 979 1031 if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) { 980 1032 char *src; 981 982 if (args->icbmflags & AIM_IMFLAGS_UNICODE) 1033 1034 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { 983 1035 src = "UCS-2BE"; 984 else1036 } else { 985 1037 src = "ISO8859-1"; 986 1038 } 1039 987 1040 /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */ 988 1041 if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) { … … 990 1043 } else if (args->icbmflags & AIM_IMFLAGS_UNICODE) { 991 1044 int i; 992 1045 993 1046 for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) { 994 1047 unsigned short uni; 995 996 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i +1] & 0xff);997 1048 1049 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i + 1] & 0xff); 1050 998 1051 if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ 999 g_snprintf(tmp +strlen(tmp), BUF_LONG-strlen(tmp), "%c", uni);1052 g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "%c", uni); 1000 1053 } else { /* something else, do UNICODE entity */ 1001 g_snprintf(tmp +strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni);1054 g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "&#%04x;", uni); 1002 1055 } 1003 1056 } … … 1009 1062 } else { 1010 1063 aim_mpmsg_section_t *part; 1011 1064 1012 1065 *tmp = 0; 1013 1066 for (part = args->mpmsg.parts; part; part = part->next) { 1014 1067 if (part->data) { 1015 g_strlcat(tmp, (char *) part->data, BUF_LONG);1068 g_strlcat(tmp, (char *) part->data, BUF_LONG); 1016 1069 g_strlcat(tmp, "\n", BUF_LONG); 1017 1070 } 1018 1071 } 1019 1072 } 1020 1073 1021 1074 strip_linefeed(tmp); 1022 1075 imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0); 1023 1076 g_free(tmp); 1024 1077 1025 1078 return 1; 1026 1079 } … … 1028 1081 void oscar_accept_chat(void *data); 1029 1082 void oscar_reject_chat(void *data); 1030 1031 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1083 1084 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, 1085 struct aim_incomingim_ch2_args *args) 1086 { 1032 1087 struct im_connection *ic = sess->aux_data; 1033 1088 1034 if (args->status != AIM_RENDEZVOUS_PROPOSE) 1089 if (args->status != AIM_RENDEZVOUS_PROPOSE) { 1035 1090 return 1; 1091 } 1036 1092 1037 1093 if (args->reqclass & AIM_CAPS_CHAT) { … … 1051 1107 inv->exchange = *exch; 1052 1108 inv->name = g_strdup(name); 1053 1109 1054 1110 imcb_ask(ic, txt, inv, oscar_accept_chat, oscar_reject_chat); 1055 1056 if (name) 1111 1112 if (name) { 1057 1113 g_free(name); 1114 } 1058 1115 } else if (args->reqclass & AIM_CAPS_ICQRTF) { 1059 1116 // TODO: constify 1060 char text[strlen(args->info.rtfmsg.rtfmsg) +1];1117 char text[strlen(args->info.rtfmsg.rtfmsg) + 1]; 1061 1118 strncpy(text, args->info.rtfmsg.rtfmsg, sizeof(text)); 1062 1119 imcb_buddy_msg(ic, normalize(userinfo->sn), text, 0, 0); … … 1066 1123 } 1067 1124 1068 static void gaim_icq_authgrant(void *data_) { 1125 static void gaim_icq_authgrant(void *data_) 1126 { 1069 1127 struct icq_auth *data = data_; 1070 1128 char *uin; 1071 struct oscar_data *od = (struct oscar_data *) data->ic->proto_data;1072 1129 struct oscar_data *od = (struct oscar_data *) data->ic->proto_data; 1130 1073 1131 uin = g_strdup_printf("%u", data->uin); 1074 1132 aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); … … 1076 1134 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); 1077 1135 imcb_ask_add(data->ic, uin, NULL); 1078 1136 1079 1137 g_free(uin); 1080 1138 g_free(data); 1081 1139 } 1082 1140 1083 static void gaim_icq_authdeny(void *data_) { 1141 static void gaim_icq_authdeny(void *data_) 1142 { 1084 1143 struct icq_auth *data = data_; 1085 1144 char *uin, *message; 1086 struct oscar_data *od = (struct oscar_data *) data->ic->proto_data;1087 1145 struct oscar_data *od = (struct oscar_data *) data->ic->proto_data; 1146 1088 1147 uin = g_strdup_printf("%u", data->uin); 1089 1148 message = g_strdup_printf("No reason given."); … … 1091 1150 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHDENIED, message); 1092 1151 g_free(message); 1093 1152 1094 1153 g_free(uin); 1095 1154 g_free(data); … … 1099 1158 * For when other people ask you for authorization 1100 1159 */ 1101 static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) { 1160 static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) 1161 { 1102 1162 struct icq_auth *data; 1103 1163 char *reason = NULL; 1104 1164 char *dialog_msg; 1105 1165 1106 if (set_getbool(&ic->acc->set, "ignore_auth_requests")) 1166 if (set_getbool(&ic->acc->set, "ignore_auth_requests")) { 1107 1167 return; 1108 1168 } 1169 1109 1170 data = g_new(struct icq_auth, 1); 1110 1171 1111 if (strlen(msg) > 6) 1172 if (strlen(msg) > 6) { 1112 1173 reason = msg + 6; 1113 1114 dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given."); 1174 } 1175 1176 dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", 1177 uin, reason ? reason : "No reason given."); 1115 1178 data->ic = ic; 1116 1179 data->uin = uin; … … 1119 1182 } 1120 1183 1121 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args) { 1184 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, 1185 struct aim_incomingim_ch4_args *args) 1186 { 1122 1187 struct im_connection *ic = sess->aux_data; 1123 1188 1124 1189 switch (args->type) { 1125 case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */ 1126 char *uin, *message; 1127 uin = g_strdup_printf("%u", args->uin); 1128 message = g_strdup(args->msg); 1129 strip_linefeed(message); 1130 imcb_buddy_msg(ic, normalize(uin), message, 0, 0); 1131 g_free(uin); 1132 g_free(message); 1133 } break; 1134 1135 case 0x0004: { /* Someone sent you a URL */ 1136 char *uin, *message; 1137 char **m; 1138 1139 uin = g_strdup_printf("%u", args->uin); 1140 m = g_strsplit(args->msg, "\376", 2); 1141 1142 if ((strlen(m[0]) != 0)) { 1143 message = g_strjoinv(" -- ", m); 1144 } else { 1145 message = m[1]; 1146 } 1147 1148 strip_linefeed(message); 1149 imcb_buddy_msg(ic, normalize(uin), message, 0, 0); 1150 g_free(uin); 1151 g_free(m); 1152 g_free(message); 1153 } break; 1154 1155 case 0x0006: { /* Someone requested authorization */ 1156 gaim_icq_authask(ic, args->uin, args->msg); 1157 } break; 1158 1159 case 0x0007: { /* Someone has denied you authorization */ 1160 imcb_log(sess->aux_data, "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin, args->msg ? args->msg : _("No reason given.") ); 1161 } break; 1162 1163 case 0x0008: { /* Someone has granted you authorization */ 1164 imcb_log(sess->aux_data, "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin, args->msg ? args->msg : _("No reason given.") ); 1165 } break; 1166 1167 case 0x0012: { 1168 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ 1169 } break; 1170 1171 default: {; 1172 } break; 1173 } 1174 1175 return 1; 1176 } 1177 1178 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { 1190 case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */ 1191 char *uin, *message; 1192 uin = g_strdup_printf("%u", args->uin); 1193 message = g_strdup(args->msg); 1194 strip_linefeed(message); 1195 imcb_buddy_msg(ic, normalize(uin), message, 0, 0); 1196 g_free(uin); 1197 g_free(message); 1198 } break; 1199 1200 case 0x0004: { /* Someone sent you a URL */ 1201 char *uin, *message; 1202 char **m; 1203 1204 uin = g_strdup_printf("%u", args->uin); 1205 m = g_strsplit(args->msg, "\376", 2); 1206 1207 if ((strlen(m[0]) != 0)) { 1208 message = g_strjoinv(" -- ", m); 1209 } else { 1210 message = m[1]; 1211 } 1212 1213 strip_linefeed(message); 1214 imcb_buddy_msg(ic, normalize(uin), message, 0, 0); 1215 g_free(uin); 1216 g_free(m); 1217 g_free(message); 1218 } break; 1219 1220 case 0x0006: { /* Someone requested authorization */ 1221 gaim_icq_authask(ic, args->uin, args->msg); 1222 } break; 1223 1224 case 0x0007: { /* Someone has denied you authorization */ 1225 imcb_log(sess->aux_data, 1226 "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin, 1227 args->msg ? args->msg : _("No reason given.")); 1228 } break; 1229 1230 case 0x0008: { /* Someone has granted you authorization */ 1231 imcb_log(sess->aux_data, 1232 "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin, 1233 args->msg ? args->msg : _("No reason given.")); 1234 } break; 1235 1236 case 0x0012: { 1237 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ 1238 } break; 1239 1240 default: {; } break; 1241 } 1242 1243 return 1; 1244 } 1245 1246 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) 1247 { 1179 1248 int channel, ret = 0; 1180 1249 aim_userinfo_t *userinfo; … … 1186 1255 1187 1256 switch (channel) { 1188 case 1: { /* standard message */ 1189 struct aim_incomingim_ch1_args *args; 1190 args = va_arg(ap, struct aim_incomingim_ch1_args *); 1191 ret = incomingim_chan1(sess, fr->conn, userinfo, args); 1192 } break; 1193 1194 case 2: { /* rendevous */ 1195 struct aim_incomingim_ch2_args *args; 1196 args = va_arg(ap, struct aim_incomingim_ch2_args *); 1197 ret = incomingim_chan2(sess, fr->conn, userinfo, args); 1198 } break; 1199 1200 case 4: { /* ICQ */ 1201 struct aim_incomingim_ch4_args *args; 1202 args = va_arg(ap, struct aim_incomingim_ch4_args *); 1203 ret = incomingim_chan4(sess, fr->conn, userinfo, args); 1204 } break; 1205 1206 default: {; 1207 } break; 1257 case 1: { /* standard message */ 1258 struct aim_incomingim_ch1_args *args; 1259 args = va_arg(ap, struct aim_incomingim_ch1_args *); 1260 ret = incomingim_chan1(sess, fr->conn, userinfo, args); 1261 } break; 1262 1263 case 2: { /* rendevous */ 1264 struct aim_incomingim_ch2_args *args; 1265 args = va_arg(ap, struct aim_incomingim_ch2_args *); 1266 ret = incomingim_chan2(sess, fr->conn, userinfo, args); 1267 } break; 1268 1269 case 4: { /* ICQ */ 1270 struct aim_incomingim_ch4_args *args; 1271 args = va_arg(ap, struct aim_incomingim_ch4_args *); 1272 ret = incomingim_chan4(sess, fr->conn, userinfo, args); 1273 } break; 1274 1275 default: {; } break; 1208 1276 } 1209 1277 … … 1213 1281 } 1214 1282 1215 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { 1283 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) 1284 { 1216 1285 va_list ap; 1217 1286 guint16 nummissed, reason; … … 1221 1290 va_arg(ap, unsigned int); /* chan */ 1222 1291 userinfo = va_arg(ap, aim_userinfo_t *); 1223 nummissed = (guint16) va_arg(ap, unsigned int);1224 reason = (guint16) va_arg(ap, unsigned int);1292 nummissed = (guint16) va_arg(ap, unsigned int); 1293 reason = (guint16) va_arg(ap, unsigned int); 1225 1294 va_end(ap); 1226 1295 1227 switch(reason) { 1228 case 0: 1229 /* Invalid (0) */ 1230 imcb_error(sess->aux_data, 1231 nummissed == 1 ? 1232 _("You missed %d message from %s because it was invalid.") : 1233 _("You missed %d messages from %s because they were invalid."), 1234 nummissed, 1235 userinfo->sn); 1236 break; 1237 case 1: 1238 /* Message too large */ 1239 imcb_error(sess->aux_data, 1240 nummissed == 1 ? 1241 _("You missed %d message from %s because it was too large.") : 1242 _("You missed %d messages from %s because they were too large."), 1243 nummissed, 1244 userinfo->sn); 1245 break; 1246 case 2: 1247 /* Rate exceeded */ 1248 imcb_error(sess->aux_data, 1249 nummissed == 1 ? 1250 _("You missed %d message from %s because the rate limit has been exceeded.") : 1251 _("You missed %d messages from %s because the rate limit has been exceeded."), 1252 nummissed, 1253 userinfo->sn); 1254 break; 1255 case 3: 1256 /* Evil Sender */ 1257 imcb_error(sess->aux_data, 1258 nummissed == 1 ? 1259 _("You missed %d message from %s because it was too evil.") : 1260 _("You missed %d messages from %s because they are too evil."), 1261 nummissed, 1262 userinfo->sn); 1263 break; 1264 case 4: 1265 /* Evil Receiver */ 1266 imcb_error(sess->aux_data, 1267 nummissed == 1 ? 1268 _("You missed %d message from %s because you are too evil.") : 1269 _("You missed %d messages from %s because you are too evil."), 1270 nummissed, 1271 userinfo->sn); 1272 break; 1273 default: 1274 imcb_error(sess->aux_data, 1275 nummissed == 1 ? 1276 _("You missed %d message from %s for unknown reasons.") : 1277 _("You missed %d messages from %s for unknown reasons."), 1278 nummissed, 1279 userinfo->sn); 1280 break; 1281 } 1282 1283 return 1; 1284 } 1285 1286 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { 1296 switch (reason) { 1297 case 0: 1298 /* Invalid (0) */ 1299 imcb_error(sess->aux_data, 1300 nummissed == 1 ? 1301 _("You missed %d message from %s because it was invalid.") : 1302 _("You missed %d messages from %s because they were invalid."), 1303 nummissed, 1304 userinfo->sn); 1305 break; 1306 case 1: 1307 /* Message too large */ 1308 imcb_error(sess->aux_data, 1309 nummissed == 1 ? 1310 _("You missed %d message from %s because it was too large.") : 1311 _("You missed %d messages from %s because they were too large."), 1312 nummissed, 1313 userinfo->sn); 1314 break; 1315 case 2: 1316 /* Rate exceeded */ 1317 imcb_error(sess->aux_data, 1318 nummissed == 1 ? 1319 _("You missed %d message from %s because the rate limit has been exceeded.") : 1320 _("You missed %d messages from %s because the rate limit has been exceeded."), 1321 nummissed, 1322 userinfo->sn); 1323 break; 1324 case 3: 1325 /* Evil Sender */ 1326 imcb_error(sess->aux_data, 1327 nummissed == 1 ? 1328 _("You missed %d message from %s because it was too evil.") : 1329 _("You missed %d messages from %s because they are too evil."), 1330 nummissed, 1331 userinfo->sn); 1332 break; 1333 case 4: 1334 /* Evil Receiver */ 1335 imcb_error(sess->aux_data, 1336 nummissed == 1 ? 1337 _("You missed %d message from %s because you are too evil.") : 1338 _("You missed %d messages from %s because you are too evil."), 1339 nummissed, 1340 userinfo->sn); 1341 break; 1342 default: 1343 imcb_error(sess->aux_data, 1344 nummissed == 1 ? 1345 _("You missed %d message from %s for unknown reasons.") : 1346 _("You missed %d messages from %s for unknown reasons."), 1347 nummissed, 1348 userinfo->sn); 1349 break; 1350 } 1351 1352 return 1; 1353 } 1354 1355 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) 1356 { 1287 1357 va_list ap; 1288 1358 guint16 reason; 1289 1359 1290 1360 va_start(ap, fr); 1291 reason = (guint16) va_arg(ap, unsigned int);1361 reason = (guint16) va_arg(ap, unsigned int); 1292 1362 va_end(ap); 1293 1363 1294 1364 imcb_error(sess->aux_data, _("SNAC threw error: %s"), 1295 reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error"); 1296 1297 return 1; 1298 } 1299 1300 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { 1365 reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error"); 1366 1367 return 1; 1368 } 1369 1370 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) 1371 { 1301 1372 va_list ap; 1302 1373 char *destn; … … 1304 1375 1305 1376 va_start(ap, fr); 1306 reason = (guint16) va_arg(ap, unsigned int);1377 reason = (guint16) va_arg(ap, unsigned int); 1307 1378 destn = va_arg(ap, char *); 1308 1379 va_end(ap); 1309 1380 1310 1381 imcb_error(sess->aux_data, _("Your message to %s did not get sent: %s"), destn, 1311 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); 1312 1313 return 1; 1314 } 1315 1316 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { 1382 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); 1383 1384 return 1; 1385 } 1386 1387 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) 1388 { 1317 1389 va_list ap; 1318 1390 char *destn; … … 1320 1392 1321 1393 va_start(ap, fr); 1322 reason = (guint16) va_arg(ap, unsigned int);1394 reason = (guint16) va_arg(ap, unsigned int); 1323 1395 destn = va_arg(ap, char *); 1324 1396 va_end(ap); 1325 1397 1326 1398 imcb_error(sess->aux_data, _("User information for %s unavailable: %s"), destn, 1327 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); 1328 1329 return 1; 1330 } 1331 1332 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { 1399 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); 1400 1401 return 1; 1402 } 1403 1404 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) 1405 { 1333 1406 guint16 id; 1334 1407 va_list ap; 1335 1408 1336 1409 va_start(ap, fr); 1337 id = (guint16) va_arg(ap, unsigned int);1410 id = (guint16) va_arg(ap, unsigned int); 1338 1411 va_arg(ap, char *); /* msg */ 1339 1412 va_end(ap); 1340 1413 1341 if (id < 4) 1414 if (id < 4) { 1342 1415 imcb_error(sess->aux_data, _("Your connection may be lost.")); 1343 1344 return 1; 1345 } 1346 1347 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { 1416 } 1417 1418 return 1; 1419 } 1420 1421 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) 1422 { 1348 1423 va_list ap; 1349 1424 guint16 type; 1350 1425 struct im_connection *ic = sess->aux_data; 1351 struct oscar_data *odata = (struct oscar_data *) ic->proto_data;1426 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 1352 1427 1353 1428 va_start(ap, fr); 1354 type = (guint16)va_arg(ap, unsigned int); 1355 1356 switch(type) { 1357 case 0x0002: { 1358 va_arg(ap, unsigned int); /* maxrooms */ 1359 va_arg(ap, int); /* exchangecount */ 1360 va_arg(ap, struct aim_chat_exchangeinfo *); /* exchanges */ 1361 va_end(ap); 1362 1363 while (odata->create_rooms) { 1364 struct create_room *cr = odata->create_rooms->data; 1365 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); 1366 g_free(cr->name); 1367 odata->create_rooms = g_slist_remove(odata->create_rooms, cr); 1368 g_free(cr); 1369 } 1370 } 1371 break; 1372 case 0x0008: { 1373 char *ck; 1374 guint16 instance, exchange; 1375 1376 va_arg(ap, char *); /* fqcn */ 1377 instance = (guint16)va_arg(ap, unsigned int); 1378 exchange = (guint16)va_arg(ap, unsigned int); 1379 va_arg(ap, unsigned int); /* flags */ 1380 va_arg(ap, guint32); /* createtime */ 1381 va_arg(ap, unsigned int); /* maxmsglen */ 1382 va_arg(ap, unsigned int); /* maxoccupancy */ 1383 va_arg(ap, int); /* createperms */ 1384 va_arg(ap, unsigned int); /* unknown */ 1385 va_arg(ap, char *); /* name */ 1386 ck = va_arg(ap, char *); 1387 va_end(ap); 1388 1389 aim_chat_join(odata->sess, odata->conn, exchange, ck, instance); 1390 } 1391 break; 1392 default: 1393 va_end(ap); 1394 break; 1395 } 1396 return 1; 1397 } 1398 1399 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { 1429 type = (guint16) va_arg(ap, unsigned int); 1430 1431 switch (type) { 1432 case 0x0002: { 1433 va_arg(ap, unsigned int); /* maxrooms */ 1434 va_arg(ap, int); /* exchangecount */ 1435 va_arg(ap, struct aim_chat_exchangeinfo *); /* exchanges */ 1436 va_end(ap); 1437 1438 while (odata->create_rooms) { 1439 struct create_room *cr = odata->create_rooms->data; 1440 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); 1441 g_free(cr->name); 1442 odata->create_rooms = g_slist_remove(odata->create_rooms, cr); 1443 g_free(cr); 1444 } 1445 } 1446 break; 1447 case 0x0008: { 1448 char *ck; 1449 guint16 instance, exchange; 1450 1451 va_arg(ap, char *); /* fqcn */ 1452 instance = (guint16) va_arg(ap, unsigned int); 1453 exchange = (guint16) va_arg(ap, unsigned int); 1454 va_arg(ap, unsigned int); /* flags */ 1455 va_arg(ap, guint32); /* createtime */ 1456 va_arg(ap, unsigned int); /* maxmsglen */ 1457 va_arg(ap, unsigned int); /* maxoccupancy */ 1458 va_arg(ap, int); /* createperms */ 1459 va_arg(ap, unsigned int); /* unknown */ 1460 va_arg(ap, char *); /* name */ 1461 ck = va_arg(ap, char *); 1462 va_end(ap); 1463 1464 aim_chat_join(odata->sess, odata->conn, exchange, ck, instance); 1465 } 1466 break; 1467 default: 1468 va_end(ap); 1469 break; 1470 } 1471 return 1; 1472 } 1473 1474 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) 1475 { 1400 1476 va_list ap; 1401 1477 int count, i; … … 1411 1487 1412 1488 c = find_oscar_chat_by_conn(g, fr->conn); 1413 if (!c) 1489 if (!c) { 1414 1490 return 1; 1415 1416 for (i = 0; i < count; i++) 1491 } 1492 1493 for (i = 0; i < count; i++) { 1417 1494 imcb_chat_add_buddy(c->cnv, normalize(info[i].sn)); 1418 1419 return 1; 1420 } 1421 1422 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { 1495 } 1496 1497 return 1; 1498 } 1499 1500 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) 1501 { 1423 1502 va_list ap; 1424 1503 int count, i; … … 1434 1513 1435 1514 c = find_oscar_chat_by_conn(g, fr->conn); 1436 if (!c) 1515 if (!c) { 1437 1516 return 1; 1438 1439 for (i = 0; i < count; i++) 1517 } 1518 1519 for (i = 0; i < count; i++) { 1440 1520 imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL); 1441 1442 return 1; 1443 } 1444 1445 static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { 1521 } 1522 1523 return 1; 1524 } 1525 1526 static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) 1527 { 1446 1528 va_list ap; 1447 1529 guint16 maxmsglen, maxvisiblemsglen; … … 1457 1539 va_arg(ap, int); /* unknown_c9 */ 1458 1540 va_arg(ap, unsigned long); /* creationtime */ 1459 maxmsglen = (guint16) va_arg(ap, int);1541 maxmsglen = (guint16) va_arg(ap, int); 1460 1542 va_arg(ap, int); /* unknown_d2 */ 1461 1543 va_arg(ap, int); /* unknown_d5 */ 1462 maxvisiblemsglen = (guint16) va_arg(ap, int);1544 maxvisiblemsglen = (guint16) va_arg(ap, int); 1463 1545 va_end(ap); 1464 1546 … … 1469 1551 } 1470 1552 1471 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { 1553 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) 1554 { 1472 1555 va_list ap; 1473 1556 aim_userinfo_t *info; … … 1489 1572 } 1490 1573 1491 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) { 1574 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) 1575 { 1492 1576 #if 0 1493 1577 static const char *codes[5] = { 1494 1578 "invalid", 1495 1496 1497 1498 1579 "change", 1580 "warning", 1581 "limit", 1582 "limit cleared", 1499 1583 }; 1500 1584 #endif … … 1503 1587 guint32 windowsize, clear, currentavg; 1504 1588 1505 va_start(ap, fr); 1506 code = (guint16) va_arg(ap, unsigned int);1589 va_start(ap, fr); 1590 code = (guint16) va_arg(ap, unsigned int); 1507 1591 va_arg(ap, unsigned int); /* rateclass */ 1508 windowsize = (guint32) va_arg(ap, unsigned long);1509 clear = (guint32) va_arg(ap, unsigned long);1592 windowsize = (guint32) va_arg(ap, unsigned long); 1593 clear = (guint32) va_arg(ap, unsigned long); 1510 1594 va_arg(ap, unsigned long); /* alert */ 1511 1595 va_arg(ap, unsigned long); /* limit */ 1512 1596 va_arg(ap, unsigned long); /* disconnect */ 1513 currentavg = (guint32) va_arg(ap, unsigned long);1597 currentavg = (guint32) va_arg(ap, unsigned long); 1514 1598 va_arg(ap, unsigned long); /* maxavg */ 1515 1599 va_end(ap); … … 1517 1601 /* XXX fix these values */ 1518 1602 if (code == AIM_RATE_CODE_CHANGE) { 1519 if (currentavg >= clear) 1603 if (currentavg >= clear) { 1520 1604 aim_conn_setlatency(fr->conn, 0); 1605 } 1521 1606 } else if (code == AIM_RATE_CODE_WARNING) { 1522 aim_conn_setlatency(fr->conn, windowsize /4);1607 aim_conn_setlatency(fr->conn, windowsize / 4); 1523 1608 } else if (code == AIM_RATE_CODE_LIMIT) { 1524 1609 imcb_error(sess->aux_data, _("The last message was not sent because you are over the rate limit. " 1525 1526 aim_conn_setlatency(fr->conn, windowsize /2);1610 "Please wait 10 seconds and try again.")); 1611 aim_conn_setlatency(fr->conn, windowsize / 2); 1527 1612 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { 1528 1613 aim_conn_setlatency(fr->conn, 0); … … 1532 1617 } 1533 1618 1534 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { 1535 return 1; 1536 } 1537 1538 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { 1619 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) 1620 { 1621 return 1; 1622 } 1623 1624 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) 1625 { 1539 1626 1540 1627 aim_reqpersonalinfo(sess, fr->conn); … … 1547 1634 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); 1548 1635 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | 1549 AIM_PRIVFLAGS_ALLOWMEMBERSINCE); 1550 1551 return 1; 1552 } 1553 1554 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { 1636 AIM_PRIVFLAGS_ALLOWMEMBERSINCE); 1637 1638 return 1; 1639 } 1640 1641 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) 1642 { 1555 1643 struct im_connection *ic = sess->aux_data; 1556 1644 struct oscar_data *od = ic->proto_data; … … 1589 1677 } 1590 1678 1591 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) { 1679 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) 1680 { 1592 1681 struct aim_icbmparameters *params; 1593 1682 va_list ap; … … 1612 1701 guint16 maxsiglen; 1613 1702 struct im_connection *ic = sess->aux_data; 1614 struct oscar_data *odata = (struct oscar_data *) ic->proto_data;1703 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 1615 1704 1616 1705 va_start(ap, fr); … … 1618 1707 va_end(ap); 1619 1708 1620 odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint) maxsiglen;1709 odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint) maxsiglen; 1621 1710 1622 1711 /* FIXME: It seems we're not really using this, and it broke now that … … 1624 1713 aim_bos_setprofile(sess, fr->conn, ic->user->user_info, NULL, gaim_caps); 1625 1714 */ 1626 1627 return 1; 1628 } 1629 1630 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { 1715 1716 return 1; 1717 } 1718 1719 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) 1720 { 1631 1721 va_list ap; 1632 1722 guint16 maxbuddies, maxwatchers; 1633 1723 struct im_connection *ic = sess->aux_data; 1634 struct oscar_data *odata = (struct oscar_data *) ic->proto_data;1724 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 1635 1725 1636 1726 va_start(ap, fr); 1637 maxbuddies = (guint16) va_arg(ap, unsigned int);1638 maxwatchers = (guint16) va_arg(ap, unsigned int);1727 maxbuddies = (guint16) va_arg(ap, unsigned int); 1728 maxwatchers = (guint16) va_arg(ap, unsigned int); 1639 1729 va_end(ap); 1640 1730 1641 odata->rights.maxbuddies = (guint)maxbuddies; 1642 odata->rights.maxwatchers = (guint)maxwatchers; 1643 1644 return 1; 1645 } 1646 1647 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { 1731 odata->rights.maxbuddies = (guint) maxbuddies; 1732 odata->rights.maxwatchers = (guint) maxwatchers; 1733 1734 return 1; 1735 } 1736 1737 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) 1738 { 1648 1739 guint16 maxpermits, maxdenies; 1649 1740 va_list ap; 1650 1741 struct im_connection *ic = sess->aux_data; 1651 struct oscar_data *odata = (struct oscar_data *) ic->proto_data;1742 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 1652 1743 1653 1744 va_start(ap, fr); 1654 maxpermits = (guint16) va_arg(ap, unsigned int);1655 maxdenies = (guint16) va_arg(ap, unsigned int);1745 maxpermits = (guint16) va_arg(ap, unsigned int); 1746 maxdenies = (guint16) va_arg(ap, unsigned int); 1656 1747 va_end(ap); 1657 1748 1658 odata->rights.maxpermits = (guint) maxpermits;1659 odata->rights.maxdenies = (guint) maxdenies;1749 odata->rights.maxpermits = (guint) maxpermits; 1750 odata->rights.maxdenies = (guint) maxdenies; 1660 1751 1661 1752 aim_clientready(sess, fr->conn); … … 1669 1760 } 1670 1761 1671 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { 1762 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) 1763 { 1672 1764 va_list ap; 1673 1765 struct aim_icq_offlinemsg *msg; … … 1679 1771 1680 1772 switch (msg->type) { 1681 case 0x0001: { /* Basic offline message */ 1682 char sender[32]; 1683 char *dialog_msg = g_strdup(msg->msg); 1684 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); 1685 g_snprintf(sender, sizeof(sender), "%u", msg->sender); 1686 strip_linefeed(dialog_msg); 1687 imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); 1688 g_free(dialog_msg); 1689 } break; 1690 1691 case 0x0004: { /* Someone sent you a URL */ 1692 char sender[32]; 1693 char *dialog_msg; 1694 char **m; 1695 1696 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); 1697 g_snprintf(sender, sizeof(sender), "%u", msg->sender); 1698 1699 m = g_strsplit(msg->msg, "\376", 2); 1700 1701 if ((strlen(m[0]) != 0)) { 1702 dialog_msg = g_strjoinv(" -- ", m); 1703 } else { 1704 dialog_msg = m[1]; 1705 } 1706 1707 strip_linefeed(dialog_msg); 1708 imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); 1709 g_free(dialog_msg); 1710 g_free(m); 1711 } break; 1712 1713 case 0x0006: { /* Authorization request */ 1714 gaim_icq_authask(ic, msg->sender, msg->msg); 1715 } break; 1716 1717 case 0x0007: { /* Someone has denied you authorization */ 1718 imcb_log(sess->aux_data, "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender, msg->msg ? msg->msg : _("No reason given.") ); 1719 } break; 1720 1721 case 0x0008: { /* Someone has granted you authorization */ 1722 imcb_log(sess->aux_data, "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender, msg->msg ? msg->msg : _("No reason given.") ); 1723 } break; 1724 1725 case 0x0012: { 1726 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ 1727 } break; 1728 1729 default: {; 1730 } 1773 case 0x0001: { /* Basic offline message */ 1774 char sender[32]; 1775 char *dialog_msg = g_strdup(msg->msg); 1776 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); 1777 g_snprintf(sender, sizeof(sender), "%u", msg->sender); 1778 strip_linefeed(dialog_msg); 1779 imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); 1780 g_free(dialog_msg); 1781 } break; 1782 1783 case 0x0004: { /* Someone sent you a URL */ 1784 char sender[32]; 1785 char *dialog_msg; 1786 char **m; 1787 1788 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); 1789 g_snprintf(sender, sizeof(sender), "%u", msg->sender); 1790 1791 m = g_strsplit(msg->msg, "\376", 2); 1792 1793 if ((strlen(m[0]) != 0)) { 1794 dialog_msg = g_strjoinv(" -- ", m); 1795 } else { 1796 dialog_msg = m[1]; 1797 } 1798 1799 strip_linefeed(dialog_msg); 1800 imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); 1801 g_free(dialog_msg); 1802 g_free(m); 1803 } break; 1804 1805 case 0x0006: { /* Authorization request */ 1806 gaim_icq_authask(ic, msg->sender, msg->msg); 1807 } break; 1808 1809 case 0x0007: { /* Someone has denied you authorization */ 1810 imcb_log(sess->aux_data, 1811 "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender, 1812 msg->msg ? msg->msg : _("No reason given.")); 1813 } break; 1814 1815 case 0x0008: { /* Someone has granted you authorization */ 1816 imcb_log(sess->aux_data, 1817 "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender, 1818 msg->msg ? msg->msg : _("No reason given.")); 1819 } break; 1820 1821 case 0x0012: { 1822 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ 1823 } break; 1824 1825 default: {; } 1731 1826 } 1732 1827 … … 1740 1835 } 1741 1836 1742 static void oscar_keepalive(struct im_connection *ic) { 1743 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1837 static void oscar_keepalive(struct im_connection *ic) 1838 { 1839 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 1840 1744 1841 aim_flap_nop(odata->sess, odata->conn); 1745 1842 } 1746 1843 1747 static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags) { 1748 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1844 static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags) 1845 { 1846 struct oscar_data *odata = (struct oscar_data *) ic->proto_data; 1749 1847 int ret = 0, len = strlen(message); 1848 1750 1849 if (imflags & OPT_AWAY) { 1751 1850 ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message); … … 1753 1852 struct aim_sendimext_args args; 1754 1853 char *s; 1755 1854 1756 1855 args.flags = AIM_IMFLAGS_ACK; 1757 if (odata->icq) 1856 if (odata->icq) { 1758 1857 args.flags |= AIM_IMFLAGS_OFFLINE; 1759 for (s = message; *s; s++) 1760 if (*s & 128) 1858 } 1859 for (s = message; *s; s++) { 1860 if (*s & 128) { 1761 1861 break; 1762 1862 } 1863 } 1864 1763 1865 /* Message contains high ASCII chars, time for some translation! */ 1764 1866 if (*s) { … … 1774 1876 } else { 1775 1877 /* OOF, translation failed... Oh well.. */ 1776 g_free( s);1878 g_free(s); 1777 1879 s = message; 1778 1880 } … … 1780 1882 s = message; 1781 1883 } 1782 1884 1783 1885 args.features = gaim_features; 1784 1886 args.featureslen = sizeof(gaim_features); 1785 1887 1786 1888 args.destsn = name; 1787 1889 args.msg = s; 1788 1890 args.msglen = len; 1789 1891 1790 1892 ret = aim_send_im_ext(odata->sess, &args); 1791 1893 1792 1894 if (s != message) { 1793 1895 g_free(s); 1794 1896 } 1795 1897 } 1796 if (ret >= 0) 1898 if (ret >= 0) { 1797 1899 return 1; 1900 } 1798 1901 return ret; 1799 1902 } 1800 1903 1801 static void oscar_get_info(struct im_connection *g, char *name) { 1802 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1803 if (odata->icq) 1904 static void oscar_get_info(struct im_connection *g, char *name) 1905 { 1906 struct oscar_data *odata = (struct oscar_data *) g->proto_data; 1907 1908 if (odata->icq) { 1804 1909 aim_icq_getallinfo(odata->sess, name); 1805 else {1910 } else { 1806 1911 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); 1807 1912 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO); … … 1809 1914 } 1810 1915 1811 static void oscar_get_away(struct im_connection *g, char *who) { 1812 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1916 static void oscar_get_away(struct im_connection *g, char *who) 1917 { 1918 struct oscar_data *odata = (struct oscar_data *) g->proto_data; 1919 1813 1920 if (odata->icq) { 1814 1921 /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back? 1815 1922 struct buddy *budlight = imcb_find_buddy(g, who); 1816 1923 if (budlight) 1817 1818 1819 1924 if ((budlight->uc & 0xff80) >> 7) 1925 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) 1926 aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7); 1820 1927 */ 1821 } else 1928 } else { 1822 1929 aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE); 1930 } 1823 1931 } 1824 1932 1825 1933 static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) 1826 1934 { 1827 if (state == NULL) 1935 if (state == NULL) { 1828 1936 state = ""; 1937 } 1829 1938 1830 1939 if (!g_strcasecmp(state, _("Visible"))) { … … 1838 1947 } 1839 1948 1840 if (od->rights.maxawaymsglen == 0) 1949 if (od->rights.maxawaymsglen == 0) { 1841 1950 imcb_error(ic, "oscar_set_away_aim called before locate rights received"); 1951 } 1842 1952 1843 1953 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); … … 1852 1962 1853 1963 if (strlen(message) > od->rights.maxawaymsglen) { 1854 imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating", od->rights.maxawaymsglen); 1964 imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating", 1965 od->rights.maxawaymsglen); 1855 1966 } 1856 1967 … … 1905 2016 ic->away = g_strdup(msg); 1906 2017 } else { 1907 2018 if (no_message) { 1908 2019 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); 1909 2020 } else { … … 1919 2030 static void oscar_set_away(struct im_connection *ic, char *state, char *message) 1920 2031 { 1921 struct oscar_data *od = (struct oscar_data *) ic->proto_data;2032 struct oscar_data *od = (struct oscar_data *) ic->proto_data; 1922 2033 1923 2034 oscar_set_away_aim(ic, od, state, message); 1924 if (od->icq) 2035 if (od->icq) { 1925 2036 oscar_set_away_icq(ic, od, state, message); 2037 } 1926 2038 1927 2039 return; 1928 2040 } 1929 2041 1930 static void oscar_add_buddy(struct im_connection *g, char *name, char *group) { 1931 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 2042 static void oscar_add_buddy(struct im_connection *g, char *name, char *group) 2043 { 2044 struct oscar_data *odata = (struct oscar_data *) g->proto_data; 1932 2045 bee_user_t *bu; 1933 1934 if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group) 2046 2047 if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group) { 1935 2048 aim_ssi_movebuddy(odata->sess, odata->conn, bu->group->name, group, name); 1936 else2049 } else { 1937 2050 aim_ssi_addbuddies(odata->sess, odata->conn, group ? : OSCAR_GROUP, &name, 1, 0); 1938 } 1939 1940 static void oscar_remove_buddy(struct im_connection *g, char *name, char *group) { 1941 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 2051 } 2052 } 2053 2054 static void oscar_remove_buddy(struct im_connection *g, char *name, char *group) 2055 { 2056 struct oscar_data *odata = (struct oscar_data *) g->proto_data; 1942 2057 struct aim_ssi_item *ssigroup; 1943 while ((ssigroup = aim_ssi_itemlist_findparent(odata->sess->ssi.items, name)) && !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)); 1944 } 1945 1946 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { 1947 return 1; 1948 } 1949 1950 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { 2058 2059 while ((ssigroup = 2060 aim_ssi_itemlist_findparent(odata->sess->ssi.items, 2061 name)) && 2062 !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)) { 2063 ; 2064 } 2065 } 2066 2067 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) 2068 { 2069 return 1; 2070 } 2071 2072 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) 2073 { 1951 2074 struct im_connection *ic = sess->aux_data; 1952 2075 struct aim_ssi_item *curitem, *curgroup = NULL; … … 1956 2079 /* Add from server list to local list */ 1957 2080 tmp = 0; 1958 for (curitem =sess->ssi.items; curitem; curitem=curitem->next) {2081 for (curitem = sess->ssi.items; curitem; curitem = curitem->next) { 1959 2082 nrm = curitem->name ? normalize(curitem->name) : NULL; 1960 2083 1961 2084 switch (curitem->type) { 1962 case 0x0000: /* Buddy */ 1963 if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) { 1964 char *realname = NULL; 1965 1966 if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) 1967 realname = aim_gettlv_str(curitem->data, 0x0131, 1); 1968 1969 imcb_add_buddy(ic, nrm, curgroup ? (curgroup->gid == curitem->gid ? curgroup->name : NULL) : NULL); 1970 1971 if (realname) { 1972 imcb_buddy_nick_hint(ic, nrm, realname); 1973 imcb_rename_buddy(ic, nrm, realname); 1974 g_free(realname); 1975 } 2085 case 0x0000: /* Buddy */ 2086 if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) { 2087 char *realname = NULL; 2088 2089 if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) { 2090 realname = aim_gettlv_str(curitem->data, 0x0131, 1); 1976 2091 } 1977 break; 1978 1979 case 0x0001: /* Group */ 1980 curgroup = curitem; 1981 break; 1982 1983 case 0x0002: /* Permit buddy */ 1984 if (curitem->name) { 1985 GSList *list; 1986 for (list=ic->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); 1987 if (!list) { 1988 char *name; 1989 name = g_strdup(nrm); 1990 ic->permit = g_slist_append(ic->permit, name); 1991 tmp++; 1992 } 2092 2093 imcb_add_buddy(ic, nrm, 2094 curgroup ? (curgroup->gid == 2095 curitem->gid ? curgroup->name : NULL) : NULL); 2096 2097 if (realname) { 2098 imcb_buddy_nick_hint(ic, nrm, realname); 2099 imcb_rename_buddy(ic, nrm, realname); 2100 g_free(realname); 1993 2101 } 1994 break; 1995 1996 case 0x0003: /* Deny buddy */ 1997 if (curitem->name) { 1998 GSList *list; 1999 for (list=ic->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); 2000 if (!list) { 2001 char *name; 2002 name = g_strdup(nrm); 2003 ic->deny = g_slist_append(ic->deny, name); 2004 tmp++; 2005 } 2102 } 2103 break; 2104 2105 case 0x0001: /* Group */ 2106 curgroup = curitem; 2107 break; 2108 2109 case 0x0002: /* Permit buddy */ 2110 if (curitem->name) { 2111 GSList *list; 2112 for (list = ic->permit; (list && aim_sncmp(curitem->name, list->data)); 2113 list = list->next) { 2114 ; 2006 2115 } 2007 break; 2008 2009 case 0x0004: /* Permit/deny setting */ 2010 if (curitem->data) { 2011 guint8 permdeny; 2012 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) { 2013 ic->permdeny = permdeny; 2014 tmp++; 2015 } 2116 if (!list) { 2117 char *name; 2118 name = g_strdup(nrm); 2119 ic->permit = g_slist_append(ic->permit, name); 2120 tmp++; 2016 2121 } 2017 break; 2018 2019 case 0x0005: /* Presence setting */ 2020 /* We don't want to change Gaim's setting because it applies to all accounts */ 2021 break; 2122 } 2123 break; 2124 2125 case 0x0003: /* Deny buddy */ 2126 if (curitem->name) { 2127 GSList *list; 2128 for (list = ic->deny; 2129 (list && aim_sncmp(curitem->name, list->data)); list = list->next) { 2130 ; 2131 } 2132 if (!list) { 2133 char *name; 2134 name = g_strdup(nrm); 2135 ic->deny = g_slist_append(ic->deny, name); 2136 tmp++; 2137 } 2138 } 2139 break; 2140 2141 case 0x0004: /* Permit/deny setting */ 2142 if (curitem->data) { 2143 guint8 permdeny; 2144 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) { 2145 ic->permdeny = permdeny; 2146 tmp++; 2147 } 2148 } 2149 break; 2150 2151 case 0x0005: /* Presence setting */ 2152 /* We don't want to change Gaim's setting because it applies to all accounts */ 2153 break; 2022 2154 } /* End of switch on curitem->type */ 2023 2155 } /* End of for loop */ 2024 2156 2025 2157 aim_ssi_enable(sess, fr->conn); 2026 2158 2027 2159 /* Request offline messages, now that the buddy list is complete. */ 2028 2160 aim_icq_reqofflinemsgs(sess); 2029 2161 2030 2162 /* Now that we have a buddy list, we can tell BitlBee that we're online. */ 2031 2163 imcb_connected(ic); 2032 2033 return 1; 2034 } 2035 2036 static int gaim_ssi_parseack( aim_session_t *sess, aim_frame_t *fr, ...)2164 2165 return 1; 2166 } 2167 2168 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) 2037 2169 { 2038 2170 aim_snac_t *origsnac; 2039 2171 va_list ap; 2040 2172 2041 va_start( ap, fr ); 2042 origsnac = va_arg( ap, aim_snac_t * ); 2043 va_end( ap ); 2044 2045 if( origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data ) 2046 { 2047 int i, st, count = aim_bstream_empty( &fr->data ); 2173 va_start(ap, fr); 2174 origsnac = va_arg(ap, aim_snac_t *); 2175 va_end(ap); 2176 2177 if (origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data) { 2178 int i, st, count = aim_bstream_empty(&fr->data); 2048 2179 char *list; 2049 2050 if( count & 1 ) 2051 { 2180 2181 if (count & 1) { 2052 2182 /* Hmm, the length should be even... */ 2053 imcb_error( 2054 return( 0);2183 imcb_error(sess->aux_data, "Received SSI ACK package with non-even length"); 2184 return(0); 2055 2185 } 2056 2186 count >>= 1; 2057 2187 2058 2188 list = (char *) origsnac->data; 2059 for( i = 0; i < count; i ++ ) 2060 { 2061 struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent( sess->ssi.items, list ); 2189 for (i = 0; i < count; i++) { 2190 struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent(sess->ssi.items, list); 2062 2191 char *group = ssigroup ? ssigroup->name : NULL; 2063 2064 st = aimbs_get16( &fr->data ); 2065 if( st == 0x00 ) 2066 { 2067 imcb_add_buddy( sess->aux_data, normalize(list), group ); 2192 2193 st = aimbs_get16(&fr->data); 2194 if (st == 0x00) { 2195 imcb_add_buddy(sess->aux_data, normalize(list), group); 2196 } else if (st == 0x0E) { 2197 imcb_log(sess->aux_data, 2198 "Buddy %s can't be added without authorization, requesting authorization", 2199 list); 2200 2201 aim_ssi_auth_request(sess, fr->conn, list, ""); 2202 aim_ssi_addbuddies(sess, fr->conn, OSCAR_GROUP, &list, 1, 1); 2203 } else if (st == 0x0A) { 2204 imcb_error(sess->aux_data, "Buddy %s is already in your list", list); 2205 } else { 2206 imcb_error(sess->aux_data, "Error while adding buddy: 0x%04x", st); 2068 2207 } 2069 else if( st == 0x0E ) 2070 { 2071 imcb_log( sess->aux_data, "Buddy %s can't be added without authorization, requesting authorization", list ); 2072 2073 aim_ssi_auth_request( sess, fr->conn, list, "" ); 2074 aim_ssi_addbuddies( sess, fr->conn, OSCAR_GROUP, &list, 1, 1 ); 2075 } 2076 else if( st == 0x0A ) 2077 { 2078 imcb_error( sess->aux_data, "Buddy %s is already in your list", list ); 2079 } 2080 else 2081 { 2082 imcb_error( sess->aux_data, "Error while adding buddy: 0x%04x", st ); 2083 } 2084 list += strlen( list ) + 1; 2085 } 2086 } 2087 2088 return( 1 ); 2089 } 2090 2091 static void oscar_add_permit(struct im_connection *ic, char *who) { 2092 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2208 list += strlen(list) + 1; 2209 } 2210 } 2211 2212 return(1); 2213 } 2214 2215 static void oscar_add_permit(struct im_connection *ic, char *who) 2216 { 2217 struct oscar_data *od = (struct oscar_data *) ic->proto_data; 2218 2093 2219 if (od->icq) { 2094 2220 aim_ssi_auth_reply(od->sess, od->conn, who, 1, ""); 2095 2221 } else { 2096 if (od->sess->ssi.received_data) 2222 if (od->sess->ssi.received_data) { 2097 2223 aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT); 2098 } 2099 } 2100 2101 static void oscar_add_deny(struct im_connection *ic, char *who) { 2102 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2224 } 2225 } 2226 } 2227 2228 static void oscar_add_deny(struct im_connection *ic, char *who) 2229 { 2230 struct oscar_data *od = (struct oscar_data *) ic->proto_data; 2231 2103 2232 if (od->icq) { 2104 2233 aim_ssi_auth_reply(od->sess, od->conn, who, 0, ""); 2105 2234 } else { 2106 if (od->sess->ssi.received_data) 2235 if (od->sess->ssi.received_data) { 2107 2236 aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY); 2108 } 2109 } 2110 2111 static void oscar_rem_permit(struct im_connection *ic, char *who) { 2112 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2237 } 2238 } 2239 } 2240 2241 static void oscar_rem_permit(struct im_connection *ic, char *who) 2242 { 2243 struct oscar_data *od = (struct oscar_data *) ic->proto_data; 2244 2113 2245 if (!od->icq) { 2114 if (od->sess->ssi.received_data) 2246 if (od->sess->ssi.received_data) { 2115 2247 aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT); 2116 } 2117 } 2118 2119 static void oscar_rem_deny(struct im_connection *ic, char *who) { 2120 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2248 } 2249 } 2250 } 2251 2252 static void oscar_rem_deny(struct im_connection *ic, char *who) 2253 { 2254 struct oscar_data *od = (struct oscar_data *) ic->proto_data; 2255 2121 2256 if (!od->icq) { 2122 if (od->sess->ssi.received_data) 2257 if (od->sess->ssi.received_data) { 2123 2258 aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY); 2259 } 2124 2260 } 2125 2261 } … … 2159 2295 va_end(ap); 2160 2296 2161 if (!info->uin) 2297 if (!info->uin) { 2162 2298 return 0; 2299 } 2163 2300 2164 2301 str = g_string_sized_new(512); 2165 2302 g_snprintf(who, sizeof(who), "%u", info->uin); 2166 2303 2167 g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), 2168 info->nick ? info->nick : "-");2304 g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), 2305 info->nick ? info->nick : "-"); 2169 2306 g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first); 2170 2307 g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last); … … 2181 2318 } 2182 2319 g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile); 2183 if (info->gender != 0) 2184 g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male")); 2320 if (info->gender != 0) { 2321 g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); 2322 } 2185 2323 if (info->birthyear || info->birthmonth || info->birthday) { 2186 2324 char date[30]; 2187 2325 struct tm tm; 2188 2326 memset(&tm, 0, sizeof(struct tm)); 2189 tm.tm_mday = (int) info->birthday;2190 tm.tm_mon = (int) info->birthmonth-1;2191 tm.tm_year = (int) info->birthyear%100;2327 tm.tm_mday = (int) info->birthday; 2328 tm.tm_mon = (int) info->birthmonth - 1; 2329 tm.tm_year = (int) info->birthyear % 100; 2192 2330 strftime(date, sizeof(date), "%Y-%m-%d", &tm); 2193 2331 g_string_append_printf(str, "\n%s: %s", _("Birthday"), date); … … 2200 2338 g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage); 2201 2339 if (info->info && info->info[0]) { 2202 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), 2203 info->info, _("End of Additional Information"));2340 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), 2341 info->info, _("End of Additional Information")); 2204 2342 } 2205 2343 g_string_append_c(str, '\n'); 2206 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 2344 if ((info->homeaddr && 2345 (info->homeaddr[0])) || 2346 (info->homecity && 2347 info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 2207 2348 g_string_append_printf(str, "%s:", _("Home Address")); 2208 2349 g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr); 2209 2350 g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity); 2210 g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate); 2351 g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate); 2211 2352 g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip); 2212 2353 g_string_append_c(str, '\n'); 2213 2354 } 2214 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 2355 if ((info->workaddr && 2356 info->workaddr[0]) || 2357 (info->workcity && 2358 info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 2215 2359 g_string_append_printf(str, "%s:", _("Work Address")); 2216 2360 g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr); … … 2220 2364 g_string_append_c(str, '\n'); 2221 2365 } 2222 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 2366 if ((info->workcompany && 2367 info->workcompany[0]) || 2368 (info->workdivision && 2369 info->workdivision[0]) || 2370 (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 2223 2371 g_string_append_printf(str, "%s:", _("Work Information")); 2224 2372 g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany); … … 2247 2395 /* Make sure encoding begins with charset= */ 2248 2396 if (strncmp(encoding, "text/plain; charset=", 20) && 2249 strncmp(encoding, "text/aolrtf; charset=", 21) && 2250 strncmp(encoding, "text/x-aolrtf; charset=", 23)) 2251 { 2397 strncmp(encoding, "text/aolrtf; charset=", 21) && 2398 strncmp(encoding, "text/x-aolrtf; charset=", 23)) { 2252 2399 return NULL; 2253 2400 } … … 2256 2403 end = strrchr(encoding, '"'); 2257 2404 2258 if ((begin == NULL) || (end == NULL) || (begin >= end)) 2405 if ((begin == NULL) || (end == NULL) || (begin >= end)) { 2259 2406 return NULL; 2260 2261 ret = g_strndup(begin+1, (end-1) - begin); 2407 } 2408 2409 ret = g_strndup(begin + 1, (end - 1) - begin); 2262 2410 2263 2411 return ret; … … 2288 2436 */ 2289 2437 if (*utf8 == 0) { 2290 2438 strncpy(utf8, text, textlen); 2291 2439 } 2292 2440 … … 2312 2460 va_end(ap); 2313 2461 2314 if (text_encoding)2462 if (text_encoding) { 2315 2463 extracted_encoding = oscar_encoding_extract(text_encoding); 2316 if(infotype == AIM_GETINFO_GENERALINFO) { 2464 } 2465 if (infotype == AIM_GETINFO_GENERALINFO) { 2317 2466 /*Display idle time*/ 2318 2467 char buff[256]; 2319 2468 struct tm idletime; 2320 if (userinfo->idletime) {2469 if (userinfo->idletime) { 2321 2470 memset(&idletime, 0, sizeof(struct tm)); 2322 2471 idletime.tm_mday = (userinfo->idletime / 60) / 24; … … 2327 2476 imcb_log(ic, "%s: %s", _("Idle Time"), buff); 2328 2477 } 2329 2330 if (text) {2478 2479 if (text) { 2331 2480 utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length); 2332 2481 imcb_log(ic, "%s\n%s", _("User Info"), utf8); … … 2334 2483 imcb_log(ic, _("No user info available.")); 2335 2484 } 2336 } else if (infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) {2485 } else if (infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) { 2337 2486 utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length); 2338 2487 imcb_log(ic, "%s\n%s", _("Away Message"), utf8); … … 2340 2489 2341 2490 g_free(utf8); 2342 2491 2343 2492 return 1; 2344 2493 } … … 2356 2505 type2 = va_arg(ap, int); 2357 2506 va_end(ap); 2358 2359 if (type2 == 0x0002) {2507 2508 if (type2 == 0x0002) { 2360 2509 /* User is typing */ 2361 2510 imcb_buddy_typing(ic, normalize(sn), OPT_TYPING); 2362 } 2363 else if (type2 == 0x0001) { 2511 } else if (type2 == 0x0001) { 2364 2512 /* User has typed something, but is not actively typing (stale) */ 2365 2513 imcb_buddy_typing(ic, normalize(sn), OPT_THINKING); 2366 } 2367 else { 2514 } else { 2368 2515 /* User has stopped typing */ 2369 2516 imcb_buddy_typing(ic, normalize(sn), 0); 2370 2517 } 2371 2518 2372 2519 return 1; 2373 2520 } … … 2376 2523 { 2377 2524 struct oscar_data *od = ic->proto_data; 2378 return( aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000) ); 2525 2526 return(aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000)); 2379 2527 } 2380 2528 … … 2382 2530 { 2383 2531 struct im_connection *ic = c->ic; 2384 struct oscar_data * od = (struct oscar_data*) ic->proto_data;2532 struct oscar_data * od = (struct oscar_data*) ic->proto_data; 2385 2533 struct chat_connection * ccon; 2386 2534 int ret; … … 2388 2536 guint16 flags; 2389 2537 char *s; 2390 2391 if (!(ccon = c->data)) 2538 2539 if (!(ccon = c->data)) { 2392 2540 return; 2393 2394 for (s = message; *s; s++) 2395 if (*s & 128) 2541 } 2542 2543 for (s = message; *s; s++) { 2544 if (*s & 128) { 2396 2545 break; 2397 2546 } 2547 } 2548 2398 2549 flags = AIM_CHATFLAGS_NOREFLECT; 2399 2550 2400 2551 /* Message contains high ASCII chars, time for some translation! */ 2401 2552 if (*s) { … … 2411 2562 } else { 2412 2563 /* OOF, translation failed... Oh well.. */ 2413 g_free( s);2564 g_free(s); 2414 2565 s = message; 2415 2566 } … … 2417 2568 s = message; 2418 2569 } 2419 2570 2420 2571 ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len); 2421 2422 if (s != message) { 2572 2573 if (s != message) { 2423 2574 g_free(s); 2424 2425 2575 } 2576 2426 2577 /* return (ret >= 0); */ 2427 2578 } … … 2430 2581 { 2431 2582 struct im_connection *ic = c->ic; 2432 struct oscar_data * od = (struct oscar_data *) ic->proto_data;2583 struct oscar_data * od = (struct oscar_data *) ic->proto_data; 2433 2584 struct chat_connection *ccon; 2434 2435 if (!(ccon = c->data)) 2585 2586 if (!(ccon = c->data)) { 2436 2587 return; 2437 2588 } 2589 2438 2590 aim_chat_invite(od->sess, od->conn, who, message ? message : "", 2439 2591 ccon->exchange, ccon->name, 0x0); 2440 2592 } 2441 2593 2442 2594 void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc) 2443 2595 { 2444 struct oscar_data *od = (struct oscar_data *) ic->proto_data;2596 struct oscar_data *od = (struct oscar_data *) ic->proto_data; 2445 2597 2446 2598 /* Notify the conversation window that we've left the chat */ … … 2449 2601 /* Destroy the chat_connection */ 2450 2602 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); 2451 if (cc->inpa > 0) 2603 if (cc->inpa > 0) { 2452 2604 b_event_remove(cc->inpa); 2605 } 2453 2606 aim_conn_kill(od->sess, &cc->conn); 2454 2607 g_free(cc->name); … … 2459 2612 void oscar_chat_leave(struct groupchat *c) 2460 2613 { 2461 if (!c->data) 2614 if (!c->data) { 2462 2615 return; 2616 } 2463 2617 oscar_chat_kill(c->ic, c->data); 2464 2618 } 2465 2619 2466 2620 struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char *room, 2467 2468 { 2469 struct oscar_data * od = (struct oscar_data *) ic->proto_data;2621 const char *nick, const char *password, int exchange_number) 2622 { 2623 struct oscar_data * od = (struct oscar_data *) ic->proto_data; 2470 2624 struct groupchat *ret = imcb_chat_new(ic, room); 2471 2625 aim_conn_t * cur; 2472 2626 2473 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {2627 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { 2474 2628 aim_chatnav_createroom(od->sess, cur, room, exchange_number); 2475 2629 2476 2630 return ret; 2477 2631 } else { 2478 2632 struct create_room * cr = g_new0(struct create_room, 1); 2479 2633 2480 2634 cr->exchange = exchange_number; 2481 2635 cr->name = g_strdup(room); 2482 2636 od->create_rooms = g_slist_append(od->create_rooms, cr); 2483 2637 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); 2484 2638 2485 2639 return ret; 2486 2640 } … … 2488 2642 2489 2643 struct groupchat *oscar_chat_join(struct im_connection *ic, const char *room, 2490 2644 const char *nick, const char *password, set_t **sets) 2491 2645 { 2492 2646 return oscar_chat_join_internal(ic, room, nick, password, set_getint(sets, "exchange_number")); … … 2495 2649 struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) 2496 2650 { 2497 struct oscar_data * od = (struct oscar_data *) ic->proto_data;2651 struct oscar_data * od = (struct oscar_data *) ic->proto_data; 2498 2652 struct groupchat *ret; 2499 2653 static int chat_id = 0; 2500 2654 char * chatname, *s; 2501 2655 2502 2656 chatname = g_strdup_printf("%s%s%d", g_ascii_isdigit(*ic->acc->user) ? "icq" : "", 2503 2657 ic->acc->user, chat_id++); 2504 2505 for (s = chatname; *s; s ++)2506 if (!g_ascii_isalnum(*s)) 2658 2659 for (s = chatname; *s; s++) { 2660 if (!g_ascii_isalnum(*s)) { 2507 2661 *s = '0'; 2508 2662 } 2663 } 2664 2509 2665 ret = oscar_chat_join_internal(ic, chatname, NULL, NULL, 4); 2510 2666 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); 2511 2667 2512 2668 g_free(chatname); 2513 2669 2514 2670 return ret; 2515 2671 } … … 2518 2674 { 2519 2675 struct aim_chat_invitation * inv = data; 2520 2676 2521 2677 oscar_chat_join_internal(inv->ic, inv->name, NULL, NULL, 4); 2522 2678 g_free(inv->name); … … 2527 2683 { 2528 2684 struct aim_chat_invitation * inv = data; 2529 2685 2530 2686 g_free(inv->name); 2531 2687 g_free(inv); … … 2542 2698 } 2543 2699 2544 void oscar_initmodule() 2700 void oscar_initmodule() 2545 2701 { 2546 2702 struct prpl *ret = g_new0(struct prpl, 1); 2703 2547 2704 ret->name = "oscar"; 2548 ret->mms = 2343;/* this guess taken from libotr UPGRADING file */2705 ret->mms = 2343; /* this guess taken from libotr UPGRADING file */ 2549 2706 ret->away_states = oscar_away_states; 2550 2707 ret->init = oscar_init; … … 2570 2727 ret->rem_deny = oscar_rem_deny; 2571 2728 ret->send_typing = oscar_send_typing; 2572 2729 2573 2730 ret->handle_cmp = aim_sncmp; 2574 2731
Note: See TracChangeset
for help on using the changeset viewer.