1
/* $Id: pidf.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJSIP_SIMPLE_PIDF_H__
21
#define __PJSIP_SIMPLE_PIDF_H__
25
* @brief PIDF/Presence Information Data Format (RFC 3863)
27
#include <pjsip-simple/types.h>
28
#include <pjlib-util/xml.h>
34
* @defgroup PJSIP_SIMPLE_PIDF PIDF/Presence Information Data Format (RFC 3863)
35
* @ingroup PJSIP_SIMPLE
36
* @brief Support for PIDF/Presence Information Data Format (RFC 3863)
39
* This file provides tools for manipulating Presence Information Data
40
* Format (PIDF) as described in RFC 3863.
42
typedef struct pj_xml_node pjpidf_pres;
43
typedef struct pj_xml_node pjpidf_tuple;
44
typedef struct pj_xml_node pjpidf_status;
45
typedef struct pj_xml_node pjpidf_note;
47
typedef struct pjpidf_status_op
49
void (*construct)(pj_pool_t*, pjpidf_status*);
50
pj_bool_t (*is_basic_open)(const pjpidf_status*);
51
void (*set_basic_open)(pjpidf_status*, pj_bool_t);
54
typedef struct pjpidf_tuple_op
56
void (*construct)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
58
const pj_str_t* (*get_id)(const pjpidf_tuple* );
59
void (*set_id)(pj_pool_t*, pjpidf_tuple *, const pj_str_t*);
61
pjpidf_status* (*get_status)(pjpidf_tuple* );
63
const pj_str_t* (*get_contact)(const pjpidf_tuple*);
64
void (*set_contact)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
65
void (*set_contact_prio)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
66
const pj_str_t* (*get_contact_prio)(const pjpidf_tuple*);
68
pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
69
pjpidf_note* (*get_first_note)(pjpidf_tuple*);
70
pjpidf_note* (*get_next_note)(pjpidf_tuple*, pjpidf_note*);
72
const pj_str_t* (*get_timestamp)(const pjpidf_tuple*);
73
void (*set_timestamp)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
74
void (*set_timestamp_np)(pj_pool_t*,pjpidf_tuple*, pj_str_t*);
78
typedef struct pjpidf_pres_op
80
void (*construct)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
82
pjpidf_tuple* (*add_tuple)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
83
pjpidf_tuple* (*get_first_tuple)(pjpidf_pres*);
84
pjpidf_tuple* (*get_next_tuple)(pjpidf_pres*, pjpidf_tuple*);
85
pjpidf_tuple* (*find_tuple)(pjpidf_pres*, const pj_str_t*);
86
void (*remove_tuple)(pjpidf_pres*, pjpidf_tuple*);
88
pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
89
pjpidf_note* (*get_first_note)(pjpidf_pres*);
90
pjpidf_note* (*get_next_note)(pjpidf_pres*, pjpidf_note*);
95
extern struct pjpidf_op_desc
98
pjpidf_tuple_op tuple;
99
pjpidf_status_op status;
103
/******************************************************************************
104
* Top level API for managing presence document.
105
*****************************************************************************/
106
PJ_DECL(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity);
107
PJ_DECL(pjpidf_pres*) pjpidf_parse(pj_pool_t *pool, char *text, int len);
108
PJ_DECL(int) pjpidf_print(const pjpidf_pres* pres, char *buf, int len);
111
/******************************************************************************
112
* API for managing Presence node.
113
*****************************************************************************/
114
PJ_DECL(void) pjpidf_pres_construct(pj_pool_t *pool, pjpidf_pres *pres,
115
const pj_str_t *entity);
116
PJ_DECL(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
118
PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_first_tuple(pjpidf_pres *pres);
119
PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_next_tuple(pjpidf_pres *pres,
121
PJ_DECL(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres,
123
PJ_DECL(void) pjpidf_pres_remove_tuple(pjpidf_pres *pres,
126
PJ_DECL(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres,
127
const pj_str_t *text);
128
PJ_DECL(pjpidf_note*) pjpidf_pres_get_first_note(pjpidf_pres *pres);
129
PJ_DECL(pjpidf_note*) pjpidf_pres_get_next_note(pjpidf_pres*, pjpidf_note*);
132
/******************************************************************************
133
* API for managing Tuple node.
134
*****************************************************************************/
135
PJ_DECL(void) pjpidf_tuple_construct(pj_pool_t *pool, pjpidf_tuple *t,
137
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_id(const pjpidf_tuple *t );
138
PJ_DECL(void) pjpidf_tuple_set_id(pj_pool_t *pool, pjpidf_tuple *t,
141
PJ_DECL(pjpidf_status*) pjpidf_tuple_get_status(pjpidf_tuple *t);
143
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact(const pjpidf_tuple *t);
144
PJ_DECL(void) pjpidf_tuple_set_contact(pj_pool_t *pool, pjpidf_tuple *t,
145
const pj_str_t *contact);
146
PJ_DECL(void) pjpidf_tuple_set_contact_prio(pj_pool_t *pool, pjpidf_tuple *t,
147
const pj_str_t *prio);
148
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact_prio(const pjpidf_tuple *t);
150
PJ_DECL(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
151
const pj_str_t *text);
152
PJ_DECL(pjpidf_note*) pjpidf_tuple_get_first_note(pjpidf_tuple *t);
153
PJ_DECL(pjpidf_note*) pjpidf_tuple_get_next_note(pjpidf_tuple *t, pjpidf_note *n);
155
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_timestamp(const pjpidf_tuple *t);
156
PJ_DECL(void) pjpidf_tuple_set_timestamp(pj_pool_t *pool, pjpidf_tuple *t,
158
PJ_DECL(void) pjpidf_tuple_set_timestamp_np( pj_pool_t*, pjpidf_tuple *t,
162
/******************************************************************************
163
* API for managing Status node.
164
*****************************************************************************/
165
PJ_DECL(void) pjpidf_status_construct(pj_pool_t*, pjpidf_status*);
166
PJ_DECL(pj_bool_t) pjpidf_status_is_basic_open(const pjpidf_status*);
167
PJ_DECL(void) pjpidf_status_set_basic_open(pjpidf_status*, pj_bool_t);
178
#endif /* __PJSIP_SIMPLE_PIDF_H__ */