|
@@ -2,166 +2,166 @@
|
|
|
#include "DeviceControlFSM.h"
|
|
|
#include "GetDevInfoHelper.h"
|
|
|
#include "EventCode.h"
|
|
|
+#include "fileutil.h"
|
|
|
+
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+static const char DEFAULT_ADAPTER_LIBRARY_NAME[] = "DeviceControl.cmbsz.1.1.dll";
|
|
|
+#else
|
|
|
+static const char DEFAULT_ADAPTER_LIBRARY_NAME[] = "libDeviceControl.cmbsz.1.1.so";
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
+namespace
|
|
|
+{
|
|
|
+bool IsNeedOpenUsb(CEntityBase* pCallerEntity)
|
|
|
+{
|
|
|
+ bool result = false;
|
|
|
+ ErrorCodeEnum errCode = Error_Unexpect;
|
|
|
+ CSystemStaticInfo sysDevInfo;
|
|
|
+ errCode = pCallerEntity->GetFunction()->GetSystemStaticInfo(sysDevInfo);
|
|
|
+ if (errCode != Error_Succeed) {
|
|
|
+ Dbg("get device info failed while judge open usb or not");
|
|
|
+ } else {
|
|
|
+ CSimpleStringA strMachineType;
|
|
|
+ strMachineType = sysDevInfo.strMachineType;
|
|
|
+ WORD majorVersion = sysDevInfo.MachineVersion.GetMajor();
|
|
|
+ WORD minorVersion = sysDevInfo.MachineVersion.GetMinor();
|
|
|
+ CSimpleStringA machineVersion = CSimpleStringA::Format("%d.%d", majorVersion, minorVersion);
|
|
|
+ Dbg("MachineType:%s, machineVersion:%s", strMachineType.GetData(), machineVersion.GetData());
|
|
|
+
|
|
|
+ if (!strMachineType.Compare("RVC.PAD", true)
|
|
|
+ || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("1.0"))) {
|
|
|
+ result = false;
|
|
|
+ } else if (!strMachineType.Compare("RVC.Stand2S", true) || !strMachineType.Compare("RVC.CardStore", true)
|
|
|
+ || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.0"))
|
|
|
+ || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.1"))
|
|
|
+ || (!strMachineType.Compare("RVC.Desk1S", true) && !machineVersion.Compare("1.0"))) {
|
|
|
+ result = true;
|
|
|
+ } else {
|
|
|
+ //TODO:: if add new machine type
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+}
|
|
|
|
|
|
ErrorCodeEnum CDeviceControlFSM::OnInit()
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
- /*------2020-02-27------*/
|
|
|
- //modify by LZM
|
|
|
- VendorLogControler(this,"DeviceControl");
|
|
|
- /*---------------------*/
|
|
|
- HRESULT hr;
|
|
|
- int initTries = 0;
|
|
|
- bool bClosePort = false;
|
|
|
- ErrorCodeEnum eErr;
|
|
|
+ LOG_FUNCTION();
|
|
|
+ ErrorCodeEnum eErr;
|
|
|
+ GET_DEV_ENTITY_BASE_POINTER()->InitializeVendorLogSwitch();
|
|
|
+ Dbg("Source Code complied at: %s %s", __DATE__, __TIME__);
|
|
|
|
|
|
m_csMachineType = "RVC.PAD";
|
|
|
+ CSmartPointer<IConfigInfo> spConfig;
|
|
|
CSystemStaticInfo sysInfo;
|
|
|
- eErr = GetEntityBase()->GetFunction()->GetSystemStaticInfo(sysInfo);
|
|
|
- if (eErr != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("Get System Static info failed(%d).", eErr);
|
|
|
+ CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
|
|
|
+ eErr = spEntityFunction->GetSystemStaticInfo(sysInfo);
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ Dbg("Get System Static info failed: %s.", SpStrError(eErr));
|
|
|
+ return eErr;
|
|
|
}
|
|
|
+ eErr = spEntityFunction->OpenConfig(Config_Root, spConfig);
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ Dbg("open cfg file failed: %s.", SpStrError(eErr));
|
|
|
+ return eErr;
|
|
|
+ }
|
|
|
+
|
|
|
m_csMachineType = sysInfo.strMachineType;
|
|
|
Dbg("machine type:%s",(LPCTSTR)m_csMachineType);
|
|
|
CSimpleStringA dllName, tmpDevSN("");
|
|
|
- GetEntityBase()->GetFunction()->GetSysVar("FWBDevSN", tmpDevSN);
|
|
|
- if (tmpDevSN.GetLength() > 12 && tmpDevSN.IndexOf("FWB") > 2)
|
|
|
- m_bFWB = true;
|
|
|
- CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
|
|
|
- CSmartPointer<IConfigInfo> spConfig;
|
|
|
+ spEntityFunction->GetSysVar("FWBDevSN", tmpDevSN);
|
|
|
+ m_bFWB = (tmpDevSN.GetLength() > 12 && tmpDevSN.IndexOf("FWB") > 2);
|
|
|
if (strnicmp(m_csMachineType, "RVC.PAD", strlen("RVC.PAD")) != 0 || m_bFWB)
|
|
|
{
|
|
|
CSimpleStringA csDepPath("");
|
|
|
- eErr = GetEntityBase()->GetFunction()->GetPath("Dep", csDepPath);
|
|
|
+ eErr = spEntityFunction->GetPath("Dep", csDepPath);
|
|
|
if (eErr == Error_Succeed)
|
|
|
{
|
|
|
Dbg("not RVC.PAD or is FWB(%d),to use default dll.", m_bFWB);
|
|
|
- CSimpleStringA csBackslash("\\");
|
|
|
- dllName = csDepPath + csBackslash + "DeviceControl.cc.1.1.dll";
|
|
|
+ dllName = csDepPath + SPLIT_SLASH_STR;
|
|
|
+ dllName += DEFAULT_ADAPTER_LIBRARY_NAME;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- eErr = SpGetDevAdaptorPath(m_pEntity, GetEntityBase()->GetEntityName(), dllName);
|
|
|
+ auto pEntity = GET_DEV_ENTITY_BASE_POINTER();
|
|
|
+ eErr = pEntity->ExtractVendorLibFullPath(dllName);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("load vendor dll(%s) failed.", (LPCTSTR)dllName);
|
|
|
return Error_DevLoadFileFailed;
|
|
|
}
|
|
|
Dbg("%s", (LPCTSTR)dllName);
|
|
|
- eErr = spEntityFunction->OpenConfig(Config_Root, spConfig);
|
|
|
- if (eErr != Error_Succeed) {
|
|
|
- Dbg("open cfg file failed!");
|
|
|
- return eErr;
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
- m_hVerdorDll = LoadLibraryA(dllName);
|
|
|
- if (m_hVerdorDll == NULL)
|
|
|
+ eErr = m_hDevHelper.LoadUp(dllName);
|
|
|
+ if (eErr != Error_Succeed)
|
|
|
{
|
|
|
- Dbg("Load dll failed.%d",GetLastError());
|
|
|
+ Dbg("Load dll failed.%s", SpStrError(eErr));
|
|
|
return Error_DevLoadFileFailed;
|
|
|
}
|
|
|
- else
|
|
|
+ else {
|
|
|
Dbg("load vendor dll suc.");
|
|
|
- if ((CreateDevComponent = (lpCreateDevCom)GetProcAddress(m_hVerdorDll,"CreateDevComponent")) == NULL)
|
|
|
- {
|
|
|
- Dbg("Get CreateDevComponent failed.");
|
|
|
- return Error_DevLoadFileFailed;
|
|
|
- }
|
|
|
- if ((ReleaseDevComponent = (lpReleaseDevCom)GetProcAddress(m_hVerdorDll,"ReleaseDevComponent")) == NULL)
|
|
|
- {
|
|
|
- Dbg("Get ReleaseDevComponent failed.");
|
|
|
- return Error_DevLoadFileFailed;
|
|
|
}
|
|
|
- CSimpleStringA csDepPath("");
|
|
|
-
|
|
|
- eErr = GetEntityBase()->GetFunction()->GetPath("Dep", csDepPath);
|
|
|
- if (eErr != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("Get dep Path failed (%d).",eErr);
|
|
|
- //return Error_Param;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CSimpleStringA csAQUkeyDll,csBackslash("\\");
|
|
|
- csAQUkeyDll = csDepPath + csBackslash + "token.dll";
|
|
|
- m_hVerdorDll = LoadLibraryA(csAQUkeyDll);
|
|
|
- if (m_hVerdorDll == NULL)
|
|
|
- {
|
|
|
- Dbg("Load aq dll failed.%d",GetLastError());
|
|
|
- return Error_DevLoadFileFailed;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if ((AQGetUKeyID = (lpGetUKeyID)GetProcAddress(m_hVerdorDll,"GetUKeyID")) == NULL)
|
|
|
- {
|
|
|
- Dbg("Get GetUKeyID failed.");
|
|
|
- return Error_DevLoadFileFailed;
|
|
|
- }
|
|
|
- if ((AQInitToken = (lpInitToken)GetProcAddress(m_hVerdorDll,"InitToken")) == NULL)
|
|
|
- {
|
|
|
- Dbg("Get InitToken failed.");
|
|
|
- return Error_DevLoadFileFailed;
|
|
|
- }
|
|
|
- Dbg("Load aq suc.");
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ InitializeTokenLib();
|
|
|
|
|
|
if (strnicmp(m_csMachineType, "RVC.PAD", strlen("RVC.PAD")) == 0 && !m_bFWB)//RVC.PAD to read root.ini
|
|
|
{
|
|
|
int baudRate, port;
|
|
|
-
|
|
|
spConfig->ReadConfigValueInt("Device.DeviceControl", "Baudrate", baudRate);
|
|
|
spConfig->ReadConfigValueInt("Device.DeviceControl", "Port", port);
|
|
|
- do{
|
|
|
- if (m_pDevCtrl == NULL)
|
|
|
- {
|
|
|
- if (CreateDevComponent((DeviceBaseClass *&)m_pDevCtrl) != Error_Succeed)
|
|
|
- {
|
|
|
- LOG_TRACE("创建设备控制模块失败");
|
|
|
- initTries++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- Dbg("%d,%d", port, baudRate);
|
|
|
- eErr = m_pDevCtrl->DevOpen(port, baudRate);
|
|
|
- if (eErr != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("打开设备失败");
|
|
|
- return Error_DevConnFailed;
|
|
|
- }
|
|
|
- Dbg("打开设备成功.");
|
|
|
- //m_pDevCtrl->PortControl(USB_PORT_ENABLE);
|
|
|
- break;
|
|
|
-
|
|
|
- } while (initTries < 3);
|
|
|
- }
|
|
|
-
|
|
|
- // 不是大机,打开USB
|
|
|
- // by XKM @20151112
|
|
|
- //修改为:是PAD才打开USB by oilyang 20160621
|
|
|
- if (strnicmp(m_csMachineType, "RVC.PAD", strlen("RVC.PAD")) ==0 && !m_bFWB)
|
|
|
- {
|
|
|
- m_pDevCtrl->PortControl(USB_PORT_ENABLE);
|
|
|
+ eErr = m_hDevHelper->DevOpen(port, baudRate);
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ Dbg("打开设备失败");
|
|
|
+ return Error_DevConnFailed;
|
|
|
+ }
|
|
|
+ m_hDevHelper->PortControl(USB_PORT_ENABLE);
|
|
|
}
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
-ErrorCodeEnum CDeviceControlFSM::OnExit()
|
|
|
-{
|
|
|
- return Error_Succeed;
|
|
|
-}
|
|
|
|
|
|
-void CDeviceControlFSM::s0_on_entry()
|
|
|
+ErrorCodeEnum CDeviceControlFSM::InitializeTokenLib()
|
|
|
{
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+
|
|
|
+ CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
|
|
|
+ CSimpleStringA csDepPath("");
|
|
|
+ ErrorCodeEnum eErr = spEntityFunction->GetPath("Dep", csDepPath);
|
|
|
+ if (eErr == Error_Succeed) {
|
|
|
+ CSimpleStringA csAQUkeyDll, csBackslash("\\");
|
|
|
+ csAQUkeyDll = csDepPath + csBackslash + "token.dll";
|
|
|
+ m_hTokenDll = LoadLibraryA(csAQUkeyDll);
|
|
|
+ if (m_hTokenDll == NULL) {
|
|
|
+ Dbg("Load aq dll failed.%d", GetLastError());
|
|
|
+ return Error_DevLoadFileFailed;
|
|
|
+ } else {
|
|
|
+ if ((AQGetUKeyID = (lpGetUKeyID)GetProcAddress(m_hTokenDll, "GetUKeyID")) == NULL) {
|
|
|
+ Dbg("Get GetUKeyID failed.");
|
|
|
+ return Error_DevLoadFileFailed;
|
|
|
+ }
|
|
|
+ if ((AQInitToken = (lpInitToken)GetProcAddress(m_hTokenDll, "InitToken")) == NULL) {
|
|
|
+ Dbg("Get InitToken failed.");
|
|
|
+ return Error_DevLoadFileFailed;
|
|
|
+ }
|
|
|
+ Dbg("Load aq suc.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return eErr;
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+ return Error_NotSupport;
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
|
|
|
}
|
|
|
-void CDeviceControlFSM::s0_on_exit()
|
|
|
-{
|
|
|
|
|
|
+ErrorCodeEnum CDeviceControlFSM::OnExit()
|
|
|
+{
|
|
|
+ return Error_Succeed;
|
|
|
}
|
|
|
+
|
|
|
unsigned int CDeviceControlFSM::s0_on_event(FSMEvent* pEvt)
|
|
|
{
|
|
|
Dbg("s0 event %d,%d",pEvt->iEvt,pEvt->param1);
|
|
@@ -216,14 +216,6 @@ unsigned int CDeviceControlFSM::s0_on_event(FSMEvent* pEvt)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void CDeviceControlFSM::s1_on_entry()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-void CDeviceControlFSM::s1_on_exit()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
unsigned int CDeviceControlFSM::s1_on_event(FSMEvent* pEvt)
|
|
|
{
|
|
|
Dbg("s1 %d,%d",pEvt->iEvt,pEvt->param1);
|
|
@@ -241,27 +233,6 @@ unsigned int CDeviceControlFSM::s1_on_event(FSMEvent* pEvt)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void CDeviceControlFSM::s2_on_entry()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-void CDeviceControlFSM::s2_on_exit()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-unsigned int CDeviceControlFSM::s2_on_event(FSMEvent* pEvt)
|
|
|
-{
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-void CDeviceControlFSM::s3_on_entry()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-void CDeviceControlFSM::s3_on_exit()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
//GetUkeyID
|
|
|
unsigned int CDeviceControlFSM::s3_on_event(FSMEvent* pEvt)
|
|
|
{
|
|
@@ -276,15 +247,8 @@ unsigned int CDeviceControlFSM::s3_on_event(FSMEvent* pEvt)
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
-//InitToken
|
|
|
-void CDeviceControlFSM::s4_on_entry()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-void CDeviceControlFSM::s4_on_exit()
|
|
|
-{
|
|
|
|
|
|
-}
|
|
|
+//InitToken
|
|
|
unsigned int CDeviceControlFSM::s4_on_event(FSMEvent* pEvt)
|
|
|
{
|
|
|
Dbg("s4 %d,%d",pEvt->iEvt,pEvt->param1);
|
|
@@ -301,48 +265,27 @@ unsigned int CDeviceControlFSM::s4_on_event(FSMEvent* pEvt)
|
|
|
int CDeviceControlFSM::UsbControl(SpReqAnsContext<DeviceControlService_USB_Req,DeviceControlService_USB_Ans>::Pointer ctx)
|
|
|
{
|
|
|
Dbg("open %d",ctx->Req.open);
|
|
|
- ControlType eType;
|
|
|
- bool bIsNeedOpenUsb = true;
|
|
|
|
|
|
- if(Error_Succeed != IsNeedOpenUsb(m_pEntity, bIsNeedOpenUsb)){
|
|
|
- Dbg("usb control failed: get device info failed.");
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ const bool bIsNeedOpenUsb = IsNeedOpenUsb(m_pEntity);
|
|
|
if(!bIsNeedOpenUsb){
|
|
|
Dbg("no need open/close usb, this machine's usb is always open.");
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 0;
|
|
|
- }
|
|
|
|
|
|
- if (ctx->Req.open)
|
|
|
- {
|
|
|
- eType = USB_PORT_ENABLE;
|
|
|
- LogEvent(Severity_Middle,LOG_EVT_USB_CONTROL_ON,"usb on");//control by gpio
|
|
|
- LogEvent(Severity_Middle,LOG_EVT_USB_LIGHT_ON,"usb on");//control by gpio
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- eType = USB_PORT_DISABLE;
|
|
|
- LogEvent(Severity_Middle,LOG_EVT_USB_CONTROL_OFF,"usb off");//control by gpio
|
|
|
- LogEvent(Severity_Middle,LOG_EVT_USB_LIGHT_OFF,"usb off");//control by gpio
|
|
|
+ } else {
|
|
|
+
|
|
|
+ ControlType eType;
|
|
|
+ if (ctx->Req.open) {
|
|
|
+ eType = USB_PORT_ENABLE;
|
|
|
+ LogEvent(Severity_Middle, LOG_EVT_USB_CONTROL_ON, "usb on");//control by gpio
|
|
|
+ LogEvent(Severity_Middle, LOG_EVT_USB_LIGHT_ON, "usb on");//control by gpio
|
|
|
+ } else {
|
|
|
+ eType = USB_PORT_DISABLE;
|
|
|
+ LogEvent(Severity_Middle, LOG_EVT_USB_CONTROL_OFF, "usb off");//control by gpio
|
|
|
+ LogEvent(Severity_Middle, LOG_EVT_USB_LIGHT_OFF, "usb off");//control by gpio
|
|
|
+ }
|
|
|
}
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 0;
|
|
|
|
|
|
- /*if (_strnicmp(m_csMachineType,"RVC.PAD",strlen("RVC.PAD")) != 0 || m_bFWB)
|
|
|
- {
|
|
|
- Dbg("not rvc.pad");
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
return 0;
|
|
|
- }
|
|
|
- ErrorCodeEnum eErr = m_pDevCtrl->PortControl(eType);
|
|
|
- if (eErr != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("usb control failed %d.",eErr);
|
|
|
- return 1;
|
|
|
- }
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 0;*/
|
|
|
}
|
|
|
|
|
|
int CDeviceControlFSM::GetUkeyIDx(SpReqAnsContext<DeviceControlService_GetUkeyID_Req, DeviceControlService_GetUkeyID_Ans>::Pointer ctx)
|
|
@@ -354,27 +297,30 @@ int CDeviceControlFSM::GetUkeyIDx(SpReqAnsContext<DeviceControlService_GetUkeyID
|
|
|
ctx->Answer(Error_Null);
|
|
|
return 1;
|
|
|
}
|
|
|
- char pID[512];
|
|
|
- ZeroMemory(pID,512);
|
|
|
- int tmp = 512;
|
|
|
- int ret = AQGetUKeyID(pID,tmp);
|
|
|
- m_bWorkingOp = false;
|
|
|
- if (ret == 0)
|
|
|
- {
|
|
|
- ctx->Ans.UkeyID = pID;
|
|
|
- ctx->Ans.UkeyIDLen = strlen(pID);
|
|
|
- Dbg("oiltest ukey id [%d][%s][%d]",tmp,(LPCTSTR)ctx->Ans.UkeyID,ctx->Ans.UkeyIDLen);
|
|
|
- ctx->Ans.reserved1 = 999;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("GetUKey failed.%d,%d",ret,GetLastError());
|
|
|
- ctx->Ans.reserved1 = ret;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 1;
|
|
|
- }
|
|
|
+
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ char pID[512];
|
|
|
+ ZeroMemory(pID, 512);
|
|
|
+ int tmp = 512;
|
|
|
+ int ret = AQGetUKeyID(pID, tmp);
|
|
|
+ m_bWorkingOp = false;
|
|
|
+ if (ret == 0) {
|
|
|
+ ctx->Ans.UkeyID = pID;
|
|
|
+ ctx->Ans.UkeyIDLen = strlen(pID);
|
|
|
+ Dbg("oiltest ukey id [%d][%s][%d]", tmp, (LPCTSTR)ctx->Ans.UkeyID, ctx->Ans.UkeyIDLen);
|
|
|
+ ctx->Ans.reserved1 = 999;
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ return 0;
|
|
|
+ } else {
|
|
|
+ Dbg("GetUKey failed.%d,%d", ret, GetLastError());
|
|
|
+ ctx->Ans.reserved1 = ret;
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+#else
|
|
|
+ ctx->Answer(Error_NotSupport);
|
|
|
+ return 1;
|
|
|
+#endif //RVC_OS_WIN
|
|
|
}
|
|
|
int CDeviceControlFSM::InitTokenx(SpReqAnsContext<DeviceControlService_InitToken_Req, DeviceControlService_InitToken_Ans>::Pointer ctx)
|
|
|
{
|
|
@@ -385,55 +331,60 @@ int CDeviceControlFSM::InitTokenx(SpReqAnsContext<DeviceControlService_InitToken
|
|
|
ctx->Answer(Error_Null);
|
|
|
return 1;
|
|
|
}
|
|
|
- int tokensnlen,pkcs10len,msglen;
|
|
|
- tokensnlen = 32;
|
|
|
- pkcs10len = 2048;
|
|
|
- msglen = 128;
|
|
|
- char tokenSn[32],pkcs10[2048],msg[128];
|
|
|
- ZeroMemory(tokenSn,tokensnlen);
|
|
|
- ZeroMemory(pkcs10,pkcs10len);
|
|
|
- ZeroMemory(msg,msglen);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ int tokensnlen, pkcs10len, msglen;
|
|
|
+ tokensnlen = 32;
|
|
|
+ pkcs10len = 2048;
|
|
|
+ msglen = 128;
|
|
|
+ char tokenSn[32], pkcs10[2048], msg[128];
|
|
|
+ ZeroMemory(tokenSn, tokensnlen);
|
|
|
+ ZeroMemory(pkcs10, pkcs10len);
|
|
|
+ ZeroMemory(msg, msglen);
|
|
|
|
|
|
- int ret = AQInitToken(const_cast<char*>(ctx->Req.CertType.GetData()),ctx->Ans.TokenType,const_cast<char*>(ctx->Req.OldSuperPwd.GetData()),const_cast<char*>(ctx->Req.UserName.GetData())
|
|
|
- ,const_cast<char*>(ctx->Req.UserIDType.GetData()),const_cast<char*>(ctx->Req.UserIDNo.GetData()),tokenSn
|
|
|
- ,tokensnlen,pkcs10,pkcs10len,msg,msglen);
|
|
|
- m_bWorkingOp = false;
|
|
|
- if (ret == 0)
|
|
|
- {
|
|
|
- Dbg("[%d][%s][%d][%s][%d]",tokensnlen,tokenSn,msglen,msg,pkcs10len);
|
|
|
- char xx1[768],xx2[768];
|
|
|
- ZeroMemory(xx1,768);
|
|
|
- ZeroMemory(xx2,768);
|
|
|
- if (pkcs10len > 600)
|
|
|
- {
|
|
|
- strncpy(xx1,pkcs10,600);
|
|
|
- strncpy(xx2,pkcs10+600,pkcs10len-600+1);
|
|
|
- }
|
|
|
- else
|
|
|
- strncpy(xx1,pkcs10,pkcs10len);
|
|
|
+ int ret = AQInitToken(const_cast<char*>(ctx->Req.CertType.GetData())
|
|
|
+ , ctx->Ans.TokenType, const_cast<char*>(ctx->Req.OldSuperPwd.GetData())
|
|
|
+ , const_cast<char*>(ctx->Req.UserName.GetData())
|
|
|
+ , const_cast<char*>(ctx->Req.UserIDType.GetData())
|
|
|
+ , const_cast<char*>(ctx->Req.UserIDNo.GetData())
|
|
|
+ , tokenSn
|
|
|
+ , tokensnlen, pkcs10, pkcs10len, msg, msglen);
|
|
|
+ m_bWorkingOp = false;
|
|
|
+ if (ret == 0) {
|
|
|
+ Dbg("[%d][%s][%d][%s][%d]", tokensnlen, tokenSn, msglen, msg, pkcs10len);
|
|
|
+ char xx1[768], xx2[768];
|
|
|
+ ZeroMemory(xx1, 768);
|
|
|
+ ZeroMemory(xx2, 768);
|
|
|
+ if (pkcs10len > 600) {
|
|
|
+ strncpy(xx1, pkcs10, 600);
|
|
|
+ strncpy(xx2, pkcs10 + 600, pkcs10len - 600 + 1);
|
|
|
+ } else
|
|
|
+ strncpy(xx1, pkcs10, pkcs10len);
|
|
|
|
|
|
- Dbg("[%s]",xx1);
|
|
|
- Dbg("[%s]",xx2);
|
|
|
- ctx->Ans.TokenSn = tokenSn;
|
|
|
- ctx->Ans.PKCS10 = pkcs10;
|
|
|
- ctx->Ans.Msg = msg;
|
|
|
- ctx->Ans.TokenSnLen = tokensnlen;
|
|
|
- ctx->Ans.PKCS10Len = pkcs10len;
|
|
|
- ctx->Ans.MsgLen = msglen;
|
|
|
- ctx->Ans.reserved1 = 999;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("InitToken failed.%d,%d",ret,GetLastError());
|
|
|
- ctx->Ans.reserved1 = ret;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ Dbg("[%s]", xx1);
|
|
|
+ Dbg("[%s]", xx2);
|
|
|
+ ctx->Ans.TokenSn = tokenSn;
|
|
|
+ ctx->Ans.PKCS10 = pkcs10;
|
|
|
+ ctx->Ans.Msg = msg;
|
|
|
+ ctx->Ans.TokenSnLen = tokensnlen;
|
|
|
+ ctx->Ans.PKCS10Len = pkcs10len;
|
|
|
+ ctx->Ans.MsgLen = msglen;
|
|
|
+ ctx->Ans.reserved1 = 999;
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ return 0;
|
|
|
+ } else {
|
|
|
+ Dbg("InitToken failed.%d,%d", ret, GetLastError());
|
|
|
+ ctx->Ans.reserved1 = ret;
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+#else
|
|
|
+ ctx->Answer(Error_NotSupport);
|
|
|
+ return 1;
|
|
|
+#endif //RVC_OS_WIN
|
|
|
|
|
|
}
|
|
|
-int CDeviceControlFSM::QueryUSB(SpReqAnsContext<DeviceControlService_QueryUSBStatus_Req,DeviceControlService_QueryUSBStatus_Ans>::Pointer ctx)
|
|
|
+int CDeviceControlFSM::QueryUSB(SpReqAnsContext<DeviceControlService_QueryUSBStatus_Req
|
|
|
+ ,DeviceControlService_QueryUSBStatus_Ans>::Pointer ctx)
|
|
|
{
|
|
|
ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
GpioService_ClientBase *pGpio = new GpioService_ClientBase(this->GetEntityBase());
|
|
@@ -482,4 +433,6 @@ void CDeviceControlFSM::WorkingOp()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|