pres_doc.h

00001 /* 
00002  * Copyright (C) 2005 iptelorg GmbH
00003  *
00004  * This file is part of ser, a free SIP server.
00005  *
00006  * ser is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * For a license to use the ser software under conditions
00012  * other than those described here, or to purchase support for this
00013  * software, please contact iptel.org by e-mail at the following addresses:
00014  *    info@iptel.org
00015  *
00016  * ser is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 #ifndef __PRESENCE_INFO_H
00027 #define __PRESENCE_INFO_H
00028 
00029 #include <cds/sstr.h>
00030 #include <cds/ptr_vector.h>
00031 #include <time.h>
00032 
00033 typedef struct _presence_note_t {
00034         str_t value;
00035         str_t lang;
00036         struct _presence_note_t *prev, *next;
00037 } presence_note_t;
00038 
00039 typedef enum {
00040         presence_tuple_open,
00041         presence_tuple_closed,
00042         presence_tuple_undefined_status
00043 } basic_tuple_status_t;
00044 
00045 typedef enum {
00046         presence_auth_rejected,
00047         presence_auth_polite_block,
00048         presence_auth_unresolved,
00049         presence_auth_granted
00050 } presence_authorization_status_t;
00051 
00052 /* additional data which need not to be understood by us */
00053 typedef struct _extension_element_t {
00054         str_t element;
00055         /* TODO: add mustUnderstand attribute and its handling */
00056         struct _extension_element_t *next, *prev; /* there can be more person elements in PIDF */
00057 } extension_element_t;
00058 
00059 typedef struct {
00060         basic_tuple_status_t basic;
00061         extension_element_t *first_unknown_element, *last_unknown_element;
00062 } presence_tuple_status_t;
00063 
00064 typedef struct _presence_tuple_info_t {
00065         str_t contact;
00066         str_t id;
00067         double priority;
00068         presence_tuple_status_t status;
00069         extension_element_t *first_unknown_element, *last_unknown_element;
00070         struct _presence_tuple_info_t *next, *prev;
00071         presence_note_t *first_note, *last_note;/* published notes */
00072         /* TODO: add timestamp element */
00073 } presence_tuple_info_t;
00074 
00075 typedef struct {
00076         str_t uri; /* do not modify this !*/
00077         presence_tuple_info_t *first_tuple, *last_tuple;
00078         presence_note_t *first_note, *last_note;/* published notes */
00079         extension_element_t *first_unknown_element, *last_unknown_element;
00080                 
00081         char presentity_data[1];
00082 } presentity_info_t;
00083 
00084 typedef struct {
00085         str_t uri; /* do not modify this !*/
00086         
00087         str_t pres_doc;
00088         str_t content_type;
00089         char uri_data[1];
00090 } raw_presence_info_t;
00091 
00092 typedef struct {
00093         str_t list_uri; /* do not modify this !*/
00094 
00095         str_t pres_doc;
00096         str_t content_type;
00097         char uri_data[1];
00098 } presence_info_t;
00099 
00100 presentity_info_t *create_presentity_info(const str_t *presentity);
00101 presence_tuple_info_t *create_tuple_info(const str_t *contact, const str_t *id, basic_tuple_status_t status);
00102 void add_tuple_info(presentity_info_t *p, presence_tuple_info_t *t);
00103 void free_presentity_info(presentity_info_t *p);
00104 
00105 raw_presence_info_t *create_raw_presence_info(const str_t *uri);
00106 void free_raw_presence_info(raw_presence_info_t *p);
00107 
00108 presence_note_t *create_presence_note(const str_t *note, const str_t *lang);
00109 presence_note_t *create_presence_note_zt(const char *note, const char *lang);
00110 void free_presence_note(presence_note_t *n);
00111 
00112 extension_element_t *create_extension_element(const str_t *element);
00113 void free_extension_element(extension_element_t *p);
00114 
00117 str_t* tuple_status2str(basic_tuple_status_t status);
00118 
00119 basic_tuple_status_t str2tuple_status(const str_t *s);
00120 
00121 /* duplicates presentity info */
00122 presentity_info_t *dup_presentity_info(presentity_info_t *p);
00123 
00124 /* content type names usable with QSA */
00125 #define CT_PRESENCE_INFO    "structured/presence-info" /* uses presence_info_t */
00126 #define CT_PIDF_XML         "application/pidf+xml" /* carries XML */
00127 #define CT_RAW              "raw" /* uses raw_presence_info_t */
00128 
00129 #endif