#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. */
- str = g_getenv("PATH");
- if (str == NULL) return;
+ envpath = g_getenv("PATH");
+ if (envpath == NULL) return NULL;
- paths = g_strsplit(str, ":", -1);
+ 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);
}
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
config_node_set_str(config, node, "name", channel->name);
+ config_node_set_str(config, node, "visible_name", channel->visible_name);
config_node_set_str(config, node, "topic", channel->topic);
config_node_set_str(config, node, "topic_by", channel->topic_by);
config_node_set_int(config, node, "topic_time", channel->topic_time);
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);
static void session_restore_channel(SERVER_REC *server, CONFIG_NODE *node)
{
CHANNEL_REC *channel;
- const char *name;
+ const char *name, *visible_name;
name = config_node_get_str(node, "name", NULL);
if (name == NULL)
return;
- channel = CHAT_PROTOCOL(server)->channel_create(server, name, TRUE);
+ visible_name = config_node_get_str(node, "visible_name", NULL);
+ channel = CHAT_PROTOCOL(server)->channel_create(server, name, visible_name, TRUE);
channel->topic = g_strdup(config_node_get_str(node, "topic", NULL));
channel->topic_by = g_strdup(config_node_get_str(node, "topic_by", NULL));
channel->topic_time = config_node_get_int(node, "topic_time", 0);
chatnet, password, nick);
if (conn != NULL) {
conn->reconnection = TRUE;
+ conn->connect_handle = g_io_channel_unix_new(handle);
- server = proto->server_connect(conn);
- server->handle = net_sendbuffer_create(g_io_channel_unix_new(handle), 0);
+ 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);
+
+ proto->server_connect(server);
}
}
{ NULL, '\0', 0, NULL }
};
- session_file = NULL;
+ session_file = NULL;
args_register(options);
command_bind("upgrade", NULL, (SIGNAL_FUNC) cmd_upgrade);