Ticket #53: bitlbee-recode-0.6.2.patch

File bitlbee-recode-0.6.2.patch, 7.3 KB (added by hmich, 2 years ago)

patch against bitlbee 1.2

  • bitlbee-1.2/irc.c

    Only in bitlbee-1.2: bitlbee.pc
    Only in bitlbee-1.2: config.h
    diff -aur tmp/bitlbee-1.2/irc.c bitlbee-1.2/irc.c
    old new  
    1   /********************************************************************\ 
     1/********************************************************************   \ 
    22  * BitlBee -- An IRC to other IM-networks gateway                     * 
    33  *                                                                    * 
    44  * Copyright 2002-2004 Wilmer van der Gaast and others                * 
     
    109109        set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 
    110110        set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 
    111111        set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 
     112    set_add( &irc->set, "oscar_recode_charset", "utf-8", set_eval_oscar_recode_charset, irc ); 
    112113        set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 
    113114        set_add( &irc->set, "default_target", "root", NULL, irc ); 
    114115        set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 
  • bitlbee-1.2/protocols/oscar/oscar.c

    Only in bitlbee-1.2: Makefile.settings
    Only in bitlbee-1.2/protocols/oscar: #*merge<2>*#4941WKm#
    Only in bitlbee-1.2/protocols/oscar: #*merge*#4941JAg#
    diff -aur tmp/bitlbee-1.2/protocols/oscar/oscar.c bitlbee-1.2/protocols/oscar/oscar.c
    old new  
    10261026        return 1; 
    10271027} 
    10281028 
     1029static char *get_oscar_recode_charset(struct im_connection *ic ) { 
     1030    char *cs; 
     1031    char *src = "ISO8859-1"; 
     1032    if ((cs = set_getstr(&ic->irc->set, "oscar_recode_charset")) && (g_strcasecmp(cs, "utf-8") != 0)) 
     1033        src = cs; 
     1034    return src; 
     1035} 
     1036 
    10291037static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { 
    10301038        char *tmp = g_malloc(BUF_LONG + 1); 
    10311039        struct im_connection *ic = sess->aux_data; 
     
    10401048                if (args->icbmflags & AIM_IMFLAGS_UNICODE) 
    10411049                        src = "UNICODEBIG"; 
    10421050                else 
    1043                         src = "ISO8859-1"; 
    1044                  
     1051            src = get_oscar_recode_charset(ic); 
     1052 
    10451053                /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */ 
    10461054                if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) { 
    10471055                        // Successfully converted! 
     
    22372245{ 
    22382246        struct im_connection *ic = sess->aux_data; 
    22392247        struct oscar_data *od = ic->proto_data; 
     2248    char tmp[BUF_LONG]; 
    22402249        gchar who[16]; 
    22412250        GString *str; 
    22422251        va_list ap; 
     
    22532262        str = g_string_sized_new(512); 
    22542263        g_snprintf(who, sizeof(who), "%u", info->uin); 
    22552264 
     2265#define translate(x) ((do_iconv(get_oscar_recode_charset(ic), "UTF-8", x, tmp, strlen(x), BUF_LONG) >= 0) ? tmp : x) 
     2266 
    22562267        g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),  
    2257         info->nick ? info->nick : "-"); 
    2258         g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first); 
    2259         g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last); 
     2268                    info->nick ? translate(info->nick) : "-"); 
     2269        g_string_append_printf(str, "\n%s: %s", _("First Name"), translate(info->first)); 
     2270        g_string_append_printf(str, "\n%s: %s", _("Last Name"), translate(info->last)); 
    22602271        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email); 
    22612272        if (info->numaddresses && info->email2) { 
    22622273                int i; 
     
    22892300        g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage); 
    22902301        if (info->info && info->info[0]) { 
    22912302                g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),  
    2292                 info->info, _("End of Additional Information")); 
     2303                          translate(info->info), _("End of Additional Information")); 
    22932304        } 
    22942305        g_string_append_c(str, '\n'); 
    22952306        if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 
    22962307                g_string_append_printf(str, "%s:", _("Home Address")); 
    2297                 g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr); 
    2298                 g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity); 
    2299                 g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);  
     2308                g_string_append_printf(str, "\n%s: %s", _("Address"), translate(info->homeaddr)); 
     2309                g_string_append_printf(str, "\n%s: %s", _("City"), translate(info->homecity)); 
     2310                g_string_append_printf(str, "\n%s: %s", _("State"), translate(info->homestate));  
    23002311                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip); 
    23012312                g_string_append_c(str, '\n'); 
    23022313        } 
    23032314        if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 
    23042315                g_string_append_printf(str, "%s:", _("Work Address")); 
    2305                 g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr); 
    2306                 g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity); 
    2307                 g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate); 
     2316                g_string_append_printf(str, "\n%s: %s", _("Address"), translate(info->workaddr)); 
     2317                g_string_append_printf(str, "\n%s: %s", _("City"), translate(info->workcity)); 
     2318                g_string_append_printf(str, "\n%s: %s", _("State"), translate(info->workstate)); 
    23082319                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip); 
    23092320                g_string_append_c(str, '\n'); 
    23102321        } 
    23112322        if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 
    23122323                g_string_append_printf(str, "%s:", _("Work Information")); 
    2313                 g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany); 
    2314                 g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision); 
    2315                 g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition); 
     2324                g_string_append_printf(str, "\n%s: %s", _("Company"), translate(info->workcompany)); 
     2325                g_string_append_printf(str, "\n%s: %s", _("Division"), translate(info->workdivision)); 
     2326                g_string_append_printf(str, "\n%s: %s", _("Position"), translate(info->workposition)); 
    23162327                if (info->workwebpage && info->workwebpage[0]) { 
    23172328                        g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage); 
    23182329                } 
    23192330                g_string_append_c(str, '\n'); 
    23202331        } 
    23212332 
     2333#undef translate 
     2334 
    23222335        imcb_log(ic, "%s\n%s", _("User Info"), str->str); 
    23232336        g_string_free(str, TRUE); 
    23242337 
  • bitlbee-1.2/set.c

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

    diff -aur tmp/bitlbee-1.2/set.h bitlbee-1.2/set.h
    old new  
    9797char *set_eval_to_char( set_t *set, char *value ); 
    9898char *set_eval_ops( set_t *set, char *value ); 
    9999char *set_eval_charset( set_t *set, char *value ); 
     100char *set_eval_oscar_recode_charset( set_t *set, char *value ); 
    100101 
    101102#endif /* __SET_H__ */