Blame gdata/gdata-authorizer.h

Packit 4b6dd7
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
Packit 4b6dd7
/*
Packit 4b6dd7
 * GData Client
Packit 4b6dd7
 * Copyright (C) Philip Withnall 2011 <philip@tecnocode.co.uk>
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is free software; you can redistribute it and/or
Packit 4b6dd7
 * modify it under the terms of the GNU Lesser General Public
Packit 4b6dd7
 * License as published by the Free Software Foundation; either
Packit 4b6dd7
 * version 2.1 of the License, or (at your option) any later version.
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is distributed in the hope that it will be useful,
Packit 4b6dd7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4b6dd7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 4b6dd7
 * Lesser General Public License for more details.
Packit 4b6dd7
 *
Packit 4b6dd7
 * You should have received a copy of the GNU Lesser General Public
Packit 4b6dd7
 * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
#ifndef GDATA_AUTHORIZER_H
Packit 4b6dd7
#define GDATA_AUTHORIZER_H
Packit 4b6dd7
Packit 4b6dd7
#include <glib.h>
Packit 4b6dd7
#include <glib-object.h>
Packit 4b6dd7
#include <gio/gio.h>
Packit 4b6dd7
#include <libsoup/soup.h>
Packit 4b6dd7
Packit 4b6dd7
#include <gdata/gdata-authorization-domain.h>
Packit 4b6dd7
Packit 4b6dd7
G_BEGIN_DECLS
Packit 4b6dd7
Packit 4b6dd7
#define GDATA_TYPE_AUTHORIZER		(gdata_authorizer_get_type ())
Packit 4b6dd7
#define GDATA_AUTHORIZER(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_AUTHORIZER, GDataAuthorizer))
Packit 4b6dd7
#define GDATA_AUTHORIZER_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_AUTHORIZER, GDataAuthorizerInterface))
Packit 4b6dd7
#define GDATA_IS_AUTHORIZER(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GDATA_TYPE_AUTHORIZER))
Packit 4b6dd7
#define GDATA_AUTHORIZER_GET_IFACE(o)	(G_TYPE_INSTANCE_GET_INTERFACE ((o), GDATA_TYPE_AUTHORIZER, GDataAuthorizerInterface))
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * GDataAuthorizer:
Packit 4b6dd7
 *
Packit 4b6dd7
 * All the fields in the #GDataAuthorizer structure are private and should never be accessed directly.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.0
Packit 4b6dd7
 */
Packit 4b6dd7
typedef struct _GDataAuthorizer		GDataAuthorizer; /* dummy typedef */
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * GDataAuthorizerInterface:
Packit 4b6dd7
 * @parent: the parent type
Packit 4b6dd7
 * @process_request: a function to append authorization headers to queries before they are submitted to the online service under the given
Packit 4b6dd7
 * authorization domain (which may be %NULL); this must be implemented and must be thread safe, and must also handle being called multiple times on
Packit 4b6dd7
 * the same #SoupMessage instance (so must be careful to replace headers rather than append them, for example)
Packit 4b6dd7
 * @is_authorized_for_domain: a function to check whether the authorizer is authorized against the given domain; this must be implemented and must
Packit 4b6dd7
 * be thread safe
Packit 4b6dd7
 * @refresh_authorization: (allow-none): a function to force a refresh of any authorization tokens the authorizer holds, returning %TRUE if a refresh
Packit 4b6dd7
 * 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
Packit 4b6dd7
 * would've been returned, if it is implemented it must be thread safe
Packit 4b6dd7
 * @refresh_authorization_async: (allow-none): an asynchronous version of @refresh_authorization; if this isn't implemented and @refresh_authorization
Packit 4b6dd7
 * is, @refresh_authorization will be called in a thread to simulate this function, whereas if this is implemented @refresh_authorization_finish must
Packit 4b6dd7
 * also be implemented and both functions must be thread safe
Packit 4b6dd7
 * @refresh_authorization_finish: (allow-none): a finish function for the asynchronous version of @refresh_authorization; this must be implemented
Packit 4b6dd7
 * exactly if @refresh_authorization_async is implemented, and must be thread safe if it is implemented
Packit 4b6dd7
 *
Packit 4b6dd7
 * The class structure for the #GDataAuthorizer interface.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.0
Packit 4b6dd7
 */
Packit 4b6dd7
typedef struct {
Packit 4b6dd7
	GTypeInterface parent;
Packit 4b6dd7
Packit 4b6dd7
	void (*process_request) (GDataAuthorizer *self, GDataAuthorizationDomain *domain, SoupMessage *message);
Packit 4b6dd7
	gboolean (*is_authorized_for_domain) (GDataAuthorizer *self, GDataAuthorizationDomain *domain);
Packit 4b6dd7
	gboolean (*refresh_authorization) (GDataAuthorizer *self, GCancellable *cancellable, GError **error);
Packit 4b6dd7
	void (*refresh_authorization_async) (GDataAuthorizer *self, GCancellable *cancellable,
Packit 4b6dd7
	                                     GAsyncReadyCallback callback, gpointer user_data);
Packit 4b6dd7
	gboolean (*refresh_authorization_finish) (GDataAuthorizer *self, GAsyncResult *async_result, GError **error);
Packit 4b6dd7
} GDataAuthorizerInterface;
Packit 4b6dd7
Packit 4b6dd7
GType gdata_authorizer_get_type (void) G_GNUC_CONST;
Packit 4b6dd7
Packit 4b6dd7
void gdata_authorizer_process_request (GDataAuthorizer *self, GDataAuthorizationDomain *domain, SoupMessage *message);
Packit 4b6dd7
gboolean gdata_authorizer_is_authorized_for_domain (GDataAuthorizer *self, GDataAuthorizationDomain *domain);
Packit 4b6dd7
Packit 4b6dd7
gboolean gdata_authorizer_refresh_authorization (GDataAuthorizer *self, GCancellable *cancellable, GError **error);
Packit 4b6dd7
void gdata_authorizer_refresh_authorization_async (GDataAuthorizer *self, GCancellable *cancellable,
Packit 4b6dd7
                                                   GAsyncReadyCallback callback, gpointer user_data);
Packit 4b6dd7
gboolean gdata_authorizer_refresh_authorization_finish (GDataAuthorizer *self, GAsyncResult *async_result, GError **error);
Packit 4b6dd7
Packit 4b6dd7
G_END_DECLS
Packit 4b6dd7
Packit 4b6dd7
#endif /* !GDATA_AUTHORIZER_H */