blob: 1b57c5d2bcf67870e3694f2ed65d0b7beccad650 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
3 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSIP_SIMPLE_PIDF_H__
20#define __PJSIP_SIMPLE_PIDF_H__
21
22/**
23 * @file pidf.h
24 * @brief PIDF/Presence Information Data Format (RFC 3863)
25 */
Benny Prijono834aee32006-02-19 01:38:06 +000026#include <pjsip-simple/types.h>
27#include <pjlib-util/xml.h>
Benny Prijono5dcb38d2005-11-21 01:55:47 +000028
29PJ_BEGIN_DECL
30
31
32/**
33 * @defgroup PJSIP_SIMPLE_PIDF PIDF/Presence Information Data Format (RFC 3863)
34 * @ingroup PJSIP_SIMPLE
35 * @{
36 *
37 * This file provides tools for manipulating Presence Information Data
38 * Format (PIDF) as described in RFC 3863.
39 */
40typedef struct pj_xml_node pjpidf_pres;
41typedef struct pj_xml_node pjpidf_tuple;
42typedef struct pj_xml_node pjpidf_status;
43typedef struct pj_xml_node pjpidf_note;
44
45typedef struct pjpidf_status_op
46{
47 void (*construct)(pj_pool_t*, pjpidf_status*);
48 pj_bool_t (*is_basic_open)(const pjpidf_status*);
49 void (*set_basic_open)(pjpidf_status*, pj_bool_t);
50} pjpidf_status_op;
51
52typedef struct pjpidf_tuple_op
53{
54 void (*construct)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
55
56 const pj_str_t* (*get_id)(const pjpidf_tuple* );
57 void (*set_id)(pj_pool_t*, pjpidf_tuple *, const pj_str_t*);
58
59 pjpidf_status* (*get_status)(pjpidf_tuple* );
60
61 const pj_str_t* (*get_contact)(const pjpidf_tuple*);
62 void (*set_contact)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
63 void (*set_contact_prio)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
64 const pj_str_t* (*get_contact_prio)(const pjpidf_tuple*);
65
66 pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
67 pjpidf_note* (*get_first_note)(pjpidf_tuple*);
68 pjpidf_note* (*get_next_note)(pjpidf_tuple*, pjpidf_note*);
69
70 const pj_str_t* (*get_timestamp)(const pjpidf_tuple*);
71 void (*set_timestamp)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
72 void (*set_timestamp_np)(pj_pool_t*,pjpidf_tuple*, pj_str_t*);
73
74} pjpidf_tuple_op;
75
76typedef struct pjpidf_pres_op
77{
78 void (*construct)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
79
80 pjpidf_tuple* (*add_tuple)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
81 pjpidf_tuple* (*get_first_tuple)(pjpidf_pres*);
82 pjpidf_tuple* (*get_next_tuple)(pjpidf_pres*, pjpidf_tuple*);
83 pjpidf_tuple* (*find_tuple)(pjpidf_pres*, const pj_str_t*);
84 void (*remove_tuple)(pjpidf_pres*, pjpidf_tuple*);
85
86 pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
87 pjpidf_note* (*get_first_note)(pjpidf_pres*);
88 pjpidf_note* (*get_next_note)(pjpidf_pres*, pjpidf_note*);
89
90} pjpidf_pres_op;
91
92
93extern struct pjpidf_op_desc
94{
95 pjpidf_pres_op pres;
96 pjpidf_tuple_op tuple;
97 pjpidf_status_op status;
98} pjpidf_op;
99
100
101/******************************************************************************
102 * Top level API for managing presence document.
103 *****************************************************************************/
104PJ_DECL(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity);
105PJ_DECL(pjpidf_pres*) pjpidf_parse(pj_pool_t *pool, char *text, int len);
106PJ_DECL(int) pjpidf_print(const pjpidf_pres* pres, char *buf, int len);
107
108
109/******************************************************************************
110 * API for managing Presence node.
111 *****************************************************************************/
112PJ_DECL(void) pjpidf_pres_construct(pj_pool_t *pool, pjpidf_pres *pres,
113 const pj_str_t *entity);
114PJ_DECL(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
115 const pj_str_t *id);
116PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_first_tuple(pjpidf_pres *pres);
117PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_next_tuple(pjpidf_pres *pres,
118 pjpidf_tuple *t);
119PJ_DECL(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres,
120 const pj_str_t *id);
121PJ_DECL(void) pjpidf_pres_remove_tuple(pjpidf_pres *pres,
122 pjpidf_tuple*);
123
124PJ_DECL(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres,
125 const pj_str_t *text);
126PJ_DECL(pjpidf_note*) pjpidf_pres_get_first_note(pjpidf_pres *pres);
127PJ_DECL(pjpidf_note*) pjpidf_pres_get_next_note(pjpidf_pres*, pjpidf_note*);
128
129
130/******************************************************************************
131 * API for managing Tuple node.
132 *****************************************************************************/
133PJ_DECL(void) pjpidf_tuple_construct(pj_pool_t *pool, pjpidf_tuple *t,
134 const pj_str_t *id);
135PJ_DECL(const pj_str_t*) pjpidf_tuple_get_id(const pjpidf_tuple *t );
136PJ_DECL(void) pjpidf_tuple_set_id(pj_pool_t *pool, pjpidf_tuple *t,
137 const pj_str_t *id);
138
139PJ_DECL(pjpidf_status*) pjpidf_tuple_get_status(pjpidf_tuple *t);
140
141PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact(const pjpidf_tuple *t);
142PJ_DECL(void) pjpidf_tuple_set_contact(pj_pool_t *pool, pjpidf_tuple *t,
143 const pj_str_t *contact);
144PJ_DECL(void) pjpidf_tuple_set_contact_prio(pj_pool_t *pool, pjpidf_tuple *t,
145 const pj_str_t *prio);
146PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact_prio(const pjpidf_tuple *t);
147
148PJ_DECL(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
149 const pj_str_t *text);
150PJ_DECL(pjpidf_note*) pjpidf_tuple_get_first_note(pjpidf_tuple *t);
151PJ_DECL(pjpidf_note*) pjpidf_tuple_get_next_note(pjpidf_tuple *t, pjpidf_note *n);
152
153PJ_DECL(const pj_str_t*) pjpidf_tuple_get_timestamp(const pjpidf_tuple *t);
154PJ_DECL(void) pjpidf_tuple_set_timestamp(pj_pool_t *pool, pjpidf_tuple *t,
155 const pj_str_t *ts);
156PJ_DECL(void) pjpidf_tuple_set_timestamp_np( pj_pool_t*, pjpidf_tuple *t,
157 pj_str_t *ts);
158
159
160/******************************************************************************
161 * API for managing Status node.
162 *****************************************************************************/
163PJ_DECL(void) pjpidf_status_construct(pj_pool_t*, pjpidf_status*);
164PJ_DECL(pj_bool_t) pjpidf_status_is_basic_open(const pjpidf_status*);
165PJ_DECL(void) pjpidf_status_set_basic_open(pjpidf_status*, pj_bool_t);
166
167
168/**
169 * @}
170 */
171
172
173PJ_END_DECL
174
175
176#endif /* __PJSIP_SIMPLE_PIDF_H__ */