1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
4  *
5  * SPDX-License-Identifier: LGPL-2.1+
6  */
7 
8 #pragma once
9 
10 #include <glib-object.h>
11 
12 #include "asb-app.h"
13 #include "asb-package.h"
14 
15 G_BEGIN_DECLS
16 
17 #define ASB_TYPE_CONTEXT (asb_context_get_type ())
18 G_DECLARE_DERIVABLE_TYPE (AsbContext, asb_context, ASB, CONTEXT, GObject)
19 
20 struct _AsbContextClass
21 {
22 	GObjectClass			parent_class;
23 	/*< private >*/
24 	void (*_asb_reserved1)	(void);
25 	void (*_asb_reserved2)	(void);
26 	void (*_asb_reserved3)	(void);
27 	void (*_asb_reserved4)	(void);
28 	void (*_asb_reserved5)	(void);
29 	void (*_asb_reserved6)	(void);
30 	void (*_asb_reserved7)	(void);
31 	void (*_asb_reserved8)	(void);
32 };
33 
34 /**
35  * AsbContextFlags:
36  * @ASB_CONTEXT_FLAG_NONE:			No special actions to use
37  * @ASB_CONTEXT_FLAG_IGNORE_MISSING_INFO:	Ignore missing information
38  * @ASB_CONTEXT_FLAG_IGNORE_MISSING_PARENTS:	Ignore missing parents
39  * @ASB_CONTEXT_FLAG_ADD_CACHE_ID:		Unused
40  * @ASB_CONTEXT_FLAG_HIDPI_ICONS:		Include HiDPI icons
41  * @ASB_CONTEXT_FLAG_EMBEDDED_ICONS:		Embed the icons in the XML
42  * @ASB_CONTEXT_FLAG_NO_NETWORK:		Do not download files
43  * @ASB_CONTEXT_FLAG_INCLUDE_FAILED:		Write the origin-ignore.xml file
44  * @ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS:	Do not pack icons into a tarball
45  * @ASB_CONTEXT_FLAG_IGNORE_DEAD_UPSTREAM:	Include apps that are dead upstream
46  * @ASB_CONTEXT_FLAG_IGNORE_OBSOLETE_DEPS:	Include apps that use obsolete toolkits
47  * @ASB_CONTEXT_FLAG_IGNORE_LEGACY_ICONS:	Include apps that use legacy icon formats
48  * @ASB_CONTEXT_FLAG_IGNORE_SETTINGS:		Include apps that are marked as settings
49  * @ASB_CONTEXT_FLAG_USE_FALLBACKS:		Fall back to suboptimal data where required
50  * @ASB_CONTEXT_FLAG_ADD_DEFAULT_ICONS:		Add artificial icons and categories where required
51  *
52  * The flags to use when processing the context.
53  **/
54 typedef enum {
55 	ASB_CONTEXT_FLAG_NONE,
56 	ASB_CONTEXT_FLAG_IGNORE_MISSING_INFO	= 0,		/* Since: 0.3.5 */
57 	ASB_CONTEXT_FLAG_IGNORE_MISSING_PARENTS	= 1 << 0,	/* Since: 0.3.5 */
58 	ASB_CONTEXT_FLAG_ADD_CACHE_ID		= 1 << 1,	/* Since: 0.3.5 */
59 	ASB_CONTEXT_FLAG_HIDPI_ICONS		= 1 << 2,	/* Since: 0.3.5 */
60 	ASB_CONTEXT_FLAG_EMBEDDED_ICONS		= 1 << 3,	/* Since: 0.3.5 */
61 	ASB_CONTEXT_FLAG_NO_NETWORK		= 1 << 4,	/* Since: 0.3.5 */
62 	ASB_CONTEXT_FLAG_INCLUDE_FAILED		= 1 << 5,	/* Since: 0.3.5 */
63 	ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS	= 1 << 6,	/* Since: 0.3.5 */
64 	ASB_CONTEXT_FLAG_IGNORE_DEAD_UPSTREAM	= 1 << 7,	/* Since: 0.4.1 */
65 	ASB_CONTEXT_FLAG_IGNORE_OBSOLETE_DEPS	= 1 << 8,	/* Since: 0.4.1 */
66 	ASB_CONTEXT_FLAG_IGNORE_LEGACY_ICONS	= 1 << 9,	/* Since: 0.4.1 */
67 	ASB_CONTEXT_FLAG_IGNORE_SETTINGS	= 1 << 10,	/* Since: 0.4.1 */
68 	ASB_CONTEXT_FLAG_USE_FALLBACKS		= 1 << 11,	/* Since: 0.4.1 */
69 	ASB_CONTEXT_FLAG_ADD_DEFAULT_ICONS	= 1 << 12,	/* Since: 0.4.1 */
70 	/*< private >*/
71 	ASB_CONTEXT_FLAG_LAST,
72 } AsbContextFlags;
73 
74 AsbContext	*asb_context_new		(void);
75 AsbPackage	*asb_context_find_by_pkgname	(AsbContext	*ctx,
76 						 const gchar 	*pkgname);
77 void		 asb_context_add_app		(AsbContext	*ctx,
78 						 AsbApp		*app);
79 void		 asb_context_add_app_ignore	(AsbContext	*ctx,
80 						 AsbPackage	*pkg);
81 void		 asb_context_set_api_version	(AsbContext	*ctx,
82 						 gdouble	 api_version);
83 void		 asb_context_set_flags		(AsbContext	*ctx,
84 						 AsbContextFlags flags);
85 void		 asb_context_set_max_threads	(AsbContext	*ctx,
86 						 guint		 max_threads);
87 void		 asb_context_set_min_icon_size	(AsbContext	*ctx,
88 						 guint		 min_icon_size);
89 void		 asb_context_set_old_metadata	(AsbContext	*ctx,
90 						 const gchar	*old_metadata);
91 void		 asb_context_set_log_dir	(AsbContext	*ctx,
92 						 const gchar	*log_dir);
93 void		 asb_context_set_screenshot_dir	(AsbContext	*ctx,
94 						 const gchar	*screenshot_dir);
95 void		 asb_context_set_cache_dir	(AsbContext	*ctx,
96 						 const gchar	*cache_dir);
97 void		 asb_context_set_temp_dir	(AsbContext	*ctx,
98 						 const gchar	*temp_dir);
99 void		 asb_context_set_output_dir	(AsbContext	*ctx,
100 						 const gchar	*output_dir);
101 void		 asb_context_set_icons_dir	(AsbContext	*ctx,
102 						 const gchar	*icons_dir);
103 void		 asb_context_set_basename	(AsbContext	*ctx,
104 						 const gchar	*basename);
105 void		 asb_context_set_origin		(AsbContext	*ctx,
106 						 const gchar	*origin);
107 const gchar	*asb_context_get_temp_dir	(AsbContext	*ctx);
108 const gchar	*asb_context_get_cache_dir	(AsbContext	*ctx);
109 AsbContextFlags	 asb_context_get_flags		(AsbContext	*ctx);
110 gboolean	 asb_context_get_flag		(AsbContext	*ctx,
111 						 AsbContextFlags flag);
112 gdouble		 asb_context_get_api_version	(AsbContext	*ctx);
113 guint		 asb_context_get_min_icon_size	(AsbContext	*ctx);
114 
115 gboolean	 asb_context_setup		(AsbContext	*ctx,
116 						 GError		**error);
117 gboolean	 asb_context_process		(AsbContext	*ctx,
118 						 GError		**error);
119 void		 asb_context_add_package	(AsbContext	*ctx,
120 						 AsbPackage	*pkg);
121 gboolean	 asb_context_add_filename	(AsbContext	*ctx,
122 						 const gchar	*filename,
123 						 GError		**error);
124 gboolean	 asb_context_find_in_cache	(AsbContext	*ctx,
125 						 const gchar	*filename);
126 
127 G_END_DECLS
128