trunk 20080912
[gitenigma.git] / src / wizard_scan.cpp
blob31263c237f2da4ff6d460e566f15e6cdc42577f9
1 #include <wizard_scan.h>
2 #include <rotorconfig.h>
3 #include <lib/dvb/frontend.h>
4 #include <lib/gdi/font.h>
5 #include <lib/gui/listbox.h>
6 #include <lib/system/init_num.h>
7 #include <lib/system/info.h>
8 #include <lib/system/econfig.h>
9 #include <satconfig.h>
10 #include <scan.h>
11 #include <enigma_scan.h>
12 #include <enigma_main.h>
14 class eDiseqcChoice: public eListBoxEntry
16 friend class eListBox<eDiseqcChoice>;
17 gPixmap *pixmap;
18 eTextPara *para;
19 static gFont font;
20 int choice;
21 eString text;
22 int yOffs;
23 public:
24 enum { none, simple, complex };
25 eDiseqcChoice(eListBox<eDiseqcChoice>* lb, int choice)
26 : eListBoxEntry( (eListBox<eListBoxEntry>*)lb), choice(choice)
28 pixmap=eSkin::getActive()->queryImage(eString().sprintf("diseqc_%d", choice));
29 if (!font.pointSize)
30 font = eSkin::getActive()->queryFont("eListBox.EntryText.normal");
31 para=0;
34 ~eDiseqcChoice()
36 delete para;
39 int getDiseqcChoice() const
41 return choice;
43 protected:
44 static int getEntryHeight()
46 return 150;
49 const eString& redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state )
51 drawEntryRect( rc, rect, coActiveB, coActiveF, coNormalB, coNormalF, state );
53 if (!para)
55 para = new eTextPara( eRect( rect.left(), 0, rect.width(), rect.height() ) );
56 para->setFont(font);
57 para->renderString(text);
58 para->realign(eTextPara::dirCenter);
59 yOffs = ((rect.height() - para->getBoundBox().height()) / 2) - para->getBoundBox().top();
61 rc->renderPara(*para, ePoint(0, rect.top() + yOffs ) );
62 if (pixmap)
63 rc->blit(*pixmap, ePoint(rect.left()+15, rect.top()+15));
65 return text;
69 gFont eDiseqcChoice::font;
71 eWizardSelectDiseqc::eWizardSelectDiseqc()
73 diseqclist=new eListBox<eDiseqcChoice>(this);
74 diseqclist->setName("choices");
75 diseqclist->setColumns(3);
77 description=new eLabel(this);
78 description->setName("description");
80 if (eSkin::getActive()->build(this, "eWizardDiseqc"))
81 eFatal("skin load of \"eWizardDiseqc\" failed");
83 eDiseqcChoice *current;
84 current=new eDiseqcChoice(diseqclist, eDiseqcChoice::none);
85 new eDiseqcChoice(diseqclist, eDiseqcChoice::simple);
86 new eDiseqcChoice(diseqclist, eDiseqcChoice::complex);
87 CONNECT(diseqclist->selchanged, eWizardSelectDiseqc::selchanged);
88 CONNECT(diseqclist->selected, eWizardSelectDiseqc::selected);
89 selchanged(current);
92 int eWizardSelectDiseqc::run()
94 eWizardSelectDiseqc *wizard=new eWizardSelectDiseqc();
95 wizard->show();
96 int res=wizard->exec();
97 wizard->hide();
98 return res;
101 void eWizardSelectDiseqc::selected(eDiseqcChoice *choice)
103 if (!choice)
104 close(-1);
105 else
106 close(choice->getDiseqcChoice());
109 void eWizardSelectDiseqc::selchanged(eDiseqcChoice *choice)
111 if (!choice)
112 return;
113 switch(choice->getDiseqcChoice())
115 case 0:
116 description->setText(_("Direct connection to one LNB"));
117 break;
118 case 1:
119 description->setText(_("Simple DiSEqC (2 LNBs/satellites)"));
120 break;
121 case 2:
122 description->setText(_("Complex configuration (including DiSEqC 1.2)"));
123 break;
127 class eWizardScanInit
129 public:
130 eWizardScanInit()
132 if ( eApp->isAppQuitNowSet() )
133 return;
134 int res = 0;
135 int diseqc=0;
136 eConfig::getInstance()->getKey("/elitedvb/wizards/diseqc", diseqc);
137 if (diseqc)
138 return;
139 if ( eSystemInfo::getInstance()->getFEType() == eSystemInfo::feSatellite )
141 // gotos considered harmless.. :)
142 again_wizard:
143 res=eWizardSelectDiseqc::run();
145 if (res >= 0)
147 eSatelliteConfigurationManager satconfig;
149 switch (res)
151 case 0:
152 satconfig.extSetComplexity(0); // single lnb
153 break;
154 case 1:
155 satconfig.extSetComplexity(1); // diseqc 1.0
156 break;
157 case 2:
158 satconfig.extSetComplexity(3); // diseqc 1.2
159 break;
163 satconfig.show();
164 res=satconfig.exec();
165 satconfig.hide();
167 if (res != 1)
168 goto again_wizard;
171 eLNB *l=eZapScan::getRotorLNB(1);
172 if (l)
174 RotorConfig c(l);
175 c.show();
176 c.exec();
177 c.hide();
182 TransponderScan scan(0, 0, TransponderScan::stateMenu);
183 res=scan.exec();
186 while (res);
190 else if ( eSystemInfo::getInstance()->getFEType() != eSystemInfo::feUnknown )
192 TransponderScan scan(0, 0, TransponderScan::stateMenu);
193 res=scan.exec();
196 eZapMain::getInstance()->showServiceSelector( eServiceSelector::dirFirst, eZapMain::pathAll );
197 diseqc=1;
198 eConfig::getInstance()->setKey("/elitedvb/wizards/diseqc", diseqc);
202 eAutoInitP0<eWizardScanInit> init_eWizardScanInit(eAutoInitNumbers::wizard+3, "wizard: scan");