Ticket #53: bitlbee-recode-0.6.3.patch

File bitlbee-recode-0.6.3.patch, 7.1 KB (added by newman, 18 months ago)

Runs OK with bitlbee-1.2.3, if anyone else, after three years, still cares...

  • bitlbee-1.2.

    diff -pruN bitlbee-1.2.3/irc.c bitlbee-1.2.3_new/irc.c
    old new  
    149149        s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 
    150150        s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 
    151151        s = set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 
     152        s = set_add( &irc->set, "oscar_recode_charset", "utf-8", set_eval_oscar_recode_charset, irc ); 
    152153        s = set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 
    153154        s = set_add( &irc->set, "default_target", "root", NULL, irc ); 
    154155        s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 
  • protocols/oscar/oscar.c

    diff -pruN bitlbee-1.2.3/protocols/oscar/oscar.c bitlbee-1.2.3_new/protocols/oscar/oscar.c
    old new  
    10551055        return 1; 
    10561056} 
    10571057 
     1058static char *get_oscar_recode_charset(struct im_connection *ic ) { 
     1059        char *cs; 
     1060        char *src = "cp1250"; 
     1061        if ((cs = set_getstr(&ic->irc->set, "oscar_recode_charset")) && (g_strcasecmp(cs, "utf-8") != 0)) 
     1062                src = cs; 
     1063        return src; 
     1064} 
     1065 
    10581066static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { 
    10591067        char *tmp = g_malloc(BUF_LONG + 1); 
    10601068        struct im_connection *ic = sess->aux_data; 
     
    10691077                if (args->icbmflags & AIM_IMFLAGS_UNICODE) 
    10701078                        src = "UNICODEBIG"; 
    10711079                else 
    1072                         src = "ISO8859-1"; 
    1073                  
     1080                        src = get_oscar_recode_charset(ic); 
     1081 
    10741082                /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */ 
    10751083                if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) { 
    10761084                        // Successfully converted! 
     
    22712279{ 
    22722280        struct im_connection *ic = sess->aux_data; 
    22732281        struct oscar_data *od = ic->proto_data; 
     2282        char tmp[BUF_LONG]; 
    22742283        gchar who[16]; 
    22752284        GString *str; 
    22762285        va_list ap; 
     
    22872296        str = g_string_sized_new(512); 
    22882297        g_snprintf(who, sizeof(who), "%u", info->uin); 
    22892298 
     2299#define translate(x) ((do_iconv(get_oscar_recode_charset(ic), "UTF-8", x, tmp, strlen(x), BUF_LONG) >= 0) ? tmp : x) 
     2300 
    22902301        g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),  
    2291         info->nick ? info->nick : "-"); 
    2292         g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first); 
    2293         g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last); 
     2302                        info->nick ? translate(info->nick) : "-"); 
     2303        g_string_append_printf(str, "\n%s: %s", _("First Name"), translate(info->first)); 
     2304        g_string_append_printf(str, "\n%s: %s", _("Last Name"), translate(info->last)); 
     2305 
    22942306        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email); 
    22952307        if (info->numaddresses && info->email2) { 
    22962308                int i; 
     
    23232335        g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage); 
    23242336        if (info->info && info->info[0]) { 
    23252337                g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),  
    2326                 info->info, _("End of Additional Information")); 
     2338                                translate(info->info), _("End of Additional Information")); 
    23272339        } 
    23282340        g_string_append_c(str, '\n'); 
    23292341        if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 
    23302342                g_string_append_printf(str, "%s:", _("Home Address")); 
    2331                 g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr); 
    2332                 g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity); 
    2333                 g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);  
     2343                g_string_append_printf(str, "\n%s: %s", _("Address"), translate(info->homeaddr)); 
     2344                g_string_append_printf(str, "\n%s: %s", _("City"), translate(info->homecity)); 
     2345                g_string_append_printf(str, "\n%s: %s", _("State"), translate(info->homestate));  
    23342346                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip); 
    23352347                g_string_append_c(str, '\n'); 
    23362348        } 
    23372349        if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 
    23382350                g_string_append_printf(str, "%s:", _("Work Address")); 
    2339                 g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr); 
    2340                 g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity); 
    2341                 g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate); 
     2351                g_string_append_printf(str, "\n%s: %s", _("Address"), translate(info->workaddr)); 
     2352                g_string_append_printf(str, "\n%s: %s", _("City"), translate(info->workcity)); 
     2353                g_string_append_printf(str, "\n%s: %s", _("State"), translate(info->workstate)); 
    23422354                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip); 
    23432355                g_string_append_c(str, '\n'); 
    23442356        } 
    23452357        if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 
    23462358                g_string_append_printf(str, "%s:", _("Work Information")); 
    2347                 g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany); 
    2348                 g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision); 
    2349                 g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition); 
     2359                g_string_append_printf(str, "\n%s: %s", _("Company"), translate(info->workcompany)); 
     2360                g_string_append_printf(str, "\n%s: %s", _("Division"), translate(info->workdivision)); 
     2361                g_string_append_printf(str, "\n%s: %s", _("Position"), translate(info->workposition)); 
    23502362                if (info->workwebpage && info->workwebpage[0]) { 
    23512363                        g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage); 
    23522364                } 
    23532365                g_string_append_c(str, '\n'); 
    23542366        } 
    23552367 
     2368#undef translate 
     2369 
    23562370        imcb_log(ic, "%s\n%s", _("User Info"), str->str); 
    23572371        g_string_free(str, TRUE); 
    23582372 
  • bitlbee-1.2.

    diff -pruN bitlbee-1.2.3/set.c bitlbee-1.2.3_new/set.c
    old new  
    245245         
    246246        return value; 
    247247} 
     248 
     249char *set_eval_oscar_recode_charset( set_t *set, char *value ) 
     250{ 
     251       GIConv cd; 
     252 
     253       if ( g_strncasecmp( value, "none", 4 ) == 0 ) 
     254               return value; 
     255 
     256       cd = g_iconv_open( "UTF-8", value ); 
     257       if( cd == (GIConv) -1 ) 
     258               return NULL; 
     259 
     260       g_iconv_close( cd ); 
     261       return value; 
     262} 
     263 
  • bitlbee-1.2.

    diff -pruN bitlbee-1.2.3/set.h bitlbee-1.2.3_new/set.h
    old new  
    100100/* Some not very generic evaluators that really shouldn't be here... */ 
    101101char *set_eval_to_char( set_t *set, char *value ); 
    102102char *set_eval_ops( set_t *set, char *value ); 
     103char *set_eval_oscar_recode_charset( set_t *set, char *value ); 
    103104 
    104105#endif /* __SET_H__ */