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
Multimedia
K3b
Commits
7431ad73
Commit
7431ad73
authored
May 17, 2021
by
Alexander Lohnau
💬
Committed by
Albert Astals Cid
May 18, 2021
Browse files
Port plugins away from desktop file loading
parent
fb74c580
Changes
29
Hide whitespace changes
Inline
Side-by-side
libk3b/plugin/CMakeLists.txt
View file @
7431ad73
...
...
@@ -8,4 +8,5 @@ install( FILES
k3bprojectplugin.h
DESTINATION
${
INCLUDE_INSTALL_DIR
}
COMPONENT Devel
)
# TODO KF6 remove
install
(
FILES k3bplugin.desktop DESTINATION
${
SERVICETYPES_INSTALL_DIR
}
)
libk3b/plugin/k3bplugin.h
View file @
7431ad73
...
...
@@ -18,6 +18,7 @@
#include "k3b_export.h"
#include <KPluginFactory>
#include <KPluginMetaData>
#include <KPluginInfo>
#include <QObject>
...
...
@@ -41,7 +42,8 @@ namespace K3b {
explicit
Plugin
(
QObject
*
parent
=
0
);
~
Plugin
()
override
;
KPluginInfo
pluginInfo
()
const
{
return
m_pluginInfo
;
}
KPluginInfo
pluginInfo
()
const
{
return
KPluginInfo
::
fromMetaData
(
d
->
metadata
);
}
KPluginMetaData
pluginMetaData
()
const
{
return
d
->
metadata
;
}
/**
* Version of the plugin system this plugin was written for.
...
...
@@ -56,7 +58,10 @@ namespace K3b {
virtual
QString
categoryName
()
const
=
0
;
private:
KPluginInfo
m_pluginInfo
;
struct
Private
{
KPluginMetaData
metadata
;
};
std
::
unique_ptr
<
Private
>
d
=
std
::
unique_ptr
<
Private
>
(
new
Private
());
};
}
...
...
libk3b/plugin/k3bpluginmanager.cpp
View file @
7431ad73
...
...
@@ -23,6 +23,8 @@
#include <KPluginInfo>
#include <KService>
#include <KServiceTypeTrader>
#include <KPluginLoader>
#include <KPluginMetaData>
#include <KMessageBox>
#include <QDebug>
...
...
@@ -40,17 +42,12 @@
class
K3b
::
PluginManager
::
Private
{
public:
Private
(
K3b
::
PluginManager
*
parent
)
:
m_parent
(
parent
)
{
Private
(){
}
QList
<
K3b
::
Plugin
*>
plugins
;
void
loadPlugin
(
const
KService
::
Ptr
&
service
);
KCModuleProxy
*
getModuleProxy
(
Plugin
*
plugin
)
const
;
private:
K3b
::
PluginManager
*
m_parent
;
};
...
...
@@ -58,7 +55,7 @@ private:
K3b
::
PluginManager
::
PluginManager
(
QObject
*
parent
)
:
QObject
(
parent
),
d
(
new
Private
(
this
)
)
d
(
new
Private
()
)
{
}
...
...
@@ -94,46 +91,6 @@ QList<K3b::Plugin*> K3b::PluginManager::plugins( const QString& group ) const
return
fl
;
}
void
K3b
::
PluginManager
::
Private
::
loadPlugin
(
const
KService
::
Ptr
&
service
)
{
qDebug
()
<<
service
->
name
()
<<
service
->
library
();
QString
err
;
K3b
::
Plugin
*
plugin
=
service
->
createInstance
<
K3b
::
Plugin
>
(
0
,
m_parent
,
QVariantList
(),
&
err
);
if
(
plugin
)
{
qDebug
()
<<
"Loaded plugin"
<<
service
->
name
();
// FIXME: improve this versioning stuff
if
(
plugin
->
pluginSystemVersion
()
!=
K3B_PLUGIN_SYSTEM_VERSION
)
{
delete
plugin
;
qDebug
()
<<
"plugin system does not fit"
;
}
else
{
plugin
->
m_pluginInfo
=
KPluginInfo
(
service
);
plugins
.
append
(
plugin
);
}
}
else
{
qDebug
()
<<
"Loading plugin"
<<
service
->
name
()
<<
"failed. Error:"
<<
err
;
}
// // make sure to only use the latest version of one plugin
// bool addPlugin = true;
// for( Q3PtrListIterator<K3b::Plugin> it( d->plugins ); *it; ++it ) {
// if( it.current()->pluginInfo().name() == plugin->pluginInfo().name() ) {
// if( K3b::Version(it.current()->pluginInfo().version()) < K3b::Version(plugin->pluginInfo().version()) ) {
// K3b::Plugin* p = it.current();
// d->plugins.removeRef( p );
// delete p;
// }
// else {
// addPlugin = false;
// }
// break;
// }
}
KCModuleProxy
*
K3b
::
PluginManager
::
Private
::
getModuleProxy
(
Plugin
*
plugin
)
const
{
foreach
(
const
KService
::
Ptr
&
service
,
plugin
->
pluginInfo
().
kcmServices
()
)
{
...
...
@@ -153,10 +110,17 @@ KCModuleProxy* K3b::PluginManager::Private::getModuleProxy( Plugin* plugin ) con
void
K3b
::
PluginManager
::
loadAll
()
{
qDebug
();
KService
::
List
services
=
KServiceTypeTrader
::
self
()
->
query
(
"K3b/Plugin"
);
Q_FOREACH
(
const
KService
::
Ptr
&
service
,
services
)
{
d
->
loadPlugin
(
service
);
const
QVector
<
KPluginMetaData
>
metadataList
=
KPluginLoader
::
findPlugins
(
"k3b_plugins"
);
for
(
const
auto
&
metadata
:
metadataList
)
{
KPluginLoader
loader
(
metadata
.
fileName
());
KPluginFactory
*
factory
=
loader
.
factory
();
if
(
auto
*
plugin
=
factory
->
create
<
K3b
::
Plugin
>
())
{
plugin
->
d
->
metadata
=
metadata
;
qDebug
()
<<
"Loaded plugin"
<<
metadata
.
metaDataFileName
();
d
->
plugins
.
append
(
plugin
);
}
else
{
qDebug
()
<<
"failed to load plugin"
<<
metadata
.
metaDataFileName
();
}
}
}
...
...
plugins/decoder/ffmpeg/CMakeLists.txt
View file @
7431ad73
add_library
(
k3bffmpegdecoder MODULE k3bffmpegdecoder.cpp k3bffmpegwrapper.cpp
)
kcoreaddons_add_plugin
(
k3bffmpegdecoder SOURCES k3bffmpegdecoder.cpp k3bffmpegwrapper.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3bffmpegdecoder
"k3bffmpegdecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
if
(
FFMPEG_INCLUDE_DIR_OLD_STYLE
)
message
(
STATUS
"didn't find new ffmpegcodecpath"
)
...
...
@@ -10,7 +11,3 @@ else()
endif
()
target_link_libraries
(
k3bffmpegdecoder k3bdevice k3blib KF5::I18n
${
FFMPEG_LIBRARIES
}
)
install
(
TARGETS k3bffmpegdecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3bffmpegdecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/ffmpeg/k3bffmpegdecoder.cpp
View file @
7431ad73
...
...
@@ -37,7 +37,7 @@ extern "C" {
#include <math.h>
K
3B_EXPORT_PLUGIN
(
k3bffm
peg
d
ecoder
,
K3bFFM
peg
D
ecoder
Factory
)
K
_PLUGIN_CLASS_WITH_JSON
(
K3bFFM
peg
D
ecoder
Factory
,
"k3bffm
peg
d
ecoder
.json"
)
K3bFFMpegDecoderFactory
::
K3bFFMpegDecoderFactory
(
QObject
*
parent
,
const
QVariantList
&
)
:
K3b
::
AudioDecoderFactory
(
parent
)
...
...
plugins/decoder/flac/CMakeLists.txt
View file @
7431ad73
...
...
@@ -15,7 +15,8 @@ endif()
configure_file
(
config-flac.h.cmake config-flac.h
)
add_library
(
k3bflacdecoder MODULE k3bflacdecoder.cpp
)
kcoreaddons_add_plugin
(
k3bflacdecoder SOURCES k3bflacdecoder.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3bflacdecoder
"k3bflacdecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_include_directories
(
k3bflacdecoder PRIVATE
${
FLAC++_INCLUDE_DIR
}
${
FLAC_INCLUDE_DIR
}
${
TAGLIB_INCLUDES
}
)
...
...
@@ -24,7 +25,3 @@ target_link_libraries(k3bflacdecoder k3bdevice k3blib KF5::I18n ${FLAC++_LIBRARI
if
(
ENABLE_TAGLIB
)
target_link_libraries
(
k3bflacdecoder
${
TAGLIB_LIBRARIES
}
)
endif
()
install
(
TARGETS k3bflacdecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3bflacdecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/flac/k3bflacdecoder.cpp
View file @
7431ad73
...
...
@@ -21,12 +21,13 @@
#include <QFile>
#include <QStringList>
#include <kpluginfactory.h>
#include <string.h>
#include <math.h>
#include <FLAC++/metadata.h>
#include <FLAC++/decoder.h>
K
3B_EXPORT_PLUGIN
(
k3bflacdecoder
,
K3bFLACDecoderFactory
)
K
_PLUGIN_CLASS_WITH_JSON
(
K3bFLACDecoderFactory
,
"k3bflacdecoder.json"
)
#ifdef ENABLE_TAGLIB
#include <tag.h>
...
...
plugins/decoder/libsndfile/CMakeLists.txt
View file @
7431ad73
add_library
(
k3blibsndfiledecoder MODULE k3blibsndfiledecoder.cpp
)
kcoreaddons_add_plugin
(
k3blibsndfiledecoder SOURCES k3blibsndfiledecoder.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3blibsndfiledecoder
"k3blibsndfiledecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_include_directories
(
k3blibsndfiledecoder PRIVATE
${
SNDFILE_INCLUDE_DIR
}
)
target_link_libraries
(
k3blibsndfiledecoder k3bdevice k3blib KF5::I18n
${
SNDFILE_LIBRARIES
}
)
install
(
TARGETS k3blibsndfiledecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3blibsndfiledecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/libsndfile/k3blibsndfiledecoder.cpp
View file @
7431ad73
...
...
@@ -26,7 +26,7 @@
#include <stdio.h>
#include <sndfile.h>
K
3B_EXPORT_PLUGIN
(
k
3b
l
ibsndfile
d
ecoder
,
K
3b
L
ibsndfile
D
ecoder
Factory
)
K
_PLUGIN_CLASS_WITH_JSON
(
K
3b
L
ibsndfile
D
ecoder
Factory
,
"k
3b
l
ibsndfile
d
ecoder
.json"
)
class
K3bLibsndfileDecoder
::
Private
{
...
...
plugins/decoder/mp3/CMakeLists.txt
View file @
7431ad73
add_library
(
k3bmaddecoder MODULE k3bmad.cpp k3bmaddecoder.cpp
)
kcoreaddons_add_plugin
(
k3bmaddecoder SOURCES k3bmad.cpp k3bmaddecoder.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3bmaddecoder
"k3bmaddecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_include_directories
(
k3bmaddecoder PRIVATE
${
MAD_INCLUDE_DIR
}
${
TAGLIB_INCLUDES
}
)
...
...
@@ -7,7 +8,3 @@ target_link_libraries(k3bmaddecoder k3bdevice k3blib KF5::I18n ${MAD_LIBRARIES})
if
(
ENABLE_TAGLIB
)
target_link_libraries
(
k3bmaddecoder
${
TAGLIB_LIBRARIES
}
)
endif
()
install
(
TARGETS k3bmaddecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3bmaddecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/mp3/k3bmaddecoder.cpp
View file @
7431ad73
...
...
@@ -44,8 +44,7 @@
#endif
K3B_EXPORT_PLUGIN
(
k3bmaddecoder
,
K3bMadDecoderFactory
)
K_PLUGIN_CLASS_WITH_JSON
(
K3bMadDecoderFactory
,
"k3bmaddecoder.json"
)
int
K3bMadDecoder
::
MaxAllowedRecoverableErrors
=
10
;
...
...
plugins/decoder/musepack/CMakeLists.txt
View file @
7431ad73
configure_file
(
k3bmpc_config.h.cmake k3bmpc_config.h
)
add_library
(
k3bmpcdecoder MODULE k3bmpcdecoder.cpp k3bmpcwrapper.cpp
)
kcoreaddons_add_plugin
(
k3bmpcdecoder SOURCES k3bmpcdecoder.cpp k3bmpcwrapper.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3bmpcdecoder
"k3bmpcdecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_include_directories
(
k3bmpcdecoder PRIVATE
${
MUSE_INCLUDE_DIR
}
)
target_link_libraries
(
k3bmpcdecoder k3bdevice k3blib KF5::I18n
${
MUSE_LIBRARIES
}
)
install
(
TARGETS k3bmpcdecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3bmpcdecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/musepack/k3bmpcdecoder.cpp
View file @
7431ad73
...
...
@@ -19,7 +19,7 @@
#include <config-k3b.h>
K
3B_EXPORT_PLUGIN
(
k
3b
m
pc
d
ecoder
,
K
3b
M
pc
D
ecoder
Factory
)
K
_PLUGIN_CLASS_WITH_JSON
(
K
3b
M
pc
D
ecoder
Factory
,
"k
3b
m
pc
d
ecoder
.json"
)
K3bMpcDecoderFactory
::
K3bMpcDecoderFactory
(
QObject
*
parent
,
const
QVariantList
&
)
:
K3b
::
AudioDecoderFactory
(
parent
)
...
...
plugins/decoder/ogg/CMakeLists.txt
View file @
7431ad73
add_library
(
k3boggvorbisdecoder MODULE k3boggvorbisdecoder.cpp
)
kcoreaddons_add_plugin
(
k3boggvorbisdecoder SOURCES k3boggvorbisdecoder.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3boggvorbisdecoder
"k3boggvorbisdecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_link_libraries
(
k3boggvorbisdecoder k3bdevice k3blib KF5::I18n
${
OGGVORBIS_LIBRARIES
}
)
install
(
TARGETS k3boggvorbisdecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3boggvorbisdecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/ogg/k3boggvorbisdecoder.cpp
View file @
7431ad73
...
...
@@ -26,7 +26,7 @@
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
K
3B_EXPORT_PLUGIN
(
k
3b
o
gg
v
orbis
d
ecoder
,
K
3b
O
gg
V
orbis
D
ecoder
Factory
)
K
_PLUGIN_CLASS_WITH_JSON
(
K
3b
O
gg
V
orbis
D
ecoder
Factory
,
"k
3b
o
gg
v
orbis
d
ecoder
.json"
)
class
K3bOggVorbisDecoder
::
Private
{
...
...
plugins/decoder/wave/CMakeLists.txt
View file @
7431ad73
add_library
(
k3bwavedecoder MODULE k3bwavedecoder.cpp
)
kcoreaddons_add_plugin
(
k3bwavedecoder SOURCES k3bwavedecoder.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3bwavedecoder
"k3bwavedecoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_link_libraries
(
k3bwavedecoder k3bdevice k3blib KF5::I18n
)
install
(
TARGETS k3bwavedecoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES k3bwavedecoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/decoder/wave/k3bwavedecoder.cpp
View file @
7431ad73
...
...
@@ -21,7 +21,7 @@
#include <QFile>
K
3B_EXPORT_PLUGIN
(
k
3b
w
ave
d
ecoder
,
K
3b
W
ave
D
ecoder
Factory
)
K
_PLUGIN_CLASS_WITH_JSON
(
K
3b
W
ave
D
ecoder
Factory
,
"k
3b
w
ave
d
ecoder
.json"
)
static
unsigned
short
le_a_to_u_short
(
unsigned
char
*
a
)
{
return
((
unsigned
short
)
...
...
plugins/encoder/external/CMakeLists.txt
View file @
7431ad73
add_library
(
k3bexternalencoder MODULE
k3bexternalencoder.cpp
k3bexternalencodercommand.cpp
)
kcoreaddons_add_plugin
(
k3bexternalencoder SOURCES k3bexternalencoder.cpp k3bexternalencodercommand.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3bexternalencoder
"k3bexternalencoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_link_libraries
(
k3bexternalencoder
k3bdevice
...
...
@@ -26,6 +24,6 @@ target_link_libraries(kcm_k3bexternalencoder
KF5::I18n
)
install
(
TARGETS
k3bexternalencoder
kcm_k3bexternalencoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
TARGETS kcm_k3bexternalencoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES
k3bexternalencoder.desktop
kcm_k3bexternalencoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
install
(
FILES kcm_k3bexternalencoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
plugins/encoder/external/k3bexternalencoder.cpp
View file @
7431ad73
...
...
@@ -32,7 +32,8 @@
#include <sys/types.h>
K3B_EXPORT_PLUGIN
(
k3bexternalencoder
,
K3bExternalEncoder
)
K_PLUGIN_CLASS_WITH_JSON
(
K3bExternalEncoder
,
"k3bexternalencoder.json"
)
Q_DECLARE_METATYPE
(
QProcess
::
ExitStatus
)
...
...
plugins/encoder/lame/CMakeLists.txt
View file @
7431ad73
add_library
(
k3blameencoder MODULE k3blameencoder.cpp
)
kcoreaddons_add_plugin
(
k3blameencoder SOURCES k3blameencoder.cpp INSTALL_NAMESPACE
"k3b_plugins"
)
kcoreaddons_desktop_to_json
(
k3blameencoder
"k3blameencoder.desktop"
SERVICE_TYPES
${
CMAKE_SOURCE_DIR
}
/libk3b/plugin/k3bplugin.desktop
)
target_link_libraries
(
k3blameencoder
k3bdevice
...
...
@@ -24,6 +25,6 @@ target_link_libraries(kcm_k3blameencoder
KF5::I18n
)
install
(
TARGETS
k3blameencoder
kcm_k3blameencoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
TARGETS kcm_k3blameencoder DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
install
(
FILES
k3blameencoder.desktop
kcm_k3blameencoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
install
(
FILES kcm_k3blameencoder.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
)
Prev
1
2
Next
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