blob: 910c9dc76e0a9e7d68d0478aeef7d1bab10a5470 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono5dcb38d2005-11-21 01:55:47 +00005 *
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.
10 *
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.
15 *
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
19 */
20#ifndef __PJSIP_SIMPLE_PIDF_H__
21#define __PJSIP_SIMPLE_PIDF_H__
22
23/**
24 * @file pidf.h
25 * @brief PIDF/Presence Information Data Format (RFC 3863)
26 */
Benny Prijono834aee32006-02-19 01:38:06 +000027#include <pjsip-simple/types.h>
28#include <pjlib-util/xml.h>
Benny Prijono5dcb38d2005-11-21 01:55:47 +000029
30PJ_BEGIN_DECL
31
32
33/**
34 * @defgroup PJSIP_SIMPLE_PIDF PIDF/Presence Information Data Format (RFC 3863)
35 * @ingroup PJSIP_SIMPLE
Benny Prijono312aff92006-06-17 04:08:30 +000036 * @brief Support for PIDF/Presence Information Data Format (RFC 3863)
Benny Prijono5dcb38d2005-11-21 01:55:47 +000037 * @{
38 *
39 * This file provides tools for manipulating Presence Information Data
40 * Format (PIDF) as described in RFC 3863.
41 */
42typedef struct pj_xml_node pjpidf_pres;
43typedef struct pj_xml_node pjpidf_tuple;
44typedef struct pj_xml_node pjpidf_status;
45typedef struct pj_xml_node pjpidf_note;
46
47typedef struct pjpidf_status_op
48{
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);
52} pjpidf_status_op;
53
54typedef struct pjpidf_tuple_op
55{
56 void (*construct)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
57
58 const pj_str_t* (*get_id)(const pjpidf_tuple* );
59 void (*set_id)(pj_pool_t*, pjpidf_tuple *, const pj_str_t*);
60
61 pjpidf_status* (*get_status)(pjpidf_tuple* );
62
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*);
67
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*);
71
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*);
75
76} pjpidf_tuple_op;
77
78typedef struct pjpidf_pres_op
79{
80 void (*construct)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
81
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*);
87
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*);
91
92} pjpidf_pres_op;
93
94
95extern struct pjpidf_op_desc
96{
97 pjpidf_pres_op pres;
98 pjpidf_tuple_op tuple;
99 pjpidf_status_op status;
100} pjpidf_op;
101
102
103/******************************************************************************
104 * Top level API for managing presence document.
105 *****************************************************************************/
106PJ_DECL(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity);
107PJ_DECL(pjpidf_pres*) pjpidf_parse(pj_pool_t *pool, char *text, int len);
108PJ_DECL(int) pjpidf_print(const pjpidf_pres* pres, char *buf, int len);
109
110
111/******************************************************************************
112 * API for managing Presence node.
113 *****************************************************************************/
114PJ_DECL(void) pjpidf_pres_construct(pj_pool_t *pool, pjpidf_pres *pres,
115 const pj_str_t *entity);
116PJ_DECL(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
117 const pj_str_t *id);
118PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_first_tuple(pjpidf_pres *pres);
119PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_next_tuple(pjpidf_pres *pres,
120 pjpidf_tuple *t);
121PJ_DECL(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres,
122 const pj_str_t *id);
123PJ_DECL(void) pjpidf_pres_remove_tuple(pjpidf_pres *pres,
124 pjpidf_tuple*);
125
126PJ_DECL(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres,
127 const pj_str_t *text);
128PJ_DECL(pjpidf_note*) pjpidf_pres_get_first_note(pjpidf_pres *pres);
129PJ_DECL(pjpidf_note*) pjpidf_pres_get_next_note(pjpidf_pres*, pjpidf_note*);
130
131
132/******************************************************************************
133 * API for managing Tuple node.
134 *****************************************************************************/
135PJ_DECL(void) pjpidf_tuple_construct(pj_pool_t *pool, pjpidf_tuple *t,
136 const pj_str_t *id);
137PJ_DECL(const pj_str_t*) pjpidf_tuple_get_id(const pjpidf_tuple *t );
138PJ_DECL(void) pjpidf_tuple_set_id(pj_pool_t *pool, pjpidf_tuple *t,
139 const pj_str_t *id);
140
141PJ_DECL(pjpidf_status*) pjpidf_tuple_get_status(pjpidf_tuple *t);
142
143PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact(const pjpidf_tuple *t);
144PJ_DECL(void) pjpidf_tuple_set_contact(pj_pool_t *pool, pjpidf_tuple *t,
145 const pj_str_t *contact);
146PJ_DECL(void) pjpidf_tuple_set_contact_prio(pj_pool_t *pool, pjpidf_tuple *t,
147 const pj_str_t *prio);
148PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact_prio(const pjpidf_tuple *t);
149
150PJ_DECL(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
151 const pj_str_t *text);
152PJ_DECL(pjpidf_note*) pjpidf_tuple_get_first_note(pjpidf_tuple *t);
153PJ_DECL(pjpidf_note*) pjpidf_tuple_get_next_note(pjpidf_tuple *t, pjpidf_note *n);
154
155PJ_DECL(const pj_str_t*) pjpidf_tuple_get_timestamp(const pjpidf_tuple *t);
156PJ_DECL(void) pjpidf_tuple_set_timestamp(pj_pool_t *pool, pjpidf_tuple *t,
157 const pj_str_t *ts);
158PJ_DECL(void) pjpidf_tuple_set_timestamp_np( pj_pool_t*, pjpidf_tuple *t,
159 pj_str_t *ts);
160
161
162/******************************************************************************
163 * API for managing Status node.
164 *****************************************************************************/
165PJ_DECL(void) pjpidf_status_construct(pj_pool_t*, pjpidf_status*);
166PJ_DECL(pj_bool_t) pjpidf_status_is_basic_open(const pjpidf_status*);
167PJ_DECL(void) pjpidf_status_set_basic_open(pjpidf_status*, pj_bool_t);
168
169
170/**
171 * @}
172 */
173
174
175PJ_END_DECL
176
177
178#endif /* __PJSIP_SIMPLE_PIDF_H__ */