WIP. stop assuming whole channel list selected == channel number

This commit is contained in:
[CST] Focus
2012-03-14 19:44:06 +04:00
parent 93d6d19016
commit 008940a3b7
4 changed files with 222 additions and 232 deletions

View File

@@ -82,7 +82,7 @@ extern CBouquetList * RADIOsatList;
extern CBouquetList * RADIOfavList; extern CBouquetList * RADIOfavList;
extern CBouquetList * RADIOallList; extern CBouquetList * RADIOallList;
#define USE_NEWZAP
//extern t_channel_id rec_channel_id; //extern t_channel_id rec_channel_id;
extern bool autoshift; extern bool autoshift;
@@ -100,7 +100,7 @@ CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vl
selected = 0; selected = 0;
selected_in_new_mode = 0; selected_in_new_mode = 0;
liststart = 0; liststart = 0;
tuned=0xfffffff; tuned = 0xfffffff;
zapProtection = NULL; zapProtection = NULL;
this->historyMode = phistoryMode; this->historyMode = phistoryMode;
vlist = _vlist; vlist = _vlist;
@@ -313,7 +313,10 @@ t_channel_id CChannelList::getActiveChannel_ChannelID(void) const
int CChannelList::getActiveChannelNumber(void) const int CChannelList::getActiveChannelNumber(void) const
{ {
return (selected + 1); //return (selected + 1);
if (selected < chanlist.size())
return chanlist[selected]->number;
return 0;
} }
int CChannelList::doChannelMenu(void) int CChannelList::doChannelMenu(void)
@@ -459,10 +462,10 @@ int CChannelList::exec()
if(new_mode >= 0) if(new_mode >= 0)
CNeutrinoApp::getInstance()->SetChannelMode(new_mode); CNeutrinoApp::getInstance()->SetChannelMode(new_mode);
} }
#if 1 #ifndef USE_NEWZAP
CNeutrinoApp::getInstance()->channelList->zapTo(getKey(nNewChannel)-1); CNeutrinoApp::getInstance()->channelList->zapTo(getKey(nNewChannel)-1);
#else #else
CNeutrinoApp::getInstance()->channelList->NewZap(chanlist[nNewChannel]->channel_id); CNeutrinoApp::getInstance()->channelList->zapToChannel(chanlist[nNewChannel]);
#endif #endif
} }
@@ -964,10 +967,16 @@ void CChannelList::hide()
bool CChannelList::showInfo(int pos, int epgpos) bool CChannelList::showInfo(int pos, int epgpos)
{ {
#if 0
if((pos >= (signed int) chanlist.size()) || (pos<0)) if((pos >= (signed int) chanlist.size()) || (pos<0))
return false; return false;
CZapitChannel* chan = chanlist[pos]; CZapitChannel* chan = chanlist[pos];
#endif
CZapitChannel* chan = getChannel(pos+1);
if(chan == NULL)
return false;
g_InfoViewer->showTitle(pos+1, chan->name, chan->getSatellitePosition(), chan->channel_id, true, epgpos); // UTF-8 g_InfoViewer->showTitle(pos+1, chan->name, chan->getSatellitePosition(), chan->channel_id, true, epgpos); // UTF-8
return true; return true;
} }
@@ -1071,9 +1080,10 @@ bool CChannelList::adjustToChannelID(const t_channel_id channel_id, bool bToo)
} }
if (chanlist[i]->channel_id == channel_id) { if (chanlist[i]->channel_id == channel_id) {
selected = i; selected = i;
tuned = i;
lastChList.store (selected, channel_id, false); lastChList.store (selected, channel_id, false);
tuned = i;
if (bToo && (bouquetList != NULL)) { if (bToo && (bouquetList != NULL)) {
int old_mode = CNeutrinoApp::getInstance()->GetChannelMode(); int old_mode = CNeutrinoApp::getInstance()->GetChannelMode();
int new_mode = old_mode; int new_mode = old_mode;
@@ -1152,34 +1162,49 @@ void CChannelList::setSelected( int nChannelNr)
bool CChannelList::zapTo_ChannelID(const t_channel_id channel_id) bool CChannelList::zapTo_ChannelID(const t_channel_id channel_id)
{ {
printf("**************************** CChannelList::zapTo_ChannelID %llx\n", channel_id); printf("**************************** CChannelList::zapTo_ChannelID %llx\n", channel_id);
for (unsigned int i=0; i<chanlist.size(); i++) { for (unsigned int i = 0; i < chanlist.size(); i++) {
if (chanlist[i]->channel_id == channel_id) { if (chanlist[i]->channel_id == channel_id) {
zapTo (i); zapTo(i);
return true; return true;
} }
} }
return false; return false;
} }
bool CChannelList::showEmptyError()
{
if (chanlist.empty()) {
DisplayErrorMessage(g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND)); // UTF-8
return true;
}
return false;
}
/* forceStoreToLastChannels defaults to false */ /* forceStoreToLastChannels defaults to false */
/* TODO make this private to call only from "current" list, where selected/pos not means channel number */ /* TODO make this private to call only from "current" list, where selected/pos not means channel number */
void CChannelList::zapTo(int pos, bool /* forceStoreToLastChannels */) void CChannelList::zapTo(int pos, bool /* forceStoreToLastChannels */)
{ {
if (chanlist.empty()) { if(showEmptyError())
DisplayErrorMessage(g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND)); // UTF-8
return; return;
}
if ( (pos >= (signed int) chanlist.size()) || (pos< 0) ) { if ( (pos >= (signed int) chanlist.size()) || (pos < 0) ) {
pos = 0; pos = 0;
} }
CZapitChannel* chan = chanlist[pos];
#ifdef USE_NEWZAP
zapToChannel(chan);
tuned = pos;
if(this->new_mode_active)
selected_in_new_mode = pos;
else
selected = pos;
#else
/* we record when we switched away from a channel, so that the parental-PIN code can /* we record when we switched away from a channel, so that the parental-PIN code can
check for timeout. last_unlocked_time == 0 means: the PIN was not entered check for timeout. last_unlocked_time == 0 means: the PIN was not entered
"tuned" is the *old* channel, before zap */ "tuned" is the *old* channel, before zap */
if (tuned < chanlist.size() && chanlist[tuned]->last_unlocked_time != 0) if (tuned < chanlist.size() && chanlist[tuned]->last_unlocked_time != 0)
chanlist[tuned]->last_unlocked_time = time_monotonic(); chanlist[tuned]->last_unlocked_time = time_monotonic();
CZapitChannel* chan = chanlist[pos];
printf("**************************** CChannelList::zapTo me %p %s tuned %d new %d %s -> %llx\n", this, name.c_str(), tuned, pos, chan->name.c_str(), chan->channel_id); printf("**************************** CChannelList::zapTo me %p %s tuned %d new %d %s -> %llx\n", this, name.c_str(), tuned, pos, chan->name.c_str(), chan->channel_id);
if ( pos!=(int)tuned ) { if ( pos!=(int)tuned ) {
@@ -1191,21 +1216,13 @@ void CChannelList::zapTo(int pos, bool /* forceStoreToLastChannels */)
tuned = pos; tuned = pos;
g_RemoteControl->zapTo_ChannelID(chan->channel_id, chan->name, !chan->bAlwaysLocked); // UTF-8 g_RemoteControl->zapTo_ChannelID(chan->channel_id, chan->name, !chan->bAlwaysLocked); // UTF-8
// TODO check is it possible bouquetList is NULL ? CNeutrinoApp::getInstance()->channelList->adjustToChannelID(chan->channel_id);
if (bouquetList != NULL) {
CNeutrinoApp::getInstance()->channelList->adjustToChannelID(chan->channel_id);
}
if(this->new_mode_active) if(this->new_mode_active)
selected_in_new_mode = pos; selected_in_new_mode = pos;
} }
if(!this->new_mode_active) { if(!this->new_mode_active) {
selected = pos; selected = pos;
#if 0
/* TODO lastChList.store also called in adjustToChannelID, which is called
only from "whole" channel list. Why here too ? */
lastChList.store (selected, chan->channel_id, forceStoreToLastChannels);
#endif
/* remove recordModeActive from infobar */ /* remove recordModeActive from infobar */
if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) { if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) {
g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0); g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0);
@@ -1214,27 +1231,46 @@ void CChannelList::zapTo(int pos, bool /* forceStoreToLastChannels */)
g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 );
CNeutrinoApp::getInstance()->channelList->getLastChannels().set_mode(chan->channel_id); CNeutrinoApp::getInstance()->channelList->getLastChannels().set_mode(chan->channel_id);
} }
#endif
} }
/* to replace zapTo_ChannelID and zapTo from "whole" list ? */ /* to replace zapTo_ChannelID and zapTo from "whole" list ? */
void CChannelList::NewZap(t_channel_id channel_id) void CChannelList::zapToChannel(CZapitChannel *channel)
{ {
CZapitChannel * chan = CServiceManager::getInstance()->FindChannel(channel_id); if(showEmptyError())
if(chan == NULL)
return; return;
printf("**************************** CChannelList::NewZap me %p %s tuned %d new %s -> %llx\n", this, name.c_str(), tuned, chan->name.c_str(), chan->channel_id); if(channel == NULL)
return;
if(selected_chid != chan->getChannelID()) { /* we record when we switched away from a channel, so that the parental-PIN code can
selected_chid = chan->getChannelID(); check for timeout. last_unlocked_time == 0 means: the PIN was not entered
g_RemoteControl->zapTo_ChannelID(chan->getChannelID(), chan->name, !chan->bAlwaysLocked); "tuned" is the *old* channel, before zap */
if (tuned < chanlist.size() && chanlist[tuned]->last_unlocked_time != 0)
chanlist[tuned]->last_unlocked_time = time_monotonic();
printf("**************************** CChannelList::zapToChannel me %p %s tuned %d new %s -> %llx\n", this, name.c_str(), tuned, channel->name.c_str(), channel->channel_id);
if(tuned < chanlist.size())
selected_chid = chanlist[tuned]->getChannelID();
if(selected_chid != channel->getChannelID()) {
if ((g_settings.radiotext_enable) && ((CNeutrinoApp::getInstance()->getMode()) == NeutrinoMessages::mode_radio) && (g_Radiotext))
{
// stop radiotext PES decoding before zapping
g_Radiotext->radiotext_stop();
}
selected_chid = channel->getChannelID();
g_RemoteControl->zapTo_ChannelID(channel->getChannelID(), channel->name, !channel->bAlwaysLocked);
CNeutrinoApp::getInstance()->channelList->adjustToChannelID(channel->getChannelID());
}
if(!this->new_mode_active) {
/* remove recordModeActive from infobar */ /* remove recordModeActive from infobar */
if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) { if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) {
g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0); g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0);
} }
CNeutrinoApp::getInstance()->channelList->adjustToChannelID(chan->getChannelID());
g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 );
CNeutrinoApp::getInstance()->channelList->getLastChannels().set_mode(channel->channel_id);
} }
} }
@@ -1246,10 +1282,8 @@ int CChannelList::numericZap(int key)
int res = -1; int res = -1;
if (chanlist.empty()) { if(showEmptyError())
DisplayErrorMessage(g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND)); // UTF-8
return res; return res;
}
// -- quickzap "0" to last seen channel... // -- quickzap "0" to last seen channel...
if (key == g_settings.key_lastchannel) { if (key == g_settings.key_lastchannel) {
@@ -1266,21 +1300,11 @@ int CChannelList::numericZap(int key)
} }
if ((key == g_settings.key_zaphistory) || (key == CRCInput::RC_games)) { if ((key == g_settings.key_zaphistory) || (key == CRCInput::RC_games)) {
if((!autoshift && CNeutrinoApp::getInstance()->recordingstatus) || (key == CRCInput::RC_games)) { if((!autoshift && CNeutrinoApp::getInstance()->recordingstatus) || (key == CRCInput::RC_games)) {
//CChannelList * orgList = bouquetList->orgChannelList;
CChannelList * orgList = CNeutrinoApp::getInstance()->channelList; CChannelList * orgList = CNeutrinoApp::getInstance()->channelList;
CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_CURRENT_TP), false, true); CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_CURRENT_TP), false, true);
#if 0
t_channel_id recid = rec_channel_id >> 16;
if(key == CRCInput::RC_games)
recid = chanlist[selected]->channel_id >> 16;
for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) {
if((orgList->chanlist[i]->channel_id >> 16) == recid) {
channelList->addChannel(orgList->chanlist[i]);
}
}
#endif
if(key == CRCInput::RC_games) { if(key == CRCInput::RC_games) {
t_channel_id recid =chanlist[selected]->channel_id >> 16; t_channel_id recid = chanlist[selected]->channel_id >> 16;
for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) { for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) {
if((orgList->chanlist[i]->channel_id >> 16) == recid) if((orgList->chanlist[i]->channel_id >> 16) == recid)
channelList->addChannel(orgList->chanlist[i]); channelList->addChannel(orgList->chanlist[i]);
@@ -1295,13 +1319,6 @@ int CChannelList::numericZap(int key)
channelList->adjustToChannelID(orgList->getActiveChannel_ChannelID(), false); channelList->adjustToChannelID(orgList->getActiveChannel_ChannelID(), false);
this->frameBuffer->paintBackground(); this->frameBuffer->paintBackground();
res = channelList->exec(); res = channelList->exec();
#if 0
int newChannel = channelList->show() ;
if (newChannel > -1) { //FIXME handle edit/mode change ??
orgList->zapTo_ChannelID(channelList->chanlist[newChannel]->channel_id);
}
#endif
} }
delete channelList; delete channelList;
return res; return res;
@@ -1327,8 +1344,6 @@ int CChannelList::numericZap(int key)
return res; return res;
} }
//int ox = 300;
//int oy = 200;
int sx = 4 * g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number) + 14; int sx = 4 * g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number) + 14;
int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6; int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6;
@@ -1340,32 +1355,33 @@ int CChannelList::numericZap(int key)
int lastchan= -1; int lastchan= -1;
bool doZap = true; bool doZap = true;
bool showEPG = false; bool showEPG = false;
int cnum = getActiveChannelNumber();
while(1) { while(1) {
if (lastchan != chn) { if (lastchan != chn) {
snprintf((char*) &valstr, sizeof(valstr), "%d", chn); snprintf((char*) &valstr, sizeof(valstr), "%d", chn);
while(strlen(valstr)<4) while(strlen(valstr) < 4)
strcat(valstr,"-"); //"_" strcat(valstr,"-"); //"_"
frameBuffer->paintBoxRel(ox, oy, sx, sy, COL_INFOBAR_PLUS_0); frameBuffer->paintBoxRel(ox, oy, sx, sy, COL_INFOBAR_PLUS_0);
for (int i=3; i>=0; i--) { for (int i = 3; i >= 0; i--) {
valstr[i+ 1]= 0; valstr[i+ 1] = 0;
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(ox+7+ i*((sx-14)>>2), oy+sy-3, sx, &valstr[i], COL_INFOBAR); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(ox+7+ i*((sx-14)>>2), oy+sy-3, sx, &valstr[i], COL_INFOBAR);
} }
showInfo(chn- 1); showInfo(chn - 1);
lastchan= chn; lastchan = chn;
} }
g_RCInput->getMsg( &msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_NUMERICZAP] * 10 ); g_RCInput->getMsg( &msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_NUMERICZAP] * 10 );
if ( msg == CRCInput::RC_timeout ) { if (msg == CRCInput::RC_timeout || msg == CRCInput::RC_ok) {
if ( ( chn > (int)chanlist.size() ) || (chn == 0) ) if ((chn > (int)chanlist.size() ) || (chn == 0))
chn = tuned + 1; chn = cnum;
break; break;
} }
else if ( msg == CRCInput::RC_favorites || msg == CRCInput::RC_sat) { else if (msg == CRCInput::RC_favorites || msg == CRCInput::RC_sat) {
} }
else if (CRCInput::isNumeric(msg)) { else if (CRCInput::isNumeric(msg)) {
if (pos == 4) { if (pos == 4) {
@@ -1377,14 +1393,8 @@ int CChannelList::numericZap(int key)
} }
chn += CRCInput::getNumericValue(msg); chn += CRCInput::getNumericValue(msg);
} }
else if ( msg == CRCInput::RC_ok ) { else if (msg == (neutrino_msg_t)g_settings.key_quickzap_down) {
if ( ( chn > (signed int) chanlist.size() ) || ( chn == 0 ) ) { if (chn == 1)
chn = tuned + 1;
}
break;
}
else if ( msg == (neutrino_msg_t)g_settings.key_quickzap_down ) {
if ( chn == 1 )
chn = chanlist.size(); chn = chanlist.size();
else { else {
chn--; chn--;
@@ -1393,25 +1403,25 @@ int CChannelList::numericZap(int key)
chn = (int)chanlist.size(); chn = (int)chanlist.size();
} }
} }
else if ( msg == (neutrino_msg_t)g_settings.key_quickzap_up ) { else if (msg == (neutrino_msg_t)g_settings.key_quickzap_up) {
chn++; chn++;
if (chn > (int)chanlist.size()) if (chn > (int)chanlist.size())
chn = 1; chn = 1;
} }
else if ( ( msg == CRCInput::RC_home ) || ( msg == CRCInput::RC_left ) || ( msg == CRCInput::RC_right) ) else if ((msg == CRCInput::RC_home) || (msg == CRCInput::RC_left) || (msg == CRCInput::RC_right))
{ {
doZap = false; doZap = false;
break; break;
} }
else if ( msg == CRCInput::RC_red ) { else if (msg == CRCInput::RC_red) {
if ( ( chn <= (signed int) chanlist.size() ) && ( chn != 0 ) ) { if ((chn <= (signed int) chanlist.size()) && (chn != 0)) {
doZap = false; doZap = false;
showEPG = true; showEPG = true;
break; break;
} }
} }
else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { else if (CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all) {
doZap = false; doZap = false;
//res = menu_return::RETURN_EXIT_ALL; //res = menu_return::RETURN_EXIT_ALL;
break; break;
@@ -1420,202 +1430,166 @@ int CChannelList::numericZap(int key)
frameBuffer->paintBackgroundBoxRel(ox, oy, sx, sy); frameBuffer->paintBackgroundBoxRel(ox, oy, sx, sy);
#if 0
chn--; chn--;
if (chn<0) if (chn < 0)
chn=0; chn = 0;
if ( doZap ) { #endif
CZapitChannel* chan = getChannel(chn);
if (doZap) {
if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0) if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0)
g_InfoViewer->killTitle(); g_InfoViewer->killTitle();
#if 0
if(SameTP(chanlist[chn])) { if(SameTP(chanlist[chn])) {
zapTo( chn ); zapTo( chn );
res = 0; res = 0;
} else } else
g_InfoViewer->killTitle(); g_InfoViewer->killTitle();
#endif
//CZapitChannel* chan = getChannel(chn);
if(chan && SameTP(chan)) {
printf("CChannelList::numericZap: chn %d channel num %d\n", chn, chan->number);
zapToChannel(chan);
res = 0;
} else
g_InfoViewer->killTitle();
} else { } else {
showInfo(tuned); /* FIXME check why showInfo before killTitle needed ? */
showInfo(cnum - 1);
g_InfoViewer->killTitle(); g_InfoViewer->killTitle();
if ( showEPG ) if (chan && showEPG)
g_EventList->exec(chanlist[chn]->channel_id, chanlist[chn]->name); g_EventList->exec(chan->channel_id, chan->getName());
} }
return res; return res;
} }
CZapitChannel* CChannelList::getPrevNextChannelNumber(int key, unsigned int &sl)
{
CZapitChannel* channel = chanlist[sl];
int bsize = bouquetList->Bouquets.size();
int bactive = bouquetList->getActiveBouquetNumber();
if(!g_settings.zap_cycle && bsize > 1) {
size_t cactive = sl;
printf("CChannelList::getPrevNextChannelNumber: selected %d total %d active bouquet %d total %d\n", cactive, chanlist.size(), bactive, bsize);
if ((key == g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) {
if(cactive == 0) {
if(bactive == 0)
bactive = bsize - 1;
else
bactive--;
bouquetList->activateBouquet(bactive, false);
cactive = bouquetList->Bouquets[bactive]->channelList->getSize() - 1;
} else {
--cactive;
sl = cactive;
}
}
else if ((key == g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) {
cactive++;
if(cactive >= chanlist.size()) {
bactive = (bactive + 1) % bsize;
bouquetList->activateBouquet(bactive, false);
cactive = 0;
} else
sl = cactive;
}
sl = cactive;
channel = bouquetList->Bouquets[bactive]->channelList->getChannelFromIndex(cactive);
printf("CChannelList::getPrevNextChannelNumber: selected %d total %d active bouquet %d total %d channel %x (%s)\n",
cactive, chanlist.size(), bactive, bsize, (int) channel, channel ? channel->getName().c_str(): "");
} else {
if ((key == g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) {
if(sl == 0)
sl = chanlist.size()-1;
else
sl--;
}
else if ((key==g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) {
sl = (sl+1)%chanlist.size();
}
channel = chanlist[sl];
}
return channel;
}
void CChannelList::virtual_zap_mode(bool up) void CChannelList::virtual_zap_mode(bool up)
{ {
neutrino_msg_t msg; neutrino_msg_t msg;
neutrino_msg_data_t data; neutrino_msg_data_t data;
if (chanlist.empty()) { if(showEmptyError())
DisplayErrorMessage(g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND)); // UTF-8
return; return;
}
int chn = getActiveChannelNumber() + (up ? 1 : -1); unsigned int sl = selected;
if (chn > (int)chanlist.size()) int old_bactive = bouquetList->getActiveBouquetNumber();
chn = 1; int bactive = old_bactive;
if (chn == 0)
chn = (int)chanlist.size();
int lastchan= -1; int cnum = getActiveChannelNumber();
bool doZap = true;
CZapitChannel* channel = getPrevNextChannelNumber(up ? CRCInput::RC_right : CRCInput::RC_left, sl);
bool doZap = false;
bool showEPG = false; bool showEPG = false;
int epgpos = 0; int epgpos = 0;
while(1) while(1) {
{ if (channel)
if (lastchan != chn || (epgpos != 0)) g_InfoViewer->showTitle(channel, true, epgpos);
{
showInfo(chn- 1, epgpos);
lastchan= chn;
}
epgpos = 0; epgpos = 0;
g_RCInput->getMsg( &msg, &data, 15*10 ); // 15 seconds, not user changable g_RCInput->getMsg(&msg, &data, 15*10); // 15 seconds, not user changable
//printf("########### %u ### %u #### %u #######\n", msg, NeutrinoMessages::EVT_TIMER, CRCInput::RC_timeout);
if ( msg == CRCInput::RC_ok ) if ((msg == CRCInput::RC_left) || (msg == CRCInput::RC_right)) {
{ channel = bouquetList->Bouquets[bactive]->channelList->getPrevNextChannelNumber(msg, sl);
if ( ( chn > (signed int) chanlist.size() ) || ( chn == 0 ) ) bactive = bouquetList->getActiveBouquetNumber();
{ }
chn = tuned + 1; else if (msg == CRCInput::RC_up || msg == CRCInput::RC_down) {
} epgpos = (msg == CRCInput::RC_up) ? -1 : 1;
}
else if ((msg == CRCInput::RC_ok) || (msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout)) {
if(msg == CRCInput::RC_ok)
doZap = true;
break; break;
} }
else if ( msg == CRCInput::RC_left ) else if (msg == CRCInput::RC_red) {
{ showEPG = true;
if ( chn == 1 )
chn = chanlist.size();
else
{
chn--;
if (chn > (int)chanlist.size())
chn = (int)chanlist.size();
}
}
else if ( msg == CRCInput::RC_right )
{
chn++;
if (chn > (int)chanlist.size())
chn = 1;
}
else if ( msg == CRCInput::RC_up )
{
epgpos = -1;
}
else if ( msg == CRCInput::RC_down )
{
epgpos = 1;
}
else if ( ( msg == CRCInput::RC_home ) || ( msg == CRCInput::RC_timeout ) )
{
// Abbruch ohne Channel zu wechseln
doZap = false;
break; break;
} }
else if ( msg == CRCInput::RC_red ) else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) {
{
// Rote Taste zeigt EPG fuer gewaehlten Kanal an
if ( ( chn <= (signed int) chanlist.size() ) && ( chn != 0 ) )
{
doZap = false;
showEPG = true;
break;
}
}
else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
doZap = false;
break; break;
} }
} }
g_InfoViewer->clearVirtualZapMode(); g_InfoViewer->clearVirtualZapMode();
chn--; if (doZap) {
if (chn<0)
chn=0;
if ( doZap )
{
if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0) if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0)
g_InfoViewer->killTitle(); g_InfoViewer->killTitle();
if(SameTP(chanlist[chn])) if(channel && SameTP(channel))
zapTo( chn ); zapToChannel(channel);
else else
g_InfoViewer->killTitle(); g_InfoViewer->killTitle();
} } else {
else showInfo(cnum - 1);
{
showInfo(tuned);
g_InfoViewer->killTitle(); g_InfoViewer->killTitle();
bouquetList->activateBouquet(old_bactive, false);
// Rote Taste zeigt EPG fuer gewaehlten Kanal an if (showEPG && channel)
if ( showEPG ) g_EventList->exec(channel->channel_id, channel->getName());
g_EventList->exec(chanlist[chn]->channel_id, chanlist[chn]->name);
} }
} }
void CChannelList::quickZap(int key, bool cycle) void CChannelList::quickZap(int key, bool /* cycle */)
{ {
if(chanlist.size() == 0) if(chanlist.size() == 0)
return; return;
int bsize = bouquetList->Bouquets.size(); CZapitChannel* channel = getPrevNextChannelNumber(key, selected);
if(!cycle && bsize > 1) { if(channel)
int bactive = bouquetList->getActiveBouquetNumber(); CNeutrinoApp::getInstance()->channelList->zapToChannel(channel);
size_t cactive = selected;
printf("CChannelList::quickZap: selected %d total %d active bouquet %d total %d\n", cactive, chanlist.size(), bactive, bsize);
if ( (key==g_settings.key_quickzap_down) || (key == CRCInput::RC_left))
{
if(cactive == 0)
{
if(bactive == 0)
bactive = bsize - 1;
else
bactive--;
bouquetList->activateBouquet(bactive, false);
cactive = bouquetList->Bouquets[bactive]->channelList->getSize() - 1;
}
else
{
selected = cactive;
--cactive;
}
}
else if ((key==g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) {
cactive++;
if(cactive >= chanlist.size()) {
bactive = (bactive + 1) % bsize;
bouquetList->activateBouquet(bactive, false);
cactive = 0;
} else
selected = cactive;
}
printf("CChannelList::quickZap: new selected %d total %d active bouquet %d total %d\n", cactive, bouquetList->Bouquets[bactive]->channelList->getSize(), bactive, bsize);
#if 1
CNeutrinoApp::getInstance()->channelList->zapTo(bouquetList->Bouquets[bactive]->channelList->getKey(cactive)-1);
#else
CZapitChannel* chan = bouquetList->Bouquets[bactive]->channelList->getChannelFromIndex(cactive);
if(chan != NULL)
CNeutrinoApp::getInstance()->channelList->NewZap(chan->channel_id);
#endif
} else {
if ( (key==g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) {
if(selected == 0)
selected = chanlist.size()-1;
else
selected--;
}
else if ((key==g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) {
selected = (selected+1)%chanlist.size();
}
#if 1
CNeutrinoApp::getInstance()->channelList->zapTo(getKey(selected)-1);
#else
CNeutrinoApp::getInstance()->channelList->NewZap(chanlist[selected]->channel_id);
#endif
}
g_RCInput->clearRCMsg(); //FIXME test for n.103 g_RCInput->clearRCMsg(); //FIXME test for n.103
} }

View File

@@ -125,7 +125,7 @@ public:
t_channel_id getActiveChannel_ChannelID(void) const; t_channel_id getActiveChannel_ChannelID(void) const;
void zapTo(int pos, bool forceStoreToLastChannels = false); void zapTo(int pos, bool forceStoreToLastChannels = false);
void NewZap(t_channel_id channel_id); void zapToChannel(CZapitChannel *channel);
void virtual_zap_mode(bool up); void virtual_zap_mode(bool up);
bool zapTo_ChannelID(const t_channel_id channel_id); bool zapTo_ChannelID(const t_channel_id channel_id);
bool adjustToChannelID(const t_channel_id channel_id, bool bToo = true); bool adjustToChannelID(const t_channel_id channel_id, bool bToo = true);
@@ -152,6 +152,9 @@ public:
bool SameTP(t_channel_id channel_id); bool SameTP(t_channel_id channel_id);
bool SameTP(CZapitChannel * channel = NULL); bool SameTP(CZapitChannel * channel = NULL);
CLastChannel & getLastChannels() { return lastChList; } CLastChannel & getLastChannels() { return lastChList; }
bool showEmptyError();
int getSelected() { return selected; }
CZapitChannel* getPrevNextChannelNumber(int key, unsigned int &sl);
//friend class CZapitChannel; //friend class CZapitChannel;
}; };
#endif #endif

View File

@@ -971,7 +971,7 @@ void CInfoViewer::loop(bool show_dot)
fader.Stop(); fader.Stop();
if (virtual_zap_mode) { if (virtual_zap_mode) {
/* if bouquet cycle set, do virtual over current bouquet */ /* if bouquet cycle set, do virtual over current bouquet */
if (g_settings.zap_cycle && (bouquetList != NULL) && !(bouquetList->Bouquets.empty())) if (/*g_settings.zap_cycle && */ (bouquetList != NULL) && !(bouquetList->Bouquets.empty()))
bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->virtual_zap_mode(msg == CRCInput::RC_right); bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->virtual_zap_mode(msg == CRCInput::RC_right);
else else
CNeutrinoApp::getInstance()->channelList->virtual_zap_mode(msg == CRCInput::RC_right); CNeutrinoApp::getInstance()->channelList->virtual_zap_mode(msg == CRCInput::RC_right);

View File

@@ -1206,16 +1206,23 @@ void CNeutrinoApp::channelsInit(bool bOnly)
/* all TV channels */ /* all TV channels */
CServiceManager::getInstance()->GetAllTvChannels(zapitList); CServiceManager::getInstance()->GetAllTvChannels(zapitList);
tvi = zapitList.size(); tvi = zapitList.size();
#if 0
TVchannelList->setSize(tvi); TVchannelList->setSize(tvi);
for(zapit_list_it_t it = zapitList.begin(); it != zapitList.end(); it++) for(zapit_list_it_t it = zapitList.begin(); it != zapitList.end(); it++)
TVchannelList->putChannel(*it); TVchannelList->putChannel(*it);
#else
TVchannelList->SetChannelList(&zapitList);
#endif
/* all RADIO channels */ /* all RADIO channels */
CServiceManager::getInstance()->GetAllRadioChannels(zapitList); CServiceManager::getInstance()->GetAllRadioChannels(zapitList);
ri = zapitList.size(); ri = zapitList.size();
#if 0
RADIOchannelList->setSize(ri); RADIOchannelList->setSize(ri);
for(zapit_list_it_t it = zapitList.begin(); it != zapitList.end(); it++) for(zapit_list_it_t it = zapitList.begin(); it != zapitList.end(); it++)
RADIOchannelList->putChannel(*it); RADIOchannelList->putChannel(*it);
#else
RADIOchannelList->SetChannelList(&zapitList);
#endif
CBouquet* hdBouquet = NULL; CBouquet* hdBouquet = NULL;
/* all HD channels */ /* all HD channels */
@@ -2303,7 +2310,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
printf("************************* ZAP START: bouquetList %p size %d old_b %d\n", bouquetList, bouquetList->Bouquets.size(), old_b);fflush(stdout); printf("************************* ZAP START: bouquetList %p size %d old_b %d\n", bouquetList, bouquetList->Bouquets.size(), old_b);fflush(stdout);
if(bouquetList->Bouquets.size()) { if(bouquetList->Bouquets.size()) {
old_num = bouquetList->Bouquets[old_b]->channelList->getActiveChannelNumber(); old_num = bouquetList->Bouquets[old_b]->channelList->getSelected();
} }
_show: _show:
if(msg == CRCInput::RC_ok) if(msg == CRCInput::RC_ok)
@@ -2322,10 +2329,12 @@ _show:
_repeat: _repeat:
printf("************************* ZAP RES: nNewChannel %d\n", nNewChannel);fflush(stdout); printf("************************* ZAP RES: nNewChannel %d\n", nNewChannel);fflush(stdout);
if(nNewChannel == -1) { // restore orig. bouquet and selected channel on cancel if(nNewChannel == -1) { // restore orig. bouquet and selected channel on cancel
/* FIXME if mode was changed while browsing,
* other modes selected bouquet not restored */
SetChannelMode(old_mode); SetChannelMode(old_mode);
bouquetList->activateBouquet(old_b, false); bouquetList->activateBouquet(old_b, false);
if(bouquetList->Bouquets.size()) if(bouquetList->Bouquets.size())
bouquetList->Bouquets[old_b]->channelList->setSelected(old_num-1); bouquetList->Bouquets[old_b]->channelList->setSelected(old_num);
StartSubtitles(mode == mode_tv); StartSubtitles(mode == mode_tv);
} }
else if(nNewChannel == -3) { // list mode changed else if(nNewChannel == -3) { // list mode changed
@@ -3938,11 +3947,15 @@ void CNeutrinoApp::StartSubtitles(bool show)
void CNeutrinoApp::SelectSubtitles() void CNeutrinoApp::SelectSubtitles()
{ {
if(!g_settings.auto_subs) #if 0
return;
int curnum = channelList->getActiveChannelNumber(); int curnum = channelList->getActiveChannelNumber();
CZapitChannel * cc = channelList->getChannel(curnum); CZapitChannel * cc = channelList->getChannel(curnum);
#endif
/* called on NeutrinoMessages::EVT_ZAP_COMPLETE, should be safe to use zapit current channel */
CZapitChannel * cc = CZapit::getInstance()->GetCurrentChannel();
if(!g_settings.auto_subs || cc == NULL)
return;
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
if(strlen(g_settings.pref_subs[i]) == 0) if(strlen(g_settings.pref_subs[i]) == 0)