📄 virphone.c
字号:
/****************************************************************
** *
** FILE : VirPhone.C *
** COPYRIGHT : (c) 2001 .Xiamen Yaxon NetWork CO.LTD *
** *
** *
** By : CCH 2002.1.15 *
****************************************************************/
#include "includes.h"
#include "message.h"
#include "systime.h"
#include "tools.h"
#include "public.h"
#include "timetask.h"
#include "systask.h"
#include "phonedrv.h"
#include "alarmer.h"
#include "callrht.h"
#include "db_talk.h"
#include "db_tb.h"
#include "db_sk.h"
#include "screen.h"
#include "hstctl.h"
#include "keyboard.h"
#include "winstack.h"
#include "prompt.h"
#include "handset.h"
#include "virphone.h"
#include "debug.h"
#if EN_HANDSET > 0
/*
********************************************************************************
* DEFINE CONFIG PARAMETERS
********************************************************************************
*/
#define SIZE_DTMFBUF 30
#define SIZE_DPLYBUF 30
#define PERIOD_WAIT SECOND, 2
#define PERIOD_WAIT_CALLING SECOND, 2
#define PERIOD_WAIT_AUTOPICK SECOND, 4
/*
********************************************************************************
* DEFINE status
********************************************************************************
*/
#define VIR_FREE 0
#define VIR_CALLING 1
#define VIR_TALKING 2
#define VIR_RINGING 3
/*
********************************************************************************
* DEFINE ENTRYTEL_STRUCT
********************************************************************************
*/
typedef struct {
INT8U attrib;
INT8U channel;
INT8U tellen;
INT8U tel[TALKREC_SIZE_TEL];
} ENTRYTEL_STRUCT;
/*
********************************************************************************
* DEFINE MODULE VIRIANTS
********************************************************************************
*/
static INT8U status;
static INT8U dtmfbuf[SIZE_DTMFBUF], dtmflen, dtmfpos;
static INT8U dplybuf[SIZE_DPLYBUF], *dplyptr, dplylen;
static BOOLEAN activated;
static TMR_TSK *waittmr;
static KEY_STRUCT curkey;
static ENTRYTEL_STRUCT EntryTel;
static TALKREC_STRUCT TalkRecord;
static PROMPT_STRUCT PromptEntry;
static INT8U dplytime[] = {"通话结束\n 00:00:00"};
static BOOLEAN Display_DTMF(void)
{
INT8U screensize, pos, i, dplylen;
screensize = GetScreenSize();
if (dtmflen > screensize)
dplylen = screensize;
else
dplylen = dtmflen;
if (dplylen == 0) return FALSE;
VTL_ClearScreen(); /* clear screen */
for (i = 1, pos = dtmfpos; i <= dplylen; i++) {
VTL_AbsMovCursor(screensize - i);
if (pos > 0)
pos--;
else
pos = sizeof(dtmfbuf) - 1;
VTL_ScreenPrint(dtmfbuf[pos]);
}
OverWriteScreen(); /* overwrite screen */
return TRUE;
}
static void AddDtmfChar(INT8U ch)
{
dtmfbuf[dtmfpos++] = ch;
if (dtmfpos >= sizeof(dtmfbuf)) dtmfpos = 0;
if (dtmflen < sizeof(dtmfbuf)) dtmflen++;
}
static void DelDtmfChar(void)
{
if (dtmflen > 0) {
if (dtmfpos == 0)
dtmfpos = sizeof(dtmfbuf) - 1;
else
dtmfpos--;
dtmflen--;
}
}
#if 0
static void ModifyDtmfChar(INT8U ch)
{
DelDtmfChar();
AddDtmfChar(ch);
}
#endif
static BOOLEAN HaveDtmfChar(void)
{
if (dtmflen > 0) return TRUE;
else return FALSE;
}
static void InitDtmfBuf(void)
{
dtmflen = dtmfpos = 0;
}
static void GetDisplayPara(void)
{
if (PubParaValid(SUCCORTEL_)) {
if (ACmpString(FALSE, EntryTel.tel, SuccorTel.tel, EntryTel.tellen, SuccorTel.tellen) == STR_EQUAL) {
memcpy(dplybuf, "求助中心", sizeof("求助中心") - 1);
dplyptr = dplybuf;
dplylen = sizeof("求助中心") - 1;
return;
}
}
dplylen = GetTBNameByTel(dplybuf, EntryTel.tellen, EntryTel.tel);
if (dplylen > 0) {
dplyptr = dplybuf;
} else {
dplyptr = EntryTel.tel;
dplylen = EntryTel.tellen;
}
}
static void Display_COMMON(INT8U textlen, char *textptr, INT8U tellen, INT8U *tel)
{
INT8U screensize;
screensize = GetScreenSize();
VTL_ClearScreen(); /* clear screen */
VTL_ScreenPrintMem((INT8U *)textptr, textlen);
if (textlen + tellen < screensize) {
VTL_AbsMovCursor(screensize - tellen);
VTL_ScreenPrintMem(tel, tellen);
}
OverWriteScreen(); /* overwrite screen */
}
static void Display_CALLING(void)
{
GetDisplayPara();
Display_COMMON(strlen("拨号…"), "拨号…", dplylen, dplyptr);
}
static void Display_CALLING_INIT(void)
{
StartTmr(waittmr, PERIOD_WAIT_CALLING);
#if EN_HSTSMON > 0
if(CmpString(EntryTel.tel,GuestSmon.GuestTel,EntryTel.tellen)==STR_EQUAL)//判断是否为召车乘客电话 add by qzc
EntryTel.tellen=0;
#endif
Display_COMMON(strlen("拨号…"), "拨号…", EntryTel.tellen, EntryTel.tel);
}
static void Display_TALKING(void)
{
GetDisplayPara();
TurnonTalkIndicator();
if (!Display_DTMF())
Display_COMMON(strlen("接通…"), "接通…", dplylen, dplyptr);
}
static void Display_RINGING(void)
{
if (EntryTel.tellen == 0)
Display_COMMON(strlen("未知来电?"), "未知来电?", 0, 0);
else {
GetDisplayPara();
Display_COMMON(strlen("来电?"), "来电?", dplylen, dplyptr);
}
}
static void Display_VOLUME(void)
{
INT8U step, linesize;
StartTmr(waittmr, PERIOD_WAIT);
step = GetVoiceVolume(PHONE_COM);
linesize = GetScreenLineSize();
VTL_ClearScreen();
VTL_ScreenPrintStr("音量\n");
VTL_ScreenPrintStr("-----------+");
VTL_AbsMovCursor(linesize + 1);
VTL_ScreenPrintChar(0x83, step);
OverWriteScreen();
}
static void Display_CHANNEL(void)
{
StartTmr(waittmr, PERIOD_WAIT);
VTL_ClearScreen();
if (GetVoiceChannel(PHONE_COM) == CHA_HANDSET) {
VTL_ScreenPrintStr("切换到\n手柄模式");
} else {
VTL_ScreenPrintStr("切换到\n免提模式");
}
OverWriteScreen();
}
static void WaitTmrProc(void)
{
StopTmr(waittmr);
if (status == VIR_TALKING) {
Display_TALKING();
} else if (status == VIR_CALLING) {
Display_CALLING();
} else if (status == VIR_RINGING) {
if (HstCfg.EnableAutoPickup) {
SendKeyMsg(ATTR_FCN, KEY_ACK);
}
}
}
static void RegisterTime(void)
{
GetSysTime_Date((DATE_STRUCT *)TalkRecord.date);
GetSysTime_Time((TIME_STRUCT *)TalkRecord.time);
}
static void InitTalkRecord(void)
{
RegisterTime();
TalkRecord.talktime[0] = 0;
TalkRecord.talktime[1] = 0;
TalkRecord.tellen = EntryTel.tellen;
memcpy(TalkRecord.tel, EntryTel.tel, sizeof(TalkRecord.tel));
}
static void StoreTalkRecord(void)
{
if (!(EntryTel.attrib == TALK_DIAL && EntryTel.tellen == 0))
AddTalkRecord(EntryTel.attrib, &TalkRecord); /* store talk record */
}
static void ExitVirPhone(char *str, INT8U time)
{
ActivateLowestWinStack();
FormatTime(&dplytime[11], 0, TalkRecord.talktime[0], TalkRecord.talktime[1]);
memset(&PromptEntry, 0, sizeof(PromptEntry));
PromptEntry.Mode = PROMPT_NOKEY;
PromptEntry.LiveTime = time;
if (str == 0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -