MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "module.h"
#include "signals.h"
#include "commands.h"
#include "args.h"
+#include "network.h"
#include "net-sendbuffer.h"
#include "pidwait.h"
#include "lib-config/iconfig.h"
#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)
{
- const char *envpath;
- char **paths, **tmp;
- char *str;
-
g_free_and_null(irssi_binary);
- if (g_path_is_absolute(path)) {
- /* full path - easy */
- irssi_binary = g_strdup(path);
- return;
- }
-
- 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);
- g_free(str);
- return;
- }
-
- /* we'll need to find it from path. */
- envpath = g_getenv("PATH");
- if (envpath == NULL) return;
-
- 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;
- break;
- }
- g_free(str);
- }
- g_strfreev(paths);
+ 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);
config_node_set_bool(config, node, "halfop", nick->halfop);
config_node_set_bool(config, node, "voice", nick->voice);
+ config_node_set_str(config, node, "prefixes", nick->prefixes);
+
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_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);
}
}
/* save pids */
str = g_string_new(NULL);
for (tmp = pidwait_get_pids(); tmp != NULL; tmp = tmp->next)
- g_string_sprintfa(str, "%d ", GPOINTER_TO_INT(tmp->data));
+ g_string_append_printf(str, "%d ", GPOINTER_TO_INT(tmp->data));
config_node_set_str(config, config->mainnode, "pids", str->str);
g_string_free(str, TRUE);
}
config_close(session);
unlink(session_file);
- session_file = NULL;
}
-void session_init(void)
+void session_register_options(void)
{
- static struct poptOption options[] = {
- { "session", 0, POPT_ARG_STRING, &session_file, 0, "Used by /UPGRADE command", "PATH" },
- { NULL, '\0', 0, NULL }
+ static GOptionEntry options[] = {
+ { "session", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &session_file, "Used by /UPGRADE command", "PATH" },
+ { NULL }
};
- session_file = NULL;
+ session_file = NULL;
args_register(options);
+}
+void session_init(void)
+{
command_bind("upgrade", NULL, (SIGNAL_FUNC) cmd_upgrade);
signal_add("session save", (SIGNAL_FUNC) sig_session_save);