webradio: add possibility to auto-load webradio files

Origin commit data
------------------
Commit: 9b28e96277
Author: vanhofen <vanhofen@gmx.de>
Date: 2018-09-25 (Tue, 25 Sep 2018)

Origin message was:
------------------
- webradio: add possibility to auto-load webradio files
This commit is contained in:
vanhofen
2018-09-25 23:53:35 +02:00
parent b4a971cb3b
commit 91f82fd522
8 changed files with 133 additions and 52 deletions

View File

@@ -1718,6 +1718,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_size Wählen Sie die Höhe der Lautstärkeanzeige
menu.hint_webradio_setup Hier konfigurierte WebRadio-Kanäle finden Sie in der Kanalverwaltung.
menu.hint_webradio_xml_auto Lädt automatisch alle WebRadio-Dateien aus %s/ und %s/
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
@@ -2806,6 +2807,7 @@ videomenu.videoformat_43 4:3
videomenu.videomode Videosystem
webradio.head WebRadio
webradio.xml WebRadio-Dateien
webradio.xml.auto WebRadio-Dateien automatisch laden
webtv.head WebTV
webtv.xml WebTV-Dateien
webtv.xml.add Hinzufügen

View File

@@ -1718,6 +1718,7 @@ menu.hint_volume_digits Numeric display of the volumebar on/off
menu.hint_volume_pos Select volume indicator position
menu.hint_volume_size Select volume indicator height
menu.hint_webradio_setup WebRadio channels configured here will be available in the standard channel lists.
menu.hint_webradio_xml_auto Auto-load all existing WebRadio files from %s/ and %s/
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
@@ -2806,6 +2807,7 @@ videomenu.videoformat_43 4:3
videomenu.videomode Digital video mode
webradio.head WebRadio
webradio.xml WebRadio files
webradio.xml.auto Auto-load WebRadio files
webtv.head WebTV
webtv.xml WebTV files
webtv.xml.add Add

View File

@@ -210,34 +210,38 @@ int CWebTVSetup::Show()
m->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, webradio ? LOCALE_WEBRADIO_XML : LOCALE_WEBTV_XML));
if (!webradio)
{
// TODO: show/hide autoloaded content when switching g_settings.webtv_xml_auto
// TODO: show/hide autoloaded content when switching g_settings.webradio/webtv_xml_auto
CMenuOptionChooser *oc;
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++));
if (webradio)
{
snprintf(hint_text, sizeof(hint_text) - 1, g_Locale->getText(LOCALE_MENU_HINT_WEBRADIO_XML_AUTO), WEBRADIODIR, WEBRADIODIR_VAR);
oc = new CMenuOptionChooser(LOCALE_WEBRADIO_XML_AUTO, &g_settings.webradio_xml_auto, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this, CRCInput::convertDigitToKey(shortcut++));
}
else
{
snprintf(hint_text, sizeof(hint_text) - 1, g_Locale->getText(LOCALE_MENU_HINT_WEBTV_XML_AUTO), WEBTVDIR, WEBTVDIR_VAR);
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();
// show autoloaded webtv files
// show autoloaded webradio/webtvtv files
for (std::list<std::string>::iterator it = webchannels.begin(); it != webchannels.end(); ++it)
{
if (webtv_xml_autodir((*it)))
if (webchannels_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
// show users webradio/webtv files
for (std::list<std::string>::iterator it = webchannels.begin(); it != webchannels.end(); ++it)
{
if (!webtv_xml_autodir((*it)))
if (!webchannels_autodir((*it)))
m->addItem(new CMenuForwarder(*it, true, NULL, this, "c"));
}
@@ -257,7 +261,6 @@ int CWebTVSetup::Show()
CMenuForwarder *f = static_cast<CMenuForwarder *>(item);
webchannels.push_back(f->getName());
}
webtv_xml_auto(); //NI
if (webradio)
{
g_settings.webradio_xml.clear();
@@ -268,6 +271,7 @@ int CWebTVSetup::Show()
g_settings.webtv_xml.clear();
g_settings.webtv_xml = webchannels;
}
webchannels_auto();
g_Zapit->reinitChannels();
changed = false;
hint.hide();
@@ -305,41 +309,71 @@ int filefilter(const struct dirent *entry)
return 0;
}
//NI
void CWebTVSetup::webtv_xml_auto()
// webradio wrapper for webchannels_auto()
void CWebTVSetup::webradio_xml_auto()
{
// TODO: g_settings.webradio_xml_auto?
if (webradio)
if (!g_settings.webradio_xml_auto)
return;
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);
webradio = true;
webchannels_auto();
}
if (!found)
{
printf("[CWebTVSetup] loading: %s\n", webtv_file);
g_settings.webtv_xml.push_back(webtv_file);
}
// webtv wrapper for webchannels_auto()
void CWebTVSetup::webtv_xml_auto()
{
if (!g_settings.webtv_xml_auto)
return;
webradio = false;
webchannels_auto();
}
void CWebTVSetup::webchannels_auto()
{
std::list<std::string> webchannels;
const char *dirs[2];
if (webradio)
{
webchannels = g_settings.webradio_xml;
dirs[0] = WEBRADIODIR_VAR;
dirs[1] = WEBRADIODIR;
}
else
{
webchannels = g_settings.webtv_xml;
dirs[0] = WEBTVDIR_VAR;
dirs[1] = WEBTVDIR;
}
struct dirent **filelist;
char webchannel_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(webchannel_file, sizeof(webchannel_file), "%s/%s", dirs[i], filelist[count]->d_name);
if (file_size(webchannel_file))
{
bool found = false;
for (std::list<std::string>::iterator it = webchannels.begin(); it != webchannels.end(); it++)
found |= ((*it).find(filelist[count]->d_name) != std::string::npos);
if (!found)
{
printf("[CWebTVSetup] loading: %s\n", webchannel_file);
if (webradio)
g_settings.webradio_xml.push_back(webchannel_file);
else
{
printf("[CWebTVSetup] skipping: %s\n", webtv_file);
}
g_settings.webtv_xml.push_back(webchannel_file);
}
else
{
printf("[CWebTVSetup] skipping: %s\n", webchannel_file);
}
}
}
@@ -347,14 +381,40 @@ void CWebTVSetup::webtv_xml_auto()
}
}
// webradio wrapper for webchannels_autodir()
bool CWebTVSetup::webradio_xml_autodir(std::string directory)
{
webradio = true;
return webchannels_autodir(directory);
}
// webtv wrapper for webchannels_autodir()
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;
webradio = false;
return webchannels_autodir(directory);
}
bool CWebTVSetup::webchannels_autodir(std::string directory)
{
if (webradio)
{
if (
(directory.empty())
|| (directory.find(WEBRADIODIR) != std::string::npos)
|| (directory.find(WEBRADIODIR_VAR) != std::string::npos)
)
return true;
}
else
{
if (
(directory.empty())
|| (directory.find(WEBTVDIR) != std::string::npos)
|| (directory.find(WEBTVDIR_VAR) != std::string::npos)
)
return true;
}
return false;
}

View File

@@ -42,8 +42,15 @@ class CWebTVSetup : public CMenuTarget, CChangeObserver //NI
int exec(CMenuTarget *parent, const std::string &actionKey);
int Show();
bool changeNotify(const neutrino_locale_t OptionName, void *data); //NI
void webtv_xml_auto(); //NI
void webradio_xml_auto();
bool webradio_xml_autodir(std::string directory);
void webtv_xml_auto();
bool webtv_xml_autodir(std::string directory);
void webchannels_auto();
bool webchannels_autodir(std::string directory);
};
class CWebTVResolution : public CMenuTarget

View File

@@ -788,6 +788,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
CWebTVSetup webtvsetup;
webtvsetup.webtv_xml_auto();
g_settings.webradio_xml_auto = configfile.getInt32("webradio_xml_auto", 1);
g_settings.webradio_xml.clear();
#ifndef BOXMODEL_CS_HD1
/*
@@ -809,6 +810,8 @@ int CNeutrinoApp::loadSetup(const char * fname)
if (file_size(webradio_xml.c_str()))
g_settings.webradio_xml.push_back(webradio_xml);
}
webtvsetup.webradio_xml_auto();
#endif
g_settings.xmltv_xml.clear();
@@ -1596,7 +1599,6 @@ void CNeutrinoApp::saveSetup(const char * fname)
int webtv_count = 0;
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);
//NI
if (webtvsetup.webtv_xml_autodir((*it)))
continue;
configfile.setString(k, *it);
@@ -1604,9 +1606,12 @@ void CNeutrinoApp::saveSetup(const char * fname)
}
configfile.setInt32 ( "webtv_xml_count", webtv_count); //NI
configfile.setInt32("webradio_xml_auto", g_settings.webradio_xml_auto);
int webradio_count = 0;
for (std::list<std::string>::iterator it = g_settings.webradio_xml.begin(); it != g_settings.webradio_xml.end(); ++it) {
std::string k = "webradio_xml_" + to_string(webradio_count);
if (webtvsetup.webradio_xml_autodir((*it)))
continue;
configfile.setString(k, *it);
webradio_count++;
}

View File

@@ -1745,6 +1745,7 @@ typedef enum
LOCALE_MENU_HINT_VOLUME_POS,
LOCALE_MENU_HINT_VOLUME_SIZE,
LOCALE_MENU_HINT_WEBRADIO_SETUP,
LOCALE_MENU_HINT_WEBRADIO_XML_AUTO,
LOCALE_MENU_HINT_WEBTV_SETUP,
LOCALE_MENU_HINT_WEBTV_XML_AUTO,
LOCALE_MENU_HINT_WINDOW_SIZE,
@@ -2833,6 +2834,7 @@ typedef enum
LOCALE_VIDEOMENU_VIDEOMODE,
LOCALE_WEBRADIO_HEAD,
LOCALE_WEBRADIO_XML,
LOCALE_WEBRADIO_XML_AUTO,
LOCALE_WEBTV_HEAD,
LOCALE_WEBTV_XML,
LOCALE_WEBTV_XML_ADD,

View File

@@ -1745,6 +1745,7 @@ const char * locale_real_names[] =
"menu.hint_volume_pos",
"menu.hint_volume_size",
"menu.hint_webradio_setup",
"menu.hint_webradio_xml_auto",
"menu.hint_webtv_setup",
"menu.hint_webtv_xml_auto",
"menu.hint_window_size",
@@ -2833,6 +2834,7 @@ const char * locale_real_names[] =
"videomenu.videomode",
"webradio.head",
"webradio.xml",
"webradio.xml.auto",
"webtv.head",
"webtv.xml",
"webtv.xml.add",

View File

@@ -285,7 +285,8 @@ struct SNeutrinoSettings
int ci_mode; //NI
std::string ci_pincode;
int radiotext_enable;
int webtv_xml_auto; //NI
int webradio_xml_auto;
int webtv_xml_auto;
//screen saver
int screensaver_delay;