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