#include "nicklist.h"
static char *session_file;
-static char *irssi_binary;
+char *irssi_binary = NULL;
static char **session_args;
-void session_set_binary(const char *path)
+#ifndef HAVE_GLIB2
+static char *g_find_program_in_path(const char *path)
{
const char *envpath;
char **paths, **tmp;
char *str;
-
- g_free_and_null(irssi_binary);
+ char *result = NULL;
if (g_path_is_absolute(path)) {
/* full path - easy */
- irssi_binary = g_strdup(path);
- return;
+ if(access(path, X_OK) == -1)
+ return NULL;
+ else
+ return g_strdup(path);
}
if (strchr(path, G_DIR_SEPARATOR) != NULL) {
/* relative path */
str = g_get_current_dir();
- irssi_binary = g_strconcat(str, G_DIR_SEPARATOR_S, path, NULL);
+ result = g_strconcat(str, G_DIR_SEPARATOR_S, path, NULL);
g_free(str);
- return;
+ if (access(result, X_OK) == -1) {
+ g_free(result);
+ return NULL;
+ }
+ else
+ return result;
}
/* we'll need to find it from path. */
envpath = g_getenv("PATH");
- if (envpath == NULL) return;
+ if (envpath == NULL) return NULL;
paths = g_strsplit(envpath, ":", -1);
for (tmp = paths; *tmp != NULL; tmp++) {
str = g_strconcat(*tmp, G_DIR_SEPARATOR_S, path, NULL);
if (access(str, X_OK) == 0) {
- irssi_binary = str;
+ result = str;
break;
}
g_free(str);
}
g_strfreev(paths);
+
+ return result;
+}
+#endif
+
+void session_set_binary(const char *path)
+{
+ g_free_and_null(irssi_binary);
+
+ irssi_binary = g_find_program_in_path(path);
}
void session_upgrade(void)
if (session_args == NULL)
return;
- execvp(session_args[0], session_args);
+ execv(session_args[0], session_args);
fprintf(stderr, "exec failed: %s: %s\n",
session_args[0], g_strerror(errno));
}
{
CONFIG_REC *session;
char *session_file, *str;
+ char *binary;
if (*data == '\0')
data = irssi_binary;
- if (data == NULL)
- cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
+
+ if ((binary = g_find_program_in_path(data)) == NULL)
+ cmd_return_error(CMDERR_PROGRAM_NOT_FOUND);
/* save the session */
session_file = g_strdup_printf("%s/session", get_irssi_dir());
/* data may contain some other program as well, like
/UPGRADE /usr/bin/screen irssi */
str = g_strdup_printf("%s --noconnect --session=%s --home=%s --config=%s",
- data, session_file, get_irssi_dir(), get_irssi_config());
+ binary, session_file, get_irssi_dir(), get_irssi_config());
+ g_free(binary);
+ g_free(session_file);
session_args = g_strsplit(str, " ", -1);
g_free(str);
static void session_save_nick(CHANNEL_REC *channel, NICK_REC *nick,
CONFIG_REC *config, CONFIG_NODE *node)
{
+ static char other[2];
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
config_node_set_str(config, node, "nick", nick->nick);
config_node_set_bool(config, node, "op", nick->op);
config_node_set_bool(config, node, "halfop", nick->halfop);
config_node_set_bool(config, node, "voice", nick->voice);
+
+ other[0] = nick->other;
+ other[1] = '\0';
+ config_node_set_str(config, node, "other", other);
signal_emit("session save nick", 4, channel, nick, config, node);
}
config_node_set_str(config, node, "chatnet", server->connrec->chatnet);
config_node_set_str(config, node, "password", server->connrec->password);
config_node_set_str(config, node, "nick", server->nick);
+ config_node_set_str(config, node, "version", server->version);
config_node_set_bool(config, node, "use_ssl", server->connrec->use_ssl);
+ config_node_set_str(config, node, "ssl_cert", server->connrec->ssl_cert);
+ config_node_set_str(config, node, "ssl_pkey", server->connrec->ssl_pkey);
+ config_node_set_bool(config, node, "ssl_verify", server->connrec->ssl_verify);
+ config_node_set_str(config, node, "ssl_cafile", server->connrec->ssl_cafile);
+ config_node_set_str(config, node, "ssl_capath", server->connrec->ssl_capath);
handle = g_io_channel_unix_get_fd(net_sendbuffer_handle(server->handle));
config_node_set_int(config, node, "handle", handle);
conn->connect_handle = g_io_channel_unix_new(handle);
server = proto->server_init_connect(conn);
+ server->version = g_strdup(config_node_get_str(node, "version", NULL));
server->session_reconnect = TRUE;
signal_emit("session restore server", 2, server, node);
void session_init(void)
{
static struct poptOption options[] = {
-#if 0 /* --session is not available in SILC Client */
{ "session", 0, POPT_ARG_STRING, &session_file, 0, "Used by /UPGRADE command", "PATH" },
-#endif
{ NULL, '\0', 0, NULL }
};
- session_file = NULL;
+ session_file = NULL;
args_register(options);
- /*command_bind("upgrade", NULL, (SIGNAL_FUNC) cmd_upgrade);*/
+ command_bind("upgrade", NULL, (SIGNAL_FUNC) cmd_upgrade);
signal_add("session save", (SIGNAL_FUNC) sig_session_save);
signal_add("session restore", (SIGNAL_FUNC) sig_session_restore);
{
g_free_not_null(irssi_binary);
- /*command_unbind("upgrade", (SIGNAL_FUNC) cmd_upgrade);*/
+ command_unbind("upgrade", (SIGNAL_FUNC) cmd_upgrade);
signal_remove("session save", (SIGNAL_FUNC) sig_session_save);
signal_remove("session restore", (SIGNAL_FUNC) sig_session_restore);