Commit 173e39c1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove it

parent dba07d5e
#project(grantleefilters)
set(grantlee_messageheaderfilters_SRCS
messageheadergrantleefilters.cpp
messageheaderfilter.cpp
)
ecm_qt_declare_logging_category(grantlee_messageheaderfilters_SRCS HEADER grantlee_messageheaderfilter_debug.h IDENTIFIER GRANTLEEMESSAGEVIEWERFILTER_LOG CATEGORY_NAME log_grantlee_messageviewerheader)
add_library(grantlee_messageheaderfilters MODULE ${grantlee_messageheaderfilters_SRCS})
GRANTLEE_ADJUST_PLUGIN_NAME(grantlee_messageheaderfilters)
target_link_libraries(grantlee_messageheaderfilters KF5::MessageCore Grantlee5::TextDocument Grantlee5::Templates)
install(TARGETS grantlee_messageheaderfilters LIBRARY DESTINATION ${KDE_INSTALL_QTPLUGINDIR}/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR} )
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "messageheaderfilter.h"
#include <kmime/kmime_headers.h>
#include <MessageCore/StringUtil>
#include <grantlee/util.h>
#include "grantlee_messageheaderfilter_debug.h"
QVariant MessageHeaderEmailShowLink::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
{
Q_UNUSED(autoescape);
Q_UNUSED(argument);
const auto mailboxes = KMime::Types::Mailbox::listFromUnicodeString(Grantlee::getSafeString(input));
return MessageCore::StringUtil::emailAddrAsAnchor(mailboxes, MessageCore::StringUtil::DisplayFullAddress, QString(), MessageCore::StringUtil::ShowLink);
}
bool MessageHeaderEmailShowLink::isSafe() const
{
return true;
}
QVariant MessageHeaderEmailNameOnly::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
{
Q_UNUSED(autoescape);
Q_UNUSED(argument);
const auto mailboxes = KMime::Types::Mailbox::listFromUnicodeString(Grantlee::getSafeString(input));
return MessageCore::StringUtil::emailAddrAsAnchor(mailboxes, MessageCore::StringUtil::DisplayNameOnly);
}
bool MessageHeaderEmailNameOnly::isSafe() const
{
return true;
}
QVariant MessageHeaderEmailExpandable::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
{
Q_UNUSED(autoescape);
Q_UNUSED(argument);
if (input.value<KMime::Headers::Cc *>()) {
const QVariant val = MessageCore::StringUtil::emailAddrAsAnchor(input.value<KMime::Headers::Cc *>(), MessageCore::StringUtil::DisplayFullAddress, QString(), MessageCore::StringUtil::ShowLink,
MessageCore::StringUtil::ExpandableAddresses, QStringLiteral("FullToAddressList"));
return val;
} else if (input.value<KMime::Headers::To *>()) {
const QVariant val = MessageCore::StringUtil::emailAddrAsAnchor(input.value<KMime::Headers::To *>(), MessageCore::StringUtil::DisplayFullAddress, QString(), MessageCore::StringUtil::ShowLink,
MessageCore::StringUtil::ExpandableAddresses, QStringLiteral("FullToAddressList"));
return val;
} else if (input.value<KMime::Headers::Bcc *>()) {
const QVariant val = MessageCore::StringUtil::emailAddrAsAnchor(input.value<KMime::Headers::Bcc *>(), MessageCore::StringUtil::DisplayFullAddress, QString(), MessageCore::StringUtil::ShowLink,
MessageCore::StringUtil::ExpandableAddresses, QStringLiteral("FullToAddressList"));
return val;
} else {
qCDebug(GRANTLEEMESSAGEVIEWERFILTER_LOG) << " invalid pointer";
}
return QVariant();
}
bool MessageHeaderEmailExpandable::isSafe() const
{
return true;
}
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MESSAGEHEADERFILTER_H
#define MESSAGEHEADERFILTER_H
#include <QObject>
#include <grantlee/filter.h>
class MessageHeaderEmailShowLink : public Grantlee::Filter
{
public:
QVariant doFilter(const QVariant &input, const QVariant &argument = QVariant(), bool autoescape = false) const Q_DECL_OVERRIDE;
bool isSafe() const Q_DECL_OVERRIDE;
};
class MessageHeaderEmailNameOnly : public Grantlee::Filter
{
public:
QVariant doFilter(const QVariant &input, const QVariant &argument = QVariant(), bool autoescape = false) const Q_DECL_OVERRIDE;
bool isSafe() const Q_DECL_OVERRIDE;
};
class MessageHeaderEmailExpandable : public Grantlee::Filter
{
public:
QVariant doFilter(const QVariant &input, const QVariant &argument = QVariant(), bool autoescape = false) const Q_DECL_OVERRIDE;
bool isSafe() const Q_DECL_OVERRIDE;
};
#endif // MESSAGEHEADERFILTER_H
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "messageheadergrantleefilters.h"
#include "messageheaderfilter.h"
MessageHeaderGrantleeFilters::MessageHeaderGrantleeFilters(QObject *parent)
: QObject(parent)
{
}
MessageHeaderGrantleeFilters::~MessageHeaderGrantleeFilters()
{
}
QHash<QString, Grantlee::Filter *> MessageHeaderGrantleeFilters::filters(const QString &name)
{
Q_UNUSED(name);
QHash<QString, Grantlee::Filter *> filters;
filters.insert(QStringLiteral("showlink"), new MessageHeaderEmailShowLink());
filters.insert(QStringLiteral("nameonly"), new MessageHeaderEmailNameOnly());
filters.insert(QStringLiteral("expandable"), new MessageHeaderEmailExpandable());
return filters;
}
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MESSAGEHEADERGRANTLEEFILTERS_H
#define MESSAGEHEADERGRANTLEEFILTERS_H
#include <QObject>
#include <grantlee/taglibraryinterface.h>
/**
* The grantlee's plugin to define filters
*/
class MessageHeaderGrantleeFilters : public QObject, public Grantlee::TagLibraryInterface
{
Q_OBJECT
Q_INTERFACES(Grantlee::TagLibraryInterface)
Q_PLUGIN_METADATA(IID "org.grantlee.TagLibraryInterface")
public:
explicit MessageHeaderGrantleeFilters(QObject *parent = Q_NULLPTR);
~MessageHeaderGrantleeFilters();
QHash<QString, Grantlee::Filter *> filters(const QString &name = QString()) Q_DECL_OVERRIDE;
};
#endif // MESSAGEHEADERGRANTLEEFILTERS_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment