Пример #1
0
/* This function does initiate a search for a keyword in all EPG Event of the Channel channel_id in sectionsd.
   The parameter search_typ does specify the search mode
	 0: none 			-> all EPG events of the channel are returned
	 1: keyword search in EPG Title
	 2: keyword search in EPG short description (INFO1)
	 3: keyword search in EPG description (INFO2)
  In case of a match, the EPG event is added to the Eventlist eList.
  */
bool CSectionsdClient::getEventsServiceKeySearchAdd(CChannelEventList& eList,const t_channel_id channel_id,char search_typ,std::string& search_text)
{
	int nBufSize=0;

	nBufSize += sizeof(t_channel_id);
	nBufSize += sizeof(char);
	nBufSize += search_text.size()+1;

	char* pSData = new char[nBufSize];
	char* pSData_ptr = pSData;

	*(t_channel_id*)pSData_ptr = channel_id;
	pSData_ptr += sizeof(t_channel_id);
	*pSData_ptr = search_typ;
	pSData_ptr += sizeof(char);
	strcpy(pSData_ptr,search_text.c_str());

	if (send(sectionsd::allEventsChannelIDSearch, pSData, nBufSize))
	{
		int nBufSize2 = readResponse();

		if( nBufSize2 > 0)
		{
			char* pData = new char[nBufSize2];
			receive_data(pData, nBufSize2);

			char* dp = pData;

//			int a = eList.size();

			while(dp < pData + nBufSize2)
			{
				CChannelEvent aEvent;

				aEvent.eventID = *((event_id_t *) dp);
				dp+=sizeof(aEvent.eventID);

				aEvent.startTime = *((time_t *) dp);
				dp+=sizeof(aEvent.startTime);

				aEvent.duration = *((unsigned *) dp);
				dp+=sizeof(aEvent.duration);

				aEvent.description= dp;
				dp+=aEvent.description.length()+1;

				aEvent.text= dp;
				dp+=aEvent.text.length()+1;

				eList.push_back(aEvent);
			}
//			int b = eList.size() -a;
			delete[] pData;
		}
	}
	delete[] pSData;

	close_connection();
	return true;
}
Пример #2
0
CChannelEventList CSectionsdClient::getEventsServiceKey(const t_channel_id channel_id)
{
	CChannelEventList eList;

	if (send(sectionsd::allEventsChannelID_, (char*)&channel_id, sizeof(channel_id)))
	{
		int nBufSize = readResponse();

		if( nBufSize > 0)
		{
			char* pData = new char[nBufSize];
			if (!receive_data(pData, nBufSize))
			{
				/* receive_data might have timed out etc. */
				delete[] pData;
				close_connection();
				return eList;
			}

			char* dp = pData;

			while(dp < pData + nBufSize)
			{
				CChannelEvent aEvent;

				aEvent.eventID = *((event_id_t *) dp);
				dp+=sizeof(aEvent.eventID);

				aEvent.startTime = *((time_t *) dp);
				dp+=sizeof(aEvent.startTime);

				aEvent.duration = *((unsigned *) dp);
				dp+=sizeof(aEvent.duration);

				aEvent.description= dp;
				dp+=strlen(dp)+1;

				aEvent.text= dp;
				dp+=strlen(dp)+1;

				eList.push_back(aEvent);
			}
			delete[] pData;
		}
	}

	close_connection();
	return eList;
}
Пример #3
0
CChannelEventList CSectionsdClient::getChannelEvents(const bool tv_mode, t_channel_id *p_requested_channels, int size_requested_channels)
{
	CChannelEventList eList;

	if (send(tv_mode ? sectionsd::actualEventListTVshortIDs : sectionsd::actualEventListRadioShortIDs, (char*)p_requested_channels, size_requested_channels))
	{
		int nBufSize = readResponse();

		if( nBufSize > 0)
		{
			char* pData = new char[nBufSize];
			if (!receive_data(pData, nBufSize)) 
			{
				delete[] pData;
				close_connection();
				return eList;
			}

			char* dp = pData;

			while(dp < pData + nBufSize)
			{
				CChannelEvent aEvent;

				aEvent.eventID = *((event_id_t *) dp);
				dp+=sizeof(aEvent.eventID);

				aEvent.startTime = *((time_t *) dp);
				dp+=sizeof(aEvent.startTime);

				aEvent.duration = *((unsigned *) dp);
				dp+=sizeof(aEvent.duration);

				aEvent.description= dp;
				dp+=strlen(dp)+1;

				aEvent.text= dp;
				dp+=strlen(dp)+1;

				eList.push_back(aEvent);
			}
			delete[] pData;
		}
	}
	close_connection();
	return eList;
}
Пример #4
0
CChannelEventList CSectionsdClient::getChannelEvents()
{
	CChannelEventList eList;

	if (send(sectionsd::actualEventListTVshortIDs))
	{
		int nBufSize = readResponse();

		if( nBufSize > 0)
		{
			char* pData = new char[nBufSize];
			receive_data(pData, nBufSize);

			char* dp = pData;

			while(dp < pData + nBufSize)
			{
				CChannelEvent aEvent;

				aEvent.eventID = *((unsigned long long *) dp);
				dp+=sizeof(aEvent.eventID);

				aEvent.startTime = *((time_t *) dp);
				dp+=sizeof(aEvent.startTime);

				aEvent.duration = *((unsigned *) dp);
				dp+=sizeof(aEvent.duration);

				aEvent.description= dp;
				dp+=strlen(dp)+1;

				aEvent.text= dp;
				dp+=strlen(dp)+1;

				eList.push_back(aEvent);
			}
			delete[] pData;
		}
	}
	close_connection();
	return eList;
}