74 changes: 15 additions & 59 deletions mythtv/programs/mythcommflag/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ static int FlagCommercials(

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
bool isVideo = false;
int result = GENERIC_EXIT_OK;

Expand All @@ -956,11 +955,6 @@ int main(int argc, char *argv[])
bool queueJobInstead = false;
QString newCutList = QString::null;

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHCOMMFLAG);

verboseMask = VB_IMPORTANT;
verboseString = "important";

MythCommFlagCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
Expand All @@ -980,10 +974,14 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_OK;
}

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHCOMMFLAG);

bool progress = !cmdline.toBool("noprogress");
int retval;
QString mask("important general");
if ((retval = cmdline.ConfigureLogging(mask, progress)) != GENERIC_EXIT_OK)
return retval;

if (!cmdline.toString("chanid").isEmpty())
chanid = cmdline.toUInt("chanid");
Expand Down Expand Up @@ -1062,31 +1060,6 @@ int main(int argc, char *argv[])
dontSubmitCommbreakListToDB = true;
force = true;
}
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
if (cmdline.toBool("verboseint"))
verboseMask = cmdline.toUInt("verboseint");

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

progress = !cmdline.toBool("noprogress");
if (progress)
quiet++;

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

if (cmdline.toBool("queue"))
queueJobInstead = true;
Expand All @@ -1109,30 +1082,17 @@ int main(int argc, char *argv[])

CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(
false/*use gui*/, false/*prompt for backend*/,
false/*bypass auto discovery*/, !useDB/*ignoreDB*/))
if (!gContext->Init( false, /*use gui*/
false, /*prompt for backend*/
false, /*bypass auto discovery*/
!useDB)) /*ignoreDB*/
{
VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting.");
return GENERIC_EXIT_NO_MYTHCONTEXT;
}

QMap<QString, QString> settingsOverride = cmdline.GetSettingsOverride();
if (settingsOverride.size())
{
QMap<QString, QString>::iterator it;
for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}
cmdline.ApplySettingsOverride();

MythTranslation::load("mythfrontend");

Expand Down Expand Up @@ -1174,7 +1134,8 @@ int main(int argc, char *argv[])
return SetCutList(QString::number(chanid), starttime, "");

if (cmdline.toBool("setcutlist"))
return SetCutList(QString::number(chanid), starttime, cmdline.toString("setcutlist"));
return SetCutList(QString::number(chanid), starttime,
cmdline.toString("setcutlist"));

if (cmdline.toBool("getcutlist"))
return GetMarkupList("cutlist", QString::number(chanid), starttime);
Expand Down Expand Up @@ -1222,11 +1183,6 @@ int main(int argc, char *argv[])
time_now = time(NULL);
if (progress)
{
VERBOSE(VB_IMPORTANT, QString("%1 version: %2 www.mythtv.org")
.arg(MYTH_APPNAME_MYTHCOMMFLAG).arg(MYTH_BINARY_VERSION));

VERBOSE(VB_IMPORTANT, QString("Enabled verbose msgs: %1").arg(verboseString));

cerr << "\nMythTV Commercial Flagger, started at "
<< ctime(&time_now);

Expand Down
55 changes: 18 additions & 37 deletions mythtv/programs/mythfilldatabase/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
FillData fill_data;
int fromfile_id = 1;
int fromfile_offset = 0;
Expand All @@ -86,11 +85,6 @@ int main(int argc, char *argv[])
bool from_dd_file = false;
int sourceid = -1;
QString fromddfile_lineupid;
int quiet = 0;

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFILLDATABASE);

myth_nice(19);

MythFillDatabaseCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
Expand All @@ -112,10 +106,14 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_OK;
}

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFILLDATABASE);

myth_nice(19);

int retval;
if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("manual"))
{
Expand Down Expand Up @@ -194,7 +192,8 @@ int main(int argc, char *argv[])
if (!cmdline.toBool("sourceid") ||
!cmdline.toBool("xawtvrcfile"))
{
cerr << "The --xawchannels option must be used in combination" << endl
cerr << "The --xawchannels option must be used in combination"
<< endl
<< "with both --sourceid and --xawtvrcfile" << endl;
}

Expand Down Expand Up @@ -253,22 +252,6 @@ int main(int argc, char *argv[])
if (cmdline.toBool("onlychannels"))
fill_data.only_update_channels = true;

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

mark_repeats = cmdline.toBool("markrepeats");
if (cmdline.toBool("exporticonmap"))
export_icon_data_filename = cmdline.toString("exporticonmap");
Expand All @@ -289,10 +272,6 @@ int main(int argc, char *argv[])

CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
{
Expand Down Expand Up @@ -332,8 +311,9 @@ int main(int argc, char *argv[])
if (query.exec() && query.next())
{
if (!query.isNull(0))
GuideDataBefore = QDateTime::fromString(query.value(0).toString(),
Qt::ISODate);
GuideDataBefore =
QDateTime::fromString(query.value(0).toString(),
Qt::ISODate);
}

if (!fill_data.GrabDataFromFile(fromfile_id, fromfile_name))
Expand All @@ -351,14 +331,15 @@ int main(int argc, char *argv[])
if (query.exec() && query.next())
{
if (!query.isNull(0))
GuideDataAfter = QDateTime::fromString(query.value(0).toString(),
Qt::ISODate);
GuideDataAfter =
QDateTime::fromString(query.value(0).toString(),
Qt::ISODate);
}

if (GuideDataAfter == GuideDataBefore)
status = QObject::tr("mythfilldatabase ran, but did not insert "
"any new data into the Guide. This can indicate a "
"potential problem with the XML file used for the update.");
"any new data into the Guide. This can indicate a "
"potential problem with the XML file used for the update.");
else
status = QObject::tr("Successful.");

Expand Down
54 changes: 5 additions & 49 deletions mythtv/programs/mythfrontend/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,6 @@ int main(int argc, char **argv)
bool bPromptForBackend = false;
bool bBypassAutoDiscovery = false;
bool upgradeAllowed = false;
int quiet = 0;

MythFrontendCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
Expand All @@ -1407,40 +1406,16 @@ int main(int argc, char **argv)
QApplication::setDesktopSettingsAware(false);
#endif
QApplication a(argc, argv);

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFRONTEND);

QString pluginname;

QFileInfo finfo(a.argv()[0]);

QString binname = finfo.baseName();

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org")
.arg(MYTH_APPNAME_MYTHFRONTEND)
.arg(MYTH_SOURCE_PATH)
.arg(MYTH_SOURCE_VERSION));
int retval;
if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
return retval;

bool ResetSettings = false;

Expand Down Expand Up @@ -1469,10 +1444,6 @@ int main(int argc, char **argv)

gContext = new MythContext(MYTH_BINARY_VERSION);

logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

if (!cmdline.toBool("noupnp"))
{
g_pUPnp = new MediaRenderer();
Expand All @@ -1483,26 +1454,14 @@ int main(int argc, char **argv)
}
}

// Override settings as early as possible to cover bootstrapped screens
// such as the language prompt
QMap<QString,QString> settingsOverride = cmdline.GetSettingsOverride();
if (settingsOverride.size())
{
QMap<QString, QString>::iterator it;
for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}

if (!gContext->Init(true, bPromptForBackend, bBypassAutoDiscovery))
{
VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting.");
return GENERIC_EXIT_NO_MYTHCONTEXT;
}

cmdline.ApplySettingsOverride();

if (!GetMythDB()->HaveSchema())
{
if (!InitializeMythSchema())
Expand Down Expand Up @@ -1535,9 +1494,6 @@ int main(int argc, char **argv)

setuid(getuid());

VERBOSE(VB_IMPORTANT,
QString("Enabled verbose msgs: %1").arg(verboseString));

LCD::SetupLCD();
if (LCD *lcd = LCD::Get())
lcd->setupLEDs(RemoteGetRecordingMask);
Expand Down
54 changes: 6 additions & 48 deletions mythtv/programs/mythjobqueue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ namespace

int main(int argc, char *argv[])
{
int quiet = 0;

MythJobQueueCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
Expand All @@ -96,45 +94,19 @@ int main(int argc, char *argv[])
}

QCoreApplication a(argc, argv);
QMap<QString, QString> settingsOverride = cmdline.GetSettingsOverride();
bool daemonize = false;

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHJOBQUEUE);

QString filename;

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;
bool daemonize = cmdline.toBool("daemon");
int retval;
QString mask("important general");
if ((retval = cmdline.ConfigureLogging(mask, daemonize)) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("pidfile"))
pidfile = cmdline.toString("pidfile");
if (cmdline.toBool("daemon"))
daemonize = true;

CleanupGuard callCleanup(cleanup);

logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

ofstream pidfs;
if (pidfile.size())
{
Expand Down Expand Up @@ -162,28 +134,14 @@ int main(int argc, char *argv[])
pidfs.close();
}

VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org")
.arg(MYTH_APPNAME_MYTHJOBQUEUE)
.arg(MYTH_SOURCE_PATH)
.arg(MYTH_SOURCE_VERSION));

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to init MythContext, exiting.");
return GENERIC_EXIT_NO_MYTHCONTEXT;
}

if (settingsOverride.size())
{
QMap<QString, QString>::iterator it;
for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}
cmdline.ApplySettingsOverride();

if (!gCoreContext->ConnectToMasterServer())
{
Expand Down
43 changes: 9 additions & 34 deletions mythtv/programs/mythlcdserver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ using namespace std;

int main(int argc, char **argv)
{
QCoreApplication a(argc, argv);
bool daemon_mode = false;
int special_port = -1;
QString startup_message = ""; // default to no startup message
int message_time = 30; // time to display startup message
verboseMask = VB_IMPORTANT; // only show important messages
QString logfile;
int quiet = 0;

// TODO: check if this can use LOG_*
debug_level = 0; // don't show any debug messages by default

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHLCDSERVER);

MythLCDServerCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
Expand All @@ -60,33 +54,14 @@ int main(int argc, char **argv)
return GENERIC_EXIT_OK;
}

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

if (cmdline.toBool("daemon"))
{
daemon_mode = true;
if (!quiet)
quiet = 1;
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHLCDSERVER);

bool daemonize = cmdline.toBool("daemon");
int retval;
QString mask("important general");
if ((retval = cmdline.ConfigureLogging(mask, daemonize)) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("port"))
{
Expand Down Expand Up @@ -122,7 +97,7 @@ int main(int argc, char **argv)
cerr << "Unable to ignore SIGPIPE\n";

// Switch to daemon mode?
if (daemon_mode)
if (daemonize)
{
if (daemon(0, 1) < 0)
{
Expand Down
13 changes: 6 additions & 7 deletions mythtv/programs/mythmediaserver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ namespace

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHMEDIASERVER);

MythMediaServerCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
Expand All @@ -92,9 +88,13 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_OK;
}

QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHMEDIASERVER);

bool daemonize = cmdline.toBool("daemon");
int retval;
if ((retval = cmdline.ConfigureLogging(daemonize)) != GENERIC_EXIT_OK)
QString mask("important general");
if ((retval = cmdline.ConfigureLogging(mask, daemonize)) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("pidfile"))
Expand All @@ -108,8 +108,7 @@ int main(int argc, char *argv[])
pidfs.open(pidfile.toAscii().constData());
if (!pidfs)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Could not open pid file" + ENO);
VERBOSE(VB_IMPORTANT, LOC_ERR + "Could not open pid file" + ENO);
return GENERIC_EXIT_PERMISSIONS_ERROR;
}
}
Expand Down
34 changes: 4 additions & 30 deletions mythtv/programs/mythpreviewgen/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ int preview_helper(const QString &_chanid, const QString &starttime,

int main(int argc, char **argv)
{
int quiet = 0;

MythPreviewGeneratorCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
Expand Down Expand Up @@ -183,9 +181,12 @@ int main(int argc, char **argv)
// such as socket notifications :[
QApplication a(argc, argv);
#endif

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHPREVIEWGEN);

int retval;
if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
return retval;

if ((!cmdline.toBool("chanid") || !cmdline.toBool("starttime")) &&
!cmdline.toBool("inputfile"))
{
Expand All @@ -195,43 +196,16 @@ int main(int argc, char **argv)
return GENERIC_EXIT_INVALID_CMDLINE;
}

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

///////////////////////////////////////////////////////////////////////

// Don't listen to console input
close(0);

CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
VERBOSE(VB_IMPORTANT, LOC_WARN + "Unable to ignore SIGPIPE");

{
QString versionStr = QString("%1 version: %2 [%3] www.mythtv.org")
.arg(MYTH_APPNAME_MYTHPREVIEWGEN).arg(MYTH_SOURCE_PATH)
.arg(MYTH_SOURCE_VERSION);
VERBOSE(VB_IMPORTANT, versionStr);
}

gContext = new MythContext(MYTH_BINARY_VERSION);

if (!gContext->Init(false))
Expand Down
40 changes: 8 additions & 32 deletions mythtv/programs/mythshutdown/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,6 @@ static int startup()

int main(int argc, char **argv)
{
// by default we don't output any messages
verboseMask = VB_NONE;

QCoreApplication a(argc, argv);

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHSHUTDOWN);

bool bLockShutdown = false;
bool bUnlockShutdown = false;
bool bCheckOKShutdown = false;
Expand All @@ -750,7 +743,6 @@ int main(int argc, char **argv)
bool bSetScheduledWakeupTime = false;
bool bCheckAndShutdown = false;
bool bWantRecStatus = true;
int quiet = 0;

MythShutdownCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
Expand All @@ -771,26 +763,13 @@ int main(int argc, char **argv)
return GENERIC_EXIT_OK;
}

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHSHUTDOWN);

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;
int retval;
QString mask("none");
if ((retval = cmdline.ConfigureLogging(mask)) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("lock"))
bLockShutdown = true;
Expand Down Expand Up @@ -818,10 +797,6 @@ int main(int argc, char **argv)
bWantRecStatus = (bool)(cmdline.toInt("status") == 1);
}

QString logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
{
Expand Down Expand Up @@ -851,8 +826,9 @@ int main(int argc, char **argv)
else if (bCheckAndShutdown)
{
res = checkOKShutdown(true);
if (res == 0) // Nothing to stop a shutdown (eg. recording in progress).
if (res == 0)
{
// Nothing to stop a shutdown (eg. recording in progress).
res = setScheduledWakeupTime();
res = shutdown();
}
Expand Down
90 changes: 23 additions & 67 deletions mythtv/programs/mythtranscode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,28 +132,20 @@ int main(int argc, char *argv[])
int jobType = JOB_NONE;
int otype = REPLEX_MPEG2;
bool useCutlist = false, keyframesonly = false;
bool build_index = false, fifosync = false, showprogress = false;
bool build_index = false, fifosync = false;
bool mpeg2 = false;
QMap<QString, QString> settingsOverride;
frm_dir_map_t deleteMap;
frm_pos_map_t posMap;
srand(time(NULL));
int AudioTrackNo = -1;

QCoreApplication a(argc, argv);

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHTRANSCODE);

verboseMask = VB_IMPORTANT;
verboseString = "important";

int found_starttime = 0;
int found_chanid = 0;
int found_infile = 0;
int update_index = 1;
int isVideo = 0;
bool passthru = false;
int quiet = 0;

MythTranscodeCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
Expand All @@ -174,12 +166,22 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_OK;
}

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
if (cmdline.toBool("verboseint"))
verboseMask = cmdline.toUInt("verboseint");
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHTRANSCODE);

if (cmdline.toBool("outputfile"))
{
outfile = cmdline.toString("outputfile");
update_index = 0;
}

bool showprogress = cmdline.toBool("showprogress");

int retval;
QString mask("important general");
bool quiet = (outfile == "-") || showprogress;
if ((retval = cmdline.ConfigureLogging(mask, quiet)) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("starttime"))
{
Expand All @@ -198,11 +200,6 @@ int main(int argc, char *argv[])
infile = cmdline.toString("inputfile");
found_infile = 1;
}
if (cmdline.toBool("outputfile"))
{
outfile = cmdline.toString("outputfile");
update_index = 0;
}
if (cmdline.toBool("video"))
isVideo = true;
if (cmdline.toBool("profile"))
Expand All @@ -224,7 +221,8 @@ int main(int argc, char *argv[])
QStringList::iterator it;
for (it = cutlist.begin(); it != cutlist.end(); ++it)
{
QStringList startend = (*it).split("-", QString::SkipEmptyParts);
QStringList startend =
(*it).split("-", QString::SkipEmptyParts);
if (startend.size() == 2)
{
cerr << "Cutting from: " << startend.first().toULongLong()
Expand Down Expand Up @@ -296,43 +294,13 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_INVALID_CMDLINE;
}
}
if (cmdline.toBool("overridesettings"))
settingsOverride = cmdline.GetSettingsOverride();
if (cmdline.toBool("audiotrack"))
AudioTrackNo = cmdline.toInt("audiotrack");
if (cmdline.toBool("passthru"))
passthru = true;

if (outfile == "-")
verboseMask = VB_NONE;

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

showprogress = cmdline.toBool("showprogress");
if (showprogress)
quiet++;

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

QString logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

// Load the context
MythContext context(MYTH_BINARY_VERSION);
gContext = &context;
gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
{
VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting.");
Expand All @@ -341,21 +309,11 @@ int main(int argc, char *argv[])

MythTranslation::load("mythfrontend");

if (settingsOverride.size())
{
QMap<QString, QString>::iterator it;
for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}
cmdline.ApplySettingsOverride();

if (jobID != -1)
{
if (JobQueue::GetJobInfoFromID(
jobID, jobType, chanid, startts))
if (JobQueue::GetJobInfoFromID(jobID, jobType, chanid, startts))
{
starttime = startts.toString(Qt::ISODate);
found_starttime = 1;
Expand All @@ -369,7 +327,7 @@ int main(int argc, char *argv[])
}
}

if ((! found_infile && !(found_chanid && found_starttime)) ||
if ((!found_infile && !(found_chanid && found_starttime)) ||
(found_infile && (found_chanid || found_starttime)) )
{
cerr << "Must specify -i OR -c AND -s options!\n";
Expand Down Expand Up @@ -401,8 +359,6 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_INVALID_CMDLINE;
}

VERBOSE(VB_IMPORTANT, QString("Enabled verbose msgs: %1").arg(verboseString));

if (!MSqlQuery::testDBConnection())
{
printf("couldn't open db\n");
Expand Down
70 changes: 14 additions & 56 deletions mythtv/programs/mythtv-setup/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ int main(int argc, char *argv[])
QString scanTableName = "atsc-vsb8-us";
QString scanInputName = "";
bool use_display = true;
int quiet = 0;

MythTVSetupCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
Expand All @@ -224,58 +223,31 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_OK;
}

if (cmdline.toBool("display"))
display = cmdline.toString("display");
if (cmdline.toBool("geometry"))
geometry = cmdline.toString("geometry");

if (cmdline.toBool("scan"))
{
quiet = 1;
use_display = false;
verboseMask = VB_NONE;
verboseString = "";
}

#ifdef Q_WS_MACX
// Without this, we can't set focus to any of the CheckBoxSetting, and most
// of the MythPushButton widgets, and they don't use the themed background.
QApplication::setDesktopSettingsAware(FALSE);
#endif
QApplication a(argc, argv, use_display);

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHTV_SETUP);

QMap<QString, QString> settingsOverride;

VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org")
.arg(MYTH_APPNAME_MYTHTV_SETUP)
.arg(MYTH_SOURCE_PATH)
.arg(MYTH_SOURCE_VERSION));

if (cmdline.toBool("verbose"))
if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
if (cmdline.toBool("display"))
display = cmdline.toString("display");
if (cmdline.toBool("geometry"))
geometry = cmdline.toString("geometry");

if (cmdline.toBool("quiet"))
bool quiet = false;
if (cmdline.toBool("scan"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
quiet = true;
use_display = false;
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;
int retval;
QString mask("important general");
if ((retval = cmdline.ConfigureLogging(mask, quiet)) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("overridesettings"))
settingsOverride = cmdline.GetSettingsOverride();
if (cmdline.toBool("expert"))
expertMode = true;
if (cmdline.toBool("scanlist"))
Expand Down Expand Up @@ -313,10 +285,6 @@ int main(int argc, char *argv[])
if (cmdline.toBool("inputname"))
scanInputName = cmdline.toString("inputname");

logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

if (!display.isEmpty())
{
MythUIHelper::SetX11Display(display);
Expand All @@ -330,18 +298,8 @@ int main(int argc, char *argv[])
gContext = new MythContext(MYTH_BINARY_VERSION);

std::auto_ptr<MythContext> contextScopeDelete(gContext);
// Override settings as early as possible to cover bootstrapped screens
// such as the language prompt
if (settingsOverride.size())
{
QMap<QString, QString>::iterator it;
for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}

cmdline.ApplySettingsOverride();

if (!gContext->Init(use_display)) // No Upnp, Prompt for db
{
Expand Down
28 changes: 3 additions & 25 deletions mythtv/programs/mythwelcome/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static void initKeys(void)
int main(int argc, char **argv)
{
bool bShowSettings = false;
int quiet = 0;

MythWelcomeCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
Expand All @@ -68,36 +67,15 @@ int main(int argc, char **argv)
}

QApplication a(argc, argv);

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHWELCOME);

if (verboseArgParse(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
int retval;
if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
return retval;

if (cmdline.toBool("setup"))
bShowSettings = true;

if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");
LogLevel_t level = cmdline.GetLogLevel();
if (level == LOG_UNKNOWN)
return GENERIC_EXIT_INVALID_CMDLINE;

logfile = cmdline.GetLogFilePath();
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, level, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init())
{
Expand Down