You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.3 KiB
C++

#include "CDllCoreCtrl.h"
#include "QMainFilter.h"
#define _USE_LIB_CORECTRL_DLL
#ifdef _USE_LIB_CORECTRL_DLL
#include "DllLoader.h"
#else
extern "C" void* Lib_CoreCtrl_Init(void* inParam);
extern "C" void Lib_CoreCtrl_Free();
#endif
CDllCoreCtrl::CDllCoreCtrl(const ZStringList& szDllPaths, IGuiCallback* pCb, class IDetectorEngine* pDE /*= NULL*/)
{
m_szDllPaths = szDllPaths;
memset(&m_tpGlobal, 0, sizeof(m_tpGlobal));
m_tpGlobal.tgdpDllPaths = &m_szDllPaths;
if (m_szDllPaths.size() > 0)
{
strncpy(m_tpGlobal.tgdMainPath, m_szDllPaths.last().toUtf8().data(), BASE_MAX_FILE_PATH - 1);
strncpy(m_tpGlobal.tgdUserPath, m_szDllPaths.first().toUtf8().data(), BASE_MAX_FILE_PATH - 1);
strcpy(m_tpGlobal.tgdDllPath, m_tpGlobal.tgdMainPath);
}
QJsonObject jsonUser = gpCallback->IJsonUser();
QString folderStr = jsonUser.value("config").toString("config\\");
strcpy(m_tpGlobal.tgdFolderNames[TP_FOLDER_NAME_CONFIG], folderStr.toUtf8().data());
folderStr = jsonUser.value("pic").toString("pic\\");
strcpy(m_tpGlobal.tgdFolderNames[TP_FOLDER_NAME_PICTURE], folderStr.toUtf8().data());
strcpy(m_tpGlobal.tgdFolderNames[TP_FOLDER_NAME_UI], "ui\\");
CORE_CTRL_IN_PARAM inParam;
inParam.pGuiCb = pCb;
inParam.pGlobalData = &m_tpGlobal;
inParam.pCoreSetting = NULL;
#ifdef _USE_LIB_CORECTRL_DLL
m_pLibCoreCtrl = new CDllLoaderM("tpCoreCtrl", "Lib_CoreCtrl_Init", "Lib_CoreCtrl_Free", m_szDllPaths);
if (NULL != m_pLibCoreCtrl)
{
m_pCoreCtrl = (ICoreCtrl*)m_pLibCoreCtrl->ModuleInit(&inParam);
if (NULL != m_pCoreCtrl)
{
m_pCoreCtrl->IInitCore(pDE);
}
else
{
tpDebugOut("failed to get instance from tpCoreCtrl.dll");
}
}
else
{
tpDebugOut("failed to load tpCoreCtrl.dll");
}
#else
m_pLibCoreCtrl = NULL;
m_pCoreCtrl = (ICoreCtrl*)Lib_CoreCtrl_Init(&inParam);
#endif
}
CDllCoreCtrl::~CDllCoreCtrl()
{
if (NULL != m_pCoreCtrl)
{
m_pCoreCtrl->IFreeCore();
#ifdef _USE_LIB_CORECTRL_DLL
if (NULL != m_pLibCoreCtrl)
{
m_pLibCoreCtrl->ModuleFree();
}
#else
Lib_CoreCtrl_Free();
#endif
m_pCoreCtrl = NULL;
}
if (NULL != m_pLibCoreCtrl)
{
delete m_pLibCoreCtrl;
m_pLibCoreCtrl = NULL;
}
}