int bouquet_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile ) { struct timeval tv; int t; int r; int i; int idx=0; int cnum; int x; Channel *ch=NULL; FILE *fp; char line[512]; char l2[512]; char *p; if ( FBInitialize( 720, 576, 8, fdfb ) < 0 ) return -1; setup_colors(); if ( RcInitialize( fdrc ) < 0 ) return -1; /* load setup */ fp = fopen( CONFIGDIR "/zapit/services.xml", "r" ); if ( !fp ) { FBDrawString( 190, 100, 64, "services.xml not found !", RED, 0 ); #ifdef USEX FBFlushGrafic(); #endif tv.tv_sec = 5; tv.tv_usec = 0; select( 0, 0, 0, 0, &tv ); RcClose(); FBClose(); return 0; } while( fgets(line,512,fp) ) { num_lines++; if ( strstr(line,"channelNR") ) { p=strstr(line,"serviceType"); if ( p && (*(p+15) == '0') ) { p+=16; if ( *p == '1' ) num_ch_tv++; if ( *p == '2' ) num_ch_radio++; if ( *p == '4' ) num_ch_tv++; } } } fclose(fp); lines = (char**)malloc(sizeof(char*)*num_lines); tv_ch = (Channel*)malloc(sizeof(Channel)*num_ch_tv); radio_ch = (Channel*)malloc(sizeof(Channel)*num_ch_radio); for( i=0;i<num_ch_tv;i++) tv_ch[i].flag=0; for( i=0;i<num_ch_radio;i++) radio_ch[i].flag=0; fp = fopen( CONFIGDIR "/zapit/services.xml", "r" ); t=num_ch_tv-1; r=num_ch_radio-1; for(i=0; i<num_lines;i++) { fgets( line, 512, fp ); lines[i] = strdup(line); if ( !strstr(line,"channelNR") ) continue; p=strstr(line,"name="); copyname(l2,p+6); p=strstr(line,"channelNR="); cnum=_atoi(p+11); if ( cnum ) idx=cnum-1; p=strstr(line,"serviceType"); if ( !p || ( *(p+15) != '0' ) ) continue; switch( *(p+16) ) { case '1' : case '4' : ch=tv_ch; if ( !cnum || ch[idx].flag ) { idx=t; t--; } break; case '2' : ch=radio_ch; if ( !cnum || ch[idx].flag ) { idx=r; r--; } break; default: p=0; break; } if ( !p ) continue; ch[idx].name=strdup(l2); ch[idx].flag=*(p+14); ch[idx].line=lines[i]; } fclose(fp); t=0; while( doexit != 3 ) { if ( t ) SortBouquet( radio_ch, num_ch_radio ); else SortBouquet( tv_ch, num_ch_tv ); t=!t; switch( doexit ) { case 2 : doexit=0; break; case 1 : SaveServices(); doexit=3; break; } } for( i=0; i<num_ch_tv; i++ ) free( tv_ch[i].name ); for( i=0; i<num_ch_radio; i++ ) free( radio_ch[i].name ); for( i=0; i<num_lines; i++ ) free( lines[i] ); free( lines ); free( tv_ch ); free( radio_ch ); /* fx2 */ /* buffer leeren, damit neutrino nicht rumspinnt */ realcode = RC_0; while( realcode != 0xee ) { tv.tv_sec = 0; tv.tv_usec = 300000; x = select( 0, 0, 0, 0, &tv ); /* 300ms pause */ RcGetActCode( ); } RcClose(); FBClose(); return 0; }
// 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; }