1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 06:25:41 +02:00

Add upgrade functions in script plugin API

This commit is contained in:
Sebastien Helleu
2009-02-22 16:49:38 +01:00
parent b2584798a1
commit 2c9bf846a6
18 changed files with 1149 additions and 47 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+42 -3
View File
@@ -105,15 +105,15 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
struct t_config_section *section,
const char *option_name,
const char *value),
char *function_read,
const char *function_read,
void (*callback_write)(void *data,
struct t_config_file *config_file,
const char *section_name),
char *function_write,
const char *function_write,
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
const char *section_name),
char *function_write_default,
const char *function_write_default,
int (*callback_create_option)(void *data,
struct t_config_file *config_file,
struct t_config_section *section,
@@ -1521,3 +1521,42 @@ script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin,
return return_code;
}
/*
* script_api_upgrade_read: read upgrade file
* return 1 if ok, 0 if error
*/
int
script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_upgrade_file *upgrade_file,
int (*callback_read)(void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist),
const char *function_read)
{
struct t_script_callback *script_callback;
int rc;
if (!function_read || !function_read[0])
return 0;
script_callback = script_callback_alloc ();
if (!script_callback)
return 0;
script_callback->script = script;
script_callback->function = strdup (function_read);
script_callback->upgrade_file = upgrade_file;
script_callback_add (script, script_callback);
rc = weechat_upgrade_read (upgrade_file,
callback_read,
script_callback);
script_callback_remove (script, script_callback);
return rc;
}
+8
View File
@@ -254,5 +254,13 @@ extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin
extern int script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option);
extern int script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_upgrade_file *upgrade_file,
int (*callback_read)(void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist),
const char *function_read);
#endif /* script-api.h */
+2
View File
@@ -47,6 +47,7 @@ script_callback_alloc ()
new_script_callback->hook = NULL;
new_script_callback->buffer = NULL;
new_script_callback->bar_item = NULL;
new_script_callback->upgrade_file = NULL;
return new_script_callback;
}
@@ -133,6 +134,7 @@ script_callback_print_log (struct t_weechat_plugin *weechat_plugin,
weechat_log_printf (" hook. . . . . . . . : 0x%lx", script_callback->hook);
weechat_log_printf (" buffer. . . . . . . : 0x%lx", script_callback->buffer);
weechat_log_printf (" bar_item. . . . . . : 0x%lx", script_callback->bar_item);
weechat_log_printf (" upgrade_file. . . . : 0x%lx", script_callback->upgrade_file);
weechat_log_printf (" prev_callback . . . : 0x%lx", script_callback->prev_callback);
weechat_log_printf (" next_callback . . . : 0x%lx", script_callback->next_callback);
}
+1
View File
@@ -29,6 +29,7 @@ struct t_script_callback
struct t_hook *hook; /* not NULL for hook */
struct t_gui_buffer *buffer; /* not NULL for buffer */
struct t_gui_bar_item *bar_item; /* not NULL for bar item */
struct t_upgrade_file *upgrade_file; /* not NULL for upgrade file */
struct t_script_callback *prev_callback; /* link to next callback */
struct t_script_callback *next_callback; /* link to previous callback */
};
File diff suppressed because it is too large Load Diff