File indexing completed on 2024-04-21 05:50:41

0001 /*
0002     SPDX-FileCopyrightText: 2008-2022 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "kgpgchangeexpire.h"
0007 
0008 #include "detailedconsole.h"
0009 
0010 KGpgChangeExpire::KGpgChangeExpire(QObject *parent, const QString &keyid, const QDateTime &date)
0011     : KGpgEditKeyTransaction(parent, keyid, QLatin1String( "expire" ), false)
0012 {
0013     setDate(date);
0014 }
0015 
0016 bool
0017 KGpgChangeExpire::nextLine(const QString &line)
0018 {
0019     if (!line.startsWith(QLatin1String("[GNUPG:]")))
0020         return false;
0021 
0022     if (line.contains(QLatin1String( "GOOD_PASSPHRASE" ))) {
0023         setSuccess(TS_OK);
0024 
0025         return false;
0026     } else if (line.contains(QLatin1String( "keygen.valid" ))) {
0027         if (m_date.isNull())
0028             write("0");
0029         else
0030             write(QByteArray::number(QDate::currentDate().daysTo(m_date.date())));
0031 
0032         return false;
0033     } else {
0034         return KGpgEditKeyTransaction::nextLine(line);
0035     }
0036 }
0037 
0038 void
0039 KGpgChangeExpire::setDate(const QDateTime &date)
0040 {
0041     m_date = date;
0042 }