1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2014 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 <stdarg.h>
13 #include <appstream-glib.h>
14 
15 G_BEGIN_DECLS
16 
17 #define ASB_TYPE_PACKAGE (asb_package_get_type ())
18 G_DECLARE_DERIVABLE_TYPE (AsbPackage, asb_package, ASB, PACKAGE, GObject)
19 
20 #define ASB_PACKAGE_ENSURE_NONE		(0u)
21 #define ASB_PACKAGE_ENSURE_NEVRA	(1u << 0)
22 #define ASB_PACKAGE_ENSURE_FILES	(1u << 1)
23 #define ASB_PACKAGE_ENSURE_RELEASES	(1u << 2)
24 #define ASB_PACKAGE_ENSURE_DEPS		(1u << 3)
25 #define ASB_PACKAGE_ENSURE_LICENSE	(1u << 4)
26 #define ASB_PACKAGE_ENSURE_URL		(1u << 5)
27 #define ASB_PACKAGE_ENSURE_SOURCE	(1u << 6)
28 #define ASB_PACKAGE_ENSURE_VCS		(1u << 7)
29 typedef guint64 AsbPackageEnsureFlags;
30 
31 struct _AsbPackageClass
32 {
33 	GObjectClass		parent_class;
34 	gboolean		 (*open)	(AsbPackage	*pkg,
35 						 const gchar	*filename,
36 						 GError		**error);
37 	gboolean		 (*ensure)	(AsbPackage	*pkg,
38 						 AsbPackageEnsureFlags flags,
39 						 GError		**error);
40 	gboolean		 (*explode)	(AsbPackage	*pkg,
41 						 const gchar	*dir,
42 						 GPtrArray	*glob,
43 						 GError		**error);
44 	gint			 (*compare)	(AsbPackage	*pkg1,
45 						 AsbPackage	*pkg2);
46 	gboolean		 (*close)	(AsbPackage	*pkg,
47 						 GError		**error);
48 	/*< private >*/
49 	void (*_asb_reserved1)	(void);
50 	void (*_asb_reserved2)	(void);
51 	void (*_asb_reserved3)	(void);
52 	void (*_asb_reserved4)	(void);
53 	void (*_asb_reserved5)	(void);
54 	void (*_asb_reserved6)	(void);
55 	void (*_asb_reserved7)	(void);
56 };
57 
58 typedef enum {
59 	ASB_PACKAGE_LOG_LEVEL_NONE,
60 	ASB_PACKAGE_LOG_LEVEL_DEBUG,
61 	ASB_PACKAGE_LOG_LEVEL_INFO,
62 	ASB_PACKAGE_LOG_LEVEL_WARNING,
63 	ASB_PACKAGE_LOG_LEVEL_LAST,
64 } AsbPackageLogLevel;
65 
66 typedef enum {
67 	ASB_PACKAGE_KIND_DEFAULT,
68 	ASB_PACKAGE_KIND_BUNDLE,
69 	ASB_PACKAGE_KIND_FIRMWARE,
70 	ASB_PACKAGE_KIND_LAST
71 } AsbPackageKind;
72 
73 void		 asb_package_log_start		(AsbPackage	*pkg);
74 void		 asb_package_log		(AsbPackage	*pkg,
75 						 AsbPackageLogLevel log_level,
76 						 const gchar	*fmt,
77 						 ...)
78 						 G_GNUC_PRINTF (3, 4);
79 gboolean	 asb_package_log_flush		(AsbPackage	*pkg,
80 						 GError		**error);
81 gboolean	 asb_package_open		(AsbPackage	*pkg,
82 						 const gchar	*filename,
83 						 GError		**error);
84 gboolean	 asb_package_close		(AsbPackage	*pkg,
85 						 GError		**error);
86 gboolean	 asb_package_ensure		(AsbPackage	*pkg,
87 						 AsbPackageEnsureFlags flags,
88 						 GError		**error);
89 void		 asb_package_clear		(AsbPackage	*pkg,
90 						 AsbPackageEnsureFlags flags);
91 gboolean	 asb_package_explode		(AsbPackage	*pkg,
92 						 const gchar	*dir,
93 						 GPtrArray	*glob,
94 						 GError		**error);
95 AsbPackageKind	 asb_package_get_kind		(AsbPackage	*pkg);
96 guint		 asb_package_get_epoch		(AsbPackage	*pkg);
97 const gchar	*asb_package_get_filename	(AsbPackage	*pkg);
98 const gchar	*asb_package_get_basename	(AsbPackage	*pkg);
99 const gchar	*asb_package_get_arch		(AsbPackage	*pkg);
100 const gchar	*asb_package_get_name		(AsbPackage	*pkg);
101 const gchar	*asb_package_get_version	(AsbPackage	*pkg);
102 const gchar	*asb_package_get_release_str	(AsbPackage	*pkg);
103 const gchar	*asb_package_get_nevr		(AsbPackage	*pkg);
104 const gchar	*asb_package_get_nevra		(AsbPackage	*pkg);
105 const gchar	*asb_package_get_evr		(AsbPackage	*pkg);
106 const gchar	*asb_package_get_url		(AsbPackage	*pkg);
107 const gchar	*asb_package_get_vcs		(AsbPackage	*pkg);
108 const gchar	*asb_package_get_license	(AsbPackage	*pkg);
109 const gchar	*asb_package_get_source		(AsbPackage	*pkg);
110 const gchar	*asb_package_get_source_pkgname	(AsbPackage	*pkg);
111 void		 asb_package_set_kind		(AsbPackage	*pkg,
112 						 AsbPackageKind	 kind);
113 void		 asb_package_set_name		(AsbPackage	*pkg,
114 						 const gchar	*name);
115 void		 asb_package_set_filename	(AsbPackage	*pkg,
116 						 const gchar	*filename);
117 void		 asb_package_set_version	(AsbPackage	*pkg,
118 						 const gchar	*version);
119 void		 asb_package_set_release	(AsbPackage	*pkg,
120 						 const gchar	*release);
121 void		 asb_package_set_arch		(AsbPackage	*pkg,
122 						 const gchar	*arch);
123 void		 asb_package_set_epoch		(AsbPackage	*pkg,
124 						 guint		 epoch);
125 void		 asb_package_set_url		(AsbPackage	*pkg,
126 						 const gchar	*url);
127 void		 asb_package_set_license	(AsbPackage	*pkg,
128 						 const gchar	*license);
129 void		 asb_package_set_vcs		(AsbPackage	*pkg,
130 						 const gchar	*vcs);
131 void		 asb_package_set_source		(AsbPackage	*pkg,
132 						 const gchar	*source);
133 void		 asb_package_set_source_pkgname	(AsbPackage	*pkg,
134 						 const gchar	*source_pkgname);
135 void		 asb_package_add_dep		(AsbPackage	*pkg,
136 						 const gchar	*dep);
137 void		 asb_package_set_filelist	(AsbPackage	*pkg,
138 						 gchar		**filelist);
139 gchar		**asb_package_get_filelist	(AsbPackage	*pkg);
140 GPtrArray	*asb_package_get_deps		(AsbPackage	*pkg);
141 GPtrArray	*asb_package_get_releases	(AsbPackage	*pkg);
142 void		 asb_package_set_config		(AsbPackage	*pkg,
143 						 const gchar	*key,
144 						 const gchar	*value);
145 const gchar	*asb_package_get_config		(AsbPackage	*pkg,
146 						 const gchar	*key);
147 gint		 asb_package_compare		(AsbPackage	*pkg1,
148 						 AsbPackage	*pkg2);
149 gboolean	 asb_package_get_enabled	(AsbPackage	*pkg);
150 void		 asb_package_set_enabled	(AsbPackage	*pkg,
151 						 gboolean	 enabled);
152 AsRelease	*asb_package_get_release	(AsbPackage	*pkg,
153 						 const gchar	*version);
154 void		 asb_package_add_release	(AsbPackage	*pkg,
155 						 const gchar	*version,
156 						 AsRelease	*release);
157 AsbPackage	*asb_package_new		(void);
158 
159 G_END_DECLS
160