diff --git a/CMakeLists.txt b/CMakeLists.txt index d73ba69..cadfc4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,144 +1,140 @@ project(kinfocenter) set(PROJECT_VERSION "5.17.90") cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(QT_MIN_VERSION "5.12.0") set(KF5_MIN_VERSION "5.66.0") find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(FeatureSummary) include(KDEClangFormat) include(ECMQMLModules) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Completion Config ConfigWidgets CoreAddons Crash DBusAddons DocTools I18n IconThemes KCMUtils KIO Service Solid WidgetsAddons WindowSystem XmlGui Declarative Package Solid ) if(${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GL") find_package(OpenGL) set_package_properties(OpenGL PROPERTIES DESCRIPTION "The OpenGL libraries" URL "https://www.opengl.org" TYPE OPTIONAL ) else() find_package(OpenGLES) set_package_properties(OpenGLES PROPERTIES DESCRIPTION "The OpenGLES libraries" URL "https://www.khronos.org/opengles" TYPE OPTIONAL ) endif() find_package(EGL) set_package_properties(EGL PROPERTIES TYPE OPTIONAL PURPOSE "Required for OpenGL Information Module" ) find_package(KF5Wayland CONFIG) set_package_properties(KF5Wayland PROPERTIES TYPE OPTIONAL ) add_feature_info("KF5Wayland" KF5Wayland_FOUND "Required for Wayland Compositor Information Module") -if(NOT APPLE) - find_package(X11) - set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" - URL "https://www.x.org" - TYPE OPTIONAL - PURPOSE "Required for building the X11 based workspace" - ) - if(X11_FOUND) - set(HAVE_X11 TRUE) - endif() -else() - set(X11_FOUND False) +find_package(X11) +set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" + URL "https://www.x.org" + TYPE OPTIONAL + PURPOSE "Required for building the X11 based workspace" +) +if(X11_FOUND) + set(HAVE_X11 TRUE) endif() ecm_find_qmlmodule(org.kde.kirigami 2.5) configure_file(config-project-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-project-version.h) configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS) add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) add_definitions(-DQT_USE_QSTRINGBUILDER) add_subdirectory( Categories ) add_subdirectory( kcontrol/menus ) add_subdirectory( Modules ) include(ECMOptionalAddSubdirectory) ecm_optional_add_subdirectory( doc ) include_directories( ToolTips ) set( kinfocenter_SRCS infocenter.cpp main.cpp sidepanel.cpp kcmcontainer.cpp kcmtreeitem.cpp kcmcategoryitem.cpp infokcmmodel.cpp infokcmproxymodel.cpp ToolTips/tooltipmanager.cpp ) add_executable( kinfocenter ${kinfocenter_SRCS} ) target_compile_definitions(kinfocenter PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") target_link_libraries( kinfocenter KF5::Completion KF5::ConfigWidgets KF5::CoreAddons KF5::Crash KF5::DBusAddons KF5::I18n KF5::IconThemes KF5::KCMUtils KF5::Service KF5::Solid KF5::WidgetsAddons KF5::WindowSystem KF5::XmlGui ) # add clang-format target for all our real source files file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) ##install install( TARGETS kinfocenter ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES org.kde.kinfocenter.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) install( PROGRAMS org.kde.kinfocenter.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) install( FILES kinfocenterui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kinfocenter ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index d120818..faf674c 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,80 +1,74 @@ add_subdirectory( about-distro ) add_subdirectory( usbview ) add_subdirectory( memory ) add_subdirectory( devinfo ) add_subdirectory( info ) -if(NOT WIN32) add_subdirectory( samba ) add_subdirectory( nics ) set(KCM_ENABLE_OPENGL FALSE) set(KCM_ENABLE_OPENGLES FALSE) if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GL")) set(KCM_ENABLE_OPENGL TRUE) endif() if(OPENGLES_FOUND AND (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2")) set(KCM_ENABLE_OPENGLES TRUE) endif() set(KCM_HAVE_GLX ${KCM_ENABLE_OPENGL}) set(KCM_HAVE_EGL ${EGL_FOUND}) if(${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GL") add_feature_info("OpenGL support" OPENGL_FOUND "View OpenGL details in kinfocenter." ) add_feature_info("OpenGL Utility Library (GLU)" OPENGL_GLU_FOUND "Required for OpenGL details in kinfocenter." ) endif() if(${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2") add_feature_info("OpenGL/ES support" KCM_ENABLE_OPENGLES "View OpenGL ES2.0 details in kinfocenter." ) endif() - if(NOT APPLE) - if(KCM_ENABLE_OPENGL OR KCM_ENABLE_OPENGLES) - add_subdirectory( opengl ) - else() - message(STATUS "OpenGL/ES2.0 information module has been disabled.") - endif() - endif() +if(KCM_ENABLE_OPENGL OR KCM_ENABLE_OPENGLES) + add_subdirectory( opengl ) +else() + message(STATUS "OpenGL/ES2.0 information module has been disabled.") +endif() find_package(PCIUTILS MODULE) set_package_properties(PCIUTILS PROPERTIES DESCRIPTION "PciUtils is a library for direct access to PCI slots" URL "https://mj.ucw.cz/sw/pciutils" TYPE OPTIONAL PURPOSE "View PCI details in kinfocenter." ) # PCI module doesn't work on Linux arm64, nor on MacOS, but does on # FreeBSD arm64, so this is a bit of a tangle of what-is-supported. set(_want_pci ON) -if(APPLE) - set(_want_pci OFF) -elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") if (${CMAKE_SYSTEM} MATCHES "FreeBSD") message(STATUS "FreeBSD arm64 pci support enabled.") else() set(_want_pci OFF) endif() endif() if(_want_pci) add_subdirectory( pci ) endif() -endif() find_package(RAW1394 MODULE) set_package_properties(RAW1394 PROPERTIES DESCRIPTION "library for direct access to IEEE 1394 bus" URL "https://ieee1394.wiki.kernel.org/index.php/Main_Page" TYPE OPTIONAL PURPOSE "View FireWire devices in kinfocenter." ) if(RAW1394_FOUND) add_subdirectory( view1394 ) endif() if (CMAKE_SYSTEM_NAME MATCHES Linux) add_subdirectory(energy) add_subdirectory(fileindexermonitor) endif() diff --git a/Modules/base/CMakeLists.txt b/Modules/base/CMakeLists.txt index 75fc33f..79d3914 100644 --- a/Modules/base/CMakeLists.txt +++ b/Modules/base/CMakeLists.txt @@ -1,9 +1,6 @@ -# TODO: HAVE_LIBDEVINFO_H (for Solaris 7 and later) -# to be set if both -ldevinfo and libdevinfo.h exist - include(CheckIncludeFiles) check_include_files(devinfo.h HAVE_DEVINFO_H) # info_fbsd.cpp set(HAVE_WAYLAND ${KF5Wayland_FOUND}) configure_file (../base/config-infocenter.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-infocenter.h ) diff --git a/Modules/base/info_aix.cpp b/Modules/base/info_aix.cpp deleted file mode 100644 index e8428ec..0000000 --- a/Modules/base/info_aix.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* -Copyright 2010 Reza Arbab - -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. -*/ - -#include -#define class _class -#include -#include -#include -#undef class -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -char * device_description(struct CuDv *cudv) { - char *desc= NULL; - struct PdDv *pddv = cudv->PdDvLn; /* link to Predefined Devices database */ - nl_catd cat; - - cat = catopen("/usr/lib/methods/devices.cat", NL_CAT_LOCALE); - if ((int)cat == -1) - return NULL; - - desc = strdup(catgets(cat, pddv->setno, pddv->msgno, "N/A") ); - catclose(cat); - - return desc; -} - -bool list_devices(QListView *lBox, char *criteria) { - struct CuDv *cudv; /* Customized Devices */ - struct listinfo info; - int i; - char *cudv_desc; - QString cudv_status; - QListViewItem *lastitem= NULL; - - lBox->addColumn(i18n("Name")); - lBox->addColumn(i18n("Status")); - lBox->addColumn(i18n("Location")); - lBox->addColumn(i18n("Description")); - - if (odm_initialize() == -1) { - kError(0) << "odm_initialize() failed: odmerrno = " << odmerrno << endl; - return (false); - } - - cudv = (struct CuDv *) odm_get_list(CuDv_CLASS, criteria, &info, 100, 2); - - if ((int)cudv == -1) { - odm_terminate(); - kError(0) << "odm_get_list() failed: odmerrno = " << odmerrno << endl; - return (false); - } else if (!cudv) /* empty list */ - { - odm_terminate(); - return (true); - } - - for (i=0; i tosize) /* E.g., from 2048 to 512. */ - return blocks * (fromsize / tosize); - else - /* E.g., from 256 to 512. */ - return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); -} - -/* Fill in the fields of FSP with information about space usage for - the filesystem on which PATH resides. - Return 0 if successful, -1 if not. */ - -#define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_bsize, 512) - -static int get_fs_usage(char *path, long *l_total, long *l_avail) { - struct statfs fsd; /* 4.3BSD, SunOS 4, HP-UX, AIX. */ - unsigned long fsu_blocks, fsu_bfree, fsu_bavail; - - *l_total = *l_avail = 0; - if (statfs(path, &fsd) < 0) - return -1; - - fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks); - fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree); - fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail); - - *l_avail = getuid() ? fsu_bavail/2 : fsu_bfree/2; - *l_total = fsu_blocks/2; - - return 0; -} diff --git a/Modules/base/info_hpux.cpp b/Modules/base/info_hpux.cpp deleted file mode 100644 index aec89fd..0000000 --- a/Modules/base/info_hpux.cpp +++ /dev/null @@ -1,235 +0,0 @@ - -/* -Copyright 1998 Helge Deller deller@gmx.de - -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) version 3 or any later version -accepted by the membership of KDE e.V. (or its successor approved -by the membership of KDE e.V.), which shall act as a proxy -defined in Section 14 of version 3 of the license. - -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 . -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -# define INFO_PCI "" // Please, who know it ???? -# define INFO_PCI_EISA "/etc/eisa/system.sci" // File ! -# define INFO_IOPORTS_1 "/etc/dmesg" // as pipe ! -# define INFO_IOPORTS_2 "/usr/sbin/dmesg" // as pipe ! -# define INFO_DEVICES "/etc/ioscan" // as pipe !! - -/* The following table is from an HP-UX 10.20 System - build out of the files - "/usr/lib/sched.models" - or - "/opt/langtools/lib/sched.models" - If you have more entries, then please add them or send them to me! - */ - -// entries for PA_REVISION[] -enum V_ENTRIES -{ V_1x0, - V_1x1, V_1x1a, V_1x1b, V_1x1c, V_1x1d, V_1x1e, - V_2x0, - V_LAST}; - -static const char PA_REVISION[V_LAST][7] = { "1.0", "1.1", "1.1a", "1.1b", "1.1c", "1.1d", "1.1e", "2.0" }; - -// entries for PA_NAME[] -enum PA_ENTRIES -{ PA7000, - PA7100, PA7100LC, PA7200, PA7300, - PA8000, PA8200, PA8500, - PARISC_PA_LAST}; - -static const char PA_NAME[PARISC_PA_LAST][11] = { "PA7000", "PA7100", "PA7100LC", "PA7200", "PA7300", "PA8000", "PA8200", "PA8500" }; - -struct _type_LOOKUPTABLE { - char Name[8]; - unsigned short parisc_rev; // = enum V_ENTRIES - unsigned short parisc_name; // = enum PA_ENTRIES -}; - -static const struct _type_LOOKUPTABLE PA_LOOKUPTABLE[] = { -/* VERSION A.00.07 - (there seems to exist several different files with same version-number !)*/ -{ "600", V_1x0, PA7000 }, { "635", V_1x0, PA7000 }, { "645", V_1x0, PA7000 }, { "700", V_1x1, PA7000 }, { "705", V_1x1a, PA7000 }, { "710", V_1x1a, PA7000 }, { "712", V_1x1c, PA7100LC }, { "715", V_1x1c, PA7100LC }, { "720", V_1x1a, PA7000 }, { "722", V_1x1c, PA7100LC }, - { "725", V_1x1c, PA7100LC }, { "728", V_1x1d, PA7200 }, { "730", V_1x1a, PA7000 }, { "735", V_1x1b, PA7100 }, - { "742", V_1x1b, PA7100 }, - { "743", V_1x1b, PA7100 }, // or a 1.1c,PA7100LC !! - { "744", V_1x1e, PA7300 }, { "745", V_1x1b, PA7100 }, { "747", V_1x1b, PA7100 }, { "750", V_1x1a, PA7000 }, { "755", V_1x1b, PA7100 }, { "770", V_1x1d, PA7200 }, { "777", V_1x1d, PA7200 }, { "778", V_1x1e, PA7300 }, { "779", V_1x1e, PA7300 }, { "780", V_2x0, PA8000 }, - { "781", V_2x0, PA8000 }, { "782", V_2x0, PA8200 }, { "783", V_2x0, PA8500 }, { "785", V_2x0, PA8500 }, - { "800", V_1x0, PA7000 }, // and one with: 2.0 / PA8000 - { "801", V_1x1c, PA7100LC }, { "802", V_2x0, PA8000 }, { "803", V_1x1e, PA7300 }, { "804", V_2x0, PA8000 }, { "806", V_1x1c, PA7100LC }, { "807", V_1x1a, PA7000 }, { "808", V_1x0, PA7000 }, { "809", V_1x1d, PA7200 }, { "810", V_2x0, PA8000 }, { "811", V_1x1c, PA7100LC }, { "813", V_1x1e, - PA7300 }, { "815", V_1x0, PA7000 }, { "816", V_1x1c, PA7100LC }, { "817", V_1x1a, PA7000 }, { "819", V_1x1d, PA7200 }, { "820", V_2x0, PA8000 }, { "821", V_1x1d, PA7200 }, { "822", V_1x0, PA7000 }, { "825", V_1x0, PA7000 }, { "826", V_1x1c, PA7100LC }, { "827", V_1x1a, PA7000 }, { - "829", V_1x1d, PA7200 }, { "831", V_1x1d, PA7200 }, { "832", V_1x0, PA7000 }, { "834", V_1x0, PA7000 }, { "835", V_1x0, PA7000 }, { "837", V_1x1a, PA7000 }, { "839", V_1x1d, PA7200 }, { "840", V_1x0, PA7000 }, { "841", V_1x1d, PA7200 }, { "842", V_1x0, PA7000 }, { "845", V_1x0, - PA7000 }, { "847", V_1x1a, PA7000 }, { "849", V_1x1d, PA7200 }, { "850", V_1x0, PA7000 }, { "851", V_1x1d, PA7200 }, { "852", V_1x0, PA7000 }, { "855", V_1x0, PA7000 }, { "856", V_1x1c, PA7100LC }, { "857", V_1x1a, PA7000 }, { "859", V_1x1d, PA7200 }, { "860", V_1x0, PA7000 }, { - "861", V_2x0, PA8000 }, { "865", V_1x0, PA7000 }, { "869", V_1x1d, PA7200 }, { "870", V_1x0, PA7000 }, { "871", V_2x0, PA8000 }, { "877", V_1x1a, PA7000 }, { "879", V_2x0, PA8000 }, { "887", V_1x1b, PA7100 }, { "889", V_2x0, PA8000 }, { "890", V_1x0, PA7000 }, { "891", V_1x1b, - PA7100 }, { "892", V_1x1b, PA7100 }, { "893", V_2x0, PA8000 }, { "895", V_2x0, PA8000 }, { "896", V_2x0, PA8000 }, { "897", V_1x1b, PA7100 }, { "898", V_2x0, PA8200 }, { "899", V_2x0, PA8200 }, { "900", V_1x0, PA7000 }, { "B115", V_1x1e, PA7300 }, { "B120", V_1x1e, PA7300 }, { - "B132L", V_1x1e, PA7300 }, { "B160L", V_1x1e, PA7300 }, { "B180L", V_1x1e, PA7300 }, { "C100", V_1x1d, PA7200 }, { "C110", V_1x1d, PA7200 }, { "C115", V_1x1e, PA7300 }, { "C120", V_1x1e, PA7300 }, { "C130", V_2x0, PA8000 }, { "C140", V_2x0, PA8000 }, { "C160L", V_1x1e, PA7300 }, { - "C160", V_2x0, PA8000 }, { "C180L", V_1x1e, PA7300 }, { "C180-XP", V_2x0, PA8000 }, { "C180", V_2x0, PA8000 }, { "C200+", V_2x0, PA8200 }, { "C230+", V_2x0, PA8200 }, { "C240+", V_2x0, PA8200 }, { "CB260", V_2x0, PA8200 }, - { "D200", V_1x1d, PA7200 }, // or: 1.1c, PA7100LC - { "D210", V_1x1d, PA7200 }, // or: 1.1c, PA7100LC - { "D220", V_1x1e, PA7300 }, { "D230", V_1x1e, PA7300 }, { "D250", V_1x1d, PA7200 }, { "D260", V_1x1d, PA7200 }, { "D270", V_2x0, PA8000 }, { "D280", V_2x0, PA8000 }, { "D310", V_1x1c, PA7100LC }, { "D320", V_1x1e, PA7300 }, { "D330", V_1x1e, PA7300 }, { "D350", V_1x1d, PA7200 }, { "D360", - V_1x1d, PA7200 }, { "D370", V_2x0, PA8000 }, { "D380", V_2x0, PA8000 }, { "D400", V_1x1d, PA7200 }, { "D410", V_1x1d, PA7200 }, { "D650", V_2x0, PA8000 }, { "DX0", V_1x1c, PA7100LC }, { "DX5", V_1x1c, PA7100LC }, { "DXO", V_1x1c, PA7100LC }, { "E25", V_1x1c, PA7100LC }, { "E35", - V_1x1c, PA7100LC }, { "E45", V_1x1c, PA7100LC }, { "E55", V_1x1c, PA7100LC }, { "F10", V_1x1a, PA7000 }, { "F20", V_1x1a, PA7000 }, { "F30", V_1x1a, PA7000 }, { "G30", V_1x1a, PA7000 }, { "G40", V_1x1a, PA7000 }, { "G50", V_1x1b, PA7100 }, { "G60", V_1x1b, PA7100 }, { "G70", V_1x1b, - PA7100 }, { "H20", V_1x1a, PA7000 }, { "H30", V_1x1a, PA7000 }, { "H40", V_1x1a, PA7000 }, { "H50", V_1x1b, PA7100 }, { "H60", V_1x1b, PA7100 }, { "H70", V_1x1b, PA7100 }, { "I30", V_1x1a, PA7000 }, { "I40", V_1x1a, PA7000 }, { "I50", V_1x1b, PA7100 }, { "I60", V_1x1b, PA7100 }, { - "I70", V_1x1b, PA7100 }, { "J200", V_1x1d, PA7200 }, { "J210XC", V_1x1d, PA7200 }, { "J210", V_1x1d, PA7200 }, { "J220", V_2x0, PA8000 }, { "J2240", V_2x0, PA8200 }, { "J280", V_2x0, PA8000 }, { "J282", V_2x0, PA8000 }, { "J400", V_2x0, PA8000 }, { "J410", V_2x0, PA8000 }, { "K100", - V_1x1d, PA7200 }, { "K200", V_1x1d, PA7200 }, { "K210", V_1x1d, PA7200 }, { "K230", V_1x1d, PA7200 }, { "K250", V_2x0, PA8000 }, { "K260", V_2x0, PA8000 }, { "K370", V_2x0, PA8200 }, { "K380", V_2x0, PA8200 }, { "K400", V_1x1d, PA7200 }, { "K410", V_1x1d, PA7200 }, { "K420", V_1x1d, - PA7200 }, { "K430", V_1x1d, PA7200 }, { "K450", V_2x0, PA8000 }, { "K460", V_2x0, PA8000 }, { "K470", V_2x0, PA8200 }, { "K570", V_2x0, PA8200 }, { "K580", V_2x0, PA8200 }, { "S700i", V_1x1e, PA7300 }, { "S715", V_1x1e, PA7300 }, { "S744", V_1x1e, PA7300 }, - { "S760", V_1x1e, PA7300 }, { "T500", V_1x1c, PA7100LC }, // or: 1.1b, PA7100 - { "T520", V_1x1b, PA7100 }, { "T540", V_2x0, PA8000 }, { "T600", V_2x0, PA8000 }, { "V2000", V_2x0, PA8000 }, { "V2200", V_2x0, PA8200 }, { "V2250", V_2x0, PA8200 }, { "V2500", V_2x0, PA8500 }, - - { "", 0, 0 } /* Last Entry has to be empty. */ -}; - -/* Helper-Functions */ - -// Value() is defined in info.cpp !!! - -static bool Find_in_LOOKUPTABLE(QListView *lBox, char *machine) { - char *Machine; - int len; - const struct _type_LOOKUPTABLE *Entry = PA_LOOKUPTABLE; - QString str; - QListViewItem* olditem = 0; - - Machine = machine; // machine is like: "9000/715/D" - while ((*Machine) && (*Machine!='/')) - ++Machine; - - if (*Machine) - ++Machine; - else - Machine=machine; - - len = strlen(Machine); - - while (Entry->Name[0]) { - if (strncmp(Entry->Name, Machine, len)==0) { - olditem = new QListViewItem(lBox, olditem, i18n("PA-RISC Processor"), - QString(PA_NAME[Entry->parisc_name])); - olditem = new QListViewItem(lBox, olditem, i18n("PA-RISC Revision"), - QString("PA-RISC ") + QString(PA_REVISION[Entry->parisc_rev])); - return true; - } else - ++Entry; // next Entry ! - } - - return false; -} - -/* all following functions should return true, when the Information - was filled into the lBox-Widget. - returning false indicates, that information was not available. - */ - -bool GetInfo_ReadfromFile(QListView *lBox, const char *Name) { - char buf[2048]; - - QFile *file = new QFile(Name); - QListViewItem* olditem = 0; - - if (!file->open(QIODevice::ReadOnly)) { - delete file; - return false; - } - - while (file->readLine(buf, sizeof(buf)-1) >= 0) { - if (strlen(buf)) - olditem = new QListViewItem(lBox, olditem, QString::fromLocal8Bit(buf)); - } - - file->close(); - delete file; - return (lBox->childCount()); -} - -bool GetInfo_IRQ(QListView *) { - return false; -} - -bool GetInfo_DMA(QListView *) { - return false; -} - -bool GetInfo_PCI(QTreeWidget* tree) { - return (GetInfo_ReadfromFile(tree, INFO_PCI) + GetInfo_ReadfromFile(tree, INFO_PCI_EISA) ); -} - -bool GetInfo_IO_Ports(QListView *lBox) { - if (GetInfo_ReadfromPipe(lBox, INFO_IOPORTS_1, false)) - return true; - else - return GetInfo_ReadfromPipe(lBox, INFO_IOPORTS_2, false); -} - -/* Parts taken from fsusage.c from the Midnight Commander (mc) - - Copyright (C) 1991, 1992 Free Software Foundation, In - - Return the number of TOSIZE-byte blocks used by - BLOCKS FROMSIZE-byte blocks, rounding away from zero. - TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ - -static long fs_adjust_blocks(long blocks, int fromsize, int tosize) { - if (tosize <= 0) - abort(); - if (fromsize <= 0) - return -1; - - if (fromsize == tosize) /* E.g., from 512 to 512. */ - return blocks; - else if (fromsize > tosize) /* E.g., from 2048 to 512. */ - return blocks * (fromsize / tosize); - else - /* E.g., from 256 to 512. */ - return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); -} - -/* Fill in the fields of FSP with information about space usage for - the filesystem on which PATH resides. - Return 0 if successful, -1 if not. */ - -#define CONVERT_BLOCKS(b) fs_adjust_blocks ((b), fsd.f_bsize, 512) - -static int get_fs_usage(char *path, long *l_total, long *l_avail) { - struct statfs fsd; /* 4.3BSD, SunOS 4, HP-UX, AIX. */ - unsigned long fsu_blocks, fsu_bfree, fsu_bavail; - - *l_total = *l_avail = 0; - if (statfs(path, &fsd) < 0) - return -1; - - fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks); - fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree); - fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail); - - *l_avail = getuid() ? fsu_bavail/2 : fsu_bfree/2; - *l_total = fsu_blocks/2; - - return 0; -} - -bool GetInfo_XServer_and_Video(QListView *lBox) { - lBox = lBox; - return GetInfo_XServer_Generic(lBox); -} diff --git a/Modules/base/info_osx.cpp b/Modules/base/info_osx.cpp deleted file mode 100644 index 9b7cc0a..0000000 --- a/Modules/base/info_osx.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2003 Benjamin Reed - * - * info_osx.cpp is part of the KDE program kcminfo. Copied wholesale - * from info_fbsd.cpp =) - * - * 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. - */ - -/* - * all following functions should return true, when the Information - * was filled into the lBox-Widget. Returning false indicates that - * information was not available. - */ - -#include -#include - -#include -#include -#include - -#include - - - -#include -#include - -#include - -bool GetInfo_IRQ(QTreeWidget*) { - return false; -} - -bool GetInfo_DMA(QTreeWidget*) { - return false; -} - -bool GetInfo_PCI(QTreeWidget*) { - return false; -} - -bool GetInfo_IO_Ports(QTreeWidget*) { - return false; -} - -bool GetInfo_XServer_and_Video(QTreeWidget* tree) { -#if HAVE_X11 - return GetInfo_XServer_Generic(tree); -#else - return false; -#endif -} diff --git a/Modules/base/info_sgi.cpp b/Modules/base/info_sgi.cpp deleted file mode 100644 index 9d5f7d9..0000000 --- a/Modules/base/info_sgi.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* info_sgi.cpp - - !!!!! this file will be included by info.cpp !!!!! - */ - -/* all following functions should return true, when the Information - was filled into the lBox-Widget. - returning false indicates, that information was not available. - */ - -#include - -bool GetInfo_IRQ(QListView *) { - return false; -} - -bool GetInfo_DMA(QListView *) { - return false; -} - -bool GetInfo_PCI(QTreeWidget*) { - return false; -} - -bool GetInfo_IO_Ports(QListView *) { - return false; -} - -bool GetInfo_XServer_and_Video(QListView *lBox) { - return GetInfo_XServer_Generic(lBox); -} - diff --git a/Modules/base/info_solaris.cpp b/Modules/base/info_solaris.cpp deleted file mode 100644 index 61f871b..0000000 --- a/Modules/base/info_solaris.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * info_solaris.cpp - * - * Torsten Kasch - */ - -#include "config-infocenter.h" - - -#include -#include -#include -#include -#include -#include - -bool GetInfo_IRQ(QTreeWidget*) { - return false; -} - -bool GetInfo_DMA(QTreeWidget*) { - return false; -} - -bool GetInfo_PCI(QTreeWidget*) { - return false; -} - -bool GetInfo_IO_Ports(QTreeWidget*) { - return false; -} - -bool GetInfo_XServer_and_Video(QTreeWidget* tree) { - return GetInfo_XServer_Generic(tree); -} diff --git a/Modules/base/os_current.cpp b/Modules/base/os_current.cpp index 995bc4c..da61f16 100644 --- a/Modules/base/os_current.cpp +++ b/Modules/base/os_current.cpp @@ -1,46 +1,36 @@ /* Copyright 2010 Nicolas Ternisien 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) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. 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, see . */ #include "os_current.h" #include "os_base.h" #ifdef __linux__ - #include "info_linux.cpp" -#elif defined(sgi) && sgi - #include "info_sgi.cpp" + #include "info_linux.cpp" #elif defined(__FreeBSD__) || defined(__DragonFly__) - #include "info_fbsd.cpp" -#elif defined(__hpux) - #include "info_hpux.cpp" + #include "info_fbsd.cpp" #elif defined(__NetBSD__) #include "info_netbsd.cpp" #elif defined(__OpenBSD__) - #include "info_openbsd.cpp" -#elif defined(__svr4__) && defined(sun) - #include "info_solaris.cpp" -#elif defined(_AIX) - #include "info_aix.cpp" -#elif defined(__APPLE__) - #include "info_osx.cpp" + #include "info_openbsd.cpp" #else #include "info_generic.cpp" /* Default for unsupported systems.... */ #endif diff --git a/Modules/base/os_current.h b/Modules/base/os_current.h index 884f3fe..c7583de 100644 --- a/Modules/base/os_current.h +++ b/Modules/base/os_current.h @@ -1,136 +1,87 @@ /* Copyright 2010 Nicolas Ternisien 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) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. 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, see . */ #ifndef OS_CURRENT_H_ #define OS_CURRENT_H_ class QTreeWidget; class QString; /* function call-back-prototypes... */ bool GetInfo_IRQ(QTreeWidget* tree); bool GetInfo_DMA(QTreeWidget* tree); bool GetInfo_PCI(QTreeWidget* tree); bool GetInfo_IO_Ports(QTreeWidget* tree); bool GetInfo_XServer_and_Video(QTreeWidget* tree); bool GetInfo_Wayland(QTreeWidget* tree); #ifdef __linux__ #define INFO_IRQ_AVAILABLE #define INFO_DMA_AVAILABLE #define INFO_IOPORTS_AVAILABLE #define INFO_XSERVER_AVAILABLE #define INFO_WAYLAND_AVAILABLE /* i18n("Maybe the proc-filesystem is not enabled in Linux-Kernel.") */ #define DEFAULT_ERRORSTRING QString() - -#elif defined(sgi) && sgi - - #define INFO_IRQ_AVAILABLE - #define INFO_DMA_AVAILABLE - #define INFO_IOPORTS_AVAILABLE - #define INFO_XSERVER_AVAILABLE - - #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") - #elif defined(__FreeBSD__) || defined(__DragonFly__) #define INFO_IRQ_AVAILABLE #define INFO_DMA_AVAILABLE #define INFO_IOPORTS_AVAILABLE #define INFO_XSERVER_AVAILABLE #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") -#elif defined(__hpux) - - #define INFO_IRQ_AVAILABLE - #define INFO_DMA_AVAILABLE - #define INFO_IOPORTS_AVAILABLE - - - #define INFO_XSERVER_AVAILABLE - - #define DEFAULT_ERRORSTRING QString() - #elif defined(__NetBSD__) #define INFO_IRQ_AVAILABLE #define INFO_DMA_AVAILABLE #define INFO_IOPORTS_AVAILABLE #define INFO_XSERVER_AVAILABLE #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") #elif defined(__OpenBSD__) #define INFO_IRQ_AVAILABLE #define INFO_DMA_AVAILABLE #define INFO_IOPORTS_AVAILABLE #define INFO_XSERVER_AVAILABLE #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") -#elif defined(__svr4__) && defined(sun) - - #define INFO_IRQ_AVAILABLE - #define INFO_DMA_AVAILABLE - #define INFO_IOPORTS_AVAILABLE - #define INFO_XSERVER_AVAILABLE - - #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") - -#elif defined(_AIX) - - - #define INFO_IRQ_AVAILABLE - #define INFO_DMA_AVAILABLE - #define INFO_IOPORTS_AVAILABLE - #define INFO_XSERVER_AVAILABLE - - #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") - -#elif defined(__APPLE__) - - //#define INFO_IRQ_AVAILABLE - //#define INFO_DMA_AVAILABLE - //#define INFO_IOPORTS_AVAILABLE - #define INFO_XSERVER_AVAILABLE - - #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") - #else #define INFO_IRQ_AVAILABLE #define INFO_DMA_AVAILABLE #define INFO_IOPORTS_AVAILABLE #define INFO_XSERVER_AVAILABLE #define DEFAULT_ERRORSTRING i18n("This system may not be completely supported yet.") #endif #endif /*OS_CURRENT_H_*/ diff --git a/Modules/memory/base.h b/Modules/memory/base.h index cc62585..dc84816 100644 --- a/Modules/memory/base.h +++ b/Modules/memory/base.h @@ -1,48 +1,43 @@ #ifndef BASE_H_ #define BASE_H_ #include #define COLOR_USED_MEMORY QColor(0x83,0xDD, 0xF5) //start : 0x00, 0x71, 0xBC //end : 0x83,0xDD, 0xF5 //#define COLOR_USED_MEMORY QColor(236,91,47) #define COLOR_USED_SWAP QColor(255,134,64) //#define COLOR_FREE_MEMORY QColor(0x00, 0x71, 0xBC) #define COLOR_FREE_MEMORY QColor(216, 231, 227) /* better to use quint64, because some 32bit-machines have more total memory (with swap) than just the 4GB which fits into a 32bit-long */ typedef quint64 t_memsize; enum { /* entries for memoryInfos[] */ TOTAL_MEM = 0, /* total physical memory (without swaps) */ - FREE_MEM, /* total free physical memory (without swaps) */ -#if !defined(__svr4__) || !defined(sun) + FREE_MEM, /* total free physical memory (without swaps) */ #if !defined(__NetBSD__) && !defined(__OpenBSD__) SHARED_MEM, /* shared memory size */ - BUFFER_MEM, /* buffered memory size */ -#else - ACTIVE_MEM, - INACTIVE_MEM, -#endif + BUFFER_MEM, /* buffered memory size */ #endif CACHED_MEM, /* cache memory size (located in ram) */ SWAP_MEM, /* total size of all swap-partitions */ FREESWAP_MEM, /* free memory in swap-partitions */ MEM_LAST_ENTRY }; #define MEMORY(x) ((t_memsize) (x)) /* it's easier... */ #define NO_MEMORY_INFO MEMORY(-1) /* DO NOT CHANGE */ #define ZERO_IF_NO_INFO(value) ((value) != NO_MEMORY_INFO ? (value) : 0) #define SPACING 16 #endif /*BASE_H_*/ diff --git a/Modules/memory/memory.cpp b/Modules/memory/memory.cpp index edb6783..45bb092 100644 --- a/Modules/memory/memory.cpp +++ b/Modules/memory/memory.cpp @@ -1,317 +1,305 @@ /* * memory.cpp * * Copyright (C) 2008 Ivo Anjo * * 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. */ #include "memory.h" #include #include #include #include #include #include /* for BSD */ #include #include #include #include "chartWidget.h" #include "physicalMemoryChart.h" #include "totalMemoryChart.h" #include "swapMemoryChart.h" /* all fetchValues()-functions should put either their results _OR_ the value NO_MEMORY_INFO into memoryInfos[] */ static t_memsize memoryInfos[MEM_LAST_ENTRY]; /******************/ /* Implementation */ /******************/ static QLabel *memorySizeLabels[MEM_LAST_ENTRY][2]; K_PLUGIN_FACTORY(KCMMemoryFactory, registerPlugin(); ) KCMMemory::KCMMemory(QWidget *parent, const QVariantList &) : KCModule(parent) { KAboutData *about = new KAboutData(i18n("kcm_memory"), i18n("KDE Panel Memory Information Control Module"), QString(), QString(), KAboutLicense::GPL, i18n("(c) 1998 - 2002 Helge Deller")); about->addAuthor(i18n("Helge Deller"), QString(), QStringLiteral("deller@gmx.de")); setAboutData(about); QString title, initial_str; setButtons(Help); QVBoxLayout *top = new QVBoxLayout(this); top->setContentsMargins(0, 0, 0, 0); top->setSpacing(1); QGroupBox* informationGroup = initializeText(); top->addWidget(informationGroup, 1); // Now the Graphics QGroupBox* graphicsGroup = initializeCharts(); top->addWidget(graphicsGroup, 2); timer = new QTimer(this); timer->start(100); connect(timer, &QTimer::timeout, this, &KCMMemory::updateDatas); updateDatas(); } KCMMemory::~KCMMemory() { /* stop the timer */ timer->stop(); } QString KCMMemory::quickHelp() const { return i18n("This display shows you the current memory usage of your system." " The values are updated on a regular basis and give you an" " overview of the physical and virtual memory being used."); } QGroupBox* KCMMemory::initializeText() { QGroupBox* informationGroup = new QGroupBox(i18n("Memory")); QHBoxLayout *hbox = new QHBoxLayout(informationGroup); /* stretch the left side */ hbox->addStretch(); QString title; //TODO Use the more smart QGridLayout !!! /* first create the Informationtext-Widget */ QVBoxLayout *vbox = new QVBoxLayout(); hbox->addLayout(vbox); vbox->setSpacing(0); for (int i = TOTAL_MEM; i < MEM_LAST_ENTRY; ++i) { switch (i) { case TOTAL_MEM: title = i18n("Total physical memory:"); break; case FREE_MEM: title = i18n("Free physical memory:"); break; -#if !defined(__svr4__) || !defined(sun) #if !defined(__NetBSD__) && !defined(__OpenBSD__) case SHARED_MEM: title = i18n("Shared memory:"); break; case BUFFER_MEM: title = i18n("Disk buffers:"); break; #else case ACTIVE_MEM: title = i18n("Active memory:"); break; case INACTIVE_MEM: title = i18n("Inactive memory:"); break; -#endif #endif case CACHED_MEM: title = i18n("Disk cache:"); break; case SWAP_MEM: vbox->addSpacing(SPACING); title = i18n("Total swap memory:"); break; case FREESWAP_MEM: title = i18n("Free swap memory:"); break; default: title = QLatin1String(""); break; }; QLabel* labelWidget = new QLabel(title, this); labelWidget->setTextInteractionFlags(Qt::TextSelectableByMouse); labelWidget->setAlignment(Qt::AlignLeft); vbox->addWidget(labelWidget); } vbox->addStretch(); /* then the memory-content-widgets */ for (int j = 0; j < 2; j++) { vbox = new QVBoxLayout(); hbox->addLayout(vbox); vbox->setSpacing(0); for (int i = TOTAL_MEM; i < MEM_LAST_ENTRY; ++i) { if (i == SWAP_MEM) vbox->addSpacing(SPACING); QLabel* labelWidget = new QLabel(this); labelWidget->setTextInteractionFlags(Qt::TextSelectableByMouse); labelWidget->setAlignment(Qt::AlignRight); memorySizeLabels[i][j] = labelWidget; vbox->addWidget(labelWidget); } vbox->addStretch(); } /* stretch the right side */ hbox->addStretch(); return informationGroup; } QGroupBox* KCMMemory::initializeCharts() { QGroupBox* chartsGroup = new QGroupBox(i18n("Charts")); QHBoxLayout* chartsLayout = new QHBoxLayout(chartsGroup); chartsLayout->setSpacing(1); chartsLayout->setContentsMargins(1, 1, 1, 1); //chartsLayout->addStretch(1); totalMemory = new ChartWidget(i18n("Total Memory"), i18n("This graph gives you an overview of the " "total sum of physical and virtual memory " "in your system."), new TotalMemoryChart(this), this); chartsLayout->addWidget(totalMemory); chartsLayout->addSpacing(SPACING); physicalMemory = new ChartWidget(i18n("Physical Memory"), i18n("This graph gives you an overview of " "the usage of physical memory in your system." "

Most operating systems (including Linux) " "will use as much of the available physical " "memory as possible as disk cache, " "to speed up the system performance.

" "

This means that if you have a small amount " "of Free Physical Memory and a large amount of " "Disk Cache Memory, your system is well " "configured.

"), new PhysicalMemoryChart(this), this); chartsLayout->addWidget(physicalMemory); chartsLayout->addSpacing(SPACING); swapMemory = new ChartWidget(i18n("Swap Space"), i18n("

The swap space is the virtual memory " "available to the system.

" "

It will be used on demand and is provided " "through one or more swap partitions and/or swap files.

"), new SwapMemoryChart(this), this); chartsLayout->addWidget(swapMemory); //chartsLayout->addStretch(1); return chartsGroup; } void KCMMemory::updateDatas() { /* get the Information from memory_linux, memory_fbsd */ fetchValues(); updateMemoryText(); updateMemoryGraphics(); } void KCMMemory::updateMemoryText() { /* update the byte-strings */ for (int i = TOTAL_MEM; i < MEM_LAST_ENTRY; i++) { QLabel* label = memorySizeLabels[i][0]; if (memoryInfos[i] == NO_MEMORY_INFO) label->clear(); else label->setText(i18np("1 byte =", "%1 bytes =", memoryInfos[i])); } /* update the MB-strings */ for (int i = TOTAL_MEM; i < MEM_LAST_ENTRY; i++) { QLabel* label = memorySizeLabels[i][1]; label->setText((memoryInfos[i] != NO_MEMORY_INFO) ? Chart::formattedUnit(memoryInfos[i]) : i18n("Not available.")); } } void KCMMemory::updateMemoryGraphics() { totalMemory->setMemoryInfos(memoryInfos); totalMemory->refresh(); physicalMemory->setMemoryInfos(memoryInfos); physicalMemory->refresh(); swapMemory->setMemoryInfos(memoryInfos); swapMemory->refresh(); } /* Include system-specific code */ #ifdef __linux__ #include "memory_linux.cpp" -#elif defined(__APPLE__) -#include "memory_osx.cpp" -#elif defined(sgi) && sgi -#include "memory_sgi.cpp" -#elif defined(__svr4__) && defined(sun) -#include "memory_solaris.cpp" #elif defined(__FreeBSD__) || defined(__DragonFly__) #include "memory_fbsd.cpp" -#elif defined(__hpux) -#include "memory_hpux.cpp" #elif defined(__NetBSD__) || defined(__OpenBSD__) #include "memory_netbsd.cpp" -#elif defined(__osf__) -#include "memory_tru64.cpp" #else /* Default for unsupported systems */ void KCMMemory::fetchValues() { int i; for (i = TOTAL_MEM; i < MEM_LAST_ENTRY; ++i) { memoryInfos[i] = NO_MEMORY_INFO; } } #endif #include "memory.moc" diff --git a/Modules/memory/memory_hpux.cpp b/Modules/memory/memory_hpux.cpp deleted file mode 100644 index 468a6a5..0000000 --- a/Modules/memory/memory_hpux.cpp +++ /dev/null @@ -1,95 +0,0 @@ - -/* -Copyright 1999 Helge Deller deller@gmx.de - -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) version 3 or any later version -accepted by the membership of KDE e.V. (or its successor approved -by the membership of KDE e.V.), which shall act as a proxy -defined in Section 14 of version 3 of the license. - -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 . -*/ - -#include -#include -#include -#include - - -#define MAX_SWAP_AREAS 16 - -void KCMMemory::fetchValues() -{ - int page_size,i; - unsigned long total_mem, total_free, - total_physical, total_swap, free_physical, - used_physical, used_swap, free_swap; - - struct pst_static pststatic; - struct pst_dynamic stats; - struct pst_vminfo vmstats; - unsigned long fields_[4]; - struct pst_swapinfo swapinfo; - - pstat_getstatic( &pststatic, sizeof( struct pst_static ), (size_t)1, 0); - total_physical = pststatic.physical_memory; - page_size = (int)pststatic.page_size; - - pstat_getdynamic(&stats, sizeof( pst_dynamic ), (size_t)1, 0); - pstat_getvminfo(&vmstats, sizeof(vmstats), (size_t)1, 0); - - fields_[0] = stats.psd_rmtxt + stats.psd_arm; // TEXT - fields_[1] = stats.psd_rm - stats.psd_rmtxt; // USED - fields_[2] = total_physical - fields_[0] - fields_[1] - stats.psd_free; //OTHER - fields_[3] = stats.psd_free; // FREE - - used_physical = (total_physical - fields_[3]) * page_size; - total_physical *= page_size; - free_physical = (total_physical - used_physical); - - - /* Now check the SWAP-AREAS !! */ - - total_swap = free_swap = 0; - - for (i = 0 ; i < MAX_SWAP_AREAS ; i++) - { - pstat_getswap(&swapinfo, sizeof(swapinfo), (size_t)1, i); - if (swapinfo.pss_idx == (unsigned)i) - { - swapinfo.pss_nfpgs *= 4; // nfpgs is in 512 Byte Blocks.... - if (swapinfo.pss_nblksenabled == 0) // == 0 ?? - swapinfo.pss_nblksenabled = swapinfo.pss_nfpgs; - total_swap += (((unsigned long)swapinfo.pss_nblksenabled) * 1024); - free_swap += (((unsigned long)swapinfo.pss_nfpgs ) * 1024); - } - } - - used_swap = total_swap - free_swap; - - - /* Now display the results */ - - total_mem = total_physical; // + total_swap; - total_free = (total_physical - used_physical);// + free_swap; - - memoryInfos[TOTAL_MEM] = MEMORY(total_mem); // total physical memory (without swaps) - memoryInfos[FREE_MEM] = MEMORY(total_free);// total free physical memory (without swaps) - memoryInfos[SHARED_MEM] = NO_MEMORY_INFO; /* FIXME ?? */ - memoryInfos[BUFFER_MEM] = MEMORY(fields_[2])*page_size; /* FIXME ?? */ - memoryInfos[SWAP_MEM] = MEMORY(total_swap); // total size of all swap-partitions - memoryInfos[FREESWAP_MEM] = MEMORY(free_swap); // free memory in swap-partitions -#ifdef __GNUC__ -#warning "FIXME: memoryInfos[CACHED_MEM]" -#endif - memoryInfos[CACHED_MEM] = NO_MEMORY_INFO; // cached memory in ram -} diff --git a/Modules/memory/memory_osx.cpp b/Modules/memory/memory_osx.cpp deleted file mode 100644 index 5ac7542..0000000 --- a/Modules/memory/memory_osx.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -/* - * Copyright (c) 2003 Benjamin Reed - * - * memory_osx.cpp is part of the KDE program kcminfo. Copied wholesale - * from memory_fbsd.cpp =) - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -void KCMMemory::fetchValues() -{ - - vm_statistics_data_t vm_info; - mach_msg_type_number_t info_count; - DIR *dirp; - struct dirent *dp; - t_memsize total; - - info_count = HOST_VM_INFO_COUNT; - if (host_statistics(mach_host_self (), HOST_VM_INFO, (host_info_t)&vm_info, &info_count)) { - qDebug() << "could not get memory statistics"; - return; - } - - memoryInfos[TOTAL_MEM] = MEMORY(vm_info.active_count + vm_info.inactive_count + - vm_info.free_count + vm_info.wire_count) * vm_page_size; - memoryInfos[FREE_MEM] = MEMORY(vm_info.free_count) * vm_page_size; - memoryInfos[SHARED_MEM] = NO_MEMORY_INFO; - memoryInfos[BUFFER_MEM] = NO_MEMORY_INFO; - memoryInfos[CACHED_MEM] = NO_MEMORY_INFO; - - dirp = opendir("/private/var/vm"); - if (!dirp) { - qDebug() << "unable to open /private/var/vm"; - return; - } - - total = 0; - - while ((dp = readdir (dirp)) != NULL) { - struct stat sb; - char fname [MAXNAMLEN]; - - if (strncmp (dp->d_name, "swapfile", 8)) - continue; - - strcpy (fname, "/private/var/vm/"); - strcat (fname, dp->d_name); - if (stat (fname, &sb) < 0) - continue; - - total += sb.st_size; - } - closedir (dirp); - - info_count = HOST_VM_INFO_COUNT; - if (host_statistics (mach_host_self (), HOST_VM_INFO, - (host_info_t) &vm_info, &info_count)) { - qDebug() << "unable to get VM info"; - } - - memoryInfos[SWAP_MEM] = total; - // off_t used = (vm_info.pageouts - vm_info.pageins) * vm_page_size; - memoryInfos[FREESWAP_MEM] = NO_MEMORY_INFO; - - /* free = MEMORY(vm_info.free_count) * vm_page_size; - used = MEMORY(vm_info.active_count) * vm_page_size; - total = MEMORY(vm_info.active_count + vm_info.inactive_count + - vm_info.free_count + vm_info.wire_count) * vm_page_size; */ - -} diff --git a/Modules/memory/memory_sgi.cpp b/Modules/memory/memory_sgi.cpp deleted file mode 100644 index cacd025..0000000 --- a/Modules/memory/memory_sgi.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -#include -#include -#include -#include - -// The following define is needed for SGI IRIX 6.2 -#define _KMEMUSER -#include - -#include -#include - -#ifndef UBSIZE -#define UBSIZE 512 -#endif - - -void KCMMemory::fetchValues() -{ - int pagesize = getpagesize(); - - struct rminfo rmi; - if( sysmp(MP_SAGET, MPSA_RMINFO, &rmi, sizeof(rmi)) == -1 ) - return; - memoryInfos[TOTAL_MEM] = MEMORY(rmi.physmem) * pagesize; // total physical memory (without swaps) - memoryInfos[FREE_MEM] = MEMORY(rmi.freemem) * pagesize; // total free physical memory (without swaps) - memoryInfos[BUFFER_MEM] = MEMORY(rmi.bufmem) * pagesize; - - - //FIXME: memoryInfos[CACHED_MEM]" - memoryInfos[CACHED_MEM] = NO_MEMORY_INFO; // cached memory in ram - - long val; - swapctl(SC_GETSWAPTOT, &val); - memoryInfos[SWAP_MEM] = MEMORY(val) * UBSIZE; // total size of all swap-partitions - - swapctl(SC_GETFREESWAP, &val); - memoryInfos[FREESWAP_MEM] = MEMORY(val) * UBSIZE; // free memory in swap-partitions - -#ifndef MPKA_SHMINFO - /* Irix 6.5 (also 6.4?) */ - memoryInfos[SHARED_MEM] = NO_MEMORY_INFO; -#else - FILE *kmem = fopen("/dev/kmem", "r"); - if( kmem == 0 ) { - memoryInfos[SHARED_MEM] = NO_MEMORY_INFO; - return; - } - - long shmip = sysmp(MP_KERNADDR, MPKA_SHMINFO); - fseek( kmem, shmip, 0 ); - struct shminfo shmi; - fread( &shmi, sizeof(shmi), 1, kmem ); - - long shmem = sysmp(MP_KERNADDR, MPKA_SHM); - - val = 0; - long pos; - struct shmid_ds shmid; - for( int i=0 ; i - */ - -#include -#include -#include - -/* Stop from crapping out on 32-bit architectures. */ - -#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 -# undef _FILE_OFFSET_BITS -# define _FILE_OFFSET_BITS 32 -#endif - -#include -#include -#include - -#define PAGETOK(a) (( (t_memsize) sysconf( _SC_PAGESIZE )) * (t_memsize) a) - -void KCMMemory::fetchValues() { - - kstat_ctl_t *kctl; - kstat_t *ksp; - kstat_named_t *kdata; - - /* - * get a kstat handle first and update the user's kstat chain - */ - if( (kctl = kstat_open()) == NULL ) - return; - while( kstat_chain_update( kctl ) != 0 ) - ; - - /* - * traverse the kstat chain to find the appropriate kstat - */ - if( (ksp = kstat_lookup( kctl, "unix", 0, "system_pages" )) == NULL ) - return; - - if( kstat_read( kctl, ksp, NULL ) == -1 ) - return; - - /* - * lookup the data - */ -#if 0 - kdata = (kstat_named_t *) kstat_data_lookup( ksp, "physmem" ); - if( kdata != NULL ) { - memoryInfos[TOTAL_MEM] = PAGETOK(kdata->value.ui32); - } -#endif - memoryInfos[TOTAL_MEM] = PAGETOK(sysconf(_SC_PHYS_PAGES)); - - kdata = (kstat_named_t *) kstat_data_lookup( ksp, "freemem" ); - if( kdata != NULL ) - memoryInfos[FREE_MEM] = PAGETOK(kdata->value.ui32); -#ifdef __GNUC__ -#warning "FIXME: memoryInfos[CACHED_MEM]" -#endif - memoryInfos[CACHED_MEM] = NO_MEMORY_INFO; // cached memory in ram - - kstat_close( kctl ); - - /* - * Swap Info - */ - - struct anoninfo am_swap; - long swaptotal; - long swapfree; - long swapused; - - swaptotal = swapused = swapfree = 0L; - - /* - * Retrieve overall swap information from anonymous memory structure - - * which is the same way "swap -s" retrieves it's statistics. - * - * swapctl(SC_LIST, void *arg) does not return what we are looking for. - */ - - if (swapctl(SC_AINFO, &am_swap) == -1) - return; - - swaptotal = am_swap.ani_max; - swapused = am_swap.ani_resv; - swapfree = swaptotal - swapused; - - memoryInfos[SWAP_MEM] = PAGETOK(swaptotal); - memoryInfos[FREESWAP_MEM] = PAGETOK(swapfree); -} diff --git a/Modules/memory/memory_tru64.cpp b/Modules/memory/memory_tru64.cpp deleted file mode 100644 index f10934e..0000000 --- a/Modules/memory/memory_tru64.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This is memory_tru64.cpp to retrieve memory information under Tru64/Alpha. - * - * Implemented by Tom Leitner, Tom@radar.tu-graz.ac.at - * - * WARNING: This module requires linking with -lmach - * - * This routine is based on m_decosf1.c from the "top" program written by: - * - * AUTHOR: Anthony Baxter, - * - */ - -#include -#include -#include -#include -#include -#include -extern "C" { -#include -} -#include - -#define pagetob(size) (MEMORY(1024L) * ((long) (size) << (long) pageshift)) -#define LOG1024 10 - -extern "C" void vm_statistics(task_t, vm_statistics_data_t*); - -void KCMMemory::fetchValues() -{ - int pageshift; /* log base 2 of the pagesize */ - register int pagesize; - vm_statistics_data_t vmstats; - int swap_pages=0,swap_free=0,i; - struct tbl_swapinfo swbuf; - - /* get the page size with "getpagesize" and calculate pageshift from it */ - - pagesize = getpagesize(); - pageshift = 0; - while (pagesize > 1) { - pageshift++; - pagesize >>= 1; - } - - /* we only need the amount of log(2)1024 for our conversion */ - - pageshift -= LOG1024; - - /* memory information */ - /* this is possibly bogus - we work out total # pages by */ - /* adding up the free, active, inactive, wired down, and */ - /* zero filled. Anyone who knows a better way, TELL ME! */ - /* Change: don't use zero filled. */ - - (void) ::vm_statistics(::task_self(), &vmstats); - - /* thanks DEC for the table() command. No thanks at all for */ - /* omitting the man page for it from OSF/1 1.2, and failing */ - /* to document SWAPINFO in the 1.3 man page. Lets hear it for */ - /* include files. */ - - i=0; - while(table(TBL_SWAPINFO,i,&swbuf,1,sizeof(struct tbl_swapinfo))>0) { - swap_pages += swbuf.size; - swap_free += swbuf.free; - i++; - } - memoryInfos[TOTAL_MEM] = pagetob((vmstats.free_count + - vmstats.active_count + - vmstats.inactive_count + - vmstats.wire_count)); - memoryInfos[FREE_MEM] = pagetob(vmstats.free_count); - memoryInfos[SHARED_MEM] = NO_MEMORY_INFO; /* FIXME ?? */ - memoryInfos[BUFFER_MEM] = NO_MEMORY_INFO; /* FIXME ?? */ -#ifdef __GNUC__ -#warning "FIXME: memoryInfos[CACHED_MEM]" -#endif - memoryInfos[CACHED_MEM] = NO_MEMORY_INFO; /* cached memory in ram */ - memoryInfos[SWAP_MEM] = pagetob(swap_pages); - memoryInfos[FREESWAP_MEM] = pagetob(swap_free); -} diff --git a/Modules/memory/physicalMemoryChart.cpp b/Modules/memory/physicalMemoryChart.cpp index 31c151f..a6887e8 100644 --- a/Modules/memory/physicalMemoryChart.cpp +++ b/Modules/memory/physicalMemoryChart.cpp @@ -1,62 +1,60 @@ /*************************************************************************** * KT list view item task implementation. * * -------------------------------------------------------------------- * * Copyright (C) 1999, Gary Meyer * * -------------------------------------------------------------------- * * 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. * ***************************************************************************/ #include "physicalMemoryChart.h" #include #include "base.h" PhysicalMemoryChart::PhysicalMemoryChart(QWidget* parent) : Chart(parent) { colorsInitialized = false; } void PhysicalMemoryChart::paintEvent(QPaintEvent* /*event*/) { /* RAM usage: */ /* don't rely on the SHARED_MEM value since it may refer to * the size of the System V sharedmem in 2.4.x. Calculate instead! */ t_memsize bufferMemory; - bufferMemory = 0; -#if !defined(__svr4__) || !defined(sun) + bufferMemory = 0; #if !defined(__NetBSD__) && !defined(__OpenBSD__) - bufferMemory = ZERO_IF_NO_INFO(memoryInfos[BUFFER_MEM]); -#endif + bufferMemory = ZERO_IF_NO_INFO(memoryInfos[BUFFER_MEM]); #endif t_memsize cachedMemory = ZERO_IF_NO_INFO(memoryInfos[CACHED_MEM]); t_memsize freeMemory = ZERO_IF_NO_INFO(memoryInfos[FREE_MEM]); t_memsize totalMemory = ZERO_IF_NO_INFO(memoryInfos[TOTAL_MEM]) - bufferMemory - cachedMemory - freeMemory; QList used; used.append(freeMemory); used.append(cachedMemory); used.append(bufferMemory); used.append(totalMemory); if (!colorsInitialized) { colorsInitialized = true; texts.append(i18n("Free Physical Memory")); colors.append(COLOR_FREE_MEMORY); // free texts.append(i18n("Disk Cache")); colors.append(QColor(88, 176, 36)); // cached texts.append(i18n("Disk Buffers")); colors.append(QColor(118, 237, 49)); // buffer texts.append(i18n("Application Data")); colors.append(COLOR_USED_MEMORY); // used+shared } drawChart(memoryInfos[TOTAL_MEM], used, colors, texts); } diff --git a/Modules/nics/nic.cpp b/Modules/nics/nic.cpp index 90cedcd..7c8b786 100644 --- a/Modules/nics/nic.cpp +++ b/Modules/nics/nic.cpp @@ -1,314 +1,305 @@ /* * nic.cpp * * Copyright (C) 2001 Alexander Neundorf * * 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. */ #include "nic.h" #include #include #include #include #include #include #include #include "config-nic.h" #ifdef HAVE_SYS_SOCKIO_H #include #endif #include #include #include #include #include #include #include -#ifdef USE_SOLARIS -/* net/if.h is incompatible with STL on Solaris 2.6 - 2.8, redefine - map in the header file because we don't need it. -- Simon Josefsson */ -#define map junkmap -#endif -# include -#ifdef USE_SOLARIS -#undef map -#endif - +#include #include #include #include #ifndef HAVE_STRUCT_SOCKADDR_SA_LEN #undef HAVE_GETNAMEINFO #undef HAVE_GETIFADDRS #endif #if defined(HAVE_GETNAMEINFO) && defined(HAVE_GETIFADDRS) #include #include QString flags_tos (unsigned int flags); #endif K_PLUGIN_FACTORY(KCMNicFactory, registerPlugin(); ) struct MyNIC { QString name; QString addr; QString netmask; QString state; QString type; QString HWaddr; }; QList findNICs(); KCMNic::KCMNic(QWidget *parent, const QVariantList &) : KCModule(parent) { QVBoxLayout *box=new QVBoxLayout(this); box->setContentsMargins(0, 0, 0, 0); m_list=new QTreeWidget(this); m_list->setRootIsDecorated(false); box->addWidget(m_list); QStringList columns; columns<setHeaderLabels(columns); QHBoxLayout *hbox=new QHBoxLayout(); box->addItem(hbox); m_updateButton=new QPushButton(i18n("&Update"),this); hbox->addStretch(1); hbox->addWidget(m_updateButton); QTimer* timer=new QTimer(this); timer->start(60000); connect(m_updateButton, &QPushButton::clicked, this, &KCMNic::update); connect(timer, &QTimer::timeout, this, &KCMNic::update); update(); KAboutData *about = new KAboutData(i18n("kcminfo"), i18n("System Information Control Module"), QString(), QString(), KAboutLicense::GPL, i18n("(c) 2001 - 2002 Alexander Neundorf")); about->addAuthor(i18n("Alexander Neundorf"), QString(), QStringLiteral("neundorf@kde.org")); setAboutData(about); } void KCMNic::update() { m_list->clear(); QList nics=findNICs(); foreach(MyNIC* tmp, nics) { QStringList lst; lst << tmp->name<addr<netmask<type<state<HWaddr; new QTreeWidgetItem(m_list,lst); delete tmp; } nics.clear(); } static QString HWaddr2String(const char *hwaddr) { QString ret; for (int i=0; i<6; i++, hwaddr++) { int v = (*hwaddr & 0xff); QString num = QStringLiteral("%1").arg(v, 0, 16); if (num.length() < 2) num.prepend(QStringLiteral("0")); if (i>0) ret.append(QStringLiteral(":")); ret.append(num); } return ret; } QList findNICs() { QString upMessage(i18nc("State of network card is connected", "Up") ); QString downMessage(i18nc("State of network card is disconnected", "Down") ); QList nl; #if !defined(HAVE_GETIFADDRS) || !defined(HAVE_GETNAMEINFO) int sockfd = socket(AF_INET, SOCK_DGRAM, 0); char buf[8*1024]; struct ifconf ifc; ifc.ifc_len = sizeof(buf); ifc.ifc_req = (struct ifreq *) buf; int result=ioctl(sockfd, SIOCGIFCONF, &ifc); for (char* ptr = buf; ptr < buf + ifc.ifc_len;) { struct ifreq *ifr =(struct ifreq *) ptr; #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN int len = sizeof(struct sockaddr); if (ifr->ifr_addr.sa_len > len) len = ifr->ifr_addr.sa_len; /* length > 16 */ ptr += sizeof(ifr->ifr_name) + len; /* for next one in buffer */ #else ptr += sizeof(*ifr); /* for next one in buffer */ #endif int flags; struct sockaddr_in *sinptr; MyNIC *tmp=nullptr; switch (ifr->ifr_addr.sa_family) { case AF_INET: sinptr = (struct sockaddr_in *) &ifr->ifr_addr; flags=0; struct ifreq ifcopy; ifcopy=*ifr; result=ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); flags=ifcopy.ifr_flags; tmp=new MyNIC; tmp->name=ifr->ifr_name; tmp->state= ((flags & IFF_UP) == IFF_UP) ? upMessage : downMessage; if ((flags & IFF_BROADCAST) == IFF_BROADCAST) tmp->type=i18nc("@item:intext Mode of network card", "Broadcast"); else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) tmp->type=i18nc("@item:intext Mode of network card", "Point to Point"); #ifndef _AIX else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) tmp->type=i18nc("@item:intext Mode of network card", "Multicast"); #endif else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) tmp->type=i18nc("@item:intext Mode of network card", "Loopback"); else tmp->type=i18nc("@item:intext Mode of network card", "Unknown"); tmp->addr=inet_ntoa(sinptr->sin_addr); ifcopy=*ifr; result=ioctl(sockfd, SIOCGIFNETMASK, &ifcopy); if (result==0) { sinptr = (struct sockaddr_in *) &ifcopy.ifr_addr; tmp->netmask=inet_ntoa(sinptr->sin_addr); } else tmp->netmask=i18nc("Unknown network mask", "Unknown"); ifcopy=*ifr; result=-1; // if none of the two #ifs below matches, ensure that result!=0 so that "Unknown" is returned as result #ifdef SIOCGIFHWADDR result=ioctl(sockfd, SIOCGIFHWADDR, &ifcopy); if (result==0) { char *n = &ifcopy.ifr_ifru.ifru_hwaddr.sa_data[0]; tmp->HWaddr = HWaddr2String(n); } #elif defined SIOCGENADDR result=ioctl(sockfd,SIOCGENADDR,&ifcopy); if (result==0) { char *n = &ifcopy.ifr_ifru.ifru_enaddr[0]; tmp->HWaddr = HWaddr2String(n); } #endif if (result!=0) { tmp->HWaddr = i18nc("Unknown HWaddr", "Unknown"); } nl.append(tmp); break; default: break; } } #else struct ifaddrs *ifap, *ifa; if (getifaddrs(&ifap) != 0) { return nl; } MyNIC *tmp=0; for (ifa = ifap; ifa; ifa = ifa->ifa_next) { switch (ifa->ifa_addr->sa_family) { case AF_INET6: case AF_INET: { tmp = new MyNIC; tmp->name = ifa->ifa_name; char buf[128]; bzero(buf, 128); getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len, buf, 127, 0, 0, NI_NUMERICHOST); tmp->addr = buf; if (ifa->ifa_netmask != nullptr) { bzero(buf, 128); getnameinfo(ifa->ifa_netmask, ifa->ifa_netmask->sa_len, buf, 127, 0, 0, NI_NUMERICHOST); tmp->netmask = buf; } tmp->state= (ifa->ifa_flags & IFF_UP) ? upMessage : downMessage; tmp->type = flags_tos(ifa->ifa_flags); nl.append(tmp); break; } default: break; } } freeifaddrs(ifap); #endif return nl; } #if defined(HAVE_GETNAMEINFO) && defined(HAVE_GETIFADDRS) QString flags_tos (unsigned int flags) { QString tmp; if (flags & IFF_POINTOPOINT) { tmp += i18n("Point to Point"); } if (flags & IFF_BROADCAST) { if (tmp.length()) { tmp += QLatin1String(", "); } tmp += i18n("Broadcast"); } if (flags & IFF_MULTICAST) { if (tmp.length()) { tmp += QLatin1String(", "); } tmp += i18n("Multicast"); } if (flags & IFF_LOOPBACK) { if (tmp.length()) { tmp += QLatin1String(", "); } tmp += i18n("Loopback"); } return tmp; } #endif #include "nic.moc" diff --git a/Modules/pci/CMakeLists.txt b/Modules/pci/CMakeLists.txt index 09b0c5c..8cc44be 100644 --- a/Modules/pci/CMakeLists.txt +++ b/Modules/pci/CMakeLists.txt @@ -1,51 +1,47 @@ # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcm_pci\") # OS Base includes include(../base/CMakeLists.txt) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../base ) ########### next target ############### set(KCM_PCI_LIBS KF5::ConfigWidgets KF5::KCMUtils KF5::I18n KF5::IconThemes ${X11_LIBRARIES} ) set(KCM_PCI_PART_SRCS kcm_pci.cpp ../base/os_current.cpp ) if(KF5Wayland_FOUND) set(KCM_PCI_LIBS ${KCM_PCI_LIBS} KF5::WaylandClient) set(KCM_PCI_PART_SRCS ${KCM_PCI_PART_SRCS} ../base/info_wayland.cpp) endif() if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(KCM_PCI_LIBS ${KCM_PCI_LIBS} devinfo) endif() if(PCIUTILS_FOUND) message(STATUS "Enabling PCI module based on pciutils library") - add_definitions(-DHAVE_PCIUTILS) - - if(UNIX AND NOT APPLE) - add_definitions (-fpermissive) - endif() + add_definitions(-DHAVE_PCIUTILS -fpermissive) set(KCM_PCI_PART_SRCS ${KCM_PCI_PART_SRCS} kpci.cpp) set(KCM_PCI_LIBS ${KCM_PCI_LIBS} ${PCIUTILS_LIBRARIES} ${ZLIB_LIBRARIES}) endif() add_library(kcm_pci MODULE ${KCM_PCI_PART_SRCS}) target_link_libraries(kcm_pci ${KCM_PCI_LIBS} ) install(TARGETS kcm_pci DESTINATION ${PLUGIN_INSTALL_DIR}) ########### install files ############### install( FILES kcm_pci.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/kcontrol/menus/CMakeLists.txt b/kcontrol/menus/CMakeLists.txt index 25b2d4e..7852d88 100644 --- a/kcontrol/menus/CMakeLists.txt +++ b/kcontrol/menus/CMakeLists.txt @@ -1,11 +1,2 @@ - - - -########### install files ############### -if (WIN32) -install( FILES kinfocenter.menu DESTINATION ${SHARE_INSTALL_DIR}/xdg/menus/) -else () install( FILES kinfocenter.menu DESTINATION ${SYSCONF_INSTALL_DIR}/xdg/menus/) -endif () - install( FILES kinfocenter.directory DESTINATION ${XDG_DIRECTORY_INSTALL_DIR} )