1 /*
2 * Copyright (C) 2014 Red Hat, Inc.
3 * Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
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:dnf-advisorypkg
24 * @short_description: Update advisory package
25 * @include: libdnf.h
26 * @stability: Unstable
27 *
28 * This object represents an package listed as an advisory.
29 *
30 * See also: #DnfAdvisory
31 */
32
33 #include "dnf-advisorypkg.h"
34 #include "sack/advisorypkg.hpp"
35
36
37 /**
38 * dnf_advisorypkg_compare:
39 * @left: a #DnfAdvisoryPkg instance.
40 * @right: another #DnfAdvisoryPkg instance.
41 *
42 * Compares one advisory against another.
43 *
44 * Returns: 0 if they are the same
45 *
46 * Since: 0.7.0
47 */
48 int
dnf_advisorypkg_compare(DnfAdvisoryPkg * left,DnfAdvisoryPkg * right)49 dnf_advisorypkg_compare(DnfAdvisoryPkg *left, DnfAdvisoryPkg *right)
50 {
51 return !left->nevraEQ(*right);
52 }
53
54 /**
55 * dnf_advisorypkg_compare_solvable:
56 * @advisorypkg: a #DnfAdvisoryPkg instance.
57 * @pool: package pool
58 * @solvable: solvable
59 *
60 * Compares advisorypkg against solvable
61 *
62 * Returns: 0 if they are the same
63 *
64 * Since: 0.7.0
65 */
66 gboolean
dnf_advisorypkg_compare_solvable(DnfAdvisoryPkg * advisorypkg,Pool * pool,Solvable * s)67 dnf_advisorypkg_compare_solvable(DnfAdvisoryPkg *advisorypkg, Pool *pool, Solvable *s)
68 {
69 return !advisorypkg->nevraEQ(s);
70 }
71
72 DnfAdvisory *
dnf_advisorypkg_get_advisory(DnfAdvisoryPkg * advisorypkg)73 dnf_advisorypkg_get_advisory (DnfAdvisoryPkg *advisorypkg)
74 {
75 return advisorypkg->getAdvisory();
76 }
77
78 /**
79 * dnf_advisorypkg_free:
80 * @advisorypkg: a #DnfAdvisoryPkg instance.
81 *
82 * Destructor of #DnfAdvisoryPkg
83 *
84 * Since: 0.13.0
85 */
86 void
dnf_advisorypkg_free(DnfAdvisoryPkg * advisorypkg)87 dnf_advisorypkg_free(DnfAdvisoryPkg *advisorypkg)
88 {
89 delete advisorypkg;
90 }
91
92 /**
93 * dnf_advisorypkg_get_name:
94 * @advisorypkg: a #DnfAdvisoryPkg instance.
95 *
96 * Returns the advisory package name.
97 *
98 * Returns: string, or %NULL.
99 *
100 * Since: 0.7.0
101 */
102 const char *
dnf_advisorypkg_get_name(DnfAdvisoryPkg * advisorypkg)103 dnf_advisorypkg_get_name(DnfAdvisoryPkg *advisorypkg)
104 {
105 return advisorypkg->getNameString();
106 }
107
108 /**
109 * dnf_advisorypkg_get_evr:
110 * @advisorypkg: a #DnfAdvisoryPkg instance.
111 *
112 * Returns the advisory package EVR.
113 *
114 * Returns: string, or %NULL.
115 *
116 * Since: 0.7.0
117 */
118 const char *
dnf_advisorypkg_get_evr(DnfAdvisoryPkg * advisorypkg)119 dnf_advisorypkg_get_evr(DnfAdvisoryPkg *advisorypkg)
120 {
121 return advisorypkg->getEVRString();
122 }
123
124 /**
125 * dnf_advisorypkg_get_arch:
126 * @advisorypkg: a #DnfAdvisoryPkg instance.
127 *
128 * Returns the advisory package architecture.
129 *
130 * Returns: string, or %NULL.
131 *
132 * Since: 0.7.0
133 */
134 const char *
dnf_advisorypkg_get_arch(DnfAdvisoryPkg * advisorypkg)135 dnf_advisorypkg_get_arch(DnfAdvisoryPkg *advisorypkg)
136 {
137 return advisorypkg->getArchString();
138 }
139
140 /**
141 * dnf_advisorypkg_get_filename:
142 * @advisorypkg: a #DnfAdvisoryPkg instance.
143 *
144 * Returns the advisory package filename.
145 *
146 * Returns: string, or %NULL.
147 *
148 * Since: 0.7.0
149 */
150 const char *
dnf_advisorypkg_get_filename(DnfAdvisoryPkg * advisorypkg)151 dnf_advisorypkg_get_filename(DnfAdvisoryPkg *advisorypkg)
152 {
153 return advisorypkg->getFileName();
154 }
155