http: simplify Single Sign-On handling
[siplcs.git] / src / core / http-conn.h
blobf8db06119ad1af07c0b8ccd779ad8d52b3d5b042
1 /**
2 * @file http-conn.h
4 * pidgin-sipe
6 * Copyright (C) 2010-2013 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2009 pier11 <pier11@operamail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 /* Forward declarations */
25 struct sipe_core_public;
27 #define HTTP_CONN_GET "GET"
28 #define HTTP_CONN_POST "POST"
30 #define HTTP_CONN_SSL SIPE_TRANSPORT_TLS
31 #define HTTP_CONN_TCP SIPE_TRANSPORT_TCP
33 #define HTTP_CONN_ALLOW_REDIRECT TRUE
34 #define HTTP_CONN_NO_REDIRECT FALSE
36 #define HTTP_CONN_ERROR -100
37 #define HTTP_CONN_ERROR_FATAL -200
40 struct http_conn_auth {
41 char *domain;
42 char *user;
43 char *password;
45 typedef struct http_conn_auth HttpConnAuth;
47 struct http_conn_struct;
48 typedef struct http_conn_struct HttpConn;
49 typedef struct http_session_struct HttpSession;
51 /** callback */
52 typedef void (*HttpConnCallback) (int return_code, const char *body, GSList* headers,
53 HttpConn *conn, void *data);
55 /**
56 * Creates SSL connection and sends.
58 * @param auth Authentication data. Must be @c NULL for Single Sign-On
60 HttpConn *
61 http_conn_create(struct sipe_core_public *sipe_public,
62 HttpSession *http_session,
63 const char *method,
64 guint conn_type,
65 gboolean allow_redirect,
66 const char *full_url,
67 const char *body,
68 const char *content_type,
69 const gchar *additional_headers,
70 HttpConnAuth *auth,
71 HttpConnCallback callback,
72 void *data);
74 /**
75 * Sends on existing http_conn connection.
77 void
78 http_conn_send( HttpConn *http_conn,
79 const char *method,
80 const char *full_url,
81 const char *body,
82 const char *content_type,
83 HttpConnCallback callback,
84 void *data);
86 gboolean
87 http_conn_is_closed(HttpConn *http_conn);
89 /**
90 * Marks connection for close
92 void
93 http_conn_set_close(HttpConn* http_conn);
95 void
96 http_conn_free(HttpConn* http_conn);
98 HttpSession *
99 http_conn_session_create(void);
101 void
102 http_conn_session_free(HttpSession *http_session);