/* 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_appman.h 
 *  $RCSfile: c_appman.h,v$
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This header file contains the application manager specific
 *         definitions, which are exported to applications.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_AEE Application Manager
 *  @ingroup groupMW
 *  @brief Provides a unified interface for APPMAN
 *  %This module manages the lifecycle of applications.
 *   - including these sub modules:
 *  @see groupMW
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

#ifndef _C_APPMAN_H_
#define _C_APPMAN_H_


/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/

#include "u_appman.h"


/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/

/*------------------------------------------------------------------*/
/*! @brief          This API starts an application. The application's init function
 *                      will be called first since this API automatically sends a
 *                      INIT message to the application's message loop.
 *  @param [in]        pt_fct_tbl  References the application's function table.
 *  @param [in]        pt_desc     References the application's description (resources,
 *                                            authorization flags, etc).
 *  @param [in]        ps_name     References the application's name.
 *  @param [in]        pf_nfy      References the notify function.
 *  @param [in]        pv_tag      References the tag passed to the notify function.
 *  @param [out]      ph_app  Contains the application handle.
 *  @note
 *  @see
 *  @return      the error code
 *  @retval      AEER_OK                    Routine successful.
 *  @retval        AEER_INV_ARG               Invalid argument.
 *  @retval        AEER_FAIL                  Routine failed.
 *  @retval        AEER_AEE_NO_RIGHTS         Permission denied.
 *  @retval        AEER_AEE_OUT_OF_RESOURCES  Not enough resources available.
 */
/*------------------------------------------------------------------*/
extern INT32 c_app_start (APP_FCT_TBL_T*     pt_fct_tbl,
                          const APP_DESC_T*  pt_desc,
                          const CHAR*        ps_name,
                          x_app_nfy_fct      pf_nfy,
                          VOID*              pv_tag,
                          HANDLE_T*          ph_app);

/*------------------------------------------------------------------*/
/*! @brief          This API sends a message to the application for it to exit.
 *  @param [in]        h_app        Contains the handle to the application.
 *  @param [in]        e_exit_mode  Contains the exit mode.
 *  @param [in]        pf_nfy       References the notify function.
 *  @param [in]        pv_tag       References the tag passed to the notify function.
 *  @param [out]        -
 *  @note
 *  @see
 *  @return      the error code
 *  @retval      AEER_OK    Routine successful.
 *  @retval        AEER_FAIL  Routine failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_app_exit (HANDLE_T         h_app,
                         APP_EXIT_MODE_T  e_exit_mode,
                         x_app_nfy_fct    pf_nfy,
                         VOID*            pv_tag);

/*------------------------------------------------------------------*/
/*! @brief          This API sends a message to the application for it to pause.
 *  @param [in]        h_app   Contains the handle to the application.
 *  @param [in]        pf_nfy  References the notify function.
 *  @param [in]        pv_tag  References the tag passed to the notify function.
 *  @param [out]        -
 *  @note
 *  @see
 *  @return      the error code
 *  @retval      AEER_OK    Routine successful.
 *  @retval        AEER_FAIL  Routine failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_app_pause (HANDLE_T       h_app,
                          x_app_nfy_fct  pf_nfy,
                          VOID*          pv_tag);

/*------------------------------------------------------------------*/
/*! @brief          This API sends a message to the application for it to post init.
 *  @param [in]        h_app   Contains the handle to the application.
 *  @param [in]        pf_nfy  References the notify function.
 *  @param [in]        pv_tag  References the tag passed to the notify function.
 *  @param [out]        -
 *  @note
 *  @see
 *  @return      the error code
 *  @retval      AEER_OK    Routine successful.
 *  @retval        AEER_FAIL  Routine failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_app_post_init (HANDLE_T       h_app,
                          x_app_nfy_fct  pf_nfy,
                          VOID*          pv_tag);

/*------------------------------------------------------------------*/
/*! @brief          This API sends a message to the application for it to resume.
 *  @param [in]        h_app   Contains the handle to the application.
 *  @param [in]        pf_nfy  References the notify function.
 *  @param [in]        pv_tag  References the tag passed to the notify function.
 *  @param [out]        -
 *  @note
 *  @see
 *  @return      the error code
 *  @retval      AEER_OK    Routine successful.
 *  @retval        AEER_FAIL  Routine failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_app_resume (HANDLE_T       h_app,
                           x_app_nfy_fct  pf_nfy,
                           VOID*          pv_tag);

/*------------------------------------------------------------------*/
/*! @brief          This API sends a message to the application. The format of the
 *                      message is not known by the application manager.
 *  @param [in]        h_app      Contains the handle to the application.
 *  @param [in]        ui4_type   Contains the type of the message.
 *  @param [in]        pv_msg     References the message data. Can be NULL.
 *  @param [in]        z_msg_len  Contains the length (in bytes) of the message data.
 *  @param [in]        pf_nfy     References the notify function.
 *  @param [in]        pv_tag     References the tag passed to the notify function.
 *  @param [out]    -
 *  @note
 *  @see
 *  @return      the error code
 *  @retval      AEER_OK              Routine successful.
 *  @retval        AEER_OUT_OF_MEMORY   Out of memory.
 *  @retval        AEER_FAIL            Routine failed.
 */
/*------------------------------------------------------------------*/
extern INT32 c_app_send_msg (HANDLE_T       h_app,
                             UINT32         ui4_type,
                             const VOID*    pv_msg,
                             SIZE_T         z_msg_len,
                             x_app_nfy_fct  pf_nfy,
                             VOID*          pv_tag);

#endif /* _C_APPMAN_H_ */

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

