summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-06-24 21:35:37 +0200
committerSébastien Helleu <flashcode@flashtux.org>2019-06-24 21:35:37 +0200
commit1d6714e42820e837d18e46a7b6d9c25902e0193b (patch)
treee0ea19e1bbb41e3f98227132c624baab47d7099f /src/plugins
parent98b5e9046966ae0fde25409987dc98ec5f0b1af8 (diff)
downloadweechat-1d6714e42820e837d18e46a7b6d9c25902e0193b.zip
core: auto disable upgrade process (command line option "--upgrade") if the file weechat.upgrade is not found
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/exec/exec.c16
-rw-r--r--src/plugins/irc/irc.c9
-rw-r--r--src/plugins/plugin.c6
-rw-r--r--src/plugins/relay/relay.c14
-rw-r--r--src/plugins/trigger/trigger.c16
-rw-r--r--src/plugins/weechat-plugin.h5
-rw-r--r--src/plugins/xfer/xfer.c14
7 files changed, 24 insertions, 56 deletions
diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c
index d99c19803..58ed9f26b 100644
--- a/src/plugins/exec/exec.c
+++ b/src/plugins/exec/exec.c
@@ -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;
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index cb3456f4c..f42eddc2a 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -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 ())
{
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index de669e8fd..2f2304f6a 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -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);
diff --git a/src/plugins/relay/relay.c b/src/plugins/relay/relay.c
index 0ee62a154..f09540918 100644
--- a/src/plugins/relay/relay.c
+++ b/src/plugins/relay/relay.c
@@ -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,
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index ea4f903b9..30e1e1101 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -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;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index abf329fc6..4b1edce8e 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -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 */
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index c1372f2f3..4936a6d36 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -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;