Ticket #53: bitlbee-recode-0.4.diff

File bitlbee-recode-0.4.diff, 7.4 KB (added by waker, 4 years ago)

oscar-recode-0.4

  • irc.c

    Only in ./: account.o
    Only in ./: bitlbee
    Only in ./: bitlbee.o
    Only in ./: commands.o
    Only in ./: config.h
    Only in ./: conf.o
    Only in ./: crypting.o
    Only in ./: diff
    Only in ./: help.o
    Only in ./: ini.o
    diff -ur ../bitlbee-1.0.3-original/irc.c ./irc.c
    old new  
    116116        set_add( irc, "buddy_sendbuffer", "false", set_eval_bool ); 
    117117        set_add( irc, "buddy_sendbuffer_delay", "200", set_eval_int ); 
    118118        set_add( irc, "charset", "iso8859-1", set_eval_charset ); 
     119        set_add( irc, "oscar_recode_charset", "iso8859-1", set_eval_oscar_recode_charset ); 
    119120        set_add( irc, "debug", "false", set_eval_bool ); 
    120121        set_add( irc, "default_target", "root", NULL ); 
    121122        set_add( irc, "display_namechanges", "false", set_eval_bool ); 
  • protocols/oscar/oscar.c

    Only in ./: irc.o
    Only in ./: log.o
    Only in ./: Makefile.settings
    Only in ./: nick.o
    Only in ./protocols/jabber: expat.o
    Only in ./protocols/jabber: hashtable.o
    Only in ./protocols/jabber: jabber_mod.o
    Only in ./protocols/jabber: jabber.o
    Only in ./protocols/jabber: jid.o
    Only in ./protocols/jabber: jpacket.o
    Only in ./protocols/jabber: jutil.o
    Only in ./protocols/jabber: log.o
    Only in ./protocols/jabber: pool.o
    Only in ./protocols/jabber: str.o
    Only in ./protocols/jabber: xmlnode.o
    Only in ./protocols/jabber: xmlparse.o
    Only in ./protocols/jabber: xmlrole.o
    Only in ./protocols/jabber: xmltok.o
    Only in ./protocols: md5.o
    Only in ./protocols: nogaim.o
    Only in ./protocols/oscar: admin.o
    Only in ./protocols/oscar: auth.o
    Only in ./protocols/oscar: bos.o
    Only in ./protocols/oscar: buddylist.o
    Only in ./protocols/oscar: chatnav.o
    Only in ./protocols/oscar: chat.o
    Only in ./protocols/oscar: conn.o
    Only in ./protocols/oscar: icq.o
    Only in ./protocols/oscar: im.o
    Only in ./protocols/oscar: info.o
    Only in ./protocols/oscar: misc.o
    Only in ./protocols/oscar: msgcookie.o
    diff -ur ../bitlbee-1.0.3-original/protocols/oscar/oscar.c ./protocols/oscar/oscar.c
    old new  
    10291029        return 1; 
    10301030} 
    10311031 
     1032extern GSList *irc_connection_list; 
     1033 
    10321034static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { 
     1035        char *src=""; 
    10331036        char *tmp = g_malloc(BUF_LONG + 1); 
    10341037        struct gaim_connection *gc = sess->aux_data; 
    10351038        int flags = 0; 
     
    10381041                flags |= IM_FLAG_AWAY; 
    10391042         
    10401043        if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) { 
    1041                 char *src; 
    10421044                 
    10431045                if (args->icbmflags & AIM_IMFLAGS_UNICODE) 
    10441046                        src = "UNICODEBIG"; 
    10451047                else 
    1046                         src = "ISO8859-1"; 
     1048                { 
     1049                        char *cs; 
     1050                        irc_t *irc = (irc_t*)irc_connection_list->data; 
     1051                        if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 
     1052                                src = cs; 
     1053                        else 
     1054                                src = "iso8859-1"; 
     1055                } 
    10471056                 
    10481057                /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */ 
    10491058                if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) { 
     
    10631072                                } 
    10641073                        } 
    10651074                } else { 
    1066                         g_snprintf(tmp, BUF_LONG, "%s", args->msg); 
     1075                        char *cs; 
     1076                        irc_t *irc = (irc_t*)irc_connection_list->data; 
     1077                        if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 
     1078                                src = cs; 
     1079                        else 
     1080                                src = "iso8859-1"; 
     1081                        if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) < 0) { 
     1082                                g_snprintf(tmp, BUF_LONG, "[1%s]%s", src, args->msg); 
     1083                        } 
    10671084                } 
    1068         } else 
    1069                 g_snprintf(tmp, BUF_LONG, "%s", args->msg); 
    1070          
     1085        } else { 
     1086                char *cs; 
     1087                irc_t *irc = (irc_t*)irc_connection_list->data; 
     1088                if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 
     1089                        src = cs; 
     1090                else 
     1091                        src = "iso8859-1"; 
     1092                if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) < 0) { 
     1093                        g_snprintf(tmp, BUF_LONG, "[2%s]%s", src, args->msg); 
     1094                } 
     1095        } 
     1096 
    10711097        strip_linefeed(tmp); 
    10721098        serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL), -1); 
    10731099        g_free(tmp); 
     
    17681794                        char sender[32]; 
    17691795                        char *dialog_msg = g_strdup(msg->msg); 
    17701796                        time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); 
     1797                        char *tmp = g_malloc(BUF_LONG + 1); 
     1798                        char *src = ""; 
     1799                        char *cs; 
     1800                        irc_t *irc = (irc_t*)irc_connection_list->data; 
     1801                        if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 
     1802                                src = cs; 
     1803                        else 
     1804                                src = "iso8859-1"; 
    17711805                        g_snprintf(sender, sizeof(sender), "%u", msg->sender); 
    17721806                        strip_linefeed(dialog_msg); 
    1773                         serv_got_im(gc, sender, dialog_msg, 0, t, -1); 
     1807                        if (do_iconv(src, "UTF-8", dialog_msg, tmp, strlen (msg->msg), BUF_LONG) < 0) 
     1808                                tmp = dialog_msg; 
     1809                        serv_got_im(gc, sender, tmp, 0, t, -1); 
     1810                        if (dialog_msg != tmp) 
     1811                                g_free (tmp); 
    17741812                        g_free(dialog_msg); 
    17751813                } break; 
    17761814 
     
    18381876        } else { 
    18391877                struct aim_sendimext_args args; 
    18401878                char *s; 
     1879                char *cs; 
     1880                char *src=""; 
     1881                irc_t *irc = (irc_t*)irc_connection_list->data; 
     1882                if( ( cs = set_getstr( irc, "oscar_recode_charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 
     1883                        src = cs; 
     1884                else 
     1885                        src = "iso8859-1"; 
     1886 
    18411887                 
    18421888                args.flags = AIM_IMFLAGS_ACK; 
    18431889                if (odata->icq) 
     
    18511897                        s = g_malloc(BUF_LONG); 
    18521898                        /* Try if we can put it in an ISO8859-1 string first. 
    18531899                           If we can't, fall back to UTF16. */ 
    1854                         if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { 
     1900                        if ((ret = do_iconv("UTF-8", src, message, s, len, BUF_LONG)) >= 0) { 
    18551901                                args.flags |= AIM_IMFLAGS_ISO_8859_1; 
    18561902                                len = ret; 
    18571903                        } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { 
     
    18631909                                s = message; 
    18641910                        } 
    18651911                } else { 
     1912                        fprintf (stderr, "outgoing message is ascii!\n"); 
    18661913                        s = message; 
    18671914                } 
    18681915                 
  • util.c

    Only in ./protocols/oscar: oscar_mod.o
    Only in ./protocols/oscar: oscar.o
    Only in ./protocols/oscar: oscar_util.o
    Only in ./protocols/oscar: rxhandlers.o
    Only in ./protocols/oscar: rxqueue.o
    Only in ./protocols/oscar: search.o
    Only in ./protocols/oscar: service.o
    Only in ./protocols/oscar: snac.o
    Only in ./protocols/oscar: ssi.o
    Only in ./protocols/oscar: stats.o
    Only in ./protocols/oscar: tlv.o
    Only in ./protocols/oscar: txqueue.o
    Only in ./protocols: protocols.o
    Only in ./protocols: proxy.o
    Only in ./protocols: sha.o
    Only in ./protocols: ssl_gnutls.o
    Only in ./: query.o
    Only in ./: set.o
    Only in ./: unix.o
    Only in ./: url.o
    Only in ./: user.o
    diff -ur ../bitlbee-1.0.3-original/util.c ./util.c
    old new  
    453453        iconv_close( cd ); 
    454454        return( value ); 
    455455} 
     456 
     457char *set_eval_oscar_recode_charset( irc_t *irc, set_t *set, char *value ) 
     458{ 
     459        iconv_t cd; 
     460 
     461        if ( g_strncasecmp( value, "none", 4 ) == 0 ) 
     462                return( value ); 
     463 
     464        cd = iconv_open( "UTF-8", value ); 
     465        if( cd == (iconv_t) -1 ) 
     466                return( NULL ); 
     467 
     468        iconv_close( cd ); 
     469        return( value ); 
     470} 
  • util.h

    diff -ur ../bitlbee-1.0.3-original/util.h ./util.h
    old new  
    4646 
    4747G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ); 
    4848char *set_eval_charset( irc_t *irc, set_t *set, char *value ); 
     49char *set_eval_oscar_recode_charset( irc_t *irc, set_t *set, char *value ); 
    4950 
    5051#endif