/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file c_rrctx.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/11/10 $
 *  $Author: dtvbm11 $
 *  
 *  @par Description:
 *         This contains Event Context library macros, definitons, structures,
 *         and API's which are exported to applications.
 */
/*----------------------------------------------------------------------------*/

#ifndef _C_RRCTX_H_
#define _C_RRCTX_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_rrctx.h"

/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_RRCTX
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/*! @fn			c_rrctx_open_rating (
 *                 			RRCTX_RATING_TYPE_T e_rating_type,
 *                 			VOID*               pv_param,
 *                  			x_rrctx_nfy_fct     pf_nfy,
 *                 			VOID*               pv_nfy_tag,
 *                   		HANDLE_T*           ph_rating)
 *
 *  @brief			API to load data of a specific rating based on the given rating type
 *
 *  @param [in]	e_rating_type		-Contains the rating type of the specific rating
 *				pv_param		-Contrain the parameters needed for opening
 *				pv_nfy_tag		-Contains the private tag value associated with the calling application
 *				pf_nfy			-Contains the callback function, which is called when the condition 
 *								  or settings of the requested rating is changed
 *								  
 *  @param [out]	ph_rating			-Contains the handle to the RRCTX object
 *
 *  @note			This function need be called when user want to get the handle of the rating engine
 *  @see			c_rrctx.c
 
 *  @return		Return the error code
 
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_ENG_NOT_FOUND    	The RRCTX engine was not found.
 *         			RRCTXR_INV_ARG          		Invalid arguments.
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 *          			RRCTXR_OUT_OF_HANDLE    	No free handle is available.
 *          			RRCTXR_OUT_OF_MEM       		Run out of memory.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_open_rating (
                    RRCTX_RATING_TYPE_T e_rating_type,
                    VOID*               pv_param,
                    x_rrctx_nfy_fct     pf_nfy,
                    VOID*               pv_nfy_tag,
                    HANDLE_T*           ph_rating);
 

/*------------------------------------------------------------------*/
/*! @fn			c_rrctx_close_rating (HANDLE_T            h_rating)
 *
 *  @brief			API to delete a loaded rating object.
 *
 *  @param [in]	h_rating		-Contains the rating handle to be deleted or returned
 *                           			  or next use
 *								  
 *  @param [out]	-
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *				RRCTXR_INV_HANDLE		 	Invalid handle value.
 * 		 		RRCTXR_NOT_INIT		 		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/

extern INT32 c_rrctx_close_rating (
                    HANDLE_T            h_rating);


/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_get_rating_info_len (
 *                  		HANDLE_T            h_rating,
 *                  		RRCTX_KEY_TYPE_T    e_key_type,
 *                   	VOID*               pv_key_param,
 *                   	SIZE_T*             pz_rating_info_len)
 *
 *  @brief		API to get the length of the requested rating information
 *
 *  @param [in]	h_rating			-Contains the rating handle to be queried.
 *				e_key_type		-Contains the specific information type to be retrieved.
 *				pv_key_param	-Contains the auxiliary data to get the requested rating information. 
 *								  Ths argument may be NULL, depending on the value of the
 *                          				  argument e_key_type.
 *								  
 *  @param [out]	pz_rating_info_len			-Contains the length of the requested rating information 
 *										  if the routine was successfully returned.
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *         	 		RRCTXR_INV_HANDLE       		Invalid handle value.
 *          			RRCTXR_INFO_NOT_FOUND   	The requested rating information is not present.
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_get_rating_info_len (
                    HANDLE_T            h_rating,
                    RRCTX_KEY_TYPE_T    e_key_type,
                    VOID*               pv_key_param,
                    SIZE_T*             pz_rating_info_len);


/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_get_rating_info (
 *                  		HANDLE_T            h_rating,
 *                  		RRCTX_KEY_TYPE_T    e_key_type,
 *                   	VOID*               pv_key_param,
 *                   	SIZE_T*             pz_rating_info_len,
 * 				VOID*               pv_rating_info)
 *
 *  @brief		API to get the requested rating information
 *
 *  @param [in]	h_rating			-Contains the rating handle to be queried.
 *				e_key_type		-Contains the specific information type to be retrieved.
 *				pv_key_param	-Contains the auxiliary data to get the requested rating information. 
 *								  Ths argument may be NULL, depending on the value of the
 *                          				  argument e_key_type.
 *				pz_rating_info_len	-Contains the length of the buffer pv_rating_info.
 *								  
 *  @param [out]	pz_rating_info_len			-Contains the length of the requested rating information 
 *										  if the routine was successfully returned.
 *				pv_rating_info				-Contains the requested information if the routine was
 *                          						  successfully returned.
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *         	 		RRCTXR_INV_HANDLE       		Invalid handle value.
 *          			RRCTXR_INFO_NOT_FOUND   	The requested rating information is not present.
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/

extern INT32 c_rrctx_get_rating_info (
                    HANDLE_T            h_rating,
                    RRCTX_KEY_TYPE_T    e_key_type,
                    VOID*               pv_key_param,
                    SIZE_T*             pz_rating_info_len,
                    VOID*               pv_rating_info);


/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_settings(
 *                   		HANDLE_T            h_rating,
 *                   		VOID*               pv_setting)
 *
 *  @brief		API to set up the settings of the RRCTX engine 
 *
 *  @param [in]	h_rating			-Contains the handle of RRCTX object to be set up.
 *				pv_settings		-Contains the setting values. 
 *								  
 *  @param [out]	-
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/

extern INT32 c_rrctx_rating_settings(
                    HANDLE_T            h_rating,
                    VOID*               pv_setting);


/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_enable(
 *                    		HANDLE_T            h_rating,
 *                   		BOOL                b_enable);
 *
 *  @brief		API to enable or disable the RRCTX engine 
 *
 *  @param [in]	h_rating			-Contains the handle of RRCTX object to be set up.
 *				b_enable			-Contains the enable/disable value. 
 *								  
 *  @param [out]	-
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_rating_enable(
                    HANDLE_T            h_rating,
                    BOOL                b_enable);


/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_exceeds(
 *                   		HANDLE_T            h_rating,
 *                   		VOID*               pt_rating_lst,  
 *                   		BOOL*               pb_exceed)
 *
 *  @brief		API to return if the given rating exceeds the current parental setttings or not.
 *
 *  @param [in]	h_rating			-Contains the handle of RRCTX object to be set up.
 *				pt_rating_lst		-Contains the specific structure of rating list for the queried engine. 
 *								  
 *  @param [out]	pb_enable		-return if the given rating exceeds the current parental setttings or not.  
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/

extern INT32 c_rrctx_rating_exceeds(
                    HANDLE_T            h_rating,
                    VOID*               pt_rating_lst,  /* V-Chip: EVCTX_ATSC_RATING_LIST_T */
                    BOOL*               pb_exceed);


/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_get_text(
 *                  		HANDLE_T            h_rating,
 *                  		VOID*               pt_rating_lst, 
 *                  		UTF16_T*            w2s_str,
 *                   		SIZE_T              z_len)
 *
 *  @brief		API to get the text of the given rating.
 *
 *  @param [in]	h_rating			-Contains the handle of RRCTX object to be set up.
 *				pt_rating_lst		-Contains the specific structure of rating list for the queried engine. 
 *				z_len			-The length of w2s_str 
 *								  
 *  @param [out]	w2s_str			-Return the text of the given rating.
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_rating_get_text(
                    HANDLE_T            h_rating,
                    VOID*               pt_rating_lst,  /* V-Chip: EVCTX_ATSC_RATING_LIST_T */
                    UTF16_T*            w2s_str,
                    SIZE_T              z_len);

/*------------------------------------------------------------------*/
/*! 
 *  @brief      API to check if rating is availale.
 *
 *  @param [in]	h_rating		-Contains the handle of RRCTX object to be set up.
 *								  
 *  @param [out]   	pb_available	-Return if the rating is available
 *
 *  @note
 *  @see            	c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK                   	The routine was successful.
 *              		RRCTXR_INV_ARG          	Invalid arguments.
 *              		RRCTXR_INTL_ERROR          Invalid rating handle. 
 *              		RRCTXR_NOT_INIT             	The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_rating_available(
                    HANDLE_T            h_rating,
                    BOOL*               pb_available);

/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_valid(
 *                    		HANDLE_T            h_rating,
 *                   		VOID*               pt_rating_lst, 
 *                   		BOOL*               pb_valid)
 *
 *  @brief		API to get the type of the given rating.
 *
 *  @param [in]	h_rating			-Contains the handle of RRCTX object to be set up.
 *				pt_rating_lst		-Contains the specific structure of rating list for the queried engine. 
 *								  
 *  @param [out]	pb_valid			-Return if the given rating is valid.
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/

extern INT32 c_rrctx_rating_valid(
                    HANDLE_T            h_rating,
                    VOID*               pt_rating_lst, 
                    BOOL*               pb_valid);

/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_get_type(
 *                   		HANDLE_T            	h_rating,
 *                   		VOID*               	pt_rating_lst, 
 *                   		RRCTX_VCHIP_TYPE_T* pt_rating_type);
 *
 *  @brief		API to get the type of the given rating.
 *
 *  @param [in]	h_rating			-Contains the handle of RRCTX object to be set up.
 *				pt_rating_lst		-Contains the specific structure of rating list for the queried engine. 
 *								  
 *  @param [out]	pt_rating_type		-Return the type of the given rating.
 *
 *  @note			
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_rating_get_type(
                    HANDLE_T            h_rating,
                    VOID*               pt_rating_lst,  /* V-Chip: EVCTX_ATSC_RATING_LIST_T */
                    RRCTX_VCHIP_TYPE_T* pt_rating_type);

/*------------------------------------------------------------------*/
/*! @fn		INT32 c_rrctx_rating_storage(
 *                  	 		HANDLE_T            	h_rating,
 *                   		BOOL                	b_store)
 *
 *  @brief		API to store or clear the data of the given rating.
 *
 *  @param [in]	h_rating		-Contains the handle of RRCTX object .
 				b_store		-Contains to store or not
 *								  
 *  @param [out]	-
 *
 *  @note			Store or Clear Rating Data
 *  @see			c_rrctx.c
 *
 *  @return		Return the error code
 *
 *  @retval		RRCTXR_OK               			The routine was successful.
 *          			RRCTXR_INV_ARG          		Invalid arguments.
 *				RRCTXR_INTL_ERROR		 	Invalid rating handle. 
 *          			RRCTXR_NOT_INIT         		The RRCTX component is not inited.
 */
/*------------------------------------------------------------------*/
extern INT32 c_rrctx_rating_storage(
                    HANDLE_T            h_rating,
                    BOOL                b_store);


#endif /* _C_RRCTX_H_ */

/*----------------------------------------------------------------------------*/
/*! @} */                               /* end of groupMW_RRCTX                            */
/*----------------------------------------------------------------------------*/

