ResourceWatcher_server_g.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. #ifndef __RESOURCEWATCHER_SERVER_G_H
  2. #define __RESOURCEWATCHER_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "ResourceWatcher_def_g.h"
  6. namespace ResourceWatcher {
  7. class ResourceWatcherService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. ResourceWatcherService_ServerSessionBase()
  11. {
  12. /// override by user
  13. }
  14. virtual ~ResourceWatcherService_ServerSessionBase()
  15. {
  16. /// override by user
  17. }
  18. virtual bool IsExclusive() { return false; }
  19. virtual bool IsSessionOverlap() { return true; }
  20. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  21. {
  22. ErrorCodeEnum Error = Error_Succeed;
  23. switch (dwMessageID) {
  24. case ResourceWatcherService_Method_Fetch:
  25. if (dwSignature == ResourceWatcherService_MethodSignature_Fetch) {
  26. bOverlap = true;
  27. } else {
  28. Error = Error_MethodSignatureFailed;
  29. }
  30. break;
  31. case ResourceWatcherService_Method_GetDevInfo:
  32. if (dwSignature == ResourceWatcherService_MethodSignature_GetDevInfo) {
  33. bOverlap = true;
  34. } else {
  35. Error = Error_MethodSignatureFailed;
  36. }
  37. break;
  38. case ResourceWatcherService_Method_GetCardSwiper:
  39. if (dwSignature == ResourceWatcherService_MethodSignature_GetCardSwiper) {
  40. bOverlap = true;
  41. } else {
  42. Error = Error_MethodSignatureFailed;
  43. }
  44. break;
  45. case ResourceWatcherService_Method_GetCpuType:
  46. if (dwSignature == ResourceWatcherService_MethodSignature_GetCpuType) {
  47. bOverlap = true;
  48. } else {
  49. Error = Error_MethodSignatureFailed;
  50. }
  51. break;
  52. case ResourceWatcherService_Method_OperateFile:
  53. if (dwSignature == ResourceWatcherService_MethodSignature_OperateFile) {
  54. bOverlap = true;
  55. } else {
  56. Error = Error_MethodSignatureFailed;
  57. }
  58. break;
  59. case ResourceWatcherService_Method_ExtractEventLog:
  60. if (dwSignature == ResourceWatcherService_MethodSignature_ExtractEventLog) {
  61. bOverlap = true;
  62. } else {
  63. Error = Error_MethodSignatureFailed;
  64. }
  65. break;
  66. case ResourceWatcherService_Method_UpdateDNS:
  67. if (dwSignature == ResourceWatcherService_MethodSignature_UpdateDNS) {
  68. bOverlap = true;
  69. } else {
  70. Error = Error_MethodSignatureFailed;
  71. }
  72. break;
  73. case ResourceWatcherService_Method_GetNetworkInfo:
  74. if (dwSignature == ResourceWatcherService_MethodSignature_GetNetworkInfo) {
  75. bOverlap = true;
  76. } else {
  77. Error = Error_MethodSignatureFailed;
  78. }
  79. break;
  80. case ResourceWatcherService_Method_GetThirdPartyInstallState:
  81. if (dwSignature == ResourceWatcherService_MethodSignature_GetThirdPartyInstallState) {
  82. bOverlap = true;
  83. } else {
  84. Error = Error_MethodSignatureFailed;
  85. }
  86. break;
  87. case ResourceWatcherService_Method_InstallThirdPartyProgram:
  88. if (dwSignature == ResourceWatcherService_MethodSignature_InstallThirdPartyProgram) {
  89. bOverlap = true;
  90. } else {
  91. Error = Error_MethodSignatureFailed;
  92. }
  93. break;
  94. default:
  95. Error = Error_MethodNotFound;
  96. break;
  97. }
  98. return Error;
  99. }
  100. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  101. {
  102. ErrorCodeEnum Error = Error_Succeed;
  103. switch (dwMessageID) {
  104. case ResourceWatcherService_Method_Fetch:
  105. if (dwSignature != ResourceWatcherService_MethodSignature_Fetch) {
  106. Error = Error_MethodSignatureFailed;
  107. }
  108. break;
  109. case ResourceWatcherService_Method_GetDevInfo:
  110. if (dwSignature != ResourceWatcherService_MethodSignature_GetDevInfo) {
  111. Error = Error_MethodSignatureFailed;
  112. }
  113. break;
  114. case ResourceWatcherService_Method_GetCardSwiper:
  115. if (dwSignature != ResourceWatcherService_MethodSignature_GetCardSwiper) {
  116. Error = Error_MethodSignatureFailed;
  117. }
  118. break;
  119. case ResourceWatcherService_Method_GetCpuType:
  120. if (dwSignature != ResourceWatcherService_MethodSignature_GetCpuType) {
  121. Error = Error_MethodSignatureFailed;
  122. }
  123. break;
  124. case ResourceWatcherService_Method_OperateFile:
  125. if (dwSignature != ResourceWatcherService_MethodSignature_OperateFile) {
  126. Error = Error_MethodSignatureFailed;
  127. }
  128. break;
  129. case ResourceWatcherService_Method_ExtractEventLog:
  130. if (dwSignature != ResourceWatcherService_MethodSignature_ExtractEventLog) {
  131. Error = Error_MethodSignatureFailed;
  132. }
  133. break;
  134. case ResourceWatcherService_Method_UpdateDNS:
  135. if (dwSignature != ResourceWatcherService_MethodSignature_UpdateDNS) {
  136. Error = Error_MethodSignatureFailed;
  137. }
  138. break;
  139. case ResourceWatcherService_Method_GetNetworkInfo:
  140. if (dwSignature != ResourceWatcherService_MethodSignature_GetNetworkInfo) {
  141. Error = Error_MethodSignatureFailed;
  142. }
  143. break;
  144. case ResourceWatcherService_Method_GetThirdPartyInstallState:
  145. if (dwSignature != ResourceWatcherService_MethodSignature_GetThirdPartyInstallState) {
  146. Error = Error_MethodSignatureFailed;
  147. }
  148. break;
  149. case ResourceWatcherService_Method_InstallThirdPartyProgram:
  150. if (dwSignature != ResourceWatcherService_MethodSignature_InstallThirdPartyProgram) {
  151. Error = Error_MethodSignatureFailed;
  152. }
  153. break;
  154. default:
  155. Error = Error_MethodNotFound;
  156. break;
  157. }
  158. return Error;
  159. }
  160. virtual void Handle_Fetch(SpReqAnsContext<ResourceWatcherService_Fetch_Req, ResourceWatcherService_Fetch_Ans>::Pointer ctx)
  161. {
  162. /// override by user
  163. }
  164. virtual void Handle_GetDevInfo(SpReqAnsContext<ResourceWatcherService_GetDevInfo_Req, ResourceWatcherService_GetDevInfo_Ans>::Pointer ctx)
  165. {
  166. /// override by user
  167. }
  168. virtual void Handle_GetCardSwiper(SpReqAnsContext<ResourceWatcherService_GetCardSwiper_Req, ResourceWatcherService_GetCardSwiper_Ans>::Pointer ctx)
  169. {
  170. /// override by user
  171. }
  172. virtual void Handle_GetCpuType(SpReqAnsContext<ResourceWatcherService_GetCpuType_Req, ResourceWatcherService_GetCpuType_Ans>::Pointer ctx)
  173. {
  174. /// override by user
  175. }
  176. virtual void Handle_OperateFile(SpReqAnsContext<ResourceWatcherService_OperateFile_Req, ResourceWatcherService_OperateFile_Ans>::Pointer ctx)
  177. {
  178. /// override by user
  179. }
  180. virtual void Handle_ExtractEventLog(SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req, ResourceWatcherService_ExtractEventLog_Ans>::Pointer ctx)
  181. {
  182. /// override by user
  183. }
  184. virtual void Handle_UpdateDNS(SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req, ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx)
  185. {
  186. /// override by user
  187. }
  188. virtual void Handle_GetNetworkInfo(SpReqAnsContext<ResourceWatcherService_GetNetworkInfo_Req, ResourceWatcherService_GetNetworkInfo_Ans>::Pointer ctx)
  189. {
  190. /// override by user
  191. }
  192. virtual void Handle_GetThirdPartyInstallState(SpReqAnsContext<ResourceWatcherService_GetThirdPartyInstallState_Req, ResourceWatcherService_GetThirdPartyInstallState_Ans>::Pointer ctx)
  193. {
  194. /// override by user
  195. }
  196. virtual void Handle_InstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req, ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx)
  197. {
  198. /// override by user
  199. }
  200. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  201. {
  202. CAutoBuffer Buf;
  203. DWORD dwMessageID;
  204. DWORD dwMessageSignature;
  205. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  206. if (Error == Error_Succeed) {
  207. #ifdef DEBUG
  208. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  209. #else
  210. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  211. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  212. return;
  213. }
  214. #endif
  215. switch (dwMessageID) {
  216. case ResourceWatcherService_Method_Fetch:
  217. {
  218. SpReqAnsContext<ResourceWatcherService_Fetch_Req,ResourceWatcherService_Fetch_Ans>::Pointer ctx;
  219. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_Fetch_Req,ResourceWatcherService_Fetch_Ans>(pTransactionContext));
  220. SpBuffer2Object(Buf, ctx->Req);
  221. Handle_Fetch(ctx);
  222. }
  223. break;
  224. case ResourceWatcherService_Method_GetDevInfo:
  225. {
  226. SpReqAnsContext<ResourceWatcherService_GetDevInfo_Req,ResourceWatcherService_GetDevInfo_Ans>::Pointer ctx;
  227. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetDevInfo_Req,ResourceWatcherService_GetDevInfo_Ans>(pTransactionContext));
  228. SpBuffer2Object(Buf, ctx->Req);
  229. Handle_GetDevInfo(ctx);
  230. }
  231. break;
  232. case ResourceWatcherService_Method_GetCardSwiper:
  233. {
  234. SpReqAnsContext<ResourceWatcherService_GetCardSwiper_Req,ResourceWatcherService_GetCardSwiper_Ans>::Pointer ctx;
  235. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetCardSwiper_Req,ResourceWatcherService_GetCardSwiper_Ans>(pTransactionContext));
  236. SpBuffer2Object(Buf, ctx->Req);
  237. Handle_GetCardSwiper(ctx);
  238. }
  239. break;
  240. case ResourceWatcherService_Method_GetCpuType:
  241. {
  242. SpReqAnsContext<ResourceWatcherService_GetCpuType_Req,ResourceWatcherService_GetCpuType_Ans>::Pointer ctx;
  243. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetCpuType_Req,ResourceWatcherService_GetCpuType_Ans>(pTransactionContext));
  244. SpBuffer2Object(Buf, ctx->Req);
  245. Handle_GetCpuType(ctx);
  246. }
  247. break;
  248. case ResourceWatcherService_Method_OperateFile:
  249. {
  250. SpReqAnsContext<ResourceWatcherService_OperateFile_Req,ResourceWatcherService_OperateFile_Ans>::Pointer ctx;
  251. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_OperateFile_Req,ResourceWatcherService_OperateFile_Ans>(pTransactionContext));
  252. SpBuffer2Object(Buf, ctx->Req);
  253. Handle_OperateFile(ctx);
  254. }
  255. break;
  256. case ResourceWatcherService_Method_ExtractEventLog:
  257. {
  258. SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,ResourceWatcherService_ExtractEventLog_Ans>::Pointer ctx;
  259. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,ResourceWatcherService_ExtractEventLog_Ans>(pTransactionContext));
  260. SpBuffer2Object(Buf, ctx->Req);
  261. Handle_ExtractEventLog(ctx);
  262. }
  263. break;
  264. case ResourceWatcherService_Method_UpdateDNS:
  265. {
  266. SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req,ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx;
  267. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req,ResourceWatcherService_UpdateDNS_Ans>(pTransactionContext));
  268. SpBuffer2Object(Buf, ctx->Req);
  269. Handle_UpdateDNS(ctx);
  270. }
  271. break;
  272. case ResourceWatcherService_Method_GetNetworkInfo:
  273. {
  274. SpReqAnsContext<ResourceWatcherService_GetNetworkInfo_Req,ResourceWatcherService_GetNetworkInfo_Ans>::Pointer ctx;
  275. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetNetworkInfo_Req,ResourceWatcherService_GetNetworkInfo_Ans>(pTransactionContext));
  276. SpBuffer2Object(Buf, ctx->Req);
  277. Handle_GetNetworkInfo(ctx);
  278. }
  279. break;
  280. case ResourceWatcherService_Method_GetThirdPartyInstallState:
  281. {
  282. SpReqAnsContext<ResourceWatcherService_GetThirdPartyInstallState_Req,ResourceWatcherService_GetThirdPartyInstallState_Ans>::Pointer ctx;
  283. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetThirdPartyInstallState_Req,ResourceWatcherService_GetThirdPartyInstallState_Ans>(pTransactionContext));
  284. SpBuffer2Object(Buf, ctx->Req);
  285. Handle_GetThirdPartyInstallState(ctx);
  286. }
  287. break;
  288. case ResourceWatcherService_Method_InstallThirdPartyProgram:
  289. {
  290. SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req,ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx;
  291. ctx.Attach(new SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req,ResourceWatcherService_InstallThirdPartyProgram_Ans>(pTransactionContext));
  292. SpBuffer2Object(Buf, ctx->Req);
  293. Handle_InstallThirdPartyProgram(ctx);
  294. }
  295. break;
  296. default:
  297. assert(0);
  298. break;
  299. }
  300. } else {
  301. pTransactionContext->SendAnswer(Error);
  302. }
  303. }
  304. };
  305. ///////////////////////////
  306. } // namespace ResourceWatcher
  307. #endif // __RESOURCEWATCHER_SERVER_G_H