Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    re7f46c5 rb8ef1b1  
    6262   static int gaim_caps = AIM_CAPS_UTF8; */
    6363
    64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY;
     64static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT;
    6565static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02};
    6666
     
    156156}
    157157
    158 #if 0
    159158static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) {
    160159        GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats;
     
    171170        return c;
    172171}
    173 #endif
     172
    174173
    175174static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,
     
    10761075}
    10771076
     1077void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv);
     1078void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv);
     1079       
    10781080static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
    1079 #if 0
    10801081        struct gaim_connection *gc = sess->aux_data;
    1081 #endif
    10821082
    10831083        if (args->status != AIM_RENDEZVOUS_PROPOSE)
    10841084                return 1;
    1085 #if 0
     1085
    10861086        if (args->reqclass & AIM_CAPS_CHAT) {
    10871087                char *name = extract_name(args->info.chat.roominfo.name);
     
    10911091                *exch = args->info.chat.roominfo.exchange;
    10921092                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       
    10981106                if (name)
    10991107                        g_free(name);
    11001108        }
    1101 #endif
     1109
    11021110        return 1;
    11031111}
     
    24432451        type2 = va_arg(ap, int);
    24442452        va_end(ap);
    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        
     2453
     2454        if(type2 == 0x0001 || type2 == 0x0002)
     2455                serv_got_typing(gc, sn, 0);
     2456
    24592457        return 1;
    24602458}
     
    24942492}
    24952493
     2494int 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
     2537void 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
     2549void 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
     2566void 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
     2576int 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
     2596int 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
     2613void 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
     2620void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv)
     2621{
     2622        g_free(inv->name);
     2623        g_free(inv);
     2624}
     2625
    24962626static struct prpl *my_protocol = NULL;
    24972627
     
    25072637        ret->add_buddy = oscar_add_buddy;
    25082638        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;
    25092643        ret->add_permit = oscar_add_permit;
    25102644        ret->add_deny = oscar_add_deny;
Note: See TracChangeset for help on using the changeset viewer.