mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
If we de-queue a reminder without issuing it, send a NOTE queued %d message in server mode.
This commit is contained in:
@@ -3753,10 +3753,6 @@ proc DisplayTime {} {
|
||||
set msg [clock format [clock seconds] -format "%e %b %Y %I:%M%p"]
|
||||
}
|
||||
Status $msg
|
||||
catch {
|
||||
puts $DaemonFile "STATUS"
|
||||
flush $DaemonFile
|
||||
}
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
|
||||
@@ -1147,7 +1147,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse, int is_queue
|
||||
DoMsgCommand(msg_command, DBufValue(&buf));
|
||||
} else {
|
||||
/* Add a space before "NOTE endreminder" */
|
||||
if (Daemon < 0 && !strncmp(DBufValue(&buf), "NOTE endreminder", 16)) {
|
||||
if (IsServerMode() && !strncmp(DBufValue(&buf), "NOTE endreminder", 16)) {
|
||||
printf(" %s", DBufValue(&buf));
|
||||
} else {
|
||||
printf("%s", DBufValue(&buf));
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
/* Characters to ignore */
|
||||
#define isempty(c) (isspace(c) || ((c) == '\\'))
|
||||
|
||||
#define IsServerMode() (Daemon < 0)
|
||||
|
||||
#include "dynbuf.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
39
src/queue.c
39
src/queue.c
@@ -141,6 +141,21 @@ SigContHandler(int d)
|
||||
UNUSED(d);
|
||||
}
|
||||
|
||||
static void
|
||||
print_num_queued(void)
|
||||
{
|
||||
int nqueued = 0;
|
||||
QueuedRem *q = QueueHead;
|
||||
while(q) {
|
||||
if (q->tt.nexttime != NO_TIME) {
|
||||
nqueued++;
|
||||
}
|
||||
q = q->next;
|
||||
}
|
||||
printf("NOTE queued %d\n", nqueued);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* HandleQueuedReminders */
|
||||
@@ -213,7 +228,7 @@ void HandleQueuedReminders(void)
|
||||
if (!q && !Daemon) break;
|
||||
|
||||
if (Daemon && !q) {
|
||||
if (Daemon < 0) {
|
||||
if (IsServerMode()) {
|
||||
/* Sleep until midnight */
|
||||
TimeToSleep = MINUTES_PER_DAY*60 - SystemTime(1);
|
||||
} else {
|
||||
@@ -232,7 +247,7 @@ void HandleQueuedReminders(void)
|
||||
|
||||
/* Wake up once a minute to recalibrate sleep time in
|
||||
case of laptop hibernation */
|
||||
if (Daemon < 0) {
|
||||
if (IsServerMode()) {
|
||||
/* Wake up on the next exact minute */
|
||||
gettimeofday(&tv, NULL);
|
||||
sleep_tv.tv_sec = 60 - (tv.tv_sec % 60);
|
||||
@@ -263,7 +278,7 @@ void HandleQueuedReminders(void)
|
||||
if (Daemon > 0 && SleepTime) CheckInitialFile();
|
||||
|
||||
if (Daemon && !q) {
|
||||
if (Daemon < 0) {
|
||||
if (IsServerMode()) {
|
||||
/* Sleep until midnight */
|
||||
TimeToSleep = MINUTES_PER_DAY*60 - SystemTime(1);
|
||||
} else {
|
||||
@@ -289,7 +304,7 @@ void HandleQueuedReminders(void)
|
||||
trig.typ = q->typ;
|
||||
strcpy(trig.passthru, q->passthru);
|
||||
RunDisabled = q->RunDisabled;
|
||||
if (Daemon < 0) {
|
||||
if (IsServerMode()) {
|
||||
printf("NOTE reminder %s",
|
||||
SimpleTime(q->tt.ttime));
|
||||
printf("%s", SimpleTime(MinutesPastMidnight(1)));
|
||||
@@ -304,7 +319,7 @@ void HandleQueuedReminders(void)
|
||||
and trigtime() work correctly */
|
||||
SaveAllTriggerInfo(&(q->t), &(q->tt), DSEToday, q->tt.ttime, 1);
|
||||
(void) TriggerReminder(&p, &trig, &q->tt, DSEToday, 1);
|
||||
if (Daemon < 0) {
|
||||
if (IsServerMode()) {
|
||||
printf("NOTE endreminder\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
@@ -321,6 +336,9 @@ void HandleQueuedReminders(void)
|
||||
q->tt.nexttime < MinutesPastMidnight(1) - MaxLateMinutes) {
|
||||
q->tt.nexttime = NO_TIME;
|
||||
}
|
||||
if (IsServerMode()) {
|
||||
print_num_queued();
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
@@ -622,16 +640,7 @@ static void DaemonWait(struct timeval *sleep_tv)
|
||||
if (!strcmp(cmdLine, "EXIT\n")) {
|
||||
exit(EXIT_SUCCESS);
|
||||
} else if (!strcmp(cmdLine, "STATUS\n")) {
|
||||
int nqueued = 0;
|
||||
QueuedRem *q = QueueHead;
|
||||
while(q) {
|
||||
if (q->tt.nexttime != NO_TIME) {
|
||||
nqueued++;
|
||||
}
|
||||
q = q->next;
|
||||
}
|
||||
printf("NOTE queued %d\n", nqueued);
|
||||
fflush(stdout);
|
||||
print_num_queued();
|
||||
} else if (!strcmp(cmdLine, "QUEUE\n")) {
|
||||
printf("NOTE queue\n");
|
||||
QueuedRem *q = QueueHead;
|
||||
|
||||
Reference in New Issue
Block a user