#include "fiiWx.h"
#include "fiiUtils.h"
#include "FLMNetLoginManager.h"
#include "FLMNetLoginRequest.h"
#include "FLMNetRegisterRequest.h"
#include "fiiWxRegisterDialog.h"
#include "fiiWxLogMessage.h"
#include "fiiWxStatusBar.h"
#include "fiiFileUtils.h"
BEGIN_EVENT_TABLE(CFLMNetLoginDialog,wxDialog)
EVT_BUTTON(fiiID_LoginBtn,CFLMNetLoginDialog::OnPushLoginButton)
//EVT_BUTTON(wxID_OK,CFLMNetLoginDialog::OnPushOKButton)
EVT_BUTTON(wxID_CANCEL,CFLMNetLoginDialog::OnPushCancelButton)
EVT_BUTTON(wxID_NEW,CFLMNetLoginDialog::OnPushRegisterButton)
EVT_TEXT_ENTER(fiiID_PasswordCtrl, CFLMNetLoginDialog::OnPushLoginButton)
EVT_UPDATE_UI(wxID_NEW, CFLMNetLoginDialog::OnRegisterButtonUpdateUI)
EVT_COMMAND (wxID_ANY, wxEVT_LOGIN_REQUEST_FINISH, CFLMNetLoginDialog::OnLoginRequestFinish)
EVT_TIMER(wxID_ANY, CFLMNetLoginDialog::OnTimer)
END_EVENT_TABLE()
CFLMNetLoginDialog::CFLMNetLoginDialog(wxWindow *parent,wxArrayString *urlHistoryList,const wxChar* lastUrl,const wxChar* lastID
,bool autoLogin, const wxChar* lastPW
,IFLMNetAddressSpecifiedRequestLauncher* inAddressSpecifiedRequestLauncher,bool showAutoLoginCheck
,IFLMNetSessionInfo *session_info,IAddressProvider *addrProvider)
: wxDialog(parent,wxID_ANY,FLOWRIANII_CAPTION,wxDefaultPosition,wxSize(470,230),wxSTAY_ON_TOP|wxDEFAULT_DIALOG_STYLE)
, m_pAddressSpecifiedRequestLauncher(inAddressSpecifiedRequestLauncher)
, m_pSessionInfo(session_info),m_pAddressProvider(addrProvider),m_pAnimation(NULL)
, timer(this)
{
m_pRegisterBtn = new wxButton(this, wxID_NEW, wxT("Register"),wxDefaultPosition, wxSize(80,25));//创建了一个Register按钮,功能与wxID_NEW相结合
m_pRegisterBtn ->Enable(false);//注册新用户的窗口起始会被禁用
wxBoxSizer* ss5 = new wxBoxSizer(wxHORIZONTAL);//创建了一个水平的布局控件 ss5
m_pUrlListCtrl = new wxComboBox(this, fiiID_UrlCtrl, lastUrl, wxDefaultPosition, wxSize(200,20));//,urlHistoryList->Count(),*urlHistoryList);
//创建了一个ComboBox(单行编辑框和一个列表框的组合)
ss5->Add(30, 1, 1, wxEXPAND);//增加一块宽度是30,高度为1,可以缩放的空白,充满
ss5->Add(new wxStaticText(this, wxID_ANY, wxT("Address:")));//在ss5里面创建了一个静态文本控件Address
ss5->Add(m_pUrlListCtrl);//将之前创建的ComboBox加到ss5里面去
ss5->Add(10, 5, 0);//增加一块宽度为10,高度为5,不可缩放的空白
ss5->Add(m_pRegisterBtn, 0);//将之前创建的Register加到ss5中
ss5->Add(30, 1, 1, wxEXPAND);//增加一块宽度是30,高度为1,可以缩放的空白,充满所在项目
ss5->SetItemMinSize((size_t)1, 80, 20);//设置每一个项目的最小size,宽80,高20, 各参数含义:size_t:非负类型(0~++)
//第一个参数是指定对加入的第几个控件进行设定,80和20是宽和高
m_pUrlListCtrl->Append(*urlHistoryList);//显示最近一次登录时的地址
wxBoxSizer* ss3 = new wxBoxSizer(wxHORIZONTAL);//创建了一个水平的布局控件 ss3
m_pUserNameCtrl = new wxTextCtrl(this, wxID_ANY, lastID, wxDefaultPosition, wxSize(200,20));//创建一个文本控件m_pUserNameCtrl,默认填写上一次登陆时的用户信息
ss3->Add(30, 1, 1, wxEXPAND);//增加一块宽度是30,高度为1,可以缩放的空白,充满
ss3->Add(new wxStaticText(this, wxID_ANY, wxT("ID:")));//创建一个静态文本控件ID
ss3->Add(m_pUserNameCtrl);//将之前创建的m_pUserNameCtrl添加到ss3中
ss3->Add(30, 1, 1, wxEXPAND);//增加一块宽度是30,高度为1,可以缩放的空白,充满
ss3->SetItemMinSize((size_t)1, 80, 20);//设置每一个项目的最小size,宽80,高20, 各参数含义:size_t:非负类型(0~++)
//第一个参数是指定对加入的第几个控件进行设定,80和20是宽和高
wxBoxSizer* ss4 = new wxBoxSizer(wxHORIZONTAL);//创建一个水平布局控件ss4
m_pPasswordCtrl = new wxTextCtrl(this, fiiID_PasswordCtrl, wxEmptyString, wxDefaultPosition, wxSize(200,20),wxTE_PASSWORD|wxTE_PROCESS_ENTER);//创建文本控件m_pPasswordCtrl
m_pAutoLoginCtrl = new wxCheckBox(this, wxID_ANY, wxT("Auto Login"), wxDefaultPosition);//创建了一个是否自动登录的一个单选框
m_pAutoLoginCtrl->SetValue(autoLogin);//默认的为选中状态【自动登录】
ss4->Add(30, 1, 1, wxEXPAND);//空白
ss4->Add(new wxStaticText(this, wxID_ANY, wxT("Password:")));//创建一个静态文本控件Password
ss4->Add(m_pPasswordCtrl);//将创建的文本控件m_pPasswordCtrl添加到ss4中
ss4->Add(10, 1, 0);//固定大小的空白
ss4->Add(m_pAutoLoginCtrl);//将创建的自动登录的单选框加到ss4中
m_pAutoLoginCtrl->Show(showAutoLoginCheck);//是否显示该单选框,如果true则显示,否则不显示
ss4->Add(30, 1, 1, wxEXPAND);//创建一个宽为30,高为1的可伸展的空白,充满当前项目
ss4->SetItemMinSize((size_t)1, 80, 20);//设置每一个项目的最小size
m_pLoginBtn = new wxButton(this, fiiID_LoginBtn, wxT("Login"),wxDefaultPosition, wxSize(80,25));//创建了个按钮login
m_pCancelBtn = new wxButton(this, wxID_CANCEL, wxT("Cancel"),wxDefaultPosition, wxSize(80,25));//创建了两个按钮login和cancel
wxBoxSizer* s_btn = new wxBoxSizer(wxHORIZONTAL);//创建一个水平的布局控件 s_btn
s_btn->Add(20, 5, 0);//给控件加入固定大小的空白
//s_btn->Add(new wxButton(this, wxID_OK, wxT("OK"),wxDefaultPosition, wxSize(80,25)), 0);
s_btn->Add(m_pLoginBtn, 0);//将创建的两个按钮加到 s_btn 中
s_btn->Add(5, 5, 0);//固定大小的空白
s_btn->Add(m_pCancelBtn, 0);
wxStaticBoxSizer* s_all = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, wxT("Login"),wxDefaultPosition,wxSize(300,180)),wxVERTICAL);
//创建了一个垂直的带有静态边框的布局控件 s_all
s_all->Add(1,10);//创建一个宽1高10的空白
s_all->Add(ss5, 1, 0, 5);//将ss3,4,5添加到s_all中,缩放因子为1,子元素保留原始大小,边界间隔大小为5
s_all->Add(ss3, 1, 0, 5);
s_all->Add(ss4, 1, 0, 5);
//s_all->Add(ss6, 1, 0, 5);
//s_all->Add(s_btn, 0, wxALIGN_CENTER| wxLEFT, 5);
//s_all->SetMinSize(220,100);
wxBoxSizer* s = new wxBoxSizer(wxVERTICAL);//创建了一个垂直的布局控件 s
s->Add(s_all,1,wxALIGN_CENTER | wxALL,10);//将s_all和s_btn添加到s中 居中对齐 而且圈了一圈大小为10的空白边框
s->Add(s_btn,0,wxALIGN_CENTER | wxALL,10);//将s_all和s_btn添加到s中 居中对齐 而且圈了一圈大小为10的空白边框
SetSizer(s);//绑定对话框和布局控件
SetIcon(wxICON(Flowman));//设置窗口图标
m_pUserNameCtrl->SetSelection(-1,-1);//选定所有的文本信息
m_pUserNameCtrl->SetFocus();//设置该窗口接收键盘输入
if(autoLogin) //如果自动登录是选中的
{
m_pPasswordCtrl->SetValue(lastPW);//自动填写最近一次登录时的密码
timer.Start(0,wxTIMER_ONE_SHOT); //时间控制【开启一个定时器】
}
//SetMinSize(wxSize(330,330));
}
CFLMNetLoginDialog::~CFLMNetLoginDialog()
{
}
void CFLMNetLoginDialog::TryLogin()
{
EnableCtrls(false);//禁用窗口上的控件
CfiiFileUtils fu;
wxString res_dir = fu.GetDirectory(ID_RESDIR);//获取已经就绪的目录
m_pAnimation = new wxAnimationCtrl(this, wxID_ANY, wxAnimation(res_dir+wxT("waiting.gif"), wxANIMATION_TYPE_ANY), wxPoint(375,142));//动画效果,会显示一个等待的GIF
m_pAnimation->Play();//开始放映
wxString url = m_pUrlListCtrl->GetValue();//获取控件的内容
wxString id = m_pUserNameCtrl->GetValue();
wxString pw = m_pPasswordCtrl->GetValue();
m_bAutoLogin = m_pAutoLoginCtrl->IsChecked();
if(url.IsEmpty()) { m_pUrlListCtrl->SetFocus(); return;}
if(id.IsEmpty()) {m_pUserNameCtrl->SetFocus(); return;}
if(pw.IsEmpty()) {m_pPasswordCtrl->SetFocus();return;}
wxString addr;
int port;
ParseURL(url,addr,port);
//m_pSessionInfo->SetAddress(addr.c_str());
m_pSessionInfo->SetUrl(url.c_str());
//m_pSessionInfo->SetPort(port);
m_pSessionInfo->SetID(id);
m_pSessionInfo->SetPassword(pw);
IFLMNetLoginRequest *login_req = new CFLMNetLoginRequest(id,pw);
CFLMNetLoginThread* login_thread = new CFLMNetLoginThread(this,m_pAddressSpecifiedRequestLauncher,login_req,addr,port);
//CFLMNetLoginThread login_thread(this,m_pAddressSpecifiedRequestLauncher,login_req,addr,port);
login_thread->Run();
}
void CFLMNetLoginDialog::EnableCtrls(bool enable)
{
m_pRegisterBtn->Enable(enable);
m_pUserNameCtrl->Enable(enable);
m_pPasswordCtrl->Enable(enable);
m_pUrlListCtrl->Enable(enable);
m_pLoginBtn->Enable(enable);
m_pCancelBtn->Enable(enable);
m_pAutoLoginCtrl->Enable(enable);
}
void OnPushEnter(wxCommandEvent &event )
{
}
void CFLMNetLoginDialog::OnTimer(wxTimerEvent& event)
{
TryLogin();
}
void CFLMNetLoginDialog::OnRegisterButtonUpdateUI(wxUpdateUIEvent &event)
{
if(m_pLoginBtn->IsEnabled())
event.Enable(!m_pUrlListCtrl->GetValue().IsEmpty());
}
void CFLMNetLoginDialog::OnPushLoginButton(wxCommandEvent &event )
{
TryLogin();
}
//void CFLMNetLoginDialog::OnPushOKButton(wxCommandEvent &event )
//{
// wxString m_sUrl;
// wxString m_sID;
// wxString m_sPasswd;
//
// m_sUrl = m_pUrlListCtrl->GetValue();
// m_sID = m_pUserNameCtrl->GetValue();
// m_sPasswd = m_pPasswordCtrl->GetValue();
// m_bAutoLogin = m_pAutoLoginCtrl->IsChecked();
//
// if(m_sUrl.IsEmpty()) { m_pUrlListCtrl->SetFocus(); return;}
// if(m_sID.IsEmpty()) {m_pUserNameCtrl->SetFocus(); return;}
// if(m_sPasswd.IsEmpty()) {m_pPasswordCtrl->SetFocus();return;}
//
// if(event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER)
// {
// EndModal(wxID_OK);
// }
// else
// event.Skip();
//}
void CFLMNetLoginDialog::OnPushCancelButton(wxCommandEvent &event )
{
event.Skip();
}
void CFLMNetLoginDialog::OnPushRegisterButton(wxCommandEvent &event )
{
wxString url = m_pUrlListCtrl->GetValue();
if(url.IsEmpty())
{
m_pUrlListCtrl->SetFocus();
return;
}
CfiiUserInfo reg_info;
CfiiWxRegisterDialog reg_dlg(this,_("Register"), url, ®_info,m_pAddressSpecifiedRequestLauncher);
if(reg_dlg.ShowModal() == wxID_OK)
{
wxString addr;
int port;
ParseURL(m_pUrlListCtrl->GetValue(),addr,port);
IFLMNetRegisterRequest *register_req = new CFLMNetRegisterRequest(
reg_info.Id.c_str(),
reg_info.Passwd.c_str(),
reg_info.Name.c_str(),
reg_info.Email.c_str(),
reg_info.Mobile.c_str(),
reg_info.Affiliation.c_str(),
reg_info.Position.c_str()
);
if(m_pAddressSpecifiedRequestLauncher->LaunchRequest(addr,port,register_req) && register_req->IsSuccess())
{
ShowInfoDialog(_("Successfully Registered"),this);
}
else
{
ShowErrorDialog(register_req->GetErrorMessage(),this);
}
}
}
void CFLMNetLoginDialog::OnLoginRequestFinish(wxCommandEvent &event)
{
CFLMNetLoginRequest *login_req = (CFLMNetLoginRequest*)event.GetEventObject();
if(login_req->IsSuccess())
{
//m_bIsLogin = true;
m_pSessionInfo->SetGrade(login_req->GetGrad());
m_pSessionInfo->SetSessionKey(login_req->GetSessionKey());
EndModal(wxID_OK);
}
else
{
if (login_req->GetErrorMessage() != wxEmptyString)
ShowErrorDialog(login_req->GetErrorMessage(),this);
EnableCtrls(true);
}
if (m_pAnimation)
{
delete m_pAnimation;
m_pAnimation = NULL;
}
delete login_req;
}
//const wxChar* CFLMNetLoginDialog::GetUrl()
//{
// return m_sUrl.c_str();
//}
//const wxChar* CFLMNetLoginDialog::GetID()
//{
// //return (m_pUserNameCtrl->GetValue()).c_str();
// return m_sID.c_str();
//}
//const wxChar* CFLMNetLoginDialog::GetPasswd()
//{
// return m_sPasswd.c_str();
//}
bool CFLMNetLoginDialog::GetIsAutoLogin()
{
return m_bAutoLogin;
}
CFLMNetLoginManager::CFLMNetLoginManager(wxWindow *parent,IFLMNetAddressSpecifiedRequestLauncher* inAddressSpecifiedRequestLauncher,CfiiEnvironment *pEnvironment)
:m_pParent(parent)
,m_pAddressSpecifiedRequestLauncher(inAddressSpecifiedRequestLauncher)
,m_pEnvironment(pEnvironment)// m_pConfig(pConfig)
,m_bIsLogin(false)
,m_bIsNewUrl(false)
{
}
CFLMNetLoginManager::~CFLMNetLoginManager(void)
{
if(m_vAgentToolInfoList.GetCount()>0)
{
for(int i=0;i<m_vAgentToolInfoList.GetCount();i++)
delete m_vAgentToolInfoList[i];
}
}
bool CFLMNetLoginManager::HasSessionInfo(bool showLoginDlg)
{
if(!m_bIsLogin&&showLoginDlg) ShowLoginDialog();
return m_bIsLogin;
}
IFLMNetSessionInfo* CFLMNetLoginManager::GetSessionInfo()
{
return (IFLMNetSessionInfo*)this;
}
//void CFLMNetLoginManager::SetAddress(wxChar* addr)
//{
// m_sAddress = addr;
//}
//void CFLMNetLoginManager::SetPort(int port)
//{
// m_iPort = port;
//}
bool CFLMNetLoginManager::HasAddress()
{
return m_bIsLogin;
}
void CFLMNetLoginManager::AddEventListener(IFLMNetLoginEventListener* evt_listener)
{
m_pLoginEventListenerPtrList.Add(evt_listener);
}
const wxChar* CFLMNetLoginManager::GetAddress()
{
return m_sAddress;
}
const wxChar* CFLMNetLoginManager::GetUrl()
{
return m_sUrl;
}
int CFLMNetLoginManager::GetPort()
{
return m_iPort;
}
int CFLMNetLoginManager::GetGrade()
{
return m_iGrade;
}
/*const wxChar* CFLMNetLoginManager:: GetAddress()
{
return m_sAddress;
}*/
const wxChar* CFLMNetLoginManager::GetID()
{
return m_sID;
}
const wxChar* CFLMNetLoginManager::GetPassword()
{
return m_sPasswd;
}
int CFLMNetLoginManager::GetSessionKey()
{
return m_iSessionKey;
}
void CFLMNetLoginManager::SetGrade(int grade)
{
m_iGrade = grade;
}
//void CFLMNetLoginManager::SetAddress(const wxChar* addr)
//{
// m_sAddress = addr;
//}
void CFLMNetLoginManager::SetUrl(const wxChar* url)
{
m_sUrl= url;
ParseURL(url,m_sAddress,m_iPort);
}
void CFLMNetLoginManager::SetID(const wxChar* id)
{
m_sID = id;
}
void CFLMNetLoginManager::SetPassword(const wxChar* pw)
{
m_sPasswd = pw;
}
void CFLMNetLoginManager::SetSessionKey(int session_key)
{
m_iSessionKey = session_key;
}
bool CFLMNetLoginManager::IsNewUrl()
{
return m_bIsNewUrl;
}
bool CFLMNetLoginManager::HasAgentInfo()
{
return !m_sAgentName.IsEmpty();
}
const wxChar* CFLMNetLoginManager::GetAgentAddress()
{
return m_sAgentAddress.c_str();
}
const wxChar* CFLMNetLoginManager::GetAgentName()
{
return m_sAgentName.c_str();
}
const wxChar* CFLMNetLoginManager::GetAgentDescription()
{
return m_sAgentDescription.c_str();
}
//long CFLMNetLoginManager::GetAgentFtpPort()
//{
// return DEFAULT_FTP_PORT;
//}
CFLMNetAgentToolInfoList* CFLMNetLoginManager::GetAgentToolInfoList()
{
return &m_vAgentToolInfoList;
}
void CFLMNetLoginManager::SetAgentInfo(IFLMNetAgentInfo* agent_info)
{
if(!agent_info) return;
m_sAgentName = agent_info->GetAgentName();
m_sAgentDescription = agent_info->GetAgentName();
m_sAgentAddress = agent_info->GetAgentAddress();
if(m_sAgentAddress.IsEmpty() || (m_sAgentAddress.Cmp(_("localhost")) == 0)) m_sAgentAddress = m_sAddress;
}
void CFLMNetLoginManager::SetFLMNetLogoutManager(IFLMNetLogoutManager* logout_man)
{
m_pLogoutMan = logout_man;
}
//void CFLMNetLoginManager::SetfiiWxSelectAgentDialog(CfiiWxSelectAgentDialog* sel_agent_dlg)
//{
// m_pfiiWxSelectAgentDialog = sel_agent_dlg;
//}
//bool CFLMNetLoginManager::ShowLoginDialog_obsolete()
//{
//wxArrayString url_list;
//m_pEnvironment->GetStringList(PROP_URL_LIST,&url_list);
//wxString last_url = m_pEnvironment->GetString(PROP_LAST_URL,_("office.systemcentroi.com:1111"));
//wxString name = m_pEnvironment->GetString(PROP_LAST_ID,wxEmptyString);
//bool auto_login = m_pEnvironment->GetBool(PROP_AUTO_LOGIN,false);
//bool did_login = false;
//bool enble_auto_login_func = m_pEnvironment->GetBool(PROP_SHOW_AUTO_LOGIN,false);
//CFLMNetLoginDialog * login_dlg = new CFLMNetLoginDialog(m_pParent,&url_list,last_url.c_str(),name.c_str(),auto_login,m_pAddressSpecifiedRequestLauncher,
// enble_auto_login_func,this,this);
//while(login_dlg->ShowModal() == wxID_OK)
//{
// //wxLogMessage(_("login with name :%s"),login_dlg->GetID());
// wxString addr;
// int port;
// ParseURL(login_dlg->GetUrl(),addr,port);
// //<<MING_20110324
// //
// m_bIsNewUrl = (url_list.Index(login_dlg->GetUrl()) == wxNOT_FOUND);
// //>>
// if(TryLogin(addr,port,login_dlg->GetID(),login_dlg->GetPasswd()))
// {
// if(m_bIsNewUrl) m_pEnvironment->AddtoStringList(PROP_URL_LIST,login_dlg->GetUrl());
// //m_pEnvironment->AddToUrlList(login_dlg->GetUrl());
// m_pEnvironment->SetString(PROP_LAST_URL,login_dlg->GetUrl());
// m_pEnvironment->SetString(PROP_LAST_ID,login_dlg->GetID());
// if(login_dlg->GetIsAutoLogin())
// m_pEnvironment->SetString(PROP_LAST_PW,login_dlg->GetPasswd());
// else
// m_pEnvironment->Remove(PROP_LAST_PW);
// m_pEnvironment->SetBool(PROP_AUTO_LOGIN,login_dlg->GetIsAutoLogin());
// did_login = m_bIsLogin;
// break;
// }
//}
//delete login_dlg;
wxLogMessage(_("%s - %s %d %d"),m_sID,m_sPasswd,m_iGrade,m_iSessionKey);
//return did_login;
//}
bool CFLMNetLoginManager::ShowLoginDialog(bool auto_login)
{
wxArrayString url_list;
m_pEnvironment->GetStringList(PROP_URL_LIST,&url_list);
wxString last_url = m_pEnvironment->GetString(PROP_LAST_URL,_("office.systemcentroi.com:1111"));
wxString name = m_pEnvironment->GetString(PROP_LAST_ID,wxEmptyString);
wxString pw = m_pEnvironment->GetString(PROP_LAST_PW,wxEmptyString);
bool did_login = false;
bool enble_auto_login_func = m_pEnvironment->GetBool(PROP_SHOW_AUTO_LOGIN,false);
CFLMNetLoginDialog * login_dlg = new CFLMNetLoginDialog(m_pParent,&url_list,last_url.c_str(),name.c_str(),auto_login,pw.c_str(),m_pAddressSpecifiedRequestLauncher,
enble_auto_login_func,this,this);
if(login_dlg->ShowModal() == wxID_OK)
{
m_bIsLogin = true;
m_sAgentName = wxEmptyString;
m_sAgentDescription = wxEmptyString;
m_sAgentAddress = wxEmptyString;
for(int i=0;i<m_pLoginEventListenerPtrList.GetCount();i++)
{
m_pLoginEventListenerPtrList[i]->LoginFLMNetSuccessed();
}
wxCommandEvent evt(fiiEVT_CHANGE_ONLINE_ICON, wxID_ANY);
evt.SetInt(m_bIsLogin);
((wxFrame*)m_pParent)->GetStatusBar()->GetEventHandler()->ProcessEvent(evt);
m_bIsNewUrl = (url_list.Index(GetUrl()) == wxNOT_FOUND);
if(m_bIsNewUrl) m_pEnvironment->AddtoStringList(PROP_URL_LIST,GetUrl());
//m_pEnvironment->AddToUrlList(login_dlg->GetUrl());
m_pEnvironment->SetString(PROP_LAST_URL,GetUrl());
m_pEnvironment->SetString(PROP_LAST_ID,GetID());
if(login_dlg->GetIsAutoLogin())
m_pEnvironment->SetString(PROP_LAST_PW,GetPassword());
else
m_pEnvironment->Remove(PROP_LAST_PW);
m_pEnvironment->SetBool(PROP_AUTO_LOGIN,login_dlg->GetIsAutoLogin());
did_login = m_bIsLogin;
}
wxString msg2;
msg2 << _("[Login] ") << (m_bIsLogin?_("Success"):_("Failed"));
wxLogMessage(msg2);
delete login_dlg;
//wxLogMessage(_("%s - %s %d %d"),m_sID,m_sPasswd,m_iGrade,m_iSessionKey);
return did_login;
}
//bool CFLMNetLoginManager::TryAutoLoginIfNeed()
//{
// if(m_pEnvironment->GetBool(PROP_AUTO_LOGIN,false))
// {
// wxString address;
// int port;
// ParseURL(m_pEnvironment->GetString(PROP_LAST_URL,wxEmptyString),address,port);
// if(TryLogin(address.c_str(),port,m_pEnvironment->GetString(PROP_LAST_ID,wxEmptyString),m_pEnvironment->GetString(PROP_LAST_PW,wxEmptyString)))
// return true;
// }
// return false;
//}
void CFLMNetLoginManager::TryLogout()
{
if(m_bIsLogin)
{
m_pLogoutMan->TryToLogout();
m_bIsLogin = false;
wxLogMessage(_("[Logout] Success"));
wxCommandEvent evt(fiiEVT_CHANGE_ONLINE_ICON, wxID_ANY);
evt.SetInt(0);
((wxFrame*)m_pParent)->GetStatusBar()->GetEventHandler()->ProcessEvent(evt);
}
}
//bool CFLMNetLoginManager::TryLogin(const wxChar* address,int port,const wxChar* id, const wxChar* passwd)
//{
// CfiiFileUtils fu;
// wxString res_dir = fu.GetDirectory(ID_RESDIR);
// //m_pAnimation = new wxAnimationCtrl(m_pParent, wxID_ANY, wxAnimation(res_dir+wxT("waiting.gif"), wxANIMATION_TYPE_ANY), wxPoint(150,0));
// //m_pAnimation->Play();
// //wxAnimationCtrl an(m_pParent, wxID_ANY, wxAnimation(res_dir+wxT("waiting3.gif"), wxANIMATION_TYPE_ANY));
// //an.Play();
// //wxThread::Sleep(10000);
//
//
// // logout first
// TryLogout();
//
// wxString msg;
// msg << _("[Login] ") << id << _("@") << address << _(":") << port;
// wxLogMessage(msg);
//
// IFLMNetLoginRequest *login_req = new CFLMNetLoginRequest(id,passwd);
// if(!m_pAddressSpecifiedRequestLauncher->LaunchRequest(address,port,login_req))
// {
// //ShowErrorDialog(_("Connection Failed"));
// //ShowErrorDialog(e.getReason());
// goto out;
// }
//
// if(login_req->IsSuccess())
// {
// m_bIsLogin = true;
// m_iGrade = login_req->GetGrad();
// m_iSessionKey = login_req->GetSessionKey();
// m_sAddress = address;
// m_sID = id;
// m_sPasswd = passwd;
// m_iPort = port;
//
// m_sAgentName = wxEmptyString;
// m_sAgentDescription = wxEmptyString;
// m_sAgentAddress = wxEmptyString;
//
//
// //wxLogMessage(_("Login success with name %s"),id);
//
// //ShowfiiWxSelectAgentDialog(true);
//
// for(int i=0;i<m_pLoginEventListenerPtrList.GetCount();i++)
// {
// m_pLoginEventListenerPtrList[i]->LoginFLMNetSuccessed();
//
// }
//
// wxCommandEvent evt(fiiEVT_CHANGE_ONLINE_ICON, wxID_ANY);
// evt.SetInt(m_bIsLogin);
// ((wxFrame*)m_pParent)->GetStatusBar()->GetEventHandler()->ProcessEvent(evt);
//
// }
// else
// {
// ShowErrorDialog(login_req->GetErrorMessage());
// }
//out:
// delete login_req;
// //delete m_pAnimation;
//
// wxString msg2;
// msg2 << _("[Login] ") << (m_bIsLogin?_("Success"):_("Failed"));
// wxLogMessage(msg2);
//
// return m_bIsLogin;
//
//}
//
//
//
//void CFLMNetLoginManager::ClearAgentList()
//{
// m_pAgentListCtrl->ClearAll();
// for(int i=0;i<m_vAgentInfoList.GetCount();i++)
// {
// delete m_vAgentInfoList[i];
// }
// m_vAgentInfoList.Clear();
//
//}
效果图
login进去以后的界面如下: