Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb48450_dismiss_testing' into 'master'
Add timedclient --dismiss-event option

See merge request mer-core/timed!24
  • Loading branch information
spiiroin committed Jan 20, 2021
2 parents 930727f + 55df2d2 commit 5b45ae6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/interface.h
Expand Up @@ -119,6 +119,7 @@ namespace Maemo
// -- to be called by voland -- //
qtdbus_method(dialog_response, (uint32_t cookie, int button), cookie, button) ;
// -- not documented stuff -- //
qtdbus_method(mode, (const QString &mode), mode);
qtdbus_method(ping, (void)) ;
qtdbus_method(pid, (void)) ;
qtdbus_method(parse, (const QString &text), text) ;
Expand Down
43 changes: 43 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 @@ -1157,6 +1172,20 @@ static void do_set_enabled(char *args)
}
}

/** Handle option: --set-mode=<string> */
static void do_set_mode(char *args)
{
QDBusReply<int> reply = timed_dbus.mode_sync(args);
if( !reply.isValid() )
{
qWarning() << "'mode' call failed" << timed_dbus.lastError();
}
else
{
printf("%d\n", reply.value());
}
}

/** Handle option: --cancel-event=<cookie> */
static void do_cancel_event(char *args)
{
Expand All @@ -1172,6 +1201,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,13 +1820,15 @@ 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},
{"set-app-snooze", 1, 0, 006}, // <app:secs>
{"get-app-snooze", 1, 0, 007}, // <app>
{"set-enabled", 1, 0, 001}, // <bool>
{"get-enabled", 0, 0, 002},
{"set-mode", 1, 0, 012}, // <string>
{"get-pid", 0, 0, 005},

{"get-info", 0, 0, 010},
Expand All @@ -1811,6 +1848,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 +1881,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 All @@ -1852,6 +1891,8 @@ static const char USAGE[] =
" --set-enabled=<bool> -- Enable/Disable alarms\n"
" --get-enabled -- Query enabled status\n"
"\n"
" --set-mode=<string> -- Report USER|ACTDEAD mode change\n"
"\n"
" --get-pid -- Query PID of timed process\n"
" --get-info -- Query settings\n"
" --set-info=<args> -- Modify settings\n"
Expand Down Expand Up @@ -2003,6 +2044,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 All @@ -2012,6 +2054,7 @@ main(int argc, char **argv)
case 007: do_get_app_snooze(optarg); break;
case 010: do_get_info(); break;
case 011: do_set_info(optarg); break;
case 012: do_set_mode(optarg); break;

default:
fprintf(stderr, "?? getopt returned character code 0x%x ??\n", opt);
Expand Down

0 comments on commit 5b45ae6

Please sign in to comment.