modules/ims_qos: added patch for flow-description bug when request originates from...
[sip-router] / src / lib / presence / pres_doc.h
1 /* 
2  * Copyright (C) 2005 iptelorg GmbH
3  *
4  * This file is part of ser, a free SIP server.
5  *
6  * ser 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  * For a license to use the ser software under conditions
12  * other than those described here, or to purchase support for this
13  * software, please contact iptel.org by e-mail at the following addresses:
14  *    info@iptel.org
15  *
16  * ser is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25
26 #ifndef __PRESENCE_INFO_H
27 #define __PRESENCE_INFO_H
28
29 #include <cds/sstr.h>
30 #include <cds/ptr_vector.h>
31 #include <time.h>
32
33 typedef struct _presence_note_t {
34         str_t value;
35         str_t lang;
36         struct _presence_note_t *prev, *next;
37 } presence_note_t;
38
39 typedef enum {
40         presence_tuple_open,
41         presence_tuple_closed,
42         presence_tuple_undefined_status
43 } basic_tuple_status_t;
44
45 typedef enum {
46         presence_auth_rejected,
47         presence_auth_polite_block,
48         presence_auth_unresolved,
49         presence_auth_granted
50 } presence_authorization_status_t;
51
52 /* additional data which need not to be understood by us */
53 typedef struct _extension_element_t {
54         str_t element;
55         /* TODO: add mustUnderstand attribute and its handling */
56         struct _extension_element_t *next, *prev; /* there can be more person elements in PIDF */
57 } extension_element_t;
58
59 typedef struct {
60         basic_tuple_status_t basic;
61         extension_element_t *first_unknown_element, *last_unknown_element;
62 } presence_tuple_status_t;
63
64 typedef struct _presence_tuple_info_t {
65         str_t contact;
66         str_t id;
67         double priority;
68         presence_tuple_status_t status;
69         extension_element_t *first_unknown_element, *last_unknown_element;
70         struct _presence_tuple_info_t *next, *prev;
71         presence_note_t *first_note, *last_note;/* published notes */
72         /* TODO: add timestamp element */
73 } presence_tuple_info_t;
74
75 typedef struct {
76         str_t uri; /* do not modify this !*/
77         presence_tuple_info_t *first_tuple, *last_tuple;
78         presence_note_t *first_note, *last_note;/* published notes */
79         extension_element_t *first_unknown_element, *last_unknown_element;
80                 
81         char presentity_data[1];
82 } presentity_info_t;
83
84 typedef struct {
85         str_t uri; /* do not modify this !*/
86         
87         str_t pres_doc;
88         str_t content_type;
89         char uri_data[1];
90 } raw_presence_info_t;
91
92 typedef struct {
93         str_t list_uri; /* do not modify this !*/
94
95         str_t pres_doc;
96         str_t content_type;
97         char uri_data[1];
98 } presence_info_t;
99
100 presentity_info_t *create_presentity_info(const str_t *presentity);
101 presence_tuple_info_t *create_tuple_info(const str_t *contact, const str_t *id, basic_tuple_status_t status);
102 void add_tuple_info(presentity_info_t *p, presence_tuple_info_t *t);
103 void free_presentity_info(presentity_info_t *p);
104
105 raw_presence_info_t *create_raw_presence_info(const str_t *uri);
106 void free_raw_presence_info(raw_presence_info_t *p);
107
108 presence_note_t *create_presence_note(const str_t *note, const str_t *lang);
109 presence_note_t *create_presence_note_zt(const char *note, const char *lang);
110 void free_presence_note(presence_note_t *n);
111
112 extension_element_t *create_extension_element(const str_t *element);
113 void free_extension_element(extension_element_t *p);
114
115 /** returns pointer to constant string (do not free it!),
116  * the return value is never NULL */
117 str_t* tuple_status2str(basic_tuple_status_t status);
118
119 basic_tuple_status_t str2tuple_status(const str_t *s);
120
121 /* duplicates presentity info */
122 presentity_info_t *dup_presentity_info(presentity_info_t *p);
123
124 /* content type names usable with QSA */
125 #define CT_PRESENCE_INFO    "structured/presence-info" /* uses presence_info_t */
126 #define CT_PIDF_XML         "application/pidf+xml" /* carries XML */
127 #define CT_RAW              "raw" /* uses raw_presence_info_t */
128
129 #endif