1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 2 /* 3 * Copyright © 2013 – 2017 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 19 #if !defined (__GOA_BACKEND_INSIDE_GOA_BACKEND_H__) && !defined (GOA_BACKEND_COMPILATION) 20 #error "Only <goabackend/goabackend.h> can be included directly." 21 #endif 22 23 #ifndef __GOA_PROVIDER_PRIV_H__ 24 #define __GOA_PROVIDER_PRIV_H__ 25 26 #include <gio/gio.h> 27 #include <goa/goa.h> 28 #include <goabackend/goaprovider.h> 29 #include <goabackend/goabackendenums.h> 30 #include <gtk/gtk.h> 31 32 G_BEGIN_DECLS 33 34 /** 35 * GoaProvider: 36 * 37 * The #GoaProvider structure contains only private data and should 38 * only be accessed using the provided API. 39 */ 40 41 /** 42 * GoaProviderClass: 43 * @parent_class: The parent class. 44 * @get_provider_type: Virtual function for goa_provider_get_provider_type(). 45 * @get_provider_name: Virtual function for goa_provider_get_provider_name(). 46 * @get_provider_icon: Virtual function for goa_provider_get_provider_icon(). 47 * @get_provider_group: Virtual function for goa_provider_get_provider_group(). 48 * @get_provider_features: Virtual function for goa_provider_get_provider_features(). 49 * @add_account: Virtual function for goa_provider_add_account(). 50 * @refresh_account: Virtual function for goa_provider_refresh_account(). 51 * @build_object: Virtual function for goa_provider_build_object(). 52 * @ensure_credentials_sync: Virtual function for goa_provider_ensure_credentials_sync(). 53 * @show_account: Virtual function for goa_provider_show_account(). 54 * @get_credentials_generation: Virtual function for goa_provider_get_credentials_generation(). 55 * 56 * Class structure for #GoaProvider. 57 */ 58 struct _GoaProviderClass 59 { 60 GObjectClass parent_class; 61 62 /* pure virtual */ 63 GoaObject *(*add_account) (GoaProvider *self, 64 GoaClient *client, 65 GtkDialog *dialog, 66 GtkBox *vbox, 67 GError **error); 68 GoaProviderFeatures (*get_provider_features) (GoaProvider *self); 69 GoaProviderGroup (*get_provider_group) (GoaProvider *self); 70 gchar *(*get_provider_name) (GoaProvider *self, 71 GoaObject *object); 72 const gchar *(*get_provider_type) (GoaProvider *self); 73 gboolean (*refresh_account) (GoaProvider *self, 74 GoaClient *client, 75 GoaObject *object, 76 GtkWindow *parent, 77 GError **error); 78 79 /* virtual but with default implementation */ 80 gboolean (*build_object) (GoaProvider *self, 81 GoaObjectSkeleton *object, 82 GKeyFile *key_file, 83 const gchar *group, 84 GDBusConnection *connection, 85 gboolean just_added, 86 GError **error); 87 gboolean (*ensure_credentials_sync) (GoaProvider *self, 88 GoaObject *object, 89 gint *out_expires_in, 90 GCancellable *cancellable, 91 GError **error); 92 guint (*get_credentials_generation) (GoaProvider *self); 93 GIcon *(*get_provider_icon) (GoaProvider *self, 94 GoaObject *object); 95 void (*remove_account) (GoaProvider *self, 96 GoaObject *object, 97 GCancellable *cancellable, 98 GAsyncReadyCallback callback, 99 gpointer user_data); 100 gboolean (*remove_account_finish) (GoaProvider *self, 101 GAsyncResult *res, 102 GError **error); 103 void (*show_account) (GoaProvider *self, 104 GoaClient *client, 105 GoaObject *object, 106 GtkBox *vbox, 107 GtkGrid *dummy1, 108 GtkGrid *dummy2); 109 }; 110 111 /** 112 * GOA_PROVIDER_EXTENSION_POINT_NAME: 113 * 114 * Extension point for #GoaProvider implementations. 115 */ 116 #define GOA_PROVIDER_EXTENSION_POINT_NAME "goa-backend-provider" 117 118 void goa_provider_ensure_builtins_loaded (void); 119 120 void goa_provider_ensure_extension_points_registered (void); 121 122 gboolean goa_provider_build_object (GoaProvider *self, 123 GoaObjectSkeleton *object, 124 GKeyFile *key_file, 125 const gchar *group, 126 GDBusConnection *connection, 127 gboolean just_added, 128 GError **error); 129 130 void goa_provider_ensure_credentials (GoaProvider *self, 131 GoaObject *object, 132 GCancellable *cancellable, 133 GAsyncReadyCallback callback, 134 gpointer user_data); 135 136 gboolean goa_provider_ensure_credentials_finish (GoaProvider *self, 137 gint *out_expires_in, 138 GAsyncResult *res, 139 GError **error); 140 141 gboolean goa_provider_ensure_credentials_sync (GoaProvider *self, 142 GoaObject *object, 143 gint *out_expires_in, 144 GCancellable *cancellable, 145 GError **error); 146 147 void goa_provider_remove_account (GoaProvider *self, 148 GoaObject *object, 149 GCancellable *cancellable, 150 GAsyncReadyCallback callback, 151 gpointer user_data); 152 153 gboolean goa_provider_remove_account_finish (GoaProvider *self, 154 GAsyncResult *res, 155 GError **error); 156 157 G_END_DECLS 158 159 #endif /* __GOA_PROVIDER_PRIV_H__ */ 160