MythTV  master
mythplugins/mythnews/mythnews/main.cpp
Go to the documentation of this file.
1 
2 // C++ headers
3 #include <unistd.h>
4 
5 // QT headers
6 #include <QApplication>
7 
8 // MythTV headers
9 #include <mythcontext.h>
10 #include <mythplugin.h>
11 #include <mythpluginapi.h>
12 #include <mythversion.h>
13 #include <mythmainwindow.h>
14 
15 // MythNews headers
16 #include "dbcheck.h"
17 #include "mythnews.h"
18 #include "mythnewsconfig.h"
19 
20 using namespace std;
21 
22 static int RunNews(void)
23 {
25 
26  MythNews *mythnews = new MythNews(mainStack, "mythnews");
27 
28  if (mythnews->Create())
29  {
30  mainStack->AddScreen(mythnews);
31  return 0;
32  }
33  delete mythnews;
34  return -1;
35 }
36 
37 static void runNews(void)
38 {
39  RunNews();
40 }
41 
42 static void setupKeys(void)
43 {
44  REG_JUMP("MythNews", QT_TRANSLATE_NOOP("MythControls",
45  "RSS News feed reader"), "", runNews);
46 
47  REG_KEY("News", "RETRIEVENEWS",
48  QT_TRANSLATE_NOOP("MythControls", "Update news items"), "I");
49  REG_KEY("News", "FORCERETRIEVE",
50  QT_TRANSLATE_NOOP("MythControls", "Force update news items"), "M");
51  REG_KEY("News", "CANCEL",
52  QT_TRANSLATE_NOOP("MythControls", "Cancel news item updating"), "C");
53 }
54 
55 int mythplugin_init(const char *libversion)
56 {
57  if (!gCoreContext->TestPluginVersion("mythnews",
58  libversion,
60  return -1;
61 
64  {
65  LOG(VB_GENERAL, LOG_ERR,
66  "Couldn't upgrade database to new schema, exiting.");
67  return -1;
68  }
70 
71  setupKeys();
72 
73  return 0;
74 }
75 
76 int mythplugin_run(void)
77 {
78  return RunNews();
79 }
80 
82 {
84 
85  MythNewsConfig *mythnewsconfig = new MythNewsConfig(mainStack, "mythnewsconfig");
86 
87  if (mythnewsconfig->Create())
88  {
89  mainStack->AddScreen(mythnewsconfig);
90  return 0;
91  }
92  delete mythnewsconfig;
93  return -1;
94 }
95 
96 
97 
#define REG_JUMP(a, b, c, d)
int mythplugin_config(void)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythScreenStack * GetMainStack()
#define REG_KEY(a, b, c, d)
bool TestPluginVersion(const QString &name, const QString &libversion, const QString &pluginversion)
static int RunNews(void)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythMainWindow * GetMythMainWindow(void)
bool UpgradeNewsDatabaseSchema(void)
bool Create(void) override
Definition: mythnews.cpp:74
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
#define MYTH_BINARY_VERSION
Update this whenever the plug-in ABI changes.
Definition: mythversion.h:16
bool Create(void) override
Plugin for browsing RSS news feeds.
Definition: mythnews.h:21
static void setupKeys(void)
void ActivateSettingsCache(bool activate=true)
static void runNews(void)
int mythplugin_init(const char *libversion)