diff options
Diffstat (limited to 'root_commands.c')
-rw-r--r-- | root_commands.c | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/root_commands.c b/root_commands.c index 1bbd1722..338fdf5f 100644 --- a/root_commands.c +++ b/root_commands.c @@ -295,6 +295,11 @@ static void cmd_save(irc_t *irc, char **cmd) irc_rootmsg(irc, "Please create an account first (see \x02help register\x02)"); } else if (storage_save(irc, NULL, TRUE) == STORAGE_OK) { irc_rootmsg(irc, "Configuration saved"); + + if (irc->save_source_id != -1) { + b_event_remove(irc->save_source_id); + irc->save_source_id = -1; + } } else { irc_rootmsg(irc, "Configuration could not be saved!"); } @@ -368,6 +373,10 @@ static int cmd_set_real(irc_t *irc, char **cmd, set_t **head, cmd_set_checkflags } else { cmd_showset(irc, head, set_name); } + + if (st /* XXX: && !(s->flags & SET_NOSAVE)*/) { + storage_setup_auto_save(irc); + } } else if (set_name) { cmd_showset(irc, head, set_name); } else { @@ -662,6 +671,23 @@ static void cmd_channel(irc_t *irc, char **cmd) "channels you're still in cannot be deleted).", irc->default_channel->name); } + } else if (len >= 1 && g_strncasecmp(cmd[2], "rename", len) == 0) { + if (strlen(cmd[3]) < 1) { + irc_rootmsg(irc, "You have to specify new name."); + } else if (!(ic->flags & IRC_CHANNEL_JOINED) && + ic != ic->irc->default_channel) { + if (irc_channel_name_hint(ic, cmd[3])) { + irc_rootmsg(irc, "Channel %s renamed to %s.", + cmd[1], cmd[3]); + } else { + irc_rootmsg(irc, "Failed to rename channel %s to %s.", + cmd[1], cmd[3]); + } + } else { + irc_rootmsg(irc, "Couldn't rename channel (main channel %s or " + "channels you're still in cannot be renamed).", + irc->default_channel->name); + } } else { irc_rootmsg(irc, "Unknown command: %s [...] %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", @@ -1016,6 +1042,8 @@ static void cmd_set(irc_t *irc, char **cmd) cmd_set_real(irc, cmd, &irc->b->set, NULL); } +#define BLIST_NICK_MAXLEN 16 + static void cmd_blist(irc_t *irc, char **cmd) { int online = 0, away = 0, offline = 0, ismatch = 0; @@ -1024,7 +1052,8 @@ static void cmd_blist(irc_t *irc, char **cmd) GError *error = NULL; char s[256]; char *format; - int n_online = 0, n_away = 0, n_offline = 0; + char *padded; + int n_online = 0, n_away = 0, n_offline = 0, b_mode = 0; if (cmd[1] && g_strcasecmp(cmd[1], "all") == 0) { online = offline = away = 1; @@ -1049,11 +1078,14 @@ static void cmd_blist(irc_t *irc, char **cmd) if (strchr(irc->umode, 'b') != NULL) { format = "%s\t%s\t%s"; + b_mode = 1; } else { - format = "%-16.16s %-40.40s %s"; + format = "%s %-40.40s %s"; } - irc_rootmsg(irc, format, "Nick", "Handle/Account", "Status"); + padded = b_mode ? g_strdup("Nick") : str_pad_and_truncate("Nick", BLIST_NICK_MAXLEN, NULL); + irc_rootmsg(irc, format, padded, "Handle/Account", "Status"); + g_free(padded); if (irc->root->last_channel && strcmp(set_getstr(&irc->root->last_channel->set, "type"), "control") != 0) { @@ -1083,7 +1115,11 @@ static void cmd_blist(irc_t *irc, char **cmd) } g_snprintf(s, sizeof(s) - 1, "%s %s", bu->handle, bu->ic->acc->tag); - irc_rootmsg(irc, format, iu->nick, s, st); + + padded = b_mode ? g_strdup(iu->nick) : str_pad_and_truncate(iu->nick, BLIST_NICK_MAXLEN, NULL); + irc_rootmsg(irc, format, padded, s, st); + + g_free(padded); } n_online++; @@ -1092,7 +1128,11 @@ static void cmd_blist(irc_t *irc, char **cmd) if ((bu->flags & BEE_USER_ONLINE) && (bu->flags & BEE_USER_AWAY)) { if (ismatch == 1 && away == 1) { g_snprintf(s, sizeof(s) - 1, "%s %s", bu->handle, bu->ic->acc->tag); - irc_rootmsg(irc, format, iu->nick, s, irc_user_get_away(iu)); + + padded = b_mode ? g_strdup(iu->nick) : str_pad_and_truncate(iu->nick, BLIST_NICK_MAXLEN, NULL); + irc_rootmsg(irc, format, padded, s, irc_user_get_away(iu)); + + g_free(padded); } n_away++; } @@ -1100,7 +1140,11 @@ static void cmd_blist(irc_t *irc, char **cmd) if (!(bu->flags & BEE_USER_ONLINE)) { if (ismatch == 1 && offline == 1) { g_snprintf(s, sizeof(s) - 1, "%s %s", bu->handle, bu->ic->acc->tag); - irc_rootmsg(irc, format, iu->nick, s, "Offline"); + + padded = b_mode ? g_strdup(iu->nick) : str_pad_and_truncate(iu->nick, BLIST_NICK_MAXLEN, NULL); + irc_rootmsg(irc, format, padded, s, "Offline"); + + g_free(padded); } n_offline++; } @@ -1504,6 +1548,13 @@ static void cmd_nick(irc_t *irc, char **cmd) irc_rootmsg(irc, "This command is deprecated. Try: account %s set display_name", cmd[1]); } +#ifdef WITH_GNUTLS +static void cmd_certfp(irc_t *irc, char **cmd) +{ + irc_rootmsg(irc, "Show current/set new certfp"); +} +#endif + /* Maybe this should be a stand-alone command as well? */ static void bitlbee_whatsnew(irc_t *irc) { @@ -1555,6 +1606,9 @@ command_t root_commands[] = { { "set", 0, cmd_set, 0 }, { "transfer", 0, cmd_transfer, 0 }, { "yes", 0, cmd_yesno, 0 }, +#ifdef WITH_GNUTLS + { "certfp", 1, cmd_certfp, 0 }, +#endif /* Not expecting too many plugins adding root commands so just make a dumb array with some empty entried at the end. */ { NULL }, |