summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-12-04 15:56:10 -0500
committerJune McEnroe <june@causal.agency>2018-12-04 15:56:10 -0500
commit638be4e7757a7e7fcb52332461b5b1b5330a6771 (patch)
tree14190aec10060e1d8b9a3af6bc95b56781590cda
parentSend only SIGHUP in sandman (diff)
downloadcatgirl-638be4e7757a7e7fcb52332461b5b1b5330a6771.tar.gz
catgirl-638be4e7757a7e7fcb52332461b5b1b5330a6771.zip
Show error if disconnected unintentionally
-rw-r--r--chat.h1
-rw-r--r--event.c6
-rw-r--r--handle.c13
-rw-r--r--input.c1
4 files changed, 15 insertions, 6 deletions
diff --git a/chat.h b/chat.h
index 01dcd72..9a544f5 100644
--- a/chat.h
+++ b/chat.h
@@ -44,6 +44,7 @@ struct {
 	char *join;
 	bool verbose;
 	bool notify;
+	bool quit;
 } self;
 
 void eventWait(const char *argv[static 2]);
diff --git a/event.c b/event.c
index 4ea9f81..a5a49cc 100644
--- a/event.c
+++ b/event.c
@@ -131,10 +131,14 @@ noreturn void eventLoop(void) {
 
 	for (;;) {
 		if (sig[SIGCHLD]) childWait();
-		if (sig[SIGHUP]) ircFmt("QUIT :zzz\r\n");
+		if (sig[SIGHUP]) {
+			ircFmt("QUIT :zzz\r\n");
+			self.quit = true;
+		}
 		if (sig[SIGINT]) {
 			signal(SIGINT, SIG_DFL);
 			ircFmt("QUIT :Goodbye\r\n");
+			self.quit = true;
 		}
 		if (sig[SIGWINCH]) {
 			curses.sa_handler(SIGWINCH);
diff --git a/handle.c b/handle.c
index 137f859..3b52f0c 100644
--- a/handle.c
+++ b/handle.c
@@ -95,11 +95,14 @@ static void handlePing(char *prefix, char *params) {
 }
 
 static void handleError(char *prefix, char *params) {
-	(void)prefix;
-	(void)params;
-	// TODO: Show error if unintended disconnect.
-	uiExit();
-	exit(EX_OK);
+	char *mesg;
+	parse(prefix, NULL, NULL, NULL, params, 1, 0, &mesg);
+	if (self.quit) {
+		uiExit();
+		exit(EX_OK);
+	} else {
+		errx(EX_PROTOCOL, "%s", mesg);
+	}
 }
 
 static void handleErrorErroneousNickname(char *prefix, char *params) {
diff --git a/input.c b/input.c
index cc52928..7093363 100644
--- a/input.c
+++ b/input.c
@@ -106,6 +106,7 @@ static void inputTopic(struct Tag tag, char *params) {
 static void inputQuit(struct Tag tag, char *params) {
 	(void)tag;
 	ircFmt("QUIT :%s\r\n", params ? params : "Goodbye");
+	self.quit = true;
 }
 
 static void inputURL(struct Tag tag, char *params) {
ader'>2019-02-23Use first word of params in input commandsJune McEnroe Prevents anything weird from happening when tab-completing, which inserts a space. 2019-02-23Add C-n and C-p key bindings to switch windowsJune McEnroe 2019-02-23Change example command to join #ascii.town on freenodeJune McEnroe 2019-02-23Call def_prog_mode after termNoFlowJune McEnroe So that the settings get restored after /url or /man. 2019-02-22Move IRC formatting reset to C-sJune McEnroe Opens C-n for window switching. 2019-02-22Disable terminal flow controlJune McEnroe This opens up C-o, C-q and C-s for key bindings without C-v. 2019-02-22Bind up and down arrows to scrollJune McEnroe Honestly it's kind of weird that IRC clients usually use these for input history. 2019-02-22Remove topic TODOJune McEnroe I played around with it and it doesn't look right unless there is only one channel listed in the status. 2019-02-22Add /znc commandJune McEnroe Only because ZNC tells you to use it and expects it to work. 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe It's actually in a good state now, I think. 2019-02-21Replace "view" with "window"June McEnroe I think originally I didn't want to use the same word as curses WINDOW but it's really much clearer for the user if they're just called windows. UI code probably needs yet another rewrite though. Still feels messy. 2019-02-21Remove ROT13June McEnroe It's just not convenient when it can only do the whole line... 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe Otherwise the "Traveling" message isn't visible while connecting. 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe