Ejemplo n.º 1
0
void CBouquetManager::parseBouquetsXml(const xmlNodePtr root, bool bUser)
{
	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");

		while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) {
			char * name = xmlGetAttribute(search, (char *) "name");
			//CZapitBouquet* newBouquet = addBouquet(xmlGetAttribute(search, (char *) "name"), bUser);
			CZapitBouquet* newBouquet = addBouquet(name, bUser);
			char* hidden = xmlGetAttribute(search, (char *) "hidden");
			char* locked = xmlGetAttribute(search, (char *) "locked");
			newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false;
			newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false;
			newBouquet->bFav = (strcmp(name, "favorites") == 0);
			channel_node = search->xmlChildrenNode;
			while ((channel_node = xmlGetNextOccurence(channel_node, "S")) != NULL) {
				std::string  name = xmlGetAttribute(channel_node, (char *) "n");
				GET_ATTR(channel_node, (char *) "i", SCANF_SERVICE_ID_TYPE, service_id);
				GET_ATTR(channel_node, (char *) "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id);
				GET_ATTR(channel_node, (char *) "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition);
				GET_ATTR(channel_node, (char *) "t", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id);
				GET_ATTR(channel_node, (char *) "frq", SCANF_SATELLITE_POSITION_TYPE, freq);
				if(freq > 20000) freq = freq/1000;

				CZapitChannel* chan;

				chan = findChannelByChannelID(CREATE_CHANNEL_ID64);
//printf("Bouquet Channel-ID freq %d pos %d id %llx\n", freq, satellitePosition, CREATE_CHANNEL_ID64);
				if (chan != NULL) {
//printf("found\n");
DBG("%04x %04x %04x %s\n", transport_stream_id, original_network_id, service_id, xmlGetAttribute(channel_node, (char *) "n"));
#if 0
					if(bUser && (name.length() > 1))
						chan->setName(name);
#endif
					if(!bUser)
						chan->pname = (char *) newBouquet->Name.c_str();

					chan->bAlwaysLocked = newBouquet->bLocked;
					newBouquet->addService(chan);
				}

				channel_node = channel_node->xmlNextNode;
			}
			if(!bUser)
				newBouquet->sortBouquet();
			search = search->xmlNextNode;
		}
		INFO("found %d bouquets", Bouquets.size());
	}
}
Ejemplo n.º 2
0
Character *Mystery::parseCharacterNode(xmlNode *node) {

    Character *character = new Character();

    character->name = xmlGetAttribute(node, "name");
    character->male = atoi(xmlGetAttribute(node, "male")) == 1;

    return character;
}
Ejemplo n.º 3
0
POI *Mystery::parsePOINode(xmlNode *node) {

    POI *poi = new POI();

    int x = atoi(xmlGetAttribute(node, "positionX"));
    int y = atoi(xmlGetAttribute(node, "positionY"));
    int interest = atoi(xmlGetAttribute(node, "interest"));

    poi->position = pointMake(x, y);
    poi->interest = (Interest) interest;
    poi->description = xmlGetAttribute(node, "description");
    poi->shortDescription = poi->description;

    if (xmlGetAttribute(node, "shortDescription") != NULL) {
        poi->shortDescription = xmlGetAttribute(node, "shortDescription");
    }

    poi->visualPosition = poi->position;

    if (xmlGetAttribute(node, "visualPositionX") != NULL) {
        int vx = atoi(xmlGetAttribute(node, "visualPositionX"));
        int vy = atoi(xmlGetAttribute(node, "visualPositionY"));
        poi->visualPosition = pointMake(vx, vy);
    }

    poi->contents = NULL;
    poi->searchedByMurderer = false;

    return poi;
}
//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;
}
Ejemplo n.º 5
0
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);
	}
}
std::string cYTFeedParser::getXmlAttr(xmlNodePtr node, const char * attr)
{
	std::string result;
	const char * value = xmlGetAttribute(node, attr);
	if (value)
		result = value;
	return result;
}
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;
}
Ejemplo n.º 8
0
// 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;
}
Ejemplo n.º 9
0
long xmlGetSignedNumericAttribute(const xmlNodePtr node, const char *name, const int base)
{
	const char *ptr = xmlGetAttribute(node, name);

	if (!ptr)
		return 0;

	return strtol(ptr, 0, base);
}
Ejemplo n.º 10
0
//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;
}
Ejemplo n.º 11
0
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);
}
Ejemplo n.º 12
0
void CBouquetManager::makeBouquetfromCurrentservices(const xmlNodePtr root)
{
	xmlNodePtr provider = root->xmlChildrenNode;
	
	// TODO: use locales
	CBouquet* newBouquet = addBouquet("Neue Sender");
			newBouquet->bHidden = false;
			newBouquet->bLocked = false;
			
	t_original_network_id original_network_id;
	t_service_id          service_id;
	t_transport_stream_id transport_stream_id;
	t_satellite_position  satellitePosition;
	
	while (provider) {
		
		xmlNodePtr transponder = provider->xmlChildrenNode;
		
		while (xmlGetNextOccurence(transponder, "transponder") != NULL) {
			
			xmlNodePtr channel_node = transponder->xmlChildrenNode;
			
			while (xmlGetNextOccurence(channel_node, "channel") != NULL) {
				
				if (strncmp(xmlGetAttribute(channel_node, "action"), "remove", 6)) {
					
					GET_ATTR(provider, "position", SCANF_SATELLITE_POSITION_TYPE, satellitePosition);
					GET_ATTR(transponder, "onid", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id);
					GET_ATTR(transponder, "id", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id);
					GET_ATTR(channel_node, "service_id", SCANF_SERVICE_ID_TYPE, service_id);
								
					CZapitChannel* chan = findChannelByChannelID(CREATE_CHANNEL_ID);

					if (chan != NULL)
						newBouquet->addService(chan);
				}
			
				channel_node = channel_node->xmlNextNode;
			}
			transponder = transponder->xmlNextNode;
		}
		provider = provider->xmlNextNode;
	}
}
Ejemplo n.º 13
0
void CServiceManager::FindTransponder(xmlNodePtr search)
{
	t_satellite_position satellitePosition = 0;
	while (search) {
		bool cable = false;

		if (!(strcmp(xmlGetName(search), "cable")))
			cable = true;
		else if ((strcmp(xmlGetName(search), "sat"))) {
			search = search->xmlNextNode;
			continue;
		}

		satellitePosition = xmlGetSignedNumericAttribute(search, "position", 10);
		DBG("going to parse dvb-%c provider %s\n", xmlGetName(search)[0], xmlGetAttribute(search, "name"));
		ParseTransponders(search->xmlChildrenNode, satellitePosition, cable);
		newfound++;
		search = search->xmlNextNode;
	}
}
Ejemplo n.º 14
0
//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;
}
Ejemplo n.º 15
0
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());
	}

}
Ejemplo n.º 16
0
// load transponders
int loadTransponders()
{
	bool satcleared = 0;
	scnt = 0;
	
	t_satellite_position position = 0; //first postion

	dprintf(DEBUG_NORMAL, "getServices:loadTransponders:\n");
	
	select_transponders.clear();
	fake_tid = fake_nid = 0;
	
	if(!satcleared)
		satellitePositions.clear();

	satcleared = 1;

	fe_type_t fe_type = FE_QAM;

	// parse sat tp
	for(int i = 0; i < FrontendCount; i++)
	{
		CFrontend * fe = getFE(i);
		fe_type = fe->getInfo()->type;

		//parseScanInputXml(i);
		parseScanInputXml(fe_type);
			
		if ( scanInputParser != NULL ) 
		{
			xmlNodePtr search = xmlDocGetRootElement(scanInputParser)->xmlChildrenNode;

			while (search) 
			{
				if (!(strcmp(xmlGetName(search), "sat"))) 
				{
					// position
					position = xmlGetSignedNumericAttribute(search, "position", 10);
					
					char * name = xmlGetAttribute(search, "name");

					if(satellitePositions.find(position) == satellitePositions.end()) 
					{
						init_sat(position);
					}

					// name
					satellitePositions[position].name = name;
					
					// type
					satellitePositions[position].type = DVB_S;
				}
				else if(!(strcmp(xmlGetName(search), "cable"))) 
				{
					//flags ???
					//satfeed ???
					
					char * name = xmlGetAttribute(search, "name");

					if(satellitePositions.find(position) == satellitePositions.end()) 
					{
						init_sat(position);
					}

					// name
					satellitePositions[position].name = name;
					
					// type //needed to resort list for scan menue
					satellitePositions[position].type = DVB_C;
				}
				else if(!(strcmp(xmlGetName(search), "terrestrial"))) 
				{
					char * name = xmlGetAttribute(search, "name");

					if(satellitePositions.find(position) == satellitePositions.end()) 
					{
						init_sat(position);
					}

					// name
					satellitePositions[position].name = name;
					
					// type //needed to resort list for scan menue
					satellitePositions[position].type = DVB_T;
				}

				// parse sat TP
				ParseSatTransponders(fe_type, search, position);
				
				position++;
				
				search = search->xmlNextNode;
			}
		}
	}

	// satip
	if(g_settings.satip_allow_satip)
	{
		if(g_settings.satip_serverbox_type == DVB_C)
			fe_type = FE_QAM;
		else if(g_settings.satip_serverbox_type == DVB_S)
			fe_type = FE_QPSK;
		else if(g_settings.satip_serverbox_type == DVB_T)
			fe_type = FE_OFDM;

		parseScanInputXml(fe_type);
			
		if ( scanInputParser != NULL ) 
		{
			xmlNodePtr search = xmlDocGetRootElement(scanInputParser)->xmlChildrenNode;

			while (search) 
			{
				if (!(strcmp(xmlGetName(search), "sat"))) 
				{
					// position
					position = xmlGetSignedNumericAttribute(search, "position", 10);
					
					char * name = xmlGetAttribute(search, "name");

					if(satellitePositions.find(position) == satellitePositions.end()) 
					{
						init_sat(position);
					}

					// name
					satellitePositions[position].name = name;
					
					// type
					satellitePositions[position].type = DVB_S;
				}
				else if(!(strcmp(xmlGetName(search), "cable"))) 
				{
					//flags ???
					//satfeed ???
					
					char * name = xmlGetAttribute(search, "name");

					if(satellitePositions.find(position) == satellitePositions.end()) 
					{
						init_sat(position);
					}

					// name
					satellitePositions[position].name = name;
					
					// type //needed to resort list for scan menue
					satellitePositions[position].type = DVB_C;
				}
				else if(!(strcmp(xmlGetName(search), "terrestrial"))) 
				{
					char * name = xmlGetAttribute(search, "name");

					if(satellitePositions.find(position) == satellitePositions.end()) 
					{
						init_sat(position);
					}

					// name
					satellitePositions[position].name = name;
					
					// type //needed to resort list for scan menue
					satellitePositions[position].type = DVB_T;
				}

				// parse sat TP
				ParseSatTransponders(fe_type, search, position);
				
				position++;
				
				search = search->xmlNextNode;
			}
		}	
	}
	
	return 0;
}	
Ejemplo n.º 17
0
void ParseChannels(xmlNodePtr node, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq, uint8_t polarisation)
{
	t_service_id service_id;
	std::string  name;
	uint8_t      service_type;
	unsigned short vpid, apid, pcrpid, pmtpid, txpid, vtype, scrambled;
	std::string desc = "";
	desc += "Preset";
	t_channel_id chid;
	int dummy;
	int * have_ptr = &dummy;

	sat_iterator_t sit = satellitePositions.find(satellitePosition);

	if(sit != satellitePositions.end())
		have_ptr = &sit->second.have_channels;

	while ((node = xmlGetNextOccurence(node, "S")) != NULL) 
	{
		*have_ptr = 1;
		service_id = xmlGetNumericAttribute(node, "i", 16);
		name = xmlGetAttribute(node, "n");
		service_type = xmlGetNumericAttribute(node, "t", 16);
		vpid = xmlGetNumericAttribute(node, "v", 16);
		apid = xmlGetNumericAttribute(node, "a", 16);
		pcrpid = xmlGetNumericAttribute(node, "p", 16);
		pmtpid = xmlGetNumericAttribute(node, "pmt", 16);
		txpid = xmlGetNumericAttribute(node, "tx", 16);
		vtype = xmlGetNumericAttribute(node, "vt", 16);
		scrambled = xmlGetNumericAttribute(node, "s", 16);

		chid = CREATE_CHANNEL_ID;
		char *ptr = xmlGetAttribute(node, "action");
		bool remove = ptr ? (!strcmp(ptr, "remove") || !strcmp(ptr, "replace")) : false;
		bool add    = ptr ? (!strcmp(ptr, "add")    || !strcmp(ptr, "replace")) : true;

		if (remove) 
		{
			int result = allchans.erase(chid);
			dprintf(DEBUG_INFO, "%s '%s' (sid=0x%x): %s", add ? "replacing" : "removing", name.c_str(), service_id, result ? "succeded.\n" : "FAILED!\n");
		}

		if(!add) 
		{
			node = node->xmlNextNode;
			continue;
		}

		map<t_channel_id, audio_map_set_t>::iterator audio_map_it;
		audio_map_it = audio_map.find(chid);
		
		if((audio_map_it != audio_map.end()) && (audio_map_it->second.apid != 0)) 
		{
			apid = audio_map_it->second.apid;
		}

		pair<map<t_channel_id, CZapitChannel>::iterator, bool> ret;

		ret = allchans.insert (std::pair <t_channel_id, CZapitChannel> (chid, CZapitChannel( name, 
												     service_id, 
												     transport_stream_id,
												     original_network_id, 
												     service_type, 
												     satellitePosition, 
												     freq)));

		if(ret.second == false) 
		{
			dprintf(DEBUG_DEBUG, "getSevices:ParseChannels: duplicate channel %s id %llx freq %d (old %s at %d)\n", name.c_str(), chid, freq, ret.first->second.getName().c_str(), ret.first->second.getFreqId());
		} 
		else 
		{
			scnt++;
			tallchans_iterator cit1 = ret.first;
			cit1->second.scrambled = scrambled;
			service_type = cit1->second.getServiceType();
			cit1->second.polarization = polarisation;

			if(pmtpid != 0 && (((service_type == ST_DIGITAL_RADIO_SOUND_SERVICE) && (apid > 0)) || ( (service_type == ST_DIGITAL_TELEVISION_SERVICE)  && (vpid > 0) && (apid > 0))) ) 
			{			
				cit1->second.setVideoPid(vpid);
				cit1->second.setAudioPid(apid);
				cit1->second.setPcrPid(pcrpid);
				cit1->second.setPmtPid(pmtpid);
				cit1->second.setTeletextPid(txpid);
				cit1->second.setPidsFlag();
				cit1->second.videoType = vtype;
			}
		}

		node = node->xmlNextNode;
	}

	return;
}
std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
{
	xmlNodePtr   root, node, snode;
	std::vector<UPnPEntry> *entries;

	xmlDocPtr parser = parseXml(result.c_str(),"UTF-8");
	root = xmlDocGetRootElement(parser);
	if (!root) {
		xmlFreeDoc(parser);
		return NULL;
	}
	entries = new std::vector<UPnPEntry>;

	for (node=xmlChildrenNode(root); node; node=xmlNextNode(node))
	{
		bool isdir;
		std::string title, artist = "", album = "", albumArtURI = "", id, children;
		const char *type, *p;

		if (!strcmp(xmlGetName(node), "container"))
		{
			std::vector<UPnPResource> resources;
			isdir=true;
			for (snode=xmlChildrenNode(node); snode; snode=xmlNextNode(snode))
			{
				type=xmlGetName(snode);
				p = strchr(type,':');
				if (p)
					type=p+1;
				if (!strcmp(type,"title"))
				{
					p=xmlGetData(snode);
					if (!p)
						p = "";
					title=std::string(p);
				}
			}
			p = xmlGetAttribute(node, "id");
			if (!p)
				p = "";
			id=std::string(p);

			p = xmlGetAttribute(node, "childCount");
			if (!p)
				p = "";
			children=std::string(p);

			UPnPEntry entry={id, isdir, title, artist, album, albumArtURI, children, "", "", resources, -1, CFile::FILE_DIR};
			entries->push_back(entry);
		}
		if (!strcmp(xmlGetName(node), "item"))
		{
			std::vector<UPnPResource> resources;
			int preferred = -1;
			std::string protocol, prot, network, mime, additional;
			CFile::FileType ftype = CFile::FILE_UNKNOWN;
			isdir=false;
			for (snode=xmlChildrenNode(node); snode; snode=xmlNextNode(snode))
			{
				std::string duration, url, size;
				unsigned int i;
				type=xmlGetName(snode);
				p = strchr(type,':');
				if (p)
					type=p+1;

				if (!strcmp(type,"title"))
				{
					p=xmlGetData(snode);
					if (!p)
						p = "";
					title=std::string(p);
				}
				else if (!strcmp(type,"artist"))
				{
					p=xmlGetData(snode);
					if (!p)
						p = "";
					artist=std::string(p);
				}
				else if (!strcmp(type,"album"))
				{
					p=xmlGetData(snode);
					if (!p)
						p = "";
					album=std::string(p);
				}
				else if (!strcmp(type,"albumArtURI"))
				{
					p=xmlGetData(snode);
					if (!p)
						p = "";
					albumArtURI=std::string(p);
				}
				else if (!strcmp(type,"res"))
				{
					p = xmlGetData(snode);
					if (!p)
						p = "";
					url=std::string(p);
					p = xmlGetAttribute(snode, "size");
					if (!p)
						p = "0";
					size=std::string(p);
					p = xmlGetAttribute(snode, "duration");
					if (!p)
						p = "";
					duration=std::string(p);
					p = xmlGetAttribute(snode, "protocolInfo");
					if (!p)
						p = "";
					protocol=std::string(p);
					UPnPResource resource = {url, protocol, size, duration};
					resources.push_back(resource);
				}
				int pref=0;
				preferred=-1;
				for (i=0; i<resources.size(); i++)
				{
					protocol=resources[i].protocol;
					splitProtocol(protocol, prot, network, mime, additional);
					if (prot != "http-get")
						continue;

					if (mime.substr(0,6) == "image/" && pref < 1)
					{
						preferred=i;
					}
					if (mime == "image/jpeg" && pref < 1)
					{
						preferred=i;
						pref=1;
					}
					if (mime == "image/gif" && pref < 2)
					{
						preferred=i;
						pref=2;
					}
					if (mime == "audio/mpeg" && pref < 3)
					{
						preferred=i;
						pref=3;
						ftype = CFile::FILE_MP3;
					}
					if ((mime == "audio/ogg" || mime == "audio/x-ogg") && pref < 4)
					{
						ftype = CFile::FILE_OGG;
						preferred=i;
						pref=4;
					}
					if (mime == "audio/x-flac" && pref < 5)
					{
						preferred=i;
						pref=5;
						ftype = CFile::FILE_FLAC;
					}
					if (mime == "audio/x-wav" && pref < 6)
					{
						preferred=i;
						pref=6;
						ftype = CFile::FILE_WAV;
					}
					if (mime.substr(0,6) == "video/" && pref < 7)
					{
						preferred=i;
						pref=7;
					}
					if (mime == "video/x-flv" && pref < 8)
					{
						preferred=i;
						pref=8;
					}
					if (mime == "video/mp4" && pref < 9)
					{
						preferred=i;
						pref=9;
					}
				}
			}
			p = xmlGetAttribute(node, "id");
			if (!p)
				p = "";
			id=std::string(p);

			p = xmlGetAttribute(node, "childCount");
			if (!p)
				p = "";
			children=std::string(p);

			UPnPEntry entry={id, isdir, title, artist, album, albumArtURI, children, prot, mime, resources, preferred, ftype};
			entries->push_back(entry);
		}
	}
	xmlFreeDoc(parser);
	return entries;
}
Ejemplo n.º 19
0
void CServiceManager::ParseChannels(xmlNodePtr node, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq)
{
	t_service_id service_id;
	std::string  name;
	uint8_t      service_type;
	unsigned short vpid, apid, pcrpid, pmtpid, txpid, vtype, scrambled;
	std::string desc = "";
	desc += "Preset";
	t_channel_id chid;
	int dummy;
	int * have_ptr = &dummy;

	sat_iterator_t sit = satellitePositions.find(satellitePosition);
	if(sit != satellitePositions.end())
		have_ptr = &sit->second.have_channels;

	while ((node = xmlGetNextOccurence(node, "S")) != NULL) {
		*have_ptr = 1;
		service_id = xmlGetNumericAttribute(node, "i", 16);
		name = xmlGetAttribute(node, "n");
		service_type = xmlGetNumericAttribute(node, "t", 16);
		vpid = xmlGetNumericAttribute(node, "v", 16);
		apid = xmlGetNumericAttribute(node, "a", 16);
		pcrpid = xmlGetNumericAttribute(node, "p", 16);
		pmtpid = xmlGetNumericAttribute(node, "pmt", 16);
		txpid = xmlGetNumericAttribute(node, "tx", 16);
		vtype = xmlGetNumericAttribute(node, "vt", 16);
		scrambled = xmlGetNumericAttribute(node, "s", 16);

		chid = CREATE_CHANNEL_ID64;
		char *ptr = xmlGetAttribute(node, "action");
		bool remove = ptr ? (!strcmp(ptr, "remove") || !strcmp(ptr, "replace")) : false;
		bool add    = ptr ? (!strcmp(ptr, "add")    || !strcmp(ptr, "replace")) : true;
		if (remove) {
			int result = allchans.erase(chid);
			printf("[getservices]: %s '%s' (sid=0x%x): %s", add ? "replacing" : "removing",
					name.c_str(), service_id, result ? "succeded.\n" : "FAILED!\n");
		}
		if(!add) {
			node = node->xmlNextNode;
			continue;
		}
		audio_map_set_t * pidmap = CZapit::getInstance()->GetSavedPids(chid);
		if(pidmap)
			apid = pidmap->apid;

		CZapitChannel * channel = new CZapitChannel ( name, service_id,
				transport_stream_id,
				original_network_id,
				service_type,
				satellitePosition,
				freq);

		bool ret = AddChannel(channel);

		//printf("INS CHANNEL %s %x\n", name.c_str(), (int) &ret.first->second);
		if(ret == false) {
			printf("[zapit] duplicate channel %s id %llx freq %d (old %s at %d)\n",
					name.c_str(), chid, freq, channel->getName().c_str(), channel->getFreqId());
		} else {
			service_count++;
			channel->scrambled = scrambled;
			service_type = channel->getServiceType();
			if(pmtpid != 0 && (((service_type == 2) && (apid > 0)) || ( (service_type == 1)  && (vpid > 0) && (apid > 0))) ) {
				DBG("[getserv] preset chan %s vpid %X sid %X tpid %X onid %X\n", name.c_str(), vpid, service_id, transport_stream_id, transport_stream_id);
				channel->setVideoPid(vpid);
				channel->setAudioPid(apid);
				channel->setPcrPid(pcrpid);
				channel->setPmtPid(pmtpid);
				channel->setTeletextPid(txpid);
				channel->setPidsFlag();
				channel->type = vtype;
			}
		}
		node = node->xmlNextNode;
	}
	return;
}
Ejemplo n.º 20
0
Mystery::Mystery(const char *file, unsigned int seed, short *collisionData, int mapWidth, int mapHeight) {

    srand(seed);

    corpseFound = false;
    ended = false;

    this->mapWidth = mapWidth;
    this->mapHeight = mapHeight;
    this->mapData = collisionData;

    Room *firstRoom = NULL;

    xmlDoc *doc = xmlReadFile(file, NULL, 0);

    xmlNode *root = xmlDocGetRootElement(doc);

    std::vector<xmlNode *> roomNodes = xmlGetChildrenForName(root, "room");
    std::vector<xmlNode *>::iterator it;

    for (it = roomNodes.begin(); it < roomNodes.end(); ++it) {

        xmlNode *roomNode = (xmlNode *) *it;

        Room *room = new Room();
        room->name = xmlGetAttribute(roomNode, "name");

        int ox = atoi(xmlGetAttribute(roomNode, "boundsOriginX"));
        int oy = atoi(xmlGetAttribute(roomNode, "boundsOriginY"));
        int w = atoi(xmlGetAttribute(roomNode, "boundsWidth"));
        int h = atoi(xmlGetAttribute(roomNode, "boundsHeight"));

        room->bounds = rectMake(ox, oy, w, h);

        if (xmlGetAttribute(roomNode, "firstRoom") != NULL) {
            firstRoom = room;
        }

        std::vector<xmlNode *> POINodes = xmlGetChildrenForName(roomNode, "pointOfInterest");
        std::vector<xmlNode *>::iterator itPOI;

        for (itPOI = POINodes.begin(); itPOI < POINodes.end(); itPOI++) {

            xmlNode *POInode = (xmlNode *) *itPOI;

            POI *poi = parsePOINode(POInode);
            room->pointsOfInterest.push_back(poi);
        }

        rooms.push_back(room);
    }

    std::vector<xmlNode *> weaponNodes = xmlGetChildrenForName(root, "weapon");

    for (it = weaponNodes.begin(); it < weaponNodes.end(); ++it) {

        xmlNode *weaponNode = (xmlNode *) *it;

        POI *weapon = parsePOINode(weaponNode);

        POI *container;
        Room *room;

        do {

            int idx = rand() % rooms.size();
            room = rooms[idx];

            std::vector<POI *> containers = room->getPointsOfInterest(InterestContainerVisible, false);

            if (containers.size() > 0) {

                idx = rand() % containers.size();
                container = containers[idx];
            } else {
                container = NULL;
            }

        } while (container == NULL || container->contents != NULL);


        container->contents = weapon;
        weapon->position = container->visualPosition;

        if (container->interest == InterestContainerConceiled) {
            weapon->position = pointMake(-20, -20);
        }

        weapons.push_back(weapon);

        printf("%s is in the %s in the %s\n", weapon->description.c_str(), container->description.c_str(), room->name.c_str());
    }

    crimeWeapon = NULL;

    std::vector<xmlNode *> charNodes = xmlGetChildrenForName(root, "character");

    int i = 1;

    for (it = charNodes.begin(); it < charNodes.end(); ++it) {

        xmlNode *charNode = (xmlNode *) *it;

        Character *character = parseCharacterNode(charNode);

        character->tag = i;
        character->interest = (Interest) (rand() % InterestContainerVisible);
        character->position = pointMake(i + 35, 50);
        character->currentRoom = firstRoom;
        character->idle = true;
        character->currentTarget = NULL;
        character->murderTarget = NULL;
        character->carryingWeapon = NULL;
        character->conversationInterval = CONVERSATION_INTERVAL;
        character->dead = false;

        const char *strInt = NULL;

        switch (character->interest) {
        case InterestBooks:
            strInt = "books";
            break;
        case InterestPottery:
            strInt = "pottery";
            break;
        case InterestPaintings:
            strInt = "paintings";
            break;
        default:
            break;
        }

        printf("%s interested in %s\n", character->name.c_str(), strInt);

        characters.push_back(character);

        i++;
    }

    int murderTargetIdx = rand() % characters.size();
    victim = characters[murderTargetIdx];

    printf("*** %s is the murder target! ***\n", victim->name.c_str());

    do {

        int murdererIdx = rand() % characters.size();
        murderer = characters[murdererIdx];

    } while (murderer == victim);

    int weaponInterest = InterestWeaponCutting + rand() % 3;
    murderer->weaponInterest = (Interest) weaponInterest;
    murderer->timeBeforeSearchWeapon = rand() % MAX_DURATION_BEFORE_SEARCH_WEAPON + MIN_DURATION_BEFORE_SEARCH_WEAPON;
    murderer->timeBeforeTryMurder = rand() % MAX_DURATION_BEFORE_TRY_MURDER + MIN_DURATION_BEFORE_TRY_MURDER;

    printf("*** %s is the murderer! ***\n", murderer->name.c_str());
    murderer->murderTarget = victim;

    time = 0;
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
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);
}
Ejemplo n.º 23
0
// 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;
}
Ejemplo n.º 24
0
// scan services.xml
void FindTransponder(xmlNodePtr search)
{
	t_satellite_position satellitePosition = 0;
	uint8_t Source;
	newtpid = 0xC000;
	
	bool have_s = false;
	bool have_c = false;
	bool have_t = false;
	
	// frontend type
	for(int i = 0; i < FrontendCount; i++)
	{
		CFrontend * fe = getFE(i);
		
		if( fe->getDeliverySystem() == DVB_S ) 
			have_s = true;
		if( fe->getDeliverySystem() == DVB_C ) 
			have_c = true;
		if( fe->getDeliverySystem() == DVB_T ) 
			have_t = true;
	}

	// satip
	if(g_settings.satip_allow_satip)
	{
		if(g_settings.satip_serverbox_type == DVB_C)
			have_c = true;
		else if(g_settings.satip_serverbox_type == DVB_S)
			have_s = true;
		else if(g_settings.satip_serverbox_type == DVB_T)
			have_t = true;
	}
	
	
	while (search) 
	{
		if ( !(strcmp(xmlGetName(search), "cable")) && have_c)
		{
			Source = DVB_C;
			
			for (sat_iterator_t spos_it = satellitePositions.begin(); spos_it != satellitePositions.end(); spos_it++) 
			{
				if( !strcmp(spos_it->second.name.c_str(), xmlGetAttribute(search, "name")) ) 
				{
					satellitePosition = spos_it->first;
					break;
				}
			}
			
			dprintf(DEBUG_NORMAL, "getservices:FindTransponder: going to parse dvb-%c provider %s\n", xmlGetName(search)[0], xmlGetAttribute(search, "name"));
		}
		else if ( !(strcmp(xmlGetName(search), "terrestrial")) && have_t)
		{
			Source = DVB_T;
			
			for (sat_iterator_t spos_it = satellitePositions.begin(); spos_it != satellitePositions.end(); spos_it++) 
			{
				if( !strcmp(spos_it->second.name.c_str(), xmlGetAttribute(search, "name")) ) 
				{
					satellitePosition = spos_it->first;
					break;
				}
			}
			
			dprintf(DEBUG_NORMAL, "getservices:FindTransponder: going to parse dvb-%c provider %s\n", xmlGetName(search)[0], xmlGetAttribute(search, "name"));
		}
		else if ( !(strcmp(xmlGetName(search), "sat")) && have_s) 
		{
			Source = DVB_S;
			satellitePosition = xmlGetSignedNumericAttribute(search, "position", 10);
			
			dprintf(DEBUG_NORMAL, "getservices:FindTransponder: going to parse dvb-%c provider %s position %d\n", xmlGetName(search)[0], xmlGetAttribute(search, "name"), satellitePosition);
		}
		else // unknow
		{
			search = search->xmlNextNode;
			continue;
		}
		
		// parse TP
		ParseTransponders(search->xmlChildrenNode, satellitePosition, Source );

		newfound++;
		
		search = search->xmlNextNode;
	}
}
Ejemplo n.º 25
0
bool CFileBrowser::readDir_vlc(const std::string & dirname, CFileList* flist)
{
//	printf("readDir_vlc %s\n",dirname.c_str());
	std::string answer="";
	char *dir_escaped = curl_escape(dirname.substr(strlen(VLC_URI)).c_str(), 0);
	std::string url = m_baseurl;
	url += dir_escaped;
	curl_free(dir_escaped);
	std::cout << "[FileBrowser] vlc URL: " << url << std::endl;
	CURL *curl_handle;
	CURLcode httpres;
	/* init the curl session */
	curl_handle = curl_easy_init();
	/* timeout. 15 seconds should be enough */
	curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 15);
	/* specify URL to get */
	curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
	/* send all data to this function  */
	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, CurlWriteToString);
	/* we pass our 'chunk' struct to the callback function */
	curl_easy_setopt(curl_handle, CURLOPT_FILE, (void *)&answer);
	/* Generate error if http error >= 400 occurs */
	curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
	/* error handling */
	char error[CURL_ERROR_SIZE];
	curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, error);
	/* get it! */
	httpres = curl_easy_perform(curl_handle);
	/* cleanup curl stuff */
	curl_easy_cleanup(curl_handle);

	// std::cout << "Answer:" << std::endl << "----------------" << std::endl << answer << std::endl;
	
	if (!answer.empty() && httpres == 0)
	{
		xmlDocPtr answer_parser = parseXml(answer.c_str());

		if (answer_parser != NULL) {
			xmlNodePtr element = xmlDocGetRootElement(answer_parser);
			element = element->xmlChildrenNode;
			char *ptr;
			if (element == NULL) {
				printf("[FileBrowser] vlc: Drive is not readable. Possibly no disc inserted\n");
				CFile file;
				file.Mode = S_IFDIR + 0777 ;
				file.Name = dirname + "..";
				file.Size = 0;
				file.Time = 0;
				flist->push_back(file);
			} else {
				while (element) {
					CFile file;
					ptr = xmlGetAttribute(element, (char *) "type");
					if (strcmp(ptr, "directory")==0)
						file.Mode = S_IFDIR + 0777 ;
					else
						file.Mode = S_IFREG + 0777 ;

					file.Name = dirname + xmlGetAttribute(element, (char *) "name");
					ptr = xmlGetAttribute(element, (char *) "size");
					if (ptr) 
						file.Size = atoi(ptr);
					else 
						file.Size = 0;
					file.Time = 0;

					element = element->xmlNextNode;
					flist->push_back(file);
				}
			}
			xmlFreeDoc(answer_parser);
			return true;
		}
	}
	
	/* since all CURL error messages use only US-ASCII characters, when can safely print them as if they were UTF-8 encoded */
	if (httpres == 22) {
	    strcat(error, "\nProbably wrong vlc version\nPlease use vlc 0.8.5 or higher");
	}
	DisplayErrorMessage(error); // UTF-8
	CFile file;

	file.Name = dirname + "..";
	file.Mode = S_IFDIR + 0777;
	file.Size = 0;
	file.Time = 0;
	flist->push_back(file);

	return false;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
0
bool CFileBrowser::readDir_sc(const std::string & dirname, CFileList* flist)
{
#define GET_SHOUTCAST_TIMEOUT	60
/* how the shoutcast xml interfaces looks/works:
1st step: get http://www.shoutcast.com/sbin/newxml.phtml
example answer:

<genrelist>
...
<genre name="Trance"/>
<genre name=...
...

2nd step: get http://www.shoutcast.com/sbin/newxml.phtml?genre=Trance
example answer:

<stationlist>
<tunein base="/sbin/tunein-station.pls"/>
<station name="TechnoBase.FM - 24h Techno, Dance, Trance, House and More - 128k MP3" mt="audio/mpeg" id="524" br="128" genre="Techno Trance Dance House" ct="We aRe oNe" lc="4466"/>
<station name=...
...

3rd step: get/decode playlist http://www.shoutcast.com/sbin/tunein-station.pls?id=524
and add to neutrino playlist

4th step: play from neutrio playlist
*/

//	printf("readDir_sc %s\n",dirname.c_str());
	std::string answer="";
//	char *dir_escaped = curl_escape(dirname.c_str(), 0);
	std::string url = m_baseurl;
//	url += dir_escaped;
//	curl_free(dir_escaped);
	url += dirname;
	std::cout << "[FileBrowser] SC URL: " << url << std::endl;
	CURL *curl_handle;
	CURLcode httpres;
	/* init the curl session */
	curl_handle = curl_easy_init();
	/* specify URL to get */
	curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
	/* send all data to this function  */
	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, CurlWriteToString);
	/* we pass our 'chunk' struct to the callback function */
	curl_easy_setopt(curl_handle, CURLOPT_FILE, (void *)&answer);
	/* Generate error if http error >= 400 occurs */
	curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
	/* set timeout to 30 seconds */
	curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, GET_SHOUTCAST_TIMEOUT);

	/* error handling */
	char error[CURL_ERROR_SIZE];
	curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, error);
	/* get it! */
	httpres = curl_easy_perform(curl_handle);
	/* cleanup curl stuff */
	curl_easy_cleanup(curl_handle);

	//std::cout << "Answer:" << std::endl << "----------------" << std::endl << answer << std::endl;
	
	if (!answer.empty() && httpres == 0)
	{
printf("CFileBrowser::readDir_sc: read done, size %d\n", answer.size());
		xmlDocPtr answer_parser = parseXml(answer.c_str());

		if (answer_parser != NULL) {
			char *ptr;
			unsigned char xml_decode = 0;
			xmlNodePtr element = xmlDocGetRootElement(answer_parser);

			if (strcmp(xmlGetName(element), "genrelist") == 0) 
				xml_decode = 1;
			else if (strcmp(xmlGetName(element), "stationlist") == 0) 
				xml_decode = 2;
			element = element->xmlChildrenNode;

			if (element == NULL) {
				printf("[FileBrowser] SC: Directory cannot be read.\n");
				CFile file;
				file.Mode = S_IFDIR + 0777 ;
				file.Name = dirname + "..";
				file.Size = 0;
				file.Time = 0;
				flist->push_back(file);
			} else {
				char * tunein_base = NULL;

				if (xml_decode == 1) {
					CFile file;
					file.Mode = S_IFDIR + 0777 ;
					file.Name = " Top500"; // use space to have it at the beginning of the list
					file.Url = "/sbin/newxml.phtml?genre=Top500";
					file.Size = 0;
					file.Time = 0;
					flist->push_back(file);
				} else if (xml_decode == 2) {
					CFile file2;
					file2.Mode = S_IFDIR + 0777 ;
					file2.Name = "..";
					file2.Url = "/sbin/newxml.phtml";
					file2.Size = 0;
					file2.Time = 0;
					flist->push_back(file2);
				}
				while (element) {
					CFile file;
					if (xml_decode == 1) {
						file.Mode = S_IFDIR + 0777 ;
						file.Name = xmlGetAttribute(element, (char *) "name");
						file.Url = "/sbin/newxml.phtml?genre=" + file.Name;
						file.Size = 0;
						file.Time = 0;
						flist->push_back(file);
					}
					else if (xml_decode == 2) {
						ptr = xmlGetName(element);
						if (ptr != NULL) {
							if (strcmp(ptr, "tunein")==0) {
								ptr = xmlGetAttribute(element, (char *) "base");
								if (ptr)
									tunein_base = ptr;
							} else if (strcmp(ptr, "station")==0) {
								ptr = xmlGetAttribute(element, (char *) "mt");
								if (ptr && (strcmp(ptr, "audio/mpeg")==0)) {
									file.Mode = S_IFREG + 0777 ;
									file.Name = xmlGetAttribute(element, (char *) "name");
									file.Url = base + tunein_base + (std::string)"?id=" + xmlGetAttribute(element, (char *) "id");
									//printf("adding %s (%s)\n", file.Name.c_str(), file.Url.c_str());
									ptr = xmlGetAttribute(element, (char *) "br");
									if (ptr) {
										file.Size = atoi(ptr);
										file.Time = atoi(ptr);
									} else {
										file.Size = 0;
										file.Time = 0;
									}
									flist->push_back(file);
								}
							}
						}
					}
					element = element->xmlNextNode;
				}
			}
			xmlFreeDoc(answer_parser);
			return true;
		}
	}
	
	/* since all CURL error messages use only US-ASCII characters, when can safely print them as if they were UTF-8 encoded */
	if (httpres == 22) {
	    strcat(error, "\nProbably wrong link.");
	}
printf("CFileBrowser::readDir_sc: httpres %d error, %s\n", httpres, error);
	DisplayErrorMessage(error); // UTF-8
	CFile file;

	file.Name = dirname + "..";
	file.Mode = S_IFDIR + 0777;
	file.Size = 0;
	file.Time = 0;
	flist->push_back(file);

	return false;
}
Ejemplo n.º 28
0
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();
}
Ejemplo n.º 29
0
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;
}