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

📄 asixbox.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 <sys\flash.h>



#include "asixmail.h"

//#include "const.h"

#include "netcfg.h"



struct mail_head	mailhead[MAXBOXITEM];

//char *rip1(char *);

//extern void rip(char *);

extern char *readline(char *bufptr);



extern void mailrip(void *s);



U8 MailBox(U8 mode){

	

//	U16       	timeCount;

//	P_U16     	data;

//        U16       	xSrc,ySrc,xDest,yDest;

//	U32       	XAreaId,PageupId,PagedownId,NewId,SendId,QuitId;

//	P_U32     	size,areaId;

	char		*inbox;

	char		*outbox;

//        char            *p;

	U8		l=0,mboxaction=0;

	char		*to,*date;

	U8		ListIconSelected=FALSE;

	U8		window=0;

	static	    MSG	   Msg;

	U32         gc,sendwin,sentwin,receivewin;

	U32         bt_newmail,bt_receivesend,bt_exit1,bt_pageup,bt_pagedown;//;

	U32         bt_[3]={0,0,0},cur;

	struct list {

		U32			id;

		struct mail_head	*head;

	} maillist[3];	

	

	

	register U8		i;

	register char		*ptr;

	struct outbox_index *tmpcfg;

	

	//timeCount=timeOutLen;



    	gc=GetGC();

	ClearScreen(gc,GPC_WHITE);



        

                         

        if(mode==OUTBOXLIST){

        sendwin=CreateWindow(WNDCLASS_WIN,"发 件 箱",WS_OVERLAPPEDWINDOW,0,0,159,239,0,0,NULL);

        bt_newmail = CreateWindow(WNDCLASS_BUTTON, "新信", WS_CHILD|BS_TOOLBAR, 0,223,53,16,sendwin,0,NULL);

	bt_receivesend = CreateWindow(WNDCLASS_BUTTON, "收发", WS_CHILD|BS_TOOLBAR, 53,223,53,16,sendwin,0,NULL);

	bt_exit1 = CreateWindow(WNDCLASS_BUTTON, "退出", WS_CHILD|BS_TOOLBAR, 106,223,53,16,sendwin,0,NULL);

	bt_pageup = CreateWindow(WNDCLASS_BUTTON, "上", WS_CHILD|BS_TOOLBAR, 139,16,20,16,sendwin,0,NULL);

	bt_pagedown = CreateWindow(WNDCLASS_BUTTON, "下", WS_CHILD|BS_TOOLBAR, 139,208,20,16,sendwin,0,NULL);

	}

        if(mode==SENTBOXLIST) {

        sentwin=CreateWindow(WNDCLASS_WIN,"已发送邮件",WS_OVERLAPPEDWINDOW,0,0,159,239,0,0,NULL);

        bt_newmail = CreateWindow(WNDCLASS_BUTTON, "新信", WS_CHILD|BS_TOOLBAR, 0,223,53,16,sentwin,0,NULL);

	bt_receivesend = CreateWindow(WNDCLASS_BUTTON, "收发", WS_CHILD|BS_TOOLBAR, 53,223,53,16,sentwin,0,NULL);

	bt_exit1 = CreateWindow(WNDCLASS_BUTTON, "退出", WS_CHILD|BS_TOOLBAR, 106,223,53,16,sentwin,0,NULL); 

	bt_pageup = CreateWindow(WNDCLASS_BUTTON, "上", WS_CHILD|BS_TOOLBAR, 139,16,20,16,sentwin,0,NULL);

	bt_pagedown = CreateWindow(WNDCLASS_BUTTON, "下", WS_CHILD|BS_TOOLBAR, 139,208,20,16,sentwin,0,NULL);

	}

        if(mode==INBOXLIST){ 

        receivewin=CreateWindow(WNDCLASS_WIN,"收 件 箱",WS_OVERLAPPEDWINDOW,0,0,159,239,0,0,NULL);

        bt_newmail = CreateWindow(WNDCLASS_BUTTON, "新信", WS_CHILD|BS_TOOLBAR,0,223,53,16,receivewin,0,NULL);

	bt_receivesend = CreateWindow(WNDCLASS_BUTTON, "收发", WS_CHILD|BS_TOOLBAR, 53,223,53,16,receivewin,0,NULL);

	bt_exit1 = CreateWindow(WNDCLASS_BUTTON, "退出", WS_CHILD|BS_TOOLBAR, 106,223,53,16,receivewin,0,NULL);

	bt_pageup = CreateWindow(WNDCLASS_BUTTON, "上", WS_CHILD|BS_TOOLBAR,139,16,20,16,receivewin,0,NULL);

	bt_pagedown = CreateWindow(WNDCLASS_BUTTON, "下", WS_CHILD|BS_TOOLBAR, 139,208,20,16,receivewin,0,NULL);                

        }

mboxaction=0;

mlist: memset((char *)mailhead,0x0,MAXBOXITEM*sizeof(struct mail_head));

	inbox=Datatemp+INBOX_HEAD;

	outbox=Datatemp+OUTBOX_HEAD;

	if ((to=(char *)Lmalloc(300))==NULL) return 1;

        if ((date=(char *)Lmalloc(300))==NULL) { Lfree(to); return 1;}

        

        l=0;ListIconSelected=FALSE;

        

	if (mode==INBOXLIST) {

		InboxIndex=(struct inbox_index *)(Datatemp+INBOX_INDEX_HEAD);

		

		for (i=0;(i<MAXBOXITEM)&&(InboxIndex[i].flag!=EMPTYINDEX);i++){

			mailhead[i].flag=InboxIndex[i].flag;

			mailhead[i].index=i;

			//mailhead[i].from=&inbox[InboxIndex[i].headoff+5];/* do not copy "From:"*/

			if((ptr = strstr(&inbox[InboxIndex[i].headoff],"From:"))!=NULL) {

				ptr += 6;

				mailhead[i].from = ptr;

			}

				

			

			

			

			

			

			for(ptr=&inbox[InboxIndex[i].headoff];*ptr!='\n';ptr++);

			mailhead[i].to=++ptr+3;/* do not copy "To:"*/

			for (ptr=++ptr;*ptr!='\n';ptr++);

			mailhead[i].subject=++ptr+8;/*do not copy "Subject:"*/

			for (ptr=++ptr;*ptr!='\n';ptr++);

			mailhead[i].date=++ptr+5;/*do not copy "Date:"*/

			for (ptr=++ptr;*ptr!='\n';ptr++);

			mailhead[i].text=++ptr;

		}	

		

	} else if (mode==OUTBOXLIST)  {

		//OutboxIndex=(struct outbox_index *)(Datatemp+OUTBOX_INDEX_HEAD);

		tmpcfg = (struct outbox_index *)Lmalloc(MAXBOXITEM*sizeof(struct outbox_index));

		memcpy(tmpcfg,Datatemp+OUTBOX_INDEX_HEAD,MAXBOXITEM*sizeof(struct outbox_index));

		OutboxIndex = (struct outbox_index *)tmpcfg;

		

		for (i=0;(i<MAXBOXITEM)&&(OutboxIndex[i].flag!=EMPTYINDEX);i++){

			if (OutboxIndex[i].flag==MAILUNSENT){

				mailhead[l].flag=OutboxIndex[i].flag;

				mailhead[l].index=i;

				mailhead[l].from=&outbox[OutboxIndex[i].headoff+5];/* do not copy "From:"*/

				ptr =&outbox[OutboxIndex[i].headoff];

				for(ptr =&outbox[OutboxIndex[i].headoff];*ptr!='\n';ptr++);

				

				mailhead[l].to=++ptr+3;/* do not copy "To:"*/

				for (ptr=++ptr;*ptr!='\n';ptr++);

				

				mailhead[l].subject=++ptr+8;/*do not copy "Subject:"*/

				for (ptr=++ptr;*ptr!='\n';ptr++);

				

				mailhead[l].date=++ptr+5;/*do not copy "Date:"*/

				for (ptr=++ptr;*ptr!='\n';ptr++);

				

				mailhead[l].text=++ptr;

				l++;

			} else continue;

		}	

	} else if (mode==SENTBOXLIST) {

		OutboxIndex=(struct outbox_index *)(Datatemp+OUTBOX_INDEX_HEAD);

		

		

		for (i=0;(i<MAXBOXITEM)&&(OutboxIndex[i].flag!=EMPTYINDEX);i++){

			if (OutboxIndex[i].flag==MAILSENT){

				mailhead[i].flag=OutboxIndex[i].flag;

				mailhead[i].index=i;

			

				mailhead[l].from=&(outbox[OutboxIndex[i].headoff+5]);/* do not copy "From:"*/

				for(ptr=&outbox[OutboxIndex[i].headoff];*ptr!='\n';ptr++);

				mailhead[l].to=++ptr+3;/* do not copy "To:"*/

				for (ptr=++ptr;*ptr!='\n';ptr++);

				mailhead[l].subject=++ptr+8;/*do not copy "Subject:"*/

				for (ptr=++ptr;*ptr!='\n';ptr++);

				mailhead[l].date=++ptr+5;/*do not copy "Date:"*/

				for (ptr=++ptr;*ptr!='\n';ptr++);

				mailhead[l].text=++ptr;

				l++;

			} else continue;

		}	

		

	} else {

		Lfree(to);Lfree(date);

		return 1;

	}

	

	



                         

        

        memset((char *)maillist,0x0,3*sizeof(struct list));

       

        

        for(i=0;(i<3)&&(mailhead[i+window].from!=NULL);i++) {

        	

		maillist[i].head=&mailhead[i+window];

		if (mode==INBOXLIST) {

//			Disp16String("from:",0,22+40*i);

//			Disp16String("date:",0,42+40*i);

//			p=rip1(maillist[i].head->from);

//		

			

//			bt_[i] = CreateWindow(WNDCLASS_BUTTON,p, WS_CHILD|BS_TOOLBAR,31,22+40*i,55,16,receivewin,0,NULL); 

//			p=rip1(maillist[i].head->date);

//			Disp16String(p,30,42+20*i);

//			if (maillist[i].head->flag==MAILREADED) {

//				InvRec(gc,0,22+40*i,105,40);

//			}

	        sprintf(to,"From:%s",readline(maillist[i].head->from));

			sprintf(date,"Date:%s",readline(maillist[i].head->date));

			mailrip(to);mailrip(date);

			if (maillist[i].head->flag==MAILUNREADED) {

				//Disp16String(to,2,24+40*i);

			    if(mboxaction==0||5)bt_[i] = CreateWindow(WNDCLASS_BUTTON,to, WS_CHILD|BS_TOOLBAR,0,60+40*i,85,17,receivewin,0,NULL);

			    //if(mboxaction==0||5)bt_[i] = CreateWindow(WNDCLASS_BUTTON,*to, WS_CHILD|BS_REGULAR,0,60+40*i,85,17,sendwin,0,NULL); 

			else {

				SetWindowText(bt_[i],to,NULL);

				//EnableWindow(bt_[i],TRUE,NULL);

				EnableWindow(bt_[i],TRUE);

            }    

				Disp16String(date,2,82+40*i);

			}

			

		} else {

//			Disp16String("to:",0,22+40*i);

//			Disp16String("da",0,42+40*i);

//			p=rip1(maillist[i].head->to);

//			

//			bt_[i] = CreateWindow(WNDCLASS_BUTTON,p, WS_CHILD|BS_TOOLBAR,0,22+40*i,85,17,sendwin,0,NULL); 

			//bt_[i]1 = CreateWindow(WNDCLASS_BUTTON,maillist[i].head->date, WS_CHILD|BS_TOOLBAR,28,22+40*i,85,20,receivewin,0,NULL); 

//			p=rip1(maillist[i].head->date);

			//			Disp16String(p,0,41+40*i);

		    sprintf(to,"To:%s",readline(maillist[i].head->to));

			sprintf(date,"Date:%s",readline(maillist[i].head->date));

			mailrip(to);mailrip(date);

			//Disp16String(to,2,24+40*i);

			if(mboxaction==0||5)bt_[i] = CreateWindow(WNDCLASS_BUTTON,to, WS_CHILD|BS_TOOLBAR,0,60+40*i,85,17,sendwin,0,NULL); 

			else {

				SetWindowText(bt_[i],to,NULL);

				//EnableWindow(bt_[i],TRUE,NULL);

				EnableWindow(bt_[i],TRUE);

            }

			Disp16String(date,2,82+40*i);

		}

				

		

		

	}

	

	mboxaction=0;

	

        while(mboxaction==0) {

        	

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

		

		                  switch ( Msg.message )

		                  {

			              case	ASIX_RTC:

				                break;



			              case	WM_COMMAND:               

				                if(Msg.lparam == bt_[0]){

							    if(ReadMail(maillist[0].head,mode)==2);

							    //EnableWindow(bt_[0],FALSE,NULL);

							    EnableWindow(bt_[0],FALSE);

								//EnableWindow(bt_[1],FALSE,NULL);

								EnableWindow(bt_[1],FALSE);

								//EnableWindow(bt_[2],FALSE,NULL);

								EnableWindow(bt_[2],FALSE);

									cur = GetCurWindow(  );

										SysClearRec( gc, GPC_LIGHTGREY, 0, 20, 140, 200 , GPC_AND_STYLE);

							          

								mboxaction=4;	

							    break;

				                }

				                

	                                        if(Msg.lparam == bt_[1]){

                                                        if(ReadMail(maillist[1].head,mode)==2);

							   // EnableWindow(bt_[0],FALSE,NULL);

							       EnableWindow(bt_[0],FALSE);

								//EnableWindow(bt_[1],FALSE,NULL);

								EnableWindow(bt_[1],FALSE);

								//EnableWindow(bt_[2],FALSE,NULL);

								EnableWindow(bt_[2],FALSE);

									cur = GetCurWindow(  );

										SysClearRec( gc, GPC_LIGHTGREY, 0, 20, 140, 200 , GPC_AND_STYLE);

							          

														mboxaction=4;	

							    break;

				                }

				                

                                               if(Msg.lparam == bt_[2]){

                                                          if(ReadMail(maillist[2].head,mode)==2);

							    // EnableWindow(bt_[0],FALSE,NULL);

							       EnableWindow(bt_[0],FALSE);

								//EnableWindow(bt_[1],FALSE,NULL);

								EnableWindow(bt_[1],FALSE);

								//EnableWindow(bt_[2],FALSE,NULL);

								EnableWindow(bt_[2],FALSE);

								

														  cur = GetCurWindow(  );

										SysClearRec( gc, GPC_LIGHTGREY, 0, 20, 140, 200 , GPC_AND_STYLE);

							          

														  mboxaction=4;	

							    break;

				                }

						 

				                if(Msg.lparam == bt_pageup){

				                	if ( (window-3)>=0 ){

										

                                      // EnableWindow(bt_[0],FALSE,NULL);

                                       EnableWindow(bt_[0],FALSE);

								       //EnableWindow(bt_[1],FALSE,NULL);

								       EnableWindow(bt_[1],FALSE);

								      // EnableWindow(bt_[2],FALSE,NULL);

								      EnableWindow(bt_[2],FALSE);

										cur = GetCurWindow(  );

										SysClearRec( gc, GPC_LIGHTGREY, 0, 20, 140, 200 , GPC_AND_STYLE);

							            window-=3;

							            mboxaction=4;

									}

								} 

						if(Msg.lparam == bt_pagedown){

							if (mailhead[window+3].from!=NULL){

							

                                       // EnableWindow(bt_[0],FALSE,NULL);

                                       EnableWindow(bt_[0],FALSE);

								//EnableWindow(bt_[1],FALSE,NULL);

								EnableWindow(bt_[1],FALSE);

								//EnableWindow(bt_[2],FALSE,NULL);

								EnableWindow(bt_[2],FALSE);

										cur = GetCurWindow(  );

										SysClearRec( gc, GPC_LIGHTGREY, 0, 20, 140, 200 , GPC_AND_STYLE);

							window+=3;

							mboxaction=4;

⌨️ 快捷键说明

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