diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/servers-reconnect.c | 4 | ||||
-rw-r--r-- | src/fe-text/gui-printtext.c | 7 | ||||
-rw-r--r-- | src/fe-text/term-terminfo.c | 29 | ||||
-rw-r--r-- | src/fe-text/term.h | 2 | ||||
-rw-r--r-- | src/irc/core/irc-servers-reconnect.c | 3 | ||||
-rw-r--r-- | src/irc/core/irc-session.c | 15 |
6 files changed, 49 insertions, 11 deletions
diff --git a/src/core/servers-reconnect.c b/src/core/servers-reconnect.c index ae97ecd2..f419035b 100644 --- a/src/core/servers-reconnect.c +++ b/src/core/servers-reconnect.c @@ -420,8 +420,8 @@ static void cmd_reconnect(const char *data, SERVER_REC *server) cmd_param_error(CMDERR_NOT_CONNECTED); rec = reconnects->data; } else { - if (g_ascii_strncasecmp(data, "RECON-", 6) == 0) - data += 6; + if (g_ascii_strncasecmp(tag, "RECON-", 6) == 0) + tag += 6; tagnum = atoi(tag); rec = tagnum <= 0 ? NULL : reconnect_find_tag(tagnum); diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c index 547d39c9..d8272df5 100644 --- a/src/fe-text/gui-printtext.c +++ b/src/fe-text/gui-printtext.c @@ -220,16 +220,15 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, get_colors(flags, &fg, &bg, &attr); if (window == NULL) { - g_return_if_fail(next_xpos != -1); + g_return_if_fail(next_xpos != -1); term_set_color2(root_window, attr, fg, bg); term_move(root_window, next_xpos, next_ypos); if (flags & GUI_PRINT_FLAG_CLRTOEOL) term_clrtoeol(root_window); - term_addstr(root_window, str); - next_xpos += strlen(str); /* FIXME utf8 or big5 */ - return; + next_xpos += term_addstr(root_window, str); + return; } lineinfo.level = dest == NULL ? 0 : dest->level; diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index ded79c28..27be904e 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -522,15 +522,36 @@ void term_add_unichar(TERM_WINDOW *window, unichar chr) } } -void term_addstr(TERM_WINDOW *window, const char *str) +int term_addstr(TERM_WINDOW *window, const char *str) { - int len; + int len, raw_len; + unichar tmp; + const char *ptr; if (vcmove) term_move_real(); - len = strlen(str); /* FIXME utf8 or big5 */ + + len = 0; + raw_len = strlen(str); + + /* The string length depends on the terminal encoding */ + + ptr = str; + + if (term_type == TERM_TYPE_UTF8) { + while (*ptr != '\0') { + tmp = g_utf8_get_char(ptr); + len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1; + ptr = g_utf8_next_char(ptr); + } + } else + len = raw_len; + term_printed_text(len); - fwrite(str, 1, len, window->term->out); + /* Use strlen() here since we need the number of raw bytes */ + fwrite(str, 1, raw_len, window->term->out); + + return len; } void term_clrtoeol(TERM_WINDOW *window) diff --git a/src/fe-text/term.h b/src/fe-text/term.h index cdcc787a..f0a76c42 100644 --- a/src/fe-text/term.h +++ b/src/fe-text/term.h @@ -83,7 +83,7 @@ void term_set_color(TERM_WINDOW *window, int col); void term_move(TERM_WINDOW *window, int x, int y); void term_addch(TERM_WINDOW *window, char chr); void term_add_unichar(TERM_WINDOW *window, unichar chr); -void term_addstr(TERM_WINDOW *window, const char *str); +int term_addstr(TERM_WINDOW *window, const char *str); void term_clrtoeol(TERM_WINDOW *window); void term_move_cursor(int x, int y); diff --git a/src/irc/core/irc-servers-reconnect.c b/src/irc/core/irc-servers-reconnect.c index b0aad26f..ca61492d 100644 --- a/src/irc/core/irc-servers-reconnect.c +++ b/src/irc/core/irc-servers-reconnect.c @@ -48,6 +48,9 @@ static void sig_server_connect_copy(SERVER_CONNECT_REC **dest, rec->max_whois = src->max_whois; rec->usermode = g_strdup(src->usermode); rec->alternate_nick = g_strdup(src->alternate_nick); + rec->sasl_mechanism = src->sasl_mechanism; + rec->sasl_username = src->sasl_username; + rec->sasl_password = src->sasl_password; *dest = (SERVER_CONNECT_REC *) rec; } diff --git a/src/irc/core/irc-session.c b/src/irc/core/irc-session.c index ea65d8a5..18e8e5c7 100644 --- a/src/irc/core/irc-session.c +++ b/src/irc/core/irc-session.c @@ -28,6 +28,8 @@ #include "irc-channels.h" #include "irc-nicklist.h" +#include "sasl.h" + struct _isupport_data { CONFIG_REC *config; CONFIG_NODE *node; }; static void session_isupport_foreach(char *key, char *value, struct _isupport_data *data) @@ -65,6 +67,10 @@ static void sig_session_save_server(IRC_SERVER_REC *server, CONFIG_REC *config, config_node_set_str(config, node, "away_reason", server->away_reason); config_node_set_bool(config, node, "emode_known", server->emode_known); + config_node_set_int(config, node, "sasl_mechanism", server->connrec->sasl_mechanism); + config_node_set_str(config, node, "sasl_username", server->connrec->sasl_username); + config_node_set_str(config, node, "sasl_password", server->connrec->sasl_password); + config_node_set_bool(config, node, "isupport_sent", server->isupport_sent); isupport = config_node_section(config, node, "isupport", NODE_TYPE_BLOCK); isupport_data.config = config; @@ -90,6 +96,15 @@ static void sig_session_restore_server(IRC_SERVER_REC *server, server->emode_known = config_node_get_bool(node, "emode_known", FALSE); server->isupport_sent = config_node_get_bool(node, "isupport_sent", FALSE); + server->connrec->sasl_mechanism = config_node_get_int(node, "sasl_mechanism", SASL_MECHANISM_NONE); + /* The fields below might have been filled when loading the chatnet + * description from the config and we favor the content that's been saved + * in the session file over that. */ + g_free(server->connrec->sasl_username); + server->connrec->sasl_username = g_strdup(config_node_get_str(node, "sasl_username", NULL)); + g_free(server->connrec->sasl_password); + server->connrec->sasl_password = g_strdup(config_node_get_str(node, "sasl_password", NULL)); + if (server->isupport == NULL) { server->isupport = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal); |