/******************************************************************************
 ** al_prog_reminder.h: Program reminder Component Header file.
 **
 ** Copyright(c) 2008 Wipro Technologies - All Rights Reserved
 ** Author : Soumya Pandiyattu
 **
 ** $Id: app_dvb_prog_reminder.h,v 1.1.1.1 2009/04/15 03:24:32 junluo Exp $
 ******************************************************************************/

#ifndef __AL_PR_H__
#define __AL_PR_H__

#include "al_basictypes.h"
#include "al_database.h"
#include "al_scheduler.h"

#define PR_MUXTEX_NAME						"PR_Mutex"

/* Value of Zero for the Service or Event
** reminder means that both share the total
** reminders. If both wants fixed number of the reminders
** then different values to be provided and total of
** both should match the total reminders */
#define AL_PR_MAX_NO_SRV_REMINDERS 		(0)
#define AL_PR_MAX_NO_EVT_REMINDERS 		(0)

typedef al_uint16 AL_PR_index_t;

typedef struct
{
	al_int8  MaxNumOfReminders;
	AL_SCH_time_t app_schd_time[AL_SCH_MAX_NO_OF_CALLBACK];
}AL_PR_Init_Param_t;

typedef enum
{
	AL_PR_INVALID_REM =0,
	AL_PR_EVT_REM = 1<<0,
	AL_PR_SRV_REM = 1<<1,
	AL_PR_ANA_EVT_REM = 1<<2
} AL_PR_type_t;

typedef enum
{
	AL_PR_REC_FIRST,
	AL_PR_REC_LAST,
	AL_PR_REC_NEXT,
	AL_PR_REC_PREV
} AL_PR_record_type_t;

typedef struct
{
	AL_RecHandle_t handle;
	AL_RecHandle_t Eventhandle;
	al_uint32 event_end_time_insec;
} AL_PR_schedule_details_t;

typedef struct
{
	AL_DB_EDBType_t db_type;
	AL_PR_type_t rem_type;
	AL_PR_schedule_details_t rem_details;
	AL_SCH_sched_id_t sch_id;
	al_uint32 start_local_time_secs;
	al_uint32 snooze_time_secs;
	al_int8 gmt_offset;
	al_bool enable;
	al_bool weekday;
} AL_PR_details_t;

typedef struct  PR_persistent_info_t_{
	AL_DB_EDBType_t db_type;
	AL_PR_type_t rem_type;
	AL_PR_schedule_details_t rem_details;
	al_uint32 start_local_time_secs;
	al_uint32 snooze_time_secs;
	al_int8 gmt_offset;
	al_bool enable;
	al_bool occupied;
	al_bool weekday;
} PR_persistent_info_t;

typedef struct  PR_details_t_{
	PR_persistent_info_t details;
	AL_SCH_sched_id_t sch_id;
	al_uint8 next_index;
} PR_details_t;
/*****************************************************************************
** FUNCTION : AL_FW_PR_SetInitParam
**
** DESCRIPTION :
**				Set init Param for Prog Reminder.
**
** PARAMETERS :
**				AL_PR_Init_Param_t
**
** RETURN VALUES:
**				void
*****************************************************************************/
al_void AL_PR_SetInitParam(AL_PR_Init_Param_t  *Init_param);

/*****************************************************************************
** FUNCTION : AL_PR_Init
**
** DESCRIPTION :
**				This function is used to initialise program reminder module.
**
** PARAMETERS :
**				set MAX_NO_REMINDERS and NOTIFY_TIME_IN_SEC
**
** RETURN VALUES:
**				AL_SUCCESS
*****************************************************************************/
 AL_Return_t AL_PR_Init (void);


/************************************************************************
 ** name				: AL_PR_GetById(AL_SCH_sched_id_t *id,APP_PR_details_t details)
 **
 ** description		: This API Terminate this component
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_GetById ( AL_SCH_sched_id_t id, AL_PR_details_t *details);

/************************************************************************
 ** name				: AL_PR_Get(AL_SCH_sched_id_t *id,APP_PR_details_t details)
 **
 ** description		: This API Terminate this component
 **
 ** input parameters	: none
 **
 ** output parameters	: none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_Get (AL_DB_EDBType_t db_type, AL_PR_record_type_t req_type, AL_PR_type_t rem_type,
					const AL_SCH_sched_id_t ref_id, AL_SCH_sched_id_t *ret_id);

/************************************************************************
 ** name				: AL_PR_GetTotal
 **
 ** description		: This API Terminate this component
 **
 ** input parameters	: none
 **
 ** output parameters	: none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_GetTotal (AL_DB_EDBType_t db_type, AL_PR_type_t rem_type, al_uint8* total_count);

 /************************************************************************
 ** name				: AL_PR_Add()
 **
 ** description		: Add new reminder
 **
 ** input parameters	: none
 **
 ** output parameters	: none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_Add( AL_PR_details_t *details, AL_SCH_sched_id_t *id);

/************************************************************************
 ** name				: AL_PR_AddEx()
 **
 ** description		: Add new reminder and get the conflicted timers
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_AddEx( AL_PR_details_t* details , AL_SCH_sched_id_t* id,AL_SCH_sched_id_t* ConflictTimerID, UINT8* ConflictTimerNum);

 /************************************************************************
 ** name				: AL_PR_Modify()
 **
 ** description		: This API modifies the scheduled event with new information
 **
 ** input parameters	: none
 **
 ** output parameters	: none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_Modify(AL_PR_details_t *details, AL_SCH_sched_id_t id);

 /************************************************************************
  ** name				 : AL_PR_ModifyEx()
  **
  ** description	 : This API modifies the scheduled event with new information
  **				 : and get the conflicted timers
  **
  ** input parameters	 : none
  **
  ** output parameters	 :	 none
  **
  ** return type	 : AL_Return_t
  ************************************************************************/
 AL_Return_t AL_PR_ModifyEx(AL_PR_details_t *details ,AL_SCH_sched_id_t id,AL_SCH_sched_id_t* ConflictTimerID, UINT8* ConflictTimerNum);

 /************************************************************************
 ** name				: AL_PR_Delete()
 **
 ** description			: This API Delete this reminder
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type			: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_Delete(AL_SCH_sched_id_t id);

 /************************************************************************
 ** name				:APP_Data_PR_delete_all_sch()
 **
 ** description		: This API delete all the schedule for the Program reminder
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_DeleteAllSch (AL_DB_EDBType_t db_type, AL_PR_type_t rem_type );

/************************************************************************
 ** name				:AL_PR_DefaultSetup()
 **
 ** description		: This API perform default setup.
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_DefaultSetup(AL_DB_EDBType_t db_type);

/************************************************************************
 ** name				: AL_PR_SetAllStatus()
 **
 ** description		: This API modifies Then enable disable status.
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_SetAllStatus(al_bool enable_rem);
/************************************************************************
 ** name				:AL_PR_GetMaxNoOfReminders()
 **
 ** description		: This API returns the second that before registed event take place.
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: al_uint8 No. of reminders
 ************************************************************************/
al_uint8 AL_PR_GetMaxNoOfReminders(void);

/************************************************************************
 ** name				:AL_PR_NotifyTime()
 **
 ** description		: This API returns the second that before registed event take place.
 **
 ** input parameters	: none
 **
 ** output parameters	:   none
 **
 ** return type		: al_uint32 time in sec
 ************************************************************************/
al_uint32 AL_PR_NotifyTime(void);

/************************************************************************
 ** name			:AL_PR_Update()
 **
 ** description		: Handle the whether reminder should be kept or removed for every reminder.
 **
 ** input parameters	:None
 **
 ** output parameters	:None.
 **
 ** return type		: AL_Return_t
 ************************************************************************/
AL_Return_t AL_PR_Update(al_int32 time_diff, al_uint32 new_time);
/**
* @brief We can konw the recording is normal recording or timer recording.
*
* @param ppfGetContext[output] callback function.
*
* @return the Prog_remind_id.
*/
al_int AL_FW_PVR_GetProgReminderId(void);
/**
* @brief We can konw the recording is normal recording or timer recording.
*
* @param if  the recording is normal recording  , the Prog_remind_id is  AL_SCH_INVALID_ID .
*
* @return none
*/

void AL_FW_PVR_SetProgReminderId(al_int id);

/************************************************************************
 ** name				: AL_PR_CheckEvtEndTime()
 **
 ** description		: 
 **
 ** input parameters	: A event end time
 **
 ** output parameters	: none
 **
 ** return type		: Boolean True  A event end time is B event start time,
 ************************************************************************/
Boolean AL_PR_CheckEvtEndTime(al_uint32 EndTime);


#endif

/******************************************************************************
 ** $Log: ACPR_Component.h,v $
 ******************************************************************************/

