code_app/app/scanner/VersionDll.cpp

537 lines
14 KiB
C++

#include "VersionDll.h"
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
VersionDll::VersionDll()
{
m_dll = NULL;
m_funcCreateMgr = NULL;
m_funcDestroyMgr = NULL;
m_funcGetServerConfig = NULL;
m_funcGetVersionList = NULL;
m_funcGetDriverVersionList = NULL;
m_funcBlackListCheck = NULL;
m_funcPostCrashInfo = NULL;
m_funcPostUserFeedback = NULL;
m_funcHttpDownload = NULL;
m_funcReleaseVersionList = NULL;
m_funcGetCurrVersion = NULL;
m_funcCompareVersion = NULL;
m_funcPostDeviceOpenInfo = NULL;
m_funcPostDeviceCloseInfo = NULL;
m_funcPostDeviceScanCountInfo = NULL;
m_funcPostDeviceClearRollerInfo = NULL;
m_funcPostDeviceHistroyCountInfo = NULL;
m_funcPostDeviceRollerCountInfo = NULL;
m_funcPostUserOpenInfo = NULL;
m_funcPostUserCloseInfo = NULL;
m_funcPostUserLoginInfo = NULL;
m_funcPostUserLogoutInfo = NULL;
m_funcPostDevicePaperJamInfo = NULL;
m_funcPostDeviceLockInfo = NULL;
m_mgr = NULL;
Load();
}
VersionDll::~VersionDll()
{
Free();
}
HGResult VersionDll::Load()
{
if (NULL != m_dll)
{
return HGBASE_ERR_FAIL;
}
HGChar moduleName[256];
HGBase_GetModuleName(nullptr, moduleName, 256);
HGChar dllPath[256];
HGBase_GetFilePath(moduleName, dllPath, 256);
#if defined(HG_CMP_MSC)
#if defined(OEM_HANWANG)
strcat(dllPath, "HwVersion.dll");
#elif defined(OEM_LISICHENG)
strcat(dllPath, "LscVersion.dll");
#elif defined(OEM_CANGTIAN)
strcat(dllPath, "CtsVersion.dll");
#else
strcat(dllPath, "HGVersion.dll");
#endif
#else
#if defined(OEM_HANWANG)
strcpy(dllPath, "libHwVersion.so");
#elif defined(OEM_LISICHENG)
strcpy(dllPath, "libLscVersion.so");
#elif defined(OEM_CANGTIAN)
strcpy(dllPath, "libCtsVersion.so");
#else
strcpy(dllPath, "libHGVersion.so");
#endif
#endif
HGBase_CreateDll(dllPath, &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);
if (NULL == m_funcDestroyMgr)
{
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_GetDriverVersionList", (HGPointer*)&m_funcGetDriverVersionList);
if (NULL == m_funcGetDriverVersionList)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_BlackListCheck", (HGPointer*)&m_funcBlackListCheck);
if (NULL == m_funcBlackListCheck)
{
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;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceOpenInfo", (HGPointer *)&m_funcPostDeviceOpenInfo);
if (NULL == m_funcPostDeviceOpenInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceCloseInfo", (HGPointer *)&m_funcPostDeviceCloseInfo);
if (NULL == m_funcPostDeviceCloseInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceScanCountInfo", (HGPointer *)&m_funcPostDeviceScanCountInfo);
if (NULL == m_funcPostDeviceScanCountInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceClearRollerInfo", (HGPointer *)&m_funcPostDeviceClearRollerInfo);
if (NULL == m_funcPostDeviceClearRollerInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceHistroyCountInfo", (HGPointer *)&m_funcPostDeviceHistroyCountInfo);
if (NULL == m_funcPostDeviceHistroyCountInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceRollerCountInfo", (HGPointer *)&m_funcPostDeviceRollerCountInfo);
if (NULL == m_funcPostDeviceRollerCountInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserOpenInfo", (HGPointer *)&m_funcPostUserOpenInfo);
if (NULL == m_funcPostUserOpenInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserCloseInfo", (HGPointer *)&m_funcPostUserCloseInfo);
if (NULL == m_funcPostUserCloseInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserLoginInfo", (HGPointer *)&m_funcPostUserLoginInfo);
if (NULL == m_funcPostUserLoginInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserLogoutInfo", (HGPointer *)&m_funcPostUserLogoutInfo);
if (NULL == m_funcPostUserLogoutInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDevicePaperJamInfo", (HGPointer *)&m_funcPostDevicePaperJamInfo);
if (NULL == m_funcPostDevicePaperJamInfo)
{
ok = false;
break;
}
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceLockInfo", (HGPointer *)&m_funcPostDeviceLockInfo);
if (NULL == m_funcPostDeviceLockInfo)
{
ok = false;
break;
}
m_funcCreateMgr(&m_mgr);
if (NULL == m_mgr)
{
ok = false;
break;
}
}while (0);
if (!ok)
{
m_funcCreateMgr = NULL;
m_funcDestroyMgr = NULL;
m_funcGetServerConfig = NULL;
m_funcGetVersionList = NULL;
m_funcGetDriverVersionList = NULL;
m_funcBlackListCheck = NULL;
m_funcPostCrashInfo = NULL;
m_funcPostUserFeedback = NULL;
m_funcHttpDownload = NULL;
m_funcReleaseVersionList = NULL;
m_funcGetCurrVersion = NULL;
m_funcCompareVersion = NULL;
m_funcPostDeviceOpenInfo = NULL;
m_funcPostDeviceCloseInfo = NULL;
m_funcPostDeviceScanCountInfo = NULL;
m_funcPostDeviceClearRollerInfo = NULL;
m_funcPostDeviceHistroyCountInfo = NULL;
m_funcPostDeviceRollerCountInfo = NULL;
m_funcPostUserOpenInfo = NULL;
m_funcPostUserCloseInfo = NULL;
m_funcPostUserLoginInfo = NULL;
m_funcPostUserLogoutInfo = NULL;
m_funcPostDevicePaperJamInfo = NULL;
m_funcPostDeviceLockInfo = 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;
}
m_funcDestroyMgr(m_mgr);
m_mgr = NULL;
HGBase_DestroyDll(m_dll);
m_dll = NULL;
return HGBASE_ERR_OK;
}
HGBool VersionDll::IsValid()
{
return (NULL != m_dll);
}
HGResult VersionDll::GetServerConfig(HGServerConfig *config)
{
if (NULL == m_funcGetServerConfig)
{
return HGBASE_ERR_FAIL;
}
return m_funcGetServerConfig(m_mgr, config);
}
HGResult VersionDll::GetVersionList(const HGChar* appName, HGVersionInfo **info, HGUInt *count)
{
if (NULL == m_funcGetVersionList)
{
return HGBASE_ERR_FAIL;
}
return m_funcGetVersionList(m_mgr, appName, info, count);
}
HGResult VersionDll::GetDriverVersionList(const HGChar* devType, HGVersionInfo** info, HGUInt* count)
{
if (NULL == m_funcGetDriverVersionList)
{
return HGBASE_ERR_FAIL;
}
return m_funcGetDriverVersionList(m_mgr, devType, info, count);
}
HGResult VersionDll::BlackListCheck(const HGChar* devSN, HGBool* inList)
{
if (NULL == m_funcBlackListCheck)
{
return HGBASE_ERR_FAIL;
}
return m_funcBlackListCheck(m_mgr, devSN, inList);
}
HGResult VersionDll::HttpDownload(const HGChar *url, const HGChar *saveFilePath, HGHttpDownloadFunc func, HGPointer param)
{
if (NULL == m_funcHttpDownload)
{
return HGBASE_ERR_FAIL;
}
return m_funcHttpDownload(m_mgr, url, saveFilePath, func, param);
}
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);
}
HGResult VersionDll::PostCrashInfo(const HGChar* appName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr)
{
if (NULL == m_funcPostCrashInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostCrashInfo(m_mgr, appName, desc, crashFilePath, exceptionAddr);
}
HGResult VersionDll::PostUserFeedback(const HGChar* appName, const HGChar* desc, const HGChar* feedback, const HGChar* contact)
{
if (NULL == m_funcPostUserFeedback)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostUserFeedback(m_mgr, appName, desc, feedback, contact);
}
HGResult VersionDll::PostDeviceOpenInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW)
{
if (NULL == m_funcPostDeviceOpenInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceOpenInfo(m_mgr, devName, devSN, devType, devFW);
}
HGResult VersionDll::PostDeviceCloseInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW)
{
if (NULL == m_funcPostDeviceCloseInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceCloseInfo(m_mgr, devName, devSN, devType, devFW);
}
HGResult VersionDll::PostDeviceScanCountInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW, HGUInt scanCount)
{
if (NULL == m_funcPostDeviceScanCountInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceScanCountInfo(m_mgr, devName, devSN, devType, devFW, scanCount);
}
HGResult VersionDll::PostDeviceClearRollerInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW)
{
if (NULL == m_funcPostDeviceClearRollerInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceClearRollerInfo(m_mgr, devName, devSN, devType, devFW);
}
HGResult VersionDll::PostDeviceHistroyCountInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW, HGUInt histroyCount)
{
if (NULL == m_funcPostDeviceHistroyCountInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceHistroyCountInfo(m_mgr, devName, devSN, devType, devFW, histroyCount);
}
HGResult VersionDll::PostDeviceRollerCountInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW, HGUInt rollerCount)
{
if (NULL == m_funcPostDeviceRollerCountInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceRollerCountInfo(m_mgr, devName, devSN, devType, devFW, rollerCount);
}
HGResult VersionDll::PostUserOpenInfo(const HGChar *appName)
{
if (NULL == m_funcPostUserOpenInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostUserOpenInfo(m_mgr, appName);
}
HGResult VersionDll::PostUserCloseInfo(const HGChar *appName)
{
if (NULL == m_funcPostUserCloseInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostUserCloseInfo(m_mgr, appName);
}
HGResult VersionDll::PostUserLoginInfo(const HGChar *appName)
{
if (NULL == m_funcPostUserLoginInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostUserLoginInfo(m_mgr, appName);
}
HGResult VersionDll::PostUserLogoutInfo(const HGChar *appName)
{
if (NULL == m_funcPostUserLogoutInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostUserLogoutInfo(m_mgr, appName);
}
HGResult VersionDll::PostDevicePaperJamInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW)
{
if (NULL == m_funcPostDevicePaperJamInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDevicePaperJamInfo(m_mgr, devName, devSN, devType, devFW);
}
HGResult HGAPI VersionDll::PostDeviceLockInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGBool isLock)
{
if (NULL == m_funcPostDeviceLockInfo)
{
return HGBASE_ERR_FAIL;
}
return m_funcPostDeviceLockInfo(m_mgr, devName, devSN, devType, devFW, isLock);
}