• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kgpg

  • sources
  • kde-4.14
  • kdeutils
  • kgpg
  • transactions
kgpgdelkey.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008,2009,2012 Rolf Eike Beer <kde@opensource.sf-tec.de>
3  */
4 
5 /***************************************************************************
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  ***************************************************************************/
13 
14 #include "kgpgdelkey.h"
15 
16 #include "gpgproc.h"
17 
18 #include <QString>
19 #include <QStringList>
20 
21 KGpgDelKey::KGpgDelKey(QObject *parent, KGpgKeyNode *key)
22  : KGpgTransaction(parent)
23 {
24  m_keys << key;
25  setCmdLine();
26 }
27 
28 KGpgDelKey::KGpgDelKey(QObject *parent, const KGpgKeyNode::List &keys)
29  : KGpgTransaction(parent),
30  m_keys(keys)
31 {
32  setCmdLine();
33 }
34 
35 KGpgDelKey::~KGpgDelKey()
36 {
37 }
38 
39 KGpgKeyNode::List
40 KGpgDelKey::keys() const
41 {
42  return m_keys;
43 }
44 
45 bool
46 KGpgDelKey::nextLine(const QString &line)
47 {
48  if (!line.startsWith(QLatin1String("[GNUPG:] GOT_IT")))
49  setSuccess(KGpgTransaction::TS_MSG_SEQUENCE);
50 
51  return false;
52 }
53 
54 KGpgTransaction::ts_boolanswer
55 KGpgDelKey::boolQuestion(const QString &line)
56 {
57  if (line.startsWith(QLatin1String("delete_key.okay")))
58  return KGpgTransaction::BA_YES;
59 
60  if (line.startsWith(QLatin1String("delete_key.secret.okay")))
61  return KGpgTransaction::BA_YES;
62 
63  return KGpgTransaction::boolQuestion(line);
64 }
65 
66 bool
67 KGpgDelKey::preStart()
68 {
69  GPGProc *proc = getProcess();
70  QStringList args = proc->program();
71 
72  foreach (const KGpgKeyNode *key, m_keys)
73  args << key->getFingerprint();
74 
75  proc->setProgram(args);
76 
77  setSuccess(KGpgTransaction::TS_OK);
78 
79  return true;
80 }
81 
82 void
83 KGpgDelKey::setCmdLine()
84 {
85  addArgument(QLatin1String( "--status-fd=1" ));
86  addArgument(QLatin1String( "--command-fd=0" ));
87  addArgument(QLatin1String( "--delete-secret-and-public-key" ));
88 
89  m_argscount = getProcess()->program().count();
90 }
91 
92 #include "kgpgdelkey.moc"
GPGProc
A interface to GnuPG handling UTF8 recoding correctly.
Definition: gpgproc.h:36
KGpgTransaction::addArgument
int addArgument(const QString &arg)
add a command line argument to gpg process
Definition: kgpgtransaction.cpp:562
KGpgTransaction::BA_YES
answer "YES"
Definition: kgpgtransaction.h:75
KGpgTransaction::TS_OK
everything went fine
Definition: kgpgtransaction.h:60
KGpgDelKey::nextLine
virtual bool nextLine(const QString &line)
Called for every line the gpg process writes.
Definition: kgpgdelkey.cpp:46
KGpgTransaction::getProcess
GPGProc * getProcess()
get a reference to the gpg process object
Definition: kgpgtransaction.cpp:556
KGpgKeyNode
A public key with or without corresponding secret key.
Definition: KGpgKeyNode.h:33
KGpgKeyNode::getFingerprint
const QString & getFingerprint() const
Definition: KGpgKeyNode.cpp:75
kgpgdelkey.h
QObject
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
gpgproc.h
KGpgTransaction::boolQuestion
virtual ts_boolanswer boolQuestion(const QString &line)
Called for every boolean question GnuPG answers.
Definition: kgpgtransaction.cpp:457
KGpgDelKey::boolQuestion
virtual ts_boolanswer boolQuestion(const QString &line)
Called for every boolean question GnuPG answers.
Definition: kgpgdelkey.cpp:55
QString
QList
KGpgTransaction::TS_MSG_SEQUENCE
unexpected sequence of GnuPG messages
Definition: kgpgtransaction.h:62
QStringList
KGpgTransaction::ts_boolanswer
ts_boolanswer
result codes for GnuPG boolean questions
Definition: kgpgtransaction.h:73
KGpgDelKey::~KGpgDelKey
virtual ~KGpgDelKey()
Definition: kgpgdelkey.cpp:35
QLatin1String
KGpgTransaction::setSuccess
void setSuccess(const int v)
set the success value that will be returned with the done signal
Definition: kgpgtransaction.cpp:448
KGpgDelKey::keys
KGpgKeyNode::List keys() const
the keys that were requested to be removed
Definition: kgpgdelkey.cpp:40
KGpgTransaction
Process one GnuPG operation.
Definition: kgpgtransaction.h:44
KGpgDelKey::preStart
virtual bool preStart()
Called before the gpg process is started.
Definition: kgpgdelkey.cpp:67
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal