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 __XCAP_CLIENT_H
27 #define __XCAP_CLIENT_H
28 
29 #include <cds/sstr.h>
30 #include <xcap/xcap_result_codes.h>
31 
32 typedef struct {
33 	/* "prefix" for XCAP query */
34 	str_t xcap_root;
35 	/** username for authentication */
36 	str_t auth_user;
37 	/** password used for authentication */
38 	str_t auth_pass;
39 	/** Accept unverifiable peers (ignore information
40 	 * stored in certificate and trust a certificate
41 	 * without know CA). */
42 	int enable_unverified_ssl_peer;
43 } xcap_query_params_t;
44 
45 typedef enum {
46 	xcap_doc_pres_rules,
47 	xcap_doc_im_rules,
48 	xcap_doc_rls_services,
49 	xcap_doc_resource_lists
50 } xcap_document_type_t;
51 
52 char *xcap_uri_for_users_document(xcap_document_type_t doc_type,
53 		const str_t *username,
54 		const str_t*filename,
55 		xcap_query_params_t *params);
56 
57 char *xcap_uri_for_global_document(xcap_document_type_t doc_type,
58 		const str_t *filename,
59 		xcap_query_params_t *params);
60 
61 /** Sends a XCAP query to the destination and using parameters from
62  * query variable a returns received data in output variables buf
63  * and bsize. */
64 /* URI is absolute HTTP/HTTPS uri for the query  */
65 int xcap_query(const char *uri, xcap_query_params_t *params,
66 		char **buf, int *bsize);
67 
68 typedef int (*xcap_query_func)(const char *uri,
69 		xcap_query_params_t *params,
70 		char **buf, int *bsize);
71 
72 void free_xcap_params_content(xcap_query_params_t *params);
73 int dup_xcap_params(xcap_query_params_t *dst, xcap_query_params_t *src);
74 
75 /* counts the length for data buffer storing values of
76  * xcap parameter members */
77 int get_inline_xcap_buf_len(xcap_query_params_t *params);
78 
79 /* copies structure into existing buffer */
80 int dup_xcap_params_inline(xcap_query_params_t *dst, xcap_query_params_t *src, char *data_buffer);
81 
82 int str2xcap_params(xcap_query_params_t *dst, const str_t *src);
83 int xcap_params2str(str_t *dst, xcap_query_params_t *src);
84 
85 #endif
86