Changeset b8ef1b1
- Timestamp:
- 2005-12-04T19:32:14Z (19 years ago)
- Branches:
- master
- Children:
- 1aa0bb5
- Parents:
- d636233
- Location:
- protocols/oscar
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/aim.h
rd636233 rb8ef1b1 466 466 int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps); 467 467 int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type); 468 int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance); 468 469 int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui); 469 470 int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl); … … 572 573 }; 573 574 575 struct aim_chat_invitation { 576 struct gaim_connection * gc; 577 char * name; 578 guint8 exchange; 579 }; 574 580 575 581 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 -
protocols/oscar/chat.c
rd636233 rb8ef1b1 180 180 181 181 aim_tx_enqueue(sess, fr); 182 183 return 0;184 }185 186 static int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)187 {188 guint8 *buf;189 int buflen;190 aim_bstream_t bs;191 192 buflen = 2 + 1 + strlen(roomname) + 2;193 194 if (!(buf = g_malloc(buflen)))195 return 0;196 197 aim_bstream_init(&bs, buf, buflen);198 199 aimbs_put16(&bs, exchange);200 aimbs_put8(&bs, strlen(roomname));201 aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname));202 aimbs_put16(&bs, instance);203 204 aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf);205 206 g_free(buf);207 182 208 183 return 0; -
protocols/oscar/im.c
rd636233 rb8ef1b1 1369 1369 } 1370 1370 1371 1372 static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) 1373 { 1374 1375 /* XXX aim_chat_roominfo_free() */ 1376 g_free(args->info.chat.roominfo.name); 1377 1378 return; 1379 } 1380 1381 static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) 1382 { 1383 1384 /* 1385 * Chat room info. 1386 */ 1387 if (servdata) 1388 aim_chat_readroominfo(servdata, &args->info.chat.roominfo); 1389 1390 args->destructor = (void *)incomingim_ch2_chat_free; 1391 1392 return; 1393 } 1394 1371 1395 static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) 1372 1396 { … … 1617 1641 if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) 1618 1642 incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr); 1643 else if (args.reqclass & AIM_CAPS_CHAT) 1644 incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr); 1619 1645 1620 1646 -
protocols/oscar/oscar.c
rd636233 rb8ef1b1 62 62 static int gaim_caps = AIM_CAPS_UTF8; */ 63 63 64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY ;64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT; 65 65 static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02}; 66 66 … … 156 156 } 157 157 158 #if 0159 158 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { 160 159 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; … … 171 170 return c; 172 171 } 173 #endif 172 174 173 175 174 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, … … 1076 1075 } 1077 1076 1077 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv); 1078 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv); 1079 1078 1080 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1079 #if 01080 1081 struct gaim_connection *gc = sess->aux_data; 1081 #endif1082 1082 1083 1083 if (args->status != AIM_RENDEZVOUS_PROPOSE) 1084 1084 return 1; 1085 #if 0 1085 1086 1086 if (args->reqclass & AIM_CAPS_CHAT) { 1087 1087 char *name = extract_name(args->info.chat.roominfo.name); … … 1091 1091 *exch = args->info.chat.roominfo.exchange; 1092 1092 m = g_list_append(m, exch); 1093 serv_got_chat_invite(gc, 1094 name ? name : args->info.chat.roominfo.name, 1095 userinfo->sn, 1096 (char *)args->msg, 1097 m); 1093 1094 char txt[1024]; 1095 1096 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg ); 1097 1098 struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); 1099 1100 inv->gc = gc; 1101 inv->exchange = *exch; 1102 inv->name = g_strdup(name); 1103 1104 do_ask_dialog( gc, txt, inv, oscar_accept_chat, oscar_reject_chat); 1105 1098 1106 if (name) 1099 1107 g_free(name); 1100 1108 } 1101 #endif 1109 1102 1110 return 1; 1103 1111 } … … 2484 2492 } 2485 2493 2494 int oscar_chat_send(struct gaim_connection * gc, int id, char *message) 2495 { 2496 struct oscar_data * od = (struct oscar_data*)gc->proto_data; 2497 struct chat_connection * ccon; 2498 2499 if(!(ccon = find_oscar_chat(gc, id))) 2500 return -1; 2501 2502 int ret; 2503 guint8 len = strlen(message); 2504 char *s; 2505 2506 for (s = message; *s; s++) 2507 if (*s & 128) 2508 break; 2509 2510 /* Message contains high ASCII chars, time for some translation! */ 2511 if (*s) { 2512 s = g_malloc(BUF_LONG); 2513 /* Try if we can put it in an ISO8859-1 string first. 2514 If we can't, fall back to UTF16. */ 2515 if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { 2516 len = ret; 2517 } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { 2518 len = ret; 2519 } else { 2520 /* OOF, translation failed... Oh well.. */ 2521 g_free( s ); 2522 s = message; 2523 } 2524 } else { 2525 s = message; 2526 } 2527 2528 ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len); 2529 2530 if (s != message) { 2531 g_free(s); 2532 } 2533 2534 return (ret >= 0); 2535 } 2536 2537 void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who) 2538 { 2539 struct oscar_data * od = (struct oscar_data *)gc->proto_data; 2540 struct chat_connection *ccon = find_oscar_chat(gc, id); 2541 2542 if (ccon == NULL) 2543 return; 2544 2545 aim_chat_invite(od->sess, od->conn, who, message ? message : "", 2546 ccon->exchange, ccon->name, 0x0); 2547 } 2548 2549 void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc) 2550 { 2551 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 2552 2553 /* Notify the conversation window that we've left the chat */ 2554 serv_got_chat_left(gc, cc->id); 2555 2556 /* Destroy the chat_connection */ 2557 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); 2558 if (cc->inpa > 0) 2559 gaim_input_remove(cc->inpa); 2560 aim_conn_kill(od->sess, &cc->conn); 2561 g_free(cc->name); 2562 g_free(cc->show); 2563 g_free(cc); 2564 } 2565 2566 void oscar_chat_leave(struct gaim_connection * gc, int id) 2567 { 2568 struct chat_connection * ccon = find_oscar_chat(gc, id); 2569 2570 if(ccon == NULL) 2571 return; 2572 2573 oscar_chat_kill(gc, ccon); 2574 } 2575 2576 int oscar_chat_join(struct gaim_connection * gc, char * name) 2577 { 2578 struct oscar_data * od = (struct oscar_data *)gc->proto_data; 2579 2580 aim_conn_t * cur; 2581 2582 if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { 2583 2584 return (aim_chatnav_createroom(od->sess, cur, name, 4) == 0); 2585 2586 } else { 2587 struct create_room * cr = g_new0(struct create_room, 1); 2588 cr->exchange = 4; 2589 cr->name = g_strdup(name); 2590 od->create_rooms = g_slist_append(od->create_rooms, cr); 2591 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); 2592 return 1; 2593 } 2594 } 2595 2596 int oscar_chat_open(struct gaim_connection * gc, char *who) 2597 { 2598 struct oscar_data * od = (struct oscar_data *)gc->proto_data; 2599 2600 static int chat_id = 0; 2601 char * chatname = g_new0(char, strlen(gc->username)+4); 2602 g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++); 2603 2604 int ret = oscar_chat_join(gc, chatname); 2605 2606 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); 2607 2608 g_free(chatname); 2609 2610 return ret; 2611 } 2612 2613 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv) 2614 { 2615 oscar_chat_join(inv->gc, inv->name); 2616 g_free(inv->name); 2617 g_free(inv); 2618 } 2619 2620 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv) 2621 { 2622 g_free(inv->name); 2623 g_free(inv); 2624 } 2625 2486 2626 static struct prpl *my_protocol = NULL; 2487 2627 … … 2497 2637 ret->add_buddy = oscar_add_buddy; 2498 2638 ret->remove_buddy = oscar_remove_buddy; 2639 ret->chat_send = oscar_chat_send; 2640 ret->chat_invite = oscar_chat_invite; 2641 ret->chat_leave = oscar_chat_leave; 2642 ret->chat_open = oscar_chat_open; 2499 2643 ret->add_permit = oscar_add_permit; 2500 2644 ret->add_deny = oscar_add_deny; -
protocols/oscar/tlv.c
rd636233 rb8ef1b1 340 340 } 341 341 342 int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance) 343 { 344 guint8 *buf; 345 int buflen; 346 aim_bstream_t bs; 347 348 buflen = 2 + 1 + strlen(roomname) + 2; 349 350 if (!(buf = g_malloc(buflen))) 351 return 0; 352 353 aim_bstream_init(&bs, buf, buflen); 354 355 aimbs_put16(&bs, exchange); 356 aimbs_put8(&bs, strlen(roomname)); 357 aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname)); 358 aimbs_put16(&bs, instance); 359 360 aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); 361 362 g_free(buf); 363 364 return 0; 365 } 366 342 367 /** 343 368 * aim_writetlvchain - Write a TLV chain into a data buffer.
Note: See TracChangeset
for help on using the changeset viewer.