diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-12-08 23:54:07 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-12-08 23:54:07 +0100 |
commit | 641de51bdbd449196c0d54102d17641cd4b5d3d7 (patch) | |
tree | 820e555781f6cb2d55bd06b5b71ee9ef083436d9 /src/core | |
parent | 3f2155e548c0ebe86a694f69630f41d7503f679c (diff) | |
download | weechat-641de51bdbd449196c0d54102d17641cd4b5d3d7.zip |
api: allow creation of structure with hdata_update (allowed for hdata "history")
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-config-file.c | 6 | ||||
-rw-r--r-- | src/core/wee-hdata.c | 11 | ||||
-rw-r--r-- | src/core/wee-hdata.h | 3 | ||||
-rw-r--r-- | src/core/wee-upgrade.c | 2 |
4 files changed, 13 insertions, 9 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index db34d95ee..505e14a8c 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -2607,7 +2607,7 @@ config_file_hdata_config_file_cb (void *data, const char *hdata_name) (void) data; hdata = hdata_new (NULL, hdata_name, "prev_config", "next_config", - 0, NULL, NULL); + 0, 0, NULL, NULL); if (hdata) { HDATA_VAR(struct t_config_file, plugin, POINTER, 0, NULL, "plugin"); @@ -2639,7 +2639,7 @@ config_file_hdata_config_section_cb (void *data, const char *hdata_name) (void) data; hdata = hdata_new (NULL, hdata_name, "prev_section", "next_section", - 0, NULL, NULL); + 0, 0, NULL, NULL); if (hdata) { HDATA_VAR(struct t_config_section, config_file, POINTER, 0, NULL, "config_file"); @@ -2677,7 +2677,7 @@ config_file_hdata_config_option_cb (void *data, const char *hdata_name) (void) data; hdata = hdata_new (NULL, hdata_name, "prev_option", "next_option", - 0, NULL, NULL); + 0, 0, NULL, NULL); if (hdata) { HDATA_VAR(struct t_config_option, config_file, POINTER, 0, NULL, "config_file"); diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c index 827573cc5..0ccad400d 100644 --- a/src/core/wee-hdata.c +++ b/src/core/wee-hdata.c @@ -75,7 +75,7 @@ hdata_free_var (struct t_hashtable *hashtable, struct t_hdata * hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name, const char *var_prev, const char *var_next, - int delete_allowed, + int create_allowed, int delete_allowed, int (*callback_update)(void *data, struct t_hdata *hdata, void *pointer, @@ -107,6 +107,7 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name, NULL, NULL); hashtable_set (weechat_hdata, hdata_name, new_hdata); + new_hdata->create_allowed = create_allowed; new_hdata->delete_allowed = delete_allowed; new_hdata->callback_update = callback_update; new_hdata->callback_update_data = callback_update_data; @@ -816,6 +817,10 @@ hdata_update (struct t_hdata *hdata, void *pointer, if (!hdata || !hashtable || !hdata->callback_update) return 0; + /* check if create of structure is allowed */ + if (hashtable_has_key (hashtable, "__create_allowed")) + return (int)hdata->create_allowed; + /* check if delete of structure is allowed */ if (hashtable_has_key (hashtable, "__delete_allowed")) return (int)hdata->delete_allowed; @@ -832,9 +837,6 @@ hdata_update (struct t_hdata *hdata, void *pointer, return (var->update_allowed) ? 1 : 0; } - if (!pointer) - return 0; - /* update data */ hdata->update_pending = 1; rc = (hdata->callback_update) (hdata->callback_update_data, @@ -1003,6 +1005,7 @@ hdata_print_log_map_cb (void *data, struct t_hashtable *hashtable, log_printf (" hash_list. . . . . . . : 0x%lx (hashtable: '%s')", ptr_hdata->hash_list, hashtable_get_string (ptr_hdata->hash_list, "keys_values")); + log_printf (" create_allowed . . . . : %d", (int)ptr_hdata->create_allowed); log_printf (" delete_allowed . . . . : %d", (int)ptr_hdata->delete_allowed); log_printf (" callback_update. . . . : 0x%lx", ptr_hdata->callback_update); log_printf (" callback_update_data . : 0x%lx", ptr_hdata->callback_update_data); diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h index 3139af4ef..f67637e8f 100644 --- a/src/core/wee-hdata.h +++ b/src/core/wee-hdata.h @@ -48,6 +48,7 @@ struct t_hdata struct t_hashtable *hash_list; /* hashtable with pointers on lists */ /* (used to search objects) */ + char create_allowed; /* create allowed? */ char delete_allowed; /* delete allowed? */ int (*callback_update) /* update callback */ (void *data, @@ -67,7 +68,7 @@ extern char *hdata_type_string[]; extern struct t_hdata *hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name, const char *var_prev, const char *var_next, - int delete_allowed, + int create_allowed, int delete_allowed, int (*callback_update)(void *data, struct t_hdata *hdata, void *pointer, diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c index fabf86045..ed8109334 100644 --- a/src/core/wee-upgrade.c +++ b/src/core/wee-upgrade.c @@ -356,7 +356,7 @@ upgrade_weechat_save () return 0; rc = 1; - rc &= upgrade_weechat_save_history (upgrade_file, last_history_global); + rc &= upgrade_weechat_save_history (upgrade_file, last_gui_history); rc &= upgrade_weechat_save_buffers (upgrade_file); rc &= upgrade_weechat_save_misc (upgrade_file); rc &= upgrade_weechat_save_hotlist (upgrade_file); |