📄 netcfg.c
字号:
/* The new Netcfg.c updated from the old one
* We use the new line editor to construct the setup wizard
* Lingming 2000/04/10
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <mem.h>
#include <asixwin.h>
#include <asixapp.h>
#include <ppsm.h>
#include <asixwin\asix_mn.h>
#include <asixwin\asix_ed.h>
#include <asixwin\select.h>
#include <asixwin\asix_sb.h>
#include <asixwin\asix_lb.h>
#include <asixwin\disp.h>
#include <sys\flash.h>
/*add by DSA 2004.07.01*/
#include <net\asixmail.h>
/*end add*/
//#include <simdrv\include\flash.h>
//#include "asixmail.h"
//#include "const.h"
#include "netcfg.h"
struct netcfg *Netcfg;
struct zhangcfg Cfg;
const char *helptext[] =
{
"\n [DNS服务器]也叫域名服务器,它的作用是将域名地址解析为IP地址,即将型如pop.company.com.cn\
的域名地址转化为 202.119.11.131形式的IP地址.所以您输入的DNS服务器地址[必须是IP地址]而不能是\
域名形式.\n如果您不知道DNS服务器的地址,请向您的[ISP(互联网服务提供商)]询问.",
"\n [SMTP服务器]负责电子邮件的发送,一般而言SMTP服务器不需要用户的帐号与口令.您可以输入该\
服务器的域名或IP地址. 如果您不知道SMTP服务器的地址,请向您的[ISP(互联网服务提供商)]询问.\n\
我们可以提供一些免费电子邮件的SMTP服务器地址:\n smtp.sohu.com\n smtp.990.net\n smtp.263.net\n\
smtp.163.net\n [注意:]\n 您输入的地址不应超过[30]个字符! ",
"\n [POP3服务器]负责电子邮件的接收.当您的PDA接收邮件时,实际上是在与POP3服务器在进行交互.\
POP3服务器需要用户的帐号与口令.一般来说,POP3服务器的地址就是您电子邮件地址的后半部分.比如:\n\
如果您的电子邮件地址是trio@263.net,那么您的POP3邮件地址就是: 263.net 或者 pop.263.net \n\
如果您不知道POP3服务器的地址,请向您的[ISP(互联网服务提供商)]询问.\n[注意:]\n 您输入的地址不应超过[30]个字符!",
"\n [POP3帐号]就是您电子邮件地址的前半部分.如果您的地址是 seuasic@sohu.com 那么您的POP3帐号就\
是 seuasic\n[注意:]\n 您输入的帐号不应超过[18]个字符!",
"\n [POP3口令]是您POP3帐号的密码.\n[注意:]\n 您输入的密码是区分大小写的,且不应超过[18]个字符!",
"\n [拨号号码]是您为建立连接所要拨出的电话号码.您可拨打长途号码,只要在电话号码前加上区号即可.\
如果您所用的电话是内线,需要先拨某几位号码切换为外线,比如9 ,则请在该号码后加逗号.如:[9,163].",
"\n [拨号账号]是您拨号的帐号.\n[注意:]\n 您输入的帐号是区分大小写的,且不应超过[18]个字符!",
"\n [拨号口令]是您拨号帐号的密码.\n[注意:]\n 您输入的密码是区分大小写的,且不应超过[18]个字符!",
//#ifdef GSMSMS
// "\n [短消息中心号码]",
// "\n [网关号码]",
//#endif
};
#define hibyte(x) ((unsigned char)((x) >> 8))
#define lobyte(x) ((unsigned char)(x))
/* Extract a short from a long */
#define hiword(x) ((U16)((x) >> 16))
#define loword(x) ((U16)(x))
U8 getcfg(char *ptr){
struct zhangcfg Cfg;
struct netcfg *tmpcfg;
if (ptr==NULL) return 1;
//Netcfg=(struct netcfg *)ptr;
tmpcfg = (struct netcfg *)malloc(sizeof(struct netcfg));
memcpy(tmpcfg,ptr,sizeof(struct netcfg));
Netcfg = (struct netcfg *)tmpcfg;
if (*(unsigned int*)(Netcfg->Valid)!=CFGVALID){
Netcfg=NULL;
return 1;
}
strcpy(Cfg.dns,inet_ntoa1(Netcfg->Dns.pridns));
strcpy(Cfg.smtp,Netcfg->Mail[0].smtpserver);
strcpy(Cfg.popser,Netcfg->Mail[0].popserver);
strcpy(Cfg.popacc,Netcfg->Mail[0].popaccount);
strcpy(Cfg.poppass,Netcfg->Mail[0].poppassword);
strcpy(Cfg.dialnum,Netcfg->Dial[0].dialnumber);
strcpy(Cfg.dialacc,Netcfg->Dial[0].dialaccount);
strcpy(Cfg.dialpass,Netcfg->Dial[0].dialpassword);
//#ifdef GSMSMS
// strcpy(Cfg.smscenter,Netcfg->Gateway[0].SMScenter);
// strcpy(Cfg.smsgateway,Netcfg->Gateway[0].SMSgateway);
//#endif
return 0;
}
/* Modufied by Lingming 11/08/1999*/
void netcfg(void){
struct zhangcfg Cfg;
U8 quit=0;
// U16 timeCount;
// U32 size,areaId;
// P_U16 data;
U32 QuitId = 0,HelpId =0,gc,cfgwin,bt_up,bt_down,bt_cancel,cur,edit,keyboard; /* we add previous step. Lingming 11/08/1999*/
U8 order=0;
// U16 xSrc,ySrc,xDest,yDest;
P_U8 point=NULL;
U8 i=0,entry_num=7,NextDisable=FALSE,PrevDisable=TRUE;
static U8 verbose=TRUE;
static MSG Msg;
U16 wndwidth, wndHeight;
struct netcfg *tmpcfg;
//#ifdef GSMSMS
// U8 entry_num=5;
//#endif
const char *Title[]=
{
"DNS服务器地址:",
"SMTP服务器地址:",
"POP3服务器地址:",
"POP3账号:",
"POP3口令:",
"拨号号码:",
"拨号账号:",
"拨号口令",
//#ifdef GSMSMS
// "短消息中心号码",
// "网关号码",
//#endif
};
const struct cfg_wizardtemp CfgTemp[]=
{
15,SHUZI,SHUZI,NULL, //dns
29,YINGWEN_L,YINGWEN_L|FUHAO|YINGWEN_U|SHUZI,NULL, //smtp server
29,YINGWEN_L,YINGWEN_L|FUHAO|YINGWEN_U|SHUZI,NULL, //pop3 server
17,YINGWEN_L,YINGWEN_L|YINGWEN_U|FUHAO,NULL, //pop3 account
17,YINGWEN_L,YINGWEN_L|YINGWEN_U|FUHAO|SHUZI,NULL, //pop3 password
29,SHUZI,SHUZI|FUHAO,NULL, //dial number
17,YINGWEN_L,YINGWEN_L|YINGWEN_U|FUHAO|SHUZI,NULL, //dial account
17,YINGWEN_L,YINGWEN_L|YINGWEN_U|FUHAO|SHUZI,NULL, //dial password
//#ifdef GSMSMS
// 11,SHUZI,SHUZI, //SMS center
// 11,SHUZI,SHUZI, //Gateway
//#endif
};
const char *str1[3]=
{
"确定放弃",
"取消",
"不再显示该信息",
};
wndwidth = ( PHY_LCD_W > ASIX_LCD_W ) ? ASIX_LCD_W : PHY_LCD_W;
wndHeight = ( PHY_LCD_H > ASIX_LCD_H ) ? ASIX_LCD_H : PHY_LCD_H;
gc=GetGC();
ClearScreen(gc,GPC_WHITE);
cfgwin=CreateWindow(WNDCLASS_WIN,"系统配置向导 ",WS_OVERLAPPEDWINDOW,0,0,159,239,0,0,NULL);
bt_up = CreateWindow(WNDCLASS_BUTTON, "上一步", WS_CHILD|BS_TOOLBAR, 0,123,53,16,cfgwin,0,NULL);
bt_down = CreateWindow(WNDCLASS_BUTTON, "下一步", WS_CHILD|BS_TOOLBAR, 53,123,53,16,cfgwin,0,NULL);
bt_cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_TOOLBAR,106,123,53,16,cfgwin,0,NULL);
recfg: if (Netcfg==NULL)
// Netcfg=(struct netcfg *)Datatemp; /*because there are some marks in the prev 10 bytes*/
tmpcfg = (struct netcfg *)malloc(sizeof(struct netcfg));
// memcpy(tmpcfg,Datatemp+NETCFG_HEAD,sizeof(struct netcfg));
Netcfg = (struct netcfg *)tmpcfg;
//timeCount=timeOutLen;
//order=0;
//ActiveAreaEnable((P_U32)&XAreaId,ICON_AREA,STROKE_MODE,1,1,158,130);
//ClearScreen(WHITE);
//DrawTextIcon((P_U32)&PrevId,1,219,53,20,GB_NORMAL_FONT,"上一步",0,BLACK,PositionMiddle);
//ActiveAreaSuspend(PrevId,AREA_SUSPEND);/*the first time we enter ,there must be no previous step.*/
//Disp16StringGrey(DARK_GREY,"上一步",3,221);
//DrawTextIcon((P_U32)&NextId,54,219,53,20,GB_NORMAL_FONT,"下一步",0,BLACK,PositionMiddle);
//DrawTextIcon((P_U32)&QuitId,107,219,51,20,GB_NORMAL_FONT,"取消",0,BLACK,PositionMiddle);
//ActiveAreaEnable((P_U32)& ,ICON_AREA,STROKE_MODE,134,21,158,45);/*24*24 icon*/
//switchonetotwo(question_mark,134,21,24,24);
//DrawRec(BLACK,1,1,158,219,0,REPLACE_STYLE);
//DrawHorz(BLACK,1,20,158,0,REPLACE_STYLE);
//Disp16String("系统配置向导",30,2);
Disp16String((char *)Title[order],5,48);
if (point==NULL) {point=Cfg.dns;}/* The first time enter netcfg. */
//else if (point!=Cfg.dns) {
//ActiveAreaSuspend(PrevId,AREA_REENABLE);
//Disp16String("上一步",3,221);
//PrevDisable=FALSE;
//NextDisable=FALSE;
//}
if(order == 0){
PrevDisable=TRUE;
NextDisable=FALSE;
}
else if(order == 7){
PrevDisable=FALSE;
NextDisable=TRUE;
}
else {
PrevDisable=FALSE;
NextDisable=FALSE;
}
//#ifdef GSMSMS
// if (point==NULL) point=Cfg.smtp; /* The first time enter netcfg. */
//#endif
//if (EditOpenMode.open_line==EDIT_OPENED) closelineedit();
//openlineedit(80, point,CfgTemp[order].len, CfgTemp[order].dft_input, CfgTemp[order].allow_input, 0);
edit = CreateWindow( WNDCLASS_EDITOR,"211.65.48.144",WS_CHILD | ES_SINGLE_REGULAR,5,70,110,20,cfgwin,30,NULL);
// keyboard = CreateWindow( WNDCLASS_KEYBAR,NULL,WS_CHILD,0,120,118,48,cfgwin,0,NULL);
keyboard = CreateWindow( WNDCLASS_KEYBD,
NULL,
WS_CHILD|KBS_PINGYING|0xff,
1,(U16)(wndHeight-16),
(U16)(wndwidth-2),16,
cfgwin,
0,
NULL);
SetFocus( edit );
quit=0;
while(quit==0)
{
//timeCount=hc(timeCount);
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(mark==1) *point=0;
if (Msg.lparam == bt_down) {
quit = 1;
if (NextDisable) {quit=1;break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -