Verified Commit a9066751 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Don't link against QWidgets anymore (still WIP)

parent 8aee8800
......@@ -3,31 +3,31 @@
add_subdirectory(packagestructure)
set(accountwizard_srcs
cryptopage.cpp
dialog.cpp
#cryptopage.cpp
#dialog.cpp
wizardmodel.cpp
controller.cpp
typepage.cpp
loadpage.cpp
global.cpp
page.cpp
#typepage.cpp
#loadpage.cpp
#global.cpp
#page.cpp
key.cpp
dynamicpage.cpp
#dynamicpage.cpp
setupmanager.cpp
setuppage.cpp
#setuppage.cpp
resource.cpp
setupobject.cpp
transport.cpp
configfile.cpp
ldap.cpp
restoreldapsettingsjob.cpp
identity.cpp
setupispdb.cpp
ispdbhelper.cpp
setupobject.cpp
setupautoconfigkolabmail.cpp
setupautoconfigkolabldap.cpp
setupautoconfigkolabfreebusy.cpp
servertest.cpp
personaldatapage.cpp
#personaldatapage.cpp
ispdb/ispdb.cpp
ispdb/autoconfigkolabmail.cpp
ispdb/autoconfigkolabldap.cpp
......@@ -35,14 +35,6 @@ set(accountwizard_srcs
resources.qrc
)
ki18n_wrap_ui(accountwizard_srcs
ui/typepage.ui
ui/loadpage.ui
ui/setuppage.ui
ui/personaldatapage.ui
ui/cryptopage.ui
)
ecm_qt_declare_logging_category(accountwizard_srcs HEADER accountwizard_debug.h IDENTIFIER ACCOUNTWIZARD_LOG CATEGORY_NAME org.kde.pim.accountwizard
OLD_CATEGORY_NAMES log_accountwizard
DESCRIPTION "accountwizard (accountwizard)" EXPORT ACCOUNTWIZARD)
......@@ -52,7 +44,6 @@ set(accountwizard_libs
KF5::AkonadiCore
KF5::MailTransportAkonadi
KF5::KCMUtils
KF5::KrossCore
KF5::KIOCore
KF5::Mime
KF5::IdentityManagement
......@@ -62,7 +53,6 @@ set(accountwizard_libs
KF5::ItemViews
KF5::I18n
KF5::Ldap
KF5::AkonadiWidgets
KF5::Crash
KF5::Libkleo
KF5::Notifications
......@@ -73,11 +63,11 @@ set(accountwizard_libs
Qt5::QuickControls2
)
if ( NOT ACCOUNTWIZARD_NO_GHNS )
set(accountwizard_srcs ${accountwizard_srcs} providerpage.cpp)
ki18n_wrap_ui(accountwizard_srcs ui/providerpage.ui)
set(accountwizard_libs ${accountwizard_libs} KF5::NewStuff)
endif ()
#if ( NOT ACCOUNTWIZARD_NO_GHNS )
# set(accountwizard_srcs ${accountwizard_srcs} providerpage.cpp)
# #ki18n_wrap_ui(accountwizard_srcs ui/providerpage.ui)
# set(accountwizard_libs ${accountwizard_libs} KF5::NewStuff)
#endif ()
add_executable(accountwizard ${accountwizard_srcs} main.cpp)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
......@@ -86,18 +76,18 @@ endif()
target_link_libraries(accountwizard ${accountwizard_libs} KF5::DBusAddons)
add_library(accountwizard_plugin MODULE ${accountwizard_srcs} inprocess-main.cpp)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
set_target_properties(accountwizard_plugin PROPERTIES UNITY_BUILD ON)
endif()
#add_library(accountwizard_plugin MODULE ${accountwizard_srcs} inprocess-main.cpp)
#if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
# set_target_properties(accountwizard_plugin PROPERTIES UNITY_BUILD ON)
#endif()
target_link_libraries(accountwizard_plugin ${accountwizard_libs})
#target_link_libraries(accountwizard_plugin ${accountwizard_libs})
if ( NOT ACCOUNTWIZARD_NO_GHNS )
install(FILES accountwizard.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR})
endif ()
install(TARGETS accountwizard ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS accountwizard_plugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
#install(TARGETS accountwizard_plugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(PROGRAMS org.kde.accountwizard.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES accountwizard-mime.xml DESTINATION ${KDE_INSTALL_MIMEDIR})
update_xdg_mimetypes(${KDE_INSTALL_MIMEDIR})
......
......@@ -24,16 +24,35 @@ Ispdb::~Ispdb()
{
}
QString Ispdb::email() const
{
return mEmail;
}
void Ispdb::setEmail(const QString &address)
{
if (mEmail == address) {
return;
}
mEmail = address;
KMime::Types::Mailbox box;
box.fromUnicodeString(address);
mAddr = box.addrSpec();
Q_EMIT emailChanged();
}
QString Ispdb::password() const
{
return mPassword;
}
void Ispdb::setPassword(const QString &password)
{
if (mPassword == password) {
return;
}
mPassword = password;
Q_EMIT passwordChanged();
}
void Ispdb::start()
......
......@@ -30,8 +30,11 @@ struct identity;
class Ispdb : public QObject
{
Q_OBJECT
Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
public:
enum socketType { None = 0, SSL, StartTLS };
Q_ENUM(socketType);
/**
Ispdb uses custom authtyps, hence the enum here.
......@@ -40,7 +43,9 @@ public:
We will always treat it as Cleartext
*/
enum authType { Plain = 0, CramMD5, NTLM, GSSAPI, ClientIP, NoAuth, Basic, OAuth2 };
Q_ENUM(authType);
enum length { Long = 0, Short };
Q_ENUM(length);
/** Constructor */
explicit Ispdb(QObject *parent = nullptr);
......@@ -48,37 +53,40 @@ public:
/** Destructor */
~Ispdb();
QString email() const;
QString password() const;
/** After finished() has been emitted you can
retrieve the domains that are covered by these
settings */
QStringList relevantDomains() const;
Q_INVOKABLE QStringList relevantDomains() const;
/** After finished() has been emitted you can
get the name of the provider, you can get a long
name and a short one */
QString name(length) const;
Q_INVOKABLE QString name(length) const;
/** After finished() has been emitted you can
get a list of imap servers available for this provider */
QVector<Server> imapServers() const;
Q_INVOKABLE QVector<Server> imapServers() const;
/** After finished() has been emitted you can
get a list of pop3 servers available for this provider */
QVector<Server> pop3Servers() const;
Q_INVOKABLE QVector<Server> pop3Servers() const;
/** After finished() has been emitted you can
get a list of smtp servers available for this provider */
QVector<Server> smtpServers() const;
Q_INVOKABLE QVector<Server> smtpServers() const;
Q_INVOKABLE QVector<identity> identities() const;
QVector<identity> identities() const;
Q_INVOKABLE int defaultIdentity() const;
int defaultIdentity() const;
public Q_SLOTS:
/** Sets the emailaddress you want to servers for */
void setEmail(const QString &);
void setEmail(const QString &email);
/** Sets the password for login */
void setPassword(const QString &);
void setPassword(const QString &password);
/** Starts looking up the servers which belong to the e-mailaddress */
void start();
......@@ -87,8 +95,10 @@ private:
Q_SIGNALS:
/** emitted when done. **/
void finished(bool);
void finished(bool ok);
void searchType(const QString &type);
void emailChanged();
void passwordChanged();
protected:
/** search types, where to search for autoconfig
......@@ -146,6 +156,7 @@ protected Q_SLOTS:
private:
KMime::Types::AddrSpec mAddr; // emailaddress
QString mPassword;
QString mEmail;
// storage of the results
QStringList mDomains;
......@@ -162,6 +173,10 @@ private:
};
struct Server {
Q_GADGET
Q_PROPERTY(QString hostname MEMBER hostname)
Q_PROPERTY(QString username MEMBER username)
public:
Server()
{
}
......
/*
SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
// SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "setupispdb.h"
#include "ispdbhelper.h"
#include "configfile.h"
#include "identity.h"
#include "ispdb/ispdb.h"
......@@ -14,44 +12,50 @@
#include <KLocalizedString>
SetupIspdb::SetupIspdb(QObject *parent)
: SetupObject(parent)
IspdbHelper::IspdbHelper(QObject *parent)
: IspdbHelper(parent, new Ispdb(this))
{
mIspdb = new Ispdb(this);
connect(mIspdb, &Ispdb::finished, this, &SetupIspdb::onIspdbFinished);
}
SetupIspdb::~SetupIspdb()
IspdbHelper::IspdbHelper(QObject *parent, Ispdb *ispdb)
: SetupObject(parent)
, mIspdb(ispdb)
{
delete mIspdb;
connect(mIspdb, &Ispdb::finished, this, &IspdbHelper::onIspdbFinished);
connect(mIspdb, &Ispdb::passwordChanged, this, &IspdbHelper::passwordChanged);
connect(mIspdb, &Ispdb::emailChanged, this, &IspdbHelper::emailChanged);
}
QStringList SetupIspdb::relevantDomains() const
QStringList IspdbHelper::relevantDomains() const
{
return mIspdb->relevantDomains();
}
QString SetupIspdb::name(int l) const
QString IspdbHelper::longName() const
{
return mIspdb->name(static_cast<Ispdb::length>(l));
return mIspdb->name(Ispdb::length::Long);
}
int SetupIspdb::defaultIdentity() const
QString IspdbHelper::shortName() const
{
return mIspdb->name(Ispdb::length::Short);
}
int IspdbHelper::defaultIdentity() const
{
return mIspdb->defaultIdentity();
}
int SetupIspdb::countIdentities() const
int IspdbHelper::countIdentities() const
{
return mIspdb->identities().count();
}
void SetupIspdb::fillIdentity(int i, QObject *o) const
void IspdbHelper::fillIdentity(int i, Identity *id) const
{
// TODO change struct name
identity isp = mIspdb->identities().at(i);
auto *id = qobject_cast<Identity *>(o);
id->setIdentityName(isp.name);
id->setRealName(isp.name);
id->setEmail(isp.email);
......@@ -59,13 +63,10 @@ void SetupIspdb::fillIdentity(int i, QObject *o) const
id->setSignature(isp.signature);
}
void SetupIspdb::fillImapServer(int i, QObject *o) const
void IspdbHelper::fillImapServer(int i, Resource *imapRes) const
{
if (mIspdb->imapServers().isEmpty()) {
return;
}
Q_ASSERT(mIspdb->imapServers().count() > i);
Server isp = mIspdb->imapServers().at(i);
auto *imapRes = qobject_cast<Resource *>(o);
imapRes->setName(isp.hostname);
imapRes->setOption(QStringLiteral("ImapServer"), isp.hostname);
......@@ -81,15 +82,15 @@ void SetupIspdb::fillImapServer(int i, QObject *o) const
}
}
int SetupIspdb::countImapServers() const
int IspdbHelper::countImapServers() const
{
return mIspdb->imapServers().count();
}
void SetupIspdb::fillSmtpServer(int i, QObject *o) const
void IspdbHelper::fillSmtpServer(int i, Transport *smtpRes) const
{
Q_ASSERT(mIspdb->smtpServers().count() > i);
Server isp = mIspdb->smtpServers().at(i);
auto *smtpRes = qobject_cast<Transport *>(o);
smtpRes->setName(isp.hostname);
smtpRes->setHost(isp.hostname);
......@@ -127,36 +128,46 @@ void SetupIspdb::fillSmtpServer(int i, QObject *o) const
}
}
int SetupIspdb::countSmtpServers() const
int IspdbHelper::countSmtpServers() const
{
return mIspdb->smtpServers().count();
}
void SetupIspdb::start()
void IspdbHelper::start()
{
mIspdb->start();
Q_EMIT info(i18n("Searching for autoconfiguration..."));
}
void SetupIspdb::setEmail(const QString &email)
void IspdbHelper::setEmail(const QString &email)
{
mIspdb->setEmail(email);
}
void SetupIspdb::setPassword(const QString &password)
void IspdbHelper::setPassword(const QString &password)
{
mIspdb->setPassword(password);
}
void SetupIspdb::create()
QString IspdbHelper::email() const
{
return mIspdb->email();
}
QString IspdbHelper::password() const
{
return mIspdb->password();
}
void IspdbHelper::create()
{
}
void SetupIspdb::destroy()
void IspdbHelper::destroy()
{
}
void SetupIspdb::onIspdbFinished(bool status)
void IspdbHelper::onIspdbFinished(bool status)
{
Q_EMIT ispdbFinished(status);
if (status) {
......
// SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include "setupobject.h"
class Identity;
class Ispdb;
class Transport;
class Resource;
class IspdbHelper : public SetupObject
{
Q_OBJECT
// Initialize IspdbHelper
Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
// Information fetched from Ispdb
Q_PROPERTY(QString shortName READ shortName NOTIFY ispdbFinished)
Q_PROPERTY(QString longName READ longName NOTIFY ispdbFinished)
Q_PROPERTY(QStringList relevantDomains READ relevantDomains NOTIFY ispdbFinished)
Q_PROPERTY(int countImapServers READ countImapServers NOTIFY ispdbFinished)
Q_PROPERTY(int countSmtpServers READ countSmtpServers NOTIFY ispdbFinished)
Q_PROPERTY(int countIdentities READ countIdentities NOTIFY ispdbFinished)
Q_PROPERTY(int defaultIdentity READ defaultIdentity NOTIFY ispdbFinished)
public:
explicit IspdbHelper(QObject *parent = nullptr);
IspdbHelper(QObject *parent, Ispdb *ispdb);
~IspdbHelper() override = default;
void create() override;
void destroy() override;
QString shortName() const;
QString longName() const;
QString email() const;
void setEmail(const QString &email);
QString password() const;
void setPassword(const QString &password);
QStringList relevantDomains() const;
Q_INVOKABLE void fillImapServer(int i, Resource *transport) const;
int countImapServers() const;
Q_INVOKABLE void fillSmtpServer(int i, Transport *transport) const;
int countSmtpServers() const;
Q_INVOKABLE void fillIdentity(int i, Identity *identity) const;
int countIdentities() const;
int defaultIdentity() const;
Q_INVOKABLE void start();
Q_SIGNALS:
void ispdbFinished(bool);
void emailChanged();
void passwordChanged();
protected Q_SLOTS:
void onIspdbFinished(bool);
protected:
Ispdb *mIspdb;
};
......@@ -38,10 +38,6 @@ Key::Key(QObject *parent)
{
}
Key::~Key()
{
}
void Key::setKey(const GpgME::Key &key)
{
m_key = key;
......
......@@ -30,7 +30,7 @@ public:
enum PublishingMethod { NoPublishing, WKS, PKS };
explicit Key(QObject *parent = nullptr);
~Key() override;
~Key() override = default;
void create() override;
void destroy() override;
......
......@@ -5,7 +5,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "controller.h"
#include "global.h"
#include "ispdb/ispdb.h"
#include "servertest.h"
#include "setupmanager.h"
#include "wizardmodel.h"
......@@ -17,6 +17,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later
#include <KDBusService>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <PimCommon/EmailValidator>
#include <QApplication>
#include <QCommandLineOption>
......@@ -66,30 +67,33 @@ int main(int argc, char **argv)
parser.process(app);
aboutData.processCommandLine(&parser);
if (parser.isSet(QStringLiteral("assistants"))) {
const QStringList lst = Global::assistants();
std::cout << i18n("The following assistants are available:").toLocal8Bit().data() << std::endl;
for (const QString &val : lst) {
std::cout << "\t" << val.toLocal8Bit().constData() << std::endl;
}
return 0;
}
// if (parser.isSet(QStringLiteral("assistants"))) {
// const QStringList lst = Global::assistants();
// std::cout << i18n("The following assistants are available:").toLocal8Bit().data() << std::endl;
// for (const QString &val : lst) {
// std::cout << "\t" << val.toLocal8Bit().constData() << std::endl;
// }
// return 0;
//}
KDBusService service(KDBusService::Unique);
Akonadi::ControlGui::start(nullptr);
const QString packageArgument = parser.value(QStringLiteral("package"));
if (!packageArgument.isEmpty()) {
Global::setAssistant(Global::unpackAssistant(QUrl::fromLocalFile(packageArgument)));
} else {
Global::setAssistant(parser.value(QStringLiteral("assistant")));
if (!Akonadi::Control::start()) {
qApp->exit(-1);
return 1;
}
QString typeValue = parser.value(QStringLiteral("type"));
if (!typeValue.isEmpty()) {
Global::setTypeFilter(typeValue.split(QLatin1Char(',')));
}
// const QString packageArgument = parser.value(QStringLiteral("package"));
// if (!packageArgument.isEmpty()) {
// Global::setAssistant(Global::unpackAssistant(QUrl::fromLocalFile(packageArgument)));
//} else {
// Global::setAssistant(parser.value(QStringLiteral("assistant")));
//}
//
// QString typeValue = parser.value(QStringLiteral("type"));
// if (!typeValue.isEmpty()) {
// Global::setTypeFilter(typeValue.split(QLatin1Char(',')));
//}
QQmlApplicationEngine engine;
......@@ -98,12 +102,13 @@ int main(int argc, char **argv)
qmlRegisterType<WizardModel>("org.kde.pim.accountwizard", 1, 0, "WizardModel");
qRegisterMetaType<Controller *>("Controller *");
qmlRegisterSingletonInstance("org.kde.pim.accountwizard", 1, 0, "Controller", &controller);
qmlRegisterType<PimCommon::EmailValidator>("org.kde.pim.accountwizard", 1, 0, "EmailValidator");
qmlRegisterType<Ispdb>("org.kde.pim.accountwizard", 1, 0, "Ispdb");
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
SetupManager setupManager;
qmlRegisterSingletonInstance("org.kde.pim.accountwizard", 1, 0, "SetupManager", &setupManager);
qmlRegisterSingletonInstance("org.kde.pim.accountwizard", 1, 0, "SetupManager", &SetupManager::instance());
ServerTest serverTest;
qmlRegisterSingletonInstance("org.kde.pim.accountwizard", 1, 0, "ServerTest", &serverTest);
......
/*
SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "page.h"
#include <KAssistantDialog>
#include <KPageWidgetModel>
Page::Page(KAssistantDialog *parent)
: QWidget(parent)
, m_item(nullptr)
, m_parent(parent)
, m_valid(false)
{
}
void Page::setPageWidgetItem(KPageWidgetItem *item)
{
m_item = item;
m_parent->setValid(m_item, m_valid);
}
void Page::setValid(bool valid)
{
if (!m_item) {
m_valid = valid;
} else {
m_parent->setValid(m_item, valid);
}
}
void Page::nextPage()
{