00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef NEA_H
00026
00027 #define NEA_H
00028
00037 #ifndef SU_ALLOC_H
00038 #include <sofia-sip/su_alloc.h>
00039 #endif
00040
00041 #include <sofia-sip/su_tag.h>
00042
00043 #ifndef NTA_H
00044 #include <sofia-sip/nta.h>
00045 #endif
00046
00047 #ifndef NEA_TAG_H
00048 #include <sofia-sip/nea_tag.h>
00049 #endif
00050
00051 SOFIA_BEGIN_DECLS
00052
00053 #define NEA_VERSION 3.0
00054 #define NEA_VERSION_STR "3.0"
00055
00056 #define NEA_DEFAULT_EXPIRES 3600
00057
00059 typedef struct nea_server_s nea_server_t;
00060
00062 typedef struct nea_sub_s nea_sub_t;
00063
00065 typedef struct nea_event_s nea_event_t;
00066
00068 typedef struct nea_event_view_s nea_event_view_t;
00069
00070 #ifndef NEA_SMAGIC_T
00071 #define NEA_SMAGIC_T struct nea_smagic_t
00072 #endif
00073
00074 typedef NEA_SMAGIC_T nea_smagic_t;
00075
00076 #ifndef NEA_EMAGIC_T
00077 #define NEA_EMAGIC_T struct nea_emagic_t
00078 #endif
00079
00080 typedef NEA_EMAGIC_T nea_emagic_t;
00081
00082 #ifndef NEA_EVMAGIC_T
00083 #define NEA_EVMAGIC_T struct nea_evmagic_t
00084 #endif
00085
00086 typedef NEA_EVMAGIC_T nea_evmagic_t;
00087
00089 typedef struct nea_subnode_t {
00090 nea_state_t sn_state;
00091 unsigned sn_fake;
00094 unsigned sn_eventlist;
00095 nea_sub_t *sn_subscriber;
00096 nea_event_t *sn_event;
00097 sip_from_t const *sn_remote;
00098 sip_contact_t const *sn_contact;
00101 sip_content_type_t const *sn_content_type;
00102 sip_payload_t const *sn_payload;
00104 unsigned sn_expires;
00105 unsigned sn_latest;
00106 unsigned sn_throttle;
00107 unsigned sn_version;
00108 sip_time_t sn_notified;
00109 sip_time_t sn_subscribed;
00110 nea_event_view_t *sn_view;
00111 } nea_subnode_t;
00112
00114 typedef struct nea_payloads_s nea_payloads_t;
00115
00128 typedef int (nea_new_event_f)(nea_smagic_t *context,
00129 nea_server_t *nes,
00130 nea_event_t **event_p,
00131 nea_event_view_t **view_p,
00132 nta_incoming_t *irq,
00133 sip_t const *sip);
00134
00136 SOFIAPUBFUN
00137 nea_server_t *nea_server_create(nta_agent_t *agent,
00138 su_root_t *root,
00139 url_t const *url,
00140 int max_subs,
00141 nea_new_event_f *callback,
00142 nea_smagic_t *context,
00143 tag_type_t tag, tag_value_t value,
00144 ...);
00145
00146
00148 SOFIAPUBFUN int nea_server_shutdown(nea_server_t *nes, int retry_after);
00149
00151 SOFIAPUBFUN void nea_server_destroy(nea_server_t *nes);
00152
00154 SOFIAPUBFUN void nea_server_flush(nea_server_t *nes, nea_event_t *event);
00155
00157 SOFIAPUBFUN
00158 int nea_server_update(nea_server_t *nes,
00159 nea_event_t *ev,
00160 tag_type_t tag,
00161 tag_value_t value,
00162 ...);
00163
00165 SOFIAPUBFUN
00166 int nea_server_add_irq(nea_server_t *nes,
00167 nta_leg_t *leg,
00168 sip_contact_t const *local_target,
00169 nta_incoming_t *irq,
00170 sip_t const *sip);
00171
00181 typedef void (nea_watcher_f)(nea_server_t *nes,
00182 nea_emagic_t *context,
00183 nea_event_t *event,
00184 nea_subnode_t *subnode,
00185 sip_t const *sip);
00186
00188 SOFIAPUBFUN
00189 nea_event_t *nea_event_create(nea_server_t *nes,
00190 nea_watcher_f *callback,
00191 nea_emagic_t *context,
00192 char const *name,
00193 char const *subname,
00194 char const *default_content_type,
00195 char const *accept);
00196
00198 SOFIAPUBFUN
00199 nea_event_t *nea_event_tcreate(nea_server_t *nes,
00200 nea_watcher_f *callback,
00201 nea_emagic_t *context,
00202 char const *name,
00203 char const *subname,
00204 tag_type_t, tag_value_t, ...);
00205
00207 SOFIAPUBFUN nea_emagic_t *nea_emagic_get(nea_event_t *event);
00208
00210 SOFIAPUBFUN nea_event_t *nea_event_get(nea_server_t const *, char const *name);
00211
00213 SOFIAPUBFUN int nea_server_active(nea_server_t *nes, nea_event_t const *ev);
00214
00216 int nea_server_non_embryonic(nea_server_t *nes, nea_event_t const *ev);
00217
00220 SOFIAPUBFUN
00221 nea_subnode_t const **nea_server_get_subscribers(nea_server_t *nes,
00222 nea_event_t const *ev);
00223
00225 SOFIAPUBFUN
00226 void nea_server_free_subscribers(nea_server_t *nes, nea_subnode_t const **);
00227
00229 SOFIAPUBFUN
00230 int nea_server_notify(nea_server_t *nes,
00231 nea_event_t *ev);
00232
00234 SOFIAPUBFUN
00235 int nea_server_notify_one(nea_server_t *nes,
00236 nea_event_t *ev,
00237 nea_sub_t *ns);
00238
00239 #define nea_server_auth nea_sub_auth
00240
00242 SOFIAPUBFUN nta_incoming_t *nea_sub_get_request(nea_sub_t *sub);
00243
00245 SOFIAPUBFUN
00246 int nea_sub_auth(nea_sub_t *, nea_state_t state,
00247 tag_type_t, tag_value_t, ...);
00248
00250 SOFIAPUBFUN nta_incoming_t *nea_subnode_get_incoming(nea_subnode_t *sn);
00252 SOFIAPUBFUN int nea_sub_version(nea_sub_t *, unsigned);
00253
00255 SOFIAPUBFUN unsigned nea_sub_pending(nea_sub_t const *);
00256
00257 #if 0
00258
00263 void nea_server_qauth(nea_server_t *nes,
00264 nea_emagic_t *context,
00265 nea_sub_t *subscriber,
00266 sip_t const *sip);
00267 #endif
00268
00270 SOFIAPUBFUN
00271 nea_event_view_t *nea_event_view(nea_event_t *, char const *content_type);
00272
00274 SOFIAPUBFUN
00275 sip_content_type_t const *nea_view_content_type(nea_event_view_t const *);
00276
00278 SOFIAPUBFUN sip_payload_t const *nea_view_payload(nea_event_view_t *);
00279
00281 SOFIAPUBFUN nea_event_view_t *nea_view_create(nea_server_t *nes,
00282 nea_event_t *ev,
00283 nea_evmagic_t *magic,
00284 tag_type_t tag,
00285 tag_value_t value,
00286 ...);
00287
00289 SOFIAPUBFUN void nea_view_destroy(nea_server_t *nes, nea_event_view_t *ev);
00290
00291 SOFIAPUBFUN nea_evmagic_t *nea_view_magic(nea_event_view_t const *);
00292
00293 SOFIAPUBFUN void nea_view_set_magic(nea_event_view_t *, nea_evmagic_t *magic);
00294
00295 SOFIAPUBFUN unsigned nea_view_version(nea_event_view_t const *);
00296
00298 #define NEATAG_RELIABLE(x) neatag_reliable, tag_bool_v((x))
00299 SOFIAPUBVAR tag_typedef_t neatag_reliable;
00300
00301 #define NEATAG_RELIABLE_REF(x) neatag_reliable_ref, tag_bool_vr((&x))
00302 SOFIAPUBVAR tag_typedef_t neatag_reliable_ref;
00303
00305 #define NEATAG_VIEW(x) neatag_view, tag_ptr_v((x))
00306 SOFIAPUBVAR tag_typedef_t neatag_view;
00307
00308 #define NEATAG_VIEW_REF(x) neatag_view_ref, tag_ptr_vr((&x), (x))
00309 SOFIAPUBVAR tag_typedef_t neatag_view_ref;
00310
00312 #define NEATAG_EVMAGIC(x) neatag_evmagic, tag_ptr_v((x))
00313 SOFIAPUBVAR tag_typedef_t neatag_evmagic;
00314
00315 #define NEATAG_EVMAGIC_REF(x) neatag_evmagic_ref, tag_ptr_vr((&x), (x))
00316 SOFIAPUBVAR tag_typedef_t neatag_evmagic_ref;
00317
00319 #define NEATAG_SUB(x) neatag_sub, tag_ptr_v((x))
00320 SOFIAPUBVAR tag_typedef_t neatag_sub;
00321
00322 #define NEATAG_SUB_REF(x) neatag_sub_ref, tag_ptr_vr((&x), (x))
00323 SOFIAPUBVAR tag_typedef_t neatag_sub_ref;
00324
00325
00326
00327
00328
00330 typedef struct nea_s nea_t;
00331
00332 #ifndef NEA_MAGIC_T
00333 #define NEA_MAGIC_T struct nea_magic_t
00334 #endif
00335
00337 typedef NEA_MAGIC_T nea_magic_t;
00338
00344 typedef int (*nea_notify_f)(nea_t *nea,
00345 nea_magic_t *context,
00346 sip_t const *sip);
00347
00348
00349
00350
00352 SOFIAPUBFUN
00353 nea_t *nea_create(nta_agent_t *agent,
00354 su_root_t *root,
00355 nea_notify_f no_callback,
00356 nea_magic_t *context,
00357 tag_type_t tag,
00358 tag_value_t value,
00359 ...);
00360
00362 SOFIAPUBFUN
00363 int nea_update(nea_t *nea,
00364 tag_type_t tag,
00365 tag_value_t value,
00366 ...);
00367
00369 SOFIAPUBFUN void nea_end(nea_t *agent);
00370
00372 SOFIAPUBFUN void nea_destroy(nea_t *agent);
00373
00374 SOFIAPUBFUN char const *nea_default_content_type(char const *event);
00375
00376 SOFIA_END_DECLS
00377
00378 #endif