neutrino test_menu: moved into it's own modul,

to add this menu to neutrino mainmenu, search for '//#define TEST_MENU'
and remove slashes

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1049 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Commit: fcee5d4769
Author: Thilo Graf <dbt@novatux.de>
Date: 2011-01-26 (Wed, 26 Jan 2011)

Origin message was:
------------------
*neutrino test_menu: moved into it's own modul,
to add this menu to neutrino mainmenu, search for '//#define TEST_MENU'
and remove slashes

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1049 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
2011-01-26 11:04:19 +00:00
parent d31eabcecc
commit d781b2257e
2 changed files with 46 additions and 273 deletions

View File

@@ -71,6 +71,7 @@ libneutrino_gui_a_SOURCES = \
screensetup.cpp \
sleeptimer.cpp \
streaminfo2.cpp \
test_menu.cpp \
themes.cpp \
timeosd.cpp \
update.cpp \

View File

@@ -34,6 +34,8 @@
#include <config.h>
#endif
//#define TEST_MENU
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -70,53 +72,55 @@
#include <gui/epgplus.h>
#include <gui/streaminfo2.h>
#include "gui/widget/colorchooser.h"
#include "gui/widget/menue.h"
#include "gui/widget/messagebox.h"
#include "gui/widget/hintbox.h"
#include "gui/widget/icons.h"
#include "gui/record_setup.h"
#include "gui/keybind_setup.h"
#include "gui/widget/keychooser.h"
#include "gui/widget/stringinput.h"
#include "gui/widget/stringinput_ext.h"
#include "gui/widget/mountchooser.h"
#include "gui/user_menue_setup.h"
#include "gui/alphasetup.h"
#include "gui/audio_setup.h"
#include "gui/audioplayer.h"
#include "gui/bedit/bouqueteditor_bouquets.h"
#include "gui/bouquetlist.h"
#include "gui/channellist.h"
#include "gui/color.h"
#include "gui/customcolor.h"
#include "gui/bedit/bouqueteditor_bouquets.h"
#include "gui/audio_setup.h"
#include "gui/bouquetlist.h"
#include "gui/eventlist.h"
#include "gui/channellist.h"
#include "gui/network_setup.h"
#include "gui/parentallock_setup.h"
#include "gui/user_menue_setup.h"
#include "gui/pluginlist.h"
#include "gui/plugins.h"
#include "gui/infoviewer.h"
#include "gui/epgview.h"
#include "gui/epg_menu.h"
#include "gui/update.h"
#include "gui/scan.h"
#include "gui/epgview.h"
#include "gui/eventlist.h"
#include "gui/favorites.h"
#include "gui/sleeptimer.h"
#include "gui/rc_lock.h"
#include "gui/timerlist.h"
#include "gui/alphasetup.h"
#include "gui/audioplayer.h"
#include "gui/imageinfo.h"
#include "gui/movieplayer.h"
#include "gui/pictureviewer.h"
#include "gui/motorcontrol.h"
#include "gui/filebrowser.h"
#include "gui/upnpbrowser.h"
#include "gui/videosettings.h"
#include "gui/imageinfo.h"
#include "gui/infoviewer.h"
#include "gui/keybind_setup.h"
#include "gui/motorcontrol.h"
#include "gui/movieplayer.h"
#include "gui/network_setup.h"
#include "gui/osd_setup.h"
#include "gui/osdlang_setup.h"
#include "gui/parentallock_setup.h"
#include "gui/pictureviewer.h"
#include "gui/pluginlist.h"
#include "gui/plugins.h"
#include "gui/rc_lock.h"
#include "gui/record_setup.h"
#include "gui/scan.h"
#include "gui/sleeptimer.h"
#ifdef TEST_MENU
#include "gui/test_menu.h"
#endif /*TEST_MENU*/
#include "gui/timerlist.h"
#include "gui/update.h"
#include "gui/upnpbrowser.h"
#include "gui/user_menue_setup.h"
#include "gui/user_menue_setup.h"
#include "gui/vfd_setup.h"
#include "gui/videosettings.h"
#include "gui/widget/colorchooser.h"
#include "gui/widget/hintbox.h"
#include "gui/widget/icons.h"
#include "gui/widget/keychooser.h"
#include "gui/widget/menue.h"
#include "gui/widget/messagebox.h"
#include "gui/widget/mountchooser.h"
#include "gui/widget/stringinput.h"
#include "gui/widget/stringinput_ext.h"
#include <system/setting_helpers.h>
#include <system/settings.h>
@@ -128,7 +132,6 @@
#include <video.h>
#include <audio.h>
#include <zapit/frontend_c.h>
// #include <xmlinterface.h>
#include <zapit/getservices.h>
#include <string.h>
@@ -144,7 +147,7 @@
#include <zapit/fastscan.h>
#include <cs_api.h>
//#define TEST_MENU
extern CFrontend * frontend;
extern CAudioPlayerGui * audioPlayer;
@@ -170,221 +173,6 @@ extern bool autoshift;
//static CTimingSettingsNotifier timingsettingsnotifier;
#ifdef TEST_MENU
class CTestMenu : public CMenuTarget
{
public:
int exec(CMenuTarget* parent, const std::string &actionkey);
};
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
extern int cs_test_card(int unit, char * str);
int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
{
if (parent)
parent->hide();
printf("CTestMenu::exec: %s\n", actionKey.c_str());
if (actionKey == "vfd") {
CVFD::getInstance()->Clear();
int icon = 0x00040000;
while (icon > 0x2) {
CVFD::getInstance()->ShowIcon((vfd_icon) icon, true);
icon /= 2;
}
for (int i = 0x01000001; i <= 0x0C000001; i+= 0x01000000) {
CVFD::getInstance()->ShowIcon((vfd_icon) i, true);
}
CVFD::getInstance()->ShowIcon((vfd_icon) 0x09000002, true);
CVFD::getInstance()->ShowIcon((vfd_icon) 0x0B000002, true);
char text[255];
char buf[XML_UTF8_ENCODE_MAX];
int ch = 0x2588;
int len = XmlUtf8Encode(ch, buf);
for (int i = 0; i < 12; i++) {
memcpy(&text[i*len], buf, len);
}
text[12*len] = 0;
CVFD::getInstance()->ShowText(text);
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
CVFD::getInstance()->Clear();
}
else if (actionKey == "network") {
int fd, ret;
struct ifreq ifr;
char * ip = NULL, str[255];
struct sockaddr_in *addrp=NULL;
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);
ret = ioctl(fd, SIOCGIFHWADDR, &ifr);
if (ret < 0)
perror("SIOCGIFHWADDR");
ret = ioctl(fd, SIOCGIFADDR, &ifr );
if (ret < 0)
perror("SIOCGIFADDR");
else {
addrp = (struct sockaddr_in *)&(ifr.ifr_addr);
ip = inet_ntoa(addrp->sin_addr);
}
sprintf(str, "MAC: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\nIP: %s",
(unsigned char)ifr.ifr_hwaddr.sa_data[0],
(unsigned char)ifr.ifr_hwaddr.sa_data[1],
(unsigned char)ifr.ifr_hwaddr.sa_data[2],
(unsigned char)ifr.ifr_hwaddr.sa_data[3],
(unsigned char)ifr.ifr_hwaddr.sa_data[4],
(unsigned char)ifr.ifr_hwaddr.sa_data[5], ip == NULL ? "Unknown" : ip);
close(fd);
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
}
else if (actionKey == "card0") {
char str[255];
int ret = cs_test_card(0, str);
switch(ret) {
case 0:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw");
break;
case -1:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info");
break;
case -2:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info");
break;
default:
case -3:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info");
break;
}
}
else if (actionKey == "card1") {
char str[255];
int ret = cs_test_card(1, str);
switch(ret) {
case 0:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw");
break;
case -1:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info");
break;
case -2:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info");
break;
default:
case -3:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info");
break;
}
}
else if (actionKey == "hdd") {
char buffer[255];
FILE *f = fopen("/proc/mounts", "r");
bool mounted = false;
if (f != NULL) {
while (fgets (buffer, 255, f) != NULL) {
if (strstr(buffer, "/dev/sda1")) {
mounted = true;
break;
}
}
fclose(f);
}
sprintf(buffer, "HDD: /dev/sda1 is %s", mounted ? "mounted" : "NOT mounted");
printf("%s\n", buffer);
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
}
else if (actionKey == "buttons") {
neutrino_msg_t msg;
neutrino_msg_data_t data;
CHintBox * khintBox = NULL;
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Press button, or press EXIT to return");
hintBox->paint();
while (1) {
g_RCInput->getMsg(&msg, &data, 100);
if (msg == CRCInput::RC_home)
break;
if (msg != CRCInput::RC_timeout && msg <= CRCInput::RC_MaxRC) {
char keyname[50];
sprintf(keyname, "Button [%s] pressed (EXIT to return)", g_RCInput->getKeyName(msg).c_str());
if (khintBox) {
delete khintBox;
}
khintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, keyname);
hintBox->hide();
khintBox->paint();
}
}
if (khintBox)
delete khintBox;
delete hintBox;
}
else if (actionKey == "22kon" || actionKey == "22koff") {
CScanTs * scanTs = new CScanTs();
int freq = (actionKey == "22kon") ? 12000*1000: 11000*1000;
sprintf(get_set.TP_freq, "%d", freq);
#if 0 // not needed ?
switch (frontend->getInfo()->type) {
case FE_QPSK:
sprintf(get_set.TP_rate, "%d", tmpI->second.feparams.u.qpsk.symbol_rate);
get_set.TP_fec = tmpI->second.feparams.u.qpsk.fec_inner;
get_set.TP_pol = tmpI->second.polarization;
break;
case FE_QAM:
sprintf(get_set.TP_rate, "%d", tmpI->second.feparams.u.qam.symbol_rate);
get_set.TP_fec = tmpI->second.feparams.u.qam.fec_inner;
get_set.TP_mod = tmpI->second.feparams.u.qam.modulation;
break;
}
#endif
scanTs->exec(NULL, "test");
delete scanTs;
}
else if (actionKey == "scan") {
CScanTs * scanTs = new CScanTs();
int freq = 12538000;
sprintf(get_set.TP_freq, "%d", freq);
switch (frontend->getInfo()->type) {
case FE_QPSK:
sprintf(get_set.TP_rate, "%d", 41250*1000);
get_set.TP_fec = 1;
get_set.TP_pol = 1;
break;
case FE_QAM:
#if 0
sprintf(get_set.TP_rate, "%d", tmpI->second.feparams.u.qam.symbol_rate);
get_set.TP_fec = tmpI->second.feparams.u.qam.fec_inner;
get_set.TP_mod = tmpI->second.feparams.u.qam.modulation;
#endif
break;
case FE_OFDM:
case FE_ATSC:
break;
}
scanTs->exec(NULL, "manual");
delete scanTs;
}
return menu_return::RETURN_REPAINT;
}
CMenuWidget * TestMenu;
#endif
//CMenuOptionStringChooser* tzSelect;
/**************************************************************************************
* CNeutrinoApp - init main menu *
@@ -394,22 +182,6 @@ void CNeutrinoApp::InitMainMenu(CMenuWidget &mainMenu, CMenuWidget &mainSettings
{
unsigned int system_rev = cs_get_revision();
#ifdef TEST_MENU
char rev[255];
sprintf(rev, "Test menu, System revision %d %s", system_rev, system_rev == 0 ? "WARNING - INVALID" : "");
TestMenu = new CMenuWidget(rev /*"Test menu"*/);
CTestMenu * testHandler = new CTestMenu();
TestMenu->addItem(new CMenuForwarderNonLocalized("VFD", true, NULL, testHandler, "vfd"));
TestMenu->addItem(new CMenuForwarderNonLocalized("Network", true, NULL, testHandler, "network"));
TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard 1", true, NULL, testHandler, "card0"));
TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard 2", true, NULL, testHandler, "card1"));
TestMenu->addItem(new CMenuForwarderNonLocalized("HDD", true, NULL, testHandler, "hdd"));
TestMenu->addItem(new CMenuForwarderNonLocalized("Buttons", true, NULL, testHandler, "buttons"));
TestMenu->addItem(new CMenuForwarderNonLocalized("Scan 12538000", true, NULL, testHandler, "scan"));
//TestMenu->addItem(new CMenuForwarderNonLocalized("22 Khz ON", true, NULL, testHandler, "22kon"));
//TestMenu->addItem(new CMenuForwarderNonLocalized("22 Khz OFF", true, NULL, testHandler, "22koff"));
#endif
int shortcut = 1;
dprintf(DEBUG_DEBUG, "init mainmenue\n");
@@ -553,7 +325,7 @@ void CNeutrinoApp::InitMainMenu(CMenuWidget &mainMenu, CMenuWidget &mainSettings
//mainSettings.addItem(new CMenuForwarder(LOCALE_CAM_SETTINGS, true, NULL, g_CamHandler));
#ifdef TEST_MENU
mainMenu.addItem(new CMenuForwarderNonLocalized("Test menu", true, NULL, TestMenu));
mainMenu.addItem(new CMenuForwarderNonLocalized("Test menu", true, NULL, new CTestMenu()));
#endif
#if 0
g_RFmod = new RFmod();