┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Schmidt-Dominé <[email protected]>2009-11-06 14:56:35 +0000
committerJonathan Schmidt-Dominé <[email protected]>2009-11-06 14:56:35 +0000
commit5114ab58bcf9ccc7fed7cfdd057bffeb87a2ad94 (patch)
treeef9437b0ec50188a392f955222d95f69e9e6f851 /src
parent2d2aea1c5823e648dec6d15c2ebe2f644de65b7c (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/dolphinui.rc3
-rw-r--r--src/dolphinviewactionhandler.cpp15
-rw-r--r--src/dolphinviewactionhandler.h5
-rw-r--r--src/khns/servicemenu.knsrc8
-rwxr-xr-xsrc/khns/servicemenudeinstallation23
-rwxr-xr-xsrc/khns/servicemenuinstallation72
7 files changed, 130 insertions, 1 deletions
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 @@
<Action name="compare_files" />
<Action name="change_remote_encoding" />
</Menu>
+ <Menu name="settings">
+ <Action name="get_servicemenu" />
+ </Menu>
</MenuBar>
<State name="new_file" >
<disable>
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 <ktoggleaction.h>
#include <krun.h>
#include <kpropertiesdialog.h>
+#include <knewstuff2/engine.h>
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