1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* 3 * soup-websocket-extension.h 4 * 5 * Copyright (C) 2019 Igalia S.L. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef __SOUP_WEBSOCKET_EXTENSION_H__ 24 #define __SOUP_WEBSOCKET_EXTENSION_H__ 1 25 26 #include <libsoup/soup-types.h> 27 #include <libsoup/soup-websocket.h> 28 29 G_BEGIN_DECLS 30 31 #define SOUP_TYPE_WEBSOCKET_EXTENSION (soup_websocket_extension_get_type ()) 32 #define SOUP_WEBSOCKET_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_WEBSOCKET_EXTENSION, SoupWebsocketExtension)) 33 #define SOUP_IS_WEBSOCKET_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_WEBSOCKET_EXTENSION)) 34 #define SOUP_WEBSOCKET_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_WEBSOCKET_EXTENSION, SoupWebsocketExtensionClass)) 35 #define SOUP_IS_WEBSOCKET_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_WEBSOCKET_EXTENSION)) 36 #define SOUP_WEBSOCKET_EXTENSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_WEBSOCKET_EXTENSION, SoupWebsocketExtensionClass)) 37 38 struct _SoupWebsocketExtension { 39 GObject parent; 40 }; 41 42 typedef struct { 43 GObjectClass parent_class; 44 45 const char *name; 46 47 gboolean (* configure) (SoupWebsocketExtension *extension, 48 SoupWebsocketConnectionType connection_type, 49 GHashTable *params, 50 GError **error); 51 52 char *(* get_request_params) (SoupWebsocketExtension *extension); 53 54 char *(* get_response_params) (SoupWebsocketExtension *extension); 55 56 GBytes *(* process_outgoing_message) (SoupWebsocketExtension *extension, 57 guint8 *header, 58 GBytes *payload, 59 GError **error); 60 61 GBytes *(* process_incoming_message) (SoupWebsocketExtension *extension, 62 guint8 *header, 63 GBytes *payload, 64 GError **error); 65 66 /* Padding for future expansion */ 67 void (*_libsoup_reserved1) (void); 68 void (*_libsoup_reserved2) (void); 69 void (*_libsoup_reserved3) (void); 70 void (*_libsoup_reserved4) (void); 71 } SoupWebsocketExtensionClass; 72 73 SOUP_AVAILABLE_IN_2_68 74 GType soup_websocket_extension_get_type (void); 75 76 SOUP_AVAILABLE_IN_2_68 77 gboolean soup_websocket_extension_configure (SoupWebsocketExtension *extension, 78 SoupWebsocketConnectionType connection_type, 79 GHashTable *params, 80 GError **error); 81 SOUP_AVAILABLE_IN_2_68 82 char *soup_websocket_extension_get_request_params (SoupWebsocketExtension *extension); 83 84 SOUP_AVAILABLE_IN_2_68 85 char *soup_websocket_extension_get_response_params (SoupWebsocketExtension *extension); 86 87 SOUP_AVAILABLE_IN_2_68 88 GBytes *soup_websocket_extension_process_outgoing_message (SoupWebsocketExtension *extension, 89 guint8 *header, 90 GBytes *payload, 91 GError **error); 92 SOUP_AVAILABLE_IN_2_68 93 GBytes *soup_websocket_extension_process_incoming_message (SoupWebsocketExtension *extension, 94 guint8 *header, 95 GBytes *payload, 96 GError **error); 97 98 G_END_DECLS 99 100 #endif /* __SOUP_WEBSOCKET_EXTENSION_H__ */ 101