1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

Automatic backwards compatibility transitions.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3144 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2003-11-16 17:27:09 +00:00 committed by cras
parent 1141081c34
commit 0235086ab9

View File

@ -393,6 +393,8 @@ static void sig_init_finished(void)
if (config_changed) {
/* some backwards compatibility changes were made to
config file, reload it */
g_warning("Some time and size related settings were "
"automatically changed to new format, please /SAVE");
signal_emit("setup changed", 0);
}
}
@ -434,14 +436,70 @@ void settings_clean_invalid(void)
}
}
static int backwards_compatibility(const char *module, CONFIG_NODE *node,
CONFIG_NODE *parent)
{
const char *new_key;
char *new_value;
int old_value;
/* FIXME: remove later - for 0.8.6 -> */
if (node->value == NULL || !is_numeric(node->value, '\0'))
return FALSE;
new_value = NULL; new_key = NULL;
old_value = atoi(node->value);
if (strcmp(module, "fe-text") == 0) {
if (strcasecmp(node->key, "lag_min_show") == 0)
new_value = g_strdup_printf("%dms", old_value*100);
else if (strcasecmp(node->key, "scrollback_hours") == 0) {
new_value = g_strdup_printf("%dh", old_value);
new_key = "scrollback_time";
}
} else if (strcmp(module, "irc/core") == 0) {
if (strcasecmp(node->key, "cmd_queue_speed") == 0)
new_value = g_strdup_printf("%dms", old_value);
} else if (strcmp(module, "irc/dcc") == 0) {
if (strcasecmp(node->key, "dcc_autoget_max_size") == 0)
new_value = g_strdup_printf("%dk", old_value);
} else if (strcmp(module, "irc/notify") == 0) {
if (strcasecmp(node->key, "notify_idle_time") == 0)
new_value = g_strdup_printf("%dmin", old_value);
} else if (strcmp(module, "core") == 0) {
if (strcasecmp(node->key, "write_buffer_mins") == 0) {
new_value = g_strdup_printf("%dmin", old_value);
new_key = "write_buffer_timeout";
} else if (strcasecmp(node->key, "write_buffer_kb") == 0) {
new_value = g_strdup_printf("%dk", old_value);
new_key = "write_buffer_size";
}
}
if (new_key != NULL || new_value != NULL) {
config_node_set_str(mainconfig, parent,
new_key != NULL ? new_key : node->key,
new_value != NULL ?
new_value : node->value);
if (new_key != NULL) {
/* remove old */
config_node_set_str(mainconfig, parent,
node->key, NULL);
}
config_changed = TRUE;
g_free(new_value);
}
return new_key != NULL;
}
/* verify that all settings in config file for `module' are actually found
from /SET list */
void settings_check_module(const char *module)
{
SETTINGS_REC *set;
CONFIG_NODE *node;
CONFIG_NODE *node, *parent;
GString *errors;
GSList *tmp;
GSList *tmp, *next;
int count;
g_return_if_fail(module != NULL);
@ -455,11 +513,16 @@ void settings_check_module(const char *module)
"file for module %s:", module);
count = 0;
parent = node;
tmp = config_node_first(node->value);
for (; tmp != NULL; tmp = config_node_next(tmp)) {
for (; tmp != NULL; tmp = next) {
node = tmp->data;
next = config_node_next(tmp);
set = g_hash_table_lookup(settings, node->key);
if (backwards_compatibility(module, node, parent))
continue;
if (set == NULL || strcmp(set->module, module) != 0) {
g_string_sprintfa(errors, " %s", node->key);
count++;