#include "StdAfx.h"
|
#include "MBLoginWnd.h"
|
#include "MBServerAdapterFix.h"
|
#include "MBAccountAdapterFix.h"
|
#include "MBLoginParseSvrXml.h"
|
|
//struct flashtime {
|
// int timeEnd;
|
// wchar_t szFlash[50];
|
//}g_flashs[] =
|
//{
|
// {0, L"morning.swf"},
|
// {8,L"noon.swf"},
|
// {12,L"afternoon.swf"},
|
// {18,L"night.swf"}
|
//};
|
//
|
// ·µ»ØÂë
|
int CMBLoginWnd::m_nRetCode = -1;
|
|
CString g_szPropName = _T("");
|
HANDLE g_hValue = (HANDLE)1;
|
//=======================================
|
// ö¾Ù´´½¨
|
//=======================================
|
BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam)
|
{
|
HANDLE h = GetProp(hwnd, g_szPropName);
|
if( h == g_hValue)
|
{
|
*(HWND*)lParam = hwnd;
|
return false;
|
}
|
return true;
|
}
|
|
|
CMBLoginWnd::CMBLoginWnd(void): SHostWnd(_T("LAYOUT:XML_LOGIN"))
|
{
|
m_pMBCfgInfo = NULL;
|
m_pMBOrgWebCMgr = NULL;
|
m_pEdPort = NULL;
|
m_pCbvServerName = NULL;
|
m_pCbvLogin = NULL;
|
m_pCkSavePwd = NULL;
|
m_pCkAutoLogin = NULL;
|
m_pEdPwd = NULL;
|
m_pTextTip = NULL;
|
m_pTextError = NULL;
|
m_pMBUserLogin = NULL;
|
m_pMBNetDiskCMgr = NULL;
|
m_pMBUserNetDiskInfo = NULL;
|
m_pMBMoboxWebCMgr = NULL;
|
m_pMBExtWebCMgr = NULL;
|
m_pMBExtCMgr = NULL;
|
|
m_pDataWebCMgr = NULL;
|
//m_pSysAppMgr = NULL;
|
m_pAppMgr = NULL;
|
m_pFileSvrMgr = NULL;
|
m_pMBOrgListMgr = NULL;
|
m_strServer = _T("");
|
m_strLoginName = _T("");
|
m_strPassword = _T("");
|
m_nPort = DEFAULTPORT_ORG;
|
m_bShellLogin = FALSE;
|
m_nStartLoginTime = 0;
|
|
m_pUserOfflineDbMgr = new CMBUserOfflineDbMgr();
|
}
|
|
|
CMBLoginWnd::~CMBLoginWnd(void)
|
{
|
MBSAFE_DELETE(m_pUserOfflineDbMgr)
|
}
|
|
int CMBLoginWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
{
|
// MARGINS mar = {5,5,30,5};
|
// DwmExtendFrameIntoClientArea ( m_hWnd, &mar );
|
SetMsgHandled(FALSE);
|
return 0;
|
}
|
|
BOOL CMBLoginWnd::OnInitDialog(HWND hWnd, LPARAM lParam)
|
{
|
m_bLayoutInited = TRUE;
|
CString strGifBg,strExtName;
|
|
AutoScale();
|
// ³õʼ»¯
|
m_pEdPort = FindChildByName2<SEdit>(L"ed_serverport");
|
m_pCbvServerName = FindChildByName2<SComboView>(L"cbx_server");
|
m_pCbvLogin = FindChildByName2<SComboView>(L"cbx_account");
|
m_pCkSavePwd = FindChildByName2<SCheckBox>(L"ck_savepwd");
|
m_pCkAutoLogin = FindChildByName2<SCheckBox>(L"ck_autologin");
|
m_pEdPwd = FindChildByName2<SEdit>(L"ed_passwd");
|
m_pTextError = FindChildByName2<SStatic>(L"ed_error");
|
m_pTextTip = FindChildByName2<SStatic>(L"text_tip");
|
// wah ÀëÏß
|
m_pCkOffline = FindChildByName2<SCheckBox>(L"ck_offline");
|
//
|
SGifPlayer *pGifPlayer = FindChildByName2<SGifPlayer>(L"gfp_login");
|
if( pGifPlayer == NULL )
|
return FALSE;
|
|
strGifBg.Format(_T("%s\\Skin\\login_bg.gif"),CBaseCommFun::GetWorkDir());
|
//strExtName = CStrFileUtils::GetFileExtName(strGifBg);
|
if( CStrFileUtils::IsExist(strGifBg) )
|
{
|
pGifPlayer->PlayGifFile(strGifBg);
|
}
|
/*SFlashCtrl * pFlash = FindChildByName2<SFlashCtrl>(L"flash_bkgnd");
|
if (pFlash)
|
{
|
wchar_t szCurDir[MAX_PATH + 1];
|
GetCurrentDirectoryW(MAX_PATH, szCurDir);
|
|
time_t long_time;
|
time(&long_time);
|
struct tm * t = localtime(&long_time);
|
|
wchar_t szFlash[MAX_PATH];
|
for (int i = 3; i >= 0; i--)
|
{
|
if (t->tm_hour >= g_flashs[i].timeEnd)
|
{
|
swprintf(szFlash, L"%s\\flash\\%s", szCurDir, g_flashs[i].szFlash);
|
break;
|
}
|
}
|
|
pFlash->Play(szFlash);
|
}
|
*/
|
|
Init();
|
|
return 0;
|
}
|
|
// ÉèÖÃ
|
void CMBLoginWnd::OnBtnSetting()
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
if (pTab)
|
{
|
STurn3dView * pTurn3d = FindChildByName2<STurn3dView>(L"turn3d");
|
if (pTurn3d)
|
{
|
pTurn3d->Turn(pTab->GetPage(_T("login")), pTab->GetPage(_T("settings")), FALSE);
|
}
|
}
|
}
|
|
void CMBLoginWnd::OnBtnSettingOK()
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
if (pTab)
|
{
|
STurn3dView * pTurn3d = FindChildByName2<STurn3dView>(L"turn3d");
|
if (pTurn3d)
|
{
|
pTurn3d->Turn(pTab->GetPage(_T("settings")), pTab->GetPage(_T("login")), TRUE);
|
}
|
}
|
}
|
|
void CMBLoginWnd::OnBtnSettingCancel()
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
if (pTab)
|
{
|
STurn3dView * pTurn3d = FindChildByName2<STurn3dView>(L"turn3d");
|
if (pTurn3d)
|
{
|
pTurn3d->Turn(pTab->GetPage(_T("settings")), pTab->GetPage(_T("login")), TRUE);
|
}
|
}
|
}
|
|
BOOL CMBLoginWnd::OnTurn3D(EventArgs *pEvt)
|
{
|
EventTurn3d *pEvt3dTurn = (EventTurn3d*)pEvt;
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
if (pEvt3dTurn->bTurn2Front_)
|
{
|
pTab->SetCurSel(_T("login"));
|
}
|
else
|
{
|
pTab->SetCurSel(_T("settings"));
|
}
|
return TRUE;
|
}
|
|
BOOL CMBLoginWnd::OnAccountChanged(EventArgs *pEvt)
|
{
|
EventCBSelChange *pEvt2 = sobj_cast<EventCBSelChange>(pEvt);
|
SASSERT(pEvt2);
|
|
if (pEvt2->nCurSel != -1)
|
{
|
SComboView *pComboView = sobj_cast<SComboView>(pEvt->sender);
|
CString strAccount = pComboView->GetWindowText();
|
CString strServerName = m_pCbvServerName->GetWindowText();
|
CString strServerID = m_pMBCfgInfo->GetServerID( strServerName );
|
CString strPort;
|
strPort.Format(_T("%d"), DEFAULTPORT_ORG);
|
CString strMyCfgPath;
|
strMyCfgPath = CMBUserProFun::GetMyIniFile(strAccount, strServerID);
|
if( CStrFileUtils::IsExist( strMyCfgPath ) )
|
{
|
CString strAutoLogin,strPassword,strSavePwd,strOffline;
|
CIniFile iniFile( strMyCfgPath );
|
iniFile.GetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_PORT,strPort);
|
iniFile.GetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_SAVEPWD,strSavePwd);
|
iniFile.GetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_PASSWORD,strPassword);
|
iniFile.GetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_AUOTOLOGIN,strAutoLogin);
|
iniFile.GetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_OFFLINE,strOffline);
|
|
if( !strPassword.IsEmpty() )
|
{
|
//CEncrypt::Encrypt(m_pMBCfgInfo->m_strPwd,KEY_PSW); // ¼ÓÃÜ
|
CEncrypt::Decrypt(strPassword,KEY_PSW); // ½âÃÜ
|
m_pEdPwd->SetWindowText( strPassword );
|
}
|
else{
|
m_pEdPwd->SetWindowText( _T("") );
|
strPassword = _T("0");
|
}
|
if( strSavePwd == _T("1") ){
|
m_pCkSavePwd->SetCheck( TRUE );
|
}else{
|
m_pCkSavePwd->SetCheck( FALSE );
|
}
|
if( strOffline == _T("1") ){
|
m_pCkOffline->SetCheck(TRUE);
|
}else{
|
m_pCkOffline->SetCheck(FALSE);
|
}
|
if( strAutoLogin == _T("1") )
|
{
|
m_pCkAutoLogin->SetCheck(TRUE);
|
}else{
|
m_pCkAutoLogin->SetCheck(FALSE);
|
}
|
m_pMBCfgInfo->m_strAutoLogin = strAutoLogin;
|
m_pMBCfgInfo->m_strSavePwd = strSavePwd;
|
m_pMBCfgInfo->m_strPort = strPort;
|
if(strPassword.IsEmpty())
|
{
|
m_pEdPwd->SetFocus();
|
}
|
}else{
|
//m_pEdPort->SetWindowText( _T("") );
|
m_pEdPwd->SetWindowText( _T("") );
|
m_pCkSavePwd->SetCheck( FALSE );
|
m_pCkAutoLogin->SetCheck(FALSE);
|
m_pCkOffline->SetCheck(FALSE);
|
m_pEdPwd->SetFocus();
|
}
|
m_pEdPort->SetWindowText( strPort );
|
|
}
|
return TRUE;
|
}
|
|
BOOL CMBLoginWnd::OnServerChanged(EventArgs *pEvt)
|
{
|
EventCBSelChange *pEvt2 = sobj_cast<EventCBSelChange>(pEvt);
|
SASSERT(pEvt2);
|
|
if (pEvt2->nCurSel != -1)
|
{
|
SComboView *pComboView = sobj_cast<SComboView>(pEvt->sender);
|
CString strServerName = pComboView->GetWindowText();
|
|
CStringArray strArray;
|
SListView *pLstView = m_pCbvLogin->GetListView();
|
CMBAccountAdapterFix *pAccountAdapter = new CMBAccountAdapterFix;
|
pAccountAdapter->m_strServer = strServerName;
|
m_pMBCfgInfo->GetLoginLst(strServerName,strArray);
|
|
pAccountAdapter->SetAccountInfo(strArray);
|
pLstView->SetAdapter(pAccountAdapter);
|
pAccountAdapter->Release();
|
m_pCbvLogin->SetCurSel(0);
|
if( strArray.IsEmpty() )
|
{
|
m_pCbvLogin->SetFocus();
|
//m_pEdPort->SetWindowText( _T("") );
|
m_pEdPwd->SetWindowText( _T("") );
|
m_pCkSavePwd->SetCheck( FALSE );
|
m_pCkAutoLogin->SetCheck(FALSE);
|
m_pCkOffline->SetCheck(FALSE);
|
}
|
}
|
|
return TRUE;
|
}
|
|
/***
|
怬
|
***/
|
void CMBLoginWnd::OnBtnLogin()
|
{
|
if( NULL == m_pCkOffline )
|
return ;
|
|
m_bShellLogin = FALSE;
|
m_nStartLoginTime = 0;
|
|
// ÀëÏßÅжÏ
|
if( !m_pCkOffline->IsChecked() )
|
{
|
// ÁªÍøµÇ¼
|
InternetLogin();
|
}
|
else{
|
// ÀëÏߵǼ
|
OfflineLogin();
|
}
|
////OnClose();
|
//// test´úÂë
|
//STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
//pTab->SetCurSel(_T("error"));
|
}
|
|
void CMBLoginWnd::SetCurLoginInfo(CString strServer,int nPort,CString strLoginName,CString strPassword,int nStartLoginTime)
|
{
|
m_bShellLogin = TRUE;
|
m_nStartLoginTime = nStartLoginTime;
|
if(!strServer.IsEmpty() && !strLoginName.IsEmpty() && !strPassword.IsEmpty() )
|
{
|
m_strServer = strServer;
|
m_strLoginName = strLoginName;
|
m_strPassword =strPassword;
|
m_nPort = nPort;
|
}
|
else if(m_strServer.IsEmpty() )
|
{
|
m_strServer = _T("");
|
m_strLoginName = _T("");;
|
m_strPassword =_T("");;
|
m_nPort = DEFAULTPORT_ORG;
|
}
|
else
|
{
|
m_strServer = strServer;
|
m_strLoginName = strLoginName;
|
m_strPassword =_T("");;
|
m_nPort = DEFAULTPORT_ORG;
|
}
|
}
|
bool CMBLoginWnd::SaveCfgInfo(CString strServerID,CString &strErrInfo)
|
{
|
CString strPort,strPwd,
|
strServerName,strLogin,
|
strAutoLogin,strSavePWd;
|
CString strMyCfgFile,strMyCfgPath,strSrcDBPath,
|
strTargetDBPath,strTmpServerID,strOffline;
|
|
strTmpServerID = strServerID;
|
|
strPort = m_pEdPort->GetWindowText();
|
strServerName = m_pCbvServerName->GetWindowText();
|
strLogin = m_pCbvLogin->GetWindowText();
|
if(m_pCkAutoLogin->IsChecked())
|
{
|
strAutoLogin = _T("1");
|
}else{
|
strAutoLogin = _T("0");
|
}
|
if(m_pCkSavePwd->IsChecked())
|
{
|
strSavePWd = _T("1");
|
strPwd = m_pEdPwd->GetWindowText();
|
CEncrypt::Encrypt(strPwd,KEY_PSW); // ¼ÓÃÜ
|
}else{
|
strSavePWd = _T("0");
|
}
|
// ÀëÏß
|
if(m_pCkOffline->IsChecked())
|
{
|
strOffline = _T("1");
|
}else{
|
strOffline = _T("0");
|
}
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("ServerName"),strServerName);
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("LoginName"),strLogin);
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("AutoLogin"),strAutoLogin);
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("SavePwd"),strSavePWd);
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("Port"),strPort);
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("Offline"),strOffline);
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("SERVERIDLIST"),strServerName,strTmpServerID);
|
CString strServerSection = m_pMBCfgInfo->GetServerSection(strServerName + _T(":") + strPort );
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("SERVERLIST"),strServerSection,strServerName + _T(":") + strPort);
|
// ÉèÖõ±Ç°ÅäÖÃÐÅÏ¢
|
m_pMBCfgInfo->m_strServerName = strServerName;
|
m_pMBCfgInfo->m_strPort = strPort;
|
m_pMBCfgInfo->m_strLoginName = strLogin;
|
m_pMBCfgInfo->m_strAutoLogin = strAutoLogin;
|
m_pMBCfgInfo->m_strSavePwd = strSavePWd;
|
//////////////////////////////////////////
|
CString strLogins = m_pMBCfgInfo->GetLoginLstStr( strServerName,strLogin );
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("SERVERLOGINLIST"),strServerName,strLogins);
|
|
strMyCfgPath = CMBUserProFun::GetMyDataDir(strLogin, strServerID);
|
strMyCfgFile = CMBUserProFun::GetMyIniFile(strLogin, strServerID);
|
if(!CStrFileUtils::IsExist( strMyCfgFile ))
|
{
|
CString strCfgFile = CMBUserProFun::GetMBDefIniFile();
|
CopyFile(strCfgFile, strMyCfgFile,FALSE);
|
}
|
CIniFile iniFile(strMyCfgFile);
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_PORT,strPort);
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_SAVEPWD,strSavePWd);
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_USERNAME,m_pMBUserLogin->m_strUserName);
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_PASSWORD,strPwd);
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_AUOTOLOGIN,strAutoLogin);
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_OFFLINE,strOffline);
|
|
CString strDownloadPath = _T("");
|
CMBUserProFun::LoadDefaultDwonloadPath( strDownloadPath,strLogin, strServerID);
|
m_pMBUserLogin->m_strMyCfgPath = strMyCfgPath;
|
m_pMBUserLogin->m_strMyCfgFile = strMyCfgFile; // µ±Ç°Óû§ÅäÖÃÎļþ·¾¶
|
DWORD dwAttr = -1;
|
if( !strDownloadPath.IsEmpty())
|
dwAttr = GetFileAttributes( strDownloadPath );
|
if ( dwAttr == -1 || (dwAttr &FILE_ATTRIBUTE_DIRECTORY) == 0 )
|
{
|
strDownloadPath.Format( _T("%s\\%s"), CBaseCommFun::GetWorkDir(), _T("Download") );
|
::CreateDirectory(strDownloadPath, NULL);
|
}
|
m_pMBUserLogin->m_strDownloadPath = strDownloadPath;
|
/////////////mbc.db///////////////////////////////////////////////////////////
|
strSrcDBPath.Format(_T("%s\\data\\mbc.db"),CBaseCommFun::GetWorkDir());
|
strTargetDBPath.Format(_T("%s\\Users\\%s\\%s\\mbc.db"),CBaseCommFun::GetWorkDir(),strLogin,strTmpServerID);
|
CopyDb( strSrcDBPath,strTargetDBPath,strErrInfo );
|
m_pMBUserLogin->m_strDBPath = strTargetDBPath;
|
/////////////mbc_online_ed.db/////////////////////////////////////////////////
|
strSrcDBPath.Format(_T("%s\\data\\mbc_online_ed.db"),CBaseCommFun::GetWorkDir());
|
strTargetDBPath.Format(_T("%s\\Users\\%s\\%s\\mbc_online_ed.db"),CBaseCommFun::GetWorkDir(),strLogin,strTmpServerID);
|
CopyDb( strSrcDBPath,strTargetDBPath,strErrInfo );
|
m_pMBUserLogin->m_strDBOnlineEdPath = strTargetDBPath;
|
|
|
//mbc.db3
|
return true;
|
}
|
|
void CMBLoginWnd::OnBtnErrorCancel()
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
if( pTab != NULL ){
|
pTab->SetCurSel(_T("login"));
|
}
|
}
|
|
|
void CMBLoginWnd::Init()
|
{
|
CString strErrInfo;
|
// ÀëÏß,³õʼ»¯Êý¾Ý¿â
|
CString strExePath = CStrFileUtils::GetCurModuleDir();
|
//m_pMBUserLogin->
|
m_pUserOfflineDbMgr->Init(strExePath,strErrInfo);
|
// ·þÎñ
|
if( !m_strServer.IsEmpty() )
|
{
|
m_pMBCfgInfo->m_strServerName = m_strServer;
|
m_pMBCfgInfo->m_strPort.Format(_T("%d"), m_nPort);
|
m_pMBCfgInfo->m_strLoginName = m_strLoginName;
|
}
|
if( m_pCbvServerName )
|
{
|
CStringArray strArray;
|
SListView *pLstView = m_pCbvServerName->GetListView();
|
|
CMBServerAdapterFix *pServerAdapter = new CMBServerAdapterFix;
|
pServerAdapter->SetCfgInfoPtr(m_pMBCfgInfo);
|
m_pMBCfgInfo->GetServerLst(strArray);
|
if( !m_strServer.IsEmpty() )
|
{
|
strArray.Add(m_pMBCfgInfo->m_strServerName + _T(":")+m_pMBCfgInfo->m_strPort);
|
}
|
pServerAdapter->SetServerInfo(strArray);
|
pLstView->SetAdapter(pServerAdapter);
|
pServerAdapter->Release();
|
m_pCbvServerName->SetCurSel(pServerAdapter->GetSelPosition(m_pMBCfgInfo->m_strServerName.GetBuffer(),m_pMBCfgInfo->m_strPort.GetBuffer()));
|
m_pMBCfgInfo->m_strServerName.ReleaseBuffer();
|
}
|
// ÕʺÅ
|
if (m_pCbvLogin)
|
{
|
CStringArray strArray;
|
SListView *pLstView = m_pCbvLogin->GetListView();
|
CMBAccountAdapterFix *pAccountAdapter = new CMBAccountAdapterFix;
|
pAccountAdapter->SetCfgInfoPtr(m_pMBCfgInfo);
|
m_pMBCfgInfo->GetLoginLst(m_pMBCfgInfo->m_strServerName,strArray);
|
pAccountAdapter->SetAccountInfo(strArray);
|
pAccountAdapter->m_strServer = m_pMBCfgInfo->m_strServerName;
|
if( !m_strLoginName.IsEmpty() )
|
{
|
strArray.Add(m_pMBCfgInfo->m_strLoginName );
|
}
|
pLstView->SetAdapter(pAccountAdapter);
|
pAccountAdapter->Release();
|
m_pCbvLogin->SetCurSel(pAccountAdapter->GetSelPosition(m_pMBCfgInfo->m_strLoginName.GetBuffer()));
|
m_pMBCfgInfo->m_strLoginName.ReleaseBuffer();
|
|
}
|
if( m_pEdPort )
|
{
|
m_pEdPort->SetWindowText( m_pMBCfgInfo->m_strPort );
|
}
|
// ÀëÏß
|
if( m_pCkOffline )
|
{
|
if( m_pMBCfgInfo->m_strOffline == _T("1") )
|
{
|
m_pCkOffline->SetCheck(TRUE);
|
}
|
}
|
|
if(m_bShellLogin&& !m_strLoginName.IsEmpty())
|
{
|
m_pEdPwd->SetWindowText( m_strPassword );
|
//m_pCkAutoLogin->SetCheck(TRUE);
|
if(m_nStartLoginTime > 0)
|
{
|
ShowWindow(SW_HIDE);
|
SetTimer(WM_TIMER_AUTOLOGION, m_nStartLoginTime * 1000);
|
}
|
else
|
SetTimer(WM_TIMER_AUTOLOGION, 500);
|
}
|
else
|
{
|
CString strPassword = _T("");
|
if(m_pEdPwd)
|
strPassword = m_pEdPwd->GetWindowText( );
|
// ×Ô¶¯µÇ¼
|
if( m_pMBCfgInfo->m_strAutoLogin == _T("1") && !strPassword.IsEmpty())
|
{
|
if(m_nStartLoginTime > 0)
|
{
|
ShowWindow(SW_HIDE);
|
SetTimer(WM_TIMER_AUTOLOGION, m_nStartLoginTime * 1000);
|
}
|
else
|
SetTimer(WM_TIMER_AUTOLOGION, 500);
|
}
|
}
|
}
|
|
|
|
void CMBLoginWnd::SetSvrMgr( CMBServerMgr *pSvrMgr )
|
{
|
m_pMBOrgWebCMgr = pSvrMgr->GetOrgWebCMgr();
|
m_pMBUserLogin = pSvrMgr->GetUserLogin();
|
m_pMBNetDiskCMgr = pSvrMgr->GetNetDiskWebCMgr();
|
m_pMBUserNetDiskInfo = pSvrMgr->GetUserNetDiskInfo();
|
m_pMBMoboxWebCMgr = pSvrMgr->GetMoboxWebCMgr();
|
m_pFileSvrMgr = pSvrMgr->GetFileSvrMgr();
|
m_pMBExtWebCMgr = pSvrMgr->GetExtWebCMgr();
|
m_pMBExtCMgr = pSvrMgr->GetExtCmderCMgr();
|
|
//m_pSysAppMgr = pSvrMgr->GetSysAppMgr();
|
m_pAppMgr = pSvrMgr->GetAppMgr();
|
m_pMBCfgInfo = pSvrMgr->GetCfgInfo();
|
m_pMBOrgListMgr = pSvrMgr->GetOrgListMgr();
|
|
m_pDataWebCMgr = pSvrMgr->GetDataWebCMgr();
|
}
|
|
|
|
|
LRESULT CMBLoginWnd::OnOrgWebResponse(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled)
|
{
|
CString strXml= *(CString*)wParam;
|
CString strParam= *(CString*)lParam;
|
long nTrID = 0;
|
CString strData;
|
CString strName;
|
CString strValue;
|
CString strAppType = _T("");
|
CString strMethod = _T("");
|
CString strSessionID,
|
strUserKey,
|
strServerID,
|
strUserInfo;
|
CString strErrInfo;
|
CString strListXML;
|
int nVer = 0;
|
CString strXML;
|
CString strPhotoFile;
|
CString strPhotoPath;
|
int nPhotoVer = 0;
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
CMBParseServerXml::ParseParamInfo( strParam,nTrID, strAppType,strMethod );
|
|
if( strMethod.CompareNoCase(_T("VerifyUserPassword4")) == 0 )
|
{
|
int nPos1 = strXml.Find(_T("\n"));
|
int nPos2 = strXml.Find(_T("\n"),nPos1+1);
|
int nPos3 = strXml.Find(_T("\n"),nPos2+1);
|
// ½âÎö·µ»ØÏûÏ¢
|
strSessionID = strXml.Left(nPos1);
|
strUserKey = strXml.Mid(nPos1,nPos2 -nPos1 -1);
|
strServerID = strXml.Mid(nPos2+1,nPos3-nPos2-1);
|
strUserInfo = strXml.Right(strXml.GetLength()-nPos3-1);
|
strServerID.TrimLeft(_T("{"));
|
strServerID.TrimRight(_T("}"));
|
m_pMBUserLogin->ParseUserLoginXml(strUserInfo);
|
m_pMBOrgWebCMgr->SetUserSession(strSessionID,m_pMBUserLogin->m_bIsSysAdmin);
|
m_pMBUserLogin->m_strOrgServerID = strServerID; // ·þÎñÆ÷ID
|
m_pMBUserLogin->m_strSessionID = strSessionID;
|
CString strLogin = m_pMBUserLogin->m_strLoginName ;
|
strLogin.MakeLower();
|
strUserKey.Format(_T("%sAsoft72e273b1"),strLogin);
|
m_pMBUserLogin->m_strOrgSVerify = CBaseCommFun::GenMD5(strUserKey);
|
m_pMBUserLogin->m_strOrgServer = m_strServer;
|
m_pMBUserLogin->m_nOrgServerPort = m_nPort;
|
// µÇ¼³É¹¦£¬ÓüÇÐÅÏ¢±£´æµ½ÀëÏßÊý¾Ý¿â
|
if(!m_pUserOfflineDbMgr->SaveUserToDb( m_pMBUserLogin->m_strServerName,m_pMBUserLogin->m_strLoginName,m_pMBUserLogin->m_strUserName,m_pMBUserLogin->m_strPwd,strErrInfo ))
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;
|
}
|
//// µÃµ½µÇ¼ÕßÐÅÏ¢
|
//nVer = 0;
|
//if(!m_pMBOrgWebCMgr->GetUserInfo(m_pMBUserLogin->m_strLoginName, strXML, nVer,strErrInfo ))
|
//{
|
// pTab->SetCurSel(_T("error"));
|
// m_pTextError->SetWindowText(strErrInfo);
|
// return FALSE;
|
//}
|
//m_pMBOrgListMgr->ParseOrgXml(AM_VIEWITEMTYPE_USER,m_pMBUserLogin->m_strLoginName,CMD_UBGI,strXML);
|
// µÃµ½ÏµÍ³ÁÙʱÎļþ¼Ð
|
TCHAR lpTempPathBuffer[MAX_PATH];
|
DWORD dwRetVal = GetTempPath(MAX_PATH,lpTempPathBuffer); // buffer for path
|
if (dwRetVal > MAX_PATH || (dwRetVal == 0))
|
{
|
pTab->SetCurSel(_T("error"));
|
strErrInfo = _T("µÃµ½ÏµÍ³ÁÙʱÎļþ¼Ðʧ°Ü£¡");
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;
|
}
|
m_pMBUserLogin->m_strSysTempPath = lpTempPathBuffer;
|
// »ñÈ¡¹«Ë¾Ãû³Æ
|
nVer = 0;
|
if(m_pMBOrgWebCMgr->GetOrgBaseInfo(strXML, nVer,strErrInfo ))
|
{
|
if( !m_pMBUserLogin->ParseOrgBaseInfoXml( strXML,strErrInfo ) )
|
{
|
//pTab->SetCurSel(_T("error"));
|
//m_pTextError->SetWindowText(strErrInfo);
|
//return FALSE;
|
}
|
}
|
// µÃµ½¹«Ë¾logo
|
CString strPath;
|
CString strTempPath;
|
if(m_pMBUserLogin->m_strLogoFile.IsEmpty() )
|
{
|
strPath.Format( _T("%s\\Users"),CBaseCommFun::GetWorkDir() );
|
::CreateDirectory(strPath, NULL);
|
strTempPath.Format( _T("%s\\LoginImage"),strPath );
|
::CreateDirectory(strTempPath, NULL);
|
m_pMBUserLogin->m_strLogoFile.Format( _T("%s\\%s_AppLogo.png"),strTempPath, m_pMBUserLogin->m_strOrgServerID );
|
}
|
//if( !CBaseCommFun::ExistThisFile(m_pMBUserLogin->m_strLogoFile))
|
{
|
if(!m_pMBOrgWebCMgr->GetOrgLogo( _T(""), m_pMBUserLogin->m_strLogoFile, strErrInfo))
|
{
|
//pTab->SetCurSel(_T("error"));
|
//m_pTextError->SetWindowText(strErrInfo);
|
//return FALSE;
|
}
|
}
|
m_pMBOrgListMgr->AddView(ROOTVIEW_SYSORGID,10000, _T("×éÖ¯½á¹¹"), _T("") );
|
m_pMBOrgListMgr->AddView(SUBVIEW_ROLEROOTID,10000, _T("½ÇÉ«"), _T("") );
|
CMBOrgView *pView = NULL;
|
CString strUsers = _T("");
|
m_pMBOrgListMgr->AddView( SUBVIEW_CONTACTSTOOT, 10000, _T("ÁªÏµÈË"), _T("") );
|
m_pMBOrgListMgr->LookupView(SUBVIEW_CONTACTSTOOT, pView);
|
if(pView)
|
{
|
pView->AddMember( AM_VIEWITEMTYPE_CUSTGROUP, SUBVIEW_TOPCONTACTS, _T("³£ÓÃÁªÏµÈË"), _T(""),0 );
|
if( !m_pMBUserLogin->m_strDepartGuid.IsEmpty() )
|
{
|
pView->AddMember( AM_VIEWITEMTYPE_GROUP, m_pMBUserLogin->m_strDepartGuid, m_pMBUserLogin->m_strDepartName, _T(""), 10000 );
|
m_pMBOrgListMgr->AddMember( AM_VIEWITEMTYPE_GROUP, m_pMBUserLogin->m_strDepartGuid,m_pMBUserLogin->m_strDepartName, 10000 );
|
}
|
else if( !m_pMBUserLogin->m_strUnitGuid.IsEmpty())
|
{
|
pView->AddMember( AM_VIEWITEMTYPE_VIEW, m_pMBUserLogin->m_strUnitGuid, m_pMBUserLogin->m_strUnitName, _T(""), 10000 );
|
m_pMBOrgListMgr->AddMember( AM_VIEWITEMTYPE_VIEW,m_pMBUserLogin->m_strUnitGuid,m_pMBUserLogin->m_strUnitName, 10000 );
|
}
|
REQLOADSERVER_ITEM regItem;
|
regItem.hWnd = m_hWnd;
|
regItem.pItem = (void*)pView;
|
regItem.strItemGUID = SUBVIEW_CONTACTSTOOT;
|
regItem.strItemType.Format(_T("%d"),AM_VIEWITEMTYPE_VIEW );
|
m_pMBOrgWebCMgr->GetContactGroupList_Asyn(m_hWnd,regItem);
|
}
|
m_pMBOrgListMgr->AddMember( AM_VIEWITEMTYPE_CUSTGROUP, SUBVIEW_TOPCONTACTS, _T("³£ÓÃÁªÏµÈË"), 0 );
|
|
// µÃµ½Îļþ·þÎñÆ÷Áбí
|
if( !m_pMBOrgWebCMgr->GetFileServerList( strListXML,strErrInfo ))
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;
|
}
|
if( !m_pFileSvrMgr->ParseXml(m_pMBUserLogin->m_strServerName, strListXML,strErrInfo ))
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;
|
}
|
CString strErr;
|
// À©Õ¹Web·þÎñ
|
nVer = 0;
|
CString strServerIP = m_pMBUserLogin->m_strServerName;
|
long nPort = DEFAULTPORT_EXTWEB;
|
CMBApplicationInfo *pApplicationInfo = new CMBApplicationInfo();
|
if( m_pMBOrgWebCMgr->GetApplicationInfo2(_T("OISTKExtWebS"),nVer,pApplicationInfo,strErrInfo))
|
{
|
nPort = _tstol(pApplicationInfo->m_strServicePort);
|
strServerIP = pApplicationInfo->m_strServerIP;
|
if(nPort < 1)
|
nPort = DEFAULTPORT_EXTWEB;
|
}
|
delete pApplicationInfo;
|
pApplicationInfo = NULL;
|
m_pMBUserLogin->m_strExtWebServer = strServerIP;
|
m_pMBUserLogin->m_nExtWebServerPort = nPort;
|
m_pMBExtWebCMgr->SetServerInfo(strServerIP,nPort);
|
|
m_pMBExtWebCMgr->SetUserInfo(m_pMBUserLogin->m_strLoginName,m_pMBUserLogin->m_strUserName);
|
m_pMBExtWebCMgr->SetUserSession(m_pMBUserLogin->m_strSessionID);
|
// À©Õ¹·þÎñ
|
nVer = 0;
|
strServerIP = m_pMBUserLogin->m_strServerName;
|
nPort = DEFAULTPORT_EXT;
|
pApplicationInfo = new CMBApplicationInfo();
|
if( m_pMBOrgWebCMgr->GetApplicationInfo2(_T("STKExtS"),nVer,pApplicationInfo,strErrInfo))
|
{
|
nPort = _tstol(pApplicationInfo->m_strServicePort);
|
strServerIP = pApplicationInfo->m_strServerIP;
|
if(nPort < 1)
|
nPort = DEFAULTPORT_EXT;
|
}
|
delete pApplicationInfo;
|
pApplicationInfo = NULL;
|
|
m_pMBUserLogin->m_strExtServer = strServerIP;
|
m_pMBUserLogin->m_nExtServerPort = nPort;
|
m_pMBExtCMgr->SetServerInfo(strServerIP,nPort);
|
m_pMBExtCMgr->SetLoginInfo(m_pMBUserLogin->m_strLoginName,m_pMBUserLogin->m_strUserName);
|
m_pMBExtCMgr->SetAppType(_T("MBC"));
|
m_pMBExtCMgr->SetInstance(::AfxGetResourceHandle());
|
m_pMBExtCMgr->Init(strErr);
|
|
//////////////////////////////////////////////////////////
|
if(!SaveCfgInfo(strServerID,strErrInfo))
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;
|
}
|
//Ups·þÎñ
|
nVer = 0;
|
strServerIP = m_pMBUserLogin->m_strServerName;
|
nPort = DEFAULTPORT_UPS;
|
pApplicationInfo = new CMBApplicationInfo();
|
if( m_pMBOrgWebCMgr->GetApplicationInfo2(_T("UpsS"),nVer,pApplicationInfo,strErrInfo))
|
{
|
nPort = _tstol(pApplicationInfo->m_strServicePort);
|
strServerIP = pApplicationInfo->m_strServerIP;
|
if(nPort < 1)
|
nPort = DEFAULTPORT_UPS;
|
}
|
delete pApplicationInfo;
|
pApplicationInfo = NULL;
|
m_pMBUserLogin->m_strUpsServer = strServerIP;
|
m_pMBUserLogin->m_nUpsServerPort = nPort;
|
// MoboxWeb·þÎñ
|
nVer = 0;
|
strServerIP = m_pMBUserLogin->m_strServerName;
|
nPort = DEFAULTPORT_MOBOX;
|
pApplicationInfo = new CMBApplicationInfo();
|
if( m_pMBOrgWebCMgr->GetApplicationInfo2(_T("OIMoboxWebS"),nVer,pApplicationInfo,strErrInfo))
|
{
|
nPort = _tstol(pApplicationInfo->m_strServicePort);
|
strServerIP = pApplicationInfo->m_strServerIP;
|
if(nPort < 1)
|
nPort = DEFAULTPORT_MOBOX;
|
}
|
delete pApplicationInfo;
|
pApplicationInfo = NULL;
|
m_pMBUserLogin->m_strMoboxServer = strServerIP;
|
m_pMBUserLogin->m_nMoboxSPort = nPort;
|
m_pMBMoboxWebCMgr->SetServerInfo(strServerIP,nPort);
|
m_pMBMoboxWebCMgr->SetUserInfo(m_pMBUserLogin->m_strLoginName,m_pMBUserLogin->m_strUserName);
|
// NetDiskWeb·þÎñ
|
nVer = 0;
|
strServerIP = m_pMBUserLogin->m_strServerName;
|
nPort = DEFAULTPORT_NETDISK;
|
pApplicationInfo = new CMBApplicationInfo();
|
if( m_pMBOrgWebCMgr->GetApplicationInfo2(_T("OINetDiskWebS"),nVer,pApplicationInfo,strErrInfo))
|
{
|
nPort = _tstol(pApplicationInfo->m_strServicePort);
|
strServerIP = pApplicationInfo->m_strServerIP;
|
if(nPort < 1)
|
nPort = DEFAULTPORT_NETDISK;
|
}
|
delete pApplicationInfo;
|
pApplicationInfo = NULL;
|
m_pMBUserLogin->m_strNetDiakServer = strServerIP;
|
m_pMBUserLogin->m_nNetDiakSPort = nPort;
|
|
// DataWeb ·þÎñ
|
nVer = 0;
|
strServerIP = m_pMBUserLogin->m_strServerName;
|
nPort = DEFAULTPORT_DATA;
|
pApplicationInfo = new CMBApplicationInfo();
|
if( m_pMBOrgWebCMgr->GetApplicationInfo2(_T("OIDataWebS"),nVer,pApplicationInfo,strErrInfo))
|
{
|
nPort = _tstol(pApplicationInfo->m_strServicePort);
|
strServerIP = pApplicationInfo->m_strServerIP;
|
if(nPort < 1)
|
nPort = DEFAULTPORT_DATA;
|
}
|
delete pApplicationInfo;
|
pApplicationInfo = NULL;
|
m_pMBUserLogin->m_strDataServer = strServerIP;
|
m_pMBUserLogin->m_nDataPort = nPort;
|
|
m_pDataWebCMgr->SetServerInfo(m_pMBUserLogin->m_strDataServer,m_pMBUserLogin->m_nDataPort);
|
m_pDataWebCMgr->SetUserInfo(m_pMBUserLogin->m_strLoginName,m_pMBUserLogin->m_strUserName);
|
|
// µÇÂ¼ÍøÅÌ
|
m_pMBNetDiskCMgr->SetServerInfo(m_pMBUserLogin->m_strNetDiakServer ,m_pMBUserLogin->m_nNetDiakSPort);
|
m_pMBNetDiskCMgr->SetUserInfo(m_pMBUserLogin->m_strLoginName,m_pMBUserLogin->m_strUserName);
|
m_pMBNetDiskCMgr->SetUserSessionID(m_pMBUserLogin->m_strSessionID);
|
if(m_pMBUserLogin->GetAuthInfo()->HasDocAuth())
|
{
|
m_pMBNetDiskCMgr->SignIn_Asyn(GetHostHwnd(),m_pMBUserLogin->m_strPwd);
|
}
|
else
|
{
|
pTab->SetCurSel(_T("connect"));
|
m_pTextTip->SetWindowText(_T("µÇ¼³É¹¦"));
|
// ±êʶ×ŵǼ³É¹¦
|
m_nRetCode = 0; // 怫
|
// ΪÁËÄܹ»ÏÔʾµÇ¼³É¹¦½çÃæ£¬¶øÉèÖõĶ¨Ê±Æ÷
|
SetTimer(WM_TIMER_CLOSE, 100);
|
}
|
|
|
|
|
|
}
|
return TRUE;
|
}
|
|
LRESULT CMBLoginWnd::OnOrgWebError(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled)
|
{
|
CString strXml= *(CString*)wParam;
|
CString strParam= *(CString*)lParam;
|
long nTrID = 0;
|
CString strData;
|
CString strName;
|
CString strValue;
|
CString strAppType = _T("");
|
CString strMethod = _T("");
|
int nErrCode = 0;
|
CString strErrInfo;
|
CMBParseServerXml::ParseParamInfo( strParam,nTrID, strAppType,strMethod );
|
CMBParseServerXml::ParseErrInfo( strXml, nErrCode,strErrInfo);
|
if( strMethod.CompareNoCase(_T("VerifyUserPassword4")) == 0 )
|
{
|
if( nErrCode == -1 )
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("OrgWeb:ÎÞ·¨Á¬½Ó·þÎñÆ÷!"));
|
}else{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("OrgWeb:") + strErrInfo);
|
}
|
}
|
|
return TRUE;
|
}
|
|
|
LRESULT CMBLoginWnd::OnNetDiskResponse(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled)
|
{
|
CString strXml= *(CString*)wParam;
|
CString strParam= *(CString*)lParam;
|
long nTrID = 0;
|
CString strData;
|
CString strName;
|
CString strValue;
|
CString strAppType = _T("");
|
CString strMethod = _T("");
|
CString strServerID,
|
strNDInfo;
|
CString strErrInfo;
|
CString strListXML;
|
int nVer = 0;
|
REQLOADSERVER_ITEM reqLoadServerItem;
|
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
CMBParseServerXml::ParseParamInfo( strParam,nTrID, strAppType,strMethod );
|
|
|
if(!m_pMBNetDiskCMgr->GetServerTrID(nTrID,reqLoadServerItem))
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextTip->SetWindowText(_T("netdisk:ûÓÐÕÒµ½´¥·¢µÄ½Ó¿Ú£¡"));
|
return FALSE;
|
}
|
if(reqLoadServerItem.strMethod == NETDISK_SIGNIN)
|
{
|
int nPos1 = strXml.Find(_T("\n"));
|
// ½âÎö·µ»ØÏûÏ¢
|
strServerID = strXml.Left(nPos1);
|
strNDInfo = strXml.Mid(nPos1+1,strXml.GetLength() -nPos1);
|
|
m_pMBNetDiskCMgr->SetUserSessionID( strServerID );
|
|
if(!CMBLoginParseSvrXml::ParseLoginCabinetXml(m_pMBUserNetDiskInfo,strNDInfo,strErrInfo))
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;
|
}
|
|
|
// µÃµ½ÏµÍ³²ÎÊý
|
CString strValue;
|
CString strContent;
|
////////////////////////////disable/////////////////////
|
if(!m_pDataWebCMgr->GetSysParam(DISABLE_APP_CODE,strValue,strErrInfo))
|
{
|
/*pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;*/
|
}
|
m_pMBUserLogin->GetAuthInfo()->SetDisableApp(strValue);
|
/////////////////////////oos///////////
|
strValue = _T("");
|
if(!m_pDataWebCMgr->GetSysParam(OOSWEBSITE_CODE,strValue,strErrInfo))
|
{
|
/*pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;*/
|
}
|
if(!m_pDataWebCMgr->LoadLongStr( strValue,strContent,strErrInfo ))
|
{
|
/*pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;*/
|
}
|
if(!m_pMBUserNetDiskInfo->ParseOOSXml(strContent,strErrInfo ))
|
{
|
/*pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;*/
|
}
|
/////////////////////gunghoÍøÖ·/////////
|
if(!m_pDataWebCMgr->GetSysParam(GUNGHOWEBSITE_CODE,strValue,strErrInfo))
|
{
|
/*pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;*/
|
}
|
m_pMBUserNetDiskInfo->m_strGungHoWebSiteUrl = strValue;
|
//////////////////////////////////////////////////////////////////////////
|
if(!m_pDataWebCMgr->GetSysParam(MOBOXWEBSITE_CODE,strValue,strErrInfo))
|
{
|
/*pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return FALSE;*/
|
}
|
m_pMBUserNetDiskInfo->m_strMoboxWebSiteUrl = strValue;
|
//////////////////////////////////////////////////////////////////////////
|
pTab->SetCurSel(_T("connect"));
|
m_pTextTip->SetWindowText(_T("µÇ¼³É¹¦"));
|
// ±êʶ×ŵǼ³É¹¦
|
m_nRetCode = 0; // 怫
|
// ΪÁËÄܹ»ÏÔʾµÇ¼³É¹¦½çÃæ£¬¶øÉèÖõĶ¨Ê±Æ÷
|
SetTimer(WM_TIMER_CLOSE, 100);
|
}
|
/*if( strMethod.CompareNoCase(_T("Sign")) == 0 )
|
{*/
|
|
|
/*} */
|
return TRUE;
|
}
|
|
LRESULT CMBLoginWnd::OnNetDiskError(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled)
|
{
|
CString strXml= *(CString*)wParam;
|
CString strParam= *(CString*)lParam;
|
long nTrID = 0;
|
CString strData;
|
CString strName;
|
CString strValue;
|
CString strAppType = _T("");
|
CString strMethod = _T("");
|
int nErrCode = 0;
|
CString strErrInfo;
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
CMBParseServerXml::ParseParamInfo( strParam,nTrID, strAppType,strMethod );
|
CMBParseServerXml::ParseErrInfo( strXml, nErrCode,strErrInfo);
|
|
if( nErrCode == -1 )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("NetDisk:ÎÞ·¨Á¬½Ó·þÎñÆ÷!"));
|
}else{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("NetDisk:") + strErrInfo);
|
}
|
|
return TRUE;
|
}
|
|
void CMBLoginWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
{
|
SetMsgHandled(FALSE);
|
// enter¼ü
|
if(((::GetAsyncKeyState( VK_RETURN ) & 0x8000)))
|
{
|
if( !IsAllowEnterLogin() )
|
return ;
|
|
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
if( NULL == pTab )
|
return ;
|
|
int nIndex = pTab->GetCurSel();
|
|
if( nIndex == 0 )
|
{
|
OnBtnLogin(); // 怬
|
}// È¡Ïû
|
else if( nIndex == 2 )
|
{
|
OnBtnErrorCancel();
|
}
|
}
|
}
|
|
|
//LRESULT CMBLoginWnd::OnMoboxResponse(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled)
|
//{
|
// CString strXml= *(CString*)wParam;
|
// CString strParam= *(CString*)lParam;
|
// long nTrID = 0;
|
// CString strData;
|
// CString strName;
|
// CString strValue;
|
// CString strAppType = _T("");
|
// CString strMethod = _T("");
|
// CString strErrInfo;
|
// int nErrCode = 0;
|
//
|
// STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
// CMBParseServerXml::ParseParamInfo( strParam,nTrID, strAppType,strMethod );
|
//
|
// if(!m_pSysAppMgr->ParseXml(strXml,strErrInfo))
|
// {
|
// pTab->SetCurSel(_T("error"));
|
// m_pTextError->SetWindowText(strErrInfo);
|
// return FALSE;
|
// }
|
//
|
// pTab->SetCurSel(_T("connect"));
|
// m_pTextTip->SetWindowText(_T("µÇ¼³É¹¦"));
|
// // ΪÁËÄܹ»ÏÔʾµÇ¼³É¹¦½çÃæ£¬¶øÉèÖõĶ¨Ê±Æ÷
|
// SetTimer(WM_TIMER_CLOSE, 100);
|
//
|
//
|
// return TRUE;
|
//}
|
//
|
//LRESULT CMBLoginWnd::OnMoboxError(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled)
|
//{
|
// CString strXml= *(CString*)wParam;
|
// CString strParam= *(CString*)lParam;
|
// long nTrID = 0;
|
// CString strData;
|
// CString strName;
|
// CString strValue;
|
// CString strAppType = _T("");
|
// CString strMethod = _T("");
|
// int nErrCode = 0;
|
// CString strErrInfo;
|
// STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
//
|
// CMBParseServerXml::ParseParamInfo( strParam,nTrID, strAppType,strMethod );
|
// CMBParseServerXml::ParseErrInfo( strXml, nErrCode,strErrInfo);
|
//
|
// if( nErrCode == -1 )
|
// {
|
// pTab->SetCurSel(_T("error"));
|
// m_pTextError->SetWindowText(_T("Mobox:ÎÞ·¨Á¬½Ó·þÎñÆ÷!"));
|
// }else{
|
// pTab->SetCurSel(_T("error"));
|
// m_pTextError->SetWindowText(_T("Mobox:") + strErrInfo);
|
// }
|
//
|
// return TRUE;
|
//}
|
|
void CMBLoginWnd::OnTimer(UINT_PTR nIDEvent)
|
{
|
switch (nIDEvent)
|
{
|
case WM_TIMER_AUTOLOGION:
|
{
|
KillTimer(WM_TIMER_AUTOLOGION);
|
ShowWindow(SW_SHOW);
|
OnBtnLogin();
|
}break;
|
case WM_TIMER_CLOSE:
|
{
|
KillTimer(WM_TIMER_CLOSE);
|
OnClose();
|
}break;
|
default:
|
SetMsgHandled(FALSE);
|
break;
|
}
|
}
|
|
void CMBLoginWnd::AutoScale()
|
{
|
|
//SendMessage(WM_DPICHANGED,125);
|
return ;
|
int width = GetSystemMetrics ( SM_CXSCREEN );
|
int height= GetSystemMetrics ( SM_CYSCREEN );
|
|
int nID = 125;
|
int nScale = 100;
|
switch(nID)
|
{
|
case 100:
|
nScale = 100;
|
break;
|
case 125:
|
nScale = 125;
|
break;
|
case 150:
|
nScale = 150;
|
break;
|
case 200:
|
nScale = 200;
|
break;
|
}
|
int nCurScale = GetScale();
|
SOUI::CRect rcWnd = GetWindowRect();
|
int OriWid = rcWnd.Width() * 100 / nCurScale;
|
int OriHei = rcWnd.Height() * 100/ nCurScale;
|
|
int nNewWid = OriWid * nScale / 100;
|
int nNewHei = OriHei * nScale / 100;
|
|
SDispatchMessage(UM_SETSCALE,nScale,0);
|
|
if(!CSimpleWnd::IsZoomed()){
|
SetWindowPos(0, 0, 0, nNewWid, nNewHei, SWP_NOZORDER | SWP_NOMOVE);
|
}
|
|
}
|
|
//¿½±´dbÎļþ
|
bool CMBLoginWnd::CopyDb( CString strSrcDb,CString strTargetDb,CString &strErrInfo )
|
{
|
if( !CStrFileUtils::IsExist(strTargetDb) )
|
{
|
if( !CStrFileUtils::IsExist(strSrcDb) )
|
return false;
|
if(!CStrFileUtils::CopySqliteDb3(strSrcDb,strTargetDb))
|
{
|
strErrInfo = strSrcDb + _T(" ¿½±´³ö´í!");
|
return false;
|
}
|
// ÕâÀïÓ¦¸ÃÓдíÎó´¦ÀíµÄ
|
}
|
return true;
|
}
|
|
// ÊÇ·ñÔÊÐíEnter·½Ê½µÇ¼
|
bool CMBLoginWnd::IsAllowEnterLogin()
|
{
|
CString strPwd,strServerName,
|
strLogin;
|
|
strServerName = m_pCbvServerName->GetWindowText();
|
strLogin = m_pCbvLogin->GetWindowText();
|
strPwd = m_pEdPwd->GetWindowText();
|
|
strServerName = strServerName.Trim();
|
strLogin = strLogin.Trim();
|
strPwd = strPwd.Trim();
|
/*if( strServerName.IsEmpty() )
|
{
|
m_pCbvServerName->SetFocus();
|
return false;
|
}
|
else if( strLogin.IsEmpty() )
|
{
|
m_pCbvLogin->SetFocus();
|
return false;
|
}
|
else*/ if( strPwd.IsEmpty() )
|
{
|
m_pEdPwd->SetFocus();
|
return false;
|
}
|
|
return true;
|
}
|
|
//=======================================
|
// ÅжÏϵͳÊÇ·ñÒÑÔÚÔËÐÐ
|
//=======================================
|
BOOL CMBLoginWnd::AppIsRun()
|
{
|
HWND oldHWnd = NULL;
|
|
EnumWindows(EnumWndProc,(LPARAM)&oldHWnd); //ö¾ÙËùÓÐÔËÐеĴ°¿Ú
|
|
if(oldHWnd != NULL)
|
return true; //Í˳ö±¾´ÎÔËÐÐ
|
|
return false;
|
}
|
|
// ÁªÍøµÇ¼
|
void CMBLoginWnd::InternetLogin()
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
CString strPort,strPwd,strServerName,
|
strLogin,strAutoLogin,strSavePWd;
|
|
strPort = m_pEdPort->GetWindowText();
|
strServerName = m_pCbvServerName->GetWindowText();
|
strLogin = m_pCbvLogin->GetWindowText();
|
strPwd = m_pEdPwd->GetWindowText();
|
if(m_pCkAutoLogin->IsChecked())
|
{
|
strAutoLogin = _T("1");
|
}else{
|
strAutoLogin = _T("0");
|
}
|
if(m_pCkSavePwd->IsChecked())
|
{
|
strSavePWd = _T("1");
|
}else{
|
strSavePWd = _T("0");
|
}
|
|
if( strServerName.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("·þÎñÆ÷Ãû³Æ²»Îª¿Õ£¡"));
|
}
|
else if( strLogin.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("ÕʺŲ»Îª¿Õ£¡"));
|
}
|
else if( strPwd.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("ÃÜÂ벻Ϊ¿Õ£¡"));
|
}
|
else if( strPort.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("¶Ë¿ÚºÅ²»Îª¿Õ£¡"));
|
}else{
|
|
m_pMBUserLogin->m_strInputName = strLogin;
|
m_pMBUserLogin->m_strPort = strPort;
|
m_pMBUserLogin->m_strPwd = strPwd;
|
m_pMBUserLogin->m_strServerName = strServerName;
|
m_pMBUserLogin->GetHostName();
|
m_pMBUserLogin->GetHostIP(m_pMBUserLogin->m_asUserIP);
|
g_szPropName.Format( _T("MBC_%s-%s-%s"), strServerName, strPort, strLogin );
|
g_szPropName.MakeLower();
|
if( AppIsRun() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("µ±Ç°Óû§±¾»úÉϵǼ£¡"));
|
return;
|
}
|
//m_pEdError->SetWindowText(strErrInfo);
|
m_pMBOrgWebCMgr->SetServerInfo(strServerName,_ttoi(strPort));
|
m_pMBOrgWebCMgr->SetUserInfo(strLogin,strLogin);
|
bool bRet = m_pMBOrgWebCMgr->VerUserPassword4_Asyn( GetHostHwnd(),strLogin,strPwd);
|
pTab->SetCurSel(_T("connect"));
|
}
|
}
|
|
|
// ÀëÏߵǼ
|
void CMBLoginWnd::OfflineLogin()
|
{
|
STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
|
CString strPort,strPwd,strServerName,strServerID,strErrInfo,
|
strLogin,strAutoLogin,strSavePWd,strOffline,strMyCfgPath,strUserName;
|
|
bool bMatch = false;
|
|
strPort = m_pEdPort->GetWindowText();
|
strServerName = m_pCbvServerName->GetWindowText();
|
strLogin = m_pCbvLogin->GetWindowText();
|
strPwd = m_pEdPwd->GetWindowText();
|
|
strPort = strPort.Trim();
|
strServerName = strServerName.Trim();
|
strLogin = strLogin.Trim();
|
strPwd = strPwd.Trim();
|
|
if(m_pCkOffline->IsChecked())
|
{
|
strOffline = _T("1");
|
}else{
|
strOffline = _T("0");
|
}
|
|
if( strServerName.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("·þÎñÆ÷Ãû³Æ²»Îª¿Õ£¡"));
|
}
|
else if( strLogin.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("ÕʺŲ»Îª¿Õ£¡"));
|
}
|
else if( strPwd.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("ÃÜÂ벻Ϊ¿Õ£¡"));
|
}
|
else if( strPort.IsEmpty() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("¶Ë¿ÚºÅ²»Îª¿Õ£¡"));
|
}else{
|
m_pMBUserLogin->m_strInputName = strLogin;
|
m_pMBUserLogin->m_strPort = strPort;
|
m_pMBUserLogin->GetHostName();
|
m_pMBUserLogin->GetHostIP(m_pMBUserLogin->m_asUserIP);
|
g_szPropName.Format( _T("MBC_%s-%s-%s"), strServerName, strPort, strLogin );
|
g_szPropName.MakeLower();
|
if( AppIsRun() )
|
{
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(_T("µ±Ç°Óû§±¾»úÉϵǼ£¡"));
|
return;
|
}
|
// ÑéÖ¤Óû§ÃÜÂë
|
if(!m_pUserOfflineDbMgr->VerUserPwd(bMatch,strServerName,strLogin,strPwd,strUserName,strErrInfo)){
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return ;
|
}
|
|
if( !bMatch )
|
{
|
strErrInfo = _T("Óû§²»´æÔÚ»òÓû§ÃÜÂë´íÎó£¡");
|
pTab->SetCurSel(_T("error"));
|
m_pTextError->SetWindowText(strErrInfo);
|
return ;
|
}
|
// ÉèÖÃÓû§ÐÅÏ¢
|
m_pMBUserLogin->m_strLoginName = strLogin;
|
m_pMBUserLogin->m_strUserName = strUserName;
|
m_pMBUserLogin->m_strServerName = strServerName;
|
m_pMBUserLogin->m_bIsOffline = true;
|
// ±£´æÊý¾Ý
|
strServerID = m_pMBCfgInfo->GetServerID( strServerName );
|
strMyCfgPath = CMBUserProFun::GetMyIniFile(strLogin, strServerID);
|
if( CStrFileUtils::IsExist( strMyCfgPath ) )
|
{
|
CIniFile iniFile( strMyCfgPath );
|
iniFile.SetProfileString(MBC_LOGIN_SECTION,MBC_LOGIN_SECTION_OFFLINE,strOffline);
|
}
|
// µÇ¼³É¹¦£¬±£´æÊý¾Ý
|
m_pMBCfgInfo->m_iniFile.SetProfileString(_T("MOBOX_APPSET"),_T("Offline"),strOffline);
|
|
//////////////////////////////////////////////////////////////////////////
|
pTab->SetCurSel(_T("connect"));
|
m_pTextTip->SetWindowText(_T("µÇ¼³É¹¦"));
|
// ±êʶ×ŵǼ³É¹¦
|
m_nRetCode = 0; // 怫
|
// ΪÁËÄܹ»ÏÔʾµÇ¼³É¹¦½çÃæ£¬¶øÉèÖõĶ¨Ê±Æ÷
|
SetTimer(WM_TIMER_CLOSE, 100);
|
}
|
}
|