void CBouquetManager::deletePosition(t_satellite_position satellitePosition)
{
	BouquetList tmplist;
	for (unsigned int i =0; i < Bouquets.size(); i++) {
		if (satellitePosition == Bouquets[i]->satellitePosition) {
			printf("CBouquetManager::deletePosition: delete [%s]\n", Bouquets[i]->Name.c_str());
			delete Bouquets[i];
		} else
			tmplist.push_back(Bouquets[i]);
	}
	Bouquets = tmplist;
}
void CBouquetManager::clearAll(bool user)
{
	BouquetList tmplist;
	for (unsigned int i =0; i < Bouquets.size(); i++) {
		if (user || !Bouquets[i]->bUser)
			delete Bouquets[i];
		else
			tmplist.push_back(Bouquets[i]);
	}

	Bouquets.clear();
	if (!user)
		Bouquets = tmplist;
	remainChannels = NULL;
}
Example #3
0
/* bouquets are numbered starting at 0 */
void CZapitClient::getBouquets(BouquetList& bouquets, const bool emptyBouquetsToo, const bool utf_encoded, const channelsMode mode)
{
	CZapitMessages::commandGetBouquets msg;

	msg.emptyBouquetsToo = emptyBouquetsToo;
	msg.mode = mode;

	send(CZapitMessages::CMD_GET_BOUQUETS, (char*)&msg, sizeof(msg));

	responseGetBouquets response;
	while (CBasicClient::receive_data((char*)&response, sizeof(responseGetBouquets)))
	{
		if (response.bouquet_nr == RESPONSE_GET_BOUQUETS_END_MARKER)
			break;

		if (!utf_encoded)
		{
			strncpy(response.name, ZapitTools::UTF8_to_Latin1(response.name).c_str(), 30);
			response.name[29] = '\0';
		}
		bouquets.push_back(response);
	}

	close_connection();
}
/* bouquets are numbered starting at 0 */
void CZapitClient::getBouquets(BouquetList& bouquets, const bool emptyBouquetsToo, const bool utf_encoded, channelsMode mode)
{
	char buffer[30 + 1];

	CZapitMessages::commandGetBouquets msg;
	VALGRIND_PARANOIA;

	msg.emptyBouquetsToo = emptyBouquetsToo;
	msg.mode = mode;

	OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
	send(CZapitMessages::CMD_GET_BOUQUETS, (char*)&msg, sizeof(msg));

	responseGetBouquets response;
	while (CBasicClient::receive_data((char*)&response, sizeof(responseGetBouquets)))
	{
		if (response.bouquet_nr == RESPONSE_GET_BOUQUETS_END_MARKER)
			break;

		if (!utf_encoded)
		{
			cstrncpy(buffer, response.name, sizeof(buffer));
			cstrncpy(response.name, ZapitTools::UTF8_to_Latin1(buffer).c_str(), sizeof(buffer));
		}
		bouquets.push_back(response);
	}

	close_connection();
}
Example #5
0
/* bouquets are numbered starting at 0 */
void CZapitClient::getBouquets(BouquetList& bouquets, const bool emptyBouquetsToo, const bool utf_encoded)
{
	char buffer[30 + 1];

	CZapitMessages::commandGetBouquets msg;

	msg.emptyBouquetsToo = emptyBouquetsToo;

	send(CZapitMessages::CMD_GET_BOUQUETS, (char*)&msg, sizeof(msg));

	responseGetBouquets response;
	while (CBasicClient::receive_data((char*)&response, sizeof(responseGetBouquets)))
	{
		if (!utf_encoded)
		{
			buffer[30] = (char) 0x00;
			strncpy(buffer, response.name, 30);
			strncpy(response.name, Utf8_to_Latin1(std::string(buffer)).c_str(), 30);
		}
		bouquets.push_back(response);
	}

	close_connection();
}
Example #6
0
void CBouquetManager::saveBouquets(const CZapitClient::bouquetMode bouquetMode)
{
/* //	printf("[zapit] b size %d\n", Bouquets.size());
	if (bouquetMode == CZapitClient::BM_CREATESATELLITEBOUQUET)
	{
//	printf("[zapit] b mode sat \n");
		while (Bouquets.size() > 1)
		{
			BouquetList::iterator it = Bouquets.begin() + 1;
			Bouquets[0]->tvChannels.insert(Bouquets[0]->tvChannels.end(), (*it)->tvChannels.begin(), (*it)->tvChannels.end());
			Bouquets[0]->radioChannels.insert(Bouquets[0]->radioChannels.end(), (*it)->radioChannels.begin(), (*it)->radioChannels.end());
			delete (*it);
			Bouquets.erase(it);
		}
//	printf("[zapit] b mode sat \n");
		if(Bouquets.size() > 0)
		Bouquets[0]->Name = providerName;
	}
*/	
//	printf("[zapit] b mode sat \n");

	if ((bouquetMode == CZapitClient::BM_UPDATEBOUQUETS) || (bouquetMode == CZapitClient::BM_CREATESATELLITEBOUQUET))
	{
		BouquetList storedBouquets;

		storedBouquets = Bouquets;
		Bouquets.clear();
		remainChannels = NULL;
		
		LoadServices(frontend->getInfo()->type, frontend->getDiseqcType(), false);
		
		loadBouquets();
		
		deleteBouquet(remainChannels);
		remainChannels = NULL;
		
		for (unsigned int i = 0; i < Bouquets.size(); i++)
		{
			unsigned int j;
			for (j = 0; j < Bouquets[i]->tvChannels.size(); j++)
				Bouquets[i]->tvChannels[j] = new CZapitChannel(*(Bouquets[i]->tvChannels[j]));
			for (j = 0; j < Bouquets[i]->radioChannels.size(); j++)
				Bouquets[i]->radioChannels[j] = new CZapitChannel(*(Bouquets[i]->radioChannels[j]));
		}
		
		allchans.clear();
		
		while (!(storedBouquets.empty()))
		{
			int dest = existsBouquet(storedBouquets[0]->Name.c_str());
			if (dest != -1)
			{
				while (!(storedBouquets[0]->tvChannels.empty()))
				{
					if (!(existsChannelInBouquet(dest, storedBouquets[0]->tvChannels[0]->getChannelID())))
					{
						Bouquets[dest]->addService(storedBouquets[0]->tvChannels[0]);
						storedBouquets[0]->removeService(storedBouquets[0]->tvChannels[0]);
					}
					else
					{
						delete storedBouquets[0]->tvChannels[0];
						storedBouquets[0]->tvChannels.erase(storedBouquets[0]->tvChannels.begin());
					}
				}
				while (!(storedBouquets[0]->radioChannels.empty()))
				{
					if (!(existsChannelInBouquet(dest, storedBouquets[0]->radioChannels[0]->getChannelID())))
					{
						Bouquets[dest]->addService(storedBouquets[0]->radioChannels[0]);
						storedBouquets[0]->removeService(storedBouquets[0]->radioChannels[0]);
					}
					else
					{
						delete storedBouquets[0]->radioChannels[0];
						storedBouquets[0]->radioChannels.erase(storedBouquets[0]->radioChannels.begin());
					}
				}
				delete storedBouquets[0];
			}
			else
			{
				Bouquets.push_back(storedBouquets[0]);
			}
			storedBouquets.erase(storedBouquets.begin());
		}
	}

	saveBouquets();
}