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

libkleo

  • sources
  • kde-4.14
  • kdepim
  • libkleo
  • backends
  • qgpgme
threadedjobmixin.cpp
Go to the documentation of this file.
1 /*
2  threadedjobmixin.cpp
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2008 Klarälvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include "threadedjobmixin.h"
34 
35 #include <qgpgme/dataprovider.h>
36 
37 #include <gpgme++/data.h>
38 
39 #include <QString>
40 #include <QStringList>
41 #include <QByteArray>
42 
43 #ifndef Q_MOC_RUN
44 #include <boost/mem_fn.hpp>
45 #endif
46 
47 #include <algorithm>
48 #include <iterator>
49 
50 using namespace Kleo;
51 using namespace GpgME;
52 using namespace boost;
53 
54 static const unsigned int GetAuditLogFlags = Context::AuditLogWithHelp|Context::HtmlAuditLog;
55 
56 QString _detail::audit_log_as_html( Context * ctx, GpgME::Error & err ) {
57  assert( ctx );
58  QGpgME::QByteArrayDataProvider dp;
59  Data data( &dp );
60  assert( !data.isNull() );
61  if ( ( err = ctx->lastError() ) || ( err = ctx->getAuditLog( data, GetAuditLogFlags ) ) )
62  return QString::fromLocal8Bit( err.asString() );
63  const QByteArray ba = dp.data();
64  return QString::fromUtf8( ba.data(), ba.size() );
65 }
66 
67 static QList<QByteArray> from_sl( const QStringList & sl ) {
68  QList<QByteArray> result;
69  std::transform( sl.begin(), sl.end(), std::back_inserter( result ),
70  mem_fn( &QString::toUtf8 ) );
71  return result;
72 }
73 
74 static QList<QByteArray> single( const QByteArray & ba ) {
75  QList<QByteArray> result;
76  result.push_back( ba );
77  return result;
78 }
79 
80 _detail::PatternConverter::PatternConverter( const QByteArray & ba )
81  : m_list( single( ba ) ), m_patterns( 0 ) {}
82 _detail::PatternConverter::PatternConverter( const QString & s )
83  : m_list( single( s.toUtf8() ) ), m_patterns( 0 ) {}
84 _detail::PatternConverter::PatternConverter( const QList<QByteArray> & lba )
85  : m_list( lba ), m_patterns( 0 ) {}
86 _detail::PatternConverter::PatternConverter( const QStringList & sl )
87  : m_list( from_sl( sl ) ), m_patterns( 0 ) {}
88 
89 const char ** _detail::PatternConverter::patterns() const {
90  if ( !m_patterns ) {
91  m_patterns = new const char*[ m_list.size() + 1 ];
92  const char ** end = std::transform( m_list.begin(), m_list.end(), m_patterns,
93  mem_fn( &QByteArray::constData ) );
94  *end = 0;
95  }
96  return m_patterns;
97 }
98 
99 _detail::PatternConverter::~PatternConverter() {
100  delete [] m_patterns;
101 }
QList::push_back
void push_back(const T &value)
QByteArray
single
static QList< QByteArray > single(const QByteArray &ba)
Definition: threadedjobmixin.cpp:74
threadedjobmixin.h
from_sl
static QList< QByteArray > from_sl(const QStringList &sl)
Definition: threadedjobmixin.cpp:67
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
Kleo::_detail::audit_log_as_html
QString audit_log_as_html(GpgME::Context *ctx, GpgME::Error &err)
Kleo::_detail::PatternConverter::patterns
const char ** patterns() const
Definition: threadedjobmixin.cpp:89
QByteArray::constData
const char * constData() const
kdtools::transform
O transform(const I &i, P p)
Definition: stl_util.h:376
Kleo::_detail::PatternConverter::PatternConverter
PatternConverter(const QByteArray &ba)
Definition: threadedjobmixin.cpp:80
QString
QList< QByteArray >
Kleo::_detail::PatternConverter::~PatternConverter
~PatternConverter()
Definition: threadedjobmixin.cpp:99
QStringList
QList::end
iterator end()
QByteArray::data
char * data()
GetAuditLogFlags
static const unsigned int GetAuditLogFlags
Definition: threadedjobmixin.cpp:54
QList::begin
iterator begin()
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkleo

Skip menu "libkleo"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

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