trunk 20080912
[gitenigma.git] / src / enigma_bouquet.cpp
blob7ed3350064d7d6c30b1bc854c676da7f494b01b2
1 #include "enigma_bouquet.h"
2 #include <enigma.h>
3 #include <enigma_main.h>
4 #include <sselect.h>
5 #include <lib/dvb/servicestructure.h>
6 #include <lib/dvb/frontend.h>
7 #include <lib/gui/actions.h>
8 #include <lib/system/info.h>
10 class eModeSelector: public eListBoxWindow<eListBoxEntryText>
12 void entrySelected(eListBoxEntryText *s);
13 public:
14 eModeSelector();
17 eModeSelector::eModeSelector()
18 :eListBoxWindow<eListBoxEntryText>(_("Bouquet Type"), 5, 400)
20 move( ePoint(100,100) );
21 new eListBoxEntryText( &list, _("TV"), (void*) eZapMain::modeTV );
22 new eListBoxEntryText( &list, _("Radio"), (void*) eZapMain::modeRadio );
23 #ifndef DISABLE_FILE
24 new eListBoxEntryText( &list, _("File"), (void*) eZapMain::modeFile );
25 #endif
26 CONNECT( list.selected, eModeSelector::entrySelected );
29 void eModeSelector::entrySelected( eListBoxEntryText *e )
31 if ( e )
32 close( (int)e->getKey() );
33 else
34 close(-1);
37 eZapBouquetSetup::eZapBouquetSetup()
38 :eSetupWindow(_("Service Organising"), 6, 430)
40 move(ePoint(150, 166));
41 int entry=0;
42 CONNECT((new eListBoxEntryMenu(&list, _("Create new bouquet"), eString().sprintf("(%d) %s", ++entry, _("create new empty bouquet"))))->selected, eZapBouquetSetup::createNewEmptyBouquet );
43 CONNECT((new eListBoxEntryMenu(&list, _("Add services to bouquet"), eString().sprintf("(%d) %s", ++entry, _("add multiple services to a specific bouquet"))))->selected, eZapBouquetSetup::editModeSelected );
44 CONNECT((new eListBoxEntryMenu(&list, _("Edit bouquets"), eString().sprintf("(%d) %s", ++entry, _("sort,rename,delete services/bouquets "))))->selected, eZapBouquetSetup::editSelected );
45 if ( eConfig::getInstance()->getParentalPin() )
47 new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
48 CONNECT((new eListBoxEntryMenu(&list, _("Lock/Unlock Services"), eString().sprintf("(%d) %s", ++entry,_("lock,unlock services (parental locking)"))))->selected, eZapBouquetSetup::lockUnlockServices );
50 // CONNECT((new eListBoxEntryMenu(&list, _("Duplicate Sat/Provider/Bouquet"), _("copy specific bouquet/provider/sat to bouquet list")))->selected, eZapBouquetSetup::editSelected );
53 void eZapBouquetSetup::editModeSelected()
55 hide();
56 eModeSelector m;
57 #ifndef DISABLE_LCD
58 m.setLCD(LCDTitle, LCDElement);
59 #endif
60 m.show();
61 int ret = m.exec();
62 m.hide();
63 if ( ret != -1 )
65 eServiceSelector &sel = *eZap::getInstance()->getServiceSelector();
67 if ( eZapMain::getInstance()->toggleEditMode(&sel,ret) )
69 show();
70 return;
73 // save ColorButtons State.. and disable
74 int ButtonsWasVisible=0;
75 eConfig::getInstance()->getKey("/ezap/serviceselector/showButtons", ButtonsWasVisible );
77 if ( ButtonsWasVisible ) // must show buttons
78 eConfig::getInstance()->setKey("/ezap/serviceselector/showButtons", (int)0 );
80 eActionMapList::getInstance()->deactivateStyle("sselect_default");
82 // save current serviceselector Path
83 eServicePath p = sel.getPath();
85 // save current selection
86 eServiceReference ref = sel.getSelected();
88 // set new service selector path... ( bouquet list root... )
90 // when satellite frontend exist we show the satellites root
91 if ( eSystemInfo::getInstance()->getFEType() == eSystemInfo::feSatellite )
93 if ( ret == eZapMain::modeTV )
94 sel.setPath( eServiceReference(eServiceReference::idDVB, eServiceReference::flagDirectory|eServiceReference::shouldSort, -4, (1<<4)|(1<<1) ));
95 else if ( ret == eZapMain::modeRadio )
96 sel.setPath( eServiceReference(eServiceReference::idDVB, eServiceReference::flagDirectory|eServiceReference::shouldSort, -4, 1<<2) );
97 #ifndef DISABLE_FILE
98 else
99 sel.setPath( eZapMain::getInstance()->getRoot(eZapMain::listAll, eZapMain::modeFile) );
100 #endif
102 else // cable or dvb-t
104 if ( ret == eZapMain::modeTV )
105 sel.setPath( eServiceReference(eServiceReference::idDVB, eServiceReference::flagDirectory|eServiceReference::shouldSort, -1, (1<<4)|(1<<1), 0xFFFFFFFF) );
106 else if ( ret == eZapMain::modeRadio )
107 sel.setPath( eServiceReference(eServiceReference::idDVB, eServiceReference::flagDirectory|eServiceReference::shouldSort, -1, 1<<2, 0xFFFFFFFF) );
108 #ifndef DISABLE_FILE
109 else
110 sel.setPath( eZapMain::getInstance()->getRoot(eZapMain::listAll, eZapMain::modeFile) );
111 #endif
114 // save current service selector style
115 int sstyle = sel.getStyle();
117 // set to SingleColumn Style
118 sel.setStyle( eServiceSelector::styleSingleColumn, true );
120 sel.choose(-1);
122 if ( ButtonsWasVisible ) // must show buttons
123 eConfig::getInstance()->setKey("/ezap/serviceselector/showButtons", (int)1 );
125 // set old Style
126 sel.setStyle( sstyle, true );
128 // set old path
129 sel.setPath(p,ref);
131 eActionMapList::getInstance()->activateStyle("sselect_default");
133 show();
136 void eZapBouquetSetup::editSelected()
138 // save ColorButtons State
139 int ButtonsWasVisible=0;
140 eConfig::getInstance()->getKey("/ezap/serviceselector/showButtons", ButtonsWasVisible );
141 if ( !ButtonsWasVisible ) // must show buttons
143 ButtonsWasVisible=2;
144 eConfig::getInstance()->setKey("/ezap/serviceselector/showButtons", (int)1 );
147 eActionMapList::getInstance()->deactivateStyle("sselect_default");
149 // enable edit actions
150 eActionMapList::getInstance()->activateStyle("sselect_edit");
152 eServiceSelector &sel = *eZap::getInstance()->getServiceSelector();
154 // save current serviceselector Path
155 eServicePath p = sel.getPath();
157 // save current selection
158 eServiceReference ref = sel.getSelected();
160 // set new service selector path... ( bouquet list root... )
161 sel.setPath( eServiceStructureHandler::getRoot(eServiceStructureHandler::modeBouquets),eServiceReference() );
163 // save current service selector style
164 int sstyle = sel.getStyle();
166 // set to SingleColumn Style
167 sel.setStyle( eServiceSelector::styleSingleColumn, true );
169 // set edit mode key descriptions ( delete, mark, rename )
170 sel.setKeyDescriptions(true);
172 hide();
174 // open service selector
175 sel.choose(-1);
177 show();
179 // restore state of color buttons
180 if ( ButtonsWasVisible == 2) // buttons was not visible.. hide
181 eConfig::getInstance()->setKey("/ezap/serviceselector/showButtons", (int)0 );
183 // restore old ssel style
184 sel.setStyle( sstyle, true );
186 // restore old actions
187 eActionMapList::getInstance()->deactivateStyle("sselect_edit");
188 eActionMapList::getInstance()->activateStyle("sselect_default");
190 sel.setPath( p, ref );
193 void eZapBouquetSetup::createNewEmptyBouquet()
195 hide();
196 eModeSelector m;
197 #ifndef DISABLE_LCD
198 m.setLCD(LCDTitle, LCDElement);
199 #endif
200 m.show();
201 int ret = m.exec();
202 m.hide();
203 if ( ret != -1 )
204 eZapMain::getInstance()->createEmptyBouquet( ret );
205 show();
208 extern bool checkPin( int pin, const char * text );
210 void eZapBouquetSetup::lockUnlockServices()
212 if ( checkPin( eConfig::getInstance()->getParentalPin(), _("parental")) )
214 eZap::getInstance()->getServiceSelector()->plockmode = 1;
215 eZap::getInstance()->getServiceSelector()->choose(-1);
216 eZap::getInstance()->getServiceSelector()->plockmode = 0;