Changeset bd69a21 for protocols/oscar/oscar.c
- Timestamp:
- 2005-12-15T12:24:25Z (19 years ago)
- Branches:
- master
- Children:
- 4146a07
- Parents:
- 2983f5e (diff), bf02a67 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/oscar.c
r2983f5e rbd69a21 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, … … 1074 1073 } 1075 1074 1075 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv); 1076 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv); 1077 1076 1078 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1077 #if 01078 1079 struct gaim_connection *gc = sess->aux_data; 1079 #endif1080 1080 1081 1081 if (args->status != AIM_RENDEZVOUS_PROPOSE) 1082 1082 return 1; 1083 #if 0 1083 1084 1084 if (args->reqclass & AIM_CAPS_CHAT) { 1085 1085 char *name = extract_name(args->info.chat.roominfo.name); 1086 1086 int *exch = g_new0(int, 1); 1087 1087 GList *m = NULL; 1088 char txt[1024]; 1089 struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); 1090 1088 1091 m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); 1089 1092 *exch = args->info.chat.roominfo.exchange; 1090 1093 m = g_list_append(m, exch); 1091 serv_got_chat_invite(gc, 1092 name ? name : args->info.chat.roominfo.name, 1093 userinfo->sn, 1094 (char *)args->msg, 1095 m); 1094 1095 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg ); 1096 1097 inv->gc = gc; 1098 inv->exchange = *exch; 1099 inv->name = g_strdup(name); 1100 1101 do_ask_dialog( gc, txt, inv, oscar_accept_chat, oscar_reject_chat); 1102 1096 1103 if (name) 1097 1104 g_free(name); 1098 1105 } 1099 #endif 1106 1100 1107 return 1; 1101 1108 } … … 2441 2448 type2 = va_arg(ap, int); 2442 2449 va_end(ap); 2443 2444 if(type2 == 0x0001 || type2 == 0x0002) 2445 serv_got_typing(gc, sn, 0); 2446 2450 2451 if(type2 == 0x0002) { 2452 /* User is typing */ 2453 serv_got_typing(gc, sn, 0, 1); 2454 } 2455 else if (type2 == 0x0001) { 2456 /* User has typed something, but is not actively typing (stale) */ 2457 serv_got_typing(gc, sn, 0, 2); 2458 } 2459 else { 2460 /* User has stopped typing */ 2461 serv_got_typing(gc, sn, 0, 0); 2462 } 2463 2447 2464 return 1; 2448 2465 } … … 2482 2499 } 2483 2500 2501 int oscar_chat_send(struct gaim_connection * gc, int id, char *message) 2502 { 2503 struct oscar_data * od = (struct oscar_data*)gc->proto_data; 2504 struct chat_connection * ccon; 2505 int ret; 2506 guint8 len = strlen(message); 2507 char *s; 2508 2509 if(!(ccon = find_oscar_chat(gc, id))) 2510 return -1; 2511 2512 for (s = message; *s; s++) 2513 if (*s & 128) 2514 break; 2515 2516 /* Message contains high ASCII chars, time for some translation! */ 2517 if (*s) { 2518 s = g_malloc(BUF_LONG); 2519 /* Try if we can put it in an ISO8859-1 string first. 2520 If we can't, fall back to UTF16. */ 2521 if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { 2522 len = ret; 2523 } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { 2524 len = ret; 2525 } else { 2526 /* OOF, translation failed... Oh well.. */ 2527 g_free( s ); 2528 s = message; 2529 } 2530 } else { 2531 s = message; 2532 } 2533 2534 ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len); 2535 2536 if (s != message) { 2537 g_free(s); 2538 } 2539 2540 return (ret >= 0); 2541 } 2542 2543 void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who) 2544 { 2545 struct oscar_data * od = (struct oscar_data *)gc->proto_data; 2546 struct chat_connection *ccon = find_oscar_chat(gc, id); 2547 2548 if (ccon == NULL) 2549 return; 2550 2551 aim_chat_invite(od->sess, od->conn, who, message ? message : "", 2552 ccon->exchange, ccon->name, 0x0); 2553 } 2554 2555 void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc) 2556 { 2557 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 2558 2559 /* Notify the conversation window that we've left the chat */ 2560 serv_got_chat_left(gc, cc->id); 2561 2562 /* Destroy the chat_connection */ 2563 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); 2564 if (cc->inpa > 0) 2565 gaim_input_remove(cc->inpa); 2566 aim_conn_kill(od->sess, &cc->conn); 2567 g_free(cc->name); 2568 g_free(cc->show); 2569 g_free(cc); 2570 } 2571 2572 void oscar_chat_leave(struct gaim_connection * gc, int id) 2573 { 2574 struct chat_connection * ccon = find_oscar_chat(gc, id); 2575 2576 if(ccon == NULL) 2577 return; 2578 2579 oscar_chat_kill(gc, ccon); 2580 } 2581 2582 int oscar_chat_join(struct gaim_connection * gc, char * name) 2583 { 2584 struct oscar_data * od = (struct oscar_data *)gc->proto_data; 2585 2586 aim_conn_t * cur; 2587 2588 if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { 2589 2590 return (aim_chatnav_createroom(od->sess, cur, name, 4) == 0); 2591 2592 } else { 2593 struct create_room * cr = g_new0(struct create_room, 1); 2594 cr->exchange = 4; 2595 cr->name = g_strdup(name); 2596 od->create_rooms = g_slist_append(od->create_rooms, cr); 2597 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); 2598 return 1; 2599 } 2600 } 2601 2602 int oscar_chat_open(struct gaim_connection * gc, char *who) 2603 { 2604 struct oscar_data * od = (struct oscar_data *)gc->proto_data; 2605 int ret; 2606 static int chat_id = 0; 2607 char * chatname = g_new0(char, strlen(gc->username)+4); 2608 2609 g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++); 2610 2611 ret = oscar_chat_join(gc, chatname); 2612 2613 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); 2614 2615 g_free(chatname); 2616 2617 return ret; 2618 } 2619 2620 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv) 2621 { 2622 oscar_chat_join(inv->gc, inv->name); 2623 g_free(inv->name); 2624 g_free(inv); 2625 } 2626 2627 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv) 2628 { 2629 g_free(inv->name); 2630 g_free(inv); 2631 } 2632 2484 2633 void oscar_init() 2485 2634 { … … 2495 2644 ret->add_buddy = oscar_add_buddy; 2496 2645 ret->remove_buddy = oscar_remove_buddy; 2646 ret->chat_send = oscar_chat_send; 2647 ret->chat_invite = oscar_chat_invite; 2648 ret->chat_leave = oscar_chat_leave; 2649 ret->chat_open = oscar_chat_open; 2497 2650 ret->add_permit = oscar_add_permit; 2498 2651 ret->add_deny = oscar_add_deny;
Note: See TracChangeset
for help on using the changeset viewer.