gtlsconnection.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2010 Red Hat, Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General
  16. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __G_TLS_CONNECTION_H__
  19. #define __G_TLS_CONNECTION_H__
  20. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  21. #error "Only <gio/gio.h> can be included directly."
  22. #endif
  23. #include <gio/giostream.h>
  24. G_BEGIN_DECLS
  25. #define G_TYPE_TLS_CONNECTION (g_tls_connection_get_type ())
  26. #define G_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection))
  27. #define G_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
  28. #define G_IS_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION))
  29. #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION))
  30. #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
  31. typedef struct _GTlsConnectionClass GTlsConnectionClass;
  32. typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
  33. struct _GTlsConnection {
  34. GIOStream parent_instance;
  35. GTlsConnectionPrivate *priv;
  36. };
  37. struct _GTlsConnectionClass
  38. {
  39. GIOStreamClass parent_class;
  40. /* signals */
  41. gboolean ( *accept_certificate) (GTlsConnection *connection,
  42. GTlsCertificate *peer_cert,
  43. GTlsCertificateFlags errors);
  44. /* methods */
  45. gboolean ( *handshake ) (GTlsConnection *conn,
  46. GCancellable *cancellable,
  47. GError **error);
  48. void ( *handshake_async ) (GTlsConnection *conn,
  49. int io_priority,
  50. GCancellable *cancellable,
  51. GAsyncReadyCallback callback,
  52. gpointer user_data);
  53. gboolean ( *handshake_finish ) (GTlsConnection *conn,
  54. GAsyncResult *result,
  55. GError **error);
  56. /*< private >*/
  57. /* Padding for future expansion */
  58. gpointer padding[8];
  59. };
  60. GLIB_AVAILABLE_IN_ALL
  61. GType g_tls_connection_get_type (void) G_GNUC_CONST;
  62. GLIB_DEPRECATED
  63. void g_tls_connection_set_use_system_certdb (GTlsConnection *conn,
  64. gboolean use_system_certdb);
  65. GLIB_DEPRECATED
  66. gboolean g_tls_connection_get_use_system_certdb (GTlsConnection *conn);
  67. GLIB_AVAILABLE_IN_ALL
  68. void g_tls_connection_set_database (GTlsConnection *conn,
  69. GTlsDatabase *database);
  70. GLIB_AVAILABLE_IN_ALL
  71. GTlsDatabase * g_tls_connection_get_database (GTlsConnection *conn);
  72. GLIB_AVAILABLE_IN_ALL
  73. void g_tls_connection_set_certificate (GTlsConnection *conn,
  74. GTlsCertificate *certificate);
  75. GLIB_AVAILABLE_IN_ALL
  76. GTlsCertificate *g_tls_connection_get_certificate (GTlsConnection *conn);
  77. GLIB_AVAILABLE_IN_ALL
  78. void g_tls_connection_set_interaction (GTlsConnection *conn,
  79. GTlsInteraction *interaction);
  80. GLIB_AVAILABLE_IN_ALL
  81. GTlsInteraction * g_tls_connection_get_interaction (GTlsConnection *conn);
  82. GLIB_AVAILABLE_IN_ALL
  83. GTlsCertificate *g_tls_connection_get_peer_certificate (GTlsConnection *conn);
  84. GLIB_AVAILABLE_IN_ALL
  85. GTlsCertificateFlags g_tls_connection_get_peer_certificate_errors (GTlsConnection *conn);
  86. GLIB_AVAILABLE_IN_ALL
  87. void g_tls_connection_set_require_close_notify (GTlsConnection *conn,
  88. gboolean require_close_notify);
  89. GLIB_AVAILABLE_IN_ALL
  90. gboolean g_tls_connection_get_require_close_notify (GTlsConnection *conn);
  91. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  92. GLIB_DEPRECATED_IN_2_60
  93. void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn,
  94. GTlsRehandshakeMode mode);
  95. GLIB_DEPRECATED_IN_2_60
  96. GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn);
  97. G_GNUC_END_IGNORE_DEPRECATIONS
  98. GLIB_AVAILABLE_IN_2_60
  99. void g_tls_connection_set_advertised_protocols (GTlsConnection *conn,
  100. const gchar * const *protocols);
  101. GLIB_AVAILABLE_IN_2_60
  102. const gchar * g_tls_connection_get_negotiated_protocol (GTlsConnection *conn);
  103. GLIB_AVAILABLE_IN_ALL
  104. gboolean g_tls_connection_handshake (GTlsConnection *conn,
  105. GCancellable *cancellable,
  106. GError **error);
  107. GLIB_AVAILABLE_IN_ALL
  108. void g_tls_connection_handshake_async (GTlsConnection *conn,
  109. int io_priority,
  110. GCancellable *cancellable,
  111. GAsyncReadyCallback callback,
  112. gpointer user_data);
  113. GLIB_AVAILABLE_IN_ALL
  114. gboolean g_tls_connection_handshake_finish (GTlsConnection *conn,
  115. GAsyncResult *result,
  116. GError **error);
  117. /**
  118. * G_TLS_ERROR:
  119. *
  120. * Error domain for TLS. Errors in this domain will be from the
  121. * #GTlsError enumeration. See #GError for more information on error
  122. * domains.
  123. */
  124. #define G_TLS_ERROR (g_tls_error_quark ())
  125. GLIB_AVAILABLE_IN_ALL
  126. GQuark g_tls_error_quark (void);
  127. /*< protected >*/
  128. GLIB_AVAILABLE_IN_ALL
  129. gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn,
  130. GTlsCertificate *peer_cert,
  131. GTlsCertificateFlags errors);
  132. G_END_DECLS
  133. #endif /* __G_TLS_CONNECTION_H__ */