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

📄 newmail.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



#include <asixwin.h>

#include <asixapp.h>

#include <ppsm.h>



#include <asixwin\asix_mn.h>

#include <asixwin\select.h>

#include <asixwin\asix_sb.h>

#include <asixwin\asix_lb.h>

#include <asixwin\disp.h>

#include <asixwin\asix_ed.h>

#include <sys\flash.h>

//#include <simdrv\include\flash.h>



#include "asixmail.h"

//#include "const.h"

#include "netcfg.h"





const char	*newmail_help[3] =
{"\n [发信人]是指发送邮件者的电子邮件地址.如果您所写的邮件是一封新邮件,ASIX 电子邮件\
系统将把系统配置中的POP3帐号与服务器地址合并为您的发信人地址. 如您的POP3帐号是 yourname\
,而POP3服务器是pop.company.com,则系统为您生成的[发信人]地址是: yourname@pop.company.com .\
如果您所写的邮件是一封回复邮件,ASIX 系统将自动地将被回复邮件的收信人地址作为[发信人]地址.\n\
当然,您可以修改系统为您填写的缺省地址.",
"\n [收信人]是指接受该邮件者的地址.  如果您所写的邮件是一封新邮件,该项将为空,您必须自己填写\
如果您所写的邮件是一封回复邮件,ASIX 系统将自动地将被回复邮件的发信人地址作为[收信人]地址.\n\
[注意] 只要将几个人的地址用逗号或空格分隔开,您就可以将一封邮件同时发送给几个人. 如您要将该\
邮件发送给 wang@host1.com.cn,liu@host2.com,和 zhang@host3.net, 则[收信人]地址应该填写:\n\
[wang@host1.com.cn,liu@host2.com,zhang@host3.net]\n 目前ASIX 邮件系统支持将一封邮件同时发送\
给5个地址.",
"\n [主题]是您所写邮件的标题.[主题]可以为空",
};



//char		*OutSideMail[MAXBOXITEM];



struct newmail_his from_his[HISTORY_NUM];

struct newmail_his to_his[HISTORY_NUM];



void mailrip(char *);

char *readline(char *bufptr);

int isaddr(char *s);/*fefined in domian.c*/



static char *newmail_wizard(char *newmail_ptr,struct mail_head *reply, U8 mode)

{



	U8      order=0,quit=0;

//	U32		PrevId,NextId,QuitId,HelpId,HistId;

	U8		from_buf[257];

	U8		to_buf[257];

	U8		sub_buf[257];

//	U8      newmail_ptr1 [800];

//	char 		temp[100];

	U32          keyboard,newmailwin1,gc,bt_up,bt_down,bt_cancel,bt_help,bt_history,edit;//bt_exit;

	static	    MSG	   Msg;

//	char      *p2;

//	char       *p3;

//	char       *p4;

//	char       *p5;

//	char        *p6;

	register P_U8	text,point=NULL;

//	U16		timeCount;

//	U16		xSrc,ySrc,xDest,yDest;

//	U32		size,areaId;

//	P_U16	        data;

	char		Monthstr[4];

    U16          year,month,day,hour,minute,second;

	U8	     NextDisable=FALSE,PrevDisable=TRUE,HistDisable=FALSE;

	U16      i=0;

	static U8	verbose=TRUE;

    char     * p;

    char		*history[10];

//	char 		pulllist_rv;

	struct newmail_his	*hisptr;

	U32  cur;

	

	 char      *Title[3]=

	{

		"发信人:",

		"收信人:",

		"主  题:"

	};

	

	

	const struct cfg_wizardtemp	CfgTemp[3]=

	{

		159,YINGWEN_L,YINGWEN_L|FUHAO|SHUZI|YINGWEN_U,(void *)from_his,	//From:

		159,YINGWEN_L,YINGWEN_L|FUHAO|SHUZI|YINGWEN_U,(void *)to_his,	//To:

		159,SHOUXIE,ALLINPUT,NULL,					//Subject:

		

	};	

	const char	*str1[3]=

	{

		"确定放弃",

		"取消",

		"不再显示该信息",

		

	};	

	



//timeCount=timeOutLen;

	//ActiveAreaEnable((P_U32)&XAreaId,ICON_AREA,STROKE_MODE,1,1,158,130);

   memset(from_buf,0x0,257);

        memset(to_buf,0x0,257);

        memset(sub_buf,0x0,257);

        if (reply!=NULL) {

       		if (mode==REPLY_MAIL) {

       			text=readline(reply->to);

       			strcpy(from_buf,text);

       			rip(from_buf);

       		

       			text=readline(reply->from);

       			strcpy(to_buf,text);

       			rip(to_buf);

       		      		

       			text=readline(reply->subject);

       			rip(text);

       			p = strcat("Re:",text);

				strcpy(sub_buf, (U8 *)p);

       			//sprintf(sub_buf,"Re:%s",text);

       			rip(sub_buf);

       		} else if (mode==EDIT_MAIL||mode==RESEND_MAIL) {

       			text=readline(reply->to);

       			strcpy(to_buf,text);

       			rip(to_buf);

       		

       			text=readline(reply->from);

       			strcpy(from_buf,text);

       			rip(from_buf);

       		      		

       			text=readline(reply->subject);

       			strcpy(sub_buf,text);

       			rip(sub_buf);

       		} else if (mode==OUTSIDE_MAIL){

       			if (reply->to!=NULL)

       				strcpy(to_buf,reply->to);

       			//Here have some problems, because maybe the user has never entered asixmail

       			//the Netcfg pointer can be invalid

       			/*Netcfg=(struct netcfg *)((char *)FirstMailMemory+NETCFG_HEAD);

       			if( *(Netcfg->Mail[0].popaccount)!='\0' && *(Netcfg->Mail[0].popserver)!='\0'&&!isaddr(Netcfg->Mail[0].popserver))

       				p = strcat(Netcfg->Mail[0].popaccount,"@");

       				p = strcat(p,Netcfg->Mail[0].popserver);

						strcpy(from_buf,(U8 *)p);

       				//sprintf(from_buf,"%s@%s",Netcfg->Mail[0].popaccount,Netcfg->Mail[0].popserver);	

       			

       		}	

       		

       	}else if( *(Netcfg->Mail[0].popaccount)!='\0' && *(Netcfg->Mail[0].popserver)!='\0' && !isaddr(Netcfg->Mail[0].popserver)){

       	p = strcat(Netcfg->Mail[0].popaccount,"@");

       				p = strcat(p,Netcfg->Mail[0].popserver);

						strcpy(from_buf,(U8 *)p);

       		//sprintf(from_buf,"%s@%s",Netcfg->Mail[0].popaccount,Netcfg->Mail[0].popserver);

       	}   */   		

}}

  mailwzd:    gc=GetGC();

	ClearScreen(gc,GPC_WHITE);

	

	

	newmailwin1 = CreateWindow(WNDCLASS_WIN,"撰写邮件向导",WS_OVERLAPPEDWINDOW,0,0,159,239,0,0,NULL);

	bt_up = CreateWindow(WNDCLASS_BUTTON, "上一步", WS_CHILD|BS_TOOLBAR, 0,223,53,16,newmailwin1,0,NULL);

	bt_down = CreateWindow(WNDCLASS_BUTTON, "下一步", WS_CHILD|BS_TOOLBAR, 53,223,53,16,newmailwin1,0,NULL);

	bt_cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_TOOLBAR, 106,223,53,16,newmailwin1,0,NULL);

	

        bt_help = CreateWindow(WNDCLASS_BUTTON, "帮助", WS_CHILD|BS_TOOLBAR, 0,21,60,16,newmailwin1,0,NULL);

        bt_history = CreateWindow(WNDCLASS_BUTTON, "历史", WS_CHILD|BS_TOOLBAR, 60,21,60,16,newmailwin1,0,NULL);

        

        edit = CreateWindow( WNDCLASS_EDITOR,"jwei@seu.edu.cn",WS_CHILD | ES_SINGLE_REGULAR,5,70,110,20,newmailwin1,30,NULL);



		

	//keyboard = CreateWindow( WNDCLASS_KEYBAR,NULL,WS_CHILD,0,120,118,16,newmailwin1,0,NULL);

	   keyboard = CreateWindow( WNDCLASS_KEYBD,

						NULL,

						WS_CHILD|KBS_PINGYING|0xff,

						1,120,

						158,80,

						newmailwin1,

						0,

						NULL);



	SetFocus( edit );

        

        Disp16String(Title[order],5,48);

        

       // memset(from_buf,0x0,257);

       // memset(to_buf,0x0,257);

       // memset(sub_buf,0x0,257);

        

        

        if (point==NULL) {point=from_buf;}/* The first time enter */

        else {

        	//ActiveAreaSuspend(PrevId,AREA_REENABLE);

        	//DestroyWindow(bt_up);

		//Disp16String("上一步",1,144);

		PrevDisable=TRUE;

		NextDisable=FALSE;

	}

	

	if (CfgTemp[order].history==NULL) {

		//ActiveAreaSuspend(HistId,AREA_SUSPEND);

		//Advswitchonetotwo(smart_history,110,21,24,24,BLACK_TO_DARKGREY,WHITE_TO_WHITE);

		HistDisable=TRUE;

	}

	//if(order == 0)InputString(Title[order],0,from_buf,sizeof(from_buf));

	//if(order == 1)InputString(Title[order],0,to_buf,sizeof(to_buf));

	//if(order == 2)InputString(Title[order],0,sub_buf,sizeof(sub_buf));

	//edit = CreateWindow( WNDCLASS_EDITOR,"欢迎使用",WS_CHILD | ES_SINGLE_REGULAR,20,65,80,20,newmailwin1,0,NULL); 

     	

    	//if (EditOpenMode.open_line==EDIT_OPENED) closelineedit();

        //openlineedit(80, point,CfgTemp[order].len, CfgTemp[order].dft_input, CfgTemp[order].allow_input, 0);	

        	

        quit=0;

        while(quit==0)

	{

	 ASIXGetMessage(&Msg, NULL, 0, 0);

		

		                  switch ( Msg.message )

		                  {

			              case	ASIX_RTC:

				                break;



			              case	WM_COMMAND:               

				                 

				                if( (Msg.lparam == bt_up) || (Msg.lparam == bt_down)){

			      	     

		      	      	        	if (Msg.lparam == bt_down) {                                                   

		      	      	        		if (NextDisable) {quit=1;break;}

		      	      	        		order++;

		      	      	        		if (!PrevDisable) {

		      	      	        			//DestroyWindow(bt_up);

		      	      	        			//ActiveAreaSuspend(PrevId,AREA_REENABLE);

		      	      	        			//Disp16String("上一步",1,144);

		      	      	        			//PrevDisable=FALSE;

		      	      	        

		      	      	        			PrevDisable=TRUE;

		      	      	        		}

		      	      	        			

		      	      	        	}else{	

		      	      	        		order--;

		      	      	        		if (NextDisable) {

		      	      	        			NextDisable=FALSE;

		      	      	        			//Disp16String("下一步",40,144);

		      	      	        		}

		      	      	        		

		      	      	        	}		

		      	      	        	if (order<0 || order>4) {

		      	      	        		order=0;

		      	      	        		PrevDisable=TRUE;

		      	      	        		//Disp16String("上一步",1,144);

		      	      	        		//DestroyWindow(bt_up);

		      	      	        		//ActiveAreaSuspend(PrevId,AREA_SUSPEND);

		      	      	        	}	 

		      	      	        	

		      	      	        	

		      	      	        	else if (order>=3){

		      	      	        		order=3;

		      	      	        		NextDisable=TRUE;

		      	      	        		Disp16String("完  成",40,144);

		      	      	        		quit=3;point=sub_buf; break;

		      	      	        	}	

		      	      	        	

		      	      	        	/*if (CfgTemp[order].history!=NULL&&HistDisable) {

		      	      	        		HistDisable=FALSE;

		      	      	        		ActiveAreaSuspend(HistId,AREA_REENABLE);

							switchonetotwo(smart_history,110,21,24,24);

		      	      	        		

		      	      	        	}

		      	      	        	if (CfgTemp[order].history==NULL&&!HistDisable) {

		      	      	        		HistDisable=TRUE;

		      	      	        		ActiveAreaSuspend(HistId,AREA_SUSPEND);

							Advswitchonetotwo(smart_history,110,21,24,24,BLACK_TO_DARKGREY,WHITE_TO_WHITE);

		      	      	        		

		      	      	        	}*/

		      	      	        		

		      	      	        	//ClearRec(GC,WHITE,2,48,155,94,REPLACE_STYLE);

		      	      	        	

		      	      	        /*	switch(order)

		      	      	        	{

		      	      	        		case 0: point=from_buf; break;

		      	      	        		case 1: point=to_buf;break;

		      	      	        		case 2: point=sub_buf; break;

		      	      	

		      	      	        }*/

		      	      	        //RepaintWindow((U32)CurWindow, 0);

					//	Disp16String(Title[order],5,48);

					        quit=1;

		      	      	        	break;

		      	      	        	//if (EditOpenMode.open_line==EDIT_OPENED) closelineedit();

		      	      	        	/*we disable pen interrupt for the safe sake*/

						//PenIrptDisable();

		      	      	        	//openlineedit(80, point,CfgTemp[order].len, CfgTemp[order].dft_input, CfgTemp[order].allow_input, 0);

		      	      	        	/* we re-enable the pen interrupt after the open procedual*/

						//PenIrptEnable();

		      	      	        	//mark=0;

			      	     // }	        

			      	       if (Msg.lparam == bt_help){

			      	      		//ActiveAreaRead(areaId,&xSrc,&ySrc,&xDest,&yDest);

                   			        //InvRec((xSrc+1),(ySrc+1),(xDest-(xSrc+1)),(yDest-(ySrc+1)));

                   			       // helpinfo(newmail_help[order]);

                 		      }

                 		   if (Msg.lparam == bt_history){

 						memset((char *)history,0x0,10*sizeof(char *));

 						hisptr=(struct newmail_his *)CfgTemp[order].history;  

 						for (i=0;i<HISTORY_NUM&&*(hisptr->str)!='\0';i++,hisptr++)

 							history[i]=hisptr->str;

 						//pulllist_rv=pulllist_ctrl(100,46,history,0);

 						//if (pulllist_rv!=-1 && pulllist_rv!=NULL_PULLLIST) {

 						//	strcpy(point,history[pulllist_rv]);

 							//if (EditOpenMode.open_line==EDIT_OPENED) closelineedit();

		      	      	        		/*we disable pen interrupt for the safe sake*/

							//PenIrptDisable();

		      	      	        	//	openlineedit(80, point,CfgTemp[order].len, CfgTemp[order].dft_input, CfgTemp[order].allow_input, 0);

		      	      	        		/* we re-enable the pen interrupt after the open procedual*/

							//PenIrptEnable();

						}	



 								              		      	

                 		      	

                 		      	

                 			}

			      	       if (Msg.lparam == bt_cancel){

			      	      	       // ActiveAreaRead(areaId,&xSrc,&ySrc,&xDest,&yDest);

                   			        //InvRec(xSrc,ySrc,xDest-xSrc,yDest-ySrc);

			      	      	        if (verbose)

			      	      	        cur = GetCurWindow(  );

			      	      	       	i= MessageBox(cur, "将放弃新邮件的编辑,确定吗?", "友情提醒", MB_YESNO );  	      	        	      	       

			      	      	       

			      	      	         if (i==IDNO){ 

			      	      	        	break;

			      	      	        }else if (i==IDYES){

			      	      	        	quit=2;

			      	      	        	verbose=FALSE;

			      	      	        	break;

			      	      	        }

					        

					 case	WM_QUIT:

				                quit = 2;

				                break;	

			      	           

			                 }

			    

			                 break;

			         default:

				             break;

	

		                }

		       

		DefWindowProc(Msg.message, Msg.lparam, Msg.data, Msg.wparam);   

                

               }

                 if(order == 1)GetEditorStr( edit, from_buf, sizeof(from_buf)-1 );

                 if(order == 2)GetEditorStr( edit, to_buf, sizeof(to_buf)-1 );

                 if(order == 3)GetEditorStr( edit, sub_buf, sizeof(sub_buf)-1 );

			 /*case IRPT_HWR:

				hw_select(areaId,(P_U16)data,size,NULL);

				editline_key(point);

				

				break;

			 

			 case IRPT_KEY: * softkey *

			      timeCount=timeOutLen;

			      SoftKeyTone(0);

			      if (kb_select(areaId,(P_U16)data,size,NULL)) break;

				editline_key(point);

			      

			      break;*/

			  

		//switch(IrptGetData((P_U32)&areaId,(P_U32*)&data,(P_U32)&size))

	//while(!quit)

	

	

	//ActiveAreaDisable(PrevId);

	//ActiveAreaDisable(NextId);

	//ActiveAreaDisable(QuitId);

	//ActiveAreaDisable(HelpId);

	//ActiveAreaDisable(HistId);

	//if (EditOpenMode.open_line==EDIT_OPENED) closelineedit();    

  

   if(quit==2) {

   		DestroyWindow(newmailwin1);

	return NULL;                  



   	

         }

        if(quit == 1) {DestroyWindow(newmailwin1);goto mailwzd;}

	

	if ( to_buf[0]=='\0'||from_buf[0]=='\0' )

   	{	

   		order=0;

   		cur = GetCurWindow(  );

   		MessageBox(cur, "收发信人地址,不能为空!", "友情提醒", MB_OK);  

   		//AdvHintWin("收发信人地址","不能为空!",60,0);

		goto mailwzd;

	}

   	

   	for (i=0;(i<HISTORY_NUM) && (from_his[i].str[0]!='\0');i++) 

   		if (!strcmp(from_his[i].str,from_buf)) break;

   	if (i==HISTORY_NUM || from_his[i].str[0]=='\0') {

   		for (i=0;i<HISTORY_NUM && from_his[i].str[0]!='\0';i++);

   		

   		if (i==HISTORY_NUM)

   			i=rand() % (i);

   		

   		memcpy(from_his[i].str, from_buf, 58);

   		from_his[i].str[58]='\0';

   		from_his[i].hits=0;

   			

   		

   	}	

   	

   	for (i=0;i<HISTORY_NUM && to_his[i].str[0]!='\0';i++) 

   		if (!strcmp(to_his[i].str,to_buf)) break;

   	if (i==HISTORY_NUM || to_his[i].str[0]=='\0') {

   		for (i=0;i<HISTORY_NUM && to_his[i].str[0]!='\0';i++);

   		

   		if (i==HISTORY_NUM)

   			i=rand() % (i);

   		

   		memcpy(to_his[i].str, to_buf, 58);

   		to_his[i].str[58]='\0';

⌨️ 快捷键说明

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