diff -Nru kcoreaddons-5.18.0/.arcconfig kcoreaddons-5.44.0a/.arcconfig --- kcoreaddons-5.18.0/.arcconfig 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/.arcconfig 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,3 @@ +{ + "phabricator.uri" : "https://phabricator.kde.org/" +} diff -Nru kcoreaddons-5.18.0/autotests/CMakeLists.txt kcoreaddons-5.44.0a/autotests/CMakeLists.txt --- kcoreaddons-5.18.0/autotests/CMakeLists.txt 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/CMakeLists.txt 2018-03-06 08:12:31.000000000 +0000 @@ -1,5 +1,3 @@ -remove_definitions(-DQT_NO_CAST_FROM_ASCII) - include(ECMAddTests) include(ConfigureChecks.cmake) #configure checks for QFileSystemWatcher @@ -28,6 +26,7 @@ ecm_add_tests( kaboutdatatest.cpp + kaboutdataapplicationdatatest.cpp kautosavefiletest.cpp kcompositejobtest.cpp kformattest.cpp @@ -36,6 +35,7 @@ kpluginloadertest.cpp kpluginmetadatatest.cpp kprocesstest.cpp + krandomtest.cpp kshareddatacachetest.cpp kshelltest.cpp kurlmimedatatest.cpp diff -Nru kcoreaddons-5.18.0/autotests/data/fakeplugin.desktop kcoreaddons-5.44.0a/autotests/data/fakeplugin.desktop --- kcoreaddons-5.18.0/autotests/data/fakeplugin.desktop 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/fakeplugin.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -84,7 +84,7 @@ X-KDE-PluginInfo-Email=sebas@kde.org X-KDE-PluginInfo-Name=fakeplugin X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website=http://kde.org/ +X-KDE-PluginInfo-Website=https://kde.org/ X-KDE-PluginInfo-Category=Examples X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=LGPL diff -Nru kcoreaddons-5.18.0/autotests/data/hiddenplugin.desktop kcoreaddons-5.44.0a/autotests/data/hiddenplugin.desktop --- kcoreaddons-5.18.0/autotests/data/hiddenplugin.desktop 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/hiddenplugin.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -84,7 +84,7 @@ X-KDE-PluginInfo-Email=sebas@kde.org X-KDE-PluginInfo-Name=fakeplugin X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website=http://kde.org/ +X-KDE-PluginInfo-Website=https://kde.org/ X-KDE-PluginInfo-Category=Examples X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=LGPL diff -Nru kcoreaddons-5.18.0/autotests/data/servicetypes/bool-servicetype.desktop kcoreaddons-5.44.0a/autotests/data/servicetypes/bool-servicetype.desktop --- kcoreaddons-5.18.0/autotests/data/servicetypes/bool-servicetype.desktop 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/servicetypes/bool-servicetype.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=ServiceType + +[PropertyDef::X-Test-Bool] +Type=bool + diff -Nru kcoreaddons-5.18.0/autotests/data/servicetypes/fake-kdedmodule.desktop kcoreaddons-5.44.0a/autotests/data/servicetypes/fake-kdedmodule.desktop --- kcoreaddons-5.18.0/autotests/data/servicetypes/fake-kdedmodule.desktop 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/servicetypes/fake-kdedmodule.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KDEDModule +[PropertyDef::X-KDE-FactoryName] +Type=QString +[PropertyDef::X-KDE-DBus-ModuleName] +Type=QString +[PropertyDef::X-KDE-Kded-autoload] +Type=bool +[PropertyDef::X-KDE-Kded-load-on-demand] +Type=bool diff -Nru kcoreaddons-5.18.0/autotests/data/servicetypes/fake-kdevelopplugin.desktop kcoreaddons-5.44.0a/autotests/data/servicetypes/fake-kdevelopplugin.desktop --- kcoreaddons-5.18.0/autotests/data/servicetypes/fake-kdevelopplugin.desktop 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/servicetypes/fake-kdevelopplugin.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -2,7 +2,7 @@ [Desktop Entry] Type=ServiceType -X-KDE-ServiceType=KDevelop/Plugin +X-KDE-ServiceType=KDevelop/NonExistentPlugin X-KDE-Derived=KPluginInfo #Name=KDevelop Plugin diff -Nru kcoreaddons-5.18.0/autotests/data/servicetypes/invalid-missing-servicetype.desktop kcoreaddons-5.44.0a/autotests/data/servicetypes/invalid-missing-servicetype.desktop --- kcoreaddons-5.18.0/autotests/data/servicetypes/invalid-missing-servicetype.desktop 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/servicetypes/invalid-missing-servicetype.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,7 @@ +[Desktop Entry] +# Type must be ServiceType otherwise this file is invalid +Type=Service + +# as this file is invalid check that this property is not converted +[PropertyDef::ShouldNotBeConvertedToInt] +Type=int diff -Nru kcoreaddons-5.18.0/autotests/data/twostepsparsetest.desktop kcoreaddons-5.44.0a/autotests/data/twostepsparsetest.desktop --- kcoreaddons-5.18.0/autotests/data/twostepsparsetest.desktop 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/data/twostepsparsetest.desktop 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,20 @@ +[Desktop Entry] +Name=Parse Test +Comment=Two Steps Parsing Test +Type=Service +Icon=preferences-system-time +MimeType=image/png;application/pdf; + +X-Test-List=first,second +X-KDE-ServiceTypes=example/servicetype +X-KDE-Library=fakeplugin +X-KDE-FormFactors=mediacenter,desktop +X-KDE-PluginInfo-Author=Sebastian Kügler +X-KDE-PluginInfo-Email=sebas@kde.org +X-KDE-PluginInfo-Name=fakeplugin +X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-Website=https://kde.org/ +X-KDE-PluginInfo-Category=Examples +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true diff -Nru kcoreaddons-5.18.0/autotests/desktoptojsontest.cpp kcoreaddons-5.44.0a/autotests/desktoptojsontest.cpp --- kcoreaddons-5.18.0/autotests/desktoptojsontest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/desktoptojsontest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -81,80 +81,82 @@ QJsonObject expectedResult; QJsonObject kpluginObj; QByteArray input = - // include an insignificant group - "[Some Group]\n" - "Foo=Bar\n" - "\n" - "[Desktop Entry]\n" - // only data inside [Desktop Entry] should be included - "Name=Example\n" - //empty lines - "\n" - " \n" - // make sure translations are included: - "Name[de_DE]=Beispiel\n" - // ignore comments: - "#Comment=Comment\n" - " #Comment=Comment\n" - "Categories=foo;bar;a\\;b\n" - // As the case is significant, the keys Name and NAME are not equivalent: - "CaseSensitive=ABC\n" - "CASESENSITIVE=abc\n" - // Space before and after the equals sign should be ignored: - "SpacesBeforeEq =foo\n" - "SpacesAfterEq= foo\n" - // Space before and after the equals sign should be ignored; the = sign is the actual delimiter. - // TODO: error in spec (spaces before and after the key??) - " SpacesBeforeKey=foo\n" - "SpacesAfterKey =foo\n" - // ignore trailing spaces - "TrailingSpaces=foo \n" - // However spaces in the value are significant: - "SpacesInValue=Hello, World!\n" - // The escape sequences \s, \n, \t, \r, and \\ are supported for values of - // type string and localestring, meaning ASCII space, newline, tab, - // carriage return, and backslash, respectively: - "EscapeSequences=So\\sme esc\\nap\\te se\\\\qu\\re\\\\nces\n" // make sure that the last n is a literal n not a newline! - // the standard keys that are used by plugins, make sure correct types are used: - "X-KDE-PluginInfo-Category=Examples\n" // string key - "X-KDE-PluginInfo-Version=1.0\n" - // The multiple values should be separated by a semicolon and the value of the key - // may be optionally terminated by a semicolon. Trailing empty strings must always - // be terminated with a semicolon. Semicolons in these values need to be escaped using \;. - "X-KDE-PluginInfo-Depends=foo,bar,esc\\,aped\n" // string list key - "X-KDE-ServiceTypes=\n" // empty string list - "X-KDE-PluginInfo-EnabledByDefault=true\n" // bool key - // now start a new group - "[New Group]\n" - "InWrongGroup=true\n"; - - expectedResult["Categories"] = QStringLiteral("foo;bar;a\\;b"); - expectedResult["CaseSensitive"] = QStringLiteral("ABC"); - expectedResult["CASESENSITIVE"] = QStringLiteral("abc"); - expectedResult["SpacesBeforeEq"] = QStringLiteral("foo"); - expectedResult["SpacesAfterEq"] = QStringLiteral("foo"); - expectedResult["SpacesBeforeKey"] = QStringLiteral("foo"); - expectedResult["SpacesAfterKey"] = QStringLiteral("foo"); - expectedResult["TrailingSpaces"] = QStringLiteral("foo"); - expectedResult["SpacesInValue"] = QStringLiteral("Hello, World!"); - expectedResult["EscapeSequences"] = QStringLiteral("So me esc\nap\te se\\qu\re\\nces"); - kpluginObj["Name"] = QStringLiteral("Example"); - kpluginObj["Name[de_DE]"] = QStringLiteral("Beispiel"); - kpluginObj["Category"] = QStringLiteral("Examples"); - kpluginObj["Dependencies"] = QJsonArray::fromStringList(QStringList() << "foo" << "bar" << "esc,aped"); - kpluginObj["ServiceTypes"] = QJsonArray::fromStringList(QStringList()); - kpluginObj["EnabledByDefault"] = true; - kpluginObj["Version"] = QStringLiteral("1.0"); + // include an insignificant group + "[Some Group]\n" + "Foo=Bar\n" + "\n" + "[Desktop Entry]\n" + // only data inside [Desktop Entry] should be included + "Name=Example\n" + //empty lines + "\n" + " \n" + // make sure translations are included: + "Name[de_DE]=Beispiel\n" + // ignore comments: + "#Comment=Comment\n" + " #Comment=Comment\n" + "Categories=foo;bar;a\\;b\n" + // As the case is significant, the keys Name and NAME are not equivalent: + "CaseSensitive=ABC\n" + "CASESENSITIVE=abc\n" + // Space before and after the equals sign should be ignored: + "SpacesBeforeEq =foo\n" + "SpacesAfterEq= foo\n" + // Space before and after the equals sign should be ignored; the = sign is the actual delimiter. + // TODO: error in spec (spaces before and after the key??) + " SpacesBeforeKey=foo\n" + "SpacesAfterKey =foo\n" + // ignore trailing spaces + "TrailingSpaces=foo \n" + // However spaces in the value are significant: + "SpacesInValue=Hello, World!\n" + // The escape sequences \s, \n, \t, \r, and \\ are supported for values of + // type string and localestring, meaning ASCII space, newline, tab, + // carriage return, and backslash, respectively: + "EscapeSequences=So\\sme esc\\nap\\te se\\\\qu\\re\\\\nces\n" // make sure that the last n is a literal n not a newline! + // the standard keys that are used by plugins, make sure correct types are used: + "X-KDE-PluginInfo-Category=Examples\n" // string key + "X-KDE-PluginInfo-Version=1.0\n" + // The multiple values should be separated by a semicolon and the value of the key + // may be optionally terminated by a semicolon. Trailing empty strings must always + // be terminated with a semicolon. Semicolons in these values need to be escaped using \;. + "X-KDE-PluginInfo-Depends=foo,bar,esc\\,aped\n" // string list key + "X-KDE-ServiceTypes=\n" // empty string list + "X-KDE-PluginInfo-EnabledByDefault=true\n" // bool key + // now start a new group + "[New Group]\n" + "InWrongGroup=true\n"; + + expectedResult[QStringLiteral("Categories")] = QStringLiteral("foo;bar;a\\;b"); + expectedResult[QStringLiteral("CaseSensitive")] = QStringLiteral("ABC"); + expectedResult[QStringLiteral("CASESENSITIVE")] = QStringLiteral("abc"); + expectedResult[QStringLiteral("SpacesBeforeEq")] = QStringLiteral("foo"); + expectedResult[QStringLiteral("SpacesAfterEq")] = QStringLiteral("foo"); + expectedResult[QStringLiteral("SpacesBeforeKey")] = QStringLiteral("foo"); + expectedResult[QStringLiteral("SpacesAfterKey")] = QStringLiteral("foo"); + expectedResult[QStringLiteral("TrailingSpaces")] = QStringLiteral("foo"); + expectedResult[QStringLiteral("SpacesInValue")] = QStringLiteral("Hello, World!"); + expectedResult[QStringLiteral("EscapeSequences")] = QStringLiteral("So me esc\nap\te se\\qu\re\\nces"); + kpluginObj[QStringLiteral("Name")] = QStringLiteral("Example"); + kpluginObj[QStringLiteral("Name[de_DE]")] = QStringLiteral("Beispiel"); + kpluginObj[QStringLiteral("Category")] = QStringLiteral("Examples"); + kpluginObj[QStringLiteral("Dependencies")] = QJsonArray::fromStringList + (QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped")); + kpluginObj[QStringLiteral("ServiceTypes")] = QJsonArray::fromStringList(QStringList()); + kpluginObj[QStringLiteral("EnabledByDefault")] = true; + kpluginObj[QStringLiteral("Version")] = QStringLiteral("1.0"); QJsonObject compatResult = expectedResult; - compatResult["Name"] = QStringLiteral("Example"); - compatResult["Name[de_DE]"] = QStringLiteral("Beispiel"); - compatResult["X-KDE-PluginInfo-Category"] = QStringLiteral("Examples"); - compatResult["X-KDE-PluginInfo-Version"] = QStringLiteral("1.0"); - compatResult["X-KDE-PluginInfo-Depends"] = QJsonArray::fromStringList(QStringList() << "foo" << "bar" << "esc,aped"); - compatResult["X-KDE-ServiceTypes"] = QJsonArray::fromStringList(QStringList()); - compatResult["X-KDE-PluginInfo-EnabledByDefault"] = true; + compatResult[QStringLiteral("Name")] = QStringLiteral("Example"); + compatResult[QStringLiteral("Name[de_DE]")] = QStringLiteral("Beispiel"); + compatResult[QStringLiteral("X-KDE-PluginInfo-Category")] = QStringLiteral("Examples"); + compatResult[QStringLiteral("X-KDE-PluginInfo-Version")] = QStringLiteral("1.0"); + compatResult[QStringLiteral("X-KDE-PluginInfo-Depends")] = QJsonArray::fromStringList + (QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped")); + compatResult[QStringLiteral("X-KDE-ServiceTypes")] = QJsonArray::fromStringList(QStringList()); + compatResult[QStringLiteral("X-KDE-PluginInfo-EnabledByDefault")] = true; - expectedResult["KPlugin"] = kpluginObj; + expectedResult[QStringLiteral("KPlugin")] = kpluginObj; QTest::newRow("newFormat") << input << expectedResult << false << QStringList(); QTest::newRow("compatFormat") << input << compatResult << true << QStringList(); @@ -162,101 +164,148 @@ // test conversion of a currently existing .desktop file (excluding most of the translations): QByteArray kdevInput = - "[Desktop Entry]\n" - "Type=Service\n" - "Icon=text-x-c++src\n" - "Exec=blubb\n" - "Comment=C/C++ Language Support\n" - "Comment[fr]=Prise en charge du langage C/C++\n" - "Comment[it]=Supporto al linguaggio C/C++\n" - "Name=C++ Support\n" - "Name[fi]=C++-tuki\n" - "Name[fr]=Prise en charge du C++\n" - "GenericName=Language Support\n" - "GenericName[sl]=Podpora jeziku\n" - "ServiceTypes=KDevelop/Plugin\n" - "X-KDE-Library=kdevcpplanguagesupport\n" - "X-KDE-PluginInfo-Name=kdevcppsupport\n" - "X-KDE-PluginInfo-Category=Language Support\n" - "X-KDevelop-Version=1\n" - "X-KDevelop-Language=C++\n" - "X-KDevelop-Args=CPP\n" - "X-KDevelop-Interfaces=ILanguageSupport\n" - "X-KDevelop-SupportedMimeTypes=text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\n" - "X-KDevelop-Mode=NoGUI\n" - "X-KDevelop-LoadMode=AlwaysOn"; + "[Desktop Entry]\n" + "Type = Service\n" + "Icon=text-x-c++src\n" + "Exec=blubb\n" + "Comment=C/C++ Language Support\n" + "Comment[fr]=Prise en charge du langage C/C++\n" + "Comment[it]=Supporto al linguaggio C/C++\n" + "Name=C++ Support\n" + "Name[fi]=C++-tuki\n" + "Name[fr]=Prise en charge du C++\n" + "GenericName=Language Support\n" + "GenericName[sl]=Podpora jeziku\n" + "ServiceTypes=KDevelop/NonExistentPlugin\n" + "X-KDE-Library=kdevcpplanguagesupport\n" + "X-KDE-PluginInfo-Name=kdevcppsupport\n" + "X-KDE-PluginInfo-Category=Language Support\n" + "X-KDevelop-Version=1\n" + "X-KDevelop-Language=C++\n" + "X-KDevelop-Args=CPP\n" + "X-KDevelop-Interfaces=ILanguageSupport\n" + "X-KDevelop-SupportedMimeTypes=text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\n" + "X-KDevelop-Mode=NoGUI\n" + "X-KDevelop-LoadMode=AlwaysOn"; QJsonParseError e; QJsonObject kdevExpected = QJsonDocument::fromJson("{\n" - " \"GenericName\": \"Language Support\",\n" - " \"GenericName[sl]\": \"Podpora jeziku\",\n" - " \"KPlugin\": {\n" - " \"Category\": \"Language Support\",\n" - " \"Description\": \"C/C++ Language Support\",\n" - " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" - " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" - " \"Icon\": \"text-x-c++src\",\n" - " \"Id\": \"kdevcppsupport\",\n" - " \"Name\": \"C++ Support\",\n" - " \"Name[fi]\": \"C++-tuki\",\n" - " \"Name[fr]\": \"Prise en charge du C++\",\n" - " \"ServiceTypes\": [ \"KDevelop/Plugin\" ]\n" - " },\n" - " \"X-KDevelop-Args\": \"CPP\",\n" - " \"X-KDevelop-Interfaces\": \"ILanguageSupport\",\n" - " \"X-KDevelop-Language\": \"C++\",\n" - " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" - " \"X-KDevelop-Mode\": \"NoGUI\",\n" - " \"X-KDevelop-SupportedMimeTypes\": \"text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\",\n" - " \"X-KDevelop-Version\": \"1\"\n" - "}\n", &e).object(); + " \"GenericName\": \"Language Support\",\n" + " \"GenericName[sl]\": \"Podpora jeziku\",\n" + " \"KPlugin\": {\n" + " \"Category\": \"Language Support\",\n" + " \"Description\": \"C/C++ Language Support\",\n" + " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" + " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" + " \"Icon\": \"text-x-c++src\",\n" + " \"Id\": \"kdevcppsupport\",\n" + " \"Name\": \"C++ Support\",\n" + " \"Name[fi]\": \"C++-tuki\",\n" + " \"Name[fr]\": \"Prise en charge du C++\",\n" + " \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n" + " },\n" + " \"X-KDevelop-Args\": \"CPP\",\n" + " \"X-KDevelop-Interfaces\": \"ILanguageSupport\",\n" + " \"X-KDevelop-Language\": \"C++\",\n" + " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" + " \"X-KDevelop-Mode\": \"NoGUI\",\n" + " \"X-KDevelop-SupportedMimeTypes\": \"text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\",\n" + " \"X-KDevelop-Version\": \"1\"\n" + "}\n", &e).object(); QCOMPARE(e.error, QJsonParseError::NoError); QTest::newRow("kdevcpplanguagesupport no servicetype") << kdevInput << kdevExpected << false << QStringList(); QJsonObject kdevExpectedWithServiceType = QJsonDocument::fromJson("{\n" - " \"GenericName\": \"Language Support\",\n" - " \"GenericName[sl]\": \"Podpora jeziku\",\n" - " \"KPlugin\": {\n" - " \"Category\": \"Language Support\",\n" - " \"Description\": \"C/C++ Language Support\",\n" - " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" - " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" - " \"Icon\": \"text-x-c++src\",\n" - " \"Id\": \"kdevcppsupport\",\n" - " \"Name\": \"C++ Support\",\n" - " \"Name[fi]\": \"C++-tuki\",\n" - " \"Name[fr]\": \"Prise en charge du C++\",\n" - " \"ServiceTypes\": [ \"KDevelop/Plugin\" ]\n" - " },\n" - " \"X-KDevelop-Args\": \"CPP\",\n" - " \"X-KDevelop-Interfaces\": [\"ILanguageSupport\"],\n" - " \"X-KDevelop-Language\": \"C++\",\n" - " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" - " \"X-KDevelop-Mode\": \"NoGUI\",\n" - " \"X-KDevelop-SupportedMimeTypes\": [\"text/x-chdr\", \"text/x-c++hdr\", \"text/x-csrc\", \"text/x-c++src\"],\n" - " \"X-KDevelop-Version\": 1\n" - "}\n", &e).object(); + " \"GenericName\": \"Language Support\",\n" + " \"GenericName[sl]\": \"Podpora jeziku\",\n" + " \"KPlugin\": {\n" + " \"Category\": \"Language Support\",\n" + " \"Description\": \"C/C++ Language Support\",\n" + " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" + " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" + " \"Icon\": \"text-x-c++src\",\n" + " \"Id\": \"kdevcppsupport\",\n" + " \"Name\": \"C++ Support\",\n" + " \"Name[fi]\": \"C++-tuki\",\n" + " \"Name[fr]\": \"Prise en charge du C++\",\n" + " \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n" + " },\n" + " \"X-KDevelop-Args\": \"CPP\",\n" + " \"X-KDevelop-Interfaces\": [\"ILanguageSupport\"],\n" + " \"X-KDevelop-Language\": \"C++\",\n" + " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" + " \"X-KDevelop-Mode\": \"NoGUI\",\n" + " \"X-KDevelop-SupportedMimeTypes\": [\"text/x-chdr\", \"text/x-c++hdr\", \"text/x-csrc\", \"text/x-c++src\"],\n" + " \"X-KDevelop-Version\": 1\n" + "}\n", &e).object(); QCOMPARE(e.error, QJsonParseError::NoError); const QString kdevServiceTypePath = QFINDTESTDATA("data/servicetypes/fake-kdevelopplugin.desktop"); QVERIFY(!kdevServiceTypePath.isEmpty()); QTest::newRow("kdevcpplanguagesupport with servicetype") << kdevInput << kdevExpectedWithServiceType - << false << QStringList(kdevServiceTypePath); + << false << QStringList(kdevServiceTypePath); // test conversion of the X-KDE-PluginInfo-Author + X-KDE-PluginInfo-Email key: QByteArray authorInput = - "[Desktop Entry]\n" - "Type=Service\n" - "X-KDE-PluginInfo-Author=Foo Bar\n" - "X-KDE-PluginInfo-Email=foo.bar@baz.com\n"; + "[Desktop Entry]\n" + "Type=Service\n" + "X-KDE-PluginInfo-Author=Foo Bar\n" + "X-KDE-PluginInfo-Email=foo.bar@baz.com\n"; QJsonObject authorsExpected = QJsonDocument::fromJson("{\n" - " \"KPlugin\": {\n" - " \"Authors\": [ { \"Name\": \"Foo Bar\", \"Email\": \"foo.bar@baz.com\" } ]\n" - " }\n }\n", &e).object(); + " \"KPlugin\": {\n" + " \"Authors\": [ { \"Name\": \"Foo Bar\", \"Email\": \"foo.bar@baz.com\" } ]\n" + " }\n }\n", &e).object(); QCOMPARE(e.error, QJsonParseError::NoError); QTest::newRow("authors") << authorInput << authorsExpected << false << QStringList(); + // test case-insensitive conversion of boolean keys + const QString boolServiceType = QFINDTESTDATA("data/servicetypes/bool-servicetype.desktop"); + QVERIFY(!boolServiceType.isEmpty()); + + QByteArray boolInput1 = "[Desktop Entry]\nType=Service\nX-Test-Bool=true\n"; + QByteArray boolInput2 = "[Desktop Entry]\nType=Service\nX-Test-Bool=TRue\n"; + QByteArray boolInput3 = "[Desktop Entry]\nType=Service\nX-Test-Bool=false\n"; + QByteArray boolInput4 = "[Desktop Entry]\nType=Service\nX-Test-Bool=FALse\n"; + + auto boolResultTrue = QJsonDocument::fromJson("{\"KPlugin\":{},\"X-Test-Bool\": true}", &e).object(); + QCOMPARE(e.error, QJsonParseError::NoError); + auto boolResultFalse = QJsonDocument::fromJson("{\"KPlugin\":{},\"X-Test-Bool\": false}", &e).object(); + QCOMPARE(e.error, QJsonParseError::NoError); + QTest::newRow("bool true") << boolInput1 << boolResultTrue << false << QStringList(boolServiceType); + QTest::newRow("bool TRue") << boolInput2 << boolResultTrue << false << QStringList(boolServiceType); + QTest::newRow("bool false") << boolInput3 << boolResultFalse << false << QStringList(boolServiceType); + QTest::newRow("bool FALse") << boolInput4 << boolResultFalse << false << QStringList(boolServiceType); + + // test conversion of kcookiejar.desktop (for some reason the wrong boolean values were committed) + QByteArray kcookiejarInput = + "[Desktop Entry]\n" + "Type= Service\n" + "Name=Cookie Jar\n" + "Comment=Stores network cookies\n" + "X-KDE-ServiceTypes=KDEDModule\n" + "X-KDE-Library=kf5/kded/kcookiejar\n" + "X-KDE-DBus-ModuleName=kcookiejar\n" + "X-KDE-Kded-autoload=false\n" + "X-KDE-Kded-load-on-demand=true\n"; + auto kcookiejarResult = QJsonDocument::fromJson( + "{\n" + " \"KPlugin\": {\n" + " \"Description\": \"Stores network cookies\",\n" + " \"Name\": \"Cookie Jar\",\n" + " \"ServiceTypes\": [\n" + " \"KDEDModule\"\n" + " ]\n" + " },\n" + "\"X-KDE-DBus-ModuleName\": \"kcookiejar\",\n" + "\"X-KDE-Kded-autoload\": false,\n" + "\"X-KDE-Kded-load-on-demand\": true\n" + "}\n", &e).object(); + const QString kdedmoduleServiceType = QFINDTESTDATA("data/servicetypes/fake-kdedmodule.desktop"); + QVERIFY(!kdedmoduleServiceType.isEmpty()); + QTest::newRow("kcookiejar") << kcookiejarInput << kcookiejarResult << false << QStringList(kdedmoduleServiceType); + } + void testDesktopToJson() { QTemporaryFile output; @@ -275,13 +324,13 @@ QProcess proc; - proc.setProgram(DESKTOP_TO_JSON_EXE); - QStringList arguments = QStringList() << "-i" << inputFile.fileName() << "-o" << output.fileName(); + proc.setProgram(QStringLiteral(DESKTOP_TO_JSON_EXE)); + QStringList arguments = QStringList() << QStringLiteral("-i") << inputFile.fileName() << QStringLiteral("-o") << output.fileName(); if (compatibilityMode) { - arguments << "-c"; + arguments << QStringLiteral("-c"); } foreach(const QString &s, serviceTypes) { - arguments << "-s" << s; + arguments << QStringLiteral("-s") << s; } proc.setArguments(arguments); proc.start(); @@ -290,7 +339,6 @@ QByteArray errorOut = proc.readAllStandardError(); if (!errorOut.isEmpty()) { qWarning().nospace() << "desktoptojson STDERR:\n\n" << errorOut.constData() << "\n"; - QFAIL("desktoptojson had errors"); } QCOMPARE(proc.exitCode(), 0); QVERIFY(output.open()); diff -Nru kcoreaddons-5.18.0/autotests/kaboutdataapplicationdatatest.cpp kcoreaddons-5.44.0a/autotests/kaboutdataapplicationdatatest.cpp --- kcoreaddons-5.18.0/autotests/kaboutdataapplicationdatatest.cpp 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kaboutdataapplicationdatatest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * 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. + */ + +// test object +#include +// Qt +#include +#include + +// Separate test for reading & setting applicationData +// to ensure a separate process where no other test case has +// directly or indirectly called KAboutData::setApplicationData before +// and thus created the global KAboutData object +class KAboutDataApplicationDataTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testInteractionWithQApplicationData(); +}; + + +static const char AppName[] = "app"; +static const char ProgramName[] = "ProgramName"; +static const char Version[] = "Version"; +static const char OrganizationDomain[] = "no.where"; +static const char DesktopFileName[] = "org.kde.someapp"; + +static const char AppName2[] = "otherapp"; +static const char ProgramName2[] = "OtherProgramName"; +static const char Version2[] = "OtherVersion"; +static const char OrganizationDomain2[] = "other.no.where"; +static const char DesktopFileName2[] = "org.kde.otherapp"; + +void KAboutDataApplicationDataTest::testInteractionWithQApplicationData() +{ + // init the app metadata the Qt way + QCoreApplication *app = QCoreApplication::instance(); + app->setApplicationName(QLatin1String(AppName)); + app->setProperty("applicationDisplayName", QLatin1String(ProgramName)); + app->setApplicationVersion(QLatin1String(Version)); + app->setOrganizationDomain(QLatin1String(OrganizationDomain)); + app->setProperty("desktopFileName", QLatin1String(DesktopFileName)); + + // without setting before, get KAboutData::applicationData + const KAboutData applicationAboutData = KAboutData::applicationData(); + + // should be initialized with Q*Application metadata + QCOMPARE(applicationAboutData.componentName(), QLatin1String(AppName)); + QCOMPARE(applicationAboutData.displayName(), QLatin1String(ProgramName)); + QCOMPARE(applicationAboutData.organizationDomain(), QLatin1String(OrganizationDomain)); + QCOMPARE(applicationAboutData.version(), QLatin1String(Version)); + QCOMPARE(applicationAboutData.desktopFileName(), QLatin1String(DesktopFileName)); + + // now set some new KAboutData, with different values + KAboutData aboutData2(QString::fromLatin1(AppName2), QString::fromLatin1(ProgramName2), QString::fromLatin1(Version2)); + aboutData2.setOrganizationDomain(OrganizationDomain2); + aboutData2.setDesktopFileName(QLatin1String(DesktopFileName2)); + + KAboutData::setApplicationData(aboutData2); + + // check that Q*Application metadata has been updated, as expected per API definition + QCOMPARE(app->applicationName(), QLatin1String(AppName2)); + QCOMPARE(app->property("applicationDisplayName").toString(), QLatin1String(ProgramName2)); + QCOMPARE(app->organizationDomain(), QLatin1String(OrganizationDomain2)); + QCOMPARE(app->applicationVersion(), QLatin1String(Version2)); + QCOMPARE(app->property("desktopFileName").toString(), QLatin1String(DesktopFileName2)); + + // and check as well KAboutData::applicationData itself + const KAboutData applicationAboutData2 = KAboutData::applicationData(); + + QCOMPARE(applicationAboutData2.componentName(), QLatin1String(AppName2)); + QCOMPARE(applicationAboutData2.displayName(), QLatin1String(ProgramName2)); + QCOMPARE(applicationAboutData2.organizationDomain(), QLatin1String(OrganizationDomain2)); + QCOMPARE(applicationAboutData2.version(), QLatin1String(Version2)); + QCOMPARE(applicationAboutData2.desktopFileName(), QLatin1String(DesktopFileName2)); +} + +QTEST_MAIN(KAboutDataApplicationDataTest) + +#include "kaboutdataapplicationdatatest.moc" diff -Nru kcoreaddons-5.18.0/autotests/kaboutdatatest.cpp kcoreaddons-5.44.0a/autotests/kaboutdatatest.cpp --- kcoreaddons-5.18.0/autotests/kaboutdatatest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kaboutdatatest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright 2008 Friedrich W. H. Kossebau + * Copyright 2017 Harald Sitter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,6 +24,7 @@ #include #include #include +#include class KAboutDataTest : public QObject { @@ -38,6 +40,9 @@ void testCopying(); void testKAboutDataOrganizationDomain(); + + void testLicenseSPDXID(); + void testLicenseOrLater(); }; static const char AppName[] = "app"; @@ -57,13 +62,13 @@ void KAboutDataTest::testLongFormConstructorWithDefaults() { - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::Unknown); - QCOMPARE(aboutData.componentName(), QLatin1String(AppName)); - QCOMPARE(aboutData.productName(), QLatin1String(AppName)); + QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName)); + QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName)); - QCOMPARE(aboutData.programIconName(), QLatin1String(AppName)); + QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.programLogo(), QVariant()); QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org")); QCOMPARE(aboutData.version(), QString::fromLatin1(Version)); @@ -74,15 +79,15 @@ QVERIFY(aboutData.translators().isEmpty()); QCOMPARE(aboutData.otherText(), QString()); QCOMPARE(aboutData.licenses().count(), 1); -// We don't know the default text, do we? -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); + // We don't know the default text, do we? + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); QCOMPARE(aboutData.copyrightStatement(), QString()); - QCOMPARE(aboutData.shortDescription(), QLatin1String(ShortDescription)); + QCOMPARE(aboutData.shortDescription(), (QLatin1String(ShortDescription))); QCOMPARE(aboutData.customAuthorPlainText(), QString()); QCOMPARE(aboutData.customAuthorRichText(), QString()); QVERIFY(!aboutData.customAuthorTextEnabled()); @@ -92,10 +97,10 @@ void KAboutDataTest::testLongFormConstructor() { - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::Unknown, QLatin1String(CopyrightStatement), QLatin1String(Text), - HomePageAddress, BugsEmailAddress); + QString::fromLatin1(HomePageAddress), QString::fromLatin1(BugsEmailAddress)); QCOMPARE(aboutData.componentName(), QLatin1String(AppName)); QCOMPARE(aboutData.productName(), QLatin1String(AppName)); @@ -109,14 +114,14 @@ QVERIFY(aboutData.authors().isEmpty()); QVERIFY(aboutData.credits().isEmpty()); QVERIFY(aboutData.translators().isEmpty()); - QCOMPARE(aboutData.otherText(), QString::fromLatin1(Text)); + QCOMPARE(aboutData.otherText(), QLatin1String(Text)); QCOMPARE(aboutData.licenses().count(), 1); -// We don't know the default text, do we? -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); + // We don't know the default text, do we? + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); QCOMPARE(aboutData.copyrightStatement(), QLatin1String(CopyrightStatement)); QCOMPARE(aboutData.shortDescription(), QLatin1String(ShortDescription)); @@ -128,10 +133,10 @@ // We support http and https protocols on the homepage address, ensure they // give the same org. domain and desktop file name. - KAboutData aboutDataSecure(AppName, QLatin1String(ProgramName), Version, - QLatin1String(ShortDescription), KAboutLicense::Unknown, - QLatin1String(CopyrightStatement), QLatin1String(Text), - HomePageSecure, BugsEmailAddress); + KAboutData aboutDataSecure(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), + QLatin1String(ShortDescription), KAboutLicense::Unknown, + QLatin1String(CopyrightStatement), QLatin1String(Text), + QString::fromLatin1(HomePageSecure), QString::fromLatin1(BugsEmailAddress)); QCOMPARE(aboutDataSecure.componentName(), QLatin1String(AppName)); QCOMPARE(aboutDataSecure.productName(), QLatin1String(AppName)); QCOMPARE(aboutDataSecure.organizationDomain(), QString::fromLatin1(OrganizationDomain)); @@ -140,12 +145,12 @@ void KAboutDataTest::testShortFormConstructor() { - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version); + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version)); - QCOMPARE(aboutData.componentName(), QLatin1String(AppName)); - QCOMPARE(aboutData.productName(), QLatin1String(AppName)); + QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName)); + QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName)); - QCOMPARE(aboutData.programIconName(), QLatin1String(AppName)); + QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.programLogo(), QVariant()); QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org")); QCOMPARE(aboutData.version(), QString::fromLatin1(Version)); @@ -156,12 +161,12 @@ QVERIFY(aboutData.translators().isEmpty()); QCOMPARE(aboutData.otherText(), QString()); QCOMPARE(aboutData.licenses().count(), 1); -// We don't know the default text, do we? -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); + // We don't know the default text, do we? + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); QCOMPARE(aboutData.copyrightStatement(), QString()); QCOMPARE(aboutData.shortDescription(), QString()); @@ -174,17 +179,17 @@ void KAboutDataTest::testKAboutDataOrganizationDomain() { - KAboutData data("app", QLatin1String("program"), "version", + KAboutData data(QString::fromLatin1("app"), QLatin1String("program"), QString::fromLatin1("version"), QLatin1String("description"), KAboutLicense::LGPL, QLatin1String("copyright"), QLatin1String("hello world"), - "http://www.koffice.org"); + QStringLiteral("http://www.koffice.org")); QCOMPARE(data.organizationDomain(), QString::fromLatin1("koffice.org")); QCOMPARE(data.desktopFileName(), QStringLiteral("org.koffice.app")); - KAboutData data2("app", QLatin1String("program"), "version", + KAboutData data2(QString::fromLatin1("app"), QLatin1String("program"), QString::fromLatin1("version"), QLatin1String("description"), KAboutLicense::LGPL, - QLatin1String("copyright"), QLatin1String("hello world"), - "http://edu.kde.org/kig"); + QString::fromLatin1("copyright"), QLatin1String("hello world"), + QStringLiteral("app")); QCOMPARE(data2.organizationDomain(), QString::fromLatin1("kde.org")); QCOMPARE(data2.desktopFileName(), QStringLiteral("org.kde.app")); } @@ -195,16 +200,16 @@ QFile licenseFile(QString::fromLatin1(LicenseFileName)); licenseFile.open(QIODevice::WriteOnly); QTextStream licenseFileStream(&licenseFile); - licenseFileStream << QLatin1String(LicenseFileText); + licenseFileStream << LicenseFileText; licenseFile.close(); const QString copyrightStatement = QLatin1String(CopyrightStatement); const QString lineFeed = QString::fromLatin1("\n\n"); - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::Unknown, QLatin1String(CopyrightStatement), QLatin1String(Text), - HomePageAddress, BugsEmailAddress); + QString::fromLatin1(HomePageAddress), QString::fromLatin1(BugsEmailAddress)); // set to GPL2 aboutData.setLicense(KAboutLicense::GPL_V2); @@ -212,19 +217,19 @@ QCOMPARE(aboutData.licenses().count(), 1); QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v2")); QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 2")); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL2Text) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL2Text) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); // set to Unknown again aboutData.setLicense(KAboutLicense::Unknown); QCOMPARE(aboutData.licenses().count(), 1); -// We don't know the default text, do we? -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); + // We don't know the default text, do we? + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty()); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); // add GPL3 @@ -233,69 +238,76 @@ QCOMPARE(aboutData.licenses().count(), 1); QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v3")); QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 3")); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); // add GPL2, Custom and File aboutData.addLicense(KAboutLicense::GPL_V2); aboutData.addLicenseText(QLatin1String(LicenseText)); - aboutData.addLicenseTextFile(QString::fromLatin1(LicenseFileName)); + aboutData.addLicenseTextFile(QLatin1String(LicenseFileName)); QCOMPARE(aboutData.licenses().count(), 4); QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v3")); QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 3")); -// QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) ); + // QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) ); QVERIFY(!aboutData.licenses().at(0).text().isEmpty()); QCOMPARE(aboutData.licenses().at(1).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v2")); QCOMPARE(aboutData.licenses().at(1).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 2")); -// QCOMPARE( aboutData.licenses().at(1).text(), QString(GPL2Text) ); + // QCOMPARE( aboutData.licenses().at(1).text(), QString(GPL2Text) ); QVERIFY(!aboutData.licenses().at(1).text().isEmpty()); QCOMPARE(aboutData.licenses().at(2).name(KAboutLicense::ShortName), QString::fromLatin1("Custom")); QCOMPARE(aboutData.licenses().at(2).name(KAboutLicense::FullName), QString::fromLatin1("Custom")); QCOMPARE(aboutData.licenses().at(2).text(), QLatin1String(LicenseText)); QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::ShortName), QString::fromLatin1("Custom")); QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::FullName), QString::fromLatin1("Custom")); - QCOMPARE(aboutData.licenses().at(3).text(), QString(copyrightStatement + lineFeed + QLatin1String(LicenseFileText))); + QCOMPARE(aboutData.licenses().at(3).text(), QString(copyrightStatement + lineFeed + + QLatin1String(LicenseFileText))); } void KAboutDataTest::testSetProgramIconName() { - const QLatin1String programIconName(ProgramIconName); + const QString programIconName(QString::fromLatin1(ProgramIconName)); - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::Unknown, QLatin1String(CopyrightStatement), QLatin1String(Text), - HomePageAddress, BugsEmailAddress); + QString::fromLatin1(HomePageAddress), QString::fromLatin1(BugsEmailAddress)); + // Deprecated, still want to test this though. Silence GCC warnings. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // set different iconname aboutData.setProgramIconName(programIconName); +#pragma GCC diagnostic pop QCOMPARE(aboutData.programIconName(), programIconName); } void KAboutDataTest::testCopying() { - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::GPL_V2); { - KAboutData aboutData2(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData2(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::GPL_V3); - aboutData2.addLicense(KAboutLicense::GPL_V2); + aboutData2.addLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions); aboutData = aboutData2; } QList licenses = aboutData.licenses(); QCOMPARE(licenses.count(), 2); QCOMPARE(licenses.at(0).key(), KAboutLicense::GPL_V3); + QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-3.0")); // check it doesn't crash QVERIFY(!licenses.at(0).text().isEmpty()); QCOMPARE(licenses.at(1).key(), KAboutLicense::GPL_V2); + QCOMPARE(aboutData.licenses().at(1).spdx(), QStringLiteral("GPL-2.0+")); // check it doesn't crash QVERIFY(!licenses.at(1).text().isEmpty()); } void KAboutDataTest::testSetDesktopFileName() { - KAboutData aboutData(AppName, QLatin1String(ProgramName), Version, + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), QLatin1String(ShortDescription), KAboutLicense::Unknown); QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app")); @@ -304,6 +316,49 @@ QCOMPARE(aboutData.desktopFileName(), QStringLiteral("foo.bar.application")); } +void KAboutDataTest::testLicenseSPDXID() +{ + // Input with + should output with +. + auto license = KAboutLicense::byKeyword(QStringLiteral("GPLv2+")); + QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0+")); + // Input without should output without. + license = KAboutLicense::byKeyword(QStringLiteral("GPLv2")); + QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0")); + + //we should be able to match by spdx too + //create a KAboutLicense from enum, then make sure going to spdx and back gives the same enum + for(int i = 1; i <= KAboutLicense::LGPL_V2_1 ; ++i) { /*current highest enum value*/ + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), + QLatin1String(ShortDescription), KAboutLicense::GPL_V2); + aboutData.setLicense(KAboutLicense::LicenseKey(i)); + QVERIFY(aboutData.licenses().count() == 1); + auto license = aboutData.licenses()[0]; + auto licenseFromKeyword = KAboutLicense::byKeyword(license.spdx()); + + QCOMPARE(license.key(), licenseFromKeyword.key()); + } +} + +void KAboutDataTest::testLicenseOrLater() +{ + // For kaboutdata we can replace the license with an orLater version. Or add a second one. + KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), + QLatin1String(ShortDescription), KAboutLicense::GPL_V2); + QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0")); + aboutData.setLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions); + QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0+")); + aboutData.addLicense(KAboutLicense::LGPL_V3, KAboutLicense::OrLaterVersions); + bool foundLGPL = false; + for (auto license : aboutData.licenses()) { + if (license.key() == KAboutLicense::LGPL_V3) { + QCOMPARE(license.spdx(), QStringLiteral("LGPL-3.0+")); + foundLGPL = true; + break; + } + } + QCOMPARE(foundLGPL, true); +} + QTEST_MAIN(KAboutDataTest) #include "kaboutdatatest.moc" diff -Nru kcoreaddons-5.18.0/autotests/kautosavefiletest.cpp kcoreaddons-5.44.0a/autotests/kautosavefiletest.cpp --- kcoreaddons-5.18.0/autotests/kautosavefiletest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kautosavefiletest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -47,7 +47,7 @@ QVERIFY(file.open()); - QUrl normalFile(QFileInfo(file).absoluteFilePath()); + QUrl normalFile = QUrl::fromLocalFile(QFileInfo(file).absoluteFilePath()); //Test basic functionality KAutoSaveFile saveFile(normalFile); @@ -80,7 +80,16 @@ void KAutoSaveFileTest::test_fileStaleFiles() { - // TODO + QUrl normalFile = QUrl::fromLocalFile(QDir::temp().absoluteFilePath(QStringLiteral("test directory/tîst me.txt"))); + + KAutoSaveFile saveFile(normalFile); + QVERIFY(saveFile.open(QIODevice::ReadWrite)); + saveFile.write("testdata"); + // Make sure the stale file is found + QVERIFY(saveFile.staleFiles(normalFile, QStringLiteral("qttest")).count() == 1); + saveFile.releaseLock(); + // Make sure the stale file is deleted + QVERIFY(saveFile.staleFiles(normalFile, QStringLiteral("qttest")).isEmpty()); } void KAutoSaveFileTest::test_applicationStaleFiles() diff -Nru kcoreaddons-5.18.0/autotests/kcompositejobtest.cpp kcoreaddons-5.44.0a/autotests/kcompositejobtest.cpp --- kcoreaddons-5.18.0/autotests/kcompositejobtest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kcompositejobtest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -89,7 +89,7 @@ QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject*))); // check if job got reparented properly - delete someParent; someParent = 0; + delete someParent; someParent = nullptr; // the job should still exist, because it is a child of KCompositeJob now QCOMPARE(destroyed_spy.size(), 0); @@ -97,7 +97,7 @@ compositeJob->start(); // delete the job during the execution - delete compositeJob; compositeJob = 0; + delete compositeJob; compositeJob = nullptr; // at this point, the subjob should be deleted, too QCOMPARE(destroyed_spy.size(), 1); } diff -Nru kcoreaddons-5.18.0/autotests/kcompositejobtest.h kcoreaddons-5.44.0a/autotests/kcompositejobtest.h --- kcoreaddons-5.18.0/autotests/kcompositejobtest.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kcompositejobtest.h 2018-03-06 08:12:31.000000000 +0000 @@ -30,7 +30,7 @@ Q_OBJECT public: - explicit TestJob(QObject *parent = 0); + explicit TestJob(QObject *parent = nullptr); /// Takes 1 second to finish void start() Q_DECL_OVERRIDE; @@ -44,7 +44,7 @@ Q_OBJECT public: - explicit CompositeJob(QObject *parent = 0) : KCompositeJob(parent) {} + explicit CompositeJob(QObject *parent = nullptr) : KCompositeJob(parent) {} void start() Q_DECL_OVERRIDE; bool addSubjob(KJob *job) Q_DECL_OVERRIDE; diff -Nru kcoreaddons-5.18.0/autotests/kdelibs4migrationtest.cpp kcoreaddons-5.44.0a/autotests/kdelibs4migrationtest.cpp --- kcoreaddons-5.18.0/autotests/kdelibs4migrationtest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kdelibs4migrationtest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -40,11 +40,10 @@ QString kdehome = kdehomeDir.path(); qputenv("KDEHOME", QFile::encodeName(kdehome)); - QString oldConfigDir = kdehome + "/share/config/"; + QString oldConfigDir = kdehome + QStringLiteral("/share/config/"); QVERIFY(QDir().mkpath(oldConfigDir)); - QString oldAppsDir = kdehome + "/share/apps/"; + QString oldAppsDir = kdehome + QStringLiteral("/share/apps/"); QVERIFY(QDir().mkpath(oldAppsDir)); - // Test Kdelibs4Migration migration; diff -Nru kcoreaddons-5.18.0/autotests/kdirwatch_unittest.cpp kcoreaddons-5.44.0a/autotests/kdirwatch_unittest.cpp --- kcoreaddons-5.18.0/autotests/kdirwatch_unittest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kdirwatch_unittest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -77,12 +77,12 @@ public: KDirWatch_UnitTest() { - s_staticObjectUsingSelf(); - - m_path = m_tempDir.path() + QLatin1Char('/'); // Speed up the test by making the kdirwatch timer (to compress changes) faster qputenv("KDIRWATCH_POLLINTERVAL", "50"); qputenv("KDIRWATCH_METHOD", KDIRWATCH_TEST_METHOD); + s_staticObjectUsingSelf(); + + m_path = m_tempDir.path() + QLatin1Char('/'); KDirWatch *dirW = &s_staticObject()->m_dirWatch; m_slow = (dirW->internalMethod() == KDirWatch::FAM || dirW->internalMethod() == KDirWatch::Stat); qDebug() << "Using method" << methodToString(dirW->internalMethod()); @@ -91,6 +91,9 @@ private Q_SLOTS: // test methods void initTestCase() { + QFileInfo pathInfo(m_path); + QVERIFY(pathInfo.isDir() && pathInfo.isWritable()); + // By creating the files upfront, we save waiting a full second for an mtime change createFile(m_path + QLatin1String("ExistingFile")); createFile(m_path + QLatin1String("TestFile")); @@ -112,6 +115,10 @@ void nestedEventLoop(); void testHardlinkChange(); void stopAndRestart(); + void shouldIgnoreQrcPaths(); + void benchCreateTree(); + void benchCreateWatcher(); + void benchNotifyWatcher(); protected Q_SLOTS: // internal slots void nestedEventLoopSlot(); @@ -130,6 +137,7 @@ void removeFile(int num); void appendToFile(const QString &path); void appendToFile(int num); + int createDirectoryTree(const QString &path, int depth = 4); QTemporaryDir m_tempDir; QString m_path; @@ -147,9 +155,7 @@ void KDirWatch_UnitTest::createFile(const QString &path) { QFile file(path); - bool ok = file.open(QIODevice::WriteOnly); - Q_UNUSED(ok) // silence warnings - Q_ASSERT(ok); + QVERIFY(file.open(QIODevice::WriteOnly)); file.write(QByteArray("foo")); file.close(); //qDebug() << path; @@ -170,6 +176,30 @@ QFile::remove(m_path + fileName); } +int KDirWatch_UnitTest::createDirectoryTree(const QString& basePath, int depth) +{ + int filesCreated = 0; + + const int numFiles = 10; + for (int i = 0; i < numFiles; ++i) { + createFile(basePath + QLatin1Char('/') + QLatin1String(s_filePrefix) + QString::number(i)); + ++filesCreated; + } + + if (depth <= 0) { + return filesCreated; + } + + const int numFolders = 5; + for (int i = 0; i < numFolders; ++i) { + const QString childPath = basePath + QLatin1String("/subdir") + QString::number(i); + QDir().mkdir(childPath); + filesCreated += createDirectoryTree(childPath, depth - 1); + } + + return filesCreated; +} + void KDirWatch_UnitTest::waitUntilMTimeChange(const QString &path) { // Wait until the current second is more than the file's mtime @@ -256,7 +286,7 @@ qWarning() << "Timeout waiting for KDirWatch. Got" << spyDirty.count() << "dirty() signals, expected" << expected; return spyDirty; } - QTest::qWait(50); + spyDirty.wait(50); } return spyDirty; } @@ -273,7 +303,7 @@ qWarning() << "Timeout waiting for KDirWatch signal" << QByteArray(sig).mid(1) << "(" << path << ")"; return false; } - QTest::qWait(50); + spyDirty.wait(50); } return verifySignalPath(spyDirty, sig, expectedPath); } @@ -330,7 +360,7 @@ qWarning() << "Timeout waiting for KDirWatch. Got" << spyDeleted.count() << "deleted() signals, expected" << expected; return spyDeleted; } - QTest::qWait(50); + spyDeleted.wait(50); } return spyDeleted; } @@ -512,20 +542,24 @@ //QCOMPARE(KDE::stat(QFile::encodeName(file1), &stat_buf), 0); //qDebug() << "initial inode" << stat_buf.st_ino; - QFile::remove(file1); - // And recreate immediately, to try and fool KDirWatch with unchanged ctime/mtime ;) - // (This emulates the /etc/localtime case) - createFile(file1); + // Make sure this even works multiple times, as needed for ksycoca + for (int i = 0; i < 5; ++i) { - //QCOMPARE(KDE::stat(QFile::encodeName(file1), &stat_buf), 0); - //qDebug() << "new inode" << stat_buf.st_ino; // same! + QFile::remove(file1); + // And recreate immediately, to try and fool KDirWatch with unchanged ctime/mtime ;) + // (This emulates the /etc/localtime case) + createFile(file1); - { - QSignalSpy spyDirty(&watch, SIGNAL(dirty(QString))); - if(!waitForRecreationSignal(watch, file1)) { - // We may get a dirty signal here instead of a deleted/created set. - if (spyDirty.isEmpty() || !verifySignalPath(spyDirty, SIGNAL(dirty(QString)), file1)) { - QFAIL("Failed to detect file deletion and recreation through either a deleted/created signal pair or through a dirty signal!"); + //QCOMPARE(KDE::stat(QFile::encodeName(file1), &stat_buf), 0); + //qDebug() << "new inode" << stat_buf.st_ino; // same! + + { + QSignalSpy spyDirty(&watch, SIGNAL(dirty(QString))); + if(!waitForRecreationSignal(watch, file1)) { + // We may get a dirty signal here instead of a deleted/created set. + if (spyDirty.isEmpty() || !verifySignalPath(spyDirty, SIGNAL(dirty(QString)), file1)) { + QFAIL("Failed to detect file deletion and recreation through either a deleted/created signal pair or through a dirty signal!"); + } } } } @@ -745,4 +779,66 @@ QFile::remove(file3); } +void KDirWatch_UnitTest::shouldIgnoreQrcPaths() +{ + const auto oldCwd = QDir::currentPath(); + QVERIFY(QDir::setCurrent(QDir::homePath())); + + KDirWatch watch; + watch.addDir(QDir::homePath()); + // This triggers bug #374075. + watch.addDir(QStringLiteral(":/kio5/newfile-templates")); + + QSignalSpy dirtySpy(&watch, &KDirWatch::dirty); + + QFile file(QStringLiteral("bug374075.txt")); + QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY(file.write(QByteArrayLiteral("test"))); + file.close(); + QVERIFY(file.exists()); + QVERIFY(dirtySpy.wait()); + QVERIFY(dirtySpy.count() > 0); + QVERIFY(file.remove()); + QVERIFY(QDir::setCurrent(oldCwd)); +} + +void KDirWatch_UnitTest::benchCreateTree() +{ + QTemporaryDir dir; + + QBENCHMARK { + createDirectoryTree(dir.path()); + } +} + +void KDirWatch_UnitTest::benchCreateWatcher() +{ + QTemporaryDir dir; + createDirectoryTree(dir.path()); + + QBENCHMARK { + KDirWatch watch; + watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch:: WatchFiles); + } +} + +void KDirWatch_UnitTest::benchNotifyWatcher() +{ + QTemporaryDir dir; + // create the dir once upfront + auto numFiles = createDirectoryTree(dir.path()); + waitUntilMTimeChange(dir.path()); + + KDirWatch watch; + watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch:: WatchFiles); + + // now touch all the files repeatedly and wait for the dirty updates to come in + QSignalSpy spy(&watch, &KDirWatch::dirty); + QBENCHMARK { + createDirectoryTree(dir.path()); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), numFiles, s_maxTries * 50 * 2); + spy.clear(); + } +} + #include "kdirwatch_unittest.moc" diff -Nru kcoreaddons-5.18.0/autotests/kformattest.cpp kcoreaddons-5.44.0a/autotests/kformattest.cpp --- kcoreaddons-5.18.0/autotests/kformattest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kformattest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -30,63 +30,63 @@ void KFormatTest::formatByteSize() { QLocale locale(QLocale::c()); - locale.setNumberOptions(0); // Qt >= 5.6 sets QLocale::OmitGroupSeparator for the C locale + locale.setNumberOptions(QLocale::DefaultNumberOptions); // Qt >= 5.6 sets QLocale::OmitGroupSeparator for the C locale KFormat format(locale); - QCOMPARE(format.formatByteSize(0), QString("0 B")); - QCOMPARE(format.formatByteSize(50), QString("50 B")); - QCOMPARE(format.formatByteSize(500), QString("500 B")); - QCOMPARE(format.formatByteSize(5000), QString("4.9 KiB")); - QCOMPARE(format.formatByteSize(50000), QString("48.8 KiB")); - QCOMPARE(format.formatByteSize(500000), QString("488.3 KiB")); - QCOMPARE(format.formatByteSize(5000000), QString("4.8 MiB")); - QCOMPARE(format.formatByteSize(50000000), QString("47.7 MiB")); - QCOMPARE(format.formatByteSize(500000000), QString("476.8 MiB")); + QCOMPARE(format.formatByteSize(0), QStringLiteral("0 B")); + QCOMPARE(format.formatByteSize(50), QStringLiteral("50 B")); + QCOMPARE(format.formatByteSize(500), QStringLiteral("500 B")); + QCOMPARE(format.formatByteSize(5000), QStringLiteral("4.9 KiB")); + QCOMPARE(format.formatByteSize(50000), QStringLiteral("48.8 KiB")); + QCOMPARE(format.formatByteSize(500000), QStringLiteral("488.3 KiB")); + QCOMPARE(format.formatByteSize(5000000), QStringLiteral("4.8 MiB")); + QCOMPARE(format.formatByteSize(50000000), QStringLiteral("47.7 MiB")); + QCOMPARE(format.formatByteSize(500000000), QStringLiteral("476.8 MiB")); #if (defined(__WORDSIZE) && (__WORDSIZE == 64)) || defined (_LP64) || defined(__LP64__) || defined(__ILP64__) - QCOMPARE(format.formatByteSize(5000000000), QString("4.7 GiB")); - QCOMPARE(format.formatByteSize(50000000000), QString("46.6 GiB")); - QCOMPARE(format.formatByteSize(500000000000), QString("465.7 GiB")); - QCOMPARE(format.formatByteSize(5000000000000), QString("4.5 TiB")); - QCOMPARE(format.formatByteSize(50000000000000), QString("45.5 TiB")); - QCOMPARE(format.formatByteSize(500000000000000), QString("454.7 TiB")); + QCOMPARE(format.formatByteSize(5000000000), QStringLiteral("4.7 GiB")); + QCOMPARE(format.formatByteSize(50000000000), QStringLiteral("46.6 GiB")); + QCOMPARE(format.formatByteSize(500000000000), QStringLiteral("465.7 GiB")); + QCOMPARE(format.formatByteSize(5000000000000), QStringLiteral("4.5 TiB")); + QCOMPARE(format.formatByteSize(50000000000000), QStringLiteral("45.5 TiB")); + QCOMPARE(format.formatByteSize(500000000000000), QStringLiteral("454.7 TiB")); #endif - QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::IECBinaryDialect), QString("1.0 KiB")); - QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::IECBinaryDialect), QString("1,023 B")); - QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::IECBinaryDialect), QString("1.1 MiB")); // 1.2 metric - - QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::IECBinaryDialect), QString("-1.0 KiB")); - QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::IECBinaryDialect), QString("-1,023 B")); - QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::IECBinaryDialect), QString("-1.1 MiB")); // 1.2 metric - - QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::JEDECBinaryDialect), QString("1.0 KB")); - QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::JEDECBinaryDialect), QString("1,023 B")); - QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::JEDECBinaryDialect), QString("1.1 MB")); - - QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::JEDECBinaryDialect), QString("-1.0 KB")); - QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::JEDECBinaryDialect), QString("-1,023 B")); - QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::JEDECBinaryDialect), QString("-1.1 MB")); - - QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::MetricBinaryDialect), QString("1.0 kB")); - QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::MetricBinaryDialect), QString("1.0 kB")); - QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::MetricBinaryDialect), QString("1.2 MB")); - - QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::MetricBinaryDialect), QString("-1.0 kB")); - QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::MetricBinaryDialect), QString("-1.0 kB")); - QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::MetricBinaryDialect), QString("-1.2 MB")); + QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::IECBinaryDialect), QStringLiteral("1.0 KiB")); + QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::IECBinaryDialect), QStringLiteral("1,023 B")); + QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::IECBinaryDialect), QStringLiteral("1.1 MiB")); // 1.2 metric + + QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::IECBinaryDialect), QStringLiteral("-1.0 KiB")); + QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::IECBinaryDialect), QStringLiteral("-1,023 B")); + QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::IECBinaryDialect), QStringLiteral("-1.1 MiB")); // 1.2 metric + + QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("1.0 KB")); + QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("1,023 B")); + QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("1.1 MB")); + + QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("-1.0 KB")); + QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("-1,023 B")); + QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("-1.1 MB")); + + QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("1.0 kB")); + QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("1.0 kB")); + QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("1.2 MB")); + + QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("-1.0 kB")); + QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("-1.0 kB")); + QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("-1.2 MB")); // Ensure all units are represented - QCOMPARE(format.formatByteSize(2.0e9, 1, KFormat::MetricBinaryDialect), QString("2.0 GB")); - QCOMPARE(format.formatByteSize(3.2e12, 1, KFormat::MetricBinaryDialect), QString("3.2 TB")); - QCOMPARE(format.formatByteSize(4.1e15, 1, KFormat::MetricBinaryDialect), QString("4.1 PB")); - QCOMPARE(format.formatByteSize(6.7e18, 2, KFormat::MetricBinaryDialect), QString("6.70 EB")); - QCOMPARE(format.formatByteSize(5.6e20, 2, KFormat::MetricBinaryDialect), QString("560.00 EB")); - QCOMPARE(format.formatByteSize(2.3e22, 2, KFormat::MetricBinaryDialect), QString("23.00 ZB")); - QCOMPARE(format.formatByteSize(1.0e27, 1, KFormat::MetricBinaryDialect), QString("1,000.0 YB")); + QCOMPARE(format.formatByteSize(2.0e9, 1, KFormat::MetricBinaryDialect), QStringLiteral("2.0 GB")); + QCOMPARE(format.formatByteSize(3.2e12, 1, KFormat::MetricBinaryDialect), QStringLiteral("3.2 TB")); + QCOMPARE(format.formatByteSize(4.1e15, 1, KFormat::MetricBinaryDialect), QStringLiteral("4.1 PB")); + QCOMPARE(format.formatByteSize(6.7e18, 2, KFormat::MetricBinaryDialect), QStringLiteral("6.70 EB")); + QCOMPARE(format.formatByteSize(5.6e20, 2, KFormat::MetricBinaryDialect), QStringLiteral("560.00 EB")); + QCOMPARE(format.formatByteSize(2.3e22, 2, KFormat::MetricBinaryDialect), QStringLiteral("23.00 ZB")); + QCOMPARE(format.formatByteSize(1.0e27, 1, KFormat::MetricBinaryDialect), QStringLiteral("1,000.0 YB")); // Spattering of specific units - QCOMPARE(format.formatByteSize(823000, 3, KFormat::IECBinaryDialect, KFormat::UnitMegaByte), QString("0.785 MiB")); - QCOMPARE(format.formatByteSize(1234034.0, 4, KFormat::JEDECBinaryDialect, KFormat::UnitByte), QString("1,234,034 B")); + QCOMPARE(format.formatByteSize(823000, 3, KFormat::IECBinaryDialect, KFormat::UnitMegaByte), QStringLiteral("0.785 MiB")); + QCOMPARE(format.formatByteSize(1234034.0, 4, KFormat::JEDECBinaryDialect, KFormat::UnitByte), QStringLiteral("1,234,034 B")); } enum TimeConstants { @@ -108,158 +108,178 @@ quint64 doubleHour = 15 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700; quint64 singleDay = 1 * MSecsInDay + 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700; quint64 doubleDay = 10 * MSecsInDay + 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700; + quint64 roundingIssues = 2* MSecsInHour + 59 * MSecsInMinute + 59 * MSecsInSecond + 900; // Default format - QCOMPARE(format.formatDuration(singleSecond), QString("0:00:04")); - QCOMPARE(format.formatDuration(doubleSecond), QString("0:00:34")); - QCOMPARE(format.formatDuration(singleMinute), QString("0:08:04")); - QCOMPARE(format.formatDuration(doubleMinute), QString("0:38:04")); - QCOMPARE(format.formatDuration(singleHour), QString("5:08:04")); - QCOMPARE(format.formatDuration(doubleHour), QString("15:08:04")); - QCOMPARE(format.formatDuration(singleDay), QString("29:08:04")); - QCOMPARE(format.formatDuration(doubleDay), QString("245:08:04")); + QCOMPARE(format.formatDuration(singleSecond), QStringLiteral("0:00:04")); + QCOMPARE(format.formatDuration(doubleSecond), QStringLiteral("0:00:34")); + QCOMPARE(format.formatDuration(singleMinute), QStringLiteral("0:08:04")); + QCOMPARE(format.formatDuration(doubleMinute), QStringLiteral("0:38:04")); + QCOMPARE(format.formatDuration(singleHour), QStringLiteral("5:08:04")); + QCOMPARE(format.formatDuration(doubleHour), QStringLiteral("15:08:04")); + QCOMPARE(format.formatDuration(singleDay), QStringLiteral("29:08:04")); + QCOMPARE(format.formatDuration(doubleDay), QStringLiteral("245:08:04")); + QCOMPARE(format.formatDuration(roundingIssues), QStringLiteral("3:00:00")); + // ShowMilliseconds format KFormat::DurationFormatOptions options = KFormat::ShowMilliseconds; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0:00:03.700")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0:00:33.700")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("0:08:03.700")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("0:38:03.700")); - QCOMPARE(format.formatDuration(singleHour, options), QString("5:08:03.700")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("15:08:03.700")); - QCOMPARE(format.formatDuration(singleDay, options), QString("29:08:03.700")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("245:08:03.700")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:00:03.700")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:00:33.700")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0:08:03.700")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0:38:03.700")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5:08:03.700")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15:08:03.700")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29:08:03.700")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245:08:03.700")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("2:59:59.900")); + // HideSeconds format options = KFormat::HideSeconds; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0:00")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0:01")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("0:08")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("0:38")); - QCOMPARE(format.formatDuration(singleHour, options), QString("5:08")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("15:08")); - QCOMPARE(format.formatDuration(singleDay, options), QString("29:08")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("245:08")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:00")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:01")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0:08")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0:38")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5:08")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15:08")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29:08")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245:08")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3:00")); + // FoldHours format options = KFormat::FoldHours; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0:04")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0:34")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("8:04")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("38:04")); - QCOMPARE(format.formatDuration(singleHour, options), QString("308:04")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("908:04")); - QCOMPARE(format.formatDuration(singleDay, options), QString("1748:04")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("14708:04")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:04")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:34")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8:04")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38:04")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308:04")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908:04")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748:04")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708:04")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("180:00")); + // FoldHours ShowMilliseconds format options = KFormat::FoldHours; options = options | KFormat::ShowMilliseconds; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0:03.700")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0:33.700")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("8:03.700")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("38:03.700")); - QCOMPARE(format.formatDuration(singleHour, options), QString("308:03.700")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("908:03.700")); - QCOMPARE(format.formatDuration(singleDay, options), QString("1748:03.700")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("14708:03.700")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:03.700")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:33.700")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8:03.700")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38:03.700")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308:03.700")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908:03.700")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748:03.700")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708:03.700")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("179:59.900")); + // InitialDuration format options = KFormat::InitialDuration; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0h00m04s")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0h00m34s")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("0h08m04s")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("0h38m04s")); - QCOMPARE(format.formatDuration(singleHour, options), QString("5h08m04s")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("15h08m04s")); - QCOMPARE(format.formatDuration(singleDay, options), QString("29h08m04s")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("245h08m04s")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0h00m04s")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0h00m34s")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0h08m04s")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0h38m04s")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5h08m04s")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15h08m04s")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m04s")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m04s")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3h00m00s")); + // InitialDuration and ShowMilliseconds format options = KFormat::InitialDuration; options = options | KFormat::ShowMilliseconds; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0h00m03.700s")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0h00m33.700s")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("0h08m03.700s")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("0h38m03.700s")); - QCOMPARE(format.formatDuration(singleHour, options), QString("5h08m03.700s")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("15h08m03.700s")); - QCOMPARE(format.formatDuration(singleDay, options), QString("29h08m03.700s")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("245h08m03.700s")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0h00m03.700s")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0h00m33.700s")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0h08m03.700s")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0h38m03.700s")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5h08m03.700s")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15h08m03.700s")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m03.700s")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m03.700s")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("2h59m59.900s")); + // InitialDuration and HideSeconds format options = KFormat::InitialDuration; options = options | KFormat::HideSeconds; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0h00m")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0h01m")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("0h08m")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("0h38m")); - QCOMPARE(format.formatDuration(singleHour, options), QString("5h08m")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("15h08m")); - QCOMPARE(format.formatDuration(singleDay, options), QString("29h08m")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("245h08m")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0h00m")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0h01m")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0h08m")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0h38m")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5h08m")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15h08m")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3h00m")); + // InitialDuration and FoldHours format options = KFormat::InitialDuration; options = options | KFormat::FoldHours; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0m04s")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0m34s")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("8m04s")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("38m04s")); - QCOMPARE(format.formatDuration(singleHour, options), QString("308m04s")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("908m04s")); - QCOMPARE(format.formatDuration(singleDay, options), QString("1748m04s")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("14708m04s")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0m04s")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0m34s")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8m04s")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38m04s")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308m04s")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908m04s")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748m04s")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708m04s")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("180m00s")); + // InitialDuration and FoldHours and ShowMilliseconds format options = KFormat::InitialDuration; options = options | KFormat::FoldHours | KFormat::ShowMilliseconds; - QCOMPARE(format.formatDuration(singleSecond, options), QString("0m03.700s")); - QCOMPARE(format.formatDuration(doubleSecond, options), QString("0m33.700s")); - QCOMPARE(format.formatDuration(singleMinute, options), QString("8m03.700s")); - QCOMPARE(format.formatDuration(doubleMinute, options), QString("38m03.700s")); - QCOMPARE(format.formatDuration(singleHour, options), QString("308m03.700s")); - QCOMPARE(format.formatDuration(doubleHour, options), QString("908m03.700s")); - QCOMPARE(format.formatDuration(singleDay, options), QString("1748m03.700s")); - QCOMPARE(format.formatDuration(doubleDay, options), QString("14708m03.700s")); + QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0m03.700s")); + QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0m33.700s")); + QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8m03.700s")); + QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38m03.700s")); + QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308m03.700s")); + QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908m03.700s")); + QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748m03.700s")); + QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708m03.700s")); + QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("179m59.900s")); } void KFormatTest::formatDecimalDuration() { KFormat format(QLocale::c()); - QCOMPARE(format.formatDecimalDuration(10), QString("10 millisecond(s)")); - QCOMPARE(format.formatDecimalDuration(10, 3), QString("10 millisecond(s)")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInSecond + 10), QString("1.01 seconds")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInSecond + 1, 3), QString("1.001 seconds")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInMinute + 10 * MSecsInSecond), QString("1.17 minutes")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInMinute + 10 * MSecsInSecond, 3), QString("1.167 minutes")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInHour + 10 * MSecsInMinute), QString("1.17 hours")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInHour + 10 * MSecsInMinute, 3), QString("1.167 hours")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInDay + 10 * MSecsInHour), QString("1.42 days")); - QCOMPARE(format.formatDecimalDuration(1 * MSecsInDay + 10 * MSecsInHour, 3), QString("1.417 days")); + QCOMPARE(format.formatDecimalDuration(10), QStringLiteral("10 millisecond(s)")); + QCOMPARE(format.formatDecimalDuration(10, 3), QStringLiteral("10 millisecond(s)")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInSecond + 10), QStringLiteral("1.01 seconds")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInSecond + 1, 3), QStringLiteral("1.001 seconds")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInMinute + 10 * MSecsInSecond), QStringLiteral("1.17 minutes")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInMinute + 10 * MSecsInSecond, 3), QStringLiteral("1.167 minutes")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInHour + 10 * MSecsInMinute), QStringLiteral("1.17 hours")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInHour + 10 * MSecsInMinute, 3), QStringLiteral("1.167 hours")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInDay + 10 * MSecsInHour), QStringLiteral("1.42 days")); + QCOMPARE(format.formatDecimalDuration(1 * MSecsInDay + 10 * MSecsInHour, 3), QStringLiteral("1.417 days")); } void KFormatTest::formatSpelloutDuration() { KFormat format(QLocale::c()); - QCOMPARE(format.formatSpelloutDuration(1000), QString("1 second(s)")); - QCOMPARE(format.formatSpelloutDuration(5000), QString("5 second(s)")); - QCOMPARE(format.formatSpelloutDuration(60000), QString("1 minute(s)")); - QCOMPARE(format.formatSpelloutDuration(300000), QString("5 minute(s)")); - QCOMPARE(format.formatSpelloutDuration(3600000), QString("1 hour(s)")); - QCOMPARE(format.formatSpelloutDuration(18000000), QString("5 hour(s)")); - QCOMPARE(format.formatSpelloutDuration(75000), QString("1 minute(s) and 15 second(s)")); + QCOMPARE(format.formatSpelloutDuration(1000), QStringLiteral("1 second(s)")); + QCOMPARE(format.formatSpelloutDuration(5000), QStringLiteral("5 second(s)")); + QCOMPARE(format.formatSpelloutDuration(60000), QStringLiteral("1 minute(s)")); + QCOMPARE(format.formatSpelloutDuration(300000), QStringLiteral("5 minute(s)")); + QCOMPARE(format.formatSpelloutDuration(3600000), QStringLiteral("1 hour(s)")); + QCOMPARE(format.formatSpelloutDuration(18000000), QStringLiteral("5 hour(s)")); + QCOMPARE(format.formatSpelloutDuration(75000), QStringLiteral("1 minute(s) and 15 second(s)")); // Problematic case #1 (there is a reference to this case on kformat.cpp) - QCOMPARE(format.formatSpelloutDuration(119999), QString("2 minute(s)")); + QCOMPARE(format.formatSpelloutDuration(119999), QStringLiteral("2 minute(s)")); // This case is strictly 2 hours, 15 minutes and 59 seconds. However, since the range is // pretty high between hours and seconds, formatSpelloutDuration always omits seconds when there // are hours in scene. - QCOMPARE(format.formatSpelloutDuration(8159000), QString("2 hour(s) and 15 minute(s)")); + QCOMPARE(format.formatSpelloutDuration(8159000), QStringLiteral("2 hour(s) and 15 minute(s)")); // This case is strictly 1 hour and 10 seconds. For the same reason, formatSpelloutDuration // detects that 10 seconds is just garbage compared to 1 hour, and omits it on the result. - QCOMPARE(format.formatSpelloutDuration(3610000), QString("1 hour(s)")); + QCOMPARE(format.formatSpelloutDuration(3610000), QStringLiteral("1 hour(s)")); } void KFormatTest::formatRelativeDate() @@ -267,35 +287,38 @@ KFormat format(QLocale::c()); QDate testDate = QDate::currentDate(); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QString("Today")); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QString("Today")); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QString("Today")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Today")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Today")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Today")); testDate = QDate::currentDate().addDays(1); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QString("Tomorrow")); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QString("Tomorrow")); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QString("Tomorrow")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Tomorrow")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Tomorrow")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Tomorrow")); testDate = QDate::currentDate().addDays(-1); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QString("Yesterday")); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QString("Yesterday")); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QString("Yesterday")); - + QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Yesterday")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Yesterday")); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Yesterday")); + + // Relative dates within a week are up to translators but there's no + // expectation that day names are shortened -- per the API docs, the date + // format is only used when the date is outside the relative window testDate = QDate::currentDate().addDays(-7); QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), - QString("Last %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); + QStringLiteral("Last %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), - QString("Last %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::ShortFormat))); + QStringLiteral("Last %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), - QString("Last %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::NarrowFormat))); + QStringLiteral("Last %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); testDate = QDate::currentDate().addDays(7); QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), - QString("Next %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); + QStringLiteral("Next %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), - QString("Next %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::ShortFormat))); + QStringLiteral("Next %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), - QString("Next %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::NarrowFormat))); + QStringLiteral("Next %1").arg(QLocale::c().dayName(testDate.dayOfWeek(), QLocale::LongFormat))); testDate = QDate::currentDate().addDays(-8); QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), @@ -313,8 +336,11 @@ QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QLocale::c().toString(testDate, QLocale::NarrowFormat)); + testDate = QDate(); // invalid date + QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Invalid date")); + QDateTime testDateTime = QDateTime(QDate::currentDate(), QTime(3, 0, 0)); - QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QString("Today, 03:00:00")); + QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("Today, 03:00:00")); testDateTime = QDateTime(QDate::currentDate().addDays(8), QTime(3, 0, 0)); QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::LongFormat), diff -Nru kcoreaddons-5.18.0/autotests/kjobtest.cpp kcoreaddons-5.44.0a/autotests/kjobtest.cpp --- kcoreaddons-5.18.0/autotests/kjobtest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kjobtest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -36,7 +36,7 @@ QTest::addColumn("errorCode"); QTest::addColumn("errorText"); - QTest::newRow("no error") << (int)KJob::NoError << QString(); + QTest::newRow("no error") << int(KJob::NoError) << QString(); QTest::newRow("error no text") << 2 << QString(); QTest::newRow("error with text") << 6 << "oops! an error? naaah, really?"; } @@ -45,8 +45,7 @@ { TestJob *job = new TestJob; - connect(job, SIGNAL(result(KJob*)), - this, SLOT(slotResult(KJob*))); + connect(job, &KJob::result, this, &KJobTest::slotResult); QFETCH(int, errorCode); QFETCH(QString, errorText); @@ -89,7 +88,7 @@ QCOMPARE(processed_spy.size(), 1); QCOMPARE(processed_spy.at(0).at(0).value(), static_cast(job)); - QCOMPARE(processed_spy.at(0).at(2).value(), (qulonglong)1); + QCOMPARE(processed_spy.at(0).at(2).value(), qulonglong(1)); QCOMPARE(total_spy.size(), 0); QCOMPARE(percent_spy.size(), 0); @@ -101,10 +100,10 @@ QCOMPARE(processed_spy.size(), 1); QCOMPARE(total_spy.size(), 1); QCOMPARE(total_spy.at(0).at(0).value(), job); - QCOMPARE(total_spy.at(0).at(2).value(), (qulonglong)10); + QCOMPARE(total_spy.at(0).at(2).value(), qulonglong(10)); QCOMPARE(percent_spy.size(), 1); QCOMPARE(percent_spy.at(0).at(0).value(), job); - QCOMPARE(percent_spy.at(0).at(1).value(), (unsigned long)10); + QCOMPARE(percent_spy.at(0).at(1).value(), static_cast(10)); /* We announce a new percentage by hand. * Total, and processed didn't change, so no signal is emitted for them. @@ -115,7 +114,7 @@ QCOMPARE(total_spy.size(), 1); QCOMPARE(percent_spy.size(), 2); QCOMPARE(percent_spy.at(1).at(0).value(), job); - QCOMPARE(percent_spy.at(1).at(1).value(), (unsigned long)15); + QCOMPARE(percent_spy.at(1).at(1).value(), static_cast(15)); /* We make some progress. * Processed size and percent are signaled. @@ -124,11 +123,11 @@ QCOMPARE(processed_spy.size(), 2); QCOMPARE(processed_spy.at(1).at(0).value(), job); - QCOMPARE(processed_spy.at(1).at(2).value(), (qulonglong)3); + QCOMPARE(processed_spy.at(1).at(2).value(), qulonglong(3)); QCOMPARE(total_spy.size(), 1); QCOMPARE(percent_spy.size(), 3); QCOMPARE(percent_spy.at(2).at(0).value(), job); - QCOMPARE(percent_spy.at(2).at(1).value(), (unsigned long)30); + QCOMPARE(percent_spy.at(2).at(1).value(), static_cast(30)); /* We set a new total size, but equals to the previous one. * No signal is emitted. @@ -146,11 +145,11 @@ QCOMPARE(processed_spy.size(), 3); QCOMPARE(processed_spy.at(2).at(0).value(), job); - QCOMPARE(processed_spy.at(2).at(2).value(), (qulonglong)0); + QCOMPARE(processed_spy.at(2).at(2).value(), qulonglong(0)); QCOMPARE(total_spy.size(), 1); QCOMPARE(percent_spy.size(), 4); QCOMPARE(percent_spy.at(3).at(0).value(), job); - QCOMPARE(percent_spy.at(3).at(1).value(), (unsigned long)0); + QCOMPARE(percent_spy.at(3).at(1).value(), static_cast(0)); /* We process more than the total size!? * Signals both percentage and new processed size. @@ -162,11 +161,11 @@ QCOMPARE(processed_spy.size(), 4); QCOMPARE(processed_spy.at(3).at(0).value(), job); - QCOMPARE(processed_spy.at(3).at(2).value(), (qulonglong)15); + QCOMPARE(processed_spy.at(3).at(2).value(), qulonglong(15)); QCOMPARE(total_spy.size(), 1); QCOMPARE(percent_spy.size(), 5); QCOMPARE(percent_spy.at(4).at(0).value(), job); - QCOMPARE(percent_spy.at(4).at(1).value(), (unsigned long)150); + QCOMPARE(percent_spy.at(4).at(1).value(), static_cast(150)); delete job; } @@ -176,7 +175,7 @@ QTest::addColumn("errorCode"); QTest::addColumn("errorText"); - QTest::newRow("no error") << (int)KJob::NoError << QString(); + QTest::newRow("no error") << int(KJob::NoError) << QString(); QTest::newRow("error no text") << 2 << QString(); QTest::newRow("error with text") << 6 << "oops! an error? naaah, really?"; } @@ -191,10 +190,15 @@ job->setError(errorCode); job->setErrorText(errorText); + int resultEmitted = 0; + // Prove to Kai Uwe that one can connect a job to a lambdas, despite the "private" signal + connect(job, &KJob::result, this, [&resultEmitted](KJob *) { ++resultEmitted; }); + QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject*))); bool status = job->exec(); + QCOMPARE(resultEmitted, 1); QCOMPARE(status, (errorCode == KJob::NoError)); QCOMPARE(job->error(), errorCode); QCOMPARE(job->errorText(), errorText); @@ -215,13 +219,13 @@ QTest::addColumn("resultEmitCount"); QTest::addColumn("finishedEmitCount"); - QTest::newRow("killed with result") << (int)KJob::EmitResult - << (int)KJob::KilledJobError + QTest::newRow("killed with result") << int(KJob::EmitResult) + << int(KJob::KilledJobError) << QString() << 1 << 1; - QTest::newRow("killed quietly") << (int)KJob::Quietly - << (int)KJob::KilledJobError + QTest::newRow("killed quietly") << int(KJob::Quietly) + << int(KJob::KilledJobError) << QString() << 0 << 1; @@ -231,10 +235,8 @@ { TestJob *job = new TestJob; - connect(job, SIGNAL(result(KJob*)), - this, SLOT(slotResult(KJob*))); - connect(job, SIGNAL(finished(KJob*)), - this, SLOT(slotFinished(KJob*))); + connect(job, &KJob::result, this, &KJobTest::slotResult); + connect(job, &KJob::finished, this, &KJobTest::slotFinished); m_lastError = KJob::NoError; m_lastErrorText.clear(); @@ -249,7 +251,7 @@ QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject*))); - job->kill((KJob::KillVerbosity)killVerbosity); + job->kill(static_cast(killVerbosity)); loop.processEvents(QEventLoop::AllEvents, 2000); QCOMPARE(m_lastError, errorCode); @@ -274,19 +276,24 @@ TestJob *job1 = new TestJob; TestJob *job2 = new TestJob; TestJobUiDelegate *delegate = new TestJobUiDelegate; + QPointer guard(delegate); - QVERIFY(job1->uiDelegate() == 0); + QVERIFY(job1->uiDelegate() == nullptr); job1->setUiDelegate(delegate); QVERIFY(job1->uiDelegate() == delegate); - QVERIFY(job2->uiDelegate() == 0); + QVERIFY(job2->uiDelegate() == nullptr); job2->setUiDelegate(delegate); - QVERIFY(job2->uiDelegate() == 0); + QVERIFY(job2->uiDelegate() == nullptr); + + delete job1; + delete job2; + QVERIFY(guard.isNull()); // deleted by job1 } void KJobTest::testNestedExec() { - m_innerJob = 0; + m_innerJob = nullptr; QTimer::singleShot(100, this, SLOT(slotStartInnerJob())); m_outerJob = new WaitJob(); m_outerJob->exec(); @@ -398,7 +405,7 @@ void TestJobUiDelegate::connectJob(KJob *job) { - QVERIFY(job->uiDelegate() != 0); + QVERIFY(job->uiDelegate() != nullptr); } #include "moc_kjobtest.cpp" diff -Nru kcoreaddons-5.18.0/autotests/kjobtest.h kcoreaddons-5.44.0a/autotests/kjobtest.h --- kcoreaddons-5.18.0/autotests/kjobtest.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kjobtest.h 2018-03-06 08:12:31.000000000 +0000 @@ -30,12 +30,12 @@ Q_OBJECT public: TestJob(); - virtual ~TestJob(); + ~TestJob() override; - virtual void start(); + void start() Q_DECL_OVERRIDE; protected: - virtual bool doKill(); + bool doKill() Q_DECL_OVERRIDE; public: void setError(int errorCode); @@ -100,7 +100,7 @@ Q_OBJECT public: - virtual void start(); + void start() Q_DECL_OVERRIDE; void makeItFinish(); }; diff -Nru kcoreaddons-5.18.0/autotests/kmacroexpandertest.cpp kcoreaddons-5.44.0a/autotests/kmacroexpandertest.cpp --- kcoreaddons-5.18.0/autotests/kmacroexpandertest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kmacroexpandertest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -89,35 +89,35 @@ QHash map2; map2.insert('a', "%n"); map2.insert('f', "filename.txt"); - map2.insert('u', "http://www.kde.org/index.html"); + map2.insert('u', "https://www.kde.org/index.html"); map2.insert('n', "Restaurant \"Chew It\""); s = "Title: %a - %f - %u - %n - %%"; QCOMPARE(KMacroExpander::expandMacros(s, map2), - QLatin1String("Title: %n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\" - %")); + QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); QHash smap; smap.insert("foo", "%n"); smap.insert("file", "filename.txt"); - smap.insert("url", "http://www.kde.org/index.html"); + smap.insert("url", "https://www.kde.org/index.html"); smap.insert("name", "Restaurant \"Chew It\""); s = "Title: %foo - %file - %url - %name - %"; QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: %n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\" - %")); + QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); s = "%foo - %file - %url - %name"; QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("%n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\"")); + QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\"")); s = "Title: %{foo} - %{file} - %{url} - %{name} - %"; QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: %n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\" - %")); + QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); s = "%{foo} - %{file} - %{url} - %{name}"; QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("%n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\"")); + QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\"")); s = "Title: %foo-%file-%url-%name-%"; QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: %n-filename.txt-http://www.kde.org/index.html-Restaurant \"Chew It\"-%")); + QLatin1String("Title: %n-filename.txt-https://www.kde.org/index.html-Restaurant \"Chew It\"-%")); s = "Title: %{file} %{url"; QCOMPARE(KMacroExpander::expandMacros(s, smap), @@ -163,13 +163,13 @@ QHash map2; map2.insert('a', "%n"); map2.insert('f', "filename.txt"); - map2.insert('u', "http://www.kde.org/index.html"); + map2.insert('u', "https://www.kde.org/index.html"); map2.insert('n', "Restaurant \"Chew It\""); #ifdef Q_OS_WIN s = "Title: %a - %f - %u - %n - %% - %VARIABLE% foo"; QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("Title: %PERCENT_SIGN%n - filename.txt - http://www.kde.org/index.html - \"Restaurant \"\\^\"\"Chew It\"\\^\" - %PERCENT_SIGN% - %VARIABLE% foo")); + QLatin1String("Title: %PERCENT_SIGN%n - filename.txt - https://www.kde.org/index.html - \"Restaurant \"\\^\"\"Chew It\"\\^\" - %PERCENT_SIGN% - %VARIABLE% foo")); s = "kedit --caption %n %f"; map2.insert('n', "Restaurant 'Chew It'"); @@ -206,7 +206,7 @@ #else s = "Title: %a - %f - %u - %n - %%"; QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("Title: %n - filename.txt - http://www.kde.org/index.html - 'Restaurant \"Chew It\"' - %")); + QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - 'Restaurant \"Chew It\"' - %")); s = "kedit --caption %n %f"; map2.insert('n', "Restaurant 'Chew It'"); diff -Nru kcoreaddons-5.18.0/autotests/kpluginfactorytest.cpp kcoreaddons-5.44.0a/autotests/kpluginfactorytest.cpp --- kcoreaddons-5.18.0/autotests/kpluginfactorytest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kpluginfactorytest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -31,11 +31,11 @@ private Q_SLOTS: void testCreate() { - KPluginLoader multiplugin("multiplugin"); + KPluginLoader multiplugin(QStringLiteral("multiplugin")); KPluginFactory *factory = multiplugin.factory(); QVERIFY(factory); QVariantList args; - args << "Some" << "args" << 5; + args << QStringLiteral("Some") << QStringLiteral("args") << 5; QObject *obj = factory->create(this, args); QVERIFY(obj); @@ -48,11 +48,11 @@ delete obj; delete obj2; - obj = factory->create("secondary", this, args); + obj = factory->create(QStringLiteral("secondary"), this, args); QVERIFY(obj); QCOMPARE(obj->objectName(), QString::fromLatin1("MultiPlugin2")); - obj2 = factory->create("secondary", this, args); + obj2 = factory->create(QStringLiteral("secondary"), this, args); QVERIFY(obj2); QCOMPARE(obj2->objectName(), QString::fromLatin1("MultiPlugin2")); QVERIFY(obj != obj2); diff -Nru kcoreaddons-5.18.0/autotests/kpluginloadertest.cpp kcoreaddons-5.44.0a/autotests/kpluginloadertest.cpp --- kcoreaddons-5.18.0/autotests/kpluginloadertest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kpluginloadertest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -25,6 +25,14 @@ #include #include +class LibraryPathRestorer { +public: + explicit LibraryPathRestorer(const QStringList &paths) : mPaths(paths) {} + ~LibraryPathRestorer() { QCoreApplication::setLibraryPaths(mPaths); } +private: + QStringList mPaths; +}; + class KPluginLoaderTest : public QObject { Q_OBJECT @@ -32,118 +40,118 @@ private Q_SLOTS: void testFindPlugin_missing() { - const QString location = KPluginLoader::findPlugin("idonotexist"); + const QString location = KPluginLoader::findPlugin(QStringLiteral("idonotexist")); QVERIFY2(location.isEmpty(), qPrintable(location)); } void testFindPlugin() { - const QString location = KPluginLoader::findPlugin("jsonplugin"); + const QString location = KPluginLoader::findPlugin(QStringLiteral("jsonplugin")); QVERIFY2(!location.isEmpty(), qPrintable(location)); } void testPluginVersion() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QCOMPARE(vplugin.pluginVersion(), quint32(5)); - KPluginLoader vplugin2("versionedplugin"); + KPluginLoader vplugin2(QStringLiteral("versionedplugin")); QCOMPARE(vplugin2.pluginVersion(), quint32(5)); - KPluginLoader uplugin("unversionedplugin"); + KPluginLoader uplugin(QStringLiteral("unversionedplugin")); QCOMPARE(uplugin.pluginVersion(), quint32(-1)); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QCOMPARE(jplugin.pluginVersion(), quint32(-1)); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QCOMPARE(eplugin.pluginVersion(), quint32(-1)); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QCOMPARE(noplugin.pluginVersion(), quint32(-1)); } void testPluginName() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QCOMPARE(vplugin.pluginName(), QString::fromLatin1("versionedplugin")); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QCOMPARE(jplugin.pluginName(), QString::fromLatin1("jsonplugin")); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY2(eplugin.pluginName().isEmpty(), qPrintable(eplugin.pluginName())); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QCOMPARE(noplugin.pluginName(), QString::fromLatin1("idonotexist")); } void testFactory() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QVERIFY(vplugin.factory()); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QVERIFY(jplugin.factory()); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY(!eplugin.factory()); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QVERIFY(!noplugin.factory()); } void testErrorString() { - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QCOMPARE(eplugin.errorString(), QString::fromLatin1("there was an error")); } void testFileName() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QCOMPARE(QFileInfo(vplugin.fileName()).canonicalFilePath(), QFileInfo(QStringLiteral(VERSIONEDPLUGIN_FILE)).canonicalFilePath()); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QCOMPARE(QFileInfo(jplugin.fileName()).canonicalFilePath(), QFileInfo(QStringLiteral(JSONPLUGIN_FILE)).canonicalFilePath()); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY2(eplugin.fileName().isEmpty(), qPrintable(eplugin.fileName())); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QVERIFY2(noplugin.fileName().isEmpty(), qPrintable(noplugin.fileName())); } void testInstance() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QVERIFY(vplugin.instance()); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QVERIFY(jplugin.instance()); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY(!eplugin.instance()); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QVERIFY(!noplugin.instance()); } void testIsLoaded() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QVERIFY(!vplugin.isLoaded()); QVERIFY(vplugin.load()); QVERIFY(vplugin.isLoaded()); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QVERIFY(!jplugin.isLoaded()); QVERIFY(jplugin.load()); QVERIFY(jplugin.isLoaded()); - KPluginLoader aplugin("alwaysunloadplugin"); + KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin")); QVERIFY(!aplugin.isLoaded()); QVERIFY(aplugin.load()); QVERIFY(aplugin.isLoaded()); @@ -153,12 +161,12 @@ qDebug() << "Could not unload alwaysunloadplugin:" << aplugin.errorString(); } - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY(!eplugin.isLoaded()); QVERIFY(!eplugin.load()); QVERIFY(!eplugin.isLoaded()); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QVERIFY(!noplugin.isLoaded()); QVERIFY(!noplugin.load()); QVERIFY(!noplugin.isLoaded()); @@ -166,57 +174,57 @@ void testLoad() { - KPluginLoader vplugin("versionedplugin"); + KPluginLoader vplugin(QStringLiteral("versionedplugin")); QVERIFY(vplugin.load()); - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QVERIFY(jplugin.load()); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY(!eplugin.load()); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QVERIFY(!noplugin.load()); } void testLoadHints() { - KPluginLoader aplugin("alwaysunloadplugin"); + KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin")); aplugin.setLoadHints(QLibrary::ResolveAllSymbolsHint); QCOMPARE(aplugin.loadHints(), QLibrary::ResolveAllSymbolsHint); } void testMetaData() { - KPluginLoader aplugin("alwaysunloadplugin"); + KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin")); QJsonObject ametadata = aplugin.metaData(); QVERIFY(!ametadata.isEmpty()); - QVERIFY(ametadata.keys().contains("IID")); - QJsonValue ametadata_metadata = ametadata.value("MetaData"); + QVERIFY(ametadata.keys().contains(QStringLiteral("IID"))); + QJsonValue ametadata_metadata = ametadata.value(QStringLiteral("MetaData")); QVERIFY(ametadata_metadata.toObject().isEmpty()); QVERIFY(!aplugin.isLoaded()); // didn't load anything - KPluginLoader jplugin(KPluginName("jsonplugin")); + KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); QJsonObject jmetadata = jplugin.metaData(); QVERIFY(!jmetadata.isEmpty()); - QJsonValue jmetadata_metadata = jmetadata.value("MetaData"); + QJsonValue jmetadata_metadata = jmetadata.value(QStringLiteral("MetaData")); QVERIFY(jmetadata_metadata.isObject()); QJsonObject jmetadata_obj = jmetadata_metadata.toObject(); QVERIFY(!jmetadata_obj.isEmpty()); - QJsonValue comment = jmetadata_obj.value("KPlugin").toObject().value("Description"); + QJsonValue comment = jmetadata_obj.value(QStringLiteral("KPlugin")).toObject().value(QStringLiteral("Description")); QVERIFY(comment.isString()); QCOMPARE(comment.toString(), QString::fromLatin1("This is a plugin")); - KPluginLoader eplugin(KPluginName::fromErrorString("there was an error")); + KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY(eplugin.metaData().isEmpty()); - KPluginLoader noplugin("idonotexist"); + KPluginLoader noplugin(QStringLiteral("idonotexist")); QVERIFY(noplugin.metaData().isEmpty()); } void testUnload() { - KPluginLoader aplugin("alwaysunloadplugin"); + KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin")); QVERIFY(aplugin.load()); // may need QEXPECT_FAIL on some platforms... QVERIFY(aplugin.unload()); @@ -224,28 +232,28 @@ void testInstantiatePlugins() { - const QString plugin1Path = KPluginLoader::findPlugin("jsonplugin"); + const QString plugin1Path = KPluginLoader::findPlugin(QStringLiteral("jsonplugin")); QVERIFY2(!plugin1Path.isEmpty(), qPrintable(plugin1Path)); - const QString plugin2Path = KPluginLoader::findPlugin("unversionedplugin"); + const QString plugin2Path = KPluginLoader::findPlugin(QStringLiteral("unversionedplugin")); QVERIFY2(!plugin2Path.isEmpty(), qPrintable(plugin2Path)); - const QString plugin3Path = KPluginLoader::findPlugin("jsonplugin2"); + const QString plugin3Path = KPluginLoader::findPlugin(QStringLiteral("jsonplugin2")); QVERIFY2(!plugin3Path.isEmpty(), qPrintable(plugin3Path)); QTemporaryDir temp; QVERIFY(temp.isValid()); QDir dir(temp.path()); QVERIFY2(QFile::copy(plugin1Path, dir.absoluteFilePath(QFileInfo(plugin1Path).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(plugin1Path).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(plugin1Path).fileName()))); QVERIFY2(QFile::copy(plugin2Path, dir.absoluteFilePath(QFileInfo(plugin2Path).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(plugin2Path).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(plugin2Path).fileName()))); QVERIFY2(QFile::copy(plugin3Path, dir.absoluteFilePath(QFileInfo(plugin3Path).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(plugin3Path).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(plugin3Path).fileName()))); // only jsonplugin, since unversionedplugin has no json metadata QList plugins = KPluginLoader::instantiatePlugins(temp.path()); QCOMPARE(plugins.size(), 2); - QStringList classNames = QStringList() << plugins[0]->metaObject()->className() - << plugins[1]->metaObject()->className(); + QStringList classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className()) + << QString::fromLatin1(plugins[1]->metaObject()->className()); classNames.sort(); QCOMPARE(classNames[0], QStringLiteral("jsonplugin2")); QCOMPARE(classNames[1], QStringLiteral("jsonpluginfa")); @@ -253,19 +261,19 @@ //try filter plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData & md) { - return md.pluginId() == "jsonplugin"; + return md.pluginId() == QStringLiteral("jsonplugin"); }); QCOMPARE(plugins.size(), 1); QCOMPARE(plugins[0]->metaObject()->className(), "jsonpluginfa"); qDeleteAll(plugins); plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData & md) { - return md.pluginId() == "unversionedplugin"; + return md.pluginId() == QStringLiteral("unversionedplugin"); }); QCOMPARE(plugins.size(), 0); plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData & md) { - return md.pluginId() == "foobar"; // ID does not match file name, is set in JSON + return md.pluginId() == QStringLiteral("foobar"); // ID does not match file name, is set in JSON }); QCOMPARE(plugins.size(), 1); QCOMPARE(plugins[0]->metaObject()->className(), "jsonplugin2"); @@ -280,14 +288,15 @@ const QString subDirName = dir.dirName(); QVERIFY(dir.cdUp()); // should now point to /tmp on Linux + LibraryPathRestorer restorer(QCoreApplication::libraryPaths()); // instantiate using relative path // make sure library path is set up correctly QCoreApplication::setLibraryPaths(QStringList() << dir.absolutePath()); QVERIFY(!QDir::isAbsolutePath(subDirName)); plugins = KPluginLoader::instantiatePlugins(subDirName); QCOMPARE(plugins.size(), 2); - classNames = QStringList() << plugins[0]->metaObject()->className() - << plugins[1]->metaObject()->className(); + classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className()) + << QString::fromLatin1(plugins[1]->metaObject()->className()); classNames.sort(); QCOMPARE(classNames[0], QStringLiteral("jsonplugin2")); QCOMPARE(classNames[1], QStringLiteral("jsonpluginfa")); @@ -296,24 +305,25 @@ void testFindPlugins() { - const QString plugin1Path = KPluginLoader::findPlugin("jsonplugin"); + const QString plugin1Path = KPluginLoader::findPlugin(QStringLiteral("jsonplugin")); QVERIFY2(!plugin1Path.isEmpty(), qPrintable(plugin1Path)); - const QString plugin2Path = KPluginLoader::findPlugin("unversionedplugin"); + const QString plugin2Path = KPluginLoader::findPlugin(QStringLiteral("unversionedplugin")); QVERIFY2(!plugin2Path.isEmpty(), qPrintable(plugin2Path)); - const QString plugin3Path = KPluginLoader::findPlugin("jsonplugin2"); + const QString plugin3Path = KPluginLoader::findPlugin(QStringLiteral("jsonplugin2")); QVERIFY2(!plugin3Path.isEmpty(), qPrintable(plugin3Path)); QTemporaryDir temp; QVERIFY(temp.isValid()); QDir dir(temp.path()); - QVERIFY(dir.mkdir("kpluginmetadatatest")); - QVERIFY(dir.cd("kpluginmetadatatest")); + QVERIFY(dir.mkdir(QStringLiteral("kpluginmetadatatest"))); + QVERIFY(dir.cd(QStringLiteral("kpluginmetadatatest"))); QVERIFY2(QFile::copy(plugin1Path, dir.absoluteFilePath(QFileInfo(plugin1Path).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(plugin1Path).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(plugin1Path).fileName()))); QVERIFY2(QFile::copy(plugin2Path, dir.absoluteFilePath(QFileInfo(plugin2Path).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(plugin2Path).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(plugin2Path).fileName()))); QVERIFY2(QFile::copy(plugin3Path, dir.absoluteFilePath(QFileInfo(plugin3Path).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(plugin3Path).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(plugin3Path).fileName()))); + LibraryPathRestorer restorer(QCoreApplication::libraryPaths()); // we only want plugins from our temporary dir QCoreApplication::setLibraryPaths(QStringList() << temp.path()); @@ -321,7 +331,7 @@ return a.pluginId() < b.pluginId(); }; // it should find jsonplugin and jsonplugin2 since unversionedplugin does not have any meta data - auto plugins = KPluginLoader::findPlugins("kpluginmetadatatest"); + auto plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest")); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 2); QCOMPARE(plugins[0].pluginId(), QStringLiteral("foobar")); // ID is not the filename, it is set in the JSON metadata @@ -330,31 +340,31 @@ QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin")); // filter accepts none - plugins = KPluginLoader::findPlugins("kpluginmetadatatest", [](const KPluginMetaData &) { return false; }); + plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) { return false; }); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 0); // filter accepts all - plugins = KPluginLoader::findPlugins("kpluginmetadatatest", [](const KPluginMetaData &) { return true; }); + plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) { return true; }); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 2); QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin")); QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin")); // invalid std::function as filter - plugins = KPluginLoader::findPlugins("kpluginmetadatatest"); + plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest")); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 2); QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin")); QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin")); // by plugin id - plugins = KPluginLoader::findPluginsById(dir.absolutePath(), "foobar"); + plugins = KPluginLoader::findPluginsById(dir.absolutePath(), QStringLiteral("foobar")); QCOMPARE(plugins.size(), 1); QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin")); // by plugin invalid id - plugins = KPluginLoader::findPluginsById(dir.absolutePath(), "invalidid"); + plugins = KPluginLoader::findPluginsById(dir.absolutePath(), QStringLiteral("invalidid")); QCOMPARE(plugins.size(), 0); // absolute path, no filter @@ -367,18 +377,18 @@ void testForEachPlugin() { - const QString jsonPluginSrc = KPluginLoader::findPlugin("jsonplugin"); + const QString jsonPluginSrc = KPluginLoader::findPlugin(QStringLiteral("jsonplugin")); QVERIFY2(!jsonPluginSrc.isEmpty(), qPrintable(jsonPluginSrc)); - const QString unversionedPluginSrc = KPluginLoader::findPlugin("unversionedplugin"); + const QString unversionedPluginSrc = KPluginLoader::findPlugin(QStringLiteral("unversionedplugin")); QVERIFY2(!unversionedPluginSrc.isEmpty(), qPrintable(unversionedPluginSrc)); - const QString jsonPlugin2Src = KPluginLoader::findPlugin("jsonplugin2"); + const QString jsonPlugin2Src = KPluginLoader::findPlugin(QStringLiteral("jsonplugin2")); QVERIFY2(!jsonPlugin2Src.isEmpty(), qPrintable(jsonPlugin2Src)); QTemporaryDir temp; QVERIFY(temp.isValid()); QDir dir(temp.path()); - QVERIFY(dir.mkdir("for-each-plugin")); - QVERIFY(dir.cd("for-each-plugin")); + QVERIFY(dir.mkdir(QStringLiteral("for-each-plugin"))); + QVERIFY(dir.cd(QStringLiteral("for-each-plugin"))); const QString jsonPluginDest = dir.absoluteFilePath(QFileInfo(jsonPluginSrc).fileName()); QVERIFY2(QFile::copy(jsonPluginSrc, jsonPluginDest), qPrintable(jsonPluginDest)); const QString unversionedPluginDest = dir.absoluteFilePath(QFileInfo(unversionedPluginSrc).fileName()); @@ -387,8 +397,8 @@ QTemporaryDir temp2; QVERIFY(temp2.isValid()); QDir dir2(temp2.path()); - QVERIFY(dir2.mkdir("for-each-plugin")); - QVERIFY(dir2.cd("for-each-plugin")); + QVERIFY(dir2.mkdir(QStringLiteral("for-each-plugin"))); + QVERIFY(dir2.cd(QStringLiteral("for-each-plugin"))); const QString jsonPlugin2Dest = dir2.absoluteFilePath(QFileInfo(jsonPlugin2Src).fileName()); QVERIFY2(QFile::copy(jsonPlugin2Src, jsonPlugin2Dest), qPrintable(jsonPlugin2Dest)); @@ -416,11 +426,12 @@ // now test relative paths + LibraryPathRestorer restorer(QCoreApplication::libraryPaths()); QCoreApplication::setLibraryPaths(QStringList() << temp.path()); expectedPlugins = QStringList() << jsonPluginDest << unversionedPluginDest; expectedPlugins.sort(); foundPlugins.clear(); - KPluginLoader::forEachPlugin("for-each-plugin", addToFoundPlugins); + KPluginLoader::forEachPlugin(QStringLiteral("for-each-plugin"), addToFoundPlugins); foundPlugins.sort(); QCOMPARE(foundPlugins, expectedPlugins); @@ -428,7 +439,7 @@ expectedPlugins = QStringList() << jsonPlugin2Dest; expectedPlugins.sort(); foundPlugins.clear(); - KPluginLoader::forEachPlugin("for-each-plugin", addToFoundPlugins); + KPluginLoader::forEachPlugin(QStringLiteral("for-each-plugin"), addToFoundPlugins); foundPlugins.sort(); QCOMPARE(foundPlugins, expectedPlugins); @@ -436,7 +447,7 @@ expectedPlugins = QStringList() << jsonPluginDest << unversionedPluginDest << jsonPlugin2Dest; expectedPlugins.sort(); foundPlugins.clear(); - KPluginLoader::forEachPlugin("for-each-plugin", addToFoundPlugins); + KPluginLoader::forEachPlugin(QStringLiteral("for-each-plugin"), addToFoundPlugins); foundPlugins.sort(); QCOMPARE(foundPlugins, expectedPlugins); } diff -Nru kcoreaddons-5.18.0/autotests/kpluginmetadatatest.cpp kcoreaddons-5.44.0a/autotests/kpluginmetadatatest.cpp --- kcoreaddons-5.18.0/autotests/kpluginmetadatatest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kpluginmetadatatest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -46,7 +46,7 @@ private Q_SLOTS: void testFromPluginLoader() { - QString location = KPluginLoader::findPlugin("jsonplugin"); + QString location = KPluginLoader::findPlugin(QStringLiteral("jsonplugin")); QVERIFY2(!location.isEmpty(),"Could not find jsonplugin"); // now that this file is translated we need to read it instead of hardcoding the contents here @@ -60,10 +60,10 @@ location = QFileInfo(location).absoluteFilePath(); - KPluginMetaData fromQPluginLoader(QPluginLoader("jsonplugin")); - KPluginMetaData fromKPluginLoader(KPluginLoader("jsonplugin")); + KPluginMetaData fromQPluginLoader(QPluginLoader(QStringLiteral("jsonplugin"))); + KPluginMetaData fromKPluginLoader(KPluginLoader(QStringLiteral("jsonplugin"))); KPluginMetaData fromFullPath(location); - KPluginMetaData fromRelativePath("jsonplugin"); + KPluginMetaData fromRelativePath(QStringLiteral("jsonplugin")); KPluginMetaData fromRawData(jsonDoc.object(), location); auto description = QStringLiteral("This is a plugin"); @@ -107,25 +107,25 @@ { QJsonParseError e; QJsonObject jo = QJsonDocument::fromJson("{\n" - " \"KPlugin\": {\n" - " \"Name\": \"Date and Time\",\n" - " \"Description\": \"Date and time by timezone\",\n" - " \"Icon\": \"preferences-system-time\",\n" - " \"Authors\": { \"Name\": \"Aaron Seigo\", \"Email\": \"aseigo@kde.org\" },\n" - " \"Translators\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" - " \"OtherContributors\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" - " \"Category\": \"Date and Time\",\n" - " \"Dependencies\": [ \"foo\", \"bar\"],\n" - " \"EnabledByDefault\": \"true\",\n" - " \"ExtraInformation\": \"Something else\",\n" - " \"License\": \"LGPL\",\n" - " \"Copyright\": \"(c) Alex Richardson 2015\",\n" - " \"Id\": \"time\",\n" - " \"Version\": \"1.0\",\n" - " \"Website\": \"http://plasma.kde.org/\",\n" - " \"MimeTypes\": [ \"image/png\" ],\n" - " \"ServiceTypes\": [\"Plasma/DataEngine\"]\n" - " }\n}\n", &e).object(); + " \"KPlugin\": {\n" + " \"Name\": \"Date and Time\",\n" + " \"Description\": \"Date and time by timezone\",\n" + " \"Icon\": \"preferences-system-time\",\n" + " \"Authors\": { \"Name\": \"Aaron Seigo\", \"Email\": \"aseigo@kde.org\" },\n" + " \"Translators\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" + " \"OtherContributors\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" + " \"Category\": \"Date and Time\",\n" + " \"Dependencies\": [ \"foo\", \"bar\"],\n" + " \"EnabledByDefault\": \"true\",\n" + " \"ExtraInformation\": \"Something else\",\n" + " \"License\": \"LGPL\",\n" + " \"Copyright\": \"(c) Alex Richardson 2015\",\n" + " \"Id\": \"time\",\n" + " \"Version\": \"1.0\",\n" + " \"Website\": \"https://plasma.kde.org/\",\n" + " \"MimeTypes\": [ \"image/png\" ],\n" + " \"ServiceTypes\": [\"Plasma/DataEngine\"]\n" + " }\n}\n", &e).object(); QCOMPARE(e.error, QJsonParseError::NoError); KPluginMetaData m(jo, QString()); QVERIFY(m.isValid()); @@ -135,7 +135,7 @@ QCOMPARE(m.extraInformation(), QStringLiteral("Something else")); QCOMPARE(m.iconName(), QStringLiteral("preferences-system-time")); QCOMPARE(m.category(), QStringLiteral("Date and Time")); - QCOMPARE(m.dependencies(), QStringList() << "foo" << "bar"); + QCOMPARE(m.dependencies(), QStringList() << QStringLiteral("foo") << QStringLiteral("bar")); QCOMPARE(m.authors().size(), 1); QCOMPARE(m.authors()[0].name(), QStringLiteral("Aaron Seigo")); QCOMPARE(m.authors()[0].emailAddress(), QStringLiteral("aseigo@kde.org")); @@ -149,7 +149,7 @@ QCOMPARE(m.license(), QStringLiteral("LGPL")); QCOMPARE(m.copyrightText(), QStringLiteral("(c) Alex Richardson 2015")); QCOMPARE(m.version(), QStringLiteral("1.0")); - QCOMPARE(m.website(), QStringLiteral("http://plasma.kde.org/")); + QCOMPARE(m.website(), QStringLiteral("https://plasma.kde.org/")); QCOMPARE(m.serviceTypes(), QStringList() << QStringLiteral("Plasma/DataEngine")); QCOMPARE(m.mimeTypes(), QStringList() << QStringLiteral("image/png")); } @@ -158,27 +158,27 @@ { QJsonParseError e; QJsonObject jo = QJsonDocument::fromJson("{ \"KPlugin\": {\n" - "\"Name\": \"Name\",\n" - "\"Name[de]\": \"Name (de)\",\n" - "\"Name[de_DE]\": \"Name (de_DE)\",\n" - "\"Description\": \"Description\",\n" - "\"Description[de]\": \"Beschreibung (de)\",\n" - "\"Description[de_DE]\": \"Beschreibung (de_DE)\"\n" - "}\n}", &e).object(); + "\"Name\": \"Name\",\n" + "\"Name[de]\": \"Name (de)\",\n" + "\"Name[de_DE]\": \"Name (de_DE)\",\n" + "\"Description\": \"Description\",\n" + "\"Description[de]\": \"Beschreibung (de)\",\n" + "\"Description[de_DE]\": \"Beschreibung (de_DE)\"\n" + "}\n}", &e).object(); KPluginMetaData m(jo, QString()); QLocale::setDefault(QLocale::c()); QCOMPARE(m.name(), QStringLiteral("Name")); QCOMPARE(m.description(), QStringLiteral("Description")); - QLocale::setDefault(QLocale("de_DE")); + QLocale::setDefault(QLocale(QStringLiteral("de_DE"))); QCOMPARE(m.name(), QStringLiteral("Name (de_DE)")); QCOMPARE(m.description(), QStringLiteral("Beschreibung (de_DE)")); - QLocale::setDefault(QLocale("de_CH")); + QLocale::setDefault(QLocale(QStringLiteral("de_CH"))); QCOMPARE(m.name(), QStringLiteral("Name (de)")); QCOMPARE(m.description(), QStringLiteral("Beschreibung (de)")); - QLocale::setDefault(QLocale("fr_FR")); + QLocale::setDefault(QLocale(QStringLiteral("fr_FR"))); QCOMPARE(m.name(), QStringLiteral("Name")); QCOMPARE(m.description(), QStringLiteral("Description")); } @@ -187,42 +187,42 @@ { QJsonParseError e; QJsonObject jo = QJsonDocument::fromJson("{\n" - "\"String\": \"foo\",\n" - "\"OneArrayEntry\": [ \"foo\" ],\n" - "\"Bool\": true,\n" // make sure booleans are accepted - "\"QuotedBool\": \"true\",\n" // make sure booleans are accepted - "\"Number\": 12345,\n" // number should also work - "\"QuotedNumber\": \"12345\",\n" // number should also work - "\"EmptyArray\": [],\n" - "\"NumberArray\": [1, 2, 3],\n" - "\"BoolArray\": [true, false, true],\n" - "\"StringArray\": [\"foo\", \"bar\"],\n" - "\"Null\": null,\n" // should return empty list - "\"QuotedNull\": \"null\",\n" // this is okay, it is a string - "\"ArrayWithNull\": [ \"foo\", null, \"bar\"],\n" // TODO: null is converted to empty string, is this okay? - "\"Object\": { \"foo\": \"bar\" }\n" // should return empty list - "}", &e).object(); + "\"String\": \"foo\",\n" + "\"OneArrayEntry\": [ \"foo\" ],\n" + "\"Bool\": true,\n" // make sure booleans are accepted + "\"QuotedBool\": \"true\",\n" // make sure booleans are accepted + "\"Number\": 12345,\n" // number should also work + "\"QuotedNumber\": \"12345\",\n" // number should also work + "\"EmptyArray\": [],\n" + "\"NumberArray\": [1, 2, 3],\n" + "\"BoolArray\": [true, false, true],\n" + "\"StringArray\": [\"foo\", \"bar\"],\n" + "\"Null\": null,\n" // should return empty list + "\"QuotedNull\": \"null\",\n" // this is okay, it is a string + "\"ArrayWithNull\": [ \"foo\", null, \"bar\"],\n" // TODO: null is converted to empty string, is this okay? + "\"Object\": { \"foo\": \"bar\" }\n" // should return empty list + "}", &e).object(); QCOMPARE(e.error, QJsonParseError::NoError); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"String\" to be a string list. Treating it as a list with a single entry: \"foo\""); - QCOMPARE(KPluginMetaData::readStringList(jo, "String"), QStringList("foo")); - QCOMPARE(KPluginMetaData::readStringList(jo, "OneArrayEntry"), QStringList("foo")); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"Bool\" to be a string list. Treating it as a list with a single entry: \"true\""); - QCOMPARE(KPluginMetaData::readStringList(jo, "Bool"), QStringList("true")); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedBool\" to be a string list. Treating it as a list with a single entry: \"true\""); - QCOMPARE(KPluginMetaData::readStringList(jo, "QuotedBool"), QStringList("true")); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"Number\" to be a string list. Treating it as a list with a single entry: \"12345\""); - QCOMPARE(KPluginMetaData::readStringList(jo, "Number"), QStringList("12345")); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedNumber\" to be a string list. Treating it as a list with a single entry: \"12345\""); - QCOMPARE(KPluginMetaData::readStringList(jo, "QuotedNumber"), QStringList("12345")); - QCOMPARE(KPluginMetaData::readStringList(jo, "EmptyArray"), QStringList()); - QCOMPARE(KPluginMetaData::readStringList(jo, "NumberArray"), QStringList() << "1" << "2" << "3"); - QCOMPARE(KPluginMetaData::readStringList(jo, "BoolArray"), QStringList() << "true" << "false" << "true"); - QCOMPARE(KPluginMetaData::readStringList(jo, "StringArray"), QStringList() << "foo" << "bar"); - QCOMPARE(KPluginMetaData::readStringList(jo, "Null"), QStringList()); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedNull\" to be a string list. Treating it as a list with a single entry: \"null\""); - QCOMPARE(KPluginMetaData::readStringList(jo, "QuotedNull"), QStringList("null")); - QCOMPARE(KPluginMetaData::readStringList(jo, "ArrayWithNull"), QStringList() << "foo" << "" << "bar"); - QCOMPARE(KPluginMetaData::readStringList(jo, "Object"), QStringList()); + QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"String\" to be a string list. Treating it as a list with a single entry: \"foo\" "); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("String")), QStringList(QStringLiteral("foo")));; + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("OneArrayEntry")), QStringList(QStringLiteral("foo"))); + QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"Bool\" to be a string list. Treating it as a list with a single entry: \"true\" "); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Bool")), QStringList(QStringLiteral("true"))); + QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedBool\" to be a string list. Treating it as a list with a single entry: \"true\" "); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("QuotedBool")), QStringList(QStringLiteral("true"))); + QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"Number\" to be a string list. Treating it as a list with a single entry: \"12345\" "); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Number")), QStringList(QStringLiteral("12345"))); + QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedNumber\" to be a string list. Treating it as a list with a single entry: \"12345\" "); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("QuotedNumber")), QStringList(QStringLiteral("12345"))); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("EmptyArray")), QStringList()); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("NumberArray")), QStringList() << QStringLiteral("1") << QStringLiteral("2") << QStringLiteral("3")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("BoolArray")), QStringList() << QStringLiteral("true") << QStringLiteral("false") << QStringLiteral("true")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("StringArray")), QStringList() << QStringLiteral("foo") << QStringLiteral("bar")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Null")), QStringList()); + QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedNull\" to be a string list. Treating it as a list with a single entry: \"null\" "); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("QuotedNull")), QStringList(QStringLiteral("null"))); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("ArrayWithNull")), QStringList() << QStringLiteral("foo") << QStringLiteral("") << QStringLiteral("bar")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Object")), QStringList()); } void testFromDesktopFile() @@ -235,18 +235,18 @@ QCOMPARE(md.metaDataFileName(), dfile); QCOMPARE(md.iconName(), QStringLiteral("preferences-system-time")); QCOMPARE(md.license(), QStringLiteral("LGPL")); - QCOMPARE(md.website(), QStringLiteral("http://kde.org/")); + QCOMPARE(md.website(), QStringLiteral("https://kde.org/")); QCOMPARE(md.category(), QStringLiteral("Examples")); QCOMPARE(md.version(), QStringLiteral("1.0")); QCOMPARE(md.dependencies(), QStringList()); QCOMPARE(md.isHidden(), false); - QCOMPARE(md.serviceTypes(), QStringList("KService/NSA")); - QCOMPARE(md.mimeTypes(), QStringList() << "image/png" << "application/pdf"); + QCOMPARE(md.serviceTypes(), QStringList(QStringLiteral("KService/NSA"))); + QCOMPARE(md.mimeTypes(), QStringList() << QStringLiteral("image/png") << QStringLiteral("application/pdf")); - auto kp = md.rawData()["KPlugin"].toObject(); + auto kp = md.rawData()[QStringLiteral("KPlugin")].toObject(); QStringList formFactors = KPluginMetaData::readStringList(kp, QStringLiteral("FormFactors")); - QCOMPARE(formFactors, QStringList() << "mediacenter" << "desktop"); - QCOMPARE(md.formFactors(), QStringList() << "mediacenter" << "desktop"); + QCOMPARE(formFactors, QStringList() << QStringLiteral("mediacenter") << QStringLiteral("desktop")); + QCOMPARE(md.formFactors(), QStringList() << QStringLiteral("mediacenter") << QStringLiteral("desktop")); const QString dfilehidden = QFINDTESTDATA("data/hiddenplugin.desktop"); KPluginMetaData mdhidden(dfilehidden); @@ -254,6 +254,17 @@ QCOMPARE(mdhidden.isHidden(), true); } + void twoStepsParseTest() + { + QStandardPaths::setTestModeEnabled(true); + const QString dfile = QFINDTESTDATA("data/twostepsparsetest.desktop"); + const QString typesPath = QFINDTESTDATA("data/servicetypes/example-servicetype.desktop"); + KPluginMetaData md = KPluginMetaData::fromDesktopFile(dfile, QStringList() << typesPath); + QVERIFY(md.isValid()); + QStringList list = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Test-List")); + QCOMPARE(list, QStringList({QStringLiteral("first"), QStringLiteral("second")})); + } + void testServiceTypes_data() { const QString kdevServiceTypePath = QFINDTESTDATA("data/servicetypes/fake-kdevelopplugin.desktop"); @@ -273,17 +284,17 @@ KPluginMetaData md = KPluginMetaData::fromDesktopFile(inputPath, QStringList() << typesPath); QVERIFY(md.isValid()); QCOMPARE(md.name(), QStringLiteral("Example")); - QCOMPARE(md.serviceTypes(), QStringList() << "foo/bar" << "bar/foo"); + QCOMPARE(md.serviceTypes(), QStringList() << QStringLiteral("foo/bar") << QStringLiteral("bar/foo")); // qDebug().noquote() << QJsonDocument(md.rawData()).toJson(); QCOMPARE(md.rawData().size(), 8); - QVERIFY(md.rawData().value("KPlugin").isObject()); - QCOMPARE(md.rawData().value("X-Test-Integer"), QJsonValue(42)); - QCOMPARE(md.rawData().value("X-Test-Bool"), QJsonValue(true)); - QCOMPARE(md.rawData().value("X-Test-Double"), QJsonValue(42.42)); - QCOMPARE(md.rawData().value("X-Test-String"), QJsonValue("foobar")); - QCOMPARE(md.rawData().value("X-Test-List"), QJsonValue(QJsonArray::fromStringList(QStringList() << "a" << "b" << "c" << "def"))); - QCOMPARE(md.rawData().value("X-Test-Size"), QJsonValue("10,20")); // QSize no longer supported (and also no longer used) - QCOMPARE(md.rawData().value("X-Test-Unknown"), QJsonValue("true")); // unknown property -> string + QVERIFY(md.rawData().value(QStringLiteral("KPlugin")).isObject()); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Integer")), QJsonValue(42)); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Bool")), QJsonValue(true)); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Double")), QJsonValue(42.42)); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-String")), QJsonValue(QStringLiteral("foobar"))); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-List")), QJsonValue(QJsonArray::fromStringList(QStringList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c") << QStringLiteral("def")))); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Size")), QJsonValue(QStringLiteral("10,20"))); // QSize no longer supported (and also no longer used) + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Unknown")), QJsonValue(QStringLiteral("true"))); // unknown property -> string } @@ -297,29 +308,28 @@ QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[PropertyDef::\""); QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[\""); QTest::ignoreMessage(QtWarningMsg, "Read empty .desktop file group name! Invalid file?"); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Skipping invalid group \"\" in service type \".*/bad-groups-servicetype.desktop\"")); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Skipping invalid group \"DoesNotStartWithPropertyDef::SomeOtherProperty\" in service type \".+/data/servicetypes/bad-groups-servicetype.desktop\"")); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Skipping invalid group \"\" in service type \".*/bad-groups-servicetype.desktop\""))); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Skipping invalid group \"DoesNotStartWithPropertyDef::SomeOtherProperty\" in service type \".+/data/servicetypes/bad-groups-servicetype.desktop\""))); QTest::ignoreMessage(QtWarningMsg, "Could not find Type= key in group \"PropertyDef::MissingType\""); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Property type \"integer\" is not a known QVariant type. Found while parsing property definition for \"InvalidType\" in \".+/data/servicetypes/bad-groups-servicetype.desktop\"")); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=11\"")); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=13\"")); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=14\"")); - + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Property type \"integer\" is not a known QVariant type. Found while parsing property definition for \"InvalidType\" in \".+/data/servicetypes/bad-groups-servicetype.desktop\""))); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=11\""))); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=13\""))); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=14\""))); KPluginMetaData md = KPluginMetaData::fromDesktopFile(inputPath, QStringList() << typesPath); QVERIFY(md.isValid()); QCOMPARE(md.name(), QStringLiteral("Bad Groups")); // qDebug().noquote() << QJsonDocument(md.rawData()).toJson(); QCOMPARE(md.rawData().size(), 8); - QCOMPARE(md.rawData().value("ThisIsOkay"), QJsonValue(10)); // integer + QCOMPARE(md.rawData().value(QStringLiteral("ThisIsOkay")), QJsonValue(10)); // integer // 11 is empty group - QCOMPARE(md.rawData().value("MissingTerminator"), QJsonValue(12)); // accept missing group terminator (for now) -> integer + QCOMPARE(md.rawData().value(QStringLiteral("MissingTerminator")), QJsonValue(12)); // accept missing group terminator (for now) -> integer // 13 is empty group name // 14 is empty group name - QCOMPARE(md.rawData().value("SomeOtherProperty"), QJsonValue("15")); // does not start with PropertyDef:: -> fall back to string - QCOMPARE(md.rawData().value("TrailingSpacesAreOkay"), QJsonValue(16)); // accept trailing spaces in group name -> integer - QCOMPARE(md.rawData().value("MissingType"), QJsonValue("17")); // Type= missing -> fall back to string - QCOMPARE(md.rawData().value("InvalidType"), QJsonValue("18")); // Type= is invalid -> fall back to string - QCOMPARE(md.rawData().value("ThisIsOkayAgain"), QJsonValue(19)); // valid defintion after invalid ones should still work -> integer + QCOMPARE(md.rawData().value(QStringLiteral("SomeOtherProperty")), QJsonValue(QStringLiteral("15"))); // does not start with PropertyDef:: -> fall back to string + QCOMPARE(md.rawData().value(QStringLiteral("TrailingSpacesAreOkay")), QJsonValue(16)); // accept trailing spaces in group name -> integer + QCOMPARE(md.rawData().value(QStringLiteral("MissingType")), QJsonValue(QStringLiteral("17"))); // Type= missing -> fall back to string + QCOMPARE(md.rawData().value(QStringLiteral("InvalidType")), QJsonValue(QStringLiteral("18"))); // Type= is invalid -> fall back to string + QCOMPARE(md.rawData().value(QStringLiteral("ThisIsOkayAgain")), QJsonValue(19)); // valid defintion after invalid ones should still work -> integer } void testJSONMetadata() @@ -329,10 +339,10 @@ QVERIFY(md.isValid()); QCOMPARE(md.name(), QStringLiteral("Test")); - QCOMPARE(md.value("X-Plasma-MainScript"), QStringLiteral("ui/main.qml")); + QCOMPARE(md.value(QStringLiteral("X-Plasma-MainScript")), QStringLiteral("ui/main.qml")); QJsonArray expected; expected.append(QStringLiteral("Export")); - QCOMPARE(md.rawData().value("X-Purpose-PluginTypes").toArray(), expected); + QCOMPARE(md.rawData().value(QStringLiteral("X-Purpose-PluginTypes")).toArray(), expected); } }; diff -Nru kcoreaddons-5.18.0/autotests/kprocesstest.cpp kcoreaddons-5.44.0a/autotests/kprocesstest.cpp --- kcoreaddons-5.18.0/autotests/kprocesstest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kprocesstest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -44,9 +44,9 @@ { QProcess p; p.setProcessChannelMode(QProcess::MergedChannels); - p.start(gargv[0], QStringList() << QString::number((int)how) << QStringLiteral("--nocrashhandler")); + p.start(QString::fromLatin1(gargv[0]), QStringList() << QString::number(how) << QStringLiteral("--nocrashhandler")); p.waitForFinished(); - return p.readAllStandardOutput(); + return QString::fromLatin1(p.readAllStandardOutput()); } #define EOUT "foo - stdout" @@ -58,8 +58,8 @@ #define EO EOUT "\n" #define EE EERR "\n" #define TESTCHAN(me,ms,pout,rout,rerr) \ - e = "mode: " ms "\n" POUT pout ROUT rout RERR rerr; \ - a = "mode: " ms "\n" + recurse(KProcess::me); \ + e = QStringLiteral("mode: " ms "\n" POUT pout ROUT rout RERR rerr); \ + a = QStringLiteral("mode: " ms "\n") + recurse(KProcess::me); \ QCOMPARE(a, e) void KProcessTest::test_channels() @@ -79,18 +79,19 @@ void KProcessTest::test_setShellCommand() { -// Condition copied from kprocess.cpp + // Condition copied from kprocess.cpp #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__GNU__) QSKIP("This test needs a free UNIX system"); #else KProcess p; - p.setShellCommand("cat"); + p.setShellCommand(QStringLiteral("cat")); QCOMPARE(p.program().count(), 1); - QCOMPARE(p.program().at(0), QStandardPaths::findExecutable("cat")); - QVERIFY(p.program().at(0).endsWith("/bin/cat")); - p.setShellCommand("true || false"); - QCOMPARE(p.program(), QStringList() << "/bin/sh" << "-c" << "true || false"); + QCOMPARE(p.program().at(0), QStandardPaths::findExecutable(QStringLiteral("cat"))); + QVERIFY(p.program().at(0).endsWith(QStringLiteral("/bin/cat"))); + p.setShellCommand(QStringLiteral("true || false")); + QCOMPARE(p.program(), QStringList() << QStringLiteral("/bin/sh") << QStringLiteral("-c") + << QString::fromLatin1("true || false")); #endif } @@ -98,8 +99,8 @@ { if (argv[1]) { KProcess p; - p.setShellCommand("echo " EOUT "; echo " EERR " >&2"); - p.setOutputChannelMode((KProcess::OutputChannelMode)atoi(argv[1])); + p.setShellCommand(QString::fromLatin1("echo " EOUT "; echo " EERR " >&2")); + p.setOutputChannelMode(static_cast(atoi(argv[1]))); fputs(POUT, stdout); fflush(stdout); p.execute(); diff -Nru kcoreaddons-5.18.0/autotests/krandomtest.cpp kcoreaddons-5.44.0a/autotests/krandomtest.cpp --- kcoreaddons-5.18.0/autotests/krandomtest.cpp 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/krandomtest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,216 @@ +/* This file is part of the KDE libraries + Copyright (c) 2016 Michael Pyne + Copyright (c) 2016 Arne Spiegelhauer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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 +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +typedef QVarLengthArray intSequenceType; + +static const char *binpath; + +static bool seqsAreEqual(const intSequenceType &l, const intSequenceType &r) +{ + if(l.size() != r.size()) { + return false; + } + const intSequenceType::const_iterator last(l.end()); + + intSequenceType::const_iterator l_first(l.begin()); + intSequenceType::const_iterator r_first(r.begin()); + + while(l_first != last && *l_first == *r_first) { + l_first++; r_first++; + } + + return l_first == last; +} + +// Fills seq with random bytes produced by a new process. Seq should already +// be sized to the needed amount of random numbers. +static bool getChildRandSeq(intSequenceType &seq) +{ + QProcess subtestProcess; + + // Launch a separate process to generate random numbers to test first-time + // seeding. + subtestProcess.start(QLatin1String(binpath), QStringList() << QString::number(seq.count())); + subtestProcess.waitForFinished(); + + QTextStream childStream(subtestProcess.readAllStandardOutput()); + + std::generate(seq.begin(), seq.end(), [&]() { + int temp; childStream >> temp; return temp; + }); + + char c; + childStream >> c; + return c == '\n' && childStream.status() == QTextStream::Ok; +} + +class KRandomTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void test_random(); + void test_randomString(); + void test_randomStringThreaded(); + void test_KRS(); +}; + +void KRandomTest::test_random() +{ + int testValue = KRandom::random(); + + QVERIFY(testValue >= 0); + QVERIFY(testValue < RAND_MAX); + + // Verify seeding results in different numbers across different procs + // See bug 362161 + intSequenceType out1(10), out2(10); + + QVERIFY(getChildRandSeq(out1)); + QVERIFY(getChildRandSeq(out2)); + + QVERIFY(!seqsAreEqual(out1, out2)); +} + +void KRandomTest::test_randomString() +{ + const int desiredLength = 12; + const QRegExp outputFormat(QStringLiteral("[A-Za-z0-9]+")); + QString testString = KRandom::randomString(desiredLength); + + QCOMPARE(testString.length(), desiredLength); + QVERIFY(outputFormat.exactMatch(testString)); +} + +void KRandomTest::test_KRS() +{ + using std::generate; + using std::all_of; + + const int maxInt = 50000; + KRandomSequence krs1, krs2; + intSequenceType out1(10), out2(10); + + generate(out1.begin(), out1.end(), [&]() { return krs1.getInt(maxInt); }); + generate(out2.begin(), out2.end(), [&]() { return krs2.getInt(maxInt); }); + QVERIFY(!seqsAreEqual(out1, out2)); + QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { return x < maxInt; })); + QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { return x < maxInt; })); + + // Compare same-seed + krs1.setSeed(5000); + krs2.setSeed(5000); + + generate(out1.begin(), out1.end(), [&]() { return krs1.getInt(maxInt); }); + generate(out2.begin(), out2.end(), [&]() { return krs2.getInt(maxInt); }); + QVERIFY(seqsAreEqual(out1, out2)); + QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { return x < maxInt; })); + QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { return x < maxInt; })); + + // Compare same-seed and assignment ctor + + krs1 = KRandomSequence(8000); + krs2 = KRandomSequence(8000); + + generate(out1.begin(), out1.end(), [&]() { return krs1.getInt(maxInt); }); + generate(out2.begin(), out2.end(), [&]() { return krs2.getInt(maxInt); }); + QVERIFY(seqsAreEqual(out1, out2)); + QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { return x < maxInt; })); + QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { return x < maxInt; })); +} + +class KRandomTestThread : public QThread +{ +protected: + void run() override + { + result = KRandom::randomString(32); + }; +public: + QString result; +}; + +void KRandomTest::test_randomStringThreaded() +{ + static const int size = 5; + KRandomTestThread* threads[size]; + for (int i=0; i < size; ++i) { + threads[i] = new KRandomTestThread(); + threads[i]->start(); + } + QSet results; + for (int i=0; i < size; ++i) { + threads[i]->wait(2000); + results.insert(threads[i]->result); + } + // each thread should have returned a unique result + QCOMPARE(results.size(), size); + for (int i=0; i < size; ++i) { + delete threads[i]; + } +} + +// Used by getChildRandSeq... outputs random numbers to stdout and then +// exits the process. +static void childGenRandom(int count) +{ + // No logic to 300, just wanted to avoid it accidentally being 2.4B... + if (count <= 0 || count > 300) { + exit(-1); + } + + while (--count > 0) { + std::cout << KRandom::random() << ' '; + } + + std::cout << KRandom::random() << '\n'; + exit(0); +} + +// Manually implemented to dispatch to child process if needed to support +// subtests +int main(int argc, char *argv[]) +{ + if (argc > 1) { + childGenRandom(std::atoi(argv[1])); + Q_UNREACHABLE(); + } + + binpath = argv[0]; + KRandomTest randomTest; + return QTest::qExec(&randomTest); +} + +#include "krandomtest.moc" diff -Nru kcoreaddons-5.18.0/autotests/kshelltest.cpp kcoreaddons-5.44.0a/autotests/kshelltest.cpp --- kcoreaddons-5.18.0/autotests/kshelltest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kshelltest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -41,18 +41,28 @@ void abortOnMeta(); }; +// The expansion of ~me isn't exactly QDir::homePath(), in case $HOME has a trailing slash, it's kept. +static QString myHomePath() +{ +#ifdef Q_OS_WIN + return QDir::homePath(); +#else + return QString::fromLocal8Bit(qgetenv("HOME")); +#endif +} + void KShellTest::tildeExpand() { QString me(KUser().loginName()); - QCOMPARE(KShell::tildeExpand("~"), QDir::homePath()); - QCOMPARE(KShell::tildeExpand("~/dir"), QString(QDir::homePath() + "/dir")); - QCOMPARE(KShell::tildeExpand('~' + me), QDir::homePath()); - QCOMPARE(KShell::tildeExpand('~' + me + "/dir"), QString(QDir::homePath() + "/dir")); + QCOMPARE(KShell::tildeExpand(QStringLiteral("~")), QDir::homePath()); + QCOMPARE(KShell::tildeExpand(QStringLiteral("~/dir")), QString(QDir::homePath() + QStringLiteral("/dir"))); + QCOMPARE(KShell::tildeExpand(QLatin1Char('~') + me), myHomePath()); + QCOMPARE(KShell::tildeExpand(QLatin1Char('~') + me + QStringLiteral("/dir")), QString(myHomePath() + QStringLiteral("/dir"))); #ifdef Q_OS_WIN - QCOMPARE(KShell::tildeExpand("^~" + me), QString('~' + me)); + QCOMPARE(KShell::tildeExpand(QStringLiteral("^~") + me), QString(QLatin1Char('~') + me)); #else - QCOMPARE(KShell::tildeExpand("\\~" + me), QString('~' + me)); + QCOMPARE(KShell::tildeExpand(QStringLiteral("\\~") + me), QString(QStringLiteral("~") + me)); #endif } @@ -60,18 +70,18 @@ KShellTest::quoteArg() { #ifdef Q_OS_WIN - QCOMPARE(KShell::quoteArg("a space"), QString("\"a space\"")); - QCOMPARE(KShell::quoteArg("fds\\\""), QString("fds\\\\\\^\"")); - QCOMPARE(KShell::quoteArg("\\\\foo"), QString("\\\\foo")); - QCOMPARE(KShell::quoteArg("\"asdf\""), QString("\\^\"asdf\\^\"")); - QCOMPARE(KShell::quoteArg("with\\"), QString("\"with\\\\\"")); - QCOMPARE(KShell::quoteArg("\\\\"), QString("\"\\\\\\\\\"")); - QCOMPARE(KShell::quoteArg("\"a space\\\""), QString("\\^\"\"a space\"\\\\\\^\"")); - QCOMPARE(KShell::quoteArg("as df\\"), QString("\"as df\\\\\"")); - QCOMPARE(KShell::quoteArg("foo bar\"\\\"bla"), QString("\"foo bar\"\\^\"\\\\\\^\"\"bla\"")); - QCOMPARE(KShell::quoteArg("a % space"), QString("\"a %PERCENT_SIGN% space\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("a space")), QStringLiteral("\"a space\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("fds\\\"")), QStringLiteral("fds\\\\\\^\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("\\\\foo")), QStringLiteral("\\\\foo")); + QCOMPARE(KShell::quoteArg(QStringLiteral("\"asdf\"")), QStringLiteral("\\^\"asdf\\^\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("with\\")), QStringLiteral("\"with\\\\\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("\\\\")), QStringLiteral("\"\\\\\\\\\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("\"a space\\\"")), QStringLiteral("\\^\"\"a space\"\\\\\\^\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("as df\\")), QStringLiteral("\"as df\\\\\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("foo bar\"\\\"bla")), QStringLiteral("\"foo bar\"\\^\"\\\\\\^\"\"bla\"")); + QCOMPARE(KShell::quoteArg(QStringLiteral("a % space")), QStringLiteral("\"a %PERCENT_SIGN% space\"")); #else - QCOMPARE(KShell::quoteArg("a space"), QString("'a space'")); + QCOMPARE(KShell::quoteArg(QStringLiteral("a space")), QStringLiteral("'a space'")); #endif } @@ -79,8 +89,8 @@ KShellTest::joinArgs() { QStringList list; - list << "this" << "is" << "a" << "test"; - QCOMPARE(KShell::joinArgs(list), QString("this is a test")); + list << QStringLiteral("this") << QStringLiteral("is") << QStringLiteral("a") << QStringLiteral("test"); + QCOMPARE(KShell::joinArgs(list), QStringLiteral("this is a test")); } static QString sj(const QString &str, KShell::Options flags, KShell::Errors *ret) @@ -94,69 +104,69 @@ KShell::Errors err = KShell::NoError; #ifdef Q_OS_WIN - QCOMPARE(sj("\"(sulli)\" text", KShell::NoOptions, &err), - QString("\"(sulli)\" text")); + QCOMPARE(sj(QStringLiteral("\"(sulli)\" text"), KShell::NoOptions, &err), + QStringLiteral("\"(sulli)\" text")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(" ha\\ lo ", KShell::NoOptions, &err), - QString("\"ha\\\\\" lo")); + QCOMPARE(sj(QStringLiteral(" ha\\ lo "), KShell::NoOptions, &err), + QStringLiteral("\"ha\\\\\" lo")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("say \" error", KShell::NoOptions, &err), + QCOMPARE(sj(QStringLiteral("say \" error"), KShell::NoOptions, &err), QString()); QVERIFY(err == KShell::BadQuoting); - QCOMPARE(sj("no \" error\"", KShell::NoOptions, &err), - QString("no \" error\"")); + QCOMPARE(sj(QStringLiteral("no \" error\""), KShell::NoOptions, &err), + QStringLiteral("no \" error\"")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("say \" still error", KShell::NoOptions, &err), + QCOMPARE(sj(QStringLiteral("say \" still error"), KShell::NoOptions, &err), QString()); QVERIFY(err == KShell::BadQuoting); - QCOMPARE(sj("BLA;asdf sdfess d", KShell::NoOptions, &err), - QString("\"BLA;asdf\" sdfess d")); + QCOMPARE(sj(QStringLiteral("BLA;asdf sdfess d"), KShell::NoOptions, &err), + QStringLiteral("\"BLA;asdf\" sdfess d")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("B\"L\"A&sdf FOO|bar sdf wer ", KShell::NoOptions, &err), - QString("\"BLA&sdf\" \"FOO|bar\" sdf wer")); + QCOMPARE(sj(QStringLiteral("B\"L\"A&sdf FOO|bar sdf wer "), KShell::NoOptions, &err), + QStringLiteral("\"BLA&sdf\" \"FOO|bar\" sdf wer")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("\"\"\"just \"\" fine\"\"\"", KShell::NoOptions, &err), - QString("\\^\"\"just \"\\^\"\" fine\"\\^\"")); + QCOMPARE(sj(QStringLiteral("\"\"\"just \"\" fine\"\"\""), KShell::NoOptions, &err), + QStringLiteral("\\^\"\"just \"\\^\"\" fine\"\\^\"")); QVERIFY(err == KShell::NoError); #else - QCOMPARE(sj("\"~qU4rK\" 'text' 'jo'\"jo\" $'crap' $'\\\\\\'\\e\\x21' ha\\ lo \\a", KShell::NoOptions, &err), - QString("'~qU4rK' text jojo crap '\\'\\''\x1b!' 'ha lo' a")); + QCOMPARE(sj(QString::fromUtf8("\"~qU4rK\" 'text' 'jo'\"jo\" $'crap' $'\\\\\\'\\e\\x21' ha\\ lo \\a"), KShell::NoOptions, &err), + QString::fromUtf8("'~qU4rK' text jojo crap '\\'\\''\x1b!' 'ha lo' a")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("\"~qU4rK\" 'text'", KShell::TildeExpand, &err), - QString("'~qU4rK' text")); + QCOMPARE(sj(QStringLiteral("\"~qU4rK\" 'text'"), KShell::TildeExpand, &err), + QStringLiteral("'~qU4rK' text")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("~\"qU4rK\" 'text'", KShell::TildeExpand, &err), - QString("'~qU4rK' text")); + QCOMPARE(sj(QStringLiteral("~\"qU4rK\" 'text'"), KShell::TildeExpand, &err), + QStringLiteral("'~qU4rK' text")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("~/\"dir\" 'text'", KShell::TildeExpand, &err), - QString(QDir::homePath() + "/dir text")); + QCOMPARE(sj(QStringLiteral("~/\"dir\" 'text'"), KShell::TildeExpand, &err), + QString(QDir::homePath() + QStringLiteral("/dir text"))); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("~ 'text' ~", KShell::TildeExpand, &err), - QString(QDir::homePath() + " text " + QDir::homePath())); + QCOMPARE(sj(QStringLiteral("~ 'text' ~"), KShell::TildeExpand, &err), + QString(QDir::homePath() + QStringLiteral(" text ") + QDir::homePath())); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("\\~ blah", KShell::TildeExpand, &err), - QString("'~' blah")); + QCOMPARE(sj(QStringLiteral("\\~ blah"), KShell::TildeExpand, &err), + QStringLiteral("'~' blah")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj("~qU4rK ~" + KUser().loginName(), KShell::TildeExpand, &err), - QString("'~qU4rK' " + QDir::homePath())); + QCOMPARE(sj(QStringLiteral("~qU4rK ~") + KUser().loginName(), KShell::TildeExpand, &err), + QString(QStringLiteral("'~qU4rK' ") + myHomePath())); QVERIFY(err == KShell::NoError); - const QString unicodeSpaceFileName = "test テスト.txt"; // #345140 + const QString unicodeSpaceFileName = QStringLiteral("test テスト.txt"); // #345140 QCOMPARE(sj(unicodeSpaceFileName, KShell::AbortOnMeta | KShell::TildeExpand, &err), - unicodeSpaceFileName); + unicodeSpaceFileName); QVERIFY(err == KShell::NoError); #endif } @@ -167,8 +177,8 @@ { QTest::addColumn("string"); - QTest::newRow("no space") << QString("hiho"); - QTest::newRow("regular space") << QString("hi there"); + QTest::newRow("no space") << QStringLiteral("hiho"); + QTest::newRow("regular space") << QStringLiteral("hi there"); QTest::newRow("special space") << QString::fromUtf8("如何定期清潔典型的電風扇 講義.pdf"); } @@ -187,56 +197,54 @@ { KShell::Errors err1 = KShell::NoError, err2 = KShell::NoError; - QCOMPARE(sj("text", KShell::AbortOnMeta, &err1), - QString("text")); + QCOMPARE(sj(QStringLiteral("text"), KShell::AbortOnMeta, &err1), + QStringLiteral("text")); QVERIFY(err1 == KShell::NoError); #ifdef Q_OS_WIN - QVERIFY(KShell::splitArgs("BLA & asdf sdfess d", KShell::AbortOnMeta, &err1).isEmpty()); + QVERIFY(KShell::splitArgs(QStringLiteral("BLA & asdf sdfess d"), KShell::AbortOnMeta, &err1).isEmpty()); QVERIFY(err1 == KShell::FoundMeta); - QVERIFY(KShell::splitArgs("foo %PATH% bar", KShell::AbortOnMeta, &err1).isEmpty()); + QVERIFY(KShell::splitArgs(QStringLiteral("foo %PATH% bar"), KShell::AbortOnMeta, &err1).isEmpty()); QVERIFY(err1 == KShell::FoundMeta); - - QCOMPARE(sj("foo %PERCENT_SIGN% bar", KShell::AbortOnMeta, &err1), - QString("foo %PERCENT_SIGN% bar")); + QCOMPARE(sj(QStringLiteral("foo %PERCENT_SIGN% bar"), KShell::AbortOnMeta, &err1), + QStringLiteral("foo %PERCENT_SIGN% bar")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj("@foo ^& bar", KShell::AbortOnMeta, &err1), - QString("foo \"&\" bar")); + QCOMPARE(sj(QStringLiteral("@foo ^& bar"), KShell::AbortOnMeta, &err1), + QStringLiteral("foo \"&\" bar")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj("\"BLA|asdf\" sdfess d", KShell::AbortOnMeta, &err1), - QString("\"BLA|asdf\" sdfess d")); + QCOMPARE(sj(QStringLiteral("\"BLA|asdf\" sdfess d"), KShell::AbortOnMeta, &err1), + QStringLiteral("\"BLA|asdf\" sdfess d")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj("B\"L\"A\"|\"sdf \"FOO | bar\" sdf wer", KShell::AbortOnMeta, &err1), - QString("\"BLA|sdf\" \"FOO | bar\" sdf wer")); + QCOMPARE(sj(QStringLiteral("B\"L\"A\"|\"sdf \"FOO | bar\" sdf wer"), KShell::AbortOnMeta, &err1), + QStringLiteral("\"BLA|sdf\" \"FOO | bar\" sdf wer")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj("b-q me \\\\^|\\\\\\^\"", KShell::AbortOnMeta, &err1), - QString("b-q me \"\\\\|\"\\\\\\^\"")); + QCOMPARE(sj(QStringLiteral("b-q me \\\\^|\\\\\\^\""), KShell::AbortOnMeta, &err1), + QStringLiteral("b-q me \"\\\\|\"\\\\\\^\"")); QVERIFY(err1 == KShell::NoError); #else - QCOMPARE(sj("say \" error", KShell::NoOptions, &err1), + QCOMPARE(sj(QStringLiteral("say \" error"), KShell::NoOptions, &err1), QString()); QVERIFY(err1 != KShell::NoError); - QCOMPARE(sj("say \" still error", KShell::AbortOnMeta, &err1), + QCOMPARE(sj(QStringLiteral("say \" still error"), KShell::AbortOnMeta, &err1), QString()); QVERIFY(err1 != KShell::NoError); - QVERIFY(sj("say `echo no error`", KShell::NoOptions, &err1) != - sj("say `echo no error`", KShell::AbortOnMeta, &err2)); + QVERIFY(sj(QStringLiteral("say `echo no error`"), KShell::NoOptions, &err1) != + sj(QStringLiteral("say `echo no error`"), KShell::AbortOnMeta, &err2)); QVERIFY(err1 != err2); - QVERIFY(sj("BLA=say echo meta", KShell::NoOptions, &err1) != - sj("BLA=say echo meta", KShell::AbortOnMeta, &err2)); + QVERIFY(sj(QStringLiteral("BLA=say echo meta"), KShell::NoOptions, &err1) != + sj(QStringLiteral("BLA=say echo meta"), KShell::AbortOnMeta, &err2)); QVERIFY(err1 != err2); - QVERIFY(sj("B\"L\"A=say FOO=bar echo meta", KShell::NoOptions, &err1) == - sj("B\"L\"A=say FOO=bar echo meta", KShell::AbortOnMeta, &err2)); - QVERIFY(err1 == err2); + QVERIFY(sj(QStringLiteral("B\"L\"A=say FOO=bar echo meta"), KShell::NoOptions, &err1) == + sj(QStringLiteral("B\"L\"A=say FOO=bar echo meta"), KShell::AbortOnMeta, &err2)); #endif } diff -Nru kcoreaddons-5.18.0/autotests/kstringhandlertest.cpp kcoreaddons-5.44.0a/autotests/kstringhandlertest.cpp --- kcoreaddons-5.18.0/autotests/kstringhandlertest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kstringhandlertest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -7,23 +7,23 @@ #include "kstringhandler.h" -QString KStringHandlerTest::test = "The quick brown fox jumped over the lazy bridge. "; +QString KStringHandlerTest::test = QStringLiteral("The quick brown fox jumped over the lazy bridge. "); void KStringHandlerTest::capwords() { QCOMPARE(KStringHandler::capwords(test), - QString("The Quick Brown Fox Jumped Over The Lazy Bridge. ")); + QStringLiteral("The Quick Brown Fox Jumped Over The Lazy Bridge. ")); } void KStringHandlerTest::tagURLs() { - QString test = "Click on http://foo@bar:www.kde.org/yoyo/dyne.html#a1 for info."; + QString test = QStringLiteral("Click on https://foo@bar:www.kde.org/yoyo/dyne.html#a1 for info."); QCOMPARE(KStringHandler::tagUrls(test), - QString("Click on http://foo@bar:www.kde.org/yoyo/dyne.html#a1 for info.")); + QStringLiteral("Click on https://foo@bar:www.kde.org/yoyo/dyne.html#a1 for info.")); - test = "http://www.foo.org/story$806"; + test = QStringLiteral("http://www.foo.org/story$806"); QCOMPARE(KStringHandler::tagUrls(test), - QString("http://www.foo.org/story$806")); + QStringLiteral("http://www.foo.org/story$806")); #if 0 // XFAIL - i.e. this needs to be fixed, but has never been @@ -36,23 +36,26 @@ void KStringHandlerTest::perlSplit() { QStringList expected; - expected << "some" << "string" << "for" << "you__here"; - QCOMPARE(KStringHandler::perlSplit("__", "some__string__for__you__here", 4), expected); + expected << QStringLiteral("some") << QStringLiteral("string") << QStringLiteral("for") + << QStringLiteral("you__here"); + QCOMPARE(KStringHandler::perlSplit(QStringLiteral("__"), QStringLiteral("some__string__for__you__here"), 4), expected); expected.clear(); - expected << "kparts" << "reaches" << "the parts other parts can't"; - QCOMPARE(KStringHandler::perlSplit(' ', "kparts reaches the parts other parts can't", 3), expected); + expected << QStringLiteral("kparts") << QStringLiteral("reaches") << QStringLiteral("the parts other parts can't"); + QCOMPARE(KStringHandler::perlSplit(QLatin1Char(' '), + QStringLiteral("kparts reaches the parts other parts can't"), 3), expected); expected.clear(); - expected << "Split" << "me" << "up ! I'm bored ! OK ?"; - QCOMPARE(KStringHandler::perlSplit(QRegExp("[! ]"), "Split me up ! I'm bored ! OK ?", 3), expected); + expected << QStringLiteral("Split") << QStringLiteral("me") << QStringLiteral("up ! I'm bored ! OK ?"); + QCOMPARE(KStringHandler::perlSplit(QRegExp(QStringLiteral("[! ]")), + QStringLiteral("Split me up ! I'm bored ! OK ?"), 3), expected); } void KStringHandlerTest::obscure() { // See bug 167900, obscure() produced chars that could not properly be converted to and from // UTF8. The result was that storing passwords with '!' in them did not work. - QString test = "!TEST!"; + QString test = QStringLiteral("!TEST!"); QString obscured = KStringHandler::obscure(test); QByteArray obscuredBytes = obscured.toUtf8(); QCOMPARE(KStringHandler::obscure(QString::fromUtf8(obscuredBytes.constData())), test); @@ -70,19 +73,22 @@ // Should insert a ZWSP after each '_' QTest::newRow("underscores") << "foo_bar_baz" - << QString("foo_" + zwsp + "bar_" + zwsp + "baz"); + << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("bar_") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP after each '-' QTest::newRow("hyphens") << "foo-bar-baz" - << QString("foo-" + zwsp + "bar-" + zwsp + "baz"); + << QString(QStringLiteral("foo-") + zwsp + + QStringLiteral("bar-") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP after each '.' QTest::newRow("periods") << "foo.bar.baz" - << QString("foo." + zwsp + "bar." + zwsp + "baz"); + << QString(QStringLiteral("foo.") + + zwsp + QStringLiteral("bar.") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP after each ',' QTest::newRow("commas") << "foo,bar,baz" - << QString("foo," + zwsp + "bar," + zwsp + "baz"); + << QString(QStringLiteral("foo,") + zwsp + + QStringLiteral("bar,") + zwsp + QStringLiteral("baz")); // Should result in no additional breaks since the '_'s are followed by spaces QTest::newRow("mixed underscores and spaces") @@ -93,32 +99,37 @@ // Should insert a ZWSP before '(' and after ')' QTest::newRow("parens") << "foo(bar)baz" - << QString("foo" + zwsp + "(bar)" + zwsp + "baz"); + << QString(QStringLiteral("foo") + zwsp + + QStringLiteral("(bar)") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP before '[' and after ']' QTest::newRow("brackets") << "foo[bar]baz" - << QString("foo" + zwsp + "[bar]" + zwsp + "baz"); + << QString(QStringLiteral("foo") + zwsp + + QStringLiteral("[bar]") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP before '{' and after '}' QTest::newRow("curly braces") << "foo{bar}baz" - << QString("foo" + zwsp + "{bar}" + zwsp + "baz"); + << QString(QStringLiteral("foo") + zwsp + + QStringLiteral("{bar}") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP before '(' but not after ')' since it's the last char QTest::newRow("ends with ')'") << "foo(bar)" - << QString("foo" + zwsp + "(bar)"); + << QString(QStringLiteral("foo") + zwsp + QStringLiteral("(bar)")); // Should insert a single ZWSP between the '_' and the '(' QTest::newRow("'_' followed by '('") << "foo_(bar)" - << QString("foo_" + zwsp + "(bar)"); + << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("(bar)")); // Should insert ZWSP's between the '_' and the '[', between the double // '['s and the double ']'s, but not before and after 'bar' QTest::newRow("'_' before double brackets") << "foo_[[bar]]" - << QString("foo_" + zwsp + '[' + zwsp + "[bar]" + zwsp + ']'); + << QString(QStringLiteral("foo_") + zwsp + + QStringLiteral("[") + zwsp + QStringLiteral("[bar]") + zwsp + + QStringLiteral("]")); // Should only insert ZWSP's between the double '['s and the double ']'s QTest::newRow("space before double brackets") << "foo [[bar]]" - << QString("foo [" + zwsp + "[bar]" + zwsp + "]"); + << QString(QStringLiteral("foo [") + zwsp + QStringLiteral("[bar]") + zwsp + QStringLiteral("]")); // Shouldn't result in any additional breaks since the '(' is preceded // by a space, and the ')' is followed by a space. @@ -126,7 +137,7 @@ // Should insert a WJ (Word Joiner) before a single quote const QChar wj(0x2060); - QTest::newRow("single quote") << "foo'bar" << QString("foo" + wj + "'bar"); + QTest::newRow("single quote") << "foo'bar" << QString(QStringLiteral("foo") + QString(wj) + QStringLiteral("'bar")); } static QString replaceZwsp(const QString &string) @@ -136,7 +147,7 @@ QString result; for (int i = 0; i < string.length(); i++) if (string[i] == zwsp) { - result += ""; + result += QStringLiteral(""); } else { result += string[i]; } @@ -153,3 +164,22 @@ replaceZwsp(expected)); } +void KStringHandlerTest::logicalLength_data() +{ + QTest::addColumn("string"); + QTest::addColumn("expected"); + + QTest::newRow("Latin") << "foo bar baz" << 11; + QTest::newRow("Chinese") << QString::fromUtf8("\xe4\xbd\xa0\xe5\xa5\xbd") << 4; + QTest::newRow("Japanese") << QString::fromUtf8("\xe9\x9d\x92\xe3\x81\x84\xe7\xa9\xba") << 6; + QTest::newRow("Korean") << QString::fromUtf8("\xed\x95\x9c\xea\xb5\xad\xec\x96\xb4") << 6; + QTest::newRow("Mixed") << QString::fromUtf8("KDE\xe6\xa1\x8c\xe9\x9d\xa2") << 7; +} + +void KStringHandlerTest::logicalLength() +{ + QFETCH(QString, string); + QFETCH(int, expected); + QCOMPARE(KStringHandler::logicalLength(string), expected); +} + diff -Nru kcoreaddons-5.18.0/autotests/kstringhandlertest.h kcoreaddons-5.44.0a/autotests/kstringhandlertest.h --- kcoreaddons-5.18.0/autotests/kstringhandlertest.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/kstringhandlertest.h 2018-03-06 08:12:31.000000000 +0000 @@ -14,6 +14,8 @@ void obscure(); void preProcessWrap_data(); void preProcessWrap(); + void logicalLength_data(); + void logicalLength(); private: static QString test; diff -Nru kcoreaddons-5.18.0/autotests/ktexttohtmltest.cpp kcoreaddons-5.44.0a/autotests/ktexttohtmltest.cpp --- kcoreaddons-5.18.0/autotests/ktexttohtmltest.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/autotests/ktexttohtmltest.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -30,6 +30,15 @@ Q_DECLARE_METATYPE(KTextToHTML::Options) +#ifndef Q_OS_WIN +void initLocale() +{ + setenv("LC_ALL", "en_US.utf-8", 1); +} +Q_CONSTRUCTOR_FUNCTION(initLocale) +#endif + + void KTextToHTMLTest::testGetEmailAddress() { // empty input @@ -53,12 +62,12 @@ KTextToHTMLHelper ll6(QStringLiteral(" @bar.baz"), 1); QVERIFY(ll6.getEmailAddress().isEmpty()); KTextToHTMLHelper ll7(QStringLiteral(".!#$%&'*+-/=?^_`{|}~@bar.baz"), - strlen(".!#$%&'*+-/=?^_`{|}~")); + qstrlen(".!#$%&'*+-/=?^_`{|}~")); QVERIFY(ll7.getEmailAddress().isEmpty()); // allowed special chars in local part of address KTextToHTMLHelper ll8(QStringLiteral("a.!#$%&'*+-/=?^_`{|}~@bar.baz"), - strlen("a.!#$%&'*+-/=?^_`{|}~")); + qstrlen("a.!#$%&'*+-/=?^_`{|}~")); QCOMPARE(ll8.getEmailAddress(), QStringLiteral("a.!#$%&'*+-/=?^_`{|}~@bar.baz")); // '@' in domain part @@ -148,7 +157,7 @@ urls << QStringLiteral("user:pass@www.kde.org:1234/sub/path:with:colon/special(123)?a=1#anchor[bla]"); urls << QStringLiteral("user:pass@www.kde.org:1234/\nsub/path:with:colon/\nspecial(123)?\na=1#anchor[bla]"); urls << QStringLiteral("user:pass@www.kde.org:1234/ \n sub/path:with:colon/ \n\t \t special(123)?") + - QStringLiteral("\n\t \n\t a=1#anchor[bla]"); + QStringLiteral("\n\t \n\t a=1#anchor[bla]"); foreach (const QString &schema, schemas) { foreach (QString url, urls) { //krazy:exclude=foreach @@ -193,7 +202,7 @@ urlsWithoutSchema << QStringLiteral(".kde.org:1234/sub/path:with:colon/special(123)?a=1#anchor[bla]"); urlsWithoutSchema << QStringLiteral(".kde.org:1234/\nsub/path:with:colon/\nspecial(123)?\na=1#anchor[bla]"); urlsWithoutSchema << QStringLiteral(".kde.org:1234/ \n sub/path:with:colon/ \n\t \t special(123)?") + - QStringLiteral("\n\t \n\t a=1#anchor[bla]"); + QStringLiteral("\n\t \n\t a=1#anchor[bla]"); QStringList starts; starts << QStringLiteral("www") << QStringLiteral("ftp") << QStringLiteral("news:www"); @@ -231,7 +240,7 @@ } // test max url length - QString url = QStringLiteral("http://www.kde.org/this/is/a_very_loooooong_url/test/test/test"); + QString url = QStringLiteral("https://www.kde.org/this/is/a_very_loooooong_url/test/test/test"); { KTextToHTMLHelper ll(url, 0, 10); QVERIFY(ll.getUrl().isEmpty()); // url too long @@ -363,15 +372,62 @@ "www.example.com/test.cpp."; // Bug 313719 - URL in parenthesis - QTest::newRow("url-in-parenthesis-1") << "KDE (website http://www.kde.org)" + QTest::newRow("url-in-parenthesis-1") << "KDE (website https://www.kde.org)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "KDE (website http://www.kde.org)"; - QTest::newRow("url-in-parenthesis-2") << "KDE website (http://www.kde.org)" + << "KDE (website https://www.kde.org)"; + QTest::newRow("url-in-parenthesis-2") << "KDE website (https://www.kde.org)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "KDE website (http://www.kde.org)"; - QTest::newRow("url-in-parenthesis-3") << "bla (http://www.kde.org - section 5.2)" + << "KDE website (https://www.kde.org)"; + QTest::newRow("url-in-parenthesis-3") << "bla (https://www.kde.org - section 5.2)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "bla (http://www.kde.org - section 5.2)"; + << "bla (https://www.kde.org - section 5.2)"; + + // Fix url as foo < > when we concatened them. + QTest::newRow("url-with-url") << "foo >" + << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + << "foo <https://www.kde.org/ <https://www.kde.org/>>"; + + //Fix url exploit + QTest::newRow("url-exec-html") << "https://\">got deleteself signal for" << e->path; - } - e->m_status = NonExistent; - e->wd = -1; - e->m_ctime = invalid_ctime; - emitEvent(e, Deleted, e->path); - // If the parent dir was already watched, tell it something changed - Entry *parentEntry = entry(e->parentDirectory()); - if (parentEntry) { - parentEntry->dirty = true; - } - // Add entry to parent dir to notice if the entry gets recreated - addEntry(0, e->parentDirectory(), e, true /*isDir*/); - } - if (event->mask & IN_IGNORED) { - // Causes bug #207361 with kernels 2.6.31 and 2.6.32! - //e->wd = -1; - } - if (event->mask & (IN_CREATE | IN_MOVED_TO)) { - Entry *sub_entry = e->findSubEntry(tpath); + Entry *e = m_inotify_wd_to_entry.value(event->wd); + if (!e) { + continue; + } + const bool wasDirty = e->dirty; + e->dirty = true; - if (s_verboseDebug) { - qCDebug(KDIRWATCH) << "-->got CREATE signal for" << (tpath) << "sub_entry=" << sub_entry; - qCDebug(KDIRWATCH) << *e; - } + const QString tpath = e->path + QLatin1Char('/') + path; - // The code below is very similar to the one in checkFAMEvent... - if (sub_entry) { - // We were waiting for this new file/dir to be created - sub_entry->dirty = true; - rescan_timer.start(0); // process this asap, to start watching that dir - } else if (e->isDir && !e->m_clients.empty()) { - const QList clients = e->inotifyClientsForFileOrDir(isDir); - Q_FOREACH (Client *client, clients) { - // See discussion in addEntry for why we don't addEntry for individual - // files in WatchFiles mode with inotify. - if (isDir) { - addEntry(client->instance, tpath, 0, isDir, - isDir ? client->m_watchModes : KDirWatch::WatchDirOnly); - } - } - if (!clients.isEmpty()) { - emitEvent(e, Created, tpath); - qCDebug(KDIRWATCH).nospace() << clients.count() << " instance(s) monitoring the new " - << (isDir ? "dir " : "file ") << tpath; - } - e->m_pendingFileChanges.append(e->path); - if (!rescan_timer.isActive()) { - rescan_timer.start(m_PollInterval); // singleshot - } - } - } - if (event->mask & (IN_DELETE | IN_MOVED_FROM)) { - if (s_verboseDebug) { - qCDebug(KDIRWATCH) << "-->got DELETE signal for" << tpath; - } - if ((e->isDir) && (!e->m_clients.empty())) { - Client *client = 0; - // A file in this directory has been removed. It wasn't an explicitly - // watched file as it would have its own watch descriptor, so - // no addEntry/ removeEntry bookkeeping should be required. Emit - // the event immediately if any clients are interested. - KDirWatch::WatchModes flag = isDir ? KDirWatch::WatchSubDirs : KDirWatch::WatchFiles; - int counter = 0; - Q_FOREACH (client, e->m_clients) { // krazy:exclude=Q_FOREACH - if (client->m_watchModes & flag) { - counter++; - } - } - if (counter != 0) { - emitEvent(e, Deleted, tpath); - } + if (s_verboseDebug) { + qCDebug(KDIRWATCH).nospace() << "got event 0x" << qPrintable(QString::number(event->mask, 16)) << " for " << e->path; + } + + if (event->mask & IN_DELETE_SELF) { + if (s_verboseDebug) { + qCDebug(KDIRWATCH) << "-->got deleteself signal for" << e->path; + } + e->m_status = NonExistent; + m_inotify_wd_to_entry.remove(e->wd); + e->wd = -1; + e->m_ctime = invalid_ctime; + emitEvent(e, Deleted, e->path); + // If the parent dir was already watched, tell it something changed + Entry *parentEntry = entry(e->parentDirectory()); + if (parentEntry) { + parentEntry->dirty = true; + } + // Add entry to parent dir to notice if the entry gets recreated + addEntry(nullptr, e->parentDirectory(), e, true /*isDir*/); + } + if (event->mask & IN_IGNORED) { + // Causes bug #207361 with kernels 2.6.31 and 2.6.32! + //e->wd = -1; + } + if (event->mask & (IN_CREATE | IN_MOVED_TO)) { + Entry *sub_entry = e->findSubEntry(tpath); + + if (s_verboseDebug) { + qCDebug(KDIRWATCH) << "-->got CREATE signal for" << (tpath) << "sub_entry=" << sub_entry; + qCDebug(KDIRWATCH) << *e; + } + + // The code below is very similar to the one in checkFAMEvent... + if (sub_entry) { + // We were waiting for this new file/dir to be created + sub_entry->dirty = true; + rescan_timer.start(0); // process this asap, to start watching that dir + } else if (e->isDir && !e->m_clients.empty()) { + const QList clients = e->inotifyClientsForFileOrDir(isDir); + // See discussion in addEntry for why we don't addEntry for individual + // files in WatchFiles mode with inotify. + if (isDir) { + for (const Client *client : clients) { + addEntry(client->instance, tpath, nullptr, isDir, + isDir ? client->m_watchModes : KDirWatch::WatchDirOnly); } } - if (event->mask & (IN_MODIFY | IN_ATTRIB)) { - if ((e->isDir) && (!e->m_clients.empty())) { - if (s_verboseDebug) { - qCDebug(KDIRWATCH) << "-->got MODIFY signal for" << (tpath); - } - // A file in this directory has been changed. No - // addEntry/ removeEntry bookkeeping should be required. - // Add the path to the list of pending file changes if - // there are any interested clients. - //QT_STATBUF stat_buf; - //QByteArray tpath = QFile::encodeName(e->path+'/'+path); - //QT_STAT(tpath, &stat_buf); - //bool isDir = S_ISDIR(stat_buf.st_mode); - - // The API doc is somewhat vague as to whether we should emit - // dirty() for implicitly watched files when WatchFiles has - // not been specified - we'll assume they are always interested, - // regardless. - // Don't worry about duplicates for the time - // being; this is handled in slotRescan. - e->m_pendingFileChanges.append(tpath); - // Avoid stat'ing the directory if only an entry inside it changed. - e->dirty = (wasDirty || (path.isEmpty() && (event->mask & IN_ATTRIB))); - } + if (!clients.isEmpty()) { + emitEvent(e, Created, tpath); + qCDebug(KDIRWATCH).nospace() << clients.count() << " instance(s) monitoring the new " + << (isDir ? "dir " : "file ") << tpath; } - + e->m_pendingFileChanges.append(e->path); if (!rescan_timer.isActive()) { rescan_timer.start(m_PollInterval); // singleshot } - - break; } } + if (event->mask & (IN_DELETE | IN_MOVED_FROM)) { + if (s_verboseDebug) { + qCDebug(KDIRWATCH) << "-->got DELETE signal for" << tpath; + } + if ((e->isDir) && (!e->m_clients.empty())) { + // A file in this directory has been removed. It wasn't an explicitly + // watched file as it would have its own watch descriptor, so + // no addEntry/ removeEntry bookkeeping should be required. Emit + // the event immediately if any clients are interested. + KDirWatch::WatchModes flag = isDir ? KDirWatch::WatchSubDirs : KDirWatch::WatchFiles; + int counter = 0; + for (const Client &client : e->m_clients) { + if (client.m_watchModes & flag) { + counter++; + } + } + if (counter != 0) { + emitEvent(e, Deleted, tpath); + } + } + } + if (event->mask & (IN_MODIFY | IN_ATTRIB)) { + if ((e->isDir) && (!e->m_clients.empty())) { + if (s_verboseDebug) { + qCDebug(KDIRWATCH) << "-->got MODIFY signal for" << (tpath); + } + // A file in this directory has been changed. No + // addEntry/ removeEntry bookkeeping should be required. + // Add the path to the list of pending file changes if + // there are any interested clients. + //QT_STATBUF stat_buf; + //QByteArray tpath = QFile::encodeName(e->path+'/'+path); + //QT_STAT(tpath, &stat_buf); + //bool isDir = S_ISDIR(stat_buf.st_mode); + + // The API doc is somewhat vague as to whether we should emit + // dirty() for implicitly watched files when WatchFiles has + // not been specified - we'll assume they are always interested, + // regardless. + // Don't worry about duplicates for the time + // being; this is handled in slotRescan. + e->m_pendingFileChanges.append(tpath); + // Avoid stat'ing the directory if only an entry inside it changed. + e->dirty = (wasDirty || (path.isEmpty() && (event->mask & IN_ATTRIB))); + } + } + + if (!rescan_timer.isActive()) { + rescan_timer.start(m_PollInterval); // singleshot + } } if (bytesAvailable > 0) { // copy partial event to beginning of buffer @@ -446,6 +440,10 @@ #endif } +KDirWatchPrivate::Entry::~Entry() +{ +} + /* In FAM mode, only entries which are marked dirty are scanned. * We first need to mark all yet nonexistent, but possible created * entries as dirty... @@ -466,39 +464,31 @@ void KDirWatchPrivate::Entry::addClient(KDirWatch *instance, KDirWatch::WatchModes watchModes) { - if (instance == 0) { + if (instance == nullptr) { return; } - Q_FOREACH (Client *client, m_clients) { - if (client->instance == instance) { - client->count++; - client->m_watchModes = watchModes; + for (Client &client : m_clients) { + if (client.instance == instance) { + client.count++; + client.m_watchModes = watchModes; return; } } - Client *client = new Client; - client->instance = instance; - client->count = 1; - client->watchingStopped = instance->isStopped(); - client->pending = NoChange; - client->m_watchModes = watchModes; - - m_clients.append(client); + m_clients.emplace_back(instance, watchModes); } void KDirWatchPrivate::Entry::removeClient(KDirWatch *instance) { - QList::iterator it = m_clients.begin(); - const QList::iterator end = m_clients.end(); + auto it = m_clients.begin(); + const auto end = m_clients.end(); for (; it != end; ++it) { - Client *client = *it; - if (client->instance == instance) { - client->count--; - if (client->count == 0) { + Client &client = *it; + if (client.instance == instance) { + client.count--; + if (client.count == 0) { m_clients.erase(it); - delete client; } return; } @@ -509,8 +499,8 @@ int KDirWatchPrivate::Entry::clientCount() const { int clients = 0; - Q_FOREACH (Client *client, m_clients) { - clients += client->count; + for (const Client &client : m_clients) { + clients += client.count; } return clients; @@ -521,16 +511,16 @@ return QDir::cleanPath(path + QLatin1String("/..")); } -QList KDirWatchPrivate::Entry::clientsForFileOrDir(const QString &tpath, bool *isDir) const +QList KDirWatchPrivate::Entry::clientsForFileOrDir(const QString &tpath, bool *isDir) const { - QList ret; + QList ret; QFileInfo fi(tpath); if (fi.exists()) { *isDir = fi.isDir(); const KDirWatch::WatchModes flag = *isDir ? KDirWatch::WatchSubDirs : KDirWatch::WatchFiles; - Q_FOREACH (Client *client, this->m_clients) { - if (client->m_watchModes & flag) { - ret.append(client); + for (const Client &client : m_clients) { + if (client.m_watchModes & flag) { + ret.append(&client); } } } else { @@ -544,13 +534,13 @@ // inotify specific function that doesn't call KDE::stat to figure out if we have a file or folder. // isDir is determined through inotify's "IN_ISDIR" flag in KDirWatchPrivate::inotifyEventReceived -QList KDirWatchPrivate::Entry::inotifyClientsForFileOrDir(bool isDir) const +QList KDirWatchPrivate::Entry::inotifyClientsForFileOrDir(bool isDir) const { - QList ret; + QList ret; const KDirWatch::WatchModes flag = isDir ? KDirWatch::WatchSubDirs : KDirWatch::WatchFiles; - Q_FOREACH (Client *client, this->m_clients) { - if (client->m_watchModes & flag) { - ret.append(client); + for (const Client &client : m_clients) { + if (client.m_watchModes & flag) { + ret.append(&client); } } return ret; @@ -571,7 +561,7 @@ debug << " inotify_wd=" << entry.wd; } #endif - debug << ", has " << entry.m_clients.count() << " clients"; + debug << ", has " << entry.m_clients.size() << " clients"; debug.space(); if (!entry.m_entries.isEmpty()) { debug << ", nonexistent subentries:"; @@ -587,7 +577,7 @@ { // we only support absolute paths if (_path.isEmpty() || QDir::isRelativePath(_path)) { - return 0; + return nullptr; } QString path(_path); @@ -598,7 +588,7 @@ EntryMap::Iterator it = m_mapEntries.find(path); if (it == m_mapEntries.end()) { - return 0; + return nullptr; } else { return &(*it); } @@ -719,7 +709,7 @@ e->m_mode = INotifyMode; if (e->m_status == NonExistent) { - addEntry(0, e->parentDirectory(), e, true); + addEntry(nullptr, e->parentDirectory(), e, true); return true; } @@ -728,6 +718,7 @@ if ((e->wd = inotify_add_watch(m_inotify_fd, QFile::encodeName(e->path).data(), mask)) >= 0) { + m_inotify_wd_to_entry.insert(e->wd, e); if (s_verboseDebug) { qCDebug(KDIRWATCH) << "inotify successfully used for monitoring" << e->path << "wd=" << e->wd; } @@ -745,7 +736,7 @@ e->dirty = false; if (e->m_status == NonExistent) { - addEntry(0, e->parentDirectory(), e, true /*isDir*/); + addEntry(nullptr, e->parentDirectory(), e, true /*isDir*/); return true; } @@ -786,13 +777,17 @@ /* If !=0, this KDirWatch instance wants to watch at <_path>, * providing in the type of the entry to be watched. - * Sometimes, entries are dependant on each other: if !=0, - * this entry needs another entry to watch himself (when notExistent). + * Sometimes, entries are dependent on each other: if !=0, + * this entry needs another entry to watch itself (when notExistent). */ void KDirWatchPrivate::addEntry(KDirWatch *instance, const QString &_path, Entry *sub_entry, bool isDir, KDirWatch::WatchModes watchModes) { QString path(_path); + if (path.startsWith(QLatin1String(":/"))) { + qCWarning(KDIRWATCH) << "Cannot watch QRC-like path" << path; + return; + } if (path.isEmpty() #ifndef Q_OS_WIN || path == QLatin1String("/dev") @@ -815,22 +810,6 @@ qCDebug(KDIRWATCH) << "Added already watched Entry" << path << "(for" << sub_entry->path << ")"; } -#if HAVE_SYS_INOTIFY_H - Entry *e = &(*it); - if ((e->m_mode == INotifyMode) && (e->wd >= 0)) { - int mask = IN_DELETE | IN_DELETE_SELF | IN_CREATE | IN_MOVE | IN_MOVE_SELF | IN_DONT_FOLLOW; - if (!e->isDir) { - mask |= IN_MODIFY | IN_ATTRIB; - } else { - mask |= IN_ONLYDIR; - } - - inotify_rm_watch(m_inotify_fd, e->wd); - e->wd = inotify_add_watch(m_inotify_fd, QFile::encodeName(e->path).data(), - mask); - //Q_ASSERT(e->wd >= 0); // fails in KDirListerTest::testDeleteCurrentDir - } -#endif } else { (*it).addClient(instance, watchModes); if (s_verboseDebug) { @@ -866,13 +845,13 @@ #endif if (e->isDir && !isDir) { - qWarning() << "KDirWatch:" << path << "is a directory. Use addDir!"; + qCWarning(KCOREADDONS_DEBUG) << "KDirWatch:" << path << "is a directory. Use addDir!"; } else if (!e->isDir && isDir) { - qWarning("KDirWatch: %s is a file. Use addFile!", qPrintable(path)); + qCWarning(KCOREADDONS_DEBUG) << "KDirWatch:" << path << "is a file. Use addFile!"; } if (!e->isDir && (watchModes != KDirWatch::WatchDirOnly)) { - qWarning() << "KDirWatch:" << path << "is a file. You can't use recursive or " + qCWarning(KCOREADDONS_DEBUG) << "KDirWatch:" << path << "is a file. You can't use recursive or " "watchFiles options"; watchModes = KDirWatch::WatchDirOnly; } @@ -946,7 +925,7 @@ // treat symlinks as files--don't follow them. bool isDir = fileInfo.isDir() && !fileInfo.isSymLink(); - addEntry(instance, fileInfo.absoluteFilePath(), 0, isDir, + addEntry(instance, fileInfo.absoluteFilePath(), nullptr, isDir, isDir ? watchModes : KDirWatch::WatchDirOnly); } } @@ -984,7 +963,6 @@ case KDirWatch::QFSWatch: entryAdded = useQFSWatch(e); break; #endif case KDirWatch::Stat: entryAdded = useStat(e); break; - default: break; } // Failing that try in order INotify, FAM, QFSWatch, Stat @@ -1019,6 +997,7 @@ #endif #if HAVE_SYS_INOTIFY_H if (e->m_mode == INotifyMode) { + m_inotify_wd_to_entry.remove(e->wd); (void) inotify_rm_watch(m_inotify_fd, e->wd); if (s_verboseDebug) { qCDebug(KDIRWATCH).nospace() << "Cancelled INotify (fd " << m_inotify_fd << ", " @@ -1036,7 +1015,7 @@ #endif } -bool KDirWatchPrivate::removeEntry(KDirWatch *instance, +void KDirWatchPrivate::removeEntry(KDirWatch *instance, const QString &_path, Entry *sub_entry) { @@ -1044,12 +1023,9 @@ qCDebug(KDIRWATCH) << "path=" << _path << "sub_entry:" << sub_entry; } Entry *e = entry(_path); - if (!e) { - return false; + if (e) { + removeEntry(instance, e, sub_entry); } - - removeEntry(instance, e, sub_entry); - return true; } void KDirWatchPrivate::removeEntry(KDirWatch *instance, @@ -1079,9 +1055,9 @@ } else { // Removed a NonExistent entry - we just remove it from the parent if (e->isDir) { - removeEntry(0, e->parentDirectory(), e); + removeEntry(nullptr, e->parentDirectory(), e); } else { - removeEntry(0, QFileInfo(e->path).absolutePath(), e); + removeEntry(nullptr, QFileInfo(e->path).absolutePath(), e); } } @@ -1099,6 +1075,9 @@ << " [" << (instance ? instance->objectName() : QString()) << "]"; } QString p = e->path; // take a copy, QMap::remove takes a reference and deletes, since e points into the map +#if HAVE_SYS_INOTIFY_H + m_inotify_wd_to_entry.remove(e->wd); +#endif m_mapEntries.remove(p); // not valid any more } @@ -1113,10 +1092,10 @@ // put all entries where instance is a client in list EntryMap::Iterator it = m_mapEntries.begin(); for (; it != m_mapEntries.end(); ++it) { - Client *c = 0; - Q_FOREACH (Client *client, (*it).m_clients) { - if (client->instance == instance) { - c = client; + Client *c = nullptr; + for (Client &client : (*it).m_clients) { + if (client.instance == instance) { + c = &client; break; } } @@ -1129,7 +1108,7 @@ } Q_FOREACH (const QString &path, pathList) { - removeEntry(instance, path, 0); + removeEntry(instance, path, nullptr); } if (minfreq > freq) { @@ -1146,11 +1125,11 @@ bool KDirWatchPrivate::stopEntryScan(KDirWatch *instance, Entry *e) { int stillWatching = 0; - Q_FOREACH (Client *client, e->m_clients) { - if (!instance || instance == client->instance) { - client->watchingStopped = true; - } else if (!client->watchingStopped) { - stillWatching += client->count; + for (Client &client : e->m_clients) { + if (!instance || instance == client.instance) { + client.watchingStopped = true; + } else if (!client.watchingStopped) { + stillWatching += client.count; } } @@ -1175,12 +1154,12 @@ bool notify) { int wasWatching = 0, newWatching = 0; - Q_FOREACH (Client *client, e->m_clients) { - if (!client->watchingStopped) { - wasWatching += client->count; - } else if (!instance || instance == client->instance) { - client->watchingStopped = false; - newWatching += client->count; + for (Client &client : e->m_clients) { + if (!client.watchingStopped) { + wasWatching += client.count; + } else if (!instance || instance == client.instance) { + client.watchingStopped = false; + newWatching += client.count; } } if (newWatching == 0) { @@ -1210,7 +1189,7 @@ e->m_ino = stat_buf.st_ino; // Same as in scanEntry: ensure no subentry in parent dir - removeEntry(0, e->parentDirectory(), e); + removeEntry(nullptr, e->parentDirectory(), e); } else { e->m_ctime = invalid_ctime; e->m_status = NonExistent; @@ -1259,9 +1238,9 @@ EntryMap::Iterator it = m_mapEntries.begin(); for (; it != m_mapEntries.end(); ++it) { - Q_FOREACH (Client *client, (*it).m_clients) { - if (!client->watchingStopped || skippedToo) { - client->pending = NoChange; + for (Client &client : (*it).m_clients) { + if (!client.watchingStopped || skippedToo) { + client.pending = NoChange; } } } @@ -1310,7 +1289,7 @@ qCDebug(KDIRWATCH) << "Setting status to Normal for just created" << e << e->path; } // We need to make sure the entry isn't listed in its parent's subentries... (#222974, testMoveTo) - removeEntry(0, e->parentDirectory(), e); + removeEntry(nullptr, e->parentDirectory(), e); return Created; } @@ -1375,7 +1354,7 @@ * and stored pending events. When watching is stopped, the event is * added to the pending events. */ -void KDirWatchPrivate::emitEvent(const Entry *e, int event, const QString &fileName) +void KDirWatchPrivate::emitEvent(Entry *e, int event, const QString &fileName) { QString path(e->path); if (!fileName.isEmpty()) { @@ -1392,30 +1371,30 @@ } if (s_verboseDebug) { - qCDebug(KDIRWATCH) << event << path << e->m_clients.count() << "clients"; + qCDebug(KDIRWATCH) << event << path << e->m_clients.size() << "clients"; } - Q_FOREACH (Client *c, e->m_clients) { - if (c->instance == 0 || c->count == 0) { + for (Client &c : e->m_clients) { + if (c.instance == nullptr || c.count == 0) { continue; } - if (c->watchingStopped) { + if (c.watchingStopped) { // Do not add event to a list of pending events, the docs say restartDirScan won't emit! #if 0 if (event == Changed) { - c->pending |= event; + c.pending |= event; } else if (event == Created || event == Deleted) { - c->pending = event; + c.pending = event; } #endif continue; } // not stopped if (event == NoChange || event == Changed) { - event |= c->pending; + event |= c.pending; } - c->pending = NoChange; + c.pending = NoChange; if (event == NoChange) { continue; } @@ -1423,16 +1402,28 @@ // Emit the signals delayed, to avoid unexpected re-entrancy from the slots (#220153) if (event & Deleted) { - QMetaObject::invokeMethod(c->instance, "setDeleted", Qt::QueuedConnection, Q_ARG(QString, path)); +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + QMetaObject::invokeMethod(c.instance, "setDeleted", Qt::QueuedConnection, Q_ARG(QString, path)); +#else + QMetaObject::invokeMethod(c.instance, [c, path]() { c.instance->setDeleted(path); }, Qt::QueuedConnection); +#endif } if (event & Created) { - QMetaObject::invokeMethod(c->instance, "setCreated", Qt::QueuedConnection, Q_ARG(QString, path)); +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + QMetaObject::invokeMethod(c.instance, "setCreated", Qt::QueuedConnection, Q_ARG(QString, path)); +#else + QMetaObject::invokeMethod(c.instance, [c, path]() { c.instance->setCreated(path); }, Qt::QueuedConnection); +#endif // possible emit Change event after creation } if (event & Changed) { - QMetaObject::invokeMethod(c->instance, "setDirty", Qt::QueuedConnection, Q_ARG(QString, path)); +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + QMetaObject::invokeMethod(c.instance, "setDirty", Qt::QueuedConnection, Q_ARG(QString, path)); +#else + QMetaObject::invokeMethod(c.instance, [c, path]() { c.instance->setDirty(path); }, Qt::QueuedConnection); +#endif } } } @@ -1446,7 +1437,7 @@ // so don't use Q_FOREACH or iterators here... while (!removeList.isEmpty()) { Entry *entry = *removeList.begin(); - removeEntry(0, entry, 0); // this will remove entry from removeList + removeEntry(nullptr, entry, nullptr); // this will remove entry from removeList } } @@ -1515,7 +1506,7 @@ if (s_verboseDebug) { qCDebug(KDIRWATCH) << "scanEntry says" << entry->path << "was deleted"; } - addEntry(0, entry->parentDirectory(), entry, true); + addEntry(nullptr, entry->parentDirectory(), entry, true); } else if (ev == Created) { if (s_verboseDebug) { qCDebug(KDIRWATCH) << "scanEntry says" << entry->path << "was created. wd=" << entry->wd; @@ -1568,7 +1559,7 @@ #if HAVE_SYS_INOTIFY_H // Remove watch of parent of new created directories Q_FOREACH (Entry *e, cList) { - removeEntry(0, e->parentDirectory(), e); + removeEntry(nullptr, e->parentDirectory(), e); } #endif @@ -1606,14 +1597,14 @@ while (use_fam && FAMPending(&fc)) { if (FAMNextEvent(&fc, &fe) == -1) { - qWarning() << "FAM connection problem, switching to polling."; + qCWarning(KCOREADDONS_DEBUG) << "FAM connection problem, switching to polling."; use_fam = false; delete sn; sn = 0; // Replace all FAMMode entries with INotify/Stat EntryMap::Iterator it = m_mapEntries.begin(); for (; it != m_mapEntries.end(); ++it) - if ((*it).m_mode == FAMMode && (*it).m_clients.count() > 0) { + if ((*it).m_mode == FAMMode && !(*it).m_clients.empty()) { Entry *e = &(*it); addWatch(e); } @@ -1727,8 +1718,8 @@ rescan_timer.start(0); // process this asap, to start watching that dir } else if (e->isDir && !e->m_clients.empty()) { bool isDir = false; - const QList clients = e->clientsForFileOrDir(tpath, &isDir); - Q_FOREACH (Client *client, clients) { + const QList clients = e->clientsForFileOrDir(tpath, &isDir); + Q_FOREACH (const Client *client, clients) { addEntry(client->instance, tpath, 0, isDir, isDir ? client->m_watchModes : KDirWatch::WatchDirOnly); } @@ -1749,7 +1740,7 @@ #else void KDirWatchPrivate::famEventReceived() { - qWarning() << "Fam event received but FAM is not supported"; + qCWarning(KCOREADDONS_DEBUG) << "Fam event received but FAM is not supported"; } #endif @@ -1766,16 +1757,16 @@ Entry *e = &(*it); qCDebug(KDIRWATCH) << " " << *e; - Q_FOREACH (Client *c, e->m_clients) { + for (const Client &c : e->m_clients) { QByteArray pending; - if (c->watchingStopped) { - if (c->pending & Deleted) { + if (c.watchingStopped) { + if (c.pending & Deleted) { pending += "deleted "; } - if (c->pending & Created) { + if (c.pending & Created) { pending += "created "; } - if (c->pending & Changed) { + if (c.pending & Changed) { pending += "changed "; } if (!pending.isEmpty()) { @@ -1783,8 +1774,8 @@ } pending = ", stopped" + pending; } - qCDebug(KDIRWATCH) << " by " << c->instance->objectName() - << " (" << c->count << " times)" << pending; + qCDebug(KDIRWATCH) << " by " << c.instance->objectName() + << " (" << c.count << " times)" << pending; } if (e->m_entries.count() > 0) { qCDebug(KDIRWATCH) << " dependent entries:"; @@ -1819,9 +1810,9 @@ } if (ev == Deleted) { if (e->isDir) { - addEntry(0, e->parentDirectory(), e, true); + addEntry(nullptr, e->parentDirectory(), e, true); } else { - addEntry(0, QFileInfo(e->path).absolutePath(), e, true); + addEntry(nullptr, QFileInfo(e->path).absolutePath(), e, true); } } else if (ev == Created) { // We were waiting for it to appear; now watch it @@ -1846,7 +1837,7 @@ void KDirWatchPrivate::fswEventReceived(const QString &path) { Q_UNUSED(path); - qWarning() << "QFileSystemWatcher event received but QFileSystemWatcher is not supported"; + qCWarning(KCOREADDONS_DEBUG) << "QFileSystemWatcher event received but QFileSystemWatcher is not supported"; } #endif // HAVE_QFILESYSTEMWATCHER @@ -1881,8 +1872,6 @@ const int counter = nameCounter.fetchAndAddRelaxed(1); // returns the old value setObjectName(QStringLiteral("KDirWatch-%1").arg(counter)); - d->_isStopped = false; - if (counter == 1) { // very first KDirWatch instance // Must delete QFileSystemWatcher before qApp is gone - bug 261541 qAddPostRoutine(postRoutine_KDirWatch); @@ -1891,7 +1880,7 @@ KDirWatch::~KDirWatch() { - if (dwp_self.hasLocalData()) { // skip this after app destruction + if (d && dwp_self.hasLocalData()) { // skip this after app destruction d->removeEntries(this); } } @@ -1899,7 +1888,7 @@ void KDirWatch::addDir(const QString &_path, WatchModes watchModes) { if (d) { - d->addEntry(this, _path, 0, true, watchModes); + d->addEntry(this, _path, nullptr, true, watchModes); } } @@ -1909,7 +1898,7 @@ return; } - d->addEntry(this, _path, 0, false); + d->addEntry(this, _path, nullptr, false); } QDateTime KDirWatch::ctime(const QString &_path) const @@ -1926,18 +1915,14 @@ void KDirWatch::removeDir(const QString &_path) { if (d) { - if (!d->removeEntry(this, _path, 0)) { - qWarning() << "doesn't know" << _path; - } + d->removeEntry(this, _path, nullptr); } } void KDirWatch::removeFile(const QString &_path) { if (d) { - if (!d->removeEntry(this, _path, 0)) { - qWarning() << "doesn't know" << _path; - } + d->removeEntry(this, _path, nullptr); } } @@ -1993,8 +1978,8 @@ return false; } - Q_FOREACH (KDirWatchPrivate::Client *client, e->m_clients) { - if (client->instance == this) { + for (const KDirWatchPrivate::Client &client : e->m_clients) { + if (client.instance == this) { return true; } } @@ -2005,8 +1990,8 @@ void KDirWatch::deleteQFSWatcher() { delete d->fsWatcher; - d->fsWatcher = 0; - d = 0; + d->fsWatcher = nullptr; + d = nullptr; } void KDirWatch::statistics() @@ -2044,17 +2029,18 @@ case KDirWatch::FAM: if (d->use_fam) { return KDirWatch::FAM; } + break; #endif #if HAVE_SYS_INOTIFY_H case KDirWatch::INotify: if (d->supports_inotify) { return KDirWatch::INotify; } + break; #endif #if HAVE_QFILESYSTEMWATCHER case KDirWatch::QFSWatch: return KDirWatch::QFSWatch; #endif case KDirWatch::Stat: return KDirWatch::Stat; - default: break; } #if HAVE_SYS_INOTIFY_H @@ -2069,8 +2055,9 @@ #endif #if HAVE_QFILESYSTEMWATCHER return KDirWatch::QFSWatch; -#endif +#else return KDirWatch::Stat; +#endif } #include "moc_kdirwatch.cpp" diff -Nru kcoreaddons-5.18.0/src/lib/io/kdirwatch.h kcoreaddons-5.44.0a/src/lib/io/kdirwatch.h --- kcoreaddons-5.18.0/src/lib/io/kdirwatch.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kdirwatch.h 2018-03-06 08:12:31.000000000 +0000 @@ -27,6 +27,8 @@ class KDirWatchPrivate; /** + * @class KDirWatch kdirwatch.h KDirWatch + * * @short Class for watching directory and file changes. * * Watch directories and files for changes. @@ -84,7 +86,7 @@ * is added. * @param parent the parent of the QObject (or 0 for parent-less KDataTools) */ - KDirWatch(QObject *parent = 0); + KDirWatch(QObject *parent = nullptr); /** * Destructor. @@ -154,7 +156,7 @@ * * @param path the path to skip * @return true if the @p path is being watched, otherwise false - * @see restartDirScanning() + * @see restartDirScan() */ bool stopDirScan(const QString &path); @@ -169,7 +171,7 @@ * * @param path the path to restart scanning * @return true if the @p path is being watched, otherwise false - * @see stopDirScanning() + * @see stopDirScan() */ bool restartDirScan(const QString &path); @@ -212,7 +214,7 @@ */ bool contains(const QString &path) const; - void deleteQFSWatcher(); + void deleteQFSWatcher(); // KF6 TODO: remove from public API /** * Dump statistic information about the KDirWatch::self() instance. diff -Nru kcoreaddons-5.18.0/src/lib/io/kdirwatch_p.h kcoreaddons-5.44.0a/src/lib/io/kdirwatch_p.h --- kcoreaddons-5.18.0/src/lib/io/kdirwatch_p.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kdirwatch_p.h 2018-03-06 08:12:31.000000000 +0000 @@ -52,7 +52,7 @@ #include // time_t, ino_t #include -#define invalid_ctime ((time_t)-1) +#define invalid_ctime (static_cast(-1)) #if HAVE_QFILESYSTEMWATCHER #include @@ -71,6 +71,21 @@ enum { NoChange = 0, Changed = 1, Created = 2, Deleted = 4 }; struct Client { + Client(KDirWatch *inst, KDirWatch::WatchModes watchModes) + : instance(inst), + count(1), + watchingStopped(inst->isStopped()), + pending(NoChange), + m_watchModes(watchModes) + {} + + // The compiler needs a copy ctor for Client when Entry is inserted into m_mapEntries + // (even though the vector of clients is empty at that point, so no performance penalty there) + //Client(const Client &) = delete; + //Client &operator=(const Client &) = delete; + //Client(Client &&) = default; + //Client &operator=(Client &&) = default; + KDirWatch *instance; int count; // did the instance stop watching @@ -83,8 +98,9 @@ class Entry { public: + ~Entry(); // instances interested in events - QList m_clients; + std::vector m_clients; // nonexistent entries of this directory QList m_entries; QString path; @@ -116,14 +132,14 @@ return sub_entry; } } - return 0; + return nullptr; } bool dirty; void propagate_dirty(); - QList clientsForFileOrDir(const QString &tpath, bool *isDir) const; - QList inotifyClientsForFileOrDir(bool isDir) const; + QList clientsForFileOrDir(const QString &tpath, bool *isDir) const; + QList inotifyClientsForFileOrDir(bool isDir) const; #if HAVE_FAM FAMRequest fr; @@ -150,7 +166,7 @@ void useFreq(Entry *e, int newFreq); void addEntry(KDirWatch *instance, const QString &_path, Entry *sub_entry, bool isDir, KDirWatch::WatchModes watchModes = KDirWatch::WatchDirOnly); - bool removeEntry(KDirWatch *instance, const QString &path, Entry *sub_entry); + void removeEntry(KDirWatch *instance, const QString &path, Entry *sub_entry); void removeEntry(KDirWatch *instance, Entry *e, Entry *sub_entry); bool stopEntryScan(KDirWatch *instance, Entry *e); bool restartEntryScan(KDirWatch *instance, Entry *e, bool notify); @@ -164,7 +180,7 @@ void removeWatch(Entry *entry); Entry *entry(const QString &_path); int scanEntry(Entry *e); - void emitEvent(const Entry *e, int event, const QString &fileName = QString()); + void emitEvent(Entry *e, int event, const QString &fileName = QString()); static bool isNoisyFile(const char *filename); @@ -205,6 +221,7 @@ QSocketNotifier *mSn; bool supports_inotify; int m_inotify_fd; + QHash m_inotify_wd_to_entry; bool useINotify(Entry *e); #endif diff -Nru kcoreaddons-5.18.0/src/lib/io/kfilesystemtype.cpp kcoreaddons-5.44.0a/src/lib/io/kfilesystemtype.cpp --- kcoreaddons-5.18.0/src/lib/io/kfilesystemtype.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kfilesystemtype.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -19,7 +19,7 @@ #include "kfilesystemtype.h" #include -#include +#include "kcoreaddons_debug.h" //#include #ifndef Q_OS_WIN @@ -92,11 +92,11 @@ // Reverse-engineering without C++ code: // strace stat -f /mnt 2>&1|grep statfs|grep mnt, and look for f_type -KFileSystemType::Type determineFileSystemTypeImpl(const QByteArray &path) +static KFileSystemType::Type determineFileSystemTypeImpl(const QByteArray &path) { struct statfs buf; if (statfs(path.constData(), &buf) != 0) { - //qDebug() << path << errno << strerror(errno); + //qCDebug(KCOREADDONS_DEBUG) << path << errno << strerror(errno); return KFileSystemType::Unknown; } switch (static_cast(buf.f_type)) { diff -Nru kcoreaddons-5.18.0/src/lib/io/kfilesystemtype.h kcoreaddons-5.44.0a/src/lib/io/kfilesystemtype.h --- kcoreaddons-5.18.0/src/lib/io/kfilesystemtype.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kfilesystemtype.h 2018-03-06 08:12:31.000000000 +0000 @@ -23,15 +23,19 @@ #include #include +/** + * @namespace KFileSystemType + * Provides utility functions for the type of file systems. + */ namespace KFileSystemType { enum Type { Unknown, - Nfs, // NFS or other full-featured networked filesystems (autofs, subfs, cachefs, sshfs) - Smb, // SMB/CIFS mount (networked but with some FAT-like behavior) - Fat, // FAT or similar (msdos, fat, vfat) - Ramfs, // RAMDISK mount - Other // ext, reiser, and so on. "Normal" local filesystems. + Nfs, ///< NFS or other full-featured networked filesystems (autofs, subfs, cachefs, sshfs) + Smb, ///< SMB/CIFS mount (networked but with some FAT-like behavior) + Fat, ///< FAT or similar (msdos, fat, vfat) + Ramfs, ///< RAMDISK mount + Other ///< ext, reiser, and so on. "Normal" local filesystems. }; /** diff -Nru kcoreaddons-5.18.0/src/lib/io/kmessage.cpp kcoreaddons-5.44.0a/src/lib/io/kmessage.cpp --- kcoreaddons-5.18.0/src/lib/io/kmessage.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kmessage.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -25,7 +25,7 @@ class StaticMessageHandler { public: - StaticMessageHandler() : m_handler(0) {} + StaticMessageHandler() : m_handler(nullptr) {} ~StaticMessageHandler() { delete m_handler; diff -Nru kcoreaddons-5.18.0/src/lib/io/kmessage.h kcoreaddons-5.44.0a/src/lib/io/kmessage.h --- kcoreaddons-5.18.0/src/lib/io/kmessage.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kmessage.h 2018-03-06 08:12:31.000000000 +0000 @@ -112,7 +112,7 @@ class KCOREADDONS_EXPORT KMessageHandler { public: - virtual ~KMessageHandler() {} + virtual ~KMessageHandler() {} // KF6 TODO: de-inline (-Wweak-vtables) /** * @brief Display a long message of a certain type. * A long message span on multiple lines and can have a caption. diff -Nru kcoreaddons-5.18.0/src/lib/io/kprocess.cpp kcoreaddons-5.44.0a/src/lib/io/kprocess.cpp --- kcoreaddons-5.18.0/src/lib/io/kprocess.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kprocess.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -37,9 +37,8 @@ KProcess::KProcess(QObject *parent) : QProcess(parent), - d_ptr(new KProcessPrivate) + d_ptr(new KProcessPrivate(this)) { - d_ptr->q_ptr = this; setOutputChannelMode(ForwardedChannels); } @@ -58,12 +57,12 @@ void KProcess::setOutputChannelMode(OutputChannelMode mode) { - QProcess::setProcessChannelMode((ProcessChannelMode)mode); + QProcess::setProcessChannelMode(static_cast(mode)); } KProcess::OutputChannelMode KProcess::outputChannelMode() const { - return (OutputChannelMode)QProcess::processChannelMode(); + return static_cast(QProcess::processChannelMode()); } void KProcess::setNextOpenMode(QIODevice::OpenMode mode) @@ -201,7 +200,7 @@ #ifdef Q_OS_UNIX // #ifdef NON_FREE // ... as they ship non-POSIX /bin/sh -# if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__GNU__) +# if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__GNU__) && !defined(__APPLE__) // If /bin/sh is a symlink, we can be pretty sure that it points to a // POSIX shell - the original bourne shell is about the only non-POSIX // shell still in use and it is always installed natively as /bin/sh. @@ -298,7 +297,7 @@ if (!QProcess::startDetached(d->prog, d->args, workingDirectory(), &pid)) { return 0; } - return (int) pid; + return static_cast(pid); } // static @@ -308,7 +307,7 @@ if (!QProcess::startDetached(exe, args, QString(), &pid)) { return 0; } - return (int) pid; + return static_cast(pid); } // static @@ -322,7 +321,7 @@ int KProcess::pid() const { #ifdef Q_OS_UNIX - return (int) QProcess::pid(); + return static_cast(QProcess::pid()); #else return QProcess::pid() ? QProcess::pid()->dwProcessId : 0; #endif diff -Nru kcoreaddons-5.18.0/src/lib/io/kprocess.h kcoreaddons-5.44.0a/src/lib/io/kprocess.h --- kcoreaddons-5.18.0/src/lib/io/kprocess.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kprocess.h 2018-03-06 08:12:31.000000000 +0000 @@ -70,12 +70,12 @@ /** * Constructor */ - explicit KProcess(QObject *parent = 0); + explicit KProcess(QObject *parent = nullptr); /** * Destructor */ - virtual ~KProcess(); + ~KProcess() override; /** * Set how to handle the output channels of the child process. diff -Nru kcoreaddons-5.18.0/src/lib/io/kprocess_p.h kcoreaddons-5.44.0a/src/lib/io/kprocess_p.h --- kcoreaddons-5.18.0/src/lib/io/kprocess_p.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kprocess_p.h 2018-03-06 08:12:31.000000000 +0000 @@ -28,8 +28,9 @@ { Q_DECLARE_PUBLIC(KProcess) protected: - KProcessPrivate() : - openMode(QIODevice::ReadWrite) + KProcessPrivate(KProcess* q) : + openMode(QIODevice::ReadWrite), + q_ptr(q) { } diff -Nru kcoreaddons-5.18.0/src/lib/io/kurlmimedata.cpp kcoreaddons-5.44.0a/src/lib/io/kurlmimedata.cpp --- kcoreaddons-5.18.0/src/lib/io/kurlmimedata.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kurlmimedata.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -21,7 +21,7 @@ #include #include -static const char s_kdeUriListMime[] = "application/x-kde4-urilist"; // keep this name "kde4" for compat. +static QString kdeUriListMime() { return QStringLiteral("application/x-kde4-urilist"); } // keep this name "kde4" for compat. static QByteArray uriListData(const QList &urls) { @@ -41,7 +41,7 @@ mimeData->setUrls(mostLocalUrls); // set text/uri-list and text/plain // Export the real KIO urls as a kde-specific mimetype - mimeData->setData(QString::fromLatin1(s_kdeUriListMime), uriListData(urls)); + mimeData->setData(kdeUriListMime(), uriListData(urls)); } void KUrlMimeData::setMetaData(const MetaDataMap &metaData, QMimeData *mimeData) @@ -58,33 +58,43 @@ QStringList KUrlMimeData::mimeDataTypes() { - return QStringList() << QString::fromLatin1(s_kdeUriListMime) << QStringLiteral("text/uri-list"); + return QStringList() << kdeUriListMime() << QStringLiteral("text/uri-list"); } +static QList extractKdeUriList(const QMimeData *mimeData) +{ + QList uris; + const QByteArray ba = mimeData->data(kdeUriListMime()); + // Code from qmimedata.cpp + QList urls = ba.split('\n'); + for (int i = 0; i < urls.size(); ++i) { + QByteArray data = urls.at(i).trimmed(); + if (!data.isEmpty()) { + uris.append(QUrl::fromEncoded(data)); + } + } + return uris; +} + + QList KUrlMimeData::urlsFromMimeData(const QMimeData *mimeData, DecodeOptions decodeOptions, MetaDataMap *metaData) { QList uris; - const char *firstMimeType = s_kdeUriListMime; - const char *secondMimeType = "text/uri-list"; if (decodeOptions == PreferLocalUrls) { - qSwap(firstMimeType, secondMimeType); - } - QByteArray ba = mimeData->data(QString::fromLatin1(firstMimeType)); - if (ba.isEmpty()) { - ba = mimeData->data(QString::fromLatin1(secondMimeType)); - } - if (!ba.isEmpty()) { - // Code from qmimedata.cpp - QList urls = ba.split('\n'); - for (int i = 0; i < urls.size(); ++i) { - QByteArray data = urls.at(i).trimmed(); - if (!data.isEmpty()) { - uris.append(QUrl::fromEncoded(data)); - } + // Extracting uris from text/uri-list, use the much faster QMimeData method urls() + uris = mimeData->urls(); + if (uris.isEmpty()) { + uris = extractKdeUriList(mimeData); + } + } else { + uris = extractKdeUriList(mimeData); + if (uris.isEmpty()) { + uris = mimeData->urls(); } } + if (metaData) { const QByteArray metaDataPayload = mimeData->data(QStringLiteral("application/x-kio-metadata")); if (!metaDataPayload.isEmpty()) { diff -Nru kcoreaddons-5.18.0/src/lib/io/kurlmimedata.h kcoreaddons-5.44.0a/src/lib/io/kurlmimedata.h --- kcoreaddons-5.18.0/src/lib/io/kurlmimedata.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/io/kurlmimedata.h 2018-03-06 08:12:31.000000000 +0000 @@ -99,7 +99,7 @@ */ KCOREADDONS_EXPORT QList urlsFromMimeData(const QMimeData *mimeData, DecodeOptions decodeOptions = PreferKdeUrls, - MetaDataMap *metaData = 0); + MetaDataMap *metaData = nullptr); } diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kcompositejob.cpp kcoreaddons-5.44.0a/src/lib/jobs/kcompositejob.cpp --- kcoreaddons-5.18.0/src/lib/jobs/kcompositejob.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kcompositejob.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -45,18 +45,16 @@ bool KCompositeJob::addSubjob(KJob *job) { Q_D(KCompositeJob); - if (job == 0 || d->subjobs.contains(job)) { + if (job == nullptr || d->subjobs.contains(job)) { return false; } job->setParent(this); d->subjobs.append(job); - connect(job, SIGNAL(result(KJob*)), - SLOT(slotResult(KJob*))); + connect(job, &KJob::result, this, &KCompositeJob::slotResult); // Forward information from that subjob. - connect(job, SIGNAL(infoMessage(KJob*,QString,QString)), - SLOT(slotInfoMessage(KJob*,QString,QString))); + connect(job, &KJob::infoMessage, this, &KCompositeJob::slotInfoMessage); return true; } @@ -64,14 +62,14 @@ bool KCompositeJob::removeSubjob(KJob *job) { Q_D(KCompositeJob); - if (job == 0) { - return false; + // remove only Subjobs that are on the list + if (d->subjobs.removeAll(job) > 0) { + job->setParent(nullptr); + disconnect(job, &KJob::result, this, &KCompositeJob::slotResult); + disconnect(job, &KJob::infoMessage, this, &KCompositeJob::slotInfoMessage); + return true; } - - job->setParent(0); - d->subjobs.removeAll(job); - - return true; + return false; } bool KCompositeJob::hasSubjobs() const @@ -88,7 +86,9 @@ { Q_D(KCompositeJob); Q_FOREACH (KJob *job, d->subjobs) { - job->setParent(0); + job->setParent(nullptr); + disconnect(job, &KJob::result, this, &KCompositeJob::slotResult); + disconnect(job, &KJob::infoMessage, this, &KCompositeJob::slotInfoMessage); } d->subjobs.clear(); } @@ -100,9 +100,11 @@ // Store it in the parent only if first error setError(job->error()); setErrorText(job->errorText()); + // Finish this job emitResult(); } - + // After a subjob is done, we might want to start another one. + // Therefore do not emitResult removeSubjob(job); } diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kcompositejob.h kcoreaddons-5.44.0a/src/lib/jobs/kcompositejob.h --- kcoreaddons-5.18.0/src/lib/jobs/kcompositejob.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kcompositejob.h 2018-03-06 08:12:31.000000000 +0000 @@ -27,6 +27,8 @@ class KCompositeJobPrivate; /** + * @class KCompositeJob kcompositejob.h KCompositeJob + * * The base class for all jobs able to be composed of one * or more subjobs. */ @@ -40,12 +42,12 @@ * * @param parent the parent QObject */ - explicit KCompositeJob(QObject *parent = 0); + explicit KCompositeJob(QObject *parent = nullptr); /** * Destroys a KCompositeJob object. */ - virtual ~KCompositeJob(); + ~KCompositeJob() override; protected: /** diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kjob.cpp kcoreaddons-5.44.0a/src/lib/jobs/kjob.cpp --- kcoreaddons-5.18.0/src/lib/jobs/kjob.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kjob.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -30,9 +30,9 @@ #include KJobPrivate::KJobPrivate() - : q_ptr(0), uiDelegate(0), error(KJob::NoError), + : q_ptr(nullptr), uiDelegate(nullptr), error(KJob::NoError), progressUnit(KJob::Bytes), percentage(0), - speedTimer(0), eventLoop(0), + speedTimer(nullptr), eventLoop(nullptr), capabilities(KJob::NoCapabilities), suspended(false), isAutoDelete(true), isFinished(false) { @@ -68,7 +68,7 @@ void KJob::setUiDelegate(KJobUiDelegate *delegate) { Q_D(KJob); - if (delegate == 0 || delegate->setJob(this)) { + if (delegate == nullptr || delegate->setJob(this)) { delete d->uiDelegate; d->uiDelegate = delegate; @@ -116,7 +116,6 @@ bool KJob::kill(KillVerbosity verbosity) { - Q_D(KJob); if (doKill()) { setError(KilledJobError); @@ -198,7 +197,7 @@ if (!d->isFinished) { d->eventLoop->exec(QEventLoop::ExcludeUserInputEvents); } - d->eventLoop = 0; + d->eventLoop = nullptr; if (wasAutoDelete) { deleteLater(); @@ -291,7 +290,6 @@ void KJob::emitResult() { - Q_D(KJob); finishJob(true); } @@ -301,7 +299,7 @@ // calculate percents if (totalAmount) { unsigned long oldPercentage = d->percentage; - d->percentage = (unsigned long)(((float)(processedAmount) / (float)(totalAmount)) * 100.0); + d->percentage = 100.0 * processedAmount / totalAmount; if (d->percentage != oldPercentage) { emit percent(this, d->percentage); } diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kjob.h kcoreaddons-5.44.0a/src/lib/jobs/kjob.h --- kcoreaddons-5.18.0/src/lib/jobs/kjob.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kjob.h 2018-03-06 08:12:31.000000000 +0000 @@ -30,6 +30,8 @@ class KJobPrivate; /** + * @class KJob kjob.h KJob + * * The base class for all jobs. * For all jobs created in an application, the code looks like * @@ -84,8 +86,6 @@ class KCOREADDONS_EXPORT KJob : public QObject { Q_OBJECT - Q_ENUMS(KillVerbosity Capability Unit) - Q_FLAGS(Capabilities) Q_PROPERTY(int error READ error NOTIFY result) Q_PROPERTY(QString errorText READ errorText NOTIFY result) Q_PROPERTY(QString errorString READ errorString NOTIFY result) @@ -94,25 +94,28 @@ public: enum Unit { Bytes, Files, Directories }; + Q_ENUM(Unit) enum Capability { NoCapabilities = 0x0000, Killable = 0x0001, Suspendable = 0x0002 }; + Q_ENUM(Capability) Q_DECLARE_FLAGS(Capabilities, Capability) + Q_FLAG(Capabilities) /** * Creates a new KJob object. * * @param parent the parent QObject */ - explicit KJob(QObject *parent = 0); + explicit KJob(QObject *parent = nullptr); /** * Destroys a KJob object. */ - virtual ~KJob(); + ~KJob() override; /** * Attach a UI delegate to this job. @@ -172,6 +175,7 @@ Q_SCRIPTABLE virtual void start() = 0; enum KillVerbosity { Quietly, EmitResult }; + Q_ENUM(KillVerbosity) public Q_SLOTS: /** diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kjobtrackerinterface.cpp kcoreaddons-5.44.0a/src/lib/jobs/kjobtrackerinterface.cpp --- kcoreaddons-5.18.0/src/lib/jobs/kjobtrackerinterface.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kjobtrackerinterface.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -21,7 +21,7 @@ #include "kjob.h" -class KJobTrackerInterface::Private +class Q_DECL_HIDDEN KJobTrackerInterface::Private { public: Private(KJobTrackerInterface *interface) : q(interface) @@ -35,7 +35,7 @@ KJobTrackerInterface::KJobTrackerInterface(QObject *parent) : QObject(parent), d(new Private(this)) { - + qRegisterMetaType>(); } KJobTrackerInterface::~KJobTrackerInterface() diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kjobtrackerinterface.h kcoreaddons-5.44.0a/src/lib/jobs/kjobtrackerinterface.h --- kcoreaddons-5.18.0/src/lib/jobs/kjobtrackerinterface.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kjobtrackerinterface.h 2018-03-06 08:12:31.000000000 +0000 @@ -27,6 +27,8 @@ #include /** + * @class KJobTrackerInterface kjobtrackerinterface.h KJobTrackerInterface + * * The interface to implement to track the progresses of a job. */ class KCOREADDONS_EXPORT KJobTrackerInterface : public QObject @@ -39,25 +41,49 @@ * * @param parent the parent object */ - KJobTrackerInterface(QObject *parent = 0); + KJobTrackerInterface(QObject *parent = nullptr); /** * Destroys a KJobTrackerInterface */ - virtual ~KJobTrackerInterface(); + ~KJobTrackerInterface() override; public Q_SLOTS: /** * Register a new job in this tracker. + * The default implementation connects the following KJob signals + * to the respective protected slots of this class: + * - finished() (also connected to the unregisterJob() slot) + * - suspended() + * - resumed() + * - description() + * - infoMessage() + * - totalAmount() + * - processedAmount() + * - percent() + * - speed() + * + * If you re-implement this method, you may want to call the default + * implementation or add at least: + * + * @code + * connect(job, &KJob::finished, this, &MyJobTracker::unregisterJob); + * @endcode + * + * so that you won't have to manually call unregisterJob(). * * @param job the job to register + * @see unregisterJob() */ virtual void registerJob(KJob *job); /** * Unregister a job from this tracker. + * @note You need to manually call this method only if you re-implemented + * registerJob() without connecting KJob::finished to this slot. * * @param job the job to unregister + * @see registerJob() */ virtual void unregisterJob(KJob *job); diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kjobuidelegate.cpp kcoreaddons-5.44.0a/src/lib/jobs/kjobuidelegate.cpp --- kcoreaddons-5.18.0/src/lib/jobs/kjobuidelegate.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kjobuidelegate.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -22,11 +22,11 @@ #include "kjobuidelegate.h" #include "kjob.h" -class KJobUiDelegate::Private +class Q_DECL_HIDDEN KJobUiDelegate::Private { public: Private(KJobUiDelegate *delegate) - : q(delegate), job(0), + : q(delegate), job(nullptr), autoErrorHandling(false), autoWarningHandling(true) { } @@ -53,7 +53,7 @@ bool KJobUiDelegate::setJob(KJob *job) { - if (d->job != 0) { + if (d->job != nullptr) { return false; } @@ -105,8 +105,7 @@ connect(job, SIGNAL(result(KJob*)), this, SLOT(_k_result(KJob*))); - connect(job, SIGNAL(warning(KJob*,QString,QString)), - this, SLOT(slotWarning(KJob*,QString,QString))); + connect(job, &KJob::warning, this, &KJobUiDelegate::slotWarning); } void KJobUiDelegate::Private::_k_result(KJob *job2) diff -Nru kcoreaddons-5.18.0/src/lib/jobs/kjobuidelegate.h kcoreaddons-5.44.0a/src/lib/jobs/kjobuidelegate.h --- kcoreaddons-5.18.0/src/lib/jobs/kjobuidelegate.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/jobs/kjobuidelegate.h 2018-03-06 08:12:31.000000000 +0000 @@ -28,6 +28,8 @@ class KJob; /** + * @class KJobUiDelegate kjobuidelegate.h KJobUiDelegate + * * The base class for all KJob UI delegate. * * A UI delegate is responsible for the events of a @@ -49,7 +51,7 @@ /** * Destroys a KJobUiDelegate. */ - virtual ~KJobUiDelegate(); + ~KJobUiDelegate() override; protected: /** diff -Nru kcoreaddons-5.18.0/src/lib/kaboutdata.cpp kcoreaddons-5.44.0a/src/lib/kaboutdata.cpp --- kcoreaddons-5.18.0/src/lib/kaboutdata.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/kaboutdata.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -4,6 +4,7 @@ * Copyright (C) 2006 Nicolas GOUTTE * Copyright (C) 2008 Friedrich W. H. Kossebau * Copyright (C) 2010 Teo Mrnjavac + * Copyright (C) 2017 Harald Sitter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -37,10 +38,17 @@ #include #include #include +#include #include -class KAboutPerson::Private + +Q_DECLARE_LOGGING_CATEGORY(KABOUTDATA) +// logging category for this framework, default: log stuff >= warning +Q_LOGGING_CATEGORY(KABOUTDATA, "kf5.kcoreaddons.kaboutdata", QtWarningMsg) + + +class Q_DECL_HIDDEN KAboutPerson::Private { public: QString _name; @@ -123,29 +131,30 @@ } -class KAboutLicense::Private : public QSharedData +class Q_DECL_HIDDEN KAboutLicense::Private : public QSharedData { public: - Private(LicenseKey licenseType, const KAboutData *aboutData); - Private(const KAboutData *aboutData); + Private(LicenseKey licenseType, + VersionRestriction versionRestriction, + const KAboutData *aboutData); Private(const Private &other); -public: - LicenseKey _licenseKey; - QString _licenseText; - QString _pathToLicenseTextFile; + + QString spdxID() const; + + LicenseKey _licenseKey; + QString _licenseText; + QString _pathToLicenseTextFile; + VersionRestriction _versionRestriction; // needed for access to the possibly changing copyrightStatement() const KAboutData *_aboutData; }; -KAboutLicense::Private::Private(LicenseKey licenseType, const KAboutData *aboutData) +KAboutLicense::Private::Private(LicenseKey licenseType, + VersionRestriction versionRestriction, + const KAboutData *aboutData) : QSharedData(), _licenseKey(licenseType), - _aboutData(aboutData) -{ -} - -KAboutLicense::Private::Private(const KAboutData *aboutData) - : QSharedData(), + _versionRestriction(versionRestriction), _aboutData(aboutData) { } @@ -155,16 +164,52 @@ _licenseKey(other._licenseKey), _licenseText(other._licenseText), _pathToLicenseTextFile(other._pathToLicenseTextFile), + _versionRestriction(other._versionRestriction), _aboutData(other._aboutData) {} +QString KAboutLicense::Private::spdxID() const +{ + switch (_licenseKey) { + case KAboutLicense::GPL_V2: + return QStringLiteral("GPL-2.0"); + case KAboutLicense::LGPL_V2: + return QStringLiteral("LGPL-2.0"); + case KAboutLicense::BSDL: + return QStringLiteral("BSD-2-Clause"); + case KAboutLicense::Artistic: + return QStringLiteral("Artistic-1.0"); + case KAboutLicense::QPL_V1_0: + return QStringLiteral("QPL-1.0"); + case KAboutLicense::GPL_V3: + return QStringLiteral("GPL-3.0"); + case KAboutLicense::LGPL_V3: + return QStringLiteral("LGPL-3.0"); + case KAboutLicense::LGPL_V2_1: + return QStringLiteral("LGPL-2.1"); + case KAboutLicense::Custom: + case KAboutLicense::File: + case KAboutLicense::Unknown: + return QString(); + } + return QString(); +} + +KAboutLicense::KAboutLicense(LicenseKey licenseType, + VersionRestriction versionRestriction, + const KAboutData *aboutData) + : d(new Private(licenseType, versionRestriction, aboutData)) +{ + +} + KAboutLicense::KAboutLicense(LicenseKey licenseType, const KAboutData *aboutData) - : d(new Private(licenseType, aboutData)) + : d(new Private(licenseType, OnlyThisVersion, aboutData)) { } KAboutLicense::KAboutLicense(const KAboutData *aboutData) - : d(new Private(aboutData)) + : d(new Private(Unknown, OnlyThisVersion, aboutData)) { } @@ -199,38 +244,42 @@ } bool knownLicense = false; - QString pathToFile; + QString pathToFile; // rel path if known license switch (d->_licenseKey) { case KAboutLicense::File: pathToFile = d->_pathToLicenseTextFile; break; case KAboutLicense::GPL_V2: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/GPL_V2")); + pathToFile = QStringLiteral("GPL_V2"); break; case KAboutLicense::LGPL_V2: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/LGPL_V2")); + pathToFile = QStringLiteral("LGPL_V2"); break; case KAboutLicense::BSDL: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/BSD")); + pathToFile = QStringLiteral("BSD"); break; case KAboutLicense::Artistic: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/ARTISTIC")); + pathToFile = QStringLiteral("ARTISTIC"); break; case KAboutLicense::QPL_V1_0: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/QPL_V1.0")); + pathToFile = QStringLiteral("QPL_V1.0"); break; case KAboutLicense::GPL_V3: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/GPL_V3")); + pathToFile = QStringLiteral("GPL_V3"); break; case KAboutLicense::LGPL_V3: knownLicense = true; - pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("LICENSES/LGPL_V3")); + pathToFile = QStringLiteral("LGPL_V3"); + break; + case KAboutLicense::LGPL_V2_1: + knownLicense = true; + pathToFile = QStringLiteral("LGPL_V21"); break; case KAboutLicense::Custom: if (!d->_licenseText.isEmpty()) { @@ -247,6 +296,8 @@ } if (knownLicense) { + pathToFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QString::fromLatin1("kf5/licenses/") + pathToFile); result += QCoreApplication::translate( "KAboutLicense", "This program is distributed under the terms of the %1.").arg(name(KAboutLicense::ShortName)); @@ -266,6 +317,26 @@ return result; } +QString KAboutLicense::spdx() const +{ + // SPDX licenses are comprised of an identifier (e.g. GPL-2.0), an optional + to denote 'or + // later versions' and optional ' WITH $exception' to denote standardized exceptions from the + // core license. As we do not offer exceptions we effectively only return GPL-2.0 or GPL-2.0+, + // this may change in the future. To that end the documentation makes no assertations about the + // actual content of the SPDX license expression we return. + // Expressions can in theory also contain AND, OR and () to build constructs involving more than + // one license. As this is outside the scope of a single license object we'll ignore this here + // for now. + // The expecation is that the return value is only run through spec-compliant parsers, so this + // can potentially be changed. + + auto id = d->spdxID(); + if (id.isNull()) { // Guard against potential future changes which would allow 'Foo+' as input. + return id; + } + return d->_versionRestriction == OrLaterVersions ? id.append(QLatin1Char('+')) : id; +} + QString KAboutLicense::name(KAboutLicense::NameFormat formatName) const { QString licenseShort; @@ -300,6 +371,10 @@ licenseShort = QCoreApplication::translate("KAboutLicense", "LGPL v3", "@item license (short name)"); licenseFull = QCoreApplication::translate("KAboutLicense", "GNU Lesser General Public License Version 3", "@item license"); break; + case KAboutLicense::LGPL_V2_1: + licenseShort = QCoreApplication::translate("KAboutLicense", "LGPL v2.1", "@item license (short name)"); + licenseFull = QCoreApplication::translate("KAboutLicense", "GNU Lesser General Public License Version 2.1", "@item license"); + break; case KAboutLicense::Custom: case KAboutLicense::File: licenseShort = licenseFull = QCoreApplication::translate("KAboutLicense", "Custom", "@item license"); @@ -331,37 +406,53 @@ { // Setup keyword->enum dictionary on first call. // Use normalized keywords, by the algorithm below. - static QHash ldict; - if (ldict.isEmpty()) { - ldict.insert("gpl", KAboutLicense::GPL); - ldict.insert("gplv2", KAboutLicense::GPL_V2); - ldict.insert("gplv2+", KAboutLicense::GPL_V2); - ldict.insert("lgpl", KAboutLicense::LGPL); - ldict.insert("lgplv2", KAboutLicense::LGPL_V2); - ldict.insert("lgplv2+", KAboutLicense::LGPL_V2); - ldict.insert("bsd", KAboutLicense::BSDL); - ldict.insert("artistic", KAboutLicense::Artistic); - ldict.insert("qpl", KAboutLicense::QPL); - ldict.insert("qplv1", KAboutLicense::QPL_V1_0); - ldict.insert("qplv10", KAboutLicense::QPL_V1_0); - ldict.insert("gplv3", KAboutLicense::GPL_V3); - ldict.insert("gplv3+", KAboutLicense::GPL_V3); - ldict.insert("lgplv3", KAboutLicense::LGPL_V3); - ldict.insert("lgplv3+", KAboutLicense::LGPL_V3); - } + static const QHash licenseDict { + { "gpl", KAboutLicense::GPL }, + { "gplv2", KAboutLicense::GPL_V2 }, + { "gplv2+", KAboutLicense::GPL_V2 }, + { "gpl20", KAboutLicense::GPL_V2 }, + { "gpl20+", KAboutLicense::GPL_V2 }, + { "lgpl", KAboutLicense::LGPL }, + { "lgplv2", KAboutLicense::LGPL_V2 }, + { "lgplv2+", KAboutLicense::LGPL_V2 }, + { "lgpl20", KAboutLicense::LGPL_V2 }, + { "lgpl20+", KAboutLicense::LGPL_V2 }, + { "bsd", KAboutLicense::BSDL }, + { "bsd2clause", KAboutLicense::BSDL }, + { "artistic", KAboutLicense::Artistic }, + { "artistic10", KAboutLicense::Artistic }, + { "qpl", KAboutLicense::QPL }, + { "qplv1", KAboutLicense::QPL_V1_0 }, + { "qplv10", KAboutLicense::QPL_V1_0 }, + { "qpl10", KAboutLicense::QPL_V1_0 }, + { "gplv3", KAboutLicense::GPL_V3 }, + { "gplv3+", KAboutLicense::GPL_V3 }, + { "gpl30", KAboutLicense::GPL_V3 }, + { "gpl30+", KAboutLicense::GPL_V3 }, + { "lgplv3", KAboutLicense::LGPL_V3 }, + { "lgplv3+", KAboutLicense::LGPL_V3 }, + { "lgpl30", KAboutLicense::LGPL_V3 }, + { "lgpl30+", KAboutLicense::LGPL_V3 }, + { "lgplv21", KAboutLicense::LGPL_V2_1 }, + { "lgplv21+", KAboutLicense::LGPL_V2_1 }, + { "lgpl21", KAboutLicense::LGPL_V2_1 }, + { "lgpl21+", KAboutLicense::LGPL_V2_1 }, + }; // Normalize keyword. QString keyword = rawKeyword; keyword = keyword.toLower(); keyword.remove(QLatin1Char(' ')); keyword.remove(QLatin1Char('.')); + keyword.remove(QLatin1Char('-')); - LicenseKey license = ldict.value(keyword.toLatin1(), - KAboutLicense::Custom); - return KAboutLicense(license, 0); + LicenseKey license = licenseDict.value(keyword.toLatin1(), + KAboutLicense::Custom); + auto restriction = keyword.endsWith(QLatin1Char('+')) ? OrLaterVersions : OnlyThisVersion; + return KAboutLicense(license, restriction, nullptr); } -class KAboutData::Private +class Q_DECL_HIDDEN KAboutData::Private { public: Private() @@ -391,7 +482,7 @@ // can just give it a pointer, w/o any allocations. QByteArray _internalProgramName; QByteArray _version; - QByteArray _bugEmailAddress; + QByteArray _bugAddress; static QList parseTranslators(const QString &translatorName, const QString &translatorEmail); @@ -405,7 +496,7 @@ const QString &_copyrightStatement, const QString &text, const QString &homePageAddress, - const QString &bugsEmailAddress + const QString &bugAddress ) : d(new Private) { @@ -425,7 +516,7 @@ d->_copyrightStatement = _copyrightStatement; d->_otherText = text; d->_homepageAddress = homePageAddress; - d->_bugEmailAddress = bugsEmailAddress.toUtf8(); + d->_bugAddress = bugAddress.toUtf8(); QUrl homePageUrl(homePageAddress); if (!homePageUrl.isValid() || homePageUrl.scheme().isEmpty()) { @@ -443,6 +534,9 @@ d->organizationDomain = hostComponents.join(dotChar); + // KF6: do not set a default desktopFileName value here, but remove this code and leave it empty + // see KAboutData::desktopFileName() for detals + // desktop file name is reverse domain name std::reverse(hostComponents.begin(), hostComponents.end()); hostComponents.append(_componentName); @@ -470,8 +564,10 @@ // match behaviour of other constructors d->_licenseList.append(KAboutLicense(KAboutLicense::Unknown, this)); - d->_bugEmailAddress = "submit@bugs.kde.org"; + d->_bugAddress = "submit@bugs.kde.org"; d->organizationDomain = QStringLiteral("kde.org"); + // KF6: do not set a default desktopFileName value here, but remove this code and leave it empty + // see KAboutData::desktopFileName() for detals d->desktopFileName = QStringLiteral("org.kde.%1").arg(d->_componentName); } @@ -510,7 +606,7 @@ KAboutData ret(plugin.pluginId(), plugin.name(), plugin.version(), plugin.description(), KAboutLicense::byKeyword(plugin.license()).key(), plugin.copyrightText(), plugin.extraInformation(), plugin.website()); - ret.setProgramIconName(plugin.iconName()); + ret.d->programIconName = plugin.iconName(); ret.d->_authorList = plugin.authors(); ret.d->_translatorList = plugin.translators(); ret.d->_creditList = plugin.otherContributors(); @@ -621,18 +717,30 @@ KAboutData &KAboutData::setLicense(KAboutLicense::LicenseKey licenseKey) { - d->_licenseList[0] = KAboutLicense(licenseKey, this); + return setLicense(licenseKey, KAboutLicense::OnlyThisVersion); +} + +KAboutData &KAboutData::setLicense(KAboutLicense::LicenseKey licenseKey, + KAboutLicense::VersionRestriction versionRestriction) +{ + d->_licenseList[0] = KAboutLicense(licenseKey, versionRestriction, this); return *this; } KAboutData &KAboutData::addLicense(KAboutLicense::LicenseKey licenseKey) { + return addLicense(licenseKey, KAboutLicense::OnlyThisVersion); +} + +KAboutData &KAboutData::addLicense(KAboutLicense::LicenseKey licenseKey, + KAboutLicense::VersionRestriction versionRestriction) +{ // if the default license is unknown, overwrite instead of append KAboutLicense &firstLicense = d->_licenseList[0]; if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == KAboutLicense::Unknown) { - firstLicense = KAboutLicense(licenseKey, this); + firstLicense = KAboutLicense(licenseKey, versionRestriction, this); } else { - d->_licenseList.append(KAboutLicense(licenseKey, this)); + d->_licenseList.append(KAboutLicense(licenseKey, versionRestriction, this)); } return *this; } @@ -657,7 +765,7 @@ KAboutData &KAboutData::setBugAddress(const QByteArray &_bugAddress) { - d->_bugEmailAddress = _bugAddress; + d->_bugAddress = _bugAddress; return *this; } @@ -754,7 +862,7 @@ QString KAboutData::bugAddress() const { - return QString::fromUtf8(d->_bugEmailAddress.constData()); + return QString::fromUtf8(d->_bugAddress.constData()); } QString KAboutData::organizationDomain() const @@ -767,10 +875,10 @@ /// for the bug mail address. Used in particular for KCrash. const char *KAboutData::internalBugAddress() const { - if (d->_bugEmailAddress.isEmpty()) { - return 0; + if (d->_bugAddress.isEmpty()) { + return nullptr; } - return d->_bugEmailAddress.constData(); + return d->_bugAddress.constData(); } QList KAboutData::authors() const @@ -826,7 +934,7 @@ "

KDE is translated into many languages thanks to the work " "of the translation teams all over the world.

" "

For more information on KDE internationalization " - "visit http://l10n.kde.org

", + "visit https://l10n.kde.org

", "replace this with information about your translation team" ); } @@ -892,12 +1000,29 @@ QString KAboutData::desktopFileName() const { return d->desktopFileName; + // KF6: switch to this code and adapt API dox +#if 0 + // if desktopFileName has been explicitely set, use that value + if (!d->desktopFileName.isEmpty()) { + return d->desktopFileName; + } + + // return a string calculated on-the-fly from the current org domain & component name + const QChar dotChar(QLatin1Char('.')); + QStringList hostComponents = d->organizationDomain.split(dotChar); + + // desktop file name is reverse domain name + std::reverse(hostComponents.begin(), hostComponents.end()); + hostComponents.append(componentName()); + + return hostComponents.join(dotChar); +#endif } class KAboutDataRegistry { public: - KAboutDataRegistry() : m_appData(0) {} + KAboutDataRegistry() : m_appData(nullptr) {} ~KAboutDataRegistry() { delete m_appData; @@ -909,18 +1034,62 @@ Q_GLOBAL_STATIC(KAboutDataRegistry, s_registry) +namespace { + +void warnIfOutOfSync(const char *aboutDataString, const QString &aboutDataValue, + const char *appDataString, const QString &appDataValue) +{ + if (aboutDataValue != appDataValue) { + qCWarning(KABOUTDATA) << appDataString <m_appData) { - s_registry->m_appData = new KAboutData(QCoreApplication::applicationName(), - QString(), - QString()); - } - if (s_registry->m_appData->displayName().isEmpty() && QCoreApplication::instance()) { - // ## add a bool to avoid doing this too often? - s_registry->m_appData->setDisplayName(QCoreApplication::instance()->property("applicationDisplayName").toString()); + QCoreApplication *app = QCoreApplication::instance(); + + KAboutData *aboutData = s_registry->m_appData; + + // not yet existing + if (!aboutData) { + // init from current Q*Application data + aboutData = new KAboutData(QCoreApplication::applicationName(), + QString(), + QString()); + // For applicationDisplayName & desktopFileName, which are only properties of QGuiApplication, + // we have to try to get them via the property system, as the static getter methods are + // part of QtGui only. Disadvantage: requires an app instance. + // Either get all or none of the properties & warn about it + if (app) { + aboutData->setOrganizationDomain(QCoreApplication::organizationDomain().toUtf8()); + aboutData->setVersion(QCoreApplication::applicationVersion().toUtf8()); + aboutData->setDisplayName(app->property("applicationDisplayName").toString()); + aboutData->setDesktopFileName(app->property("desktopFileName").toString()); + } else { + qCWarning(KABOUTDATA) << "Could not initialize the properties of KAboutData::applicationData by the equivalent properties from Q*Application: no app instance (yet) existing."; + } + + s_registry->m_appData = aboutData; + } else { + // check if in-sync with Q*Application metadata, as their setters could have been called + // after the last KAboutData::setApplicationData, with different values + warnIfOutOfSync("KAboutData::applicationData().componentName", aboutData->componentName(), + "QCoreApplication::applicationName", QCoreApplication::applicationName()); + warnIfOutOfSync("KAboutData::applicationData().version", aboutData->version(), + "QCoreApplication::applicationVersion", QCoreApplication::applicationVersion()); + warnIfOutOfSync("KAboutData::applicationData().organizationDomain", aboutData->organizationDomain(), + "QCoreApplication::organizationDomain", QCoreApplication::organizationDomain()); + if (app) { + warnIfOutOfSync("KAboutData::applicationData().displayName", aboutData->displayName(), + "QGuiApplication::applicationDisplayName", app->property("applicationDisplayName").toString()); + warnIfOutOfSync("KAboutData::applicationData().desktopFileName", aboutData->desktopFileName(), + "QGuiApplication::desktopFileName", app->property("desktopFileName").toString()); + } } - return *s_registry->m_appData; + + return *aboutData; } void KAboutData::setApplicationData(const KAboutData &aboutData) @@ -931,6 +1100,10 @@ s_registry->m_appData = new KAboutData(aboutData); } + // For applicationDisplayName & desktopFileName, which are only properties of QGuiApplication, + // we have to try to set them via the property system, as the static getter methods are + // part of QtGui only. Disadvantage: requires an app instance. + // So set either all or none of the properties & warn about it QCoreApplication *app = QCoreApplication::instance(); if (app) { app->setApplicationVersion(aboutData.version()); @@ -938,7 +1111,16 @@ app->setOrganizationDomain(aboutData.organizationDomain()); app->setProperty("applicationDisplayName", aboutData.displayName()); app->setProperty("desktopFileName", aboutData.desktopFileName()); + } else { + qCWarning(KABOUTDATA) << "Could not initialize the equivalent properties of Q*Application: no instance (yet) existing."; } + // KF6: Rethink the current relation between KAboutData::applicationData and the Q*Application metadata + // Always overwriting the Q*Application metadata here, but not updating back the KAboutData + // in applicationData() is unbalanced and can result in out-of-sync data if the Q*Application + // setters have been called meanwhile + // Options are to remove the overlapping properties of KAboutData for cleancode, or making the + // overlapping properties official shadow properties of their Q*Application countparts, though + // that increases behavioural complexity a little. } void KAboutData::registerPluginData(const KAboutData &aboutData) @@ -958,7 +1140,7 @@ if (s_registry.exists()) { return s_registry->m_appData; } - return 0; + return nullptr; } bool KAboutData::setupCommandLine(QCommandLineParser *parser) @@ -989,20 +1171,20 @@ if (d->_authorList.isEmpty()) { printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "This application was written by somebody who wants to remain anonymous."))); } else { - printf(qPrintable(QCoreApplication::translate("KAboutData CLI", "%s was written by:\n")), qPrintable(qAppName())); + printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "%1 was written by:").arg(qAppName()))); Q_FOREACH (const KAboutPerson &person, d->_authorList) { QString authorData = QStringLiteral(" ") + person.name(); if (!person.emailAddress().isEmpty()) { authorData.append(QStringLiteral(" <") + person.emailAddress() + QStringLiteral(">")); } - printf("%s\n", qPrintable(authorData));; + printf("%s\n", qPrintable(authorData)); } } if (!customAuthorTextEnabled()) { if (bugAddress() == QLatin1String("submit@bugs.kde.org") ) { - printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please use http://bugs.kde.org to report bugs."))); + printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please use https://bugs.kde.org to report bugs."))); } else if (!bugAddress().isEmpty()) { - printf(qPrintable(QCoreApplication::translate("KAboutData CLI", "Please report bugs to %s.\n")), qPrintable(bugAddress())); + printf("%s\n", qPrintable(QCoreApplication::translate("KAboutData CLI", "Please report bugs to %1.").arg(bugAddress()))); } } else { printf("%s\n", qPrintable(customAuthorPlainText())); diff -Nru kcoreaddons-5.18.0/src/lib/kaboutdata.h kcoreaddons-5.44.0a/src/lib/kaboutdata.h --- kcoreaddons-5.18.0/src/lib/kaboutdata.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/kaboutdata.h 2018-03-06 08:12:31.000000000 +0000 @@ -4,6 +4,7 @@ * Copyright (C) 2008 Friedrich W. H. Kossebau * Copyright (C) 2010 Teo Mrnjavac * Copyright (C) 2013 David Faure + * Copyright (C) 2017 Harald Sitter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -193,7 +194,8 @@ QPL = 5, QPL_V1_0 = 5, GPL_V3 = 6, - LGPL_V3 = 7 + LGPL_V3 = 7, + LGPL_V2_1 = 8 ///< @since 5.25 }; /** @@ -205,6 +207,14 @@ }; /** + * Whether later versions of the license are allowed. + */ + enum VersionRestriction { + OnlyThisVersion, + OrLaterVersions + }; + + /** * Copy constructor. Performs a deep copy. * @param other object to copy */ @@ -242,7 +252,24 @@ KAboutLicense::LicenseKey key() const; /** - * Fetch a known license by a keyword. + * Returns the SPDX license expression of this license. + * If the underlying license cannot be expressed as a SPDX expression a null string is returned. + * + * @note SPDX expression are expansive constructs. If you parse the return value, do it in a + * SPDX specification compliant manner by splitting on whitespaces to discard unwanted + * informationor or by using a complete SPDX license expression parser. + * @note SPDX identifiers are case-insensitive. Do not use case-senstivie checks on the return + * value. + * @see https://spdx.org/licenses + * @return SPDX license expression or QString() if the license has no identifier. Compliant + * with SPDX 2.1. + * + * @since 5.37 + */ + QString spdx() const; + + /** + * Fetch a known license by a keyword/spdx ID * * Frequently the license data is provided by a terse keyword-like string, * e.g. by a field in a .desktop file. Using this method, an application @@ -268,6 +295,12 @@ /** * @internal Used by KAboutData to construct a predefined license. */ + explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType, + enum KAboutLicense::VersionRestriction versionRestriction, + const KAboutData *aboutData); + /** + * @internal Used by KAboutData to construct a predefined license. + */ explicit KAboutLicense(enum KAboutLicense::LicenseKey licenseType, const KAboutData *aboutData); /** * @internal Used by KAboutData to construct a KAboutLicense @@ -287,8 +320,10 @@ }; /** + * @class KAboutData kaboutdata.h KAboutData + * * This class is used to store information about a program or plugin. - * It can store such values as version number, program name, home page, email address + * It can store such values as version number, program name, home page, address * for bug reporting, multiple authors and contributors * (using KAboutPerson), license and copyright information. * @@ -303,6 +338,43 @@ * applies to the old setCatalogName() and catalogName() members. But see also * K4AboutData in kde4support as a compatibility class. * + * Example: + * Setting the metadata of an application using KAboutData in code also relying + * on the KDE Framework modules KI18n and KDBusAddons: + * @code + * // create QApplication instance + * QApplication app(argc, argv); + * // setup translation string domain for the i18n calls + * KLocalizedString::setApplicationDomain("foo"); + * // create a KAboutData object to use for setting the application metadata + * KAboutData aboutData("foo", i18n("Foo"), "0.1", + * i18n("To Foo or not To Foo"), + * KAboutLicense::LGPL, + * i18n("Copyright 2017 Bar Foundation"), QString(), + * "https://www.foo-the-app.net"); + * // overwrite default-generated values of organizationDomain & desktopFileName + * aboutData.setOrganizationDomain("barfoundation.org"); + * aboutData.setDesktopFileName("org.barfoundation.foo"); + * + * // set the application metadata + * KAboutData::setApplicationData(aboutData); + * // in GUI apps set the window icon manually, not covered by KAboutData + * // needed for environments where the icon name is not extracted from + * // the information in the application's desktop file + * QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("foo"))); + * + * // integrate with commandline argument handling + * QCommandLineParser parser; + * aboutData.setupCommandLine(&parser); + * // setup of app specific commandline args + * [...] + * parser.process(app); + * aboutData.processCommandLine(&parser); + * + * // with the application metadata set, register to the D-Bus session + * KDBusService programDBusService(KDBusService::Multiple | KDBusService::NoExitOnFailure); + * @endcode + * * @short Holds information needed by the "About" box and other * classes. * @author Espen Sand (espen@kde.org), David Faure (faure@kde.org) @@ -314,8 +386,15 @@ /** * Returns the KAboutData for the application. - * This contains information such as authors, license, etc. - * provided that the main() called setApplicationData. + * + * This contains information such as authors, license, etc., + * provided that setApplicationData has been called before. + * If not called before, the returned KAboutData will be initialized from the + * equivalent properties of QCoreApplication (and its subclasses), + * if an instance of that already exists. + * For the list of such properties see setApplicationData + * (before 5.22: limited to QCoreApplication::applicationName). + * @see setApplicationData */ static KAboutData applicationData(); @@ -323,8 +402,17 @@ * Sets the application data for this application. * * In addition to changing the result of applicationData(), this initializes - * the relevant properties of QCoreApplication (and its subclasses) with - * information from @p aboutData. + * the equivalent properties of QCoreApplication (and its subclasses) with + * information from @p aboutData, if an instance of that already exists. + * Those properties are: +
    +
  • QCoreApplication::applicationName
  • +
  • QCoreApplication::applicationVersion
  • +
  • QCoreApplication::organizationDomain
  • +
  • QGuiApplication::applicationDisplayName
  • +
  • QGuiApplication::desktopFileName (since 5.16)
  • +
+ * @see applicationData */ static void setApplicationData(const KAboutData &aboutData); @@ -383,16 +471,19 @@ * @param homePageAddress The URL to the component's homepage, including * URL scheme. "http://some.domain" is correct, "some.domain" is * not. Since KDE Frameworks 5.17, https and other valid URL schemes - * are also valid. - * - * IMPORTANT: This argument is used to provide a default organization - * domain for the application (which is used to automatically register on - * the session D-Bus, locate the appropriate desktop file, etc.). Use - * setOrganizationDomain() if you want to control this value yourself. - * @see setOrganizationDomain + * are also valid. See also the note below. * - * @param bugsEmailAddress The bug report email address string. + * @param bugAddress The bug report address string, an email address or a URL. * This defaults to the kde.org bug system. + * + * @note The @p homePageAddress argument is used to derive a default organization + * domain for the application (which is used to register on the session D-Bus, + * locate the appropriate desktop file, etc.), by taking the host name and dropping + * the first component, unless there are less than three (e.g. "www.kde.org" -> "kde.org"). + * Use both setOrganizationDomain(const QByteArray&) and setDesktopFileName() if their default values + * do not have proper values. + * + * @see setOrganizationDomain(const QByteArray&), setDesktopFileName(const QString&) */ // KF6: remove constructor that includes catalogName, and put default // values back in for shortDescription and licenseType @@ -404,7 +495,7 @@ const QString ©rightStatement = QString(), const QString &otherText = QString(), const QString &homePageAddress = QString(), - const QString &bugsEmailAddress = QStringLiteral("submit@bugs.kde.org") + const QString &bugAddress = QStringLiteral("submit@bugs.kde.org") ); /** @@ -417,6 +508,11 @@ * should be translated. Example: i18n("KWrite") * * @param version The component version string. + * + * Sets the property desktopFileName to "org.kde."+componentName and + * the property organizationDomain to "kde.org". + * + * @see setOrganizationDomain(const QByteArray&), setDesktopFileName(const QString&) */ KAboutData(const QString &componentName, const QString &displayName, @@ -651,6 +747,19 @@ KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey); /** + * Defines the license identifier. + * + * @param licenseKey The license identifier. + * @param versionRestriction Whether later versions of the license are also allowed. + * e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions. + * @see addLicenseText, setLicenseText, setLicenseTextFile + * + * @since 5.37 + */ + KAboutData &setLicense(KAboutLicense::LicenseKey licenseKey, + KAboutLicense::VersionRestriction versionRestriction); + + /** * Adds a license identifier. * * If there is only one unknown license set, e.g. by using the default @@ -662,6 +771,22 @@ KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey); /** + * Adds a license identifier. + * + * If there is only one unknown license set, e.g. by using the default + * parameter in the constructor, that one is replaced. + * + * @param licenseKey The license identifier. + * @param versionRestriction Whether later versions of the license are also allowed. + * e.g. licensed under "GPL 2.0 or at your option later versions" would be OrLaterVersions. + * @see setLicenseText, addLicenseText, addLicenseTextFile + * + * @since 5.37 + */ + KAboutData &addLicense(KAboutLicense::LicenseKey licenseKey, + KAboutLicense::VersionRestriction versionRestriction); + + /** * Defines the copyright statement to show when displaying the license. * * @param copyrightStatement A copyright statement, that can look like @@ -691,27 +816,40 @@ /** * Defines the address where bug reports should be sent. * - * @param bugAddress The bug report email address string. + * @param bugAddress The bug report email address or URL. * This defaults to the kde.org bug system. */ KAboutData &setBugAddress(const QByteArray &bugAddress); /** - * Defines the Internet domain of the organization that wrote this application. + * Defines the domain of the organization that wrote this application. * The domain is set to kde.org by default, or the domain of the homePageAddress constructor argument, * if set. * - * Make sure to call setOrganizationDomain if your product is developed out of the - * kde.org version-control system. + * Make sure to call setOrganizationDomain(const QByteArray&) if your product + * is not developed inside the KDE community. + * + * Used e.g. for the registration to D-Bus done by KDBusService + * from the KDE Frameworks KDBusAddons module. + * + * Calling this method has no effect on the value of the desktopFileName property. * - * Used by the automatic registration to D-Bus done by KApplication and KUniqueApplication. + * @note: If your program should work as a D-Bus activatable service, the base name + * of the D-Bus service description file or of the desktop file you install must match + * the D-Bus "well-known name" for which the program will register. + * For example, KDBusService will use a name created from the reversed organization domain + * with the component name attached, so for an organization domain "bar.org" and a + * component name "foo" the name of an installed D-Bus service file needs to be + * "org.bar.foo.service" or the the name of the installed desktop file "org.bar.foo.desktop" + * (and the desktopFileName property accordingly set to "org.bar.foo"). + * For still supporting the deprecated start of services via KToolInvocation, + * the desktop file needs to have an entry with the key "X-DBUS-ServiceName" + * and a value which matches the used D-Bus "well-known name" as just described, + * so with the above used values it needs a line "X-DBUS-ServiceName=org.bar.foo" * - * IMPORTANT: if the organization domain is set, the .desktop file that describes your - * application should have an entry like X-DBUS-ServiceName=reversed_domain.kmyapp - * For instance kwrite passes "http://www.kate-editor.org" as the homePageAddress so it needs - * X-DBUS-ServiceName=org.kate-editor.kwrite in its kwrite.desktop file. + * @param domain the domain name, for instance kde.org, koffice.org, etc. * - * @param domain the domain name, for instance kde.org, koffice.org, kdevelop.org, etc. + * @see setDesktopFileName(const QString&) */ KAboutData &setOrganizationDomain(const QByteArray &domain); @@ -749,7 +887,7 @@ /** * Returns the domain name of the organization that wrote this application. * - * Used by the automatic registration to D-Bus done by KApplication and KUniqueApplication. + * @see setOrganizationDomain(const QByteArray&) */ QString organizationDomain() const; @@ -813,8 +951,8 @@ QString homepage() const; /** - * Returns the email address for bugs. - * @return the email address where to report bugs. + * Returns the email address or URL for bugs. + * @return the address where to report bugs. */ QString bugAddress() const; @@ -948,9 +1086,11 @@ * * A default desktop file name is constructed when the KAboutData * object is created, using the reverse domain name of the - * organizationDomain() and the componentName(). Call this method to - * override the default name, or if you call setOrganizationDomain() or - * setComponentName(). + * organizationDomain() and the componentName() as they are at the time + * of the KAboutData object creation. + * Call this method to override that default name. Typically this is + * done when also setOrganizationDomain(const QByteArray&) or setComponentName(const QString&) + * need to be called to override the initial values. * * The desktop file name can also be passed to the application at runtime through * the @c desktopfile command line option which is added by setupCommandLine(QCommandLineParser*). diff -Nru kcoreaddons-5.18.0/src/lib/kcoreaddons.cpp kcoreaddons-5.44.0a/src/lib/kcoreaddons.cpp --- kcoreaddons-5.18.0/src/lib/kcoreaddons.cpp 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/kcoreaddons.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * This file is part of the KDE Libraries + * Copyright (C) 2016 David Edmundson + * + * 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 + +#include "kcoreaddons.h" +#include "kcoreaddons_version.h" + +QString KCoreAddons::versionString() +{ + return QStringLiteral(KCOREADDONS_VERSION_STRING); +} + +uint KCoreAddons::version() +{ + return KCOREADDONS_VERSION; +} diff -Nru kcoreaddons-5.18.0/src/lib/kcoreaddons.h kcoreaddons-5.44.0a/src/lib/kcoreaddons.h --- kcoreaddons-5.18.0/src/lib/kcoreaddons.h 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/kcoreaddons.h 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * This file is part of the KDE Libraries + * Copyright (C) 2016 David Edmundson + * + * 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. + * + */ + +#ifndef KCOREADDONS_H +#define KCOREADDONS_H + +#include +#include + +/** + * @namespace KCoreAddons + * Provides utility functions for metadata about the KCoreAddons library. + */ +namespace KCoreAddons +{ + /** + * Returns the version number of KCoreAddons at run-time as a string (for example, "5.19.0"). + * This may be a different version than the version the application was compiled against. + * @since 5.20 + */ + KCOREADDONS_EXPORT QString versionString(); + + /** + * Returns a numerical version number of KCoreAddons at run-time in the form 0xMMNNPP + * (MM = major, NN = minor, PP = patch) + * This can be compared using the macro QT_VERSION_CHECK. + * + * For example: + * \code + * if (KCoreAddons::version() < QT_VERSION_CHECK(5,19,0)) + * \endcode + * + * This may be a different version than the version the application was compiled against. + * @since 5.20 + */ + KCOREADDONS_EXPORT unsigned int version(); +} + +#endif diff -Nru kcoreaddons-5.18.0/src/lib/licenses/ARTISTIC kcoreaddons-5.44.0a/src/lib/licenses/ARTISTIC --- kcoreaddons-5.18.0/src/lib/licenses/ARTISTIC 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/ARTISTIC 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,124 @@ +The "Artistic License" + + Preamble + + The intent of this document is to state the conditions under which a + Package may be copied, such that the Copyright Holder maintains some + semblance of artistic control over the development of the package, + while giving the users of the package the right to use and distribute + the Package in a more-or-less customary fashion, plus the right to + make reasonable modifications. + + Definitions + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes of the + Copyright Holder as specified below. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing this + Package. + + "Reasonable copying fee" is whatever you can justify on the basis + of media cost, duplication charges, time of people involved, and so + on. (You will not be required to justify it to the Copyright + Holder, but only to the computing community at large as a market + that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. It + also means that recipients of the item may redistribute it under + the same conditions they received it. + + 1. You may make and give away verbatim copies of the source form of + the Standard Version of this Package without restriction, provided + that you duplicate all of the original copyright notices and + associated disclaimers. + 2. You may apply bug fixes, portability fixes and other modifications + derived from the Public Domain or from the Copyright Holder. A + Package modified in such a way shall still be considered the + Standard Version. + 3. You may otherwise modify your copy of this Package in any way, + provided that you insert a prominent notice in each changed file + stating how and when you changed that file, and provided that you + do at least ONE of the following: + + a. place your modifications in the Public Domain or otherwise make + them Freely Available, such as by posting said modifications to + Usenet or an equivalent medium, or placing the modifications on a + major archive site such as uunet.uu.net, or by allowing the + Copyright Holder to include your modifications in the Standard + Version of the Package. + b. use the modified Package only within your corporation or + organization. + c. rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and + provide a separate manual page for each non-standard executable + that clearly documents how it differs from the Standard Version. + d. make other distribution arrangements with the Copyright Holder. + + You may distribute the programs of this Package in object code or + executable form, provided that you do at least ONE of the following: + + a. distribute a Standard Version of the executables and library + files, together with instructions (in the manual page or + equivalent) on where to get the Standard Version. + b. accompany the distribution with the machine-readable source of the + Package with your modifications. + c. give non-standard executables non-standard names, and clearly + document the differences in manual pages (or equivalent), together + with instructions on where to get the Standard Version. + d. make other distribution arrangements with the Copyright Holder. + + You may charge a reasonable copying fee for any distribution of this + Package. You may charge any fee you choose for support of this + Package. You may not charge a fee for this Package itself. However, + you may distribute this Package in aggregate with other (possibly + commercial) programs as part of a larger (possibly commercial) + software distribution provided that you do not advertise this Package + as a product of your own. You may embed this Package's interpreter + within an executable of yours (by linking); this shall be construed as + a mere form of aggregation, provided that the complete Standard + Version of the interpreter is so embedded. + + The scripts and library files supplied as input to or produced as + output from the programs of this Package do not automatically fall + under the copyright of this Package, but belong to whomever generated + them, and may be sold commercially, and may be aggregated with this + Package. If such scripts or library files are aggregated with this + Package via the so-called "undump" or "unexec" methods of producing a + binary executable image, then distribution of such an image shall + neither be construed as a distribution of this Package nor shall it + fall under the restrictions of Paragraphs 3 and 4, provided that you + do not represent such an executable image as a Standard Version of + this Package. + + C subroutines (or comparably compiled subroutines in other + languages) supplied by you and linked into this Package in order to + emulate subroutines and variables of the language defined by this + Package shall not be considered part of this Package, but are the + equivalent of input as in Paragraph 6, provided these subroutines do + not change the language in any way that would cause it to fail the + regression tests for the language. + + Aggregation of this Package with a commercial distribution is always + permitted provided that the use of this Package is embedded; that is, + when no overt attempt is made to make this Package's interfaces + visible to the end user of the commercial distribution. Such use shall + not be construed as a distribution of this Package. + + The name of the Copyright Holder may not be used to endorse or + promote products derived from this software without specific prior + written permission. + + THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End diff -Nru kcoreaddons-5.18.0/src/lib/licenses/BSD kcoreaddons-5.44.0a/src/lib/licenses/BSD --- kcoreaddons-5.18.0/src/lib/licenses/BSD 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/BSD 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,20 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff -Nru kcoreaddons-5.18.0/src/lib/licenses/CMakeLists.txt kcoreaddons-5.44.0a/src/lib/licenses/CMakeLists.txt --- kcoreaddons-5.18.0/src/lib/licenses/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/CMakeLists.txt 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,8 @@ +# Install license files for use by KAboutLicense and KAboutData + +install( + FILES + BSD GPL_V2 GPL_V3 LGPL_V2 LGPL_V21 LGPL_V3 QPL_V1.0 ARTISTIC + DESTINATION + ${KDE_INSTALL_DATADIR}/kf5/licenses +) diff -Nru kcoreaddons-5.18.0/src/lib/licenses/GPL_V2 kcoreaddons-5.44.0a/src/lib/licenses/GPL_V2 --- kcoreaddons-5.18.0/src/lib/licenses/GPL_V2 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/GPL_V2 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff -Nru kcoreaddons-5.18.0/src/lib/licenses/GPL_V3 kcoreaddons-5.44.0a/src/lib/licenses/GPL_V3 --- kcoreaddons-5.18.0/src/lib/licenses/GPL_V3 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/GPL_V3 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff -Nru kcoreaddons-5.18.0/src/lib/licenses/LGPL_V2 kcoreaddons-5.44.0a/src/lib/licenses/LGPL_V2 --- kcoreaddons-5.18.0/src/lib/licenses/LGPL_V2 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/LGPL_V2 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff -Nru kcoreaddons-5.18.0/src/lib/licenses/LGPL_V21 kcoreaddons-5.44.0a/src/lib/licenses/LGPL_V21 --- kcoreaddons-5.18.0/src/lib/licenses/LGPL_V21 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/LGPL_V21 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff -Nru kcoreaddons-5.18.0/src/lib/licenses/LGPL_V3 kcoreaddons-5.44.0a/src/lib/licenses/LGPL_V3 --- kcoreaddons-5.18.0/src/lib/licenses/LGPL_V3 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/LGPL_V3 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff -Nru kcoreaddons-5.18.0/src/lib/licenses/QPL_V1.0 kcoreaddons-5.44.0a/src/lib/licenses/QPL_V1.0 --- kcoreaddons-5.18.0/src/lib/licenses/QPL_V1.0 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/licenses/QPL_V1.0 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1,103 @@ + THE Q PUBLIC LICENSE + version 1.0 + + Copyright (C) 1999-2000 Troll Tech AS, Norway. + Everyone is permitted to copy and + distribute this license document. + +The intent of this license is to establish freedom to share and change the +software regulated by this license under the open source model. + +This license applies to any software containing a notice placed by the +copyright holder saying that it may be distributed under the terms of +the Q Public License version 1.0. Such software is herein referred to as +the Software. This license covers modification and distribution of the +Software, use of third-party application programs based on the Software, +and development of free software which uses the Software. + + Granted Rights + +1. You are granted the non-exclusive rights set forth in this license + provided you agree to and comply with any and all conditions in this + license. Whole or partial distribution of the Software, or software + items that link with the Software, in any form signifies acceptance of + this license. + +2. You may copy and distribute the Software in unmodified form provided + that the entire package, including - but not restricted to - copyright, + trademark notices and disclaimers, as released by the initial developer + of the Software, is distributed. + +3. You may make modifications to the Software and distribute your + modifications, in a form that is separate from the Software, such as + patches. The following restrictions apply to modifications: + + a. Modifications must not alter or remove any copyright notices in + the Software. + + b. When modifications to the Software are released under this + license, a non-exclusive royalty-free right is granted to the + initial developer of the Software to distribute your modification + in future versions of the Software provided such versions remain + available under these terms in addition to any other license(s) of + the initial developer. + +4. You may distribute machine-executable forms of the Software or + machine-executable forms of modified versions of the Software, provided + that you meet these restrictions: + + a. You must include this license document in the distribution. + + b. You must ensure that all recipients of the machine-executable forms + are also able to receive the complete machine-readable source code + to the distributed Software, including all modifications, without + any charge beyond the costs of data transfer, and place prominent + notices in the distribution explaining this. + + c. You must ensure that all modifications included in the + machine-executable forms are available under the terms of this + license. + +5. You may use the original or modified versions of the Software to + compile, link and run application programs legally developed by you + or by others. + +6. You may develop application programs, reusable components and other + software items that link with the original or modified versions of the + Software. These items, when distributed, are subject to the following + requirements: + + a. You must ensure that all recipients of machine-executable forms of + these items are also able to receive and use the complete + machine-readable source code to the items without any charge + beyond the costs of data transfer. + + b. You must explicitly license all recipients of your items to use + and re-distribute original and modified versions of the items in + both machine-executable and source code forms. The recipients must + be able to do so without any charges whatsoever, and they must be + able to re-distribute to anyone they choose. + + + c. If the items are not available to the general public, and the + initial developer of the Software requests a copy of the items, + then you must supply one. + + Limitations of Liability + +In no event shall the initial developers or copyright holders be liable +for any damages whatsoever, including - but not restricted to - lost +revenue or profits or other direct, indirect, special, incidental or +consequential damages, even if they have been advised of the possibility +of such damages, except to the extent invariable law, if any, provides +otherwise. + + No Warranty + +The Software and this license document are provided AS IS with NO WARRANTY +OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. + Choice of Law + +This license is governed by the Laws of Norway. Disputes shall be settled +by Oslo City Court. diff -Nru kcoreaddons-5.18.0/src/lib/plugin/desktopfileparser.cpp kcoreaddons-5.44.0a/src/lib/plugin/desktopfileparser.cpp --- kcoreaddons-5.18.0/src/lib/plugin/desktopfileparser.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/desktopfileparser.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -32,17 +32,15 @@ #include #include #include +#include +#include -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) // in the desktoptojson binary enable debug messages by default, in the library only warning messages #ifdef BUILDING_DESKTOPTOJSON_TOOL Q_LOGGING_CATEGORY(DESKTOPPARSER, "kf5.kcoreaddons.desktopparser", QtDebugMsg) #else Q_LOGGING_CATEGORY(DESKTOPPARSER, "kf5.kcoreaddons.desktopparser", QtWarningMsg) #endif -#else -Q_LOGGING_CATEGORY(DESKTOPPARSER, "kf5.kcoreaddons.desktopparser") -#endif #ifdef BUILDING_DESKTOPTOJSON_TOOL @@ -197,7 +195,7 @@ } // we only convert data inside the [Desktop Entry] group while (!file.atEnd()) { - QByteArray line = file.readLine().trimmed(); + const QByteArray line = file.readLine().trimmed(); lineNr++; if (line == "[Desktop Entry]") { return true; @@ -230,23 +228,83 @@ *nextGroup = name; break; } - if (line.startsWith(QByteArrayLiteral("Type="))) { - // TODO: should we also have to accept spaces around equals here? - type = line.mid(strlen("Type=")); + + const static QRegularExpression typeEntryRegex( + QStringLiteral("^Type\\s*=\\s*(.*)$")); + const auto match = typeEntryRegex.match(QString::fromUtf8(line)); + if (match.hasMatch()) { + type = match.captured(1).toUtf8(); } } return type; } -QVector* parseServiceTypesFile(QString path) +bool tokenizeKeyValue(QFile &df, const QString &src, QByteArray &key, QString &value, int &lineNr) +{ + const QByteArray line = df.readLine().trimmed(); + lineNr++; + if (line.isEmpty()) { + DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << ": empty"; + return true; + } + if (line.startsWith('#')) { + DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << ": comment"; + return true; // skip comments + } + if (line.startsWith('[')) { + // start of new group -> doesn't interest us anymore + DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << ": start of new group " << line; + return false; + } + // must have form key=value now + const int equalsIndex = line.indexOf('='); + if (equalsIndex == -1) { + qCWarning(DESKTOPPARSER).nospace() << qPrintable(src) << ':' << lineNr << ": Line is neither comment nor group " + "and doesn't contain an '=' character: \"" << line.constData() << '\"'; + return true; + } + // trim key and value to remove spaces around the '=' char + key = line.mid(0, equalsIndex).trimmed(); + if (key.isEmpty()) { + qCWarning(DESKTOPPARSER).nospace() << qPrintable(src) << ':' << lineNr << ": Key name is missing: \"" << line.constData() << '\"'; + return true; + } + + const QByteArray valueRaw = line.mid(equalsIndex + 1).trimmed(); + const QByteArray valueEscaped = escapeValue(valueRaw); + value = QString::fromUtf8(valueEscaped); + +#ifdef BUILDING_DESKTOPTOJSON_TOOL + DESKTOPTOJSON_VERBOSE_DEBUG.nospace() << "Line " << lineNr << ": key=" << key << ", value=" << value; + if (valueEscaped != valueRaw) { + DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << " contained escape sequences"; + } +#endif + + return true; +} + +static QString locateRelativeServiceType(const QString &relPath) +{ + return QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("kservicetypes5/") + relPath); +} + +static QVector* parseServiceTypesFile(const QString &inputPath) { int lineNr = 0; + QString path = inputPath; if (QDir::isRelativePath(path)) { - const QString originalPath = path; - path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("kservicetypes5/") + path); + path = locateRelativeServiceType(path); + QString rcPath; if (path.isEmpty()) { - qCCritical(DESKTOPPARSER) << "Could not locate service type file kservicetypes5/" << originalPath << ", tried" << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + rcPath = QStringLiteral(":/kservicetypes5/") + inputPath; + if (QFileInfo::exists(rcPath)) { + path = rcPath; + } + } + if (path.isEmpty()) { + qCWarning(DESKTOPPARSER).nospace() << "Could not locate service type file kservicetypes5/" << qPrintable(inputPath) << ", tried " << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation) << " and " << rcPath; return nullptr; } } @@ -280,7 +338,7 @@ qCWarning(DESKTOPPARSER) << "Could not find Type= key in group" << currentGroup; continue; } - QByteArray propertyName = currentGroup.mid(strlen("PropertyDef::")); + QByteArray propertyName = currentGroup.mid(qstrlen("PropertyDef::")); QVariant::Type type = QVariant::nameToType(typeStr.constData()); switch (type) { case QVariant::String: @@ -311,47 +369,47 @@ } // end of anonymous namespace -ServiceTypeDefinition::ServiceTypeDefinition(const QVector< CustomPropertyDefinition >& defs) - : m_definitions(defs) -{ -} - -ServiceTypeDefinition::~ServiceTypeDefinition() +ServiceTypeDefinition::ServiceTypeDefinition() { } ServiceTypeDefinition ServiceTypeDefinition::fromFiles(const QStringList &paths) { - QVector defs; - defs.reserve(paths.size()); - + ServiceTypeDefinition ret; + ret.m_definitions.reserve(paths.size()); // as we might modify the cache we need to acquire a mutex here - foreach (const QString &serviceType, paths) { - QMutexLocker lock(&s_serviceTypesMutex); - - QVector* def = s_serviceTypes->object(serviceType); - - if (def) { - // in cache but we still must make our own copy - defs << *def; - } - else { - // not found in cache -> we need to parse the file - qCDebug(DESKTOPPARSER) << "About to parse service type file" << serviceType; - def = parseServiceTypesFile(serviceType); - if (!def) { + foreach (const QString &serviceTypePath, paths) { + bool added = ret.addFile(serviceTypePath); + if (!added) { #ifdef BUILDING_DESKTOPTOJSON_TOOL - exit(1); // this is a fatal error when using kcoreaddons_desktop_to_json() -#else - continue; + exit(1); // this is a fatal error when using kcoreaddons_desktop_to_json() #endif - } + } + } + return ret; +} - defs << *def; // This must *precede* insert call, insert might delete - s_serviceTypes->insert(serviceType, def); +bool ServiceTypeDefinition::addFile(const QString& path) +{ + QMutexLocker lock(&s_serviceTypesMutex); + QVector* def = s_serviceTypes->object(path); + + if (def) { + // in cache but we still must make our own copy + m_definitions << *def; + } + else { + // not found in cache -> we need to parse the file + qCDebug(DESKTOPPARSER) << "About to parse service type file" << path; + def = parseServiceTypesFile(path); + if (!def) { + return false; } + + m_definitions << *def; // This must *precede* insert call, insert might delete + s_serviceTypes->insert(path, def); } - return ServiceTypeDefinition(defs); + return true; } QJsonValue ServiceTypeDefinition::parseValue(const QByteArray &key, const QString &value) const @@ -366,7 +424,7 @@ return QJsonValue(value); } -void DesktopFileParser::convertToJson(const QByteArray &key, const ServiceTypeDefinition &serviceTypes, const QString &value, +void DesktopFileParser::convertToJson(const QByteArray &key, ServiceTypeDefinition &serviceTypes, const QString &value, QJsonObject &json, QJsonObject &kplugin, int lineNr) { /* The following keys are recognized (and added to a "KPlugin" object): @@ -405,8 +463,9 @@ } else if (key == QByteArrayLiteral("X-KDE-PluginInfo-Depends")) { kplugin[QStringLiteral("Dependencies")] = QJsonArray::fromStringList(deserializeList(value)); } else if (key == QByteArrayLiteral("X-KDE-ServiceTypes") || key == QByteArrayLiteral("ServiceTypes")) { - // some .desktop files still use the legacy ServiceTypes= key - kplugin[QStringLiteral("ServiceTypes")] = QJsonArray::fromStringList(deserializeList(value)); + //NOTE: "X-KDE-ServiceTypes" and "ServiceTypes" were already managed in the first parse step, so this second one is almost a noop + const auto services = deserializeList(value); + kplugin[QStringLiteral("ServiceTypes")] = QJsonArray::fromStringList(services); } else if (key == QByteArrayLiteral("MimeType")) { // MimeType is a XDG string list and not a KConfig list so we need to use ';' as the separator kplugin[QStringLiteral("MimeTypes")] = QJsonArray::fromStringList(deserializeList(value, ';')); @@ -447,7 +506,7 @@ } else if (key == QByteArrayLiteral("Comment")) { kplugin[QStringLiteral("Description")] = value; } else if (key.startsWith(QByteArrayLiteral("Comment["))) { - kplugin[QStringLiteral("Description") + QString::fromUtf8(key.mid(strlen("Comment")))] = value; + kplugin[QStringLiteral("Description") + QString::fromUtf8(key.mid(qstrlen("Comment")))] = value; } else if (key == QByteArrayLiteral("Hidden")) { DESKTOPTOJSON_VERBOSE_WARNING << "Hidden= key found in desktop file, this makes no sense" " with metadata inside the plugin."; @@ -472,46 +531,52 @@ ServiceTypeDefinition serviceTypeDef = ServiceTypeDefinition::fromFiles(serviceTypes); readUntilDesktopEntryGroup(df, src, lineNr); DESKTOPTOJSON_VERBOSE_DEBUG << "Found [Desktop Entry] group in line" << lineNr; + auto startPos = df.pos(); - //QJsonObject json; - QJsonObject kplugin; // the "KPlugin" key of the metadata + //parse it a first time to know servicetype while (!df.atEnd()) { - const QByteArray line = df.readLine().trimmed(); - lineNr++; - if (line.isEmpty()) { - DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << ": empty"; - continue; - } - if (line.startsWith('#')) { - DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << ": comment"; - continue; // skip comments - } - if (line.startsWith('[')) { - // start of new group -> doesn't interest us anymore - DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << ": start of new group " << line; + QByteArray key; + QString value; + if (!tokenizeKeyValue(df, src, key, value, lineNr)) { break; } - // must have form key=value now - const int equalsIndex = line.indexOf('='); - if (equalsIndex == -1) { - qCWarning(DESKTOPPARSER).nospace() << qPrintable(src) << ':' << lineNr << ": Line is neither comment nor group " - "and doesn't contain an '=' character: \"" << line.constData() << '\"'; - continue; + // some .desktop files still use the legacy ServiceTypes= key + if (key == QByteArrayLiteral("X-KDE-ServiceTypes") || key == QByteArrayLiteral("ServiceTypes")) { + const QString dotDesktop = QStringLiteral(".desktop"); + const QChar slashChar(QLatin1Char('/')); + const auto serviceList = deserializeList(value); + + for (const auto &service : serviceList) { + // Make up the filename from the service type name. This assumes consistent naming... + QString absFileName = locateRelativeServiceType( + service.toLower().replace(slashChar, QLatin1Char('-')) + dotDesktop); + if (absFileName.isEmpty()) { + absFileName = locateRelativeServiceType( + service.toLower().remove(slashChar) + dotDesktop); + } + if (absFileName.isEmpty()) { + qCWarning(DESKTOPPARSER) << "Unable to find service type for service" << service << "listed in" << src; + } else { + serviceTypeDef.addFile(absFileName); + } + } + break; } - // trim key and value to remove spaces around the '=' char - const QByteArray key = line.mid(0, equalsIndex).trimmed(); - if (key.isEmpty()) { - qCWarning(DESKTOPPARSER).nospace() << qPrintable(src) << ':' << lineNr << ": Key name is missing: \"" << line.constData() << '\"'; + } + lineNr=0; + df.seek(startPos); + + QJsonObject kplugin; // the "KPlugin" key of the metadata + //QJsonObject json; + while (!df.atEnd()) { + QByteArray key; + QString value; + if (!tokenizeKeyValue(df, src, key, value, lineNr)) { + break; + } else if (key.isEmpty()) { continue; } - const QByteArray valueRaw = line.mid(equalsIndex + 1).trimmed(); - const QByteArray valueEscaped = escapeValue(valueRaw); - const QString value = QString::fromUtf8(valueEscaped); #ifdef BUILDING_DESKTOPTOJSON_TOOL - DESKTOPTOJSON_VERBOSE_DEBUG.nospace() << "Line " << lineNr << ": key=" << key << ", value=" << value; - if (valueEscaped != valueRaw) { - DESKTOPTOJSON_VERBOSE_DEBUG << "Line " << lineNr << " contained escape sequences"; - } if (s_compatibilityMode) { convertToCompatibilityJson(QString::fromUtf8(key), value, json, lineNr); } else { diff -Nru kcoreaddons-5.18.0/src/lib/plugin/desktopfileparser_p.h kcoreaddons-5.44.0a/src/lib/plugin/desktopfileparser_p.h --- kcoreaddons-5.18.0/src/lib/plugin/desktopfileparser_p.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/desktopfileparser_p.h 2018-03-06 08:12:31.000000000 +0000 @@ -36,8 +36,7 @@ struct CustomPropertyDefinition; struct ServiceTypeDefinition { - ServiceTypeDefinition(const QVector &defs); - ~ServiceTypeDefinition(); + ServiceTypeDefinition(); static ServiceTypeDefinition fromFiles(const QStringList &paths); /** @@ -45,6 +44,14 @@ * If there is no custom property definition for @p key this will simply return the string value */ QJsonValue parseValue(const QByteArray &key, const QString &value) const; + + /** + * Parses the service file in @p path and extracts its definitions + * + * @returns whether the action could be performed + */ + bool addFile(const QString &path); + private: QVector m_definitions; }; @@ -54,7 +61,7 @@ QByteArray escapeValue(const QByteArray &input); QStringList deserializeList(const QString &data, char separator = ','); bool convert(const QString &src, const QStringList &serviceTypes, QJsonObject &json, QString *libraryPath); - void convertToJson(const QByteArray &key, const ServiceTypeDefinition &serviceTypes, const QString &value, + void convertToJson(const QByteArray &key, ServiceTypeDefinition &serviceTypes, const QString &value, QJsonObject &json, QJsonObject &kplugin, int lineNr); #ifdef BUILDING_DESKTOPTOJSON_TOOL void convertToCompatibilityJson(const QString &key, const QString &value, QJsonObject &json, int lineNr); diff -Nru kcoreaddons-5.18.0/src/lib/plugin/kpluginfactory.cpp kcoreaddons-5.44.0a/src/lib/plugin/kpluginfactory.cpp --- kcoreaddons-5.18.0/src/lib/plugin/kpluginfactory.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/kpluginfactory.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -23,7 +23,7 @@ #include "kpluginfactory_p.h" #include -#include +#include "kcoreaddons_debug.h" Q_GLOBAL_STATIC(QObjectCleanupHandler, factorycleanup) @@ -58,7 +58,7 @@ // we allow different interfaces to be registered without keyword if (!keyword.isEmpty()) { if (d->createInstanceHash.contains(keyword)) { - qWarning() << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!"; + qCWarning(KCOREADDONS_DEBUG) << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!"; } d->createInstanceHash.insert(keyword, KPluginFactoryPrivate::Plugin(metaObject, instanceFunction)); } else { @@ -69,7 +69,7 @@ for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; otherSuper = otherSuper->superClass()) { if (superClass == otherSuper) { - qWarning() << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins."; + qCWarning(KCOREADDONS_DEBUG) << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins."; } } } @@ -80,7 +80,7 @@ for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; otherSuper = otherSuper->superClass()) { if (superClass == otherSuper) { - qWarning() << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins."; + qCWarning(KCOREADDONS_DEBUG) << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins."; } } } @@ -95,7 +95,7 @@ Q_UNUSED(parent); Q_UNUSED(className); Q_UNUSED(args); - return 0; + return nullptr; } #endif @@ -106,7 +106,7 @@ Q_UNUSED(parentWidget); Q_UNUSED(classname); Q_UNUSED(args); - return 0; + return nullptr; } #endif @@ -114,7 +114,7 @@ { Q_D(KPluginFactory); - QObject *obj = 0; + QObject *obj = nullptr; #ifndef KCOREADDONS_NO_DEPRECATED if (keyword.isEmpty()) { @@ -140,7 +140,7 @@ for (const QMetaObject *current = plugin.first; current; current = current->superClass()) { if (0 == qstrcmp(iface, current->className())) { if (obj) { - qWarning() << "ambiguous interface requested from a DSO containing more than one plugin"; + qCWarning(KCOREADDONS_DEBUG) << "ambiguous interface requested from a DSO containing more than one plugin"; } obj = plugin.second(parentWidget, parent, args); break; diff -Nru kcoreaddons-5.18.0/src/lib/plugin/kpluginfactory.h kcoreaddons-5.44.0a/src/lib/plugin/kpluginfactory.h --- kcoreaddons-5.18.0/src/lib/plugin/kpluginfactory.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/kpluginfactory.h 2018-03-06 08:12:31.000000000 +0000 @@ -29,6 +29,8 @@ #include #include // for source compat +class QWidget; + class KPluginFactoryPrivate; namespace KParts { @@ -46,8 +48,6 @@ public: \ explicit name(); \ ~name(); \ - private: \ - void init(); \ }; #define K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY_JSON(name, baseFactory, json) \ @@ -81,6 +81,15 @@ * \param pluginRegistrations Code to be inserted into the constructor of the * class. Usually a series of registerPlugin() calls. * + * @note K_PLUGIN_FACTORY declares the subclass including a Q_OBJECT macro. + * So you need to make sure to have Qt's moc run also for the source file + * where you use the macro. E.g. in projects using CMake and it's automoc feature, + * as usual you need to have a line + * @code + * #include + * @endcode + * in the same source file when that one has the name "myplugin.cpp". + * * Example: * \code * #include @@ -125,6 +134,15 @@ * * \param jsonFile Name of the json file to be compiled into the plugin as metadata * + * @note K_PLUGIN_FACTORY_WITH_JSON declares the subclass including a Q_OBJECT macro. + * So you need to make sure to have Qt's moc run also for the source file + * where you use the macro. E.g. in projects using CMake and it's automoc feature, + * as usual you need to have a line + * @code + * #include + * @endcode + * in the same source file when that one has the name "myplugin.cpp". + * * Example: * \code * #include @@ -157,6 +175,44 @@ /** * \relates KPluginFactory * + * Create a KPluginFactory subclass and export it as the root plugin object with + * JSON metadata. + * + * This macro does the same as K_PLUGIN_FACTORY_WITH_JSON, but you only have to pass the class name and the json file. + * The factory name and registerPlugin call are deduced from the class name. + * + * @code + * #include + * @endcode + * in the same source file when that one has the name "myplugin.cpp". + * + * Example: + * \code + * #include + * #include + * + * class MyPlugin : public PluginInterface + * { + * public: + * MyPlugin(QObject *parent, const QVariantList &args) + * : PluginInterface(parent) + * {} + * }; + * + * K_PLUGIN_CLASS_WITH_JSON(MyPlugin, "metadata.json") + * + * #include + * \endcode + * + * \see K_PLUGIN_FACTORY_WITH_JSON + * + * @since 5.44 + */ +#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile) K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, jsonFile, registerPlugin();) + +/** + * \relates KPluginFactory + * * K_PLUGIN_FACTORY_DECLARATION declares the KPluginFactory subclass. This macro * can be used in a header file. * @@ -284,7 +340,7 @@ /** * This destroys the PluginFactory. */ - virtual ~KPluginFactory(); + ~KPluginFactory() override; /** * Use this method to create an object. It will try to create an object which inherits @@ -298,7 +354,7 @@ * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T *create(QObject *parent = 0, const QVariantList &args = QVariantList()); + T *create(QObject *parent = nullptr, const QVariantList &args = QVariantList()); /** * Use this method to create an object. It will try to create an object which inherits @@ -312,7 +368,7 @@ * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T *create(const QString &keyword, QObject *parent = 0, const QVariantList &args = QVariantList()); + T *create(const QString &keyword, QObject *parent = nullptr, const QVariantList &args = QVariantList()); /** * Use this method to create an object. It will try to create an object which inherits @@ -331,7 +387,7 @@ T *create(QWidget *parentWidget, QObject *parent, const QString &keyword = QString(), const QVariantList &args = QVariantList()); /** - * @deprecated + * @deprecated since 4.0 use create(QObject *parent, const QVariantList &args) */ #ifndef KCOREADDONS_NO_DEPRECATED template @@ -343,12 +399,12 @@ #endif /** - * @deprecated + * @deprecated since 4.0 use create(QObject *parent, const QVariantList &args) */ #ifndef KCOREADDONS_NO_DEPRECATED - KCOREADDONS_DEPRECATED QObject *create(QObject *parent = 0, const char *classname = "QObject", const QStringList &args = QStringList()) + KCOREADDONS_DEPRECATED QObject *create(QObject *parent = nullptr, const char *classname = "QObject", const QStringList &args = QStringList()) { - return create(classname, 0, parent, stringListToVariantList(args), QString()); + return create(classname, nullptr, parent, stringListToVariantList(args), QString()); } #endif @@ -436,14 +492,14 @@ KPluginFactoryPrivate *const d_ptr; /** - * @deprecated + * @deprecated since 4.0 use create(QObject *parent, const QVariantList &args) */ #ifndef KCOREADDONS_NO_DEPRECATED virtual KCOREADDONS_DEPRECATED QObject *createObject(QObject *parent, const char *className, const QStringList &args); #endif /** - * @deprecated + * @deprecated since 4.0 use create(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args) */ #ifndef KCOREADDONS_NO_DEPRECATED virtual KCOREADDONS_DEPRECATED KParts::Part *createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args); @@ -469,7 +525,7 @@ static QObject *createInstance(QWidget *parentWidget, QObject *parent, const QVariantList &args) { Q_UNUSED(parentWidget); - ParentType *p = 0; + ParentType *p = nullptr; if (parent) { p = qobject_cast(parent); Q_ASSERT(p); @@ -492,7 +548,7 @@ template inline T *KPluginFactory::create(QObject *parent, const QVariantList &args) { - QObject *o = create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast(parent) : 0, parent, args, QString()); + QObject *o = create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast(parent) : nullptr, parent, args, QString()); T *t = qobject_cast(o); if (!t) { @@ -504,7 +560,7 @@ template inline T *KPluginFactory::create(const QString &keyword, QObject *parent, const QVariantList &args) { - QObject *o = create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast(parent) : 0, parent, args, keyword); + QObject *o = create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast(parent) : nullptr, parent, args, keyword); T *t = qobject_cast(o); if (!t) { diff -Nru kcoreaddons-5.18.0/src/lib/plugin/kpluginloader.cpp kcoreaddons-5.44.0a/src/lib/plugin/kpluginloader.cpp --- kcoreaddons-5.18.0/src/lib/plugin/kpluginloader.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/kpluginloader.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -25,7 +25,7 @@ #include #include #include -#include +#include "kcoreaddons_debug.h" #include #include @@ -40,7 +40,7 @@ protected: KPluginLoaderPrivate(const QString &libname) : name(libname), - loader(0), + loader(nullptr), pluginVersion(~0U), pluginVersionResolved(false) {} @@ -90,7 +90,7 @@ if (pluginName.isValid()) { d->loader->setFileName(pluginName.name()); if (d->loader->fileName().isEmpty()) { - qWarning() << "Error loading plugin" << pluginName.name() << d->loader->errorString() << endl + qCWarning(KCOREADDONS_DEBUG) << "Error loading plugin" << pluginName.name() << d->loader->errorString() << endl << "Plugin search paths are" << QCoreApplication::libraryPaths() << endl << "The environment variable QT_PLUGIN_PATH might be not correctly set"; } @@ -111,13 +111,13 @@ QObject *obj = instance(); if (!obj) { - return 0; + return nullptr; } KPluginFactory *factory = qobject_cast(obj); - if (factory == 0) { - qDebug() << "Expected a KPluginFactory, got a" << obj->metaObject()->className(); + if (factory == nullptr) { + qCDebug(KCOREADDONS_DEBUG) << "Expected a KPluginFactory, got a" << obj->metaObject()->className(); delete obj; d->errorString = tr("The library %1 does not offer a KPluginFactory.").arg(d->name); } @@ -164,7 +164,7 @@ Q_D(const KPluginLoader); if (!load()) { - return 0; + return nullptr; } return d->loader->instance(); @@ -194,7 +194,7 @@ Q_ASSERT(lib.isLoaded()); // already loaded by QPluginLoader::load() // TODO: this messes up KPluginLoader::errorString(): it will change from unknown error to could not resolve kde_plugin_version - quint32 *version = (quint32 *) lib.resolve("kde_plugin_version"); + quint32 *version = reinterpret_cast(lib.resolve("kde_plugin_version")); if (version) { d->pluginVersion = *version; } else { @@ -294,7 +294,7 @@ loader.setFileName(metadata.fileName()); QObject* obj = loader.instance(); if (!obj) { - qWarning().nospace() << "Could not instantiate plugin \"" << metadata.fileName() << "\": " + qCWarning(KCOREADDONS_DEBUG).nospace() << "Could not instantiate plugin \"" << metadata.fileName() << "\": " << loader.errorString(); continue; } diff -Nru kcoreaddons-5.18.0/src/lib/plugin/kpluginloader.h kcoreaddons-5.44.0a/src/lib/plugin/kpluginloader.h --- kcoreaddons-5.18.0/src/lib/plugin/kpluginloader.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/kpluginloader.h 2018-03-06 08:12:31.000000000 +0000 @@ -87,7 +87,7 @@ * \param plugin The name of the plugin. * \param parent A parent object. */ - explicit KPluginLoader(const QString &plugin, QObject *parent = 0); + explicit KPluginLoader(const QString &plugin, QObject *parent = nullptr); /** * Load a plugin by name. @@ -99,7 +99,7 @@ * \param name The name of the plugin. * \param parent A parent object. */ - explicit KPluginLoader(const KPluginName &name, QObject *parent = 0); + explicit KPluginLoader(const KPluginName &name, QObject *parent = nullptr); /** * Destroys the plugin loader. @@ -287,7 +287,7 @@ * } else { * return pluginGroup.readEntry(md.pluginName(), false); * } - * } + * }; * QList plugins = KPluginLoader::instantiatePlugins("myapp", filter); * @endcode * @@ -298,7 +298,14 @@ * @param filter a callback function that returns @c true if the found plugin should be loaded * and @c false if it should be skipped. If this argument is omitted all plugins will be loaded. * - * @param parent the parent to set for the instantiated plugins + * @param parent the parent to set for the instantiated plugins, if the + * plugins were not already loaded. + * + * @note If the plugins have been previously loaded (via QPluginLoader, + * directly or due to this class) without being deleted in the meantime + * then they are not re-created or re-parented and will be returned using + * the parent they were originally created with. @sa + * QPluginLoader::instance(). * * @return a list containing an instantiation of each plugin that met the filter criteria * @@ -308,7 +315,7 @@ */ static QList instantiatePlugins(const QString &directory, std::function filter = std::function(), - QObject* parent = Q_NULLPTR); + QObject* parent = nullptr); /** * Find all plugins inside @p directory. Only plugins which have JSON metadata will be considered. @@ -429,7 +436,7 @@ /** * Construct an invalid plugin name with an error message. * - * When this object is passed to KPluginLoader, @param errorString + * When this object is passed to KPluginLoader, @p errorString * will be used for KPluginLoader::errorString(). * * @param errorString The (translated) error string. diff -Nru kcoreaddons-5.18.0/src/lib/plugin/kpluginmetadata.cpp kcoreaddons-5.44.0a/src/lib/plugin/kpluginmetadata.cpp --- kcoreaddons-5.18.0/src/lib/plugin/kpluginmetadata.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/kpluginmetadata.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -26,7 +26,7 @@ #include #include #include -#include +#include "kcoreaddons_debug.h" #include "kpluginloader.h" #include "kaboutdata.h" @@ -67,10 +67,15 @@ QFile f(file); bool b = f.open(QIODevice::ReadOnly); if (!b) { - qWarning() << "Couldn't open" << file; + qCWarning(KCOREADDONS_DEBUG) << "Couldn't open" << file; return; } - m_metaData = QJsonDocument::fromJson(f.readAll()).object(); + + QJsonParseError error; + m_metaData = QJsonDocument::fromJson(f.readAll(), &error).object(); + if (error.error) { + qCWarning(KCOREADDONS_DEBUG) << "error parsing" << file << error.errorString(); + } m_fileName = file; d->metaDataFileName = file; } else { @@ -174,8 +179,9 @@ return value.toVariant().toStringList(); } else { QString asString = value.isString() ? value.toString() : value.toVariant().toString(); - qWarning() << "Expected JSON property" << key << "to be a string list." - " Treating it as a list with a single entry:" << asString; + const QString id = obj.value(QStringLiteral("KPlugin")).toObject().value(QStringLiteral("Id")).toString(); + qCWarning(KCOREADDONS_DEBUG) << "Expected JSON property" << key << "to be a string list." + " Treating it as a list with a single entry:" << asString << id.toLatin1().constData(); return QStringList(asString); } } @@ -187,7 +193,7 @@ if (it != jo.constEnd()) { return it.value(); } - const QString language = languageWithCountry.mid(0, languageWithCountry.indexOf(QLatin1Char('_'))); + const QStringRef language = languageWithCountry.midRef(0, languageWithCountry.indexOf(QLatin1Char('_'))); it = jo.constFind(key + QLatin1Char('[') + language + QLatin1Char(']')); if (it != jo.constEnd()) { return it.value(); @@ -208,7 +214,7 @@ static inline void addPersonFromJson(const QJsonObject &obj, QList* out) { KAboutPerson person = KAboutPerson::fromJSON(obj); if (person.name().isEmpty()) { - qWarning() << "Invalid plugin metadata: Attempting to create a KAboutPerson from json without 'Name' property:" << obj; + qCWarning(KCOREADDONS_DEBUG) << "Invalid plugin metadata: Attempting to create a KAboutPerson from json without 'Name' property:" << obj; return; } out->append(person); @@ -340,7 +346,23 @@ QString KPluginMetaData::value(const QString &key, const QString &defaultValue) const { - return m_metaData.value(key).toString(defaultValue); + const QJsonValue value = m_metaData.value(key); + if (value.isString()) { + return value.toString(defaultValue); + } else if (value.isArray()) { + qCWarning(KCOREADDONS_DEBUG) << "Expected JSON property" << key << "to be a single string." + " but it is a stringlist"; + const QStringList list = value.toVariant().toStringList(); + if (list.isEmpty()) { + return defaultValue; + } + return list.join(QChar::fromLatin1(',')); + } else if (value.isBool()) { + qCWarning(KCOREADDONS_DEBUG) << "Expected JSON property" << key << "to be a single string." + " but it is a bool"; + return value.toBool() ? QStringLiteral("true") : QStringLiteral("false"); + } + return defaultValue; } bool KPluginMetaData::operator==(const KPluginMetaData &other) const diff -Nru kcoreaddons-5.18.0/src/lib/plugin/kpluginmetadata.h kcoreaddons-5.44.0a/src/lib/plugin/kpluginmetadata.h --- kcoreaddons-5.18.0/src/lib/plugin/kpluginmetadata.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/plugin/kpluginmetadata.h 2018-03-06 08:12:31.000000000 +0000 @@ -37,7 +37,10 @@ class QObject; -/** This class allows easily accessing some standardized values from the JSON metadata that +/** + * @class KPluginMetaData kpluginmetadata.h KPluginMetaData + * + * This class allows easily accessing some standardized values from the JSON metadata that * can be embedded into Qt plugins. Additional plugin-specific metadata can be retrieved by * directly reading from the QJsonObject returned by KPluginMetaData::rawData(). * @@ -83,7 +86,7 @@ "License": "LGPL", "Id": "time", "Version": "1.0", - "Website": "http://plasma.kde.org/", + "Website": "https://plasma.kde.org/", "ServiceTypes": ["Plasma/DataEngine"] } } diff -Nru kcoreaddons-5.18.0/src/lib/randomness/krandom.cpp kcoreaddons-5.44.0a/src/lib/randomness/krandom.cpp --- kcoreaddons-5.18.0/src/lib/randomness/krandom.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/randomness/krandom.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -35,23 +35,25 @@ #include #include +#include +#include int KRandom::random() { - static bool init = false; - if (!init) { + static QThreadStorage initialized_threads; + if (!initialized_threads.localData()) { unsigned int seed; - init = true; + initialized_threads.setLocalData(true); QFile urandom(QStringLiteral("/dev/urandom")); - bool opened = urandom.open(QIODevice::ReadOnly); - if (!opened || urandom.read((char *)&seed, sizeof(seed)) != sizeof(seed)) { + bool opened = urandom.open(QIODevice::ReadOnly | QIODevice::Unbuffered); + if (!opened || urandom.read(reinterpret_cast(&seed), sizeof(seed)) != sizeof(seed)) { // No /dev/urandom... try something else. - srand(getpid()); - seed = rand() + time(0); + qsrand(getpid()); + seed = qrand() ^ time(nullptr) ^ reinterpret_cast(QThread::currentThread()); } - srand(seed); + qsrand(seed); } - return rand(); + return qrand(); } QString KRandom::randomString(int length) diff -Nru kcoreaddons-5.18.0/src/lib/randomness/krandom.h kcoreaddons-5.44.0a/src/lib/randomness/krandom.h --- kcoreaddons-5.18.0/src/lib/randomness/krandom.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/randomness/krandom.h 2018-03-06 08:12:31.000000000 +0000 @@ -32,6 +32,8 @@ * @short Helper class to create random data * * This namespace provides methods which generate random data. + * KRandom is not recommended for serious random-number generation needs, + * like cryptography. */ namespace KRandom { diff -Nru kcoreaddons-5.18.0/src/lib/randomness/krandomsequence.cpp kcoreaddons-5.44.0a/src/lib/randomness/krandomsequence.cpp --- kcoreaddons-5.18.0/src/lib/randomness/krandomsequence.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/randomness/krandomsequence.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -21,7 +21,7 @@ #include "krandomsequence.h" #include "krandom.h" -class KRandomSequence::Private +class Q_DECL_HIDDEN KRandomSequence::Private { public: enum {SHUFFLE_TABLE_SIZE = 32}; @@ -73,7 +73,7 @@ ////////////////////////////////////////////////////////////////////////////// void KRandomSequence::setSeed(long lngSeed1) { - setSeed((int)lngSeed1); + setSeed(static_cast(lngSeed1)); } void KRandomSequence::setSeed(int lngSeed1) @@ -197,7 +197,7 @@ unsigned long KRandomSequence::getLong(unsigned long max) { - return (unsigned long) getInt((int)max); + return getInt(static_cast(max)); } unsigned int @@ -205,7 +205,7 @@ { d->draw(); - return max ? (((unsigned int) d->lngShufflePos) % max) : 0; + return max ? ((static_cast(d->lngShufflePos)) % max) : 0; } bool @@ -213,5 +213,5 @@ { d->draw(); - return (((unsigned int) d->lngShufflePos) & 1); + return ((static_cast(d->lngShufflePos)) & 1); } diff -Nru kcoreaddons-5.18.0/src/lib/text/kmacroexpander.cpp kcoreaddons-5.44.0a/src/lib/text/kmacroexpander.cpp --- kcoreaddons-5.18.0/src/lib/text/kmacroexpander.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/kmacroexpander.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -34,14 +34,12 @@ delete d; } -void -KMacroExpanderBase::setEscapeChar(QChar c) +void KMacroExpanderBase::setEscapeChar(QChar c) { d->escapechar = c; } -QChar -KMacroExpanderBase::escapeChar() const +QChar KMacroExpanderBase::escapeChar() const { return d->escapechar; } diff -Nru kcoreaddons-5.18.0/src/lib/text/kmacroexpander_unix.cpp kcoreaddons-5.44.0a/src/lib/text/kmacroexpander_unix.cpp --- kcoreaddons-5.18.0/src/lib/text/kmacroexpander_unix.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/kmacroexpander_unix.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -45,7 +45,7 @@ using namespace KMacroExpander; -#pragma message("KDE5 TODO: Import these methods into Qt5") +#pragma message("TODO: Import these methods into Qt") inline static bool isSpecial(QChar cUnicode) { diff -Nru kcoreaddons-5.18.0/src/lib/text/kstringhandler.cpp kcoreaddons-5.44.0a/src/lib/text/kstringhandler.cpp --- kcoreaddons-5.18.0/src/lib/text/kstringhandler.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/kstringhandler.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -26,6 +26,7 @@ #include // for the word ranges #include #include +#include // // Capitalization routines @@ -339,3 +340,22 @@ return result; } +int KStringHandler::logicalLength(const QString& text) +{ + int length = 0; + auto chrs = text.toUcs4(); + for (auto chr : chrs) { + auto script = QChar::script(chr); + if (script == QChar::Script_Han || + script == QChar::Script_Hangul || + script == QChar::Script_Hiragana || + script == QChar::Script_Katakana || + script == QChar::Script_Yi || + QChar::isHighSurrogate(chr)) { + length += 2; + } else { + length += 1; + } + } + return length; +} diff -Nru kcoreaddons-5.18.0/src/lib/text/kstringhandler.h kcoreaddons-5.44.0a/src/lib/text/kstringhandler.h --- kcoreaddons-5.18.0/src/lib/text/kstringhandler.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/kstringhandler.h 2018-03-06 08:12:31.000000000 +0000 @@ -215,5 +215,15 @@ @since 4.4 */ KCOREADDONS_EXPORT QString preProcessWrap(const QString &text); + +/** + Returns the length that reflects the density of information in the text. In + general the character from CJK languages are assigned with weight 2, while + other Latin characters are assigned with 1. + + @since 5.41 +*/ +KCOREADDONS_EXPORT int logicalLength(const QString &text); + } #endif diff -Nru kcoreaddons-5.18.0/src/lib/text/ktexttohtml.cpp kcoreaddons-5.44.0a/src/lib/text/ktexttohtml.cpp --- kcoreaddons-5.18.0/src/lib/text/ktexttohtml.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/ktexttohtml.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -32,9 +32,9 @@ #include -#include +#include "kcoreaddons_debug.h" -static KTextToHTMLEmoticonsInterface *s_emoticonsInterface = 0; +static KTextToHTMLEmoticonsInterface *s_emoticonsInterface = nullptr; static void loadEmoticonsPlugin() { @@ -69,7 +69,7 @@ { } -KTextToHTMLEmoticonsInterface* KTextToHTMLHelper::emoticonsInterface() +KTextToHTMLEmoticonsInterface* KTextToHTMLHelper::emoticonsInterface() const { if (!s_emoticonsInterface) { loadEmoticonsPlugin(); @@ -109,7 +109,7 @@ // determine the domain part of the email address int dotPos = INT_MAX; int end = mPos + 1; - while (end < (int)mText.length() && + while (end < mText.length() && (mText[end].isLetterOrNumber() || mText[end] == QLatin1Char('@') || // allow @ to find invalid email addresses mText[end] == QLatin1Char('.') || @@ -143,7 +143,7 @@ return address; } -bool KTextToHTMLHelper::atUrl() +bool KTextToHTMLHelper::atUrl() const { // the following characters are allowed in a dot-atom (RFC 2822): // a-z A-Z 0-9 . ! # $ % & ' * + - / = ? ^ _ ` { | } ~ @@ -156,25 +156,24 @@ (allowedSpecialChars.indexOf(mText[mPos - 1]) != -1))) { return false; } - QChar ch = mText[mPos]; return - (ch == QLatin1Char('h') && (mText.mid(mPos, 7) == QLatin1String("http://") || - mText.mid(mPos, 8) == QLatin1String("https://"))) || - (ch == QLatin1Char('v') && mText.mid(mPos, 6) == QLatin1String("vnc://")) || - (ch == QLatin1Char('f') && (mText.mid(mPos, 7) == QLatin1String("fish://") || - mText.mid(mPos, 6) == QLatin1String("ftp://") || - mText.mid(mPos, 7) == QLatin1String("ftps://"))) || - (ch == QLatin1Char('s') && (mText.mid(mPos, 7) == QLatin1String("sftp://") || - mText.mid(mPos, 6) == QLatin1String("smb://"))) || - (ch == QLatin1Char('m') && mText.mid(mPos, 7) == QLatin1String("mailto:")) || - (ch == QLatin1Char('w') && mText.mid(mPos, 4) == QLatin1String("www.")) || - (ch == QLatin1Char('f') && (mText.mid(mPos, 4) == QLatin1String("ftp.") || - mText.mid(mPos, 7) == QLatin1String("file://"))) || - (ch == QLatin1Char('n') && mText.mid(mPos, 5) == QLatin1String("news:")); + (ch == QLatin1Char('h') && (mText.midRef(mPos, 7) == QLatin1String("http://") || + mText.midRef(mPos, 8) == QLatin1String("https://"))) || + (ch == QLatin1Char('v') && mText.midRef(mPos, 6) == QLatin1String("vnc://")) || + (ch == QLatin1Char('f') && (mText.midRef(mPos, 7) == QLatin1String("fish://") || + mText.midRef(mPos, 6) == QLatin1String("ftp://") || + mText.midRef(mPos, 7) == QLatin1String("ftps://"))) || + (ch == QLatin1Char('s') && (mText.midRef(mPos, 7) == QLatin1String("sftp://") || + mText.midRef(mPos, 6) == QLatin1String("smb://"))) || + (ch == QLatin1Char('m') && mText.midRef(mPos, 7) == QLatin1String("mailto:")) || + (ch == QLatin1Char('w') && mText.midRef(mPos, 4) == QLatin1String("www.")) || + (ch == QLatin1Char('f') && (mText.midRef(mPos, 4) == QLatin1String("ftp.") || + mText.midRef(mPos, 7) == QLatin1String("file://"))) || + (ch == QLatin1Char('n') && mText.midRef(mPos, 5) == QLatin1String("news:")); } -bool KTextToHTMLHelper::isEmptyUrl(const QString &url) +bool KTextToHTMLHelper::isEmptyUrl(const QString &url) const { return url.isEmpty() || url == QLatin1String("http://") || @@ -192,7 +191,7 @@ url == QLatin1String("news://"); } -QString KTextToHTMLHelper::getUrl() +QString KTextToHTMLHelper::getUrl(bool *badurl) { QString url; if (atUrl()) { @@ -228,11 +227,52 @@ url.reserve(mMaxUrlLen); // avoid allocs int start = mPos; - while ((mPos < (int)mText.length()) && + bool previousCharIsSpace = false; + bool previousCharIsADoubleQuote = false; + bool previousIsAnAnchor = false; + while ((mPos < mText.length()) && (mText[mPos].isPrint() || mText[mPos].isSpace()) && ((afterUrl.isNull() && !mText[mPos].isSpace()) || (!afterUrl.isNull() && mText[mPos] != afterUrl))) { - if (!mText[mPos].isSpace()) { // skip whitespace + if (!previousCharIsSpace && (mText[mPos] == QLatin1Char('<')) && ((mPos + 1) < mText.length())) { + // Fix Bug #346132: allow "http://www.foo.bar" + // < inside a URL is not allowed, however there is a test which + // checks that "http://some/path" should be allowed + // Therefore: check if what follows is another URL and if so, stop here + mPos++; + if (atUrl()) { + mPos--; + break; + } + mPos--; + } + if (mText[mPos].isSpace()) { + previousCharIsSpace = true; + } else if (!previousIsAnAnchor && mText[mPos] == QLatin1Char('[')) { + break; + } else if (!previousIsAnAnchor && mText[mPos] == QLatin1Char(']')) { + break; + } else { // skip whitespace + if (previousCharIsSpace && mText[mPos] == QLatin1Char('<')) { + url.append(QLatin1Char(' ')); + break; + } + previousCharIsSpace = false; + if (mText[mPos] == QLatin1Char('>') && previousCharIsADoubleQuote) { + //it's an invalid url + if (badurl) { + *badurl = true; + } + return QString(); + } + if (mText[mPos] == QLatin1Char('"')) { + previousCharIsADoubleQuote = true; + } else { + previousCharIsADoubleQuote = false; + } + if (mText[mPos] == QLatin1Char('#')) { + previousIsAnAnchor = true; + } url.append(mText[mPos]); if (url.length() > mMaxUrlLen) { break; @@ -255,8 +295,7 @@ // a dot to finish the sentence. That would lead the parser to include the dot in the url, // even though that is not wanted. So work around that here. // Most real-life URLs hopefully don't end with dots or commas. - QList wordBoundaries; - wordBoundaries << QLatin1Char('.') << QLatin1Char(',') << QLatin1Char(':') << QLatin1Char('!') << QLatin1Char('?') << QLatin1Char(')') << QLatin1Char('>'); + static const QString wordBoundaries = QStringLiteral(".,:!?)>"); if (url.length() > 1) { do { if (wordBoundaries.contains(url.at(url.length() - 1))) { @@ -267,7 +306,6 @@ } } while (url.length() > 1); } - return url; } @@ -308,7 +346,7 @@ } -QString KTextToHTMLHelper::pngToDataUrl(const QString &iconPath) +QString KTextToHTMLHelper::pngToDataUrl(const QString &iconPath) const { if (iconPath.isEmpty()) { return QString(); @@ -321,7 +359,7 @@ QByteArray ba = pngFile.readAll(); pngFile.close(); - return QString(QStringLiteral("data:image/png;base64,%1")).arg(QLatin1String(ba.toBase64().constData())); + return QStringLiteral("data:image/png;base64,%1").arg(QLatin1String(ba.toBase64().constData())); } @@ -330,12 +368,12 @@ KTextToHTMLHelper helper(plainText, maxUrlLen, maxAddressLen); QString str; - QString result((QChar *)0, (int)helper.mText.length() * 2); + QString result(static_cast(nullptr), helper.mText.length() * 2); QChar ch; int x; bool startOfLine = true; - for (helper.mPos = 0, x = 0; helper.mPos < (int)helper.mText.length(); + for (helper.mPos = 0, x = 0; helper.mPos < helper.mText.length(); ++helper.mPos, ++x) { ch = helper.mText[helper.mPos]; if (flags & PreserveSpaces) { @@ -401,7 +439,27 @@ } else { const int start = helper.mPos; if (!(flags & IgnoreUrls)) { - str = helper.getUrl(); + bool badUrl = false; + str = helper.getUrl(&badUrl); + if (badUrl) { + QString resultBadUrl; + const int helperTextSize(helper.mText.count()); + for (int i = 0; i < helperTextSize; ++i) { + const QChar chBadUrl = helper.mText[i]; + if (chBadUrl == QLatin1Char('&')) { + resultBadUrl += QLatin1String("&"); + } else if (chBadUrl == QLatin1Char('"')) { + resultBadUrl += QLatin1String("""); + } else if (chBadUrl == QLatin1Char('<')) { + resultBadUrl += QLatin1String("<"); + } else if (chBadUrl == QLatin1Char('>')) { + resultBadUrl += QLatin1String(">"); + } else { + resultBadUrl += chBadUrl; + } + } + return resultBadUrl; + } if (!str.isEmpty()) { QString hyperlink; if (str.left(4) == QLatin1String("www.")) { @@ -446,12 +504,12 @@ } if (flags & ReplaceSmileys) { - QStringList exclude; - exclude << QStringLiteral("(c)") << QStringLiteral("(C)") << QStringLiteral(">:-(") << QStringLiteral(">:(") << QStringLiteral("(B)") << QStringLiteral("(b)") << QStringLiteral("(P)") << QStringLiteral("(p)"); - exclude << QStringLiteral("(O)") << QStringLiteral("(o)") << QStringLiteral("(D)") << QStringLiteral("(d)") << QStringLiteral("(E)") << QStringLiteral("(e)") << QStringLiteral("(K)") << QStringLiteral("(k)"); - exclude << QStringLiteral("(I)") << QStringLiteral("(i)") << QStringLiteral("(L)") << QStringLiteral("(l)") << QStringLiteral("(8)") << QStringLiteral("(T)") << QStringLiteral("(t)") << QStringLiteral("(G)"); - exclude << QStringLiteral("(g)") << QStringLiteral("(F)") << QStringLiteral("(f)") << QStringLiteral("(H)"); - exclude << QStringLiteral("8)") << QStringLiteral("(N)") << QStringLiteral("(n)") << QStringLiteral("(Y)") << QStringLiteral("(y)") << QStringLiteral("(U)") << QStringLiteral("(u)") << QStringLiteral("(W)") << QStringLiteral("(w)"); + const QStringList exclude = { QStringLiteral("(c)"), QStringLiteral("(C)"), QStringLiteral(">:-("), QStringLiteral(">:("), QStringLiteral("(B)"), QStringLiteral("(b)"), QStringLiteral("(P)"), QStringLiteral("(p)") + , QStringLiteral("(O)"), QStringLiteral("(o)"), QStringLiteral("(D)"), QStringLiteral("(d)"), QStringLiteral("(E)"), QStringLiteral("(e)"), QStringLiteral("(K)"), QStringLiteral("(k)") + , QStringLiteral("(I)"), QStringLiteral("(i)"), QStringLiteral("(L)"), QStringLiteral("(l)"), QStringLiteral("(8)"), QStringLiteral("(T)"), QStringLiteral("(t)"), QStringLiteral("(G)") + , QStringLiteral("(g)"), QStringLiteral("(F)"), QStringLiteral("(f)"), QStringLiteral("(H)") + , QStringLiteral("8)"), QStringLiteral("(N)"), QStringLiteral("(n)"), QStringLiteral("(Y)"), QStringLiteral("(y)"), QStringLiteral("(U)"), QStringLiteral("(u)"), QStringLiteral("(W)"), QStringLiteral("(w)") + , QStringLiteral("(6)")}; result = helper.emoticonsInterface()->parseEmoticons(result, true, exclude); } diff -Nru kcoreaddons-5.18.0/src/lib/text/ktexttohtmlemoticonsinterface.h kcoreaddons-5.44.0a/src/lib/text/ktexttohtmlemoticonsinterface.h --- kcoreaddons-5.18.0/src/lib/text/ktexttohtmlemoticonsinterface.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/ktexttohtmlemoticonsinterface.h 2018-03-06 08:12:31.000000000 +0000 @@ -21,6 +21,7 @@ #define KTEXTTOHTMLEMOTICONSINTERFACE_H #include +#include /** * @internal @@ -30,7 +31,7 @@ { public: KTextToHTMLEmoticonsInterface() {} - virtual ~KTextToHTMLEmoticonsInterface() {} + virtual ~KTextToHTMLEmoticonsInterface() {} // KF6 TODO: de-inline (-Wweak-vtables) virtual QString parseEmoticons(const QString &text, bool strictParse = false, diff -Nru kcoreaddons-5.18.0/src/lib/text/ktexttohtml.h kcoreaddons-5.44.0a/src/lib/text/ktexttohtml.h --- kcoreaddons-5.18.0/src/lib/text/ktexttohtml.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/ktexttohtml.h 2018-03-06 08:12:31.000000000 +0000 @@ -69,7 +69,7 @@ * to HTML entities: & " < >. Newlines are also preserved. * * @param plainText The text to be converted into HTML. - * @param flags The flags to consider when processing @p plainText. + * @param options The options to use when processing @p plainText. * @param maxUrlLen The maximum length of permitted URLs. The reason for * this limit is that there may be possible security * implications in handling URLs of unlimited length. diff -Nru kcoreaddons-5.18.0/src/lib/text/ktexttohtml_p.h kcoreaddons-5.44.0a/src/lib/text/ktexttohtml_p.h --- kcoreaddons-5.18.0/src/lib/text/ktexttohtml_p.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/text/ktexttohtml_p.h 2018-03-06 08:12:31.000000000 +0000 @@ -44,13 +44,13 @@ public: KTextToHTMLHelper(const QString &plainText, int pos = 0, int maxUrlLen = 4096, int maxAddressLen = 255); - KTextToHTMLEmoticonsInterface *emoticonsInterface(); + KTextToHTMLEmoticonsInterface *emoticonsInterface() const; QString getEmailAddress(); - bool atUrl(); - bool isEmptyUrl(const QString &url); - QString getUrl(); - QString pngToDataUrl(const QString &pngPath); + bool atUrl() const; + bool isEmptyUrl(const QString &url) const; + QString getUrl(bool *badurl = nullptr); + QString pngToDataUrl(const QString &pngPath) const; QString highlightedText(); QString mText; diff -Nru kcoreaddons-5.18.0/src/lib/util/config-accountsservice.h.cmake kcoreaddons-5.44.0a/src/lib/util/config-accountsservice.h.cmake --- kcoreaddons-5.18.0/src/lib/util/config-accountsservice.h.cmake 1970-01-01 00:00:00.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/config-accountsservice.h.cmake 2018-03-06 08:12:31.000000000 +0000 @@ -0,0 +1 @@ +#define ACCOUNTS_SERVICE_ICON_DIR "${ACCOUNTS_SERVICE_ICON_DIR}" diff -Nru kcoreaddons-5.18.0/src/lib/util/kdelibs4configmigrator.cpp kcoreaddons-5.44.0a/src/lib/util/kdelibs4configmigrator.cpp --- kcoreaddons-5.18.0/src/lib/util/kdelibs4configmigrator.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kdelibs4configmigrator.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -25,10 +25,14 @@ #include #include #include -#include +#include #include -class Kdelibs4ConfigMigrator::Private +Q_DECLARE_LOGGING_CATEGORY(MIGRATOR) +// logging category for this framework, default: log stuff >= warning +Q_LOGGING_CATEGORY(MIGRATOR, "kf5.kcoreaddons.kdelibs4configmigrator", QtWarningMsg) + +class Q_DECL_HIDDEN Kdelibs4ConfigMigrator::Private { public: Private(const QString &_appName) @@ -70,9 +74,11 @@ return false; } + bool didSomething = false; + Q_FOREACH (const QString &configFileName, d->configFiles) { const QString newConfigLocation - = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + configFileName; if (QFile(newConfigLocation).exists()) { @@ -84,8 +90,10 @@ const QString oldConfigFile(migration.locateLocal("config", configFileName)); if (!oldConfigFile.isEmpty()) { - QFile(oldConfigFile).copy(newConfigLocation); - qDebug()<<"old config "<appName + QLatin1Char('/') + uiFileName)); if (!oldConfigFile.isEmpty()) { - QFile(oldConfigFile).copy(newConfigLocation); - qDebug()<<"old config "<reparseConfiguration() via the framework integration plugin - QPluginLoader lib(QStringLiteral("kf5/FrameworkIntegrationPlugin")); - QObject *rootObj = lib.instance(); - if (rootObj) { - QMetaObject::invokeMethod(rootObj, "reparseConfiguration"); + if (didSomething) { + QPluginLoader lib(QStringLiteral("kf5/FrameworkIntegrationPlugin")); + QObject *rootObj = lib.instance(); + if (rootObj) { + QMetaObject::invokeMethod(rootObj, "reparseConfiguration"); + } } + return true; } diff -Nru kcoreaddons-5.18.0/src/lib/util/kdelibs4configmigrator.h kcoreaddons-5.44.0a/src/lib/util/kdelibs4configmigrator.h --- kcoreaddons-5.18.0/src/lib/util/kdelibs4configmigrator.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kdelibs4configmigrator.h 2018-03-06 08:12:31.000000000 +0000 @@ -25,6 +25,8 @@ #include /** + * @class Kdelibs4ConfigMigrator kdelibs4configmigrator.h Kdelibs4ConfigMigrator + * * Kdelibs4ConfigMigrator migrates selected config files and ui files * from the kdelibs 4.x location ($KDEHOME, as used by KStandardDirs) * to the Qt 5.x location ($XDG_*_HOME, as used by QStandardPaths). diff -Nru kcoreaddons-5.18.0/src/lib/util/kdelibs4migration.cpp kcoreaddons-5.44.0a/src/lib/util/kdelibs4migration.cpp --- kcoreaddons-5.18.0/src/lib/util/kdelibs4migration.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kdelibs4migration.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -22,9 +22,13 @@ #include "kdelibs4migration.h" #include "config-kde4home.h" #include -#include +#include "kcoreaddons_debug.h" #include +#ifdef Q_OS_WIN +# include +#endif + class Kdelibs4MigrationPrivate { public: @@ -35,15 +39,22 @@ : d(new Kdelibs4MigrationPrivate) { if (qEnvironmentVariableIsSet("KDEHOME")) { - //qDebug() << "Using KDEHOME as the location of the old config file"; + //qCDebug(KCOREADDONS_DEBUG) << "Using KDEHOME as the location of the old config file"; d->m_kdeHome = QString::fromLocal8Bit(qgetenv("KDEHOME")); } else { QDir homeDir = QDir::home(); QVector testSubdirs; testSubdirs << QStringLiteral(KDE4_DEFAULT_HOME) << QStringLiteral(".kde4") << QStringLiteral(".kde"); +#ifdef Q_OS_WIN + WCHAR wPath[MAX_PATH + 1]; + if (SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, wPath) == S_OK) { + testSubdirs << QDir::fromNativeSeparators(QString::fromUtf16((const ushort *) wPath)) + + QLatin1String("/" KDE4_DEFAULT_HOME); + } +#endif Q_FOREACH (const QString &testSubdir, testSubdirs) { if (homeDir.exists(testSubdir)) { - //qDebug() << "Using" << testSubdir << "as the location of the old config file"; + //qCDebug(KCOREADDONS_DEBUG) << "Using" << testSubdir << "as the location of the old config file"; d->m_kdeHome = homeDir.filePath(testSubdir); break; } @@ -117,7 +128,7 @@ return dir; } } - qWarning() << "No such resource" << type; + qCWarning(KCOREADDONS_DEBUG) << "No such resource" << type; return QString(); } diff -Nru kcoreaddons-5.18.0/src/lib/util/kdelibs4migration.h kcoreaddons-5.44.0a/src/lib/util/kdelibs4migration.h --- kcoreaddons-5.18.0/src/lib/util/kdelibs4migration.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kdelibs4migration.h 2018-03-06 08:12:31.000000000 +0000 @@ -33,6 +33,8 @@ */ /** + * @class Kdelibs4Migration kdelibs4migration.h Kdelibs4Migration + * * Kdelibs4Migration provides support for locating config files * and application data files saved by kdelibs 4 in the user's home directory * ($KDEHOME, i.e. typically ~/.kde). diff -Nru kcoreaddons-5.18.0/src/lib/util/kformat.cpp kcoreaddons-5.44.0a/src/lib/util/kformat.cpp --- kcoreaddons-5.18.0/src/lib/util/kformat.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kformat.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -34,6 +34,12 @@ { } +KFormat& KFormat::operator=(const KFormat &other) +{ + d = other.d; + return *this; +} + KFormat::~KFormat() { } diff -Nru kcoreaddons-5.18.0/src/lib/util/kformat.h kcoreaddons-5.44.0a/src/lib/util/kformat.h --- kcoreaddons-5.18.0/src/lib/util/kformat.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kformat.h 2018-03-06 08:12:31.000000000 +0000 @@ -55,6 +55,8 @@ */ /** + * @class KFormat kformat.h KFormat + * * KFormat provides support for formatting numbers and datetimes in * formats that are not supported by QLocale. * @@ -145,7 +147,7 @@ FoldHours = 0x8 ///< Fold the hours into the minutes, e.g. 83:45 or 83m45s, overrides HideSeconds }; Q_DECLARE_FLAGS(DurationFormatOptions, DurationFormatOption) - Q_FLAGS(DurationFormatOption) + Q_FLAG(DurationFormatOption) /** * Constructs a KFormat. @@ -159,6 +161,8 @@ */ KFormat(const KFormat &other); + KFormat& operator=(const KFormat &other); + /** * Destructor */ @@ -180,7 +184,7 @@ * @param dialect binary unit standard to use. Use DefaultBinaryDialect to * use the localized user selection unless you need to use a specific * unit type (such as displaying a flash memory size in JEDEC). - * @param specificUnit specific unit size to use in result. Use + * @param units specific unit size to use in result. Use * DefaultBinaryUnits to automatically select a unit that will return * a sanely-sized number. * @return converted size as a translated string including the units. diff -Nru kcoreaddons-5.18.0/src/lib/util/kformatprivate.cpp kcoreaddons-5.44.0a/src/lib/util/kformatprivate.cpp --- kcoreaddons-5.18.0/src/lib/util/kformatprivate.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kformatprivate.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -60,7 +60,7 @@ // If a specific unit conversion is given, use it directly. Otherwise // search until the result is in [0, multiplier] (or out of our range). if (units == KFormat::DefaultBinaryUnits) { - while (qAbs(size) >= multiplier && unit < (int) KFormat::UnitYottaByte) { + while (qAbs(size) >= multiplier && unit < int(KFormat::UnitYottaByte)) { size /= multiplier; ++unit; } @@ -188,13 +188,19 @@ QString KFormatPrivate::formatDuration(quint64 msecs, KFormat::DurationFormatOptions options) const { quint64 ms = msecs; + if (options & KFormat::HideSeconds) { + //round to nearest minute + ms = qRound(ms / (qreal)MSecsInMinute) * MSecsInMinute ; + } else if (!(options & KFormat::ShowMilliseconds)) { + //round to nearest second + ms = qRound(ms / (qreal)MSecsInSecond) * MSecsInSecond ; + } + int hours = ms / MSecsInHour; ms = ms % MSecsInHour; int minutes = ms / MSecsInMinute; - int roundMinutes = qRound(ms / 60000.0); ms = ms % MSecsInMinute; int seconds = ms / MSecsInSecond; - int roundSeconds = qRound(ms / 1000.0); ms = ms % MSecsInSecond; if ((options & KFormat::InitialDuration) == KFormat::InitialDuration) { @@ -208,11 +214,11 @@ } else if ((options & KFormat::FoldHours) == KFormat::FoldHours) { //: @item:intext Duration format minutes and seconds return tr("%1m%2s").arg(hours * 60 + minutes, 1, 10, QLatin1Char('0')) - .arg(roundSeconds, 2, 10, QLatin1Char('0')); + .arg(seconds, 2, 10, QLatin1Char('0')); } else if ((options & KFormat::HideSeconds) == KFormat::HideSeconds) { //: @item:intext Duration format hours and minutes return tr("%1h%2m").arg(hours, 1, 10, QLatin1Char('0')) - .arg(roundMinutes, 2, 10, QLatin1Char('0')); + .arg(minutes, 2, 10, QLatin1Char('0')); } else if ((options & KFormat::ShowMilliseconds) == KFormat::ShowMilliseconds) { //: @item:intext Duration format hours, minutes, seconds, milliseconds return tr("%1h%2m%3.%4s").arg(hours, 1, 10, QLatin1Char('0')) @@ -223,7 +229,7 @@ //: @item:intext Duration format hours, minutes, seconds return tr("%1h%2m%3s").arg(hours, 1, 10, QLatin1Char('0')) .arg(minutes, 2, 10, QLatin1Char('0')) - .arg(roundSeconds, 2, 10, QLatin1Char('0')); + .arg(seconds, 2, 10, QLatin1Char('0')); } } else { @@ -237,11 +243,11 @@ } else if ((options & KFormat::FoldHours) == KFormat::FoldHours) { //: @item:intext Duration format minutes and seconds return tr("%1:%2").arg(hours * 60 + minutes, 1, 10, QLatin1Char('0')) - .arg(roundSeconds, 2, 10, QLatin1Char('0')); + .arg(seconds, 2, 10, QLatin1Char('0')); } else if ((options & KFormat::HideSeconds) == KFormat::HideSeconds) { //: @item:intext Duration format hours and minutes return tr("%1:%2").arg(hours, 1, 10, QLatin1Char('0')) - .arg(roundMinutes, 2, 10, QLatin1Char('0')); + .arg(minutes, 2, 10, QLatin1Char('0')); } else if ((options & KFormat::ShowMilliseconds) == KFormat::ShowMilliseconds) { //: @item:intext Duration format hours, minutes, seconds, milliseconds return tr("%1:%2:%3.%4").arg(hours, 1, 10, QLatin1Char('0')) @@ -252,13 +258,12 @@ //: @item:intext Duration format hours, minutes, seconds return tr("%1:%2:%3").arg(hours, 1, 10, QLatin1Char('0')) .arg(minutes, 2, 10, QLatin1Char('0')) - .arg(roundSeconds, 2, 10, QLatin1Char('0')); + .arg(seconds, 2, 10, QLatin1Char('0')); } } - // Should never reach here - Q_ASSERT(false); + Q_UNREACHABLE(); return QString(); } @@ -280,7 +285,7 @@ //: @item:intext %1 is a whole number //~ singular %n millisecond //~ plural %n milliseconds - return tr("%n millisecond(s)", 0, msecs); + return tr("%n millisecond(s)", nullptr, msecs); } enum DurationUnits { @@ -298,22 +303,22 @@ //: @item:intext %n is a whole number //~ singular %n day //~ plural %n days - return KFormatPrivate::tr("%n day(s)", 0, n); + return KFormatPrivate::tr("%n day(s)", nullptr, n); case Hours: //: @item:intext %n is a whole number //~ singular %n hour //~ plural %n hours - return KFormatPrivate::tr("%n hour(s)", 0, n); + return KFormatPrivate::tr("%n hour(s)", nullptr, n); case Minutes: //: @item:intext %n is a whole number //~ singular %n minute //~ plural %n minutes - return KFormatPrivate::tr("%n minute(s)", 0, n); + return KFormatPrivate::tr("%n minute(s)", nullptr, n); case Seconds: //: @item:intext %n is a whole number //~ singular %n second //~ plural %n seconds - return KFormatPrivate::tr("%n second(s)", 0, n); + return KFormatPrivate::tr("%n second(s)", nullptr, n); } Q_ASSERT(false); return QString(); @@ -363,7 +368,11 @@ QString KFormatPrivate::formatRelativeDate(const QDate &date, QLocale::FormatType format) const { - int daysTo = QDate::currentDate().daysTo(date); + if (!date.isValid()) { + return tr("Invalid date", "used when a relative date string can't be generated because the date is invalid"); + } + + const int daysTo = QDate::currentDate().daysTo(date); if (daysTo > 7 || daysTo < -7) { return m_locale.toString(date, format); } @@ -377,19 +386,42 @@ return tr("Yesterday"); } - if (daysTo < -1) - /*: a day of the week, eg "Monday" (but translated). Refers to the most recent such day that - has already happened. */ - { - return tr("Last %1").arg(m_locale.dayName(date.dayOfWeek(), format)); - } else if (daysTo > 1) - /*: a day of the week, eg "Monday" (but translated). Refers to the soonest such day that - has not already happened. */ - { - return tr("Next %1").arg(m_locale.dayName(date.dayOfWeek(), format)); + if (daysTo < -1) { + switch (date.dayOfWeek()) { + case 1: + return tr("Last Monday", "most recent such day before today"); + case 2: + return tr("Last Tuesday", "most recent such day before today"); + case 3: + return tr("Last Wednesday", "most recent such day before today"); + case 4: + return tr("Last Thursday", "most recent such day before today"); + case 5: + return tr("Last Friday", "most recent such day before today"); + case 6: + return tr("Last Saturday", "most recent such day before today"); + case 7: + return tr("Last Sunday", "most recent such day before today"); + } + } else if (daysTo > 1) { + switch (date.dayOfWeek()) { + case 1: + return tr("Next Monday", "the next such day after today"); + case 2: + return tr("Next Tuesday", "the next such day after today"); + case 3: + return tr("Next Wednesday", "the next such day after today"); + case 4: + return tr("Next Thursday", "the next such day after today"); + case 5: + return tr("Next Friday", "the next such day after today"); + case 6: + return tr("Next Saturday", "the next such day after today"); + case 7: + return tr("Next Sunday", "the next such day after today"); + } } - - return m_locale.toString(date, format); + Q_UNREACHABLE(); } QString KFormatPrivate::formatRelativeDateTime(const QDateTime &dateTime, QLocale::FormatType format) const diff -Nru kcoreaddons-5.18.0/src/lib/util/kshell.cpp kcoreaddons-5.44.0a/src/lib/util/kshell.cpp --- kcoreaddons-5.18.0/src/lib/util/kshell.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kshell.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -20,14 +20,12 @@ */ #include "kshell.h" +#include "kshell_p.h" #include "kuser.h" #include -namespace KShell -{ - -QString homeDir(const QString &user) +QString KShell::homeDir(const QString &user) { if (user.isEmpty()) { return QDir::homePath(); @@ -35,8 +33,6 @@ return KUser(user).homeDir(); } -} - QString KShell::joinArgs(const QStringList &args) { QString ret; diff -Nru kcoreaddons-5.18.0/src/lib/util/kshell.h kcoreaddons-5.44.0a/src/lib/util/kshell.h --- kcoreaddons-5.18.0/src/lib/util/kshell.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kshell.h 2018-03-06 08:12:31.000000000 +0000 @@ -144,7 +144,7 @@ * target, see \ref Errors * @return a list of unquoted words or an empty list if an error occurred */ -KCOREADDONS_EXPORT QStringList splitArgs(const QString &cmd, Options flags = NoOptions, Errors *err = 0); +KCOREADDONS_EXPORT QStringList splitArgs(const QString &cmd, Options flags = NoOptions, Errors *err = nullptr); /** * Quotes and joins @p args together according to system shell rules. diff -Nru kcoreaddons-5.18.0/src/lib/util/kshell_unix.cpp kcoreaddons-5.44.0a/src/lib/util/kshell_unix.cpp --- kcoreaddons-5.18.0/src/lib/util/kshell_unix.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kshell_unix.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -152,7 +152,7 @@ } c = args.unicode()[pos++]; } while (c != QLatin1Char('\'')); - cret += args.mid(spos, pos - spos - 1); + cret += args.midRef(spos, pos - spos - 1); } else if (c == QLatin1Char('"')) { for (;;) { if (pos >= args.length()) { diff -Nru kcoreaddons-5.18.0/src/lib/util/kuser.h kcoreaddons-5.44.0a/src/lib/util/kuser.h --- kcoreaddons-5.18.0/src/lib/util/kuser.h 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kuser.h 2018-03-06 08:12:31.000000000 +0000 @@ -45,6 +45,12 @@ struct group; #endif +// The following is to avoid compile errors using msvc, and it is done +// using a common #define to avoid helpful people accidentally cleaning this +// not quite pretty thing and breaking it for people on windows. +// See https://git.reviewboard.kde.org/r/127598/ for details +#define KCOREADDONS_UINT_MAX (std::numeric_limits::max)() + /** A platform independent user or group ID. * * @@ -368,13 +374,13 @@ * @param maxCount the maximum number of groups to return * @return all groups of the user */ - QList groups(uint maxCount = std::numeric_limits::max()) const; + QList groups(uint maxCount = KCOREADDONS_UINT_MAX) const; /** * @param maxCount the maximum number of groups to return * @return all group names of the user */ - QStringList groupNames(uint maxCount = std::numeric_limits::max()) const; + QStringList groupNames(uint maxCount = KCOREADDONS_UINT_MAX) const; enum UserProperty { FullName, RoomNumber, WorkPhone, HomePhone }; @@ -397,13 +403,13 @@ * @param maxCount the maximum number of users to return * @return all users of the system. */ - static QList allUsers(uint maxCount = std::numeric_limits::max()); + static QList allUsers(uint maxCount = KCOREADDONS_UINT_MAX); /** * @param maxCount the maximum number of users to return * @return all user names of the system. */ - static QStringList allUserNames(uint maxCount = std::numeric_limits::max()); + static QStringList allUserNames(uint maxCount = KCOREADDONS_UINT_MAX); private: class Private; @@ -536,13 +542,13 @@ * @param maxCount the maximum number of users to return * @return a list of all users of the group */ - QList users(uint maxCount = std::numeric_limits::max()) const; + QList users(uint maxCount = KCOREADDONS_UINT_MAX) const; /** * @param maxCount the maximum number of groups to return * @return a list of all user login names of the group */ - QStringList userNames(uint maxCount = std::numeric_limits::max()) const; + QStringList userNames(uint maxCount = KCOREADDONS_UINT_MAX) const; /** * Destructor. @@ -553,13 +559,13 @@ * @param maxCount the maximum number of groups to return * @return a list of all groups on this system */ - static QList allGroups(uint maxCount = std::numeric_limits::max()); + static QList allGroups(uint maxCount = KCOREADDONS_UINT_MAX); /** * @param maxCount the maximum number of groups to return * @return a list of all group names on this system */ - static QStringList allGroupNames(uint maxCount = std::numeric_limits::max()); + static QStringList allGroupNames(uint maxCount = KCOREADDONS_UINT_MAX); private: class Private; diff -Nru kcoreaddons-5.18.0/src/lib/util/kuser_unix.cpp kcoreaddons-5.44.0a/src/lib/util/kuser_unix.cpp --- kcoreaddons-5.18.0/src/lib/util/kuser_unix.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kuser_unix.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -21,6 +21,7 @@ #include "kuser.h" #include "config-getgrouplist.h" +#include "config-accountsservice.h" #include #include @@ -34,7 +35,16 @@ #include // std::find #include // std::function -class KUser::Private : public QSharedData +#if defined(__BIONIC__) +static inline struct passwd * getpwent() { return nullptr; } +inline void setpwent() { } +static inline void setgrent() { } +static inline struct group * getgrent() { return nullptr; } +inline void endpwent() { } +static inline void endgrent() { } +#endif + +class Q_DECL_HIDDEN KUser::Private : public QSharedData { public: uid_t uid; @@ -46,7 +56,7 @@ Private() : uid(uid_t(-1)), gid(gid_t(-1)) {} Private(const char *name) : uid(uid_t(-1)), gid(gid_t(-1)) { - fillPasswd(name ? ::getpwnam(name) : 0); + fillPasswd(name ? ::getpwnam(name) : nullptr); } Private(const passwd *p) : uid(uid_t(-1)), gid(gid_t(-1)) { @@ -56,7 +66,11 @@ void fillPasswd(const passwd *p) { if (p) { +#ifndef __BIONIC__ QString gecos = QString::fromLocal8Bit(p->pw_gecos); +#else + QString gecos = QString(); +#endif QStringList gecosList = gecos.split(QLatin1Char(',')); // fill up the list, should be at least 4 entries while (gecosList.size() < 4) { @@ -170,7 +184,16 @@ QString KUser::faceIconPath() const { - QString pathToFaceIcon(homeDir() + QDir::separator() + QStringLiteral(".face.icon")); + QString pathToFaceIcon; + if (!d->loginName.isEmpty()) { + pathToFaceIcon = QStringLiteral(ACCOUNTS_SERVICE_ICON_DIR) + QLatin1Char('/') + d->loginName; + } + + if (QFile::exists(pathToFaceIcon)) { + return pathToFaceIcon; + } + + pathToFaceIcon = QString(homeDir() + QLatin1Char('/') + QStringLiteral(".face.icon")); if (QFile::exists(pathToFaceIcon)) { return pathToFaceIcon; @@ -313,7 +336,7 @@ { } -class KUserGroup::Private : public QSharedData +class Q_DECL_HIDDEN KUserGroup::Private : public QSharedData { public: gid_t gid; @@ -322,7 +345,7 @@ Private() : gid(gid_t(-1)) {} Private(const char *_name) : gid(gid_t(-1)) { - fillGroup(_name ? ::getgrnam(_name) : 0); + fillGroup(_name ? ::getgrnam(_name) : nullptr); } Private(const ::group *p) : gid(gid_t(-1)) { @@ -399,7 +422,7 @@ return d->name; } -void listGroupMembers(gid_t gid, uint maxCount, std::function handleNextGroupUser) +static void listGroupMembers(gid_t gid, uint maxCount, std::function handleNextGroupUser) { if (maxCount == 0) { return; @@ -410,7 +433,7 @@ } uint found = 0; QVarLengthArray addedUsers; - struct passwd *p = 0; + struct passwd *p = nullptr; for (char **user = g->gr_mem; *user; user++) { if ((p = getpwnam(*user))) { addedUsers.append(p->pw_uid); diff -Nru kcoreaddons-5.18.0/src/lib/util/kuser_win.cpp kcoreaddons-5.44.0a/src/lib/util/kuser_win.cpp --- kcoreaddons-5.18.0/src/lib/util/kuser_win.cpp 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/lib/util/kuser_win.cpp 2018-03-06 08:12:31.000000000 +0000 @@ -21,7 +21,7 @@ #include "kuser.h" -#include +#include "kcoreaddons_debug.h" #include #include @@ -156,7 +156,7 @@ NET_API_STATUS ret = NetUserGetGroups(nullptr, nameStr, level, buffer, MAX_PREFERRED_LENGTH, count, total); // if we return ERROR_MORE_DATA here it will result in an enless loop if (ret == ERROR_MORE_DATA) { - qWarning() << "NetUserGetGroups for user" << name << "returned ERROR_MORE_DATA. This should not happen!"; + qCWarning(KCOREADDONS_DEBUG) << "NetUserGetGroups for user" << name << "returned ERROR_MORE_DATA. This should not happen!"; ret = NERR_Success; } return ret; @@ -172,7 +172,7 @@ }); } -class KUser::Private : public QSharedData +class Q_DECL_HIDDEN KUser::Private : public QSharedData { typedef QExplicitlySharedDataPointer Ptr; Private() : isAdmin(false) {} @@ -226,13 +226,13 @@ WCHAR domainBuffer[UNLEN + 1]; SID_NAME_USE use; if (!LookupAccountSidW(nullptr, uid.nativeId(), nameBuffer, &nameBufferLen, domainBuffer, &domainBufferLen, &use)) { - qWarning() << "Could not lookup user " << uid.toString() << "error =" << GetLastError(); + qCWarning(KCOREADDONS_DEBUG) << "Could not lookup user " << uid.toString() << "error =" << GetLastError(); return sharedNull; } QString loginName = QString::fromWCharArray(nameBuffer); QString domainName = QString::fromWCharArray(domainBuffer); if (use != SidTypeUser && use != SidTypeDeletedAccount) { - qWarning().nospace() + qCWarning(KCOREADDONS_DEBUG).nospace() << "SID for " << domainName << "\\" << loginName << " (" << uid.toString() << ") is not of type user (" << SidTypeUser << " or " << SidTypeDeletedAccount << "). Got type " << use << " instead."; @@ -273,7 +273,7 @@ homeDir = QString::fromWCharArray(userInfo11->usri11_home_dir); isAdmin = userInfo11->usri11_priv == USER_PRIV_ADMIN; } else { - qWarning().nospace() << "Could not get information for user " << domainName << "\\" << loginName + qCWarning(KCOREADDONS_DEBUG).nospace() << "Could not get information for user " << domainName << "\\" << loginName << ": error code = " << status; return sharedNull; } @@ -486,7 +486,7 @@ { } -class KUserGroup::Private : public QSharedData +class Q_DECL_HIDDEN KUserGroup::Private : public QSharedData { public: QString name; @@ -501,7 +501,7 @@ // must always be freed, even on error ScopedNetApiBuffer groupInfo((GROUP_INFO_0 *)groupInfoTmp); if (status != NERR_Success) { - qWarning() << "Failed to find group with name" << name << "error =" << status; + qCWarning(KCOREADDONS_DEBUG) << "Failed to find group with name" << name << "error =" << status; groupInfo.reset(); } if (!id.isValid()) { @@ -537,7 +537,7 @@ if (eUse == SidTypeGroup || eUse == SidTypeWellKnownGroup) { name = QString::fromWCharArray(buffer); } else { - qWarning() << QString::fromWCharArray(buffer) << "is not a group, SID type is" << eUse; + qCWarning(KCOREADDONS_DEBUG) << QString::fromWCharArray(buffer) << "is not a group, SID type is" << eUse; } } return name; @@ -814,7 +814,7 @@ SID_NAME_USE sidType; bool ok = LookupAccountNameW(nullptr, (LPCWSTR)name.utf16(), buffer, &sidLength, domainBuffer, &domainBufferSize, &sidType); if (!ok) { - qWarning() << "Failed to lookup account" << name << "error code =" << GetLastError(); + qCWarning(KCOREADDONS_DEBUG) << "Failed to lookup account" << name << "error code =" << GetLastError(); return T(); } return callback(buffer, sidType); @@ -825,7 +825,7 @@ return sidFromName(name, [&](PSID sid, SID_NAME_USE sidType) -> KUserId { if (sidType != SidTypeUser && sidType != SidTypeDeletedAccount) { - qWarning().nospace() << "Failed to lookup user name " << name + qCWarning(KCOREADDONS_DEBUG).nospace() << "Failed to lookup user name " << name << ": resulting SID " << sidToString(sid) << " is not a user." " Got SID type " << sidType << " instead."; return KUserId(); @@ -839,7 +839,7 @@ return sidFromName(name, [&](PSID sid, SID_NAME_USE sidType) -> KGroupId { if (sidType != SidTypeGroup && sidType != SidTypeWellKnownGroup) { - qWarning().nospace() << "Failed to lookup user name " << name + qCWarning(KCOREADDONS_DEBUG).nospace() << "Failed to lookup user name " << name << ": resulting SID " << sidToString(sid) << " is not a group." " Got SID type " << sidType << " instead."; return KGroupId(); @@ -853,7 +853,7 @@ HANDLE _token; if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &_token)) { qWarning("Failed to get the token for the current process: %d", (int)GetLastError()); - return false; + return nullptr; } ScopedHANDLE token(_token, handleCloser); // query required size diff -Nru kcoreaddons-5.18.0/src/mimetypes/CMakeLists.txt kcoreaddons-5.44.0a/src/mimetypes/CMakeLists.txt --- kcoreaddons-5.18.0/src/mimetypes/CMakeLists.txt 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/mimetypes/CMakeLists.txt 2018-03-06 08:12:31.000000000 +0000 @@ -1,8 +1,8 @@ # always install the mime-types install(FILES kde5.xml DESTINATION ${KDE_INSTALL_MIMEDIR}) -# for KDE frameworks 5 we require at least version 0.70 -find_package(SharedMimeInfo 0.70) +# for KDE frameworks 5 we require at least version 1.3 +find_package(SharedMimeInfo 1.3) set_package_properties(SharedMimeInfo PROPERTIES TYPE OPTIONAL PURPOSE "Allows KDE applications to determine file types" diff -Nru kcoreaddons-5.18.0/src/mimetypes/kde5.xml kcoreaddons-5.44.0a/src/mimetypes/kde5.xml --- kcoreaddons-5.18.0/src/mimetypes/kde5.xml 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/src/mimetypes/kde5.xml 2018-03-06 08:12:31.000000000 +0000 @@ -21,65 +21,6 @@ in s-m-i means that someone receiving such a file by email or from a website will at least get a description of what it is, even without kcoreaddons installed.--> - - - Metalink download - تنزيل Metalink - Descarga d'enllaz meta - metalink preuzimanje - Baixada de «Metalink» - Baixada de «Metalink» - Stahování Metalink - Metalink-download - Metalink-Download - Λήψη Metalink - Metalink download - Descarga Metalink - Metalinki allalaadimine - Metalik deskarga - Metalink-lataus - Téléchargement par méta-liens - Íosluchtú Metalink - luchdadh a-nuas meata-cheangail - Descarga de Metalink - Metalink preuzimanje - Metalinkletöltés - Discargamento de Metalink - Metalink niðurhal - scaricamento Metalink - Metalink ダウンロード - Метасілтеме - ទាញយក​តំណ​មេតា - Metalink 다운로드 - Metalink atsiuntimas - Metalink lejupielāde - മെറ്റാ-കണ്ണി ഡൌണ്‍ലോഡ് - मेटालिंक डाउनलोड - Metalink nedlasting - Metalink-Daalladen - Download van metalink - Metalink-nedlasting - ਮੇਟਾਲਿੰਕ ਡਾਊਨਲੋਡ - Pobieranie Metalink - Transferência do Metalink - Transferência do Metalink - Descărcare Metalink - метассылка - Metalink-viežžan - Sťahovanie Metalink - Prejem Metalink - металинк преузимање - металинк преузимање - metalink preuzimanje - metalink preuzimanje - Metalink-nerladdning - Metalink indirmesi - Metalink چۈشۈرۈش - метапосилання отримання - Metalink 下载 - Metalink 下載 - - RELAX NG @@ -105,6 +46,7 @@ RELAX NG RELAX NG RELAX NG + RELAX NG RELAX NG RELAX NG RELAX NG @@ -144,7 +86,7 @@ CD audio صوت CD - CD d'audiu + Audiu CD CD audio CD àudio CD àudio @@ -164,6 +106,7 @@ CD audio CD-hang Audio CD + Audio CD CD hljóð audio CD CD オーディオ @@ -205,7 +148,7 @@ SNF bitmap font خط SNF bitmap - Fonte mapa de bits SNF + Fonte de mapa de bits SNF SNF bitmapski font Tipus de lletra de mapa de bits SNF Tipus de lletra de mapa de bits SNF @@ -225,6 +168,7 @@ SNF bitmap pismo SNF-betűtípus font de bitmap SNF + Fonta bitmap SNF SNF bitamyndaletur carattere bitmap SNF SNF ビットマップフォント @@ -266,7 +210,7 @@ Java applet بريمج جافا - Applet Java + Applet de Java Аплет на Java JAVA aplet Miniaplicació Java @@ -283,10 +227,11 @@ Applet Java Feidhmchláirín Java aplaid Java - Applet de Java + Miniaplicativo de Java Java applet Java-kisalkalmazás Applet Java + Applet Java Java forritlingur applet Java Java アプレット @@ -346,6 +291,7 @@ KHTML adapter proširenja KHTML-es kiterjesztéskezelő Adaptator pro KHTML Extension + Adaptor Ekstensi KHTML Aðlögun KHTML-endinga adattatore di estensioni di KHTML KHTML エクステンションアダプタ @@ -383,7 +329,7 @@ KDE color scheme مخطط ألوان كدي - Esquema de color KDE + Esquema de color de KDE Цветова схема за KDE KDE šema boja Esquema de color del KDE @@ -404,6 +350,7 @@ KDE-ova paleta boja KDE-színséma Schema de color KDE + Skema warna KDE KDE litastef schema di colori di KDE KDE 色スキーム @@ -466,6 +413,7 @@ KNewStuff paket KNewStuff-csomag KNewStuff: Pacchetto + Paket KNewStuff KNewStuff pakki pacchetto di KNewStuff KNewStuff パッケージ @@ -526,6 +474,7 @@ KWallet lisnica KWallet-jelszófájl Kwallet :portafolio + Wallet KWallet KWallet veski Portafogli di KDE KWallet ウォレット @@ -568,7 +517,7 @@ Kugar report template قالب تقرير Kugar - Plantía d'informe Kugar + Plantía d'informes de Kugar Kugarov šablon izvještaja Plantilla d'informe del Kugar Plantilla d'informe del Kugar @@ -588,6 +537,7 @@ Kugar predložak izvještaja Kugar-jelentéssablon Kugar : patrono de reporto + Template laporan Kugar Kugar skýrslugerðarforsnið modello di rapporto di Kugar Kugar レポートテンプレート @@ -624,124 +574,6 @@ Kugar 報告樣本 - - mime encapsulated web archive - نوع ملفات يغلف أرشف ويب - archivu web encapsuláu mime - MIME učaurena veb arhiva - Arxiu web encapsulat en MIME - Arxiu web encapsulat en MIME - web archív zapouzdřený v MIME - MIME-indkapslet webarkiv - MIME-ummanteltes Web-Archiv - εσωκλειόμενο μήνυμα mime αρχειοθήκης ιστοσελίδας - mime encapsulated web archive - archivo web encapsulado mime - MIME kapselduses veebiarhiiv - mime kaptsulatutako web artxiboa - MIME-kapseloitu web-arkisto - Archive Web encapsulée MIME - cartlann Ghréasáin cuachta mar MIME - tasglann-lìn capslaichte mime - arquivo web mime encapsulado - mime enkapsulirana mrežna arhiva - MIME formátumú webes archívum - mime : archivo web encapsulate - MIME-formað vefskráasafn - archivio Web incapsulato in MIME - mime カプセル化された web アーカイブ - MIME инкапсуляцияланған веб-архиві - ប័ណ្ណសារ​បណ្ដាញ​​ដែល​បាន​ស្រោប​របស់ mime - MIME 캡슐화된 웹 압축 파일 - į mime įdėtas žiniatinklio archyvas - mime iekapsilēts tīmekļa arhīvs - സംക്ഷേപിച്ച മൈം വെബ് ശേഖരം - mime असलेला वेब संग्रह - mime-innkapslet nettarkiv - MIME-inkapselt Nettarchiev - mime-ingekapseld webarchief - MIME-innkapsla vevarkiv - archiwum WWW w kodowaniu MIME - pacote Web encapsulado em MIME - Arquivo web encapsulado em MIME - arhivă web încapsulată mime - веб-архив - web archív zapuzdrený v MIME - spletni arhiv vložen po MIME - МИМЕ учаурена веб архива - МИМЕ учаурена веб архива - MIME učaurena veb arhiva - MIME učaurena veb arhiva - MIME-inkapslat webbarkiv - kapsüllenmiş web arşivi - كاپسۇللانغان mime تور بەت ئارخىپى - інкапсульований вебархів MIME - 封装 MIME 的网页归档 - MIME 封裝網頁歸檔 - - - - - NewzBin usenet index - فهرس يوزنت NewzBin - Índiz usenet de NewzBin - NewzBinov indeks Useneta - Índex usenet NewzBin - Índex usenet NewzBin - Index NewzBin usenet - NewzBin usenet-indeks - NewzBin-Usenet-Index - Ευρετήριο νέων NewzBin - NewzBin usenet index - Índice usenet de NewzBin - NewzBini useneti indeks - NewzBin usenet indizea - NewzBin-keskusteluryhmäindeksi - Index Usenet de NewzBin - Innéacs usenet NewzBin - clàr-innse usenet NewzBin - Índice da usenet de NewsBin - NewzBin usenet indeks - NewzBin Usenet-index - Indice usenet de NewzBiz - NewzBin usenet yfirlit - indice Usenet di NewzBin - NewzBin usenet インデックス - NewzBin usenet индексі - លិបិក្រម​​បណ្ដាញ​ប្រើ​របស់ NewzBin - NewzBin 유즈넷 인덱스 - NewzBin usenet indeksas - NewzBin usenet indekss - ന്യൂസ്ബിന്‍ യൂസ്നെറ്റ് സൂചിക - न्युझबिन युजनेट अनुक्रमणिका - NewzBin usenet index - NewzBin-Usenet-Index - NewzBin-usenet-index - NewzBin-temagruppeindeks - Indeks grup dyskusyjnych NewzBin - Índice de notícias do NewzBin - Índice de notícias do NewzBin - index usenet NewzBin - индекс Usenet для NewzBin - NewzBin usenetindeaksa - NewzBin usenet index - Kazalo novičarskih skupin NewzBin - Њузбинов индекс јузнета - Њузбинов индекс јузнета - NewzBinov indeks Useneta - NewzBinov indeks Useneta - Newzbin-diskussionsgruppindex - NewzBin usenet dizini - NewzBin usenet ئىندېكس - покажчик usenet NewzBin - NewzBin usenet 索引 - NewzBin usenet 索引 - - - - - - plasmoid @@ -766,6 +598,7 @@ plasmoid plazmoid plasmoid + plasmoid plasmíð plasmoide plasmoid @@ -807,7 +640,7 @@ SuperKaramba theme سمة SuperKaramba - Tema SuperKaramba + Tema de SuperKaramba Тема за SuperKaramba superkaramba tema Tema del SuperKaramba @@ -828,6 +661,7 @@ tema za SuperKarambu SuperKaramba-téma Thema de SuperKaramba + Tema SuperKaramba SuperKaramba þema tema di SuperKaramba SuperKaramba テーマ @@ -867,7 +701,6 @@ Calligra Plan project management document وثيقة إدارة مشاريع Calligra Plan - Documentu de xestión de proyeutu Calligra Plan Calligra Plan dokument upravljanja projektima Document per a la gestió de projectes del Calligra Plan Document per a la gestió de projectes del Calligra Plan @@ -886,6 +719,7 @@ Calligra Plan, dokument za upravljanje projektom Calligra Plan projektkezelő dokumentum Calligra Plan: Documento de gestion de projecto + Dokumen pengelolaan proyek Calligra Plan Calligra Plan verkstjórnunarskjal documento di gestione dei progetti di Calligra Plan Calligra Plan プロジェクト管理文書 @@ -924,7 +758,6 @@ Calligra Plan work package document وثيقة حزمة عمل Calligra Plan - Documentu de paquete de trabayu Calligra Plan Calligra Plan dokument radnog paketa Document de paquet de treball del Calligra Plan Document de paquet de treball del Calligra Plan @@ -943,6 +776,7 @@ Calligra Plan, dokument za radni paket Calligra Plan munkacsomag dokumentum Documento de pacchetto de labor de Calligra Plan + Dokumen pemaketan kerja Calligra Plan Calligra Plan verkpakkaskjal documento dei pacchetti di lavoro di Calligra Plan Calligra Plan жұмыс дестесі @@ -979,7 +813,7 @@ KPlato project management document وثيقة إدارة مشاريع KPlato - Documentu de xestión de proyeutu KPlato + Documentu de xestión de proyeutos de KPlato KPlatoov dokument upravljanja projektom Document per a la gestió de projectes del KPlato Document per a la gestió de projectes del KPlato @@ -999,6 +833,7 @@ KPlato dokument upravljanja projektom KPlato projektkezelő dokumentum KPlato: Documento de gestion de projecto + Dokumen pengelolaan proyek KPlato KPlato verkstjórnunarskjal documento di gestione dei progetti di KPlato KPlato プロジェクト管理文書 @@ -1037,7 +872,7 @@ KPlato project management work package حزمة عمل إدارة مشاريع KPlato - Paquete de trabayu de xestión de proyeutu KPlato + Paquete de trabayu de xestión de proyeutos de KPlato KPlatoov radni paket upravljanja projektom Paquet de treball per a la gestió de projectes del KPlato Paquet de treball per a la gestió de projectes del KPlato @@ -1057,6 +892,7 @@ KPlato radni paket upravljanja projektom KPlato projektkezelő munkacsomag KPlato: Pacchetto de travalio de gestion de projecto + Paket kerja pengelolaan proyek KPlato KPlato verkstjórnunar vinnupakki pacchetto di lavoro di gestione dei progetti di KPlato KPlato プロジェクト管理作業パッケージ @@ -1115,6 +951,7 @@ Kugar arhiva Kugar-archívum Kugar : archivo + Arsip Kugar Kugar safnskrá archivio di Kugar Kugar アーカイブ @@ -1175,6 +1012,7 @@ web arhiva webes archívum archivo web + arsip web vefsafnskrá archivio Web ウェブアーカイブ @@ -1215,7 +1053,7 @@ W3C XML schema مخطط W3C XML - Esquema XML W3C + Esquema XML de W3C W3C‑ova XML šema Esquema XML de la W3C Esquema XML de la W3C @@ -1235,6 +1073,7 @@ W3C XML shema W3C XML-séma schema XML de W3C + Skema XML W3C W3C XML skema Schema XML del W3C W3C XML スキーマ @@ -1270,71 +1109,10 @@ W3C XML 機制 - - AAC sound - صوت AAC - Soníu AAC - AAC zvuk - So AAC - So AAC - Zvuk AAC - AAC-lyd - AAC-Audio - Ήχος ACC - AAC sound - Sonido AAC - AAC helifail - AAC soinua - AAC-ääni - Son AAC - Fuaim AAC - fuaim AAC - Son AAC - AAC zvuk - AAC-hang - Sono AAC - AAC hljóð - suono AAC - AAC サウンド - AAC дыбысы - សំឡេង AAC - AAC 소리 - AAC garsas - AAC skaņa - എഎസി ശബ്ദം - AAC आवाज - Bunyi AAC - AAC-lyd - AAC-Kläng - AAC-geluid - AAC-lyd - AAC ਸਾਊਂਡ - Dźwięk AAC - Som AAC - Som AAC - Sunet AAC - аудио AAC - AAC-jietna - Zvuk AAC - Zvok AAC - AAC sound - ААЦ звук - ААЦ звук - AAC zvuk - AAC zvuk - AAC-ljud - เสียงรูปแบบ AAC - AAC sesi - AAC ئاۋاز - звук у форматі AAC - AAC 声音 - AAC 音效 - - RealAudio plugin file ملف ملحق RealAudio - Ficheru de complementu RealAudio + Ficheru de complementu de RealAudio RealAudio priključak Fitxer del connector RealAudio Fitxer del connector RealAudio @@ -1354,6 +1132,7 @@ priključna datoteka za RealAudio RealAudio-bővítményfájl RealAudio: File de plugin + File Plugin RealAudio RealAudio plugin skrá file di estensioni RealAudio RealAudio プラグインファイル @@ -1412,6 +1191,7 @@ KPhotoAlbum uvoz KPhotoAlbum-import Importation de KPhotoAlbum + Impor KPhotoAlbum KPhotoAlbum innflutningur importazione di KPhotoAlbum KPhotoAlbum インポート @@ -1472,6 +1252,7 @@ HDR slika HDR-kép Imagine HDR + Citra HDR HDR mynd immagine HDR HDR イメージ @@ -1517,7 +1298,7 @@ KDE raw image formats تنسيقات صور خام لكدي - Formatos d'imaxe en brutu de KDE + Formatos d'imaxe en bruto de KDE KDE formati sirovih slika Formats d'imatge RAW del KDE Formats d'imatge RAW del KDE @@ -1537,6 +1318,7 @@ KDE-ovi sirovi slikovni podaci KDE-s nyers képformátumok Formatos de imagines crude de KDE + Format citra raw KDE KDE RAW myndsnið formati di immagine raw di KDE KDE raw イメージ形式 @@ -1589,7 +1371,7 @@ Intel® hexadecimal object file ملف كائن سداسي عشر Intel® - Ficheru d'oxetu hexadecimal Intel® + Ficheru d'oxetu hexadecimal d'Intel® Intelova heksadekadna objektna datoteka Fitxer objecte hexadecimal d'Intel® Fitxer objecte hexadecimal d'Intel® @@ -1609,6 +1391,7 @@ Intelova® heksadecimalna objektna datoteka Intel®-féle hexadecimális objektumfájl File objecto hexadecimal de Intel(c) + File objek heksadesimal Intel® Intel® hexadesimal hlutaskrá file oggetto esadecimale Intel® Intel® 十六進オブジェクトファイル @@ -1651,7 +1434,6 @@ Kate file list loader plugin list قائمة ملحقات محملات قائمة ملفات لكيت - Llista de complementos del cargador de llistes de ficheros Kate spisak Kateinog priključka za učitavanje datoteka Llista del connector carregador de llista de fitxers del Kate Llista del connector carregador de llista de fitxers del Kate @@ -1670,6 +1452,7 @@ Kate lista od priključka učitavača liste datoteka Kate-listafájl (fájllista vagy bővítménylista) Kate: Lista de plugin de cargator de lista de file + Daftar fail Kate pemuat daftar plugin Kate skráahleðsluíforritalisti elenco delle estensioni del caricatore di elenchi di file di Kate Kate ファイルリストローダプラグインリスト @@ -1705,70 +1488,10 @@ Kate 檔案清單載入器外掛程式清單 - - - Objective-C header - ترويسة Objective-C - Testera Objective-C - Objective‑c zaglavlje - Capçalera Objective-C - Capçalera Objective-C - Objective-C hlavička - Objective-C header-fil - Objective-C-Header - Κεφαλίδα Objective-C - Objective-C header - Cabecera de Objective-C - Objective-C päis - Objective-C goiburua - Objective C -otsake - En-tête « Objective-C » - Ceanntásc Objective-C - bann-cinn Objective-C - Cabeceira de Objective-C - Objective-C zaglavlje - Objective-C-fejlécfájl - Capite de Objective-C - Objective-C haus - intestazione Objective-C - Objective-C ヘッダ - Objective-C айдар файлы - ក្បាល Objective-C - 오브젝티브-C 헤더 - Objektinio-C antraštė - Objective-C galvene - ഒബ്ജക്ടീവ്-സി ഹെഡര്‍ - ओब्जेक्टिव्ह-सी हेडर - Objective-C hodefil - "Objective-C"-Koppdatei - Objective-C-header - Objective-C-deklarasjonsfil - Objective-C ਹੈੱਡਰ - Plik nagłówkowy Objective-C - Ficheiro de inclusão em Objective-C - Cabeçalho em Objetive-C - antet Objective-C - заголовочный файл Objective-C - Objective-C oaivefiila - Hlavičkový súbor Objektového C - Glava za Objective-C - објектив‑Ц заглавље - објектив‑Ц заглавље - Objective‑c zaglavlje - Objective‑c zaglavlje - Objective-C deklarationsfil - แฟ้มส่วนหัวภาษา Objective-C - Objective-C başlığı - Objective-C باشى - файл заголовків Objective-C - Objective-C 头文件 - Objective-C 標頭檔 - abc musical notation file ملف كراسة موسيقية abc - ficheru de notación musical abc muzička notacija ABC Fitxer de notació musical abc Fitxer de notació musical abc @@ -1788,6 +1511,7 @@ abc muzičko notacijska datoteka Abc-kottafájl file de notation musical abc + File notasi musikal abc abc nótnaskriftarskrá file di notazione musicale abc abc ミュージカルノーテーションファイル @@ -1850,6 +1574,7 @@ paket pisama betűtípuscsomag pacchettos de fonts + Paket fonta leturpakki pacchetto di caratteri フォントパッケージ @@ -1891,7 +1616,7 @@ Windows server خادم ويندوز - Sirvidor Windows + Sirvidor de Windows windows server Servidor Windows Servidor Windows @@ -1911,6 +1636,7 @@ Windows poslužitelj Windows-kiszolgáló Servitor de Windows + Server Windows Windows miðlari server Windows Windows サーバ @@ -1951,7 +1677,7 @@ Windows workgroup مجموعة عمل ويندوز - Grupu de trabayu Windows + Grupu de trabayu de Windows windows radna grupa Treball en grup de Windows Treball en grup de Windows @@ -1971,6 +1697,7 @@ Windows radna grupa Windows munkacsoport Gruppo de travalio de Windows + Workgroup Windows Windows vinnuhópur gruppo di lavoro di Windows Windows ワークグループ @@ -2032,6 +1759,7 @@ KDE-ov monitor sustava KDE rendszermonitor Monitor de Systema de KDE + Pemantau Sistem KDE KDE kerfiseftirlit monitor di sistema di KDE KDE システムモニタ @@ -2072,7 +1800,7 @@ KDE theme سمة كدي - Tema KDE + Tema de KDE Тема за KDE KDE tema Tema del KDE @@ -2093,6 +1821,7 @@ KDE-ova tema KDE-téma Thema de KDE + Tema KDE KDE þema tema di KDE KDE テーマ @@ -2155,6 +1884,7 @@ Quanta projekt Quanta-projekt Quanta : Projecto + Proyek Quanta Quanta verkefni progetto di Quanta Quanta プロジェクト @@ -2195,7 +1925,7 @@ Kommander file ملف Kommander - Ficheru Kommander + Ficheru de Kommander Файл на Kommander Kommanderov fajl Fitxer del Kommander @@ -2216,6 +1946,7 @@ Kommander datoteka Kommander-fájl Kommander : file + File kommander Kommander skrá file di Kommander Kommander ファイル @@ -2274,6 +2005,7 @@ potato potato patata + potato Kartafla (potato) patata potato @@ -2313,7 +2045,7 @@ Kolf saved game لعبة Kolf محفوظة - Xuegu guardáu Kolf + Partida guardada de Kolf Запазена игра на Kolf Kolfova sačuvana igra Joc desat del Kolf @@ -2334,6 +2066,7 @@ Kolf spremljena igra Kolf mentett állás Kolf : Joco salveguardate + Permainan tersimpan Kolf Vistaður Kolf leikur partita salvata di Kolf Kolf 保存されたゲーム @@ -2376,6 +2109,7 @@ Kolf course دورة Kolf + Cursu Kolf Kolfov teren Camp del Kolf Camp del Kolf @@ -2395,6 +2129,7 @@ Kolf staza Kolf-pálya Kolf : curso + Tentu saja Kolf Kolf braut campo da Kolf Kolf コース @@ -2460,6 +2195,7 @@ arhiva dokumenta za Okular Okular-archívum Okular : archivo de documento + Arsip dokumen Okular Okular skjalasafnskrá archivio di documenti di Okular Okular 文書アーカイブ @@ -2520,6 +2256,7 @@ Cabri figura Cabri-alakzat Cabri : Figura + Sosok Cabri Cabri teikning figura Cabri Cabri figure @@ -2564,7 +2301,7 @@ Dr. Geo figure صورة Dr. Geo - Figura Dr. Geo + Figura de Dr. Geo Dr Geov crtež Figura del Dr. Geo Figura del Dr. Geo @@ -2584,6 +2321,7 @@ Dr. Geo figura Dr. Geo-alakzat Dr.Geo : Figura + Sosok Dr. Geo Dr. Geo teikning figura Dr. Geo Dr. Geo figure @@ -2627,7 +2365,7 @@ KGeo figure صورة KGeo - Figura KGeo + Ficheru KGeo Фигура за KGeo KGeov crtež Figura del KGeo @@ -2648,6 +2386,7 @@ KGeo skica KGeo-alakzat KGeo : Figura + Sosok KGeo KGeo teikning figura di KGeo KGeo figure @@ -2707,6 +2446,7 @@ Kig figura Kig-alakzat Kig : figura + Sosok Kig Kig teikning figura di Kig Kig figure @@ -2746,7 +2486,7 @@ KSeg document وثيقة KSeg - Documentu KSeg + Documentu Kseg Документ KSeg KSegov dokument Document del KSeg @@ -2767,6 +2507,7 @@ KSeg dokument KSeg-dokumentum KSeg :documento + Dokumen KSeg KSeg skjal documento di KSeg KSeg 文書 @@ -2807,7 +2548,6 @@ vocabulary trainer document وثيقة مدرب المفردات - documentu d'entrenador de vocabulariu dokument za uvježbavanje rječnika Document de l'entrenador de vocabulari Document de l'entrenador de vocabulari @@ -2827,6 +2567,7 @@ dokument vokabularskog trenera szógyűjtemény documento de instructor de vocabulario + dokumen pelatih kosakata orðaforðaþjálfunarskjal documento di allenamento a vocabolario ボキャブラリトレーナー文書 @@ -2865,7 +2606,7 @@ KmPlot file ملف KmPlot - Ficheru KmPlot + Ficheru de KmPlot Файл на KmPlot KmPlot datoteka Fitxer del KmPlot @@ -2886,6 +2627,7 @@ KmPlot datoteka KmPlot-fájl KmPlot: file + File KmPlot KmPlot skrá file di KmPlot KmPlot ファイル @@ -2945,6 +2687,7 @@ KWordQuiz vokabular KWordQuiz-szótár KWordQuiz : vocabulario + Kosakata KWordQuiz KWordQuiz orðaforði vocabolario di KWordQuiz KWordQuiz ボキャブラリ @@ -3002,6 +2745,7 @@ Cachegrind/Callgrind odbačeni profil Cachegrind/Callgrind-képfájl Cachegrind/Callgrind : Discargatorio de profilo + Gardu profil Cachegrind/Callgrind Cachegrind/Callgrind sniðdump dump di profilatura di Cachegrind e Callgrind Cachegrind/Callgrind プロファイルダンプ @@ -3042,6 +2786,7 @@ Umbrello UML Modeller file ملف Umbrello UML Modeller + Ficheru del modelador UML Umbrello Umbrello UML datoteka Fitxer del modelador UML Umbrello Fitxer del modelador UML Umbrello @@ -3061,6 +2806,7 @@ Umbrello UML Modeller datoteka Umbrello UML-fájl Umbrello: file Modellator UML + File Umbrello UML Modeller Umbrello UML Modeller skrá file del modellatore UML Umbrello Umbrello UML モデラーファイル @@ -3101,7 +2847,7 @@ Windows link وصلة ويندوز - Enllaz Windows + Enllaz de Windows windows veza Enllaç del Windows Enllaç del Windows @@ -3121,6 +2867,7 @@ Windows veza Windows-link Ligamine de Windows + Tautan Windows Windows tengill collegamento di Windows Windows リンク @@ -3163,7 +2910,7 @@ KGet download list قائمة تنزيل KGet - Llistáu de descarga KGet + Llistáu de descargues de KGet Списък за изтегляне на KGet KGetova spisak preuzimanja Llista de baixades del KGet @@ -3184,6 +2931,7 @@ KGet lista preuzimanja KGet letöltési lista KGet : Lista de discargar + Daftar unduhan KGet KGet niðurhalslisti elenco di scaricamenti di KGet KGet ダウンロードリスト @@ -3223,7 +2971,7 @@ Kopete emoticons archive أرشف إبتسامات Kopete - Archivu de fustaxes Kopete + Archivu de fustaxe de Kopete Kopeteova arhiva emotikona Arxiu de les emoticones del Kopete Arxiu de les emoticones del Kopete @@ -3243,6 +2991,7 @@ Kopete arhiva emotikona Kopete-emotikoncsomag Kopete : archivo de emoticones + Arsip emosikon Kopete Kopete tjáningartáknasafn archivio di faccine di Kopete Kopete 感情アイコンアーカイブ @@ -3281,7 +3030,7 @@ ICQ contact جهة اتصال ICQ - Contautu ICQ + Contautu d'ICQ Контакт в ICQ ICQ kontakt Contacte de l'ICQ @@ -3302,6 +3051,7 @@ ICQ kontakt ICQ-névjegy ICQ : Contacto + Kontak ICQ ICQ tengiliður contatto ICQ ICQ コンタクト @@ -3345,7 +3095,7 @@ Microsoft Media Format تنسيق وسائط مايكروسوفت - Formatu de medios Microsoft + Formatu de medios de Microsoft Формат Microsoft Media Microsoftov medija format Format de suports de Microsoft @@ -3366,12 +3116,13 @@ Microsoft Media Format Microsoft-médiafájl Formato de Media de Microsoft + Format Media Microsoft Microsoft Media Format formato multimediale di Microsoft Microsoft メディアフォーマット Microsoft Media Format ទ្រង់ទ្រាយ​របស់ Microsoft Media - 마이크로소프트 미디어 포맷 + Microsoft 미디어 포맷 Microsoft media formatas Microsoft Media formāts മൈക്രോസോഫ്റ്റ് മിഡിയ ഘടന @@ -3406,74 +3157,12 @@ - - - - TriG RDF document - وثيقة TriG RDF - Documentu RDF TriG - TriG RDF dokument - Document RDF del TriG - Document RDF del TriG - Dokument TriG RDF - TriG RDF-dokument - TriG-RDF-Dokument - Έγγραφο TriG RDF - TriG RDF document - Documento RDF TriG - TriG RDF-dokument - TriG RDF dokumentua - TriG RDF -tiedosto - Document « RDF TriG » - Cáipéis RDF TriG - sgrìobhainn TriG RDF - Documento RDF de TriG - TriG RDF dokument - TriG RDF-dokumentum - Documento RDF de TRiG - TriG RDF skjal - documento TriG RDF - TriG RDF 文書 - TriG RDF құжаты - ឯកសារ TriG RDF - TriG RDF 문서 - TriG RDF dokumentas - TriG RDF dokuments - ട്രിഗ് ആര്‍ ഡി എഫ് രേഖ - ट्रीग RDF दस्तऐवज - TriG RDF-dokument - RDF-Dokment för TriG - TriG RDF-document - TriG RDF-dokument - TriG RDF ਡੌਕੂਮੈਂਟ - Dokument TriG RDF - Documento RDF do TriG - Documento RDF do TriG - Document RDF TriG - документ TriG RDF - TriG RDF-dokumeanta - Dokument TriG RDF - Dokument TriG RDF - TriG RDF dokument - три‑Г РДФ документ - три‑Г РДФ документ - TriG RDF dokument - TriG RDF dokument - Trig RDF-dokument - TriG RDF belgesi - TriG RDF پۈتۈك - документ RDF TriG - TriG RDF 文档 - TriG RDF 文件 - - - Turtle RDF document وثيقة Turtle RDF - Documentu RDF Turtle + Documentu RDF de Turtle Turtle RDF dokument Document RDF del Turtle Document RDF del Turtle @@ -3493,6 +3182,7 @@ Turtle RDF dokument Turtle RDF-dokumentum documento RDF de Turtle + Dokumen Turtle RDF Turtle RDF skjal documento Turtle RDF Turtle RDF 文書 @@ -3532,7 +3222,7 @@ Softimage PIC image صورة PIC - Imaxe Softimage PIC + Imaxe PIC de Softimage Softimidžova PIC slika Imatge PIC de Softimage Imatge PIC de Softimage @@ -3552,6 +3242,7 @@ Softimage PIC slika Softimage PIC-kép Imagine PIC de SoftImage + Citra Softimage PIC Softimage PIC mynd immagine Softimage PIC Softimage PIC 画像 @@ -3590,10 +3281,10 @@ - + Qt Markup Language file ملف لغة الوصف Qt - Ficheru de llinguax d'etiquetes Qt + Ficheru de llinguax de marques Qt Datoteka Qt jezika za označavanje Fitxer de llenguatge de marques de les Qt Fitxer de llenguatge de marques de les Qt @@ -3609,10 +3300,11 @@ Fichier de langage à balises Qt Comhad Teanga Mharcála Qt faidhle Qt Markup Language - Ficheiro na lingua de etiquetas de Qt + Ficheiro na linguaxe de etiquetas de Qt Datoteka Qt-ovog označnog jezika Qt Markup Language fájl Le de linguage de marcation de QT + File Language Markup Qt Qt Markup tungumálsskrá File di linguaggio a marcatori di Qt Qt белгілеу тіліндегі файл @@ -3650,119 +3342,145 @@ - - Mobipocket e-book - كتاب إلكتروني Mobipocket - Llibru electrónicu Mobipocket - Mobipocket e-book - Llibre electrònic Mobipocket - Llibre electrònic Mobipocket - E-Book Mobipocket - Mobipocket e-bog - Mobipocket-e-book - Ηλ. βιβλίο Mobipocket - Mobipocket e-book - Libro electrónico Mobipocket - Mobipocketi e-raamat - Mobipocket liburu elektronikoa (e-book) - Mobipocket-e-kirja - Livre électronique « Mobipocket » - Ríomhleabhar Mobipocket - leabhar-d Mobipocket - Libro electrónico Mobipocket - E-knjiga u Mobipocketu - Mobipocket e-book - Mobipocket e-book - Mobipocket rafbók - Libro elettronico Mobipocket - Mobipocket эл.кітабі - Mobipocket e-book - Mobipocket 전자책 - Mobipocket e-knyga - Mobipocket e-grāmata - मोबीपॉकेट इ-पुस्तक - Mobipocket e-bok - E-Book för Mobipocket - Mobipocket e-book - Mobipocket e-bøk - Mobipocket e-book - E-Book do Mobipocket - E-book do Mobipocket - Carte digitală Mobipocket - электронная книга Mobipocket - Mobipocket e-girji - Elektronická kniha Mobipocket - E-knjiga Mobipocket - Мобипокетова е‑књига - Мобипокетова е‑књига - Mobipocketova e‑knjiga - Mobipocketova e‑knjiga - Mobipocket e-bok - Mobipocket e-kitap - Mobipocket ئې-كىتاب - електронна книга Mobipocket - Mobipocket 电子书 - Mobipocket e-book - - - - - - - - + + KConfigXT Configuration Options + Opcions de configuració del KConfigXT + Opcions de configuració del KConfigXT + Konfigurationsmuligheder til KConfigXT + KConfigXT-Einrichtungsoptionen + KConfigXT Configuration Options + Opciones de configuración de KConfigXT + KConfigXT Configuration Options + Options de configuration de KConfigXT + Opcións de configuración de KConfigXT + Opsi Konfigurasi KConfigXT + Opzioni di configurazione KConfigXT + KConfigXT 설정 옵션 + Configuratie-opties van KConfigXT + KConfigXT-oppsett + Opcje KConfigXT + Opções de Configuração do KConfigXT + Opções de configuração do KConfigXT + параметры конфигурации KConfigXT + Nastavitvene možnosti KConfigXT + поставне опције К‑конфиг‑ИксТ‑а + поставне опције К‑конфиг‑ИксТ‑а + postavne opcije KConfigXT‑a + postavne opcije KConfigXT‑a + KConfigXT-inställningsalternativ + параметри налаштування KConfigXT + KConfigXT 配置选项 + KConfigXT 設定選項 + + - + + + + + + KConfigXT Code Generation Options + Opcions de generació de codi del KConfigXT + Opcions de generació de codi del KConfigXT + Kodegenereringsmuligheder til KConfigXT + KConfigXT-Optionen zur Quelltexterzeugung + KConfigXT Code Generation Options + Opciones de generación de código de KConfigXT + KConfigXT Code Generation Options + Options de génération de code de KConfigXT + Opcións de xeración de código de KConfigXT + Opsi Penghasilan Kode KConfigXT + Opzioni di generazione codice KConfigXT + KConfigXT 코드 생성 옵션 + Codegeneratie-opties van KConfigXT + KConfigXT-kodegeneringsval + Opcje tworzenia kodu KConfigXT + Opções de Geração de Código do KConfigXT + Opções de geração de código do KConfigXT + параметры создания кода KConfigXT + Možnosti ustvarjanja kode KConfigXT + опције генерисања кода К‑конфиг‑ИксТ‑а + опције генерисања кода К‑конфиг‑ИксТ‑а + opcije generisanja koda KConfigXT‑a + opcije generisanja koda KConfigXT‑a + KConfigXT-kodgenereringsalternativ + параметри створення коду KConfigXT + KConfigXT 代码生成选项 + KConfigXT 代碼產生選項 + + + - - - WebP image - Imaxe WebP - Imatge WebP - Imatge WebP - Obrázek WebP - WebP-billede - WebP-Bild - Εικόνα WebP - WebP image - Imagen WebP - WebP-kuva - Image WebP - dealbh WebP - Imaxe WebP - WebP-kép - Imagine de WebP - immagine WebP - WebP 그림 - WebP paveikslėlis - WebP प्रतिमा - WebP-bilde - WebP-Bild - WebP-image - WebP-bilete - WebP ਚਿੱਤਰ - Obraz WebP - Imagem WebP - Imagem WebP - Imagine WebP - изображение WebP - WebP obrázok - Slika WebP - вебП слика - вебП слика - WebP slika - WebP slika - WebP-bild - WebP resmi - зображення WebP - WebP 图像 - WebP 影像 - - - - + + KXMLGUI UI Declaration + Declaració IU KXMLGUI + Declaració IU KXMLGUI + KXMLGUI UI-erklæring + KXMLGUI-UI-Deklaration + KXMLGUI UI Declaration + Declaración de interfaz de usuario de KXMLGUI + KXMLGUI UI Declaration + Déclaration d'interface KXMLGUI + Declaración de interface gráfica de KXMLGUI + Deklarasi KXMLGUI UI + Dichiarazione UI KXMLGUI + KXMLGUI UI 선언 + Declaratie van KXMLGUI UI + KXMLGUI UI-deklarasjon + Dklaracja KXMLGUI UI + Declaração de UI do KXMLGUI + Declaração UI do KXMLGUI + конфигурация интерфейса KXMLGUI + Deklaracija uporabniškega vmesnika KXMLGUI + декларације за KXmlGui + декларације за KXmlGui + deklaracije za KXmlGui + deklaracije za KXmlGui + KXMLGUI-användargränssnittsdeklaration + оголошення інтерфейсу KXMLGUI + KXMLGUI 用户界面声明 + KXMLGUI UI 宣告 + + + + + - + + + + + KNotification Declaration + Declaració del KNotification + Declaració del KNotification + KNotification-erklæring + KNotification-Deklaration + KNotification Declaration + Declaración de KNotification + KNotification Declaration + Déclaration de KNotification + Declaración de KNotification + Deklarasi KNotification + Dichiarazione KNotification + KNotification 선언 + Declaratie van KNotification + KNotification-deklarasjon + Deklaracja KNotification + Declaração do KNotification + Declaração do KNotification + конфигурация KNotification + Deklaracija KNotification + декларације за KNotification + декларације за KNotification + deklaracije za KNotification + deklaracije za KNotification + KNotification-deklaration + оголошення KNotification + Knotification 声明 + KNotification 宣告 + + + diff -Nru kcoreaddons-5.18.0/tests/CMakeLists.txt kcoreaddons-5.44.0a/tests/CMakeLists.txt --- kcoreaddons-5.18.0/tests/CMakeLists.txt 2016-01-02 16:27:51.000000000 +0000 +++ kcoreaddons-5.44.0a/tests/CMakeLists.txt 2018-03-06 08:12:31.000000000 +0000 @@ -1,20 +1,11 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII) -find_package(Qt5Widgets ${REQUIRED_QT_VERSION} CONFIG QUIET) +find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG QUIET OPTIONAL_COMPONENTS Widgets) if(NOT Qt5Widgets_FOUND) message(STATUS "Qt5Widgets not found, examples will not be built.") return() endif() -macro(KCOREADDONS_EXAMPLES) - foreach(_testname ${ARGN}) - add_executable(${_testname} ${_testname}.cpp) # TODO NOGUI - target_link_libraries(${_testname} Qt5::Test KF5::CoreAddons) - endforeach() -endmacro() - -########### kdirwatchtest_gui ############### - add_executable(kdirwatchtest_gui kdirwatchtest_gui.cpp) target_link_libraries(kdirwatchtest_gui Qt5::Widgets KF5::CoreAddons)