MythTV  master
mythplugins/mythnetvision/mythnetvision/main.cpp
Go to the documentation of this file.
1 // C++ headers
2 #include <unistd.h>
3 
4 // QT headers
5 #include <QApplication>
6 
7 // MythTV headers
8 #include <mythcontext.h>
9 #include <mythplugin.h>
10 #include <mythpluginapi.h>
11 #include <mythversion.h>
12 #include <mythmainwindow.h>
13 #include <netgrabbermanager.h>
14 #include <mythrssmanager.h>
15 
16 // MythNetVision headers
17 #include "netsearch.h"
18 #include "nettree.h"
19 #include "treeeditor.h"
20 
21 using namespace std;
22 
24 RSSManager *rssMan = nullptr;
25 
26 static int RunNetVision(void)
27 {
29 
30  auto *netsearch = new NetSearch(mainStack, "mythnetsearch");
31 
32  if (netsearch->Create())
33  {
34  mainStack->AddScreen(netsearch);
35  return 0;
36  }
37  delete netsearch;
38  return -1;
39 }
40 
41 static int RunNetTree(void)
42 {
44 
45  DialogType type = static_cast<DialogType>(gCoreContext->GetNumSetting(
46  "mythnetvision.ViewMode", DLG_TREE));
47 
48  auto *nettree = new NetTree(type, mainStack, "mythnettree");
49 
50  if (nettree->Create())
51  {
52  mainStack->AddScreen(nettree);
53  return 0;
54  }
55  delete nettree;
56  return -1;
57 }
58 
59 static void runNetVision(void)
60 {
61  RunNetVision();
62 }
63 
64 static void runNetTree(void)
65 {
66  RunNetTree();
67 }
68 
69 static void setupKeys(void)
70 {
71  REG_JUMP("MythNetSearch", QT_TRANSLATE_NOOP("MythControls",
72  "Internet Television Client - Search"), "", runNetVision);
73  REG_JUMP("MythNetTree", QT_TRANSLATE_NOOP("MythControls",
74  "Internet Television Client - Site/Tree View"), "", runNetTree);
75 
76  REG_KEY("Internet Video", "PAGELEFT", QT_TRANSLATE_NOOP("MythControls",
77  "Previous Page"), "");
78  REG_KEY("Internet Video", "PAGERIGHT", QT_TRANSLATE_NOOP("MythControls",
79  "Next Page"), "");
80 }
81 
82 int mythplugin_init(const char *libversion)
83 {
84  if (!MythCoreContext::TestPluginVersion("mythnetvision",
85  libversion,
87  return -1;
88 
89  setupKeys();
90 
91  return 0;
92 }
93 
94 int mythplugin_run(void)
95 {
96  return RunNetVision();
97 }
98 
#define REG_JUMP(a, b, c, d)
int mythplugin_init(const char *libversion)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythScreenStack * GetMainStack()
#define REG_KEY(a, b, c, d)
static bool TestPluginVersion(const QString &name, const QString &libversion, const QString &pluginversion)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
DialogType
Definition: nettree.h:20
MythMainWindow * GetMythMainWindow(void)
int GetNumSetting(const QString &key, int defaultval=0)
#define MYTH_BINARY_VERSION
Update this whenever the plug-in ABI changes.
Definition: mythversion.h:16
static void runNetVision(void)