summaryrefslogtreecommitdiff
path: root/libappstream-builder/asb-package.h
blob: e63c190f0a1f0ae266044d020bd8a5b247755ca4 (plain)
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
167
168
169
170
171
172
173
174
175
176
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
 *
 * Licensed under the GNU Lesser General Public License Version 2.1
 *
 * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef ASB_PACKAGE_H
#define ASB_PACKAGE_H

#include <glib-object.h>

#include <stdarg.h>
#include <appstream-glib.h>

G_BEGIN_DECLS

#define ASB_TYPE_PACKAGE (asb_package_get_type ())
G_DECLARE_DERIVABLE_TYPE (AsbPackage, asb_package, ASB, PACKAGE, GObject)

#define ASB_PACKAGE_ENSURE_NONE		(0u)
#define ASB_PACKAGE_ENSURE_NEVRA	(1u << 0)
#define ASB_PACKAGE_ENSURE_FILES	(1u << 1)
#define ASB_PACKAGE_ENSURE_RELEASES	(1u << 2)
#define ASB_PACKAGE_ENSURE_DEPS		(1u << 3)
#define ASB_PACKAGE_ENSURE_LICENSE	(1u << 4)
#define ASB_PACKAGE_ENSURE_URL		(1u << 5)
#define ASB_PACKAGE_ENSURE_SOURCE	(1u << 6)
#define ASB_PACKAGE_ENSURE_VCS		(1u << 7)
typedef guint64 AsbPackageEnsureFlags;

struct _AsbPackageClass
{
	GObjectClass		parent_class;
	gboolean		 (*open)	(AsbPackage	*pkg,
						 const gchar	*filename,
						 GError		**error);
	gboolean		 (*ensure)	(AsbPackage	*pkg,
						 AsbPackageEnsureFlags flags,
						 GError		**error);
	gboolean		 (*explode)	(AsbPackage	*pkg,
						 const gchar	*dir,
						 GPtrArray	*glob,
						 GError		**error);
	gint			 (*compare)	(AsbPackage	*pkg1,
						 AsbPackage	*pkg2);
	gboolean		 (*close)	(AsbPackage	*pkg,
						 GError		**error);
	/*< private >*/
	void (*_asb_reserved1)	(void);
	void (*_asb_reserved2)	(void);
	void (*_asb_reserved3)	(void);
	void (*_asb_reserved4)	(void);
	void (*_asb_reserved5)	(void);
	void (*_asb_reserved6)	(void);
	void (*_asb_reserved7)	(void);
};

typedef enum {
	ASB_PACKAGE_LOG_LEVEL_NONE,
	ASB_PACKAGE_LOG_LEVEL_DEBUG,
	ASB_PACKAGE_LOG_LEVEL_INFO,
	ASB_PACKAGE_LOG_LEVEL_WARNING,
	ASB_PACKAGE_LOG_LEVEL_LAST,
} AsbPackageLogLevel;

typedef enum {
	ASB_PACKAGE_KIND_DEFAULT,
	ASB_PACKAGE_KIND_BUNDLE,
	ASB_PACKAGE_KIND_FIRMWARE,
	ASB_PACKAGE_KIND_LAST
} AsbPackageKind;

void		 asb_package_log_start		(AsbPackage	*pkg);
void		 asb_package_log		(AsbPackage	*pkg,
						 AsbPackageLogLevel log_level,
						 const gchar	*fmt,
						 ...)
						 G_GNUC_PRINTF (3, 4);
gboolean	 asb_package_log_flush		(AsbPackage	*pkg,
						 GError		**error);
gboolean	 asb_package_open		(AsbPackage	*pkg,
						 const gchar	*filename,
						 GError		**error);
gboolean	 asb_package_close		(AsbPackage	*pkg,
						 GError		**error);
gboolean	 asb_package_ensure		(AsbPackage	*pkg,
						 AsbPackageEnsureFlags flags,
						 GError		**error);
void		 asb_package_clear		(AsbPackage	*pkg,
						 AsbPackageEnsureFlags flags);
gboolean	 asb_package_explode		(AsbPackage	*pkg,
						 const gchar	*dir,
						 GPtrArray	*glob,
						 GError		**error);
AsbPackageKind	 asb_package_get_kind		(AsbPackage	*pkg);
guint		 asb_package_get_epoch		(AsbPackage	*pkg);
const gchar	*asb_package_get_filename	(AsbPackage	*pkg);
const gchar	*asb_package_get_basename	(AsbPackage	*pkg);
const gchar	*asb_package_get_arch		(AsbPackage	*pkg);
const gchar	*asb_package_get_name		(AsbPackage	*pkg);
const gchar	*asb_package_get_version	(AsbPackage	*pkg);
const gchar	*asb_package_get_release_str	(AsbPackage	*pkg);
const gchar	*asb_package_get_nevr		(AsbPackage	*pkg);
const gchar	*asb_package_get_nevra		(AsbPackage	*pkg);
const gchar	*asb_package_get_evr		(AsbPackage	*pkg);
const gchar	*asb_package_get_url		(AsbPackage	*pkg);
const gchar	*asb_package_get_vcs		(AsbPackage	*pkg);
const gchar	*asb_package_get_license	(AsbPackage	*pkg);
const gchar	*asb_package_get_source		(AsbPackage	*pkg);
const gchar	*asb_package_get_source_pkgname	(AsbPackage	*pkg);
void		 asb_package_set_kind		(AsbPackage	*pkg,
						 AsbPackageKind	 kind);
void		 asb_package_set_name		(AsbPackage	*pkg,
						 const gchar	*name);
void		 asb_package_set_filename	(AsbPackage	*pkg,
						 const gchar	*filename);
void		 asb_package_set_version	(AsbPackage	*pkg,
						 const gchar	*version);
void		 asb_package_set_release	(AsbPackage	*pkg,
						 const gchar	*release);
void		 asb_package_set_arch		(AsbPackage	*pkg,
						 const gchar	*arch);
void		 asb_package_set_epoch		(AsbPackage	*pkg,
						 guint		 epoch);
void		 asb_package_set_url		(AsbPackage	*pkg,
						 const gchar	*url);
void		 asb_package_set_license	(AsbPackage	*pkg,
						 const gchar	*license);
void		 asb_package_set_vcs		(AsbPackage	*pkg,
						 const gchar	*vcs);
void		 asb_package_set_source		(AsbPackage	*pkg,
						 const gchar	*source);
void		 asb_package_set_source_pkgname	(AsbPackage	*pkg,
						 const gchar	*source_pkgname);
void		 asb_package_add_dep		(AsbPackage	*pkg,
						 const gchar	*dep);
void		 asb_package_set_filelist	(AsbPackage	*pkg,
						 gchar		**filelist);
gchar		**asb_package_get_filelist	(AsbPackage	*pkg);
GPtrArray	*asb_package_get_deps		(AsbPackage	*pkg);
GPtrArray	*asb_package_get_releases	(AsbPackage	*pkg);
void		 asb_package_set_config		(AsbPackage	*pkg,
						 const gchar	*key,
						 const gchar	*value);
const gchar	*asb_package_get_config		(AsbPackage	*pkg,
						 const gchar	*key);
gint		 asb_package_compare		(AsbPackage	*pkg1,
						 AsbPackage	*pkg2);
gboolean	 asb_package_get_enabled	(AsbPackage	*pkg);
void		 asb_package_set_enabled	(AsbPackage	*pkg,
						 gboolean	 enabled);
AsRelease	*asb_package_get_release	(AsbPackage	*pkg,
						 const gchar	*version);
void		 asb_package_add_release	(AsbPackage	*pkg,
						 const gchar	*version,
						 AsRelease	*release);
AsbPackage	*asb_package_new		(void);

G_END_DECLS

#endif /* ASB_PACKAGE_H */