diff options
author | Slávek Banko <[email protected]> | 2012-06-17 19:09:27 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2012-06-17 19:15:56 +0200 |
commit | 1c84948d57c174bcd9732a5a0a51d42d3626d000 (patch) | |
tree | bea1edb0356d7d6809d03f27ff37e89273fbe595 /ark/sevenzip.cpp | |
parent | ba8d2a9f33e4921a7188936098ad76af8d9ab8be (diff) | |
download | tdeutils-1c84948d57c174bcd9732a5a0a51d42d3626d000.tar.gz tdeutils-1c84948d57c174bcd9732a5a0a51d42d3626d000.zip |
[Ark] Repairs and extensions
Added support for Arj
Added support for check archives
Added support for password processing
Fix show broken filenames into real UTF-8
This closes Bug 1030
Diffstat (limited to 'ark/sevenzip.cpp')
-rw-r--r-- | ark/sevenzip.cpp | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/ark/sevenzip.cpp b/ark/sevenzip.cpp index 216fb8d..c1dc7a7 100644 --- a/ark/sevenzip.cpp +++ b/ark/sevenzip.cpp @@ -25,6 +25,7 @@ */ #include <tqdir.h> +#include <tqtextcodec.h> #include <kglobal.h> #include <klocale.h> @@ -120,6 +121,12 @@ void SevenZipArch::create() Arch::Extract | Arch::Delete | Arch::Add | Arch::View ); } +void SevenZipArch::createPassword() +{ + if( m_password.isEmpty() && ArkSettings::askCreatePassword() ) + KPasswordDialog::getNewPassword( m_password, i18n("Warning!\nUsing KGpg for encryption is more secure.\nCancel this dialog or enter password for %1 archiver:").arg(m_archiver_program) ); +} + void SevenZipArch::addFile( const TQStringList & urls ) { KProcess *kp = m_currentProcess = new KProcess; @@ -127,6 +134,9 @@ void SevenZipArch::addFile( const TQStringList & urls ) kp->clearArguments(); *kp << m_archiver_program << "a" ; + if ( !m_password.isEmpty() ) + *kp << "-p" + m_password; + KURL url( urls.first() ); TQDir::setCurrent( url.directory() ); @@ -163,6 +173,11 @@ void SevenZipArch::addDir( const TQString & dirName ) } } +bool SevenZipArch::passwordRequired() +{ + return m_lastShellOutput.find("Enter password") >= 0; +} + void SevenZipArch::remove( TQStringList *list ) { if ( !list ) @@ -212,6 +227,12 @@ void SevenZipArch::unarchFileInternal( ) //*kp << "-ao"; } + // FIXME overwrite existing files created with wrong password + *kp << "-y"; + + if ( !m_password.isEmpty() ) + *kp << "-p" + m_password; + *kp << m_filename; // if the file list is empty, no filenames go on the command line, @@ -243,12 +264,15 @@ void SevenZipArch::unarchFileInternal( ) bool SevenZipArch::processLine( const TQCString& _line ) { - TQCString line( _line ); + TQString line; TQString columns[ 11 ]; unsigned int pos = 0; int strpos, len; - columns[ 0 ] = line.right( line.length() - m_nameColumnPos +1); + TQTextCodec *codec = TQTextCodec::codecForLocale(); + line = codec->toUnicode( _line ); + + columns[ 0 ] = line.right( line.length() - m_nameColumnPos); line.truncate( m_nameColumnPos ); // Go through our columns, try to pick out data, return silently on failure @@ -275,6 +299,8 @@ bool SevenZipArch::processLine( const TQCString& _line ) columns[ curCol->colRef ] = line.mid( strpos, len ); } + // Separated directories pass + if(columns[4].length() && columns[4][0] == 'D') return true; if ( m_dateCol >= 0 ) { @@ -364,4 +390,32 @@ void SevenZipArch::slotReceivedTOC( KProcess*, char* data, int length ) data[ length ] = endchar; } +void SevenZipArch::test() +{ + clearShellOutput(); + + KProcess *kp = m_currentProcess = new KProcess; + kp->clearArguments(); + + *kp << m_unarchiver_program << "t"; + + if ( !m_password.isEmpty() ) + *kp << "-p" + m_password; + + *kp << m_filename; + + connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ), + SLOT( slotReceivedOutput(KProcess*, char*, int) ) ); + connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ), + SLOT( slotReceivedOutput(KProcess*, char*, int) ) ); + connect( kp, SIGNAL( processExited(KProcess*) ), + SLOT( slotTestExited(KProcess*) ) ); + + if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) ) + { + KMessageBox::error( 0, i18n( "Could not start a subprocess." ) ); + emit sigTest( false ); + } +} + #include "sevenzip.moc" |