Changeset b8ef1b1 for protocols/oscar/oscar.c
- Timestamp:
- 2005-12-04T19:32:14Z (19 years ago)
- Branches:
- master
- Children:
- 1aa0bb5
- Parents:
- d636233
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.