1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 19:23:13 +02:00

Disable auto-connect for plugins with command line option ("-a")

This commit is contained in:
Sebastien Helleu
2008-05-13 14:27:33 +02:00
parent a804fb1936
commit 673e4ad3be
9 changed files with 47 additions and 38 deletions
+1 -1
View File
@@ -1661,7 +1661,7 @@ command_quit (void *data, struct t_gui_buffer *buffer,
(argc > 1) ? argv_eol[1] : NULL);
/* force end of main loop */
quit_weechat = 1;
weechat_quit = 1;
return WEECHAT_RC_OK;
}
+2 -2
View File
@@ -940,7 +940,7 @@ string_iconv_to_internal (char *charset, char *string)
output = string_iconv (0,
(charset && charset[0]) ?
charset : local_charset,
charset : weechat_local_charset,
WEECHAT_INTERNAL_CHARSET,
input);
utf8_normalize (output, '?');
@@ -976,7 +976,7 @@ string_iconv_from_internal (char *charset, char *string)
output = string_iconv (1,
WEECHAT_INTERNAL_CHARSET,
(charset && charset[0]) ?
charset : local_charset,
charset : weechat_local_charset,
input);
free (input);
return output;
+2 -2
View File
@@ -41,7 +41,7 @@ int local_utf8 = 0;
void
utf8_init ()
{
local_utf8 = (string_strcasecmp (local_charset, "UTF-8") == 0);
local_utf8 = (string_strcasecmp (weechat_local_charset, "UTF-8") == 0);
}
/*
@@ -443,7 +443,7 @@ utf8_pos (char *string, int real_pos)
int count;
char *limit;
if (!string || !local_charset)
if (!string || !weechat_local_charset)
return real_pos;
count = 0;
+21 -22
View File
@@ -66,18 +66,16 @@
#include "../plugins/plugin.h"
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0]) */
char *weechat_session = NULL; /* WeeChat session file (for /upgrade cmd) */
time_t weechat_start_time; /* WeeChat start time (used by /uptime cmd) */
int quit_weechat; /* = 1 if quit request from user... why ? :'( */
int sigsegv = 0; /* SIGSEGV received? */
char *weechat_home = NULL; /* WeeChat home dir. (default: ~/.weechat) */
char *local_charset = NULL; /* local charset, for ex.: ISO-8859-1, UTF-8 */
int server_cmd_line; /* at least 1 server on WeeChat command line */
int auto_connect; /* enabled by default (cmd option to disable) */
int auto_load_plugins; /* enabled by default (cmd option to disable) */
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0])*/
char *weechat_session = NULL; /* session file (/upgrade) */
time_t weechat_start_time; /* start time (used by /uptime cmd) */
int weechat_quit; /* = 1 if quit request from user */
int weechat_sigsegv = 0; /* SIGSEGV received? */
char *weechat_home = NULL; /* home dir. (default: ~/.weechat) */
char *weechat_local_charset = NULL; /* example: ISO-8859-1, UTF-8 */
int weechat_server_cmd_line = 0; /* at least 1 server on cmd line */
int weechat_auto_load_plugins = 1; /* auto load plugins */
int weechat_auto_connect = 1; /* auto connect in plugins */
/*
@@ -181,15 +179,15 @@ weechat_parse_args (int argc, char *argv[])
weechat_argv0 = strdup (argv[0]);
weechat_session = NULL;
weechat_home = NULL;
server_cmd_line = 0;
auto_connect = 1;
auto_load_plugins = 1;
weechat_server_cmd_line = 0;
weechat_auto_load_plugins = 1;
weechat_auto_connect = 1;
for (i = 1; i < argc; i++)
{
if ((strcmp (argv[i], "-a") == 0)
|| (strcmp (argv[i], "--no-connect") == 0))
auto_connect = 0;
weechat_auto_connect = 0;
else if ((strcmp (argv[i], "-c") == 0)
|| (strcmp (argv[i], "--config") == 0))
{
@@ -248,7 +246,7 @@ weechat_parse_args (int argc, char *argv[])
else if ((strcmp (argv[i], "-p") == 0)
|| (strcmp (argv[i], "--no-plugin") == 0))
{
auto_load_plugins = 0;
weechat_auto_load_plugins = 0;
}
else if (strcmp (argv[i], "--session") == 0)
{
@@ -435,8 +433,8 @@ weechat_shutdown (int return_code, int crash)
if (weechat_home)
free (weechat_home);
log_close ();
if (local_charset)
free (local_charset);
if (weechat_local_charset)
free (weechat_local_charset);
if (crash)
abort();
@@ -459,9 +457,9 @@ main (int argc, char *argv[])
#endif
#ifdef HAVE_LANGINFO_CODESET
local_charset = strdup (nl_langinfo (CODESET));
weechat_local_charset = strdup (nl_langinfo (CODESET));
#else
local_charset = strdup ("");
weechat_local_charset = strdup ("");
#endif
utf8_init ();
@@ -488,7 +486,8 @@ main (int argc, char *argv[])
//session_load (weechat_session); /* load previous session if asked */
weechat_welcome_message (); /* display WeeChat welcome message */
command_startup (0); /* command executed before plugins */
plugin_init (auto_load_plugins); /* init plugin interface(s) */
plugin_init (weechat_auto_load_plugins); /* init plugin interface(s) */
weechat_auto_connect = 1; /* auto-connect for future plugins */
command_startup (1); /* command executed after plugins */
gui_main_loop (); /* WeeChat main loop */
+3 -2
View File
@@ -100,9 +100,10 @@
extern char *weechat_argv0;
extern time_t weechat_start_time;
extern int quit_weechat;
extern int weechat_quit;
extern char *weechat_home;
extern char *local_charset;
extern char *weechat_local_charset;
extern int weechat_auto_connect;
extern void weechat_dump (int crash);
extern void weechat_shutdown (int return_code, int crash);
+2 -2
View File
@@ -349,7 +349,7 @@ gui_keyboard_read_cb (void *data)
/* no data on stdin, terminal lost */
log_printf (_("Terminal lost, exiting WeeChat..."));
hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
quit_weechat = 1;
weechat_quit = 1;
return WEECHAT_RC_OK;
}
if (ret <= 0)
@@ -371,7 +371,7 @@ gui_keyboard_read_cb (void *data)
/* no data on stdin, terminal lost */
log_printf (_("Terminal lost, exiting WeeChat..."));
hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
quit_weechat = 1;
weechat_quit = 1;
return WEECHAT_RC_OK;
}
if (ret < 0)
+4 -4
View File
@@ -163,7 +163,7 @@ gui_main_signal_sigquit ()
log_printf (_("Signal %s received, exiting WeeChat..."),
"SIGQUIT");
hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
quit_weechat = 1;
weechat_quit = 1;
}
/*
@@ -176,7 +176,7 @@ gui_main_signal_sigterm ()
log_printf (_("Signal %s received, exiting WeeChat..."),
"SIGTERM");
hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
quit_weechat = 1;
weechat_quit = 1;
}
/*
@@ -219,7 +219,7 @@ gui_main_loop ()
int max_fd;
int ready;
quit_weechat = 0;
weechat_quit = 0;
/* catch SIGTERM signal: quit program */
util_catch_signal (SIGTERM, &gui_main_signal_sigterm);
@@ -235,7 +235,7 @@ gui_main_loop ()
hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
&gui_keyboard_read_cb, NULL);
while (!quit_weechat)
while (!weechat_quit)
{
/* reload config, if SIGHUP reveived */
if (gui_reload_config)
+6 -2
View File
@@ -85,6 +85,8 @@ irc_signal_quit_cb (void *data, char *signal, char *type_data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin)
{
char *auto_connect;
weechat_plugin = plugin;
#ifdef HAVE_GNUTLS
@@ -111,8 +113,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
/* hook completions */
irc_completion_init ();
irc_server_auto_connect (1, 0);
auto_connect = weechat_info_get ("auto_connect");
irc_server_auto_connect ((auto_connect && (strcmp (auto_connect, "1") == 0)) ? 1 : 0,
0);
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
&irc_server_timer_cb, NULL);
+6 -1
View File
@@ -439,7 +439,7 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
}
else if (string_strcasecmp (info, "charset_terminal") == 0)
{
return local_charset;
return weechat_local_charset;
}
else if (string_strcasecmp (info, "charset_internal") == 0)
{
@@ -459,6 +459,11 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
snprintf (value, sizeof (value), "%d", gui_filters_enabled);
return value;
}
else if (string_strcasecmp (info, "auto_connect") == 0)
{
snprintf (value, sizeof (value), "%d", weechat_auto_connect);
return value;
}
/* info not found */
return NULL;