Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 564 lines (483 sloc) 15.832 kB
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2010 Richard Hughes <richard@hughsie.com>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; 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:zif-md-filelists-xml
24 * @short_description: FilelistsXml metadata functionality
25 *
26 * Provide access to the filelists_xml repo metadata.
27 * This object is a subclass of #ZifMd
28 */
29
30 typedef enum {
31 ZIF_MD_FILELISTS_XML_SECTION_LIST,
32 ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN
33 } ZifMdFilelistsXmlSection;
34
35 typedef enum {
36 ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE,
37 ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN
38 } ZifMdFilelistsXmlSectionList;
39
40 typedef enum {
41 ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE,
42 ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN
43 } ZifMdFilelistsXmlSectionListPackage;
44
45 #ifdef HAVE_CONFIG_H
46 # include <config.h>
47 #endif
48
49 #include <glib.h>
50 #include <string.h>
51 #include <stdlib.h>
52 #include <sqlite3.h>
53 #include <gio/gio.h>
54
55 #include "zif-md.h"
56 #include "zif-md-filelists-xml.h"
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
57 #include "zif-package-remote.h"
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
58
59 #include "egg-debug.h"
60
61 #define ZIF_MD_FILELISTS_XML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_FILELISTS_XML, ZifMdFilelistsXmlPrivate))
62
63 /**
64 * ZifMdFilelistsXmlPrivate:
65 *
66 * Private #ZifMdFilelistsXml data
67 **/
68 struct _ZifMdFilelistsXmlPrivate
69 {
70 gboolean loaded;
71 ZifMdFilelistsXmlSection section;
72 ZifMdFilelistsXmlSectionList section_list;
73 ZifMdFilelistsXmlSectionListPackage section_list_package;
74 ZifPackage *package_temp;
75 GPtrArray *array;
76 GPtrArray *array_temp;
77 };
78
79 G_DEFINE_TYPE (ZifMdFilelistsXml, zif_md_filelists_xml, ZIF_TYPE_MD)
80
81 /**
82 * zif_md_filelists_xml_unload:
83 **/
84 static gboolean
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
85 zif_md_filelists_xml_unload (ZifMd *md, ZifState *state, GError **error)
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
86 {
87 gboolean ret = FALSE;
88 return ret;
89 }
90
91 /**
92 * zif_md_filelists_xml_parser_start_element:
93 **/
94 static void
95 zif_md_filelists_xml_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
96 const gchar **attribute_names, const gchar **attribute_values,
97 gpointer user_data, GError **error)
98 {
99 guint i;
100 ZifMdFilelistsXml *filelists_xml = user_data;
101
102 g_return_if_fail (ZIF_IS_MD_FILELISTS_XML (filelists_xml));
103
104 /* group element */
105 if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN) {
106
107 /* start of update */
108 if (g_strcmp0 (element_name, "filelists") == 0) {
109 filelists_xml->priv->section = ZIF_MD_FILELISTS_XML_SECTION_LIST;
110 goto out;
111 }
112
113 egg_warning ("unhandled element: %s", element_name);
114 goto out;
115 }
116
117 /* update element */
118 if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_LIST) {
119
120 if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN) {
121
122 if (g_strcmp0 (element_name, "package") == 0) {
123 filelists_xml->priv->section_list = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE;
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
124 filelists_xml->priv->package_temp = ZIF_PACKAGE (zif_package_remote_new ());
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
125 filelists_xml->priv->array_temp = g_ptr_array_new_with_free_func (g_free);
126 for (i=0; attribute_names[i] != NULL; i++) {
127 if (g_strcmp0 (attribute_names[i], "pkgid") == 0) {
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
128 zif_package_remote_set_pkgid (ZIF_PACKAGE_REMOTE (filelists_xml->priv->package_temp),
129 attribute_values[i]);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
130 }
131 }
132 goto out;
133 }
134
135 egg_warning ("unhandled update list tag: %s", element_name);
136 goto out;
137
138 }
139 if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE) {
140
141 if (g_strcmp0 (element_name, "version") == 0) {
142 filelists_xml->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN;
143 goto out;
144 }
145
146 if (g_strcmp0 (element_name, "file") == 0) {
147 filelists_xml->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE;
148 goto out;
149 }
150 egg_warning ("unhandled update package tag: %s", element_name);
151 goto out;
152 }
153 egg_warning ("unhandled package tag: %s", element_name);
154 }
155
156 egg_warning ("unhandled base tag: %s", element_name);
157
158 out:
159 return;
160 }
161
162 /**
163 * zif_md_filelists_xml_parser_end_element:
164 **/
165 static void
166 zif_md_filelists_xml_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
167 gpointer user_data, GError **error)
168 {
169 ZifMdFilelistsXml *filelists_xml = user_data;
170
171 /* no element */
172 if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN) {
173 egg_warning ("unhandled base end tag: %s", element_name);
174 goto out;
175 }
176
177 /* update element */
178 if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_LIST) {
179
180 /* update element */
181 if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN) {
182
183 /* end of list */
184 if (g_strcmp0 (element_name, "filelists") == 0) {
185 filelists_xml->priv->section = ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN;
186 goto out;
187 }
188 egg_warning ("unhandled outside tag: %s", element_name);
189 goto out;
190 }
191
192 /* update element */
193 if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE) {
194
195 if (filelists_xml->priv->section_list_package == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN) {
196
197 if (g_strcmp0 (element_name, "version") == 0)
198 goto out;
199
200 /* end of list */
201 if (g_strcmp0 (element_name, "package") == 0) {
202 zif_package_set_files (filelists_xml->priv->package_temp, filelists_xml->priv->array_temp);
203 g_ptr_array_add (filelists_xml->priv->array, filelists_xml->priv->package_temp);
204 filelists_xml->priv->package_temp = NULL;
205 filelists_xml->priv->array_temp = NULL;
206 filelists_xml->priv->section_list = ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN;
207 goto out;
208 }
209 egg_warning ("unhandled package tag: %s", element_name);
210 goto out;
211 }
212
213 if (filelists_xml->priv->section_list_package == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE) {
214 if (g_strcmp0 (element_name, "file") == 0) {
215 filelists_xml->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN;
216 goto out;
217 }
218 egg_warning ("unhandled end of file tag: %s", element_name);
219 goto out;
220 }
221 egg_warning ("unhandled end of package tag: %s", element_name);
222 goto out;
223 }
224
225 egg_warning ("unhandled update end tag: %s", element_name);
226 goto out;
227 }
228
229 egg_warning ("unhandled end tag: %s", element_name);
230 out:
231 return;
232 }
233
234 /**
235 * zif_md_filelists_xml_parser_text:
236 **/
237 static void
238 zif_md_filelists_xml_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
239 gpointer user_data, GError **error)
240
241 {
242 ZifMdFilelistsXml *filelists_xml = user_data;
243
244 /* skip whitespace */
245 if (text_len < 1 || text[0] == ' ' || text[0] == '\t' || text[0] == '\n')
246 goto out;
247
248 /* group section */
249 if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_LIST) {
250 if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN) {
251 egg_warning ("not saving: %s", text);
252 goto out;
253 }
254 if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE) {
706e45e @hughsie Fix up a couple of enum types that caused a compile warning
authored
255 if (filelists_xml->priv->section_list_package == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE) {
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
256 g_ptr_array_add (filelists_xml->priv->array_temp, g_strdup (text));
257 goto out;
258 };
259 egg_warning ("not saving: %s", text);
260 goto out;
261 }
262 egg_warning ("not saving: %s", text);
263 goto out;
264 }
265 out:
266 return;
267 }
268
269 /**
270 * zif_md_filelists_xml_load:
271 **/
272 static gboolean
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
273 zif_md_filelists_xml_load (ZifMd *md, ZifState *state, GError **error)
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
274 {
275 const gchar *filename;
276 gboolean ret;
277 gchar *contents = NULL;
278 gsize size;
279 ZifMdFilelistsXml *filelists_xml = ZIF_MD_FILELISTS_XML (md);
280 GMarkupParseContext *context = NULL;
281 const GMarkupParser gpk_md_filelists_xml_markup_parser = {
282 zif_md_filelists_xml_parser_start_element,
283 zif_md_filelists_xml_parser_end_element,
284 zif_md_filelists_xml_parser_text,
285 NULL, /* passthrough */
286 NULL /* error */
287 };
288
289 g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), FALSE);
290
291 /* already loaded */
292 if (filelists_xml->priv->loaded)
293 goto out;
294
295 /* get filename */
296 filename = zif_md_get_filename_uncompressed (md);
297 if (filename == NULL) {
298 g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
299 "failed to get filename for filelists_xml");
300 goto out;
301 }
302
303 /* open database */
304 egg_debug ("filename = %s", filename);
d897d9c @hughsie Check for cancel in many, many more places
authored
305 zif_state_set_allow_cancel (state, FALSE);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
306 ret = g_file_get_contents (filename, &contents, &size, error);
307 if (!ret)
308 goto out;
309
310 /* create parser */
311 context = g_markup_parse_context_new (&gpk_md_filelists_xml_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, filelists_xml, NULL);
312
313 /* parse data */
d897d9c @hughsie Check for cancel in many, many more places
authored
314 zif_state_set_allow_cancel (state, FALSE);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
315 ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
316 if (!ret)
317 goto out;
318
319 /* we don't need to keep syncing */
320 filelists_xml->priv->loaded = TRUE;
321 out:
0c2ee4f @hughsie Fix up some memory leaks spotted by valgrind
authored
322 if (context != NULL)
323 g_markup_parse_context_free (context);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
324 g_free (contents);
325 return filelists_xml->priv->loaded;
326 }
327
328 /**
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
329 * zif_md_filelists_xml_get_files:
330 **/
331 static GPtrArray *
332 zif_md_filelists_xml_get_files (ZifMd *md, ZifPackage *package,
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
333 ZifState *state, GError **error)
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
334 {
335 GPtrArray *array = NULL;
336 GPtrArray *packages;
337 ZifPackage *package_tmp;
338 guint i;
339 gboolean ret;
340 const gchar *pkgid;
341 const gchar *pkgid_tmp;
342 GError *error_local = NULL;
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
343 ZifState *state_local;
344 ZifState *state_loop;
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
345 ZifMdFilelistsXml *md_filelists = ZIF_MD_FILELISTS_XML (md);
346
347 g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), NULL);
348 g_return_val_if_fail (error == NULL || *error == NULL, NULL);
349
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
350 /* setup state */
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
351 if (md_filelists->priv->loaded)
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
352 zif_state_set_number_steps (state, 1);
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
353 else
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
354 zif_state_set_number_steps (state, 2);
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
355
356 /* if not already loaded, load */
357 if (!md_filelists->priv->loaded) {
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
358 state_local = zif_state_get_child (state);
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
359 ret = zif_md_load (ZIF_MD (md), state_local, &error_local);
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
360 if (!ret) {
361 g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
362 "failed to load md_filelists_xml file: %s", error_local->message);
363 g_error_free (error_local);
364 goto out;
365 }
366
367 /* this section done */
d897d9c @hughsie Check for cancel in many, many more places
authored
368 ret = zif_state_done (state, error);
369 if (!ret)
370 goto out;
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
371 }
372
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
373 /* setup steps */
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
374 state_local = zif_state_get_child (state);
375 zif_state_set_number_steps (state_local, md_filelists->priv->array->len);
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
376
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
377 /* search array */
378 pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
379 packages = md_filelists->priv->array;
380 for (i=0; i<packages->len; i++) {
381 package_tmp = g_ptr_array_index (packages, i);
382 pkgid_tmp = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package_tmp));
383 if (g_strcmp0 (pkgid, pkgid_tmp) == 0) {
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
384 state_loop = zif_state_get_child (state_local);
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
385 array = zif_package_get_files (package_tmp, state_loop, NULL);
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
386 break;
387 }
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
388
389 /* this section done */
d897d9c @hughsie Check for cancel in many, many more places
authored
390 ret = zif_state_done (state_local, error);
391 if (!ret)
392 goto out;
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
393 }
394
395 /* this section done */
d897d9c @hughsie Check for cancel in many, many more places
authored
396 ret = zif_state_done (state, error);
397 if (!ret)
398 goto out;
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
399 out:
400 return array;
401 }
402
403 /**
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
404 * zif_md_filelists_xml_search_file:
405 **/
406 static GPtrArray *
407 zif_md_filelists_xml_search_file (ZifMd *md, gchar **search,
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
408 ZifState *state, GError **error)
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
409 {
410 GPtrArray *array = NULL;
411 GPtrArray *packages;
412 ZifPackage *package;
413 GPtrArray *files = NULL;
414 const gchar *filename;
415 guint i, j, k;
416 gboolean ret;
417 const gchar *pkgid;
418 GError *error_local = NULL;
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
419 ZifState *state_local;
420 ZifState *state_loop;
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
421 ZifMdFilelistsXml *md_filelists = ZIF_MD_FILELISTS_XML (md);
422
423 g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), NULL);
424 g_return_val_if_fail (error == NULL || *error == NULL, NULL);
425
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
426 /* setup state */
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
427 if (md_filelists->priv->loaded)
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
428 zif_state_set_number_steps (state, 1);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
429 else
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
430 zif_state_set_number_steps (state, 2);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
431
432 /* if not already loaded, load */
433 if (!md_filelists->priv->loaded) {
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
434 state_local = zif_state_get_child (state);
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
435 ret = zif_md_load (ZIF_MD (md), state_local, &error_local);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
436 if (!ret) {
437 g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
438 "failed to load md_filelists_xml file: %s", error_local->message);
439 g_error_free (error_local);
440 goto out;
441 }
442
443 /* this section done */
d897d9c @hughsie Check for cancel in many, many more places
authored
444 ret = zif_state_done (state, error);
445 if (!ret)
446 goto out;
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
447 }
448
b2c0b12 @hughsie trivial: fix up two runtime critical warnings
authored
449 /* create results array */
450 array = g_ptr_array_new_with_free_func (g_free);
451
452 /* no entries, so shortcut */
453 if (md_filelists->priv->array->len == 0) {
d897d9c @hughsie Check for cancel in many, many more places
authored
454 ret = zif_state_done (state, error);
455 if (!ret)
456 goto out;
b2c0b12 @hughsie trivial: fix up two runtime critical warnings
authored
457 goto out;
458 }
459
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
460 /* setup steps */
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
461 state_local = zif_state_get_child (state);
462 zif_state_set_number_steps (state_local, md_filelists->priv->array->len);
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
463
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
464 /* search array */
465 packages = md_filelists->priv->array;
466 for (i=0; i<packages->len; i++) {
467 package = g_ptr_array_index (packages, i);
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
468 pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
65c90f0 @hughsie Rename ZifCompletion to ZifState
authored
469 state_loop = zif_state_get_child (state_local);
45b3b5f @hughsie Smush a GCancellable into #ZifState to reduce the number of args in l…
authored
470 files = zif_package_get_files (package, state_loop, NULL);
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
471 for (k=0; k<files->len; k++) {
472 filename = g_ptr_array_index (files, k);
473 for (j=0; search[j] != NULL; j++) {
474 if (g_strcmp0 (filename, search[j]) == 0) {
475 g_ptr_array_add (array, g_strdup (pkgid));
476 break;
477 }
478 }
479 }
8a8aed4 @hughsie Use completion and cancellation for actions that can block for some time
authored
480
481 /* this section done */
d897d9c @hughsie Check for cancel in many, many more places
authored
482 ret = zif_state_done (state_local, error);
483 if (!ret)
484 goto out;
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
485 }
486
487 /* this section done */
d897d9c @hughsie Check for cancel in many, many more places
authored
488 ret = zif_state_done (state, error);
489 if (!ret)
490 goto out;
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
491 out:
492 if (files != NULL)
493 g_ptr_array_unref (files);
494 return array;
495 }
496
497 /**
498 * zif_md_filelists_xml_finalize:
499 **/
500 static void
501 zif_md_filelists_xml_finalize (GObject *object)
502 {
503 ZifMdFilelistsXml *md;
504
505 g_return_if_fail (object != NULL);
506 g_return_if_fail (ZIF_IS_MD_FILELISTS_XML (object));
507 md = ZIF_MD_FILELISTS_XML (object);
508
509 g_ptr_array_unref (md->priv->array);
510
511 G_OBJECT_CLASS (zif_md_filelists_xml_parent_class)->finalize (object);
512 }
513
514 /**
515 * zif_md_filelists_xml_class_init:
516 **/
517 static void
518 zif_md_filelists_xml_class_init (ZifMdFilelistsXmlClass *klass)
519 {
520 GObjectClass *object_class = G_OBJECT_CLASS (klass);
521 ZifMdClass *md_class = ZIF_MD_CLASS (klass);
522 object_class->finalize = zif_md_filelists_xml_finalize;
523
524 /* map */
525 md_class->load = zif_md_filelists_xml_load;
526 md_class->unload = zif_md_filelists_xml_unload;
527 md_class->search_file = zif_md_filelists_xml_search_file;
fc63678 @hughsie Add the functionality to get the file lists for a remote package
authored
528 md_class->get_files = zif_md_filelists_xml_get_files;
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
529
530 g_type_class_add_private (klass, sizeof (ZifMdFilelistsXmlPrivate));
531 }
532
533 /**
534 * zif_md_filelists_xml_init:
535 **/
536 static void
537 zif_md_filelists_xml_init (ZifMdFilelistsXml *md)
538 {
539 md->priv = ZIF_MD_FILELISTS_XML_GET_PRIVATE (md);
540 md->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
541 md->priv->loaded = FALSE;
542 md->priv->section = ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN;
543 md->priv->section_list = ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN;
544 md->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN;
545 md->priv->package_temp = NULL;
546 md->priv->array_temp = NULL;
547 }
548
549 /**
550 * zif_md_filelists_xml_new:
551 *
552 * Return value: A new #ZifMdFilelistsXml class instance.
553 *
61330b1 @hughsie Bump version ready for release
authored
554 * Since: 0.1.0
9673756 @hughsie Add ZifMdFilelistsXml so we can read filelists from rpmfusion-free
authored
555 **/
556 ZifMdFilelistsXml *
557 zif_md_filelists_xml_new (void)
558 {
559 ZifMdFilelistsXml *md;
560 md = g_object_new (ZIF_TYPE_MD_FILELISTS_XML, NULL);
561 return ZIF_MD_FILELISTS_XML (md);
562 }
563
Something went wrong with that request. Please try again.