Ich habe mal ein paar Sachen ausgeschnitten und entschärft. Vielleicht kannst Du ja was damit anfangen. Die Kommunikation mit zapit erfolgt allerdings noch nach meiner schon vor längerer Zeit mal gemachten Erweiterung. Die müßtest Du an Eure geplante Erweiterung anpassen.
Code: Alles auswählen
enum {
savechan,
saveaudio,
showdiv,
ucswitch,
ZAPIT_MENUE_ENTRIES};
// Globals for Startchannel select
char New_TVStartchannel_name[256];
t_channel_id New_TVStartchannel_ID=0,Last_TVStartchannel_ID=0;
char New_RadioStartchannel_name[256];
t_channel_id New_RadioStartchannel_ID=0,Last_RadioStartchannel_ID=0;
void SYSTEM_ConfWidget::startchan_menu(CZapitClient::channelsMode mode)
{
std::vector<CMenuWidget *> toDelete;
CZapitClient zapit;
CZapitClient::BouquetList bouquetlist;
zapit.getBouquets(bouquetlist, false, true, mode); // UTF-8
CZapitClient::BouquetList::iterator bouquet = bouquetlist.begin();
CMenuWidget mctv(LOCALE_TIMERLIST_BOUQUETSELECT, NEUTRINO_ICON_SETTINGS);
if(mode==CZapitClient::MODE_TV)
strcpy(New_TVStartchannel_name,CTimerList::convertChannelId2String(zapit.getLastTVSDChannel()).c_str());
else
strcpy(New_RadioStartchannel_name,CTimerList::convertChannelId2String(zapit.getLastRadioSDChannel()).c_str());
for(; bouquet != bouquetlist.end();bouquet++)
{
CMenuWidget* mwtv = new CMenuWidget(LOCALE_TIMERLIST_CHANNELSELECT, NEUTRINO_ICON_SETTINGS);
toDelete.push_back(mwtv);
CZapitClient::BouquetChannelList subchannellist;
zapit.getBouquetChannels(bouquet->bouquet_nr,subchannellist, mode, true); // UTF-8
CZapitClient::BouquetChannelList::iterator channel = subchannellist.begin();
for(; channel != subchannellist.end();channel++)
{
char cChannelId[32];
sprintf(cChannelId,
"%cSC:%016llx,",
(mode==CZapitClient::MODE_TV)?'T':'R',
channel->channel_id);
mwtv->addItem(new CMenuForwarderNonLocalized(channel->name, true, NULL, this, (std::string(cChannelId) + channel->name).c_str()));
}
if (!subchannellist.empty())
mctv.addItem(new CMenuForwarderNonLocalized(bouquet->name, true, NULL, mwtv));
subchannellist.clear();
}
mctv.exec (NULL, "");
mctv.hide ();
// delete dynamic created objects
for(unsigned int count=0;count<toDelete.size();count++)
{
delete toDelete[count];
}
toDelete.clear();
}
int SYSTEM_ConfWidget::exec(CMenuTarget* parent, const std::string & actionKey)
{
if(actionKey == "tvstartchan_menu")
{
startchan_menu(CZapitClient::MODE_TV);
}
else if(actionKey == "radiostartchan_menu")
{
startchan_menu(CZapitClient::MODE_RADIO);
}
return true;
}
void SYSTEM_ConfWidget::zapit_menu()
{
int zapit_entry[ZAPIT_MENUE_ENTRIES];
int zapit_save [ZAPIT_MENUE_ENTRIES];
CZapitClient *pZapit = new CZapitClient;
CMenuForwarder *no_menu = (CMenuForwarder *)NULL;
zapit_entry[saveaudio]=(pZapit->getSaveAudio())?1:0;
zapit_entry[savechan]=(pZapit->getSaveLastChannel())?1:0;
zapit_entry[showdiv]=(pZapit->getMakeRemainingBouquets())?1:0;
zapit_entry[ucswitch]=pZapit->getUncommittedSwitchMode();
memcpy(zapit_save,zapit_entry , sizeof(zapit_save));
Last_TVStartchannel_ID=New_TVStartchannel_ID=pZapit->getLastTVSDChannel();
Last_RadioStartchannel_ID=New_RadioStartchannel_ID=pZapit->getLastRadioSDChannel();
if(New_TVStartchannel_ID && (!zapit_entry[savechan]))
{
strcpy(New_TVStartchannel_name,CTimerList::convertChannelId2String(New_TVStartchannel_ID).c_str());
}
else
{
strcpy(New_TVStartchannel_name,"----");
}
if(New_RadioStartchannel_ID && (!zapit_entry[savechan]))
{
strcpy(New_RadioStartchannel_name,CTimerList::convertChannelId2String(New_RadioStartchannel_ID).c_str());
}
else
{
strcpy(New_RadioStartchannel_name,"----");
}
CMenuWidget* zapit_selector = new CMenuWidget(LOCALE_ZAPIT_MENU, "neutrino.raw");
CMenuForwarder* o_tvstartchan = new CMenuForwarder(LOCALE_ZAPIT_TVSTARTCHAN, !zapit_entry[savechan], New_TVStartchannel_name, this, "tvstartchan_menu");
CMenuForwarder* o_radiostartchan = new CMenuForwarder(LOCALE_ZAPIT_RADIOSTARTCHAN, !zapit_entry[savechan], New_RadioStartchannel_name, this, "radiostartchan_menu");
CMenuSettingsNotifier* schanNotifier = new CMenuSettingsNotifier( o_tvstartchan, o_radiostartchan, no_menu, no_menu, no_menu, no_menu, no_menu, no_menu, zapit_entry);
CMenuOptionChooser* o_savechan = new CMenuOptionChooser(LOCALE_ZAPIT_SAVECHAN, &zapit_entry[savechan], OPTIONS_OFF_ON_OPTIONS,OPTIONS_OFF_ON_OPTION_COUNT,true,schanNotifier);
CMenuOptionChooser* o_saveaudio = new CMenuOptionChooser(LOCALE_ZAPIT_SAVEAUDIO, &zapit_entry[saveaudio], OPTIONS_OFF_ON_OPTIONS,OPTIONS_OFF_ON_OPTION_COUNT,true);
CMenuOptionChooser* o_showdiv = new CMenuOptionChooser(LOCALE_ZAPIT_SHOWDIV, &zapit_entry[showdiv], OPTIONS_OFF_ON_OPTIONS,OPTIONS_OFF_ON_OPTION_COUNT,true);
CMenuOptionChooser* o_ucswitch = new CMenuOptionChooser(LOCALE_ZAPIT_UCSWITCH, &zapit_entry[ucswitch], UCSWITCH_OPTIONS,UCSWITCH_OPTION_COUNT,true);
zapit_selector->addItem(GenericMenuSeparator);
zapit_selector->addItem(GenericMenuBack);
zapit_selector->addItem(GenericMenuSeparatorLine);
zapit_selector->addItem( o_savechan );
zapit_selector->addItem( o_tvstartchan );
zapit_selector->addItem( o_radiostartchan );
zapit_selector->addItem( o_saveaudio );
zapit_selector->addItem( o_showdiv );
if(g_info.delivery_system == DVB_S) zapit_selector->addItem( o_ucswitch );
zapit_selector->exec (NULL, "");
zapit_selector->hide ();
delete zapit_selector;
if ((memcmp(zapit_save,zapit_entry , sizeof(zapit_save))!=0)||(Last_TVStartchannel_ID!=New_TVStartchannel_ID)||(Last_RadioStartchannel_ID!=New_RadioStartchannel_ID))
{
if (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_MAINSETTINGS_SAVESETTINGSNOW , CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel, "info.raw",400) != CMessageBox::mbrYes) // UTF-8
return;
pZapit->setSaveAudio(zapit_entry[saveaudio]);
pZapit->setSaveLastChannel(zapit_entry[savechan]);
pZapit->setMakeRemainingBouquets(zapit_entry[showdiv]);
pZapit->setUncommittedSwitchMode(zapit_entry[ucswitch]);
pZapit->setLastTVSDChannel(New_TVStartchannel_ID);
pZapit->setLastRadioSDChannel(New_RadioStartchannel_ID);
if(zapit_entry[showdiv] != zapit_save[showdiv])
if (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO,LOCALE_MAINMENU_REBOOT, CMessageBox::mbrCancel, CMessageBox::mbYes | CMessageBox::mbCancel, "error.raw",400) != CMessageBox::mbrYes) // UTF-8
return;
else
{
system ("touch /tmp/.reboot");
g_RCInput->postMsg( NeutrinoMessages::SHUTDOWN, 0 );
}
}
}