Blame lang/cpp/src/swdbresult.h

Packit d7e8d0
/*
Packit d7e8d0
  swdbresult.h - wraps a gpgme swdb query / rsult
Packit d7e8d0
  Copyright (C) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Packit d7e8d0
  Software engineering by Intevation GmbH
Packit d7e8d0
Packit d7e8d0
  This file is part of GPGME++.
Packit d7e8d0
Packit d7e8d0
  GPGME++ is free software; you can redistribute it and/or
Packit d7e8d0
  modify it under the terms of the GNU Library General Public
Packit d7e8d0
  License as published by the Free Software Foundation; either
Packit d7e8d0
  version 2 of the License, or (at your option) any later version.
Packit d7e8d0
Packit d7e8d0
  GPGME++ is distributed in the hope that it will be useful,
Packit d7e8d0
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit d7e8d0
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit d7e8d0
  GNU Library General Public License for more details.
Packit d7e8d0
Packit d7e8d0
  You should have received a copy of the GNU Library General Public License
Packit d7e8d0
  along with GPGME++; see the file COPYING.LIB.  If not, write to the
Packit d7e8d0
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit d7e8d0
  Boston, MA 02110-1301, USA.
Packit d7e8d0
*/
Packit d7e8d0
#ifndef __GPGMEPP_SWDB_H__
Packit d7e8d0
#define __GPGMEPP_SWDB_H__
Packit d7e8d0
Packit d7e8d0
#include "gpgmepp_export.h"
Packit d7e8d0
Packit d7e8d0
#include "global.h"
Packit d7e8d0
#include "engineinfo.h"
Packit d7e8d0
Packit d7e8d0
#include <vector>
Packit d7e8d0
#include <string>
Packit d7e8d0
#include <iostream>
Packit d7e8d0
#include <ostream>
Packit d7e8d0
Packit d7e8d0
namespace GpgME
Packit d7e8d0
{
Packit d7e8d0
Packit d7e8d0
class GPGMEPP_EXPORT SwdbResult
Packit d7e8d0
{
Packit d7e8d0
public:
Packit d7e8d0
    /* Obtain swdb results through query() */
Packit d7e8d0
    SwdbResult();
Packit d7e8d0
    explicit SwdbResult(gpgme_query_swdb_result_t result);
Packit d7e8d0
Packit d7e8d0
    /** Query the swdb to get information about updates.
Packit d7e8d0
     *
Packit d7e8d0
     * Runs gpgconf --query-swdb through gpgme and
Packit d7e8d0
     * returns a list of results.
Packit d7e8d0
     * If iversion is given as NULL a check is only done if GPGME
Packit d7e8d0
     * can figure out the version by itself (for example when using
Packit d7e8d0
     * "gpgme" or "gnupg").
Packit d7e8d0
     *
Packit d7e8d0
     * If NULL is used for name the current gpgme version is
Packit d7e8d0
     * checked.
Packit d7e8d0
     *
Packit d7e8d0
     * @param name: Name of the component to query.
Packit d7e8d0
     * @param iversion: Optionally the installed version.
Packit d7e8d0
     * @param err: Optional error.
Packit d7e8d0
     */
Packit d7e8d0
    static std::vector<SwdbResult> query(const char *name,
Packit d7e8d0
                                         const char *iversion = NULL,
Packit d7e8d0
                                         Error *err = NULL);
Packit d7e8d0
Packit d7e8d0
    const SwdbResult &operator=(SwdbResult other)
Packit d7e8d0
    {
Packit d7e8d0
        swap(other);
Packit d7e8d0
        return *this;
Packit d7e8d0
    }
Packit d7e8d0
Packit d7e8d0
    void swap(SwdbResult &other)
Packit d7e8d0
    {
Packit d7e8d0
        using std::swap;
Packit d7e8d0
        swap(this->d, other.d);
Packit d7e8d0
    }
Packit d7e8d0
    bool isNull() const;
Packit d7e8d0
Packit d7e8d0
    /* The name of the package (e.g. "gpgme", "gnupg") */
Packit d7e8d0
    std::string name() const;
Packit d7e8d0
Packit d7e8d0
    /* The version of the installed version.  */
Packit d7e8d0
    EngineInfo::Version installedVersion() const;
Packit d7e8d0
Packit d7e8d0
    /* The time the online info was created.  */
Packit d7e8d0
    unsigned long created() const;
Packit d7e8d0
Packit d7e8d0
    /* The time the online info was retrieved.  */
Packit d7e8d0
    unsigned long retrieved() const;
Packit d7e8d0
Packit d7e8d0
    /* This bit is set if an error occurred or some of the information
Packit d7e8d0
     * in this structure may not be set.  */
Packit d7e8d0
    bool warning() const;
Packit d7e8d0
Packit d7e8d0
    /* An update is available.  */
Packit d7e8d0
    bool update() const;
Packit d7e8d0
Packit d7e8d0
    /* The update is important.  */
Packit d7e8d0
    bool urgent() const;
Packit d7e8d0
Packit d7e8d0
    /* No information at all available.  */
Packit d7e8d0
    bool noinfo() const;
Packit d7e8d0
Packit d7e8d0
    /* The package name is not known. */
Packit d7e8d0
    bool unknown() const;
Packit d7e8d0
Packit d7e8d0
    /* The information here is too old.  */
Packit d7e8d0
    bool tooOld() const;
Packit d7e8d0
Packit d7e8d0
    /* Other error.  */
Packit d7e8d0
    bool error() const;
Packit d7e8d0
Packit d7e8d0
    /* The version of the latest released version.  */
Packit d7e8d0
    EngineInfo::Version version() const;
Packit d7e8d0
Packit d7e8d0
    /* The release date of that version.  */
Packit d7e8d0
    unsigned long releaseDate() const;
Packit d7e8d0
Packit d7e8d0
private:
Packit d7e8d0
    class Private;
Packit d7e8d0
    std::shared_ptr<Private> d;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const SwdbResult &info;;
Packit d7e8d0
Packit d7e8d0
} // namespace GpgME
Packit d7e8d0
Packit d7e8d0
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(SwdbResult)
Packit d7e8d0
Packit d7e8d0
#endif