Sitebook.cpp
资源名称:(vc).rar [点击查看]
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:5k
源码类别:
Telnet服务器
开发平台:
Visual C++
- // Sitebook.cpp : implementation file
- //
- #include "stdafx.h"
- #include "anywhere.h"
- #include "Sitebook.h"
- #include "thread1.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSitebook dialog
- const char sitebook[]="sitebook";
- static CString iplist[]={
- "ip1",
- "ip2",
- "ip3",
- "ip4",
- "ip5"
- };
- static CString label[]={
- "label1",
- "label2",
- "label3",
- "label4",
- "label5"
- };
- static CString user[]={
- "user1",
- "user2",
- "user3",
- "user4",
- "user5"
- };
- static CString pass[]={
- "pass1",
- "pass2",
- "pass3",
- "pass4",
- "pass5"
- };
- CSitebook::CSitebook(CWnd* pParent /*=NULL*/)
- : CDialog(CSitebook::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSitebook)
- m_ip = _T("");
- m_label = _T("");
- m_password = _T("");
- m_username = _T("");
- //}}AFX_DATA_INIT
- bFirst=true;
- }
- void CSitebook::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSitebook)
- DDX_Control(pDX, IDC_ASSUME, m_btassume);
- DDX_Control(pDX, IDOK, m_btok);
- DDX_Control(pDX, IDCANCEL, m_btcancel);
- DDX_Control(pDX, IDC_APPLY, m_btapply);
- DDX_Control(pDX, IDC_SITE_LIST, m_site);
- DDX_Text(pDX, IDC_IP, m_ip);
- DDX_Text(pDX, IDC_LABEL, m_label);
- DDX_Text(pDX, IDC_PASSWORD, m_password);
- DDX_Text(pDX, IDC_USER, m_username);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSitebook, CDialog)
- //{{AFX_MSG_MAP(CSitebook)
- ON_NOTIFY(NM_CLICK, IDC_SITE_LIST, OnClickSiteList)
- ON_BN_CLICKED(IDC_APPLY, OnApply)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSitebook message handlers
- BOOL CSitebook::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_ImageList.Create(32,32,ILC_COLOR16|ILC_MASK,5,1);
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_IPLIST));
- m_site.SetImageList(&m_ImageList,LVSIL_NORMAL);
- m_btassume.SetCheck(1);
- readdata();
- //if (bFirst) {
- //m_treedir.SubclassDlgItem(IDC_TREE_DIR, this );
- //m_TreeCtrl->Expand(m_root,TVE_EXPAND);
- //m_TreeCtrl->Expand(m_child,TVE_EXPAND);
- //m_TreeCtrl->SelectItem(m_child);
- //m_treedir.FindDir("\debug");
- //select=FALSE;
- //m_treedir.SetSelPath("e:\myproject\anywhere\Include");
- //m_treedir.init("e:\myproject");//SetRoot("我的配置文件夹");
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CSitebook::OnOK()
- {
- UpdateData(TRUE);
- if (m_username.GetLength()!=8 || m_password.GetLength()!=8)
- return;
- if (m_ip.IsEmpty()||m_username.IsEmpty()||m_password.IsEmpty()) {
- CString sErrmsg,caption;
- sErrmsg.LoadString(IDS_WRONG_ACTION);
- caption.LoadString(IDS_CAPTION);
- MessageBox(sErrmsg,caption,MB_OK);
- return;
- }
- linkrc.ip=m_ip;
- linkrc.mainport=7700;//主端口
- linkrc.getfileport=9110;//getfile端口;
- linkrc.putfileport=9111;//putfile端口;
- linkrc.viewport=9113;//viewscr端口;
- linkrc.username=m_username;
- linkrc.password=m_password;
- linkrc.sAddr=CSockAddr(linkrc.ip,linkrc.mainport);
- if (m_btassume.GetCheck()==1) linkrc.bConnected=FALSE;
- else linkrc.bConnected=TRUE;
- //linkrc.bConnected=FALSE;
- //设定主端口及ip
- //strcpy(linkrc.sbuf,linkrc.username);
- //strcat(linkrc.sbuf,linkrc.password);
- CDialog::OnOK();
- }
- void CSitebook::OnClickSiteList(NMHDR* pNMHDR, LRESULT* pResult)
- {
- int i=m_site.GetNextItem(-1,LVNI_ALL|LVNI_SELECTED);
- if (i==-1) return ;
- m_label=strlabel[i];//m_site.GetItemText(i,0);
- m_ip=strip[i];
- m_username=struser[i];
- m_password=strpass[i];
- UpdateData(FALSE);
- *pResult = 0;
- }
- void CSitebook::OnApply()
- {
- UpdateData(TRUE);
- int i=m_site.GetNextItem(-1,LVNI_ALL|LVNI_SELECTED);
- if (i==-1) return;
- AfxGetApp()->WriteProfileString(sitebook,iplist[i],m_ip);
- AfxGetApp()->WriteProfileString(sitebook,label[i],m_label);
- AfxGetApp()->WriteProfileString(sitebook,user[i],m_username);
- AfxGetApp()->WriteProfileString(sitebook,pass[i],m_password);
- readdata();
- }
- void CSitebook::readdata()
- {
- m_site.DeleteAllItems();
- for (int i=0;i<5;i++)
- {
- strip[i]=AfxGetApp()->GetProfileString(sitebook,iplist[i]);
- strlabel[i]=AfxGetApp()->GetProfileString(sitebook,label[i]);
- struser[i]=AfxGetApp()->GetProfileString(sitebook,user[i]);
- strpass[i]=AfxGetApp()->GetProfileString(sitebook,pass[i]);
- m_site.InsertItem(i,strlabel[i],0);
- }
- timeout=AfxGetApp()->GetProfileInt("Settings","timeout",30);
- request=AfxGetApp()->GetProfileInt("Settings","request",300);
- }