trunk 20080912
[gitenigma.git] / src / enigma_info.cpp
blob36cdaddd44d3ca1e9fe131863a7dc1258a0b084d
1 /*
2 * enigma_info.cpp
4 * Copyright (C) 2002 Felix Domke <tmbinc@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: enigma_info.cpp,v 1.33 2006/07/15 13:22:48 ghostrider Exp $
23 #include <enigma_info.h>
24 #include <unistd.h>
26 #include <streaminfo.h>
28 #include <lib/base/i18n.h>
29 #include <lib/dvb/service.h>
30 #include <lib/dvb/frontend.h>
31 #include <lib/gui/ewindow.h>
32 #include <lib/gui/eskin.h>
33 #include <lib/gui/elabel.h>
34 #include <lib/gui/ebutton.h>
35 #include <lib/system/info.h>
36 #include <lib/system/dmfp.h>
38 eZapInfo::eZapInfo()
39 :eListBoxWindow<eListBoxEntryMenu>(_("Infos"), 7, 320)
41 move(ePoint(150, 166));
42 CONNECT((new eListBoxEntryMenu(&list, _("Streaminfo"), _("open the Streaminfo")))->selected, eZapInfo::sel_streaminfo);
43 CONNECT((new eListBoxEntryMenu(&list, _("About..."), _("open the about dialog")))->selected, eZapInfo::sel_about);
46 eZapInfo::~eZapInfo()
50 void eZapInfo::sel_streaminfo()
52 hide();
53 eStreaminfo si(0, eServiceInterface::getInstance()->service);
54 #ifndef DISABLE_LCD
55 si.setLCD(LCDTitle, LCDElement);
56 #endif
57 si.show();
58 si.exec();
59 si.hide();
60 show();
63 static eString getVersionInfo(const char *info)
65 FILE *f=fopen("/.version", "rt");
66 if (!f)
67 f = fopen("/etc/image-version", "rt");
68 if (!f)
69 return "";
70 eString result;
71 while (1)
73 char buffer[128];
74 if (!fgets(buffer, 128, f))
75 break;
76 if (strlen(buffer))
77 buffer[strlen(buffer)-1]=0;
78 if ((!strncmp(buffer, info, strlen(info)) && (buffer[strlen(info)]=='=')))
80 int i = strlen(info)+1;
81 result = eString(buffer).mid(i, strlen(buffer)-i);
82 break;
85 fclose(f);
86 return result;
89 class eAboutScreen: public eWindow
91 eLabel *machine, *processor, *frontend, *harddisks, *vendor, *logo, *version, *dreamlogo, *triaxlogo, *fpversion;
92 eButton *okButton;
94 public:
95 eAboutScreen()
97 setHelpID(43);
99 machine=new eLabel(this);
100 machine->setName("machine");
102 vendor=new eLabel(this);
103 vendor->setName("vendor");
105 processor=new eLabel(this);
106 processor->setName("processor");
108 frontend=new eLabel(this);
109 frontend->setName("frontend");
111 harddisks=new eLabel(this);
112 harddisks->setName("harddisks");
114 okButton=new eButton(this);
115 okButton->setName("okButton");
117 dreamlogo=new eLabel(this);
118 dreamlogo->setName("dreamlogo");
120 triaxlogo=new eLabel(this);
121 triaxlogo->setName("triaxlogo");
123 version=new eLabel(this);
124 version->setName("version");
126 fpversion=new eLabel(this);
127 fpversion->setName("fp_version");
129 if (eSkin::getActive()->build(this, "eAboutScreen"))
130 eFatal("skin load of \"eAboutScreen\" failed");
132 dreamlogo->hide();
133 triaxlogo->hide();
135 if ( !eSystemInfo::getInstance()->hasHDD() )
137 harddisks->hide();
138 eWidget *h=search("harddisk_label");
139 if(h)
140 h->hide();
143 machine->setText(eSystemInfo::getInstance()->getModel());
144 vendor->setText(eSystemInfo::getInstance()->getManufacturer());
145 processor->setText(eString().sprintf("Processor: %s", eSystemInfo::getInstance()->getCPUInfo()));
147 switch (eSystemInfo::getInstance()->getFEType())
149 case eSystemInfo::feSatellite:
150 frontend->setText(_("Frontend: Satellite"));
151 break;
152 case eSystemInfo::feCable:
153 frontend->setText(_("Frontend: Cable"));
154 break;
155 case eSystemInfo::feTerrestrial:
156 frontend->setText(_("Frontend: Terrestrial"));
157 break;
158 default:
159 frontend->setText(_("Frontend: Unknown"));
162 eString sharddisks;
163 #ifndef DISABLE_FILE
164 if ( eSystemInfo::getInstance()->hasHDD() )
166 for (int c='a'; c<'h'; c++)
168 char line[1024];
169 int ok=1;
170 FILE *f=fopen(eString().sprintf("/proc/ide/hd%c/media", c).c_str(), "r");
171 if (!f)
172 continue;
173 if ((!fgets(line, 1024, f)) || strcmp(line, "disk\n"))
174 ok=0;
175 fclose(f);
176 if (ok)
178 FILE *f=fopen(eString().sprintf("/proc/ide/hd%c/model", c).c_str(), "r");
179 if (!f)
180 continue;
181 *line=0;
182 fgets(line, 1024, f);
183 fclose(f);
184 if (!*line)
185 continue;
186 line[strlen(line)-1]=0;
187 sharddisks+=line;
188 f=fopen(eString().sprintf("/proc/ide/hd%c/capacity", c).c_str(), "r");
189 if (!f)
190 continue;
191 int capacity=0;
192 fscanf(f, "%d", &capacity);
193 fclose(f);
194 sharddisks+=" (";
195 if (c&1)
196 sharddisks+="master";
197 else
198 sharddisks+="slave";
199 if (capacity)
200 sharddisks+=eString().sprintf(", %d MB", capacity/2048);
201 sharddisks+=")\n";
205 #endif //DISABLE_FILE
206 if (sharddisks == "")
207 sharddisks=_("none");
208 harddisks->setText(sharddisks);
211 eString verid=getVersionInfo("version");
212 if (!verid)
213 version->setText(_("unknown"));
214 else
216 int type=atoi(verid.left(1).c_str());
217 char *typea[3];
218 typea[0]=_("release");
219 typea[1]=_("beta");
220 typea[2]=_("internal");
221 eString ver=verid.mid(1, 3);
222 eString date=verid.mid(4, 8);
223 // eString time=verid.mid(12, 4);
224 if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000 )
225 version->setText(
226 eString(typea[type%3]) + eString(" ") + ver[0] + "." + ver[1] + "." + ver[2]
227 + ", " + date.mid(6, 2) + "." + date.mid(4,2) + "." + date.left(4));
228 else
229 version->setText(
230 eString().sprintf
231 ("%s %c.%d. %s", typea[type%3], ver[0],
232 atoi( eString().sprintf("%c%c",ver[1],ver[2]).c_str() ),
233 (date.mid(6, 2) + "." + date.mid(4,2) + "." + date.left(4)).c_str()
239 if ( !strcmp(eSystemInfo::getInstance()->getManufacturer(),"Triax") )
240 triaxlogo->show();
241 else if ( !strcmp(eSystemInfo::getInstance()->getManufacturer(),"Dream-Multimedia-TV") )
242 dreamlogo->show();
244 if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000
245 || eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7020)
247 eString fp_version = fpversion->getText();
248 fp_version += eString().sprintf(" 1.%02d", eDreamboxFP::getFPVersion());
249 eDebug("%s", fp_version.c_str());
250 fpversion->setText(fp_version);
252 else
253 fpversion->hide();
255 CONNECT(okButton->selected, eWidget::accept);
259 void eZapInfo::sel_about()
261 hide();
262 eAboutScreen about;
263 about.show();
264 about.exec();
265 about.hide();
266 show();