• 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
kgpgeditkeytransaction.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 "kgpgeditkeytransaction.h"
15 
16 KGpgEditKeyTransaction::KGpgEditKeyTransaction(QObject *parent, const QString &keyid,
17  const QString &command, const bool hasValue, const bool autoSave)
18  : KGpgTransaction(parent),
19  m_autosave(autoSave),
20  m_keyid(keyid)
21 {
22  addArgument(QLatin1String( "--status-fd=1" ));
23  addArgument(QLatin1String( "--command-fd=0" ));
24  addArgument(QLatin1String( "--edit-key" ));
25  addArgument(keyid);
26 
27  m_cmdpos = addArgument(command);
28  addArgumentRef(&m_cmdpos);
29 
30  if (hasValue) {
31  m_argpos = addArgument(QString());
32  addArgumentRef(&m_argpos);
33  } else {
34  m_argpos = -1;
35  }
36 
37  if (autoSave)
38  addArgument(QLatin1String( "save" ));
39 }
40 
41 KGpgEditKeyTransaction::~KGpgEditKeyTransaction()
42 {
43 }
44 
45 QString
46 KGpgEditKeyTransaction::getKeyid() const
47 {
48  return m_keyid;
49 }
50 
51 bool
52 KGpgEditKeyTransaction::preStart()
53 {
54  setSuccess(TS_MSG_SEQUENCE);
55 
56  return true;
57 }
58 
59 bool
60 KGpgEditKeyTransaction::nextLine(const QString &line)
61 {
62  if (line == QLatin1String("[GNUPG:] GOT_IT")) {
63  setSuccess(TS_OK);
64  return false;
65  } else if (getSuccess() == TS_USER_ABORTED) {
66  if (line.contains(QLatin1String( "GET_" ) ))
67  return true;
68  } else if ((getSuccess() == TS_OK) && line.contains(QLatin1String( "keyedit.prompt" ))) {
69  return true;
70  } else if (line.contains(QLatin1String( "NEED_PASSPHRASE" ))) {
71  // nothing for now
72  // we could use the id from NEED_PASSPHRASE as user id hint ...
73  } else {
74  if (getSuccess() != TS_BAD_PASSPHRASE)
75  setSuccess(TS_MSG_SEQUENCE);
76  return true;
77  }
78 
79  return false;
80 }
81 
82 KGpgTransaction::ts_boolanswer
83 KGpgEditKeyTransaction::boolQuestion(const QString& line)
84 {
85  if ((getSuccess() == TS_OK) && (line == QLatin1String("keyedit.save.okay")) && !m_autosave) {
86  return BA_YES;
87  } else {
88  return KGpgTransaction::boolQuestion(line);
89  }
90 }
91 
92 void
93 KGpgEditKeyTransaction::replaceValue(const QString &arg)
94 {
95  Q_ASSERT(m_argpos >= 0);
96 
97  replaceArgument(m_argpos, arg);
98 }
99 
100 void
101 KGpgEditKeyTransaction::replaceCommand(const QString &cmd)
102 {
103  replaceArgument(m_cmdpos, cmd);
104 }
105 
106 #include "kgpgeditkeytransaction.moc"
KGpgTransaction::getSuccess
int getSuccess() const
get the success value that will be returned with the done signal
Definition: kgpgtransaction.cpp:442
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
KGpgTransaction::replaceArgument
void replaceArgument(const int pos, const QString &arg)
replace the argument at the given position
Definition: kgpgtransaction.cpp:582
KGpgEditKeyTransaction::getKeyid
QString getKeyid() const
return the id of the key we are editing
Definition: kgpgeditkeytransaction.cpp:46
KGpgEditKeyTransaction::~KGpgEditKeyTransaction
virtual ~KGpgEditKeyTransaction()
destructor
Definition: kgpgeditkeytransaction.cpp:41
KGpgTransaction::addArgumentRef
void addArgumentRef(int *ref)
make sure the reference to a specific argument is kept up to date
Definition: kgpgtransaction.cpp:617
QObject
KGpgEditKeyTransaction::nextLine
virtual bool nextLine(const QString &line)
handle standard GnuPG prompts
Definition: kgpgeditkeytransaction.cpp:60
KGpgTransaction::boolQuestion
virtual ts_boolanswer boolQuestion(const QString &line)
Called for every boolean question GnuPG answers.
Definition: kgpgtransaction.cpp:457
QString
KGpgTransaction::TS_MSG_SEQUENCE
unexpected sequence of GnuPG messages
Definition: kgpgtransaction.h:62
KGpgTransaction::ts_boolanswer
ts_boolanswer
result codes for GnuPG boolean questions
Definition: kgpgtransaction.h:73
KGpgEditKeyTransaction::replaceCommand
void replaceCommand(const QString &cmd)
replace the command
Definition: kgpgeditkeytransaction.cpp:101
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
KGpgTransaction::TS_USER_ABORTED
the user aborted the transaction
Definition: kgpgtransaction.h:63
kgpgeditkeytransaction.h
KGpgEditKeyTransaction::boolQuestion
virtual ts_boolanswer boolQuestion(const QString &line)
Called for every boolean question GnuPG answers.
Definition: kgpgeditkeytransaction.cpp:83
QLatin1String
KGpgTransaction::setSuccess
void setSuccess(const int v)
set the success value that will be returned with the done signal
Definition: kgpgtransaction.cpp:448
KGpgTransaction::TS_BAD_PASSPHRASE
the passphrase was not correct
Definition: kgpgtransaction.h:61
KGpgTransaction
Process one GnuPG operation.
Definition: kgpgtransaction.h:44
KGpgEditKeyTransaction::preStart
virtual bool preStart()
reset class before next operation starts
Definition: kgpgeditkeytransaction.cpp:52
KGpgEditKeyTransaction::replaceValue
void replaceValue(const QString &arg)
replace the argument of the edit command
Definition: kgpgeditkeytransaction.cpp:93
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