Ejemplo n.º 1
0
CA_QUERY_STATUS_EN CA_STOP_PRODUCT_ListSendQuery(ia_word32 wResourceId)
{
	ia_msg_handle pvMsg;
	msg_product_list_query_st stProductList;
	ia_byte sectorCnt = 0;

	/* check the input parameter smartcardId */
	sectorCnt = CA_SCARD_GetSectorNumber(wResourceId);
	if (sectorCnt == INVALID_SC_SECTOR)
		return CA_QUERY_FAIL;
	CA_DBG_V(("<= MSG_PRODUCT_LIST_QUERY, sectorCnt = %d\n", sectorCnt));

	pvMsg = IA_OpenOutputMessage(sizeof(msg_product_list_query_st), sizeof
		(msg_product_list_query_st));

	if (pvMsg != 0)
	{
		stProductList.wResourceId = wResourceId;
		stProductList.bGracePeriod = 0;
		stProductList.fKeepTrack = IA_TRUE;
		stProductList.fAnySector = IA_FALSE;
		stProductList.bSectorCount = sectorCnt;

		IA_WriteToMessage(pvMsg, &stProductList, sizeof
			(msg_product_list_query_st));

		if (SCELL_Message(MSG_PRODUCT_LIST_QUERY, 0, IA_GetOutputMessageLength
			(pvMsg), IA_GetOutputMessage(pvMsg)) == IA_SUCCESS)
		{
			/* The buffer will be freed by the receiver. */
			IA_CloseMessage(pvMsg, IA_FALSE);
		}
		else
		{
			/* Message not sent. We must free the buffer. */
			IA_CloseMessage(pvMsg, IA_TRUE);
			CA_ERROR(("Sending MSG_PRODUCT_LIST_QUERY failed.\n"));
			CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MESSAGE);
			return CA_QUERY_FAIL;
		}
	}
	else
	{
		CA_ERROR(("Malloc error.\n"));
		CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
		return CA_QUERY_FAIL;
	}

	return CA_QUERY_SUCCESS;
}
Ejemplo n.º 2
0
////////////////////////////////////////////////////////////
/// Construit le shader à partir des 2 fichiers
/// <name>.vert
/// <name>.frag
///
/// \param shaderFile_ : fichier vertex shader : <name>.vertexshader
///
////////////////////////////////////////////////////////////
GLShader::GLShader(IFile *pFile_)
{
	std::string fragmentFile = pFile_->Filename();

	size_t pos = fragmentFile.find(IRenderer::Get().GetShaderFileExtension());

	if (pos != std::string::npos)
	{
		fragmentFile = fragmentFile.substr(0, pos) + ".frag";
		IFile *pFragFile = MediaManager::Instance().FindMedia(fragmentFile, false);

		if (pFragFile == nullptr)
		{
			throw CLoadingFailed(fragmentFile, "GLShader() : Can't find the fragment shader (maybe add a reference to the right directory ?)");
		}

		if (pFragFile->Exists() == false)
		{
			throw CLoadingFailed(fragmentFile, "GLShader() : The fragment shader doesn't exist");
		}

		m_ProgramID = LoadShaderFrombuffer(pFile_->GetBuffer(), pFragFile->GetBuffer());

		DELETE_AO pFragFile;
	}
	else
	{
		CA_ERROR("GLShader() : Can't find the character '%s' in the filename '%s' to get the fragment shader.", 
			IRenderer::Get().GetShaderFileExtension(), pFile_->Filename().c_str());
	}
}
Ejemplo n.º 3
0
/* For Expired Product*/
CA_QUERY_STATUS_EN CA_EXPIRED_PRODUCTSendQuery(ia_word32 wResourceId)
{
	ia_msg_handle pvMsg;
	msg_expired_product_query_st stExpiredProduct;

	CA_DBG_V(("<= MSG_EXPIRED_PRODUCT_QUERY\n"));

	pvMsg = IA_OpenOutputMessage(sizeof(msg_expired_product_query_st), sizeof
		(msg_expired_product_query_st));

	CA_DBG_V(("[CA_EXPIRED_PRODUCTSendQuery]Open an output message\n"));
	if (pvMsg != 0)
	{
		stExpiredProduct.wResourceId = wResourceId;
		CA_DBG_V(("[CA_EXPIRED_PRODUCTSendQuery]ResourceId is %d\n", wResourceId));

		IA_WriteToMessage(pvMsg, &stExpiredProduct, sizeof(msg_expired_product_query_st));

		/* jyou: 3.4.2 multiple smart card */
		if (SCELL_Message(MSG_EXPIRED_PRODUCT_QUERY, (ia_word16)wResourceId /*0*/,
			IA_GetOutputMessageLength(pvMsg), IA_GetOutputMessage(pvMsg)) ==
			IA_SUCCESS)
		{
			/* The buffer will be freed by the receiver. */
			IA_CloseMessage(pvMsg, IA_FALSE);
		}
		else
		{
			/* Message not sent. We must free the buffer. */
			IA_CloseMessage(pvMsg, IA_TRUE);
			CA_ERROR(("Sending MSG_EXPIRED_PRODUCT_QUERY failed.\n"));
			CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MESSAGE);
			return CA_QUERY_FAIL;
		}

	}
	else
	{
		CA_ERROR(("Malloc error.\n"));
		CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
		return CA_QUERY_FAIL;
	}

	CA_DBG_V(("Returned from MSG_EXPIRED_PRODUCT_QUERY\n"));
	return CA_QUERY_SUCCESS;

}
Ejemplo n.º 4
0
void ScriptComponent::Initialize()
{
    m_pScriptObject = ScriptEngine::Instance().CreateScriptObjectFromClassID(m_ClassID, GetEntity());

    if (m_pScriptObject != nullptr)
    {
        m_pScriptObject->OnInitialize();
    }
    else
    {
        CA_ERROR("Error when create script object from the class id %d\n", m_ClassID);
    }
}
Ejemplo n.º 5
0
	void SetFrameEvent::Activate(Animation *pAnim_)
	{
		CA_ASSERT(pAnim_ != nullptr, "SetFrameEvent::Activate() : Animation is nullptr");

		Animation2D *pAnim2D = static_cast<Animation2D *>(pAnim_);

		if (pAnim2D != nullptr)
		{
			pAnim2D->CurrentFrame(m_FrameID.c_str());
		}
		else
		{
			CA_ERROR("SetFrameEvent.Activate() : Animation(%d - %s) is not a Animation2D\n", 
				pAnim_->ID(), pAnim_->GetName().c_str());
		}
	}
Ejemplo n.º 6
0
/*
* Description: Query control for CA_QC_MAIL type.
*
* Parameters : pstScData - Pointer to the data buffer provided by the manufacturer.
*
* Returns    : CA_QUERY_SUCCESS       - Successful.
*              CA_QUERY_FAIL          - Failed.
*/
CA_QUERY_STATUS_EN CA_MAIL_MailQueryControl( ia_word32 wHandle, void* pCAClientMsg )
{
	MESSAGE *pMailMsg;
	CA_MAIL_T *caMail;
	ia_word16 wNumGroups = CA_SVCINFO_GetSvcMaxNumber(); /* CA_TASK_GetInitCfg()
														->wNumGroups; */

	CA_PARAM_NOT_USED( wHandle );
	caMail = ( CA_MAIL_T* ) pCAClientMsg;

	if (caMail->bIndex >= MAX_MAILS *wNumGroups)
	{
		CA_ERROR(("Mail index is out of limit.\n"));
		return CA_QUERY_FAIL;
	}

	pMailMsg = IRD_MSG_GetMailMsg(caMail->bIndex);
	caMail->bType = CA_MAIL;
	return BuildCaMailAnnounce(caMail, pMailMsg);
}
Ejemplo n.º 7
0
/*
* Description: Query control for CA_QC_ANNOUNCE type.
*
* Parameters : pstScData - Pointer to the data buffer provided by the manufacturer.
*
* Returns    : CA_QUERY_SUCCESS       - Successful.
*              CA_QUERY_FAIL          - Failed.
*/
CA_QUERY_STATUS_EN CA_MAIL_AnnounceQueryControl( ia_word32 wHandle, void* pCAClientMsg )
{
	MESSAGE *pMailMsg;
	CA_MAIL_T *caMail;

	ia_word16 wNumGroups = CA_SVCINFO_GetSvcMaxNumber(); /* CA_TASK_GetInitCfg()
														 ->wNumGroups; */

	CA_PARAM_NOT_USED(astrSCellMsgDisplay);	/* to supress warning */
	CA_PARAM_NOT_USED( wHandle );
	caMail = ( CA_MAIL_T* ) pCAClientMsg;
	if (caMail->bIndex >= MAX_ANNOUNCEMENTS *wNumGroups)
	{
		CA_ERROR(("Annoucement index is out of limit.\n"));
		return CA_QUERY_FAIL;
	}

	pMailMsg = IRD_MSG_GetAnnounceMsg(caMail->bIndex);
	caMail->bType = CA_ANNOUNCE;
	return BuildCaMailAnnounce(caMail, pMailMsg);
}
Ejemplo n.º 8
0
CA_QUERY_STATUS_EN CA_EXTENDED_PRODUCT_ListSendQuery(CA_EPL_QUERY_T *eplQuery)
{
	ia_msg_handle pvMsg;
	ia_byte sectorCnt = 0, bSectorNum;
	ia_byte bSectorID;
	ia_sint16 i;
	msg_extended_product_list_query_st stExProductList;
	ia_word16 wLength;
	ia_word32 wResourceId = 0;
	CA_LOCAL_SMARTCARD_INFO_T *pstSmartCard;

	CA_DBG_V(("<= MSG_EXTENDED_PRODUCT_LIST_QUERY\n"));

	if (eplQuery != 0)
	{
		sectorCnt = eplQuery->sectorCnt;
	}
	else
	{
		return CA_QUERY_FAIL;
	}
	wResourceId = eplQuery->wResourceId;

	/* jyou: 3.4.3 SCR#25649 2007-03-05 start */
	pstSmartCard = CA_LOCAL_FindSmartCard( eplQuery->wResourceId );
	if ( pstSmartCard == 0 )
	{
		CA_ERROR( ("Smart Card [%d] not available.\n", eplQuery->wResourceId) );
		return CA_QUERY_FAIL;
	}
	bSectorNum = pstSmartCard->bSectorCount; /* the actual sector number in card */
	if ( sectorCnt < bSectorNum && sectorCnt > 0 )
	{ /* a valid sector count is input */
		stExProductList.fAnySector = IA_FALSE;
	}
	else
	{ /* an invalid one */
		stExProductList.fAnySector = IA_TRUE;
		/* If fAnySector set to IA_TRUE, The list of sectors is then ignored and must be empty. */
		sectorCnt = 0;
	}
	/* jyou: 3.4.3 SCR#25649 2007-03-05 end */

	wLength = (ia_word16)(sizeof(msg_extended_product_list_query_st) + sectorCnt * sizeof(ia_byte));
	pvMsg = IA_OpenOutputMessage(wLength, sizeof(ia_byte));

	if (pvMsg != 0)
	{
		stExProductList.wResourceId = eplQuery->wResourceId;
		stExProductList.bSectorCount = sectorCnt;

		IA_WriteToMessage(pvMsg, &stExProductList, sizeof(msg_extended_product_list_query_st));

		for (i = 0; i < sectorCnt; i++)
		{
			bSectorID = eplQuery->sectorIndex[i];
			/* jyou: 3.4.3.6 SCR#26045 2007-06-01 */
			if ( bSectorID == INVALID_SC_SECTOR )
			{
				CA_ERROR(("Invalid sector number.\n"));
				IA_CloseMessage(pvMsg, IA_TRUE);
				return CA_QUERY_FAIL;
			}

			IA_WriteToMessage(pvMsg, &bSectorID, sizeof(ia_byte));
		}

		/* jyou: 3.4.2 multiple smart cards fix */
		if (SCELL_Message(MSG_EXTENDED_PRODUCT_LIST_QUERY, (ia_word16)wResourceId,
			IA_GetOutputMessageLength(pvMsg), IA_GetOutputMessage(pvMsg)) ==
			IA_SUCCESS)
		{
			/* The buffer will be freed by the receiver. */
			IA_CloseMessage(pvMsg, IA_FALSE);
		}
		else
		{
			/* Message not sent. We must free the buffer. */
			IA_CloseMessage(pvMsg, IA_TRUE);
			CA_ERROR(("Sending MSG_EXTENDED_PRODUCT_LIST_QUERY failed.\n"));
			CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MESSAGE);
			return CA_QUERY_FAIL;
		}
	}
	else
	{
		CA_ERROR(("Malloc error.\n"));
		CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
		return CA_QUERY_FAIL;
	}

	CA_DBG_V(("Return from MSG_EXTENDED_PRODUCT_LIST_QUERY\n"));
	return CA_QUERY_SUCCESS;
} /* CA_EXTENDED_PRODUCT_ListSendQuery */
Ejemplo n.º 9
0
CA_QUERY_STATUS_EN CA_PRODUCT_CheckSendQuery(ia_bool fPVRProd, CA_QUERY_PRODUCT_CHECK_T *pQueryProductCheck)
{
	ia_msg_handle pvMsg;
	msg_product_check_query_st stProductCheck;
	msg_product_check_query_product_st stProduct;
	 /* ia_byte sectorNum; */
	ia_byte totalProductNum = 0;
	ia_word32 wResId;

	ia_word16 wLength;
	ia_sint16 i;

	if (pQueryProductCheck == 0)
	{
		return CA_QUERY_FAIL;
	}
	if ((pQueryProductCheck->pstQuerySector == 0) && (pQueryProductCheck->bProductCount > 0))
	{
		return CA_QUERY_FAIL;
	}

	if (pQueryProductCheck->bRequestType == REQUEST_TYPE_QUERY)
	{
		totalProductNum = pQueryProductCheck->bProductCount;
		wLength = (ia_word16)(sizeof(msg_product_check_query_st) + totalProductNum * sizeof
		(msg_product_check_query_product_st));

		 pvMsg = IA_OpenOutputMessage(wLength, sizeof (msg_product_check_query_product_st));
		 if (pvMsg == 0)
		 {
			return CA_QUERY_FAIL;
		 }

		ansi_memset((void *)&stProductCheck, 0, sizeof(msg_product_check_query_product_st));
		stProductCheck.wResourceId = pQueryProductCheck->wResourceId;
		stProductCheck.bGracePeriod = pQueryProductCheck->bGracePeriod;
		stProductCheck.fKeepTrack = pQueryProductCheck->fKeepTrack;
		stProductCheck.bProductCount = totalProductNum;

		IA_WriteToMessage(pvMsg, &stProductCheck, sizeof
			(msg_product_check_query_st));

		for (i = 0; i < totalProductNum; i++)
		{
			if (pQueryProductCheck->pstQuerySector == 0)
			{
				CA_ERROR(("Sending MSG_PRODUCT_CHECK_QUERY failed. sector memery error\n"));
				IA_CloseMessage(pvMsg, IA_TRUE);
				return CA_QUERY_FAIL;
			}

			ansi_memset((void *)&stProduct, 0, sizeof(msg_product_check_query_product_st));
			stProduct.bSector = pQueryProductCheck->pstQuerySector[i].bSector;
			stProduct.fAnySector = pQueryProductCheck->pstQuerySector[i].fAnySector;
			stProduct.wProduct = pQueryProductCheck->pstQuerySector[i].wProduct;

			IA_WriteToMessage(pvMsg, &stProduct, sizeof (msg_product_check_query_product_st));

		}

		if (SCELL_Message(MSG_PRODUCT_CHECK_QUERY, 0, IA_GetOutputMessageLength
			(pvMsg), IA_GetOutputMessage(pvMsg)) == IA_SUCCESS)
		{
			/* The buffer will be freed by the receiver. */
			IA_CloseMessage(pvMsg, IA_FALSE);
		}
		else
		{
			/* Message not sent. We must free the buffer. */
			IA_CloseMessage(pvMsg, IA_TRUE);
			CA_ERROR(("Sending MSG_PRODUCT_CHECK_QUERY failed.\n"));
			CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MESSAGE);
			return CA_QUERY_FAIL;
		}
	}

	if (pQueryProductCheck->bRequestType == REQUEST_TYPE_REPLY)
	{
		/* jyou: 3.4.2 SCR#25328, a temporary solution, this piece of code needs to be reviewed */
		wResId = FindSmartCardIndex( pQueryProductCheck->wResourceId );
		if (wResId >= SC_SLOT_MAX)
		{
			return CA_QUERY_FAIL;
		}
		if (fPVRProd == IA_TRUE)
		{
			totalProductNum = pQueryProductCheck->bProductCount = astProductCheck[wResId].bProductCount;

			for (i = 0; i < totalProductNum; i++)
			{
				pQueryProductCheck->pstQuerySector[i].bSector = astProductCheck[wResId].pstQuerySector[i].bSector;
				pQueryProductCheck->pstQuerySector[i].fSectorValid = astProductCheck[wResId].pstQuerySector[i].fSectorValid;
				pQueryProductCheck->pstQuerySector[i].fProductValid = astProductCheck[wResId].pstQuerySector[i].fProductValid;
				pQueryProductCheck->pstQuerySector[i].wProduct = astProductCheck[wResId].pstQuerySector[i].wProduct;
			}
		}
		else
		{
			for (i = 0; i < pQueryProductCheck->bProductCount; i++)
			{
				pQueryProductCheck->pstQuerySector[i].bSector = astProductBlock[wResId].astProduct[i].bSector;
				pQueryProductCheck->pstQuerySector[i].fSectorValid = astProductBlock[wResId].astProduct[i].fSectorValid;
				pQueryProductCheck->pstQuerySector[i].fProductValid = astProductBlock[wResId].astProduct[i].fProductValid;
				pQueryProductCheck->pstQuerySector[i].wProduct = astProductBlock[wResId].astProduct[i].wProduct;
			}
		}
	}

	return CA_QUERY_SUCCESS;
}
Ejemplo n.º 10
0
int app_table_ota_monitor_filter_restart(void)
{	
	handle_t filter;
	uint8_t match[8] = {0,};
	uint8_t mask[8] = {0,};

	int32_t ret = 0;
	match[0] = ota_table_id;
	mask[0]  = 0xFF;
	match[6] = 0x00; // section number 0
	mask[6]  = 0xFF;
	app_porting_psi_demux_lock();

	if (0x1fff == ota_pid)
	{
		/*
		 * ota pid invalid 
		 */
		app_porting_psi_demux_unlock();
		return 0;
	}


	CAS_Dbg("app_table_ota_monitor_filter_restart\n");


	if (0 != ota_filter)
	{
		//				ret = GxDemux_FilterDisable(ota_filter);
		//				CHECK_RET(DEMUX,ret);
		ret = GxDemux_FilterFree(ota_filter);
		CHECK_RET(DEMUX,ret);
		ota_filter = 0;
	}
	if (0 != ota_channel)
	{
		ret = GxDemux_ChannelFree(ota_channel);
		CHECK_RET(DEMUX,ret);
		ota_channel = 0;
	}

	ota_channel = GxDemux_ChannelAllocate(0, ota_pid);
	if ((0 == ota_channel)||(-1 == ota_channel))
	{
		CA_ERROR(" ota_channel=0x%x\n",ota_channel);
		ota_channel = 0;
		app_porting_psi_demux_unlock();
		return 0;
	}
	filter = GxDemux_FilterAllocate(ota_channel);
	if (( 0 == filter)||(-1 == filter))
	{
		ret = GxDemux_ChannelFree(ota_channel);
		CHECK_RET(DEMUX,ret);
		ota_channel = 0;

		CA_ERROR(" filter=0x%x\n",filter);
		filter = 0;
		app_porting_psi_demux_unlock();
		return 0;
	}


	ret = GxDemux_FilterSetup(filter, match, mask, TRUE, TRUE,0, 8);
	CHECK_RET(DEMUX,ret);
	//	GxCA_DemuxFilterRigsterNotify(filter, app_table_cat_filter_notify,NULL);
	ret = GxDemux_ChannelEnable(ota_channel);
	CHECK_RET(DEMUX,ret);
	ret = GxDemux_FilterEnable(filter);
	CHECK_RET(DEMUX,ret);
	ota_filter = filter;
	app_porting_psi_demux_unlock();

	return 0;
}
Ejemplo n.º 11
0
int app_table_ota_monitor_filter_open(uint16_t pid,uint8_t tabieid)
{
	handle_t filter;
	uint8_t match[8] = {0,};
	uint8_t mask[8] = {0,};

	int32_t ret = 0;
	match[0] = tabieid;
	mask[0]  = 0xFF;
	match[6] = 0x00; // section number 0
	mask[6]  = 0xFF;


	CAS_Dbg("app_table_ota_monitor_filter_open\n");
	app_porting_psi_demux_lock();

	if(ota_channel != 0)
	{
		printf("ota_channel = 0x%x\n",ota_channel);
		app_porting_psi_demux_unlock();

		return 0;
	}
	printf("!!!!!!!!!!app_table_ota_monitor_filter_open!!!!!!!!!!!!!!!!!\n");
	ota_channel = GxDemux_ChannelAllocate(0, pid);
	if ((0 == ota_channel)||(-1 == ota_channel))
	{
		CA_ERROR("  nit_channel=0x%x\n",ota_channel);
		ota_channel = 0;
		app_porting_psi_demux_unlock();

		return 0;
	}

	filter = GxDemux_FilterAllocate(ota_channel);
	if (( 0 == filter)||(-1 == filter))
	{
		ret = GxDemux_ChannelFree(ota_channel);
		CHECK_RET(DEMUX,ret);
		ota_channel = 0;

		CA_ERROR(" filter=0x%x\n",filter);
		filter = 0;
		app_porting_psi_demux_unlock();

		return 0;
	}

	ota_filter = filter;
	ret = GxDemux_FilterSetup(filter, match, mask, TRUE, TRUE,0, 8);
	CHECK_RET(DEMUX,ret);
	//	GxCA_DemuxFilterRigsterNotify(filter, app_table_nit_filter_notify,NULL);
	ret = GxDemux_ChannelEnable(ota_channel);
	CHECK_RET(DEMUX,ret);
	ret = GxDemux_FilterEnable(filter);
	CHECK_RET(DEMUX,ret);
	ota_pid = pid;
	ota_table_id = tabieid;
	app_porting_psi_demux_unlock();



	return 0;
}
Ejemplo n.º 12
0
GLuint LoadShaders(const char * vertex_file_path, const char * fragment_file_path)
{
	// Create the shaders
	GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
	GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);

	// Read the Vertex Shader code from the file
	std::string VertexShaderCode;
	std::ifstream VertexShaderStream(vertex_file_path, std::ios::in);
	if(VertexShaderStream.is_open() == true)
	{
		std::string Line = "";
		while(getline(VertexShaderStream, Line))
			VertexShaderCode += "\n" + Line;
		VertexShaderStream.close();
	}
	else
	{
		CA_ERROR("GLShader::LoadShaders() : Can't open %s.\n", vertex_file_path);
		return 0;
	}

	// Read the Fragment Shader code from the file
	std::string FragmentShaderCode;
	std::ifstream FragmentShaderStream(fragment_file_path, std::ios::in);

	if(FragmentShaderStream.is_open() == true)
	{
		std::string Line = "";
		while(getline(FragmentShaderStream, Line))
			FragmentShaderCode += "\n" + Line;
		FragmentShaderStream.close();
	}
	else
	{
		CA_ERROR("Impossible to open %s.\n", fragment_file_path);
		return 0;
	}

	GLint Result = GL_FALSE;
	int InfoLGLength;

	// Compile Vertex Shader
	CA_TRACE("Compiling shader : %d (%s)\n", VertexShaderID, vertex_file_path);
	char const * VertexSourcePointer = VertexShaderCode.c_str();
	// (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
	GLCheck(glShaderSource(VertexShaderID, 1, &VertexSourcePointer, nullptr));
	GLCheck(glCompileShader(VertexShaderID));

	// Check Vertex Shader
	GLCheck(glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result));
	GLCheck(glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLGLength));
	if (Result == GL_FALSE)
	{
		std::vector<char> VertexShaderErrorMessage(InfoLGLength+1);
		glGetShaderInfoLog(VertexShaderID, InfoLGLength, nullptr, &VertexShaderErrorMessage[0]);
		CA_ERROR("Compile vertex shader error %s\n", &VertexShaderErrorMessage[0]);
	}

	// Compile Fragment Shader
	CA_TRACE("Compiling shader : %d (%s)\n", FragmentShaderID, fragment_file_path);
	char const * FragmentSourcePointer = FragmentShaderCode.c_str();
	GLCheck(glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , nullptr));
	GLCheck(glCompileShader(FragmentShaderID));

	// Check Fragment Shader
	GLCheck(glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result));
	GLCheck(glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLGLength));
	if (Result == GL_FALSE)
	{
		std::vector<char> FragmentShaderErrorMessage(InfoLGLength+1);
		glGetShaderInfoLog(FragmentShaderID, InfoLGLength, nullptr, &FragmentShaderErrorMessage[0]);
		CA_ERROR("Compile fragment shader error %s\n", &FragmentShaderErrorMessage[0]);
	}

	// Link the program
	GLuint ProgramID = glCreateProgram();
	CA_TRACE("Linking program %d (vertex shader %d, fragment shader %d)\n", ProgramID, VertexShaderID, FragmentShaderID);		
	GLCheck(glAttachShader(ProgramID, VertexShaderID));
	GLCheck(glAttachShader(ProgramID, FragmentShaderID));
	GLCheck(glLinkProgram(ProgramID));

	// Check the program
	GLCheck(glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result));
	GLCheck(glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLGLength));
	if (Result == GL_FALSE)
	{
		if ( InfoLGLength > 1 )
		{
			std::vector<char> ProgramErrorMessage(InfoLGLength+1);
			glGetProgramInfoLog(ProgramID, InfoLGLength, nullptr, &ProgramErrorMessage[0]);
			CA_ERROR("Link program error %s\n", &ProgramErrorMessage[0]);
		}
	}

	GLCheck(glDeleteShader(VertexShaderID));
	GLCheck(glDeleteShader(FragmentShaderID));

	return ProgramID;
}
Ejemplo n.º 13
0
/*
*     ROUTINE : CA_PRODUCT_BlockQueryControl()
* DESCRIPTION : Process CA Client's Query Control reqeust CA_QC_PRODUCT_BLOCK
*       INPUT : ia_word32 wHandle - Reserved for future use.
*       void    pCAClientMsg - Pointer to the data buffer provided by CA Client.
*      OUTPUT : None
*     RETURNS : CA_QUERY_SUCCESS       - Successful.
*       CA_QUERY_FAIL          - Failed.
*       CA_QUERY_NOT_AVAILABLE - Unable to run this query.
* SIDE EFFECT : Calls SendProductBlockQueryMsg or ReadProductBlockReplyMsg depends on request type
*   CALLED BY : CA_TASK_QueryControl when INCL_PRODUCT_BLOCKING is defined
*      Author : Jane You
* Last Changed: October 18, 2006
*/
CA_QUERY_STATUS_EN CA_PRODUCT_BlockQueryControl( ia_word32 wHandle, void* pCAClientMsg )
{
	ia_sint16 i, j = 0;
	CA_QUERY_STATUS_EN status;
	CA_QUERY_PRODUCT_CHECK_T stQueryProductCheck;
	CA_ANY_PRODUCT_CHECK_T stAnyProduct;
	CA_PRODUCT_BLOCK_T  *pCaProductBlock;

	CA_PARAM_NOT_USED( wHandle );
	pCaProductBlock = (CA_PRODUCT_BLOCK_T *)pCAClientMsg;
	if (pCaProductBlock == 0)
		return CA_QUERY_FAIL;

#if 0 /* 2008-5-11 Angela: Here ResourceId indicates the smartcard resource. */
	if ( pCaProductBlock->wResourceId >= MAX_SECTOR_NUMBER )
#else
	if ( pCaProductBlock->wResourceId >= SC_SLOT_MAX)
#endif
	{
		return CA_QUERY_FAIL;
	}

	if ( pCaProductBlock->bRequestType == REQUEST_TYPE_QUERY )
	{
		ansi_memset((void *)&stAnyProduct, 0, sizeof(CA_ANY_PRODUCT_CHECK_T));
		stAnyProduct.bRequestType = REQUEST_TYPE_QUERY;
		stAnyProduct.wResourceId = pCaProductBlock->wResourceId;

		ansi_memset((void *)&stQueryProductCheck, 0, sizeof(CA_QUERY_PRODUCT_CHECK_T));
		stQueryProductCheck.bRequestType = REQUEST_TYPE_QUERY;
		stQueryProductCheck.wResourceId = pCaProductBlock->wResourceId;
		stQueryProductCheck.fKeepTrack = IA_TRUE;

		/* check and tell any product or indicated product */
		if ( pCaProductBlock->bNumEntries)   /* start check */
		{
			for (i = 0; i < pCaProductBlock->bNumEntries; i++)
			{
				if (pCaProductBlock->astProduct[i].wProduct == 0xFFFF)  /* any products on sector */
				{
					stAnyProduct.sectorIndex[stAnyProduct.bSectorCount] = pCaProductBlock->astProduct[i].bSector;
					stAnyProduct.bSectorCount++;
				}
				else  /* indicate products */
				{
					stQueryProductCheck.bProductCount++;
				}
			}

			if (stQueryProductCheck.bProductCount)  /* indicate product */
			{
				stQueryProductCheck.pstQuerySector = (CA_QUERY_SECTOR_PRODUCT_T *)OS_DRV_AllocateMemory((unsigned long)
					sizeof(CA_QUERY_SECTOR_PRODUCT_T)*(unsigned long)stQueryProductCheck.bProductCount);

				if (stQueryProductCheck.pstQuerySector == 0)
				{
					CA_ERROR(("CA_PRODUCT_BlockQueryControl: Memory allocate failed.\n"));
					CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
					return CA_QUERY_FAIL;
				}

				for (i = 0; i < pCaProductBlock->bNumEntries; i++)
				{
					if (pCaProductBlock->astProduct[i].wProduct != 0xFFFF)
					{
						stQueryProductCheck.pstQuerySector[j].fAnySector = IA_FALSE;
						stQueryProductCheck.pstQuerySector[j].bSector =  pCaProductBlock->astProduct[i].bSector;
						stQueryProductCheck.pstQuerySector[j].wProduct =  pCaProductBlock->astProduct[i].wProduct;
						j++;
					}
				}
				status = CA_PRODUCT_CheckSendQuery(IA_FALSE, &stQueryProductCheck);
				if (status == CA_QUERY_FAIL)
					return CA_QUERY_FAIL;
			}

			if (stAnyProduct.bSectorCount)
			{
				OS_DRV_DelayTask(2000);
				status = CA_ANY_PRODUCT_SendQuery(&stAnyProduct); /* just for normal products */
				if (status == CA_QUERY_FAIL)
					return CA_QUERY_FAIL;
			}

		}

		else  /* stop check */
		{
			stQueryProductCheck.fKeepTrack = IA_FALSE;
			stQueryProductCheck.bProductCount = 0;
			stQueryProductCheck.pstQuerySector = 0;
			stQueryProductCheck.bRequestType = REQUEST_TYPE_QUERY;
			status = CA_PRODUCT_CheckSendQuery(IA_FALSE, &stQueryProductCheck); /* stop check indicate product */
			if (status == CA_QUERY_FAIL)
				return CA_QUERY_FAIL;
			status = CA_STOP_ANY_PRODUCT_SendQuery(pCaProductBlock->wResourceId);
			if (status == CA_QUERY_FAIL)
				return CA_QUERY_FAIL;
		}
	}
	if (pCaProductBlock->bRequestType == REQUEST_TYPE_REPLY)
	{
		CA_ANY_PRODUCT_CHECK_T stAnyProQuery;
		ia_bool fAnyProdCheck = IA_FALSE;

		ansi_memset((void *)&stAnyProQuery, 0, sizeof(CA_ANY_PRODUCT_CHECK_T));
		ansi_memset((void *)&stQueryProductCheck, 0, sizeof(CA_QUERY_PRODUCT_CHECK_T));

		/*get the any product and indate product*/
		for (i = 0; i < pCaProductBlock->bNumEntries; i++)
		{
			if (pCaProductBlock->astProduct[i].wProduct != ANY_FTA_PRODUCT)
			{
				stQueryProductCheck.bProductCount ++;
			}
			else
			{
				if (fAnyProdCheck == IA_FALSE)
				{
					stAnyProQuery.wResourceId = pCaProductBlock->wResourceId;
					stAnyProQuery.bRequestType = REQUEST_TYPE_REPLY;
					CA_ANY_PRODUCT_SendQuery(&stAnyProQuery);
					fAnyProdCheck = IA_TRUE;
				}
			}

		}

		if (stQueryProductCheck.bProductCount)
		{
			stQueryProductCheck.wResourceId = pCaProductBlock->wResourceId;
			stQueryProductCheck.bRequestType = REQUEST_TYPE_REPLY;
			stQueryProductCheck.fKeepTrack = IA_TRUE;
			stQueryProductCheck.bGracePeriod = 0;
			stQueryProductCheck.pstQuerySector = (CA_QUERY_SECTOR_PRODUCT_T*)
				OS_DRV_AllocateMemory((unsigned long)sizeof(CA_QUERY_SECTOR_PRODUCT_T)*(unsigned long)stQueryProductCheck.bProductCount);
			if (stQueryProductCheck.pstQuerySector == 0)
			{
				CA_ERROR(("CA_PRODUCT_BlockQueryControl: Memory allocate failed.\n"));
				CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
				return CA_QUERY_FAIL;
			}
			CA_PRODUCT_CheckSendQuery(IA_FALSE, &stQueryProductCheck);
		}

		for (i = 0; i < pCaProductBlock->bNumEntries; i++)
		{
			if ( pCaProductBlock->astProduct[i].wProduct == ANY_FTA_PRODUCT )
			{
				/* fill any product */
				for (j = 0; j < MAX_SECTOR_NUMBER; j++)
				{
					if (pCaProductBlock->astProduct[i].bSector == stAnyProQuery.stQuerySector[j].bSector)
					{
						pCaProductBlock->astProduct[i].wProduct = stAnyProQuery.stQuerySector[j].wProduct;
						pCaProductBlock->astProduct[i].fSectorValid = stAnyProQuery.stQuerySector[j].fSectorValid;
						pCaProductBlock->astProduct[i].fProductValid = stAnyProQuery.stQuerySector[j].fProductValid;
						break;

					}
				}
			}
			else  /* fill indicated product */
			{
				for (j = 0; j < stQueryProductCheck.bProductCount; j++)
				{
					if (pCaProductBlock->astProduct[i].wProduct == stQueryProductCheck.pstQuerySector[j].wProduct &&
						pCaProductBlock->astProduct[i].bSector == stQueryProductCheck.pstQuerySector[j].bSector)
					{
						pCaProductBlock->astProduct[i].fSectorValid = stQueryProductCheck.pstQuerySector[j].fSectorValid;
						pCaProductBlock->astProduct[i].fProductValid = stQueryProductCheck.pstQuerySector[j].fProductValid;
					}
				}

			}
		}
		if (stQueryProductCheck.pstQuerySector)
		{
			OS_DRV_FreeMemory(stQueryProductCheck.pstQuerySector);
			stQueryProductCheck.pstQuerySector = 0;
		}
	}

	return CA_QUERY_SUCCESS;

}
Ejemplo n.º 14
0
GLuint LoadShaderFrombuffer(const char* pVertexBuffer, const char* pFragmentBuffer)
{
	std::string shaderInit;

#if CA_PLATFORM_ANDROID
	shaderInit = "#version 100\n#define GLES2\n#define texture texture2D\nprecision mediump float;\n";
#else
	shaderInit = "#version 330 core\n";
#endif

	//TODO : use shader compilation option
	shaderInit += "#pragma debug (on)\n#pragma optimize (off)\n";

	const char *pArrayString[2];

	// Create the shaders
	GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
	GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);

	GLint Result = GL_FALSE;
	int InfoLGLength;

	// Compile Vertex Shader
	pArrayString[0] = shaderInit.c_str();;
	pArrayString[1] = pVertexBuffer;
	CA_TRACE("Compiling vertex shader : %d\n", VertexShaderID);
	GLCheck(glShaderSource(VertexShaderID, 2, pArrayString, nullptr));
	GLCheck(glCompileShader(VertexShaderID));

	// Check Vertex Shader
	glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
	glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLGLength);
	if (Result == GL_FALSE)
	{
		if (InfoLGLength > 1)
		{
			std::vector<char> VertexShaderErrorMessage(InfoLGLength+1);
			glGetShaderInfoLog(VertexShaderID, InfoLGLength, nullptr, &VertexShaderErrorMessage[0]);
			CA_ERROR("Compile vertex shader error %s\n", &VertexShaderErrorMessage[0]);
		}
	}

	// Compile Fragment Shader
	pArrayString[0] = shaderInit.c_str();;
	pArrayString[1] = pFragmentBuffer;
	CA_TRACE("Compiling fragment shader : %d\n", FragmentShaderID);
	GLCheck(glShaderSource(FragmentShaderID, 2, pArrayString , nullptr));
	GLCheck(glCompileShader(FragmentShaderID));

	// Check Fragment Shader
	glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
	glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLGLength);
	if (Result == GL_FALSE)
	{
		if (InfoLGLength > 1)
		{
			std::vector<char> FragmentShaderErrorMessage(InfoLGLength+1);
			glGetShaderInfoLog(FragmentShaderID, InfoLGLength, nullptr, &FragmentShaderErrorMessage[0]);
			CA_ERROR("Compile fragment shader error %s\n", &FragmentShaderErrorMessage[0]);
		}
	}

	// Link the program
	GLuint ProgramID = glCreateProgram();
	CA_TRACE("Linking program %d (vertex shader %d, fragment shader %d)\n", ProgramID, VertexShaderID, FragmentShaderID);		
	GLCheck(glAttachShader(ProgramID, VertexShaderID));
	GLCheck(glAttachShader(ProgramID, FragmentShaderID));
	GLCheck(glLinkProgram(ProgramID));

	// Check the program
	glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
	glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLGLength);
	
	if (Result == GL_FALSE)
	{
		if (InfoLGLength > 1)
		{
			std::vector<char> ProgramErrorMessage(InfoLGLength+1);
			glGetProgramInfoLog(ProgramID, InfoLGLength, nullptr, &ProgramErrorMessage[0]);
			CA_ERROR("Link program error %s\n", &ProgramErrorMessage[0]);
		}
	}

	GLCheck(glDeleteShader(VertexShaderID));
	GLCheck(glDeleteShader(FragmentShaderID));

	return ProgramID;
}
Ejemplo n.º 15
0
void CA_PRODUCT_EXTENDED_PRODUCT_ListReplyMsg(const CA_SCELL_MSG *pstSCellMsg)
{
	ia_msg_handle pvMsg;

	msg_extended_product_list_reply_st stExProductListReply;
	msg_extended_product_list_sector_st stExProdcutSector;
	msg_extended_product_list_product_st stExProducts;
	ia_sint16 i, j, m;

	/*allocate the memeory of message and get extended product list message*/
	pvMsg = IA_OpenInputMessage(pstSCellMsg->pvMessage, pstSCellMsg->wLength);
	if (pvMsg == 0)
		return ;
	if (IA_ReadFromMessage(pvMsg, &stExProductListReply, sizeof
		(msg_extended_product_list_reply_st)) == 0)
	{
		IA_CloseMessage(pvMsg, IA_FALSE);
		return ;
	}

	for (m = 0; m < SC_SLOT_MAX; m++)
	{
		if (astCaExProductList[m].wResourceId ==
			stExProductListReply.wResourceId)
			break;
	}
	if (m == SC_SLOT_MAX)
		/* cann't find the resource id */
	{
		IA_CloseMessage(pvMsg, IA_FALSE);
		return ;
	}


	CA_EXTENDED_PRODUCT_ListFreeMemory(stExProductListReply.wResourceId);

	astCaExProductList[m].bSectorCount = stExProductListReply.bSectorCount;
	astCaExProductList[m].wOrgSizeSectorProducts =
		stExProductListReply.bSectorCount;
	astCaExProductList[m].pstSectorProducts = (CA_SECTOR_EXTEND_SECTOR_T*)
		ALLOCATE_MEMORY(CA_SECTOR_EXTEND_SECTOR_T,
		stExProductListReply.bSectorCount);
	if (astCaExProductList[m].pstSectorProducts == 0 && stExProductListReply.bSectorCount > 0)
	{
		IA_CloseMessage(pvMsg, IA_FALSE);
		CA_ERROR(("CA_PRODUCT_EXTENDED_PRODUCT_ListReplyMsg: Memory allocate failed.\n"));
		CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
		return ;
	}

	CA_DBG_V(("<ca_product> allocate extended sector 0x40 : address %0#10x\n", astCaExProductList[m].pstSectorProducts));

	for (i = 0; i < stExProductListReply.bSectorCount; i++)
	{
		IA_ReadFromMessage(pvMsg, &stExProdcutSector, sizeof
			(msg_extended_product_list_sector_st));

		astCaExProductList[m].pstSectorProducts[i].bProductCount =
			stExProdcutSector.bProductCount;
		astCaExProductList[m].pstSectorProducts[i].bSector =
			stExProdcutSector.bSector;
		astCaExProductList[m].pstSectorProducts[i].bSectorStatus =
			(ia_byte)stExProdcutSector.fSectorValid;
		astCaExProductList[m].pstSectorProducts[i].wSectorDateCode =
			stExProdcutSector.wSectorDateCode;
		astCaExProductList[m].pstSectorProducts[i].wMaxSizeExtendProducts =
			stExProdcutSector.bProductCount;
		astCaExProductList[m].pstSectorProducts[i].pstExtendProducts = 0;

		/* jyou: SCR Allocate memory error */
		if (stExProdcutSector.fSectorValid == IA_TRUE && stExProdcutSector.bProductCount > 0 )
		{
			astCaExProductList[m].pstSectorProducts[i].pstExtendProducts =
				(CA_SECTOR_EXTEND_PRODUCT_T*)ALLOCATE_MEMORY
				(CA_SECTOR_EXTEND_PRODUCT_T, stExProdcutSector.bProductCount);
			if (astCaExProductList[m].pstSectorProducts[i].pstExtendProducts == 0)
			{
				IA_CloseMessage(pvMsg, IA_FALSE);
				CA_ERROR(("CA_PRODUCT_EXTENDED_PRODUCT_ListReplyMsg: Memory allocate failed.\n"));
				CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
				return ;
			}
			CA_DBG_V(("<ca_product> allocate extended sector 0x6: sector %d: address %0#10x\n", i, astCaExProductList[m].pstSectorProducts[i].pstExtendProducts));

			for (j = 0; j < stExProdcutSector.bProductCount; j++)
			{
				IA_ReadFromMessage(pvMsg, &stExProducts, sizeof
					(msg_extended_product_list_product_st));
				astCaExProductList[m].pstSectorProducts[i].pstExtendProducts[j].wProduct = stExProducts.wProductId;
				astCaExProductList[m].pstSectorProducts[i].pstExtendProducts[j].wStartDate = stExProducts.wStartDate;
				astCaExProductList[m].pstSectorProducts[i].pstExtendProducts[j].bDuration = stExProducts.bDuration;
			}
		}
	}

	/* send the extended productlist to CA client */
	CA_CLIENT_Notify(stExProductListReply.wResourceId,
		CA_QC_EXTENDED_PRODUCT_LIST, (ia_word32)
		astCaExProductList[m].bSectorCount);

	IA_CloseMessage(pvMsg, IA_FALSE);
}
Ejemplo n.º 16
0
/* PVR Product Check and FTA Product */
void CA_PRODUCT_CheckReplyMsg(const CA_SCELL_MSG *pstSCellMsg)
{
	ia_msg_handle pvMsg;

	msg_product_check_reply_st stProductReply;
	msg_product_check_reply_product_st stProdcut, *pstTempProd = 0;
	ia_word16 i, j;
	ia_word32 wResId;
	ia_bool fPVRProductCheck = IA_FALSE;
	ia_word32 wPVRProductCount = 0;
	ia_word32 wFTAProductCount = 0;
	ia_word16 m = 0, n = 0;

	/*allocate the memeory of message and get product check message*/
	pvMsg = IA_OpenInputMessage(pstSCellMsg->pvMessage, pstSCellMsg->wLength);
	if (pvMsg == 0)
		return ;
	if (IA_ReadFromMessage(pvMsg, &stProductReply, sizeof
		(msg_product_check_reply_st)) == 0)
	{
		IA_CloseMessage(pvMsg, IA_FALSE);
		return ;
	}

	wResId = stProductReply.wResourceId;
	pstTempProd = (msg_product_check_reply_product_st *) OS_DRV_AllocateMemory((unsigned long)
		sizeof(msg_product_check_reply_product_st)* (unsigned long)stProductReply.bProductCount);
	/* Fixed SCR#27163 */
	if (pstTempProd == 0 && stProductReply.bProductCount > 0)
	{
		IA_CloseMessage(pvMsg, IA_FALSE);
		CA_ERROR(("CA_PRODUCT_CheckReplyMsg: Memory allocate failed.\n"));
		CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
		return ;
	}

	for (j = 0; j< stProductReply.bProductCount; j++)
	{
		ansi_memset((void *)&stProdcut, 0, sizeof(msg_product_check_query_product_st));
		IA_ReadFromMessage(pvMsg, &stProdcut, sizeof
			(msg_product_check_reply_product_st));
		ansi_memcpy((void *)&pstTempProd[j], (void *)&stProdcut, sizeof(msg_product_check_reply_product_st));
		/* check the product reply for PVR product check or Product blocking */

		/* sren, SCR#27165, tag 3_6_12:Application only get the PVR product check reply when there have normal and PVR check.*/ 
		if ( (stProdcut.wProduct >= 0xffe0)&&(stProdcut.wProduct <= 0xffef) )  /* PVR product */
		{
			fPVRProductCheck = IA_TRUE;
			wPVRProductCount++;
		}
		else
		{
			wFTAProductCount++;
		}
	}

	if (fPVRProductCheck == IA_TRUE)
	{
		i = CA_PRODUCT_CHECK_ListFreeMemory(wResId);
		if (i == SC_SLOT_MAX)
		{
			IA_CloseMessage(pvMsg, IA_FALSE);
			return;
		}
		astProductCheck[i].bProductCount = wPVRProductCount;
		if ( astProductCheck[i].bProductCount > 0 )
		{
			astProductCheck[i].pstQuerySector = OS_DRV_AllocateMemory(
				(unsigned long)sizeof(CA_QUERY_SECTOR_PRODUCT_T)*(unsigned long)wPVRProductCount);
			if ( astProductCheck[i].pstQuerySector == 0 )
			{
				IA_CloseMessage(pvMsg, IA_FALSE);
				CA_ERROR(("CA_PRODUCT_CheckReplyMsg: Memory allocate failed.\n"));
				CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
				return;
			}
		}

		/*sren, SCR#27165, tag 3_6_12: changed for store the PVR product correctly*/
		for (j = 0; j < wPVRProductCount; j++)
		{
			for( ; m<stProductReply.bProductCount; m++)
			{
				if ( (pstTempProd[m].wProduct >= 0xffe0)&&(pstTempProd[m].wProduct <= 0xffef) )
				{
					astProductCheck[i].pstQuerySector[j].bSector = pstTempProd[m].bSector;
					astProductCheck[i].pstQuerySector[j].fSectorValid = pstTempProd[m].fSectorValid;
					astProductCheck[i].pstQuerySector[j].fProductValid = pstTempProd[m].fProductValid;
					astProductCheck[i].pstQuerySector[j].wProduct = pstTempProd[m].wProduct;
					m++;	/*Check the next PVR Product*/
					break;	/*This will get the PVR product*/
				}
			}
		}

		/* monitor PVR products, if the status is changed, it will send the CA_QC_PVR_PRODUCT_BLOCK notification */
		CA_CLIENT_Notify(stProductReply.wResourceId, CA_QC_PVR_PRODUCT_BLOCK, wPVRProductCount);

	}

	/*Continue check for normal products*/
	if( wFTAProductCount > 0 )
	{
		/* hqian: 3.4.2 SCR#25328  changed j++ to i++ */
		for (i = 0; i < SC_SLOT_MAX; i++)
		{
			if (astProductBlock[i].wResourceId  ==  wResId)
			{
				break;
			}
		}

		if (i == SC_SLOT_MAX)
		{
			IA_CloseMessage(pvMsg, IA_FALSE);
			return ;
		}

		if (wFTAProductCount > MAX_FTA_PRODUCTS)
		{
			wFTAProductCount = MAX_FTA_PRODUCTS;
		}

		astProductBlock[i].bNumEntries = wFTAProductCount;
		for (j = 0; j< wFTAProductCount; j++)
		{
			for( ; n<stProductReply.bProductCount; n++)
			{
				if ( (pstTempProd[n].wProduct <= 0xffe0)||(pstTempProd[n].wProduct >= 0xffef) )
				{
					astProductBlock[i].astProduct[j].bSector = pstTempProd[n].bSector;
					astProductBlock[i].astProduct[j].wProduct = pstTempProd[n].wProduct;
					astProductBlock[i].astProduct[j].fSectorValid = pstTempProd[n].fSectorValid;
					astProductBlock[i].astProduct[j].fProductValid = pstTempProd[n].fProductValid;
					n++;	/*Check the next FTA Product*/
					break;	/*This will get the FTA product*/
				}
			}
		}
		CA_CLIENT_Notify(stProductReply.wResourceId, CA_QC_PRODUCT_BLOCK, wFTAProductCount);
	}
	
	if (pstTempProd != 0)
	{
		OS_DRV_FreeMemory(pstTempProd);
		pstTempProd = 0;
	}
	
	IA_CloseMessage(pvMsg, IA_FALSE);
}
Ejemplo n.º 17
0
/* for any product */
CA_QUERY_STATUS_EN CA_ANY_PRODUCT_SendQuery(CA_ANY_PRODUCT_CHECK_T *proQuery)
{
	ia_msg_handle pvMsg;
	msg_any_product_query_st stAnyProduct;
	ia_byte sectorCnt;
	ia_byte abSectors;
	ia_sint16 i, j;
	ia_word16 wLength;
	ia_word32 wSCardId;

	if (proQuery != 0)
	{
		sectorCnt = proQuery->bSectorCount;
	}
	else
	{
		return CA_QUERY_FAIL;
	}
	wSCardId = proQuery->wResourceId;
	if (proQuery->bRequestType == REQUEST_TYPE_QUERY)
	{
		if (CA_SCARD_GetGlobalSmartCardStatus(wSCardId) != STATUS_CARD_IN)
		{
				return CA_QUERY_FAIL;
		}
		wLength = (ia_word16)(sizeof(msg_any_product_query_st) + sectorCnt * sizeof(ia_byte));

		pvMsg = IA_OpenOutputMessage(wLength, sizeof(ia_byte));

		if (pvMsg != 0)
		{
			stAnyProduct.wResourceId = wSCardId;
			stAnyProduct.bGracePeriod = 0;
			stAnyProduct.fKeepTrack = IA_TRUE;
			stAnyProduct.fAnySector = IA_FALSE;
			stAnyProduct.bSectorCount = sectorCnt;

			IA_WriteToMessage(pvMsg, &stAnyProduct, sizeof
				(msg_any_product_query_st));

			for (i = 0; i < sectorCnt; i++)
			{
				abSectors = proQuery->sectorIndex[i];
				IA_WriteToMessage(pvMsg, &abSectors, sizeof(ia_byte));
			}

			if (SCELL_Message(MSG_ANY_PRODUCT_QUERY, 0,
				IA_GetOutputMessageLength(pvMsg), IA_GetOutputMessage(pvMsg))
				== IA_SUCCESS)
			{
				/* The buffer will be freed by the receiver. */
				IA_CloseMessage(pvMsg, IA_FALSE);
			}
			else
			{
				/* Message not sent. We must free the buffer. */
				IA_CloseMessage(pvMsg, IA_TRUE);
				CA_ERROR(("Sending MSG_ANY_PRODUCT_QUERY failed.\n"));
				CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MESSAGE);
				return CA_QUERY_FAIL;
			}
		}
		else
		{
			CA_ERROR(("Malloc error.\n"));
			CA_ERROR_Notify(CA_ERROR_SOURCE_ECT, CA_ERROR_MEMORY);
			return CA_QUERY_FAIL;
		}
	}
	if (proQuery->bRequestType == REQUEST_TYPE_REPLY)
	{
		wSCardId = proQuery->wResourceId;
		for ( j = 0; j < SC_SLOT_MAX; j++ )
		{
			if ( astAnyProductBlock[j].wResourceId == wSCardId )
			{
				break;
			}
		}

		if ( j == SC_SLOT_MAX )
		{
			return CA_QUERY_FAIL;
		}

		sectorCnt = astAnyProductBlock[j].bSectorCount;

		for (i = 0; i < sectorCnt; i++)
		{
			proQuery->stQuerySector[i].bSector = astAnyProductBlock[j].stQuerySector[i].bSector;
			proQuery->stQuerySector[i].fSectorValid = astAnyProductBlock[j].stQuerySector[i].fSectorValid;
			proQuery->stQuerySector[i].fProductValid = astAnyProductBlock[j].stQuerySector[i].fProductValid;
			proQuery->stQuerySector[i].wProduct = astAnyProductBlock[j].stQuerySector[i].wProduct;
		}
	}

	return CA_QUERY_SUCCESS;
}