Commit 3a5f8691 authored by Rafi Yanai's avatar Rafi Yanai
Browse files

new KrServices class and KrServicrs:cmdExist() replaces

the use of the 'which'  shell command
parent 2643b13f
......@@ -9,6 +9,7 @@
ADDED: you can now use the command line to "cd" into konqi-supported urls.
( try: cd audiocd:/?dev=/dev/cdrom )
ADDED: you can try to execute files in remote filesystem.
ADDED: new command detection function instead of using 'which'
FIXED: rewritten the panel sorting function, it should be better and faster now.
FIXED: back to KRDirWatch, since KDirWatch crashed us on systems with FAM enabled.
......
......@@ -703,7 +703,7 @@ install_location=
type=HEADER
[krusader/Makefile.am]
files=krusader/krusader.desktop,krusader/lo32-app-krusader.png,krusader/lo16-app-krusader.png,krusader/defaults.h,krusader/kicons.cpp,krusader/kicons.h,krusader/krslots.cpp,krusader/krslots.h,krusader/krusader.cpp,krusader/krusader.h,krusader/krusaderui.rc,krusader/krusaderview.cpp,krusader/krusaderview.h,krusader/lo32-app-krusader2.png,krusader/main.cpp,krusader/resources.h,krusader/x-ace.desktop
files=krusader/krusader.desktop,krusader/lo32-app-krusader.png,krusader/lo16-app-krusader.png,krusader/defaults.h,krusader/kicons.cpp,krusader/kicons.h,krusader/krslots.cpp,krusader/krslots.h,krusader/krusader.cpp,krusader/krusader.h,krusader/krusaderui.rc,krusader/krusaderview.cpp,krusader/krusaderview.h,krusader/lo32-app-krusader2.png,krusader/main.cpp,krusader/resources.h,krusader/x-ace.desktop,krusader/krservices.cpp,krusader/krservices.h
sub_dirs=BookMan,Dialogs,GUI,Konfigurator,KViewer,MountMan,Panel,RemoteMan,VFS,Search
type=prog_main
......@@ -1042,6 +1042,18 @@ install=false
install_location=
type=HEADER
[krusader/krservices.cpp]
dist=true
install=false
install_location=
type=SOURCE
[krusader/krservices.h]
dist=true
install=false
install_location=
type=HEADER
[krusader/krslots.cpp]
dist=true
install=false
......
......@@ -3,12 +3,12 @@ bin_PROGRAMS = krusader
## INCLUDES were found outside kdevelop specific part
krusader_SOURCES = main.cpp krusaderview.cpp krusader.cpp krslots.cpp kicons.cpp
krusader_SOURCES = krservices.cpp main.cpp krusaderview.cpp krusader.cpp krslots.cpp kicons.cpp
krusader_LDADD = ./BookMan/libBookMan.a ./Dialogs/libDialogs.a ./GUI/libGUI.a ./Konfigurator/libKonfigurator.a ./KViewer/libKViewer.a ./MountMan/libMountMan.a ./Panel/libPanel.a ./RemoteMan/libRemoteMan.a ./VFS/libVFS.a ./Search/libSearch.a VFS/libVFS.a KViewer/libKViewer.a Dialogs/libDialogs.a -lm $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
SUBDIRS = BookMan Dialogs GUI Konfigurator KViewer MountMan Panel RemoteMan VFS Search
EXTRA_DIST = krusader.desktop lo32-app-krusader.png lo16-app-krusader.png defaults.h kicons.cpp kicons.h krslots.cpp krslots.h krusader.cpp krusader.h krusaderui.rc krusaderview.cpp krusaderview.h lo32-app-krusader2.png main.cpp resources.h x-ace.desktop
EXTRA_DIST = krusader.desktop lo32-app-krusader.png lo16-app-krusader.png defaults.h kicons.cpp kicons.h krslots.cpp krslots.h krusader.cpp krusader.h krusaderui.rc krusaderview.cpp krusaderview.h lo32-app-krusader2.png main.cpp resources.h x-ace.desktop krservices.cpp krservices.h
install-data-local:
$(mkinstalldirs) $(kde_appsdir)/Applications/
......
......@@ -39,70 +39,28 @@
#include "krarchandler.h"
#include "../krusader.h"
#include "../defaults.h"
#include "../krservices.h"
QStringList KRarcHandler::supportedPackers(){
QStringList packers;
// we will simply try to find the packers here..
KShellProcess proc;
proc << "which tar >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("tar");
proc.clearArguments();
proc << "which gzip >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("gzip");
proc.clearArguments();
proc << "which bzip2 >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("bzip2");
proc.clearArguments();
proc << "which unzip >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("unzip");
proc.clearArguments();
proc << "which zip >/dev/null 2>&1" ;
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("zip");
proc.clearArguments();
proc << "which rpm >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("rpm");
proc.clearArguments();
proc << "which cpio >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("cpio");
proc.clearArguments();
proc << "which unrar >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("unrar");
proc.clearArguments();
proc << "which rar >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("rar");
proc.clearArguments();
proc << "which unarj >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("unarj");
proc.clearArguments();
proc << "which unace >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 )
packers.append("unace");
// kdWarning() << "Supported Packers:" << endl;
if( KrServices::cmdExist("tar") ) packers.append("tar");
if( KrServices::cmdExist("gzip") ) packers.append("gzip");
if( KrServices::cmdExist("bzip2") ) packers.append("bzip2");
if( KrServices::cmdExist("unzip") ) packers.append("unzip");
if( KrServices::cmdExist("zip") ) packers.append("zip");
if( KrServices::cmdExist("rpm") ) packers.append("rpm");
if( KrServices::cmdExist("cpio") ) packers.append("cpio");
if( KrServices::cmdExist("unrar") ) packers.append("unrar");
if( KrServices::cmdExist("rar") ) packers.append("rar");
if( KrServices::cmdExist("unarj") ) packers.append("unarj");
if( KrServices::cmdExist("unace") ) packers.append("unace");
// kdDebug() << "Supported Packers:" << endl;
//QStringList::Iterator it;
//for( it = packers.begin(); it != packers.end(); ++it )
// kdWarning() << *it << endl;
// kdDebug() << *it << endl;
return packers;
}
......
......@@ -63,6 +63,7 @@
#include "GUI/kfnkeys.h"
#include "GUI/kcmdline.h"
#include "krslots.h"
#include "krservices.h"
// define the static members
Krusader *Krusader::App=0;
......@@ -548,55 +549,24 @@ void Krusader::updateGUI(bool enforce) {
// if (i!=-1) pathToDiff=lst[i+1];
QStringList Krusader::supportedTools() {
QStringList tools;
bool skip;
KShellProcess proc;
// first, a diff program: kdiff
skip = false;
if (!skip) {
proc << "which kdiff >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
tools.append("DIFF"); tools.append("kdiff");
skip = true;
}
}
if (!skip) {
proc.clearArguments();
proc << "which kompare >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
tools.append("DIFF"); tools.append("kompare");
skip = true;
}
}
if (!skip) {
proc.clearArguments();
proc << "which xxdiff >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
tools.append("DIFF"); tools.append("xxdiff");
skip = true;
}
if ( KrServices::cmdExist("kdiff") ){
tools.append("DIFF"); tools.append("kdiff");
}
else if ( KrServices::cmdExist("kompare") ) {
tools.append("DIFF"); tools.append("kompare");
}
else if ( KrServices::cmdExist("xxdiff") ) {
tools.append("DIFF"); tools.append("xxdiff");
}
// a mailer: kmail
skip = false;
if (!skip) {
proc.clearArguments();
proc << "which kmail >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
tools.append("MAIL"); tools.append("kmail");
skip = true;
}
}
if ( KrServices::cmdExist("kmail") ) {
tools.append("MAIL"); tools.append("kmail");
}
// rename tool: krename
skip = false;
if (!skip) {
proc.clearArguments();
proc << "which krename >/dev/null 2>&1";
if( proc.start(KProcess::Block) && proc.normalExit() && proc.exitStatus()==0 ) {
tools.append("RENAME"); tools.append("krename");
skip = true;
}
if ( KrServices::cmdExist("krename") ) {
tools.append("RENAME"); tools.append("krename");
}
return tools;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment