void CBouquetManager::loadBouquets(bool ignoreBouquetFile) { xmlDocPtr parser; if (ignoreBouquetFile == false) { parser = parseXmlFile(UBOUQUETS_XML); if (parser != NULL) { INFO("reading " UBOUQUETS_XML); parseBouquetsXml(xmlDocGetRootElement(parser)); xmlFreeDoc(parser); } parser = parseXmlFile(BOUQUETS_XML); if (parser != NULL) { INFO("reading " BOUQUETS_XML); parseBouquetsXml(xmlDocGetRootElement(parser)); xmlFreeDoc(parser); } parser = parseXmlFile(CURRENTSERVICES_XML); if (parser != NULL) { INFO("reading " CURRENTSERVICES_XML); makeBouquetfromCurrentservices(xmlDocGetRootElement(parser)); xmlFreeDoc(parser); } } renumServices(); }
void GettingStartedWelcomePageWidget::updateExamples(const QString &examplePath, const QString &demosPath, const QString &sourcePath) { QString demoXml = demosPath + "/qtdemo/xml/examples.xml"; if (!QFile::exists(demoXml)) { demoXml = sourcePath + "/demos/qtdemo/xml/examples.xml"; if (!QFile::exists(demoXml)) return; } QMenuHash cppSubMenuHash; QMenuHash qmlSubMenuHash; const QString dropDownLabel = tr("Choose an Example..."); QMenu *cppMenu = new QMenu(ui->cppExamplesButton); ui->cppExamplesButton->setMenu(cppMenu); QMenu *qmlMenu = new QMenu(ui->qmlExamplesButton); // let Creator's files take precedence QString localQmlExamplesXml = Core::ICore::instance()->resourcePath()+QLatin1String("/examplebrowser/qmlexamples.xml"); QFile localDescriptions(localQmlExamplesXml); if (localDescriptions.open(QFile::ReadOnly)) { parseXmlFile(&localDescriptions, cppSubMenuHash, qmlSubMenuHash, examplePath, sourcePath); } QFile descriptions(demoXml); if (!descriptions.open(QFile::ReadOnly)) return; ui->cppExamplesButton->setEnabled(true); ui->cppExamplesButton->setText(dropDownLabel); parseXmlFile(&descriptions, cppSubMenuHash, qmlSubMenuHash, examplePath, sourcePath); QList<QMenu*> cppSubMenus = cppSubMenuHash.values(); qSort(cppSubMenus.begin(), cppSubMenus.end(), menuEntryCompare); QList<QMenu*> qmlSubMenus = qmlSubMenuHash.values(); qSort(qmlSubMenus.begin(), qmlSubMenus.end(), menuEntryCompare); foreach (QMenu *menu, cppSubMenus) cppMenu->addMenu(menu); foreach (QMenu *menu, qmlSubMenus) qmlMenu->addMenu(menu); if (!qmlMenu->isEmpty()) { ui->qmlExamplesButton->setMenu(qmlMenu); ui->qmlExamplesButton->setEnabled(true); ui->qmlExamplesButton->setText(dropDownLabel); } }
void deleteOldfileEvents(const char *epgdir) { std::string indexname = std::string(epgdir) + "/index.xml"; xmlDocPtr filter_parser = parseXmlFile(indexname.c_str()); std::string filename; std::string file; if (filter_parser != NULL) { xmlNodePtr filter = xmlDocGetRootElement(filter_parser); filter = xmlChildrenNode(filter); while (filter) { const char * name = xmlGetAttribute(filter, "name"); if(name){ filename=name; file = epgdir; file +="/"; file +=filename; unlink(file.c_str()); filter = xmlNextNode(filter); } } xmlFreeDoc(filter_parser); } }
void readDVBTimeFilter(void) { xmlDocPtr filter_parser = parseXmlFile(dvbtime_filter_dir.c_str()); t_original_network_id onid = 0; t_transport_stream_id tsid = 0; t_service_id sid = 0; if (filter_parser != NULL) { dprintf("Reading DVBTimeFilters\n"); xmlNodePtr filter = xmlDocGetRootElement(filter_parser); filter = xmlChildrenNode(filter); while (filter) { onid = xmlGetNumericAttribute(filter, "onid", 16); tsid = xmlGetNumericAttribute(filter, "tsid", 16); sid = xmlGetNumericAttribute(filter, "serviceID", 16); addNoDVBTimelist(onid, tsid, sid); filter = xmlNextNode(filter); } xmlFreeDoc(filter_parser); } else { dvb_time_update = true; } }
bool readEPGFilter(void) { xmlDocPtr filter_parser = parseXmlFile(epg_filter_dir.c_str()); t_original_network_id onid = 0; t_transport_stream_id tsid = 0; t_service_id sid = 0; if (filter_parser != NULL) { dprintf("Reading EPGFilters\n"); xmlNodePtr filter = xmlDocGetRootElement(filter_parser); if (xmlGetNumericAttribute(filter, "is_whitelist", 10) == 1) epg_filter_is_whitelist = true; if (xmlGetNumericAttribute(filter, "except_current_next", 10) == 1) epg_filter_except_current_next = true; filter = xmlChildrenNode(filter); while (filter) { onid = xmlGetNumericAttribute(filter, "onid", 16); tsid = xmlGetNumericAttribute(filter, "tsid", 16); sid = xmlGetNumericAttribute(filter, "serviceID", 16); if (xmlGetNumericAttribute(filter, "blacklist", 10) == 1) addBlacklist(onid, tsid, sid); else addEPGFilter(onid, tsid, sid); filter = xmlNextNode(filter); } } xmlFreeDoc(filter_parser); return (CurrentEPGFilter != NULL); }
void PhonemeEditorWidget::loadPhonemeFile(unsigned int id, const QString& path) { blockSignals(true); m_entityWorldID = id; m_phonemeFileName = QString(path); if( !m_phonemeFileName.isEmpty() ) { // Open phoneme file QFile file( QDir(GameEngine::soundResourceDirectory()).absoluteFilePath(m_phonemeFileName) ); if (file.open(QIODevice::ReadOnly)) { QString errorMsg; int errorLine, errorColumn; // read phoneme file if (!m_phonemeXml.setContent(&file, &errorMsg, &errorLine, &errorColumn)) setStatusTip(tr("Error in line %1 column %2 when reading phoneme file %3: %4").arg(errorLine).arg(errorColumn).arg(m_phonemeFileName).arg(errorMsg)); else { setStatusTip(""); //make Content visible parseXmlFile(); } file.close(); } else setStatusTip(file.errorString()); } setEnabled(!m_phonemeFileName.isEmpty()); blockSignals(false); }
bool CServiceManager::ParseScanXml(void) { if(scanInputParser) { delete scanInputParser; scanInputParser = NULL; } switch (CFrontend::getInstance()->getInfo()->type) { case FE_QPSK: scanInputParser = parseXmlFile(SATELLITES_XML); break; case FE_QAM: scanInputParser = parseXmlFile(CABLES_XML); break; default: WARN("Unknown type %d", CFrontend::getInstance()->getInfo()->type); return false; } return (scanInputParser != NULL); }
void *insertEventsfromFile(void * data) { set_threadname(__func__); reader_ready=false; std::string indexname; std::string filename; std::string epgname; xmlNodePtr eventfile; int ev_count = 0; if (!data) { reader_ready = true; pthread_exit(NULL); } std::string epg_dir = (char *) data; indexname = epg_dir + "index.xml"; time_t now = time_monotonic_ms(); xmlDocPtr index_parser = parseXmlFile(indexname.c_str()); if (index_parser == NULL) { readEventsFromDir(epg_dir, ev_count); printf("[sectionsd] Reading Information finished after %ld milliseconds (%d events)\n", time_monotonic_ms()-now, ev_count); reader_ready = true; pthread_exit(NULL); } printdate_ms(stdout); printf("[sectionsd] Reading Information from file %s:\n", indexname.c_str()); eventfile = xmlDocGetRootElement(index_parser); eventfile = xmlChildrenNode(eventfile); while (eventfile) { const char * name = xmlGetAttribute(eventfile, "name"); if(name) filename=name; epgname = epg_dir + filename; readEventsFromFile(epgname, ev_count); eventfile = xmlNextNode(eventfile); } xmlFreeDoc(index_parser); printdate_ms(stdout); printf("[sectionsd] Reading Information finished after %ld milliseconds (%d events)\n", time_monotonic_ms()-now, ev_count); reader_ready = true; pthread_exit(NULL); }
void CBouquetManager::loadBouquets(bool ignoreBouquetFile) { xmlDocPtr parser; TIMER_START(); if (ignoreBouquetFile == false) { parser = parseXmlFile(BOUQUETS_XML); if (parser != NULL) { parseBouquetsXml(xmlDocGetRootElement(parser), false); xmlFreeDoc(parser); parser = NULL; } sortBouquets(); } parser = parseXmlFile(UBOUQUETS_XML); if (parser != NULL) { parseBouquetsXml(xmlDocGetRootElement(parser), true); xmlFreeDoc(parser); parser = NULL; } renumServices(); TIMER_STOP("[zapit] bouquet loading took"); }
//returns items for selectable timezones CMenuOptionStringChooser* COsdLangSetup::getTzItems() { xmlDocPtr parser = parseXmlFile("/etc/timezone.xml"); CMenuOptionStringChooser* tzSelect = NULL; if (parser != NULL) { tzSelect = new CMenuOptionStringChooser(LOCALE_MAINSETTINGS_TIMEZONE, &g_settings.timezone, true, tzNotifier, CRCInput::RC_green, NULL, true); tzSelect->setHint("", LOCALE_MENU_HINT_TIMEZONE); xmlNodePtr search = xmlDocGetRootElement(parser); search = xmlChildrenNode(search); bool found = false; while (search) { if (!strcmp(xmlGetName(search), "zone")) { const char* zptr = xmlGetAttribute(search, "zone"); std::string zone; if(zptr) zone = zptr; //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); if (access("/usr/share/zoneinfo/" + zone, R_OK)) printf("[neutrino] timezone file '%s' not installed\n", zone.c_str()); else { const char* ptr = xmlGetAttribute(search, "name"); if(ptr){ std::string name = ptr; tzSelect->addOption(name); found = true; } } } search = xmlNextNode(search); } if (!found) { delete tzSelect; tzSelect = NULL; } xmlFreeDoc(parser); } return tzSelect; }
bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data) { bool found = false; std::string name, zone; printf("CTZChangeNotifier::changeNotify: %s\n", (char *) Data); xmlDocPtr parser = parseXmlFile("/etc/timezone.xml"); if (parser != NULL) { xmlNodePtr search = xmlDocGetRootElement(parser); search = xmlChildrenNode(search); while (search) { if (!strcmp(xmlGetName(search), "zone")) { const char *nptr = xmlGetAttribute(search, "name"); if(nptr) name = nptr; if(g_settings.timezone == name) { const char *zptr = xmlGetAttribute(search, "zone"); if(zptr) zone = zptr; if (!access("/usr/share/zoneinfo/" + zone, R_OK)) found = true; break; } } search = xmlNextNode(search); } xmlFreeDoc(parser); } if(found) { printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); std::string cmd = "/usr/share/zoneinfo/" + zone; printf("symlink %s to /etc/localtime\n", cmd.c_str()); if (unlink("/etc/localtime")) perror("unlink failed"); if (symlink(cmd.c_str(), "/etc/localtime")) perror("symlink failed"); #if 0 cmd = ":" + zone; setenv("TZ", cmd.c_str(), 1); #endif tzset(); } return false; }
// TZ notifier bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data) { bool found = false; std::string name, zone; dprintf(DEBUG_NORMAL, "CTZChangeNotifier::changeNotify: %s\n", (char *) Data); xmlDocPtr parser = parseXmlFile("/etc/timezone.xml"); if (parser != NULL) { xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; while (search) { if (!strcmp(xmlGetName(search), "zone")) { name = xmlGetAttribute(search, (char *) "name"); zone = xmlGetAttribute(search, (char *) "zone"); if(!strcmp(g_settings.timezone, name.c_str())) { found = true; break; } } search = search->xmlNextNode; } xmlFreeDoc(parser); } if(found) { dprintf(DEBUG_NORMAL, "CTZChangeNotifier::changeNotify: Timezone: %s -> %s\n", name.c_str(), zone.c_str()); std::string cmd = "ln -sf /usr/share/zoneinfo/" + zone + " /etc/localtime"; dprintf(DEBUG_NORMAL, "exec %s\n", cmd.c_str()); system(cmd.c_str()); tzset(); } return true; }
//returns items for selectable timezones CMenuOptionStringChooser* COsdLangSetup::getTzItems() { xmlDocPtr parser = parseXmlFile("/etc/timezone.xml"); CMenuOptionStringChooser* tzSelect = NULL; if (parser != NULL) { tzSelect = new CMenuOptionStringChooser(LOCALE_MAINSETTINGS_TIMEZONE, g_settings.timezone, true, new CTZChangeNotifier(), CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN, true); xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; bool found = false; while (search) { if (!strcmp(xmlGetName(search), "zone")) { std::string name = xmlGetAttribute(search, "name"); std::string zone = xmlGetAttribute(search, "zone"); //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); if (access(("/usr/share/zoneinfo/" + zone).c_str(), R_OK)) printf("[neutrino] timezone file '%s' not installed\n", zone.c_str()); else { tzSelect->addOption(name.c_str()); found = true; } } search = search->xmlNextNode; } if (!found) { delete tzSelect; tzSelect = NULL; } xmlFreeDoc(parser); } return tzSelect; }
//returns items for selectable timezones CMenuOptionStringChooser* COsdLangSetup::getTzItems() { xmlDocPtr parser = parseXmlFile("/etc/timezone.xml"); CMenuOptionStringChooser* tzSelect = NULL; if (parser != NULL) { tzSelect = new CMenuOptionStringChooser(LOCALE_MAINSETTINGS_TIMEZONE, &g_settings.timezone, true, tzNotifier, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN, true); tzSelect->setHint("", LOCALE_MENU_HINT_TIMEZONE); xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; bool found = false; while (search) { if (!strcmp(xmlGetName(search), "zone")) { std::string name = xmlGetAttribute(search, "name"); // std::string zone = xmlGetAttribute(search, "zone"); //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); tzSelect->addOption(name.c_str()); found = true; } search = search->xmlNextNode; } if (!found) { delete tzSelect; tzSelect = NULL; } xmlFreeDoc(parser); } return tzSelect; }
// 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; }
void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) { xmlDocPtr parser; parser = parseXmlFile(fname); if (parser == NULL) return; xmlNodePtr root = xmlDocGetRootElement(parser); xmlNodePtr search = root->xmlChildrenNode; xmlNodePtr channel_node; if (search) { t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; int16_t satellitePosition; freq_id_t freq = 0; INFO("reading bouquets from %s", fname); while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { char * name = xmlGetAttribute(search, "name"); if(name == NULL) name = const_cast<char*>("Unknown"); CZapitBouquet* newBouquet = addBouquet(name, bUser); char* hidden = xmlGetAttribute(search, "hidden"); char* locked = xmlGetAttribute(search, "locked"); char* scanepg = xmlGetAttribute(search, "epg"); newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; newBouquet->bFav = (strcmp(name, "favorites") == 0); newBouquet->bScanEpg = scanepg ? (strcmp(scanepg, "1") == 0) : false; channel_node = search->xmlChildrenNode; while ((channel_node = xmlGetNextOccurence(channel_node, "S")) != NULL) { std::string name2 = xmlGetAttribute(channel_node, "n"); char *url = xmlGetAttribute(channel_node, "u"); GET_ATTR(channel_node, "i", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, "t", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); GET_ATTR(channel_node, "frq", SCANF_SATELLITE_POSITION_TYPE, freq); if(freq > 20000) freq = freq/1000; CZapitChannel* chan; t_channel_id chid = create_channel_id64(service_id, original_network_id, transport_stream_id, satellitePosition, freq, url); /* FIXME to load old cable settings with new cable "positions" started from 0xF00 */ if(!url && (bUser || CFEManager::getInstance()->cableOnly())) chan = CServiceManager::getInstance()->FindChannelFuzzy(chid, satellitePosition, freq); else chan = CServiceManager::getInstance()->FindChannel(chid); if (chan != NULL) { DBG("%04x %04x %04x %s\n", transport_stream_id, original_network_id, service_id, xmlGetAttribute(channel_node, "n")); #if 0 if(bUser && (name2.length() > 1)) chan->setName(name2); #endif if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); newBouquet->addService(chan); } else if (bUser) { chan = new CZapitChannel(name2, chid, 1 /*service_type*/, satellitePosition, freq); CServiceManager::getInstance()->AddChannel(chan); chan->flags = CZapitChannel::NOT_FOUND; newBouquet->addService(chan); CServiceManager::getInstance()->SetServicesChanged(false); } channel_node = channel_node->xmlNextNode; if(!bUser) { /* set satellite position for provider bouquets. reset position to 0, if position not match - means mixed bouquet */ if (newBouquet->satellitePosition == INVALID_SAT_POSITION) newBouquet->satellitePosition = satellitePosition; else if (newBouquet->satellitePosition != satellitePosition) newBouquet->satellitePosition = 0; } } if(!bUser) newBouquet->sortBouquet(); search = search->xmlNextNode; } INFO("total: %d bouquets", (int)Bouquets.size()); } xmlFreeDoc(parser); }
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; }
bool readEventsFromFile(std::string &epgname, int &ev_count) { xmlDocPtr event_parser = NULL; xmlNodePtr service; xmlNodePtr event; t_original_network_id onid = 0; t_transport_stream_id tsid = 0; t_service_id sid = 0; if (!(event_parser = parseXmlFile(epgname.c_str()))) { dprintf("unable to open %s for reading\n", epgname.c_str()); return false; } service = xmlDocGetRootElement(event_parser); service = xmlChildrenNode(service); while (service) { onid = xmlGetNumericAttribute(service, "original_network_id", 16); tsid = xmlGetNumericAttribute(service, "transport_stream_id", 16); sid = xmlGetNumericAttribute(service, "service_id", 16); event = xmlChildrenNode(service); while (event) { SIevent e(onid,tsid,sid,xmlGetNumericAttribute(event, "id", 16)); uint8_t tid = xmlGetNumericAttribute(event, "tid", 16); std::string contentClassification, userClassification; if(tid) e.table_id = tid; e.table_id |= 0x80; /* make sure on-air data has a lower table_id */ xmlNodePtr node; node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "name"))) { const char *s = xmlGetAttribute(node, "string"); if (s) e.setName(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "text"))) { const char *s = xmlGetAttribute(node, "string"); if (s) e.setText(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "item"))) { #ifdef USE_ITEM_DESCRIPTION const char *s = xmlGetAttribute(node, "string"); if (s) e.item = s; #endif node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "item_description"))) { #ifdef USE_ITEM_DESCRIPTION const char *s = xmlGetAttribute(node, "string"); if (s) e.itemDescription = s; #endif node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "extended_text"))) { const char *l = xmlGetAttribute(node, "lang"); const char *s = xmlGetAttribute(node, "string"); if (l && s) e.appendExtendedText(ZapitTools::UTF8_to_Latin1(l), s); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "time"))) { e.times.insert(SItime(xmlGetNumericAttribute(node, "start_time", 10), xmlGetNumericAttribute(node, "duration", 10))); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "content"))) { const char cl = xmlGetNumericAttribute(node, "class", 16); contentClassification += cl; const char cl2 = xmlGetNumericAttribute(node, "user", 16); userClassification += cl2; node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "component"))) { SIcomponent c; c.streamContent = xmlGetNumericAttribute(node, "stream_content", 16); c.componentType = xmlGetNumericAttribute(node, "type", 16); c.componentTag = xmlGetNumericAttribute(node, "tag", 16); const char *s = xmlGetAttribute(node, "text"); if (s) c.setComponent(s); //e.components.insert(c); e.components.push_back(c); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "parental_rating"))) { const char *s = xmlGetAttribute(node, "country"); if (s) #if 0 e.ratings.insert(SIparentalRating(ZapitTools::UTF8_to_Latin1(s), (unsigned char) xmlGetNumericAttribute(node, "rating", 10))); #endif e.ratings.push_back(SIparentalRating(ZapitTools::UTF8_to_Latin1(s), (unsigned char) xmlGetNumericAttribute(node, "rating", 10))); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "linkage"))) { SIlinkage l; l.linkageType = xmlGetNumericAttribute(node, "type", 16); l.transportStreamId = xmlGetNumericAttribute(node, "transport_stream_id", 16); l.originalNetworkId = xmlGetNumericAttribute(node, "original_network_id", 16); l.serviceId = xmlGetNumericAttribute(node, "service_id", 16); const char *s = xmlGetAttribute(node, "linkage_descriptor"); if (s) l.name = s; e.linkage_descs.insert(e.linkage_descs.end(), l); node = xmlNextNode(node); } if (!contentClassification.empty()) { #ifdef FULL_CONTENT_CLASSIFICATION ssize_t off = e.classifications.reserve(2 * contentClassification.size()); if (off > -1) for (unsigned i = 0; i < contentClassification.size(); i++) off = e.classifications.set(off, contentClassification.at(i), userClassification.at(i)); #else e.classifications.content = contentClassification.at(0); e.classifications.user = userClassification.at(0); #endif } addEvent(e, 0); ev_count++; event = xmlNextNode(event); } service = xmlNextNode(service); } xmlFreeDoc(event_parser); return true; }
void CGeneralSettings::showMenu() { dprintf(DEBUG_NORMAL, "CGeneralSettings::showMenu:\n"); CMenuWidget miscSettingsGeneral(LOCALE_MISCSETTINGS_GENERAL, NEUTRINO_ICON_SETTINGS); // intros miscSettingsGeneral.addItem(new CMenuForwarder(LOCALE_MENU_BACK, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_LEFT)); miscSettingsGeneral.addItem( new CMenuSeparator(CMenuSeparator::LINE) ); // save settings miscSettingsGeneral.addItem(new CMenuForwarder(LOCALE_MAINSETTINGS_SAVESETTINGSNOW, true, NULL, this, "savesettings", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED)); miscSettingsGeneral.addItem( new CMenuSeparator(CMenuSeparator::LINE) ); // rc delay CMenuOptionChooser * m1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL_RCDELAY, &g_settings.shutdown_real_rcdelay, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, !g_settings.shutdown_real); CMiscNotifier * miscNotifier = new CMiscNotifier( m1 ); // shutdown real miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL, &g_settings.shutdown_real, OPTIONS_OFF1_ON0_OPTIONS, OPTIONS_OFF1_ON0_OPTION_COUNT, true, miscNotifier )); // delayed shutdown miscSettingsGeneral.addItem(m1); // delay counter CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, g_settings.shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); miscSettingsGeneral.addItem(new CMenuForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, true, g_settings.shutdown_count, miscSettings_shutdown_count)); // start to standby miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_EXTRA_STARTSTANDBY, &g_settings.power_standby, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); // sig/snr miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_INFOBAR_SAT_DISPLAY, &g_settings.infobar_sat_display, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); // radio text miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_INFOBAR_RADIOTEXT, &g_settings.radiotext_enable, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this )); // logos dir miscSettingsGeneral.addItem( new CMenuForwarder(LOCALE_MISCSETTINGS_LOGOSDIR, true, g_settings.logos_dir, this, "logos_dir" ) ); // epgplus logos miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPGPLUS_SHOW_LOGOS, &g_settings.epgplus_show_logo, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true )); // infobar show channelname miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_INFOBAR_SHOW_CHANNELNAME, &g_settings.show_channelname, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true )); // recording screenshot miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_RECORDING_SCREENSHOT, &g_settings.recording_screenshot, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true )); // subchan pos miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_INFOVIEWER_SUBCHAN_DISP_POS, &g_settings.infobar_subchan_disp_pos, INFOBAR_SUBCHAN_DISP_POS_OPTIONS, INFOBAR_SUBCHAN_DISP_POS_OPTIONS_COUNT, true, NULL, CRCInput::RC_nokey, "", true)); // volumebar position miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_EXTRA_VOLUME_POS, &g_settings.volume_pos, VOLUMEBAR_DISP_POS_OPTIONS, VOLUMEBAR_DISP_POS_OPTIONS_COUNT, true, NULL, CRCInput::RC_nokey, "", true )); // corners miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_EXTRA_ROUNDED_CORNERS, &g_settings.rounded_corners, MENU_CORNERSETTINGS_TYPE_OPTIONS, MENU_CORNERSETTINGS_TYPE_OPTION_COUNT, true)); // head gradient miscSettingsGeneral.addItem(new CMenuOptionChooser("Head Color Gradient", &g_settings.menu_Head_gradient, COLOR_GRADIENT_TYPE_OPTIONS, COLOR_GRADIENT_TYPE_OPTION_COUNT, true, NULL, CRCInput::RC_nokey, "", true )); // foot gradient miscSettingsGeneral.addItem(new CMenuOptionChooser("Foot Color Gradient", &g_settings.menu_Foot_gradient, COLOR_GRADIENT_TYPE_OPTIONS, COLOR_GRADIENT_TYPE_OPTION_COUNT, true, NULL, CRCInput::RC_nokey, "", true )); // menu design miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_EXTRA_MENU_DESIGN, &g_settings.menu_design, MENU_DESIGN_OPTIONS, MENU_DESIGN_OPTION_COUNT, true)); // menu position miscSettingsGeneral.addItem(new CMenuOptionChooser(LOCALE_EXTRA_MENU_POSITION, &g_settings.menu_position, MENU_POSITION_OPTIONS, MENU_POSITION_OPTION_COUNT, true)); // progressbar color miscSettingsGeneral.addItem(new CMenuOptionChooser("ProgressBar Color", &g_settings.progressbar_color, PROGRESSBAR_COLOR_OPTIONS, PROGRESSBAR_COLOR_OPTION_COUNT, true)); // volume bar steps CStringInput * audio_step = new CStringInput(LOCALE_AUDIOMENU_VOLUMEBAR_AUDIOSTEPS,g_settings.audio_step, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 " ); CMenuForwarder *as = new CMenuForwarder(LOCALE_AUDIOMENU_VOLUMEBAR_AUDIOSTEPS, true, g_settings.audio_step, audio_step ); miscSettingsGeneral.addItem(as); // timezone xmlDocPtr parser; parser = parseXmlFile("/etc/timezone.xml"); if (parser != NULL) { tzSelect = new CMenuOptionStringChooser(LOCALE_MAINSETTINGS_TIMEZONE, g_settings.timezone, true, new CTZChangeNotifier(), CRCInput::RC_nokey, "", true); xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; bool found = false; while (search) { if (!strcmp(xmlGetName(search), "zone")) { std::string name = xmlGetAttribute(search, (char *) "name"); std::string zone = xmlGetAttribute(search, (char *) "zone"); //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); tzSelect->addOption(name.c_str()); found = true; } search = search->xmlNextNode; } if(found) miscSettingsGeneral.addItem(tzSelect); else { delete tzSelect; tzSelect = NULL; } xmlFreeDoc(parser); } // reset factory setup miscSettingsGeneral.addItem(new CMenuSeparator(CMenuSeparator::LINE)); CDataResetNotifier * resetNotifier = new CDataResetNotifier(); miscSettingsGeneral.addItem(new CMenuForwarder(LOCALE_MISCSETTINGS_RESET, true, NULL, resetNotifier, "factory", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN )); miscSettingsGeneral.addItem(new CMenuForwarder(LOCALE_SETTINGS_BACKUP, true, NULL, resetNotifier, "backup", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW )); miscSettingsGeneral.addItem(new CMenuForwarder(LOCALE_SETTINGS_RESTORE, true, NULL, resetNotifier, "restore", CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE )); miscSettingsGeneral.exec(NULL, ""); miscSettingsGeneral.hide(); }
// readxml file bool CWebTV::readChannellist(std::string filename) { dprintf(DEBUG_NORMAL, "CWebTV::readChannellist parsing %s\n", filename.c_str()); // clear channellist ClearChannels(); // check for extension int ext_pos = 0; ext_pos = filename.rfind('.'); bool iptv = false; bool webtv = false; bool playlist = false; if( ext_pos > 0) { std::string extension; extension = filename.substr(ext_pos + 1, filename.length() - ext_pos); if( strcasecmp("tv", extension.c_str()) == 0) iptv = true; else if( strcasecmp("m3u", extension.c_str()) == 0) playlist = true; if( strcasecmp("xml", extension.c_str()) == 0) webtv = true; } if(iptv) { FILE * f = fopen(filename.c_str(), "r"); std::string title; std::string URL; std::string url; std::string description; if(f != NULL) { while(1) { char line[1024]; if (!fgets(line, 1024, f)) break; size_t len = strlen(line); if (len < 2) // Lines with less than one char aren't meaningful continue; /* strip newline */ line[--len] = 0; // strip carriage return (when found) if (line[len - 1] == '\r') line[len - 1 ] = 0; if (strncmp(line, "#SERVICE 4097:0:1:0:0:0:0:0:0:0:", 32) == 0) url = line + 32; //else if ( (strncmp(line, "#DESCRIPTION: ", 14) == 0) || (strncmp(line, "#DESCRIPTION ", 13) == 0) ) else if (strncmp(line, "#DESCRIPTION", 12) == 0) { int offs = line[12] == ':' ? 14 : 13; title = line + offs; description = "stream"; addUrl2Playlist(urlDecode(url).c_str(), title.c_str(), description.c_str()); //urlDecode defined in edvbstring.h } } fclose(f); return true; } } else if(webtv) { parser = parseXmlFile(filename.c_str()); if (parser) { xmlNodePtr l0 = NULL; xmlNodePtr l1 = NULL; l0 = xmlDocGetRootElement(parser); l1 = l0->xmlChildrenNode; neutrino_msg_t msg; neutrino_msg_data_t data; CHintBox* hintBox = NULL; hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RELOAD_HINT)); g_RCInput->getMsg(&msg, &data, 0); if (l1) { while ( ((xmlGetNextOccurence(l1, "webtv")) || (xmlGetNextOccurence(l1, "station"))) && msg != CRCInput::RC_home) { char * title; char * url; char * description; // title if(xmlGetNextOccurence(l1, "webtv")) { title = xmlGetAttribute(l1, (char *)"title"); // url url = xmlGetAttribute(l1, (char *)"url"); description = xmlGetAttribute(l1, (char *)"description"); addUrl2Playlist(url, title, description); } else if (xmlGetNextOccurence(l1, "station")) { hintBox->paint(); title = xmlGetAttribute(l1, (char *)"name"); url = xmlGetAttribute(l1, (char *)"url"); description = "stream"; processPlaylistUrl(url, title, description) ; } l1 = l1->xmlNextNode; g_RCInput->getMsg(&msg, &data, 0); } } hintBox->hide(); delete hintBox; hintBox = NULL; return true; } xmlFreeDoc(parser); } else if(playlist) { std::ifstream infile; char cLine[1024]; char name[1024] = { 0 }; int duration; std::string description; infile.open(filename.c_str(), std::ifstream::in); while (infile.good()) { infile.getline(cLine, sizeof(cLine)); // remove CR if(cLine[strlen(cLine) - 1] == '\r') cLine[strlen(cLine) - 1] = 0; sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &duration, name); if(strlen(cLine) > 0 && cLine[0] != '#') { char *url = NULL; if ((url = strstr(cLine, "http://")) || (url = strstr(cLine, "rtmp://")) || (url = strstr(cLine, "rtsp://")) || (url = strstr(cLine, "mmsh://")) ) { if (url != NULL) { description = "stream"; addUrl2Playlist(url, name, description.c_str()); } } } } infile.close(); } return false; }