1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* 3 * Copyright (C) 2000-2003, Ximian, Inc. 4 */ 5 6 #ifndef __SOUP_SESSION_H__ 7 #define __SOUP_SESSION_H__ 1 8 9 #include <libsoup/soup-types.h> 10 #include <libsoup/soup-address.h> 11 #include <libsoup/soup-message.h> 12 #include <libsoup/soup-websocket-connection.h> 13 14 G_BEGIN_DECLS 15 16 #define SOUP_TYPE_SESSION (soup_session_get_type ()) 17 #define SOUP_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SESSION, SoupSession)) 18 #define SOUP_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SESSION, SoupSessionClass)) 19 #define SOUP_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SESSION)) 20 #define SOUP_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SESSION)) 21 #define SOUP_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SESSION, SoupSessionClass)) 22 23 typedef void (*SoupSessionCallback) (SoupSession *session, 24 SoupMessage *msg, 25 gpointer user_data); 26 27 struct _SoupSession { 28 GObject parent; 29 30 }; 31 32 typedef struct { 33 GObjectClass parent_class; 34 35 /* signals */ 36 void (*request_started) (SoupSession *session, SoupMessage *msg, 37 SoupSocket *socket); 38 void (*authenticate) (SoupSession *session, SoupMessage *msg, 39 SoupAuth *auth, gboolean retrying); 40 41 /* methods */ 42 void (*queue_message) (SoupSession *session, SoupMessage *msg, 43 SoupSessionCallback callback, 44 gpointer user_data); 45 void (*requeue_message) (SoupSession *session, SoupMessage *msg); 46 guint (*send_message) (SoupSession *session, SoupMessage *msg); 47 48 void (*cancel_message) (SoupSession *session, SoupMessage *msg, 49 guint status_code); 50 51 void (*auth_required) (SoupSession *session, SoupMessage *msg, 52 SoupAuth *auth, gboolean retrying); 53 54 void (*flush_queue) (SoupSession *session); 55 56 void (*kick) (SoupSession *session); 57 58 /* Padding for future expansion */ 59 void (*_libsoup_reserved4) (void); 60 } SoupSessionClass; 61 62 SOUP_AVAILABLE_IN_2_42 63 GType soup_session_get_type (void); 64 65 #define SOUP_SESSION_LOCAL_ADDRESS "local-address" 66 #define SOUP_SESSION_PROXY_URI "proxy-uri" 67 #define SOUP_SESSION_PROXY_RESOLVER "proxy-resolver" 68 #define SOUP_SESSION_MAX_CONNS "max-conns" 69 #define SOUP_SESSION_MAX_CONNS_PER_HOST "max-conns-per-host" 70 #define SOUP_SESSION_USE_NTLM "use-ntlm" 71 #define SOUP_SESSION_SSL_CA_FILE "ssl-ca-file" 72 #define SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE "ssl-use-system-ca-file" 73 #define SOUP_SESSION_TLS_DATABASE "tls-database" 74 #define SOUP_SESSION_SSL_STRICT "ssl-strict" 75 #define SOUP_SESSION_TLS_INTERACTION "tls-interaction" 76 #define SOUP_SESSION_ASYNC_CONTEXT "async-context" 77 #define SOUP_SESSION_USE_THREAD_CONTEXT "use-thread-context" 78 #define SOUP_SESSION_TIMEOUT "timeout" 79 #define SOUP_SESSION_USER_AGENT "user-agent" 80 #define SOUP_SESSION_ACCEPT_LANGUAGE "accept-language" 81 #define SOUP_SESSION_ACCEPT_LANGUAGE_AUTO "accept-language-auto" 82 #define SOUP_SESSION_IDLE_TIMEOUT "idle-timeout" 83 #define SOUP_SESSION_ADD_FEATURE "add-feature" 84 #define SOUP_SESSION_ADD_FEATURE_BY_TYPE "add-feature-by-type" 85 #define SOUP_SESSION_REMOVE_FEATURE_BY_TYPE "remove-feature-by-type" 86 #define SOUP_SESSION_HTTP_ALIASES "http-aliases" 87 #define SOUP_SESSION_HTTPS_ALIASES "https-aliases" 88 89 SOUP_AVAILABLE_IN_2_42 90 SoupSession *soup_session_new (void); 91 92 SOUP_AVAILABLE_IN_2_42 93 SoupSession *soup_session_new_with_options (const char *optname1, 94 ...) G_GNUC_NULL_TERMINATED; 95 96 SOUP_AVAILABLE_IN_2_4 97 void soup_session_queue_message (SoupSession *session, 98 SoupMessage *msg, 99 SoupSessionCallback callback, 100 gpointer user_data); 101 SOUP_AVAILABLE_IN_2_4 102 void soup_session_requeue_message (SoupSession *session, 103 SoupMessage *msg); 104 105 SOUP_AVAILABLE_IN_2_4 106 guint soup_session_send_message (SoupSession *session, 107 SoupMessage *msg); 108 109 SOUP_AVAILABLE_IN_2_4 110 void soup_session_pause_message (SoupSession *session, 111 SoupMessage *msg); 112 SOUP_AVAILABLE_IN_2_4 113 void soup_session_unpause_message (SoupSession *session, 114 SoupMessage *msg); 115 116 SOUP_AVAILABLE_IN_2_4 117 void soup_session_cancel_message (SoupSession *session, 118 SoupMessage *msg, 119 guint status_code); 120 SOUP_AVAILABLE_IN_2_4 121 void soup_session_abort (SoupSession *session); 122 123 SOUP_AVAILABLE_IN_2_4 124 GMainContext *soup_session_get_async_context(SoupSession *session); 125 126 SOUP_AVAILABLE_IN_2_42 127 void soup_session_send_async (SoupSession *session, 128 SoupMessage *msg, 129 GCancellable *cancellable, 130 GAsyncReadyCallback callback, 131 gpointer user_data); 132 SOUP_AVAILABLE_IN_2_42 133 GInputStream *soup_session_send_finish (SoupSession *session, 134 GAsyncResult *result, 135 GError **error); 136 SOUP_AVAILABLE_IN_2_42 137 GInputStream *soup_session_send (SoupSession *session, 138 SoupMessage *msg, 139 GCancellable *cancellable, 140 GError **error); 141 142 #ifndef SOUP_DISABLE_DEPRECATED 143 SOUP_AVAILABLE_IN_2_30 144 SOUP_DEPRECATED_IN_2_38_FOR (soup_session_prefetch_dns) 145 void soup_session_prepare_for_uri (SoupSession *session, 146 SoupURI *uri); 147 #endif 148 149 SOUP_AVAILABLE_IN_2_38 150 void soup_session_prefetch_dns (SoupSession *session, 151 const char *hostname, 152 GCancellable *cancellable, 153 SoupAddressCallback callback, 154 gpointer user_data); 155 156 SOUP_AVAILABLE_IN_2_38 157 gboolean soup_session_would_redirect (SoupSession *session, 158 SoupMessage *msg); 159 SOUP_AVAILABLE_IN_2_38 160 gboolean soup_session_redirect_message (SoupSession *session, 161 SoupMessage *msg); 162 163 SOUP_AVAILABLE_IN_2_24 164 void soup_session_add_feature (SoupSession *session, 165 SoupSessionFeature *feature); 166 SOUP_AVAILABLE_IN_2_24 167 void soup_session_add_feature_by_type (SoupSession *session, 168 GType feature_type); 169 SOUP_AVAILABLE_IN_2_24 170 void soup_session_remove_feature (SoupSession *session, 171 SoupSessionFeature *feature); 172 SOUP_AVAILABLE_IN_2_24 173 void soup_session_remove_feature_by_type (SoupSession *session, 174 GType feature_type); 175 SOUP_AVAILABLE_IN_2_42 176 gboolean soup_session_has_feature (SoupSession *session, 177 GType feature_type); 178 SOUP_AVAILABLE_IN_2_26 179 GSList *soup_session_get_features (SoupSession *session, 180 GType feature_type); 181 SOUP_AVAILABLE_IN_2_26 182 SoupSessionFeature *soup_session_get_feature (SoupSession *session, 183 GType feature_type); 184 SOUP_AVAILABLE_IN_2_28 185 SoupSessionFeature *soup_session_get_feature_for_message(SoupSession *session, 186 GType feature_type, 187 SoupMessage *msg); 188 189 SOUP_AVAILABLE_IN_2_42 190 SoupRequest *soup_session_request (SoupSession *session, 191 const char *uri_string, 192 GError **error); 193 SOUP_AVAILABLE_IN_2_42 194 SoupRequest *soup_session_request_uri (SoupSession *session, 195 SoupURI *uri, 196 GError **error); 197 SOUP_AVAILABLE_IN_2_42 198 SoupRequestHTTP *soup_session_request_http (SoupSession *session, 199 const char *method, 200 const char *uri_string, 201 GError **error); 202 SOUP_AVAILABLE_IN_2_42 203 SoupRequestHTTP *soup_session_request_http_uri (SoupSession *session, 204 const char *method, 205 SoupURI *uri, 206 GError **error); 207 208 SOUP_AVAILABLE_IN_2_42 209 GQuark soup_request_error_quark (void); 210 #define SOUP_REQUEST_ERROR soup_request_error_quark () 211 212 typedef enum { 213 SOUP_REQUEST_ERROR_BAD_URI, 214 SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME, 215 SOUP_REQUEST_ERROR_PARSING, 216 SOUP_REQUEST_ERROR_ENCODING 217 } SoupRequestError; 218 219 SOUP_AVAILABLE_IN_2_50 220 GIOStream *soup_session_steal_connection (SoupSession *session, 221 SoupMessage *msg); 222 223 SOUP_AVAILABLE_IN_2_50 224 void soup_session_websocket_connect_async (SoupSession *session, 225 SoupMessage *msg, 226 const char *origin, 227 char **protocols, 228 GCancellable *cancellable, 229 GAsyncReadyCallback callback, 230 gpointer user_data); 231 232 SOUP_AVAILABLE_IN_2_50 233 SoupWebsocketConnection *soup_session_websocket_connect_finish (SoupSession *session, 234 GAsyncResult *result, 235 GError **error); 236 237 typedef void (*SoupSessionConnectProgressCallback) (SoupSession *session, 238 GSocketClientEvent event, 239 GIOStream *connection, 240 gpointer user_data); 241 242 SOUP_AVAILABLE_IN_2_62 243 void soup_session_connect_async (SoupSession *session, 244 SoupURI *uri, 245 GCancellable *cancellable, 246 SoupSessionConnectProgressCallback progress_callback, 247 GAsyncReadyCallback callback, 248 gpointer user_data); 249 250 SOUP_AVAILABLE_IN_2_62 251 GIOStream *soup_session_connect_finish (SoupSession *session, 252 GAsyncResult *result, 253 GError **error); 254 255 G_END_DECLS 256 257 #endif /* __SOUP_SESSION_H__ */ 258