From 5114ab58bcf9ccc7fed7cfdd057bffeb87a2ad94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Schmidt-Domin=C3=A9?= Date: Fri, 6 Nov 2009 14:56:35 +0000 Subject: [PATCH] Initial ServiceMenu-KHotNewStuff-stuff TODO: fix the existing servicemenus (some install-scripts are broken, some do not provide a simple CLI-interface) TODO: add support for single-desktop-file-servicemenus (for example the "open as root") svn path=/trunk/KDE/kdebase/apps/; revision=1045663 --- src/CMakeLists.txt | 5 ++- src/dolphinui.rc | 3 ++ src/dolphinviewactionhandler.cpp | 15 +++++++ src/dolphinviewactionhandler.h | 5 +++ src/khns/servicemenu.knsrc | 8 ++++ src/khns/servicemenudeinstallation | 23 ++++++++++ src/khns/servicemenuinstallation | 72 ++++++++++++++++++++++++++++++ 7 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/khns/servicemenu.knsrc create mode 100755 src/khns/servicemenudeinstallation create mode 100755 src/khns/servicemenuinstallation diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6ab669e9..0c3416c1e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,7 +72,7 @@ kde4_add_kcfg_files(dolphinprivate_LIB_SRCS kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS}) -target_link_libraries(dolphinprivate ${KDE4_KIO_LIBS} ${KDE4_KFILE_LIBS} konq ${QIMAGEBLITZ_LIBRARIES} ${X11_LIBRARIES}) +target_link_libraries(dolphinprivate ${KDE4_KIO_LIBS} ${KDE4_KFILE_LIBS} konq knewstuff2 ${QIMAGEBLITZ_LIBRARIES} ${X11_LIBRARIES}) if(X11_Xrender_FOUND) target_link_libraries(dolphinprivate ${X11_Xrender_LIB} ) endif(X11_Xrender_FOUND) @@ -276,3 +276,6 @@ install( FILES kcm/kcmdolphinviewmodes.desktop DESTINATION ${SERVICES_INSTALL_DI install( FILES kcm/kcmdolphinnavigation.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install( FILES kcm/kcmdolphinservices.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install( FILES kcm/kcmdolphingeneral.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES khns/servicemenu.knsrc DESTINATION ${CONFIG_INSTALL_DIR} ) +install( PROGRAMS khns/servicemenuinstallation DESTINATION ${BIN_INSTALL_DIR} ) +install( PROGRAMS khns/servicemenudeinstallation DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/src/dolphinui.rc b/src/dolphinui.rc index a70285fb3..525b9c022 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -81,6 +81,9 @@ + + + diff --git a/src/dolphinviewactionhandler.cpp b/src/dolphinviewactionhandler.cpp index 3c010f80f..76989aa4d 100644 --- a/src/dolphinviewactionhandler.cpp +++ b/src/dolphinviewactionhandler.cpp @@ -31,6 +31,7 @@ #include #include #include +#include DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) @@ -180,6 +181,13 @@ void DolphinViewActionHandler::createActions() findFile->setShortcut(Qt::CTRL | Qt::Key_F); findFile->setIcon(KIcon("edit-find")); connect(findFile, SIGNAL(triggered()), this, SLOT(slotFindFile())); + + // Settings menu + + KAction* getServiceMenu = m_actionCollection->addAction("get_servicemenu"); + getServiceMenu->setText(i18nc("@action:inmenu Settings", "Get Servicemenu...")); + getServiceMenu->setIcon(KIcon ("get-hot-new-stuff")); + connect(getServiceMenu, SIGNAL(triggered()), this, SLOT(slotGetServiceMenu())); } QActionGroup* DolphinViewActionHandler::createAdditionalInformationActionGroup() @@ -532,3 +540,10 @@ void DolphinViewActionHandler::slotProperties() dialog->raise(); dialog->activateWindow(); } + +void DolphinViewActionHandler::slotGetServiceMenu() +{ + KNS::Engine khns(m_currentView); + khns.init("servicemenu.knsrc"); + khns.downloadDialogModal(m_currentView); +} diff --git a/src/dolphinviewactionhandler.h b/src/dolphinviewactionhandler.h index 91875ec0c..d30cd044f 100644 --- a/src/dolphinviewactionhandler.h +++ b/src/dolphinviewactionhandler.h @@ -209,6 +209,11 @@ private Q_SLOTS: * like name, size and permissions. */ void slotProperties(); + + /** + * Starts KHotNewStuff to download servicemenus. + */ + void slotGetServiceMenu(); private: /** diff --git a/src/khns/servicemenu.knsrc b/src/khns/servicemenu.knsrc new file mode 100644 index 000000000..7914f7c63 --- /dev/null +++ b/src/khns/servicemenu.knsrc @@ -0,0 +1,8 @@ +[KNewStuff2] +ProvidersUrl=http://download.kde.org/khotnewstuff/servicemenu-providers.xml +ChecksumPolicy=ifpossible +SignaturePolicy=ifpossible +TargetDir=servicemenu-download +Uncompress=never +InstallationCommand=servicemenuinstallation %f +UninstallCommand=servicemenudeinstallation %f diff --git a/src/khns/servicemenudeinstallation b/src/khns/servicemenudeinstallation new file mode 100755 index 000000000..eeadb4033 --- /dev/null +++ b/src/khns/servicemenudeinstallation @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +require 'fileutils' +topdir = ARGV[0] + "-dir" +# try: deinstall.sh +# try: deinstall +# try: installKDE4.sh +# try: installKDE4 +# try: install.sh +# try: install +dd = Dir.new(topdir) +dd.read +dd.read +dir = dd.read +def fail() + system("kdialog --passivepopup \"Deinstallation failed\" 15") + exit(-1) +end +if !((File.exist?(file = dir + "/deinstall.sh") || File.exist?(file = dir + "/deinstall")) && system(file)) + fail() if !File.exist?(file = dir + "/installKDE4.sh") && !File.exist?(file = dir + "/installKDE4") && !File.exist?(file = dir + "/install.sh") && !File.exist?(file = dir + "/install") +File.new(file).chmod(0700) + fail() if !system(file + " --remove") && !system(file + " --delete") && !system(file + " --uninstall") && !system(file + " --deinstall") +end +FileUtils.rm_r(topdir) \ No newline at end of file diff --git a/src/khns/servicemenuinstallation b/src/khns/servicemenuinstallation new file mode 100755 index 000000000..fc04b8c56 --- /dev/null +++ b/src/khns/servicemenuinstallation @@ -0,0 +1,72 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +archive = ARGV[0] +def mimeType(filename) + IO.popen("file --mime-type -b " + filename).gets().strip!() +end +$archivetypes = { "application/x-tar" => :"tar -xf %s -C %s", + "application/tar" => :"tar -xf %s -C %s", + "application/x-gzip" => :"tar -zxf %s -C %s", + "application/gzip" => :"tar -zxf %s -C %s", + "application/x-gzip-compressed-tar" => :"tar -zxf %s -C %s", + "application/gzip-compressed-tar" => :"tar -zxf %s -C %s", + "application/x-gzip-compressed" => :"tar -zxf %s -C %s", + "application/gzip-compressed" => :"tar -zxf %s -C %s", + "application/bzip" => :"tar -jxf %s -C %s", + "application/bzip2" => :"tar -jxf %s -C %s", + "application/x-bzip" => :"tar -jxf %s -C %s", + "application/x-bzip2" => :"tar -jxf %s -C %s", + "application/bzip-compressed" => :"tar -jxf %s -C %s", + "application/bzip2-compressed" => :"tar -jxf %s -C %s", + "application/x-bzip-compressed" => :"tar -jxf %s -C %s", + "application/x-bzip2-compressed" => :"tar -jxf %s -C %s", + "application/bzip-compressed-tar" => :"tar -jxf %s -C %s", + "application/bzip2-compressed-tar" => :"tar -jxf %s -C %s", + "application/x-bzip-compressed-tar" => :"tar -jxf %s -C %s", + "application/x-bzip2-compressed-tar" => :"tar -jxf %s -C %s", + "application/zip" => :"unzip %s -d %s", + "application/x-zip" => :"unzip %s -d %s", + "application/x-zip-compressed" => :"unzip %s -d %s", + "multipart/x-zip" => :"unzip %s -d %s", + "application/tgz" => :"tar -zxf %s -C %s", + "application/x-compressed-gtar" => :"tar -zxf %s -C %s", + "application/x-gtar" => :"tar -zxf %s -C %s", + "file/tgz" => :"tar -zxf %s -C %s", + "multipart/x-tar-gz" => :"tar -zxf %s -C %s", + "application/x-gunzip" => :"tar -zxf %s -C %s", + "application/gzipped" => :"tar -zxf %s -C %s", + "gzip/document" => :"tar -zxf %s -C %s", + "application/x-bz2 " => :"tar -jxf %s -C %s", + "application/x-gtar" => :"tar -xf %s -C %s", + "multipart/x-tar" => :"tar -xf %s -C %s" +} +def uncompress(filename, output) + system(sprintf($archivetypes[mimeType(filename)].to_s, filename, output)) +end +dir = archive + "-dir" +if File.exist?(dir) + FileleUtils.rm_r(dir) +end +FileUtils.mkdir(dir) +exit(-1) if !uncompress(archive, dir) +# try: install-it.sh +# try: install-it +# try: installKDE4.sh +# try: installKDE4 +# try: install.sh +# try: install +dd = Dir.new(dir) +dd.read +dd.read +dir += "/" + dd.read +dd = nil +def fail() + system("kdialog --passivepopup \"Installation failed\" 15") + exit(-1) +end +if !((File.exist?(file = dir + "/install-it.sh") || File.exist?(file = dir + "/install-it")) && system(file)) + fail() if !File.exist?(file = dir + "/installKDE4.sh") && !File.exist?(file = dir + "/installKDE4") && !File.exist?(file = dir + "/install.sh") && !File.exist?(file = dir + "/install") + File.new(file).chmod(0700) + fail() if !system(file + " --local") && !system(file + "--local-install") && !system(file + " --install") +end -- 2.47.3