Add functionality for webtv

Taken from bitbucket.org/neutrino-images/ni-neutrino-hd

Required  build fixes:
    Clean cherry-pick was impossible and build was broken,
    because of missing parts of historie inside source repository.
    That forces to add many other missing code parts.
This commit is contained in:
2017-11-27 16:12:31 +01:00
parent 5731cf10a4
commit 720e1d3cfd
8 changed files with 171 additions and 22 deletions

View File

@@ -1525,6 +1525,7 @@ menu.hint_volume_digits Zifferndarstellung der Lautstärkeanzeige ein- oder auss
menu.hint_volume_pos Wählen Sie die Position der Lautstärkeanzeige aus menu.hint_volume_pos Wählen Sie die Position der Lautstärkeanzeige aus
menu.hint_volume_size Wählen Sie die Höhe der Lautstärkeanzeige menu.hint_volume_size Wählen Sie die Höhe der Lautstärkeanzeige
menu.hint_webtv_setup Hier konfigurierte WebTV-Kanäle finden Sie in der Kanalverwaltung. menu.hint_webtv_setup Hier konfigurierte WebTV-Kanäle finden Sie in der Kanalverwaltung.
menu.hint_webtv_xml_auto Lädt automatisch alle WebTV-Dateien aus %s/ und %s/
menu.hint_window_size Kanalliste, EPG-Infos und einige andere Fenster werden mit diesem Faktor skaliert menu.hint_window_size Kanalliste, EPG-Infos und einige andere Fenster werden mit diesem Faktor skaliert
menu.hint_youtube_dev_id Geben Sie die YouTube Dev ID ein. Eine leere Eingabe schaltet die YouTube-Unterstützung aus menu.hint_youtube_dev_id Geben Sie die YouTube Dev ID ein. Eine leere Eingabe schaltet die YouTube-Unterstützung aus
menu.hint_youtube_enabled Schaltet die YouTube-Unterstützung ein oder aus menu.hint_youtube_enabled Schaltet die YouTube-Unterstützung ein oder aus
@@ -2564,9 +2565,12 @@ videomenu.videoformat_169 16:9
videomenu.videoformat_43 4:3 videomenu.videoformat_43 4:3
videomenu.videomode Videosystem videomenu.videomode Videosystem
webtv.head WebTV webtv.head WebTV
webtv.xml WebTV-XML-Dateien webtv.xml WebTV-Dateien
webtv.xml.add XML-Datei hinzufügen webtv.xml.add Hinzufügen
webtv.xml.del XML-Datei entfernen webtv.xml.auto WebTV-Dateien automatisch laden
webtv.xml.del Entfernen
webtv.xml.enter Eintragen
webtv.xml.reload Neu laden
window_size Fenstergröße in % window_size Fenstergröße in %
wizard.initial_settings Grundeinstellungen gefunden wizard.initial_settings Grundeinstellungen gefunden
wizard.install_settings Kanalliste für Astra 19.2°E installieren? wizard.install_settings Kanalliste für Astra 19.2°E installieren?

View File

@@ -1525,6 +1525,7 @@ menu.hint_volume_digits Numeric display of the volumebar on/off
menu.hint_volume_pos Select volume indicator position menu.hint_volume_pos Select volume indicator position
menu.hint_volume_size Select volume indicator height menu.hint_volume_size Select volume indicator height
menu.hint_webtv_setup WebTV channels configured here will be available in the standard channel lists. menu.hint_webtv_setup WebTV channels configured here will be available in the standard channel lists.
menu.hint_webtv_xml_auto Auto-load all existing WebTV files from %s/ and %s/
menu.hint_window_size Channellist, EPG-infos and some other windows are scaled by this factor menu.hint_window_size Channellist, EPG-infos and some other windows are scaled by this factor
menu.hint_youtube_dev_id Type your YouTube Dev ID. An empty input disables YouTube support menu.hint_youtube_dev_id Type your YouTube Dev ID. An empty input disables YouTube support
menu.hint_youtube_enabled Enable or disable YouTube support menu.hint_youtube_enabled Enable or disable YouTube support
@@ -2564,9 +2565,12 @@ videomenu.videoformat_169 16:9
videomenu.videoformat_43 4:3 videomenu.videoformat_43 4:3
videomenu.videomode Digital video mode videomenu.videomode Digital video mode
webtv.head WebTV webtv.head WebTV
webtv.xml WebTV XML files webtv.xml WebTV files
webtv.xml.add Add XML file webtv.xml.add Add
webtv.xml.del Remove XML file webtv.xml.auto Auto-load WebTV files
webtv.xml.del Remove
webtv.xml.enter Enter
webtv.xml.reload Reload
window_size Window size in % window_size Window size in %
wizard.initial_settings Initial settings found wizard.initial_settings Initial settings found
wizard.install_settings Do you want to install channels for Astra 19.2°E? wizard.install_settings Do you want to install channels for Astra 19.2°E?

View File

@@ -35,9 +35,15 @@
#include <neutrino_menue.h> #include <neutrino_menue.h>
#include "webtv_setup.h" #include "webtv_setup.h"
#include <dirent.h>
#include <mymenu.h>
#include <system/helpers.h>
#include <zapit/settings.h>
CWebTVSetup::CWebTVSetup() CWebTVSetup::CWebTVSetup()
{ {
width = 55; width = 75;
selected = -1; selected = -1;
item_offset = 0; item_offset = 0;
changed = false; changed = false;
@@ -54,10 +60,11 @@ const CMenuOptionChooser::keyval_ext LIVESTREAM_RESOLUTION_OPTIONS[] =
}; };
#define LIVESTREAM_RESOLUTION_OPTION_COUNT (sizeof(LIVESTREAM_RESOLUTION_OPTIONS)/sizeof(CMenuOptionChooser::keyval_ext)) #define LIVESTREAM_RESOLUTION_OPTION_COUNT (sizeof(LIVESTREAM_RESOLUTION_OPTIONS)/sizeof(CMenuOptionChooser::keyval_ext))
#define CWebTVSetupFooterButtonCount 2 #define CWebTVSetupFooterButtonCount 3
static const struct button_label CWebTVSetupFooterButtons[CWebTVSetupFooterButtonCount] = { static const struct button_label CWebTVSetupFooterButtons[CWebTVSetupFooterButtonCount] = {
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_WEBTV_XML_DEL }, { NEUTRINO_ICON_BUTTON_RED, LOCALE_WEBTV_XML_DEL },
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_WEBTV_XML_ADD } { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_WEBTV_XML_ADD },
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_WEBTV_XML_RELOAD }
}; };
int CWebTVSetup::exec(CMenuTarget* parent, const std::string & actionKey) int CWebTVSetup::exec(CMenuTarget* parent, const std::string & actionKey)
@@ -108,6 +115,11 @@ int CWebTVSetup::exec(CMenuTarget* parent, const std::string & actionKey)
} }
return res; return res;
} }
if(actionKey == "r" /* reload */) {
changed = true;
return menu_return::RETURN_EXIT_ALL;
}
if (actionKey == "script_path") { if (actionKey == "script_path") {
const char *action_str = "ScriptPath"; const char *action_str = "ScriptPath";
chooserDir(g_settings.livestreamScriptPath, false, action_str); chooserDir(g_settings.livestreamScriptPath, false, action_str);
@@ -129,6 +141,7 @@ int CWebTVSetup::Show()
m = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_STREAMING, width, MN_WIDGET_ID_WEBTVSETUP); m = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_STREAMING, width, MN_WIDGET_ID_WEBTVSETUP);
m->addKey(CRCInput::RC_red, this, "d"); m->addKey(CRCInput::RC_red, this, "d");
m->addKey(CRCInput::RC_green, this, "a"); m->addKey(CRCInput::RC_green, this, "a");
m->addKey(CRCInput::RC_blue, this, "r");
m->addIntroItems(LOCALE_WEBTV_HEAD, LOCALE_LIVESTREAM_HEAD); m->addIntroItems(LOCALE_WEBTV_HEAD, LOCALE_LIVESTREAM_HEAD);
@@ -146,30 +159,142 @@ int CWebTVSetup::Show()
m->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_WEBTV_XML)); m->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_WEBTV_XML));
// TODO: show/hide autoloaded content when switching g_settings.webtv_xml_auto
char hint_text[1024];
snprintf(hint_text, sizeof(hint_text)-1, g_Locale->getText(LOCALE_MENU_HINT_WEBTV_XML_AUTO), WEBTVDIR, WEBTVDIR_VAR);
CMenuOptionChooser *oc = new CMenuOptionChooser(LOCALE_WEBTV_XML_AUTO, &g_settings.webtv_xml_auto, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this, CRCInput::convertDigitToKey(shortcut++));
oc->setHint("", hint_text);
m->addItem(oc);
m->addItem(GenericMenuSeparator);
item_offset = m->getItemsCount(); item_offset = m->getItemsCount();
// show autoloaded webtv files
for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it)
m->addItem(new CMenuForwarder(*it, true, NULL, this, "c")); {
if (webtv_xml_autodir((*it)))
m->addItem(new CMenuForwarder(*it, false, "auto"));
}
if (item_offset < m->getItemsCount())
m->addItem(GenericMenuSeparator);
item_offset = m->getItemsCount();
// show users webtv files
for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it)
{
if (!webtv_xml_autodir((*it)))
m->addItem(new CMenuForwarder(*it, true, NULL, this, "c"));
}
m->setFooter(CWebTVSetupFooterButtons, CWebTVSetupFooterButtonCount); //Why we need here an extra buttonbar? m->setFooter(CWebTVSetupFooterButtons, CWebTVSetupFooterButtonCount); //Why we need here an extra buttonbar?
int res = m->exec(NULL, ""); int res = m->exec(NULL, "");
m->hide(); m->hide();
if (changed) {
g_settings.webtv_xml.clear(); if (changed)
for (int i = item_offset; i < m->getItemsCount(); i++) { {
CMenuItem *item = m->getItem(i); g_settings.webtv_xml.clear();
CMenuForwarder *f = static_cast<CMenuForwarder*>(item); for (int i = item_offset; i < m->getItemsCount(); i++)
g_settings.webtv_xml.push_back(f->getName()); {
} CMenuItem *item = m->getItem(i);
g_Zapit->reinitChannels(); CMenuForwarder *f = static_cast<CMenuForwarder*>(item);
changed = false; g_settings.webtv_xml.push_back(f->getName());
}
webtv_xml_auto();
g_Zapit->reinitChannels();
changed = false;
} }
delete m; delete m;
return res; return res;
} }
bool CWebTVSetup::changeNotify(const neutrino_locale_t OptionName, void */*data*/)
{
int ret = menu_return::RETURN_NONE;
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_WEBTV_XML_AUTO))
{
changed = true;
ret = menu_return::RETURN_REPAINT;
}
return ret;
}
int filefilter(const struct dirent *entry)
{
int len = strlen(entry->d_name);
if (len > 3 && (
(entry->d_name[len-3] == 'x' && entry->d_name[len-2] == 'm' && entry->d_name[len-1] == 'l')
|| (entry->d_name[len-3] == 'm' && entry->d_name[len-2] == '3' && entry->d_name[len-1] == 'u')
|| ( entry->d_name[len-2] == 't' && entry->d_name[len-1] == 'v')
)
)
return 1;
return 0;
}
void CWebTVSetup::webtv_xml_auto()
{
if (g_settings.webtv_xml_auto)
{
const char *dirs[] = {WEBTVDIR_VAR, WEBTVDIR};
struct dirent **filelist;
char webtv_file[1024] = {0};
for (int i = 0; i < 2; i++)
{
int file_count = scandir(dirs[i], &filelist, filefilter, alphasort);
if (file_count > -1)
{
for (int count = 0; count < file_count; count++)
{
snprintf(webtv_file, sizeof(webtv_file), "%s/%s", dirs[i], filelist[count]->d_name);
if (file_size(webtv_file))
{
bool found = false;
for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); it++)
found |= ((*it).find(filelist[count]->d_name) != std::string::npos);
if (!found)
{
printf("[CWebTVSetup] loading: %s\n", webtv_file);
g_settings.webtv_xml.push_back(webtv_file);
}
else
{
printf("[CWebTVSetup] skipping: %s\n", webtv_file);
}
}
}
}
}
}
}
bool CWebTVSetup::webtv_xml_autodir(std::string directory)
{
if (
(directory.empty())
|| (directory.find(WEBTVDIR) != std::string::npos)
|| (directory.find(WEBTVDIR_VAR) != std::string::npos)
)
return true;
return false;
}
int xml_filter(const struct dirent *entry)
{
int len = strlen(entry->d_name);
if (len > 3 && entry->d_name[len-3] == 'x' && entry->d_name[len-2] == 'm' && entry->d_name[len-1] == 'l')
return 1;
return 0;
}
/* ## CWebTVResolution ############################################# */ /* ## CWebTVResolution ############################################# */
CWebTVResolution::CWebTVResolution() CWebTVResolution::CWebTVResolution()

View File

@@ -27,7 +27,7 @@
#include <string.h> #include <string.h>
#include <gui/widget/menue.h> #include <gui/widget/menue.h>
class CWebTVSetup : public CMenuTarget class CWebTVSetup : public CMenuTarget, CChangeObserver
{ {
private: private:
int width; int width;
@@ -39,6 +39,9 @@ class CWebTVSetup : public CMenuTarget
CWebTVSetup(); CWebTVSetup();
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
int Show(); int Show();
bool changeNotify(const neutrino_locale_t OptionName, void *data);
void webtv_xml_auto();
bool webtv_xml_autodir(std::string directory);
}; };
class CWebTVResolution : public CMenuTarget class CWebTVResolution : public CMenuTarget

View File

@@ -93,6 +93,7 @@
#include "gui/update.h" #include "gui/update.h"
#include "gui/videosettings.h" #include "gui/videosettings.h"
#include "gui/audio_select.h" #include "gui/audio_select.h"
#include "gui/webtv_setup.h"
#include "gui/widget/hintbox.h" #include "gui/widget/hintbox.h"
#include "gui/widget/icons.h" #include "gui/widget/icons.h"
@@ -703,6 +704,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.logo_hdd_dir = configfile.getString( "logo_hdd_dir", "/media/sda1/logos" ); g_settings.logo_hdd_dir = configfile.getString( "logo_hdd_dir", "/media/sda1/logos" );
g_settings.webtv_xml_auto = configfile.getInt32("webtv_xml_auto", 1);
g_settings.webtv_xml.clear(); g_settings.webtv_xml.clear();
int webtv_count = configfile.getInt32("webtv_xml_count", 0); int webtv_count = configfile.getInt32("webtv_xml_count", 0);
if (webtv_count) { if (webtv_count) {
@@ -719,6 +721,8 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.webtv_xml.push_back(webtv_xml); g_settings.webtv_xml.push_back(webtv_xml);
} }
CWebTVSetup webtvsetup;
webtvsetup.webtv_xml_auto();
g_settings.webradio_xml.clear(); g_settings.webradio_xml.clear();
#ifndef BOXMODEL_CS_HD1 #ifndef BOXMODEL_CS_HD1
/* /*
@@ -1426,7 +1430,7 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setString ( "plugins_lua", g_settings.plugins_lua ); configfile.setString ( "plugins_lua", g_settings.plugins_lua );
configfile.setString ( "logo_hdd_dir", g_settings.logo_hdd_dir ); configfile.setString ( "logo_hdd_dir", g_settings.logo_hdd_dir );
configfile.setInt32("webtv_xml_auto", g_settings.webtv_xml_auto);
int webtv_count = 0; int webtv_count = 0;
for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) { for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) {
std::string k = "webtv_xml_" + to_string(webtv_count); std::string k = "webtv_xml_" + to_string(webtv_count);

View File

@@ -1552,6 +1552,7 @@ typedef enum
LOCALE_MENU_HINT_VOLUME_POS, LOCALE_MENU_HINT_VOLUME_POS,
LOCALE_MENU_HINT_VOLUME_SIZE, LOCALE_MENU_HINT_VOLUME_SIZE,
LOCALE_MENU_HINT_WEBTV_SETUP, LOCALE_MENU_HINT_WEBTV_SETUP,
LOCALE_MENU_HINT_WEBTV_XML_AUTO,
LOCALE_MENU_HINT_WINDOW_SIZE, LOCALE_MENU_HINT_WINDOW_SIZE,
LOCALE_MENU_HINT_YOUTUBE_DEV_ID, LOCALE_MENU_HINT_YOUTUBE_DEV_ID,
LOCALE_MENU_HINT_YOUTUBE_ENABLED, LOCALE_MENU_HINT_YOUTUBE_ENABLED,
@@ -2593,7 +2594,10 @@ typedef enum
LOCALE_WEBTV_HEAD, LOCALE_WEBTV_HEAD,
LOCALE_WEBTV_XML, LOCALE_WEBTV_XML,
LOCALE_WEBTV_XML_ADD, LOCALE_WEBTV_XML_ADD,
LOCALE_WEBTV_XML_AUTO,
LOCALE_WEBTV_XML_DEL, LOCALE_WEBTV_XML_DEL,
LOCALE_WEBTV_XML_ENTER,
LOCALE_WEBTV_XML_RELOAD,
LOCALE_WINDOW_SIZE, LOCALE_WINDOW_SIZE,
LOCALE_WIZARD_INITIAL_SETTINGS, LOCALE_WIZARD_INITIAL_SETTINGS,
LOCALE_WIZARD_INSTALL_SETTINGS, LOCALE_WIZARD_INSTALL_SETTINGS,

View File

@@ -1552,6 +1552,7 @@ const char * locale_real_names[] =
"menu.hint_volume_pos", "menu.hint_volume_pos",
"menu.hint_volume_size", "menu.hint_volume_size",
"menu.hint_webtv_setup", "menu.hint_webtv_setup",
"menu.hint_webtv_xml_auto",
"menu.hint_window_size", "menu.hint_window_size",
"menu.hint_youtube_dev_id", "menu.hint_youtube_dev_id",
"menu.hint_youtube_enabled", "menu.hint_youtube_enabled",
@@ -2593,7 +2594,10 @@ const char * locale_real_names[] =
"webtv.head", "webtv.head",
"webtv.xml", "webtv.xml",
"webtv.xml.add", "webtv.xml.add",
"webtv.xml.auto",
"webtv.xml.del", "webtv.xml.del",
"webtv.xml.enter",
"webtv.xml.reload",
"window_size", "window_size",
"wizard.initial_settings", "wizard.initial_settings",
"wizard.install_settings", "wizard.install_settings",

View File

@@ -330,6 +330,7 @@ struct SNeutrinoSettings
std::list<std::string> webtv_xml; std::list<std::string> webtv_xml;
std::list<std::string> webradio_xml; std::list<std::string> webradio_xml;
std::list<std::string> xmltv_xml; // see http://wiki.xmltv.org/ std::list<std::string> xmltv_xml; // see http://wiki.xmltv.org/
int webtv_xml_auto;
//personalize //personalize
enum PERSONALIZE_SETTINGS //settings.h enum PERSONALIZE_SETTINGS //settings.h