rt_SipEvent.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #pragma once
  19. #include "rt_Config.h"
  20. #include "rt_Enums.h"
  21. struct tsip_event_s;
  22. class SipEvent;
  23. class DialogEvent;
  24. class StackEvent;
  25. class InviteEvent;
  26. class MessagingEvent;
  27. class InfoEvent;
  28. class OptionsEvent;
  29. class PublicationEvent;
  30. class RegistrationEvent;
  31. class SubscriptionEvent;
  32. #define rtISipEvent_Declare() \
  33. virtual short getCode(); \
  34. virtual Platform::String^ getPhrase(); \
  35. virtual rtISipSession^ getBaseSession(); \
  36. virtual rtSipMessage^ getSipMessage(); \
  37. #define rtISipEvent_Implement(cls) \
  38. short cls##::getCode(){ \
  39. return m_pEvent->getCode(); \
  40. } \
  41. Platform::String^ cls##::getPhrase(){ \
  42. return rtString::toString(m_pEvent->getPhrase()); \
  43. } \
  44. rtISipSession^ cls##::getBaseSession(){ \
  45. return ref new rtSipSession(const_cast<SipStack*>(m_pEvent->getStack()), const_cast<tsip_ssession_handle_t*>(m_pEvent->getWrappedEvent()->ss)); \
  46. } \
  47. rtSipMessage^ cls##::getSipMessage(){ \
  48. return ref new rtSipMessage(const_cast<struct tsip_message_s*>(const_cast<SipMessage*>(m_pEvent->getSipMessage())->getWrappedSipMessage())); \
  49. } \
  50. namespace doubango_rt
  51. {
  52. namespace BackEnd
  53. {
  54. interface class rtISipSession;
  55. ref class rtSipMessage;
  56. ref class rtInviteSession;
  57. ref class rtMsrpSession;
  58. ref class rtCallSession;
  59. ref class rtMessagingSession;
  60. ref class rtInfoSession;
  61. ref class rtOptionsSession;
  62. ref class rtPublicationSession;
  63. ref class rtRegistrationSession;
  64. ref class rtSubscriptionSession;
  65. /* ======================== rtISipEvent ========================*/
  66. public interface class rtISipEvent
  67. {
  68. short getCode();
  69. Platform::String^ getPhrase();
  70. rtISipSession^ getBaseSession();
  71. rtSipMessage^ getSipMessage();
  72. };
  73. /* ======================== rtDialogEvent ========================*/
  74. public ref class rtDialogEvent sealed : rtISipEvent
  75. {
  76. internal:
  77. rtDialogEvent(const struct tsip_event_s *e);
  78. public:
  79. virtual ~rtDialogEvent();
  80. rtISipEvent_Declare();
  81. private:
  82. DialogEvent* m_pEvent;
  83. };
  84. /* ======================== rtStackEvent ========================*/
  85. public ref class rtStackEvent sealed : rtISipEvent
  86. {
  87. internal:
  88. rtStackEvent(const struct tsip_event_s *e);
  89. public:
  90. virtual ~rtStackEvent();
  91. rtISipEvent_Declare();
  92. private:
  93. StackEvent* m_pEvent;
  94. };
  95. /* ======================== rtInviteEvent ========================*/
  96. public ref class rtInviteEvent sealed : rtISipEvent
  97. {
  98. internal:
  99. rtInviteEvent(const struct tsip_event_s *e);
  100. public:
  101. virtual ~rtInviteEvent();
  102. rtISipEvent_Declare();
  103. rt_tsip_invite_event_type_t getType();
  104. rt_twrap_media_type_t getMediaType();
  105. rtInviteSession^ getSession();
  106. rtCallSession^ takeCallSessionOwnership();
  107. rtMsrpSession^ takeMsrpSessionOwnership();
  108. private:
  109. InviteEvent* m_pEvent;
  110. };
  111. /* ======================== rtMessagingEvent ========================*/
  112. public ref class rtMessagingEvent sealed : rtISipEvent
  113. {
  114. internal:
  115. rtMessagingEvent(const struct tsip_event_s *e);
  116. public:
  117. virtual ~rtMessagingEvent();
  118. rtISipEvent_Declare();
  119. rt_tsip_message_event_type_t getType();
  120. rtMessagingSession^ getSession();
  121. rtMessagingSession^ takeSessionOwnership();
  122. private:
  123. MessagingEvent* m_pEvent;
  124. };
  125. /* ======================== rtInfoEvent ========================*/
  126. public ref class rtInfoEvent sealed : rtISipEvent
  127. {
  128. internal:
  129. rtInfoEvent(const struct tsip_event_s *e);
  130. public:
  131. virtual ~rtInfoEvent();
  132. rtISipEvent_Declare();
  133. rt_tsip_info_event_type_t getType();
  134. rtInfoSession^ getSession();
  135. rtInfoSession^ takeSessionOwnership();
  136. private:
  137. InfoEvent* m_pEvent;
  138. };
  139. /* ======================== rtOptionsEvent ========================*/
  140. public ref class rtOptionsEvent sealed : rtISipEvent
  141. {
  142. internal:
  143. rtOptionsEvent(const struct tsip_event_s *e);
  144. public:
  145. virtual ~rtOptionsEvent();
  146. rtISipEvent_Declare();
  147. rt_tsip_options_event_type_t getType();
  148. rtOptionsSession^ getSession();
  149. rtOptionsSession^ takeSessionOwnership();
  150. private:
  151. OptionsEvent* m_pEvent;
  152. };
  153. /* ======================== rtPublicationEvent ========================*/
  154. public ref class rtPublicationEvent sealed : rtISipEvent
  155. {
  156. internal:
  157. rtPublicationEvent(const struct tsip_event_s *e);
  158. public:
  159. virtual ~rtPublicationEvent();
  160. rtISipEvent_Declare();
  161. rt_tsip_publish_event_type_t getType();
  162. rtPublicationSession^ getSession();
  163. rtPublicationSession^ takeSessionOwnership();
  164. private:
  165. PublicationEvent* m_pEvent;
  166. };
  167. /* ======================== rtRegistrationEvent ========================*/
  168. public ref class rtRegistrationEvent sealed : rtISipEvent
  169. {
  170. internal:
  171. rtRegistrationEvent(const struct tsip_event_s *e);
  172. public:
  173. virtual ~rtRegistrationEvent();
  174. rtISipEvent_Declare();
  175. rt_tsip_register_event_type_t getType();
  176. rtRegistrationSession^ getSession();
  177. rtRegistrationSession^ takeSessionOwnership();
  178. private:
  179. RegistrationEvent* m_pEvent;
  180. };
  181. /* ======================== rtSubscriptionEvent ========================*/
  182. public ref class rtSubscriptionEvent sealed : rtISipEvent
  183. {
  184. internal:
  185. rtSubscriptionEvent(const struct tsip_event_s *e);
  186. public:
  187. virtual ~rtSubscriptionEvent();
  188. rtISipEvent_Declare();
  189. rt_tsip_subscribe_event_type_t getType();
  190. rtSubscriptionSession^ getSession();
  191. rtSubscriptionSession^ takeSessionOwnership();
  192. private:
  193. SubscriptionEvent* m_pEvent;
  194. };
  195. }
  196. }