(root)/
glib-2.79.0/
gio/
gdbusauthmechanism.h
       1  /* GDBus - GLib D-Bus Library
       2   *
       3   * Copyright (C) 2008-2010 Red Hat, Inc.
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   *
       7   * This library is free software; you can redistribute it and/or
       8   * modify it under the terms of the GNU Lesser General Public
       9   * License as published by the Free Software Foundation; either
      10   * version 2.1 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   * Lesser General Public License for more details.
      16   *
      17   * You should have received a copy of the GNU Lesser General
      18   * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19   *
      20   * Author: David Zeuthen <davidz@redhat.com>
      21   */
      22  
      23  #ifndef __G_DBUS_AUTH_MECHANISM_H__
      24  #define __G_DBUS_AUTH_MECHANISM_H__
      25  
      26  #if !defined (GIO_COMPILATION)
      27  #error "gdbusauthmechanism.h is a private header file."
      28  #endif
      29  
      30  #include <gio/giotypes.h>
      31  
      32  G_BEGIN_DECLS
      33  
      34  #define G_TYPE_DBUS_AUTH_MECHANISM         (_g_dbus_auth_mechanism_get_type ())
      35  #define G_DBUS_AUTH_MECHANISM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanism))
      36  #define G_DBUS_AUTH_MECHANISM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanismClass))
      37  #define G_DBUS_AUTH_MECHANISM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanismClass))
      38  #define G_IS_DBUS_AUTH_MECHANISM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_AUTH_MECHANISM))
      39  #define G_IS_DBUS_AUTH_MECHANISM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_AUTH_MECHANISM))
      40  
      41  typedef struct _GDBusAuthMechanism        GDBusAuthMechanism;
      42  typedef struct _GDBusAuthMechanismClass   GDBusAuthMechanismClass;
      43  typedef struct _GDBusAuthMechanismPrivate GDBusAuthMechanismPrivate;
      44  
      45  typedef enum {
      46    G_DBUS_AUTH_MECHANISM_STATE_INVALID,
      47    G_DBUS_AUTH_MECHANISM_STATE_WAITING_FOR_DATA,
      48    G_DBUS_AUTH_MECHANISM_STATE_HAVE_DATA_TO_SEND,
      49    G_DBUS_AUTH_MECHANISM_STATE_REJECTED,
      50    G_DBUS_AUTH_MECHANISM_STATE_ACCEPTED,
      51  } GDBusAuthMechanismState;
      52  
      53  struct _GDBusAuthMechanismClass
      54  {
      55    /*< private >*/
      56    GObjectClass parent_class;
      57  
      58    /*< public >*/
      59  
      60    /* VTable */
      61  
      62    /* TODO: server_initiate and client_initiate probably needs to have a
      63     * GCredentials parameter...
      64     */
      65  
      66    gint                      (*get_priority)             (void);
      67    const gchar              *(*get_name)                 (void);
      68  
      69    /* functions shared by server/client */
      70    gboolean                  (*is_supported)             (GDBusAuthMechanism   *mechanism);
      71    gchar                    *(*encode_data)              (GDBusAuthMechanism   *mechanism,
      72                                                           const gchar          *data,
      73                                                           gsize                 data_len,
      74                                                           gsize                *out_data_len);
      75    gchar                    *(*decode_data)              (GDBusAuthMechanism   *mechanism,
      76                                                           const gchar          *data,
      77                                                           gsize                 data_len,
      78                                                           gsize                *out_data_len);
      79  
      80    /* functions for server-side authentication */
      81    GDBusAuthMechanismState   (*server_get_state)         (GDBusAuthMechanism   *mechanism);
      82    void                      (*server_initiate)          (GDBusAuthMechanism   *mechanism,
      83                                                           const gchar          *initial_response,
      84                                                           gsize                 initial_response_len);
      85    void                      (*server_data_receive)      (GDBusAuthMechanism   *mechanism,
      86                                                           const gchar          *data,
      87                                                           gsize                 data_len);
      88    gchar                    *(*server_data_send)         (GDBusAuthMechanism   *mechanism,
      89                                                           gsize                *out_data_len);
      90    gchar                    *(*server_get_reject_reason) (GDBusAuthMechanism   *mechanism);
      91    void                      (*server_shutdown)          (GDBusAuthMechanism   *mechanism);
      92  
      93    /* functions for client-side authentication */
      94    GDBusAuthMechanismState   (*client_get_state)         (GDBusAuthMechanism   *mechanism);
      95    gchar                    *(*client_initiate)          (GDBusAuthMechanism   *mechanism,
      96                                                           GDBusConnectionFlags  conn_flags,
      97                                                           gsize                *out_initial_response_len);
      98    void                      (*client_data_receive)      (GDBusAuthMechanism   *mechanism,
      99                                                           const gchar          *data,
     100                                                           gsize                 data_len);
     101    gchar                    *(*client_data_send)         (GDBusAuthMechanism   *mechanism,
     102                                                           gsize                *out_data_len);
     103    void                      (*client_shutdown)          (GDBusAuthMechanism   *mechanism);
     104  };
     105  
     106  struct _GDBusAuthMechanism
     107  {
     108    GObject parent_instance;
     109    GDBusAuthMechanismPrivate *priv;
     110  };
     111  
     112  GType                     _g_dbus_auth_mechanism_get_type                 (void) G_GNUC_CONST;
     113  
     114  gint                      _g_dbus_auth_mechanism_get_priority             (GType                 mechanism_type);
     115  const gchar              *_g_dbus_auth_mechanism_get_name                 (GType                 mechanism_type);
     116  
     117  GIOStream                *_g_dbus_auth_mechanism_get_stream               (GDBusAuthMechanism   *mechanism);
     118  GCredentials             *_g_dbus_auth_mechanism_get_credentials          (GDBusAuthMechanism   *mechanism);
     119  
     120  gboolean                  _g_dbus_auth_mechanism_is_supported             (GDBusAuthMechanism   *mechanism);
     121  gchar                    *_g_dbus_auth_mechanism_encode_data              (GDBusAuthMechanism   *mechanism,
     122                                                                             const gchar          *data,
     123                                                                             gsize                 data_len,
     124                                                                             gsize                *out_data_len);
     125  gchar                    *_g_dbus_auth_mechanism_decode_data              (GDBusAuthMechanism   *mechanism,
     126                                                                             const gchar          *data,
     127                                                                             gsize                 data_len,
     128                                                                             gsize                *out_data_len);
     129  
     130  GDBusAuthMechanismState   _g_dbus_auth_mechanism_server_get_state         (GDBusAuthMechanism   *mechanism);
     131  void                      _g_dbus_auth_mechanism_server_initiate          (GDBusAuthMechanism   *mechanism,
     132                                                                             const gchar          *initial_response,
     133                                                                             gsize                 initial_response_len);
     134  void                      _g_dbus_auth_mechanism_server_data_receive      (GDBusAuthMechanism   *mechanism,
     135                                                                             const gchar          *data,
     136                                                                             gsize                 data_len);
     137  gchar                    *_g_dbus_auth_mechanism_server_data_send         (GDBusAuthMechanism   *mechanism,
     138                                                                             gsize                *out_data_len);
     139  gchar                    *_g_dbus_auth_mechanism_server_get_reject_reason (GDBusAuthMechanism   *mechanism);
     140  void                      _g_dbus_auth_mechanism_server_shutdown          (GDBusAuthMechanism   *mechanism);
     141  
     142  GDBusAuthMechanismState   _g_dbus_auth_mechanism_client_get_state         (GDBusAuthMechanism   *mechanism);
     143  gchar                    *_g_dbus_auth_mechanism_client_initiate          (GDBusAuthMechanism   *mechanism,
     144                                                                             GDBusConnectionFlags  conn_flags,
     145                                                                             gsize                *out_initial_response_len);
     146  void                      _g_dbus_auth_mechanism_client_data_receive      (GDBusAuthMechanism   *mechanism,
     147                                                                             const gchar          *data,
     148                                                                             gsize                 data_len);
     149  gchar                    *_g_dbus_auth_mechanism_client_data_send         (GDBusAuthMechanism   *mechanism,
     150                                                                            gsize                *out_data_len);
     151  void                      _g_dbus_auth_mechanism_client_shutdown          (GDBusAuthMechanism   *mechanism);
     152  
     153  
     154  G_END_DECLS
     155  
     156  #endif /* __G_DBUS_AUTH_MECHANISM_H__ */