00001
00002
00003 #include <unistd.h>
00004
00005
00006 #include <QApplication>
00007
00008
00009 #include <mythcontext.h>
00010 #include <mythplugin.h>
00011 #include <mythpluginapi.h>
00012 #include <mythversion.h>
00013 #include <mythmainwindow.h>
00014
00015
00016 #include "dbcheck.h"
00017 #include "mythnews.h"
00018 #include "mythnewsconfig.h"
00019
00020 using namespace std;
00021
00022 static int RunNews(void)
00023 {
00024 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
00025
00026 MythNews *mythnews = new MythNews(mainStack, "mythnews");
00027
00028 if (mythnews->Create())
00029 {
00030 mainStack->AddScreen(mythnews);
00031 return 0;
00032 }
00033 else
00034 {
00035 delete mythnews;
00036 return -1;
00037 }
00038 }
00039
00040 static void runNews(void)
00041 {
00042 RunNews();
00043 }
00044
00045 static void setupKeys(void)
00046 {
00047 REG_JUMP("MythNews", QT_TRANSLATE_NOOP("MythControls",
00048 "RSS News feed reader"), "", runNews);
00049
00050 REG_KEY("News", "RETRIEVENEWS",
00051 QT_TRANSLATE_NOOP("MythControls", "Update news items"), "I");
00052 REG_KEY("News", "FORCERETRIEVE",
00053 QT_TRANSLATE_NOOP("MythControls", "Force update news items"), "M");
00054 REG_KEY("News", "CANCEL",
00055 QT_TRANSLATE_NOOP("MythControls", "Cancel news item updating"), "C");
00056 }
00057
00058 int mythplugin_init(const char *libversion)
00059 {
00060 if (!gContext->TestPopupVersion("mythnews",
00061 libversion,
00062 MYTH_BINARY_VERSION))
00063 return -1;
00064
00065 gCoreContext->ActivateSettingsCache(false);
00066 if (!UpgradeNewsDatabaseSchema())
00067 {
00068 LOG(VB_GENERAL, LOG_ERR,
00069 "Couldn't upgrade database to new schema, exiting.");
00070 return -1;
00071 }
00072 gCoreContext->ActivateSettingsCache(true);
00073
00074 setupKeys();
00075
00076 return 0;
00077 }
00078
00079 int mythplugin_run(void)
00080 {
00081 return RunNews();
00082 }
00083
00084 int mythplugin_config(void)
00085 {
00086 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
00087
00088 MythNewsConfig *mythnewsconfig = new MythNewsConfig(mainStack, "mythnewsconfig");
00089
00090 if (mythnewsconfig->Create())
00091 {
00092 mainStack->AddScreen(mythnewsconfig);
00093 return 0;
00094 }
00095 else
00096 {
00097 delete mythnewsconfig;
00098 return -1;
00099 }
00100 }
00101
00102
00103