📄 call.c
字号:
/*************************************************************************
*
* Copyright 2002 National ASIC Center, All rights Reserved
*
* FILE NAME: voicecall.c
* PROGRAMMER: longn_qi
* Date of Creation: 2002/09/12
*
* DESCRIPTION:
*
* NOTE:
*
*
* FUNCTIONS LIST:
* -------------------------------------------------------------------------
* testAt
* VoiceCall
* InitialGSM
* DialDlg
* TalkingDlg
*
* GLOBAL VARS LIST:
*
*
**************************************************************************
*
* MODIFICATION HISTORY
*
*
* 2002/09/12 by longn_qi Create the file
*
*************************************************************************/
#include <stdio.h>
#include <string.h>
#include "asixwin.h"
#include "asixapp.h"
#include "lmalloc.h"
#include "at.h"
#include "asix_ed.h"
#include "asix_lb.h"
#include "bitmap.h"
#include "sysicon.h"
#include "phonehdb.h"
#include "at_rps.h"
#include "at_pdu.h"
#include "psat.h"
#include "phbook.h"
#include "phonehis.h"
#include "call.h"
#define ST_COMMAND_ERROR 0x00
#define ST_ACTIVE_HANG_UP 0x02
#define ST_INACTIVE_HANG_UP 0x03
#define ST_INACTIVE_PICK_UP 0x04
#define ST_DIALING 0x05
#define ST_TALKING 0x06
#define ST_RINGING 0x07
//static U8 curSMSFormat;
//static U8 LastSMS = 25;
TASKDESCRIPTION PhoneTskDesp =
{"电话", ASIX_APP, 0, dianhua, 4096, 1, LCD_WIDTH, LCD_HEIGHT, VoiceCall, APP_PRI};
//---------------------------------------------------------------
// Name: InitialGSM
//
// Description: Initailize GSM module.
//
// Parameters:
// None
//
// Returns:
// 0 -Initialization succeed.
// result -Initialization failure code.
//---------------------------------------------------------------
DWORD InitGSM( )
{
MSG msg;
DWORD result = 0;
// EnableUartInt( UART0 );
// Test
TEST_AT( );
if( WAIT_AT_COMMAND_RPS( &msg, AT_COM_AT ) != SYS_OK )
result |= 0x00000001;
// Set echo mode
SET_ECHO_MODE( "0" ); // echo off
if( WAIT_AT_COMMAND_RPS( &msg, AT_COM_ATE ) != SYS_OK )
result |= 0x00000002;
// Set SMS format
SET_SMS_FORMAT( "0" ); // PDU format
if( WAIT_AT_COMMAND_RPS( &msg, AT_COM_CMGF ) != SYS_OK )
result |= 0x00000004;
// Set CNMI
SET_CNMI_MODE( "2,1,0,0,1" ); // alert display arriving sms
if( WAIT_AT_COMMAND_RPS( &msg, AT_COM_CNMI ) != SYS_OK )
result |= 0x00000008;
// Set CLIP
SET_CLIP_MODE( "1" ); // display incoming call number
if( WAIT_AT_COMMAND_RPS( &msg, AT_COM_CLIP ) != SYS_OK )
result |= 0x00000010;
// Set Connent Result Code
SET_CONNECT_RESULT_CODE( "4" );
if( WAIT_AT_COMMAND_RPS( &msg, AT_COM_CLIP ) != SYS_OK )
result |= 0x00000020;
return result;
}
//---------------------------------------------------------------
// Name: VoiceCall
//
// Description: This is the phone application main window.
// In this window, there are three functions,
// including searching phone number in phone-book,
// dialing and browser talking history record.
//
// Parameters:
// None
//
// Returns:
//
//---------------------------------------------------------------
void VoiceCall( )
{
MSG msg;
// MSG uartmsg;
// U32 hGC;
// 窗口和控件ID
U32 mainwin; // 主窗口
U32 bt[4];
U32 bt_common; // 常用电话号码
U32 dialPanel;
U32 editor;
U32 tskbar;
// U32 ringTimer;
U8 i, quit = 0;
// U8 state;
U16 temp;
S8 *btcap[4] = { "\\拨号", "\\电话本", "\\通话记录", "\\删除" };
const U8 *bt_icon[4] = { zi_bohao, zi_dianhuabenchazhao, zi_lishijiluchazhao, zi_clean };
// WINDOW ARRANGEMENT
const U16 form_w = PHY_LCD_W, form_h = PHY_LCD_H, form_x = 0, form_y = 0;
const U16 ed_w = form_w - 43, ed_h = 24, ed_x = form_x + 4, ed_y = form_y + 42;
const U16 bt_w = 24, bt_h = 24, bt_x = PHY_LCD_W - bt_w -11, bt_y = ed_y + ed_h + 8;
dbgprintf( "### Enter 电话 ###" );
mainwin = CreateWindow( WNDCLASS_WIN,
"电话",
WS_OVERLAPPEDWINDOW,
form_x,form_y,
form_w,form_h,
0,
0,
NULL);
tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,mainwin, 0, NULL);
temp = bt_y;
for( i = 0; i < 4; i++ )
{
bt[i] = CreateWindow( WNDCLASS_BUTTON,
btcap[i],
WS_CHILD | BS_ICON | BS_FLAT,
bt_x,temp,
bt_w,bt_h,
mainwin,0,(void *)bt_icon[i] );
temp += bt_h + 8;
// 屏蔽按键焦点
EnableFocus( bt[i], FALSE );
}
editor = CreateWindow( WNDCLASS_EDITOR,
NULL,
WS_CHILD | ES_SINGLELINE | ES_RIGHT,
ed_x,ed_y,
ed_w,ed_h,
mainwin,
0,
NULL);
bt_common = CreateWindow( WNDCLASS_BUTTON,
"\\常用电话号码",
WS_CHILD | BS_ICON | BS_FLAT,
bt_x,ed_y,
bt_w,bt_h,
mainwin,0,(void *)zi_changyongyu);
// 屏蔽按键焦点
EnableFocus( bt_common, FALSE );
dialPanel = CreateWindow( WNDCLASS_KEYBD,
NULL,
WS_CHILD|KBS_DIALPAD|0xff,
ed_x,bt_y,
(U16)(form_w-2),16,
mainwin,
0,
NULL);
SetFocus( editor );
// CreateTimer( &ringTimer, 10000, NULL, NULL, ALARM_MODE|AUTO_CLEAR_MODE );
while( !quit )
{
ASIXGetMessage( &msg, NULL, 0, 0 );
switch( msg.message )
{
case WM_COMMAND:
if( msg.lparam == bt[0] ) // 按下拨号键
{
char *number = GetEditorStr( editor, NULL, 0 );
char name[MAXNAMELEN];
char is_find = 0;
if( *number != '\0' )
{
// 根据电话号码查找用户姓名
FindNameFromPhbook( number, name, &is_find );
if( !is_find )
name[0] = '\0';
// 拨号
DialDlg( number, name );
}
else
{
MessageBox( mainwin, "号码不能为空!", "错误", MB_OK | MB_ICONERROR );
}
}
else if( msg.lparam == bt[1] ) // 浏览电话本
{
char *number;
// 查找电话号码
number = GetCallFromPhbook();
if( number != NULL )
SetWindowText( editor, number, NULL );
}
else if( msg.lparam == bt[2] ) // 浏览通话记录
{
// 察看通话记录
BrowserPhoneHistory();
}
else if( msg.lparam == bt[3] ) // 按下删除键
{
MSG ed_msg;
ed_msg.message = WM_CHAR;
ed_msg.lparam = editor;
ed_msg.wparam = ASIX_KEY_DROP;
ed_msg.data = ((ASIX_WINDOW *)editor)->ctrl_str;
SysSendMessage( GetCurTaskID(), &ed_msg );
}
else if( msg.lparam == bt_common ) // 按下常用电话号码键
{
MessageBox( mainwin, "该功能尚未开通!", "谢谢使用", MB_OK | MB_ICONINFORMATION );
}
break;
case WM_ALARM:
if( msg.wparam == ALARM_PHONE ) // 来电
{
char *name, *number;
// 获取来电号码和来电者姓名
name = (char *)msg.data;
if( *name == '\0' )
name = NULL;
number = (char *)msg.data + 25;
if( *number == '\0' )
number = NULL;
// 通话
TalkingDlg( number, name, PhHisTypeLst[RECEIVED_TYPE][0] );
Lfree( msg.data );
}
break;
case WM_KEYDOWN:
case WM_KEYUP:
if( msg.wparam == ASIX_KEY_CALL ) // 按下拨号键
{
char *number = GetEditorStr( editor, NULL, 0 );
char name[MAXNAMELEN];
char is_find = 0;
if( *number != '\0' )
{
// 根据电话号码查找用户姓名
FindNameFromPhbook( number, name, &is_find );
if( !is_find )
name[0] = '\0';
// 拨号
DialDlg( number, name );
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( mainwin );
dbgprintf( "### Exit 电话 ###" );
EndofTask();
}
//---------------------------------------------------------------
// Name: DialDlg
//
// Description: This is dialing dialog window.
//
// Parameters:
// number number for dialing.
// name name of the number owner
//
// Returns:
//
//---------------------------------------------------------------
void DialDlg( char *number, char *name )
{
// U32 hGC;
MSG msg;
U8 quit = 0;
// 窗口和控件ID
U32 mainwin; // 对话框主窗口
U32 stPrompt; // 姓名和电话号码提示
U32 btHangUp = 0, btReDial = 0; // 挂断键和重拨键
U8 state; // 拨号状态
S8 *number_info;
// WINDOW ARRANGEMENT
const U16 formW = PHY_LCD_W*2/3, formH = PHY_LCD_H/3, formX = PHY_LCD_W/6, formY = ( PHY_LCD_H - formH )/2;
const U16 stW = formW - 8, stH = 30, stX = formX + 4, stY = formY + 22;
const U16 btW = 32, btH = 20, btGap = ( formW - btW )/2;
const U16 btHangUpX = formX + btGap, btHangUpY = formY + formH - 24;
dbgprintf( "### Enter 拨号 ###" );
mainwin = CreateWindow( WNDCLASS_WIN,
"拨号中...",
WS_POPUPWINDOW,
formX,formY,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -