LCOV - code coverage report
Current view: top level - lang/qt/src - qgpgmequickjob.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 34 0.0 %
Date: 2018-11-15 08:49:49 Functions: 0 11 0.0 %

          Line data    Source code
       1             : /* qgpgmequickjob.cpp
       2             : 
       3             :     Copyright (c) 2017 Intevation GmbH
       4             : 
       5             :     QGpgME is free software; you can redistribute it and/or
       6             :     modify it under the terms of the GNU General Public License as
       7             :     published by the Free Software Foundation; either version 2 of the
       8             :     License, or (at your option) any later version.
       9             : 
      10             :     QGpgME is distributed in the hope that it will be useful,
      11             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :     General Public License for more details.
      14             : 
      15             :     You should have received a copy of the GNU General Public License along
      16             :     with this program; if not, write to the Free Software Foundation, Inc.,
      17             :     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      18             : 
      19             :     In addition, as a special exception, the copyright holders give
      20             :     permission to link the code of this program with any edition of
      21             :     the Qt library by Trolltech AS, Norway (or with modified versions
      22             :     of Qt that use the same license as Qt), and distribute linked
      23             :     combinations including the two.  You must obey the GNU General
      24             :     Public License in all respects for all of the code used other than
      25             :     Qt.  If you modify this file, you may extend this exception to
      26             :     your version of the file, but you are not obligated to do so.  If
      27             :     you do not wish to do so, delete this exception statement from
      28             :     your version.
      29             : */
      30             : 
      31             : #ifdef HAVE_CONFIG_H
      32             :  #include "config.h"
      33             : #endif
      34             : 
      35             : #include "qgpgmequickjob.h"
      36             : 
      37             : #include "context.h"
      38             : #include "key.h"
      39             : #include "util.h"
      40             : 
      41             : using namespace QGpgME;
      42             : using namespace GpgME;
      43             : 
      44           0 : QGpgMEQuickJob::QGpgMEQuickJob(Context *context)
      45           0 :     : mixin_type(context)
      46             : {
      47           0 :     lateInitialization();
      48           0 : }
      49             : 
      50           0 : QGpgMEQuickJob::~QGpgMEQuickJob() {}
      51             : 
      52           0 : static QGpgMEQuickJob::result_type createWorker(GpgME::Context *ctx,
      53             :                                                 const QString &uid,
      54             :                                                 const char *algo,
      55             :                                                 const QDateTime &expires,
      56             :                                                 const GpgME::Key &key,
      57             :                                                 unsigned int flags)
      58             : {
      59           0 :     auto err = ctx->createKey(uid.toUtf8().constData(),
      60             :                               algo,
      61             :                               0,
      62           0 :                               expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000) : 0,
      63             :                               key,
      64           0 :                               flags);
      65           0 :     return std::make_tuple(err, QString(), Error());
      66             : }
      67             : 
      68           0 : static QGpgMEQuickJob::result_type addSubkeyWorker(GpgME::Context *ctx,
      69             :                                                     const GpgME::Key &key,
      70             :                                                     const char *algo,
      71             :                                                     const QDateTime &expires,
      72             :                                                     unsigned int flags)
      73             : {
      74             :     auto err = ctx->createSubkey(key, algo,  0,
      75           0 :                                  expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000): 0,
      76           0 :                                  flags);
      77           0 :     return std::make_tuple(err, QString(), Error());
      78             : }
      79             : 
      80           0 : static QGpgMEQuickJob::result_type addUidWorker(GpgME::Context *ctx,
      81             :                                                 const GpgME::Key &key,
      82             :                                                 const QString &uid)
      83             : {
      84           0 :     auto err = ctx->addUid(key, uid.toUtf8().constData());
      85           0 :     return std::make_tuple(err, QString(), Error());
      86             : }
      87             : 
      88           0 : static QGpgMEQuickJob::result_type revUidWorker(GpgME::Context *ctx,
      89             :                                                 const GpgME::Key &key,
      90             :                                                 const QString &uid)
      91             : {
      92           0 :     auto err = ctx->revUid(key, uid.toUtf8().constData());
      93           0 :     return std::make_tuple(err, QString(), Error());
      94             : }
      95             : 
      96           0 : void QGpgMEQuickJob::startCreate(const QString &uid,
      97             :                  const char *algo,
      98             :                  const QDateTime &expires,
      99             :                  const GpgME::Key &key,
     100             :                  unsigned int flags)
     101             : {
     102           0 :     run(std::bind(&createWorker, std::placeholders::_1, uid, algo,
     103           0 :                   expires, key, flags));
     104           0 : }
     105             : 
     106           0 : void QGpgMEQuickJob::startAddUid(const GpgME::Key &key, const QString &uid)
     107             : {
     108           0 :     run(std::bind(&addUidWorker, std::placeholders::_1, key, uid));
     109           0 : }
     110             : 
     111           0 : void QGpgMEQuickJob::startRevUid(const GpgME::Key &key, const QString &uid)
     112             : {
     113           0 :     run(std::bind(&revUidWorker, std::placeholders::_1, key, uid));
     114           0 : }
     115             : 
     116           0 : void QGpgMEQuickJob::startAddSubkey(const GpgME::Key &key, const char *algo,
     117             :                                     const QDateTime &expires,
     118             :                                     unsigned int flags)
     119             : {
     120           0 :     run(std::bind(&addSubkeyWorker, std::placeholders::_1, key, algo,
     121           0 :                   expires, flags));
     122           0 : }
     123             : #include "qgpgmequickjob.moc"

Generated by: LCOV version 1.13