Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Messagelib
Commits
56c26d85
Commit
56c26d85
authored
Jun 25, 2021
by
Laurent Montel
😁
Browse files
Prepare to create check before deleting plugin support
parent
de3d4cf9
Changes
8
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
56c26d85
cmake_minimum_required
(
VERSION 3.16 FATAL_ERROR
)
set
(
PIM_VERSION
"5.17.5
0
"
)
set
(
PIM_VERSION
"5.17.5
1
"
)
project
(
Messagelib VERSION
${
PIM_VERSION
}
)
...
...
messageviewer/src/CMakeLists.txt
View file @
56c26d85
...
...
@@ -227,6 +227,12 @@ set(libmessageviewer_configureplugins_SRCS
messageviewerconfigureplugins/messageviewerconfiguresettingspluginwidget.cpp
)
set
(
libmessageviewer_checkbeforedeltingplugins_SRCS
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingplugin.cpp
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginmanager.cpp
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginwidget.cpp
)
set
(
libmessageviewer_messagepartthemes_default_SRCS
messagepartthemes/default/converthtmltoplaintext.cpp
messagepartthemes/default/defaultrenderer.cpp
...
...
@@ -257,6 +263,7 @@ set(libmessageviewer_remotecontent
)
set
(
libmessageviewer_SRCS
${
libmessageviewer_checkbeforedeltingplugins_SRCS
}
${
libmessageviewer_remotecontent
}
${
messageviewer_renderer_SRCS
}
${
libmessageviewer_conversationviewer_SRCS
}
...
...
messageviewer/src/messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingplugin.cpp
0 → 100644
View file @
56c26d85
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "messageviewercheckbeforedeletingplugin.h"
using
namespace
MessageViewer
;
class
MessageViewer
::
MessageViewerCheckBeforeDeletingPluginPrivate
{
public:
MessageViewerCheckBeforeDeletingPluginPrivate
()
{
}
};
MessageViewerCheckBeforeDeletingPlugin
::
MessageViewerCheckBeforeDeletingPlugin
(
QObject
*
parent
)
:
QObject
(
parent
)
,
d
(
new
MessageViewer
::
MessageViewerCheckBeforeDeletingPluginPrivate
)
{
}
MessageViewerCheckBeforeDeletingPlugin
::~
MessageViewerCheckBeforeDeletingPlugin
()
{
delete
d
;
}
void
MessageViewerCheckBeforeDeletingPlugin
::
showConfigureDialog
(
QWidget
*
parent
)
{
Q_UNUSED
(
parent
)
// Reimplement
}
messageviewer/src/messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingplugin.h
0 → 100644
View file @
56c26d85
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include <QObject>
#include "messageviewer_export.h"
namespace
MessageViewer
{
class
MessageViewerCheckBeforeDeletingPluginPrivate
;
/**
* @brief The MessageViewerCheckBeforeDeletingPlugin class
* @author Laurent Montel <montel@kde.org>
*/
class
MESSAGEVIEWER_EXPORT
MessageViewerCheckBeforeDeletingPlugin
:
public
QObject
{
Q_OBJECT
public:
explicit
MessageViewerCheckBeforeDeletingPlugin
(
QObject
*
parent
=
nullptr
);
~
MessageViewerCheckBeforeDeletingPlugin
();
virtual
void
showConfigureDialog
(
QWidget
*
parent
);
Q_SIGNALS:
void
configChanged
();
private:
MessageViewerCheckBeforeDeletingPluginPrivate
*
const
d
;
};
}
messageviewer/src/messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginmanager.cpp
0 → 100644
View file @
56c26d85
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "messageviewercheckbeforedeletingpluginmanager.h"
#include "messageviewer_debug.h"
#include "messageviewerconfiguresettingsplugin.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
#include <QFileInfo>
#include <QSet>
using
namespace
MessageViewer
;
class
ConfigureSettingsPluginInfo
{
public:
ConfigureSettingsPluginInfo
()
{
}
PimCommon
::
PluginUtilData
pluginData
;
QString
metaDataFileNameBaseName
;
QString
metaDataFileName
;
MessageViewer
::
MessageViewerConfigureSettingsPlugin
*
plugin
=
nullptr
;
};
class
MessageViewer
::
MessageViewerCheckBeforeDeletingPluginManagerPrivate
{
public:
explicit
MessageViewerCheckBeforeDeletingPluginManagerPrivate
(
MessageViewerCheckBeforeDeletingPluginManager
*
qq
)
:
q
(
qq
)
{
}
QVector
<
MessageViewer
::
MessageViewerConfigureSettingsPlugin
*>
pluginsList
()
const
;
QVector
<
PimCommon
::
PluginUtilData
>
pluginDataList
()
const
;
void
initializePluginList
();
void
loadPlugin
(
ConfigureSettingsPluginInfo
*
item
);
QString
configGroupName
()
const
;
QString
configPrefixSettingKey
()
const
;
MessageViewerConfigureSettingsPlugin
*
pluginFromIdentifier
(
const
QString
&
id
);
private:
QVector
<
PimCommon
::
PluginUtilData
>
mPluginDataList
;
QVector
<
ConfigureSettingsPluginInfo
>
mPluginList
;
MessageViewerCheckBeforeDeletingPluginManager
*
const
q
;
};
namespace
{
QString
pluginVersion
()
{
return
QStringLiteral
(
"1.0"
);
}
}
QVector
<
PimCommon
::
PluginUtilData
>
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
pluginDataList
()
const
{
return
mPluginDataList
;
}
QString
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
configGroupName
()
const
{
return
QStringLiteral
(
"MessageViewerCheckBeforeDeletingPlugins"
);
}
QString
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
configPrefixSettingKey
()
const
{
return
QStringLiteral
(
"MessageViewerCheckBeforeDeletingPlugin"
);
}
void
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
initializePluginList
()
{
const
QVector
<
KPluginMetaData
>
plugins
=
KPluginLoader
::
findPlugins
(
QStringLiteral
(
"messageviewer/checkbeforedeleting"
));
QVectorIterator
<
KPluginMetaData
>
i
(
plugins
);
i
.
toBack
();
const
QPair
<
QStringList
,
QStringList
>
pair
=
PimCommon
::
PluginUtil
::
loadPluginSetting
(
configGroupName
(),
configPrefixSettingKey
());
QVector
<
int
>
listOrder
;
while
(
i
.
hasPrevious
())
{
ConfigureSettingsPluginInfo
info
;
const
KPluginMetaData
data
=
i
.
previous
();
// 1) get plugin data => name/description etc.
info
.
pluginData
=
PimCommon
::
PluginUtil
::
createPluginMetaData
(
data
);
// 2) look at if plugin is activated
info
.
metaDataFileNameBaseName
=
QFileInfo
(
data
.
fileName
()).
baseName
();
info
.
metaDataFileName
=
data
.
fileName
();
const
QString
version
=
data
.
version
();
if
(
pluginVersion
()
==
version
)
{
const
QVariant
p
=
data
.
rawData
().
value
(
QStringLiteral
(
"X-KDE-MessageViewer-Configure-Order"
)).
toVariant
();
int
order
=
-
1
;
if
(
p
.
isValid
())
{
order
=
p
.
toInt
();
}
int
pos
=
0
;
for
(;
pos
<
listOrder
.
count
();
++
pos
)
{
if
(
listOrder
.
at
(
pos
)
>
order
)
{
pos
--
;
break
;
}
}
pos
=
qMax
(
0
,
pos
);
listOrder
.
insert
(
pos
,
order
);
info
.
plugin
=
nullptr
;
mPluginList
.
insert
(
pos
,
info
);
}
else
{
qCWarning
(
MESSAGEVIEWER_LOG
)
<<
"Plugin "
<<
data
.
name
()
<<
" doesn't have correction plugin version. It will not be loaded."
;
}
}
QVector
<
ConfigureSettingsPluginInfo
>::
iterator
end
(
mPluginList
.
end
());
for
(
QVector
<
ConfigureSettingsPluginInfo
>::
iterator
it
=
mPluginList
.
begin
();
it
!=
end
;
++
it
)
{
loadPlugin
(
&
(
*
it
));
}
}
QVector
<
MessageViewer
::
MessageViewerConfigureSettingsPlugin
*>
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
pluginsList
()
const
{
QVector
<
MessageViewer
::
MessageViewerConfigureSettingsPlugin
*>
lst
;
QVector
<
ConfigureSettingsPluginInfo
>::
ConstIterator
end
(
mPluginList
.
constEnd
());
for
(
QVector
<
ConfigureSettingsPluginInfo
>::
ConstIterator
it
=
mPluginList
.
constBegin
();
it
!=
end
;
++
it
)
{
if
(
auto
plugin
=
(
*
it
).
plugin
)
{
lst
<<
plugin
;
}
}
return
lst
;
}
void
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
loadPlugin
(
ConfigureSettingsPluginInfo
*
item
)
{
KPluginLoader
pluginLoader
(
item
->
metaDataFileName
);
if
(
pluginLoader
.
factory
())
{
item
->
plugin
=
pluginLoader
.
factory
()
->
create
<
MessageViewer
::
MessageViewerConfigureSettingsPlugin
>
(
q
,
QVariantList
()
<<
item
->
metaDataFileNameBaseName
);
// By default it's true
item
->
pluginData
.
mHasConfigureDialog
=
true
;
mPluginDataList
.
append
(
item
->
pluginData
);
}
}
MessageViewerConfigureSettingsPlugin
*
MessageViewerCheckBeforeDeletingPluginManagerPrivate
::
pluginFromIdentifier
(
const
QString
&
id
)
{
QVector
<
ConfigureSettingsPluginInfo
>::
ConstIterator
end
(
mPluginList
.
constEnd
());
for
(
QVector
<
ConfigureSettingsPluginInfo
>::
ConstIterator
it
=
mPluginList
.
constBegin
();
it
!=
end
;
++
it
)
{
if
((
*
it
).
pluginData
.
mIdentifier
==
id
)
{
return
(
*
it
).
plugin
;
}
}
return
{};
}
MessageViewerCheckBeforeDeletingPluginManager
*
MessageViewerCheckBeforeDeletingPluginManager
::
self
()
{
static
MessageViewerCheckBeforeDeletingPluginManager
s_self
;
return
&
s_self
;
}
MessageViewerCheckBeforeDeletingPluginManager
::
MessageViewerCheckBeforeDeletingPluginManager
(
QObject
*
parent
)
:
QObject
(
parent
)
,
d
(
new
MessageViewer
::
MessageViewerCheckBeforeDeletingPluginManagerPrivate
(
this
))
{
d
->
initializePluginList
();
}
MessageViewerCheckBeforeDeletingPluginManager
::~
MessageViewerCheckBeforeDeletingPluginManager
()
{
delete
d
;
}
QVector
<
MessageViewer
::
MessageViewerConfigureSettingsPlugin
*>
MessageViewerCheckBeforeDeletingPluginManager
::
pluginsList
()
const
{
return
d
->
pluginsList
();
}
QString
MessageViewerCheckBeforeDeletingPluginManager
::
configGroupName
()
const
{
return
d
->
configGroupName
();
}
QString
MessageViewerCheckBeforeDeletingPluginManager
::
configPrefixSettingKey
()
const
{
return
d
->
configPrefixSettingKey
();
}
QVector
<
PimCommon
::
PluginUtilData
>
MessageViewerCheckBeforeDeletingPluginManager
::
pluginsDataList
()
const
{
return
d
->
pluginDataList
();
}
MessageViewerConfigureSettingsPlugin
*
MessageViewerCheckBeforeDeletingPluginManager
::
pluginFromIdentifier
(
const
QString
&
id
)
{
return
d
->
pluginFromIdentifier
(
id
);
}
messageviewer/src/messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginmanager.h
0 → 100644
View file @
56c26d85
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "messageviewer_export.h"
#include <PimCommon/PluginUtil>
#include <QObject>
namespace
MessageViewer
{
class
MessageViewerConfigureSettingsPlugin
;
class
MessageViewerCheckBeforeDeletingPluginManagerPrivate
;
/**
* @brief The MessageViewerCheckBeforeDeletingPluginManager class
* @author Laurent Montel <montel@kde.org>
*/
class
MESSAGEVIEWER_EXPORT
MessageViewerCheckBeforeDeletingPluginManager
:
public
QObject
{
Q_OBJECT
public:
static
MessageViewerCheckBeforeDeletingPluginManager
*
self
();
explicit
MessageViewerCheckBeforeDeletingPluginManager
(
QObject
*
parent
=
nullptr
);
~
MessageViewerCheckBeforeDeletingPluginManager
();
Q_REQUIRED_RESULT
QVector
<
MessageViewer
::
MessageViewerConfigureSettingsPlugin
*>
pluginsList
()
const
;
Q_REQUIRED_RESULT
QVector
<
PimCommon
::
PluginUtilData
>
pluginsDataList
()
const
;
Q_REQUIRED_RESULT
QString
configPrefixSettingKey
()
const
;
Q_REQUIRED_RESULT
QString
configGroupName
()
const
;
Q_REQUIRED_RESULT
MessageViewerConfigureSettingsPlugin
*
pluginFromIdentifier
(
const
QString
&
id
);
private:
MessageViewerCheckBeforeDeletingPluginManagerPrivate
*
const
d
;
};
}
messageviewer/src/messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginwidget.cpp
0 → 100644
View file @
56c26d85
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "messageviewercheckbeforedeletingpluginwidget.h"
using
namespace
MessageViewer
;
MessageViewerCheckBeforeDeletingPluginWidget
::
MessageViewerCheckBeforeDeletingPluginWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
}
MessageViewerCheckBeforeDeletingPluginWidget
::~
MessageViewerCheckBeforeDeletingPluginWidget
()
{
}
QString
MessageViewerCheckBeforeDeletingPluginWidget
::
helpAnchor
()
const
{
return
QString
();
}
messageviewer/src/messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginwidget.h
0 → 100644
View file @
56c26d85
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "messageviewer_export.h"
#include <QWidget>
namespace
MessageViewer
{
/**
* @brief The MessageViewerCheckBeforeDeletingPluginWidget class
* @author Laurent Montel <montel@kde.org>
*/
class
MESSAGEVIEWER_EXPORT
MessageViewerCheckBeforeDeletingPluginWidget
:
public
QWidget
{
Q_OBJECT
public:
explicit
MessageViewerCheckBeforeDeletingPluginWidget
(
QWidget
*
parent
=
nullptr
);
~
MessageViewerCheckBeforeDeletingPluginWidget
();
virtual
void
loadSettings
()
=
0
;
virtual
void
saveSettings
()
=
0
;
virtual
void
resetSettings
()
=
0
;
virtual
Q_REQUIRED_RESULT
QString
helpAnchor
()
const
;
Q_SIGNALS:
void
configureChanged
();
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment