core: auto disable upgrade process (command line option "--upgrade") if the file weechat.upgrade is not found

v2.8-utf8proc
Sébastien Helleu 2019-06-24 21:35:37 +02:00
parent 98b5e90469
commit 1d6714e428
9 changed files with 29 additions and 58 deletions

View File

@ -26,6 +26,7 @@ New features::
Bug fixes::
* core: auto disable upgrade process (command line option "--upgrade") if the file weechat.upgrade is not found
* core: replace newlines by spaces in argument "completion" of function hook_command (issue #538)
* core: replace char "," by "~" in color codes to separate foreground from background (issue #1264)
* alias: remove default aliases /AME and /AMSG (issue #1355)

View File

@ -808,8 +808,10 @@ weechat_init (int argc, char *argv[], void (*gui_init_cb)())
if (weechat_upgrading)
{
upgrade_weechat_load (); /* upgrade with session file */
weechat_upgrade_count++; /* increase /upgrade count */
if (upgrade_weechat_load ()) /* upgrade with session file */
weechat_upgrade_count++; /* increase /upgrade count */
else
weechat_upgrading = 0;
}
weechat_startup_message (); /* display WeeChat startup message */
gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */

View File

@ -750,7 +750,9 @@ exec_debug_dump_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, upgrading;
/* make C compiler happy */
(void) argc;
(void) argv;
weechat_plugin = plugin;
@ -767,17 +769,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* hook completions */
exec_completion_init ();
/* look at arguments */
upgrading = 0;
for (i = 0; i < argc; i++)
{
if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
{
upgrading = 1;
}
}
if (upgrading)
if (weechat_exec_plugin->upgrading)
exec_buffer_set_callbacks ();
return WEECHAT_RC_OK;

View File

@ -164,7 +164,7 @@ irc_signal_upgrade_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, auto_connect, upgrading;
int i, auto_connect;
weechat_plugin = plugin;
@ -217,7 +217,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* look at arguments */
auto_connect = 1;
upgrading = 0;
for (i = 0; i < argc; i++)
{
if ((weechat_strcasecmp (argv[i], "-a") == 0)
@ -236,13 +235,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[i]);
}
}
else if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
{
upgrading = 1;
}
}
if (upgrading)
if (weechat_irc_plugin->upgrading)
{
if (!irc_upgrade_load ())
{

View File

@ -290,7 +290,6 @@ plugin_get_args (struct t_weechat_plugin *plugin,
|| (strcmp (argv[i], "--no-connect") == 0)
|| (strcmp (argv[i], "-s") == 0)
|| (strcmp (argv[i], "--no-script") == 0)
|| (strcmp (argv[i], "--upgrade") == 0)
|| (strncmp (argv[i], plugin->name,
strlen (plugin->name)) == 0))
{
@ -572,6 +571,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->initialized = 0;
ptr_option = config_weechat_debug_get (name);
new_plugin->debug = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
new_plugin->upgrading = weechat_upgrading;
new_plugin->variables = hashtable_new (
32,
WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING,
@ -1402,6 +1402,7 @@ plugin_hdata_plugin_cb (const void *pointer, void *data,
HDATA_VAR(struct t_weechat_plugin, priority, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, initialized, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, debug, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, upgrading, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, variables, HASHTABLE, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, prev_plugin, POINTER, 0, NULL, hdata_name);
HDATA_VAR(struct t_weechat_plugin, next_plugin, POINTER, 0, NULL, hdata_name);
@ -1460,6 +1461,8 @@ plugin_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "debug", plugin->debug))
return 0;
if (!infolist_new_var_integer (ptr_item, "upgrading", plugin->upgrading))
return 0;
if (!hashtable_add_to_infolist (plugin->variables, ptr_item, "var"))
return 0;
@ -1491,6 +1494,7 @@ plugin_print_log ()
log_printf (" priority . . . . . . . : %d", ptr_plugin->priority);
log_printf (" initialized. . . . . . : %d", ptr_plugin->initialized);
log_printf (" debug. . . . . . . . . : %d", ptr_plugin->debug);
log_printf (" upgrading. . . . . . . : %d", ptr_plugin->upgrading);
hashtable_print_log (ptr_plugin->variables, "variables");
log_printf (" prev_plugin. . . . . . : 0x%lx", ptr_plugin->prev_plugin);
log_printf (" next_plugin. . . . . . : 0x%lx", ptr_plugin->next_plugin);

View File

@ -187,8 +187,6 @@ relay_debug_dump_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, upgrading;
/* make C compiler happy */
(void) argc;
(void) argv;
@ -212,17 +210,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
relay_info_init ();
/* look at arguments */
upgrading = 0;
for (i = 0; i < argc; i++)
{
if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
{
upgrading = 1;
}
}
if (upgrading)
if (weechat_relay_plugin->upgrading)
relay_upgrade_load ();
relay_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,

View File

@ -1301,7 +1301,9 @@ trigger_debug_dump_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, upgrading;
/* make C compiler happy */
(void) argc;
(void) argv;
weechat_plugin = plugin;
@ -1320,17 +1322,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* hook completions */
trigger_completion_init ();
/* look at arguments */
upgrading = 0;
for (i = 0; i < argc; i++)
{
if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
{
upgrading = 1;
}
}
if (upgrading)
if (weechat_trigger_plugin->upgrading)
trigger_buffer_set_callbacks ();
return WEECHAT_RC_OK;

View File

@ -67,7 +67,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20190615-01"
#define WEECHAT_PLUGIN_API_VERSION "20190624-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -261,6 +261,9 @@ struct t_weechat_plugin
int priority; /* plugin priority (default is 1000) */
int initialized; /* plugin initialized? (init called) */
int debug; /* debug level for plugin (0=off) */
int upgrading; /* 1 if the plugin must load upgrade */
/* info on startup (if weechat is */
/* run with --upgrade) */
struct t_hashtable *variables; /* plugin custom variables */
struct t_weechat_plugin *prev_plugin; /* link to previous plugin */
struct t_weechat_plugin *next_plugin; /* link to next plugin */

View File

@ -1805,7 +1805,9 @@ xfer_debug_dump_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, upgrading;
/* make C compiler happy */
(void) argc;
(void) argv;
weechat_plugin = plugin;
@ -1835,15 +1837,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
xfer_info_init ();
/* look at arguments */
upgrading = 0;
for (i = 0; i < argc; i++)
{
if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
upgrading = 1;
}
if (upgrading)
if (weechat_xfer_plugin->upgrading)
xfer_upgrade_load ();
return WEECHAT_RC_OK;