📄 phbook.c
字号:
/***********************************************************
注意,需要添加代码发送短信和拨打电话在 *
CardDualSMS()函数中 *
************************************************************
/**********************************************************
*
*Copyright ? 2001-2003 National ASIC Center, All right Reserved
*
* FILE NAME: Phbook.c
* PROGRAMMER: Christian-ren
* Date of Creation: 2002/08/28
*
* DESCRIPTION: PHONEBOOK module
*
* NOTE:
*------------------------------------------------------------------
* FUNCTIONS LIST:
* -- PUBLIC FUNCTIONS --
* void MainPhoneBook(void)
*------------------------------------------------------------------
* -- LOCAL FUNCTIONS --
* STATUS PhBookDetailDisplay(P_S8 * recordinf,P_S8 * cueinf, U16 len, S16 startpos, S16 endpos, U32 *bt,U32 *st);
* STATUS DualOrSendSMS(U32 hGC,P_S8 numptr,P_S8 nameptr,U8 ismobcall);
* P_S8 BrowseDetailNote(PHONEBOOK * thisptr, ACCESSSTYLE mode, U8 *isturntoedit,S16 * starpos ,U16 len,THUMBRECORD *thumbtype,U8 isfirst,U8 islast,U32 hGC);
* PHONEBOOK* SearchPhoneBook(U16 *recordlen,U8 * isfindok,U32 hGC);
* PHONEBOOK * LinkJumpToPos(PHONEBOOK * head,S16 pos);
* STATUS PhBookDisplay(PHONEBOOK * displaylist, U16 len, S16 startpos, S16 endpos, U32 *bt);
* void NewRecordInf(PHONEBOOK * newptr);
* void SaveItemToNew(PHONEBOOK *target,PHONEBOOK *source);
* P_S8 PhoneBookProcess(ACCESSSTYLE accesstyle,PHONEBOOK *getitem);
*
*------------------------------------------------------------------
*
* GLOBAL VARS LIST:
* DBLACB *phbooklacb; //定义一个数据库控制块的变量
*-------------------------------------------------------------------
*
* MODIFICATION HISTORY
*
*
* 2002/08/28 by Christian-ren Create the file
*
*************************************************************/
#include <string.h>
#include <asixwin.h>
#include <asixapp.h>
#include <asixwin\asix_lb.h>
#include <asixwin\asix_ed.h>
#include <resource\bitmap.h>
#include <..\app\phone\call.h>
#include <..\app\phone\phonehis.h>
#include <..\app\sms\sms.h>
#include "phbook.h"
#include <database\carddb.h>
#include <resource\sysicon.h>
extern PHONEBOOK * LoadRelationData(RELATIONSHIP relation,U16 *len,DBLACB *phbooklacb);
extern STATUS DelRecord(PHONEBOOK *thisptr,DBLACB *phbooklacb);
extern STATUS SaveSourceToDB(PHONEBOOK *thisptr);
extern void AddRecordToDB(PHONEBOOK *thisptr,SAVEMODE mode,DBLACB *phbooklacb);
extern void CompareModAndSrc(PHONEBOOK *thisptr,P_S8 *recordinf,U8 ctel,U8 cmob,U8 cbp,P_U8 ismodfptr);
extern STATUS SaveModfToSrc(PHONEBOOK *thisptr,P_S8 * recordinf,U8 ctel,U8 cmob,U8 cbp);
extern U8 EditDetailNote(PHONEBOOK * thisptr, ACCESSSTYLE mode ,U8 PhStyle,U8 *outputname,SAVEMODE savemode,DBLACB *phbooklacb);
extern PHONEBOOK * LoadSearchData(P_S8 string,U16 *len,U8 mode,DBLACB *phbooklacb);
extern void FreePhbookList(PHONEBOOK *head);
void MainPhoneBook(void);
TASKDESCRIPTION PhbookTskDesp =
{"电话本", ASIX_APP, 0, gupiao, 4096, 1, LCD_WIDTH, LCD_HEIGHT, MainPhoneBook, APP_PRI};
//是在浏览模块中调用的函数
STATUS PhBookDetailDisplay(P_S8 * recordinf,P_S8 * cueinf, U16 len, S16 startpos, S16 endpos, U32 *bt,U32 *st)
// displaylist是现在需要显示的记录类,listlen是此记录的长度,
//startpos,endpos 分别是链表显示信息的起始和终止记录
//bt是显示记录button的ID,
{
U16 count;
U16 pos = 0;
U32 hGC;
hGC = GetGC();
GroupOn( hGC );
for(count = 0; count < DISP_NUM; count++)
{
SetWindowText(bt[count], NULL, NULL);
SetWindowText(st[count], "", NULL);
EnableWindow(bt[count],FALSE);
// bt++;
// st++;
}
// bt -= DISP_NUM;//XXXX需要注意暂时先显示8个记录,以后要变成9个
// st -= DISP_NUM;
if(len <= 0)
{
SetWindowText(bt[0], " 此记录为空", NULL);
//return ASIX_OK;
goto herephbook;
}
for(count = startpos; count < endpos; count++)
{
EnableWindow(bt[pos], TRUE);
SetWindowText(bt[pos], recordinf[count], NULL);
SetWindowText(st[pos], cueinf[count],NULL);
pos++;
// bt++;
// st++;
}
herephbook:
GroupOff( hGC, 1, 1, LCD_WIDTH-1,LCD_HEIGHT-1);
return ASIX_OK;
}
STATUS DualOrSendSMS(P_S8 numptr,P_S8 nameptr,U8 ismobcall)
{
MSG msg;
U32 hGC;
U32 sendwin,bt1,bt2,bt3,st;
U8 quit=0;
S8 outputinf[200] = "请选择拨号或放送短信:\n\n";
P_S8 str1 = "姓名:";
P_S8 str2 = "号码:";
strcat(outputinf,str1);
strcat(outputinf,nameptr);
strcat(outputinf,"\n\n");
strcat(outputinf,str2);
strcat(outputinf,numptr);
hGC = GetGC();
sendwin = CreateWindow( WNDCLASS_WIN,
"提示信息",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
bt1 = CreateWindow( WNDCLASS_BUTTON,
"拨打电话",
WS_CHILD|BS_REGULAR,
10,150,
40,
20,
sendwin,
0,
NULL);
bt2 = CreateWindow( WNDCLASS_BUTTON,
"发送短信",
WS_CHILD|BS_REGULAR,
60,150,
40,
20,
sendwin,
0,
NULL);
bt3 = CreateWindow( WNDCLASS_BUTTON,
"取消",
WS_CHILD|BS_REGULAR,
110,150,
40,
20,
sendwin,
0,
NULL);
st = CreateWindow(WNDCLASS_STATIC,
outputinf,
WS_CHILD|SS_TEXT|SS_MULTILINE,
10,65,
146,66,
sendwin,
0,
NULL);
hGC = GetGC();
if(ismobcall != 1)
{
EnableWindow(bt2, FALSE);
}
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if( msg.lparam == bt1 )
{
//拨打电话
DialDlg( numptr, nameptr );
quit = 1;
} else
if( msg.lparam == bt2 )
{
//发送短信
ReplySMS( numptr );
quit = 1;
}else
if( msg.lparam == bt3 )
{
quit =1;
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( sendwin );
return ASIX_OK;
}
PHONEBOOK * LinkJumpToPos(PHONEBOOK * head,S16 pos)
{
S16 count;
PHONEBOOK * pointer;
if(pos < 0)
{
return NULL;//error
}
if(pos == 0)
{
return head;
}
pointer = head;
for(count = 0;count<pos;count++)
{
pointer = pointer->next;
}
return pointer;
}
PHONEBOOK *SearchThisidFrList(PHONEBOOK * head,U32 id)
{
PHONEBOOK * tmptr = head;
while(tmptr !=NULL)
{
if(tmptr->ID == id)
return tmptr;
tmptr=tmptr->next;
}
return NULL;
}
//如果是需要上下记录的翻阅,可以使用**thisptr XXXXXX
//XXXX内部外部访问模式还未编程,等到编写外部模块时候在说
P_S8 BrowseDetailNote(PHONEBOOK * head, ACCESSSTYLE mode, U8 *isturntoedit,U16 len,U32 inputid,U32 *outputid)
{
MSG msg;
U32 browsewin,bt1,bt2,bt3,bt4,bt5,scroll,tskbar;
U8 quit=0;
U8 ctel = 0,cmob = 0,cbp = 0,countall = 0;
P_S8 nameptr,relationptr;
P_S8 recordinf[MAX_PHBOOKINFNUM];
P_S8 cueinf[MAX_PHBOOKINFNUM];
PHONEBOOK * thisptr;
U32 firstid;
U32 lastid;
U8 count,pos;
U8 isfirst = 0;
U8 islast = 0;
U8 isneedfreshscr = 0;
U32 bt[DISP_NUM];
U32 st[DISP_NUM];
U8 topdir=FALSE,enddir=FALSE;//标志滚动滑块在页首和页尾,用于阻止相同页面的重刷
S16 startp,endp,high,low;
U8 stringlen;
U32 hmenu;
static S8 string[100];
P_S8 returncall = NULL;
U8 ismobnum = 0;
U32 hGC;
//首先是对输入的数据进行查询,有多少信息
//即就是有多少电话,手机,BP
memset( (P_VOID)recordinf, 0x0 , MAX_PHBOOKINFNUM*sizeof(P_S8));//初试化新的记录
memset( (P_VOID)cueinf, 0x0 , MAX_PHBOOKINFNUM*sizeof(P_S8));//初试化新的记录
memset( (P_VOID)string, 0x0 , 100*sizeof(S8));
firstid = head->ID;
thisptr = LinkJumpToPos(head,(S16)(len -1));
lastid = thisptr->ID;
thisptr = SearchThisidFrList(head,inputid);
if(thisptr->ID ==firstid)
isfirst = 1;
if(thisptr->ID == lastid)
islast = 1;
nameptr = thisptr->name;
switch (thisptr->relation)
{
case FRIEND: relationptr = "朋友"; break;
case FAMILY: relationptr = "家人"; break;
case SCHMATE: relationptr = "同学"; break;
case COLLEAGUE: relationptr = "同事"; break;
case OTHERS: relationptr = "其他"; break;
default:break;
}
recordinf[0] = nameptr;
recordinf[1] = relationptr;
pos = 1;
for (count =0;count<(MAXTELNUM);count++)
{
if((P_S8)(*(thisptr->tel[count]))!= NULL)
{
ctel++;
pos++;
recordinf[pos] = thisptr->tel[count];
}
}
for (count =0;count<(MAXMOBNUM);count++)
{
if((P_S8)(*(thisptr->mobile[count]))!= NULL)
{
cmob++;
pos++;
recordinf[pos] = thisptr->mobile[count];
}
}
for (count =0;count<(MAXBPNUM);count++)
{
if((P_S8)(*(thisptr->bp[count]))!= NULL)
{
cbp++;
pos++;
recordinf[pos] = thisptr->bp[count];
}
}
countall = ctel + cmob + cbp +2;//表示有多少数据
//需要先初始化数组
cueinf[0] = "姓名:";
cueinf[1] = "关系:";
if(ctel != 0)
{
cueinf[2] = "固话:";
}
if(cmob != 0)
{
cueinf[2+ctel] = "手机:";
}
if(cbp != 0)
{
cueinf[2+ctel+cmob] = "寻呼:";
}
hGC = GetGC();
GroupOn(hGC);
browsewin = CreateWindow(WNDCLASS_WIN,
"浏览电话本",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,browsewin, 0, NULL);
bt1 = CreateWindow( WNDCLASS_BUTTON,
"\\第一条",
WS_CHILD|BS_REGULAR,
LCD_WIDTH/2-LCD_HEIGHT*5/24-6,18,
LCD_HEIGHT/12,
LCD_HEIGHT/12,
browsewin,
0,
(char*)zi_first);
bt2 = CreateWindow( WNDCLASS_BUTTON,
"\\上一条",
WS_CHILD|BS_REGULAR,
LCD_WIDTH/2-LCD_HEIGHT/8-3,18,
LCD_HEIGHT/12,
LCD_HEIGHT/12,
browsewin,
0,
(char*)zi_prev);
bt3 = CreateWindow( WNDCLASS_BUTTON,
"\\下一条",
WS_CHILD|BS_REGULAR,
LCD_WIDTH/2-LCD_HEIGHT/24,18,
LCD_HEIGHT/12,
LCD_HEIGHT/12,
browsewin,
0,
(char*)zi_next);
bt4 = CreateWindow( WNDCLASS_BUTTON,
"\\最后一条",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -