Debian Codegraph @

lib/packagekit-glib2/pk-eula-required.c

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2009 Richard Hughes <[email protected]>
4 *
5 * Licensed under the GNU Lesser General Public License Version 2.1
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * SECTION:pk-eula-required
24 * @short_description: EulaRequired object
25 *
26 * This GObject represents a eula_required from a transaction.
27 * These objects represent single items of data from the transaction, and are
28 * often present in lists (#PkResults) or just refcounted in client programs.
29 */
30
31 #include "config.h"
32
33 #include <glib-object.h>
34
35 #include <packagekit-glib2/pk-eula-required.h>
36
37 static void pk_eula_required_finalize (GObject *object);
38
39 /**
40 * PkEulaRequiredPrivate:
41 *
42 * Private #PkEulaRequired data
43 **/
44 struct _PkEulaRequiredPrivate
45 {
46 gchar *eula_id;
47 gchar *package_id;
48 gchar *vendor_name;
49 gchar *license_agreement;
50 };
51
52 enum {
53 PROP_0,
54 PROP_EULA_ID,
55 PROP_PACKAGE_ID,
56 PROP_VENDOR_NAME,
57 PROP_LICENSE_AGREEMENT,
58 PROP_LAST
59 };
60
61 G_DEFINE_TYPE_WITH_PRIVATE (PkEulaRequired, pk_eula_required, PK_TYPE_SOURCE)
62 #define GET_PRIVATE(o) (pk_eula_required_get_instance_private (o))
63
64 /**
65 * pk_eula_required_get_eula_id:
66 * @eula_required: a valid #PkEulaRequired instance.
67 *
68 * Get the ID for this EULA
69 *
70 * Return value: an ID
71 *
72 * Since: 1.1.8
73 */
74 const gchar *
75 pk_eula_required_get_eula_id (PkEulaRequired *eula_required)
76 {
77 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
78
79 g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
80
81 return priv->eula_id;
82 }
83
84 /**
85 * pk_eula_required_get_package_id:
86 * @eula_required: a valid #PkEulaRequired instance.
87 *
88 * Get the PackageID this EULA is for
89 *
90 * Return value: a PackageID
91 *
92 * Since: 1.1.8
93 */
94 const gchar *
95 pk_eula_required_get_package_id (PkEulaRequired *eula_required)
96 {
97 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
98
99 g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
100
101 return priv->package_id;
102 }
103
104 /**
105 * pk_eula_required_get_vendor_name:
106 * @eula_required: a valid #PkEulaRequired instance.
107 *
108 * Get the vendor this EULA is from.
109 *
110 * Return value: license vendor name
111 *
112 * Since: 1.1.8
113 */
114 const gchar *
115 pk_eula_required_get_vendor_name (PkEulaRequired *eula_required)
116 {
117 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
118
119 g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
120
121 return priv->vendor_name;
122 }
123
124 /**
125 * pk_eula_required_get_license_agreement:
126 * @eula_required: a valid #PkEulaRequired instance.
127 *
128 * Get the text of the license agreement.
129 *
130 * Return value: license agreement text
131 *
132 * Since: 1.1.8
133 **/
134 const gchar *
135 pk_eula_required_get_license_agreement (PkEulaRequired *eula_required)
136 {
137 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
138
139 g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
140
141 return priv->license_agreement;
142 }
143
144 /*
145 * pk_eula_required_get_property:
146 **/
147 static void
148 pk_eula_required_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
149 {
150 PkEulaRequired *eula_required = PK_EULA_REQUIRED (object);
151 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
152
153 switch (prop_id) {
154 case PROP_EULA_ID:
155 g_value_set_string (value, priv->eula_id);
156 break;
157 case PROP_PACKAGE_ID:
158 g_value_set_string (value, priv->package_id);
159 break;
160 case PROP_VENDOR_NAME:
161 g_value_set_string (value, priv->vendor_name);
162 break;
163 case PROP_LICENSE_AGREEMENT:
164 g_value_set_string (value, priv->license_agreement);
165 break;
166 default:
167 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
168 break;
169 }
170 }
171
172 /*
173 * pk_eula_required_set_property:
174 **/
175 static void
176 pk_eula_required_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
177 {
178 PkEulaRequired *eula_required = PK_EULA_REQUIRED (object);
179 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
180
181 switch (prop_id) {
182 case PROP_EULA_ID:
183 g_free (priv->eula_id);
184 priv->eula_id = g_value_dup_string (value);
185 break;
186 case PROP_PACKAGE_ID:
187 g_free (priv->package_id);
188 priv->package_id = g_value_dup_string (value);
189 break;
190 case PROP_VENDOR_NAME:
191 g_free (priv->vendor_name);
192 priv->vendor_name = g_value_dup_string (value);
193 break;
194 case PROP_LICENSE_AGREEMENT:
195 g_free (priv->license_agreement);
196 priv->license_agreement = g_value_dup_string (value);
197 break;
198 default:
199 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
200 break;
201 }
202 }
203
204 /*
205 * pk_eula_required_class_init:
206 **/
207 static void
208 pk_eula_required_class_init (PkEulaRequiredClass *klass)
209 {
210 GParamSpec *pspec;
211 GObjectClass *object_class = G_OBJECT_CLASS (klass);
212 object_class->finalize = pk_eula_required_finalize;
213 object_class->get_property = pk_eula_required_get_property;
214 object_class->set_property = pk_eula_required_set_property;
215
216 /**
217 * PkEulaRequired:eula-id:
218 *
219 * ID for this EULA.
220 *
221 * Since: 0.5.4
222 */
223 pspec = g_param_spec_string ("eula-id", NULL, NULL,
224 NULL,
225 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
226 g_object_class_install_property (object_class, PROP_EULA_ID, pspec);
227
228 /**
229 * PkEulaRequired:package-id:
230 *
231 * PackageID this EULA is for.
232 *
233 * Since: 0.5.4
234 */
235 pspec = g_param_spec_string ("package-id", NULL, NULL,
236 NULL,
237 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
238 g_object_class_install_property (object_class, PROP_PACKAGE_ID, pspec);
239
240 /**
241 * PkEulaRequired:vendor-name:
242 *
243 * Vendor this EULA is from.
244 *
245 * Since: 0.5.4
246 */
247 pspec = g_param_spec_string ("vendor-name", NULL, NULL,
248 NULL,
249 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
250 g_object_class_install_property (object_class, PROP_VENDOR_NAME, pspec);
251
252 /**
253 * PkEulaRequired:license-agreement:
254 *
255 * The text of the license agreement.
256 *
257 * Since: 0.5.4
258 */
259 pspec = g_param_spec_string ("license-agreement", NULL, NULL,
260 NULL,
261 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
262 g_object_class_install_property (object_class, PROP_LICENSE_AGREEMENT, pspec);
263 }
264
265 /*
266 * pk_eula_required_init:
267 **/
268 static void
269 pk_eula_required_init (PkEulaRequired *eula_required)
270 {
271 eula_required->priv = GET_PRIVATE(eula_required);
272 }
273
274 /*
275 * pk_eula_required_finalize:
276 **/
277 static void
278 pk_eula_required_finalize (GObject *object)
279 {
280 PkEulaRequired *eula_required = PK_EULA_REQUIRED (object);
281 PkEulaRequiredPrivate *priv = GET_PRIVATE(eula_required);
282
283 g_clear_pointer (&priv->eula_id, g_free);
284 g_clear_pointer (&priv->package_id, g_free);
285 g_clear_pointer (&priv->vendor_name, g_free);
286 g_clear_pointer (&priv->license_agreement, g_free);
287
288 G_OBJECT_CLASS (pk_eula_required_parent_class)->finalize (object);
289 }
290
291 /**
292 * pk_eula_required_new:
293 *
294 * Return value: a new #PkEulaRequired object.
295 *
296 * Since: 0.5.4
297 **/
298 PkEulaRequired *
299 pk_eula_required_new (void)
300 {
301 PkEulaRequired *eula_required;
302 eula_required = g_object_new (PK_TYPE_EULA_REQUIRED, NULL);
303 return PK_EULA_REQUIRED (eula_required);
304 }