void CBouquetManager::makeRemainingChannelsBouquet(void) { ZapitChannelList unusedChannels; set<t_channel_id> chans_processed; bool tomake = config.getBool("makeRemainingChannelsBouquet", true); for (tallchans::iterator it = allchans.begin(); it != allchans.end(); it++) it->second.number = 0; int i = 1, j = 1; for (vector<CZapitBouquet*>::const_iterator it = Bouquets.begin(); it != Bouquets.end(); it++) { for (vector<CZapitChannel*>::iterator jt = (*it)->tvChannels.begin(); jt != (*it)->tvChannels.end(); jt++) { if(tomake) chans_processed.insert((*jt)->getChannelID()); if(!(*jt)->number) (*jt)->number = i++; if(!(*jt)->pname && !(*it)->bUser) (*jt)->pname = (char *) (*it)->Name.c_str(); } for (vector<CZapitChannel*>::iterator jt = (*it) ->radioChannels.begin(); jt != (*it)->radioChannels.end(); jt++) { if(tomake) chans_processed.insert((*jt)->getChannelID()); if(!(*jt)->number) (*jt)->number = j++; if(!(*jt)->pname && !(*it)->bUser) (*jt)->pname = (char *) (*it)->Name.c_str(); } } if(!tomake) return; // TODO: use locales remainChannels = addBouquet((Bouquets.size() == 0) ? "All Channels" : "Other", false); // UTF-8 encoded for (tallchans::iterator it = allchans.begin(); it != allchans.end(); it++) if (chans_processed.find(it->first) == chans_processed.end()) unusedChannels.push_back(&(it->second)); sort(unusedChannels.begin(), unusedChannels.end(), CmpChannelByChName()); for (ZapitChannelList::const_iterator it = unusedChannels.begin(); it != unusedChannels.end(); it++) { remainChannels->addService(findChannelByChannelID((*it)->getChannelID())); } if ((remainChannels->tvChannels.empty()) && (remainChannels->radioChannels.empty())) { deleteBouquet(remainChannels); remainChannels = NULL; return; } for (vector<CZapitChannel*>::iterator jt = remainChannels->tvChannels.begin(); jt != remainChannels->tvChannels.end(); jt++) if(!(*jt)->number) (*jt)->number = i++; for (vector<CZapitChannel*>::iterator jt = remainChannels->radioChannels.begin(); jt != remainChannels->radioChannels.end(); jt++) if(!(*jt)->number) (*jt)->number = j++; }
void CBouquetManager::saveBouquets(bool includeBouquetOthers) { FILE * bouq_fd; bool write_names = config.getBool("writeChannelsNames", true); unsigned int string_number = (strcmp(getFrontendName(), "sat") == 0) ? 1 : 0; const char * channel_printf_string = write_names ? printf_string_with_names[string_number] : printf_string_without_names[string_number]; if (includeBouquetOthers) makeRemainingChannelsBouquet(); bouq_fd = fopen(BOUQUETS_XML, "w"); fprintf(bouq_fd, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zapit>\n"); for (BouquetList::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { // TODO: use locales if (includeBouquetOthers || (((*it) != remainChannels) && (strncmp((*it)->Name.c_str(),"Neue Sender",11) != 0))) { //fprintf(bouq_fd, "\t<Bouquet name=\"%s\" hidden=\"%d\" locked=\"%d\">\n", fprintf(bouq_fd, "\t<Bouquet type=\"%01x\" bouquet_id=\"%04x\" name=\"%s\" hidden=\"%01x\" locked=\"%01x\">\n", (*it)->type, (*it)->bouquet_id, convert_UTF8_To_UTF8_XML((*it)->Name.c_str()).c_str(), (*it)->bHidden ? 1 : 0, (*it)->bLocked ? 1 : 0); writeChannelList(bouq_fd, (*it)->tvChannels , write_names, channel_printf_string); writeChannelList(bouq_fd, (*it)->radioChannels, write_names, channel_printf_string); fprintf(bouq_fd, "\t</Bouquet>\n"); } } fprintf(bouq_fd, "</zapit>\n"); fclose(bouq_fd); chmod(BOUQUETS_XML, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); }
void CBouquetManager::parseBouquetsXml(const xmlNodePtr root) { extern CConfigFile config; bool channel_names_from_bouquet = config.getBool("ChannelNamesFromBouquet", false); 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; t_satellite_position satellitePosition; INFO("reading bouquets"); while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { CBouquet *newBouquet; char *name = xmlGetAttribute(search, "name"); int bnum = existsBouquet(name); if (bnum != -1) newBouquet = Bouquets[bnum]; else { newBouquet = addBouquet(name); char* hidden = xmlGetAttribute(search, "hidden"); char* locked = xmlGetAttribute(search, "locked"); newBouquet->type = xmlGetNumericAttribute(search, "type", 16); newBouquet->bouquet_id = xmlGetNumericAttribute(search, "bouquet_id", 16); newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; bnum = Bouquets.size() - 1; } channel_node = search->xmlChildrenNode; while ((channel_node = xmlGetNextOccurence(channel_node, "channel")) != NULL) { GET_ATTR(channel_node, "serviceID", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, "onid", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, "sat", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, "tsid", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); CZapitChannel* chan = findChannelByChannelID(CREATE_CHANNEL_ID); if (chan != NULL) { if (channel_names_from_bouquet) chan->setName(xmlGetAttribute(channel_node, "name")); if (existsChannelInBouquet(bnum, CREATE_CHANNEL_ID)) { DBG("b %d '%s' ch %012llx sat %3d name '%s' exists, not added", bnum, name, CREATE_CHANNEL_ID, satellitePosition, chan->getName().c_str()); } else newBouquet->addService(chan); } channel_node = channel_node->xmlNextNode; } search = search->xmlNextNode; } INFO("found %d bouquets", Bouquets.size()); } }
//----------------------------------------------------------------------------- // Read Webserver Configurationfile // Call "Hooks_ReadConfig" so Hooks can read/write own Configuration Values //----------------------------------------------------------------------------- void Cyhttpd::ReadConfig(void) { log_level_printf(3, "ReadConfig Start\n"); CConfigFile *Config = new CConfigFile(','); bool have_config = false; if (access(HTTPD_CONFIGFILE, R_OK) == 0) have_config = true; Config->loadConfig(HTTPD_CONFIGFILE); // convert old config files if (have_config) { if (Config->getInt32("configfile.version", 0) == 0) { CConfigFile OrgConfig = *Config; Config->clear(); Config->setInt32("server.log.loglevel", OrgConfig.getInt32( "LogLevel", 0)); Config->setInt32("configfile.version", CONF_VERSION); Config->setString("webserver.websites", "WebsiteMain"); Config->setBool("webserver.threading", OrgConfig.getBool("THREADS", true)); Config->setInt32("WebsiteMain.port", OrgConfig.getInt32("Port", HTTPD_STANDARD_PORT)); Config->setString("WebsiteMain.directory", OrgConfig.getString( "PrivatDocRoot", PRIVATEDOCUMENTROOT)); if (!OrgConfig.getString("PublicDocRoot", "").empty()) Config->setString("WebsiteMain.override_directory", OrgConfig.getString("PublicDocRoot", PRIVATEDOCUMENTROOT)); // mod_auth Config->setString("mod_auth.username", OrgConfig.getString( "AuthUser", AUTHUSER)); Config->setString("mod_auth.password", OrgConfig.getString( "AuthPassword", AUTHPASSWORD)); Config->setString("mod_auth.no_auth_client", OrgConfig.getString( "NoAuthClient", "")); Config->setString("mod_auth.authenticate", OrgConfig.getString( "Authenticate", "false")); Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT); Config->saveConfig(HTTPD_CONFIGFILE); } // Add Defaults for Version 2 if (Config->getInt32("configfile.version") < 2) { Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT); Config->setInt32("configfile.version", CONF_VERSION); Config->setString("mod_sendfile.sendAll", "false"); Config->saveConfig(HTTPD_CONFIGFILE); } // Add Defaults for Version 4 if (Config->getInt32("configfile.version") < 4) { Config->setInt32("configfile.version", CONF_VERSION); Config->setString("Language.selected", HTTPD_DEFAULT_LANGUAGE); Config->setString("Language.directory", HTTPD_LANGUAGEDIR); if (Config->getString("WebsiteMain.hosted_directory", "").empty()) Config->setString("WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); Config->saveConfig(HTTPD_CONFIGFILE); } } // configure debugging & logging if (CLogging::getInstance()->LogLevel == 0) CLogging::getInstance()->LogLevel = Config->getInt32("server.log.loglevel", 0); if (CLogging::getInstance()->LogLevel > 0) CLogging::getInstance()->setDebug(true); // get variables webserver->init(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT), Config->getBool("webserver.threading", true)); // informational use ConfigList["WebsiteMain.port"] = itoa(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT)); ConfigList["webserver.threading"] = Config->getString( "webserver.threading", "true"); ConfigList["configfile.version"] = Config->getInt32("configfile.version", CONF_VERSION); ConfigList["server.log.loglevel"] = itoa(Config->getInt32( "server.log.loglevel", 0)); ConfigList["server.no_keep-alive_ips"] = Config->getString( "server.no_keep-alive_ips", ""); webserver->conf_no_keep_alive_ips = Config->getStringVector( "server.no_keep-alive_ips"); // MainSite ConfigList["WebsiteMain.directory"] = Config->getString( "WebsiteMain.directory", PRIVATEDOCUMENTROOT); ConfigList["WebsiteMain.override_directory"] = Config->getString( "WebsiteMain.override_directory", PUBLICDOCUMENTROOT); ConfigList["WebsiteMain.hosted_directory"] = Config->getString( "WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); ConfigList["Tuxbox.DisplayLogos"] = Config->getString("Tuxbox.DisplayLogos", "true"); // Check location of logos if (Config->getString("Tuxbox.LogosURL", "").empty()) { if (access(ConfigList["WebsiteMain.override_directory"] + "/logos", R_OK) == 0) { Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.override_directory"] + "/logos"); have_config = false; //save config } else if (access(ConfigList["WebsiteMain.directory"] + "/logos", R_OK) == 0){ Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.directory"] + "/logos"); have_config = false; //save config } #ifdef Y_CONFIG_USE_HOSTEDWEB else if (access(ConfigList["WebsiteMain.hosted_directory"] + "/logos", R_OK) == 0){ Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.hosted_directory"] + "/logos"); have_config = false; //save config } #endif //Y_CONFIG_USE_HOSTEDWEB } ConfigList["Tuxbox.LogosURL"] = Config->getString("Tuxbox.LogosURL", ""); #ifdef Y_CONFIG_USE_OPEN_SSL ConfigList["SSL"] = Config->getString("WebsiteMain.ssl", "false"); ConfigList["SSL_pemfile"] = Config->getString("WebsiteMain.ssl_pemfile", SSL_PEMFILE); ConfigList["SSL_CA_file"] = Config->getString("WebsiteMain.ssl_ca_file", SSL_CA_FILE); CySocket::SSL_pemfile = ConfigList["SSL_pemfile"]; CySocket::SSL_CA_file = ConfigList["SSL_CA_file"]; if(ConfigList["SSL"] == "true") CySocket::initSSL(); #endif ConfigList["server.user_name"] = Config->getString("server.user_name", ""); ConfigList["server.group_name"] = Config->getString("server.group_name", ""); ConfigList["server.chroot"] = Config->getString("server.chroot", ""); // language ConfigList["Language.directory"] = Config->getString("Language.directory", HTTPD_LANGUAGEDIR); ConfigList["Language.selected"] = Config->getString("Language.selected", HTTPD_DEFAULT_LANGUAGE); yhttpd->ReadLanguage(); // Read App specifig settings by Hook CyhookHandler::Hooks_ReadConfig(Config, ConfigList); // Save if new defaults are set if (!have_config) Config->saveConfig(HTTPD_CONFIGFILE); log_level_printf(3, "ReadConfig End\n"); delete Config; }
//----------------------------------------------------------------------------- // Read Webserver Configurationfile // Call "Hooks_ReadConfig" so Hooks can read/write own Configuration Values //----------------------------------------------------------------------------- void Cyhttpd::ReadConfig(void) { log_level_printf(3,"ReadConfig Start\n"); CConfigFile *Config = new CConfigFile(','); bool have_config = false; if(access(HTTPD_CONFIGFILE,4) == 0) have_config = true; Config->loadConfig(HTTPD_CONFIGFILE); // convert old config files if(have_config) if(Config->getInt32("Port", 0) != 0) { CConfigFile OrgConfig = *Config; Config->clear(); Config->setInt32("server.log.loglevel", OrgConfig.getInt32("LogLevel", 0)); Config->setString("configfile.version", "1"); Config->setString("webserver.websites", "WebsiteMain"); Config->setBool("webserver.threading", OrgConfig.getBool("THREADS", true)); Config->setInt32("WebsiteMain.port",OrgConfig.getInt32("Port", HTTPD_STANDARD_PORT)); Config->setString("WebsiteMain.directory", OrgConfig.getString("PrivatDocRoot", PRIVATEDOCUMENTROOT)); if(OrgConfig.getString("PublicDocRoot", "") != "") Config->setString("WebsiteMain.override_directory", OrgConfig.getString("PublicDocRoot", PRIVATEDOCUMENTROOT)); if(OrgConfig.getString("HostedDocRoot", "") != "") Config->setString("WebsiteMain.special_locations", "/hosted/="+OrgConfig.getString("HostedDocRoot", PRIVATEDOCUMENTROOT)); if(OrgConfig.getString("HostedDocRoot", "") != "") Config->setString("Tuxbox.HostedDocumentRoot", OrgConfig.getString("HostedDocRoot", PRIVATEDOCUMENTROOT)); // mod_auth Config->setString("mod_auth.username", OrgConfig.getString("AuthUser", AUTHUSER)); Config->setString("mod_auth.password", OrgConfig.getString("AuthPassword", AUTHPASSWORD)); Config->setString("mod_auth.no_auth_client", OrgConfig.getString("NoAuthClient", "")); Config->setString("mod_auth.authenticate", OrgConfig.getString("Authenticate", "false")); Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT); Config->saveConfig(HTTPD_CONFIGFILE); } // configure debugging & logging if(CLogging::getInstance()->LogLevel == 0) CLogging::getInstance()->LogLevel = Config->getInt32("server.log.loglevel", 0); // get variables webserver->init(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT), Config->getBool("webserver.threading", true)); // informational use ConfigList["WebsiteMain.port"]= itoa(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT)); ConfigList["webserver.threading"]= Config->getString("webserver.threading", "true"); ConfigList["configfile.version"]= Config->getString("configfile.version", "1"); ConfigList["server.log.loglevel"]= itoa(Config->getInt32("server.log.loglevel", 0)); ConfigList["server.no_keep-alive_ips"]= Config->getString("server.no_keep-alive_ips", ""); webserver->conf_no_keep_alive_ips = Config->getStringVector("server.no_keep-alive_ips"); // MainSite ConfigList["PrivatDocumentRoot"]= Config->getString("WebsiteMain.directory", PRIVATEDOCUMENTROOT); ConfigList["PublicDocumentRoot"]= Config->getString("WebsiteMain.override_directory", PUBLICDOCUMENTROOT); ConfigList["HostedDocumentRoot"]= Config->getString("Tuxbox.HostedDocumentRoot", HOSTEDDOCUMENTROOT); #ifdef Y_CONFIG_USE_OPEN_SSL ConfigList["SSL"] = Config->getString("WebsiteMain.ssl", "false"); ConfigList["SSL_pemfile"] = Config->getString("WebsiteMain.ssl_pemfile", SSL_PEMFILE); ConfigList["SSL_CA_file"] = Config->getString("WebsiteMain.ssl_ca_file", SSL_CA_FILE); CySocket::SSL_pemfile = ConfigList["SSL_pemfile"]; CySocket::SSL_CA_file = ConfigList["SSL_CA_file"]; if(ConfigList["SSL"] == "true") CySocket::initSSL(); #endif ConfigList["server.user_name"]= Config->getString("server.user_name", ""); ConfigList["server.group_name"]= Config->getString("server.group_name", ""); ConfigList["server.chroot"]= Config->getString("server.chroot", ""); // Read App specifig settings by Hook CyhookHandler::Hooks_ReadConfig(Config, ConfigList); // Save if new defaults are set if (!have_config) Config->saveConfig(HTTPD_CONFIGFILE); log_level_printf(3,"ReadConfig End\n"); delete Config; }