Browse Source

Z991239-527 #comment fix: Linux 下编译 mod_PinPad 实体

gifur 5 years ago
parent
commit
77817d1ffb

+ 3 - 4
Module/mod_pinpad/CMakeLists.txt

@@ -11,6 +11,7 @@ add_module_libraries(${MODULE_PREFIX} ${MODULE_NAME} ${MOD_VERSION_STRING})
 
 
 target_include_directories(${MODULE_NAME} PRIVATE
 target_include_directories(${MODULE_NAME} PRIVATE
 	${DevHeadPath}
 	${DevHeadPath}
+	${RVC_TOOLKIT_INCLUDE_DIR}
 	${ModuleCommonHeadPath}
 	${ModuleCommonHeadPath}
 	${MODULE_BASE_DIR}/mod_heartbeat
 	${MODULE_BASE_DIR}/mod_heartbeat
 )
 )
@@ -19,9 +20,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES
 COMPILE_DEFINITIONS "MOD_PINPAD_EXPORTS")
 COMPILE_DEFINITIONS "MOD_PINPAD_EXPORTS")
 
 
 # 添加实体需要依赖的其他共享库(包括系统库)
 # 添加实体需要依赖的其他共享库(包括系统库)
-set(${MODULE_PREFIX}_LIBS spbase)
-target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
-
-
+set(${MODULE_PREFIX}_LIBS)
+target_link_libraries(${MODULE_NAME} ${MODULE_BASE_LIBS} ${${MODULE_PREFIX}_LIBS})
 
 
 deploy_module(${MODULE_PREFIX} ${MODULE_NAME})
 deploy_module(${MODULE_PREFIX} ${MODULE_NAME})

+ 15 - 55
Module/mod_pinpad/PinPadFSM.cpp

@@ -6,8 +6,15 @@
 #include "ModuleMix.h"
 #include "ModuleMix.h"
 #include "PinPad_UserErrorCode.h"
 #include "PinPad_UserErrorCode.h"
 #include "CommDevEntityErrorCode.h"
 #include "CommDevEntityErrorCode.h"
+#include "mod_DevAdptEntityBase.hpp"
 #include <map>
 #include <map>
 #include <thread>
 #include <thread>
+#include "path.h"
+
+#include <winpr/library.h>
+#include <winpr/sysinfo.h>
+#include <winpr/thread.h>
+
 using namespace std;
 using namespace std;
 
 
 const int PINPAD_INIT_TRIES = 3;
 const int PINPAD_INIT_TRIES = 3;
@@ -15,29 +22,13 @@ const int PINPAD_ANY_INPUT_TIMER = 1;
 const int PINPAD_ANY_INPUT_TIMEOUT = 100;
 const int PINPAD_ANY_INPUT_TIMEOUT = 100;
 const int MAX_PINPAD_INPUT_TIMEOUT = 60000;
 const int MAX_PINPAD_INPUT_TIMEOUT = 60000;
 const int MAX_INPUT_TIMER_TIMEOUT = 600000;
 const int MAX_INPUT_TIMER_TIMEOUT = 600000;
-//#pragma comment(lib,"../../dev/PinPad/PinPad.lib")
-bool isnostr(const char *str)
-{
-	int len = strlen(str);
-	if (len == 0)
-		return true;
-	for (int i = 0; i < len; ++i)
-	{
-		if (*(str+i) != ' ')
-			return false;
-	}
-	return true;
-}
+
 ErrorCodeEnum CPinPadFSM::OnInit()
 ErrorCodeEnum CPinPadFSM::OnInit()
 {
 {
 	LOG_FUNCTION();
 	LOG_FUNCTION();
-	/*------2020-02-13-------*/
-	//modify by LZM
-	if (VendorLogControler(this,"PinPad")!=Error_Succeed)
-	{
-		Dbg("VendorLogControler Failed...");
-	}
-	/*-----------------------*/
+	auto devEntity = dynamic_cast<CDevAdptEntityBase*>(GetEntityBase());
+	devEntity->InitializeVendorLogSwitch();
+
 	CSystemStaticInfo sysInfo;
 	CSystemStaticInfo sysInfo;
 
 
 	m_csMachineType = m_csSite = m_terminalNo = "";
 	m_csMachineType = m_csSite = m_terminalNo = "";
@@ -396,8 +387,10 @@ int CPinPadFSM::Initial()
 		Dbg("is RVC.IL.");
 		Dbg("is RVC.IL.");
 		return 0;
 		return 0;
 	}
 	}
+#ifdef _WIN32
 	DWORD dwCurrThId = GetCurrentThreadId();
 	DWORD dwCurrThId = GetCurrentThreadId();
-	Dbg("Initial thread id:%d",dwCurrThId);
+	Dbg("Initial thread id:%d", dwCurrThId);
+#endif //_WIN32
 	ErrorCodeEnum eErrDev;
 	ErrorCodeEnum eErrDev;
 
 
 	CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
 	CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
@@ -410,7 +403,7 @@ int CPinPadFSM::Initial()
 	}
 	}
 
 
 
 
-	CSimpleStringA dllName,tmpVendor(""), tmpDevSN(""), tmpDLLVersion(""), csDepPath(""), csBackslash("\\");
+	CSimpleStringA dllName,tmpVendor(""), tmpDevSN(""), tmpDLLVersion(""), csDepPath(""), csBackslash(SPLIT_SLASH_STR);
 	GetEntityBase()->GetFunction()->GetSysVar("FWBVendor", tmpVendor);
 	GetEntityBase()->GetFunction()->GetSysVar("FWBVendor", tmpVendor);
 	GetEntityBase()->GetFunction()->GetSysVar("FWBDevSN", tmpDevSN);
 	GetEntityBase()->GetFunction()->GetSysVar("FWBDevSN", tmpDevSN);
 	GetEntityBase()->GetFunction()->GetSysVar("FWBVersion", tmpDLLVersion);
 	GetEntityBase()->GetFunction()->GetSysVar("FWBVersion", tmpDLLVersion);
@@ -451,39 +444,6 @@ int CPinPadFSM::Initial()
 	spConfig->ReadConfigValue("Device.PinPad", "Keysn", m_keySN);
 	spConfig->ReadConfigValue("Device.PinPad", "Keysn", m_keySN);
 	spConfig->ReadConfigValue("Device.PinPad", "KeysnSM", m_keySNSM);
 	spConfig->ReadConfigValue("Device.PinPad", "KeysnSM", m_keySNSM);
 	Dbg("to load vendor dll.");
 	Dbg("to load vendor dll.");
-	//ErrorCodeEnum Error;
-	//CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
-	//CSmartPointer<IConfigInfo> spConfig;
-	//Error = spEntityFunction->OpenConfig(Config_Root, spConfig);
-	//if (Error != Error_Succeed) {
-	//	LOG_TRACE("open cfg file failed!");
-	//	return Error;
-	//}
-	//CSimpleStringA dllName,devName,devVendor,devVer,devBatch,dllSuffix;
-	//dllName = devName = "PinPad";
-	//dllSuffix = ".dll";
-	//devVendor = devVer = devBatch = "";
-	//spConfig->ReadConfigValue("Device.PinPad","Vendor",devVendor);
-	//spConfig->ReadConfigValue("Device.PinPad","Version",devVer);
-	//spConfig->ReadConfigValue("Device.PinPad","Batch",devBatch);
-
-	//Dbg("[%s],[%s],[%s]",(LPCSTR)devVendor,(LPCSTR)devVer,(LPCSTR)devBatch);
-	//CSimpleStringA csDepPath,csBackslash("\\");
-	//ErrorCodeEnum eErrDep = GetEntityBase()->GetFunction()->GetPath("Dep", csDepPath);
-	//if (eErrDep != Error_Succeed)
-	//{
-	//	Dbg("GetBasePath failed (%d).",eErrDep);
-	//	return Error_Param;
-	//}
-	//dllName = csDepPath + csBackslash + dllName;	
-	//if (!isnostr(devVendor.GetData()))
-	//	dllName = dllName + "." + devVendor;
-	//if (!isnostr(devVer.GetData()))
-	//	dllName = dllName + "." +  devVer;
-	//if (!isnostr(devBatch.GetData()))
-	//	dllName = dllName + "." +  devBatch;
-	//dllName += dllSuffix;
-	//Dbg("dllName:[%s]",dllName);
 	m_hVerdorDll = LoadLibraryA(dllName);
 	m_hVerdorDll = LoadLibraryA(dllName);
 	if (m_hVerdorDll == NULL)
 	if (m_hVerdorDll == NULL)
 	{
 	{

+ 2 - 1
Module/mod_pinpad/PinPadFSM.h

@@ -265,7 +265,7 @@ public:
 	void PushInputChar(char *buf, int c);
 	void PushInputChar(char *buf, int c);
 	void pop_char(char *buf, int *len,bool bClear=true);
 	void pop_char(char *buf, int *len,bool bClear=true);
 	void clear_char(char *buf, int *len);
 	void clear_char(char *buf, int *len);
-	bool CPinPadFSM::Get12Account(char *szAcc);
+	bool Get12Account(char *szAcc);
 	void OpenInputText(void *pUserdata);
 	void OpenInputText(void *pUserdata);
 	ErrorCodeEnum GetText(SpReqAnsContext<PinPadService_GetInput_Req, PinPadService_GetInput_Ans>::Pointer ctx
 	ErrorCodeEnum GetText(SpReqAnsContext<PinPadService_GetInput_Req, PinPadService_GetInput_Ans>::Pointer ctx
 		,SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadService_GetInputSM_Ans>::Pointer ctxSM,bool bSM=false);
 		,SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadService_GetInputSM_Ans>::Pointer ctxSM,bool bSM=false);
@@ -373,6 +373,7 @@ private:
 	bool m_bDevInit,m_bFrontCancel,m_bWaitingMore,m_bExit,m_bPlainPin,m_bEntityExit
 	bool m_bDevInit,m_bFrontCancel,m_bWaitingMore,m_bExit,m_bPlainPin,m_bEntityExit
 		,m_bPinInput,m_bPlainOpen,m_bLoadKey,m_bEncrypt,m_bSM,m_b3DESLoaded,m_bSMLoaded,m_bInMainPage
 		,m_bPinInput,m_bPlainOpen,m_bLoadKey,m_bEncrypt,m_bSM,m_b3DESLoaded,m_bSMLoaded,m_bInMainPage
 		, m_bRVCIL;
 		, m_bRVCIL;
+
 	PinPadClass* m_pPinPad;
 	PinPadClass* m_pPinPad;
 	CSimpleStringA m_deviceNo,m_devCheckData,m_keySN,m_keySNSM,m_szModel,m_szType,m_szVendor;
 	CSimpleStringA m_deviceNo,m_devCheckData,m_keySN,m_keySNSM,m_szModel,m_szType,m_szVendor;
 	char m_buf[4];
 	char m_buf[4];

+ 1 - 1
Module/mod_pinpad/PinPad_common.h

@@ -1,7 +1,7 @@
 #ifndef __PINPAD_COMMON_H
 #ifndef __PINPAD_COMMON_H
 #define __PINPAD_COMMON_H
 #define __PINPAD_COMMON_H
 
 
-#include "spHelper.h"
+#include "SpHelper.h"
 
 
 namespace PinPad {
 namespace PinPad {
 //
 //

+ 1 - 1
Module/mod_pinpad/PinPad_def_g.h

@@ -5,7 +5,7 @@
 
 
 // This code is generated by spgen tool!
 // This code is generated by spgen tool!
 
 
-#include "spHelper.h"
+#include "SpHelper.h"
 
 
 namespace PinPad {
 namespace PinPad {
 //
 //

+ 1 - 1
Module/mod_pinpad/PinPad_msg_g.h

@@ -6,7 +6,7 @@
 
 
 // This code is generated by spgen tool!
 // This code is generated by spgen tool!
 
 
-#include "spHelper.h"
+#include "SpHelper.h"
 
 
 namespace PinPad {
 namespace PinPad {
 #define eMsg_InputContent 0
 #define eMsg_InputContent 0

+ 2 - 6
Module/mod_pinpad/mod_PinPad.h

@@ -3,6 +3,7 @@
 
 
 #include "SpBase.h"
 #include "SpBase.h"
 #include "PinPadFSM.h"
 #include "PinPadFSM.h"
+#include "mod_DevAdptEntityBase.hpp"
 
 
 class PinPadServerSession : public PinPad::PinPadService_ServerSessionBase
 class PinPadServerSession : public PinPad::PinPadService_ServerSessionBase
 {
 {
@@ -27,7 +28,7 @@ private:
 	CPinPadEntity* m_pEntity;
 	CPinPadEntity* m_pEntity;
 };
 };
 
 
-class CPinPadEntity : public CEntityBase, public ISysVarListener
+class CPinPadEntity : public CDevAdptEntityBase, public ISysVarListener
 {
 {
 public:
 public:
 	CPinPadEntity():m_state(-1){}
 	CPinPadEntity():m_state(-1){}
@@ -68,11 +69,6 @@ public:
 		LOG_FUNCTION();
 		LOG_FUNCTION();
 		return Error_Succeed;
 		return Error_Succeed;
 	}
 	}
-	//virtual ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
-	//{
-
-	//	return Error_Succeed;
-	//}
 
 
 	virtual CServerSessionBase* OnNewSession(const char*,const char*)
 	virtual CServerSessionBase* OnNewSession(const char*,const char*)
 	{
 	{

+ 17 - 9
module/CMakeLists.txt

@@ -5,6 +5,11 @@ macro(define_moudle _module_name)
 	string(TOUPPER "${MODULE_NAME}" MODULE_PREFIX)
 	string(TOUPPER "${MODULE_NAME}" MODULE_PREFIX)
 endmacro(define_moudle)
 endmacro(define_moudle)
 
 
+set(MODULE_BASE_LIBS spbase libtoolkit)
+if(NOT MSVC)
+    list(APPEND MODULE_BASE_LIBS winpr)
+endif(NOT MSVC)
+
 #对于 Windows 设置实体的版本信息
 #对于 Windows 设置实体的版本信息
 #定义共享库输出
 #定义共享库输出
 macro(add_module_libraries _module_prefix _module_name _module_version)
 macro(add_module_libraries _module_prefix _module_name _module_version)
@@ -71,16 +76,19 @@ macro(deploy_module _module_prefix _module_name)
     set_property(TARGET ${_module_name} PROPERTY FOLDER "module/")
     set_property(TARGET ${_module_name} PROPERTY FOLDER "module/")
 endmacro(deploy_module)
 endmacro(deploy_module)
 
 
+
+add_subdirectory(mod_pinpad)
+
 # 遍历实体
 # 遍历实体
-file(GLOB all_valid_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt")
-
-foreach(dir ${all_valid_subdirs})
-	if(${dir} MATCHES "^([^/]*)/+CMakeLists.txt")
-		string(REGEX REPLACE "^([^/]*)/+CMakeLists.txt" "\\1" dir_trimmed ${dir})
-		message(STATUS "add module ${dir_trimmed}")
-		add_subdirectory(${dir_trimmed})
-	endif()
-endforeach(dir)
+# file(GLOB all_valid_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt")
+
+# foreach(dir ${all_valid_subdirs})
+# 	if(${dir} MATCHES "^([^/]*)/+CMakeLists.txt")
+# 		string(REGEX REPLACE "^([^/]*)/+CMakeLists.txt" "\\1" dir_trimmed ${dir})
+# 		message(STATUS "add module ${dir_trimmed}")
+# 		add_subdirectory(${dir_trimmed})
+# 	endif()
+# endforeach(dir)