diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,9 @@ include(ECMGenerateHeaders) include(ECMAddQch) include(ECMQtDeclareLoggingCategory) -include(GenerateExportHeader) +include(ECMGenerateExportHeader) + +set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -25,9 +25,6 @@ kplugininfotest ) -# we want to test the deprecated API without a (useless) warning -target_compile_definitions(kplugininfotest PRIVATE KSERVICE_DEPRECATED=) - # the test plays with the timestamp of ~/.qttest/share/kservicetypes5, and with the ksycoca file, other tests can collide set_tests_properties(ksycocatest PROPERTIES RUN_SERIAL TRUE) # KServiceTest::testAllServices can fail if any service is deleted while the test runs diff --git a/autotests/kplugininfotest.cpp b/autotests/kplugininfotest.cpp --- a/autotests/kplugininfotest.cpp +++ b/autotests/kplugininfotest.cpp @@ -83,13 +83,17 @@ // for most constructors translations are performed when the object is constructed and not at runtime! QLocale::setDefault(QLocale::c()); KPluginInfo info(fakepluginDesktop); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) KService::Ptr fakepluginService(new KService(fakepluginDesktop)); KPluginInfo infoFromService(fakepluginService); +#endif KPluginInfo compatJsonInfo(KPluginMetaData(compatJson, pluginName)); QLocale::setDefault(QLocale(QLocale::German, QLocale::Germany)); KPluginInfo infoGerman(fakepluginDesktop); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) KService::Ptr fakepluginServiceGerman(new KService(fakepluginDesktop)); KPluginInfo infoFromServiceGerman(fakepluginServiceGerman); +#endif KPluginInfo compatJsonInfoGerman(KPluginMetaData(compatJson, pluginName)); QLocale::setDefault(QLocale::c()); @@ -99,11 +103,13 @@ QTest::newRow("from .desktop") << fakepluginDesktop << info << infoGerman << QVariant() << false; QTest::newRow("with custom property") << info.libraryPath() << withCustomProperty(info) << withCustomProperty(infoGerman) << QVariant("Baz") << false; +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) QTest::newRow("from KService::Ptr") << fakepluginDesktop << infoFromService << infoFromServiceGerman << QVariant() << true; QTest::newRow("from KService::Ptr + custom property") << pluginName << withCustomProperty(infoFromService) << withCustomProperty(infoFromServiceGerman) << QVariant("Baz") << true; +#endif QTest::newRow("from JSON file") << pluginName << jsonInfo << jsonInfo << QVariant() << false; QTest::newRow("from JSON file + custom property") << pluginName << withCustomProperty(jsonInfo) << withCustomProperty(jsonInfo) << QVariant("Baz") << false; diff --git a/autotests/kservicetest.h b/autotests/kservicetest.h --- a/autotests/kservicetest.h +++ b/autotests/kservicetest.h @@ -18,6 +18,8 @@ #ifndef KSERVICETEST_H #define KSERVICETEST_H +#include + #include #include @@ -28,7 +30,9 @@ KServiceTest() : m_sycocaUpdateDone(0) {} private Q_SLOTS: void initTestCase(); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) void testKPluginMetaData(); +#endif void cleanupTestCase(); void testByName(); void testConstructorFullPath(); diff --git a/autotests/kservicetest.cpp b/autotests/kservicetest.cpp --- a/autotests/kservicetest.cpp +++ b/autotests/kservicetest.cpp @@ -899,6 +899,7 @@ QCOMPARE(KService(QStringLiteral("/hallo/a.b.c.desktop")).name(), QStringLiteral("a.b.c")); } +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) void KServiceTest::testKPluginMetaData() { const QString fakePart = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kservices5/") + "fakepart.desktop"; @@ -908,6 +909,7 @@ auto info_md = info.toMetaData(); QCOMPARE(info_md.formFactors(), md.formFactors()); } +#endif void KServiceTest::testTraderQueryMustRebuildSycoca() { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,8 +81,15 @@ #unistd.h does not exist on windows target_compile_definitions(KF5Service PRIVATE YY_NO_UNISTD_H=1) endif() -generate_export_header(KF5Service BASE_NAME KService) add_library(KF5::Service ALIAS KF5Service) +ecm_generate_export_header(KF5Service + BASE_NAME KService + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 5.0 5.15 5.61 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) set(kservice_includes ${CMAKE_CURRENT_BINARY_DIR}/.. # Since we publicly include kservice_version.h ${CMAKE_CURRENT_SOURCE_DIR}/services diff --git a/src/kdeinit/ktoolinvocation.h b/src/kdeinit/ktoolinvocation.h --- a/src/kdeinit/ktoolinvocation.h +++ b/src/kdeinit/ktoolinvocation.h @@ -82,6 +82,7 @@ public Q_SLOTS: +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * Convenience method; invokes the standard email application. * @@ -93,7 +94,8 @@ * @deprecated since 5.0, use QDesktopServices::openUrl(mailtoURL), * using QUrl::setPath(address) and a query item of "subject" for the subject. */ - KSERVICE_DEPRECATED static void invokeMailer(const QString &address, const QString &subject, + KSERVICE_DEPRECATED_VERSION(5, 0, "Use QDesktopServices::openUrl(mailtoURL), using QUrl::setPath(address) and a query item of \"subject\" for the subject") + static void invokeMailer(const QString &address, const QString &subject, const QByteArray &startup_id = QByteArray()); /** @@ -106,8 +108,10 @@ * The default is false; do not honor requests for attachments. * @deprecated since 5.0, use QDesktopServices::openUrl(mailtoURL) */ - KSERVICE_DEPRECATED static void invokeMailer(const QUrl &mailtoURL, const QByteArray &startup_id = QByteArray(), + KSERVICE_DEPRECATED_VERSION(5, 0, "Use QDesktopServices::openUrl(const QUrl&)") + static void invokeMailer(const QUrl &mailtoURL, const QByteArray &startup_id = QByteArray(), bool allowAttachments = false); +#endif /** * Convenience method; invokes the standard email application. @@ -130,6 +134,7 @@ const QStringList &attachURLs = QStringList(), const QByteArray &startup_id = QByteArray()); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * Invokes the user's preferred browser. * Note that you should only do this when you know for sure that the browser can @@ -145,8 +150,10 @@ * "" ( empty string ) is the default * @deprecated since 5.0, use QDesktopServices::openUrl(url) */ - KSERVICE_DEPRECATED static void invokeBrowser(const QString &url, - const QByteArray &startup_id = QByteArray()); + KSERVICE_DEPRECATED_VERSION(5, 0, "Use QDesktopServices::openUrl(const QUrl&)") + static void invokeBrowser(const QString &url, + const QByteArray &startup_id = QByteArray()); +#endif /** * Invokes the standard terminal application. @@ -164,6 +171,7 @@ public: +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * Starts a service based on the (translated) name of the service. * E.g. "Web Browser" @@ -185,11 +193,10 @@ * @return an error code indicating success (== 0) or failure (> 0). * @deprecated Use startServiceByDesktopName or startServiceByDesktopPath */ -#ifndef KSERVICE_NO_DEPRECATED - KSERVICE_DEPRECATED static int startServiceByName(const QString &_name, const QString &URL, + KSERVICE_DEPRECATED_VERSION(5, 0, "Use KToolInvocation::startServiceByDesktopName(...) or KToolInvocation::startServiceByDesktopPath(...)") + static int startServiceByName(const QString &_name, const QString &URL, QString *error = nullptr, QString *serviceName = nullptr, int *pid = nullptr, const QByteArray &startup_id = QByteArray(), bool noWait = false); -#endif /** * Starts a service based on the (translated) name of the service. @@ -212,8 +219,8 @@ * @return an error code indicating success (== 0) or failure (> 0). * @deprecated Use startServiceByDesktopName or startServiceByDesktopPath */ -#ifndef KSERVICE_NO_DEPRECATED - KSERVICE_DEPRECATED static int startServiceByName(const QString &_name, const QStringList &URLs = QStringList(), + KSERVICE_DEPRECATED_VERSION(5, 0, "Use KToolInvocation::startServiceByDesktopName(...) or KToolInvocation::startServiceByDesktopPath(...)") + static int startServiceByName(const QString &_name, const QStringList &URLs = QStringList(), QString *error = nullptr, QString *serviceName = nullptr, int *pid = nullptr, const QByteArray &startup_id = QByteArray(), bool noWait = false); #endif diff --git a/src/kdeinit/ktoolinvocation.cpp b/src/kdeinit/ktoolinvocation.cpp --- a/src/kdeinit/ktoolinvocation.cpp +++ b/src/kdeinit/ktoolinvocation.cpp @@ -134,7 +134,7 @@ #endif } -#ifndef KSERVICE_NO_DEPRECATED +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) int KToolInvocation::startServiceByName(const QString &_name, const QString &URL, QString *error, QString *serviceName, int *pid, @@ -153,7 +153,7 @@ } #endif -#ifndef KSERVICE_NO_DEPRECATED +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) int KToolInvocation::startServiceByName(const QString &_name, const QStringList &URLs, QString *error, QString *serviceName, int *pid, @@ -252,6 +252,7 @@ name, args, error, nullptr, pid, startup_id, false); } +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) void KToolInvocation::invokeMailer(const QString &address, const QString &subject, const QByteArray &startup_id) { if (!isMainThreadActive()) { @@ -299,6 +300,7 @@ invokeMailer(address, cc, bcc, subject, body, QString(), attachURLs, startup_id); } +#endif void KToolInvocation::ensureKdeinitRunning() { diff --git a/src/kdeinit/ktoolinvocation_win.cpp b/src/kdeinit/ktoolinvocation_win.cpp --- a/src/kdeinit/ktoolinvocation_win.cpp +++ b/src/kdeinit/ktoolinvocation_win.cpp @@ -33,6 +33,7 @@ #include "windows.h" #include "shellapi.h" +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) void KToolInvocation::invokeBrowser(const QString &url, const QByteArray &startup_id) { #ifndef _WIN32_WCE @@ -49,6 +50,7 @@ ShellExecuteEx(&cShellExecuteInfo); #endif } +#endif void KToolInvocation::invokeMailer(const QString &_to, const QString &_cc, const QString &_bcc, const QString &subject, const QString &body, diff --git a/src/kdeinit/ktoolinvocation_x11.cpp b/src/kdeinit/ktoolinvocation_x11.cpp --- a/src/kdeinit/ktoolinvocation_x11.cpp +++ b/src/kdeinit/ktoolinvocation_x11.cpp @@ -249,6 +249,7 @@ } } +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) void KToolInvocation::invokeBrowser(const QString &url, const QByteArray &startup_id) { if (!isMainThreadActive()) { @@ -342,6 +343,7 @@ i18n("Could not launch Browser")); } } +#endif void KToolInvocation::invokeTerminal(const QString &command, const QString &workdir, diff --git a/src/plugin/kdbusservicestarter.h b/src/plugin/kdbusservicestarter.h --- a/src/plugin/kdbusservicestarter.h +++ b/src/plugin/kdbusservicestarter.h @@ -25,6 +25,7 @@ class KDBusServiceStarterPrivate; +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 61) /** * @class KDBusServiceStarter kdbusservicestarter.h * @@ -38,10 +39,11 @@ * * @deprecated since 5.61, use D-Bus activation instead */ -class KSERVICE_DEPRECATED_EXPORT KDBusServiceStarter //krazy:exclude=dpointer (uses Q_GLOBAL_STATIC) +class KSERVICE_EXPORT KDBusServiceStarter //krazy:exclude=dpointer (uses Q_GLOBAL_STATIC) { public: + KSERVICE_DEPRECATED_VERSION(5, 61, "Use D-Bus activation") static KDBusServiceStarter *self(); /** @@ -99,6 +101,7 @@ KDBusServiceStarter(); virtual ~KDBusServiceStarter(); }; +#endif #endif diff --git a/src/plugin/kdbusservicestarter.cpp b/src/plugin/kdbusservicestarter.cpp --- a/src/plugin/kdbusservicestarter.cpp +++ b/src/plugin/kdbusservicestarter.cpp @@ -25,6 +25,8 @@ #include #include +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 61) + class KDBusServiceStarterPrivate { public: @@ -111,3 +113,5 @@ //qDebug() << "starting" << ptr->entryPath(); return KToolInvocation::startServiceByDesktopPath(ptr->entryPath(), QStringList(), error, dbusService); } + +#endif diff --git a/src/services/kplugininfo.h b/src/services/kplugininfo.h --- a/src/services/kplugininfo.h +++ b/src/services/kplugininfo.h @@ -83,6 +83,7 @@ */ explicit KPluginInfo(const QString &filename /*, QStandardPaths::StandardLocation resource = ...? GenericDataLocation + services ? Is this used? */); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * Read plugin info from a KService object. * @@ -110,8 +111,8 @@ * @deprecated since 5.0, use (Q|K)PluginLoader instead and build the * metadata into the plugin using K_PLUGIN_CLASS_WITH_JSON( ..., "mypluginmetadata.json") */ -#ifndef KSERVICE_NO_DEPRECATED - explicit KSERVICE_DEPRECATED KPluginInfo(const KService::Ptr service); + KSERVICE_DEPRECATED_VERSION(5, 0, "Use (Q|K)PluginLoader") + explicit KPluginInfo(const KService::Ptr service); #endif /** @@ -182,6 +183,7 @@ ~KPluginInfo(); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * @return A list of KPluginInfo objects constructed from a list of * KService objects. If you get a trader offer of the plugins you want @@ -192,8 +194,8 @@ * @deprecated since 5.0, use (Q|K)PluginLoader instead and build the * metadata into the plugins using K_PLUGIN_CLASS_WITH_JSON( ..., "mypluginmetadata.json") */ -#ifndef KSERVICE_NO_DEPRECATED - static KSERVICE_DEPRECATED KPluginInfo::List fromServices(const KService::List &services, const KConfigGroup &config = KConfigGroup()); + KSERVICE_DEPRECATED_VERSION(5, 0, "Use (Q|K)PluginLoader") + static KPluginInfo::List fromServices(const KService::List &services, const KConfigGroup &config = KConfigGroup()); #endif /** diff --git a/src/services/kplugininfo.cpp b/src/services/kplugininfo.cpp --- a/src/services/kplugininfo.cpp +++ b/src/services/kplugininfo.cpp @@ -298,7 +298,7 @@ } } -#ifndef KSERVICE_NO_DEPRECATED +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) KPluginInfo::KPluginInfo(const KService::Ptr service) : d(new KPluginInfoPrivate) { @@ -413,7 +413,7 @@ { } -#ifndef KSERVICE_NO_DEPRECATED +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) QList KPluginInfo::fromServices(const KService::List &services, const KConfigGroup &config) { QList infolist; diff --git a/src/services/kservice.h b/src/services/kservice.h --- a/src/services/kservice.h +++ b/src/services/kservice.h @@ -316,6 +316,7 @@ */ bool noDisplay() const; +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * Whether the service should be shown in KDE at all * (including in context menus). @@ -327,8 +328,8 @@ * @since 4.5 * @deprecated since 5.0, use showInCurrentDesktop() */ -#ifndef KSERVICE_NO_DEPRECATED - KSERVICE_DEPRECATED bool showInKDE() const { return showInCurrentDesktop(); } + KSERVICE_DEPRECATED_VERSION(5, 0, "Use KService::showInCurrentDesktop()") + bool showInKDE() const { return showInCurrentDesktop(); } #endif /** diff --git a/src/sycoca/ksycoca.h b/src/sycoca/ksycoca.h --- a/src/sycoca/ksycoca.h +++ b/src/sycoca/ksycoca.h @@ -110,18 +110,21 @@ */ static QString absoluteFilePath(DatabaseType type = LocalDatabase); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 15) /** * @internal - returns language stored inside database */ - KSERVICE_DEPRECATED QString language(); // KF6: remove + KSERVICE_DEPRECATED_VERSION(5, 15, "No longer use.") + QString language(); // KF6: remove /** * @internal - returns timestamp of database * * The database contains all changes made _before_ this time and * _might_ contain changes made after that. */ - KSERVICE_DEPRECATED quint32 timeStamp(); // KF6: remove + KSERVICE_DEPRECATED_VERSION(5, 15, "No longer use.") + quint32 timeStamp(); // KF6: remove /** * @internal - returns update signature of database @@ -132,7 +135,9 @@ * Touching this file causes the database to be recreated * from scratch. */ - KSERVICE_DEPRECATED quint32 updateSignature(); // KF6: remove + KSERVICE_DEPRECATED_VERSION(5, 15, "No longer use.") + quint32 updateSignature(); // KF6: remove +#endif /** * @internal - returns all directories with information @@ -151,22 +156,26 @@ */ virtual bool isBuilding(); +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 15) /** * @internal - disables launching of kbuildsycoca * @deprecated since 5.15, it only outputs a warning */ - KSERVICE_DEPRECATED static void disableAutoRebuild(); // KF6: remove + KSERVICE_DEPRECATED_VERSION(5, 15, "Feature no longer exists.") + static void disableAutoRebuild(); // KF6: remove +#endif +#if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) /** * When you receive a "databaseChanged" signal, you can query here if * a change has occurred in a specific resource type. * @see KStandardDirs for the various resource types. * * This method is meant to be called from the GUI thread only. * @deprecated use the signal databaseChanged(QStringList) instead. */ -#ifndef KSERVICE_NO_DEPRECATED - static KSERVICE_DEPRECATED bool isChanged(const char *type); + KSERVICE_DEPRECATED_VERSION(5, 0, "Use signal KSycoca::databaseChanged(QStringList)") + static bool isChanged(const char *type); #endif /** diff --git a/src/sycoca/ksycoca.cpp b/src/sycoca/ksycoca.cpp --- a/src/sycoca/ksycoca.cpp +++ b/src/sycoca/ksycoca.cpp @@ -415,7 +415,7 @@ d->addFactory(factory); } -#ifndef KSERVICE_NO_DEPRECATED +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) bool KSycoca::isChanged(const char *type) { return self()->d->changeList.contains(QString::fromLatin1(type)); @@ -655,21 +655,25 @@ return true; } +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 15) quint32 KSycoca::timeStamp() { if (!d->timeStamp) { (void) d->readSycocaHeader(); } return d->timeStamp / 1000; // from ms to s } +#endif +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 15) quint32 KSycoca::updateSignature() { if (!d->timeStamp) { (void) d->readSycocaHeader(); } return d->updateSig; } +#endif QString KSycoca::absoluteFilePath(DatabaseType type) { @@ -692,13 +696,15 @@ } } +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 15) QString KSycoca::language() { if (d->language.isEmpty()) { (void) d->readSycocaHeader(); } return d->language; } +#endif QStringList KSycoca::allResourceDirs() { @@ -728,10 +734,12 @@ return false; } +#if KSERVICE_BUILD_DEPRECATED_SINCE(5, 15) void KSycoca::disableAutoRebuild() { qCWarning(SYCOCA) << "KSycoca::disableAutoRebuild() is internal, do not call it."; } +#endif QDataStream *&KSycoca::stream() { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,10 +17,16 @@ kservice_executable_tests( startserviceby - kdbusservicestartertest kservicegroup_dumper findservice ) +if(NOT EXCLUDE_DEPRECATED_BEFORE_AND_AT STREQUAL "CURRENT" AND + EXCLUDE_DEPRECATED_BEFORE_AND_AT VERSION_LESS 5.61.0) + kservice_executable_tests( + kdbusservicestartertest + ) +endif() + set(kmimeassociations_dumper_debug_SRCS) ecm_qt_declare_logging_category(kmimeassociations_dumper_debug_SRCS HEADER sycocadebug.h IDENTIFIER SYCOCA CATEGORY_NAME kf5.kservice.sycoca) set(kmimeassociations_dumper_SRCS kmimeassociations_dumper.cpp ../src/sycoca/kmimeassociations.cpp ${kmimeassociations_dumper_debug_SRCS})