#include "StdAfx.h"
|
#include "MBFileSvrInfo.h"
|
#include "MBBaseDef.h"
|
CMBFileSvrInfo::CMBFileSvrInfo(void)
|
{
|
m_bServerChecked = FALSE;
|
m_pThreadCheckServer = new CMBThreadCheckServer();
|
m_pThreadCheckServer->m_pSvrInfo = this;
|
}
|
CMBFileSvrInfo::~CMBFileSvrInfo(void)
|
{
|
m_pThreadCheckServer->OverThread();
|
MBSAFE_DELETE(m_pThreadCheckServer);
|
}
|
CString CMBFileSvrInfo::GetUrl( )
|
{
|
CString strURL;
|
if( !m_strInterURL.IsEmpty() )
|
{
|
strURL = m_strInterURL;
|
}
|
else{
|
strURL = m_strExterURL;
|
}
|
return strURL;
|
}
|
|
// <FileService Flag="NetDisk" ExterServer="0" ExterIP="115.29.185.26" ExterPort="5012"><ExterURL><![CDATA[http://115.29.185.26:80]]></ExterURL></FileService>
|
|
bool CMBFileSvrInfo::ParseXml( CString strXml,CString strOrgServer,CString &strErrInfo )
|
{
|
pugi::xml_document xmlDoc;
|
if (!xmlDoc.load(strXml))
|
{
|
return false;
|
}
|
m_bServerChecked = FALSE;
|
pugi::xml_node form = xmlDoc.child(_T("FileService"));
|
m_strFlag = form.attribute(_T("Flag")).value();
|
m_strExterIP = form.attribute(_T("ExterIP")).value();
|
m_strExterPort = form.attribute(_T("ExterPort")).value();
|
if( _tstol(m_strExterPort) < 0)
|
m_strExterPort.Format(_T("%d"),DEFAULTPORT_FILE);
|
m_strInterIP = form.attribute(_T("InterIP")).value();
|
m_strInterPort = form.attribute(_T("InterPort")).value();
|
if( _tstol(m_strInterPort) < 0)
|
m_strInterPort.Format(_T("%d"),DEFAULTPORT_FILE);
|
m_strExterURL = form.child_value(_T("ExterURL"));
|
m_strInterURL = form.child_value(_T("InterURL"));
|
return CheckServerInfo(strOrgServer);
|
}
|
bool CMBFileSvrInfo::CheckServerInfo( CString strOrgServer)
|
{
|
CString strExtURLValue = m_strExterURL;
|
CString strInterURLValue = m_strInterURL;
|
m_strInterURL = _T("");
|
m_strExterURL = _T("");
|
if(m_strInterIP.IsEmpty() )
|
{
|
if(m_strExterIP.IsEmpty() )
|
{
|
m_strExterIP = strOrgServer;
|
|
}
|
SetValidSvrInfo(m_strExterIP, m_strExterPort);
|
}
|
else
|
{
|
if(m_strExterIP.IsEmpty())
|
{
|
SetValidSvrInfo(m_strInterIP, m_strInterIP);
|
}
|
else
|
{
|
if(m_strExterIP.CompareNoCase(m_strInterIP) == 0)
|
{
|
SetValidSvrInfo(m_strExterIP, m_strExterPort);
|
}
|
else
|
{
|
m_pThreadCheckServer->StartThread();
|
}
|
}
|
}
|
if( !strInterURLValue.IsEmpty())
|
{
|
CString strIP = m_strInterIP;
|
if(strIP.IsEmpty())
|
strIP = strOrgServer;
|
CString strInterURL = strInterURLValue;
|
strInterURLValue.MakeLower();
|
CString strHttp = _T("http://:");
|
int nPos = strInterURLValue.Find(strHttp);
|
if(nPos == 0)
|
{
|
strInterURLValue.Format(_T("http://%s:%s"),strIP, strInterURL.Right(strInterURLValue.GetLength() -strHttp.GetLength() ));
|
strInterURL = strInterURLValue;
|
}
|
else
|
{
|
strHttp = _T("https://:");
|
nPos = strInterURLValue.Find(strHttp);
|
if(nPos == 0)
|
{
|
strInterURLValue.Format(_T("https://%s:%s"),strIP, strInterURL.Right(strInterURLValue.GetLength() -strHttp.GetLength() ));
|
strInterURL = strInterURLValue;
|
}
|
}
|
m_strInterURL = strInterURL;
|
}
|
else
|
{
|
CString strIP = m_strExterIP;
|
if(strIP.IsEmpty())
|
strIP = strOrgServer;
|
CString strExtURL = strExtURLValue;
|
strExtURLValue.MakeLower();
|
CString strHttp = _T("http://:");
|
int nPos = strExtURLValue.Find(strHttp);
|
if(nPos == 0)
|
{
|
strExtURLValue.Format(_T("http://%s:%s"),strIP, strExtURL.Right(strExtURLValue.GetLength() -strHttp.GetLength() ));
|
strExtURL = strExtURLValue;
|
}
|
else
|
{
|
strHttp = _T("https://:");
|
nPos = strExtURLValue.Find(strHttp);
|
if(nPos == 0)
|
{
|
strExtURLValue.Format(_T("https://%s:%s"),strIP, strExtURL.Right(strExtURLValue.GetLength() -strHttp.GetLength() ));
|
strExtURL = strExtURLValue;
|
}
|
}
|
m_strExterURL = strExtURL;
|
}
|
return true;
|
}
|