~ubuntu-branches/ubuntu/oneiric/libgdata/oneiric-backports

« back to all changes in this revision

Viewing changes to gdata/gdata-authorizer.h

  • Committer: Package Import Robot
  • Author(s): Evan Broder
  • Date: 2011-11-15 21:59:48 UTC
  • mfrom: (4.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20111115215948-e17s889ocgu5fv4f
Tags: 0.10.1-1~oneiric1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * GData Client
 
4
 * Copyright (C) Philip Withnall 2011 <philip@tecnocode.co.uk>
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 */
 
19
 
 
20
#ifndef GDATA_AUTHORIZER_H
 
21
#define GDATA_AUTHORIZER_H
 
22
 
 
23
#include <glib.h>
 
24
#include <glib-object.h>
 
25
#include <gio/gio.h>
 
26
#include <libsoup/soup.h>
 
27
 
 
28
#include <gdata/gdata-authorization-domain.h>
 
29
 
 
30
G_BEGIN_DECLS
 
31
 
 
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))
 
37
 
 
38
/**
 
39
 * GDataAuthorizer:
 
40
 *
 
41
 * All the fields in the #GDataAuthorizer structure are private and should never be accessed directly.
 
42
 *
 
43
 * Since: 0.9.0
 
44
 */
 
45
typedef struct _GDataAuthorizer         GDataAuthorizer; /* dummy typedef */
 
46
 
 
47
/**
 
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
 
54
 * be thread safe
 
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
 
63
 *
 
64
 * The class structure for the #GDataAuthorizer interface.
 
65
 *
 
66
 * Since: 0.9.0
 
67
 */
 
68
typedef struct {
 
69
        GTypeInterface parent;
 
70
 
 
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;
 
78
 
 
79
GType gdata_authorizer_get_type (void) G_GNUC_CONST;
 
80
 
 
81
void gdata_authorizer_process_request (GDataAuthorizer *self, GDataAuthorizationDomain *domain, SoupMessage *message);
 
82
gboolean gdata_authorizer_is_authorized_for_domain (GDataAuthorizer *self, GDataAuthorizationDomain *domain);
 
83
 
 
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);
 
88
 
 
89
G_END_DECLS
 
90
 
 
91
#endif /* !GDATA_AUTHORIZER_H */