00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023
00024 #include <qapplication.h>
00025 #include <unistd.h>
00026
00027 #include "mythflix.h"
00028 #include "mythflixqueue.h"
00029 #include "mythflixconfig.h"
00030
00031 #include <mythtv/mythcontext.h>
00032 #include <mythtv/mythdialogs.h>
00033 #include <mythtv/mythplugin.h>
00034 #include <mythtv/mythpluginapi.h>
00035
00036 #include <mythtv/libmythui/myththemedmenu.h>
00037
00038 #include "flixutil.h"
00039 #include "dbcheck.h"
00040
00041 using namespace std;
00042
00043
00044
00045 void browse(void){
00046 gContext->addCurrentLocation("flixbrowse");
00047 MythFlix flix(gContext->GetMainWindow(), "netflix browse");
00048 flix.exec();
00049 gContext->removeCurrentLocation();
00050 }
00051
00052 void queue(void){
00053 gContext->addCurrentLocation("flixqueue");
00054 QString queue = chooseQueue();
00055 if (queue != "__NONE__")
00056 {
00057 MythFlixQueue flix(gContext->GetMainWindow(), "netflix queue",
00058 queue);
00059 flix.exec();
00060 }
00061 gContext->removeCurrentLocation();
00062 }
00063
00064 void history(void){
00065 gContext->addCurrentLocation("flixhistory");
00066 QString queue = chooseQueue();
00067 if (queue != "__NONE__")
00068 {
00069 MythFlixQueue flix(gContext->GetMainWindow(), "netflix history",
00070 queue);
00071 flix.exec();
00072 }
00073 gContext->removeCurrentLocation();
00074 }
00075
00076 void NetFlixCallback(void *data, QString &selection)
00077 {
00078 (void)data;
00079 QString sel = selection.lower();
00080
00081 if (sel == "netflix_queue")
00082 {
00083 queue();
00084 }
00085 if (sel == "netflix_history")
00086 {
00087 history();
00088 }
00089 if (sel == "netflix_browse")
00090 {
00091 browse();
00092 }
00093 }
00094
00095 void runMenu()
00096 {
00097 QString themedir = gContext->GetThemeDir();
00098
00099 MythThemedMenu *diag = new MythThemedMenu(themedir.ascii(),
00100 "netflix_menu.xml",
00101 GetMythMainWindow()->GetMainStack(),
00102 "netflix menu");
00103
00104 diag->setCallback(NetFlixCallback, NULL);
00105 diag->setKillable();
00106
00107 if (diag->foundTheme())
00108 {
00109 GetMythMainWindow()->GetMainStack()->AddScreen(diag);
00110 }
00111 else
00112 {
00113 VERBOSE(VB_IMPORTANT, QString("MythFlix: Couldn't find theme %1").arg(themedir));
00114 delete diag;
00115 }
00116 }
00117
00118 void setupKeys(void)
00119 {
00120 REG_JUMP("Netflix Browser", "Browse Netflix titles", "", browse);
00121 REG_JUMP("Netflix Queue", "Administer Netflix Queue", "", queue);
00122 REG_JUMP("Netflix History", "View Netflix History", "", history);
00123
00124 REG_KEY("NetFlix", "MOVETOTOP", "Moves movie to top of queue", "1");
00125 REG_KEY("NetFlix", "REMOVE", "Removes movie from queue", "D");
00126
00127
00128
00129 }
00130
00131 int mythplugin_run(void)
00132 {
00133 runMenu();
00134 return 0;
00135 }
00136
00137 int mythplugin_config(void)
00138 {
00139 MythFlixConfig config(gContext->GetMainWindow(), "netflix");
00140 config.exec();
00141
00142 return 0;
00143 }
00144
00145 int mythplugin_init(const char *libversion)
00146 {
00147 if (!gContext->TestPopupVersion("mythflix",
00148 libversion,
00149 MYTH_BINARY_VERSION))
00150 return -1;
00151
00152 gContext->ActivateSettingsCache(false);
00153 if (!UpgradeFlixDatabaseSchema())
00154 {
00155 VERBOSE(VB_IMPORTANT,
00156 "Couldn't upgrade database to new schema, exiting.");
00157 return -1;
00158 }
00159 gContext->ActivateSettingsCache(true);
00160
00161 setupKeys();
00162
00163 return 0;
00164 }
00165
00166