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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of gsignond
*
* Copyright (C) 2013 Intel Corporation.
*
* Contact: Jussi Laako <jussi.laako@linux.intel.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; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "tizen-extension.h"
#include "tizen-storage-manager.h"
#include "tizen-secret-storage.h"
#include "tizen-access-control-manager.h"
G_DEFINE_TYPE (ExtensionTizen, extension_tizen, GSIGNOND_TYPE_EXTENSION);
#define EXTENSION_TIZEN_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), EXTENSION_TYPE_TIZEN, ExtensionTizenPrivate)
struct _ExtensionTizenPrivate
{
GSignondAccessControlManager *access_control_manager;
GSignondStorageManager *storage_manager;
GSignondSecretStorage *secret_storage;
};
static void
_dispose (GObject *obj)
{
ExtensionTizen *self = EXTENSION_TIZEN (obj);
if (!self) return;
ExtensionTizenPrivate *priv = self->priv;
if (priv) {
g_clear_object (&priv->access_control_manager);
g_clear_object (&priv->secret_storage);
g_clear_object (&priv->storage_manager);
}
G_OBJECT_CLASS (extension_tizen_parent_class)->dispose (obj);
}
static const gchar *
_get_extension_name (GSignondExtension *self)
{
(void) self;
return "tizen";
}
static guint32
_get_extension_version (GSignondExtension *self)
{
(void) self;
return 0x01000000;
}
static GSignondStorageManager *
_get_storage_manager (GSignondExtension *self, GSignondConfig *config)
{
g_return_val_if_fail (self && EXTENSION_IS_TIZEN(self), NULL);
ExtensionTizenPrivate *priv = EXTENSION_TIZEN(self)->priv;
if (!priv->storage_manager) {
priv->storage_manager =
g_object_new (EXTENSION_TYPE_TIZEN_STORAGE_MANAGER,
"config", config, NULL);
}
return priv->storage_manager;
}
static GSignondSecretStorage *
_get_secret_storage (GSignondExtension *self, GSignondConfig *config)
{
g_return_val_if_fail (self && EXTENSION_IS_TIZEN(self), NULL);
ExtensionTizenPrivate *priv = EXTENSION_TIZEN(self)->priv;
if (!priv->secret_storage) {
priv->secret_storage =
g_object_new (EXTENSION_TYPE_TIZEN_SECRET_STORAGE,
"config", config, NULL);
}
return priv->secret_storage;
}
static GSignondAccessControlManager *
_get_access_control_manager (GSignondExtension *self, GSignondConfig *config)
{
g_return_val_if_fail (self && EXTENSION_IS_TIZEN(self), NULL);
ExtensionTizenPrivate *priv = EXTENSION_TIZEN(self)->priv;
if (!priv->access_control_manager) {
priv->access_control_manager =
g_object_new (EXTENSION_TYPE_TIZEN_ACCESS_CONTROL_MANAGER,
"config", config, NULL);
}
return priv->access_control_manager;
}
static void
extension_tizen_class_init (ExtensionTizenClass *klass)
{
GSignondExtensionClass *parent_class = GSIGNOND_EXTENSION_CLASS (klass);
g_type_class_add_private (G_OBJECT_CLASS(klass), sizeof (ExtensionTizenPrivate));
G_OBJECT_CLASS (klass)->dispose = _dispose;
parent_class->get_extension_name = _get_extension_name;
parent_class->get_extension_version = _get_extension_version;
parent_class->get_storage_manager = _get_storage_manager;
parent_class->get_secret_storage = _get_secret_storage;
parent_class->get_access_control_manager = _get_access_control_manager;
}
static void
extension_tizen_init (ExtensionTizen *self)
{
self->priv = EXTENSION_TIZEN_PRIV (self);
self->priv->storage_manager = NULL;
self->priv->secret_storage = NULL;
self->priv->access_control_manager = NULL;
}
static void
_on_object_dispose (gpointer data, GObject *object)
{
if (data) *(ExtensionTizen **)data = NULL;
}
GSignondExtension *
tizen_extension_init ()
{
static GSignondExtension *tizen_extension = NULL;
if (!tizen_extension) {
tizen_extension = g_object_new (EXTENSION_TYPE_TIZEN, NULL);
g_object_weak_ref (G_OBJECT (tizen_extension), _on_object_dispose, &tizen_extension);
}
return tizen_extension;
}
|