blob: ccd844ce4c5948ffa5502add7900c5a0280cfd1a [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
Benny Prijono312aff92006-06-17 04:08:30 +000035 * @brief Support for PIDF/Presence Information Data Format (RFC 3863)
Benny Prijono5dcb38d2005-11-21 01:55:47 +000036 * @{
37 *
38 * This file provides tools for manipulating Presence Information Data
39 * Format (PIDF) as described in RFC 3863.
40 */
41typedef struct pj_xml_node pjpidf_pres;
42typedef struct pj_xml_node pjpidf_tuple;
43typedef struct pj_xml_node pjpidf_status;
44typedef struct pj_xml_node pjpidf_note;
45
46typedef struct pjpidf_status_op
47{
48 void (*construct)(pj_pool_t*, pjpidf_status*);
49 pj_bool_t (*is_basic_open)(const pjpidf_status*);
50 void (*set_basic_open)(pjpidf_status*, pj_bool_t);
51} pjpidf_status_op;
52
53typedef struct pjpidf_tuple_op
54{
55 void (*construct)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
56
57 const pj_str_t* (*get_id)(const pjpidf_tuple* );
58 void (*set_id)(pj_pool_t*, pjpidf_tuple *, const pj_str_t*);
59
60 pjpidf_status* (*get_status)(pjpidf_tuple* );
61
62 const pj_str_t* (*get_contact)(const pjpidf_tuple*);
63 void (*set_contact)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
64 void (*set_contact_prio)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
65 const pj_str_t* (*get_contact_prio)(const pjpidf_tuple*);
66
67 pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
68 pjpidf_note* (*get_first_note)(pjpidf_tuple*);
69 pjpidf_note* (*get_next_note)(pjpidf_tuple*, pjpidf_note*);
70
71 const pj_str_t* (*get_timestamp)(const pjpidf_tuple*);
72 void (*set_timestamp)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
73 void (*set_timestamp_np)(pj_pool_t*,pjpidf_tuple*, pj_str_t*);
74
75} pjpidf_tuple_op;
76
77typedef struct pjpidf_pres_op
78{
79 void (*construct)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
80
81 pjpidf_tuple* (*add_tuple)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
82 pjpidf_tuple* (*get_first_tuple)(pjpidf_pres*);
83 pjpidf_tuple* (*get_next_tuple)(pjpidf_pres*, pjpidf_tuple*);
84 pjpidf_tuple* (*find_tuple)(pjpidf_pres*, const pj_str_t*);
85 void (*remove_tuple)(pjpidf_pres*, pjpidf_tuple*);
86
87 pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
88 pjpidf_note* (*get_first_note)(pjpidf_pres*);
89 pjpidf_note* (*get_next_note)(pjpidf_pres*, pjpidf_note*);
90
91} pjpidf_pres_op;
92
93
94extern struct pjpidf_op_desc
95{
96 pjpidf_pres_op pres;
97 pjpidf_tuple_op tuple;
98 pjpidf_status_op status;
99} pjpidf_op;
100
101
102/******************************************************************************
103 * Top level API for managing presence document.
104 *****************************************************************************/
105PJ_DECL(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity);
106PJ_DECL(pjpidf_pres*) pjpidf_parse(pj_pool_t *pool, char *text, int len);
107PJ_DECL(int) pjpidf_print(const pjpidf_pres* pres, char *buf, int len);
108
109
110/******************************************************************************
111 * API for managing Presence node.
112 *****************************************************************************/
113PJ_DECL(void) pjpidf_pres_construct(pj_pool_t *pool, pjpidf_pres *pres,
114 const pj_str_t *entity);
115PJ_DECL(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
116 const pj_str_t *id);
117PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_first_tuple(pjpidf_pres *pres);
118PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_next_tuple(pjpidf_pres *pres,
119 pjpidf_tuple *t);
120PJ_DECL(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres,
121 const pj_str_t *id);
122PJ_DECL(void) pjpidf_pres_remove_tuple(pjpidf_pres *pres,
123 pjpidf_tuple*);
124
125PJ_DECL(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres,
126 const pj_str_t *text);
127PJ_DECL(pjpidf_note*) pjpidf_pres_get_first_note(pjpidf_pres *pres);
128PJ_DECL(pjpidf_note*) pjpidf_pres_get_next_note(pjpidf_pres*, pjpidf_note*);
129
130
131/******************************************************************************
132 * API for managing Tuple node.
133 *****************************************************************************/
134PJ_DECL(void) pjpidf_tuple_construct(pj_pool_t *pool, pjpidf_tuple *t,
135 const pj_str_t *id);
136PJ_DECL(const pj_str_t*) pjpidf_tuple_get_id(const pjpidf_tuple *t );
137PJ_DECL(void) pjpidf_tuple_set_id(pj_pool_t *pool, pjpidf_tuple *t,
138 const pj_str_t *id);
139
140PJ_DECL(pjpidf_status*) pjpidf_tuple_get_status(pjpidf_tuple *t);
141
142PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact(const pjpidf_tuple *t);
143PJ_DECL(void) pjpidf_tuple_set_contact(pj_pool_t *pool, pjpidf_tuple *t,
144 const pj_str_t *contact);
145PJ_DECL(void) pjpidf_tuple_set_contact_prio(pj_pool_t *pool, pjpidf_tuple *t,
146 const pj_str_t *prio);
147PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact_prio(const pjpidf_tuple *t);
148
149PJ_DECL(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
150 const pj_str_t *text);
151PJ_DECL(pjpidf_note*) pjpidf_tuple_get_first_note(pjpidf_tuple *t);
152PJ_DECL(pjpidf_note*) pjpidf_tuple_get_next_note(pjpidf_tuple *t, pjpidf_note *n);
153
154PJ_DECL(const pj_str_t*) pjpidf_tuple_get_timestamp(const pjpidf_tuple *t);
155PJ_DECL(void) pjpidf_tuple_set_timestamp(pj_pool_t *pool, pjpidf_tuple *t,
156 const pj_str_t *ts);
157PJ_DECL(void) pjpidf_tuple_set_timestamp_np( pj_pool_t*, pjpidf_tuple *t,
158 pj_str_t *ts);
159
160
161/******************************************************************************
162 * API for managing Status node.
163 *****************************************************************************/
164PJ_DECL(void) pjpidf_status_construct(pj_pool_t*, pjpidf_status*);
165PJ_DECL(pj_bool_t) pjpidf_status_is_basic_open(const pjpidf_status*);
166PJ_DECL(void) pjpidf_status_set_basic_open(pjpidf_status*, pj_bool_t);
167
168
169/**
170 * @}
171 */
172
173
174PJ_END_DECL
175
176
177#endif /* __PJSIP_SIMPLE_PIDF_H__ */