Status system reworked
This commit is contained in:
1 parent
33567db5a3
commit
a29ba6e4d2
18 files changed
+326
-345
No files matched your search
+15
-16
@@ -14,13 +14,13 @@
|
||||
* - Statuses are the text you would type at the prompt: "prompt", "testing",
|
||||
* "uploading", "frozen", "done", "limit-reset", "wait 4:30pm", "wait 16:30"
|
||||
* or just "wait" (only while the task's account is already waiting).
|
||||
* - A wait belongs to the account: setting a task to "wait <time>" sets its
|
||||
* account's wait, and the account's Prompt / Testing tasks then show Wait
|
||||
* until that time and Limit reset after it. A task you explicitly set to
|
||||
* "testing" or "prompt" while the wait is running shows that status instead
|
||||
* (overrides_wait = 1) and the other tasks keep waiting; "wait" makes it follow
|
||||
* the account again. If the wait is already over (Limit reset), setting a task
|
||||
* to testing / prompt clears it: the account is in use again (see the README).
|
||||
* - Waits: an account hits its limit until a time. A task set to "wait" is waiting
|
||||
* for that: "wait <time>" sets the account's wait and marks the task Wait; "wait"
|
||||
* alone marks it Wait while the account is already waiting. When the time passes
|
||||
* the account stops waiting by itself and its Wait tasks show Limit reset (the
|
||||
* conversation can be continued). Prompt / Testing tasks are not waiting: they
|
||||
* keep their status, with "(account-waiting)" added to the label while the
|
||||
* account waits (account_waiting = 1).
|
||||
* - Times are Unix seconds (UTC); clock-time text like "4:30pm" is read in the
|
||||
* local time zone, and a time that has passed today means tomorrow.
|
||||
*
|
||||
@@ -75,8 +75,7 @@ extern "C" {
|
||||
|
||||
/* ---- Account wait states (lls_account_info.wait_state) -------------------- */
|
||||
#define LLS_WAIT_NONE 0
|
||||
#define LLS_WAIT_WAITING 1 /* wait_until is in the future */
|
||||
#define LLS_WAIT_LIMIT_RESET 2 /* wait_until has passed; stays until cleared */
|
||||
#define LLS_WAIT_WAITING 1 /* waiting until wait_until; after that it is NONE again (automatically) */
|
||||
|
||||
typedef struct lls_db lls_db;
|
||||
typedef struct lls_task_list lls_task_list;
|
||||
@@ -86,13 +85,13 @@ typedef struct lls_account_list lls_account_list;
|
||||
typedef struct lls_task_info {
|
||||
const char* name;
|
||||
const char* account; /* NULL when the task has no account */
|
||||
int status; /* LLS_STATUS_*, as shown (Wait / Limit reset come from the account) */
|
||||
const char* status_label; /* "Prompt", "Limit reset", "Wait 16:30", ... */
|
||||
int status; /* LLS_STATUS_*, as shown (Wait becomes Limit reset when the account's wait ends) */
|
||||
const char* status_label; /* "Prompt", "Limit reset", "Wait 16:30", "Testing (account-waiting)", ... */
|
||||
int stored_status; /* LLS_STATUS_*, what is saved underneath */
|
||||
int64_t until; /* for Wait / Limit reset: when the wait ends (ended); else 0 */
|
||||
const char* notes; /* the full text, "" if none (any length) */
|
||||
int notes_lines; /* number of lines in the notes */
|
||||
int overrides_wait; /* 1 if its account waits but this task ignores it (set to Testing / Prompt) */
|
||||
int account_waiting; /* 1 if it is Prompt / Testing while its account waits (the label says so) */
|
||||
} lls_task_info;
|
||||
|
||||
/* An account with its computed state. */
|
||||
@@ -101,8 +100,8 @@ typedef struct lls_account_info {
|
||||
int level; /* LLS_LEVEL_* */
|
||||
const char* level_label; /* "Busy", "Taken", "Free" */
|
||||
int wait_state; /* LLS_WAIT_* */
|
||||
int64_t wait_until; /* when the wait ends (ended); 0 if none */
|
||||
int wait_listed; /* 1 if the wait is not shown by any task (it still makes the account Busy) */
|
||||
int64_t wait_until; /* when the wait ends; 0 if it is not waiting */
|
||||
int wait_listed; /* 1 if it is waiting but no task is set to Wait (it is still Busy) */
|
||||
int task_count;
|
||||
const char* const* tasks; /* the tasks at the account's level (a Free account: its Uploading/Frozen/Done ones) */
|
||||
} lls_account_info;
|
||||
@@ -152,9 +151,9 @@ LLS_API int lls_account_add(lls_db* db, const char* name);
|
||||
LLS_API int lls_account_delete(lls_db* db, const char* name); /* its tasks become unassigned */
|
||||
LLS_API int lls_account_rename(lls_db* db, const char* name, const char* new_name);
|
||||
/* The account hit its limit until a clock time ("16:30", "4:30pm") / until a Unix time. */
|
||||
LLS_API int lls_account_set_wait(lls_db* db, const char* name, const char* time_text);
|
||||
LLS_API int lls_account_set_wait(lls_db* db, const char* name, const char* time_text); /* tasks set to Wait follow it */
|
||||
LLS_API int lls_account_set_wait_at(lls_db* db, const char* name, int64_t until);
|
||||
/* Clears its wait / limit reset. Sets *was_waiting (if not NULL) to 1 or 0. */
|
||||
/* Ends the wait now: its Wait tasks become Limit reset. Sets *was_waiting (if not NULL) to 1 or 0. */
|
||||
LLS_API int lls_account_clear_wait(lls_db* db, const char* name, int* was_waiting);
|
||||
|
||||
/* ---- Tasks ---------------------------------------------------------------- */
|
||||
|
||||
Reference in new issue
Block a user