├── .arcconfig ├── .gitignore ├── .krazy ├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── HACKING ├── Mainpage.dox ├── Messages.sh ├── QAptConfig.cmake.in ├── TODO ├── autotests ├── CMakeLists.txt ├── data │ ├── test1.list │ └── test2.list ├── dependencyinfotest.cpp ├── sourceslisttest.cpp ├── sourceslisttest.h ├── transactionerrorhandlingtest.cpp └── transactionerrorhandlingtest.h ├── cmake └── modules │ ├── COPYING-CMAKE-SCRIPTS │ ├── FindAptPkg.cmake │ ├── FindGLIB2.cmake │ ├── FindGStreamer.cmake │ ├── FindXapian.cmake │ └── cmake_uninstall.cmake.in ├── doxy.config.in ├── example ├── CMakeLists.txt ├── cacheupdatewidget.cpp ├── cacheupdatewidget.h ├── commitwidget.cpp ├── commitwidget.h ├── main.cpp ├── qapttest.cpp └── qapttest.h ├── libqapt.pc.cmake ├── qaptversion.h.cmake ├── src ├── CMakeLists.txt ├── backend.cpp ├── backend.h ├── cache.cpp ├── cache.h ├── changelog.cpp ├── changelog.h ├── config.cpp ├── config.h ├── dbusinterfaces_p.h.cmake ├── debfile.cpp ├── debfile.h ├── dependencyinfo.cpp ├── dependencyinfo.h ├── downloadprogress.cpp ├── downloadprogress.h ├── globals.h ├── history.cpp ├── history.h ├── markingerrorinfo.cpp ├── markingerrorinfo.h ├── package.cpp ├── package.h ├── sourceentry.cpp ├── sourceentry.h ├── sourceslist.cpp ├── sourceslist.h ├── transaction.cpp ├── transaction.h └── worker │ ├── CMakeLists.txt │ ├── aptlock.cpp │ ├── aptlock.h │ ├── aptworker.cpp │ ├── aptworker.h │ ├── main.cpp │ ├── org.kubuntu.qaptworker.conf.cmake │ ├── org.kubuntu.qaptworker.policy.cmake │ ├── org.kubuntu.qaptworker.service.cmake │ ├── org.kubuntu.qaptworker.transaction.xml.cmake │ ├── org.kubuntu.qaptworker.xml.cmake │ ├── qaptauthorization.h │ ├── qaptworker.actions.cmake │ ├── transaction.cpp │ ├── transaction.h │ ├── transactionqueue.cpp │ ├── transactionqueue.h │ ├── urihelper.h.cmake │ ├── workeracquire.cpp │ ├── workeracquire.h │ ├── workerdaemon.cpp │ ├── workerdaemon.h │ ├── workerinstallprogress.cpp │ └── workerinstallprogress.h └── utils ├── CMakeLists.txt ├── plasma-runner-installer ├── CMakeLists.txt ├── installerrunner.cpp ├── installerrunner.h └── plasma-runner-installer.desktop ├── qapt-batch ├── CMakeLists.txt ├── detailswidget.cpp ├── detailswidget.h ├── main.cpp ├── qaptbatch.cpp └── qaptbatch.h ├── qapt-deb-installer ├── CMakeLists.txt ├── ChangesDialog.cpp ├── ChangesDialog.h ├── DebCommitWidget.cpp ├── DebCommitWidget.h ├── DebInstaller.cpp ├── DebInstaller.h ├── DebViewer.cpp ├── DebViewer.h ├── main.cpp └── qapt-deb-installer.desktop ├── qapt-deb-thumbnailer ├── CMakeLists.txt ├── DebThumbnailer.cpp ├── DebThumbnailer.h └── debthumbnailer.desktop └── qapt-gst-helper ├── CMakeLists.txt ├── GstMatcher.cpp ├── GstMatcher.h ├── PluginFinder.cpp ├── PluginFinder.h ├── PluginHelper.cpp ├── PluginHelper.h ├── PluginInfo.cpp ├── PluginInfo.h └── main.cpp /.arcconfig: -------------------------------------------------------------------------------- 1 | { 2 | "phabricator.uri" : "https://phabricator.kde.org/" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.kdev4 2 | my* 3 | build 4 | -------------------------------------------------------------------------------- /.krazy: -------------------------------------------------------------------------------- 1 | SKIP libqapt\.pc\.cmake 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(qapt) 2 | cmake_minimum_required(VERSION 2.8.12) 3 | 4 | set(PROJECT_VERSION_MAJOR 3) 5 | set(PROJECT_VERSION_MINOR 0) 6 | set(PROJECT_VERSION_PATCH 5) 7 | set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" ) 8 | set(PROJECT_SOVERSION ${PROJECT_VERSION_MAJOR}) 9 | 10 | find_package(ECM 0.0.14 REQUIRED NO_MODULE) 11 | set(CMAKE_MODULE_PATH 12 | ${ECM_MODULE_PATH} 13 | ${ECM_KDE_MODULE_DIR} 14 | ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) 15 | 16 | include(ECMGenerateHeaders) 17 | include(ECMPackageConfigHelpers) 18 | include(ECMPoQmTools) 19 | include(ECMSetupVersion) 20 | include(FeatureSummary) 21 | include(KDEInstallDirs) 22 | include(KDECMakeSettings NO_POLICY_SCOPE) 23 | include(KDECompilerSettings NO_POLICY_SCOPE) 24 | include(ECMGeneratePriFile) # This needs InstallDirs 25 | 26 | # Turn exceptions on 27 | kde_enable_exceptions() 28 | 29 | set(REQUIRED_QT_VERSION 5.8.0) # Used in QAptConfig 30 | find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus Widgets) 31 | 32 | find_package(Xapian REQUIRED) 33 | find_package(AptPkg REQUIRED) 34 | 35 | find_package(PolkitQt5-1 0.112 REQUIRED) 36 | 37 | # Find the required Libaries 38 | include_directories( 39 | ${CMAKE_SOURCE_DIR} 40 | ${CMAKE_CURRENT_BINARY_DIR} 41 | ${POLKITQT-1_INCLUDE_DIR} 42 | ${XAPIAN_INCLUDE_DIR} 43 | ${APTPKG_INCLUDE_DIR}) 44 | 45 | ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX QAPT 46 | VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qaptversion.h" 47 | PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/QAptConfigVersion.cmake" 48 | SOVERSION ${PROJECT_SOVERSION}) 49 | 50 | set(QAPT_WORKER_VERSION ${PROJECT_SOVERSION}) 51 | set(QAPT_WORKER_RDN org.kubuntu.qaptworker) 52 | set(QAPT_WORKER_RDN_VERSIONED ${QAPT_WORKER_RDN}${QAPT_WORKER_VERSION}) 53 | 54 | # For forwarding into C++ convert them into properly excaped strings. 55 | set(QAPT_WORKER_VERSION_STRING \"${QAPT_WORKER_VERSION}\") 56 | set(QAPT_WORKER_RDN_VERSIONED_STRING \"${QAPT_WORKER_RDN_VERSIONED}\") 57 | 58 | add_definitions(-DQAPT_WORKER_VERSION_STRING=${QAPT_WORKER_VERSION_STRING}) 59 | add_definitions(-DQAPT_WORKER_RDN_VERSIONED_STRING=${QAPT_WORKER_RDN_VERSIONED_STRING}) 60 | 61 | # Also forward version for utils. 62 | add_definitions(-DCMAKE_PROJECT_VERSION=\"${PROJECT_VERSION}\") 63 | 64 | set(KF5_DEP_VERSION "5.0.0") 65 | 66 | # Only used to install worker actions 67 | find_package(KF5Auth ${KF5_DEP_VERSION}) 68 | 69 | # Used for utils 70 | find_package(KF5CoreAddons ${KF5_DEP_VERSION}) 71 | find_package(KF5I18n ${KF5_DEP_VERSION}) 72 | find_package(KF5KIO ${KF5_DEP_VERSION}) 73 | find_package(KF5Runner ${KF5_DEP_VERSION}) 74 | find_package(KF5TextWidgets ${KF5_DEP_VERSION}) 75 | find_package(KF5WidgetsAddons ${KF5_DEP_VERSION}) 76 | find_package(KF5WindowSystem ${KF5_DEP_VERSION}) 77 | find_package(KF5IconThemes ${KF5_DEP_VERSION}) 78 | 79 | find_package(DebconfKDE 1.0) 80 | find_package(GStreamer 1.0) 81 | find_package(GLIB2 2.0) 82 | 83 | if (KF5CoreAddons_FOUND 84 | AND KF5I18n_FOUND 85 | AND KF5KIO_FOUND 86 | AND KF5Runner_FOUND 87 | AND KF5TextWidgets_FOUND 88 | AND KF5WidgetsAddons_FOUND 89 | AND KF5WindowSystem_FOUND 90 | AND KF5IconThemes_FOUND 91 | AND DebconfKDE_FOUND) 92 | set(WITH_UTILS true) 93 | endif() 94 | 95 | if (WITH_UTILS AND GSTREAMER_FOUND AND GLIB2_FOUND) 96 | set(WITH_GSTREAMER true) 97 | add_definitions(${GSTREAMER_DEFINITIONS}) 98 | endif() 99 | 100 | add_feature_info(qapt-utils WITH_UTILS "Runtime utilities using KDE frameworks") 101 | add_feature_info(qapt-gst-helper WITH_GSTREAMER "GStreamer codec helper util") 102 | 103 | message(WARNING "gettext and tr in the same source is insanely tricky, maybe we should give some ki18n to qapt...") 104 | if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") 105 | ecm_install_po_files_as_qm(po) 106 | endif() 107 | 108 | # create a Config.cmake and a ConfigVersion.cmake file and install them 109 | set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/QApt") 110 | 111 | ecm_configure_package_config_file( 112 | "${CMAKE_CURRENT_SOURCE_DIR}/QAptConfig.cmake.in" 113 | "${CMAKE_CURRENT_BINARY_DIR}/QAptConfig.cmake" 114 | INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) 115 | 116 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/QAptConfig.cmake" 117 | "${CMAKE_CURRENT_BINARY_DIR}/QAptConfigVersion.cmake" 118 | DESTINATION "${CMAKECONFIG_INSTALL_DIR}" 119 | COMPONENT Devel) 120 | install(EXPORT QAptTargets 121 | DESTINATION "${CMAKECONFIG_INSTALL_DIR}" 122 | FILE QAptTargets.cmake 123 | NAMESPACE QApt:: ) 124 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qaptversion.h 125 | DESTINATION include/qapt 126 | COMPONENT Devel) 127 | 128 | add_subdirectory(autotests) 129 | add_subdirectory(src) 130 | 131 | if(WITH_UTILS) 132 | add_subdirectory(utils) 133 | 134 | #Do not remove or modify these. The release script substitutes in for these 135 | #comments with appropriate doc and translation directories. 136 | #PO_SUBDIR 137 | #DOC_SUBDIR 138 | endif() 139 | 140 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libqapt.pc.cmake 141 | ${CMAKE_CURRENT_BINARY_DIR}/libqapt.pc 142 | @ONLY) 143 | 144 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqapt.pc 145 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig 146 | COMPONENT Devel) 147 | 148 | ecm_generate_pri_file(BASE_NAME QApt 149 | LIB_NAME QApt 150 | DEPS "core widgets dbus" 151 | FILENAME_VAR PRI_FILENAME 152 | INCLUDE_INSTALL_DIR include/QApt) 153 | install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) 154 | 155 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) 156 | -------------------------------------------------------------------------------- /HACKING: -------------------------------------------------------------------------------- 1 | A few notes to hackers: 2 | 3 | - This library, for the most part, follows the Kubuntu coding style: https://wiki.kubuntu.org/Kubuntu/Specs/MaverickCodestylePolicy (Which in itself is quite similar to the kdelibs coding style) The exceptions are when code has been copied almost verbatim from places like synaptic, and for syncing purposes it would be better to have as little difference as possible. 4 | - API and ABI are frozen until QApt2. (Except for additions) 5 | - Strings are frozen for all point releases (e.g. 1.0.1 or 1.0.2), with freezes starting two weeks before a minor release. For example, there will be a string freeze before 1.1.0 and will remain frozen for 1.1.1 and 1.1.2. 6 | 7 | -------------------------------------------------------------------------------- /Mainpage.dox: -------------------------------------------------------------------------------- 1 | /** @mainpage The QApt Library API Reference 2 | 3 | This is a Qt wrapper library around the libapt-pkg API/Apt implementation. It 4 | provides a nice object-oriented, Qt-like API for controlling Apt in a world 5 | where iterators and strange API reign supreme. 6 | 7 | // DOXYGEN_NAME=libqapt 8 | // DOXYGEN_ENABLE=YES 9 | // vim:ts=4:sw=4:expandtab:filetype=doxygen 10 | -------------------------------------------------------------------------------- /Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $XGETTEXT `find utils/qapt-batch -name '*.cpp'` -o $podir/qaptbatch.pot 3 | $XGETTEXT `find utils/qapt-gst-helper -name '*.cpp'` -o $podir/qapt-gst-helper.pot 4 | $XGETTEXT `find utils/qapt-deb-installer -name '*.cpp'` -o $podir/qapt-deb-installer.pot 5 | $XGETTEXT `find utils/plasma-runner-installer -name '*.cpp'` -o $podir/plasma_runner_installer.pot 6 | $EXTRACT_TR_STRINGS `find src -name '*.cpp'` -o $podir/libqapt.pot 7 | -------------------------------------------------------------------------------- /QAptConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # QAptConfig.cmake provides information about the installed QApt library. 2 | # It can be used directly from CMake via find_package(QApt NO_MODULE) 3 | # 4 | # The following CMake variables are provided: 5 | # QAPT_VERSION_MAJOR - the major version number of QApt 6 | # QAPT_VERSION_MINOR - the minor version number of QApt 7 | # QAPT_VERSION_PATCH - the patch version number of QApt 8 | # QAPT_INCLUDE_DIRS - the include directories to use 9 | # 10 | # Additionally, the following imported library targets are created, which may be used directly 11 | # with target_link_libraries(): 12 | # QApt - the QApt library 13 | 14 | @PACKAGE_INIT@ 15 | 16 | #set(QAPT_DBUS_INTERFACES_DIR "${PACKAGE_PREFIX_DIR}/@DBUS_INTERFACES_INSTALL_DIR@") 17 | 18 | find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@) 19 | 20 | include("${CMAKE_CURRENT_LIST_DIR}/QAptTargets.cmake") 21 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | -Make the direct output of the dpkg process available, so that advanced package managers can have a console GUI for power users 2 | -grep -iR "FIMXE" src/ 3 | -grep -iR "TODO" src/ 4 | ;-) 5 | 6 | -------------------------------------------------------------------------------- /autotests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ECMAddTests) 2 | 3 | find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test) 4 | 5 | # FIXME: the data doesn't need to be copied, the absolute path to the data should be passed through definitions to the target 6 | configure_file( 7 | data/test1.list 8 | ${CMAKE_CURRENT_BINARY_DIR}/data/test1.list 9 | COPYONLY 10 | ) 11 | 12 | configure_file( 13 | data/test2.list 14 | ${CMAKE_CURRENT_BINARY_DIR}/data/test2.list 15 | COPYONLY 16 | ) 17 | 18 | ecm_add_test(dependencyinfotest.cpp 19 | LINK_LIBRARIES 20 | Qt5::Test 21 | QApt::Main) 22 | 23 | ecm_add_test(sourceslisttest.cpp 24 | LINK_LIBRARIES 25 | Qt5::Test 26 | QApt::Main) 27 | 28 | ecm_add_test(transactionerrorhandlingtest.cpp 29 | LINK_LIBRARIES 30 | Qt5::Test 31 | QApt::Main) 32 | -------------------------------------------------------------------------------- /autotests/data/test1.list: -------------------------------------------------------------------------------- 1 | ## First test 2 | deb http://apttest/ubuntu saucy partner 3 | deb-src http://apttest/ubuntu saucy partner 4 | deb http://apttest/ubuntu saucy contrib main partner 5 | deb [arch=i386] http://apttest/ubuntu saucy partner 6 | deb [arch=i386,ppc] http://apttest/ubuntu saucy partner 7 | deb [arch=i386,ppc] http://apttest/ubuntu saucy contrib main partner 8 | deb [arch=i386,ppc] https://apttest/ubuntu saucy contrib main partner 9 | 10 | # deb [arch=i386,ppc] http://apttest/ubuntu saucy contrib main partner 11 | #deb [arch=i386,ppc] http://apttest/ubuntu saucy contrib main partner 12 | ###deb [arch=i386,ppc] http://apttest/ubuntu saucy contrib main partner 13 | ## 14 | deb cdrom:[Kubuntu 11.10 _Oneiric Ocelot_ - Release amd64 (20111012)]/ oneiric main restricted 15 | -------------------------------------------------------------------------------- /autotests/data/test2.list: -------------------------------------------------------------------------------- 1 | ## Some explanatory comments here... 2 | deb http://apttest2/ubuntu saucy universe 3 | deb-src http://apttest2/ubuntu saucy universe 4 | -------------------------------------------------------------------------------- /autotests/dependencyinfotest.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2014 Harald Sitter * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "sourceslisttest.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace QApt { 28 | 29 | class DependencyInfoTest : public QObject 30 | { 31 | Q_OBJECT 32 | private slots: 33 | void testSimpleParse(); 34 | void testOrDependency(); 35 | 36 | void testMultiArchAnnotation(); 37 | void testNoMultiArchAnnotation(); 38 | }; 39 | 40 | void DependencyInfoTest::testSimpleParse() 41 | { 42 | // Build list of [ dep1 dep2 dep3 ] to later use for comparison. 43 | int depCount = 3; 44 | QStringList packageNames; 45 | for (int i = 0; i < depCount; ++i) { 46 | packageNames.append(QStringLiteral("dep%1").arg(QString::number(i))); 47 | } 48 | 49 | QString field = packageNames.join(","); 50 | DependencyType depType = Depends; 51 | auto depList = DependencyInfo::parseDepends(field, depType); 52 | QCOMPARE(depList.size(), depCount); 53 | 54 | for (int i = 0; i < depCount; ++i) { 55 | auto depGroup = depList.at(i); 56 | QCOMPARE(depGroup.size(), 1); 57 | QCOMPARE(depGroup.first().packageName(), packageNames.at(i)); 58 | } 59 | } 60 | 61 | void DependencyInfoTest::testOrDependency() 62 | { 63 | QString field = QStringLiteral("dep1 | dep2"); 64 | DependencyType depType = Depends; 65 | auto depList = DependencyInfo::parseDepends(field, depType); 66 | QCOMPARE(depList.size(), 1); 67 | auto depGroup = depList.first(); 68 | QCOMPARE(depGroup.size(), 2); // Must have two dependency in this group. 69 | QCOMPARE(depGroup.at(0).packageName(), QStringLiteral("dep1")); 70 | QCOMPARE(depGroup.at(1).packageName(), QStringLiteral("dep2")); 71 | } 72 | 73 | void DependencyInfoTest::testMultiArchAnnotation() 74 | { 75 | QString field = QStringLiteral("dep1:any"); 76 | DependencyType depType = Depends; 77 | auto depList = DependencyInfo::parseDepends(field, depType); 78 | for (auto depGroup : depList) { 79 | for (auto dep : depGroup) { 80 | QCOMPARE(dep.packageName(), field.split(':').first()); 81 | QCOMPARE(dep.multiArchAnnotation(), QStringLiteral("any")); 82 | } 83 | } 84 | } 85 | 86 | void DependencyInfoTest::testNoMultiArchAnnotation() 87 | { 88 | QString field = QStringLiteral("dep1"); 89 | DependencyType depType = Depends; 90 | auto depList = DependencyInfo::parseDepends(field, depType); 91 | for (auto depGroup : depList) { 92 | for (auto dep : depGroup) { 93 | QCOMPARE(dep.packageName(), field); 94 | QVERIFY(dep.multiArchAnnotation().isEmpty()); 95 | } 96 | } 97 | } 98 | 99 | } 100 | 101 | QTEST_MAIN(QApt::DependencyInfoTest); 102 | 103 | #include "dependencyinfotest.moc" 104 | -------------------------------------------------------------------------------- /autotests/sourceslisttest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Michael D. Stemle 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License or (at your option) version 3 or any later version 9 | * accepted by the membership of KDE e.V. (or its successor approved 10 | * by the membership of KDE e.V.), which shall act as a proxy 11 | * defined in Section 14 of version 3 of the license. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | #ifndef SOURCESLISTTEST_H 24 | #define SOURCESLISTTEST_H 25 | 26 | #include 27 | #include 28 | 29 | #include "sourceslist.h" 30 | #include "sourceentry.h" 31 | 32 | class SourcesListTest : public QObject 33 | { 34 | Q_OBJECT 35 | private slots: 36 | void initTestCase(); 37 | void cleanupTestCase(); 38 | 39 | void init(); 40 | void cleanup(); 41 | 42 | void testConstructor(); 43 | void testLoadSourcesOneFile(); 44 | void testLoadSourcesManyFiles(); 45 | void testAddSource(); 46 | void testRemoveSource(); 47 | void testSaveSources(); 48 | 49 | private: 50 | QStringList sampleSourcesHasOneFile; 51 | QStringList sampleSourcesHasTwoFiles; 52 | QStringList sampleSourcesHasDuplicateFiles; 53 | QString outputFile; 54 | QString dummyFile; 55 | 56 | void verifySourceEntry (const QString &label, 57 | const QApt::SourceEntry &entry, 58 | const QString &type, 59 | const QString &uri, 60 | const QString &dist, 61 | const QString &components, 62 | const QString &archs, 63 | const bool isEnabled, 64 | const bool isValid 65 | ); 66 | }; 67 | 68 | #endif // SOURCESLISTTEST_H 69 | -------------------------------------------------------------------------------- /autotests/transactionerrorhandlingtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * transactionerrorhandlingtest - A test for error handling in QApt::Transaction 3 | * Copyright 2014 Michael D. Stemle 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License or (at your option) version 3 or any later version 9 | * accepted by the membership of KDE e.V. (or its successor approved 10 | * by the membership of KDE e.V.), which shall act as a proxy 11 | * defined in Section 14 of version 3 of the license. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | #ifndef TRANSACTIONERRORHANDLINGTEST_H 24 | #define TRANSACTIONERRORHANDLINGTEST_H 25 | 26 | #include 27 | 28 | #define __CURRENTLY_UNIT_TESTING__ 1 29 | 30 | #include 31 | 32 | // namespace QAptTests { 33 | class TransactionErrorHandlingTest : public QObject 34 | { 35 | Q_OBJECT 36 | 37 | QApt::Transaction *subject; 38 | 39 | private slots: 40 | void initTestCase(); 41 | void cleanupTestCase(); 42 | 43 | void init(); 44 | void cleanup(); 45 | 46 | void testSuccess(); 47 | void testUnknownError(); 48 | void testInitError(); 49 | void testLockError(); 50 | void testDiskSpaceError(); 51 | void testFetchError(); 52 | void testCommitError(); 53 | void testAuthError(); 54 | void testWorkerDisappeared(); 55 | void testUntrustedError(); // This one should test some plurals in translation 56 | void testDownloadDisallowedError(); 57 | void testNotFoundError(); 58 | void testWrongArchError(); 59 | void testMarkingError(); 60 | }; 61 | // } 62 | 63 | #endif // TRANSACTIONERRORHANDLINGTEST_H 64 | -------------------------------------------------------------------------------- /cmake/modules/COPYING-CMAKE-SCRIPTS: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /cmake/modules/FindAptPkg.cmake: -------------------------------------------------------------------------------- 1 | # - find Library for managing Debian package information 2 | # APTPKG_INCLUDE_DIR - Where to find Library for managing Debian package information header files (directory) 3 | # APTPKG_LIBRARIES - Library for managing Debian package information libraries 4 | # APTPKG_LIBRARY_RELEASE - Where the release library is 5 | # APTPKG_LIBRARY_DEBUG - Where the debug library is 6 | # APTPKG_FOUND - Set to TRUE if we found everything (library, includes and executable) 7 | 8 | # Copyright (c) 2010 David Palacio, 9 | # 10 | # Redistribution and use is allowed according to the terms of the BSD license. 11 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 12 | # 13 | # Generated by CModuler, a CMake Module Generator - http://gitorious.org/cmoduler 14 | 15 | include(FindPackageHandleStandardArgs) 16 | 17 | IF( APTPKG_INCLUDE_DIR AND APTPKG_LIBRARY_RELEASE AND APTPKG_LIBRARY_DEBUG ) 18 | SET(APTPKG_FIND_QUIETLY TRUE) 19 | ENDIF( APTPKG_INCLUDE_DIR AND APTPKG_LIBRARY_RELEASE AND APTPKG_LIBRARY_DEBUG ) 20 | 21 | FIND_PATH( APTPKG_INCLUDE_DIR apt-pkg/init.h ) 22 | 23 | FIND_LIBRARY(APTPKG_LIBRARY_RELEASE NAMES apt-pkg ) 24 | FIND_LIBRARY(APTINST_LIBRARY NAMES apt-inst ) 25 | 26 | # apt-inst is optional these days! 27 | IF ( NOT APTINST_LIBRARY ) 28 | SET( APTINST_LIBRARY "" ) 29 | ENDIF( ) 30 | 31 | FIND_LIBRARY(APTPKG_LIBRARY_DEBUG NAMES apt-pkg apt-pkgd HINTS /usr/lib/debug/usr/lib/ ) 32 | 33 | IF( APTPKG_LIBRARY_RELEASE OR APTPKG_LIBRARY_DEBUG AND APTPKG_INCLUDE_DIR ) 34 | SET( APTPKG_FOUND TRUE ) 35 | ENDIF( APTPKG_LIBRARY_RELEASE OR APTPKG_LIBRARY_DEBUG AND APTPKG_INCLUDE_DIR ) 36 | 37 | IF( APTPKG_LIBRARY_DEBUG AND APTPKG_LIBRARY_RELEASE ) 38 | # if the generator supports configuration types then set 39 | # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value 40 | IF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) 41 | SET( APTPKG_LIBRARIES optimized ${APTPKG_LIBRARY_RELEASE} ${APTINST_LIBRARY} debug ${APTPKG_LIBRARY_DEBUG} ) 42 | ELSE( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) 43 | # if there are no configuration types and CMAKE_BUILD_TYPE has no value 44 | # then just use the release libraries 45 | SET( APTPKG_LIBRARIES ${APTPKG_LIBRARY_RELEASE} ${APTINST_LIBRARY} ) 46 | ENDIF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) 47 | ELSEIF( APTPKG_LIBRARY_RELEASE ) 48 | SET( APTPKG_LIBRARIES ${APTPKG_LIBRARY_RELEASE} ${APTINST_LIBRARY}) 49 | ELSE( APTPKG_LIBRARY_DEBUG AND APTPKG_LIBRARY_RELEASE ) 50 | SET( APTPKG_LIBRARIES ${APTPKG_LIBRARY_DEBUG} ${APTINST_LIBRARY} ) 51 | ENDIF( APTPKG_LIBRARY_DEBUG AND APTPKG_LIBRARY_RELEASE ) 52 | 53 | find_package_handle_standard_args(AptPkg DEFAULT_MSG APTPKG_LIBRARIES APTPKG_INCLUDE_DIR) 54 | -------------------------------------------------------------------------------- /cmake/modules/FindGLIB2.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the GLIB2 libraries 2 | # Once done this will define 3 | # 4 | # GLIB2_FOUND - system has glib2 5 | # GLIB2_INCLUDE_DIR - the glib2 include directory 6 | # GLIB2_LIBRARIES - glib2 library 7 | 8 | # Copyright (c) 2008 Laurent Montel, 9 | # 10 | # Redistribution and use is allowed according to the terms of the BSD license. 11 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 12 | 13 | 14 | if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) 15 | # Already in cache, be silent 16 | set(GLIB2_FIND_QUIETLY TRUE) 17 | endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) 18 | 19 | find_package(PkgConfig) 20 | pkg_check_modules(PC_LibGLIB2 glib-2.0) 21 | 22 | find_path(GLIB2_MAIN_INCLUDE_DIR 23 | NAMES glib.h 24 | HINTS ${PC_LibGLIB2_INCLUDEDIR} 25 | PATH_SUFFIXES glib-2.0) 26 | 27 | find_library(GLIB2_LIBRARY 28 | NAMES glib-2.0 29 | HINTS ${PC_LibGLIB2_LIBDIR} 30 | ) 31 | 32 | set(GLIB2_LIBRARIES ${GLIB2_LIBRARY}) 33 | 34 | # search the glibconfig.h include dir under the same root where the library is found 35 | get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) 36 | 37 | find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h 38 | PATH_SUFFIXES glib-2.0/include 39 | HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) 40 | 41 | set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}") 42 | 43 | # not sure if this include dir is optional or required 44 | # for now it is optional 45 | if(GLIB2_INTERNAL_INCLUDE_DIR) 46 | set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}") 47 | endif(GLIB2_INTERNAL_INCLUDE_DIR) 48 | 49 | include(FindPackageHandleStandardArgs) 50 | find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) 51 | 52 | mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) 53 | -------------------------------------------------------------------------------- /cmake/modules/FindGStreamer.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find GStreamer 2 | # Once done this will define 3 | # 4 | # GSTREAMER_FOUND - system has GStreamer 5 | # GSTREAMER_INCLUDE_DIR - the GStreamer include directory 6 | # GSTREAMER_LIBRARIES - the libraries needed to use GStreamer 7 | # GSTREAMER_DEFINITIONS - Compiler switches required for using GStreamer 8 | # GSTREAMER_VERSION - the version of GStreamer 9 | 10 | # Copyright (c) 2008 Helio Chissini de Castro, 11 | # (c)2006, Tim Beaulen 12 | 13 | # TODO: Other versions --> GSTREAMER_X_Y_FOUND (Example: GSTREAMER_0_8_FOUND and GSTREAMER_1.0_FOUND etc) 14 | 15 | 16 | IF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_APP_LIBRARY) 17 | # in cache already 18 | SET(GStreamer_FIND_QUIETLY TRUE) 19 | ELSE (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_APP_LIBRARY) 20 | SET(GStreamer_FIND_QUIETLY FALSE) 21 | ENDIF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_APP_LIBRARY) 22 | 23 | IF (NOT WIN32) 24 | FIND_PACKAGE(PkgConfig REQUIRED) 25 | # use pkg-config to get the directories and then use these values 26 | # in the FIND_PATH() and FIND_LIBRARY() calls 27 | # don't make this check required - otherwise you can't use macro_optional_find_package on this one 28 | PKG_CHECK_MODULES(PKG_GSTREAMER gstreamer-1.0) 29 | SET(GSTREAMER_VERSION ${PKG_GSTREAMER_VERSION}) 30 | SET(GSTREAMER_DEFINITIONS ${PKG_GSTREAMER_CFLAGS}) 31 | ENDIF (NOT WIN32) 32 | 33 | FIND_PATH(GSTREAMER_INCLUDE_DIR gst/gst.h 34 | PATHS 35 | ${PKG_GSTREAMER_INCLUDE_DIRS} 36 | PATH_SUFFIXES gstreamer-1.0 37 | ) 38 | 39 | FIND_LIBRARY(GSTREAMER_LIBRARIES NAMES gstreamer-1.0 40 | PATHS 41 | ${PKG_GSTREAMER_LIBRARY_DIRS} 42 | ) 43 | 44 | FIND_LIBRARY(GSTREAMER_BASE_LIBRARY NAMES gstbase-1.0 45 | PATHS 46 | ${PKG_GSTREAMER_LIBRARY_DIRS} 47 | ) 48 | 49 | FIND_LIBRARY(GSTREAMER_APP_LIBRARY NAMES gstapp-1.0 50 | PATHS 51 | ${PKG_GSTREAMER_LIBRARY_DIRS} 52 | ) 53 | 54 | IF (GSTREAMER_INCLUDE_DIR) 55 | ELSE (GSTREAMER_INCLUDE_DIR) 56 | MESSAGE(STATUS "GStreamer: WARNING: include dir not found") 57 | ENDIF (GSTREAMER_INCLUDE_DIR) 58 | 59 | IF (GSTREAMER_LIBRARIES) 60 | ELSE (GSTREAMER_LIBRARIES) 61 | MESSAGE(STATUS "GStreamer: WARNING: library not found") 62 | ENDIF (GSTREAMER_LIBRARIES) 63 | 64 | if (GSTREAMER_APP_LIBRARY) 65 | ELSE (GSTREAMER_APP_LIBRARY) 66 | MESSAGE(STATUS "GStreamer: WARNING: app library not found") 67 | ENDIF (GSTREAMER_APP_LIBRARY) 68 | 69 | IF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_APP_LIBRARY) 70 | SET(GSTREAMER_FOUND TRUE) 71 | ELSE (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_APP_LIBRARY) 72 | SET(GSTREAMER_FOUND FALSE) 73 | ENDIF (GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY AND GSTREAMER_APP_LIBRARY) 74 | 75 | IF (GSTREAMER_FOUND) 76 | IF (NOT GStreamer_FIND_QUIETLY) 77 | MESSAGE(STATUS "Found GStreamer: ${GSTREAMER_LIBRARIES}") 78 | ENDIF (NOT GStreamer_FIND_QUIETLY) 79 | ELSE (GSTREAMER_FOUND) 80 | IF (GStreamer_FIND_REQUIRED) 81 | MESSAGE(SEND_ERROR "Could NOT find GStreamer") 82 | ENDIF (GStreamer_FIND_REQUIRED) 83 | ENDIF (GSTREAMER_FOUND) 84 | 85 | MARK_AS_ADVANCED(GSTREAMER_INCLUDE_DIR GSTREAMER_LIBRARIES GSTREAMER_BASE_LIBRARY GSTREAMER_INTERFACE_LIBRARY GSTREAMER_APP_LIBRARY) 86 | -------------------------------------------------------------------------------- /cmake/modules/FindXapian.cmake: -------------------------------------------------------------------------------- 1 | # Find Xapian search engine library 2 | # 3 | # XAPIAN_FOUND - system has Xapian 4 | # XAPIAN_INCLUDE_DIR - the Xapian include directory 5 | # XAPIAN_LIBRARIES - the libraries needed to use Xapian 6 | # 7 | # Copyright © 2010 Harald Sitter 8 | # 9 | # Redistribution and use is allowed according to the terms of the BSD license. 10 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 11 | 12 | if(XAPIAN_INCLUDE_DIR AND XAPIAN_LIBRARIES) 13 | # Already in cache, be silent 14 | set(Xapian_FIND_QUIETLY TRUE) 15 | endif(XAPIAN_INCLUDE_DIR AND XAPIAN_LIBRARIES) 16 | 17 | FIND_PATH(XAPIAN_INCLUDE_DIR xapian/version.h) 18 | 19 | FIND_LIBRARY(XAPIAN_LIBRARIES NAMES xapian) 20 | 21 | IF(XAPIAN_INCLUDE_DIR AND XAPIAN_LIBRARIES) 22 | SET(XAPIAN_FOUND TRUE) 23 | ELSE(XAPIAN_INCLUDE_DIR AND XAPIAN_LIBRARIES) 24 | SET(XAPIAN_FOUND FALSE) 25 | ENDIF(XAPIAN_INCLUDE_DIR AND XAPIAN_LIBRARIES) 26 | 27 | IF(XAPIAN_FOUND) 28 | IF(NOT Xapian_FIND_QUIETLY) 29 | MESSAGE(STATUS "Found Xapian: ${XAPIAN_LIBRARIES}") 30 | ENDIF(NOT Xapian_FIND_QUIETLY) 31 | ELSE(XAPIAN_FOUND) 32 | IF(Xapian_FIND_REQUIRED) 33 | MESSAGE(FATAL_ERROR "Could not find Xapian") 34 | ENDIF(Xapian_FIND_REQUIRED) 35 | IF(NOT Xapian_FIND_QUIETLY) 36 | MESSAGE(STATUS "Could not find Xapian") 37 | ENDIF(NOT Xapian_FIND_QUIETLY) 38 | ENDIF(XAPIAN_FOUND) 39 | 40 | # show the XAPIAN_INCLUDE_DIR and XAPIAN_LIBRARIES variables only in the advanced view 41 | MARK_AS_ADVANCED(XAPIAN_INCLUDE_DIR XAPIAN_LIBRARIES) 42 | -------------------------------------------------------------------------------- /cmake/modules/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 3 | ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | STRING(REGEX REPLACE "\n" ";" files "${files}") 7 | FOREACH(file ${files}) 8 | MESSAGE(STATUS "Uninstalling \"${file}\"") 9 | IF(NOT EXISTS "${file}") 10 | MESSAGE(FATAL_ERROR "File \"${file}\" does not exists.") 11 | ENDIF(NOT EXISTS "${file}") 12 | EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"${file}\"" 13 | OUTPUT_VARIABLE rm_out 14 | RETURN_VARIABLE rm_retval) 15 | IF("${rm_retval}" GREATER 0) 16 | MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"") 17 | ENDIF("${rm_retval}" GREATER 0) 18 | ENDFOREACH(file) 19 | 20 | IF(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uninstall_plus.cmake") 21 | INCLUDE("@CMAKE_CURRENT_BINARY_DIR@/uninstall_plus.cmake") 22 | ENDIF(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uninstall_plus.cmake") 23 | 24 | IF(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uninstall_plus.cmake") 25 | FILE( REMOVE "@CMAKE_CURRENT_BINARY_DIR@/uninstall_plus.cmake") 26 | ENDIF(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uninstall_plus.cmake") 27 | -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(qapttest) 2 | cmake_minimum_required(VERSION 2.6.0) 3 | 4 | find_package(KDE4 REQUIRED) 5 | include(FindPkgConfig REQUIRED) 6 | find_package(QApt REQUIRED) 7 | include(KDE4Defaults) 8 | 9 | set(qapttest_SRCS 10 | main.cpp 11 | qapttest.cpp 12 | cacheupdatewidget.cpp 13 | commitwidget.cpp 14 | ) 15 | 16 | include( FindPkgConfig ) 17 | 18 | add_executable(qaptest ${qapttest_SRCS}) 19 | 20 | target_link_libraries(qaptest ${KDE4_KDEUI_LIBS} 21 | ${KDE4_KIO_LIBS} 22 | ${QAPT_LIBRARY} 23 | DebconfKDE::Main) 24 | 25 | install(TARGETS qaptest ${INSTALL_TARGETS_DEFAULT_ARGS} ) 26 | 27 | -------------------------------------------------------------------------------- /example/cacheupdatewidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef CACHEUPDATEWIDGET_H 22 | #define CACHEUPDATEWIDGET_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | class QLabel; 33 | class QListView; 34 | class QProgressBar; 35 | class QStandardItemModel; 36 | class QPushButton; 37 | 38 | namespace QApt { 39 | class Transaction; 40 | class DownloadProgress; 41 | } 42 | 43 | class CacheUpdateWidget : public KVBox 44 | { 45 | Q_OBJECT 46 | public: 47 | CacheUpdateWidget(QWidget *parent); 48 | 49 | void clear(); 50 | void setTransaction(QApt::Transaction *trans); 51 | 52 | private: 53 | QApt::Transaction *m_trans; 54 | QStringList m_downloads; 55 | int m_lastRealProgress; 56 | 57 | QLabel *m_headerLabel; 58 | QListView *m_downloadView; 59 | QStandardItemModel *m_downloadModel; 60 | QProgressBar *m_totalProgress; 61 | QLabel *m_downloadSpeedLabel; 62 | QLabel *m_ETALabel; 63 | QPushButton *m_cancelButton; 64 | 65 | private slots: 66 | void onTransactionStatusChanged(QApt::TransactionStatus status); 67 | void progressChanged(int progress); 68 | void downloadProgressChanged(const QApt::DownloadProgress &progress); 69 | void updateDownloadSpeed(quint64 speed); 70 | void updateETA(quint64 ETA); 71 | void addItem(const QString &message); 72 | 73 | signals: 74 | void cancelCacheUpdate(); 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /example/commitwidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "commitwidget.h" 22 | 23 | //Qt 24 | #include 25 | #include 26 | 27 | //QApt 28 | #include 29 | 30 | CommitWidget::CommitWidget(QWidget *parent) 31 | : KVBox(parent) 32 | , m_trans(0) 33 | { 34 | m_commitLabel = new QLabel(this); 35 | m_progressBar = new QProgressBar(this); 36 | } 37 | 38 | void CommitWidget::setTransaction(QApt::Transaction *trans) 39 | { 40 | m_trans = trans; 41 | connect(m_trans, SIGNAL(statusDetailsChanged(QString)), 42 | m_commitLabel, SLOT(setText(QString))); 43 | connect(m_trans, SIGNAL(progressChanged(int)), 44 | m_progressBar, SLOT(setValue(int))); 45 | m_progressBar->setValue(trans->progress()); 46 | } 47 | 48 | void CommitWidget::clear() 49 | { 50 | m_commitLabel->setText(QString()); 51 | m_progressBar->setValue(0); 52 | m_trans = 0; 53 | } 54 | 55 | #include "commitwidget.moc" 56 | -------------------------------------------------------------------------------- /example/commitwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef COMMITWIDGET_H 22 | #define COMMITWIDGET_H 23 | 24 | #include 25 | 26 | class QLabel; 27 | class QProgressBar; 28 | 29 | namespace QApt { 30 | class Transaction; 31 | } 32 | 33 | class CommitWidget : public KVBox 34 | { 35 | Q_OBJECT 36 | public: 37 | explicit CommitWidget(QWidget *parent = 0); 38 | 39 | void setTransaction(QApt::Transaction *trans); 40 | void clear(); 41 | 42 | private: 43 | QApt::Transaction *m_trans; 44 | 45 | QLabel *m_commitLabel; 46 | QProgressBar *m_progressBar; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /example/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "qapttest.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | static const char description[] = 28 | I18N_NOOP("A KDE 4 Application"); 29 | 30 | static const char version[] = "0.1"; 31 | 32 | int main(int argc, char **argv) 33 | { 34 | KAboutData about("qapttest", 0, ki18n("LibQApt test"), version, ki18n(description), 35 | KAboutData::License_GPL, ki18n("(C) 2010 Jonathan Thomas"), KLocalizedString(), 0, "echidnaman@kubuntu.org"); 36 | about.addAuthor( ki18n("Jonathan Thomas"), KLocalizedString(), "echidnaman@kubuntu.org" ); 37 | KCmdLineArgs::init(argc, argv, &about); 38 | 39 | KApplication app; 40 | 41 | QAptTest *widget = new QAptTest; 42 | 43 | widget->show(); 44 | return app.exec(); 45 | } 46 | -------------------------------------------------------------------------------- /example/qapttest.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPTTEST_H 22 | #define QAPTTEST_H 23 | 24 | #include 25 | 26 | #include <../src/globals.h> 27 | 28 | class QLabel; 29 | class QPushButton; 30 | class QStackedWidget; 31 | 32 | class KToggleAction; 33 | class KLineEdit; 34 | 35 | class CacheUpdateWidget; 36 | class CommitWidget; 37 | 38 | namespace QApt { 39 | class Backend; 40 | class Package; 41 | class Transaction; 42 | class DownloadProgress; 43 | } 44 | 45 | namespace DebconfKde { 46 | class DebconfGui; 47 | } 48 | 49 | class QAptTest : public KMainWindow 50 | { 51 | Q_OBJECT 52 | public: 53 | QAptTest(); 54 | 55 | private Q_SLOTS: 56 | void updateLabels(); 57 | void updateCache(); 58 | void commitAction(); 59 | void upgrade(); 60 | void onTransactionStatusChanged(QApt::TransactionStatus status); 61 | void updateStatusBar(); 62 | 63 | private: 64 | QApt::Backend *m_backend; 65 | QApt::Package *m_package; 66 | QApt::Group *m_group; 67 | QApt::Transaction *m_trans; 68 | 69 | QStackedWidget *m_stack; 70 | QWidget *m_mainWidget; 71 | CacheUpdateWidget *m_cacheUpdateWidget; 72 | CommitWidget *m_commitWidget; 73 | KLineEdit *m_lineEdit; 74 | QPushButton *m_actionButton; 75 | QLabel *m_nameLabel; 76 | QLabel *m_sectionLabel; 77 | QLabel *m_originLabel; 78 | QLabel *m_installedSizeLabel; 79 | QLabel *m_maintainerLabel; 80 | QLabel *m_sourceLabel; 81 | QLabel *m_versionLabel; 82 | QLabel *m_packageSizeLabel; 83 | QLabel *m_shortDescriptionLabel; 84 | QLabel *m_longDescriptionLabel; 85 | 86 | QLabel *m_changedPackagesLabel; 87 | QLabel *m_packageCountLabel; 88 | 89 | DebconfKde::DebconfGui *m_debconfGui; 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /libqapt.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@ 4 | includedir=@CMAKE_INSTALL_PREFIX@/include/libqapt 5 | 6 | Name: libqapt 7 | Description: Qt wrapper around libapt-pkg 8 | Version: @QAPT_VERSION_STRING@ 9 | Libs: -L${libdir} -lQApt 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /qaptversion.h.cmake: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Sebastian Trueg 3 | * Copyright (C) 2009 Dario Freddi 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public License 16 | * along with this library; see the file COPYING.LIB. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef _AQPM_VERSION_H_ 22 | #define _AQPM_VERSION_H_ 23 | 24 | #include "Visibility.h" 25 | 26 | /// @brief QApt version as string at compile time. 27 | #define AQPM_VERSION_STRING "${AQPM_VERSION_STRING}" 28 | 29 | /// @brief The major QApt version number at compile time 30 | #define AQPM_VERSION_MAJOR ${MAJOR_AQPM_VERSION} 31 | 32 | /// @brief The minor QApt version number at compile time 33 | #define AQPM_VERSION_MINOR ${MINOR_AQPM_VERSION} 34 | 35 | /// @brief The QApt release version number at compile time 36 | #define AQPM_VERSION_RELEASE ${PATCH_AQPM_VERSION} 37 | 38 | /// @brief The QApt fix version number at compile time 39 | #define AQPM_VERSION_FIX ${FIX_AQPM_VERSION} 40 | 41 | /** 42 | * \brief Create a unique number from the major, minor and release number of a %QApt version 43 | * 44 | * This function can be used for preprocessing. For version information at runtime 45 | * use the version methods in the QApt namespace. 46 | */ 47 | #define AQPM_MAKE_VERSION( a,b,c,d ) (((a) << 16) | ((b) << 8) | (c) | (d)) 48 | 49 | /** 50 | * \brief %QApt Version as a unique number at compile time 51 | * 52 | * This macro calculates the %QApt version into a number. It is mainly used 53 | * through AQPM_IS_VERSION in preprocessing. For version information at runtime 54 | * use the version methods in the QApt namespace. 55 | */ 56 | #define AQPM_VERSION \ 57 | AQPM_MAKE_VERSION(AQPM_VERSION_MAJOR,AQPM_VERSION_MINOR,AQPM_VERSION_RELEASE,AQPM_VERSION_FIX) 58 | 59 | /** 60 | * \brief Check if the %QApt version matches a certain version or is higher 61 | * 62 | * This macro is typically used to compile conditionally a part of code: 63 | * \code 64 | * #if AQPM_IS_VERSION(2,1) 65 | * // Code for QApt 2.1 66 | * #else 67 | * // Code for QApt 2.0 68 | * #endif 69 | * \endcode 70 | * 71 | * For version information at runtime 72 | * use the version methods in the QApt namespace. 73 | */ 74 | #define AQPM_IS_VERSION(a,b,c,d) ( AQPM_VERSION >= AQPM_MAKE_VERSION(a,b,c,d) ) 75 | 76 | 77 | namespace QApt { 78 | /** 79 | * @brief Returns the major number of QApt's version, e.g. 80 | * 1 for %QApt 1.0.2. 81 | * @return the major version number at runtime. 82 | */ 83 | AQPM_EXPORT unsigned int versionMajor(); 84 | 85 | /** 86 | * @brief Returns the minor number of QApt's version, e.g. 87 | * 0 for %QApt 1.0.2. 88 | * @return the minor version number at runtime. 89 | */ 90 | AQPM_EXPORT unsigned int versionMinor(); 91 | 92 | /** 93 | * @brief Returns the release of QApt's version, e.g. 94 | * 2 for %QApt 1.0.2. 95 | * @return the release number at runtime. 96 | */ 97 | AQPM_EXPORT unsigned int versionRelease(); 98 | 99 | /** 100 | * @brief Returns the release of QApt's version, e.g. 101 | * 3 for %QApt 1.0.2.3. 102 | * @return the release number at runtime. 103 | */ 104 | AQPM_EXPORT unsigned int versionFix(); 105 | 106 | /** 107 | * @brief Returns the %QApt version as string, e.g. "1.0.2". 108 | * 109 | * On contrary to the macro AQPM_VERSION_STRING this function returns 110 | * the version number of QApt at runtime. 111 | * @return the %QApt version. You can keep the string forever 112 | */ 113 | AQPM_EXPORT const char* versionString(); 114 | } 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(qapt_SRCS 2 | backend.cpp 3 | cache.cpp 4 | package.cpp 5 | config.cpp 6 | history.cpp 7 | debfile.cpp 8 | dependencyinfo.cpp 9 | changelog.cpp 10 | transaction.cpp 11 | downloadprogress.cpp 12 | markingerrorinfo.cpp 13 | sourceentry.cpp 14 | sourceslist.cpp) 15 | 16 | add_subdirectory(worker) 17 | 18 | set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/worker/${QAPT_WORKER_RDN_VERSIONED}.transaction.xml 19 | APPEND PROPERTY 20 | INCLUDE downloadprogress.h 21 | ) 22 | set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/worker/${QAPT_WORKER_RDN_VERSIONED}.transaction.xml 23 | APPEND PROPERTY 24 | NO_NAMESPACE 1 25 | ) 26 | 27 | message(WARNING "terrible use of transaction xml file") 28 | qt5_add_dbus_interface(qapt_SRCS 29 | ${CMAKE_CURRENT_BINARY_DIR}/worker/${QAPT_WORKER_RDN_VERSIONED}.transaction.xml 30 | transactioninterface_p) 31 | 32 | set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/worker/${QAPT_WORKER_RDN_VERSIONED}.xml 33 | APPEND PROPERTY 34 | NO_NAMESPACE 1 35 | ) 36 | 37 | message(WARNING "terrible use of worker xml file") 38 | qt5_add_dbus_interface(qapt_SRCS 39 | ${CMAKE_CURRENT_BINARY_DIR}/worker/${QAPT_WORKER_RDN_VERSIONED}.xml 40 | workerinterface_p) 41 | 42 | configure_file(dbusinterfaces_p.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/dbusinterfaces_p.h) 43 | 44 | ecm_create_qm_loader(qapt_SRCS libqapt) 45 | 46 | add_library(QApt SHARED ${qapt_SRCS}) 47 | add_library(QApt::Main ALIAS QApt) 48 | 49 | # Set header paths for target so the utils can find them. 50 | target_include_directories(QApt PUBLIC "$") 51 | target_include_directories(QApt INTERFACE "$" ) 52 | 53 | set_target_properties(QApt 54 | PROPERTIES 55 | VERSION ${QAPT_VERSION_STRING} 56 | SOVERSION ${QAPT_SOVERSION} 57 | EXPORT_NAME Main) 58 | 59 | target_link_libraries(QApt 60 | PUBLIC 61 | Qt5::Widgets 62 | ${APTPKG_LIBRARIES} 63 | PRIVATE 64 | Qt5::DBus 65 | ${XAPIAN_LIBRARIES}) 66 | 67 | install(TARGETS QApt EXPORT QAptTargets LIBRARY DESTINATION ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) 68 | 69 | ecm_generate_headers(QAPT_CAMEL_CASE_HEADERS 70 | HEADER_NAMES 71 | Backend 72 | Changelog 73 | Config 74 | DebFile 75 | DependencyInfo 76 | DownloadProgress 77 | Globals 78 | History 79 | MarkingErrorInfo 80 | Package 81 | SourceEntry 82 | SourcesList 83 | Transaction 84 | 85 | REQUIRED_HEADERS QAPT_HEADERS 86 | PREFIX QApt) 87 | 88 | install(FILES ${QAPT_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/qapt COMPONENT Devel) 89 | install(FILES ${QAPT_CAMEL_CASE_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/QApt COMPONENT Devel) 90 | -------------------------------------------------------------------------------- /src/cache.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "cache.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace QApt { 28 | 29 | class CachePrivate 30 | { 31 | public: 32 | CachePrivate() 33 | : cache(new pkgCacheFile()) 34 | , trustCache(new QHash) 35 | { 36 | } 37 | 38 | ~CachePrivate() 39 | { 40 | delete cache; 41 | delete trustCache; 42 | } 43 | 44 | pkgCacheFile *cache; 45 | 46 | QHash *trustCache; 47 | }; 48 | 49 | Cache::Cache(QObject* parent) 50 | : QObject(parent) 51 | , d_ptr(new CachePrivate) 52 | { 53 | } 54 | 55 | Cache::~Cache() 56 | { 57 | delete d_ptr; 58 | } 59 | 60 | bool Cache::open() 61 | { 62 | Q_D(Cache); 63 | 64 | // Close cache in case it's been opened 65 | d->cache->Close(); 66 | d->trustCache->clear(); 67 | 68 | // Build the cache, return whether it opened 69 | return d->cache->ReadOnlyOpen(); 70 | } 71 | 72 | pkgDepCache *Cache::depCache() const 73 | { 74 | Q_D(const Cache); 75 | 76 | return *d->cache; 77 | } 78 | 79 | pkgSourceList *Cache::list() const 80 | { 81 | Q_D(const Cache); 82 | 83 | return d->cache->GetSourceList(); 84 | } 85 | 86 | QHash *Cache::trustCache() const 87 | { 88 | Q_D(const Cache); 89 | 90 | return d->trustCache; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/cache.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPT_CACHE_H 22 | #define QAPT_CACHE_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | class pkgDepCache; 30 | class pkgIndexFile; 31 | class pkgSourceList; 32 | 33 | namespace QApt { 34 | 35 | /** 36 | * CachePrivate is a class containing all private members of the Cache class 37 | */ 38 | class CachePrivate; 39 | 40 | /** 41 | * The Cache class is what handles the internal APT package cache. It is used 42 | * internally by QApt::Backend to manage the APT cache, as well as to act as 43 | * an additional cache for a list of packages that can be downloaded from a 44 | * trusted source. 45 | * 46 | * @author Jonathan Thomas 47 | */ 48 | class Cache : public QObject 49 | { 50 | Q_OBJECT 51 | public: 52 | /** 53 | * Constructor 54 | */ 55 | explicit Cache(QObject* parent); 56 | 57 | /** 58 | * Destructor 59 | */ 60 | ~Cache(); 61 | 62 | /** 63 | * Returns a pointer to the interal dependency cache, which keeps track of 64 | * inter-package dependencies. 65 | */ 66 | pkgDepCache *depCache() const; 67 | 68 | /// Returns a pointer to the interal package source list. 69 | pkgSourceList *list() const; 70 | 71 | /** 72 | * Returns a pointer to QApt's cache of trusted package source index 73 | * files. These are used by QApt::Package to determine whether or not 74 | * a package is trusted 75 | */ 76 | QHash *trustCache() const; 77 | 78 | public Q_SLOTS: 79 | /** 80 | * Initializes the internal package cache. It is also used to re-open the 81 | * cache when the need arises. (E.g. such as an updated sources list, or a 82 | * package installation or removal) 83 | * 84 | * @return @c true if opening succeeds, false otherwise 85 | */ 86 | bool open(); 87 | 88 | protected: 89 | CachePrivate *const d_ptr; 90 | 91 | private: 92 | Q_DECLARE_PRIVATE(Cache) 93 | }; 94 | 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /src/changelog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPT_CHANGELOG_H 22 | #define QAPT_CHANGELOG_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace QApt { 30 | 31 | class ChangelogEntryPrivate; 32 | class ChangelogPrivate; 33 | 34 | /** 35 | * The ChangelogEntry class represents a single entry in a Debian changelog file 36 | * 37 | * @author Jonathan Thomas 38 | * @since 1.3 39 | */ 40 | 41 | class Q_DECL_EXPORT ChangelogEntry 42 | { 43 | public: 44 | /** 45 | * Constructs a Debian changelog entry with the provided entry data for 46 | * the specified source package 47 | * 48 | * @param entryData The raw changelog entry 49 | * @param sourcePackage The source package the changelog entry is for 50 | */ 51 | ChangelogEntry(const QString &entryData, const QString &sourcePackage); 52 | 53 | /// Copy constructor 54 | ChangelogEntry(const ChangelogEntry &other); 55 | 56 | /// Destructor 57 | ~ChangelogEntry(); 58 | 59 | /// Assignment operator 60 | ChangelogEntry &operator=(const ChangelogEntry &rhs); 61 | 62 | /// Returns the raw text that makes up the changelog entry 63 | QString entryText() const; 64 | 65 | /// Returns the version of the source package that this changelog entry is for. 66 | QString version() const; 67 | 68 | /// Returns the timestamp of the changelog entry. 69 | QDateTime issueDateTime() const; 70 | 71 | /** 72 | * Returns the description portion of the changelog entry, minus any formatting 73 | * data such as source package, version, issue time, etc. 74 | */ 75 | QString description() const; 76 | 77 | /** 78 | * Returns a list of URLs to webpages providing descriptions of Common 79 | * Vulnerabilities and Exposures that the version of a package that this 80 | * changelog entry describes fixes. 81 | */ 82 | QStringList CVEUrls() const; 83 | 84 | private: 85 | QSharedDataPointer d; 86 | }; 87 | 88 | typedef QList ChangelogEntryList; 89 | 90 | 91 | /** 92 | * The Changelog class is an interface for retreiving information from a Debian 93 | * changelog file 94 | * 95 | * @author Jonathan Thomas 96 | * @since 1.3 97 | */ 98 | class Q_DECL_EXPORT Changelog 99 | { 100 | public: 101 | /** 102 | * Constructor 103 | * 104 | * @param data The full contents of a Debian changelog file 105 | * @param sourcePackage The source package the changelog file is for 106 | */ 107 | Changelog(const QString &data, const QString &sourcePackage); 108 | 109 | /// Copy constructor 110 | Changelog(const Changelog &other); 111 | 112 | /// Destructor 113 | ~Changelog(); 114 | 115 | /// Assignment operator 116 | Changelog &operator=(const Changelog &rhs); 117 | 118 | /// Returns the full changelog as a string 119 | QString text() const; 120 | 121 | /// Returns a list of parsed individual changelog entries 122 | ChangelogEntryList entries() const; 123 | 124 | /** 125 | * Returns a list of parsed individual changelog entries that have been 126 | * made since the specified version. 127 | */ 128 | ChangelogEntryList newEntriesSince(const QString &version) const; 129 | 130 | private: 131 | QSharedDataPointer d; 132 | }; 133 | 134 | } 135 | 136 | Q_DECLARE_TYPEINFO(QApt::ChangelogEntry, Q_MOVABLE_TYPE); 137 | Q_DECLARE_TYPEINFO(QApt::Changelog, Q_MOVABLE_TYPE); 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPT_CONFIG_H 22 | #define QAPT_CONFIG_H 23 | 24 | #include 25 | #include 26 | 27 | /** 28 | * The QApt namespace is the main namespace for LibQApt. All classes in this 29 | * library fall under this namespace. 30 | */ 31 | namespace QApt { 32 | 33 | /** 34 | * ConfigPrivate is a class containing all private members of the Config class 35 | */ 36 | class ConfigPrivate; 37 | 38 | /** 39 | * @brief Config wrapper for the libapt-pkg config API 40 | * 41 | * Config is a wrapper around libapt-pkg's config.h. It provides Qt-style 42 | * calls to get/set config. It writes to the main apt config file, usually in 43 | * /etc/apt/apt.conf. It is possible to use this class without a QApt::Backend, 44 | * but please note that you \b _MUST_ initialize the package system with 45 | * libapt-pkg before the values returned by readEntry will be accurate. 46 | * 47 | * @author Jonathan Thomas 48 | * @since 1.1 49 | */ 50 | class Q_DECL_EXPORT Config : public QObject 51 | { 52 | Q_OBJECT 53 | public: 54 | /** 55 | * Default constructor 56 | */ 57 | explicit Config(QObject *parent); 58 | 59 | /** 60 | * Default destructor 61 | */ 62 | ~Config(); 63 | 64 | /** 65 | * Reads the value of an entry specified by @p key 66 | * 67 | * @param key the key to search for 68 | * @param defaultValue the default value returned if the key was not found 69 | * 70 | * @return the value for this key, or @p default if the key was not found 71 | * 72 | * @see writeEntry() 73 | */ 74 | bool readEntry(const QString &key, const bool defaultValue) const; 75 | 76 | /** Overload for readEntry(const QString&, const bool) */ 77 | int readEntry(const QString &key, const int defaultValue) const; 78 | 79 | /** Overload for readEntry(const QString&, const bool) */ 80 | QString readEntry(const QString &key, const QString &defaultValue) const; 81 | 82 | /** 83 | * Locates the path of the given key. This uses APT's configuration 84 | * key algorithm to return various apt-related directories. For example, 85 | * a key of 'Dir::Etc' would return the location of the APT configuration 86 | * directory (usually /etc/apt), and 'Dir::Etc::main' would return the 87 | * location of apt.conf (usually /etc/apt/apt.conf) 88 | * 89 | * @param key the key to search for 90 | * @param defaultValue the directory to use as default if the key isn't found 91 | * 92 | * @return the location of the config key, or the default if the key 93 | * is not found 94 | * @since 1.4 95 | */ 96 | QString findDirectory(const QString &key, const QString &defaultValue = QString()) const; 97 | 98 | /** 99 | * Writes a value to the APT configuration object, and applies it 100 | * 101 | * @param key the key to write to 102 | * @param value the value to write 103 | * 104 | * @see readEntry() 105 | */ 106 | void writeEntry(const QString &key, const bool value); 107 | 108 | /** Overload for writeEntry(const QString&, const bool) */ 109 | void writeEntry(const QString &key, const int value); 110 | 111 | /** Overload for writeEntry(const QString&, const bool) */ 112 | void writeEntry(const QString &key, const QString &value); 113 | 114 | /** 115 | * Locates the file of the given key. This uses APT's configuration 116 | * key algorithm to return various apt-related files. For example, 117 | * a key of 'Dir::Etc::sourcelist' would return the location of the APT 118 | * sources.list file (usually /etc/apt/sources.list) 119 | * 120 | * @param key the key to search for 121 | * @param defaultValue the directory to use as default if the key isn't found 122 | * 123 | * @return the location of the config key, or the default if the key 124 | * is not found 125 | * @since 1.4 126 | */ 127 | QString findFile(const QString &key, const QString &defaultValue = QString()) const; 128 | 129 | /** 130 | * Returns a list of the CPU architectures APT is configured to support 131 | * 132 | * @since 1.4 133 | */ 134 | QStringList architectures() const; 135 | 136 | private: 137 | Q_DECLARE_PRIVATE(Config) 138 | ConfigPrivate *const d_ptr; 139 | }; 140 | 141 | } 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /src/dbusinterfaces_p.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef QAPT_DBUSINTERFACES_P_H 2 | #define QAPT_DBUSINTERFACES_P_H 3 | 4 | #include "transactioninterface_p.h" 5 | #include "workerinterface_p.h" 6 | 7 | // Unlike other approaches this one will always explode when a define does not 8 | // actually make it into the compiler (e.g. because the CMake var was renamed). 9 | // e.g. QString() would compile fine if the define is missing, 10 | // char[]=; on the other hand won't. 11 | static const char s_workerVersion[] = @QAPT_WORKER_VERSION_STRING@; 12 | static const char s_workerReverseDomainName[] = @QAPT_WORKER_RDN_VERSIONED_STRING@; 13 | 14 | // This will fail regardless of whether the var is present or not as this is 15 | // hard typed anyway. 16 | typedef OrgKubuntuQaptworker@QAPT_WORKER_VERSION@Interface WorkerInterface; 17 | typedef OrgKubuntuQaptworker@QAPT_WORKER_VERSION@TransactionInterface TransactionInterface; 18 | 19 | #endif // QAPT_DBUSINTERFACES_P_H 20 | -------------------------------------------------------------------------------- /src/dependencyinfo.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2014 Harald Sitter * 3 | * Copyright © 2011 Jonathan Thomas * 4 | * * 5 | * This program is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU General Public License as * 7 | * published by the Free Software Foundation; either version 2 of * 8 | * the License or (at your option) version 3 or any later version * 9 | * accepted by the membership of KDE e.V. (or its successor approved * 10 | * by the membership of KDE e.V.), which shall act as a proxy * 11 | * defined in Section 14 of version 3 of the license. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program. If not, see . * 20 | ***************************************************************************/ 21 | 22 | #ifndef QAPT_DEPENDENCYINFO_H 23 | #define QAPT_DEPENDENCYINFO_H 24 | 25 | #include 26 | #include 27 | 28 | #include "globals.h" 29 | 30 | namespace QApt { 31 | 32 | class DependencyInfoPrivate; 33 | 34 | /** 35 | * The DependencyInfo object describes a single dependency that a package can 36 | * have. DependencyInfo objects that are part of a group of "or" dependencies 37 | * will return @c true for the isOrDependency() function 38 | * 39 | * This class has a rather low-level dependency. You will most likely not need 40 | * to use this function, unless you are installing packages via .deb files 41 | * directly with dpkg circumventing APT, and wish to check that all 42 | * dependencies are satisfied before blindly installing the package with dpkg. 43 | * 44 | * @since 1.2 45 | * 46 | * @author Jonathan Thomas 47 | */ 48 | class Q_DECL_EXPORT DependencyInfo 49 | { 50 | public: 51 | /** 52 | * Default constructor. 53 | * 54 | * All unspecified fields are either empty or 0 55 | */ 56 | DependencyInfo(); 57 | 58 | /** 59 | * Copy constructor. Creates a shallow copy. 60 | */ 61 | DependencyInfo(const DependencyInfo &other); 62 | 63 | /** 64 | * Default destructor. 65 | */ 66 | ~DependencyInfo(); 67 | 68 | /** 69 | * Assignment operator. 70 | */ 71 | DependencyInfo &operator=(const DependencyInfo &rhs); 72 | 73 | static QList > parseDepends(const QString &field, DependencyType type); 74 | 75 | /** 76 | * The name of the package that the dependency describes. 77 | * 78 | * @return The package name of the dependency 79 | */ 80 | QString packageName() const; 81 | 82 | /** 83 | * The version of the package that the dependency describes. 84 | * 85 | * @return The package version of the dependency 86 | */ 87 | QString packageVersion() const; 88 | 89 | /** 90 | * The logical relation in regards to the version that the dependency 91 | * describes 92 | * 93 | * @return The logical relation of the dependency 94 | */ 95 | RelationType relationType() const; 96 | 97 | /** 98 | * The dependency type that the dependency describes, such as a 99 | * "Depend", "Recommends", "Suggests", etc. 100 | * 101 | * @return The @c DependencyType of the dependency 102 | */ 103 | DependencyType dependencyType() const; 104 | 105 | /** 106 | * @return the multi-arch annotation defining on whether Multi-Arch: allowed 107 | * dependency candidates may be used to resolve the dependency. 108 | * A non-empty annotation would be either 'any', 'native' or a 109 | * specific architecture tag (please refer to the multi-arch specifiation 110 | * for additional information on what the tags mean). 111 | */ 112 | QString multiArchAnnotation() const; 113 | 114 | /** 115 | * @return a localized string representation of the type. 116 | */ 117 | static QString typeName(DependencyType type); 118 | 119 | private: 120 | DependencyInfo(const QString &package, 121 | const QString &version, 122 | RelationType rType, 123 | DependencyType dType); 124 | 125 | QSharedDataPointer d; 126 | 127 | friend class Package; 128 | }; 129 | 130 | /** 131 | * A DependencyItem is a list of DependencyInfo objects that are all 132 | * interchangable "or" dependencies of a package. Any one of the package 133 | * name/version combinations specified by the DependencyInfo objects in this 134 | * list will satisfy the dependency 135 | */ 136 | typedef QList DependencyItem; 137 | 138 | } 139 | 140 | Q_DECLARE_TYPEINFO(QApt::DependencyInfo, Q_MOVABLE_TYPE); 141 | Q_DECLARE_TYPEINFO(QList, Q_MOVABLE_TYPE); 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /src/downloadprogress.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DOWNLOADPROGRESS_H 22 | #define DOWNLOADPROGRESS_H 23 | 24 | #include 25 | #include 26 | 27 | #include "globals.h" 28 | 29 | class QDBusArgument; 30 | 31 | namespace QApt { 32 | 33 | class DownloadProgressPrivate; 34 | 35 | /** 36 | * The DownloadProgress class contains progress information for a single 37 | * file being downloaded through a Transaction. 38 | * 39 | * @author Jonathan Thomas 40 | * @since 2.0 41 | */ 42 | class Q_DECL_EXPORT DownloadProgress 43 | { 44 | public: 45 | DownloadProgress(); 46 | 47 | /** 48 | * Constructs a new download progress from the given data. 49 | */ 50 | DownloadProgress(const QString &uri, QApt::DownloadStatus status, 51 | const QString &shortDesc, quint64 fileSize, 52 | quint64 fetchedSize, const QString &statusMessage); 53 | 54 | /** 55 | * Constructs a copy of the @a other download progress. 56 | */ 57 | DownloadProgress(const DownloadProgress &other); 58 | 59 | /** 60 | * Destroys the download progress. 61 | */ 62 | ~DownloadProgress(); 63 | 64 | /** 65 | * Assigns @a other to this download progress and returns a reference 66 | * to this download progress. 67 | */ 68 | DownloadProgress &operator=(const DownloadProgress &rhs); 69 | 70 | /** 71 | * Returns the uniform resource identifier for the file being 72 | * downloaded. (Its remote path.) 73 | */ 74 | QString uri() const; 75 | 76 | /** 77 | * Returns the current status for this download. 78 | */ 79 | QApt::DownloadStatus status() const; 80 | 81 | /** 82 | * Returns a one-line short description of the file being downloaded. 83 | * (E.g. a package name or the name of a package list file that is being 84 | * downloaded.) 85 | */ 86 | QString shortDescription() const; 87 | 88 | /** 89 | * Returns the full size of the file being downloaded. 90 | * 91 | * @sa partialSize() 92 | */ 93 | quint64 fileSize() const; 94 | 95 | /** 96 | * Returns the size of the data that has already been downloaded for 97 | * the file. 98 | */ 99 | quint64 fetchedSize() const; 100 | 101 | /** 102 | * Returns the current status message for the download. 103 | */ 104 | QString statusMessage() const; 105 | 106 | /** 107 | * Returns the download progress of the URI, described in percentage. 108 | */ 109 | int progress() const; 110 | 111 | /** 112 | * Convenience function to register DownloadProgress with the Qt 113 | * meta-type system for use with queued signals/slots or D-Bus. 114 | */ 115 | static void registerMetaTypes(); 116 | 117 | friend const QDBusArgument &operator>>(const QDBusArgument &argument, 118 | QApt::DownloadProgress &progress); 119 | friend QDBusArgument &operator<<(QDBusArgument &argument, 120 | const QApt::DownloadProgress &progress); 121 | 122 | private: 123 | QSharedDataPointer d; 124 | 125 | void setUri(const QString &uri); 126 | void setStatus(QApt::DownloadStatus status); 127 | void setShortDescription(const QString &shortDescription); 128 | void setFileSize(quint64 fileSize); 129 | void setFetchedSize(quint64 fetchedSize); 130 | void setStatusMessage(const QString &message); 131 | }; 132 | 133 | } 134 | 135 | Q_DECLARE_TYPEINFO(QApt::DownloadProgress, Q_MOVABLE_TYPE); 136 | Q_DECLARE_METATYPE(QApt::DownloadProgress) 137 | 138 | #endif // DOWNLOADPROGRESS_H 139 | -------------------------------------------------------------------------------- /src/history.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPT_HISTORY_H 22 | #define QAPT_HISTORY_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "package.h" 31 | 32 | /** 33 | * The QApt namespace is the main namespace for LibQApt. All classes in this 34 | * library fall under this namespace. 35 | */ 36 | namespace QApt { 37 | 38 | /** 39 | * HistoryItemPrivate is a class containing all private members of the HistoryItem class 40 | */ 41 | class HistoryItemPrivate; 42 | 43 | /** 44 | * The HistoryItem class represents a single entry in the APT history logs 45 | * 46 | * @author Jonathan Thomas 47 | * @since 1.1 48 | */ 49 | class Q_DECL_EXPORT HistoryItem 50 | { 51 | public: 52 | /** 53 | * Constructor 54 | * 55 | * @param data The raw text from the history log 56 | */ 57 | HistoryItem(const QString &data); 58 | 59 | /** 60 | * Shallow copy constructor 61 | * 62 | * @param other The HistoryItem to be copied 63 | */ 64 | HistoryItem(const HistoryItem &other); 65 | 66 | /** 67 | * Constructor 68 | */ 69 | ~HistoryItem(); 70 | 71 | /** 72 | * Equality operator implementing a shallow copy 73 | * 74 | * @param rhs The object to be copied 75 | */ 76 | HistoryItem &operator=(const HistoryItem &rhs); 77 | 78 | /** 79 | * Returns the date upon which the transaction occurred. 80 | * 81 | * @return the date when the transaction occurred as a \c QDateTime 82 | */ 83 | QDateTime startDate() const; 84 | 85 | /** 86 | * Returns the list of packages installed during the transaction 87 | * 88 | * @return the package list as a \c QStringList 89 | */ 90 | QStringList installedPackages() const; 91 | 92 | /** 93 | * Returns the list of packages upgraded during the transaction 94 | * 95 | * @return the package list as a \c QStringList 96 | */ 97 | QStringList upgradedPackages() const; 98 | 99 | /** 100 | * Returns the list of packages downgraded during the transaction 101 | * 102 | * @return the package list as a \c QStringList 103 | */ 104 | QStringList downgradedPackages() const; 105 | 106 | /** 107 | * Returns the list of packages removed during the transaction 108 | * 109 | * @return the package list as a \c QStringList 110 | */ 111 | QStringList removedPackages() const; 112 | 113 | /** 114 | * Returns the list of packages purged during the transaction 115 | * 116 | * @return the package list as a \c QStringList 117 | */ 118 | QStringList purgedPackages() const; 119 | 120 | /** 121 | * Returns the error reported by dpkg, if there is one. If the transaction 122 | * did not encounter an error, this will return an empty QString. 123 | * 124 | * @return the error as a \c QString 125 | */ 126 | QString errorString() const; 127 | 128 | /** 129 | * Returns whether or not the HistoryItem is valid. (It could be an improperly 130 | * parsed portion of the log 131 | */ 132 | bool isValid() const; 133 | 134 | private: 135 | QSharedDataPointer d; 136 | }; 137 | 138 | typedef QList HistoryItemList; 139 | 140 | /** 141 | * HistoryPrivate is a class containing all private members of the History class 142 | */ 143 | class HistoryPrivate; 144 | 145 | 146 | /** 147 | * The History class is an interface for retreiving information from the APT 148 | * history logs. 149 | * 150 | * @author Jonathan Thomas 151 | * @since 1.1 152 | */ 153 | class Q_DECL_EXPORT History : public QObject 154 | { 155 | Q_OBJECT 156 | public: 157 | /** 158 | * Constructor 159 | */ 160 | explicit History(QObject *parent); 161 | 162 | /** 163 | * Destructor 164 | */ 165 | ~History(); 166 | 167 | /** 168 | * Returns a list of all history items in APT's history logs. 169 | */ 170 | HistoryItemList historyItems() const; 171 | 172 | private: 173 | Q_DECLARE_PRIVATE(History) 174 | HistoryPrivate *const d_ptr; 175 | 176 | public Q_SLOTS: 177 | /** 178 | * Re-initializes the history log data. This should be connected to a 179 | * directory watch (such as KDirWatch) to catch changes to the history 180 | * file on-the-fly, if desired 181 | */ 182 | void reload(); 183 | }; 184 | 185 | } 186 | 187 | Q_DECLARE_TYPEINFO(QApt::HistoryItem, Q_MOVABLE_TYPE); 188 | 189 | #endif 190 | -------------------------------------------------------------------------------- /src/markingerrorinfo.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "markingerrorinfo.h" 22 | 23 | namespace QApt { 24 | 25 | class MarkingErrorInfoPrivate : public QSharedData { 26 | public: 27 | MarkingErrorInfoPrivate() 28 | : MarkingErrorInfoPrivate(QApt::UnknownReason) 29 | {} 30 | 31 | MarkingErrorInfoPrivate(BrokenReason reason, const DependencyInfo &info = DependencyInfo()) 32 | : QSharedData() 33 | , errorType(reason) 34 | , errorInfo(info) 35 | {} 36 | 37 | MarkingErrorInfoPrivate(const MarkingErrorInfoPrivate &other) 38 | : QSharedData(other) 39 | , errorType(other.errorType) 40 | , errorInfo(other.errorInfo) 41 | {} 42 | 43 | // Data members 44 | QApt::BrokenReason errorType; 45 | QApt::DependencyInfo errorInfo; 46 | }; 47 | 48 | MarkingErrorInfo::MarkingErrorInfo() 49 | : d(new MarkingErrorInfoPrivate()) 50 | { 51 | } 52 | 53 | MarkingErrorInfo::MarkingErrorInfo(BrokenReason reason, const DependencyInfo &info) 54 | : d(new MarkingErrorInfoPrivate(reason, info)) 55 | { 56 | } 57 | 58 | MarkingErrorInfo::MarkingErrorInfo(const MarkingErrorInfo &other) 59 | : d(other.d) 60 | { 61 | } 62 | 63 | MarkingErrorInfo::~MarkingErrorInfo() 64 | { 65 | } 66 | 67 | MarkingErrorInfo &MarkingErrorInfo::operator=(const MarkingErrorInfo &rhs) 68 | { 69 | // Protect against self-assignment 70 | if (this == &rhs) { 71 | return *this; 72 | } 73 | d = rhs.d; 74 | return *this; 75 | } 76 | 77 | BrokenReason MarkingErrorInfo::errorType() const 78 | { 79 | return d->errorType; 80 | } 81 | 82 | DependencyInfo MarkingErrorInfo::errorInfo() const 83 | { 84 | return d->errorInfo; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/markingerrorinfo.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef MARKINGERRORINFO_H 22 | #define MARKINGERRORINFO_H 23 | 24 | #include 25 | #include 26 | 27 | #include "dependencyinfo.h" 28 | 29 | namespace QApt { 30 | 31 | class MarkingErrorInfoPrivate; 32 | 33 | class Q_DECL_EXPORT MarkingErrorInfo 34 | { 35 | public: 36 | /** 37 | * Default constructor, empty values 38 | */ 39 | explicit MarkingErrorInfo(); 40 | 41 | /** 42 | * Constructs a marking error information object with the given 43 | * reason and dependency info 44 | * 45 | * @param reason Why a marking is broken 46 | * @param info Additional dependency information describing the error 47 | */ 48 | explicit MarkingErrorInfo(QApt::BrokenReason reason, const DependencyInfo &info = DependencyInfo()); 49 | 50 | /** 51 | * Copy constructor 52 | */ 53 | explicit MarkingErrorInfo(const MarkingErrorInfo &other); 54 | 55 | /** 56 | * Default Destructor 57 | */ 58 | ~MarkingErrorInfo(); 59 | 60 | /** 61 | * Assignment operator 62 | */ 63 | MarkingErrorInfo &operator=(const MarkingErrorInfo &rhs); 64 | 65 | QApt::BrokenReason errorType() const; 66 | 67 | /** 68 | * Returns dependency info related to the error, if the error 69 | * is dependency-related. (E.g. info on an uninstallable parent, 70 | * info on an uninstallable dependency, or info about the wrong 71 | * version of a package being available for installation. 72 | */ 73 | QApt::DependencyInfo errorInfo() const; 74 | 75 | private: 76 | QSharedDataPointer d; 77 | }; 78 | 79 | } 80 | 81 | Q_DECLARE_TYPEINFO(QApt::MarkingErrorInfo, Q_MOVABLE_TYPE); 82 | 83 | #endif // MARKINGERRORINFO_H 84 | -------------------------------------------------------------------------------- /src/sourceentry.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2013 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef SOURCEENTRY_H 22 | #define SOURCEENTRY_H 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | namespace QApt { 29 | 30 | class SourceEntryPrivate; 31 | 32 | class Q_DECL_EXPORT SourceEntry 33 | { 34 | public: 35 | explicit SourceEntry(); 36 | explicit SourceEntry(const QString &line, const QString &file = QString()); 37 | explicit SourceEntry(const QString &type, const QString &uri, const QString &dist, 38 | const QStringList &comps, const QString &comment, 39 | const QStringList &archs = QStringList(), const QString &file = QString()); 40 | SourceEntry(const SourceEntry &entry); 41 | SourceEntry &operator=(const SourceEntry &); 42 | ~SourceEntry(); 43 | 44 | bool operator==(const SourceEntry &other) const; 45 | 46 | bool isValid() const; 47 | bool isEnabled() const; 48 | QString type() const; 49 | QStringList architectures() const; 50 | QString uri() const; 51 | QString dist() const; 52 | QStringList components() const; 53 | QString comment() const; 54 | QString file() const; 55 | QString toString() const; 56 | 57 | void setEnabled(bool isEnabled); 58 | void setType(const QString &type); 59 | void setArchitectures(const QStringList &archs); 60 | void setUri(const QString &uri); 61 | void setDist(const QString &dist); 62 | void setComponents(const QStringList &comps); 63 | void setComment(const QString &comment); 64 | void setFile(const QString &file); 65 | 66 | private: 67 | QSharedDataPointer d; 68 | }; 69 | 70 | typedef QList SourceEntryList; 71 | 72 | } 73 | 74 | Q_DECLARE_TYPEINFO(QApt::SourceEntry, Q_MOVABLE_TYPE); 75 | 76 | #endif // SOURCEENTRY_H 77 | -------------------------------------------------------------------------------- /src/sourceslist.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2013 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef SOURCESLIST_H 22 | #define SOURCESLIST_H 23 | 24 | // Qt includes 25 | #include 26 | 27 | // Own includes 28 | #include "sourceentry.h" 29 | 30 | namespace QApt { 31 | 32 | class SourcesListPrivate; 33 | 34 | class Q_DECL_EXPORT SourcesList : public QObject 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit SourcesList(QObject *parent = 0); 39 | explicit SourcesList(QObject *parent, const QStringList &sourcesFileList); 40 | ~SourcesList(); 41 | SourceEntryList entries() const; 42 | SourceEntryList entries(const QString &sourceFile) const; 43 | 44 | void addEntry(const SourceEntry &entry); 45 | void removeEntry(const SourceEntry &entry); 46 | bool containsEntry(const SourceEntry &entry, const QString &sourceFile = QString()); 47 | QStringList sourceFiles(); 48 | QString toString() const; 49 | void save(); 50 | 51 | private: 52 | Q_DECLARE_PRIVATE(SourcesList) 53 | SourcesListPrivate *const d_ptr; 54 | 55 | QString dataForSourceFile(const QString &sourceFile); 56 | 57 | public Q_SLOTS: 58 | void reload(); 59 | }; 60 | 61 | } 62 | 63 | #endif // SOURCESLIST_H 64 | -------------------------------------------------------------------------------- /src/worker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file(org.kubuntu.qaptworker.transaction.xml.cmake 2 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.transaction.xml) 3 | configure_file(org.kubuntu.qaptworker.xml.cmake 4 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.xml) 5 | configure_file(org.kubuntu.qaptworker.service.cmake 6 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.service) 7 | configure_file(qaptworker.actions.cmake 8 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.actions) 9 | configure_file(org.kubuntu.qaptworker.policy.cmake 10 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.policy) 11 | configure_file(org.kubuntu.qaptworker.conf.cmake 12 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.conf) 13 | configure_file(urihelper.h.cmake 14 | ${CMAKE_CURRENT_BINARY_DIR}/urihelper.h) 15 | 16 | include_directories( 17 | ${CMAKE_CURRENT_SOURCE_DIR} 18 | ${CMAKE_CURRENT_BINARY_DIR} 19 | ${CMAKE_SOURCE_DIR}/src) 20 | 21 | set(qapt_worker_SRCS 22 | main.cpp 23 | aptlock.cpp 24 | aptworker.cpp 25 | transaction.cpp 26 | transactionqueue.cpp 27 | workeracquire.cpp 28 | workerdaemon.cpp 29 | workerinstallprogress.cpp) 30 | 31 | qt5_add_dbus_adaptor(qapt_worker_adaptor_SRCS 32 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.transaction.xml 33 | transaction.h 34 | Transaction 35 | transactionadaptor 36 | TransactionAdaptor) 37 | 38 | qt5_add_dbus_adaptor(qapt_worker_SRCS 39 | ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.xml 40 | workerdaemon.h 41 | WorkerDaemon 42 | workeradaptor 43 | WorkerAdaptor) 44 | 45 | add_executable(qaptworker${QAPT_WORKER_VERSION} 46 | ${qapt_worker_SRCS} 47 | ${qapt_worker_adaptor_SRCS}) 48 | 49 | target_link_libraries(qaptworker${QAPT_WORKER_VERSION} 50 | Qt5::Core 51 | Qt5::DBus 52 | PolkitQt5-1::Core 53 | util 54 | QApt::Main) 55 | 56 | install(TARGETS qaptworker${QAPT_WORKER_VERSION} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 57 | 58 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.service 59 | DESTINATION ${DBUS_SYSTEM_SERVICES_INSTALL_DIR}) 60 | 61 | if(KF5Auth_FOUND) 62 | kauth_install_actions(${QAPT_WORKER_RDN_VERSIONED} ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.actions) 63 | else() 64 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.policy 65 | DESTINATION ${CMAKE_INSTALL_PREFIX}/share/polkit-1/actions) 66 | endif() 67 | 68 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${QAPT_WORKER_RDN_VERSIONED}.conf 69 | DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/) 70 | -------------------------------------------------------------------------------- /src/worker/aptlock.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "aptlock.h" 22 | 23 | #include 24 | #include 25 | 26 | AptLock::AptLock(const QString &path) 27 | : m_path(path.toUtf8()) 28 | , m_fd(-1) 29 | { 30 | } 31 | 32 | bool AptLock::isLocked() const 33 | { 34 | return m_fd != -1; 35 | } 36 | 37 | bool AptLock::acquire() 38 | { 39 | if (isLocked()) 40 | return true; 41 | 42 | std::string str = m_path.data(); 43 | m_fd = GetLock(str + "lock"); 44 | m_lock.Fd(m_fd); 45 | 46 | return isLocked(); 47 | } 48 | 49 | void AptLock::release() 50 | { 51 | if (!isLocked()) 52 | return; 53 | 54 | m_lock.Close(); 55 | ::close(m_fd); 56 | m_fd = -1; 57 | } 58 | -------------------------------------------------------------------------------- /src/worker/aptlock.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef APTLOCK_H 22 | #define APTLOCK_H 23 | 24 | #include 25 | 26 | #include 27 | 28 | class AptLock 29 | { 30 | public: 31 | AptLock(const QString &path); 32 | 33 | bool isLocked() const; 34 | bool acquire(); 35 | void release(); 36 | 37 | private: 38 | QByteArray m_path; 39 | int m_fd; 40 | FileFd m_lock; 41 | }; 42 | 43 | #endif // APTLOCK_H 44 | -------------------------------------------------------------------------------- /src/worker/aptworker.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef APTWORKER_H 22 | #define APTWORKER_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class QProcess; 29 | 30 | class pkgCacheFile; 31 | class pkgRecords; 32 | 33 | class AptLock; 34 | class Transaction; 35 | 36 | class AptWorker : public QObject 37 | { 38 | Q_OBJECT 39 | public: 40 | explicit AptWorker(QObject *parent = 0); 41 | ~AptWorker(); 42 | 43 | Transaction *currentTransaction(); 44 | quint64 lastActiveTimestamp(); 45 | 46 | private: 47 | pkgCacheFile *m_cache; 48 | pkgRecords *m_records; 49 | QMutex m_transMutex; 50 | Transaction *m_trans; 51 | bool m_ready; 52 | QVector m_locks; 53 | QMutex m_timestampMutex; 54 | quint64 m_lastActiveTimestamp; 55 | QProcess *m_dpkgProcess; 56 | 57 | /** 58 | * If the locks on the package system cannot be immediately taken, this 59 | * function will wait until the package system is unlocked, and proceed 60 | * to lock it. 61 | */ 62 | void waitForLocks(); 63 | 64 | /** 65 | * Releases APT locks and sets the transaction as done. 66 | */ 67 | void cleanupCurrentTransaction(); 68 | 69 | /** 70 | * Builds the package cache and package records. 71 | */ 72 | void openCache(int begin = 0, int end = 5); 73 | 74 | /** 75 | * Checks for and downloads new package source lists. 76 | */ 77 | void updateCache(); 78 | 79 | /** 80 | * Marks changes as definied by the current transaction 81 | */ 82 | bool markChanges(); 83 | 84 | /** 85 | * Runs an APT commit 86 | */ 87 | void commitChanges(); 88 | 89 | /** 90 | * Upgrades packages 91 | */ 92 | void upgradeSystem(); 93 | 94 | /** 95 | * Installs a Debian package file by calling dpkg 96 | */ 97 | void installFile(); 98 | 99 | /** 100 | * Special function to download archives for DownloadArchivesRole transactions. 101 | */ 102 | void downloadArchives(); 103 | 104 | public slots: 105 | /** 106 | * Initializes the worker's package system. This is done lazily to allow 107 | * the object to first be put in to another thread. 108 | */ 109 | void init(); 110 | 111 | /** 112 | * This function will run the provided transaction in a blocking fashion 113 | * until the transaction is complete. As such, it is suggested that this 114 | * class be run in a thread separate from ones e.g. looking for D-Bus 115 | * messages. 116 | * 117 | * @param trans 118 | */ 119 | void runTransaction(Transaction *trans); 120 | 121 | /** 122 | * Stops the separate thread that AptWorker lives in. Call this before 123 | * exit to prevent the thread from whining that it was destroyed on shutdown. 124 | */ 125 | void quit(); 126 | 127 | private slots: 128 | void dpkgStarted(); 129 | void updateDpkgProgress(); 130 | void dpkgFinished(int exitCode, QProcess::ExitStatus exitStatus); 131 | }; 132 | 133 | #endif // APTWORKER_H 134 | -------------------------------------------------------------------------------- /src/worker/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "workerdaemon.h" 22 | 23 | int main(int argc, char **argv) 24 | { 25 | WorkerDaemon daemon(argc, argv); 26 | 27 | return daemon.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /src/worker/org.kubuntu.qaptworker.conf.cmake: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/worker/org.kubuntu.qaptworker.policy.cmake: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Kubuntu 7 | http://www.kubuntu.org 8 | 9 | 10 | Update software sources 11 | Update software sources 12 | 13 | no 14 | yes 15 | 16 | 17 | 18 | Install or remove packages 19 | Install or remove packages 20 | 21 | no 22 | auth_admin_keep 23 | 24 | 25 | 26 | Change system settings 27 | Change system settings 28 | 29 | no 30 | auth_admin_keep 31 | 32 | 33 | 34 | Cancel the task of another user 35 | To cancel someone else's software changes, you need to authenticate. 36 | 37 | auth_admin 38 | auth_admin 39 | auth_admin 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/worker/org.kubuntu.qaptworker.service.cmake: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=@QAPT_WORKER_RDN_VERSIONED@ 3 | Exec=/usr/bin/qaptworker@QAPT_WORKER_VERSION@ 4 | User=root 5 | 6 | -------------------------------------------------------------------------------- /src/worker/org.kubuntu.qaptworker.transaction.xml.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/worker/org.kubuntu.qaptworker.xml.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/worker/qaptauthorization.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2010 by Dario Freddi * 3 | * drf@chakra-project.org * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify * 6 | * it under the terms of the GNU General Public License as published by * 7 | * the Free Software Foundation; either version 2 of the License, or * 8 | * (at your option) any later version. * 9 | * * 10 | * This program is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 | * GNU General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program; if not, write to the * 17 | * Free Software Foundation, Inc., * 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPTAUTHORIZATION_H 22 | #define QAPTAUTHORIZATION_H 23 | 24 | #include 25 | #include 26 | 27 | namespace QApt { 28 | namespace Auth { 29 | 30 | inline bool authorize(const QString &action, const QString &service) 31 | { 32 | PolkitQt1::SystemBusNameSubject subject(service); 33 | 34 | PolkitQt1::Authority::Result result = PolkitQt1::Authority::instance()->checkAuthorizationSync(action, subject, 35 | PolkitQt1::Authority::AllowUserInteraction); 36 | 37 | return (result == PolkitQt1::Authority::Yes); 38 | } 39 | 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/worker/transactionqueue.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2012 Jonathan Thomas * 3 | * Copyright © 2008-2009 Sebastian Heinlein * 4 | * * 5 | * This program is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU General Public License as * 7 | * published by the Free Software Foundation; either version 2 of * 8 | * the License or (at your option) version 3 or any later version * 9 | * accepted by the membership of KDE e.V. (or its successor approved * 10 | * by the membership of KDE e.V.), which shall act as a proxy * 11 | * defined in Section 14 of version 3 of the license. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program. If not, see . * 20 | ***************************************************************************/ 21 | 22 | #include "transactionqueue.h" 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // Own includes 29 | #include "aptworker.h" 30 | #include "transaction.h" 31 | 32 | TransactionQueue::TransactionQueue(QObject *parent, AptWorker *worker) 33 | : QObject(parent) 34 | , m_worker(worker) 35 | , m_activeTransaction(nullptr) 36 | { 37 | } 38 | 39 | QList TransactionQueue::transactions() const 40 | { 41 | return m_queue; 42 | } 43 | 44 | Transaction *TransactionQueue::activeTransaction() const 45 | { 46 | return m_activeTransaction; 47 | } 48 | 49 | bool TransactionQueue::isEmpty() const 50 | { 51 | return (m_queue.isEmpty() && m_pending.isEmpty()); 52 | } 53 | 54 | Transaction *TransactionQueue::pendingTransactionById(const QString &id) const 55 | { 56 | Transaction *transaction = nullptr; 57 | 58 | for (Transaction *trans : m_pending) { 59 | if (trans->transactionId() == id) { 60 | transaction = trans; 61 | break; 62 | } 63 | } 64 | 65 | return transaction; 66 | } 67 | 68 | Transaction *TransactionQueue::transactionById(const QString &id) const 69 | { 70 | Transaction *transaction = nullptr; 71 | 72 | for (Transaction *trans : m_queue) { 73 | if (trans->transactionId() == id) { 74 | transaction = trans; 75 | break; 76 | } 77 | } 78 | 79 | return transaction; 80 | } 81 | 82 | void TransactionQueue::addPending(Transaction *trans) 83 | { 84 | m_pending.append(trans); 85 | connect(trans, SIGNAL(idleTimeout(Transaction*)), 86 | this, SLOT(removePending(Transaction*))); 87 | } 88 | 89 | void TransactionQueue::removePending(Transaction *trans) 90 | { 91 | m_pending.removeAll(trans); 92 | 93 | trans->deleteLater(); 94 | } 95 | 96 | void TransactionQueue::enqueue(QString tid) 97 | { 98 | Transaction *trans = pendingTransactionById(tid); 99 | 100 | if (!trans) 101 | return; 102 | 103 | connect(trans, SIGNAL(finished(int)), this, SLOT(onTransactionFinished())); 104 | m_pending.removeAll(trans); 105 | m_queue.enqueue(trans); 106 | 107 | if (!m_worker->currentTransaction()) 108 | runNextTransaction(); 109 | else { 110 | trans->setStatus(QApt::WaitingStatus); 111 | } 112 | 113 | emitQueueChanged(); 114 | } 115 | 116 | void TransactionQueue::remove(QString tid) 117 | { 118 | Transaction *trans = transactionById(tid); 119 | 120 | if (!trans) 121 | return; 122 | 123 | m_queue.removeAll(trans); 124 | 125 | if (trans == m_activeTransaction) 126 | m_activeTransaction = nullptr; 127 | 128 | emitQueueChanged(); 129 | 130 | // Wait in case clients are a bit slow. 131 | QTimer::singleShot(5000, trans, SLOT(deleteLater())); 132 | } 133 | 134 | void TransactionQueue::onTransactionFinished() 135 | { 136 | Transaction *trans = qobject_cast(sender()); 137 | 138 | if (!trans) // Don't want no trouble... 139 | return; 140 | 141 | // TODO: Transaction chaining 142 | 143 | remove(trans->transactionId()); 144 | if (m_queue.count()) 145 | runNextTransaction(); 146 | emitQueueChanged(); 147 | } 148 | 149 | void TransactionQueue::runNextTransaction() 150 | { 151 | m_activeTransaction = m_queue.head(); 152 | 153 | QMetaObject::invokeMethod(m_worker, "runTransaction", Qt::QueuedConnection, 154 | Q_ARG(Transaction *, m_activeTransaction)); 155 | } 156 | 157 | void TransactionQueue::emitQueueChanged() 158 | { 159 | QString tid; 160 | QStringList queued; 161 | 162 | if (m_activeTransaction) 163 | tid = m_activeTransaction->transactionId(); 164 | 165 | for (Transaction *trans : m_queue) 166 | queued << trans->transactionId(); 167 | 168 | emit queueChanged(tid, queued); 169 | } 170 | -------------------------------------------------------------------------------- /src/worker/transactionqueue.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2012 Jonathan Thomas * 3 | * Copyright © 2008-2009 Sebastian Heinlein * 4 | * * 5 | * This program is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU General Public License as * 7 | * published by the Free Software Foundation; either version 2 of * 8 | * the License or (at your option) version 3 or any later version * 9 | * accepted by the membership of KDE e.V. (or its successor approved * 10 | * by the membership of KDE e.V.), which shall act as a proxy * 11 | * defined in Section 14 of version 3 of the license. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program. If not, see . * 20 | ***************************************************************************/ 21 | 22 | #ifndef TRANSACTIONQUEUE_H 23 | #define TRANSACTIONQUEUE_H 24 | 25 | #include 26 | #include 27 | 28 | class AptWorker; 29 | class Transaction; 30 | 31 | class TransactionQueue : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | TransactionQueue(QObject *parent, AptWorker *worker); 36 | 37 | QList transactions() const; 38 | Transaction *activeTransaction() const; 39 | bool isEmpty() const; 40 | 41 | private: 42 | AptWorker *m_worker; 43 | QQueue m_queue; 44 | QList m_pending; 45 | Transaction *m_activeTransaction; 46 | 47 | Transaction *pendingTransactionById(const QString &id) const; 48 | Transaction *transactionById(const QString &id) const; 49 | 50 | signals: 51 | void queueChanged(const QString &active, 52 | const QStringList &queued); 53 | 54 | public slots: 55 | void addPending(Transaction *trans); 56 | void removePending(Transaction *trans); 57 | void enqueue(QString tid); 58 | void remove(QString tid); 59 | 60 | private slots: 61 | void onTransactionFinished(); 62 | void runNextTransaction(); 63 | void emitQueueChanged(); 64 | }; 65 | 66 | #endif // TRANSACTIONQUEUE_H 67 | -------------------------------------------------------------------------------- /src/worker/urihelper.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef QAPT_URIHELPER_P_H 2 | #define QAPT_URIHELPER_P_H 3 | 4 | #include 5 | 6 | // Unlike other approaches this one will always explode when a define does not 7 | // actually make it into the compiler (e.g. because the CMake var was renamed). 8 | // e.g. QString() would compile fine if the define is missing, 9 | // char[]=; on the other hand won't. 10 | static const char s_workerVersion[] = @QAPT_WORKER_VERSION_STRING@; 11 | static const char s_workerReverseDomainName[] = @QAPT_WORKER_RDN_VERSIONED_STRING@; 12 | 13 | static QString dbusActionUri(const char *actionId) 14 | { 15 | return QString("%1.%2").arg(QLatin1String(s_workerReverseDomainName), 16 | QLatin1String(actionId)); 17 | } 18 | 19 | #endif // QAPT_URIHELPER_P_H 20 | -------------------------------------------------------------------------------- /src/worker/workeracquire.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef WORKERACQUIRE_H 22 | #define WORKERACQUIRE_H 23 | 24 | // Qt includes 25 | #include 26 | 27 | // Apt-pkg includes 28 | #include 29 | 30 | class Transaction; 31 | 32 | class WorkerAcquire : public QObject, public pkgAcquireStatus 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit WorkerAcquire(QObject *parent, int begin = 0, int end = 100); 37 | 38 | void Start(); 39 | void IMSHit(pkgAcquire::ItemDesc &Itm); 40 | void Fetch(pkgAcquire::ItemDesc &Itm); 41 | void Done(pkgAcquire::ItemDesc &Itm); 42 | void Fail(pkgAcquire::ItemDesc &Itm); 43 | void Stop(); 44 | bool MediaChange(std::string Media, std::string Drive); 45 | 46 | bool Pulse(pkgAcquire *Owner); 47 | 48 | void setTransaction(Transaction *trans); 49 | 50 | private: 51 | Transaction *m_trans; 52 | bool m_calculatingSpeed; 53 | int m_progressBegin; 54 | int m_progressEnd; 55 | int m_lastProgress; 56 | 57 | private Q_SLOTS: 58 | void updateStatus(const pkgAcquire::ItemDesc &Itm); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/worker/workerdaemon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef WORKERDAEMON_H 22 | #define WORKERDAEMON_H 23 | 24 | #include 25 | #include 26 | 27 | #include "globals.h" 28 | 29 | class QThread; 30 | class QTimer; 31 | 32 | class AptWorker; 33 | class Transaction; 34 | class TransactionQueue; 35 | 36 | class WorkerDaemon : public QCoreApplication, protected QDBusContext 37 | { 38 | Q_OBJECT 39 | 40 | Q_CLASSINFO("D-Bus Interface", "org.kubuntu.qaptworker") 41 | public: 42 | WorkerDaemon(int &argc, char **argv); 43 | 44 | private: 45 | TransactionQueue *m_queue; 46 | AptWorker *m_worker; 47 | QThread *m_workerThread; 48 | QTimer *m_idleTimer; 49 | 50 | int dbusSenderUid() const; 51 | Transaction *createTransaction(QApt::TransactionRole role, 52 | QVariantMap instructionsList = QVariantMap()); 53 | 54 | signals: 55 | Q_SCRIPTABLE void transactionQueueChanged(const QString &active, 56 | const QStringList &queued); 57 | 58 | public slots: 59 | // Transaction-based methods. Return transaction ids. 60 | QString updateCache(); 61 | QString installFile(const QString &file); 62 | QString commitChanges(QVariantMap instructionsList); 63 | QString upgradeSystem(bool safeUpgrade); 64 | QString downloadArchives(const QStringList &packageNames, const QString &dest); 65 | 66 | // Synchronous methods 67 | bool writeFileToDisk(const QString &contents, const QString &path); 68 | bool copyArchiveToCache(const QString &archivePath); 69 | 70 | private slots: 71 | void checkIdle(); 72 | }; 73 | 74 | #endif // WORKERDAEMON_H 75 | -------------------------------------------------------------------------------- /src/worker/workerinstallprogress.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * Copyright © 2004 Canonical * 4 | * * 5 | * This program is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU General Public License as * 7 | * published by the Free Software Foundation; either version 2 of * 8 | * the License or (at your option) version 3 or any later version * 9 | * accepted by the membership of KDE e.V. (or its successor approved * 10 | * by the membership of KDE e.V.), which shall act as a proxy * 11 | * defined in Section 14 of version 3 of the license. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program. If not, see . * 20 | ***************************************************************************/ 21 | 22 | #ifndef WORKERINSTALLPROGRESS_H 23 | #define WORKERINSTALLPROGRESS_H 24 | 25 | #include 26 | 27 | class Transaction; 28 | 29 | class WorkerInstallProgress 30 | { 31 | public: 32 | explicit WorkerInstallProgress(int begin = 0, int end = 100); 33 | 34 | void setTransaction(Transaction *trans); 35 | pkgPackageManager::OrderResult start(pkgPackageManager *pm); 36 | 37 | private: 38 | Transaction *m_trans; 39 | 40 | pid_t m_child_id; 41 | bool m_startCounting; 42 | int m_progressBegin; 43 | int m_progressEnd; 44 | 45 | void updateInterface(int fd, int writeFd); 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(qapt-batch) 2 | add_subdirectory(qapt-deb-installer) 3 | add_subdirectory(qapt-deb-thumbnailer) 4 | add_subdirectory(plasma-runner-installer) 5 | 6 | if(WITH_GSTREAMER) 7 | add_definitions(-fexceptions) 8 | add_definitions(-DGST_DISABLE_DEPRECATED) 9 | add_subdirectory(qapt-gst-helper) 10 | endif() 11 | -------------------------------------------------------------------------------- /utils/plasma-runner-installer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # KI18N Translation Domain for this library 2 | add_definitions(-DTRANSLATION_DOMAIN=\"plasma-runner-installer\") 3 | 4 | add_library(krunner_installer MODULE installerrunner.cpp) 5 | 6 | target_link_libraries(krunner_installer 7 | KF5::I18n 8 | KF5::Runner) 9 | 10 | install(TARGETS krunner_installer DESTINATION ${PLUGIN_INSTALL_DIR} ) 11 | install(FILES plasma-runner-installer.desktop DESTINATION ${SERVICES_INSTALL_DIR}) 12 | -------------------------------------------------------------------------------- /utils/plasma-runner-installer/installerrunner.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "installerrunner.h" 22 | 23 | // Qt includes 24 | #include 25 | #include 26 | 27 | // KDE includes 28 | #include 29 | #include 30 | #include 31 | 32 | K_EXPORT_PLASMA_RUNNER(installer, InstallerRunner) 33 | 34 | InstallerRunner::InstallerRunner(QObject *parent, const QVariantList &args) 35 | : Plasma::AbstractRunner(parent, args) 36 | { 37 | Q_UNUSED(args) 38 | 39 | setObjectName("Installation Suggestions"); 40 | setPriority(AbstractRunner::HighestPriority); 41 | 42 | addSyntax(Plasma::RunnerSyntax(":q:", i18n("Suggests the installation of applications if :q: is not found"))); 43 | } 44 | 45 | InstallerRunner::~InstallerRunner() 46 | { 47 | } 48 | 49 | void InstallerRunner::match(Plasma::RunnerContext &context) 50 | { 51 | const QString term = context.query(); 52 | if (term.length() < 3) { 53 | return; 54 | } 55 | 56 | // Search for applications which are executable and case-insensitively match the search term 57 | // See http://techbase.kde.org/Development/Tutorials/Services/Traders#The_KTrader_Query_Language 58 | // if the following is unclear to you. 59 | QString query = QString("exist Exec and ('%1' =~ Name)").arg(term); 60 | KService::List services = KServiceTypeTrader::self()->query("Application", query); 61 | 62 | QList matches; 63 | 64 | if (services.isEmpty()) { 65 | KProcess process; 66 | if (QFile::exists("/usr/lib/command-not-found")) { 67 | process << "/usr/lib/command-not-found" << term; 68 | } else if (QFile::exists("/usr/bin/command-not-found")) { 69 | process << "/usr/bin/command-not-found" << term; 70 | } else { 71 | process << "/bin/ls" << term; // Play it safe even if it won't work at all 72 | } 73 | process.setTextModeEnabled(true); 74 | process.setOutputChannelMode(KProcess::OnlyStderrChannel); 75 | process.start(); 76 | process.waitForFinished(); 77 | 78 | QString output = QString(process.readAllStandardError()); 79 | QStringList resultLines = output.split('\n'); 80 | foreach(const QString &line, resultLines) { 81 | if (line.startsWith(QLatin1String("sudo"))) { 82 | QString package = line.split(' ').last(); 83 | Plasma::QueryMatch match(this); 84 | match.setType(Plasma::QueryMatch::ExactMatch); 85 | setupMatch(package, term, match); 86 | match.setRelevance(1); 87 | matches << match; 88 | } 89 | } 90 | } 91 | 92 | if (!context.isValid()) { 93 | return; 94 | } 95 | 96 | 97 | context.addMatches(matches); 98 | } 99 | 100 | void InstallerRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) 101 | { 102 | Q_UNUSED(context); 103 | QString package = match.data().toString(); 104 | if (!package.isEmpty()) { 105 | KProcess *process = new KProcess(this); 106 | QStringList args = QStringList() << "--install" << package; 107 | process->setProgram("/usr/bin/qapt-batch", args); 108 | process->start(); 109 | } 110 | } 111 | 112 | void InstallerRunner::setupMatch(const QString &package, const QString &term, Plasma::QueryMatch &match) 113 | { 114 | match.setText(i18n("Install %1", package)); 115 | match.setData(package); 116 | if (term != package) { 117 | match.setSubtext(i18n("The \"%1\" package contains %2", package, term)); 118 | } 119 | 120 | match.setIcon(QIcon::fromTheme("applications-other")); 121 | } 122 | 123 | #include "installerrunner.moc" 124 | -------------------------------------------------------------------------------- /utils/plasma-runner-installer/installerrunner.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef INSTALLERRUNNER_H 22 | #define INSTALLERRUNNER_H 23 | 24 | #include 25 | 26 | /** 27 | * This runner checks if the query exists as an executable in the normal paths 28 | * and suggests the installation of the package that would normally contain 29 | * the executable if not found. 30 | */ 31 | class InstallerRunner : public Plasma::AbstractRunner 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | InstallerRunner(QObject *parent, const QVariantList &args); 37 | ~InstallerRunner(); 38 | 39 | void match(Plasma::RunnerContext &context); 40 | void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action); 41 | 42 | protected: 43 | void setupMatch(const QString &package, const QString &term, Plasma::QueryMatch &action); 44 | }; 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /utils/plasma-runner-installer/plasma-runner-installer.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Installer 3 | Name[ar]=المثبّت 4 | Name[ast]=Instalador 5 | Name[bs]=Instaler 6 | Name[ca]=Instal·lador 7 | Name[ca@valencia]=Instal·lador 8 | Name[cs]=Instalátor 9 | Name[da]=Installationsprogram 10 | Name[de]=Installationsprogramm 11 | Name[el]=Installer 12 | Name[en_GB]=Installer 13 | Name[es]=Instalador 14 | Name[et]=Paigaldaja 15 | Name[fi]=Asennusohjelma 16 | Name[fr]=Programme d'installation 17 | Name[ga]=Suiteálaí 18 | Name[gl]=Instalador 19 | Name[hu]=Telepítő 20 | Name[id]=Pemasang 21 | Name[it]=Installatore 22 | Name[kk]=Орнатқыш 23 | Name[ko]=설치기 24 | Name[lt]=Diegimo programa 25 | Name[mr]=प्रतिष्ठापक 26 | Name[nb]=Installerer 27 | Name[nds]=Installeerprogramm 28 | Name[nl]=Installatieprogramma 29 | Name[pa]=ਇੰਸਟਾਲਰ 30 | Name[pl]=Instalator 31 | Name[pt]=Instalador 32 | Name[pt_BR]=Instalador 33 | Name[ro]=Instalator 34 | Name[ru]=Установка приложений 35 | Name[sk]=Inštalátor 36 | Name[sl]=Namestilnik 37 | Name[sr]=Инсталатер 38 | Name[sr@ijekavian]=Инсталатер 39 | Name[sr@ijekavianlatin]=Instalater 40 | Name[sr@latin]=Instalater 41 | Name[sv]=Installation 42 | Name[tr]=Kur 43 | Name[ug]=ئورناتقۇچ 44 | Name[uk]=Встановлювач 45 | Name[x-test]=xxInstallerxx 46 | Name[zh_CN]=安装器 47 | Name[zh_TW]=安裝程式 48 | Comment=Suggests the installation of not-installed applications 49 | Comment[ar]=يقترح تثبيت تطبيقات غير مثبّتة 50 | Comment[ast]=Suxer la instalación d'aplicaciones non instalaes 51 | Comment[bs]=Predlaže instalaciju neinstaliranih paketa 52 | Comment[ca]=Suggereix la instal·lació d'aplicacions no instal·lades 53 | Comment[ca@valencia]=Suggerix la instal·lació d'aplicacions no instal·lades 54 | Comment[cs]=Navrhuje instalaci nenainstalovaných aplikací 55 | Comment[da]=Foreslår installation af ikke-installerede programmer 56 | Comment[de]=Schlägt die Installation von Anwendungen vor, die nicht installiert sind 57 | Comment[el]=Προτείνει την εγκατάσταση μη-εγκατεστημένων εφαρμογών 58 | Comment[en_GB]=Suggests the installation of not-installed applications 59 | Comment[es]=Sugiere la instalación de aplicaciones no instaladas 60 | Comment[et]=Paigaldamata rakenduse paigaldamise pakkumine 61 | Comment[fi]=Ehdottaa uusien sovellusten asentamista 62 | Comment[fr]=Suggère l'installation d'applications non installées 63 | Comment[gl]=Suxire a instalación de aplicacións non instaladas 64 | Comment[hu]=Nem telepített alkalmazások telepítésének ajánlása 65 | Comment[id]=Menyarankan penginstalan aplikasi yang tidak terinstal 66 | Comment[it]=Suggerisce l'installazione di applicazioni non installate 67 | Comment[kk]=Орнатылмаған қолданбаларды орнатуды ұсынады 68 | Comment[ko]=설치되지 않은 프로그램의 설치 제안 69 | Comment[lt]=Pasiūlo neįdiegtų programų įdiegimą 70 | Comment[mr]=प्रतिष्ठापीत नसलेल्या अनुप्रयोगांची प्रतिष्ठापना सुचवितो 71 | Comment[nb]=Foreslår installering av ikke installerte programmer 72 | Comment[nds]=Raadt dat Installeren vun nich installeert Programmen an 73 | Comment[nl]=Suggereert de installatie van niet geïnstalleerde programma's 74 | Comment[pl]=Sugeruje instalację niezainstalowanych programów 75 | Comment[pt]=Sugere a instalação de aplicações não instaladas 76 | Comment[pt_BR]=Sugere a instalação de aplicativos não instalados 77 | Comment[ro]=Sugerează instalarea unor aplicații neinstalate 78 | Comment[ru]=Предлагает установить приложения 79 | Comment[sk]=Doporučí inštaláciu nenainštalovaných aplikácií 80 | Comment[sl]=Predlaga namestitev še ne nameščenih paketov 81 | Comment[sr]=Предлаже инсталирање неинсталираних програма 82 | Comment[sr@ijekavian]=Предлаже инсталирање неинсталираних програма 83 | Comment[sr@ijekavianlatin]=Predlaže instaliranje neinstaliranih programa 84 | Comment[sr@latin]=Predlaže instaliranje neinstaliranih programa 85 | Comment[sv]=Föreslå installation av program som inte är installerade 86 | Comment[tr]=Kurulu olmayan uygulamaları kurmanızı önerir 87 | Comment[ug]=ئورنىتىلمىغان قوللىنىشچان پروگراممىلارنى ئورنىتىشنى تەۋسىيە قىلىدۇ 88 | Comment[uk]=Пропонує встановити програми, потрібні для виконання певних завдань 89 | Comment[x-test]=xxSuggests the installation of not-installed applicationsxx 90 | Comment[zh_CN]=未安装应用程序的安装建议 91 | Comment[zh_TW]=建議安裝應用程式 92 | X-KDE-ServiceTypes=Plasma/Runner 93 | Type=Service 94 | Icon=applications-other 95 | X-KDE-Library=krunner_installer 96 | X-Plasma-RunnerPhase=first 97 | X-KDE-PluginInfo-Author=Jonathan Thomas 98 | X-KDE-PluginInfo-Email=echidnaman@kubuntu.org 99 | X-KDE-PluginInfo-Name=installer 100 | X-KDE-PluginInfo-Version=1.0 101 | X-KDE-PluginInfo-License=LGPL 102 | X-KDE-PluginInfo-EnabledByDefault=true 103 | -------------------------------------------------------------------------------- /utils/qapt-batch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(qaptbatch_SRCS 2 | main.cpp 3 | qaptbatch.cpp 4 | detailswidget.cpp 5 | ) 6 | 7 | add_executable(qapt-batch ${qaptbatch_SRCS}) 8 | 9 | target_link_libraries(qapt-batch 10 | KF5::CoreAddons 11 | KF5::I18n 12 | KF5::KIOCore 13 | KF5::WidgetsAddons 14 | KF5::WindowSystem 15 | QApt::Main) 16 | 17 | install(TARGETS qapt-batch ${INSTALL_TARGETS_DEFAULT_ARGS}) 18 | -------------------------------------------------------------------------------- /utils/qapt-batch/detailswidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "detailswidget.h" 22 | 23 | // Qt includes 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // KDE includes 30 | #include 31 | #include 32 | #include 33 | 34 | // LibQApt includes 35 | #include 36 | 37 | DetailsWidget::DetailsWidget(QWidget *parent) 38 | : QWidget(parent) 39 | , m_trans(nullptr) 40 | { 41 | QGridLayout *layout = new QGridLayout(this); 42 | 43 | QVBoxLayout *columnOne = new QVBoxLayout; 44 | QVBoxLayout *columnTwo = new QVBoxLayout; 45 | 46 | layout->addLayout(columnOne, 0, 0); 47 | layout->addLayout(columnTwo, 0, 1); 48 | setLayout(layout); 49 | 50 | QLabel *label1 = new QLabel(this); 51 | label1->setText(i18nc("@label Remaining time", "Remaining Time:")); 52 | label1->setAlignment(Qt::AlignRight); 53 | columnOne->addWidget(label1); 54 | 55 | QLabel *label2 = new QLabel(this); 56 | label2->setText(i18nc("@label Download Rate", "Speed:")); 57 | label2->setAlignment(Qt::AlignRight); 58 | columnOne->addWidget(label2); 59 | 60 | m_timeLabel = new QLabel(this); 61 | columnTwo->addWidget(m_timeLabel); 62 | m_speedLabel = new QLabel(this); 63 | columnTwo->addWidget(m_speedLabel); 64 | } 65 | 66 | void DetailsWidget::setTransaction(QApt::Transaction *trans) 67 | { 68 | m_trans = trans; 69 | 70 | connect(m_trans, SIGNAL(statusChanged(QApt::TransactionStatus)), 71 | this, SLOT(transactionStatusChanged(QApt::TransactionStatus))); 72 | connect(m_trans, SIGNAL(downloadETAChanged(quint64)), 73 | this, SLOT(updateTimeText(quint64))); 74 | connect(m_trans, SIGNAL(downloadSpeedChanged(quint64)), 75 | this, SLOT(updateSpeedText(quint64))); 76 | } 77 | 78 | void DetailsWidget::transactionStatusChanged(QApt::TransactionStatus status) 79 | { 80 | // Limit visibility of details to when details exist 81 | switch (status) { 82 | case QApt::DownloadingStatus: 83 | show(); 84 | break; 85 | case QApt::CommittingStatus: 86 | case QApt::FinishedStatus: 87 | hide(); 88 | if (parentWidget()) { 89 | // Update size to prevent the dialog from looking silly. 90 | parentWidget()->adjustSize(); 91 | } 92 | break; 93 | default: 94 | break; 95 | } 96 | } 97 | 98 | void DetailsWidget::updateTimeText(quint64 eta) 99 | { 100 | QString timeRemaining; 101 | quint64 ETAMilliseconds = eta * 1000; 102 | 103 | // Greater than zero and less than 2 days 104 | if (ETAMilliseconds > 0 && ETAMilliseconds < 2*24*60*60) { 105 | timeRemaining = KFormat().formatDuration(ETAMilliseconds); 106 | } else { 107 | timeRemaining = i18nc("@info:progress Remaining time", "Unknown"); 108 | } 109 | 110 | m_timeLabel->setText(timeRemaining); 111 | } 112 | 113 | void DetailsWidget::updateSpeedText(quint64 speed) 114 | { 115 | QString downloadSpeed = i18nc("@info:progress Download rate", 116 | "%1/s", KFormat().formatByteSize(speed)); 117 | m_speedLabel->setText(downloadSpeed); 118 | } 119 | -------------------------------------------------------------------------------- /utils/qapt-batch/detailswidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DETAILSWIDGET_H 22 | #define DETAILSWIDGET_H 23 | 24 | #include 25 | 26 | #include 27 | 28 | class QLabel; 29 | 30 | namespace QApt { 31 | class Transaction; 32 | } 33 | 34 | class DetailsWidget : public QWidget 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit DetailsWidget(QWidget *parent); 39 | 40 | void setTransaction(QApt::Transaction *trans); 41 | 42 | private: 43 | QApt::Transaction *m_trans; 44 | 45 | QLabel *m_timeLabel; 46 | QLabel *m_speedLabel; 47 | QLabel *m_speedDescriptor; 48 | 49 | private slots: 50 | void updateTimeText(quint64 eta); 51 | void updateSpeedText(quint64 speed); 52 | void transactionStatusChanged(QApt::TransactionStatus status); 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /utils/qapt-batch/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "qaptbatch.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | static const char description[] = 33 | I18N_NOOP2("@info", "A batch installer using QApt"); 34 | 35 | static const char version[] = CMAKE_PROJECT_VERSION; 36 | 37 | int main(int argc, char **argv) 38 | { 39 | QApplication app(argc, argv); 40 | app.setWindowIcon(QIcon::fromTheme("applications-other")); 41 | 42 | KLocalizedString::setApplicationDomain("qapt-batch"); 43 | 44 | KAboutData aboutData("qaptbatch", 45 | i18nc("@title", "QApt Batch Installer"), 46 | version, 47 | i18nc("@info", description), 48 | KAboutLicense::LicenseKey::GPL, 49 | i18nc("@info:credit", "(C) 2010 Jonathan Thomas")); 50 | 51 | aboutData.addAuthor(i18nc("@info:credit", "Jonathan Thomas"), 52 | QString(), 53 | QStringLiteral("echidnaman@kubuntu.org")); 54 | aboutData.addAuthor(i18nc("@info:credit", "Harald Sitter"), 55 | i18nc("@info:credit", "Qt 5 port"), 56 | QStringLiteral("apachelogger@kubuntu.org")); 57 | KAboutData::setApplicationData(aboutData); 58 | 59 | QCommandLineParser parser; 60 | parser.addHelpOption(); 61 | parser.addVersionOption(); 62 | QCommandLineOption attachOption(QStringLiteral("attach"), 63 | i18nc("@info:shell", "Attaches the window to an X app specified by winid"), 64 | i18nc("@info:shell value name", "winid"), 65 | QStringLiteral("0")); 66 | parser.addOption(attachOption); 67 | QCommandLineOption installOption(QStringLiteral("install"), 68 | i18nc("@info:shell", "Install a package")); 69 | parser.addOption(installOption); 70 | QCommandLineOption uninstallOption(QStringLiteral("uninstall"), 71 | i18nc("@info:shell", "Remove a package")); 72 | parser.addOption(uninstallOption); 73 | QCommandLineOption updateOption(QStringLiteral("update"), 74 | i18nc("@info:shell", "Update the package cache")); 75 | parser.addOption(updateOption); 76 | parser.addPositionalArgument("packages", 77 | i18nc("@info:shell", "Packages to be operated upon")); 78 | aboutData.setupCommandLine(&parser); 79 | parser.process(app); 80 | aboutData.processCommandLine(&parser); 81 | 82 | QString mode; 83 | 84 | int winId = parser.value(attachOption).toInt(); 85 | 86 | if (!(parser.isSet(installOption) ^ parser.isSet(uninstallOption) ^ parser.isSet(updateOption))) { 87 | qCritical() << i18nc("@info:shell error", "Only one operation mode may be defined."); 88 | return 1; 89 | } 90 | 91 | if (parser.isSet(installOption)) { 92 | mode = QStringLiteral("install"); 93 | } else if (parser.isSet(uninstallOption)) { 94 | mode = QStringLiteral("uninstall"); 95 | } else if (parser.isSet(updateOption)) { 96 | mode = QStringLiteral("update"); 97 | } else { 98 | qCritical() << i18nc("@info:shell error", "No operation mode defined."); 99 | return 1; 100 | } 101 | 102 | QStringList packages = parser.positionalArguments(); 103 | 104 | Q_UNUSED(app); 105 | QPointer batchInstaller = new QAptBatch(mode, packages, winId); 106 | switch (batchInstaller->exec()) { 107 | case QDialog::Accepted: 108 | return 0; 109 | break; 110 | case QDialog::Rejected: 111 | default: 112 | return 1; 113 | } 114 | app.exec(); 115 | } 116 | -------------------------------------------------------------------------------- /utils/qapt-batch/qaptbatch.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef QAPTBATCH_H 22 | #define QAPTBATCH_H 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // LibQApt includes 29 | #include 30 | 31 | class DetailsWidget; 32 | class QLabel; 33 | class QProgressBar; 34 | 35 | namespace QApt { 36 | class Backend; 37 | class Transaction; 38 | } 39 | 40 | class QAptBatch : public QDialog 41 | { 42 | Q_OBJECT 43 | public: 44 | explicit QAptBatch(QString mode, QStringList packages, int winId); 45 | 46 | void reject() Q_DECL_OVERRIDE Q_DECL_FINAL; 47 | 48 | private Q_SLOTS: 49 | void initError(); 50 | void commitChanges(int mode, const QStringList &packageStrs); 51 | void errorOccurred(QApt::ErrorCode code); 52 | void provideMedium(const QString &label, const QString &mountPoint); 53 | void untrustedPrompt(const QStringList &untrustedPackages); 54 | void raiseErrorMessage(const QString &text, const QString &title); 55 | void transactionStatusChanged(QApt::TransactionStatus status); 56 | void cancellableChanged(bool cancellable); 57 | 58 | void updateProgress(int progress); 59 | void updateCommitMessage(const QString& message); 60 | 61 | private: 62 | void setTransaction(QApt::Transaction *trans); 63 | void setVisibleButtons(QDialogButtonBox::StandardButtons buttons); 64 | 65 | QApt::Backend *m_backend; 66 | QApt::Transaction *m_trans; 67 | 68 | int m_winId; 69 | int m_lastRealProgress; 70 | QString m_mode; 71 | QStringList m_packages; 72 | bool m_done; 73 | 74 | // ui 75 | QLabel *m_label; 76 | QProgressBar *m_progressBar; 77 | DetailsWidget *m_detailsWidget; 78 | QDialogButtonBox *m_buttonBox; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(qapt-deb-installer_SRCS 2 | main.cpp 3 | DebCommitWidget.cpp 4 | DebInstaller.cpp 5 | DebViewer.cpp 6 | ChangesDialog.cpp) 7 | 8 | add_executable(qapt-deb-installer ${qapt-deb-installer_SRCS}) 9 | 10 | target_link_libraries(qapt-deb-installer 11 | KF5::CoreAddons 12 | KF5::I18n 13 | KF5::KIOCore 14 | KF5::TextWidgets 15 | KF5::WidgetsAddons 16 | DebconfKDE::Main 17 | QApt::Main) 18 | 19 | install(TARGETS qapt-deb-installer ${INSTALL_TARGETS_DEFAULT_ARGS}) 20 | install(PROGRAMS qapt-deb-installer.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) 21 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/ChangesDialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "ChangesDialog.h" 22 | 23 | // Qt includes 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | // KDE includes 31 | #include 32 | #include 33 | 34 | ChangesDialog::ChangesDialog(QWidget *parent, const QApt::StateChanges &changes) 35 | : QDialog(parent) 36 | { 37 | setWindowTitle(i18nc("@title:window", "Confirm Additional Changes")); 38 | QVBoxLayout *layout = new QVBoxLayout(this); 39 | setLayout(layout); 40 | 41 | QLabel *headerLabel = new QLabel(this); 42 | headerLabel->setText(i18nc("@info", "

Additional Changes

")); 43 | 44 | int count = countChanges(changes); 45 | QLabel *label = new QLabel(this); 46 | label->setText(i18np("This action requires a change to another package:", 47 | "This action requires changes to other packages:", 48 | count)); 49 | 50 | QTreeView *packageView = new QTreeView(this); 51 | packageView->setHeaderHidden(true); 52 | packageView->setRootIsDecorated(false); 53 | 54 | QWidget *bottomBox = new QWidget(this); 55 | QHBoxLayout *bottomLayout = new QHBoxLayout(bottomBox); 56 | bottomLayout->setSpacing(0); 57 | bottomLayout->setMargin(0); 58 | bottomBox->setLayout(bottomLayout); 59 | 60 | QWidget *bottomSpacer = new QWidget(bottomBox); 61 | bottomSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); 62 | 63 | QPushButton *okButton = new QPushButton(bottomBox); 64 | KGuiItem okItem = KStandardGuiItem::ok(); 65 | okButton->setText(okItem.text()); 66 | okButton->setIcon(okItem.icon()); 67 | connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); 68 | 69 | bottomLayout->addWidget(bottomSpacer); 70 | bottomLayout->addWidget(okButton); 71 | 72 | m_model = new QStandardItemModel(this); 73 | packageView->setModel(m_model); 74 | addPackages(changes); 75 | packageView->expandAll(); 76 | 77 | layout->addWidget(headerLabel); 78 | layout->addWidget(label); 79 | layout->addWidget(packageView); 80 | layout->addWidget(bottomBox); 81 | } 82 | 83 | void ChangesDialog::addPackages(const QApt::StateChanges &changes) 84 | { 85 | QHash hash; 86 | hash[QApt::Package::ToInstall] = i18nc("@info:status Requested action", "Install"); 87 | hash[QApt::Package::NewInstall] = i18nc("@info:status Requested action", "Install"); 88 | hash[QApt::Package::ToRemove] = i18nc("@info:status Requested action", "Remove"); 89 | 90 | for (auto i = changes.constBegin(); i != changes.constEnd(); ++i) { 91 | QStandardItem *root = new QStandardItem; 92 | root->setText(hash.value(i.key())); 93 | root->setEditable(false); 94 | 95 | QFont font = root->font(); 96 | font.setBold(true); 97 | root->setFont(font); 98 | 99 | const QApt::PackageList packages = i.value(); 100 | 101 | QStandardItem *item = 0; 102 | for (QApt::Package *package : packages) { 103 | item = new QStandardItem; 104 | item->setText(package->name()); 105 | item->setEditable(false); 106 | item->setIcon(QIcon::fromTheme("muon")); 107 | 108 | root->appendRow(item); 109 | } 110 | 111 | m_model->appendRow(root); 112 | } 113 | } 114 | 115 | int ChangesDialog::countChanges(const QApt::StateChanges &changes) 116 | { 117 | int count = 0; 118 | auto iter = changes.constBegin(); 119 | 120 | while (iter != changes.constEnd()) { 121 | const QApt::PackageList packages = iter.value(); 122 | count += packages.size(); 123 | 124 | ++iter; 125 | } 126 | 127 | return count; 128 | } 129 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/ChangesDialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef CHANGESDIALOG_H 22 | #define CHANGESDIALOG_H 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // LibQApt includes 29 | #include 30 | 31 | class QStandardItemModel; 32 | 33 | class ChangesDialog : public QDialog 34 | { 35 | public: 36 | ChangesDialog(QWidget *parent, const QApt::StateChanges &changes); 37 | 38 | private: 39 | QStandardItemModel *m_model; 40 | 41 | void addPackages(const QApt::StateChanges &changes); 42 | int countChanges(const QApt::StateChanges &changes); 43 | }; 44 | 45 | #endif // CHANGESDIALOG_H 46 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/DebCommitWidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DEBCOMMITWIDGET_H 22 | #define DEBCOMMITWIDGET_H 23 | 24 | #include 25 | 26 | #include 27 | 28 | class QLabel; 29 | class QProgressBar; 30 | class KTextEdit; 31 | 32 | namespace DebconfKde { 33 | class DebconfGui; 34 | } 35 | 36 | namespace QApt { 37 | class Transaction; 38 | } 39 | 40 | class DebCommitWidget : public QWidget 41 | { 42 | Q_OBJECT 43 | public: 44 | explicit DebCommitWidget(QWidget *parent = 0); 45 | 46 | QString pipe() const; 47 | void setTransaction(QApt::Transaction *trans); 48 | 49 | private: 50 | QApt::Transaction *m_trans; 51 | QString m_pipe; 52 | QLabel *m_headerLabel; 53 | KTextEdit *m_terminal; 54 | DebconfKde::DebconfGui *m_debconfGui; 55 | QProgressBar *m_progressBar; 56 | 57 | private Q_SLOTS: 58 | void statusChanged(QApt::TransactionStatus status); 59 | void errorOccurred(QApt::ErrorCode error); 60 | void updateProgress(int progress); 61 | void updateTerminal(const QString &message); 62 | void showProgress(); 63 | void hideProgress(); 64 | void showDebconf(); 65 | void hideDebconf(); 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/DebInstaller.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DEBINSTALLER_H 22 | #define DEBINSTALLER_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | class QDialogButtonBox; 31 | class QStackedWidget; 32 | 33 | namespace QApt { 34 | class Backend; 35 | class Transaction; 36 | } 37 | 38 | class DebCommitWidget; 39 | class DebViewer; 40 | 41 | class DebInstaller : public QDialog 42 | { 43 | Q_OBJECT 44 | public: 45 | explicit DebInstaller(QWidget *parent, const QString &debFile); 46 | 47 | private: 48 | // Backend stuff 49 | QApt::Backend *m_backend; 50 | QApt::DebFile *m_debFile; 51 | QApt::Transaction *m_trans; 52 | QString m_foreignArch; 53 | 54 | // GUI 55 | QStackedWidget *m_stack; 56 | DebViewer *m_debViewer; 57 | DebCommitWidget *m_commitWidget; 58 | QPushButton *m_applyButton; 59 | QPushButton *m_cancelButton; 60 | QDialogButtonBox *m_buttonBox; 61 | 62 | //Misc 63 | QString m_statusString; 64 | bool m_canInstall; 65 | QString m_versionTitle; 66 | QString m_versionInfo; 67 | 68 | // Functions 69 | void initError(); 70 | bool checkDeb(); 71 | void compareDebWithCache(); 72 | QString maybeAppendArchSuffix(const QString& pkgName, bool checkingConflicts = false); 73 | QApt::PackageList checkConflicts(); 74 | QApt::Package *checkBreaksSystem(); 75 | bool satisfyDepends(); 76 | 77 | private Q_SLOTS: 78 | void initGUI(); 79 | 80 | void transactionStatusChanged(QApt::TransactionStatus status); 81 | void errorOccurred(QApt::ErrorCode error); 82 | 83 | void setupTransaction(QApt::Transaction *trans); 84 | void installDebFile(); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/DebViewer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DEBVIEWER_H 22 | #define DEBVIEWER_H 23 | 24 | #include 25 | 26 | #include 27 | 28 | class QLabel; 29 | class QPushButton; 30 | class QTextBrowser; 31 | 32 | namespace QApt { 33 | class Backend; 34 | class DebFile; 35 | } 36 | 37 | class DebViewer : public QWidget 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit DebViewer(QWidget *parent); 42 | ~DebViewer(); 43 | 44 | private: 45 | QApt::Backend *m_backend; 46 | QApt::DebFile *m_debFile; 47 | QApt::CacheState m_oldCacheState; 48 | 49 | QLabel *m_iconLabel; 50 | QLabel *m_nameLabel; 51 | QLabel *m_statusLabel; 52 | QPushButton *m_detailsButton; 53 | QWidget *m_versionInfoWidget; 54 | QLabel *m_versionTitleLabel; 55 | QLabel *m_versionInfoLabel; 56 | QTextBrowser *m_descriptionWidget; 57 | QLabel *m_versionLabel; 58 | QLabel *m_sizeLabel; 59 | QLabel *m_maintainerLabel; 60 | QLabel *m_sectionLabel; 61 | QLabel *m_homepageLabel; 62 | QTextBrowser *m_fileWidget; 63 | 64 | public Q_SLOTS: 65 | void setBackend(QApt::Backend *backend); 66 | void setDebFile(QApt::DebFile *debFile); 67 | void setStatusText(const QString &text); 68 | void showDetailsButton(bool show); 69 | void hideVersionInfo(); 70 | void setVersionTitle(const QString &title); 71 | void setVersionInfo(const QString &info); 72 | 73 | private Q_SLOTS: 74 | void detailsButtonClicked(); 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /utils/qapt-deb-installer/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011,2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "DebInstaller.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | static const char description[] = 32 | I18N_NOOP2("@info", "A Debian package installer"); 33 | 34 | static const char version[] = CMAKE_PROJECT_VERSION; 35 | 36 | int main(int argc, char **argv) 37 | { 38 | QApplication app(argc, argv); 39 | app.setWindowIcon(QIcon::fromTheme("applications-other")); 40 | 41 | KLocalizedString::setApplicationDomain("qapt-deb-installer"); 42 | 43 | KAboutData aboutData("qapt-deb-installer", 44 | i18nc("@title", "QApt Package Installer"), 45 | version, 46 | i18nc("@info", description), 47 | KAboutLicense::LicenseKey::GPL, 48 | i18nc("@info:credit", "(C) 2011 Jonathan Thomas")); 49 | 50 | aboutData.addAuthor(i18nc("@info:credit", "Jonathan Thomas"), 51 | QString(), 52 | QStringLiteral("echidnaman@kubuntu.org")); 53 | aboutData.addAuthor(i18nc("@info:credit", "Harald Sitter"), 54 | i18nc("@info:credit", "Qt 5 port"), 55 | QStringLiteral("apachelogger@kubuntu.org")); 56 | KAboutData::setApplicationData(aboutData); 57 | 58 | QCommandLineParser parser; 59 | parser.addHelpOption(); 60 | parser.addVersionOption(); 61 | parser.addPositionalArgument("file", 62 | i18nc("@info:shell argument", ".deb file")); 63 | aboutData.setupCommandLine(&parser); 64 | parser.process(app); 65 | aboutData.processCommandLine(&parser); 66 | 67 | // do not restore! 68 | if (app.isSessionRestored()) { 69 | exit(0); 70 | } 71 | 72 | QString debFile; 73 | 74 | if (parser.positionalArguments().size() > 0) { 75 | debFile = parser.positionalArguments().at(0); 76 | } 77 | 78 | QPointer debInstaller = new DebInstaller(0, debFile); 79 | 80 | switch (debInstaller->exec()) { 81 | case QDialog::Accepted: 82 | return 0; 83 | break; 84 | case QDialog::Rejected: 85 | default: 86 | return 1; 87 | } 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /utils/qapt-deb-thumbnailer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(debthumbnailer MODULE DebThumbnailer.cpp) 2 | 3 | target_link_libraries(debthumbnailer 4 | KF5::KIOWidgets 5 | QApt::Main) 6 | 7 | message(WARNING "make sure thumbnailer actually works") 8 | 9 | install(TARGETS debthumbnailer DESTINATION ${PLUGIN_INSTALL_DIR}) 10 | install(FILES debthumbnailer.desktop DESTINATION ${SERVICES_INSTALL_DIR}) 11 | -------------------------------------------------------------------------------- /utils/qapt-deb-thumbnailer/DebThumbnailer.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * Copyright © 2014 Harald Sitter * 4 | * * 5 | * This program is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU General Public License as * 7 | * published by the Free Software Foundation; either version 2 of * 8 | * the License or (at your option) version 3 or any later version * 9 | * accepted by the membership of KDE e.V. (or its successor approved * 10 | * by the membership of KDE e.V.), which shall act as a proxy * 11 | * defined in Section 14 of version 3 of the license. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program. If not, see . * 20 | ***************************************************************************/ 21 | 22 | #include "DebThumbnailer.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | extern "C" 35 | { 36 | Q_DECL_EXPORT ThumbCreator *new_creator() 37 | { 38 | return new DebThumbnailer; 39 | } 40 | } 41 | 42 | 43 | DebThumbnailer::DebThumbnailer() 44 | { 45 | } 46 | 47 | DebThumbnailer::~DebThumbnailer() 48 | { 49 | } 50 | 51 | bool DebThumbnailer::create(const QString &path, int width, int height, QImage &img) 52 | { 53 | const QApt::DebFile debFile(path); 54 | 55 | if (!debFile.isValid()) { 56 | qDebug() << Q_FUNC_INFO << "debfile not valid"; 57 | return false; 58 | } 59 | 60 | QStringList iconsList = debFile.iconList(); 61 | 62 | // Drop everything but pngs and xpms. 63 | // ::iconList is based on ::fileList which contrary to what the name suggests 64 | // does a full content list including parent directories. 65 | // To get sensible results we therefore need to discard everything we cannot 66 | // identify as supported. 67 | // TODO: should debfile ever get more sensible this should be changed to 68 | // exclude unsupported formats (svg) rather than include supported ones. 69 | for (auto it = iconsList.begin(); it != iconsList.end(); ++it) { 70 | if (!(*it).endsWith(QStringLiteral(".png")) && !(*it).endsWith(QStringLiteral(".xpm"))) { 71 | iconsList.erase(it); 72 | } 73 | } 74 | 75 | qSort(iconsList); 76 | 77 | if (iconsList.isEmpty()) { 78 | return false; 79 | } 80 | 81 | QString iconPath = iconsList.last(); 82 | 83 | // FIXME: two users at the same time cannot use the thumbnailer or bad things happen 84 | QDir tempDir = QDir::temp(); 85 | tempDir.mkdir(QStringLiteral("kde-deb-thumbnailer")); 86 | 87 | QString destPath = QDir::tempPath() % QLatin1Literal("/kde-deb-thumbnailer/"); 88 | 89 | if (!debFile.extractFileFromArchive(iconPath, destPath)) { 90 | return false; 91 | } 92 | 93 | QPixmap mimeIcon = QIcon::fromTheme("application-x-deb").pixmap(width, height); 94 | QPixmap appOverlay = QPixmap(destPath % iconPath).scaledToWidth(width/2); 95 | 96 | QPainter painter(&mimeIcon); 97 | for (int y = 0; y < appOverlay.height(); y += appOverlay.height()) { 98 | painter.drawPixmap( 0, y, appOverlay ); 99 | } 100 | 101 | img = mimeIcon.toImage(); 102 | 103 | return true; 104 | } 105 | 106 | ThumbCreator::Flags DebThumbnailer::flags() const 107 | { 108 | return None; 109 | } 110 | -------------------------------------------------------------------------------- /utils/qapt-deb-thumbnailer/DebThumbnailer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DEBTHUMBNAILER_H 22 | #define DEBTHUMBNAILER_H 23 | 24 | #include 25 | 26 | #include 27 | 28 | namespace QApt { 29 | class DebFile; 30 | } 31 | 32 | class DebThumbnailer : public ThumbCreator 33 | { 34 | public: 35 | DebThumbnailer(); 36 | virtual ~DebThumbnailer(); 37 | 38 | virtual bool create(const QString &path, int w, int h, QImage &img); 39 | virtual Flags flags() const; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /utils/qapt-deb-thumbnailer/debthumbnailer.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | Name=Debian Package Files 4 | Name[ar]=ملفّات حزم دبيانيّة 5 | Name[bs]=Debian paketne datoteke 6 | Name[ca]=Fitxers de paquets de la Debian 7 | Name[ca@valencia]=Fitxers de paquets de Debian 8 | Name[cs]=Soubory balíčků pro Debian 9 | Name[da]=Debian-pakkefiler 10 | Name[de]=Debian-Paketdateien 11 | Name[el]=Αρχεία πακέτων Debian 12 | Name[en_GB]=Debian Package Files 13 | Name[es]=Archivos de paquete Debian 14 | Name[et]=Debiani paketifailid 15 | Name[fi]=Debian-pakettitiedostot 16 | Name[fr]=Fichiers de paquets Debian 17 | Name[gl]=Ficheiros de paquetes de Debian 18 | Name[hu]=Debian csomagfájlok 19 | Name[id]=File Paket Debian 20 | Name[it]=File dei pacchetti di Debian 21 | Name[kk]=Debian десте файлдары 22 | Name[ko]=데비안 패키지 파일 23 | Name[lt]=Debian paketų failai 24 | Name[mr]=डेबियन पॅकेज फाईल्स 25 | Name[nb]=Debian pakkefiler 26 | Name[nds]=Debian-Paketdateien 27 | Name[nl]=Debian-pakketbestanden 28 | Name[pa]=ਡੇਬੀਅਨ ਪੈਕੇਜ ਫਾਇਲਾਂ 29 | Name[pl]=Pliki pakietów dla Debiana 30 | Name[pt]=Ficheiros de Pacotes da Debian 31 | Name[pt_BR]=Arquivos de pacotes do Debian 32 | Name[ro]=Fișiere de pachet Debian 33 | Name[ru]=Пакеты Debian 34 | Name[sk]=Súbory balíkov Debianu 35 | Name[sl]=Datoteke s paketi za Debian 36 | Name[sr]=Фајлови Дебијанових пакета 37 | Name[sr@ijekavian]=Фајлови Дебијанових пакета 38 | Name[sr@ijekavianlatin]=Fajlovi Debianovih paketa 39 | Name[sr@latin]=Fajlovi Debianovih paketa 40 | Name[sv]=Debian-paketfiler 41 | Name[tr]=Debian Paket Dosyaları 42 | Name[ug]=Debian بوغچا ھۆججەتلىرى 43 | Name[uk]=Файли пакунків Debian 44 | Name[x-test]=xxDebian Package Filesxx 45 | Name[zh_CN]=Debian 软件包文件 46 | Name[zh_TW]=Debian 軟體包檔案 47 | X-KDE-ServiceTypes=ThumbCreator 48 | MimeType=application/x-deb; 49 | X-KDE-Library=debthumbnailer 50 | CacheThumbnail=true 51 | IgnoreMaximumSize=true 52 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(qapt-gst-helper_SRCS 2 | main.cpp 3 | GstMatcher.cpp 4 | PluginFinder.cpp 5 | PluginHelper.cpp 6 | PluginInfo.cpp) 7 | 8 | include_directories(${GSTREAMER_INCLUDE_DIR} 9 | ${GLIB2_INCLUDE_DIR}) 10 | 11 | add_executable(qapt-gst-helper ${qapt-gst-helper_SRCS}) 12 | 13 | target_link_libraries(qapt-gst-helper 14 | ${GSTREAMER_LIBRARIES} 15 | ${GLIB2_LIBRARIES} 16 | KF5::CoreAddons 17 | KF5::I18n 18 | KF5::KIOCore 19 | KF5::WidgetsAddons 20 | KF5::WindowSystem 21 | QApt::Main) 22 | 23 | install(TARGETS qapt-gst-helper DESTINATION ${LIBEXEC_INSTALL_DIR}) 24 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/GstMatcher.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010 Daniel Nicoletti * 3 | * Copyright © 2011 Jonathan Thomas * 4 | * * 5 | * This program is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU General Public License as * 7 | * published by the Free Software Foundation; either version 2 of * 8 | * the License or (at your option) version 3 or any later version * 9 | * accepted by the membership of KDE e.V. (or its successor approved * 10 | * by the membership of KDE e.V.), which shall act as a proxy * 11 | * defined in Section 14 of version 3 of the license. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program. If not, see . * 20 | ***************************************************************************/ 21 | 22 | #ifndef GSTMATCHER_H 23 | #define GSTMATCHER_H 24 | 25 | #include 26 | #include 27 | 28 | class PluginInfo; 29 | 30 | namespace QApt { 31 | class Package; 32 | } 33 | 34 | class GstMatcher 35 | { 36 | public: 37 | explicit GstMatcher(const PluginInfo *info); 38 | ~GstMatcher(); 39 | 40 | bool matches(QApt::Package *package); 41 | bool hasMatches() const; 42 | 43 | private: 44 | const PluginInfo *m_info; 45 | QVector m_aptTypes; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/PluginFinder.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "PluginFinder.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "GstMatcher.h" 28 | #include "PluginInfo.h" 29 | 30 | PluginFinder::PluginFinder(QObject *parent, QApt::Backend *backend) 31 | : QObject(parent) 32 | , m_backend(backend) 33 | , m_stop(false) 34 | { 35 | } 36 | 37 | PluginFinder::~PluginFinder() 38 | { 39 | } 40 | 41 | void PluginFinder::find(const PluginInfo *pluginInfo) 42 | { 43 | if (m_stop) { 44 | return; 45 | } 46 | 47 | GstMatcher matcher(pluginInfo); 48 | 49 | if (!matcher.hasMatches()) { 50 | // No such codec 51 | emit notFound(); 52 | return; 53 | } 54 | 55 | foreach (QApt::Package *package, m_backend->availablePackages()) { 56 | if (matcher.matches(package) && package->architecture() == m_backend->nativeArchitecture()) { 57 | emit foundCodec(package); 58 | return; 59 | } 60 | } 61 | 62 | emit notFound(); 63 | } 64 | 65 | void PluginFinder::setSearchList(const QList &list) 66 | { 67 | m_searchList = list; 68 | } 69 | 70 | void PluginFinder::startSearch() 71 | { 72 | foreach(PluginInfo *info, m_searchList) { 73 | find(info); 74 | } 75 | 76 | thread()->quit(); 77 | } 78 | 79 | void PluginFinder::stop() 80 | { 81 | m_stop = true; 82 | } 83 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/PluginFinder.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef PLUGINFINDER_H 22 | #define PLUGINFINDER_H 23 | 24 | #include 25 | #include 26 | 27 | namespace QApt { 28 | class Backend; 29 | class Package; 30 | } 31 | 32 | class PluginInfo; 33 | 34 | class PluginFinder : public QObject 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit PluginFinder(QObject *parent = 0, QApt::Backend *backend = 0); 39 | ~PluginFinder(); 40 | 41 | private: 42 | QApt::Backend *m_backend; 43 | bool m_stop; 44 | QList m_searchList; 45 | 46 | public Q_SLOTS: 47 | void startSearch(); 48 | void setSearchList(const QList &list); 49 | void stop(); 50 | 51 | private Q_SLOTS: 52 | void find(const PluginInfo *pluginInfo); 53 | 54 | Q_SIGNALS: 55 | void foundCodec(QApt::Package *package); 56 | void notFound(); 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/PluginHelper.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef PLUGINHELPER_H 22 | #define PLUGINHELPER_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | class QThread; 30 | 31 | namespace QApt { 32 | class Backend; 33 | class Transaction; 34 | } 35 | 36 | class PluginFinder; 37 | class PluginInfo; 38 | 39 | #define ERR_NO_PLUGINS 1 40 | #define ERR_RANDOM_ERR 2 41 | #define ERR_PARTIAL_SUCCESS 3 42 | #define ERR_CANCEL 4 43 | 44 | class PluginHelper : public QProgressDialog 45 | { 46 | Q_OBJECT 47 | public: 48 | PluginHelper(QWidget *parent, const QStringList &details, int winId); 49 | 50 | void run(); 51 | 52 | private: 53 | QApt::Backend *m_backend; 54 | QApt::Transaction *m_trans; 55 | int m_winId; 56 | bool m_partialFound; 57 | bool m_done; 58 | 59 | QStringList m_details; 60 | QList m_searchList; 61 | QList m_foundCodecs; 62 | 63 | QThread *m_finderThread; 64 | PluginFinder *m_finder; 65 | 66 | void setCloseButton(); 67 | 68 | private Q_SLOTS: 69 | void initError(); 70 | void canSearch(); 71 | void offerInstallPackages(); 72 | void cancellableChanged(bool cancellable); 73 | 74 | void transactionErrorOccurred(QApt::ErrorCode error); 75 | void transactionStatusChanged(QApt::TransactionStatus status); 76 | void provideMedium(const QString &label, const QString &mountPoint); 77 | void untrustedPrompt(const QStringList &untrustedPackages); 78 | void raiseErrorMessage(const QString &text, const QString &title); 79 | void foundCodec(QApt::Package *); 80 | void notFound(); 81 | void notFoundError(); 82 | void incrementProgress(); 83 | void install(); 84 | 85 | void updateProgress(int percentage); 86 | void updateCommitStatus(const QString& message); 87 | 88 | void reject(); 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/PluginInfo.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "PluginInfo.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | PluginInfo::PluginInfo(const QString &gstDetails) 28 | : m_structure(nullptr) 29 | , m_pluginType(InvalidType) 30 | , m_data(gstDetails) 31 | , m_isValid(true) 32 | { 33 | parseDetails(gstDetails); 34 | } 35 | 36 | PluginInfo::~PluginInfo() 37 | { 38 | gst_structure_free(m_structure); 39 | } 40 | 41 | void PluginInfo::parseDetails(const QString &gstDetails) 42 | { 43 | QStringList parts = gstDetails.split('|'); 44 | 45 | if (parts.count() != 5) { 46 | m_isValid = false; 47 | return; 48 | } 49 | 50 | m_version = parts.at(1); 51 | m_requestedBy = parts.at(2); 52 | m_name = parts.at(3); 53 | m_capsInfo = parts.at(4); 54 | 55 | QStringList ss; 56 | 57 | if (m_capsInfo.startsWith(QLatin1String("uri"))) { 58 | // Split URI 59 | ss = parts.at(4).split(QLatin1Char(' ')); 60 | 61 | if (!ss.isEmpty()) { 62 | m_typeName = parts.at(0); 63 | } else { 64 | m_isValid = false; 65 | } 66 | return; 67 | } 68 | 69 | // Everything up to the first '-' is the typeName 70 | m_typeName = parts.at(4).section('-', 0, 0); 71 | m_capsInfo.remove(m_typeName + '-'); 72 | 73 | if (m_typeName == "encoder") { 74 | m_pluginType = Encoder; 75 | } else if (m_typeName == "decoder") { 76 | m_pluginType = Decoder; 77 | } else if (m_typeName== "urisource") { 78 | m_pluginType = UriSource; 79 | } else if (m_typeName == "urisink") { 80 | m_pluginType = UriSink; 81 | } else if (m_typeName == "element") { 82 | m_pluginType = Element; 83 | } else { 84 | qDebug() << "invalid plugin type"; 85 | m_pluginType = InvalidType; 86 | } 87 | 88 | m_structure = gst_structure_new_from_string(m_capsInfo.toUtf8().constData()); 89 | if (!m_structure) { 90 | qDebug() << "Failed to parse structure: " << m_capsInfo; 91 | m_isValid = false; 92 | return; 93 | } 94 | 95 | /* remove fields that are almost always just MIN-MAX of some sort 96 | * in order to make the caps look less messy */ 97 | gst_structure_remove_field(m_structure, "pixel-aspect-ratio"); 98 | gst_structure_remove_field(m_structure, "framerate"); 99 | gst_structure_remove_field(m_structure, "channels"); 100 | gst_structure_remove_field(m_structure, "width"); 101 | gst_structure_remove_field(m_structure, "height"); 102 | gst_structure_remove_field(m_structure, "rate"); 103 | gst_structure_remove_field(m_structure, "depth"); 104 | gst_structure_remove_field(m_structure, "clock-rate"); 105 | gst_structure_remove_field(m_structure, "bitrate"); 106 | } 107 | 108 | QString PluginInfo::version() const 109 | { 110 | return m_version; 111 | } 112 | 113 | QString PluginInfo::requestedBy() const 114 | { 115 | return m_requestedBy; 116 | } 117 | 118 | QString PluginInfo::name() const 119 | { 120 | return m_name; 121 | } 122 | 123 | QString PluginInfo::capsInfo() const 124 | { 125 | return m_capsInfo; 126 | } 127 | 128 | int PluginInfo::pluginType() const 129 | { 130 | return m_pluginType; 131 | } 132 | 133 | QString PluginInfo::data() const 134 | { 135 | return m_data; 136 | } 137 | 138 | QString PluginInfo::typeName() const 139 | { 140 | return m_typeName; 141 | } 142 | 143 | bool PluginInfo::isValid() const 144 | { 145 | return m_isValid; 146 | } 147 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/PluginInfo.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2011 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef PLUGININFO_H 22 | #define PLUGININFO_H 23 | 24 | #include 25 | 26 | // Apt and Gst both define FLAG, forcefully undef the Apt def and hope nothing 27 | // breaks :/ 28 | #undef FLAG 29 | #include 30 | 31 | class PluginInfo 32 | { 33 | public: 34 | enum PluginType { 35 | InvalidType = 0, 36 | Encoder, 37 | Decoder, 38 | UriSource, 39 | UriSink, 40 | Element 41 | }; 42 | 43 | explicit PluginInfo(const QString &gstDetails = QString()); 44 | ~PluginInfo(); 45 | 46 | QString version() const; 47 | QString requestedBy() const; 48 | QString name() const; 49 | QString capsInfo() const; 50 | int pluginType() const; 51 | QString data() const; 52 | QString typeName() const; 53 | 54 | bool isValid() const; 55 | 56 | private: 57 | QString m_version; 58 | QString m_requestedBy; 59 | QString m_name; 60 | QString m_typeName; 61 | QString m_capsInfo; 62 | GstStructure *m_structure; 63 | int m_pluginType; 64 | QString m_data; 65 | 66 | bool m_isValid; 67 | 68 | void parseDetails(const QString &gstDetails); 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /utils/qapt-gst-helper/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright © 2010-2012 Jonathan Thomas * 3 | * * 4 | * This program is free software; you can redistribute it and/or * 5 | * modify it under the terms of the GNU General Public License as * 6 | * published by the Free Software Foundation; either version 2 of * 7 | * the License or (at your option) version 3 or any later version * 8 | * accepted by the membership of KDE e.V. (or its successor approved * 9 | * by the membership of KDE e.V.), which shall act as a proxy * 10 | * defined in Section 14 of version 3 of the license. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "PluginHelper.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | static const char description[] = 34 | I18N_NOOP2("@info", "A GStreamer codec installer using QApt"); 35 | 36 | static const char version[] = CMAKE_PROJECT_VERSION; 37 | 38 | int main(int argc, char **argv) 39 | { 40 | QApplication app(argc, argv); 41 | app.setWindowIcon(QIcon::fromTheme("applications-other")); 42 | 43 | KLocalizedString::setApplicationDomain("qapt-gst-helper"); 44 | 45 | KAboutData aboutData("qapt-gst-helper", 46 | i18nc("@title", "QApt Codec Searcher"), 47 | version, 48 | i18nc("@info", description), 49 | KAboutLicense::LicenseKey::GPL, 50 | i18nc("@info:credit", "(C) 2011 Jonathan Thomas")); 51 | 52 | aboutData.addAuthor(i18nc("@info:credit", "Jonathan Thomas"), 53 | QString(), 54 | QStringLiteral("echidnaman@kubuntu.org")); 55 | aboutData.addAuthor(i18nc("@info:credit", "Harald Sitter"), 56 | i18nc("@info:credit", "Qt 5 port"), 57 | QStringLiteral("apachelogger@kubuntu.org")); 58 | KAboutData::setApplicationData(aboutData); 59 | 60 | QCommandLineParser parser; 61 | parser.addHelpOption(); 62 | parser.addVersionOption(); 63 | QCommandLineOption transientOption(QStringLiteral("transient-for"), 64 | i18nc("@info:shell", "Attaches the window to an X app specified by winid"), 65 | i18nc("@info:shell value name", "winid"), 66 | QStringLiteral("0")); 67 | parser.addOption(transientOption); 68 | parser.addPositionalArgument("GStreamer Info", 69 | i18nc("@info:shell", "GStreamer install info")); 70 | aboutData.setupCommandLine(&parser); 71 | parser.process(app); 72 | aboutData.processCommandLine(&parser); 73 | 74 | GError *error = nullptr; 75 | gst_init_check(&argc, &argv, &error); 76 | if (error) { 77 | // TODO: we should probably show an error message. API documention suggests 78 | // so at least. Then again explaining random init errors to the user 79 | // might be a bit tricky. 80 | #warning FIXME 3.1 show error msgbox when gstreamer init fails 81 | return GST_INSTALL_PLUGINS_ERROR; 82 | } 83 | 84 | // do not restore! 85 | if (app.isSessionRestored()) { 86 | exit(0); 87 | } 88 | 89 | int winId = parser.value(transientOption).toInt(); 90 | QStringList details = parser.positionalArguments(); 91 | 92 | PluginHelper pluginHelper(0, details, winId); 93 | pluginHelper.run(); 94 | 95 | return app.exec(); 96 | } 97 | --------------------------------------------------------------------------------