mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 01:03:14 +02:00
api: allow creation of structure with hdata_update (allowed for hdata "history")
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user