Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[timedclient] Add --dismiss-event option. JB#48450
Dismissing a snoozed event either cancels or reschedules the event
depending on whether it is one-shot or recurring one.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
  • Loading branch information
spiiroin committed Dec 22, 2020
1 parent 930727f commit 17b615a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tools/timedclient/timedclient.cpp
Expand Up @@ -907,6 +907,21 @@ static void event_emit_details(CONST Maemo::Timed::Event &eve)
* Cookie helpers
* ------------------------------------------------------------------------- */

/** Dismiss snoozed event */
static void cookie_dismiss(uint cookie)
{
QDBusReply<bool> res = timed_dbus.dismiss_sync(cookie);

if(!res.isValid())
{
qWarning() << "'dismiss' call failed:" << timed_dbus.lastError();
}
else
{
printf("cookie %u dismissed = %s\n", cookie, repr_bool(res.value()));
}
}

/** Delete event from timed event queue */
static void cookie_cancel(uint cookie)
{
Expand Down Expand Up @@ -1172,6 +1187,12 @@ static void do_cancel_events(void)
}
}

/** Handle option: --dismiss-event=<cookie> */
static void do_dismiss_event(char *args)
{
cookie_dismiss(parse_cookie(args));
}

/** Handle option: --add-button=<args> */
static void do_add_button(char *args)
{
Expand Down Expand Up @@ -1785,6 +1806,7 @@ static const struct option OPT_L[] =

{"cancel-event", 1, 0, 'c'}, // <cookie>
{"cancel-events", 0, 0, 'C'},
{"dismiss-event", 0, 0, 'd'},

{"set-snooze", 1, 0, 003}, // <secs>
{"get-snooze", 0, 0, 004},
Expand All @@ -1811,6 +1833,7 @@ static const char OPT_S[] =
"L" // --show
"c:" // --cancel-event=<cookie>
"C" // --cancel-events
"d:" // --dismiss-event=<cookie>
"g:" // --get-event=<cookie>
"b:" // --add-button=<cookie>
"a:" // --add-action=<cookie>
Expand Down Expand Up @@ -1843,6 +1866,7 @@ static const char USAGE[] =
"\n"
" --cancel-event=<cookie> -c<cookie> -- Cancel one event\n"
" --cancel-events -C -- Cancel all events\n"
" --dismiss-event=<cookie> -d<cookie> -- Dismiss snoozed event\n"
"\n"
" --set-snooze=<secs> -- Set default snooze value\n"
" --get-snooze -- Query default snooze value\n"
Expand Down Expand Up @@ -2003,6 +2027,7 @@ main(int argc, char **argv)
case 'e': do_add_event(optarg); break;
case 'c': do_cancel_event(optarg); break;
case 'C': do_cancel_events(); break;
case 'd': do_dismiss_event(optarg); break;
case 001: do_set_enabled(optarg); break;
case 002: do_get_enabled(); break;
case 003: do_set_snooze(optarg); break;
Expand Down

0 comments on commit 17b615a

Please sign in to comment.