mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kinfocenter: new kernel module
requires:
b089f32459
warns about (possibly) missing firmwares too:
https://ibb.co/HKggFvr
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
272e8cf088
commit
905cae04fd
9 changed files with 272 additions and 4 deletions
|
@ -136,6 +136,13 @@ set_package_properties(LibUSB PROPERTIES
|
|||
PURPOSE "Provides Logitech mouse support in KControl and USB devices information"
|
||||
)
|
||||
|
||||
macro_optional_find_package(Kmod)
|
||||
set_package_properties(Kmod PROPERTIES
|
||||
DESCRIPTION "Set of tools to handle common tasks with Linux kernel modules"
|
||||
URL "https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/"
|
||||
TYPE OPTIONAL
|
||||
PURPOSE "Kernel modules information"
|
||||
)
|
||||
macro_optional_find_package(PCIUTILS)
|
||||
set_package_properties(PCIUTILS PROPERTIES
|
||||
DESCRIPTION "PciUtils is a library for direct access to PCI slots"
|
||||
|
|
|
@ -26,7 +26,7 @@ build_script:
|
|||
libglu1-mesa-dev mesa-common-dev libmtp-dev libusb-1.0-0-dev libssh-dev \
|
||||
libsmbclient-dev libdrm-dev libraw1394-dev libsensors4-dev \
|
||||
libegl-dev libpci-dev libopenexr-dev liblzma-dev libbz2-dev libgphoto2-dev \
|
||||
liblightdm-gobject-1-dev libdbusmenu-katie ccache
|
||||
liblightdm-gobject-1-dev libkmod-dev libdbusmenu-katie ccache
|
||||
|
||||
export PATH="/usr/lib/ccache/:$PATH"
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
/* KDE's static data directory */
|
||||
#define KDE_DATADIR "${KDE4_DATA_INSTALL_DIR}"
|
||||
|
||||
/* KDE's static shared data directory */
|
||||
#define KDE_SHAREDIR "${KDE4_SHARE_INSTALL_PREFIX}"
|
||||
/* KDE's static libraries directory */
|
||||
#define KDE_LIBDIR "${KDE4_LIB_INSTALL_DIR}"
|
||||
|
||||
/* KDE's system configuration directory */
|
||||
#define KDE_SYSCONFDIR "${KDE4_SYSCONF_INSTALL_DIR}"
|
||||
|
|
|
@ -11,7 +11,8 @@ add_subdirectory( pci )
|
|||
add_feature_info("OpenGL support" OPENGL_FOUND "View OpenGL details in kinfocenter." )
|
||||
add_feature_info("EGL support" OpenGL_EGL_FOUND "View EGL details in kinfocenter." )
|
||||
add_feature_info("DRM support" LIBDRM_FOUND "View 3D acceleration details in kinfocenter." )
|
||||
add_feature_info("USB support" LIBUSB_FOUND "USB details in kinfocenter." )
|
||||
add_feature_info("USB support" LIBUSB_FOUND "View USB details in kinfocenter." )
|
||||
add_feature_info("Kernel modules support" KMOD_FOUND "View kernel module details in kinfocenter." )
|
||||
|
||||
if((OPENGL_FOUND AND OPENGL_GLU_FOUND) OR OpenGL_EGL_FOUND)
|
||||
add_subdirectory( opengl )
|
||||
|
@ -28,3 +29,7 @@ endif()
|
|||
if(RAW1394_FOUND)
|
||||
add_subdirectory( view1394 )
|
||||
endif(RAW1394_FOUND)
|
||||
|
||||
if(KMOD_FOUND)
|
||||
add_subdirectory( kernel )
|
||||
endif(KMOD_FOUND)
|
||||
|
|
24
kinfocenter/Modules/kernel/CMakeLists.txt
Normal file
24
kinfocenter/Modules/kernel/CMakeLists.txt
Normal file
|
@ -0,0 +1,24 @@
|
|||
include_directories(${KMOD_INCLUDE_DIR})
|
||||
|
||||
########### next target ###############
|
||||
|
||||
set(kcm_kernel_PART_SRCS kernel.cpp )
|
||||
|
||||
kde4_add_plugin(kcm_kernel ${kcm_kernel_PART_SRCS})
|
||||
|
||||
target_link_libraries(kcm_kernel
|
||||
${KDE4_KIO_LIBS}
|
||||
${KMOD_LIBRARIES}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS kcm_kernel
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install(
|
||||
FILES kernel.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
2
kinfocenter/Modules/kernel/Messages.sh
Normal file
2
kinfocenter/Modules/kernel/Messages.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
$XGETTEXT *.cpp -o $podir/kcmkernel.pot
|
178
kinfocenter/Modules/kernel/kernel.cpp
Normal file
178
kinfocenter/Modules/kernel/kernel.cpp
Normal file
|
@ -0,0 +1,178 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
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 "kernel.h"
|
||||
#include "config-workspace.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <kaboutdata.h>
|
||||
#include <kglobal.h>
|
||||
#include <kicon.h>
|
||||
#include <kdebug.h>
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginLoader>
|
||||
|
||||
#include <libkmod.h>
|
||||
|
||||
static const QStringList s_firmwarepaths = QStringList()
|
||||
<< "/lib/firmware"
|
||||
<< "/usr/lib/firmware"
|
||||
<< KDE_LIBDIR "/firmware";
|
||||
|
||||
K_PLUGIN_FACTORY(KCMKernelFactory, registerPlugin<KCMKernel>();)
|
||||
K_EXPORT_PLUGIN(KCMKernelFactory("kcmkernel"))
|
||||
|
||||
KCMKernel::KCMKernel(QWidget *parent, const QVariantList &)
|
||||
: KCModule(KCMKernelFactory::componentData(), parent)
|
||||
{
|
||||
KAboutData *about = new KAboutData(
|
||||
I18N_NOOP("kcmkernel"), 0,
|
||||
ki18n("Kernel Modules Information Control Module"),
|
||||
0, KLocalizedString(), KAboutData::License_GPL,
|
||||
ki18n("(c) 2022 Ivailo Monev")
|
||||
);
|
||||
|
||||
about->addAuthor(ki18n("Ivailo Monev"), KLocalizedString(), "xakepa10@gmail.com");
|
||||
setAboutData(about);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setSpacing(0);
|
||||
layout->setMargin(0);
|
||||
|
||||
m_treewidget = new QTreeWidget(this);
|
||||
layout->addWidget(m_treewidget);
|
||||
m_treewidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_treewidget->setAllColumnsShowFocus(true);
|
||||
m_treewidget->setWhatsThis(i18n("This list displays kernel modules information."));
|
||||
|
||||
QStringList treeheaders;
|
||||
treeheaders << i18n("Information") << i18n("Value");
|
||||
m_treewidget->setHeaderLabels(treeheaders);
|
||||
m_treewidget->setRootIsDecorated(true);
|
||||
}
|
||||
|
||||
void KCMKernel::load()
|
||||
{
|
||||
struct kmod_ctx *kmodctx = kmod_new(NULL, NULL);
|
||||
if (!kmodctx) {
|
||||
kWarning() << "Could not create kmod context";
|
||||
return;
|
||||
}
|
||||
struct kmod_list *kmodlist = NULL;
|
||||
int kmodresult = kmod_module_new_from_loaded(kmodctx, &kmodlist);
|
||||
if (kmodresult == 0) {
|
||||
struct kmod_list *kmodit = NULL;
|
||||
for (kmodit = kmodlist; kmodit != NULL; kmodit = kmod_list_next(kmodlist, kmodit)) {
|
||||
struct kmod_module *kmodmodule = kmod_module_get_module(kmodit);
|
||||
// qDebug() << Q_FUNC_INFO << kmod_module_get_name(kmodmodule);
|
||||
|
||||
QStringList modulewidgetitemlist;
|
||||
modulewidgetitemlist << QString::fromAscii(kmod_module_get_name(kmodmodule));
|
||||
QTreeWidgetItem* modulewidgetitem = new QTreeWidgetItem(m_treewidget, modulewidgetitemlist);
|
||||
|
||||
QStringList modulepathwidgetitemlist;
|
||||
modulepathwidgetitemlist << i18n("Path") << QString::fromAscii(kmod_module_get_path(kmodmodule));
|
||||
(void)new QTreeWidgetItem(modulewidgetitem, modulepathwidgetitemlist);
|
||||
|
||||
QStringList moduleoptionswidgetitemlist;
|
||||
moduleoptionswidgetitemlist << i18n("Size") << KGlobal::locale()->formatByteSize(kmod_module_get_size(kmodmodule), 1);
|
||||
(void)new QTreeWidgetItem(modulewidgetitem, moduleoptionswidgetitemlist);
|
||||
|
||||
QTreeWidgetItem* moduleauthorswidgetitem = nullptr;
|
||||
QTreeWidgetItem* modulefirmwareswidgetitem = nullptr;
|
||||
|
||||
struct kmod_list *kseclist = NULL;
|
||||
kmodresult = kmod_module_get_info(kmodmodule, &kseclist);
|
||||
if (kmodresult >= 0) {
|
||||
struct kmod_list *ksecit = NULL;
|
||||
for (ksecit = kseclist; ksecit != NULL; ksecit = kmod_list_next(kseclist, ksecit)) {
|
||||
const char* kmodkey = kmod_module_info_get_key(ksecit);
|
||||
const char* kmodvalue = kmod_module_info_get_value(ksecit);
|
||||
// qDebug() << Q_FUNC_INFO << kmodkey << kmodvalue;
|
||||
|
||||
QStringList modulesectionwidgetitemlist;
|
||||
if (qstrcmp(kmodkey, "license") == 0) {
|
||||
modulesectionwidgetitemlist << i18n("License") << QString::fromAscii(kmodvalue);
|
||||
(void)new QTreeWidgetItem(modulewidgetitem, modulesectionwidgetitemlist);
|
||||
} else if (qstrcmp(kmodkey, "description") == 0) {
|
||||
modulesectionwidgetitemlist << i18n("Description") << QString::fromAscii(kmodvalue);
|
||||
(void)new QTreeWidgetItem(modulewidgetitem, modulesectionwidgetitemlist);
|
||||
} else if (qstrcmp(kmodkey, "author") == 0) {
|
||||
if (!moduleauthorswidgetitem) {
|
||||
QStringList moduleauthorswidgetitemlist;
|
||||
moduleauthorswidgetitemlist << i18n("Authors");
|
||||
moduleauthorswidgetitem = new QTreeWidgetItem(modulewidgetitem, moduleauthorswidgetitemlist);
|
||||
}
|
||||
|
||||
modulesectionwidgetitemlist << i18n("Author") << QString::fromAscii(kmodvalue);
|
||||
(void)new QTreeWidgetItem(moduleauthorswidgetitem, modulesectionwidgetitemlist);
|
||||
} else if (qstrcmp(kmodkey, "signer") == 0) {
|
||||
modulesectionwidgetitemlist << i18n("Signer") << QString::fromAscii(kmodvalue);
|
||||
(void)new QTreeWidgetItem(modulewidgetitem, modulesectionwidgetitemlist);
|
||||
} else if (qstrcmp(kmodkey, "firmware") == 0) {
|
||||
if (!modulefirmwareswidgetitem) {
|
||||
QStringList modulefirmwareswidgetitemlist;
|
||||
modulefirmwareswidgetitemlist << i18n("Firmwares");
|
||||
modulefirmwareswidgetitem = new QTreeWidgetItem(modulewidgetitem, modulefirmwareswidgetitemlist);
|
||||
}
|
||||
|
||||
modulesectionwidgetitemlist << i18n("Firmware") << QString::fromAscii(kmodvalue);
|
||||
QTreeWidgetItem* modulefirmwarewidgetitem = new QTreeWidgetItem(
|
||||
modulefirmwareswidgetitem, modulesectionwidgetitemlist
|
||||
);
|
||||
bool isfirmwarepresent = false;
|
||||
foreach (const QString &firmwarepath, s_firmwarepaths) {
|
||||
const QString modulefirmwarepath = firmwarepath + QDir::separator() + QString::fromAscii(kmodvalue);
|
||||
if (QFile::exists(modulefirmwarepath)) {
|
||||
isfirmwarepresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isfirmwarepresent) {
|
||||
modulewidgetitem->setIcon(1, KIcon("dialog-warning"));
|
||||
modulefirmwareswidgetitem->setIcon(1, KIcon("dialog-warning"));
|
||||
modulefirmwarewidgetitem->setIcon(1, KIcon("dialog-warning"));
|
||||
modulefirmwarewidgetitem->setToolTip(1, i18n("Missing firmware"));
|
||||
}
|
||||
// qDebug() << Q_FUNC_INFO << kmod_get_dirname(kmodctx);
|
||||
}
|
||||
}
|
||||
kmod_module_info_free_list(kseclist);
|
||||
} else {
|
||||
kWarning() << "Could not get module sections list";
|
||||
}
|
||||
|
||||
kmod_module_unref(kmodmodule);
|
||||
}
|
||||
kmod_module_unref_list(kmodlist);
|
||||
} else {
|
||||
kWarning() << "Could not get loaded modules list";
|
||||
}
|
||||
kmod_unref(kmodctx);
|
||||
|
||||
// Resize the column width to the maximum needed
|
||||
m_treewidget->expandAll();
|
||||
m_treewidget->resizeColumnToContents(0);
|
||||
m_treewidget->collapseAll();
|
||||
|
||||
m_treewidget->sortItems(0, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
#include "moc_kernel.cpp"
|
14
kinfocenter/Modules/kernel/kernel.desktop
Normal file
14
kinfocenter/Modules/kernel/kernel.desktop
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Desktop Entry]
|
||||
Exec=kcmshell4 kernel
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
Icon=preferences-plugin
|
||||
|
||||
X-KDE-Library=kcm_kernel
|
||||
X-KDE-ParentApp=kinfocenter
|
||||
X-DocPath=kinfocenter/index.html#kernel
|
||||
|
||||
Name=Kernel Modules
|
||||
Comment=Kernel modules information
|
||||
|
||||
Categories=Qt;KDE;X-KDE-information;
|
38
kinfocenter/Modules/kernel/kernel.h
Normal file
38
kinfocenter/Modules/kernel/kernel.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCONTROL_KERNEL_H
|
||||
#define KCONTROL_KERNEL_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <kcmodule.h>
|
||||
|
||||
class KCMKernel : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KCMKernel(QWidget *parent = 0, const QVariantList &list = QVariantList());
|
||||
|
||||
public Q_SLOTS:
|
||||
void load();
|
||||
|
||||
private:
|
||||
QTreeWidget* m_treewidget;
|
||||
};
|
||||
|
||||
#endif // KCONTROL_KERNEL_H
|
Loading…
Add table
Reference in a new issue