mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-03 10:51:05 +02:00
CServiceManager: add services_changed flag, save services from CZapit if changed
Origin commit data
------------------
Commit: bee30ec491
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-03-22 (Thu, 22 Mar 2012)
This commit is contained in:
@@ -116,6 +116,7 @@ class CServiceManager
|
|||||||
bool have_numbers;
|
bool have_numbers;
|
||||||
service_number_map_t tv_numbers;
|
service_number_map_t tv_numbers;
|
||||||
service_number_map_t radio_numbers;
|
service_number_map_t radio_numbers;
|
||||||
|
bool services_changed;
|
||||||
|
|
||||||
fe_type_t frontendType;
|
fe_type_t frontendType;
|
||||||
satellite_map_t satellitePositions;
|
satellite_map_t satellitePositions;
|
||||||
@@ -143,7 +144,7 @@ class CServiceManager
|
|||||||
|
|
||||||
bool InitSatPosition(t_satellite_position position, char * name = NULL, bool force = false);
|
bool InitSatPosition(t_satellite_position position, char * name = NULL, bool force = false);
|
||||||
bool LoadServices(bool only_current);
|
bool LoadServices(bool only_current);
|
||||||
void SaveServices(bool tocopy);
|
void SaveServices(bool tocopy, bool if_changed = false);
|
||||||
void SaveMotorPositions();
|
void SaveMotorPositions();
|
||||||
bool SaveCurrentServices(transponder_id_t tpid);
|
bool SaveCurrentServices(transponder_id_t tpid);
|
||||||
|
|
||||||
|
@@ -44,6 +44,7 @@ CServiceManager::CServiceManager()
|
|||||||
{
|
{
|
||||||
scanInputParser = NULL;
|
scanInputParser = NULL;
|
||||||
service_count = 0;
|
service_count = 0;
|
||||||
|
services_changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CServiceManager::~CServiceManager()
|
CServiceManager::~CServiceManager()
|
||||||
@@ -391,7 +392,6 @@ void CServiceManager::ParseChannels(xmlNodePtr node, const t_transport_stream_id
|
|||||||
satellitePosition,
|
satellitePosition,
|
||||||
freq);
|
freq);
|
||||||
|
|
||||||
bool ret = AddChannel(channel);
|
|
||||||
if(number) {
|
if(number) {
|
||||||
have_numbers = true;
|
have_numbers = true;
|
||||||
service_number_map_t::iterator it = channel_numbers->find(number);
|
service_number_map_t::iterator it = channel_numbers->find(number);
|
||||||
@@ -403,6 +403,7 @@ void CServiceManager::ParseChannels(xmlNodePtr node, const t_transport_stream_id
|
|||||||
channel_numbers->insert(number);
|
channel_numbers->insert(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ret = AddChannel(channel);
|
||||||
//printf("INS CHANNEL %s %x\n", name.c_str(), (int) &ret.first->second);
|
//printf("INS CHANNEL %s %x\n", name.c_str(), (int) &ret.first->second);
|
||||||
if(ret == false) {
|
if(ret == false) {
|
||||||
printf("[zapit] duplicate channel %s id %llx freq %d (old %s at %d)\n",
|
printf("[zapit] duplicate channel %s id %llx freq %d (old %s at %d)\n",
|
||||||
@@ -680,8 +681,10 @@ do_current:
|
|||||||
FindTransponder(xmlDocGetRootElement(parser)->xmlChildrenNode);
|
FindTransponder(xmlDocGetRootElement(parser)->xmlChildrenNode);
|
||||||
xmlFreeDoc(parser);
|
xmlFreeDoc(parser);
|
||||||
unlink(CURRENTSERVICES_XML);
|
unlink(CURRENTSERVICES_XML);
|
||||||
if(newfound)
|
if(newfound) {
|
||||||
SaveServices(true);
|
//SaveServices(true);
|
||||||
|
services_changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!only_current) {
|
if(!only_current) {
|
||||||
@@ -691,6 +694,8 @@ do_current:
|
|||||||
xmlFreeDoc(parser);
|
xmlFreeDoc(parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!have_numbers)
|
||||||
|
services_changed = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -744,41 +749,33 @@ void CServiceManager::WriteTransponderHeader(FILE * fd, struct transponder &tp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServiceManager::SaveServices(bool tocopy)
|
void CServiceManager::SaveServices(bool tocopy, bool if_changed)
|
||||||
{
|
{
|
||||||
transponder_id_t tpid = 0;
|
|
||||||
FILE * fd = 0;
|
|
||||||
bool updated = 0;
|
|
||||||
|
|
||||||
channel_map_iterator_t ccI;
|
|
||||||
channel_map_iterator_t dI;
|
|
||||||
transponder_list_t::iterator tI;
|
|
||||||
bool tpdone = 0;
|
|
||||||
bool satdone = 0;
|
|
||||||
int processed = 0;
|
int processed = 0;
|
||||||
sat_iterator_t spos_it;
|
|
||||||
updated = 0;
|
if(if_changed && !services_changed)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef SAVE_DEBUG
|
#ifdef SAVE_DEBUG
|
||||||
set<t_channel_id> chans_processed;
|
set<t_channel_id> chans_processed;
|
||||||
DBG("\nChannel size: %d\n", sizeof(CZapitChannel));
|
|
||||||
#endif
|
#endif
|
||||||
printf("total channels: %d\n", allchans.size());
|
printf("CServiceManager::SaveServices: total channels: %d\n", allchans.size());
|
||||||
fd = fopen(SERVICES_TMP, "w");
|
FILE * fd = fopen(SERVICES_TMP, "w");
|
||||||
if(!fd) {
|
if(!fd) {
|
||||||
perror(SERVICES_TMP);
|
perror(SERVICES_TMP);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(fd, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zapit api=\"3\">\n");
|
fprintf(fd, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zapit api=\"3\">\n");
|
||||||
for (spos_it = satellitePositions.begin(); spos_it != satellitePositions.end(); ++spos_it) {
|
for (sat_iterator_t spos_it = satellitePositions.begin(); spos_it != satellitePositions.end(); ++spos_it) {
|
||||||
satdone = 0;
|
bool satdone = 0;
|
||||||
#ifdef SAVE_DEBUG
|
#ifdef SAVE_DEBUG
|
||||||
printf("Process sat: %s\n", spos_it->second.name.c_str());
|
printf("Process sat: %s\n", spos_it->second.name.c_str());
|
||||||
printf("processed channels: %d\n", chans_processed.size());
|
printf("processed channels: %d\n", chans_processed.size());
|
||||||
printf("tp count: %d\n", transponders.size());
|
printf("tp count: %d\n", transponders.size());
|
||||||
#endif
|
#endif
|
||||||
for(tI = transponders.begin(); tI != transponders.end(); ++tI) {
|
for(transponder_list_t::iterator tI = transponders.begin(); tI != transponders.end(); ++tI) {
|
||||||
t_satellite_position satpos = GET_SATELLITEPOSITION_FROM_TRANSPONDER_ID(tI->first) & 0xFFF;
|
t_satellite_position satpos = GET_SATELLITEPOSITION_FROM_TRANSPONDER_ID(tI->first) & 0xFFF;
|
||||||
tpdone = 0;
|
bool tpdone = 0;
|
||||||
if(GET_SATELLITEPOSITION_FROM_TRANSPONDER_ID(tI->first) & 0xF000)
|
if(GET_SATELLITEPOSITION_FROM_TRANSPONDER_ID(tI->first) & 0xF000)
|
||||||
satpos = -satpos;
|
satpos = -satpos;
|
||||||
|
|
||||||
@@ -788,9 +785,8 @@ void CServiceManager::SaveServices(bool tocopy)
|
|||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tpid = tI->first;
|
for (channel_map_iterator_t ccI = allchans.begin(); ccI != allchans.end(); ++ccI) {
|
||||||
for (ccI = allchans.begin(); ccI != allchans.end(); ++ccI) {
|
if(ccI->second.getTransponderId() == tI->first) {
|
||||||
if(ccI->second.getTransponderId() == tpid) {
|
|
||||||
if(!satdone) {
|
if(!satdone) {
|
||||||
WriteSatHeader(fd, spos_it->second);
|
WriteSatHeader(fd, spos_it->second);
|
||||||
satdone = 1;
|
satdone = 1;
|
||||||
@@ -836,7 +832,7 @@ void CServiceManager::SaveServices(bool tocopy)
|
|||||||
printf("unused channel %d sat %d freq %d sid %04X: %s\n", ++i, it->second.getSatellitePosition(), it->second.getFreqId(), it->second.getServiceId(), it->second.getName().c_str());
|
printf("unused channel %d sat %d freq %d sid %04X: %s\n", ++i, it->second.getSatellitePosition(), it->second.getFreqId(), it->second.getServiceId(), it->second.getName().c_str());
|
||||||
chans_processed.clear();
|
chans_processed.clear();
|
||||||
#endif
|
#endif
|
||||||
printf("processed channels: %d\n", processed);
|
printf("CServiceManager::SaveServices: processed channels: %d\n", processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* helper for reused code */
|
/* helper for reused code */
|
||||||
|
@@ -707,6 +707,8 @@ bool CZapit::PrepareChannels()
|
|||||||
|
|
||||||
INFO("LoadServices: success");
|
INFO("LoadServices: success");
|
||||||
g_bouquetManager->loadBouquets();
|
g_bouquetManager->loadBouquets();
|
||||||
|
/* save if services changed (update from sdt, etc) */
|
||||||
|
CServiceManager::getInstance()->SaveServices(true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user