PDA

View Full Version : [AIW][DEVELOPMENT]] diff to add freddys epg on and off switch



nj2006
15-02-2008, 01:51 AM
new aiw_servers.cpp


--- tuxbox-cvs-orig/apps/tuxbox/neutrino/src/gui/aiw_servers.cpp 1970-01-01 01:00:00.000000000 +0100
+++ tuxbox-cvs/apps/tuxbox/neutrino/src/gui/aiw_servers.cpp 2008-02-15 00:27:11.000000000 +0000
@@ -0,0 +1,274 @@
+/*
+================================================= ===============================================
+Neutrino-GUI - DBoxII-Project
+
+Copyright (C) 2001 Steffen Hehn 'McClean'
+Homepage: http://dbox.cyberphoria.org/
+
+Comments:
+
+In this version I have had to resort to using a touch file for the server switching.
+This is because the files that we need to work with are daemons, and cannot just be
+started and stopped whenever we want unless we introduce a more complicated method.
+
+To enable this to work, "start_neutrino" and "rCs" will need to be modified. A section
+similar to the following will be required:
+
+In start_neutrino:
+ # HTTP Server switching operations
+ if [ -e /var/etc/.nhttpd ]; then
+ nhttpd &
+ fi
+
+In rCs:
+Find this:
+ if [ -x /sbin/inetd ]; then
+ /sbin/inetd
+ fi
+
+and directly before it, add:
+ # FTP Server switching operations
+ if [ -e /var/etc/.ftpd ]; then
+ ln -s /sbin/ftpd /sbin/in.ftpd
+ else
+ rm /sbin/in.ftpd
+ fi
+
+
+Finally, rename in.ftpd in /sbin to "ftpd".
+The startup script will symlink it to its original filename when required, and before
+inetd is loaded.
+
+
+License: GPL
+
+================================================= ===============================================
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <global.h>
+#include <neutrino.h>
+#include <driver/fontrenderer.h>
+#include <driver/rcinput.h>
+#include <daemonc/remotecontrol.h>
+#include "widget/menue.h"
+#include "widget/messagebox.h"
+#include "widget/hintbox.h"
+#include "widget/lcdcontroler.h"
+#include "widget/keychooser.h"
+#include "widget/stringinput.h"
+#include "widget/stringinput_ext.h"
+#include "color.h"
+#include "aiw_servers.h" // Reference to Self
+#include <system/debug.h>
+
+#define ONOROFF_OPTION_COUNT 2
+
+const CMenuOptionChooser::keyval ONOROFF_OPTIONS[ONOROFF_OPTION_COUNT] =
+{
+{ 0, LOCALE_ALLINWONDER_ITEMDISABLED }, // Disabled (Off)
+{ 1, LOCALE_ALLINWONDER_ITEMENABLED }, // Enabled (On)
+};
+
+UberNinja_ServerMenu::UberNinja_ServerMenu()
+: configfile('\t')
+{
+ frameBuffer = CFrameBuffer::getInstance();
+ width = 600;
+ hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
+ mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
+ height = hheight+13*mheight+ 10;
+ x=(((g_settings.screen_EndX- g_settings.screen_StartX)-width) / 2) + g_settings.screen_StartX;
+ y=(((g_settings.screen_EndY- g_settings.screen_StartY)-height) / 2) + g_settings.screen_StartY;
+}
+
+void UberNinja_ServerMenu::DoServerAction(char* action)
+{
+ /* IMAGE CREATORS: This section was intended to be a library of actions for server related options. In the
+ end I only put 1 function here but you can easily extend this to include your own coding if you wish to
+ do so. This allows quick multiple calling of the same function without repeated code. */
+
+ if (action == "restart_box") {
+ system("reboot"); } // Dirty method of rebooting the entire box
+}
+
+int UberNinja_ServerMenu::exec(CMenuTarget* parent, const std::string & actionKey)
+{
+ int res = menu_return::RETURN_REPAINT;
+
+ if (parent) { parent->hide(); }
+ ShowServerMenu();
+ return res;
+}
+
+void UberNinja_ServerMenu::hide()
+{
+ frameBuffer->paintBackgroundBoxRel(x,y, width,height);
+}
+
+void UberNinja_ServerMenu::ShowServerMenu()
+{
+
+ std::string ExtrasDocRoot, ExtrasDocURL, HostedDocumentRoot, MainDirectory, OverrideDirectory;
+ std::string ZapitXMLPath, confversion, no_auth_client, cache_directory, mime_types, log_format, logfile, chroot;
+ std::string group_name, loglevel, no_keepalive_ips, user_name, threading;
+
+ int cainfo=0; int old_cainfo=0; //- turn cainfo bar on and off
+ int vepg=0; int old_vepg=0; //- turn freddyfrogs extended epg on or off
+ int httpd=0; int old_httpd=0;
+ int ftpd=0; int old_ftpd=0;
+ int info=0; int old_info=0;
+ int rdate=0; int old_rdate=0;
+ std::string old_webport, webport;
+ std::string old_webusername, webusername;
+ std::string old_webpassword, webpassword;
+ std::string authstring = "false";
+ int old_webauth, webauth;
+
+ old_webport = webport; old_webusername = webusername;
+ old_webpassword = webpassword; old_webauth = webauth;
+
+
+ /* Grab a few values before the menu is shown on-screen, so we can get the correct information
+ displayed to the end user.*/
+
+ CConfigFile config('\t');
+ config.loadConfig("/var/tuxbox/config/nhttpd.conf");
+ webport = config.getString("WebsiteMain.port","80");
+ webusername = config.getString("mod_auth.username", "root");
+ webpassword = config.getString("mod_auth.password", "commando");
+ authstring = config.getString("mod_auth.authenticate", "false");
+ // These values also need to be recorded:
+ ExtrasDocRoot = "/mnt/hosted/extras";
+ ExtrasDocURL = "/hosted/extras";
+ HostedDocumentRoot = "/mnt/hosted";
+ MainDirectory = "/share/tuxbox/neutrino/httpd-y";
+ OverrideDirectory = "/var/httpd";
+ ZapitXMLPath = "/var/tuxbox/config/zapit";
+ confversion = "1";
+ no_auth_client = "";
+ cache_directory = "/tmp/.cache";
+ mime_types = "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream";
+ log_format = "";
+ logfile = "/tmp/yhhtpd.log";
+ chroot = "";
+ group_name = "";
+ loglevel = "0";
+ no_keepalive_ips = "";
+ user_name = "";
+ threading = "true";
+
+ if (authstring == "false")
+ webauth = 0;
+ else if (authstring == "true")
+ webauth = 1;
+
+ FILE *cainfo_enabled = fopen("/var/etc/.cryptinfo", "r");
+ FILE *vepg_enabled = fopen("/var/etc/.vepg", "r");
+ FILE *httpd_enabled = fopen("/var/etc/.nhttpd", "r");
+ FILE *ftpd_enabled = fopen("/var/etc/.ftpd", "r");
+ FILE *info_enabled = fopen("/var/etc/.boot_info", "r");
+ FILE *rdate_enabled = fopen ("/var/etc/.rdate", "r");
+ if (cainfo_enabled) { cainfo=1; fclose(cainfo_enabled); } else if (!cainfo_enabled) { cainfo=0; }
+ if (vepg_enabled) { vepg=1; fclose(vepg_enabled); } else if (!vepg_enabled) { vepg=0; }
+ if (httpd_enabled) { httpd=1; fclose(httpd_enabled); } else if (!httpd_enabled) { httpd=0; }
+ if (ftpd_enabled) { ftpd=1; fclose(ftpd_enabled); } else if (!ftpd_enabled) { ftpd=0; }
+ if (info_enabled) { info=1; fclose(info_enabled); } else if (!info_enabled) { info=0; }
+ if (rdate_enabled) { rdate=1; fclose(rdate_enabled); } else if (!rdate_enabled) { rdate=0; }
+ old_httpd = httpd; old_ftpd = ftpd; old_info=info;
+ old_rdate = rdate; old_vepg = vepg; old_cainfo =cainfo;
+
+ // --------------------------------------------------------------------------------------------
+
+ CMenuWidget* serverMenu = new CMenuWidget("Servers / Boot","aiw_large.raw");
+ CStringInput* input_port = new CStringInput(LOCALE_ALLINWONDER_WEBPORT, &webport, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789");
+ CStringInputSMS * input_username = new CStringInputSMS(LOCALE_NFS_USERNAME, &webusername, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789");
+ CStringInputSMS * input_password = new CStringInputSMS(LOCALE_NFS_PASSWORD, &webpassword, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789");
+
+
+ serverMenu->addItem(GenericMenuSeparator);
+ serverMenu->addItem(GenericMenuBack);
+ serverMenu->addItem(GenericMenuSeparatorLine);
+
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_DRIVERSETTINGS_VEPG, &vepg, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL, CRCInput::RC_1));
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_DRIVERSETTINGS_CAINFO, &cainfo, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL, CRCInput::RC_2));
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_DRIVERSETTINGS_BOOTINFO, &info, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL, CRCInput::RC_3));
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_DRIVERSETTINGS_PMTUPDATE , &rdate, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL, CRCInput::RC_4));
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_ALLINWONDER_FTPSERVER, &ftpd, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL, CRCInput::RC_5));
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_ALLINWONDER_WEBINTERFACE , &httpd, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL, CRCInput::RC_6));
+
+ serverMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_ALLINWONDER_WEBOPTIONS));
+ serverMenu->addItem(new CMenuForwarder(LOCALE_ALLINWONDER_WEBPORT, true , webport, input_port));
+ serverMenu->addItem(new CMenuOptionChooser(LOCALE_ALLINWONDER_WEBREQUIREAU TH, &webauth, ONOROFF_OPTIONS, ONOROFF_OPTION_COUNT, true, NULL));
+ serverMenu->addItem(new CMenuForwarder(LOCALE_NFS_USERNAME, true , webusername, input_username));
+ serverMenu->addItem(new CMenuForwarder(LOCALE_NFS_PASSWORD, true , webpassword, input_password));
+
+ serverMenu->exec (NULL, "");
+ serverMenu->hide();
+ delete serverMenu;
+
+ /* IMAGE CREATORS: The coding below this point is executed AFTER the menu has been taken off screen. You can use this
+ area for whatever you like, but remember - the more code you have here, the more time it will take to remove the menu
+ from the screen. The user may think that neutrino has temporarily crashed. Use this section wisely. */
+
+ if (old_cainfo != cainfo) {
+ if (cainfo==0) { remove("/var/etc/.cryptinfo"); } //turn on off cainfo bar
+ if (cainfo==1) { system("touch /var/etc/.cryptinfo"); } }
+
+ if (old_vepg != vepg) {
+ if (vepg==0) { remove("/var/etc/.vepg"); system("killall -9 sectionsd && sectionsd -disableVirgin"); } //turn on and off freddys epg
+ if (vepg==1) { system("touch /var/etc/.vepg && sectionsd"); } }
+
+ if (old_httpd != httpd) {
+ if (httpd==0) { remove("/var/etc/.nhttpd"); system("killall -9 nhttpd"); }
+ if (httpd==1) { system("touch /var/etc/.nhttpd && /bin/nhttpd"); } }
+
+ if (old_ftpd != ftpd) {
+ if (ftpd==0) { remove("/var/etc/.ftpd"); system("killall -9 in.ftpd"); }
+ if (ftpd==1) { system("touch /var/etc/.ftpd"); } }
+
+ if (old_info != info) {
+ if (info==0) { remove("/var/etc/.boot_info"); }
+ if (info==1) { system("touch /var/etc/.boot_info"); } }
+
+ if (old_rdate != rdate) {
+ if (rdate==0) { remove("/var/etc/.rdate"); }
+ if (rdate==1) { system("touch /var/etc/.rdate"); } }
+
+ if (old_webport != webport || old_webusername != webusername || old_webpassword != webpassword || old_webauth != webauth)
+ {
+ /* If the user has made changes to the web configuration then we need to save those changes, but we also need to take into
+ account the other options which we also there. */
+
+ config.setString("ExtrasDocRoot", ExtrasDocRoot);
+ config.setString("ExtrasDocURL", ExtrasDocURL);
+ config.setString("Tuxbox.HostedDocumentRoot", HostedDocumentRoot);
+ config.setString("WebsiteMain.directory", MainDirectory);
+ config.setString("WebsiteMain.override_directory", OverrideDirectory);
+ config.setString("WebsiteMain.port", webport);
+ config.setString("Zapit_XML_Path", ZapitXMLPath);
+ config.setString("configfile.version", confversion);
+ if (webauth==1) { authstring = "true"; } if (webauth==0) { authstring = "false"; }
+ config.setString("mod_auth.authenticate", authstring);
+ config.setString("mod_auth.no_auth_client", no_auth_client);
+ config.setString("mod_auth.password", webpassword);
+ config.setString("mod_auth.username", webusername);
+ config.setString("mod_cache.cache_directory", cache_directory);
+ config.setString("mod_sendfile.mime_type", mime_types);
+ config.setString("mod_weblog.log_format", log_format);
+ config.setString("mod_weblog.logfile", logfile);
+ config.setString("server.chroot", chroot);
+ config.setString("server.group_name", group_name);
+ config.setString("server.log.loglevel", loglevel);
+ config.setString("server.no_keep-alive_ips", no_keepalive_ips);
+ config.setString("server.user_name", user_name);
+ config.setString("webserver.threading", threading);
+ config.saveConfig("/var/tuxbox/config/nhttpd.conf");
+ }
+
+
+}


you will need to add the new locals for


LOCALE_DRIVERSETTINGS_VEPG
LOCALE_DRIVERSETTINGS_CAINFO


driversettings.vepg
driversettings.cainfo


this will add a on and off switch for freddy frogs 7 day epg and
an on and off switch for the infobar renny and ss been looking at.