Skip to content

Commit

Permalink
[timedclient] Add --set-mode option
Browse files Browse the repository at this point in the history
Reporting mode change should unfreeze event queue if restarted timed
for some reason comes to conclusion that bootup is not finished yet.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
  • Loading branch information
spiiroin committed Dec 22, 2020
1 parent 17b615a commit 55df2d2
Show file tree
Hide file tree
Showing 2 changed files with 19 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
18 changes: 18 additions & 0 deletions tools/timedclient/timedclient.cpp
Expand Up @@ -1172,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 Down Expand Up @@ -1814,6 +1828,7 @@ static const struct option OPT_L[] =
{"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 Down Expand Up @@ -1876,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 @@ -2037,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 55df2d2

Please sign in to comment.