1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4
* Copyright (C) Philip Withnall 2011 <philip@tecnocode.co.uk>
6
* GData Client is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GData Client is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GData Client. If not, see <http://www.gnu.org/licenses/>.
20
#ifndef GDATA_AUTHORIZER_H
21
#define GDATA_AUTHORIZER_H
24
#include <glib-object.h>
26
#include <libsoup/soup.h>
28
#include <gdata/gdata-authorization-domain.h>
32
#define GDATA_TYPE_AUTHORIZER (gdata_authorizer_get_type ())
33
#define GDATA_AUTHORIZER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_AUTHORIZER, GDataAuthorizer))
34
#define GDATA_AUTHORIZER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_AUTHORIZER, GDataAuthorizerInterface))
35
#define GDATA_IS_AUTHORIZER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDATA_TYPE_AUTHORIZER))
36
#define GDATA_AUTHORIZER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GDATA_TYPE_AUTHORIZER, GDataAuthorizerInterface))
41
* All the fields in the #GDataAuthorizer structure are private and should never be accessed directly.
45
typedef struct _GDataAuthorizer GDataAuthorizer; /* dummy typedef */
48
* GDataAuthorizerInterface:
49
* @parent: the parent type
50
* @process_request: a function to append authorization headers to queries before they are submitted to the online service under the given
51
* authorization domain (which may be %NULL); this must be implemented and must be thread safe, and must also handle being called multiple times on
52
* the same #SoupMessage instance (so must be careful to replace headers rather than append them, for example)
53
* @is_authorized_for_domain: a function to check whether the authorizer is authorized against the given domain; this must be implemented and must
55
* @refresh_authorization: (allow-none): a function to force a refresh of any authorization tokens the authorizer holds, returning %TRUE if a refresh
56
* was attempted and was successful, or %FALSE if a refresh wasn't attempted or was unsuccessful; if this isn't implemented it's assumed %FALSE
57
* would've been returned, if it is implemented it must be thread safe
58
* @refresh_authorization_async: (allow-none): an asynchronous version of @refresh_authorization; if this isn't implemented and @refresh_authorization
59
* is, @refresh_authorization will be called in a thread to simulate this function, whereas if this is implemented @refresh_authorization_finish must
60
* also be implemented and both functions must be thread safe
61
* @refresh_authorization_finish: (allow-none): a finish function for the asynchronous version of @refresh_authorization; this must be implemented
62
* exactly if @refresh_authorization_async is implemented, and must be thread safe if it is implemented
64
* The class structure for the #GDataAuthorizer interface.
69
GTypeInterface parent;
71
void (*process_request) (GDataAuthorizer *self, GDataAuthorizationDomain *domain, SoupMessage *message);
72
gboolean (*is_authorized_for_domain) (GDataAuthorizer *self, GDataAuthorizationDomain *domain);
73
gboolean (*refresh_authorization) (GDataAuthorizer *self, GCancellable *cancellable, GError **error);
74
void (*refresh_authorization_async) (GDataAuthorizer *self, GCancellable *cancellable,
75
GAsyncReadyCallback callback, gpointer user_data);
76
gboolean (*refresh_authorization_finish) (GDataAuthorizer *self, GAsyncResult *async_result, GError **error);
77
} GDataAuthorizerInterface;
79
GType gdata_authorizer_get_type (void) G_GNUC_CONST;
81
void gdata_authorizer_process_request (GDataAuthorizer *self, GDataAuthorizationDomain *domain, SoupMessage *message);
82
gboolean gdata_authorizer_is_authorized_for_domain (GDataAuthorizer *self, GDataAuthorizationDomain *domain);
84
gboolean gdata_authorizer_refresh_authorization (GDataAuthorizer *self, GCancellable *cancellable, GError **error);
85
void gdata_authorizer_refresh_authorization_async (GDataAuthorizer *self, GCancellable *cancellable,
86
GAsyncReadyCallback callback, gpointer user_data);
87
gboolean gdata_authorizer_refresh_authorization_finish (GDataAuthorizer *self, GAsyncResult *async_result, GError **error);
91
#endif /* !GDATA_AUTHORIZER_H */