Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34109796
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
4 KB
Subscribers
None
View Options
diff --git a/src/kleo/auditlogentry.cpp b/src/kleo/auditlogentry.cpp
index 9ad1d86c..5eaf7f68 100644
--- a/src/kleo/auditlogentry.cpp
+++ b/src/kleo/auditlogentry.cpp
@@ -1,109 +1,117 @@
/* -*- mode: c++; c-basic-offset:4 -*-
kleo/auditlogentry.cpp
This file is part of libkleopatra, the KDE keymanagement library
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-libkleo.h>
#include "auditlogentry.h"
#include <libkleo_debug.h>
#include <QGpgME/Job>
#include <QUrl>
#include <QUrlQuery>
#include <gpgme++/error.h>
using namespace Kleo;
class AuditLogEntry::Private
{
public:
QString text;
GpgME::Error error;
};
AuditLogEntry::AuditLogEntry()
: AuditLogEntry{QString{}, GpgME::Error{}}
{
}
AuditLogEntry::AuditLogEntry(const GpgME::Error &error)
: AuditLogEntry{QString{}, error}
{
}
AuditLogEntry::AuditLogEntry(const QString &text, const GpgME::Error &error)
: d{new Private{text, error}}
{
}
AuditLogEntry::~AuditLogEntry() = default;
AuditLogEntry::AuditLogEntry(const AuditLogEntry &other)
: d{new Private{*other.d}}
{
}
AuditLogEntry &AuditLogEntry::operator=(const AuditLogEntry &other)
{
*d = *other.d;
return *this;
}
AuditLogEntry::AuditLogEntry(AuditLogEntry &&other) = default;
AuditLogEntry &AuditLogEntry::operator=(AuditLogEntry &&other) = default;
AuditLogEntry AuditLogEntry::fromJob(const QGpgME::Job *job)
{
if (job) {
return AuditLogEntry{job->auditLogAsHtml(), job->auditLogError()};
} else {
return AuditLogEntry{};
}
}
GpgME::Error AuditLogEntry::error() const
{
return d->error;
}
QString AuditLogEntry::text() const
{
return d->text;
}
QUrl AuditLogEntry::asUrl(const QUrl &urlTemplate) const
{
// more or less the same as
// kmail/objecttreeparser.cpp:makeShowAuditLogLink(), so any bug
// fixed here equally applies there:
if (const int code = d->error.code()) {
if (code == GPG_ERR_NOT_IMPLEMENTED) {
qCDebug(LIBKLEO_LOG) << "not showing link (not implemented)";
} else if (code == GPG_ERR_NO_DATA) {
qCDebug(LIBKLEO_LOG) << "not showing link (not available)";
} else {
qCDebug(LIBKLEO_LOG) << "Error Retrieving Audit Log:" << QString::fromLocal8Bit(d->error.asString());
}
return {};
}
if (d->text.isEmpty()) {
return {};
}
QUrl url = urlTemplate;
QUrlQuery urlQuery{url};
urlQuery.addQueryItem(QStringLiteral("log"), d->text);
url.setQuery(urlQuery);
return url;
}
+
+QDebug operator<<(QDebug debug, const AuditLogEntry &auditLog)
+{
+ const bool oldSetting = debug.autoInsertSpaces();
+ debug.nospace() << "AuditLogEntry(" << auditLog.error().asString() << ", " << auditLog.text() << ')';
+ debug.setAutoInsertSpaces(oldSetting);
+ return debug.maybeSpace();
+}
diff --git a/src/kleo/auditlogentry.h b/src/kleo/auditlogentry.h
index 3a8df3bf..830e3cb6 100644
--- a/src/kleo/auditlogentry.h
+++ b/src/kleo/auditlogentry.h
@@ -1,60 +1,62 @@
/* -*- mode: c++; c-basic-offset:4 -*-
kleo/auditlogentry.h
This file is part of libkleopatra, the KDE keymanagement library
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "kleo_export.h"
#include <memory>
class QDebug;
class QString;
class QUrl;
namespace GpgME
{
class Error;
}
namespace QGpgME
{
class Job;
}
namespace Kleo
{
class KLEO_EXPORT AuditLogEntry
{
public:
AuditLogEntry();
explicit AuditLogEntry(const GpgME::Error &error);
AuditLogEntry(const QString &text, const GpgME::Error &error);
~AuditLogEntry();
AuditLogEntry(const AuditLogEntry &other);
AuditLogEntry &operator=(const AuditLogEntry &other);
AuditLogEntry(AuditLogEntry &&other);
AuditLogEntry &operator=(AuditLogEntry &&other);
static AuditLogEntry fromJob(const QGpgME::Job *);
GpgME::Error error() const;
QString text() const;
QUrl asUrl(const QUrl &urlTemplate) const;
private:
class Private;
std::unique_ptr<Private> d;
};
}
+
+KLEO_EXPORT QDebug operator<<(QDebug debug, const Kleo::AuditLogEntry &auditLog);
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Dec 5, 4:59 AM (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
3f/bb/d6499a4d792383abbf599c51b424
Attached To
rLIBKLEO Libkleo
Event Timeline
Log In to Comment