Blame gfbgraph/gfbgraph-authorizer.c

Packit 87b8d1
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-  */
Packit 87b8d1
/*
Packit 87b8d1
 * libgfbgraph - GObject library for Facebook Graph API
Packit 87b8d1
 * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com>
Packit 87b8d1
 *
Packit 87b8d1
 * GFBGraph is free software; you can redistribute it and/or
Packit 87b8d1
 * modify it under the terms of the GNU Lesser General Public
Packit 87b8d1
 * License as published by the Free Software Foundation; either
Packit 87b8d1
 * version 2.1 of the License, or (at your option) any later version.
Packit 87b8d1
 *
Packit 87b8d1
 * GFBGraph is distributed in the hope that it will be useful,
Packit 87b8d1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 87b8d1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 87b8d1
 * Lesser General Public License for more details.
Packit 87b8d1
 *
Packit 87b8d1
 * You should have received a copy of the GNU Lesser General Public
Packit 87b8d1
 * License along with GFBGraph.  If not, see <http://www.gnu.org/licenses/>.
Packit 87b8d1
 */
Packit 87b8d1
Packit 87b8d1
/**
Packit 87b8d1
 * SECTION:gfbgraph-authorizer
Packit 87b8d1
 * @title: GFBGraphAuthorizer
Packit 87b8d1
 * @short_description: Facebook Graph API authorization interface.
Packit 87b8d1
 * @include: gfbgraph/gfbgraph.h
Packit 87b8d1
 *
Packit 87b8d1
 * #GFBGraphAuthorizer interface provides a uniform way to implement authentication
Packit 87b8d1
 * and authorization process for use by GFBGraph functions.
Packit 87b8d1
 **/
Packit 87b8d1
Packit 87b8d1
#include "gfbgraph-authorizer.h"
Packit 87b8d1
Packit 87b8d1
G_DEFINE_INTERFACE (GFBGraphAuthorizer, gfbgraph_authorizer, G_TYPE_OBJECT);
Packit 87b8d1
Packit 87b8d1
static void
Packit 87b8d1
gfbgraph_authorizer_default_init (GFBGraphAuthorizerInterface *iface)
Packit 87b8d1
{
Packit 87b8d1
}
Packit 87b8d1
Packit 87b8d1
/**
Packit 87b8d1
 * gfbgraph_authorizer_process_call:
Packit 87b8d1
 * @iface: A #GFBGraphAuthorizer.
Packit 87b8d1
 * @call: A #RestProxyCall.
Packit 87b8d1
 *
Packit 87b8d1
 * Adds the necessary authorization to @call.
Packit 87b8d1
 *
Packit 87b8d1
 * This method modifies @call in place and is thread safe.
Packit 87b8d1
 */
Packit 87b8d1
void
Packit 87b8d1
gfbgraph_authorizer_process_call (GFBGraphAuthorizer *iface, RestProxyCall *call)
Packit 87b8d1
{
Packit 87b8d1
        g_return_if_fail (GFBGRAPH_IS_AUTHORIZER (iface));
Packit 87b8d1
        GFBGRAPH_AUTHORIZER_GET_IFACE (iface)->process_call (iface, call);
Packit 87b8d1
}
Packit 87b8d1
Packit 87b8d1
/**
Packit 87b8d1
 * gfbgraph_authorizer_process_message:
Packit 87b8d1
 * @iface: A #GFBGraphAuthorizer.
Packit 87b8d1
 * @message: A #SoupMessage.
Packit 87b8d1
 *
Packit 87b8d1
 * Adds the necessary authorization to @message. The type of @message
Packit 87b8d1
 * can be DELETE, GET and POST.
Packit 87b8d1
 *
Packit 87b8d1
 * This method modifies @message in place and is thread safe.
Packit 87b8d1
 */
Packit 87b8d1
void
Packit 87b8d1
gfbgraph_authorizer_process_message (GFBGraphAuthorizer *iface, SoupMessage *message)
Packit 87b8d1
{
Packit 87b8d1
        g_return_if_fail (GFBGRAPH_IS_AUTHORIZER (iface));
Packit 87b8d1
        GFBGRAPH_AUTHORIZER_GET_IFACE (iface)->process_message (iface, message);
Packit 87b8d1
}
Packit 87b8d1
Packit 87b8d1
/**
Packit 87b8d1
 * gfbgraph_authorizer_refresh_authorization:
Packit 87b8d1
 * @iface: A #GFBGraphAuthorizer.
Packit 87b8d1
 * @cancellable: (allow-none): An optional #GCancellable object, or %NULL.
Packit 87b8d1
 * @error: (allow-none): An optional #GError, or %NULL.
Packit 87b8d1
 *
Packit 87b8d1
 * Synchronously forces @iface to refresh any authorization tokens
Packit 87b8d1
 * held by it.
Packit 87b8d1
 *
Packit 87b8d1
 * This method is thread safe.
Packit 87b8d1
 *
Packit 87b8d1
 * Returns: %TRUE if the authorizer now has a valid token.
Packit 87b8d1
 */
Packit 87b8d1
gboolean
Packit 87b8d1
gfbgraph_authorizer_refresh_authorization (GFBGraphAuthorizer *iface, GCancellable *cancellable, GError **error)
Packit 87b8d1
{
Packit 87b8d1
        g_return_val_if_fail (GFBGRAPH_IS_AUTHORIZER (iface), FALSE);
Packit 87b8d1
        return GFBGRAPH_AUTHORIZER_GET_IFACE (iface)->refresh_authorization (iface, cancellable, error);
Packit 87b8d1
}