Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 76c4d24e authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

PK: Decode update information coded as markdown

BUG: 388894
parent 04a59628
......@@ -35,6 +35,7 @@ set(CMAKE_AUTORCC ON)
pkg_check_modules(Flatpak IMPORTED_TARGET flatpak>=0.6.12)
pkg_check_modules(Fwupd IMPORTED_TARGET fwupd>=1.0.6)
pkg_check_modules(Markdown IMPORTED_TARGET libmarkdown)
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
# CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros.
......
......@@ -17,9 +17,13 @@ add_library(packagekit-backend MODULE PackageKitBackend.cpp
)
target_link_libraries(packagekit-backend PRIVATE Discover::Common Qt5::Core PK::packagekitqt5 KF5::ConfigGui KF5::KIOCore KF5::Archive AppStreamQt)
install(TARGETS packagekit-backend DESTINATION ${PLUGIN_INSTALL_DIR}/discover)
if(TARGET PkgConfig::Markdown)
target_compile_definitions(packagekit-backend PRIVATE -DWITH_MARKDOWN)
target_link_libraries(packagekit-backend PRIVATE PkgConfig::Markdown)
endif()
#notifier
add_library(DiscoverPackageKitNotifier MODULE PackageKitNotifier.cpp)
target_link_libraries(DiscoverPackageKitNotifier PRIVATE PK::packagekitqt5 Discover::Notifiers KF5::I18n KF5::Notifications KF5::ConfigCore)
......
......@@ -28,6 +28,12 @@
#include <QJsonArray>
#include <QDebug>
#if WITH_MARKDOWN
extern "C" {
#include <mkdio.h>
}
#endif
const QStringList PackageKitResource::m_objects({ QStringLiteral("qrc:/qml/DependenciesButton.qml") });
PackageKitResource::PackageKitResource(QString packageName, QString summary, PackageKitBackend* parent)
......@@ -248,9 +254,28 @@ static QStringList urlToLinks(const QStringList& urls)
}
void PackageKitResource::updateDetail(const QString& packageID, const QStringList& updates, const QStringList& obsoletes, const QStringList& vendorUrls,
const QStringList& /*bugzillaUrls*/, const QStringList& /*cveUrls*/, PackageKit::Transaction::Restart restart, const QString& updateText,
const QStringList& /*bugzillaUrls*/, const QStringList& /*cveUrls*/, PackageKit::Transaction::Restart restart, const QString &_updateText,
const QString& /*changelog*/, PackageKit::Transaction::UpdateState state, const QDateTime& /*issued*/, const QDateTime& /*updated*/)
{
#if WITH_MARKDOWN
const char* xx = _updateText.toUtf8().constData();
MMIOT *markdownHandle = mkd_string(xx, _updateText.size(), 0);
QString updateText;
if ( !mkd_compile( markdownHandle, MKD_FENCEDCODE | MKD_GITHUBTAGS | MKD_AUTOLINK ) ) {
updateText = _updateText;
} else {
char *htmlDocument;
const int size = mkd_document( markdownHandle, &htmlDocument );
updateText = QString::fromUtf8( htmlDocument, size );
}
mkd_cleanup( markdownHandle );
#else
const auto& updateText = _updateText;
#endif
const auto name = PackageKit::Daemon::packageName(packageID);
QString info;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment