📄 mms_timer.c
字号:
/*
+-----------------------------------------------------------------------------
| File : mms_timer.c
+-----------------------------------------------------------------------------
| Purpose : This Modul defines the functions for mms timer
+-----------------------------------------------------------------------------
*/
#define ENTITY_MMS
/*==== INCLUDES ===================================================*/
#if defined (NEW_FRAME)
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "typedefs.h"
#include "pcm.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "pei.h"
#include "tok.h"
#else
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "stddefs.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "vsi.h"
#include "pei.h"
#include "tok.h"
#endif
#include "mmstask.h"
#define TRACE_EVENT(f) MMS_TRACE_EVENT(("hyl,mms_timer.c,%s",f));
#define TRACE_FUNCTION(f) TRACE_EVENT(f);
typedef int (*MMS_TimerCb) (U32, void *);
typedef struct
{
MMS_TimerCb mms_timercb;
USHORT time;
}
T_MMS_TIMER;
T_MMS_TIMER mms_timer;
#if !defined (NEW_FRAME)
T_VSI_THANDLE tmms_handle = VSI_ERROR;
#endif
#define MMS_TIMER_ID 0
/*==== VARIABLES ==================================================*/
/*==== FUNCTIONS ==================================================*/
/*
Description: Initialize the timer for mms
*/
GLOBAL BOOL mms_init_timer (void)
{
TRACE_FUNCTION("mms_init_timer");
#if !defined (NEW_FRAME)
tmms_handle = vsi_t_open (VSI_CALLER "TMMS");
if (tmms_handle < VSI_OK)
return FALSE;
#endif
return TRUE;
}
/*
Description : Closes the timer for the browser
*/
GLOBAL void mms_close_timer (void)
{
TRACE_FUNCTION ("wap_close_timer()");
#if !defined (NEW_FRAME)
vsi_t_close (VSI_CALLER tmms_handle);
#endif
}
GLOBAL void mms_start_timer(ULONG ms)
{
int ret;
TRACE_FUNCTION("mms_start_timer");
#if defined (NEW_FRAME)
ret = vsi_t_start (VSI_CALLER MMS_TIMER_ID, ms);
#else
ret = vsi_t_start (VSI_CALLER tmms_handle, ms);
#endif
MMS_TRACE_EVENT(("ret: %d",ret));
}
GLOBAL void mms_stop_timer(void)
{
TRACE_FUNCTION("mms_stop_timer");
#if defined (NEW_FRAME)
vsi_t_stop (VSI_CALLER MMS_TIMER_ID);
#else
vsi_t_stop (VSI_CALLER tmms_handle);
#endif
}
int mms_timeout (USHORT t)
{
TRACE_FUNCTION("mms_timeout");
if (mms_timer.mms_timercb)
{
extern void set_mmstask_proc(BYTE flag);
set_mmstask_proc(1);
mms_timer.mms_timercb(0,0);
set_mmstask_proc(0);
return 1;
}
return 0;
}
void *mms_settimer(int value, void * callback)
{
TRACE_FUNCTION("mms_settimer");
mms_timer.mms_timercb = (MMS_TimerCb)callback;
mms_timer.time = (USHORT)value;
mms_start_timer(value);
return &mms_timer;
}
int mms_restarttimer(void *timer)
{
T_MMS_TIMER *t = (T_MMS_TIMER*)timer;
TRACE_FUNCTION("mms_restarttimer");
mms_stop_timer();
mms_start_timer(t->time);
return t->time;
}
int mms_resettimervalue(void *timer, int fast)
{
T_MMS_TIMER *t = (T_MMS_TIMER*)timer;
TRACE_FUNCTION("mms_restarttimer");
t->time = fast;
mms_stop_timer();
return fast;
}
int mms_killtimer(void* timer)
{
T_MMS_TIMER *t = (T_MMS_TIMER*)timer;
TRACE_FUNCTION("mms_killtimer");
mms_stop_timer();
memset(t, 0 ,sizeof(T_MMS_TIMER));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -