MythTV  master
libmythnews.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 <libmyth/mythcontext.h>
10 #include <libmythbase/mythplugin.h>
12 #include <libmythbase/mythversion.h>
14 
15 // MythNews headers
16 #include "mythnews.h"
17 #include "mythnewsconfig.h"
18 #include "newsdbcheck.h"
19 
20 static int RunNews(void)
21 {
23 
24  auto *mythnews = new MythNews(mainStack, "mythnews");
25 
26  if (mythnews->Create())
27  {
28  mainStack->AddScreen(mythnews);
29  return 0;
30  }
31  delete mythnews;
32  return -1;
33 }
34 
35 static void runNews(void)
36 {
37  RunNews();
38 }
39 
40 static void setupKeys(void)
41 {
42  REG_JUMP("MythNews", QT_TRANSLATE_NOOP("MythControls",
43  "RSS News feed reader"), "", runNews);
44 
45  REG_KEY("News", "RETRIEVENEWS",
46  QT_TRANSLATE_NOOP("MythControls", "Update news items"), "I");
47  REG_KEY("News", "FORCERETRIEVE",
48  QT_TRANSLATE_NOOP("MythControls", "Force update news items"), "M");
49  REG_KEY("News", "CANCEL",
50  QT_TRANSLATE_NOOP("MythControls", "Cancel news item updating"), "C");
51 }
52 
53 int mythplugin_init(const char *libversion)
54 {
55  if (!MythCoreContext::TestPluginVersion("mythnews",
56  libversion,
57  MYTH_BINARY_VERSION))
58  return -1;
59 
62  {
63  LOG(VB_GENERAL, LOG_ERR,
64  "Couldn't upgrade database to new schema, exiting.");
65  return -1;
66  }
68 
69  setupKeys();
70 
71  return 0;
72 }
73 
74 int mythplugin_run(void)
75 {
76  return RunNews();
77 }
78 
80 {
82 
83  auto *mythnewsconfig = new MythNewsConfig(mainStack, "mythnewsconfig");
84 
85  if (mythnewsconfig->Create())
86  {
87  mainStack->AddScreen(mythnewsconfig);
88  return 0;
89  }
90  delete mythnewsconfig;
91  return -1;
92 }
93 
94 
95 
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:318
REG_KEY
static void REG_KEY(const QString &Context, const QString &Action, const QString &Description, const QString &Key)
Definition: mythmainwindow.h:175
mythplugin_run
int mythplugin_run(void)
Definition: libmythnews.cpp:74
newsdbcheck.h
mythnewsconfig.h
mythplugin.h
runNews
static void runNews(void)
Definition: libmythnews.cpp:35
MythScreenStack
Definition: mythscreenstack.h:16
MythNews
Plugin for browsing RSS news feeds.
Definition: mythnews.h:21
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythCoreContext::TestPluginVersion
static bool TestPluginVersion(const QString &name, const QString &libversion, const QString &pluginversion)
Definition: mythcorecontext.cpp:2079
setupKeys
static void setupKeys(void)
Definition: libmythnews.cpp:40
mythnews.h
UpgradeNewsDatabaseSchema
bool UpgradeNewsDatabaseSchema(void)
Definition: newsdbcheck.cpp:19
RunNews
static int RunNews(void)
Definition: libmythnews.cpp:20
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
mythpluginapi.h
mythplugin_init
int mythplugin_init(const char *libversion)
Definition: libmythnews.cpp:53
REG_JUMP
static void REG_JUMP(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void))
Definition: mythmainwindow.h:188
mythcontext.h
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:104
MythCoreContext::ActivateSettingsCache
void ActivateSettingsCache(bool activate=true)
Definition: mythcorecontext.cpp:833
mythplugin_config
int mythplugin_config(void)
Definition: libmythnews.cpp:79
MythNewsConfig
Definition: mythnewsconfig.h:16
mythmainwindow.h
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:52