Ejemplo n.º 1
0
void eTextInputField::updated()
{
	if ( editLabel )
		editLabel->setText(convertDVBUTF8((unsigned char*)isotext.c_str(),isotext.length(), table));
	else
		text=convertDVBUTF8((unsigned char*)isotext.c_str(),isotext.length(), table);
	drawCursor();
}
Ejemplo n.º 2
0
 SIcomponent(const struct descr_component_header *comp) {
   streamContent=comp->stream_content;
   componentType=comp->component_type;
   componentTag=comp->component_tag;
   if(comp->descriptor_length>sizeof(struct descr_component_header)-2)
     //component=std::string(((const char *)comp)+sizeof(struct descr_component_header), comp->descriptor_length-(sizeof(struct descr_component_header)-2));
     component=convertDVBUTF8(((const char *)comp)+sizeof(struct descr_component_header), comp->descriptor_length-(sizeof(struct descr_component_header)-2), 0, 0);
 }
Ejemplo n.º 3
0
	SIlinkage(const struct descr_linkage_header *link) {
		linkageType = link->linkage_type;
		transportStreamId = (link->transport_stream_id_hi << 8) | link->transport_stream_id_lo;
		originalNetworkId = (link->original_network_id_hi << 8) | link->original_network_id_lo;
		serviceId = (link->service_id_hi << 8) | link->service_id_lo;
		if (link->descriptor_length > sizeof(struct descr_linkage_header) - 2)
			//name = std::string(((const char *)link) + sizeof(struct descr_linkage_header), link->descriptor_length - (sizeof(struct descr_linkage_header) - 2));
			name = convertDVBUTF8(((const char *)link)+sizeof(struct descr_linkage_header), link->descriptor_length-(sizeof(struct descr_linkage_header)-2), 0, 0);
	}
Ejemplo n.º 4
0
void eTextInputField::updateHelpWidget()
{
	if ( helpwidget )
	{
		eString keysStr;

		for (int i=0; i < 12; ++i )
		{
			char *language=0;
			eConfig::getInstance()->getKey("/elitedvb/language", language);
			if ( language && keymappings.find(language) != keymappings.end() )
			{
				keysStr = capslock ? keymappings[language][i].second :
					keymappings[language][i].first;
			}
			else
			{
				keysStr = capslock ? keymappings["default"][i].second :
					keymappings["default"][i].first;
			}
			if ( language )
				free(language);

			eString tmpStr = convertUTF8DVB(keysStr, table);

			if ( i < 10)
			{
				if ( swapNum )
					tmpStr = (char)(i+0x30) + tmpStr;
				else
					tmpStr += (char)(i+0x30);
			}

			eString filtered;

			for (unsigned int d=0; d < tmpStr.length(); ++d )
				if ( useableChars.find(tmpStr[d]) != eString::npos )
					filtered+=tmpStr[d];

			helpwidget->keys[i]->setText(convertDVBUTF8((unsigned char*)filtered.c_str(),filtered.length(), table));
		}
	}
}
Ejemplo n.º 5
0
void eCableScan::parseSDT()
{
	unsigned long hash = 0;
	ePtr<iDVBChannelList> db;
	ePtr<eDVBResourceManager> res;

	if (m_SDT->getSections().empty()) return;

	eDVBResourceManager::getInstance(res);
	res->getChannelList(db);

	currentScanChannel->getHash(hash);
	eDVBNamespace dvbnamespace(hash & ~0xFFFF);

	eDVBChannelID chid(dvbnamespace, (**m_SDT->getSections().begin()).getTransportStreamId(), (**m_SDT->getSections().begin()).getOriginalNetworkId());

	db->addChannelToList(chid, currentScanChannel);

	std::vector<ServiceDescriptionSection*>::const_iterator i;
	for (i = m_SDT->getSections().begin(); i != m_SDT->getSections().end(); ++i)
	{
		const ServiceDescriptionSection &sdt = **i;
		const ServiceDescriptionList &services = *sdt.getDescriptions();
		for (ServiceDescriptionConstIterator s(services.begin()); s != services.end(); ++s)
		{
			unsigned short service_id = (*s)->getServiceId();
			eServiceReferenceDVB ref;
			ePtr<eDVBService> service = new eDVBService;

			ref.set(chid);
			ref.setServiceID(service_id);

			for (DescriptorConstIterator desc = (*s)->getDescriptors()->begin();
					desc != (*s)->getDescriptors()->end(); ++desc)
			{
				switch ((*desc)->getTag())
				{
				case SERVICE_DESCRIPTOR:
				{
					ServiceDescriptor &d = (ServiceDescriptor&)**desc;
					int servicetype = d.getServiceType();
					ref.setServiceType(servicetype);
					service->m_service_name = convertDVBUTF8(d.getServiceName());
					service->genSortName();
					service->m_provider_name = convertDVBUTF8(d.getServiceProviderName());
					providerNames[service->m_provider_name]++;
					break;
				}
				case CA_IDENTIFIER_DESCRIPTOR:
				{
					CaIdentifierDescriptor &d = (CaIdentifierDescriptor&)**desc;
					const CaSystemIdList &caids = *d.getCaSystemIds();
					for (CaSystemIdList::const_iterator i(caids.begin()); i != caids.end(); ++i)
					{
						service->m_ca.push_front(*i);
					}
					break;
				}
				default:
					break;
				}
			}
			ePtr<eDVBService> dvb_service;
			if (!db->getService(ref, dvb_service))
			{
				dvb_service->m_flags |= service->m_flags;
				if (service->m_ca.size())
					dvb_service->m_ca = service->m_ca;
			}
			else
			{
				db->addService(ref, service);
				service->m_flags |= eDVBService::dxNewFound;
			}
			int logicalchannelid = 0;
			if (hdList)
			{
				std::map<int, int>::const_iterator it = serviceIdToHDChannelId.find(service_id);
				if (it != serviceIdToHDChannelId.end())
				{
					logicalchannelid = it->second;
				}
			}
			if (!logicalchannelid)
			{
				std::map<int, int>::const_iterator it = serviceIdToChannelId.find(service_id);
				if (it != serviceIdToChannelId.end())
				{
					logicalchannelid = it->second;
				}
			}
			if (logicalchannelid)
			{
				switch (ref.getServiceType())
				{
				case 1: /* digital television service */
				case 4: /* nvod reference service (NYI) */
				case 17: /* MPEG-2 HD digital television service */
				case 22: /* advanced codec SD digital television */
				case 24: /* advanced codec SD NVOD reference service (NYI) */
				case 25: /* advanced codec HD digital television */
				case 27: /* advanced codec HD NVOD reference service (NYI) */
				default:
					/* just assume that anything *not* radio is tv */
					numberedServiceRefs[logicalchannelid] = ref;
					break;
				case 2: /* digital radio sound service */
				case 10: /* advanced codec digital radio sound service */
					numberedRadioServiceRefs[logicalchannelid] = ref;
					break;
				}
			}
		}
	}
}
Ejemplo n.º 6
0
int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t data, bool from_menu)
{
	int ret = 0;
	char str[255];
	char cnt[5];
	int i;
	MMI_MENU_LIST_INFO Menu;
	MMI_ENGUIRY_INFO MmiEnquiry;
	int curslot;
	MMI_MENU_LIST_INFO * pMenu = &Menu;
	MMI_ENGUIRY_INFO * pMmiEnquiry = &MmiEnquiry;

	if(msg == NeutrinoMessages::EVT_CI_INSERTED) 
	{
		if(hintBox != NULL) 
		{
			hintBox->hide();
			delete hintBox;
			hintBox = NULL;
		}
		
		sprintf(str, "%s %d", g_Locale->getText(LOCACE_CAM_INSERTED), (int) data+1);

		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleMsg: %s\n", str);
		
		hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, str);
		hintBox->paint();

		sleep(CI_MSG_TIME);
		hintBox->hide();
		delete hintBox;
		hintBox = NULL;

	} 
	else if (msg == NeutrinoMessages::EVT_CI_REMOVED) 
	{
		if(hintBox != NULL) 
		{
			hintBox->hide();
			delete hintBox;
			hintBox = NULL;
		}
		sprintf(str, "%s %d", g_Locale->getText(LOCALE_CAM_REMOVED), (int) data+1);

		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleMsg: %s\n", str);
		
		hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, str);

		hintBox->paint();

		sleep(CI_MSG_TIME);
		hintBox->hide();
		delete hintBox;
		hintBox = NULL;
	} 
	else if(msg == NeutrinoMessages::EVT_CI_INIT_OK) 
	{
		if(hintBox != NULL) 
		{
			hintBox->hide();
			delete hintBox;
			hintBox = NULL;
		}
		char name[255] = "Unknown";
		
		ci->GetName((int) data, name);
		sprintf(str, "%s %d: %s", g_Locale->getText(LOCALE_CAM_INIT_OK), (int) data+1, name);

		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleMsg: %s\n", str);
		
		hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, str);
		hintBox->paint();
		sleep(CI_MSG_TIME);
		hintBox->hide();
		delete hintBox;
		hintBox = NULL;
	}
	else if(msg == NeutrinoMessages::EVT_CI_MMI_MENU || msg == NeutrinoMessages::EVT_CI_MMI_LIST) 
	{
		bool sublevel = false;
		if(msg != NeutrinoMessages::EVT_CI_MMI_MENU)
			sublevel = true;

		/*
		if(msg != NeutrinoMessages::EVT_CI_MMI_MENU)
			dprintf(DEBUG_NORMAL, "NeutrinoMessages::EVT_CI_MMI_MENU \n");
		else
			dprintf(DEBUG_NORMAL, "NeutrinoMessages::EVT_CI_MMI_LIST \n");
		*/
		
		memcpy(pMenu, (MMI_MENU_LIST_INFO*) data, sizeof(MMI_MENU_LIST_INFO));
		free((void *)data);

		curslot = pMenu->slot;

		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: slot %d menu ready, title %s choices %d\n", curslot, convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), pMenu->choice_nb);

		if(hintBox) 
		{
			hintBox->hide();
		}

		int selected = -1;
		if(pMenu->choice_nb) 
		{
			CMenuWidget* menu = new CMenuWidget(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), NEUTRINO_ICON_SETTINGS);

			CMenuSelectorTarget * selector = new CMenuSelectorTarget(&selected);
			int slen = strlen(pMenu->subtitle);
			
			if(slen) 
			{
				char * sptr = pMenu->subtitle;
				char * tptr = sptr;
				int bpos = 0;
				for(int i1 = 0; i1 < slen; i1++) 
				{
					if((tptr[i1] == 0x8A) || ((bpos >= 38) && (tptr[i1] == 0x20)) ) 
					{
						bpos = 0;
						tptr[i1] = 0;
						
						dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr);
						
						menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false));
						sptr = &tptr[i1+1];
					}
					bpos++;
				}
				
				if(strlen(sptr)) 
				{
					dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr);
					
					menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false));
				}
			}
			
			for(i = 0; i < pMenu->choice_nb; i++) 
			{
				sprintf(cnt, "%d", i);
				if(sublevel)
					menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt));
				else
					menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1)));
			}
			slen = strlen(pMenu->bottom);
			
			if(slen) 
			{
				dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: bottom: %s\n", pMenu->bottom);
				
				menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false));
			}

			menu->exec(NULL, "");

			delete menu;
			delete selector;
		} 
		else 
		{
			char _str[255];
			snprintf(_str, 255, "%s\n%s\n%s", pMenu->title, pMenu->subtitle, pMenu->bottom);
			
			if(hintBox)
			{
				delete hintBox;
				hintBox = NULL;
			}

			hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(_str, strlen(_str), 0).c_str());
			hintBox->paint();
			sleep(4);//FIXME
			
			if(!from_menu) 
			{
				delete hintBox;
				hintBox = NULL;
			}
			return 1;
		}

		if(sublevel)
			return 0;

		if(selected >= 0) 
		{
			dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: selected %d:%s sublevel %s\n", selected, pMenu->choice_item[i], sublevel ? "yes" : "no");

			ci->CI_MenuAnswer(curslot, selected+1);

			timeoutEnd = CRCInput::calcTimeoutEnd(10);
			return 1;
		} 
		else 
		{
			return 2;
		}
	}
	else if(msg == NeutrinoMessages::EVT_CI_MMI_REQUEST_INPUT) 
	{
		memcpy(pMmiEnquiry, (MMI_ENGUIRY_INFO*) data, sizeof(MMI_ENGUIRY_INFO));
		free((void *)data);
		curslot = pMmiEnquiry->slot;
		
		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str());
		
		if(hintBox)
			hintBox->hide();

		char cPIN[pMmiEnquiry->answerlen+1];
		cPIN[0] = 0;

		CPINInput *PINInput = new CPINInput((char *) convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str(), cPIN, 4, NONEXISTANT_LOCALE);
		PINInput->exec(NULL, "");
		delete PINInput;

		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: input=[%s]\n", cPIN);

		if((int) strlen(cPIN) != pMmiEnquiry->answerlen) 
		{
			dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: wrong input len\n");

			ci->CI_Answer(curslot, (unsigned char *) cPIN, 0);

			return 0;
		} 
		else 
		{
			ci->CI_Answer(curslot, (unsigned char *) cPIN, pMmiEnquiry->answerlen);

			return 1;
		}
	}
	else if(msg == NeutrinoMessages::EVT_CI_MMI_CLOSE) 
	{
		curslot = (int) data;
		
		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: close request slot: %d\n", curslot);

		ci->CI_CloseMMI(curslot);

		return 0;
	}
	else if(msg == NeutrinoMessages::EVT_CI_MMI_TEXT) 
	{
		curslot = (int) data;
		
		dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: text\n");
	} 
	else
		ret = -1;

	return ret;
}
int CCAMMenuHandler::handleCamMsg(const neutrino_msg_t msg, neutrino_msg_data_t data, int &msgret, bool from_menu)
{
	char str[255];
	char cnt[5];
	int i;
	MMI_MENU_LIST_INFO Menu;
	MMI_ENQUIRY_INFO MmiEnquiry;
	MMI_MENU_LIST_INFO *pMenu = &Menu;
	MMI_ENQUIRY_INFO *pMmiEnquiry = &MmiEnquiry;
	CA_MESSAGE Msg, *rMsg;

	//printf("CCAMMenuHandler::handleCamMsg: msg %x data %x from %s\n", msg, data, from_menu ? "menu" : "neutrino");
	msgret = messages_return::unhandled;

	if ((msg == NeutrinoMessages::EVT_TIMER) && (data == close_timer)) {
		printf("CCAMMenuHandler::handleCamMsg: EVT_TIMER close_timer %d\n", close_timer);
		g_RCInput->killTimer(close_timer);
		msgret = messages_return::cancel_info;
	}

	if (msg != NeutrinoMessages::EVT_CA_MESSAGE)
		return 1;

	msgret = messages_return::handled;

	rMsg	= (CA_MESSAGE *)data;
	if (!rMsg)
		return -1;

	Msg = *rMsg;
	delete rMsg;

	u32 MsgId             = Msg.MsgId;
	CA_SLOT_TYPE SlotType = Msg.SlotType;
	int curslot           = Msg.Slot;

	printf("CCAMMenuHandler::handleCamMsg: CA msg %x from %s\n", MsgId, from_menu ? "menu" : "neutrino");

	if (g_settings.ci_ignore_messages && !from_menu)
		return 1;

	hideHintBox();

	if (SlotType != CA_SLOT_TYPE_SMARTCARD && SlotType != CA_SLOT_TYPE_CI)
		return -1;

	if(MsgId == CA_MESSAGE_MSG_INSERTED) {
		snprintf(str, sizeof(str), "%s %d", 
				g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INSERTED : LOCALE_SC_INSERTED), (int)curslot+1);
		printf("CCAMMenuHandler::handleCamMsg: %s\n", str);
		ShowHint(LOCALE_MESSAGEBOX_INFO, str, 450, 3);
		if (in_menu)
			msgret = messages_return::cancel_all;
	} else if (MsgId == CA_MESSAGE_MSG_REMOVED) {
		snprintf(str, sizeof(str), "%s %d", 
				g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_REMOVED : LOCALE_SC_REMOVED), (int)curslot+1);

		printf("CCAMMenuHandler::handleCamMsg: %s\n", str);
		ShowHint(LOCALE_MESSAGEBOX_INFO, str, 450, 3);
#if 0
		if (menu_slot == curslot && menu_type == SlotType)
			return 3;
#endif
		if (in_menu)
			msgret = messages_return::cancel_all;
	} else if(MsgId == CA_MESSAGE_MSG_INIT_OK) {
		char name[255] = "Unknown";
		if (ca)
			ca->ModuleName(SlotType, curslot, name);

		snprintf(str, sizeof(str), "%s %d: %s", 
				g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INIT_OK : LOCALE_SC_INIT_OK), (int)curslot+1, name);
		printf("CCAMMenuHandler::handleCamMsg: %s\n", str);
		CCamManager::getInstance()->Start(CZapit::getInstance()->GetCurrentChannelID(), CCamManager::PLAY, true);
		ShowHint(LOCALE_MESSAGEBOX_INFO, str, 450, 3);
	} else if(MsgId == CA_MESSAGE_MSG_INIT_FAILED) {
		char name[255] = "Unknown";
		if (ca)
			ca->ModuleName(SlotType, curslot, name);

		snprintf(str, sizeof(str), "%s %d: %s", 
				g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INIT_FAILED : LOCALE_SC_INIT_FAILED), (int)curslot+1, name);

		printf("CCAMMenuHandler::handleCamMsg: %s\n", str);
		ShowHint(LOCALE_MESSAGEBOX_INFO, str, 450, 3);
	} else if(MsgId == CA_MESSAGE_MSG_MMI_MENU || MsgId == CA_MESSAGE_MSG_MMI_LIST) {
		bool sublevel = false;

		if(MsgId != CA_MESSAGE_MSG_MMI_MENU)
			sublevel = true;

		if (!(Msg.Flags & CA_MESSAGE_HAS_PARAM1_DATA))
			return -1;

		memmove(pMenu, (MMI_MENU_LIST_INFO*)Msg.Msg.Data[0], sizeof(MMI_MENU_LIST_INFO));
		free((void *)Msg.Msg.Data[0]);

		printf("CCAMMenuHandler::handleCamMsg: slot %d menu ready, title %s choices %d\n", curslot, convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), pMenu->choice_nb);

		int menuret = menu_return::RETURN_REPAINT;
		int selected = -1;
		if(pMenu->choice_nb && from_menu) {
			CMenuWidget* menu = new CMenuWidget(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), NEUTRINO_ICON_SETTINGS);
			menu->enableSaveScreen(true);

			CMenuSelectorTarget * selector = new CMenuSelectorTarget(&selected);
			int slen = strlen(pMenu->subtitle);
			if(slen) {
				char * sptr = pMenu->subtitle;
				char * tptr = sptr;
				int bpos = 0;
				for(int li = 0; li < slen; li++) {
					if((tptr[li] == 0x8A) || ((bpos > 38) && (tptr[li] == 0x20)) ) {
						bpos = 0;
						tptr[li] = 0;
						printf("CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr);
						menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false));
						sptr = &tptr[li+1];
					}
					bpos++;
				}
				if(strlen(sptr)) {
					printf("CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr);
					menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false));
				}
			}
			for(i = 0; (i < pMenu->choice_nb) && (i < MAX_MMI_ITEMS); i++) {
				snprintf(cnt, sizeof(cnt), "%d", i);
				if(sublevel)
					menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt));
				else
					menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1)));
			}
			slen = strlen(pMenu->bottom);
			if(slen) {
				printf("CCAMMenuHandler::handleCamMsg: bottom: %s\n", pMenu->bottom);
				menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false));
			}

			menuret = menu->exec(NULL, "");
			delete menu;
			delete selector;
		} else {

			char lstr[255];
			int slen = 0;

			if(strlen(pMenu->title))
				slen += snprintf(&lstr[slen], 255-slen, "%s\n", pMenu->title);
			if(strlen(pMenu->subtitle))
				slen += snprintf(&lstr[slen], 255-slen, "%s\n", pMenu->subtitle);
			if(strlen(pMenu->bottom))
				slen += snprintf(&lstr[slen], 255-slen, "%s\n", pMenu->bottom);

			for(i = 0; (i < pMenu->choice_nb) && (i < MAX_MMI_ITEMS); i++)
				slen += snprintf(&lstr[slen], 255-slen, "%s\n", pMenu->choice_item[i]);

			ShowHint(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str());
			return 0;
		}

		if(sublevel)
			return menuret == menu_return::RETURN_EXIT_ALL ? 3 : 0;

		if(selected >= 0) {
			printf("CCAMMenuHandler::handleCamMsg: selected %d:%s sublevel %s\n", selected, pMenu->choice_item[i], sublevel ? "yes" : "no");
			ca->MenuAnswer(SlotType, curslot, selected+1);
			timeoutEnd = CRCInput::calcTimeoutEnd(10);
			return 1;
		} else {
			return menuret == menu_return::RETURN_EXIT_ALL ? 3 : 2;
		}
	}
	else if(MsgId == CA_MESSAGE_MSG_MMI_REQ_INPUT) {
		if (!(Msg.Flags & CA_MESSAGE_HAS_PARAM1_DATA))
			return -1;

		memmove(pMmiEnquiry, (MMI_ENQUIRY_INFO *)Msg.Msg.Data[0], sizeof(MMI_ENQUIRY_INFO));
		free((void *)Msg.Msg.Data[0]);
		printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str());

		std::string ENQAnswer;

		if (/* !from_menu && */ g_settings.ci_save_pincode && pMmiEnquiry->blind != 0 && (int) g_settings.ci_pincode.length() == pMmiEnquiry->answerlen) {
			static int acount = 0;
			static time_t last_ask = 0;

			ENQAnswer = g_settings.ci_pincode;
			printf("CCAMMenuHandler::handleCamMsg: using saved answer [%s] (#%d, time diff %d)\n", ENQAnswer.c_str(), acount, (int) (time_monotonic() - last_ask));
			if ((time_monotonic() - last_ask) < 10) {
				acount++;
				if (acount > 4)
					g_settings.ci_pincode.clear();
			} else {
				last_ask = time_monotonic();
				acount = 0;
			}
		} else {
			CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE);
			Inquiry->exec(NULL, "");
			delete Inquiry;
			g_settings.ci_pincode = ENQAnswer;
		}

		printf("CCAMMenuHandler::handleCamMsg: input=[%s]\n", ENQAnswer.c_str());

		if((int) ENQAnswer.length() != pMmiEnquiry->answerlen) {
			printf("CCAMMenuHandler::handleCamMsg: wrong input len\n");
			ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer.c_str(), 0);
			return 1; //FIXME
		} else {
			ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer.c_str(), pMmiEnquiry->answerlen);
			return 1;
		}
	}
	else if(MsgId == CA_MESSAGE_MSG_MMI_CLOSE) {
		int timeout = 0;
		if (Msg.Flags & CA_MESSAGE_HAS_PARAM1_INT)
			timeout = Msg.Msg.Param[0];
		printf("CCAMMenuHandler::handleCamMsg: close request slot: %d (timeout %d)\n", curslot, timeout);
		//ca->MenuClose(SlotType, curslot);
		if (timeout)
			close_timer = g_RCInput->addTimer(timeout*1000*1000, true);
		else
			msgret = messages_return::cancel_info;
		return 0;
	}
	else if(MsgId == CA_MESSAGE_MSG_MMI_TEXT) {
		printf("CCAMMenuHandler::handleCamMsg: text\n");
	}
	else if(MsgId == CA_MESSAGE_MSG_CHANNEL_CHANGE) {
		if (!(Msg.Flags & CA_MESSAGE_HAS_PARAM1_LONG))
			return -1;

		t_channel_id chid = Msg.Msg.ParamLong[0];
		printf("CCAMMenuHandler::handleCamMsg: CA_MESSAGE_MSG_CHANNEL_CHANGE: %" PRIx64 "\n", chid);
		CZapitChannel * channel = CServiceManager::getInstance()->FindChannel48(chid);
		if (!channel) {
			printf("CCAMMenuHandler::handleCamMsg: channel %" PRIx64 "not found\n", chid);
			return -1;
		}
		CNeutrinoApp::getInstance()->zapTo(channel->getChannelID());
	} 
	return 1;
}
Ejemplo n.º 8
0
/* search for the presence of language from given EIT event descriptors*/
bool eServiceEvent::loadLanguage(Event *evt, const std::string &lang, int tsidonid)
{
	bool retval=0;
	std::string language = lang;
	for (DescriptorConstIterator desc = evt->getDescriptors()->begin(); desc != evt->getDescriptors()->end(); ++desc)
	{
		switch ((*desc)->getTag())
		{
			case LINKAGE_DESCRIPTOR:
				m_linkage_services.clear();
				break;
			case SHORT_EVENT_DESCRIPTOR:
			{
				const ShortEventDescriptor *sed = (ShortEventDescriptor*)*desc;
				std::string cc = sed->getIso639LanguageCode();
				std::transform(cc.begin(), cc.end(), cc.begin(), tolower);
				int table=encodingHandler.getCountryCodeDefaultMapping(cc);
				if (language == "---" || language.find(cc) != std::string::npos)
				{
					/* stick to this language, avoid merging or mixing descriptors of different languages */
					language = cc;
					m_event_name += replace_all(replace_all(convertDVBUTF8(sed->getEventName(), table, tsidonid), "\n", " "), "\t", " ");
					m_short_description += convertDVBUTF8(sed->getText(), table, tsidonid);
					retval=1;
				}
				break;
			}
			case EXTENDED_EVENT_DESCRIPTOR:
			{
				const ExtendedEventDescriptor *eed = (ExtendedEventDescriptor*)*desc;
				std::string cc = eed->getIso639LanguageCode();
				std::transform(cc.begin(), cc.end(), cc.begin(), tolower);
				int table=encodingHandler.getCountryCodeDefaultMapping(cc);
				if (language == "---" || language.find(cc) != std::string::npos)
				{
					/* stick to this language, avoid merging or mixing descriptors of different languages */
					language = cc;
					/*
					 * Bit of a hack, some providers put the event description partly in the short descriptor,
					 * and the remainder in extended event descriptors.
					 * In that case, we cannot really treat short/extended description as separate descriptions.
					 * Unfortunately we cannot recognise this, but we'll use the length of the short description
					 * to guess whether we should concatenate both descriptions (without any spaces)
					 */
					if (m_extended_description.empty() && m_short_description.size() >= 180)
					{
						m_extended_description = m_short_description;
						m_short_description = "";
					}
					m_extended_description += convertDVBUTF8(eed->getText(), table, tsidonid);
					retval=1;
				}
#if 0
				const ExtendedEventList *itemlist = eed->getItems();
				for (ExtendedEventConstIterator it = itemlist->begin(); it != itemlist->end(); ++it)
				{
					m_extended_description += '\n';
					m_extended_description += convertDVBUTF8((*it)->getItemDescription());
					m_extended_description += ' ';
					m_extended_description += convertDVBUTF8((*it)->getItem());
				}
#endif
				break;
			}
			default:
				break;
		}
	}
	if ( retval == 1 )
	{
		for (DescriptorConstIterator desc = evt->getDescriptors()->begin(); desc != evt->getDescriptors()->end(); ++desc)
		{
			switch ((*desc)->getTag())
			{
				case COMPONENT_DESCRIPTOR:
				{
					const ComponentDescriptor *cp = (ComponentDescriptor*)*desc;
					eComponentData data;
					data.m_streamContent = cp->getStreamContent();
					data.m_componentType = cp->getComponentType();
					data.m_componentTag = cp->getComponentTag();
					data.m_iso639LanguageCode = cp->getIso639LanguageCode();
					std::transform(data.m_iso639LanguageCode.begin(), data.m_iso639LanguageCode.end(), data.m_iso639LanguageCode.begin(), tolower);
					int table=encodingHandler.getCountryCodeDefaultMapping(data.m_iso639LanguageCode);
					data.m_text = convertDVBUTF8(cp->getText(),table,tsidonid);
					m_component_data.push_back(data);
					break;
				}
				case LINKAGE_DESCRIPTOR:
				{
					const LinkageDescriptor  *ld = (LinkageDescriptor*)*desc;
					if ( ld->getLinkageType() == 0xB0 )
					{
						eServiceReferenceDVB dvb_ref;
						dvb_ref.type = eServiceReference::idDVB;
						dvb_ref.setServiceType(1);
						dvb_ref.setTransportStreamID(ld->getTransportStreamId());
						dvb_ref.setOriginalNetworkID(ld->getOriginalNetworkId());
						dvb_ref.setServiceID(ld->getServiceId());
						const PrivateDataByteVector *privateData = ld->getPrivateDataBytes();
						dvb_ref.name = convertDVBUTF8((const unsigned char*)&((*privateData)[0]), privateData->size(), 1, tsidonid);
						m_linkage_services.push_back(dvb_ref);
					}
					break;
				}
				case CONTENT_DESCRIPTOR:
				{
					const ContentDescriptor *cd = (ContentDescriptor *)*desc;
					const ContentClassificationList *con = cd->getClassifications();
					for (ContentClassificationConstIterator it = con->begin(); it != con->end(); ++it)
					{
						eGenreData data;
				                data.m_level1 = (*it)->getContentNibbleLevel1();
						data.m_level2 = (*it)->getContentNibbleLevel2();
						data.m_user1  = (*it)->getUserNibble1();
						data.m_user2  = (*it)->getUserNibble2();
						m_genres.push_back(data);
					}
					break;
				}
				case PARENTAL_RATING_DESCRIPTOR:
				{
					const ParentalRatingDescriptor *prd = (ParentalRatingDescriptor *)*desc;
					const ParentalRatingList *par = prd->getParentalRatings();
					for (ParentalRatingConstIterator it = par->begin(); it != par->end(); ++it)
					{
						eParentalData data;

						data.m_country_code = (*it)->getCountryCode();
						data.m_rating = (*it)->getRating();
						m_ratings.push_back(data);
					}
					break;
				}
			}
		}
	}
	if ( m_extended_description.find(m_short_description) == 0 )
		m_short_description="";
	return retval;
}
Ejemplo n.º 9
0
bool CPmt::ParseEsInfo(ElementaryStreamInfo *esinfo, CZapitChannel * const channel)
{
	std::string description = "";
	unsigned char componentTag = 0xFF;
	CZapitAudioChannel::ZapitAudioChannelType audio_type = CZapitAudioChannel::UNKNOWN;

	uint8_t stream_type = esinfo->getType();

	bool audio = false;

	const DescriptorList * dlist = esinfo->getDescriptors();
	DescriptorConstIterator dit;
	for (dit = dlist->begin(); dit != dlist->end(); ++dit) {
		Descriptor * d = *dit;
		switch (d->getTag()) {
		case REGISTRATION_DESCRIPTOR:
			{
				RegistrationDescriptor *sd = (RegistrationDescriptor*) d;
				switch (sd->getFormatIdentifier()) {
				case 0x44545331:
				case 0x44545332:
				case 0x44545333:
					audio_type = CZapitAudioChannel::DTS;
					break;
				case 0x41432d33:
					audio_type = CZapitAudioChannel::AC3;
					break;
				default:
#ifdef DEBUG_PMT
					printf("PMT: REGISTRATION_DESCRIPTOR: %x\n", sd->getFormatIdentifier());
#endif
					break;
				}
			}
			break;
		case ISO_639_LANGUAGE_DESCRIPTOR:
			{
				Iso639LanguageDescriptor * sd = (Iso639LanguageDescriptor*) d;
				const Iso639LanguageList *languages = sd->getIso639Languages();
				Iso639LanguageConstIterator it;
				for (it = languages->begin(); it != languages->end(); ++it) {
					description = (*it)->getIso639LanguageCode();
					break;
				}
			}
			break;
		case STREAM_IDENTIFIER_DESCRIPTOR:
			{
				StreamIdentifierDescriptor *sd = (StreamIdentifierDescriptor*) d;
				componentTag = sd->getComponentTag();
			}
			break;
		case TELETEXT_DESCRIPTOR:
			{
				TeletextDescriptor *td = (TeletextDescriptor*)d;
				const VbiTeletextList *vbilist = td->getVbiTeletexts();
				VbiTeletextConstIterator it;
				DBG("teletext pid %04x\n", esinfo->getPid());
				for (it = vbilist->begin(); it != vbilist->end(); ++it) {
					VbiTeletext * vbi = *it;

					std::string lang = vbi->getIso639LanguageCode();
					uint8_t page = vbi->getTeletextPageNumber();
					uint8_t magazine = vbi->getTeletextMagazineNumber();
					DBG("teletext type %d mag %d page %d lang [%s]\n",
							vbi->getTeletextType(), magazine, page, lang.c_str());
					if (vbi->getTeletextType() == 0x01)
						channel->setTeletextLang(lang);
					else if (vbi->getTeletextType() == 0x02)
						channel->addTTXSubtitle(esinfo->getPid(), lang, magazine, page);
					else if (vbi->getTeletextType() == 0x05)
						channel->addTTXSubtitle(esinfo->getPid(), lang, magazine, page, true);
				}
				channel->setTeletextPid(esinfo->getPid());
			}
			break;
		case SUBTITLING_DESCRIPTOR:
			if(stream_type == 0x06) {
				SubtitlingDescriptor *sd = (SubtitlingDescriptor*) d;
				const SubtitlingList *sublist = sd->getSubtitlings();
				SubtitlingConstIterator it;
				for (it = sublist->begin(); it != sublist->end(); ++it) {
					Subtitling * sub = *it;

					uint16_t composition_page_id = sub->getCompositionPageId();
					uint16_t ancillary_page_id = sub->getAncillaryPageId();
					std::string lang = sub->getIso639LanguageCode();

					channel->addDVBSubtitle(esinfo->getPid(), lang, sub->getSubtitlingType(),
							composition_page_id, ancillary_page_id);
				}
			}
			break;
		case AC3_DESCRIPTOR:
			audio_type = CZapitAudioChannel::AC3;
			break;
		case ENHANCED_AC3_DESCRIPTOR:
			audio_type = CZapitAudioChannel::EAC3;
			break;
		case DTS_DESCRIPTOR:
			audio_type = CZapitAudioChannel::DTS;
			break;
		case AAC_DESCRIPTOR:
			audio_type = CZapitAudioChannel::AAC;
			break;
		case 0xC5: /* User Private descriptor - Canal+ Radio */
			if(d->getLength() >= 25) {
				uint8_t *buf = new uint8_t[2 + d->getLength()];
				if(buf){
					d->writeToBuffer(buf);
					int tsidonid =  channel->getTransportStreamId() << 16 | channel->getOriginalNetworkId();
					description = convertDVBUTF8((const char*)&buf[3], 24, 2, tsidonid);
					delete []buf;
				}
			}
			break;
		case AUDIO_STREAM_DESCRIPTOR:
			break;
		case VIDEO_STREAM_DESCRIPTOR:
			break;
		case CA_DESCRIPTOR:
			break;
		default:
			{
#ifdef DEBUG_PMT_UNUSED
				printf("PMT: descriptor %02x: ", d->getTag());
				uint8_t len = 2+d->getLength();
				uint8_t buf[len];
				d->writeToBuffer(buf);
				for(uint8_t i = 0; i < len; i++)
					printf("%02x ", buf[i]);
				printf("\n");
#endif
			}
			break;
		}
	}
	switch (stream_type) {
	case 0x01:
	case 0x02:
	case 0x1b: // AVC Video Stream (MPEG4 H264)
		channel->setVideoPid(esinfo->getPid());
		channel->type = (stream_type == 0x1b); //FIXME
		DBG("vpid %04x stream %d type %d\n", esinfo->getPid(), stream_type, channel->type);
		break;
	case 0x03:
	case 0x04:
		audio_type = CZapitAudioChannel::MPEG;
		audio = true;
		break;
	case 0x06:
		if(audio_type != CZapitAudioChannel::UNKNOWN)
			audio = true;
		break;
	case 0x0F: // AAC ADTS
	case 0x11: // AAC LATM
		audio_type = CZapitAudioChannel::AAC;
		audio = true;
		break;
	case 0x81:
		audio_type = CZapitAudioChannel::AC3;
		audio = true;
		break;
	default:
#ifdef DEBUG_PMT_UNUSED
		printf("PMT: pid %04x stream_type: %02x\n", esinfo->getPid(), stream_type);
#endif
		break;
	}
	if(audio) {
		if(description.empty()) {
			char str[DESC_MAX_LEN];
//			snprintf(str, DESC_MAX_LEN, "Unknown 0x%04x", esinfo->getPid());
			snprintf(str, DESC_MAX_LEN, "Unknown");
			description = str;
		}
		DBG("apid %04x stream %02x type %d [%s]\n", esinfo->getPid(), stream_type,
				(int) audio_type, description.c_str());
		if(CServiceScan::getInstance()->Scanning()) {
			if(channel->getPreAudioPid() == 0)
				channel->setAudioPid(esinfo->getPid());
		} else
			channel->addAudioChannel(esinfo->getPid(), audio_type, description, componentTag);
	}
	return true;
}
Ejemplo n.º 10
0
int eMMI_UI::processMMIData(int slot_id, const unsigned char *tag, const void *data, int len)
{
	switch (tag[2])
	{
	case 0x00:		//Tmmi_close
	{
		unsigned char *d=(unsigned char*)data;
		int timeout=0;
		if (d[0] == 1)
		{
			if (len > 1)
				timeout = d[1];
			else
			{
				eDebug("mmi close tag incorrect.. no timeout given.. assume 5 seconds");
				timeout = 5;
			}
		}
		else if (d[0] > 1)
			eDebug("mmi close tag incorrect.. byte 4 should be 0 or 1");
		mmiScreenClose(slot_id, timeout);
		break;
	}
	case 0x01:
		eDebug("MMI display control");
		if (((unsigned char*)data)[0] != 1)
			eDebug("kann ich nicht. aber das sag ich dem modul nicht.");
		return 1;
	case 0x07:		//Tmenu_enq
	{
		unsigned char *d=(unsigned char*)data;
		unsigned char *max=((unsigned char*)d) + len;
		int textlen = len - 2;
		eDebug("in enq");
		if ((d+2) > max)
			break;
		int blind = *d++ & 1;
		int alen = *d++;
			eDebug("%d bytes text", textlen);
		if ((d+textlen) > max)
			break;
		char str[textlen + 1];
		memcpy(str, ((char*)d), textlen);
		str[textlen] = '\0';
		eDebug("enq-text: %s",str);
		mmiScreenEnq(slot_id, blind, alen, (char*)convertDVBUTF8(str).c_str());
		break;
	}
	case 0x09:		//Tmenu_last
	case 0x0c:		//Tlist_last
	{
		unsigned char *d=(unsigned char*)data;
		unsigned char *max=((unsigned char*)d) + len;
		int pos = 0;
		eDebug("Tmenu_last");
		if (d > max)
			break;
		int n=*d++;
		if(tag[2] == 0x09)	//menu
			mmiScreenBegin(slot_id, 0);
		else								//list
			mmiScreenBegin(slot_id, 1);
		if (n == 0xFF)
			n=0;
		else
			n++;
		eDebug("%d texts", n);
		for (int i=0; i < (n+3); ++i)
		{
			int textlen;
			if ((d+3) > max)
				break;
			eDebug("text tag: %02x %02x %02x", d[0], d[1], d[2]);
			d+=3;
			d+=eDVBCISession::parseLengthField(d, textlen);
			eDebug("%d bytes text", textlen);
			if ((d+textlen) > max)
				break;
			char str[textlen + 1];
			memcpy(str, ((char*)d), textlen);
			str[textlen] = '\0';
			mmiScreenAddText(slot_id, pos++, (char*)convertDVBUTF8(str).c_str());
			eDebug("[eMMI_UI] %s", str);
			d += textlen;
		}
		mmiScreenFinish(slot_id);
		break;
	}
	default:
		eDebug("unknown APDU tag 9F 88 %02x", tag[2]);
		break;
	}
	return 0;
}
Ejemplo n.º 11
0
std::string convertDVBUTF8(const unsigned char *data, int len, int table, int tsidonid)
{
	if (!len)
		return "";

	int i=0, t=0;

	if ( tsidonid )
		encodingHandler.getTransponderDefaultMapping(tsidonid, table);

	switch(data[0])
	{
		case 1 ... 11:
			// For Thai providers, encoding char is present but faulty.
			if (table != 11)
				table=data[i]+4;
			++i;
//			eDebug("(1..11)text encoded in ISO-8859-%d",table);
			break;
		case 0x10:
		{
			int n=(data[++i]<<8);
			n |= (data[++i]);
//			eDebug("(0x10)text encoded in ISO-8859-%d",n);
			++i;
			switch(n)
			{
				case 12:
					eDebug("unsup. ISO8859-12 enc.");
					break;
				default:
					table=n;
					break;
			}
			break;
		}
		case 0x11: //  Basic Multilingual Plane of ISO/IEC 10646-1 enc  (UTF-16... Unicode)
			table = 65;
			tsidonid = 0;
			++i;
			break;
		case 0x12:
			++i;
			eDebug("unsup. KSC 5601 enc.");
			break;
		case 0x13:
			++i;
			eDebug("unsup. GB-2312-1980 enc.");
			break;
		case 0x14:
			++i;
			eDebug("unsup. Big5 subset of ISO/IEC 10646-1 enc.");
			break;
		case 0x15: // UTF-8 encoding of ISO/IEC 10646-1
			return std::string((char*)data+1, len-1);
		case 0x1F:
			{
				// Attempt to decode Freesat Huffman encoded string
				unsigned char *temp = (unsigned char *) huffmanDecoder.decode(data, len);
				if (temp)
				{
					int newlen = strlen((char*) temp);
					std::string decoded_string = convertDVBUTF8(temp, newlen, table, tsidonid);
					free(temp);
					return decoded_string;
				}
			}
			i++;
			eDebug("failed to decode bbc freesat huffman");
			break;
		case 0x0:
		case 0xC ... 0xF:
		case 0x16 ... 0x1E:
			eDebug("reserved %d", data[0]);
			++i;
			break;
	}

	bool useTwoCharMapping = !table || (tsidonid && encodingHandler.getTransponderUseTwoCharMapping(tsidonid));

	if (useTwoCharMapping && table == 5) { // i hope this dont break other transponders which realy use ISO8859-5 and two char byte mapping...
//		eDebug("Cyfra / Cyfrowy Polsat HACK... override given ISO8859-5 with ISO6397");
		table = 0;
	}

	unsigned char res[2048];
	while (i < len)
	{
		unsigned long code=0;
		if ( useTwoCharMapping && i+1 < len && (code=doVideoTexSuppl(data[i], data[i+1])) )
			i+=2;
		if (!code) {
			if (table == 65) { // unicode
				if (i+1 < len) {
					code=(data[i] << 8) | data[i+1];
					i += 2;
				}
			}
			else
				code=recode(data[i++], table);
		}
		if (!code)
			continue;
				// Unicode->UTF8 encoding
		if (code < 0x80) // identity ascii <-> utf8 mapping
			res[t++]=char(code);
		else if (code < 0x800) // two byte mapping
		{
			res[t++]=(code>>6)|0xC0;
			res[t++]=(code&0x3F)|0x80;
		} else if (code < 0x10000) // three bytes mapping