From 56a67d56e0ac5da860756418014f7f1ba2586a33 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 3 May 2015 20:03:21 +0200
Subject: degesch: add a /connect command
---
degesch.c | 75 +++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 47 insertions(+), 28 deletions(-)
diff --git a/degesch.c b/degesch.c
index 6a7e0db..2118a4d 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1983,6 +1983,10 @@ irc_remove_user_from_channel (struct user *user, struct channel *channel)
// --- Supporting code ---------------------------------------------------------
+static bool irc_connect (struct server *s, bool *should_retry, struct error **);
+static void irc_cancel_timers (struct server *s);
+static void on_irc_reconnect_timeout (void *user_data);
+
static char *
irc_cut_nickname (const char *prefix)
{
@@ -4236,6 +4240,22 @@ handle_command_part (struct app_context *ctx, char *arguments)
return true;
}
+static bool
+handle_command_connect (struct app_context *ctx, char *arguments)
+{
+ // TODO: multiserver
+ struct server *s = &ctx->server;
+ if (s->irc_fd != -1)
+ {
+ buffer_send_error (ctx, s->buffer, "Already connected");
+ return true;
+ }
+
+ irc_cancel_timers (s);
+ on_irc_reconnect_timeout (s);
+ return true;
+}
+
static bool
handle_command_list (struct app_context *ctx, char *arguments)
{
@@ -4283,31 +4303,31 @@ static struct command_handler
}
g_command_handlers[] =
{
- { "help", handle_command_help, "Show help",
+ { "help", handle_command_help, "Show help",
"[ |