trunk 20080912
[gitenigma.git] / src / setup_extra.cpp
blobc162b1fb5269f05e2e67ba099be8b2c47a223cb5
1 /*
2 * setup_extra.cpp
4 * Copyright (C) 2003 Andreas Monzner <ghostrider@tuxbox.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * $Id: setup_extra.cpp,v 1.77 2008/08/30 16:47:35 dbluelle Exp $
22 #include <enigma.h>
23 #include <setup_extra.h>
24 #include <setupengrab.h>
25 #include <setupnetwork.h>
26 #include <software_update.h>
27 #include <setup_rc.h>
28 #include <swapmanager.h>
29 #include <lib/dvb/decoder.h>
30 #include <lib/gui/emessage.h>
31 #include <lib/system/info.h>
33 #ifndef TUXTXT_CFG_STANDALONE
34 extern "C" int tuxtxt_stop();
35 extern "C" void tuxtxt_close();
36 extern "C" int tuxtxt_init();
37 extern "C" int tuxtxt_start(int tpid);
38 #endif
40 eExpertSetup::eExpertSetup()
41 :eSetupWindow(_("Expert Setup"), 10, 400)
43 init_eExpertSetup();
46 void eExpertSetup::init_eExpertSetup()
48 cmove(ePoint(170, 115));
50 int lockWebIf=1;
51 if ( eConfig::getInstance()->getKey("/ezap/webif/lockWebIf", lockWebIf) )
52 eConfig::getInstance()->setKey("/ezap/webif/lockWebIf", lockWebIf);
54 int showSatPos=1;
55 if ( eConfig::getInstance()->getKey("/extras/showSatPos", showSatPos) )
56 eConfig::getInstance()->setKey("/extras/showSatPos", showSatPos);
58 int entry=0;
59 #ifndef DISABLE_NETWORK
60 if (eSystemInfo::getInstance()->hasNetwork())
62 CONNECT((new eListBoxEntryMenu(&list, _("Communication Setup"), eString().sprintf("(%d) %s", ++entry, _("open communication setup")) ))->selected, eExpertSetup::communication_setup);
63 CONNECT((new eListBoxEntryMenu(&list, _("Ngrab Streaming Setup"), eString().sprintf("(%d) %s", ++entry, _("open ngrab server setup")) ))->selected, eExpertSetup::ngrab_setup);
64 switch (eSystemInfo::getInstance()->getHwType())
66 case eSystemInfo::DM7020:
67 case eSystemInfo::DM600PVR:
68 case eSystemInfo::DM500PLUS:
69 break;
70 default:
71 CONNECT((new eListBoxEntryMenu(&list, _("Software Update"), eString().sprintf("(%d) %s", ++entry, _("open software update")) ))->selected, eExpertSetup::software_update);
74 int startSamba=1;
75 if ( eConfig::getInstance()->getKey("/elitedvb/network/samba", startSamba) )
76 eConfig::getInstance()->setKey("/elitedvb/network/samba", startSamba);
77 #endif
78 CONNECT((new eListBoxEntryMenu(&list, _("Remote Control"), eString().sprintf("(%d) %s", ++entry, _("open remote control setup")) ))->selected, eExpertSetup::rc_setup);
79 #ifndef DISABLE_HDD
80 #ifndef DISABLE_FILE
81 CONNECT((new eListBoxEntryMenu(&list, _("Swap Manager"), eString().sprintf("(%d) %s", ++entry, _("open swapspace setup")) ))->selected, eExpertSetup::swapmanager);
82 #endif
83 #endif
84 if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000 )
85 CONNECT((new eListBoxEntryMenu(&list, _("Factory reset"), eString().sprintf("(%d) %s", ++entry, _("all settings will set to factory defaults")) ))->selected, eExpertSetup::factory_reset);
86 new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
87 list.setFlags(list.getFlags()|eListBoxBase::flagNoPageMovement);
88 #ifndef DISABLE_FILE
89 if ( eSystemInfo::getInstance()->canRecordTS() && !eDVB::getInstance()->recorder )
91 record_split_size = new eListBoxEntryMulti(&list, _("record split size (left, right)"));
92 record_split_size->add(" 650MB >", 650*1024);
93 record_split_size->add("< 700MB >", 700*1024);
94 record_split_size->add("< 800MB >", 800*1024);
95 record_split_size->add("< 1GB >", 1024*1024);
96 record_split_size->add("< 1,5GB >", 1536*1024);
97 record_split_size->add("< 2GB >", 2*1024*1024);
98 record_split_size->add("< 4GB >", 4*1024*1024);
99 record_split_size->add("< 8GB >", 8*1024*1024);
100 record_split_size->add("< 16GB ", 16*1024*1024);
101 int splitsize=0;
102 if (eConfig::getInstance()->getKey("/extras/record_splitsize", splitsize))
103 splitsize=1024*1024; // 1G
104 record_split_size->setCurrent(splitsize);
105 CONNECT( list.selchanged, eExpertSetup::selChanged );
107 #endif
108 if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000 )
109 CONNECT((new eListBoxEntryCheck(&list,_("Enable fast zapping"),"/elitedvb/extra/fastzapping",_("enables faster zapping.. but with visible sync")))->selected, eExpertSetup::fastZappingChanged );
110 CONNECT((new eListBoxEntryCheck(&list, _("Use http authentification"), "/ezap/webif/lockWebIf", _("enables the http (user/password) authentification")))->selected, eExpertSetup::reinitializeHTTPServer );
111 CONNECT((new eListBoxEntryCheck(&list, _("Don't open serial port"), "/ezap/extra/disableSerialOutput", _("don't write debug messages to /dev/tts/0")))->selected, eExpertSetup::reinitializeHTTPServer );
112 new eListBoxEntryCheck(&list, _("Auto bouquet change"), "/elitedvb/extra/autobouquetchange", _("change into next bouquet when end of current bouquet is reached"));
113 new eListBoxEntryCheck(&list, _("Auto reconnect cahandler"), "/elitedvb/extra/cahandlerReconnect", _("try to reconnect when an external cahandler connection was lost"));
114 #ifndef DISABLE_NETWORK
115 if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000 ||
116 eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7020)
117 new eListBoxEntryCheck(&list, _("Enable file sharing"), "/elitedvb/network/samba", _("start file sharing(samba) on startup"));
118 #endif
119 #ifndef TUXTXT_CFG_STANDALONE
120 CONNECT((new eListBoxEntryCheck(&list, _("Disable teletext caching"), "/ezap/extra/teletext_caching", _("don't cache teletext pages in background")))->selected, eExpertSetup::tuxtxtCachingChanged );
121 #endif
122 new eListBoxEntryCheck(&list, _("Enable Zapping History"), "/elitedvb/extra/extzapping", _("don't care about actual mode when zapping in history list"));
123 if ( eSystemInfo::getInstance()->getHwType() < eSystemInfo::DM5600 )
124 new eListBoxEntryCheck(&list, _("Disable Standby"), "/extras/fastshutdown", _("Box goes directly into Deep-Standby"));
125 #ifdef ENABLE_MHW_EPG
126 int mhwepg=1;
127 if ( eConfig::getInstance()->getKey("/extras/mhwepg", mhwepg) )
128 eConfig::getInstance()->setKey("/extras/mhwepg", mhwepg);
129 new eListBoxEntryCheck(&list, _("Enable MHW EPG"), "/extras/mhwepg", _("Mediahighway EPG, activate swap space when using with multiple operators"));
130 #endif
131 #ifdef HAVE_DREAMBOX_HARDWARE
132 if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000 )
134 int corefilesDisable = 0;
135 if (access("/var/etc/.no_corefiles", R_OK) == 0)
136 corefilesDisable = 1;
137 eConfig::getInstance()->setKey("/extras/corefiles_disable", corefilesDisable);
138 new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
139 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable CoreFiles"), "/extras/corefiles_disable", _("don't create 'Corefiles' after an Enigma crash")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_corefiles");
140 #ifdef ENABLE_EXPERT_WEBIF
141 int dontMountHDD = 0;
142 if (access("/var/etc/.dont_mount_hdd", R_OK) == 0)
143 dontMountHDD = 1;
144 eConfig::getInstance()->setKey("/extras/dont_mount_hdd", dontMountHDD);
145 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable HDD mount"), "/extras/dont_mount_hdd", _("don't mount the HDD via 'rcS'")))->selected, eExpertSetup::fileToggle,"/var/etc/.dont_mount_hdd");
146 #endif
148 #endif
149 #ifndef DISABLE_FILE
150 int autoplay=1;
151 if ( eConfig::getInstance()->getKey("/ezap/extra/autoplay", autoplay) )
152 eConfig::getInstance()->setKey("/ezap/extra/autoplay", autoplay);
153 new eListBoxEntryCheck(&list, _("Enable Filemode Autoplay"), "/ezap/extra/autoplay", _("continue playing last selected movie when entering Filemode"));
154 #endif
155 #ifndef HAVE_DREAMBOX_HARDWARE
156 new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
157 //Boot-info
158 int bootInfo = 0;
159 if (access("/var/etc/.boot_info", R_OK) == 0)
160 bootInfo = 1;
161 eConfig::getInstance()->setKey("/extras/bootinfo", bootInfo);
162 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Show Boot-Info"), "/extras/bootinfo", _("Show Boot-Infos (IP, etc.)")))->selected, eExpertSetup::fileToggle,"/var/etc/.boot_info");
163 //HW-Sections
164 int hwSectionsDisable = 0;
165 if (access("/var/etc/.hw_sections", R_OK) == 0)
166 hwSectionsDisable = 1;
167 eConfig::getInstance()->setKey("/extras/hw_sections_disable", hwSectionsDisable);
168 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable HW_Sections"), "/extras/hw_sections_disable", _("don't use hardware section filtering")))->selected, eExpertSetup::fileToggle,"/var/etc/.hw_sections");
169 //Watchdog
170 int watchdogDisable = 0;
171 if (access("/var/etc/.no_watchdog", R_OK) == 0)
172 watchdogDisable = 1;
173 eConfig::getInstance()->setKey("/extras/watchdog_disable", watchdogDisable);
174 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable Watchdog"), "/extras/watchdog_disable", _("don't use the Watchdog")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_watchdog");
175 //ENX-Watchdog - Philips and Sagem
176 if ( eSystemInfo::getInstance()->getHwType() != eSystemInfo::dbox2Nokia )
178 int enxWatchdogDisable = 0;
179 if (access("/var/etc/.no_enxwatchdog", R_OK) == 0)
180 enxWatchdogDisable = 1;
181 eConfig::getInstance()->setKey("/extras/enxwatchdog_disable", enxWatchdogDisable);
182 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable ENX-Watchdog"), "/extras/enxwatchdog_disable", _("don't use the ENX-Watchdog")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_enxwatchdog");
184 //SPTS-Recording
185 int sptsMode = 0;
186 if (access("/var/etc/.spts_mode", R_OK) == 0)
187 sptsMode = 1;
188 eConfig::getInstance()->setKey("/extras/spts_mode", sptsMode);
189 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Enable SPTS-Mode"), "/extras/spts_mode", _("use SPTS-Mode (enables TS-recording)")))->selected, eExpertSetup::fileToggle,"/var/etc/.spts_mode");
190 //File I/O-Options
191 int OSyncDisable = 0;
192 if (access("/var/etc/.no_o_sync", R_OK) == 0)
193 OSyncDisable = 1;
194 eConfig::getInstance()->setKey("/extras/O_SYNC_disable", OSyncDisable);
195 CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable O_SYNC"), "/extras/O_SYNC_disable", _("The file/recording is not opened for synchronous I/O")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_o_sync");
196 //Alternative Frontenddriver for Philips
197 if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::dbox2Philips )
199 int tda80xx = 0;
200 if (access("/var/etc/.tda80xx", R_OK) == 0)
201 tda80xx = 1;
202 eConfig::getInstance()->setKey("/extras/tda80xx", tda80xx);
203 CONNECT_2_1((new eListBoxEntryCheck(&list, _("New Philips driver"), "/extras/tda80xx", _("use tda80xx driver for Philips boxes")))->selected, eExpertSetup::fileToggle,"/var/etc/.tda80xx");
205 #endif
206 setHelpID(92);
209 void eExpertSetup::fileToggle(bool newState, const char* filename)
211 FILE* test;
212 test = fopen(filename,"r");
213 if (test != NULL)
215 fclose(test);
216 ::unlink(filename);
218 else
220 eString cmd = "touch ";
221 cmd += filename;
222 system(cmd.c_str());
226 #ifndef TUXTXT_CFG_STANDALONE
227 void eExpertSetup::tuxtxtCachingChanged(bool b)
229 if ( b )
231 if (Decoder::current.tpid != -1)
232 tuxtxt_stop();
233 tuxtxt_close();
235 else
237 tuxtxt_init();
238 if (Decoder::current.tpid != -1)
239 tuxtxt_start(Decoder::current.tpid);
242 #endif
244 #ifndef DISABLE_FILE
245 void eExpertSetup::selChanged(eListBoxEntryMenu* e)
247 if ( eSystemInfo::getInstance()->canRecordTS() &&
248 e == (eListBoxEntryMenu*)record_split_size )
249 eConfig::getInstance()->setKey("/extras/record_splitsize", (int)e->getKey());
251 #endif
253 void eExpertSetup::reinitializeHTTPServer(bool)
255 eZap::getInstance()->reconfigureHTTPServer();
258 void eExpertSetup::fastZappingChanged(bool b)
260 Decoder::setFastZap(b);
263 #ifndef DISABLE_NETWORK
264 void eExpertSetup::communication_setup()
266 hide();
267 eZapNetworkSetup setup;
268 #ifndef DISABLE_LCD
269 setup.setLCD(LCDTitle, LCDElement);
270 #endif
271 setup.show();
272 setup.exec();
273 setup.hide();
274 show();
277 void eExpertSetup::ngrab_setup()
279 hide();
280 ENgrabSetup setup;
281 #ifndef DISABLE_LCD
282 setup.setLCD(LCDTitle, LCDElement);
283 #endif
284 setup.show();
285 setup.exec();
286 setup.hide();
287 show();
290 void eExpertSetup::software_update()
292 hide();
293 eSoftwareUpdate setup;
294 #ifndef DISABLE_LCD
295 setup.setLCD(LCDTitle, LCDElement);
296 #endif
297 setup.show();
298 setup.exec();
299 setup.hide();
300 show();
303 #endif
305 void eExpertSetup::rc_setup()
307 hide();
308 eZapRCSetup setup;
309 #ifndef DISABLE_LCD
310 setup.setLCD(LCDTitle, LCDElement);
311 #endif
312 setup.show();
313 setup.exec();
314 setup.hide();
315 show();
317 #ifndef DISABLE_HDD
318 #ifndef DISABLE_FILE
319 void eExpertSetup::swapmanager()
321 hide();
322 eSwapManager setup;
323 #ifndef DISABLE_LCD
324 setup.setLCD(LCDTitle, LCDElement);
325 #endif
326 setup.show();
327 setup.exec();
328 setup.hide();
329 show();
331 #endif
332 #endif
334 //implemented in upgrade.cpp
335 extern bool erase(char mtd[30], const char *titleText);
337 void eExpertSetup::factory_reset()
339 hide();
340 eMessageBox mb(
341 _("When you do a factory reset, you will lose ALL your configuration data\n"
342 "(including bouquets, services, satellite data ...)\n"
343 "After completion of factory reset, your receiver will restart automatically!\n\n"
344 "Really do a factory reset?"),
345 _("Factory reset"),
346 eMessageBox::btYes|eMessageBox::btNo|eMessageBox::iconQuestion,
347 eMessageBox::btNo );
348 mb.show();
349 int ret = mb.exec();
350 mb.hide();
351 if ( ret == eMessageBox::btYes )
353 switch( eSystemInfo::getInstance()->getHwType() )
355 case eSystemInfo::DM500PLUS:
356 case eSystemInfo::DM600PVR:
357 case eSystemInfo::DM7020:
358 system("rm -R /etc/enigma && killall -9 enigma");
359 break;
360 case eSystemInfo::DM7000:
361 case eSystemInfo::DM500:
362 case eSystemInfo::DM5620:
363 case eSystemInfo::DM5600:
364 case eSystemInfo::TR_DVB272S:
365 erase("/dev/mtd/1", _("Factory reset..."));
366 system("reboot");
367 break;
368 default:
369 eDebug("factory reset not implemented for this hardware!!\n");
372 show();