diff --git a/mythtv/programs/mythshutdown/commandlineparser.cpp b/mythtv/programs/mythshutdown/commandlineparser.cpp
index d1cb383..e30d38e 100644
|
a
|
b
|
void MythShutdownCommandLineParser::LoadArguments(void)
|
| 22 | 22 | CommandLineArg::AllowOneOf( QList<CommandLineArg*>() |
| 23 | 23 | << add(QStringList( QStringList() << "-w" << "--setwakeup" ), |
| 24 | 24 | "setwakeup", "", |
| 25 | | "Set the wakeup time (yyyy-MM-ddThh:mm:ss)", "") |
| | 25 | "Set the wakeup time (yyyy-MM-ddThh:mm:ss) " |
| | 26 | "default is in local time", "") |
| 26 | 27 | << add(QStringList( QStringList() << "-t" << "--setscheduledwakeup" ), |
| 27 | 28 | "setschedwakeup", false, |
| 28 | 29 | "Set wakeup time to the next scheduled recording", "") |
| … |
… |
void MythShutdownCommandLineParser::LoadArguments(void)
|
| 66 | 67 | " 64 - In daily wakeup/shutdown period\n" |
| 67 | 68 | " 128 - Less than 15 minutes to next wakeup period\n" |
| 68 | 69 | " 255 - Setup is running") ); |
| | 70 | |
| | 71 | // The localtime command line parameter exists solely to make scripts |
| | 72 | // using this executable self documenting. |
| | 73 | |
| | 74 | CommandLineArg::AllowOneOf( QList<CommandLineArg*>() |
| | 75 | << add("--utc", |
| | 76 | "utc", false, |
| | 77 | "Specify that the wakeup time is in utc", "") |
| | 78 | << add("--localtime", |
| | 79 | "localtime", false, |
| | 80 | "Specify that the wakeup time is in local time", "") ); |
| 69 | 81 | } |
| 70 | 82 | |
diff --git a/mythtv/programs/mythshutdown/main.cpp b/mythtv/programs/mythshutdown/main.cpp
index cf369d9..3988580 100644
|
a
|
b
|
static int checkOKShutdown(bool bWantRecStatus)
|
| 375 | 375 | return res; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | | static int setWakeupTime(QString sWakeupTime) |
| | 378 | static void setWakeupTime(const QDateTime &wakeupTime) |
| 379 | 379 | { |
| 380 | 380 | LOG(VB_GENERAL, LOG_INFO, "Mythshutdown: --setwakeup"); |
| 381 | 381 | |
| 382 | 382 | LOG(VB_GENERAL, LOG_NOTICE, |
| 383 | | QString("Mythshutdown: wakeup time given is: %1").arg(sWakeupTime)); |
| 384 | | |
| 385 | | // check time given is valid |
| 386 | | QDateTime dtWakeupTime; |
| 387 | | dtWakeupTime = MythDate::fromString(sWakeupTime); |
| 388 | | |
| 389 | | if (!dtWakeupTime.isValid()) |
| 390 | | { |
| 391 | | LOG(VB_GENERAL, LOG_ERR, |
| 392 | | QString("Mythshutdown: --setwakeup invalid date " |
| 393 | | "format (%1)\n\t\t\t" |
| 394 | | "must be yyyy-MM-ddThh:mm:ss") |
| 395 | | .arg(sWakeupTime)); |
| 396 | | return 1; |
| 397 | | } |
| | 383 | QString("Mythshutdown: wakeup time given is: %1 (local time)") |
| | 384 | .arg(MythDate::toString(wakeupTime))); |
| 398 | 385 | |
| 399 | 386 | setGlobalSetting("MythShutdownNextScheduled", |
| 400 | | MythDate::toString(dtWakeupTime, MythDate::kDatabase)); |
| 401 | | |
| 402 | | return 0; |
| | 387 | MythDate::toString(wakeupTime, MythDate::kDatabase)); |
| 403 | 388 | } |
| 404 | 389 | |
| 405 | 390 | static int setScheduledWakeupTime() |
| … |
… |
static int setScheduledWakeupTime()
|
| 432 | 417 | if (add) |
| 433 | 418 | restarttime = restarttime.addSecs((-1) * add); |
| 434 | 419 | |
| 435 | | setWakeupTime(restarttime.toString(Qt::ISODate)); |
| | 420 | setWakeupTime(restarttime); |
| 436 | 421 | |
| 437 | 422 | return 0; |
| 438 | 423 | } |
| … |
… |
int main(int argc, char **argv)
|
| 821 | 806 | else if (cmdline.toBool("status")) |
| 822 | 807 | res = getStatus((bool)(cmdline.toInt("status") == 1)); |
| 823 | 808 | else if (cmdline.toBool("setwakeup")) |
| 824 | | res = setWakeupTime(cmdline.toString("setwakeup")); |
| | 809 | { |
| | 810 | // only one of --utc or --localtime can be passed per |
| | 811 | // CommandLineArg::AllowOneOf() in commandlineparser.cpp |
| | 812 | bool utc = cmdline.toBool("utc"); |
| | 813 | QString tmp = cmdline.toString("setwakeup"); |
| | 814 | |
| | 815 | QDateTime wakeuptime = (utc) ? |
| | 816 | MythDate::fromString(tmp) : |
| | 817 | QDateTime::fromString(tmp, Qt::ISODate).toUTC(); |
| | 818 | |
| | 819 | if (!wakeuptime.isValid()) |
| | 820 | { |
| | 821 | cerr << qPrintable( |
| | 822 | QObject::tr("mythshutdown: --setwakeup invalid date " |
| | 823 | "format (%1)\n\t\t\t" |
| | 824 | "must be yyyy-MM-ddThh:mm:ss") |
| | 825 | .arg(tmp)) << endl; |
| | 826 | res = 1; |
| | 827 | } |
| | 828 | else |
| | 829 | { |
| | 830 | setWakeupTime(wakeuptime); |
| | 831 | } |
| | 832 | } |
| 825 | 833 | else if (cmdline.toBool("safeshutdown")) |
| 826 | 834 | { |
| 827 | 835 | res = checkOKShutdown(true); |