Commit 9b2fbc57 authored by Csaba Karai's avatar Csaba Karai
Browse files

ADDED: new krarc (see ChangeLog for more details)

parent 4469fef6
ADDED: new krarc !
supports passworded arj, ace, rar, zip
step into hidden archives by pressing <RIGHT> on the archive
decompressing debian packages by Alt+U
using KWallet to store the passwords
writes out the error messages of the archiver
archive type autodetection by its header (first 512 byte)
1.70.0 "Round Robin"
==========================
ADDED: new splashscreen + button to disable it in the look&feel section
......
This diff is collapsed.
/***************************************************************************
krarc.h
-------------------
begin : Sat Jun 14 14:42:49 IDT 2003
copyright : (C) 2003 by Rafi Yanai & Shie Erlich
email : yanai@users.sf.net
***************************************************************************/
krarc.h
-------------------
begin : Sat Jun 14 14:42:49 IDT 2003
copyright : (C) 2003 by Rafi Yanai & Shie Erlich
email : yanai@users.sf.net
***************************************************************************/
/***************************************************************************
* *
......@@ -26,61 +26,69 @@
#include <kurl.h>
#include <kio/global.h>
#include <kio/slavebase.h>
#include <kprocess.h>
class KProcess;
class KFileItem;
class QCString;
class kio_krarcProtocol : public QObject, public KIO::SlaveBase {
Q_OBJECT
Q_OBJECT
public:
kio_krarcProtocol( const QCString &pool_socket, const QCString &app_socket );
kio_krarcProtocol(const QCString &pool_socket, const QCString &app_socket);
virtual ~kio_krarcProtocol();
virtual void stat( const KURL & url );
virtual void get( const KURL& url );
virtual void put( const KURL& url, int permissions, bool overwrite, bool resume );
virtual void mkdir( const KURL& url, int permissions );
virtual void listDir( const KURL& url );
virtual void del( KURL const & url, bool isFile );
virtual void copy ( const KURL &src, const KURL &dest, int permissions, bool overwrite );
virtual void get(const KURL& url);
virtual void put(const KURL& url,int permissions,bool overwrite,bool resume);
virtual void mkdir(const KURL& url,int permissions);
virtual void listDir(const KURL& url);
virtual void del(KURL const & url, bool isFile);
virtual void copy (const KURL &src, const KURL &dest, int permissions, bool overwrite);
public slots:
void receivedData( KProcess* proc, char* buf, int len );
void receivedData(KProcess* proc,char* buf,int len);
protected:
virtual bool initDirDict( const KURL& url, bool forced = false );
virtual bool initArcParameters();
virtual void parseLine( int lineNo, QString line, QFile* temp );
virtual bool setArcFile( const QString& path );
virtual bool initDirDict(const KURL& url,bool forced = false);
virtual bool initArcParameters();
static QString detectArchive( bool &encrypted, QString fileName );
virtual void parseLine(int lineNo, QString line, QFile* temp);
virtual bool setArcFile(const KURL& url);
virtual QString getPassword();
virtual void invalidatePassword();
// archive specific commands
QString cmd; ///< the archiver name.
QString listCmd; ///< list files.
QString listCmd; ///< list files.
QString getCmd; ///< unpack files command.
QString delCmd; ///< delete files command.
QString putCmd; ///< add file command.
QString copyCmd; ///< copy to file command.
private:
void get(const KURL& url, int tries);
/** checks if the exit code is OK. */
bool checkStatus( int exitCode );
/** service function for parseLine. */
QString nextWord( QString &s, char d = ' ' );
QString nextWord(QString &s,char d=' ');
/** translate permittion string to mode_t. */
mode_t parsePermString( QString perm );
mode_t parsePermString(QString perm);
/** return the name of the directory inside the archive. */
QString findArcDirectory( const KURL& url );
QString findArcDirectory(const KURL& url);
/** find the UDSEntry of a file in a directory. */
KIO::UDSEntry* findFileEntry( const KURL& url );
KIO::UDSEntry* findFileEntry(const KURL& url);
/** add a new directory (file list container). */
KIO::UDSEntryList* addNewDir( QString path );
KIO::UDSEntryList* addNewDir(QString path);
QString fullPathName( QString name );
static QString convertName( QString name );
static QString escape( QString name );
QDict<KIO::UDSEntryList> dirDict; //< the directoris data structure.
bool encrypted; //< tells whether the archive is encrypted
bool archiveChanged; //< true if the archive was changed.
bool archiveChanging; //< true if the archive is currently changing.
bool newArchiveURL; //< true if new archive was entered for the protocol
KIO::filesize_t decompressedLen; //< the number of the decompressed bytes
KFileItem* arcFile; //< the archive file item.
QString arcPath; //< the archive location
QString arcTempDir; //< the currently used temp directory.
......@@ -90,5 +98,28 @@ private:
KConfig *krConfig; //< The configuration file for krusader
};
class KrShellProcess : public KShellProcess {
Q_OBJECT
public:
KrShellProcess() : KShellProcess(), errorMsg( QString::null ) {
connect(this,SIGNAL(receivedStderr(KProcess*,char*,int)),
this,SLOT(receivedErrorMsg(KProcess*,char*,int)) );
}
QString getErrorMsg() {
return errorMsg.right( 500 );
}
public slots:
void receivedErrorMsg(KProcess*, char *buf, int len) {
QByteArray d(len);
d.setRawData(buf,len);
errorMsg += QString( d );
d.resetRawData(buf,len);
}
private:
QString errorMsg;
};
#endif
......@@ -37,6 +37,7 @@ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
#include "../krusaderview.h"
#include "../krslots.h"
#include "../VFS/krpermhandler.h"
#include "../VFS/krarchandler.h"
#include "../GUI/kcmdline.h"
#include "../Dialogs/krspecialwidgets.h"
#include "../panelmanager.h"
......@@ -326,7 +327,7 @@ void KrDetailedView::addItems( vfs *v, bool addUpDir ) {
// re-enable sorting
setSorting( cl, as );
sort();
if ( !currentItem )
currentItem = firstChild();
KListView::setCurrentItem( currentItem );
......@@ -852,6 +853,20 @@ void KrDetailedView::keyPressEvent( QKeyEvent * e ) {
if ( i->VF->vfile_isDir() ) { // we create a return-pressed event,
QString tmp = i->name();
op()->emitExecuted(tmp); // thereby emulating a chdir
} else if( i->VF->vfile_getUrl().isLocalFile() ) {
bool encrypted;
KURL url = i->VF->vfile_getUrl();
QString mime = ((vfile *)(i->VF))->vfile_getMime();
QString type = KRarcHandler::getType( encrypted, url.path(), mime );
if( KRarcHandler::arcSupported( type ) ) {
KURL url = i->VF->vfile_getUrl();
if( type == "-tar" || type == "-tgz" || type == "-tbz" )
url.setProtocol( "tar" );
else
url.setProtocol( "krarc" );
ACTIVE_FUNC->openUrl( url );
}
}
return ; // safety
}
......@@ -1178,7 +1193,7 @@ bool KrDetailedView::eventFilter( QObject * watched, QEvent * e )
void KrDetailedView::makeItemVisible( const KrViewItem *item ) {
// qApp->processEvents(); // Please don't remove the comment. Causes crash if it is inserted!
ensureItemVisible( static_cast<const KrDetailedViewItem*>( item ) );
ensureItemVisible( static_cast<const KrDetailedViewItem*>( item ) );
}
void KrDetailedView::initOperator() {
......
......@@ -788,7 +788,6 @@ void ListPanelFunc::testArchive() {
return ; // safety
KURL arcURL = files() ->vfs_getFile( arcName );
QString type = files() ->vfs_search( arcName ) ->vfile_getMime().right( 4 );
QString url = QString::null;
// download the file if it's on a remote filesystem
......@@ -801,14 +800,20 @@ void ListPanelFunc::testArchive() {
} else
url = arcURL.path( -1 );
QString mime = files() ->vfs_search( arcName ) ->vfile_getMime();
bool encrypted = false;
QString type = KRarcHandler::getType( encrypted, url, mime );
// check we that archive is supported
if ( !KRarcHandler::arcSupported( type ) ) {
KMessageBox::sorry( krApp, i18n( "%1, unknown archive type." ).arg( arcName ) );
return ;
}
QString password = encrypted ? KRarcHandler::getPassword( url ) : QString::null;
// test the archive
if ( KRarcHandler::test( url, type ) )
if ( KRarcHandler::test( url, type, password ) )
KMessageBox::information( krApp, i18n( "%1, test passed." ).arg( arcName ) );
else
KMessageBox::error( krApp, i18n( "%1, test failed!" ).arg( arcName ) );
......@@ -870,17 +875,19 @@ void ListPanelFunc::unpack() {
// determining the type
QString mime = files() ->vfs_search( arcName ) ->vfile_getMime();
QString type = mime.right( 4 );
if ( mime.contains( "-rar" ) )
type = "-rar";
bool encrypted = false;
QString type = KRarcHandler::getType( encrypted, url, mime );
// check we that archive is supported
if ( !KRarcHandler::arcSupported( type ) ) {
KMessageBox::sorry( krApp, i18n( "%1, unknown archive type" ).arg( arcName ) );
continue;
}
QString password = encrypted ? KRarcHandler::getPassword( url ) : QString::null;
// unpack the files
KRarcHandler::unpack( url, type, dest.path( -1 ) );
KRarcHandler::unpack( url, type, password, dest.path( -1 ) );
// remove the downloaded file if necessary
if ( url != arcURL.path( -1 ) )
......
......@@ -165,13 +165,17 @@ void KRSearchMod::scanLocalDir( KURL urlToScan )
if ( KRarcHandler::arcSupported( type ) )
{
KURL archiveURL = url;
bool encrypted;
QString realType = KRarcHandler::getType( encrypted, url.path(), mime );
if ( type == "-tbz" || type == "-tgz" || type == "tarz" || type == "-tar" )
archiveURL.setProtocol( "tar" );
else
archiveURL.setProtocol( "krarc" );
if( !encrypted ) {
if ( realType == "-tbz" || realType == "-tgz" || realType == "tarz" || realType == "-tar" )
archiveURL.setProtocol( "tar" );
else
archiveURL.setProtocol( "krarc" );
unScannedUrls.push( archiveURL );
unScannedUrls.push( archiveURL );
}
}
}
......
This diff is collapsed.
......@@ -34,34 +34,62 @@
#include <qobject.h>
#include <kprocess.h>
#include <kurl.h>
#include <kwallet.h>
class KRarcHandler: public QObject {
Q_OBJECT
Q_OBJECT
public:
// return the number of files in the archive
static long arcFileCount(QString archive, QString type);
static long arcFileCount(QString archive, QString type, QString password);
// unpack an archive to destination directory
static bool unpack(QString archive, QString type, QString dest );
static bool unpack(QString archive, QString type, QString password, QString dest );
// pack an archive to destination directory
static bool pack(QStringList fileNames, QString type, QString dest, long count );
// test an archive
static bool test(QString archive, QString type, long count = 0L, QString password = QString::null);
static bool test(QString archive, QString type, QString password, long count = 0L );
// true - if the right unpacker exist in the system
static bool arcSupported(QString type);
// true - if supported and the user want us to handle this kind of archive
static bool arcHandled(QString type);
// return the a list of supported packers
static QStringList supportedPackers();
// removes the alias names for a packer
static void removeAliases( QString &type );
// true - if the url is an archive (ie: tar:/home/test/file.tar.bz2)
static bool isArchive(const KURL& url);
// used to store the current archive password
QString password;
int inSet;
static QString getPassword(QString archive, QString type);
// used to determine the type of the archive
static QString getType( bool &encrypted, QString fileName, QString mime );
// queries the password from the user
static QString getPassword( QString path );
// detects the archive type
static QString detectArchive( bool &encrypted, QString fileName );
private:
// checks if the returned status is correct
static bool checkStatus( QString type, int exitCode );
static KWallet::Wallet * wallet;
};
class KrShellProcess : public KShellProcess {
Q_OBJECT
public:
KrShellProcess() : KShellProcess(), errorMsg( QString::null ) {
connect(this,SIGNAL(receivedStderr(KProcess*,char*,int)),
this,SLOT(receivedErrorMsg(KProcess*,char*,int)) );
}
QString getErrorMsg() {
return errorMsg.right( 500 );
}
public slots:
void setPassword(KProcess *,char *buffer,int buflen);
void receivedErrorMsg(KProcess*, char *buf, int len) {
QByteArray d(len);
d.setRawData(buf,len);
errorMsg += QString( d );
d.resetRawData(buf,len);
}
private:
QString errorMsg;
};
#endif
......@@ -99,7 +99,7 @@ void temp_vfs::handleAceArj(QString origin, QString type){
if (!quietMode) KMessageBox::error(krApp,"This archive type is NOT supported");
return;
}
else if( !KRarcHandler::unpack(origin,type,tmpDir) ){
else if( !KRarcHandler::unpack(origin,type, QString::null, tmpDir) ){
return;
}
}
......
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