nea 1.12.11devel
Loading...
Searching...
No Matches
nea.h
Go to the documentation of this file.
1/*
2 * This file is part of the Sofia-SIP package
3 *
4 * Copyright (C) 2005 Nokia Corporation.
5 *
6 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef NEA_H
27#define NEA_H
37#ifndef SU_ALLOC_H
38#include <sofia-sip/su_alloc.h>
39#endif
40
41#include <sofia-sip/su_tag.h>
42
43#ifndef NTA_H
44#include <sofia-sip/nta.h>
45#endif
46
47#ifndef NEA_TAG_H
48#include <sofia-sip/nea_tag.h>
49#endif
50
51SOFIA_BEGIN_DECLS
52
53#define NEA_VERSION 3.0
54#define NEA_VERSION_STR "3.0"
55
56#define NEA_DEFAULT_EXPIRES 3600
57
59typedef struct nea_server_s nea_server_t;
60
62typedef struct nea_sub_s nea_sub_t;
63
65typedef struct nea_event_s nea_event_t;
66
68typedef struct nea_event_view_s nea_event_view_t;
69
70#ifndef NEA_SMAGIC_T
71#define NEA_SMAGIC_T struct nea_smagic_t
72#endif
74typedef NEA_SMAGIC_T nea_smagic_t;
75
76#ifndef NEA_EMAGIC_T
77#define NEA_EMAGIC_T struct nea_emagic_t
78#endif
80typedef NEA_EMAGIC_T nea_emagic_t;
81
82#ifndef NEA_EVMAGIC_T
83#define NEA_EVMAGIC_T struct nea_evmagic_t
84#endif
86typedef NEA_EVMAGIC_T nea_evmagic_t;
87
112
114typedef struct nea_payloads_s nea_payloads_t;
115
128typedef int (nea_new_event_f)(nea_smagic_t *context,
129 nea_server_t *nes,
130 nea_event_t **event_p,
131 nea_event_view_t **view_p,
132 nta_incoming_t *irq,
133 sip_t const *sip);
134
138 su_root_t *root,
139 url_t const *url,
140 int max_subs,
141 nea_new_event_f *callback,
142 nea_smagic_t *context,
143 tag_type_t tag, tag_value_t value,
144 ...);
145
146
148SOFIAPUBFUN int nea_server_shutdown(nea_server_t *nes, int retry_after);
149
152
155
159 nea_event_t *ev,
160 tag_type_t tag,
161 tag_value_t value,
162 ...);
163
167 nta_leg_t *leg,
168 sip_contact_t const *local_target,
169 nta_incoming_t *irq,
170 sip_t const *sip);
171
181typedef void (nea_watcher_f)(nea_server_t *nes,
182 nea_emagic_t *context,
183 nea_event_t *event,
184 nea_subnode_t *subnode,
185 sip_t const *sip);
186
190 nea_watcher_f *callback,
191 nea_emagic_t *context,
192 char const *name,
193 char const *subname,
194 char const *default_content_type,
195 char const *accept);
196
200 nea_watcher_f *callback,
201 nea_emagic_t *context,
202 char const *name,
203 char const *subname,
204 tag_type_t, tag_value_t, ...);
205
208
210SOFIAPUBFUN nea_event_t *nea_event_get(nea_server_t const *, char const *name);
211
214
217
222 nea_event_t const *ev);
223
227
231 nea_event_t *ev);
232
236 nea_event_t *ev,
237 nea_sub_t *ns);
238
239#define nea_server_auth nea_sub_auth
240
243
247 tag_type_t, tag_value_t, ...);
248
252SOFIAPUBFUN int nea_sub_version(nea_sub_t *, unsigned);
253
256
257#if 0
263void nea_server_qauth(nea_server_t *nes,
264 nea_emagic_t *context,
265 nea_sub_t *subscriber,
266 sip_t const *sip);
267#endif
268
271nea_event_view_t *nea_event_view(nea_event_t *, char const *content_type);
272
275sip_content_type_t const *nea_view_content_type(nea_event_view_t const *);
276
279
282 nea_event_t *ev,
283 nea_evmagic_t *magic,
284 tag_type_t tag,
285 tag_value_t value,
286 ...);
287
290
291SOFIAPUBFUN nea_evmagic_t *nea_view_magic(nea_event_view_t const *);
292
293SOFIAPUBFUN void nea_view_set_magic(nea_event_view_t *, nea_evmagic_t *magic);
294
295SOFIAPUBFUN unsigned nea_view_version(nea_event_view_t const *);
296
298#define NEATAG_RELIABLE(x) neatag_reliable, tag_bool_v((x))
299SOFIAPUBVAR tag_typedef_t neatag_reliable;
300
301#define NEATAG_RELIABLE_REF(x) neatag_reliable_ref, tag_bool_vr((&x))
302SOFIAPUBVAR tag_typedef_t neatag_reliable_ref;
303
305#define NEATAG_VIEW(x) neatag_view, tag_ptr_v((x))
306SOFIAPUBVAR tag_typedef_t neatag_view;
307
308#define NEATAG_VIEW_REF(x) neatag_view_ref, tag_ptr_vr((&x), (x))
309SOFIAPUBVAR tag_typedef_t neatag_view_ref;
310
312#define NEATAG_EVMAGIC(x) neatag_evmagic, tag_ptr_v((x))
313SOFIAPUBVAR tag_typedef_t neatag_evmagic;
314
315#define NEATAG_EVMAGIC_REF(x) neatag_evmagic_ref, tag_ptr_vr((&x), (x))
316SOFIAPUBVAR tag_typedef_t neatag_evmagic_ref;
317
319#define NEATAG_SUB(x) neatag_sub, tag_ptr_v((x))
320SOFIAPUBVAR tag_typedef_t neatag_sub;
321
322#define NEATAG_SUB_REF(x) neatag_sub_ref, tag_ptr_vr((&x), (x))
323SOFIAPUBVAR tag_typedef_t neatag_sub_ref;
324
325
326/* ====================================================================== */
327/* Watcher side */
328
330typedef struct nea_s nea_t;
331
332#ifndef NEA_MAGIC_T
333#define NEA_MAGIC_T struct nea_magic_t
334#endif
335
337typedef NEA_MAGIC_T nea_magic_t;
338
344typedef int (*nea_notify_f)(nea_t *nea,
345 nea_magic_t *context,
346 sip_t const *sip);
347
348/* ====================================================================== */
349/* Client side */
350
354 su_root_t *root,
355 nea_notify_f no_callback,
356 nea_magic_t *context,
357 tag_type_t tag,
358 tag_value_t value,
359 ...);
360
363int nea_update(nea_t *nea,
364 tag_type_t tag,
365 tag_value_t value,
366 ...);
367
369SOFIAPUBFUN void nea_end(nea_t *agent);
370
372SOFIAPUBFUN void nea_destroy(nea_t *agent);
373
374SOFIAPUBFUN char const *nea_default_content_type(char const *event);
375
376SOFIA_END_DECLS
377
378#endif /* !defined(NEA_H) */
int nea_server_add_irq(nea_server_t *nes, nta_leg_t *leg, sip_contact_t const *local_target, nta_incoming_t *irq, sip_t const *sip)
Add a new subscriber from subscribe transaction to an existing notifier.
Definition nea_server.c:1497
int nea_server_notify_one(nea_server_t *nes, nea_event_t *ev, nea_sub_t *ns)
Notify a subscriber.
int nea_server_active(nea_server_t *nes, nea_event_t const *ev)
Get number of active subscribers.
Definition nea_server.c:2185
void nea_server_destroy(nea_server_t *nes)
Destroy a server.
Definition nea_server.c:584
NEA_SMAGIC_T nea_smagic_t
NEA server context.
Definition nea.h:74
unsigned nea_sub_pending(nea_sub_t const *)
Return time until next notification can be sent.
struct nea_s nea_t
NEA Event Watcher.
Definition nea.h:330
nea_t * nea_create(nta_agent_t *agent, su_root_t *root, nea_notify_f no_callback, nea_magic_t *context, tag_type_t tag, tag_value_t value,...)
Create a subscription agent.
Definition nea.c:113
nea_server_t * nea_server_create(nta_agent_t *agent, su_root_t *root, url_t const *url, int max_subs, nea_new_event_f *callback, nea_smagic_t *context, tag_type_t tag, tag_value_t value,...)
Create a notifier server.
Definition nea_server.c:372
void nea_destroy(nea_t *agent)
Destroy a subscription agent.
Definition nea.c:312
NEA_MAGIC_T nea_magic_t
NEA Event Agent context.
Definition nea.h:337
NEA_EVMAGIC_T nea_evmagic_t
Event view context.
Definition nea.h:86
sip_content_type_t const * nea_view_content_type(nea_event_view_t const *)
Get a content type for event's payload.
Definition nea_server.c:930
int nea_sub_auth(nea_sub_t *, nea_state_t state, tag_type_t, tag_value_t,...)
Authorize a subscription.
Definition nea_server.c:2258
int nea_sub_version(nea_sub_t *, unsigned)
Set subscriber version sequence.
Definition nea_server.c:2226
nea_event_t * nea_event_tcreate(nea_server_t *nes, nea_watcher_f *callback, nea_emagic_t *context, char const *name, char const *subname, tag_type_t, tag_value_t,...)
Create a new event (or subevent) with tags.
Definition nea_server.c:1214
int nea_server_shutdown(nea_server_t *nes, int retry_after)
Shutdown an event server.
Definition nea_server.c:545
void nea_server_flush(nea_server_t *nes, nea_event_t *event)
Zap terminated subscribtions.
Definition nea_server.c:1066
int nea_server_non_embryonic(nea_server_t *nes, nea_event_t const *ev)
Get number of (non-embryonic) subscribers.
Definition nea_server.c:2211
struct nea_event_view_s nea_event_view_t
Event view.
Definition nea.h:68
struct nea_payloads_s nea_payloads_t
Multiple content types per event.
Definition nea.h:114
nea_event_t * nea_event_get(nea_server_t const *, char const *name)
Find a nea event object with given event name.
Definition nea_server.c:1359
void nea_end(nea_t *agent)
Unsubscribe agent.
Definition nea.c:290
void nea_server_free_subscribers(nea_server_t *nes, nea_subnode_t const **)
Free a list of subscriptions.
Definition nea_server.c:2348
sip_payload_t const * nea_view_payload(nea_event_view_t *)
Get actual payload for an event.
int nea_server_notify(nea_server_t *nes, nea_event_t *ev)
Notify subscribers.
Definition nea_server.c:1018
int() nea_new_event_f(nea_smagic_t *context, nea_server_t *nes, nea_event_t **event_p, nea_event_view_t **view_p, nta_incoming_t *irq, sip_t const *sip)
Unknown event callback.
Definition nea.h:128
nea_event_view_t * nea_view_create(nea_server_t *nes, nea_event_t *ev, nea_evmagic_t *magic, tag_type_t tag, tag_value_t value,...)
Create a private event view.
Definition nea_server.c:848
struct nea_sub_s nea_sub_t
Subscription object.
Definition nea.h:62
void() nea_watcher_f(nea_server_t *nes, nea_emagic_t *context, nea_event_t *event, nea_subnode_t *subnode, sip_t const *sip)
QAUTH callback function type.
Definition nea.h:181
int nea_update(nea_t *nea, tag_type_t tag, tag_value_t value,...)
Update SUBSCRIBE payload (filter rules)
Definition nea.c:221
int(* nea_notify_f)(nea_t *nea, nea_magic_t *context, sip_t const *sip)
Event notification callback type.
Definition nea.h:344
nta_incoming_t * nea_sub_get_request(nea_sub_t *sub)
Get nta_incoming_t from nea_sub_t.
Definition nea_server.c:1371
struct nea_server_s nea_server_t
Event notifier object.
Definition nea.h:59
nea_emagic_t * nea_emagic_get(nea_event_t *event)
Return magic context bind to nea_event.
Definition nea_server.c:1349
NEA_EMAGIC_T nea_emagic_t
NEA server event context.
Definition nea.h:80
void nea_view_destroy(nea_server_t *nes, nea_event_view_t *ev)
Destroy a private event view.
Definition nea_server.c:870
nea_event_view_t * nea_event_view(nea_event_t *, char const *content_type)
Get primary event view for given content type
Definition nea_server.c:912
nea_event_t * nea_event_create(nea_server_t *nes, nea_watcher_f *callback, nea_emagic_t *context, char const *name, char const *subname, char const *default_content_type, char const *accept)
Create a new event (or subevent)
Definition nea_server.c:1198
nta_incoming_t * nea_subnode_get_incoming(nea_subnode_t *sn)
Get nta_incoming_t from sn->sn_subscriber.
Definition nea_server.c:1137
nea_subnode_t const ** nea_server_get_subscribers(nea_server_t *nes, nea_event_t const *ev)
Obtain a list of subscriptions.
Definition nea_server.c:2313
struct nea_event_s nea_event_t
Event.
Definition nea.h:65
int nea_server_update(nea_server_t *nes, nea_event_t *ev, tag_type_t tag, tag_value_t value,...)
Update event information.
Definition nea_server.c:667
Tags for Nokia User Agent Library.
nea_state_t
Event states.
Definition nea_tag.h:54
struct nta_leg_s nta_leg_t
struct nta_incoming_s nta_incoming_t
struct nta_agent_s nta_agent_t
msg_time_t sip_time_t
Description of subscription.
Definition nea.h:89
unsigned sn_version
Latest notified version # by application.
Definition nea.h:107
nea_sub_t * sn_subscriber
Pointer to subscriber object.
Definition nea.h:95
unsigned sn_expires
When subscription expires.
Definition nea.h:104
sip_contact_t const * sn_contact
Contact of subscriber.
Definition nea.h:98
nea_state_t sn_state
Subscription state.
Definition nea.h:90
sip_time_t sn_notified
When latest notify was sent.
Definition nea.h:108
nea_event_view_t * sn_view
Event view for this subscriber.
Definition nea.h:110
sip_from_t const * sn_remote
Identity of subscriber.
Definition nea.h:97
sip_payload_t const * sn_payload
Body of subscribe.
Definition nea.h:102
sip_time_t sn_subscribed
When first SUBSCRIBE was recv.
Definition nea.h:109
sip_content_type_t const * sn_content_type
Content-Type of SUBSCRIBE body (filter).
Definition nea.h:101
unsigned sn_throttle
Throttle value.
Definition nea.h:106
unsigned sn_eventlist
Subscriber supports eventlist.
Definition nea.h:94
nea_event_t * sn_event
Event.
Definition nea.h:96
unsigned sn_fake
True if subscriber is given fake contents.
Definition nea.h:91
unsigned sn_latest
Latest notification version.
Definition nea.h:105
#define SOFIAPUBFUN
#define SOFIAPUBVAR
struct tag_type_s const tag_typedef_t[1]
intptr_t tag_value_t
struct tag_type_s const * tag_type_t
struct su_root_t su_root_t

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.