kb_machblue_tv_event.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:6k
- //*****************************************************************************
- //File Name: kb_machblue_tv_event.c
- //
- //Description: event function
- //
- // used by Machblue to retrieve event information from an event objects
- //
- //Author: wisco & steven
- //
- //Date: 2007.01.20
- //
- //Version: v1.0
- //*****************************************************************************
- #include "machblue_defines.h"
- #include "machblue_porting_core.h"
- #include "machblue_tv_defines.h"
- #include "machblue_tv_customer.h"
- #include "kb_machblue_client_data.h"
- #include "kb_machblue_client_define.h"
- /**
- * This function releases an event schedule object.
- * evs < event schedule object to release >
-
- * @return MB_SUCCESS on success, MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_evs_release(mb_tv_event_schedule_t evs)
- {
- return MB_SUCCESS;
- }
- /**
- * This function retrieves the number of events of an event schedule object.
- * evs < event schedule to query >
- * event_count < pointer to int to store event count >
-
- * @return MB_SUCCESS on success MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_evs_event_count_get(mb_tv_event_schedule_t evs,int *event_count)
- {
- kb_movie_eventSchedule_t *pEvs=(kb_movie_eventSchedule_t*)evs;
- if((pEvs==NULL)||(event_count==NULL))
- {
- mb_printf("n[Machblue]:Event schedule get event count NULL.");
- return MB_FAILURE;
- }
- *event_count=(int)pEvs->evtCount;
- return MB_SUCCESS;
- }
- /**
- * This function retrieves the index of the current event of an
- * event schedule object if available. Otherwise returns 0 as
- * index if the query is not applicable (recording event schedule for instance).
- * evs < event schedule to query >
- * index < pointer to the current event index to update >
-
- * @return MB_SUCCESS on success MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_evs_current_event_index_get(mb_tv_event_schedule_t evs,int *index)
- {
- unsigned long evtIndex;
- mb_system_time_t curTime;
- kb_movie_eventSchedule_t *pEvs=(kb_movie_eventSchedule_t*)evs;
- if((pEvs==NULL)||(index==NULL))
- {
- mb_printf("n[Machblue]:Event schedule get current event index NULL.");
- return MB_FAILURE;
- }
- // Gets the current time
- if(mb_system_time_get(&curTime)==MB_FAILURE)
- {
- mb_printf("n[Machblue]:Event schedule get current event index time error.");
- return MB_FAILURE;
- }
- *index=0;
- for(evtIndex=0;evtIndex<pEvs->evtCount;evtIndex++)
- {
- if((pEvs->events[evtIndex].attributes.start_time<curTime.sec)&&
- ((pEvs->events[evtIndex].attributes.start_time+pEvs->events[evtIndex].attributes.event_info.duration)>curTime.sec))
- {
- *index=(int)evtIndex;
- break;
- }
- }
- return MB_SUCCESS;
- }
- /**
- * This function retrieves events from an event schedule object.
- * This function is ASYNCHRONOUS. The system should send an
- * MB_TV_NR_EVS_EVENTS_GET notification once the request is completed.
- * @see MB_TV_NR_EVS_EVENTS_GET
- * evs < event schedule to query >
- * first_event_pos < position of the first event to get (0 based) >
- * event_count, < pointer to number of event to retrieve. This
- pointer should be updated with number of events actually retrieved >
- * event_list < pointer to list (array) of events to update >
-
- * @return MB_SUCCESS on success MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_evs_events_get(mb_tv_event_schedule_t evs,int first_event_pos,int *event_count,mb_tv_event_t *event_list)
- {
- unsigned long index;
- mb_error_t ret;
- mb_args_t args;
- kb_movie_eventSchedule_t *pEvs=(kb_movie_eventSchedule_t*)evs;
- kb_movie_event_t **pEvt=(kb_movie_event_t**)event_list;
- if((pEvt==NULL)||(event_count==NULL)||(pEvs == NULL))
- {
- mb_printf("n[Machblue]:Event schedule get event list NULL.");
- return MB_FAILURE;
- }
- for(index=first_event_pos;(index-first_event_pos<*event_count)&&(&(pEvs->events[index])!= NULL);++index)
- *(pEvt++)=&(pEvs->events[index]);
-
- *event_count=(int)(index-first_event_pos);
- pEvt-=*event_count;
- MB_TV_EVENT_LIST_ARG(&args)=pEvt;
- MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
- ret=kb_mb_notification_send(MB_TV_NR_EVS_EVENTS_GET,&args);
- if(ret!=MB_SUCCESS)
- {
- mb_printf("n[Machblue]:Event schedule get event list send notification error.");
- return MB_FAILURE;
- }
- return MB_SUCCESS;
- }
- /**
- * This function releases an event object.
- * event < event to release >
-
- * @return MB_SUCCESS on success, MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_event_release(mb_tv_event_t event)
- {
- return MB_SUCCESS;
- }
- /**
- * This function retrieves an event's attributes.
- * event < event object to query >
- * event_attrib < event attributes structure to update >
-
- * @return MB_SUCCESS on success, MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_event_attributes_get(mb_tv_event_t event,mb_tv_event_attributes_t *event_attrib)
- {
- kb_movie_event_t *pEvt=(kb_movie_event_t*)event;
-
- if((event_attrib==NULL)||(pEvt==NULL))
- {
- mb_printf("n[Machblue]:Event get attributes NULL.");
- return MB_FAILURE;
- }
- *event_attrib=pEvt->attributes;
- return MB_SUCCESS;
- }
- /**
- * This function retrieves a given event authorization flags.
- * The list of authorization flags is enumerated in
- * mb_tv_authorization_flag_t.
- * @see mb_tv_authorization_flag_t
- * event < event object to query >
- * auth_flags < pointer to event authorization flags to update. @see mb_tv_authorization_flag_t. >
-
- * @return MB_SUCCESS on success, MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_event_auth_flags_get(mb_tv_event_t event,unsigned int *auth_flags)
- {
- kb_movie_event_t *pEvt=(kb_movie_event_t*)event;
-
- if((auth_flags==NULL)||(pEvt==NULL))
- {
- mb_printf("n[Machblue]:Event get auth flag NULL.");
- return MB_FAILURE;
- }
- *auth_flags=pEvt->auth;
- return MB_SUCCESS;
- }
- /**
- * This function retrieves an event' service.
- * event < event object to query >
- * service < pointer to event service to update >
-
- * @return MB_SUCCESS on success, MB_FAILURE otherwise.
- */
- mb_error_t mb_tv_event_service_get(mb_tv_event_t event,mb_tv_service_t *service)
- {
- kb_movie_event_t *pEvt=(kb_movie_event_t*)event;
- kb_movie_service_t **pSer=(kb_movie_service_t**)service;
-
- if((pSer==NULL)||(pEvt==NULL))
- {
- mb_printf("n[Machblue]:Event get service NULL.");
- return MB_FAILURE;
- }
- *pSer=pEvt->service;
- return MB_SUCCESS;
- }