1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* Copyright (C) 2015 Red Hat, Inc. (www.redhat.com)
* Copyright (C) 2018 Red Hat, Inc. (www.redhat.com)
*
* This library is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "evolution-data-server-config.h"
#include <glib.h>
#include "e-oauth2-services.h"
#include "e-oauth2-service.h"
#include "e-source-credentials-provider-impl-oauth2.h"
struct _ESourceCredentialsProviderImplOAuth2Private {
EOAuth2Services *services;
};
G_DEFINE_TYPE_WITH_PRIVATE (ESourceCredentialsProviderImplOAuth2, e_source_credentials_provider_impl_oauth2, E_TYPE_SOURCE_CREDENTIALS_PROVIDER_IMPL)
static gboolean
e_source_credentials_provider_impl_oauth2_can_process (ESourceCredentialsProviderImpl *provider_impl,
ESource *source)
{
ESourceCredentialsProviderImplOAuth2 *oauth2_provider;
EOAuth2Service *service;
gboolean can_process;
g_return_val_if_fail (E_IS_SOURCE_CREDENTIALS_PROVIDER_IMPL_OAUTH2 (provider_impl), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
oauth2_provider = E_SOURCE_CREDENTIALS_PROVIDER_IMPL_OAUTH2 (provider_impl);
if (!e_oauth2_services_is_supported () || !oauth2_provider->priv->services)
return FALSE;
service = e_oauth2_services_find (oauth2_provider->priv->services, source);
can_process = service != NULL;
g_clear_object (&service);
return can_process;
}
static gboolean
e_source_credentials_provider_impl_oauth2_can_store (ESourceCredentialsProviderImpl *provider_impl)
{
g_return_val_if_fail (E_IS_SOURCE_CREDENTIALS_PROVIDER_IMPL_OAUTH2 (provider_impl), FALSE);
return FALSE;
}
static gboolean
e_source_credentials_provider_impl_oauth2_can_prompt (ESourceCredentialsProviderImpl *provider_impl)
{
g_return_val_if_fail (E_IS_SOURCE_CREDENTIALS_PROVIDER_IMPL_OAUTH2 (provider_impl), FALSE);
return e_oauth2_services_is_supported ();
}
static void
e_source_credentials_provider_impl_oauth2_dispose (GObject *object)
{
ESourceCredentialsProviderImplOAuth2 *provider_impl = E_SOURCE_CREDENTIALS_PROVIDER_IMPL_OAUTH2 (object);
g_clear_object (&provider_impl->priv->services);
/* Chain up to parent's method. */
G_OBJECT_CLASS (e_source_credentials_provider_impl_oauth2_parent_class)->dispose (object);
}
static void
e_source_credentials_provider_impl_oauth2_class_init (ESourceCredentialsProviderImplOAuth2Class *klass)
{
ESourceCredentialsProviderImplClass *impl_class;
GObjectClass *object_class;
impl_class = E_SOURCE_CREDENTIALS_PROVIDER_IMPL_CLASS (klass);
impl_class->can_process = e_source_credentials_provider_impl_oauth2_can_process;
impl_class->can_store = e_source_credentials_provider_impl_oauth2_can_store;
impl_class->can_prompt = e_source_credentials_provider_impl_oauth2_can_prompt;
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = e_source_credentials_provider_impl_oauth2_dispose;
}
static void
e_source_credentials_provider_impl_oauth2_init (ESourceCredentialsProviderImplOAuth2 *provider_impl)
{
provider_impl->priv = e_source_credentials_provider_impl_oauth2_get_instance_private (provider_impl);
if (e_oauth2_services_is_supported ())
provider_impl->priv->services = e_oauth2_services_new ();
}
|