gproxy.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
  2. /* GIO - GLib Input, Output and Streaming Library
  3. *
  4. * Copyright (C) 2010 Collabora Ltd.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General
  19. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
  22. */
  23. #ifndef __G_PROXY_H__
  24. #define __G_PROXY_H__
  25. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  26. #error "Only <gio/gio.h> can be included directly."
  27. #endif
  28. #include <gio/giotypes.h>
  29. G_BEGIN_DECLS
  30. #define G_TYPE_PROXY (g_proxy_get_type ())
  31. #define G_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_PROXY, GProxy))
  32. #define G_IS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_PROXY))
  33. #define G_PROXY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_PROXY, GProxyInterface))
  34. /**
  35. * G_PROXY_EXTENSION_POINT_NAME:
  36. *
  37. * Extension point for proxy functionality.
  38. * See [Extending GIO][extending-gio].
  39. *
  40. * Since: 2.26
  41. */
  42. #define G_PROXY_EXTENSION_POINT_NAME "gio-proxy"
  43. typedef struct _GProxyInterface GProxyInterface;
  44. /**
  45. * GProxyInterface:
  46. * @g_iface: The parent interface.
  47. * @connect: Connect to proxy server and wrap (if required) the #connection
  48. * to handle payload.
  49. * @connect_async: Same as connect() but asynchronous.
  50. * @connect_finish: Returns the result of connect_async()
  51. * @supports_hostname: Returns whether the proxy supports hostname lookups.
  52. *
  53. * Provides an interface for handling proxy connection and payload.
  54. *
  55. * Since: 2.26
  56. */
  57. struct _GProxyInterface
  58. {
  59. GTypeInterface g_iface;
  60. /* Virtual Table */
  61. GIOStream * (* connect) (GProxy *proxy,
  62. GIOStream *connection,
  63. GProxyAddress *proxy_address,
  64. GCancellable *cancellable,
  65. GError **error);
  66. void (* connect_async) (GProxy *proxy,
  67. GIOStream *connection,
  68. GProxyAddress *proxy_address,
  69. GCancellable *cancellable,
  70. GAsyncReadyCallback callback,
  71. gpointer user_data);
  72. GIOStream * (* connect_finish) (GProxy *proxy,
  73. GAsyncResult *result,
  74. GError **error);
  75. gboolean (* supports_hostname) (GProxy *proxy);
  76. };
  77. GIO_AVAILABLE_IN_ALL
  78. GType g_proxy_get_type (void) G_GNUC_CONST;
  79. GIO_AVAILABLE_IN_ALL
  80. GProxy *g_proxy_get_default_for_protocol (const gchar *protocol);
  81. GIO_AVAILABLE_IN_ALL
  82. GIOStream *g_proxy_connect (GProxy *proxy,
  83. GIOStream *connection,
  84. GProxyAddress *proxy_address,
  85. GCancellable *cancellable,
  86. GError **error);
  87. GIO_AVAILABLE_IN_ALL
  88. void g_proxy_connect_async (GProxy *proxy,
  89. GIOStream *connection,
  90. GProxyAddress *proxy_address,
  91. GCancellable *cancellable,
  92. GAsyncReadyCallback callback,
  93. gpointer user_data);
  94. GIO_AVAILABLE_IN_ALL
  95. GIOStream *g_proxy_connect_finish (GProxy *proxy,
  96. GAsyncResult *result,
  97. GError **error);
  98. GIO_AVAILABLE_IN_ALL
  99. gboolean g_proxy_supports_hostname (GProxy *proxy);
  100. G_END_DECLS
  101. #endif /* __G_PROXY_H__ */