/*
* EPG.C ver 0.1
*
* (c) Copyright SGS-Thomson Microelectronics Limited 1996.
*
* Source file name : EPG.C
* Authors T.H.Thillai Rajan (tht.rajan@st.com)
*
* Original Work: none
*
* =======================
* IMPROVEMENTS THOUGHT OF
* =======================
*
* =====================
* MODIFICATION HISTORY:
* =====================
*
* Date Modification Initials
* ---- ------------ --------
18.12.2000 Added options for STWTK user interface BK
* 15.11.96 CREATED THT
*/
#include <stdio.h>
#include <string.h>
#include "usif.h"
#include "usifext.h"
#include "drawuif.h"
#include "app_data.h"
/*}}}*/
/*
* CODE : EpgPrevKeyFunction
* TYPE : sub-routine
* PROTOTYPE :
* BOOLEAN EpgPrevKeyFunction ( int iNoOfValidElements );
*
* STACK : callers stack
* INPUT :
* a. iNoOfValidElements int
* number of valid elements in the menu data linked list which actually
* determines offset in case of PAGE mode
* OUTPUT : nothing
* a. return_status BOOLEAN
* If the previous element is valid then it will be TRUE else FALSE
*
* GLOBAL VARIABLES USED :
* a. astMenuData array of structure type MENU_DATA_STRUCT ( R/W )
* b. pstMenuDataHead pointer to type MENU_DATA_STRUCT ( R/W )
* b. pstMenuDataTail pointer to type MENU_DATA_STRUCT ( R/W )
*
* DEVICES ACCESSED : nothing
*
* CALLERS :
* a. Display_menu : src\usif\Draw_meu.c
*
* PURPOSE:
* This routine searches the previous program info which is not included
* in the menu data list and it updates menu data list.
*
* ALGORITHM:
* 1. check if the last menu_page_sel is already PREV_PAGE, then goto step 5
* 2. position the program info with the offset of -MAX_NO_OF_MENU_ELEMENTS.
* 3. if it is valid then return to the caller with status TRUE
* 4. return FALSE
* 5. since already the DBASE_Rertriever is positioned as same as the topmost
* element of the current menu data list, just check the validity of this
* element's previous link.
* 6. if it is valid then return to caller with return status TRUE
* 7. return FALSE
*
* IMPROVEMENT(s) THOUGHT OF:
*/
/*{{{ EpgPrevKeyFunction ()*/
BOOLEAN EpgPrevKeyFunction(int iNoOfValidItems)
{
int iOffset;
int iProgNo;
int CurProgramStatus;
MENU_DATA_STRUCT *pstMenuDataTemp;
PROG_INFO_STRUCT *pstProgInfoTemp;
iOffset = iNoOfValidItems;
if (menu_page_last_sel == PREV_PAGE)
iOffset = 1;
if (PositionProgInfoNeg(iOffset) == INVALID_LINK)
return FALSE;
menu_page_last_sel = PREV_PAGE;
if ((pstProgInfoTemp = CurProgInfo(&iProgNo)) == NULL)
{
#ifdef USIF_DEBUG
report(severity_error, "Failed to read prev element, even after positioning");
#endif
return FALSE;
}
/*
* cut the tail and add it as a new head
*/
pstMenuDataTemp = pstMenuDataTail;
pstMenuDataTail->Prev->Next = (MENU_DATA_STRUCT *)NULL;
pstMenuDataTail = pstMenuDataTail->Prev;
pstMenuDataTemp->Next = pstMenuDataHead;
pstMenuDataHead->Prev = pstMenuDataTemp;
pstMenuDataHead = pstMenuDataTemp;
pstMenuDataHead->Prev = (MENU_DATA_STRUCT *)NULL;
/*
* fill the data now, after cleraing the existing data
*/
memset(pstMenuDataHead->aucData, 0, sizeof(pstMenuDataHead->aucData));
CurProgramStatus = PROGRAM_INVALID;
if (pstProgInfoTemp->sVidPid != DEMUX_INVALID_PID)
CurProgramStatus |= PROGRAM_VIDEO_ONLY;
if (pstProgInfoTemp->astAudStr[0].sAudPid != DEMUX_INVALID_PID)
CurProgramStatus |= PROGRAM_AUDIO_ONLY;
switch (CurProgramStatus)
{
case PROGRAM_VIDEO_ONLY:
sprintf((char *)pstMenuDataHead->aucData, "%03d %-8s %-10s ",
iProgNo,
pstProgInfoTemp->cServiceProviderName,
pstProgInfoTemp->cServiceName);
break;
case PROGRAM_AUDIO_ONLY:
sprintf((char *)pstMenuDataHead->aucData, "%03d %-8s %-10s ",
iProgNo,
pstProgInfoTemp->cServiceProviderName,
pstProgInfoTemp->cServiceName);
break;
case PROGRAM_VIDEO_AUDIO:
sprintf((char *)pstMenuDataHead->aucData, "%03d %-8s %-10s ",
iProgNo,
pstProgInfoTemp->cServiceProviderName,
pstProgInfoTemp->cServiceName);
break;
default:
sprintf((char *)pstMenuDataHead->aucData, "%03d %-8s %-10s ",
iProgNo,
pstProgInfoTemp->cServiceProviderName,
pstProgInfoTemp->cServiceName);
break;
}
STTBX_Print(("Epg data head %s\n", pstMenuDataHead->aucData));
STTBX_Print(("Epg data tail %s\n", pstMenuDataTail->aucData));
return TRUE;
}
/*}}}*/
/*
* CODE : EpgNextKeyFunction
* TYPE : sub-routine
* PROTOTYPE :
* BOOLEAN EpgNextKeyFunction ( int iNoOfValidItems );
*
* STACK : callers stack
* INPUT :
* a. iNoOfValidItems int
* number of valid elements in the menu data linked list which actually
* determines offset in case of PAGE mode
* OUTPUT : nothing
* a. return_status BOOLEAN
* If the next element is valid then it will be TRUE else FALSE
*
* GLOBAL VARIABLES USED :
* a. astMenuData array of structure type MENU_DATA_STRUCT ( R/W )
* b. pstMenuDataHead pointer to type MENU_DATA_STRUCT ( R/W )
* b. pstMenuDataTail pointer to type MENU_DATA_STRUCT ( R/W )
*
* DEVICES ACCESSED : nothing
o ..\EPG\SOURCE\VDBASE.C
*
* CALLERS :
* a. a. Display_menu : src\usif\Draw_meu.c
*
* PURPOSE:
* This routine searches the next program info which is not included
* in the menu data list and it updates menu data list.
*
* ALGORITHM:
* 1. check if the last menu_page_sel is already NEXT_PAGE, then goto step 5
* 2. position the program info with the offset of +MAX_NO_OF_MENU_ELEMENTS.
* 3. if it is valid then return to the caller with status TRUE
* 4. return FALSE
* 5. since already the DBASE_Rertriever is positioned as same as the bottom
* most element of the current menu data list, just check the validity of
* this element's next link.
* 6. if it is valid then return to caller with return status TRUE
* 7. return FALSE
*
* IMPROVEMENT(s) THOUGHT OF:
*/
/*{{{ EpgNextKeyFunction ()*/
BOOLEAN EpgNextKeyFunction(int iNoOfValidItems)
{
int iOffset;
int iProgNo;
int CurProgramStatus;
MENU_DATA_STRUCT *pstMenuDataTemp;
PROG_INFO_STRUCT *pstProgInfoTemp;
iOffset = iNoOfValidItems;
if (menu_page_last_sel == NEXT_PAGE)
iOffset = 1;
if (PositionProgInfoPos(iOffset) == INVALID_LINK)
return FALSE;
menu_page_last_sel = NEXT_PAGE;
if ((pstProgInfoTemp = CurProgInfo(&iProgNo)) == NULL)
{
#ifdef USIF_DEBUG
report(severity_error, "Failed to read next element, even after positioning");
#endif
return FALSE;
}
/*
* cut the head and add it as a new tail
*/
pstMenuDataTemp = pstMenuDataHead;
pstMenuDataHead->Next->Prev = (MENU_DATA_STRUCT *)NULL;
pstMenuDataHead = pstMenuDataHead->Next;
pstMenuDataTemp->Prev = pstMenuDataTail;
pstMenuDataTail->Next = pstMenuDataTemp;
pstMenuDataTail = pstMenuDataTemp;
pstMenuDataTail->Next = (MENU_DATA_STRUCT *)NULL;
/*
* fill the data now, after cleraing the existing data
*/
memset(pstMenuDataTail->aucData, 0, sizeof(pstMenuDataHead->aucData));
CurProgramStatus = PROGRAM_INVALID;
if (pstProgInfoTemp->sVidPid != DEMUX_INVALID_PID)
CurProgramStatus |= PROGRAM_VIDEO_ONLY;
if (pstProgInfoTemp->astAudStr[0].sAudPid != DEMUX_INVALID_PID)
CurProgramStatus |= PROGRAM_AUDIO_ONLY;
switch (CurProgramStatus)
{
case PROGRAM_VIDEO_ONLY:
sprintf((char *)pstMenuDataTail->aucData, "%03d %-8s %-10s ",
iProgNo,
pstProgInfoTemp->cServiceProviderName,
pstProgInfoTemp->cServiceName);
break;
case PROGRAM_AUDIO_ONLY:
sprintf((char *)pstMenuData