#include "misc.h"
#include "levels.h"
#include "settings.h"
+#include "irssi-version.h"
+#ifdef HAVE_NL_LANGINFO
+# include <langinfo.h>
+#endif
+#include "servers.h"
#include "channels.h"
#include "servers-setup.h"
+#include "recode.h"
+#include "autorun.h"
+#include "fe-core-commands.h"
#include "fe-queries.h"
#include "hilight-text.h"
#include "command-history.h"
#include "translation.h"
#include "fe-channels.h"
#include "fe-windows.h"
+#include "window-activity.h"
#include "window-items.h"
#include "windows-layout.h"
+#include "fe-recode.h"
#include <signal.h>
static char *cmdline_nick;
static char *cmdline_hostname;
-void autorun_init(void);
-void autorun_deinit(void);
-
void fe_core_log_init(void);
void fe_core_log_deinit(void);
void fe_settings_init(void);
void fe_settings_deinit(void);
-void window_activity_init(void);
-void window_activity_deinit(void);
-
void window_commands_init(void);
void window_commands_deinit(void);
-void fe_core_commands_init(void);
-void fe_core_commands_deinit(void);
+static void sig_setup_changed(void);
+
+static void print_version(void)
+{
+ printf(PACKAGE" " IRSSI_VERSION" (%d %04d)\n",
+ IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
+ exit(0);
+}
static void sig_connected(SERVER_REC *server)
{
static void sig_disconnected(SERVER_REC *server)
{
- g_free(MODULE_DATA(server));
+ void *data = MODULE_DATA(server);
+ g_free(data);
+ MODULE_DATA_UNSET(server);
}
static void sig_channel_created(CHANNEL_REC *channel)
static void sig_channel_destroyed(CHANNEL_REC *channel)
{
- g_free(MODULE_DATA(channel));
+ void *data = MODULE_DATA(channel);
+
+ g_free(data);
+ MODULE_DATA_UNSET(channel);
}
void fe_common_core_init(void)
{
+ static struct poptOption version_options[] = {
+ { NULL, '\0', POPT_ARG_CALLBACK, (void *)&print_version, '\0', NULL },
+ { "version", 'v', POPT_ARG_NONE, NULL, 0, "Display irssi version" },
+ { NULL, '\0', 0, NULL }
+ };
+
static struct poptOption options[] = {
- { "connect", 'c', POPT_ARG_STRING, &autocon_server, 0, "Automatically connect to server/ircnet", "SERVER" },
- { "password", 'w', POPT_ARG_STRING, &autocon_password, 0, "Autoconnect password", "SERVER" },
+ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, version_options, 0, NULL, NULL },
+ POPT_AUTOHELP
+ { "connect", 'c', POPT_ARG_STRING, &autocon_server, 0, "Automatically connect to server/network", "SERVER" },
+ { "password", 'w', POPT_ARG_STRING, &autocon_password, 0, "Autoconnect password", "PASSWORD" },
{ "port", 'p', POPT_ARG_INT, &autocon_port, 0, "Autoconnect port", "PORT" },
{ "noconnect", '!', POPT_ARG_NONE, &no_autoconnect, 0, "Disable autoconnecting", NULL },
- /*
{ "nick", 'n', POPT_ARG_STRING, &cmdline_nick, 0, "Specify nick to use", NULL },
{ "hostname", 'h', POPT_ARG_STRING, &cmdline_hostname, 0, "Specify host name to use", NULL },
- */
{ NULL, '\0', 0, NULL }
};
autocon_server = NULL;
autocon_password = NULL;
- autocon_port = 6667;
+ autocon_port = 0;
no_autoconnect = FALSE;
cmdline_nick = NULL;
cmdline_hostname = NULL;
args_register(options);
settings_add_bool("lookandfeel", "timestamps", TRUE);
- settings_add_bool("lookandfeel", "msgs_timestamps", FALSE);
- settings_add_int("lookandfeel", "timestamp_timeout", 0);
+ settings_add_level("lookandfeel", "timestamp_level", "ALL");
+ settings_add_time("lookandfeel", "timestamp_timeout", "0");
settings_add_bool("lookandfeel", "bell_beeps", FALSE);
- settings_add_str("lookandfeel", "beep_msg_level", "");
+ settings_add_level("lookandfeel", "beep_msg_level", "");
settings_add_bool("lookandfeel", "beep_when_window_active", TRUE);
settings_add_bool("lookandfeel", "beep_when_away", TRUE);
settings_add_bool("lookandfeel", "hide_text_style", FALSE);
+ settings_add_bool("lookandfeel", "hide_colors", FALSE);
settings_add_bool("lookandfeel", "hide_server_tags", FALSE);
settings_add_bool("lookandfeel", "use_status_window", TRUE);
settings_add_bool("lookandfeel", "use_msgs_window", FALSE);
-
+#if defined (HAVE_NL_LANGINFO) && defined(CODESET)
+ settings_add_str("lookandfeel", "term_charset",
+ *nl_langinfo(CODESET) != '\0' ?
+ nl_langinfo(CODESET) : "ISO8859-1");
+#else
+ settings_add_str("lookandfeel", "term_charset", "ISO8859-1");
+#endif
themes_init();
theme_register(fecommon_core_formats);
- autorun_init();
command_history_init();
completion_init();
keyboard_init();
fe_messages_init();
hilight_text_init();
fe_ignore_messages_init();
+ fe_recode_init();
settings_check();
signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected);
signal_add_first("channel created", (SIGNAL_FUNC) sig_channel_created);
signal_add_last("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
+
+ module_register("core", "fe");
}
void fe_common_core_deinit(void)
{
- autorun_deinit();
hilight_text_deinit();
command_history_deinit();
completion_deinit();
fe_queries_deinit();
fe_messages_deinit();
- fe_ignore_messages_init();
+ fe_ignore_messages_deinit();
+ fe_recode_deinit();
theme_unregister();
themes_deinit();
+ signal_remove("setup changed", (SIGNAL_FUNC) sig_setup_changed);
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected);
signal_remove("channel created", (SIGNAL_FUNC) sig_channel_created);
}
if (windows == NULL)
- fprintf(stderr, "GLib %s: %s", reason, message);
+ fprintf(stderr, "GLib %s: %s\n", reason, message);
else {
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
TXT_GLIB_ERROR, reason, message);
}
}
+#define MSGS_WINDOW_LEVELS (MSGLEVEL_MSGS|MSGLEVEL_ACTIONS|MSGLEVEL_DCCMSGS)
+
static void create_windows(void)
{
WINDOW_REC *window;
-
- windows_layout_restore();
- if (windows != NULL)
- return;
-
- if (settings_get_bool("use_status_window")) {
- window = window_create(NULL, TRUE);
- window_set_name(window, "(status)");
- window_set_level(window, MSGLEVEL_ALL ^
- (settings_get_bool("use_msgs_window") ?
- (MSGLEVEL_MSGS|MSGLEVEL_DCCMSGS) : 0));
+ int have_status = settings_get_bool("use_status_window");
+
+ window = window_find_name("(status)");
+ if (have_status) {
+ if (window == NULL) {
+ window = window_create(NULL, TRUE);
+ window_set_refnum(window, 1);
+ window_set_name(window, "(status)");
+ window_set_level(window, MSGLEVEL_ALL ^
+ (settings_get_bool("use_msgs_window") ?
+ MSGS_WINDOW_LEVELS : 0));
+ window_set_immortal(window, TRUE);
+ }
+ } else {
+ if (window != NULL) {
+ window_set_name(window, NULL);
+ window_set_level(window, 0);
+ window_set_immortal(window, FALSE);
+ }
}
+ window = window_find_name("(msgs)");
if (settings_get_bool("use_msgs_window")) {
- window = window_create(NULL, TRUE);
- window_set_name(window, "(msgs)");
- window_set_level(window, MSGLEVEL_MSGS|MSGLEVEL_DCCMSGS);
+ if (window == NULL) {
+ window = window_create(NULL, TRUE);
+ window_set_refnum(window, have_status ? 2 : 1);
+ window_set_name(window, "(msgs)");
+ window_set_level(window, MSGS_WINDOW_LEVELS);
+ window_set_immortal(window, TRUE);
+ }
+ } else {
+ if (window != NULL) {
+ window_set_name(window, NULL);
+ window_set_level(window, 0);
+ window_set_immortal(window, FALSE);
+ }
}
if (windows == NULL) {
g_slist_free(chatnets);
}
+static void sig_setup_changed(void)
+{
+ static int firsttime = TRUE;
+ static int status_window = FALSE, msgs_window = FALSE;
+ int changed = FALSE;
+
+ if (settings_get_bool("use_status_window") != status_window) {
+ status_window = !status_window;
+ changed = TRUE;
+ }
+ if (settings_get_bool("use_msgs_window") != msgs_window) {
+ msgs_window = !msgs_window;
+ changed = TRUE;
+ }
+
+ if (firsttime) {
+ firsttime = FALSE;
+ changed = TRUE;
+
+ windows_layout_restore();
+ if (windows != NULL)
+ return;
+ }
+
+ if (changed)
+ create_windows();
+}
+
void fe_common_core_finish_init(void)
{
+ int setup_changed;
+
signal_emit("irssi init read settings", 0);
#ifdef SIGPIPE
signal(SIGPIPE, SIG_IGN);
#endif
- if (cmdline_nick != NULL) {
+ setup_changed = FALSE;
+ if (cmdline_nick != NULL && *cmdline_nick != '\0') {
/* override nick found from setup */
settings_set_str("nick", cmdline_nick);
+ setup_changed = TRUE;
}
if (cmdline_hostname != NULL) {
/* override host name found from setup */
settings_set_str("hostname", cmdline_hostname);
+ setup_changed = TRUE;
}
- create_windows();
+ sig_setup_changed();
+ signal_add_first("setup changed", (SIGNAL_FUNC) sig_setup_changed);
/* _after_ windows are created.. */
+#if GLIB_CHECK_VERSION(2,6,0)
+ g_log_set_default_handler((GLogFunc) glog_func, NULL);
+#else
g_log_set_handler(G_LOG_DOMAIN,
(GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_WARNING),
(GLogFunc) glog_func, NULL);
+ g_log_set_handler("GLib",
+ (GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_WARNING),
+ (GLogFunc) glog_func, NULL); /* send glib errors to the same place */
+#endif
+
+ if (setup_changed)
+ signal_emit("setup changed", 0);
+ autorun_startup();
autoconnect_servers();
}