Commit 2501d112 authored by Carl Schwan's avatar Carl Schwan 🚴 Committed by Claudio Cambra
Browse files

Add tests to cmake files and fix some reuse issues



Signed-off-by: Carl Schwan's avatarCarl Schwan <carl@carlschwan.eu>
parent 33eee8ca
......@@ -18,6 +18,8 @@ Dependencies:
'pim/kmime' : '@same'
'pim/eventviews' : '@same'
'pim/kdepim-runtime' : '@same'
'pim/mailcommon' : '@same'
'pim/pimcommon' : '@same'
'frameworks/kirigami' : '@latest'
Options:
......
......@@ -13,3 +13,7 @@ License: GPL-3.0-or-later
Files: src/contacts/qml/qmldir
Copyright: Carl Schwan <carl@carlschwan.eu>
License: CC0-1.0
Files: mimetreeparser/autotests/data/* src/mail/mimetreeparser/tests/gnupg_home/* src/mail/mime/testdata/* src/mail/mimetreeparser/testdata/*
Copyright: none
License: CC0-1.0
......@@ -22,7 +22,11 @@ include(FeatureSummary)
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${ECM_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
)
include(KDEInstallDirs)
include(KDECMakeSettings)
......@@ -51,6 +55,7 @@ ecm_setup_version(${PROJECT_VERSION}
################# Find dependencies #################
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg DBus Test QuickTest WebEngineWidgets)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 DBusAddons I18n CalendarCore ConfigWidgets WindowSystem CoreAddons QQC2DesktopStyle Contacts ItemModels XmlGui IconThemes)
find_package(Gpgme REQUIRED)
set_package_properties(KF5QQC2DesktopStyle PROPERTIES
TYPE RUNTIME
)
......
# SPDX-FileCopyrightText: 2013 Sandro Knauß <mail@sandroknauss.de>
# SPDX-License-Identifier: BSD-3-Clause
find_path(GPGME_INCLUDE_DIR NAMES gpgme.h)
find_path(GPGERROR_INCLUDE_DIR NAMES gpg-error.h)
find_library(GPGME_LIBRARY NAMES gpgme)
find_library(GPGERROR_LIBRARY NAMES gpg-error)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Gpgme DEFAULT_MSG GPGME_INCLUDE_DIR GPGERROR_INCLUDE_DIR GPGME_LIBRARY GPGERROR_LIBRARY)
mark_as_advanced(GPGME_INCLUDE_DIR GPGME_LIBRARY GPGME_INCLUDE_DIR GPGME_LIBRARY)
set(GPGME_LIBRARIES ${GPGME_LIBRARY} ${GPGERROR_LIBRARY})
set(GPGME_INCLUDE_DIRS ${GPGME_INCLUDE_DIR} ${GPGERROR_INCLUDE_DIR})
if (GPGME_FOUND AND NOT TARGET Gpgme::Gpgme)
add_library(Gpgme::Gpgme INTERFACE IMPORTED)
set_target_properties(Gpgme::Gpgme PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GPGME_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${GPGME_LIBRARIES}"
)
endif()
# SPDX-FileCopyrightText: 2013 Sandro Knauß <mail@sandroknauss.de>
# SPDX-License-Identifier: BSD-3-Clause
set( MIMETREEPARSERRELPATH src/mail/mimetreeparser)
set( GNUPGHOME ${CMAKE_BINARY_DIR}/${MIMETREEPARSERRELPATH}/tests/gnupg_home )
add_definitions( -DGNUPGHOME="${GNUPGHOME}" )
macro (ADD_GPG_CRYPTO_TEST _target _testname)
if (UNIX)
if (APPLE)
set(_library_path_variable "DYLD_LIBRARY_PATH")
elseif (CYGWIN)
set(_library_path_variable "PATH")
else (APPLE)
set(_library_path_variable "LD_LIBRARY_PATH")
endif (APPLE)
if (APPLE)
# DYLD_LIBRARY_PATH does not work like LD_LIBRARY_PATH
# OSX already has the RPATH in libraries and executables, putting runtime directories in
# DYLD_LIBRARY_PATH actually breaks things
set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/")
else (APPLE)
set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/:${LIB_INSTALL_DIR}:${QT_LIBRARY_DIR}")
endif (APPLE)
set(_executable "$<TARGET_FILE:${_target}>")
# use add_custom_target() to have the sh-wrapper generated during build time instead of cmake time
add_custom_command(TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND}
-D_filename=${_executable}.shell -D_library_path_variable=${_library_path_variable}
-D_ld_library_path="${_ld_library_path}" -D_executable=${_executable}
-D_gnupghome="${GNUPGHOME}"
-P ${CMAKE_SOURCE_DIR}/cmake/modules/generate_crypto_test_wrapper.cmake
)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_executable}.shell" )
add_test(NAME ${_testname} COMMAND ${_executable}.shell)
else (UNIX)
# under windows, set the property WRAPPER_SCRIPT just to the name of the executable
# maybe later this will change to a generated batch file (for setting the PATH so that the Qt libs are found)
set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\;${LIB_INSTALL_DIR}\;${QT_LIBRARY_DIR}")
set(_executable "$<TARGET_FILE:${_target}>")
# use add_custom_target() to have the batch-file-wrapper generated during build time instead of cmake time
add_custom_command(TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND}
-D_filename="${_executable}.bat"
-D_ld_library_path="${_ld_library_path}" -D_executable="${_executable}"
-D_gnupghome="${GNUPGHOME}"
-P ${CMAKE_SOURCE_DIR}/cmake/modules/generate_crypto_test_wrapper.cmake
)
add_test(NAME ${_testname} COMMAND ${_executable}.bat)
endif (UNIX)
endmacro (ADD_GPG_CRYPTO_TEST)
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2013, Sandro Knauß <mail@sandroknauss.de>
# Copyright (c) 2018, Christian Mollekopf <mollekopf@kolabsys.com>
#
# SPDX-License-Identifier: BSD-3-Clause
if (UNIX)
file(WRITE "${_filename}"
"#!/usr/bin/env sh
# created by cmake, don't edit, changes will be lost
# don't mess with a gpg-agent already running on the system
unset GPG_AGENT_INFO
${_library_path_variable}=${_ld_library_path}\${${_library_path_variable}:+:\$${_library_path_variable}} GNUPGHOME=${_gnupghome} gpg-agent --daemon \"${_executable}\" \"$@\"
_result=$?
GNUPGHOME=${_gnupghome} gpg-connect-agent killagent /bye
exit \$_result
")
# make it executable
# since this is only executed on UNIX, it is safe to call chmod
exec_program(chmod ARGS ug+x \"${_filename}\" OUTPUT_VARIABLE _dummy )
else (UNIX)
file(TO_NATIVE_PATH "${_ld_library_path}" win_path)
file(TO_NATIVE_PATH "${_gnupghome}" win_gnupghome)
file(WRITE "${_filename}"
"
set PATH=${win_path};$ENV{PATH}
set GNUPGHOME=${win_gnupghome};$ENV{GNUPGHOME}
gpg-agent --daemon \"${_executable}\" %*
")
endif (UNIX)
......@@ -176,7 +176,7 @@ void KalendarApplication::setupActions()
if (KAuthorized::authorizeAction(actionName)) {
auto mailAction = mCollection.addAction(actionName, this, &KalendarApplication::openMailView);
mailAction->setText(i18n("Mail View"));
mailAction->setIcon(QIcon::fromTheme(QStringLiteral("gnumeric-link-email")));
mailAction->setIcon(QIcon::fromTheme(QStringLiteral("mail-message")));
mailAction->setCheckable(true);
mailAction->setActionGroup(m_viewGroup);
connect(mailAction, &QAction::toggled, this, [](bool checked) {
......
......@@ -3,7 +3,7 @@
ecm_add_qml_module(kalendar_mail_plugin URI "org.kde.kalendar.mail" VERSION 1.0)
target_sources(kalendar_mail_plugin PRIVATE
target_sources(kalendar_mail_plugin PUBLIC
mailplugin.cpp
mailplugin.h
mailmanager.cpp
......@@ -70,9 +70,11 @@ ecm_qt_install_logging_categories(
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
)
#if (BUILD_TESTING)
# add_subdirectory(autotests)
#endif()
if (BUILD_TESTING)
add_subdirectory(mime/tests)
add_subdirectory(mimetreeparser/autotests)
add_subdirectory(mimetreeparser/tests)
endif()
ecm_finalize_qml_module(kalendar_mail_plugin
DESTINATION ${KDE_INSTALL_QMLDIR}
......
/*
Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Copyright (c) 2010 Leo Franchi <lfranchi@kde.org>
Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
// SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
// SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
// SPDX-FileCopyrightText: 2010 Leo Franchi <lfranchi@kde.org>
// SPDX-FileCopyrightText: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "crypto.h"
#include "errors.h"
......
/*
Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
// SPDX-FileCopyrightText: 2016 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
......
/*
Copyright (c) 2018 Christian Mollekopf <mollekopf@kolabsys.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
// SPDX-FileCopyrightText: 2018 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include <memory>
......
......@@ -7,19 +7,19 @@
#include <QTimer>
// Akonadi
#include <Akonadi/ChangeRecorder>
#include <Akonadi/CollectionFilterProxyModel>
#include <Akonadi/EntityMimeTypeFilterModel>
#include <Akonadi/EntityTreeModel>
#include <Akonadi/ItemFetchScope>
#include <Akonadi/MessageModel>
#include <Akonadi/Monitor>
#include <Akonadi/Session>
#include <Akonadi/ChangeRecorder>
#include <MailCommon/FolderCollectionMonitor>
#include <KMime/Message>
#include <KDescendantsProxyModel>
#include <Akonadi/EntityMimeTypeFilterModel>
#include <Akonadi/EntityTreeModel>
#include <Akonadi/SelectionProxyModel>
#include <Akonadi/ServerManager>
#include <Akonadi/Session>
#include <KDescendantsProxyModel>
#include <KMime/Message>
#include <MailCommon/FolderCollectionMonitor>
#include <QApplication>
#include <QtCore/QItemSelectionModel>
......@@ -29,7 +29,6 @@ MailManager::MailManager(QObject *parent)
: QObject(parent)
, m_loading(true)
{
using namespace Akonadi;
// mailModel
// ^
......@@ -93,20 +92,19 @@ MailManager::MailManager(QObject *parent)
if (Akonadi::ServerManager::isRunning()) {
m_loading = false;
} else {
connect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged,
this, [this](Akonadi::ServerManager::State state) {
if (state == Akonadi::ServerManager::State::Broken) {
qApp->exit(-1);
return;
}
bool loading = state != Akonadi::ServerManager::State::Running;
if (loading == m_loading) {
return;
}
m_loading = loading;
Q_EMIT loadingChanged();
disconnect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged, this, nullptr);
});
connect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged, this, [this](Akonadi::ServerManager::State state) {
if (state == Akonadi::ServerManager::State::Broken) {
qApp->exit(-1);
return;
}
bool loading = state != Akonadi::ServerManager::State::Running;
if (loading == m_loading) {
return;
}
m_loading = loading;
Q_EMIT loadingChanged();
disconnect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged, this, nullptr);
});
}
Q_EMIT folderModelChanged();
Q_EMIT loadingChanged();
......
......@@ -3,10 +3,11 @@
#include <QObject>
namespace Akonadi {
class CollectionFilterProxyModel;
class EntityMimeTypeFilterModel;
class Session;
namespace Akonadi
{
class CollectionFilterProxyModel;
class EntityMimeTypeFilterModel;
class Session;
}
class QAbstractListModel;
......@@ -45,9 +46,8 @@ private:
Akonadi::Session *m_session;
Akonadi::CollectionFilterProxyModel *m_foldersModel;
//folders
// folders
QItemSelectionModel *m_collectionSelectionModel;
MailModel *m_folderModel;
QString m_selectedFolderName;
};
......@@ -42,7 +42,7 @@ QVariant MailModel::data(const QModelIndex &index, int role) const
Akonadi::Item item = itemVariant.value<Akonadi::Item>();
if (!item.hasPayload<KMime::Message::Ptr>()) {
return {};
return {};
}
const KMime::Message::Ptr mail = item.payload<KMime::Message::Ptr>();
......
......@@ -30,5 +30,5 @@ void CalendarPlugin::registerTypes(const char *uri)
qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser");
qRegisterMetaType<MailModel*>("MailModel*");
qRegisterMetaType<MailModel *>("MailModel*");
}
include_directories(${GPGME_INCLUDE_DIRS})
add_library(mailcrypto STATIC
mailcrypto.cpp
)
target_link_libraries(mailcrypto
PUBLIC
Qt5::Core
KF5::Mime
Gpgme::Gpgme
sink
)
/*
Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-FileCopyrightText: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#pragma once
#include <QFuture>
......
/*
Copyright (c) 2016 Sandro Knauß <knauss@kolabsys.com>
Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
// SPDX-FileCopyrightText: 2016 Sandro Knauß <knauss@kolabsys.com>
// SPDX-FileCopyCopyright: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "attachmentmodel.h"
......
/*
Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
// SPDX-FileCopyrightText: 2016 Sandro Knauß <knauss@kolabsys.com>
// SPDX-FileCopyCopyright: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include <QObject>
......
/*
Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-FileCopyrightText: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "htmlutils.h"
#include <QMap>
......
Supports Markdown
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