Changes in protocols/oscar/oscar.c [b8ef1b1:e7f46c5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/oscar.c
rb8ef1b1 re7f46c5 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 | AIM_CAPS_CHAT;64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY; 65 65 static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02}; 66 66 … … 156 156 } 157 157 158 #if 0 158 159 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { 159 160 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; … … 170 171 return c; 171 172 } 172 173 #endif 173 174 174 175 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, … … 1075 1076 } 1076 1077 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 1080 1078 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1079 #if 0 1081 1080 struct gaim_connection *gc = sess->aux_data; 1081 #endif 1082 1082 1083 1083 if (args->status != AIM_RENDEZVOUS_PROPOSE) 1084 1084 return 1; 1085 1085 #if 0 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 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 1093 serv_got_chat_invite(gc, 1094 name ? name : args->info.chat.roominfo.name, 1095 userinfo->sn, 1096 (char *)args->msg, 1097 m); 1106 1098 if (name) 1107 1099 g_free(name); 1108 1100 } 1109 1101 #endif 1110 1102 return 1; 1111 1103 } … … 2451 2443 type2 = va_arg(ap, int); 2452 2444 va_end(ap); 2453 2454 if(type2 == 0x0001 || type2 == 0x0002) 2455 serv_got_typing(gc, sn, 0); 2456 2445 2446 if(type2 == 0x0002) { 2447 /* User is typing */ 2448 serv_got_typing(gc, sn, 0, 1); 2449 } 2450 else if (type2 == 0x0001) { 2451 /* User has typed something, but is not actively typing (stale) */ 2452 serv_got_typing(gc, sn, 0, 2); 2453 } 2454 else { 2455 /* User has stopped typing */ 2456 serv_got_typing(gc, sn, 0, 0); 2457 } 2458 2457 2459 return 1; 2458 2460 } … … 2492 2494 } 2493 2495 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 2626 2496 static struct prpl *my_protocol = NULL; 2627 2497 … … 2637 2507 ret->add_buddy = oscar_add_buddy; 2638 2508 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;2643 2509 ret->add_permit = oscar_add_permit; 2644 2510 ret->add_deny = oscar_add_deny;
Note: See TracChangeset
for help on using the changeset viewer.