2022-07-14 07:44:53 +00:00
|
|
|
#include "VersionDll.h"
|
|
|
|
#include "base/HGDef.h"
|
|
|
|
#include "base/HGInc.h"
|
|
|
|
|
|
|
|
VersionDll::VersionDll()
|
|
|
|
{
|
|
|
|
m_dll = NULL;
|
|
|
|
m_funcCreateMgr = NULL;
|
|
|
|
m_funcDestroyMgr = NULL;
|
|
|
|
m_funcGetServerConfig = NULL;
|
|
|
|
m_funcGetVersionList = NULL;
|
|
|
|
m_funcPostCrashInfo = NULL;
|
|
|
|
m_funcPostUserFeedback = NULL;
|
|
|
|
m_funcHttpDownload = NULL;
|
|
|
|
m_funcReleaseVersionList = NULL;
|
|
|
|
m_funcGetCurrVersion = NULL;
|
|
|
|
m_funcCompareVersion = NULL;
|
2022-07-14 10:45:35 +00:00
|
|
|
m_mgr = NULL;
|
2022-07-14 07:44:53 +00:00
|
|
|
|
|
|
|
Load();
|
|
|
|
}
|
|
|
|
|
|
|
|
VersionDll::~VersionDll()
|
|
|
|
{
|
|
|
|
Free();
|
|
|
|
}
|
|
|
|
|
|
|
|
HGResult VersionDll::Load()
|
|
|
|
{
|
|
|
|
if (NULL != m_dll)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_CreateDll("HGVersion.dll", &m_dll);
|
|
|
|
if (NULL == m_dll)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_CreateMgr", (HGPointer *)&m_funcCreateMgr);
|
|
|
|
if (NULL == m_funcCreateMgr)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_DestroyMgr", (HGPointer *)&m_funcDestroyMgr);
|
2022-07-14 10:45:35 +00:00
|
|
|
if (NULL == m_funcDestroyMgr)
|
2022-07-14 07:44:53 +00:00
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetServerConfig", (HGPointer *)&m_funcGetServerConfig);
|
|
|
|
if (NULL == m_funcGetServerConfig)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostCrashInfo", (HGPointer *)&m_funcPostCrashInfo);
|
|
|
|
if (NULL == m_funcPostCrashInfo)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserFeedback", (HGPointer *)&m_funcPostUserFeedback);
|
|
|
|
if (NULL == m_funcPostUserFeedback)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetVersionList", (HGPointer *)&m_funcGetVersionList);
|
|
|
|
if (NULL == m_funcGetVersionList)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_HttpDownload", (HGPointer *)&m_funcHttpDownload);
|
|
|
|
if (NULL == m_funcHttpDownload)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_ReleaseVersionList", (HGPointer *)&m_funcReleaseVersionList);
|
|
|
|
if (NULL == m_funcReleaseVersionList)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetCurrVersion", (HGPointer *)&m_funcGetCurrVersion);
|
|
|
|
if (NULL == m_funcGetCurrVersion)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBase_GetDllProcAddress(m_dll, "HGVersion_CompareVersion", (HGPointer *)&m_funcCompareVersion);
|
|
|
|
if (NULL == m_funcCompareVersion)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
m_funcCreateMgr(&m_mgr);
|
|
|
|
if (NULL == m_mgr)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-07-14 07:44:53 +00:00
|
|
|
}while (0);
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
m_funcCreateMgr = NULL;
|
|
|
|
m_funcDestroyMgr = NULL;
|
|
|
|
m_funcGetServerConfig = NULL;
|
|
|
|
m_funcGetVersionList = NULL;
|
|
|
|
m_funcPostCrashInfo = NULL;
|
|
|
|
m_funcPostUserFeedback = NULL;
|
|
|
|
m_funcHttpDownload = NULL;
|
|
|
|
m_funcReleaseVersionList = NULL;
|
|
|
|
m_funcGetCurrVersion = NULL;
|
|
|
|
m_funcCompareVersion = NULL;
|
|
|
|
|
|
|
|
HGBase_DestroyDll(m_dll);
|
|
|
|
m_dll = NULL;
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HGBASE_ERR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGResult VersionDll::Free()
|
|
|
|
{
|
|
|
|
if (NULL == m_dll)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
m_funcDestroyMgr(m_mgr);
|
|
|
|
m_mgr = NULL;
|
2022-07-14 07:44:53 +00:00
|
|
|
HGBase_DestroyDll(m_dll);
|
|
|
|
m_dll = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGBool VersionDll::IsValid()
|
|
|
|
{
|
|
|
|
return (NULL != m_dll);
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
HGResult VersionDll::GetServerConfig(HGServerConfig *config)
|
2022-07-14 07:44:53 +00:00
|
|
|
{
|
|
|
|
if (NULL == m_funcGetServerConfig)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
return m_funcGetServerConfig(m_mgr, config);
|
2022-07-14 07:44:53 +00:00
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
HGResult VersionDll::GetVersionList(const HGChar* appName, HGVersionInfo **info, HGUInt *count)
|
2022-07-14 07:44:53 +00:00
|
|
|
{
|
|
|
|
if (NULL == m_funcGetVersionList)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
return m_funcGetVersionList(m_mgr, appName, info, count);
|
2022-07-14 07:44:53 +00:00
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
HGResult VersionDll::HttpDownload(const HGChar *url, const HGChar *saveFilePath, HGHttpDownloadFunc func, HGPointer param)
|
2022-07-14 07:44:53 +00:00
|
|
|
{
|
|
|
|
if (NULL == m_funcHttpDownload)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
return m_funcHttpDownload(m_mgr, url, saveFilePath, func, param);
|
2022-07-14 07:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HGResult VersionDll::ReleaseVersionList(HGVersionInfo* info, HGUInt count)
|
|
|
|
{
|
|
|
|
if (NULL == m_funcReleaseVersionList)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_funcReleaseVersionList(info, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
HGResult VersionDll::GetCurrVersion(const HGChar* appName, HGChar* version, HGUInt maxLen)
|
|
|
|
{
|
|
|
|
if (NULL == m_funcGetCurrVersion)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_funcGetCurrVersion(appName, version, maxLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
HGResult VersionDll::CompareVersion(const HGChar* version1, const HGChar* version2, HGInt* result)
|
|
|
|
{
|
|
|
|
if (NULL == m_funcCompareVersion)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_funcCompareVersion(version1, version2, result);
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
HGResult VersionDll::PostCrashInfo(const HGChar* appName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr)
|
2022-07-14 07:44:53 +00:00
|
|
|
{
|
|
|
|
if (NULL == m_funcPostCrashInfo)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
return m_funcPostCrashInfo(m_mgr, appName, desc, crashFilePath, exceptionAddr);
|
2022-07-14 07:44:53 +00:00
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
HGResult VersionDll::PostUserFeedback(const HGChar* appName, const HGChar* desc, const HGChar* feedback, const HGChar* contact)
|
2022-07-14 07:44:53 +00:00
|
|
|
{
|
|
|
|
if (NULL == m_funcPostUserFeedback)
|
|
|
|
{
|
|
|
|
return HGBASE_ERR_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-07-14 10:45:35 +00:00
|
|
|
return m_funcPostUserFeedback(m_mgr, appName, desc, feedback, contact);
|
2022-07-14 07:44:53 +00:00
|
|
|
}
|