Skip to content

Commit

Permalink
Add --jumppoint and --runplugin to mythfrontend
Browse files Browse the repository at this point in the history
This adds two new options for mythfrontend.  --jumppoint will
immediately jump to the specified point when the frontend has finished
loading.  --runplugin will jump to the base window of the specified
plugin.  Both will terminate if an invalid name is given.

This removes the old behavior of allowing plugin access through
alternate executable file names, or extra arguments on the command line.

Closes #10135

Signed-off-by: Raymond Wagner <rwagner@mythtv.org>
  • Loading branch information
androidrbox authored and wagnerrp committed Nov 15, 2011
1 parent 8ea8f9a commit 32c1268
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
13 changes: 11 additions & 2 deletions mythtv/programs/mythfrontend/commandlineparser.cpp
Expand Up @@ -12,7 +12,6 @@ MythFrontendCommandLineParser::MythFrontendCommandLineParser() :

void MythFrontendCommandLineParser::LoadArguments(void)
{
allowArgs();
addHelp();
addVersion();
addWindowed();
Expand All @@ -28,7 +27,17 @@ void MythFrontendCommandLineParser::LoadArguments(void)
add(QStringList( QStringList() << "-p" << "--prompt" ), "prompt", false,
"Always prompt for backend selection.", "");
add(QStringList( QStringList() << "-d" << "--disable-autodiscovery" ),
"noautodiscovery", false, "Prevent frontend from using UPnP autodiscovery.", "");
"noautodiscovery", false,
"Prevent frontend from using UPnP autodiscovery.", "");

add("--jumppoint", "jumppoint", "",
"Start the frontend at specified jump point.", "")
->SetGroup("Startup Behavior");
add("--runplugin", "runplugin", "",
"Start the frontend within specified plugin.", "")
->SetGroup("Startup Behavior")
->SetBlocks("jumppoint");

}

QString MythFrontendCommandLineParser::GetHelpHeader(void) const
Expand Down
46 changes: 29 additions & 17 deletions mythtv/programs/mythfrontend/main.cpp
Expand Up @@ -1465,20 +1465,12 @@ int main(int argc, char **argv)
new QApplication(argc, argv);
QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFRONTEND);

QString pluginname;

QFileInfo finfo(qApp->argv()[0]);
QString binname = finfo.baseName();

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

bool ResetSettings = false;

if (binname.toLower() != "mythfrontend")
pluginname = binname;

if (cmdline.toBool("prompt"))
bPromptForBackend = true;
if (cmdline.toBool("noautodiscovery"))
Expand Down Expand Up @@ -1526,9 +1518,6 @@ int main(int argc, char **argv)
if (cmdline.toBool("reset"))
ResetSettings = true;

if (cmdline.GetArgs().size() >= 1)
pluginname = cmdline.GetArgs()[0];

QString fileprefix = GetConfDir();

QDir dir(fileprefix);
Expand Down Expand Up @@ -1616,17 +1605,22 @@ int main(int argc, char **argv)
pmanager = new MythPluginManager();
gContext->SetPluginManager(pmanager);

if (pluginname.size())
if (cmdline.toBool("runplugin"))
{
if (pmanager->run_plugin(pluginname) ||
pmanager->run_plugin("myth" + pluginname))
if (!pmanager->run_plugin(cmdline.toString("runplugin")) ||
!pmanager->run_plugin("myth" + cmdline.toString("runplugin")))
{
qApp->exec();

return GENERIC_EXIT_OK;
}
else
return GENERIC_EXIT_INVALID_CMDLINE;

LOG(VB_GENERAL, LOG_ERR,
QString("Invalid plugin name supplied on command line: '%1'")
.arg(cmdline.toString("runplugin")));
// TODO: list available plugins
// will require new method in MythPluginManager to enumerate
// registered plugins
return GENERIC_EXIT_INVALID_CMDLINE;
}

MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
Expand Down Expand Up @@ -1681,6 +1675,24 @@ int main(int argc, char **argv)
PreviewGeneratorQueue::CreatePreviewGeneratorQueue(
PreviewGenerator::kRemote, 50, 60);

if (cmdline.toBool("jumppoint"))
{
MythMainWindow *mmw = GetMythMainWindow();

if (mmw->DestinationExists(cmdline.toString("jumppoint")))
mmw->JumpTo(cmdline.toString("jumppoint"));
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("Invalid jump point supplied on the command line: %1")
.arg(cmdline.toString("jumppoint")));
// TODO: list available jump points
// will require new method from MythMainWindow to enumerate
// registered points
return GENERIC_EXIT_INVALID_CMDLINE;
}
}

int ret = qApp->exec();

PreviewGeneratorQueue::TeardownPreviewGeneratorQueue();
Expand Down

0 comments on commit 32c1268

Please sign in to comment.