File indexing completed on 2024-04-21 05:50:42
0001 /* 0002 SPDX-FileCopyrightText: 2010-2022 Rolf Eike Beer <kde@opensource.sf-tec.de> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "kgpgkeyserversearchtransaction.h" 0007 0008 KGpgKeyserverSearchTransaction::KGpgKeyserverSearchTransaction(QObject *parent, const QString &keyserver, const QString &pattern, const bool withProgress, const QString &proxy) 0009 : KGpgKeyserverTransaction(parent, keyserver, withProgress, proxy), 0010 m_pageEmpty(true) 0011 { 0012 addArgument(QLatin1String( "--with-colons" )); 0013 addArgument(QLatin1String( "--search-keys" )); 0014 m_patternPos = addArgument(pattern); 0015 } 0016 0017 bool 0018 KGpgKeyserverSearchTransaction::preStart() 0019 { 0020 setSuccess(TS_MSG_SEQUENCE); 0021 m_keyLines.clear(); 0022 0023 return KGpgKeyserverTransaction::preStart(); 0024 } 0025 0026 bool 0027 KGpgKeyserverSearchTransaction::nextLine(const QString &line) 0028 { 0029 if (line.startsWith(QLatin1String("[GNUPG:] GET_LINE keysearch.prompt"))) { 0030 if (!m_pageEmpty) { 0031 write("n"); 0032 m_pageEmpty = true; 0033 } else { 0034 return true; 0035 } 0036 } else if (!line.isEmpty() && !line.startsWith(QLatin1String("[GNUPG:] "))) { 0037 m_pageEmpty = false; 0038 if (line.startsWith(QLatin1String("pub:"))) { 0039 if (!m_keyLines.isEmpty()) { 0040 Q_EMIT newKey(m_keyLines); 0041 m_keyLines.clear(); 0042 } 0043 m_keyLines.append(line); 0044 } else if (!m_keyLines.isEmpty() && (line != QLatin1String("\r"))) 0045 m_keyLines.append(line); 0046 } 0047 0048 return false; 0049 } 0050 0051 void 0052 KGpgKeyserverSearchTransaction::finish() 0053 { 0054 if (!m_keyLines.isEmpty()) { 0055 Q_EMIT newKey(m_keyLines); 0056 m_keyLines.clear(); 0057 } 0058 } 0059 0060 void 0061 KGpgKeyserverSearchTransaction::setPattern(const QString &pattern) 0062 { 0063 replaceArgument(m_patternPos, pattern); 0064 }