summaryrefslogtreecommitdiffstats
path: root/bindings/winrt/doubango_rt/src/rt_SipEvent.cxx
blob: 1bd414e5b57159f7c19bf0fe3de5624de6de50f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
*	
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*	
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*/
#include "rt_SipEvent.h"
#include "rt_String.h"
#include "rt_SipMessage.h"
#include "rt_SipSession.h"

#include "tinysip/tsip_event.h"

#include "SipMessage.h"
#include "SipSession.h"
#include "SipEvent.h"

using namespace doubango_rt::BackEnd;
using namespace Platform;
using namespace std;

#define rt_getSession_Implement(cls) \
rt##cls##Session^ rt##cls##Event::getSession(){ \
	const cls##Session* s = m_pEvent->getSession(); \
	if(s){ \
		return ref new rt##cls##Session(const_cast<SipStack*>(const_cast<##cls##Session*>(s)->getStack()), const_cast<tsip_ssession_handle_t*>(const_cast<##cls##Session*>(s)->getWrappedSession())); \
	} \
	return nullptr; \
} \

#define rt_takeOwnership_Implement(cls, name, session) \
rt##name##Session^ rt##cls##Event::take##session##Ownership(){ \
	name##Session* s = m_pEvent->take##session##Ownership(); \
	if(s){ \
		rt##name##Session^ _s = ref new rt##name##Session(const_cast<SipStack*>(s->getStack()), const_cast<tsip_ssession_handle_t*>(s->getWrappedSession())); \
		rtSafeDelete(s); \
		return _s; \
	} \
	return nullptr; \
} \

/* ======================== rtDialogEvent ========================*/
rtISipEvent_Implement(rtDialogEvent);

rtDialogEvent::rtDialogEvent(const struct tsip_event_s *e)
{
	m_pEvent = new DialogEvent(e);
}

rtDialogEvent::~rtDialogEvent()
{
	rtSafeDelete(m_pEvent);
}


/* ======================== rtStackEvent ========================*/
rtISipEvent_Implement(rtStackEvent);

rtStackEvent::rtStackEvent(const struct tsip_event_s *e)
{
	m_pEvent = new StackEvent(e);
}

rtStackEvent::~rtStackEvent()
{
	rtSafeDelete(m_pEvent);
}


 /* ======================== rtInviteEvent ========================*/
rtISipEvent_Implement(rtInviteEvent);

rtInviteEvent::rtInviteEvent(const struct tsip_event_s *e)
{
	m_pEvent = new InviteEvent(e);
}

rtInviteEvent::~rtInviteEvent()
{
	rtSafeDelete(m_pEvent);
}

rt_tsip_invite_event_type_t rtInviteEvent::getType()
{
	return (rt_tsip_invite_event_type_t)m_pEvent->getType();
}

rt_twrap_media_type_t rtInviteEvent::getMediaType()
{
	return (rt_twrap_media_type_t)m_pEvent->getMediaType();
}

rt_getSession_Implement(Invite);
rt_takeOwnership_Implement(Invite, Call, CallSession);
rt_takeOwnership_Implement(Invite, Msrp, MsrpSession);

/* ======================== rtMessagingEvent ========================*/
rtISipEvent_Implement(rtMessagingEvent);

rtMessagingEvent::rtMessagingEvent(const struct tsip_event_s *e)
{
	m_pEvent = new MessagingEvent(e);
}

	
rtMessagingEvent::~rtMessagingEvent()
{
	rtSafeDelete(m_pEvent);
}	

rt_tsip_message_event_type_t rtMessagingEvent::getType()
{
	return (rt_tsip_message_event_type_t)m_pEvent->getType();
}

rt_getSession_Implement(Messaging);
rt_takeOwnership_Implement(Messaging, Messaging, Session);


/* ======================== rtInfoEvent ========================*/
rtISipEvent_Implement(rtInfoEvent);

rtInfoEvent::rtInfoEvent(const struct tsip_event_s *e)
{
	m_pEvent = new InfoEvent(e);
}

rtInfoEvent::~rtInfoEvent()
{
	rtSafeDelete(m_pEvent);
}

rt_tsip_info_event_type_t rtInfoEvent::getType()
{
	return (rt_tsip_info_event_type_t)m_pEvent->getType();
}

rt_getSession_Implement(Info);
rt_takeOwnership_Implement(Info, Info, Session);


/* ======================== rtOptionsEvent ========================*/
rtISipEvent_Implement(rtOptionsEvent);

rtOptionsEvent::rtOptionsEvent(const struct tsip_event_s *e)
{
	m_pEvent = new OptionsEvent(e);
}

rtOptionsEvent::~rtOptionsEvent()
{
	rtSafeDelete(m_pEvent);
}

rt_tsip_options_event_type_t rtOptionsEvent::getType()
{
	return (rt_tsip_options_event_type_t)m_pEvent->getType();
}

rt_getSession_Implement(Options);
rt_takeOwnership_Implement(Options, Options, Session);


/* ======================== rtPublicationEvent ========================*/
rtISipEvent_Implement(rtPublicationEvent);

rtPublicationEvent::rtPublicationEvent(const struct tsip_event_s *e)
{
	m_pEvent = new PublicationEvent(e);
}

rtPublicationEvent::~rtPublicationEvent()
{
	rtSafeDelete(m_pEvent);
}

rt_tsip_publish_event_type_t rtPublicationEvent::getType()
{
	return (rt_tsip_publish_event_type_t)m_pEvent->getType();
}

rt_getSession_Implement(Publication);
rt_takeOwnership_Implement(Publication, Publication, Session);



/* ======================== rtRegistrationEvent ========================*/
rtISipEvent_Implement(rtRegistrationEvent);

rtRegistrationEvent::rtRegistrationEvent(const struct tsip_event_s *e)
{
	m_pEvent = new RegistrationEvent(e);
}

rtRegistrationEvent::~rtRegistrationEvent()
{
	rtSafeDelete(m_pEvent);
}

rt_tsip_register_event_type_t rtRegistrationEvent::getType()
{
	return (rt_tsip_register_event_type_t)m_pEvent->getType();
}

rt_getSession_Implement(Registration);
rt_takeOwnership_Implement(Registration, Registration, Session);


/* ======================== rtSubscriptionEvent ========================*/
rtISipEvent_Implement(rtSubscriptionEvent);

rtSubscriptionEvent::rtSubscriptionEvent(const struct tsip_event_s *e)
{
	m_pEvent = new SubscriptionEvent(e);
}

rtSubscriptionEvent::~rtSubscriptionEvent()
{
	rtSafeDelete(m_pEvent);
}

rt_tsip_subscribe_event_type_t rtSubscriptionEvent::getType()
{
	return (rt_tsip_subscribe_event_type_t)m_pEvent->getType();
}

rt_getSession_Implement(Subscription);
rt_takeOwnership_Implement(Subscription, Subscription, Session);
OpenPOWER on IntegriCloud