PinPad_server_g.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. #ifndef __PINPAD_SERVER_G_H
  2. #define __PINPAD_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "PinPad_def_g.h"
  6. namespace PinPad {
  7. class PinPadService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. PinPadService_ServerSessionBase() { }
  11. virtual ~PinPadService_ServerSessionBase() { }
  12. virtual bool IsExclusive() { return false; }
  13. virtual bool IsSessionOverlap() { return true; }
  14. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  15. {
  16. ErrorCodeEnum Error = Error_Succeed;
  17. switch (dwMessageID) {
  18. case PinPadService_Method_GetInput:
  19. if (dwSignature == PinPadService_MethodSignature_GetInput) {
  20. bOverlap = true;
  21. } else {
  22. Error = Error_MethodSignatureFailed;
  23. }
  24. break;
  25. case PinPadService_Method_InputWaitMore:
  26. if (dwSignature == PinPadService_MethodSignature_InputWaitMore) {
  27. bOverlap = true;
  28. } else {
  29. Error = Error_MethodSignatureFailed;
  30. }
  31. break;
  32. case PinPadService_Method_InputCancel:
  33. if (dwSignature == PinPadService_MethodSignature_InputCancel) {
  34. bOverlap = true;
  35. } else {
  36. Error = Error_MethodSignatureFailed;
  37. }
  38. break;
  39. case PinPadService_Method_Exit:
  40. if (dwSignature == PinPadService_MethodSignature_Exit) {
  41. bOverlap = true;
  42. } else {
  43. Error = Error_MethodSignatureFailed;
  44. }
  45. break;
  46. case PinPadService_Method_LoadKeys:
  47. if (dwSignature == PinPadService_MethodSignature_LoadKeys) {
  48. bOverlap = true;
  49. } else {
  50. Error = Error_MethodSignatureFailed;
  51. }
  52. break;
  53. case PinPadService_Method_EncryptData:
  54. if (dwSignature == PinPadService_MethodSignature_EncryptData) {
  55. bOverlap = true;
  56. } else {
  57. Error = Error_MethodSignatureFailed;
  58. }
  59. break;
  60. case PinPadService_Method_GetInputSM:
  61. if (dwSignature == PinPadService_MethodSignature_GetInputSM) {
  62. bOverlap = true;
  63. } else {
  64. Error = Error_MethodSignatureFailed;
  65. }
  66. break;
  67. case PinPadService_Method_LoadKeysSM:
  68. if (dwSignature == PinPadService_MethodSignature_LoadKeysSM) {
  69. bOverlap = true;
  70. } else {
  71. Error = Error_MethodSignatureFailed;
  72. }
  73. break;
  74. case PinPadService_Method_EncryptDataSM:
  75. if (dwSignature == PinPadService_MethodSignature_EncryptDataSM) {
  76. bOverlap = true;
  77. } else {
  78. Error = Error_MethodSignatureFailed;
  79. }
  80. break;
  81. case PinPadService_Method_QueryFunc:
  82. if (dwSignature == PinPadService_MethodSignature_QueryFunc) {
  83. bOverlap = true;
  84. } else {
  85. Error = Error_MethodSignatureFailed;
  86. }
  87. break;
  88. case PinPadService_Method_GetCheckCode:
  89. if (dwSignature == PinPadService_MethodSignature_GetCheckCode) {
  90. bOverlap = true;
  91. } else {
  92. Error = Error_MethodSignatureFailed;
  93. }
  94. break;
  95. case PinPadService_Method_CrossTermCall:
  96. if (dwSignature == PinPadService_MethodSignature_CrossTermCall) {
  97. bOverlap = true;
  98. } else {
  99. Error = Error_MethodSignatureFailed;
  100. }
  101. break;
  102. case PinPadService_Method_CrossTermInvokeInfo:
  103. if (dwSignature == PinPadService_MethodSignature_CrossTermInvokeInfo) {
  104. bOverlap = true;
  105. } else {
  106. Error = Error_MethodSignatureFailed;
  107. }
  108. break;
  109. case PinPadService_Method_GetDevInfo:
  110. if (dwSignature == PinPadService_MethodSignature_GetDevInfo) {
  111. bOverlap = true;
  112. } else {
  113. Error = Error_MethodSignatureFailed;
  114. }
  115. break;
  116. default:
  117. Error = Error_MethodNotFound;
  118. break;
  119. }
  120. return Error;
  121. }
  122. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  123. {
  124. ErrorCodeEnum Error = Error_Succeed;
  125. switch (dwMessageID) {
  126. case PinPadService_Method_GetInput:
  127. if (dwSignature != PinPadService_MethodSignature_GetInput) {
  128. Error = Error_MethodSignatureFailed;
  129. }
  130. break;
  131. case PinPadService_Method_InputWaitMore:
  132. if (dwSignature != PinPadService_MethodSignature_InputWaitMore) {
  133. Error = Error_MethodSignatureFailed;
  134. }
  135. break;
  136. case PinPadService_Method_InputCancel:
  137. if (dwSignature != PinPadService_MethodSignature_InputCancel) {
  138. Error = Error_MethodSignatureFailed;
  139. }
  140. break;
  141. case PinPadService_Method_Exit:
  142. if (dwSignature != PinPadService_MethodSignature_Exit) {
  143. Error = Error_MethodSignatureFailed;
  144. }
  145. break;
  146. case PinPadService_Method_LoadKeys:
  147. if (dwSignature != PinPadService_MethodSignature_LoadKeys) {
  148. Error = Error_MethodSignatureFailed;
  149. }
  150. break;
  151. case PinPadService_Method_EncryptData:
  152. if (dwSignature != PinPadService_MethodSignature_EncryptData) {
  153. Error = Error_MethodSignatureFailed;
  154. }
  155. break;
  156. case PinPadService_Method_GetInputSM:
  157. if (dwSignature != PinPadService_MethodSignature_GetInputSM) {
  158. Error = Error_MethodSignatureFailed;
  159. }
  160. break;
  161. case PinPadService_Method_LoadKeysSM:
  162. if (dwSignature != PinPadService_MethodSignature_LoadKeysSM) {
  163. Error = Error_MethodSignatureFailed;
  164. }
  165. break;
  166. case PinPadService_Method_EncryptDataSM:
  167. if (dwSignature != PinPadService_MethodSignature_EncryptDataSM) {
  168. Error = Error_MethodSignatureFailed;
  169. }
  170. break;
  171. case PinPadService_Method_QueryFunc:
  172. if (dwSignature != PinPadService_MethodSignature_QueryFunc) {
  173. Error = Error_MethodSignatureFailed;
  174. }
  175. break;
  176. case PinPadService_Method_GetCheckCode:
  177. if (dwSignature != PinPadService_MethodSignature_GetCheckCode) {
  178. Error = Error_MethodSignatureFailed;
  179. }
  180. break;
  181. case PinPadService_Method_CrossTermCall:
  182. if (dwSignature != PinPadService_MethodSignature_CrossTermCall) {
  183. Error = Error_MethodSignatureFailed;
  184. }
  185. break;
  186. case PinPadService_Method_CrossTermInvokeInfo:
  187. if (dwSignature != PinPadService_MethodSignature_CrossTermInvokeInfo) {
  188. Error = Error_MethodSignatureFailed;
  189. }
  190. break;
  191. case PinPadService_Method_GetDevInfo:
  192. if (dwSignature != PinPadService_MethodSignature_GetDevInfo) {
  193. Error = Error_MethodSignatureFailed;
  194. }
  195. break;
  196. default:
  197. Error = Error_MethodNotFound;
  198. break;
  199. }
  200. return Error;
  201. }
  202. virtual void Handle_GetInput(SpReqAnsContext<PinPadService_GetInput_Req, PinPadService_GetInput_Ans>::Pointer ctx)
  203. {
  204. /// override by user
  205. }
  206. virtual void Handle_InputWaitMore(SpOnewayCallContext<PinPadService_InputWaitMore_Info>::Pointer ctx)
  207. {
  208. /// override by user
  209. }
  210. virtual void Handle_InputCancel(SpOnewayCallContext<PinPadService_InputCancel_Info>::Pointer ctx)
  211. {
  212. /// override by user
  213. }
  214. virtual void Handle_Exit(SpOnewayCallContext<PinPadService_Exit_Info>::Pointer ctx)
  215. {
  216. /// override by user
  217. }
  218. virtual void Handle_LoadKeys(SpReqAnsContext<PinPadService_LoadKeys_Req, PinPadService_LoadKeys_Ans>::Pointer ctx)
  219. {
  220. /// override by user
  221. }
  222. virtual void Handle_EncryptData(SpReqAnsContext<PinPadService_EncryptData_Req, PinPadService_EncryptData_Ans>::Pointer ctx)
  223. {
  224. /// override by user
  225. }
  226. virtual void Handle_GetInputSM(SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadService_GetInputSM_Ans>::Pointer ctx)
  227. {
  228. /// override by user
  229. }
  230. virtual void Handle_LoadKeysSM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadService_LoadKeysSM_Ans>::Pointer ctx)
  231. {
  232. /// override by user
  233. }
  234. virtual void Handle_EncryptDataSM(SpReqAnsContext<PinPadService_EncryptDataSM_Req, PinPadService_EncryptDataSM_Ans>::Pointer ctx)
  235. {
  236. /// override by user
  237. }
  238. virtual void Handle_QueryFunc(SpReqAnsContext<PinPadService_QueryFunc_Req, PinPadService_QueryFunc_Ans>::Pointer ctx)
  239. {
  240. /// override by user
  241. }
  242. virtual void Handle_GetCheckCode(SpReqAnsContext<PinPadService_GetCheckCode_Req, PinPadService_GetCheckCode_Ans>::Pointer ctx)
  243. {
  244. /// override by user
  245. }
  246. virtual void Handle_CrossTermCall(SpReqAnsContext<PinPadService_CrossTermCall_Req, PinPadService_CrossTermCall_Ans>::Pointer ctx)
  247. {
  248. /// override by user
  249. }
  250. virtual void Handle_CrossTermInvokeInfo(SpOnewayCallContext<PinPadService_CrossTermInvokeInfo_Info>::Pointer ctx)
  251. {
  252. /// override by user
  253. }
  254. virtual void Handle_GetDevInfo(SpReqAnsContext<PinPadService_GetDevInfo_Req, PinPadService_GetDevInfo_Ans>::Pointer ctx)
  255. {
  256. /// override by user
  257. }
  258. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  259. {
  260. CAutoBuffer Buf;
  261. DWORD dwMessageID;
  262. DWORD dwMessageSignature;
  263. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  264. if (Error == Error_Succeed) {
  265. #ifdef DEBUG
  266. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  267. #else
  268. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  269. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  270. return;
  271. }
  272. #endif
  273. switch (dwMessageID) {
  274. case PinPadService_Method_GetInput:
  275. {
  276. SpReqAnsContext<PinPadService_GetInput_Req,PinPadService_GetInput_Ans>::Pointer ctx;
  277. ctx.Attach(new SpReqAnsContext<PinPadService_GetInput_Req,PinPadService_GetInput_Ans>(pTransactionContext));
  278. SpBuffer2Object(Buf, ctx->Req);
  279. Handle_GetInput(ctx);
  280. }
  281. break;
  282. case PinPadService_Method_InputWaitMore:
  283. {
  284. SpOnewayCallContext<PinPadService_InputWaitMore_Info>::Pointer ctx;
  285. ctx.Attach(new SpOnewayCallContext<PinPadService_InputWaitMore_Info>());
  286. SpBuffer2Object(Buf, ctx->Info);
  287. Handle_InputWaitMore(ctx);
  288. }
  289. break;
  290. case PinPadService_Method_InputCancel:
  291. {
  292. SpOnewayCallContext<PinPadService_InputCancel_Info>::Pointer ctx;
  293. ctx.Attach(new SpOnewayCallContext<PinPadService_InputCancel_Info>());
  294. SpBuffer2Object(Buf, ctx->Info);
  295. Handle_InputCancel(ctx);
  296. }
  297. break;
  298. case PinPadService_Method_Exit:
  299. {
  300. SpOnewayCallContext<PinPadService_Exit_Info>::Pointer ctx;
  301. ctx.Attach(new SpOnewayCallContext<PinPadService_Exit_Info>());
  302. SpBuffer2Object(Buf, ctx->Info);
  303. Handle_Exit(ctx);
  304. }
  305. break;
  306. case PinPadService_Method_LoadKeys:
  307. {
  308. SpReqAnsContext<PinPadService_LoadKeys_Req,PinPadService_LoadKeys_Ans>::Pointer ctx;
  309. ctx.Attach(new SpReqAnsContext<PinPadService_LoadKeys_Req,PinPadService_LoadKeys_Ans>(pTransactionContext));
  310. SpBuffer2Object(Buf, ctx->Req);
  311. Handle_LoadKeys(ctx);
  312. }
  313. break;
  314. case PinPadService_Method_EncryptData:
  315. {
  316. SpReqAnsContext<PinPadService_EncryptData_Req,PinPadService_EncryptData_Ans>::Pointer ctx;
  317. ctx.Attach(new SpReqAnsContext<PinPadService_EncryptData_Req,PinPadService_EncryptData_Ans>(pTransactionContext));
  318. SpBuffer2Object(Buf, ctx->Req);
  319. Handle_EncryptData(ctx);
  320. }
  321. break;
  322. case PinPadService_Method_GetInputSM:
  323. {
  324. SpReqAnsContext<PinPadService_GetInputSM_Req,PinPadService_GetInputSM_Ans>::Pointer ctx;
  325. ctx.Attach(new SpReqAnsContext<PinPadService_GetInputSM_Req,PinPadService_GetInputSM_Ans>(pTransactionContext));
  326. SpBuffer2Object(Buf, ctx->Req);
  327. Handle_GetInputSM(ctx);
  328. }
  329. break;
  330. case PinPadService_Method_LoadKeysSM:
  331. {
  332. SpReqAnsContext<PinPadService_LoadKeysSM_Req,PinPadService_LoadKeysSM_Ans>::Pointer ctx;
  333. ctx.Attach(new SpReqAnsContext<PinPadService_LoadKeysSM_Req,PinPadService_LoadKeysSM_Ans>(pTransactionContext));
  334. SpBuffer2Object(Buf, ctx->Req);
  335. Handle_LoadKeysSM(ctx);
  336. }
  337. break;
  338. case PinPadService_Method_EncryptDataSM:
  339. {
  340. SpReqAnsContext<PinPadService_EncryptDataSM_Req,PinPadService_EncryptDataSM_Ans>::Pointer ctx;
  341. ctx.Attach(new SpReqAnsContext<PinPadService_EncryptDataSM_Req,PinPadService_EncryptDataSM_Ans>(pTransactionContext));
  342. SpBuffer2Object(Buf, ctx->Req);
  343. Handle_EncryptDataSM(ctx);
  344. }
  345. break;
  346. case PinPadService_Method_QueryFunc:
  347. {
  348. SpReqAnsContext<PinPadService_QueryFunc_Req,PinPadService_QueryFunc_Ans>::Pointer ctx;
  349. ctx.Attach(new SpReqAnsContext<PinPadService_QueryFunc_Req,PinPadService_QueryFunc_Ans>(pTransactionContext));
  350. SpBuffer2Object(Buf, ctx->Req);
  351. Handle_QueryFunc(ctx);
  352. }
  353. break;
  354. case PinPadService_Method_GetCheckCode:
  355. {
  356. SpReqAnsContext<PinPadService_GetCheckCode_Req,PinPadService_GetCheckCode_Ans>::Pointer ctx;
  357. ctx.Attach(new SpReqAnsContext<PinPadService_GetCheckCode_Req,PinPadService_GetCheckCode_Ans>(pTransactionContext));
  358. SpBuffer2Object(Buf, ctx->Req);
  359. Handle_GetCheckCode(ctx);
  360. }
  361. break;
  362. case PinPadService_Method_CrossTermCall:
  363. {
  364. SpReqAnsContext<PinPadService_CrossTermCall_Req,PinPadService_CrossTermCall_Ans>::Pointer ctx;
  365. ctx.Attach(new SpReqAnsContext<PinPadService_CrossTermCall_Req,PinPadService_CrossTermCall_Ans>(pTransactionContext));
  366. SpBuffer2Object(Buf, ctx->Req);
  367. Handle_CrossTermCall(ctx);
  368. }
  369. break;
  370. case PinPadService_Method_CrossTermInvokeInfo:
  371. {
  372. SpOnewayCallContext<PinPadService_CrossTermInvokeInfo_Info>::Pointer ctx;
  373. ctx.Attach(new SpOnewayCallContext<PinPadService_CrossTermInvokeInfo_Info>());
  374. SpBuffer2Object(Buf, ctx->Info);
  375. Handle_CrossTermInvokeInfo(ctx);
  376. }
  377. break;
  378. case PinPadService_Method_GetDevInfo:
  379. {
  380. SpReqAnsContext<PinPadService_GetDevInfo_Req,PinPadService_GetDevInfo_Ans>::Pointer ctx;
  381. ctx.Attach(new SpReqAnsContext<PinPadService_GetDevInfo_Req,PinPadService_GetDevInfo_Ans>(pTransactionContext));
  382. SpBuffer2Object(Buf, ctx->Req);
  383. Handle_GetDevInfo(ctx);
  384. }
  385. break;
  386. default:
  387. assert(0);
  388. break;
  389. }
  390. } else {
  391. pTransactionContext->SendAnswer(Error);
  392. }
  393. }
  394. };
  395. ///////////////////////////
  396. } // namespace PinPad
  397. #endif // __PINPAD_SERVER_G_H