Line data Source code
1 : /*
2 : swdbresult.h - wraps a gpgme swdb query / rsult
3 : Copyright (C) 2016 Intevation GmbH
4 :
5 : This file is part of GPGME++.
6 :
7 : GPGME++ is free software; you can redistribute it and/or
8 : modify it under the terms of the GNU Library General Public
9 : License as published by the Free Software Foundation; either
10 : version 2 of the License, or (at your option) any later version.
11 :
12 : GPGME++ 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 Library General Public License for more details.
16 :
17 : You should have received a copy of the GNU Library General Public License
18 : along with GPGME++; see the file COPYING.LIB. If not, write to the
19 : Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 : Boston, MA 02110-1301, USA.
21 : */
22 : #ifndef __GPGMEPP_SWDB_H__
23 : #define __GPGMEPP_SWDB_H__
24 :
25 : #include "gpgmepp_export.h"
26 :
27 : #include "global.h"
28 : #include "engineinfo.h"
29 :
30 : #include <vector>
31 : #include <string>
32 : #include <iostream>
33 : #include <ostream>
34 :
35 : namespace GpgME
36 : {
37 :
38 0 : class GPGMEPP_EXPORT SwdbResult
39 : {
40 : public:
41 : /* Obtain swdb results through query() */
42 : SwdbResult();
43 : explicit SwdbResult(gpgme_query_swdb_result_t result);
44 :
45 : /** Query the swdb to get information about updates.
46 : *
47 : * Runs gpgconf --query-swdb through gpgme and
48 : * returns a list of results.
49 : * If iversion is given as NULL a check is only done if GPGME
50 : * can figure out the version by itself (for example when using
51 : * "gpgme" or "gnupg").
52 : *
53 : * If NULL is used for name the current gpgme version is
54 : * checked.
55 : *
56 : * @param name: Name of the component to query.
57 : * @param iversion: Optionally the installed version.
58 : * @param err: Optional error.
59 : */
60 : static std::vector<SwdbResult> query(const char *name,
61 : const char *iversion = NULL,
62 : Error *err = NULL);
63 :
64 : const SwdbResult &operator=(SwdbResult other)
65 : {
66 : swap(other);
67 : return *this;
68 : }
69 :
70 : void swap(SwdbResult &other)
71 : {
72 : using std::swap;
73 : swap(this->d, other.d);
74 : }
75 : bool isNull() const;
76 :
77 : /* The name of the package (e.g. "gpgme", "gnupg") */
78 : std::string name() const;
79 :
80 : /* The version of the installed version. */
81 : EngineInfo::Version installedVersion() const;
82 :
83 : /* The time the online info was created. */
84 : unsigned long created() const;
85 :
86 : /* The time the online info was retrieved. */
87 : unsigned long retrieved() const;
88 :
89 : /* This bit is set if an error occured or some of the information
90 : * in this structure may not be set. */
91 : bool warning() const;
92 :
93 : /* An update is available. */
94 : bool update() const;
95 :
96 : /* The update is important. */
97 : bool urgent() const;
98 :
99 : /* No information at all available. */
100 : bool noinfo() const;
101 :
102 : /* The package name is not known. */
103 : bool unknown() const;
104 :
105 : /* The information here is too old. */
106 : bool tooOld() const;
107 :
108 : /* Other error. */
109 : bool error() const;
110 :
111 : /* The version of the latest released version. */
112 : EngineInfo::Version version() const;
113 :
114 : /* The release date of that version. */
115 : unsigned long releaseDate() const;
116 :
117 : private:
118 : class Private;
119 : std::shared_ptr<Private> d;
120 : };
121 :
122 : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const SwdbResult &info);
123 :
124 : } // namespace GpgME
125 :
126 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(SwdbResult)
127 :
128 : #endif
|