Show error if disconnected unintentionally

weechat-hashes
Curtis McEnroe 2018-12-04 15:56:10 -05:00
parent b1427dd169
commit 638be4e775
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 15 additions and 6 deletions

1
chat.h
View File

@ -44,6 +44,7 @@ struct {
char *join;
bool verbose;
bool notify;
bool quit;
} self;
void eventWait(const char *argv[static 2]);

View File

@ -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);

View File

@ -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.
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) {

View File

@ -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) {