1 /*
2  * e-backend.h
3  *
4  * This library is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library. If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #if !defined (__LIBEBACKEND_H_INSIDE__) && !defined (LIBEBACKEND_COMPILATION)
19 #error "Only <libebackend/libebackend.h> should be included directly."
20 #endif
21 
22 #ifndef E_BACKEND_H
23 #define E_BACKEND_H
24 
25 #include <libedataserver/libedataserver.h>
26 
27 /* Standard GObject macros */
28 #define E_TYPE_BACKEND \
29 	(e_backend_get_type ())
30 #define E_BACKEND(obj) \
31 	(G_TYPE_CHECK_INSTANCE_CAST \
32 	((obj), E_TYPE_BACKEND, EBackend))
33 #define E_BACKEND_CLASS(cls) \
34 	(G_TYPE_CHECK_CLASS_CAST \
35 	((cls), E_TYPE_BACKEND, EBackendClass))
36 #define E_IS_BACKEND(obj) \
37 	(G_TYPE_CHECK_INSTANCE_TYPE \
38 	((obj), E_TYPE_BACKEND))
39 #define E_IS_BACKEND_CLASS(cls) \
40 	(G_TYPE_CHECK_CLASS_TYPE \
41 	((cls), E_TYPE_BACKEND))
42 #define E_BACKEND_GET_CLASS(obj) \
43 	(G_TYPE_INSTANCE_GET_CLASS \
44 	((obj), E_TYPE_BACKEND, EBackendClass))
45 
46 G_BEGIN_DECLS
47 
48 /* forward declaration */
49 struct _EUserPrompter;
50 
51 typedef struct _EBackend EBackend;
52 typedef struct _EBackendClass EBackendClass;
53 typedef struct _EBackendPrivate EBackendPrivate;
54 
55 /**
56  * EBackend:
57  *
58  * Contains only private data that should be read and manipulated using the
59  * functions below.
60  *
61  * Since: 3.4
62  **/
63 struct _EBackend {
64 	/*< private >*/
65 	GObject parent;
66 	EBackendPrivate *priv;
67 };
68 
69 /**
70  * EBackendClass:
71  * @authenticate_sync: Authenticate synchronously
72  * @get_destination_address: Fetch the destination address
73  * @prepare_shutdown: Prepare for shutdown
74  *
75  * Base class structure for the #EBackend class
76  *
77  * Since: 3.4
78  **/
79 struct _EBackendClass {
80 	/*< private >*/
81 	GObjectClass parent_class;
82 
83 	/*< public >*/
84 	/* Methods */
85 	gboolean	(*get_destination_address)
86 						(EBackend *backend,
87 						 gchar **host,
88 						 guint16 *port);
89 	void		(*prepare_shutdown)	(EBackend *backend);
90 
91 	ESourceAuthenticationResult
92 			(*authenticate_sync)	(EBackend *backend,
93 						 const ENamedParameters *credentials,
94 						 gchar **out_certificate_pem,
95 						 GTlsCertificateFlags *out_certificate_errors,
96 						 GCancellable *cancellable,
97 						 GError **error);
98 
99 	/*< private >*/
100 	gpointer reserved[11];
101 };
102 
103 GType		e_backend_get_type		(void) G_GNUC_CONST;
104 gboolean	e_backend_get_online		(EBackend *backend);
105 void		e_backend_set_online		(EBackend *backend,
106 						 gboolean online);
107 void		e_backend_ensure_online_state_updated
108 						(EBackend *backend,
109 						 GCancellable *cancellable);
110 ESource *	e_backend_get_source		(EBackend *backend);
111 GSocketConnectable *
112 		e_backend_ref_connectable	(EBackend *backend);
113 void		e_backend_set_connectable	(EBackend *backend,
114 						 GSocketConnectable *connectable);
115 GMainContext *	e_backend_ref_main_context	(EBackend *backend);
116 gboolean	e_backend_credentials_required_sync
117 						(EBackend *backend,
118 						 ESourceCredentialsReason reason,
119 						 const gchar *certificate_pem,
120 						 GTlsCertificateFlags certificate_errors,
121 						 const GError *op_error,
122 						 GCancellable *cancellable,
123 						 GError **error);
124 void		e_backend_credentials_required	(EBackend *backend,
125 						 ESourceCredentialsReason reason,
126 						 const gchar *certificate_pem,
127 						 GTlsCertificateFlags certificate_errors,
128 						 const GError *op_error,
129 						 GCancellable *cancellable,
130 						 GAsyncReadyCallback callback,
131 						 gpointer user_data);
132 gboolean	e_backend_credentials_required_finish
133 						(EBackend *backend,
134 						 GAsyncResult *result,
135 						 GError **error);
136 void		e_backend_schedule_credentials_required
137 						(EBackend *backend,
138 						 ESourceCredentialsReason reason,
139 						 const gchar *certificate_pem,
140 						 GTlsCertificateFlags certificate_errors,
141 						 const GError *op_error,
142 						 GCancellable *cancellable,
143 						 const gchar *who_calls);
144 void		e_backend_schedule_authenticate	(EBackend *backend,
145 						 const ENamedParameters *credentials);
146 void		e_backend_ensure_source_status_connected
147 						(EBackend *backend);
148 struct _EUserPrompter *
149 		e_backend_get_user_prompter	(EBackend *backend);
150 ETrustPromptResponse
151 		e_backend_trust_prompt_sync	(EBackend *backend,
152 						 const ENamedParameters *parameters,
153 						 GCancellable *cancellable,
154 						 GError **error);
155 void		e_backend_trust_prompt		(EBackend *backend,
156 						 const ENamedParameters *parameters,
157 						 GCancellable *cancellable,
158 						 GAsyncReadyCallback callback,
159 						 gpointer user_data);
160 ETrustPromptResponse
161 		e_backend_trust_prompt_finish	(EBackend *backend,
162 						 GAsyncResult *result,
163 						 GError **error);
164 
165 gboolean	e_backend_get_destination_address
166 						(EBackend *backend,
167 						 gchar **host,
168 						 guint16 *port);
169 gboolean	e_backend_is_destination_reachable
170 						(EBackend *backend,
171 						 GCancellable *cancellable,
172 						 GError **error);
173 void		e_backend_prepare_shutdown	(EBackend *backend);
174 
175 G_END_DECLS
176 
177 #endif /* E_BACKEND_H */
178