• 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
kgpgkeyserversearchtransaction.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010,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 "kgpgkeyserversearchtransaction.h"
15 
16 KGpgKeyserverSearchTransaction::KGpgKeyserverSearchTransaction(QObject *parent, const QString &keyserver, const QString &pattern, const bool withProgress, const QString &proxy)
17  : KGpgKeyserverTransaction(parent, keyserver, withProgress, proxy),
18  m_pageEmpty(true)
19 {
20  addArgument(QLatin1String( "--with-colons" ));
21  addArgument(QLatin1String( "--search-keys" ));
22  m_patternPos = addArgument(pattern);
23 }
24 
25 KGpgKeyserverSearchTransaction::~KGpgKeyserverSearchTransaction()
26 {
27 }
28 
29 bool
30 KGpgKeyserverSearchTransaction::preStart()
31 {
32  setSuccess(TS_MSG_SEQUENCE);
33  m_keyLines.clear();
34 
35  return KGpgKeyserverTransaction::preStart();
36 }
37 
38 bool
39 KGpgKeyserverSearchTransaction::nextLine(const QString &line)
40 {
41  if (line.startsWith(QLatin1String("[GNUPG:] GET_LINE keysearch.prompt"))) {
42  if (!m_pageEmpty) {
43  write("n");
44  m_pageEmpty = true;
45  } else {
46  return true;
47  }
48  } else if (!line.isEmpty() && !line.startsWith(QLatin1String("[GNUPG:] "))) {
49  m_pageEmpty = false;
50  if (line.startsWith(QLatin1String("pub:"))) {
51  if (!m_keyLines.isEmpty()) {
52  emit newKey(m_keyLines);
53  m_keyLines.clear();
54  }
55  m_keyLines.append(line);
56  } else if (!m_keyLines.isEmpty() && (line != QLatin1String("\r")))
57  m_keyLines.append(line);
58  }
59 
60  return false;
61 }
62 
63 void
64 KGpgKeyserverSearchTransaction::finish()
65 {
66  if (!m_keyLines.isEmpty()) {
67  emit newKey(m_keyLines);
68  m_keyLines.clear();
69  }
70 }
71 
72 void
73 KGpgKeyserverSearchTransaction::setPattern(const QString &pattern)
74 {
75  replaceArgument(m_patternPos, pattern);
76 }
77 
78 #include "kgpgkeyserversearchtransaction.moc"
QList::clear
void clear()
KGpgKeyserverSearchTransaction::nextLine
virtual bool nextLine(const QString &line)
Called for every line the gpg process writes.
Definition: kgpgkeyserversearchtransaction.cpp:39
KGpgTransaction::addArgument
int addArgument(const QString &arg)
add a command line argument to gpg process
Definition: kgpgtransaction.cpp:562
KGpgTransaction::write
void write(const QByteArray &a, const bool lf=true)
write data to standard input of gpg process
Definition: kgpgtransaction.cpp:413
KGpgTransaction::replaceArgument
void replaceArgument(const int pos, const QString &arg)
replace the argument at the given position
Definition: kgpgtransaction.cpp:582
QList::append
void append(const T &value)
QObject
QList::isEmpty
bool isEmpty() const
QString::isEmpty
bool isEmpty() const
kgpgkeyserversearchtransaction.h
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QString
KGpgTransaction::TS_MSG_SEQUENCE
unexpected sequence of GnuPG messages
Definition: kgpgtransaction.h:62
KGpgKeyserverSearchTransaction::newKey
void newKey(QStringList lines)
emitted every time a new key is completed
KGpgKeyserverSearchTransaction::preStart
virtual bool preStart()
Called before the gpg process is started.
Definition: kgpgkeyserversearchtransaction.cpp:30
KGpgKeyserverSearchTransaction::~KGpgKeyserverSearchTransaction
virtual ~KGpgKeyserverSearchTransaction()
Definition: kgpgkeyserversearchtransaction.cpp:25
QLatin1String
KGpgTransaction::setSuccess
void setSuccess(const int v)
set the success value that will be returned with the done signal
Definition: kgpgtransaction.cpp:448
KGpgKeyserverTransaction::preStart
virtual bool preStart()
Called before the gpg process is started.
Definition: kgpgkeyservertransaction.cpp:68
KGpgKeyserverTransaction
base class for transactions involving key servers
Definition: kgpgkeyservertransaction.h:27
KGpgKeyserverSearchTransaction::finish
virtual void finish()
needed to submit the last search result
Definition: kgpgkeyserversearchtransaction.cpp:64
KGpgKeyserverSearchTransaction::setPattern
void setPattern(const QString &pattern)
Definition: kgpgkeyserversearchtransaction.cpp:73
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