SIPPhone_server_g.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. #ifndef __SIPPHONE_SERVER_G_H
  2. #define __SIPPHONE_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "SIPPhone_def_g.h"
  6. namespace SIPPhone {
  7. class PhoneService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. PhoneService_ServerSessionBase() { }
  11. virtual ~PhoneService_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 PhoneService_Method_MakeCall:
  19. if (dwSignature == PhoneService_MethodSignature_MakeCall) {
  20. bOverlap = true;
  21. } else {
  22. Error = Error_MethodSignatureFailed;
  23. }
  24. break;
  25. case PhoneService_Method_HangupCall:
  26. if (dwSignature == PhoneService_MethodSignature_HangupCall) {
  27. bOverlap = true;
  28. } else {
  29. Error = Error_MethodSignatureFailed;
  30. }
  31. break;
  32. case PhoneService_Method_StartVideo:
  33. if (dwSignature == PhoneService_MethodSignature_StartVideo) {
  34. bOverlap = true;
  35. } else {
  36. Error = Error_MethodSignatureFailed;
  37. }
  38. break;
  39. case PhoneService_Method_StopVideo:
  40. if (dwSignature == PhoneService_MethodSignature_StopVideo) {
  41. bOverlap = true;
  42. } else {
  43. Error = Error_MethodSignatureFailed;
  44. }
  45. break;
  46. case PhoneService_Method_RealErrorCheck:
  47. if (dwSignature == PhoneService_MethodSignature_RealErrorCheck) {
  48. bOverlap = true;
  49. } else {
  50. Error = Error_MethodSignatureFailed;
  51. }
  52. break;
  53. case PhoneService_Method_ReleaseCall:
  54. if (dwSignature == PhoneService_MethodSignature_ReleaseCall) {
  55. bOverlap = true;
  56. } else {
  57. Error = Error_MethodSignatureFailed;
  58. }
  59. break;
  60. case PhoneService_Method_BeginState:
  61. if (dwSignature == PhoneService_MethodSignature_BeginState) {
  62. bOverlap = false;
  63. } else {
  64. Error = Error_MethodSignatureFailed;
  65. }
  66. break;
  67. case PhoneService_Method_EndState:
  68. if (dwSignature == PhoneService_MethodSignature_EndState) {
  69. bOverlap = true;
  70. } else {
  71. Error = Error_MethodSignatureFailed;
  72. }
  73. break;
  74. case PhoneService_Method_SetCallingParam:
  75. if (dwSignature == PhoneService_MethodSignature_SetCallingParam) {
  76. bOverlap = true;
  77. } else {
  78. Error = Error_MethodSignatureFailed;
  79. }
  80. break;
  81. case PhoneService_Method_GetHandfreeOutVolume:
  82. if (dwSignature == PhoneService_MethodSignature_GetHandfreeOutVolume) {
  83. bOverlap = true;
  84. } else {
  85. Error = Error_MethodSignatureFailed;
  86. }
  87. break;
  88. case PhoneService_Method_SetHandfreeOutVolume:
  89. if (dwSignature == PhoneService_MethodSignature_SetHandfreeOutVolume) {
  90. bOverlap = true;
  91. } else {
  92. Error = Error_MethodSignatureFailed;
  93. }
  94. break;
  95. case PhoneService_Method_SetPickupOutVolume:
  96. if (dwSignature == PhoneService_MethodSignature_SetPickupOutVolume) {
  97. bOverlap = true;
  98. } else {
  99. Error = Error_MethodSignatureFailed;
  100. }
  101. break;
  102. case PhoneService_Method_GetPickupOutVolume:
  103. if (dwSignature == PhoneService_MethodSignature_GetPickupOutVolume) {
  104. bOverlap = true;
  105. } else {
  106. Error = Error_MethodSignatureFailed;
  107. }
  108. break;
  109. default:
  110. Error = Error_MethodNotFound;
  111. break;
  112. }
  113. return Error;
  114. }
  115. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  116. {
  117. ErrorCodeEnum Error = Error_Succeed;
  118. switch (dwMessageID) {
  119. case PhoneService_Method_MakeCall:
  120. if (dwSignature != PhoneService_MethodSignature_MakeCall) {
  121. Error = Error_MethodSignatureFailed;
  122. }
  123. break;
  124. case PhoneService_Method_HangupCall:
  125. if (dwSignature != PhoneService_MethodSignature_HangupCall) {
  126. Error = Error_MethodSignatureFailed;
  127. }
  128. break;
  129. case PhoneService_Method_StartVideo:
  130. if (dwSignature != PhoneService_MethodSignature_StartVideo) {
  131. Error = Error_MethodSignatureFailed;
  132. }
  133. break;
  134. case PhoneService_Method_StopVideo:
  135. if (dwSignature != PhoneService_MethodSignature_StopVideo) {
  136. Error = Error_MethodSignatureFailed;
  137. }
  138. break;
  139. case PhoneService_Method_RealErrorCheck:
  140. if (dwSignature != PhoneService_MethodSignature_RealErrorCheck) {
  141. Error = Error_MethodSignatureFailed;
  142. }
  143. break;
  144. case PhoneService_Method_ReleaseCall:
  145. if (dwSignature != PhoneService_MethodSignature_ReleaseCall) {
  146. Error = Error_MethodSignatureFailed;
  147. }
  148. break;
  149. case PhoneService_Method_BeginState:
  150. if (dwSignature != PhoneService_MethodSignature_BeginState) {
  151. Error = Error_MethodSignatureFailed;
  152. }
  153. break;
  154. case PhoneService_Method_EndState:
  155. if (dwSignature != PhoneService_MethodSignature_EndState) {
  156. Error = Error_MethodSignatureFailed;
  157. }
  158. break;
  159. case PhoneService_Method_SetCallingParam:
  160. if (dwSignature != PhoneService_MethodSignature_SetCallingParam) {
  161. Error = Error_MethodSignatureFailed;
  162. }
  163. break;
  164. case PhoneService_Method_GetHandfreeOutVolume:
  165. if (dwSignature != PhoneService_MethodSignature_GetHandfreeOutVolume) {
  166. Error = Error_MethodSignatureFailed;
  167. }
  168. break;
  169. case PhoneService_Method_SetHandfreeOutVolume:
  170. if (dwSignature != PhoneService_MethodSignature_SetHandfreeOutVolume) {
  171. Error = Error_MethodSignatureFailed;
  172. }
  173. break;
  174. case PhoneService_Method_SetPickupOutVolume:
  175. if (dwSignature != PhoneService_MethodSignature_SetPickupOutVolume) {
  176. Error = Error_MethodSignatureFailed;
  177. }
  178. break;
  179. case PhoneService_Method_GetPickupOutVolume:
  180. if (dwSignature != PhoneService_MethodSignature_GetPickupOutVolume) {
  181. Error = Error_MethodSignatureFailed;
  182. }
  183. break;
  184. default:
  185. Error = Error_MethodNotFound;
  186. break;
  187. }
  188. return Error;
  189. }
  190. virtual void Handle_MakeCall(SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx)
  191. {
  192. /// override by user
  193. }
  194. virtual void Handle_HangupCall(SpReqAnsContext<PhoneService_HangupCall_Req, PhoneService_HangupCall_Ans>::Pointer ctx)
  195. {
  196. /// override by user
  197. }
  198. virtual void Handle_StartVideo(SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx)
  199. {
  200. /// override by user
  201. }
  202. virtual void Handle_StopVideo(SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx)
  203. {
  204. /// override by user
  205. }
  206. virtual void Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx)
  207. {
  208. /// override by user
  209. }
  210. virtual void Handle_ReleaseCall(SpReqAnsContext<PhoneService_ReleaseCall_Req, PhoneService_ReleaseCall_Ans>::Pointer ctx)
  211. {
  212. /// override by user
  213. }
  214. virtual void Handle_BeginState(SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx)
  215. {
  216. /// override by user
  217. }
  218. virtual void Handle_EndState(SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx)
  219. {
  220. /// override by user
  221. }
  222. virtual void Handle_SetCallingParam(SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx)
  223. {
  224. /// override by user
  225. }
  226. virtual void Handle_GetHandfreeOutVolume(SpReqAnsContext<PhoneService_GetHandfreeOutVolume_Req, PhoneService_GetHandfreeOutVolume_Ans>::Pointer ctx)
  227. {
  228. /// override by user
  229. }
  230. virtual void Handle_SetHandfreeOutVolume(SpReqAnsContext<PhoneService_SetHandfreeOutVolume_Req, PhoneService_SetHandfreeOutVolume_Ans>::Pointer ctx)
  231. {
  232. /// override by user
  233. }
  234. virtual void Handle_SetPickupOutVolume(SpReqAnsContext<PhoneService_SetPickupOutVolume_Req, PhoneService_SetPickupOutVolume_Ans>::Pointer ctx)
  235. {
  236. /// override by user
  237. }
  238. virtual void Handle_GetPickupOutVolume(SpReqAnsContext<PhoneService_GetPickupOutVolume_Req, PhoneService_GetPickupOutVolume_Ans>::Pointer ctx)
  239. {
  240. /// override by user
  241. }
  242. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  243. {
  244. CAutoBuffer Buf;
  245. DWORD dwMessageID;
  246. DWORD dwMessageSignature;
  247. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  248. if (Error == Error_Succeed) {
  249. #ifdef DEBUG
  250. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  251. #else
  252. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  253. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  254. return;
  255. }
  256. #endif
  257. switch (dwMessageID) {
  258. case PhoneService_Method_MakeCall:
  259. {
  260. SpReqAnsContext<PhoneService_MakeCall_Req,PhoneService_MakeCall_Ans>::Pointer ctx;
  261. ctx.Attach(new SpReqAnsContext<PhoneService_MakeCall_Req,PhoneService_MakeCall_Ans>(pTransactionContext));
  262. SpBuffer2Object(Buf, ctx->Req);
  263. Handle_MakeCall(ctx);
  264. }
  265. break;
  266. case PhoneService_Method_HangupCall:
  267. {
  268. SpReqAnsContext<PhoneService_HangupCall_Req,PhoneService_HangupCall_Ans>::Pointer ctx;
  269. ctx.Attach(new SpReqAnsContext<PhoneService_HangupCall_Req,PhoneService_HangupCall_Ans>(pTransactionContext));
  270. SpBuffer2Object(Buf, ctx->Req);
  271. Handle_HangupCall(ctx);
  272. }
  273. break;
  274. case PhoneService_Method_StartVideo:
  275. {
  276. SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx;
  277. ctx.Attach(new SpOnewayCallContext<PhoneService_StartVideo_Info>());
  278. SpBuffer2Object(Buf, ctx->Info);
  279. Handle_StartVideo(ctx);
  280. }
  281. break;
  282. case PhoneService_Method_StopVideo:
  283. {
  284. SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx;
  285. ctx.Attach(new SpOnewayCallContext<PhoneService_StopVideo_Info>());
  286. SpBuffer2Object(Buf, ctx->Info);
  287. Handle_StopVideo(ctx);
  288. }
  289. break;
  290. case PhoneService_Method_RealErrorCheck:
  291. {
  292. SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx;
  293. ctx.Attach(new SpOnewayCallContext<PhoneService_RealErrorCheck_Info>());
  294. SpBuffer2Object(Buf, ctx->Info);
  295. Handle_RealErrorCheck(ctx);
  296. }
  297. break;
  298. case PhoneService_Method_ReleaseCall:
  299. {
  300. SpReqAnsContext<PhoneService_ReleaseCall_Req,PhoneService_ReleaseCall_Ans>::Pointer ctx;
  301. ctx.Attach(new SpReqAnsContext<PhoneService_ReleaseCall_Req,PhoneService_ReleaseCall_Ans>(pTransactionContext));
  302. SpBuffer2Object(Buf, ctx->Req);
  303. Handle_ReleaseCall(ctx);
  304. }
  305. break;
  306. case PhoneService_Method_BeginState:
  307. {
  308. SpSubscribeContext<PhoneService_BeginState_Sub,PhoneService_PhoneState_Info>::Pointer ctx;
  309. ctx.Attach(new SpSubscribeContext<PhoneService_BeginState_Sub,PhoneService_PhoneState_Info>(pTransactionContext));
  310. SpBuffer2Object(Buf, ctx->Req);
  311. Handle_BeginState(ctx);
  312. }
  313. break;
  314. case PhoneService_Method_EndState:
  315. {
  316. SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx;
  317. ctx.Attach(new SpOnewayCallContext<PhoneService_EndState_Info>());
  318. SpBuffer2Object(Buf, ctx->Info);
  319. Handle_EndState(ctx);
  320. }
  321. break;
  322. case PhoneService_Method_SetCallingParam:
  323. {
  324. SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx;
  325. ctx.Attach(new SpOnewayCallContext<PhoneService_SetCallingParam_Info>());
  326. SpBuffer2Object(Buf, ctx->Info);
  327. Handle_SetCallingParam(ctx);
  328. }
  329. break;
  330. case PhoneService_Method_GetHandfreeOutVolume:
  331. {
  332. SpReqAnsContext<PhoneService_GetHandfreeOutVolume_Req,PhoneService_GetHandfreeOutVolume_Ans>::Pointer ctx;
  333. ctx.Attach(new SpReqAnsContext<PhoneService_GetHandfreeOutVolume_Req,PhoneService_GetHandfreeOutVolume_Ans>(pTransactionContext));
  334. SpBuffer2Object(Buf, ctx->Req);
  335. Handle_GetHandfreeOutVolume(ctx);
  336. }
  337. break;
  338. case PhoneService_Method_SetHandfreeOutVolume:
  339. {
  340. SpReqAnsContext<PhoneService_SetHandfreeOutVolume_Req,PhoneService_SetHandfreeOutVolume_Ans>::Pointer ctx;
  341. ctx.Attach(new SpReqAnsContext<PhoneService_SetHandfreeOutVolume_Req,PhoneService_SetHandfreeOutVolume_Ans>(pTransactionContext));
  342. SpBuffer2Object(Buf, ctx->Req);
  343. Handle_SetHandfreeOutVolume(ctx);
  344. }
  345. break;
  346. case PhoneService_Method_SetPickupOutVolume:
  347. {
  348. SpReqAnsContext<PhoneService_SetPickupOutVolume_Req,PhoneService_SetPickupOutVolume_Ans>::Pointer ctx;
  349. ctx.Attach(new SpReqAnsContext<PhoneService_SetPickupOutVolume_Req,PhoneService_SetPickupOutVolume_Ans>(pTransactionContext));
  350. SpBuffer2Object(Buf, ctx->Req);
  351. Handle_SetPickupOutVolume(ctx);
  352. }
  353. break;
  354. case PhoneService_Method_GetPickupOutVolume:
  355. {
  356. SpReqAnsContext<PhoneService_GetPickupOutVolume_Req,PhoneService_GetPickupOutVolume_Ans>::Pointer ctx;
  357. ctx.Attach(new SpReqAnsContext<PhoneService_GetPickupOutVolume_Req,PhoneService_GetPickupOutVolume_Ans>(pTransactionContext));
  358. SpBuffer2Object(Buf, ctx->Req);
  359. Handle_GetPickupOutVolume(ctx);
  360. }
  361. break;
  362. default:
  363. assert(0);
  364. break;
  365. }
  366. } else {
  367. pTransactionContext->SendAnswer(Error);
  368. }
  369. }
  370. };
  371. ///////////////////////////
  372. } // namespace SIPPhone
  373. #endif // __SIPPHONE_SERVER_G_H