1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 11:46:45 +02:00

Add support for auto-away based on screen attach/detach

This commit is contained in:
fr33domlover
2015-02-26 23:51:20 +02:00
parent 3e3f2614b5
commit 0c39e7b158
12 changed files with 486 additions and 6 deletions

View File

@ -528,12 +528,14 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
bool have_note = false;
const char *errmsg;
lock_status ();
if (argc >= 2) {
have_note = true;
} else if (argc < 1) {
errmsg = "Require a status. Statuses are: online, busy and away.";
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
return;
goto finish;
}
char status[MAX_STR_SIZE];
@ -551,7 +553,7 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
else {
errmsg = "Invalid status. Valid statuses are: online, busy and away.";
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
return;
goto finish;
}
tox_set_user_status(m, status_kind);
@ -560,7 +562,7 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
if (have_note) {
if (argv[2][0] != '\"') {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Note must be enclosed in quotes.");
return;
goto finish;
}
/* remove opening and closing quotes */
@ -571,4 +573,7 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
prompt_update_statusmessage(prompt, m, msg);
}
finish:
unlock_status ();
}