1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 2 /* 3 * Copyright © 2012 – 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_UTILS_H__ 24 #define __GOA_UTILS_H__ 25 26 #include <gio/gio.h> 27 #include <glib.h> 28 #include <gtk/gtk.h> 29 #include <libsoup/soup.h> 30 31 #include "goaprovider.h" 32 33 G_BEGIN_DECLS 34 35 #define GOA_OAUTH2_ACCESS_DENIED "access_denied" 36 37 #define GOA_SETTINGS_SCHEMA "org.gnome.online-accounts" 38 #define GOA_SETTINGS_WHITELISTED_PROVIDERS "whitelisted-providers" 39 40 typedef gpointer (*GoaPeekInterfaceFunc) (GoaObject *); 41 42 void goa_utils_account_add_attention_needed (GoaClient *client, 43 GoaObject *object, 44 GoaProvider *provider, 45 GtkBox *vbox); 46 47 void goa_utils_account_add_header (GoaObject *object, GtkGrid *grid, gint row); 48 49 gboolean goa_utils_check_duplicate (GoaClient *client, 50 const gchar *identity, 51 const gchar *presentation_identity, 52 const gchar *provider_type, 53 GoaPeekInterfaceFunc func, 54 GError **error); 55 56 gint goa_utils_convert_abs_usec_to_duration_sec (gint64 abs_usec); 57 58 gint64 goa_utils_convert_duration_sec_to_abs_usec (gint duration_sec); 59 60 gchar *goa_utils_data_input_stream_read_line (GDataInputStream *stream, 61 gsize *length, 62 GCancellable *cancellable, 63 GError **error); 64 65 void goa_utils_set_dialog_title (GoaProvider *provider, GtkDialog *dialog, gboolean add_account); 66 67 gboolean goa_utils_delete_credentials_for_account_sync (GoaProvider *provider, 68 GoaAccount *account, 69 GCancellable *cancellable, 70 GError **error); 71 72 gboolean goa_utils_delete_credentials_for_id_sync (GoaProvider *provider, 73 const gchar *id, 74 GCancellable *cancellable, 75 GError **error); 76 77 GVariant *goa_utils_lookup_credentials_sync (GoaProvider *provider, 78 GoaObject *object, 79 GCancellable *cancellable, 80 GError **error); 81 82 gboolean goa_utils_store_credentials_for_id_sync (GoaProvider *provider, 83 const gchar *id, 84 GVariant *credentials, 85 GCancellable *cancellable, 86 GError **error); 87 88 gboolean goa_utils_store_credentials_for_object_sync (GoaProvider *provider, 89 GoaObject *object, 90 GVariant *credentials, 91 GCancellable *cancellable, 92 GError **error); 93 94 gboolean goa_utils_keyfile_copy_group (GKeyFile *src_key_file, 95 const gchar *src_group_name, 96 GKeyFile *dest_key_file, 97 const gchar *dest_group_name); 98 99 gboolean goa_utils_keyfile_get_boolean (GKeyFile *key_file, const gchar *group_name, const gchar *key); 100 101 void goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key); 102 103 void goa_utils_keyfile_set_boolean (GoaAccount *account, const gchar *key, gboolean value); 104 105 void goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value); 106 107 gboolean goa_utils_parse_email_address (const gchar *email, gchar **out_username, gchar **out_domain); 108 109 void goa_utils_set_error_soup (GError **err, SoupMessage *msg); 110 111 void goa_utils_set_error_ssl (GError **err, GTlsCertificateFlags flags); 112 113 gboolean goa_utils_get_credentials (GoaProvider *provider, 114 GoaObject *object, 115 const gchar *id, 116 gchar **username, 117 gchar **password, 118 GCancellable *cancellable, 119 GError **error); 120 121 G_END_DECLS 122 123 #endif /* __GOA_UTILS_H__ */ 124