Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow --jumppoint and --runplugin to print available destinations

This adds methods to MythMainWindow and MythPluginManager to allow
enumeration of available jump points and plugins, and uses it to list
them when an invalid one is supplied on the command line. This causes a
ABI bump.

Also, this moves the code to load a specific plugin to just prior to
normal program init in the frontend, ensuring certain background tasks
get initialized.

Refs #10135
  • Loading branch information...
commit ca52816fd809366f0298b20e603f9f14f51a3c0a 1 parent c293896
@wagnerrp wagnerrp authored
View
15 mythtv/libs/libmyth/mythplugin.cpp
@@ -19,8 +19,8 @@
using namespace std;
-MythPlugin::MythPlugin(const QString &libname)
- : QLibrary(libname)
+MythPlugin::MythPlugin(const QString &libname, const QString &plugname)
+ : QLibrary(libname), m_plugName(plugname)
{
enabled = true;
position = 0;
@@ -178,7 +178,7 @@ bool MythPluginManager::init_plugin(const QString &plugname)
if (!m_dict[newname])
{
- m_dict.insert(newname, new MythPlugin(newname));
+ m_dict.insert(newname, new MythPlugin(newname, plugname));
}
int result = m_dict[newname]->init(MYTH_BINARY_VERSION);
@@ -318,3 +318,12 @@ void MythPluginManager::DestroyAllPlugins(void)
menuPluginList.clear();
}
+QStringList MythPluginManager::EnumeratePlugins(void)
+{
+ QStringList ret;
+ QHash<QString, MythPlugin*>::const_iterator it = m_dict.begin();
+ for (; it != m_dict.end(); ++it)
+ ret << (*it)->getName();
+ return ret;
+}
+
View
6 mythtv/libs/libmyth/mythplugin.h
@@ -22,7 +22,7 @@ typedef enum {
class MythPlugin : public QLibrary
{
public:
- MythPlugin(const QString &);
+ MythPlugin(const QString &, const QString &);
virtual ~MythPlugin();
// This method will call the mythplugin_init() function of the library.
@@ -48,6 +48,8 @@ class MythPlugin : public QLibrary
int getPosition() { return position; }
void setPosition(int pos) { position = pos; }
+ QString getName(void) { return m_plugName; }
+
// mainmenu plugins, probably should separate out
// setup the plugin -- returns how often (in ms) the plugin wants updated
@@ -59,6 +61,7 @@ class MythPlugin : public QLibrary
private:
bool enabled;
int position;
+ QString m_plugName;
};
// this should only be instantiated through MythContext.
@@ -77,6 +80,7 @@ class MPUBLIC MythPluginManager
MythPlugin *GetMenuPlugin(const QString &plugname);
MythPlugin *GetMenuPluginAt(int pos);
+ QStringList EnumeratePlugins(void);
void DestroyAllPlugins();
private:
View
2  mythtv/libs/libmythbase/mythversion.h
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
-#define MYTH_BINARY_VERSION "0.25.20111111-1"
+#define MYTH_BINARY_VERSION "0.25.20111116-1"
/** \brief Increment this whenever the MythTV network protocol changes.
*
View
5 mythtv/libs/libmythui/mythmainwindow.cpp
@@ -1815,6 +1815,11 @@ bool MythMainWindow::DestinationExists(const QString& destination) const
return (d->destinationMap.count(destination) > 0) ? true : false;
}
+QStringList MythMainWindow::EnumerateDestinations(void) const
+{
+ return d->destinationMap.keys();
+}
+
void MythMainWindow::RegisterMediaPlugin(const QString &name,
const QString &desc,
MediaPlayCallback fn)
View
1  mythtv/libs/libmythui/mythmainwindow.h
@@ -81,6 +81,7 @@ class MUI_PUBLIC MythMainWindow : public QWidget
void JumpTo(const QString &destination, bool pop = true);
bool DestinationExists(const QString &destination) const;
+ QStringList EnumerateDestinations(void) const;
bool IsExitingToMain(void) const;
View
45 mythtv/programs/mythfrontend/main.cpp
@@ -1605,24 +1605,6 @@ int main(int argc, char **argv)
pmanager = new MythPluginManager();
gContext->SetPluginManager(pmanager);
- if (cmdline.toBool("runplugin"))
- {
- if (!pmanager->run_plugin(cmdline.toString("runplugin")) ||
- !pmanager->run_plugin("myth" + cmdline.toString("runplugin")))
- {
- qApp->exec();
- return GENERIC_EXIT_OK;
- }
-
- 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();
if (mon)
{
@@ -1675,7 +1657,26 @@ int main(int argc, char **argv)
PreviewGeneratorQueue::CreatePreviewGeneratorQueue(
PreviewGenerator::kRemote, 50, 60);
- if (cmdline.toBool("jumppoint"))
+ if (cmdline.toBool("runplugin"))
+ {
+ QStringList plugins = pmanager->EnumeratePlugins();
+
+ if (plugins.contains(cmdline.toString("runplugin")))
+ pmanager->run_plugin(cmdline.toString("runplugin"));
+ else if (plugins.contains("myth" + cmdline.toString("runplugin")))
+ pmanager->run_plugin("myth" + cmdline.toString("runplugin"));
+ else
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Invalid plugin name supplied on command line: '%1'")
+ .arg(cmdline.toString("runplugin")));
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Available plugins: %1")
+ .arg(plugins.join(", ")));
+ return GENERIC_EXIT_INVALID_CMDLINE;
+ }
+ }
+ else if (cmdline.toBool("jumppoint"))
{
MythMainWindow *mmw = GetMythMainWindow();
@@ -1686,9 +1687,9 @@ int main(int argc, char **argv)
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
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Available jump points: %2")
+ .arg(mmw->EnumerateDestinations().join(", ")));
return GENERIC_EXIT_INVALID_CMDLINE;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.