示例#1
0
void CControlAPI::SendTimers(CWebserverRequest* request)
{
	CTimerd::TimerList timerlist;             // List of bouquets

	timerlist.clear();
	Parent->Timerd->getTimerList(timerlist);

	CZapitClient::BouquetChannelList channellist;     
	channellist.clear();

	CTimerd::TimerList::iterator timer = timerlist.begin();
	for(; timer != timerlist.end();timer++)
	{
      // Add Data
		char zAddData[20+1]={0};
		switch(timer->eventType)
		{
			case CTimerd::TIMER_NEXTPROGRAM :
			case CTimerd::TIMER_ZAPTO :
			case CTimerd::TIMER_RECORD :
            {
				if(channellist.size()==0)
				{
					Parent->Zapit->getChannels(channellist);
				}
				CZapitClient::BouquetChannelList::iterator channel = channellist.begin();
				for(; channel != channellist.end();channel++)
				{
					if(channel->channel_id==timer->channel_id)
					{
						strncpy(zAddData, channel->name, 20);
						zAddData[20]=0;
						break;
					}
				}
				if(channel == channellist.end())
					strcpy(zAddData,"Unknown");
			}
            break;
			
			case CTimerd::TIMER_STANDBY :
            {
               sprintf(zAddData,"Standby: %s",(timer->standby_on ? "ON" : "OFF"));
            }
            break;
         default:{}
		}
		request->printf("%d %d %d %d %d %d %s\n",timer->eventID,(int)timer->eventType,
             (int)timer->eventRepeat,(int)timer->announceTime,
             (int)timer->alarmTime,(int)timer->stopTime,zAddData);
	}
}
示例#2
0
void InitZapitChannelHelper(CZapitClient::channelsMode mode)
{
	CZapitChannelExec *ZapitChannelChooser = new CZapitChannelExec;
	std::vector<CMenuWidget *> toDelete;
	CZapitClient zapit;
	CZapitClient::BouquetList bouquetlist;
	zapit.getBouquets(bouquetlist, false, true, mode); // UTF-8
	CZapitClient::BouquetList::iterator bouquet = bouquetlist.begin();
	CMenuWidget mctv(LOCALE_TIMERLIST_BOUQUETSELECT, NEUTRINO_ICON_SETTINGS);

	for(; bouquet != bouquetlist.end();bouquet++)
	{
		CMenuWidget* mwtv = new CMenuWidget(LOCALE_TIMERLIST_CHANNELSELECT, NEUTRINO_ICON_SETTINGS);
		toDelete.push_back(mwtv);
		CZapitClient::BouquetChannelList channellist;
		zapit.getBouquetChannels(bouquet->bouquet_nr,channellist,mode, true); // UTF-8
		CZapitClient::BouquetChannelList::iterator channel = channellist.begin();
		for(; channel != channellist.end();channel++)
		{
			char cChannelId[32];
			sprintf(cChannelId,
				"ZC%c:%d,",
				(mode==CZapitClient::MODE_TV)?'T':'R',
				channel->nr);
			mwtv->addItem(new CMenuForwarderNonLocalized(channel->name, true, NULL, ZapitChannelChooser, (std::string(cChannelId) + channel->name).c_str()));
		}
		if (!channellist.empty())
			mctv.addItem(new CMenuForwarderNonLocalized(bouquet->name, true, NULL, mwtv));
		channellist.clear();
	}
	mctv.exec (NULL, "");
	mctv.hide ();

	// delete dynamic created objects
	for(unsigned int count=0;count<toDelete.size();count++)
	{
		delete toDelete[count];
	}
	toDelete.clear();
}
示例#3
0
//-------------------------------------------------------------------------
bool CVCRControl::CServerDevice::sendCommand(CVCRCommand command, const t_channel_id channel_id, unsigned long long epgid, uint apid)
{
	printf("Send command: %d channel_id: %x epgid: %llx\n",command, channel_id, epgid);
	if(serverConnect())
	{
		char tmp[40];
		string extCommand="unknown";
		string ext_channel_id = "error";
		string ext_channel_name = "unknown";
		string extEpgid="error";
		string extVideoPID="error";
		string extAudioPID="error";
		string extEPGTitle="not available";
		sprintf(tmp,"%u", channel_id);
		ext_channel_id = tmp;
		sprintf(tmp,"%llu", epgid);
		extEpgid = tmp;
//		sprintf(tmp,"%u", g_RemoteControl->current_PIDs.PIDs.vpid );
		CZapitClient::responseGetPIDs pids;
		g_Zapit->getPIDS (pids);
 		CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo ();
		sprintf(tmp,"%u", si.vdid );
		extVideoPID = tmp;
//		sprintf(tmp,"%u", g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].pid);
		if(apid==0)
			apid=(uint)si.apid;
		sprintf(tmp,"%u", apid);
		extAudioPID = tmp;

		CZapitClient::BouquetChannelList channellist;     
		g_Zapit->getChannels(channellist);
		CZapitClient::BouquetChannelList::iterator channel = channellist.begin();
		for(; channel != channellist.end();channel++)
		{
			if(channel->channel_id==channel_id)
			{
				ext_channel_name=channel->name;
				break;
			}
		}

		CSectionsdClient sections;
		CSectionsdClient::responseGetCurrentNextInfoChannelID current_next;
		if(sections.getCurrentNextServiceKey(channel_id, current_next))
		{
			extEPGTitle=current_next.current_name;
		}

		switch(command)
		{
			case CMD_VCR_RECORD: extCommand="record";
				break;
			case CMD_VCR_STOP: extCommand="stop";
				break;
			case CMD_VCR_PAUSE: extCommand="pause";
				break;
			case CMD_VCR_RESUME: extCommand="resume";
				break;
			case CMD_VCR_AVAILABLE: extCommand="available";
				break;
			case CMD_VCR_UNKNOWN:
			default:
				printf("CVCRControl: Unknown Command\n");
		}

		string extMessage = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n\n";
		extMessage +="<neutrino commandversion=\"1\">\n";
		extMessage +="    <record command=\"" + extCommand + "\">\n";
		extMessage +="        <channelname>" + ext_channel_name + "</channelname>\n";
		extMessage +="        <epgtitle>" + extEPGTitle + "</epgtitle>\n";
		extMessage +="        <onidsid>" + ext_channel_id + "</onidsid>\n";
		extMessage +="        <epgid>" + extEpgid + "</epgid>\n";
		extMessage +="        <videopid>" + extVideoPID + "</videopid>\n";
		extMessage +="        <audiopids selected=\"" + extAudioPID + "\">\n";
		// super hack :-), der einfachste weg an die apid descriptions ranzukommen
		g_RemoteControl->current_PIDs = pids;
		g_RemoteControl->processAPIDnames();
		bool apidFound=false;
		for(unsigned int i= 0; i< pids.APIDs.size(); i++)
		{
			sprintf(tmp, "%u",  pids.APIDs[i].pid );
			extMessage +="            <audio pid=\"" + string(tmp) + "\" name=\"" + string(g_RemoteControl->current_PIDs.APIDs[i].desc)  + "\">\n";
			if(pids.APIDs[i].pid==apid)
				apidFound=true;
		}
		if(!apidFound)
		{
			// add spec apid to available
			extMessage +="            <audio pid=\"" + extAudioPID + "\" name=\"" + extAudioPID  + "\"/>\n";
		}
		extMessage +="        </audiopids>\n";
		extMessage +="    </record>\n";
		extMessage +="</neutrino>\n";

		printf("sending to vcr-client:\n\n%s\n", extMessage.c_str());
		write(sock_fd, extMessage.c_str() , extMessage.length() );

		serverDisconnect();

		deviceState = command;
		return true;
	}
	else
		return false;

}
示例#4
0
// para ::= <type=new|modify> [timerid]
std::string  CNeutrinoYParser::func_set_timer_form(CyhookHandler *hh, std::string para)
{
	unsigned timerId=0;
	std::string cmd, stimerid;
	CTimerd::responseGetTimer timer;             // Timer
	time_t now_t = time(NULL);
	ySplitString(para, " ", cmd, stimerid);
	if(cmd != "new")
	{
		// init timerid
		if(stimerid != "")
			timerId = (unsigned)atoi(stimerid.c_str());
		
		NeutrinoAPI->Timerd->getTimer(timer, timerId);
		std::string zType = NeutrinoAPI->timerEventType2Str(timer.eventType);
	
		hh->ParamList["timerId"] = itoa(timerId);
		hh->ParamList["zType"] = zType;
	}
	// Alarm/StopTime
	struct tm *alarmTime = (cmd == "new") ? localtime(&now_t) : localtime(&(timer.alarmTime));

	hh->ParamList["alarm_mday"] = string_printf("%02d", alarmTime->tm_mday);
	hh->ParamList["alarm_mon"]  = string_printf("%02d", alarmTime->tm_mon +1);
	hh->ParamList["alarm_year"] = string_printf("%04d", alarmTime->tm_year + 1900);
	hh->ParamList["alarm_hour"] = string_printf("%02d", alarmTime->tm_hour);
	hh->ParamList["alarm_min"]  = string_printf("%02d", alarmTime->tm_min);

	struct tm *stopTime = (cmd == "new") ? alarmTime : ( (timer.stopTime > 0) ? localtime(&(timer.stopTime)) : NULL );
	if(stopTime != NULL)
	{
		hh->ParamList["stop_mday"] = string_printf("%02d", stopTime->tm_mday);
		hh->ParamList["stop_mon"]  = string_printf("%02d", stopTime->tm_mon +1);
		hh->ParamList["stop_year"] = string_printf("%04d", stopTime->tm_year + 1900);
		hh->ParamList["stop_hour"] = string_printf("%02d", stopTime->tm_hour);
		hh->ParamList["stop_min"]  = string_printf("%02d", stopTime->tm_min);

		// APid settings for Record
		if(timer.apids == TIMERD_APIDS_CONF)
			hh->ParamList["TIMERD_APIDS_CONF"] = "y";
		if(timer.apids & TIMERD_APIDS_STD)
			hh->ParamList["TIMERD_APIDS_STD"]  = "y";
		if(timer.apids & TIMERD_APIDS_ALT)
			hh->ParamList["TIMERD_APIDS_ALT"]  = "y";
		if(timer.apids & TIMERD_APIDS_AC3)
			hh->ParamList["TIMERD_APIDS_AC3"]  = "y";
	}
	else
		hh->ParamList["stop_mday"] = "0";
	// event type
	std::string sel;
	for(int i=1; i<=8;i++)
	{
		if(i!=(int)CTimerd::TIMER_NEXTPROGRAM)
		{
			std::string sel;
			std::string zType = NeutrinoAPI->timerEventType2Str((CTimerd::CTimerEventTypes) i);
			if(cmd != "new")
				sel = (i==(int)timer.eventType) ? "selected=\"selected\"" : "";
			else
				sel = (i==(int)CTimerd::TIMER_RECORD) ? "selected=\"selected\"" : "";
			hh->ParamList["timertype"] += 
				string_printf("<option value=\"%d\" %s>%s\n",i,sel.c_str(),zType.c_str());
		}
	}
	// Repeat types
	std::string zRep;
	sel = "";
	for(int i=0; i<=6;i++)
	{
		if(i!=(int)CTimerd::TIMERREPEAT_BYEVENTDESCRIPTION)
		{

			zRep = NeutrinoAPI->timerEventRepeat2Str((CTimerd::CTimerEventRepeat) i);
			if(cmd != "new")
				sel = (((int)timer.eventRepeat) == i) ? "selected=\"selected\"" : "";
			hh->ParamList["repeat"] += 
				string_printf("<option value=\"%d\" %s>%s</option>\n",i,sel.c_str(),zRep.c_str());
		}
	}
	// Repeat Weekdays
	zRep = NeutrinoAPI->timerEventRepeat2Str(CTimerd::TIMERREPEAT_WEEKDAYS);
	if(timer.eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS && cmd != "new")
		sel = "selected=\"selected\"";
	else
		sel = "";
	hh->ParamList["repeat"] += 
		string_printf("<option value=\"%d\" %s>%s</option>\n",(int)CTimerd::TIMERREPEAT_WEEKDAYS, sel.c_str(), zRep.c_str());

	// Weekdays
	char weekdays[8];
	NeutrinoAPI->Timerd->setWeekdaysToStr(timer.eventRepeat, weekdays);
	hh->ParamList["weekdays"]=	 weekdays;
	
	// timer repeats
	if (timer.eventRepeat == CTimerd::TIMERREPEAT_ONCE)
		hh->ParamList["TIMERREPEAT_ONCE"]  = "y";
	hh->ParamList["timer_repeatCount"]  = itoa(timer.repeatCount);

	t_channel_id current_channel = (cmd == "new") ? live_channel_id /*NeutrinoAPI->Zapit->getCurrentServiceID()*/ : timer.channel_id;
	CBouquetManager::ChannelIterator cit = g_bouquetManager->tvChannelsBegin();
	for (; !(cit.EndOfChannels()); cit++) {
		std::string sel = ((*cit)->channel_id == current_channel) ? "selected=\"selected\"" : "";
		hh->ParamList["program_row"] +=
			string_printf("<option value=\""
				PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
				"\" %s>%s</option>\n",
				(*cit)->channel_id, sel.c_str(), (*cit)->getName().c_str());
	}
	cit = g_bouquetManager->radioChannelsBegin();
	for (; !(cit.EndOfChannels()); cit++) {
		std::string sel = ((*cit)->channel_id == current_channel) ? "selected=\"selected\"" : "";
		hh->ParamList["program_row"] +=
			string_printf("<option value=\""
				PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
				"\" %s>%s</option>\n",
				(*cit)->channel_id, sel.c_str(), (*cit)->getName().c_str());
	}
#if 0
	// program row
	CZapitClient::BouquetChannelList channellist;     
	channellist.clear();
	NeutrinoAPI->Zapit->getChannels(channellist,CZapitClient::MODE_TV, CZapitClient::SORT_BOUQUET, true);
	CZapitClient::BouquetChannelList::iterator channel = channellist.begin();
	for(; channel != channellist.end();channel++)
	{
		std::string sel = (channel->channel_id == current_channel) ? "selected=\"selected\"" : "";
		hh->ParamList["program_row"] +=
			string_printf("<option value=\""
				PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
				"\" %s>%s</option>\n",
				channel->channel_id, sel.c_str(), channel->getName());
	}

	channellist.clear();
	NeutrinoAPI->Zapit->getChannels(channellist,CZapitClient::MODE_RADIO, CZapitClient::SORT_BOUQUET, true);
	for (channel = channellist.begin(); channel != channellist.end(); channel++)
	{
		std::string sel = (channel->channel_id == current_channel) ? "selected=\"selected\"" : "";
		hh->ParamList["program_row"] +=
			string_printf("<option value=\""
				PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
				"\" %s>%s</option>\n",
				channel->channel_id, sel.c_str(), channel->getName());
	}
#endif
	// recordingDir
	hh->ParamList["RECORD_DIR_MAXLEN"] = itoa(RECORD_DIR_MAXLEN-1);
	if(cmd != "new") {
		if(timer.eventType == CTimerd::TIMER_RECORD)
			hh->ParamList["timer_recordingDir"] = timer.recordingDir;
	}
	else
	{
		// get Default Recordingdir
		CConfigFile *Config = new CConfigFile(',');
		Config->loadConfig(NEUTRINO_CONFIGFILE);
		hh->ParamList["timer_recordingDir"] = Config->getString("network_nfs_recordingdir", "/mnt/filme");
		delete Config;//Memory leak: Config
	}
	hh->ParamList["standby"] = (cmd == "new")? "0" : ((timer.standby_on)?"1":"0");
	hh->ParamList["message"] = (cmd == "new")? "" : timer.message;
	hh->ParamList["pluginname"] = (cmd == "new")? "" : timer.pluginName;
	
	return "";
}
示例#5
0
//-------------------------------------------------------------------------
// func: Bouquet Edit
//-------------------------------------------------------------------------
std::string  CNeutrinoYParser::func_set_bouquet_edit_form(CyhookHandler *hh, std::string para)
{
	if (!(hh->ParamList["selected"].empty()))
	{
		int selected = atoi(hh->ParamList["selected"].c_str()) - 1;
		int mode = NeutrinoAPI->Zapit->getMode();
		ZapitChannelList* channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[selected]->tvChannels) : &(g_bouquetManager->Bouquets[selected]->radioChannels);
		for(int j = 0; j < (int) channels->size(); j++) {
			hh->ParamList["bouquet_channels"] +=
				string_printf("<option value=\""
					PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
					"\">%s</option>\n",
					(*channels)[j]->channel_id,
					(*channels)[j]->getName().c_str());
		}
		ZapitChannelList Channels;
		Channels.clear();
		if (mode == CZapitClient::MODE_RADIO) {
			for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++)
				if (it->second.getServiceType() == ST_DIGITAL_RADIO_SOUND_SERVICE)
					Channels.push_back(&(it->second));
		} else {
			for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++)
				if (it->second.getServiceType() != ST_DIGITAL_RADIO_SOUND_SERVICE)
					Channels.push_back(&(it->second));
		}
		sort(Channels.begin(), Channels.end(), CmpChannelByChName());

		for (int i = 0; i < (int) Channels.size(); i++) {
			if (!g_bouquetManager->existsChannelInBouquet(selected, Channels[i]->channel_id)){
				hh->ParamList["all_channels"] +=
					string_printf("<option value=\""
						PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
						"\">%s</option>\n",
						Channels[i]->channel_id,
						Channels[i]->getName().c_str());
			}
		}
#if 0
		CZapitClient::BouquetChannelList BChannelList;
		CZapitClient::BouquetChannelList::iterator channels;

		int selected = atoi(hh->ParamList["selected"].c_str()) - 1;

		// List channels in bouquet
		NeutrinoAPI->Zapit->getBouquetChannels(selected, BChannelList, CZapitClient::MODE_CURRENT, true); // UTF-8
		for(channels = BChannelList.begin(); channels != BChannelList.end(); channels++)
		{
			hh->ParamList["bouquet_channels"] +=
				string_printf("<option value=\""
					PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
					"\">%s</option>\n",
					channels->channel_id,
					channels->name);
		}
		// List all channels
		NeutrinoAPI->Zapit->getChannels(BChannelList, CZapitClient::MODE_CURRENT, CZapitClient::SORT_ALPHA, true); // UTF-8
		for(channels = BChannelList.begin(); channels != BChannelList.end(); channels++)
		{
			if (!NeutrinoAPI->Zapit->existsChannelInBouquet(selected, channels->channel_id)){
				hh->ParamList["all_channels"] +=
					string_printf("<option value=\""
						PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
						"\">%s</option>\n",
						channels->channel_id,
						channels->name);
			}
		}
#endif
		return "";
	}
	else
		return "No Bouquet selected";
}