diff options
author | Michael Vetter <jubalh@iodoru.org> | 2023-04-18 14:43:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 14:43:01 +0200 |
commit | 4933d4e4f3d1cc8ee308c1bb6bfc4c13ec64ac57 (patch) | |
tree | 1fed6ab534a857572c0732fe5c9dad73af4617dd /src/command/cmd_funcs.c | |
parent | f51dc019bc08e41fa4564d465136522648a7a663 (diff) | |
parent | bed5c02c0dde0fe3cd8eb6018322a78b4441e22a (diff) | |
download | profani-tty-4933d4e4f3d1cc8ee308c1bb6bfc4c13ec64ac57.tar.gz |
Merge pull request #1827 from H3rnand3zzz/feature/sessions-alarm
New Feature: Session Alarm
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r-- | src/command/cmd_funcs.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 7c533a45..4a5c7fa1 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -905,6 +905,28 @@ _account_set_auth(char* account_name, char* policy) } gboolean +_account_set_max_sessions(char* account_name, char* max_sessions_raw) +{ + int max_sessions; + char* err_msg = NULL; + gboolean res = strtoi_range(max_sessions_raw, &max_sessions, 0, INT_MAX, &err_msg); + if (!res) { + cons_show(err_msg); + cons_show(""); + free(err_msg); + return TRUE; + } + accounts_set_max_sessions(account_name, max_sessions); + if (max_sessions < 1) { + cons_show("Max sessions alarm for account %s has been disabled.", account_name); + } else { + cons_show("Max sessions alarm for account %s has been set to %d", account_name, max_sessions); + } + cons_show(""); + return TRUE; +} + +gboolean _account_set_presence_priority(char* account_name, char* presence, char* priority) { int intval; @@ -997,6 +1019,8 @@ cmd_account_set(ProfWin* window, const char* const command, gchar** args) return _account_set_tls(account_name, value); if (strcmp(property, "auth") == 0) return _account_set_auth(account_name, value); + if (strcmp(property, "session_alarm") == 0) + return _account_set_max_sessions(account_name, value); if (valid_resource_presence_string(property)) { return _account_set_presence_priority(account_name, property, value); @@ -1057,6 +1081,9 @@ cmd_account_clear(ProfWin* window, const char* const command, gchar** args) } else if (strcmp(property, "resource") == 0) { accounts_clear_resource(account_name); cons_show("Removed resource for account %s", account_name); + } else if (strcmp(property, "session_alarm") == 0) { + accounts_clear_max_sessions(account_name); + cons_show("Disabled session alarm for account %s", account_name); } else { cons_show("Invalid property: %s", property); } |