gtlsconnection.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 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. GLIB_AVAILABLE_IN_ALL
  92. void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn,
  93. GTlsRehandshakeMode mode);
  94. GLIB_AVAILABLE_IN_ALL
  95. GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn);
  96. GLIB_AVAILABLE_IN_ALL
  97. gboolean g_tls_connection_handshake (GTlsConnection *conn,
  98. GCancellable *cancellable,
  99. GError **error);
  100. GLIB_AVAILABLE_IN_ALL
  101. void g_tls_connection_handshake_async (GTlsConnection *conn,
  102. int io_priority,
  103. GCancellable *cancellable,
  104. GAsyncReadyCallback callback,
  105. gpointer user_data);
  106. GLIB_AVAILABLE_IN_ALL
  107. gboolean g_tls_connection_handshake_finish (GTlsConnection *conn,
  108. GAsyncResult *result,
  109. GError **error);
  110. /**
  111. * G_TLS_ERROR:
  112. *
  113. * Error domain for TLS. Errors in this domain will be from the
  114. * #GTlsError enumeration. See #GError for more information on error
  115. * domains.
  116. */
  117. #define G_TLS_ERROR (g_tls_error_quark ())
  118. GLIB_AVAILABLE_IN_ALL
  119. GQuark g_tls_error_quark (void);
  120. /*< protected >*/
  121. GLIB_AVAILABLE_IN_ALL
  122. gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn,
  123. GTlsCertificate *peer_cert,
  124. GTlsCertificateFlags errors);
  125. G_END_DECLS
  126. #endif /* __G_TLS_CONNECTION_H__ */