⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 callcard.c

📁 国家ASIC工程中心使用的嵌入式操作系统
💻 C
📖 第 1 页 / 共 5 页
字号:



/***********************************************************
注意,需要添加代码发送短信和拨打电话在        *
CardDualSMS()函数中                                                                       *
************************************************************







/**********************************************************
*
*Copyright ? 2001-2003 National ASIC Center,	All right Reserved
*
* FILE NAME:				Callcard.c
* PROGRAMMER:			Christian-ren
* Date of Creation:		2002/08/28
* 
* DESCRIPTION:		      Card module
*		
* NOTE:
*------------------------------------------------------------------
* FUNCTIONS LIST:
* -- PUBLIC FUNCTIONS --
*     void MainCard(void)
*------------------------------------------------------------------
* -- LOCAL FUNCTIONS --
*	CALLCARD * CardLinkJumpToPos(CALLCARD * head,S16 pos)
*	void CardDualSMS(U32 hGC,P_S8 numptr,P_S8 nameptr,U8 ismobcall)
*	STATUS	CardDetailDisplay(P_S8 * recordinf,P_S8 * cueinf, U16 len, S16 startpos, S16 endpos, U32 *bt,U32 *st)
*	void   BrowseCardDetail(CALLCARD * thisptr, U8  mode, U8 *isturntoedit,S16 * starpos ,U16  len,THUMBRECORD *thumbtype,U8 isfirst,U8 islast,U32 hGC)
*	CALLCARD *  SearchCallCard(U16 *recordlen,U8 * isfindok,U32 hGC)
*	STATUS	CardDisplay(CALLCARD *  displaylist, U16 len, S16 startpos, S16 endpos, U32 *bt)
*	void  NewCardRecordInf(CALLCARD* newptr)
*	void  FreeCardList(CALLCARD *head)
*	void CardProcess(void)
*
*------------------------------------------------------------------
*
* GLOBAL VARS LIST:
*    DBLACB	*cardlacb;   //定义一个数据库控制块的变量
*-------------------------------------------------------------------
*
* 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 "callcard.h"
#include <database\carddb.h>

#include <resource\sysicon.h>

extern  CALLCARD * CardLoadRelationData(RELATIONSHIP relation,U16 *len);
extern  STATUS  CardDelRecord(CALLCARD*thisptr);
extern  STATUS CardSaveModfToSrc(CALLCARD*thisptr,CARDBUFRECORDINF * inf);
extern void  CardAddRecordToDB(CALLCARD*thisptr,SAVEMODE mode);
extern  void CardCompareModSrc(CALLCARD *thisptr,CARDBUFRECORDINF * inf,U8 * ismodfptr);
extern  STATUS CardSaveModfToSrc(CALLCARD*thisptr,CARDBUFRECORDINF * inf);
extern  void  EditCardDetail(CALLCARD * thisptr, ACCESSSTYLE  mode ,U8 PhStyle, P_S8 * num ,U8 *wintext,SAVEMODE savemode);
extern CALLCARD * CardLoadSearchData(P_S8 string,U16 *len,U8 mode);

void MainCard(void);


TASKDESCRIPTION CallCardTskDesp = 
{"名片",	ASIX_APP,	0,	zi_card,	8192,	1,	LCD_WIDTH,	LCD_HEIGHT,	MainCard,	APP_PRI};



DBLACB	*cardlacb;   //定义一个数据库控制块的变量



CALLCARD * CardLinkJumpToPos(CALLCARD * head,S16 pos)
{
    S16 count;
    CALLCARD * 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;
}







void CardDualSMS(P_S8 numptr,P_S8 nameptr,U8 ismobcall)
{
    MSG 	msg;
 	U32		sendwin,bt1,bt2,bt3,st;
 	U8		quit=0;
    S8      outputinf[200] = "请选择拨号或放送短信:\n\n";
    P_S8      str1 = "姓名:";
    P_S8      str2 = "号码:";
    U32 hGC;
	U32	tskbar;	// 任务栏

    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);		
 	tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,sendwin, 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 );

}


CALLCARD *CardSearchThisidFrList(CALLCARD* head,U32 id)
{
	CALLCARD * tmptr = head;

	while(tmptr !=NULL)
	{
		if(tmptr->ID == id)
			return tmptr;	
		tmptr=tmptr->next;
	}
	return NULL;
}





//是在浏览模块中调用的函数
STATUS	CardDetailDisplay(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 hereCardDetail;
		}

		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++;
		}
		hereCardDetail:
//		GroupOff( hGC, 4, 68, 142,215);
		return	ASIX_OK;
}











//返回值作了修改,原来是PHONE
//如果是需要上下记录的翻阅,可以使用**thisptr   XXXXXX
//XXXX内部外部访问模式还未编程,等到编写外部模块时候在说
 void   BrowseCardDetail(CALLCARD * head, U8  mode, U8 *isturntoedit,U16  len,U32 inputid,U32 *outputid)
 {
	MSG 	msg;
 	U32		browsewin,bt1,bt2,bt3,bt4,bt5,scroll;
 	U8		quit=0;
    U8         ctel = 0,cmob = 0,cbp = 0,countall = 0;
    U8         cfax = 0,cunit=0,cemail=0,caddress=0,cQQ=0,chabit=0,cpostalcode=0;
    P_S8      nameptr,relationptr;
        
    P_S8      recordinf[MAX_CARDINFNUM];
    P_S8      cueinf[MAX_CARDINFNUM];
    CALLCARD * 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;
	U32		tskbar;	// 任务栏

	hGC = GetGC();
//首先是对输入的数据进行查询,有多少信息
//即就是有多少电话,手机,BP

   memset( (P_VOID)recordinf, 0x0 , MAX_CARDINFNUM*sizeof(P_S8));//初试化新的记录
   memset( (P_VOID)cueinf, 0x0 , MAX_CARDINFNUM*sizeof(P_S8));//初试化新的记录
   memset( (P_VOID)string,  0x0 , 100*sizeof(S8));
   
   firstid = head->ID;
   thisptr = CardLinkJumpToPos(head,(S16)(len -1));
   lastid = thisptr->ID;
   
   thisptr = CardSearchThisidFrList(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];
    }
   }
    

   for (count =0;count<(MAXFAX);count++)
   {
		if((P_S8)(*(thisptr->fax[count]))!= NULL)
      	{
      		cfax++;
      	    pos++;
      	    recordinf[pos] = thisptr->fax[count];
      	}
   }
   for (count =0;count<(MAXUNIT);count++)
   {
		if((P_S8)(*(thisptr->unit[count]))!= NULL)
      	{
      		cunit++;
      	    pos++;
      	    recordinf[pos] = thisptr->unit[count];
      	}
   }
       
   for (count =0;count<(MAXEMAIL);count++)
   {
		if((P_S8)(*(thisptr->email[count]))!= NULL)
      	{
      		cemail++;
      	    pos++;
      	    recordinf[pos] = thisptr->email[count];
      	}
   }

   for (count =0;count<(MAXADDRESS);count++)
   {
		if((P_S8)(*(thisptr->address[count]))!= NULL)
      	{
      		caddress++;
      	    pos++;
      	    recordinf[pos] = thisptr->address[count];
      	}
   }
   for (count =0;count<(MAXQQ);count++)
   {
		if((P_S8)(*(thisptr->QQ[count]))!= NULL)
      	{
      		cQQ++;
      	    pos++;
      	    recordinf[pos] = thisptr->QQ[count];
      	}
   }

   for (count =0;count<(MAXHABIT);count++)
   {
		if((P_S8)(*(thisptr->habbit[count]))!= NULL)
      	{
      		chabit++;
      	    pos++;
      	    recordinf[pos] = thisptr->habbit[count];
      	}
   }

   for (count =0;count<(MAXPOSTALCODE);count++)
   {
		if((P_S8)(*(thisptr->postalcode[count]))!= NULL)
		{
      		cpostalcode++;
      	    pos++;
      	    recordinf[pos] = thisptr->postalcode[count];
      	}
   }

   countall = ctel + cmob + cbp +2+cfax+cunit+cemail+caddress+cQQ+chabit+cpostalcode;//表示有多少数据
   //需要先初始化数组
   cueinf[0] = "姓名:";
   cueinf[1] = "关系:";
   if(ctel != 0)
   {
		cueinf[2] = "固话:"; 
   }
   if(cmob != 0)
   {
		cueinf[2+ctel] = "手机:";
   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -