Loading...
Searching...
No Matches
nea.h
Go to the documentation of this file.
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef NEA_H
#define NEA_H
#ifndef SU_ALLOC_H
#include <sofia-sip/su_alloc.h>
#endif
#include <sofia-sip/su_tag.h>
#ifndef NTA_H
#include <sofia-sip/nta.h>
#endif
#ifndef NEA_TAG_H
#include <sofia-sip/nea_tag.h>
#endif
SOFIA_BEGIN_DECLS
#define NEA_VERSION 3.0
#define NEA_VERSION_STR "3.0"
#define NEA_DEFAULT_EXPIRES 3600
typedef struct nea_server_s nea_server_t;
typedef struct nea_sub_s nea_sub_t;
typedef struct nea_event_s nea_event_t;
typedef struct nea_event_view_s nea_event_view_t;
#ifndef NEA_SMAGIC_T
#define NEA_SMAGIC_T struct nea_smagic_t
#endif
typedef NEA_SMAGIC_T nea_smagic_t;
#ifndef NEA_EMAGIC_T
#define NEA_EMAGIC_T struct nea_emagic_t
#endif
typedef NEA_EMAGIC_T nea_emagic_t;
#ifndef NEA_EVMAGIC_T
#define NEA_EVMAGIC_T struct nea_evmagic_t
#endif
typedef NEA_EVMAGIC_T nea_evmagic_t;
typedef struct nea_subnode_t {
nea_state_t sn_state;
unsigned sn_fake;
unsigned sn_eventlist;
nea_sub_t *sn_subscriber;
nea_event_t *sn_event;
sip_from_t const *sn_remote;
sip_contact_t const *sn_contact;
sip_content_type_t const *sn_content_type;
sip_payload_t const *sn_payload;
unsigned sn_expires;
unsigned sn_latest;
unsigned sn_throttle;
unsigned sn_version;
sip_time_t sn_notified;
sip_time_t sn_subscribed;
nea_event_view_t *sn_view;
} nea_subnode_t;
typedef struct nea_payloads_s nea_payloads_t;
typedef 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);
SOFIAPUBFUN
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,
...);
SOFIAPUBFUN int nea_server_shutdown(nea_server_t *nes, int retry_after);
SOFIAPUBFUN void nea_server_destroy(nea_server_t *nes);
SOFIAPUBFUN void nea_server_flush(nea_server_t *nes, nea_event_t *event);
SOFIAPUBFUN
int nea_server_update(nea_server_t *nes,
nea_event_t *ev,
tag_type_t tag,
tag_value_t value,
...);
SOFIAPUBFUN
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);
typedef void (nea_watcher_f)(nea_server_t *nes,
nea_emagic_t *context,
nea_event_t *event,
nea_subnode_t *subnode,
sip_t const *sip);
SOFIAPUBFUN
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);
SOFIAPUBFUN
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, ...);
SOFIAPUBFUN nea_emagic_t *nea_emagic_get(nea_event_t *event);
SOFIAPUBFUN nea_event_t *nea_event_get(nea_server_t const *, char const *name);
SOFIAPUBFUN int nea_server_active(nea_server_t *nes, nea_event_t const *ev);
int nea_server_non_embryonic(nea_server_t *nes, nea_event_t const *ev);
SOFIAPUBFUN
nea_subnode_t const **nea_server_get_subscribers(nea_server_t *nes,
nea_event_t const *ev);
SOFIAPUBFUN
void nea_server_free_subscribers(nea_server_t *nes, nea_subnode_t const **);
SOFIAPUBFUN
int nea_server_notify(nea_server_t *nes,
nea_event_t *ev);
SOFIAPUBFUN
int nea_server_notify_one(nea_server_t *nes,
nea_event_t *ev,
nea_sub_t *ns);
#define nea_server_auth nea_sub_auth
SOFIAPUBFUN nta_incoming_t *nea_sub_get_request(nea_sub_t *sub);
SOFIAPUBFUN
int nea_sub_auth(nea_sub_t *, nea_state_t state,
tag_type_t, tag_value_t, ...);
SOFIAPUBFUN nta_incoming_t *nea_subnode_get_incoming(nea_subnode_t *sn);
SOFIAPUBFUN int nea_sub_version(nea_sub_t *, unsigned);
SOFIAPUBFUN unsigned nea_sub_pending(nea_sub_t const *);
#if 0
void nea_server_qauth(nea_server_t *nes,
nea_emagic_t *context,
nea_sub_t *subscriber,
sip_t const *sip);
#endif
SOFIAPUBFUN
nea_event_view_t *nea_event_view(nea_event_t *, char const *content_type);
SOFIAPUBFUN
sip_content_type_t const *nea_view_content_type(nea_event_view_t const *);
SOFIAPUBFUN sip_payload_t const *nea_view_payload(nea_event_view_t *);
SOFIAPUBFUN 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,
...);
SOFIAPUBFUN void nea_view_destroy(nea_server_t *nes, nea_event_view_t *ev);
SOFIAPUBFUN nea_evmagic_t *nea_view_magic(nea_event_view_t const *);
SOFIAPUBFUN void nea_view_set_magic(nea_event_view_t *, nea_evmagic_t *magic);
SOFIAPUBFUN unsigned nea_view_version(nea_event_view_t const *);
#define NEATAG_RELIABLE(x) neatag_reliable, tag_bool_v((x))
SOFIAPUBVAR tag_typedef_t neatag_reliable;
#define NEATAG_RELIABLE_REF(x) neatag_reliable_ref, tag_bool_vr((&x))
SOFIAPUBVAR tag_typedef_t neatag_reliable_ref;
#define NEATAG_VIEW(x) neatag_view, tag_ptr_v((x))
SOFIAPUBVAR tag_typedef_t neatag_view;
#define NEATAG_VIEW_REF(x) neatag_view_ref, tag_ptr_vr((&x), (x))
SOFIAPUBVAR tag_typedef_t neatag_view_ref;
#define NEATAG_EVMAGIC(x) neatag_evmagic, tag_ptr_v((x))
SOFIAPUBVAR tag_typedef_t neatag_evmagic;
#define NEATAG_EVMAGIC_REF(x) neatag_evmagic_ref, tag_ptr_vr((&x), (x))
SOFIAPUBVAR tag_typedef_t neatag_evmagic_ref;
#define NEATAG_SUB(x) neatag_sub, tag_ptr_v((x))
SOFIAPUBVAR tag_typedef_t neatag_sub;
#define NEATAG_SUB_REF(x) neatag_sub_ref, tag_ptr_vr((&x), (x))
SOFIAPUBVAR tag_typedef_t neatag_sub_ref;
/* ====================================================================== */
/* Watcher side */
typedef struct nea_s nea_t;
#ifndef NEA_MAGIC_T
#define NEA_MAGIC_T struct nea_magic_t
#endif
typedef NEA_MAGIC_T nea_magic_t;
typedef int (*nea_notify_f)(nea_t *nea,
nea_magic_t *context,
sip_t const *sip);
/* ====================================================================== */
/* Client side */
SOFIAPUBFUN
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,
...);
SOFIAPUBFUN
int nea_update(nea_t *nea,
tag_type_t tag,
tag_value_t value,
...);
SOFIAPUBFUN void nea_end(nea_t *agent);
SOFIAPUBFUN void nea_destroy(nea_t *agent);
SOFIAPUBFUN char const *nea_default_content_type(char const *event);
SOFIA_END_DECLS
#endif /* !defined(NEA_H) */
sip_contact_t
struct sip_contact_s sip_contact_t
sip_content_type_t
struct msg_content_type_s sip_content_type_t
sip_from_t
struct sip_addr_s sip_from_t
sip_payload_t
msg_payload_t sip_payload_t
nea_server_add_irq
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
nea_watcher_f
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
nea_server_notify_one
int nea_server_notify_one(nea_server_t *nes, nea_event_t *ev, nea_sub_t *ns)
Notify a subscriber.
nea_server_active
int nea_server_active(nea_server_t *nes, nea_event_t const *ev)
Get number of active subscribers.
Definition nea_server.c:2185
nea_server_destroy
void nea_server_destroy(nea_server_t *nes)
Destroy a server.
Definition nea_server.c:584
nea_smagic_t
NEA_SMAGIC_T nea_smagic_t
NEA server context.
Definition nea.h:74
nea_sub_pending
unsigned nea_sub_pending(nea_sub_t const *)
Return time until next notification can be sent.
nea_t
struct nea_s nea_t
NEA Event Watcher.
Definition nea.h:330
nea_create
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_create
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
nea_destroy
void nea_destroy(nea_t *agent)
Destroy a subscription agent.
Definition nea.c:312
nea_magic_t
NEA_MAGIC_T nea_magic_t
NEA Event Agent context.
Definition nea.h:337
nea_evmagic_t
NEA_EVMAGIC_T nea_evmagic_t
Event view context.
Definition nea.h:86
nea_view_content_type
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
nea_sub_auth
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
nea_sub_version
int nea_sub_version(nea_sub_t *, unsigned)
Set subscriber version sequence.
Definition nea_server.c:2226
nea_new_event_f
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_tcreate
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
nea_server_shutdown
int nea_server_shutdown(nea_server_t *nes, int retry_after)
Shutdown an event server.
Definition nea_server.c:545
nea_server_flush
void nea_server_flush(nea_server_t *nes, nea_event_t *event)
Zap terminated subscribtions.
Definition nea_server.c:1066
nea_server_non_embryonic
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
nea_event_view_t
struct nea_event_view_s nea_event_view_t
Event view.
Definition nea.h:68
nea_payloads_t
struct nea_payloads_s nea_payloads_t
Multiple content types per event.
Definition nea.h:114
nea_event_get
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
nea_end
void nea_end(nea_t *agent)
Unsubscribe agent.
Definition nea.c:290
nea_server_free_subscribers
void nea_server_free_subscribers(nea_server_t *nes, nea_subnode_t const **)
Free a list of subscriptions.
Definition nea_server.c:2348
nea_view_payload
sip_payload_t const * nea_view_payload(nea_event_view_t *)
Get actual payload for an event.
nea_server_notify
int nea_server_notify(nea_server_t *nes, nea_event_t *ev)
Notify subscribers.
Definition nea_server.c:1018
nea_view_create
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
nea_sub_t
struct nea_sub_s nea_sub_t
Subscription object.
Definition nea.h:62
nea_update
int nea_update(nea_t *nea, tag_type_t tag, tag_value_t value,...)
Update SUBSCRIBE payload (filter rules).
Definition nea.c:221
nea_notify_f
int(* nea_notify_f)(nea_t *nea, nea_magic_t *context, sip_t const *sip)
Event notification callback type.
Definition nea.h:344
nea_sub_get_request
nta_incoming_t * nea_sub_get_request(nea_sub_t *sub)
Get nta_incoming_t from nea_sub_t.
Definition nea_server.c:1371
nea_server_t
struct nea_server_s nea_server_t
Event notifier object.
Definition nea.h:59
nea_emagic_get
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_emagic_t
NEA server event context.
Definition nea.h:80
nea_view_destroy
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
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_create
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
nea_subnode_get_incoming
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_server_get_subscribers
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
nea_event_t
struct nea_event_s nea_event_t
Event.
Definition nea.h:65
nea_server_update
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
nea_tag.h
Tags for Nokia User Agent Library.
nea_state_t
nea_state_t
Event states.
Definition nea_tag.h:54
nta.h
nta_leg_t
struct nta_leg_s nta_leg_t
nta_incoming_t
struct nta_incoming_s nta_incoming_t
nta_agent_t
struct nta_agent_s nta_agent_t
sip_t
struct sip_s sip_t
sip_time_t
msg_time_t sip_time_t
nea_subnode_t
Description of subscription.
Definition nea.h:89
nea_subnode_t::sn_version
unsigned sn_version
Latest notified version # by application.
Definition nea.h:107
nea_subnode_t::sn_subscriber
nea_sub_t * sn_subscriber
Pointer to subscriber object.
Definition nea.h:95
nea_subnode_t::sn_expires
unsigned sn_expires
When subscription expires.
Definition nea.h:104
nea_subnode_t::sn_contact
sip_contact_t const * sn_contact
Contact of subscriber.
Definition nea.h:98
nea_subnode_t::sn_state
nea_state_t sn_state
Subscription state.
Definition nea.h:90
nea_subnode_t::sn_notified
sip_time_t sn_notified
When latest notify was sent.
Definition nea.h:108
nea_subnode_t::sn_view
nea_event_view_t * sn_view
Event view for this subscriber.
Definition nea.h:110
nea_subnode_t::sn_remote
sip_from_t const * sn_remote
Identity of subscriber.
Definition nea.h:97
nea_subnode_t::sn_payload
sip_payload_t const * sn_payload
Body of subscribe.
Definition nea.h:102
nea_subnode_t::sn_subscribed
sip_time_t sn_subscribed
When first SUBSCRIBE was recv.
Definition nea.h:109
nea_subnode_t::sn_content_type
sip_content_type_t const * sn_content_type
Content-Type of SUBSCRIBE body (filter).
Definition nea.h:101
nea_subnode_t::sn_throttle
unsigned sn_throttle
Throttle value.
Definition nea.h:106
nea_subnode_t::sn_eventlist
unsigned sn_eventlist
Subscriber supports eventlist.
Definition nea.h:94
nea_subnode_t::sn_event
nea_event_t * sn_event
Event.
Definition nea.h:96
nea_subnode_t::sn_fake
unsigned sn_fake
True if subscriber is given fake contents.
Definition nea.h:91
nea_subnode_t::sn_latest
unsigned sn_latest
Latest notification version.
Definition nea.h:105
url_t
su_alloc.h
SOFIAPUBFUN
#define SOFIAPUBFUN
SOFIAPUBVAR
#define SOFIAPUBVAR
su_tag.h
tag_typedef_t
struct tag_type_s const tag_typedef_t[1]
tag_value_t
intptr_t tag_value_t
tag_type_t
struct tag_type_s const * tag_type_t
su_root_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.