diff options
author | Timo Sirainen <cras@irssi.org> | 2003-11-16 17:27:09 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2003-11-16 17:27:09 +0000 |
commit | 0235086ab9edca9b29669e3b9bc40cee8f891625 (patch) | |
tree | dff802fc9f20cd8f1d8bb680804d6a7dab90d209 /src/core/settings.c | |
parent | 1141081c34d0e8b560c06916ae41f78d2fd7b16d (diff) | |
download | irssi-0235086ab9edca9b29669e3b9bc40cee8f891625.zip |
Automatic backwards compatibility transitions.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3144 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/settings.c')
-rw-r--r-- | src/core/settings.c | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index e6e0c7d5..2037823b 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -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++; |