Skip to content

Commit

Permalink
Merge branch 'master' of github.com:MythTV/mythtv
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Kendall committed Jun 30, 2011
2 parents 24256df + e3486be commit 0665d99
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 48 deletions.
52 changes: 52 additions & 0 deletions mythtv/libs/libmythbase/mythcommandlineparser.cpp
Expand Up @@ -18,6 +18,7 @@ using namespace std;
#include <QTextStream>

#include "mythcommandlineparser.h"
#include "mythcorecontext.h"
#include "exitcodes.h"
#include "mythconfig.h"
#include "mythlogging.h"
Expand Down Expand Up @@ -1047,3 +1048,54 @@ bool MythCommandLineParser::SetValue(const QString &key, QVariant value)
return true;
}

int MythCommandLineParser::ConfigureLogging(void)
{
int err = 0,
quiet = 0;

verboseMask = VB_IMPORTANT;
verboseString = "important";

if (toBool("verbose"))
if ((err = verboseArgParse(toString("verbose"))))
return err;
else if (toBool("verboseint"))
verboseMask = toUInt("verboseint");
else if (toBool("quiet"))
{
quiet = toUInt("quiet");
if (quiet > 1)
{
verboseMask = VB_NONE;
verboseArgParse("none");
}
}

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

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

return 0;
}

// WARNING: this must not be called until after MythContext is initialized
void MythCommandLineParser::ApplySettingsOverride(void)
{
QMap<QString, QString> override = GetSettingsOverride();
if (override.size())
{
QMap<QString, QString>::iterator it;
for (it = override.begin(); it != override.end(); ++it)
{
VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
.arg(it.key()).arg(*it));
gCoreContext->OverrideSettingForSession(it.key(), *it);
}
}
}
6 changes: 4 additions & 2 deletions mythtv/libs/libmythbase/mythcommandlineparser.h
Expand Up @@ -131,8 +131,6 @@ class MBASE_PUBLIC MythCommandLineParser
LogLevel_t GetLogLevel(void);
QString GetPassthrough(void) const { return m_passthrough.join(" "); }

bool SetValue(const QString &key, QVariant value);

bool toBool(QString key) const;
int toInt(QString key) const;
uint toUInt(QString key) const;
Expand All @@ -144,6 +142,10 @@ class MBASE_PUBLIC MythCommandLineParser
QMap<QString,QString> toMap(QString key) const;
QDateTime toDateTime(QString key) const;

bool SetValue(const QString &key, QVariant value);
int ConfigureLogging(void);
void ApplySettingsOverride(void);

protected:
void allowExtras(bool allow=true) { m_allowExtras = allow; }
void allowPassthrough(bool allow=true) { m_allowPassthrough = allow; }
Expand Down
13 changes: 13 additions & 0 deletions mythtv/libs/libmythmetadata/metadatacommon.cpp
Expand Up @@ -419,6 +419,19 @@ MetadataLookup* ParseMetadataMovieNFO(const QDomElement& item,
.trimmed().toUInt();
runtimesecs = runtime * 60;

QDomElement actor = item.firstChildElement("actor");
if (!actor.isNull())
{
while (!actor.isNull())
{
PersonInfo info;
info.name = actor.firstChildElement("name").text();
info.role = actor.firstChildElement("role").text();
people.insert(ACTOR, info);
actor = actor.nextSiblingElement("actor");
}
}

return new MetadataLookup(lookup->GetType(), lookup->GetData(),
lookup->GetStep(), lookup->GetAutomatic(), lookup->GetHandleImages(),
lookup->GetAllowOverwrites(), lookup->GetPreferDVDOrdering(),
Expand Down
50 changes: 4 additions & 46 deletions mythtv/programs/mythmediaserver/main.cpp
Expand Up @@ -70,17 +70,12 @@ namespace
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QMap<QString, QString> settingsOverride;
bool daemonize = false;
int quiet = 0;

QString filename;

QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHMEDIASERVER);

verboseMask = VB_IMPORTANT;
verboseString = "important";

MythMediaServerCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
Expand All @@ -100,43 +95,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;
cmdline.ConfigureLogging();

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

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");
}
}

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

CleanupGuard callCleanup(cleanup);

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

ofstream pidfs;
if (pidfile.size())
{
Expand All @@ -152,6 +117,8 @@ int main(int argc, char *argv[])
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
VERBOSE(VB_IMPORTANT, LOC_WARN + "Unable to ignore SIGPIPE");

daemonize = cmdline.toBool("daemon");

if (daemonize && (daemon(0, 1) < 0))
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to daemonize" + ENO);
Expand All @@ -176,16 +143,7 @@ int main(int argc, char *argv[])
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

0 comments on commit 0665d99

Please sign in to comment.