pidf.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 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. * @file pidf.h
  23. * @brief PIDF/Presence Information Data Format (RFC 3863)
  24. */
  25. #include <pjsip-simple/types.h>
  26. #include <pjlib-util/xml.h>
  27. PJ_BEGIN_DECL
  28. /**
  29. * @defgroup PJSIP_SIMPLE_PIDF PIDF/Presence Information Data Format (RFC 3863)
  30. * @ingroup PJSIP_SIMPLE
  31. * @brief Support for PIDF/Presence Information Data Format (RFC 3863)
  32. * @{
  33. *
  34. * This file provides tools for manipulating Presence Information Data
  35. * Format (PIDF) as described in RFC 3863.
  36. */
  37. typedef struct pj_xml_node pjpidf_pres;
  38. typedef struct pj_xml_node pjpidf_tuple;
  39. typedef struct pj_xml_node pjpidf_status;
  40. typedef struct pj_xml_node pjpidf_note;
  41. typedef struct pjpidf_status_op
  42. {
  43. void (*construct)(pj_pool_t*, pjpidf_status*);
  44. pj_bool_t (*is_basic_open)(const pjpidf_status*);
  45. void (*set_basic_open)(pjpidf_status*, pj_bool_t);
  46. } pjpidf_status_op;
  47. typedef struct pjpidf_tuple_op
  48. {
  49. void (*construct)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
  50. const pj_str_t* (*get_id)(const pjpidf_tuple* );
  51. void (*set_id)(pj_pool_t*, pjpidf_tuple *, const pj_str_t*);
  52. pjpidf_status* (*get_status)(pjpidf_tuple* );
  53. const pj_str_t* (*get_contact)(const pjpidf_tuple*);
  54. void (*set_contact)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
  55. void (*set_contact_prio)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
  56. const pj_str_t* (*get_contact_prio)(const pjpidf_tuple*);
  57. pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
  58. pjpidf_note* (*get_first_note)(pjpidf_tuple*);
  59. pjpidf_note* (*get_next_note)(pjpidf_tuple*, pjpidf_note*);
  60. const pj_str_t* (*get_timestamp)(const pjpidf_tuple*);
  61. void (*set_timestamp)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
  62. void (*set_timestamp_np)(pj_pool_t*,pjpidf_tuple*, pj_str_t*);
  63. } pjpidf_tuple_op;
  64. typedef struct pjpidf_pres_op
  65. {
  66. void (*construct)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
  67. pjpidf_tuple* (*add_tuple)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
  68. pjpidf_tuple* (*get_first_tuple)(pjpidf_pres*);
  69. pjpidf_tuple* (*get_next_tuple)(pjpidf_pres*, pjpidf_tuple*);
  70. pjpidf_tuple* (*find_tuple)(pjpidf_pres*, const pj_str_t*);
  71. void (*remove_tuple)(pjpidf_pres*, pjpidf_tuple*);
  72. pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
  73. pjpidf_note* (*get_first_note)(pjpidf_pres*);
  74. pjpidf_note* (*get_next_note)(pjpidf_pres*, pjpidf_note*);
  75. } pjpidf_pres_op;
  76. extern struct pjpidf_op_desc
  77. {
  78. pjpidf_pres_op pres;
  79. pjpidf_tuple_op tuple;
  80. pjpidf_status_op status;
  81. } pjpidf_op;
  82. /******************************************************************************
  83. * Top level API for managing presence document.
  84. *****************************************************************************/
  85. PJ_DECL(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity);
  86. PJ_DECL(pjpidf_pres*) pjpidf_parse(pj_pool_t *pool, char *text, int len);
  87. PJ_DECL(int) pjpidf_print(const pjpidf_pres* pres, char *buf, int len);
  88. /******************************************************************************
  89. * API for managing Presence node.
  90. *****************************************************************************/
  91. PJ_DECL(void) pjpidf_pres_construct(pj_pool_t *pool, pjpidf_pres *pres,
  92. const pj_str_t *entity);
  93. PJ_DECL(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
  94. const pj_str_t *id);
  95. PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_first_tuple(pjpidf_pres *pres);
  96. PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_next_tuple(pjpidf_pres *pres,
  97. pjpidf_tuple *t);
  98. PJ_DECL(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres,
  99. const pj_str_t *id);
  100. PJ_DECL(void) pjpidf_pres_remove_tuple(pjpidf_pres *pres,
  101. pjpidf_tuple*);
  102. PJ_DECL(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres,
  103. const pj_str_t *text);
  104. PJ_DECL(pjpidf_note*) pjpidf_pres_get_first_note(pjpidf_pres *pres);
  105. PJ_DECL(pjpidf_note*) pjpidf_pres_get_next_note(pjpidf_pres*, pjpidf_note*);
  106. /******************************************************************************
  107. * API for managing Tuple node.
  108. *****************************************************************************/
  109. PJ_DECL(void) pjpidf_tuple_construct(pj_pool_t *pool, pjpidf_tuple *t,
  110. const pj_str_t *id);
  111. PJ_DECL(const pj_str_t*) pjpidf_tuple_get_id(const pjpidf_tuple *t );
  112. PJ_DECL(void) pjpidf_tuple_set_id(pj_pool_t *pool, pjpidf_tuple *t,
  113. const pj_str_t *id);
  114. PJ_DECL(pjpidf_status*) pjpidf_tuple_get_status(pjpidf_tuple *t);
  115. PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact(const pjpidf_tuple *t);
  116. PJ_DECL(void) pjpidf_tuple_set_contact(pj_pool_t *pool, pjpidf_tuple *t,
  117. const pj_str_t *contact);
  118. PJ_DECL(void) pjpidf_tuple_set_contact_prio(pj_pool_t *pool, pjpidf_tuple *t,
  119. const pj_str_t *prio);
  120. PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact_prio(const pjpidf_tuple *t);
  121. PJ_DECL(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
  122. const pj_str_t *text);
  123. PJ_DECL(pjpidf_note*) pjpidf_tuple_get_first_note(pjpidf_tuple *t);
  124. PJ_DECL(pjpidf_note*) pjpidf_tuple_get_next_note(pjpidf_tuple *t, pjpidf_note *n);
  125. PJ_DECL(const pj_str_t*) pjpidf_tuple_get_timestamp(const pjpidf_tuple *t);
  126. PJ_DECL(void) pjpidf_tuple_set_timestamp(pj_pool_t *pool, pjpidf_tuple *t,
  127. const pj_str_t *ts);
  128. PJ_DECL(void) pjpidf_tuple_set_timestamp_np( pj_pool_t*, pjpidf_tuple *t,
  129. pj_str_t *ts);
  130. /******************************************************************************
  131. * API for managing Status node.
  132. *****************************************************************************/
  133. PJ_DECL(void) pjpidf_status_construct(pj_pool_t*, pjpidf_status*);
  134. PJ_DECL(pj_bool_t) pjpidf_status_is_basic_open(const pjpidf_status*);
  135. PJ_DECL(void) pjpidf_status_set_basic_open(pjpidf_status*, pj_bool_t);
  136. /**
  137. * @}
  138. */
  139. PJ_END_DECL
  140. #endif /* __PJSIP_SIMPLE_PIDF_H__ */