// load services int loadServices(bool only_current) { xmlDocPtr parser; scnt = 0; dprintf(DEBUG_NORMAL, "getServices:loadServices:\n"); if(only_current) goto do_current; // parse services.xml parser = parseXmlFile(SERVICES_XML); if (parser != NULL) { xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; while (search) { if (!(strcmp(xmlGetName(search), "sat"))) { // position t_satellite_position position = xmlGetSignedNumericAttribute(search, "position", 10); char * name = xmlGetAttribute(search, "name"); if(satellitePositions.find(position) == satellitePositions.end()) { init_sat(position); satellitePositions[position].name = name; } } // jump to the next node search = search->xmlNextNode; } FindTransponder( xmlDocGetRootElement(parser)->xmlChildrenNode ); xmlFreeDoc(parser); } // load motor position for(int i = 0; i < FrontendCount; i++) { if( getFE(i)->getInfo()->type == FE_QPSK) { loadMotorPositions(); break; } } dprintf(DEBUG_NORMAL, "[zapit] %d services loaded (%d)...\n", scnt, allchans.size()); do_current: dprintf(DEBUG_DEBUG, "loading current services\n"); if (scanSDT && (parser = parseXmlFile(CURRENTSERVICES_XML))) { newfound = 0; dprintf(DEBUG_INFO, "[getservices] " CURRENTSERVICES_XML " found.\n"); FindTransponder( xmlDocGetRootElement(parser)->xmlChildrenNode ); xmlFreeDoc(parser); unlink(CURRENTSERVICES_XML); if(newfound) SaveServices(true); //FIXME for second tuner } if(!only_current) { parser = parseXmlFile(MYSERVICES_XML); if (parser != NULL) { FindTransponder(xmlDocGetRootElement(parser)->xmlChildrenNode); xmlFreeDoc(parser); } } return 0; }
bool CServiceManager::LoadServices(bool only_current) { xmlDocPtr parser; static bool satcleared = 0;//clear only once, because menu is static service_count = 0; printf("[zapit] Loading services, channel size %d ..\n", sizeof(CZapitChannel)); fe_type_t frontendType = CFrontend::getInstance()->getInfo()->type; if(only_current) goto do_current; TIMER_START(); allchans.clear(); transponders.clear(); select_transponders.clear(); fake_tid = fake_nid = 0; if (ParseScanXml()) { t_satellite_position position = 0; if(!satcleared) satellitePositions.clear(); satcleared = 1; xmlNodePtr search = xmlDocGetRootElement(scanInputParser)->xmlChildrenNode; while (search) { if (!(strcmp(xmlGetName(search), "sat"))) { position = xmlGetSignedNumericAttribute(search, "position", 10); char * name = xmlGetAttribute(search, "name"); /* FIXME reuse this */ if(satellitePositions.find(position) == satellitePositions.end()) { InitSatPosition(position); } satellitePositions[position].name = name; } else if(!(strcmp(xmlGetName(search), "cable"))) { char * name = xmlGetAttribute(search, "name"); if(satellitePositions.find(position) == satellitePositions.end()) { InitSatPosition(position); } satellitePositions[position].name = name; } ParseSatTransponders(frontendType, search, position); position++; search = search->xmlNextNode; } } parser = parseXmlFile(SERVICES_XML); if (parser != NULL) { xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; while (search) { if (!(strcmp(xmlGetName(search), "sat"))) { t_satellite_position position = xmlGetSignedNumericAttribute(search, "position", 10); char * name = xmlGetAttribute(search, "name"); if(satellitePositions.find(position) == satellitePositions.end()) { InitSatPosition(position); satellitePositions[position].name = name; } } search = search->xmlNextNode; } FindTransponder(xmlDocGetRootElement(parser)->xmlChildrenNode); xmlFreeDoc(parser); } if(frontendType == FE_QPSK) { LoadMotorPositions(); } printf("[zapit] %d services loaded (%d)...\n", service_count, allchans.size()); TIMER_STOP("[zapit] service loading took"); if(0) { //zapit_debug) {//FIXME sat_iterator_t sit; for(sit = satellitePositions.begin(); sit != satellitePositions.end(); sit++) printf("satelliteName = %s (%d), satellitePosition = %d motor position = %d usals %d\n", sit->second.name.c_str(), sit->second.name.size(), sit->first, sit->second.motor_position, sit->second.use_usals); } do_current: DBG("Loading current..\n"); if (CZapit::getInstance()->scanSDT() && (parser = parseXmlFile(CURRENTSERVICES_XML))) { newfound = 0; printf("[getservices] " CURRENTSERVICES_XML " found.\n"); FindTransponder(xmlDocGetRootElement(parser)->xmlChildrenNode); xmlFreeDoc(parser); unlink(CURRENTSERVICES_XML); if(newfound) SaveServices(true); } if(!only_current) { parser = parseXmlFile(MYSERVICES_XML); if (parser != NULL) { FindTransponder(xmlDocGetRootElement(parser)->xmlChildrenNode); xmlFreeDoc(parser); } } return true; }