1 #include "enigma_bouquet.h"
3 #include <enigma_main.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
);
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
);
24 new eListBoxEntryText( &list
, _("File"), (void*) eZapMain::modeFile
);
26 CONNECT( list
.selected
, eModeSelector::entrySelected
);
29 void eModeSelector::entrySelected( eListBoxEntryText
*e
)
32 close( (int)e
->getKey() );
37 eZapBouquetSetup::eZapBouquetSetup()
38 :eSetupWindow(_("Service Organising"), 6, 430)
40 move(ePoint(150, 166));
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()
58 m
.setLCD(LCDTitle
, LCDElement
);
65 eServiceSelector
&sel
= *eZap::getInstance()->getServiceSelector();
67 if ( eZapMain::getInstance()->toggleEditMode(&sel
,ret
) )
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) );
99 sel
.setPath( eZapMain::getInstance()->getRoot(eZapMain::listAll
, eZapMain::modeFile
) );
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) );
110 sel
.setPath( eZapMain::getInstance()->getRoot(eZapMain::listAll
, eZapMain::modeFile
) );
114 // save current service selector style
115 int sstyle
= sel
.getStyle();
117 // set to SingleColumn Style
118 sel
.setStyle( eServiceSelector::styleSingleColumn
, true );
122 if ( ButtonsWasVisible
) // must show buttons
123 eConfig::getInstance()->setKey("/ezap/serviceselector/showButtons", (int)1 );
126 sel
.setStyle( sstyle
, true );
131 eActionMapList::getInstance()->activateStyle("sselect_default");
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
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);
174 // open service selector
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()
198 m
.setLCD(LCDTitle
, LCDElement
);
204 eZapMain::getInstance()->createEmptyBouquet( ret
);
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;