• 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
kgpgtextinterface.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002 Jean-Baptiste Mardelle <bj@altern.org>
3  * Copyright (C) 2007,2008,2009,2010,2011,2012
4  * Rolf Eike Beer <kde@opensource.sf-tec.de>
5  */
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "kgpgtextinterface.h"
17 
18 #include "gpgproc.h"
19 #include "kgpgsettings.h"
20 
21 #include <KLocale>
22 #include <QFile>
23 #include <QString>
24 #include <QStringList>
25 #include <QTextCodec>
26 
27 class KGpgTextInterfacePrivate
28 {
29 public:
30  KGpgTextInterfacePrivate(QObject *parent, const QString &keyID, const QStringList &options);
31 
32  GPGProc * const m_process;
33  int m_step;
34  const QStringList m_gpgopts;
35  KUrl::List m_files;
36 
37  void signFile(const QString &fileName);
38 };
39 
40 static QStringList
41 buildCmdLine(const QString &keyID, const QStringList &options)
42 {
43  return QStringList(QLatin1String("-u")) <<
44  keyID <<
45  options <<
46  QLatin1String("--detach-sign") <<
47  QLatin1String("--output");
48 }
49 
50 KGpgTextInterfacePrivate::KGpgTextInterfacePrivate(QObject *parent, const QString &keyID, const QStringList &options)
51  : m_process(new GPGProc(parent)),
52  m_step(0),
53  m_gpgopts(buildCmdLine(keyID, options))
54 {
55 }
56 
57 void
58 KGpgTextInterfacePrivate::signFile(const QString &fileName)
59 {
60  m_process->resetProcess();
61  *m_process <<
62  m_gpgopts <<
63  fileName + QLatin1String(".sig") <<
64  fileName;
65 
66  m_process->start();
67 }
68 
69 KGpgTextInterface::KGpgTextInterface(QObject *parent, const QString &keyID, const QStringList &options)
70  : QObject(parent),
71  d(new KGpgTextInterfacePrivate(parent, keyID, options))
72 {
73  connect(d->m_process, SIGNAL(processExited()), SLOT(slotSignFile()));
74 }
75 
76 KGpgTextInterface::~KGpgTextInterface()
77 {
78  delete d->m_process;
79  delete d;
80 }
81 
82 // signatures
83 void
84 KGpgTextInterface::signFiles(const KUrl::List &srcUrls)
85 {
86  d->m_files = srcUrls;
87 
88  slotSignFile();
89 }
90 
91 void
92 KGpgTextInterface::slotSignFile()
93 {
94  const QString fileName = d->m_files.takeFirst().path();
95 
96  if (d->m_files.isEmpty()) {
97  disconnect(d->m_process, SIGNAL(processExited()), this, SLOT(slotSignFile()));
98  connect(d->m_process, SIGNAL(processExited()), SLOT(slotSignFinished()));
99  }
100 
101  d->signFile(fileName);
102 }
103 
104 void
105 KGpgTextInterface::slotSignFinished()
106 {
107  emit fileSignFinished();
108 }
109 
110 #include "kgpgtextinterface.moc"
GPGProc
A interface to GnuPG handling UTF8 recoding correctly.
Definition: gpgproc.h:36
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
KGpgTextInterface::signFiles
void signFiles(const KUrl::List &srcUrl)
Sign file function.
Definition: kgpgtextinterface.cpp:84
buildCmdLine
static QStringList buildCmdLine(const QString &keyID, const QStringList &options)
Definition: kgpgtextinterface.cpp:41
QObject
gpgproc.h
QString
KGpgTextInterface::fileSignFinished
void fileSignFinished()
Emitted when all files passed to KgpgSignFile() where processed.
QStringList
KGpgTextInterface::~KGpgTextInterface
~KGpgTextInterface()
Definition: kgpgtextinterface.cpp:76
kgpgsettings.h
QLatin1String
kgpgtextinterface.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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