@ -46,7 +46,7 @@
# include "../krservices.h"
# include "../krservices.h"
# include "../Dialogs/krpleasewait.h"
# include "../Dialogs/krpleasewait.h"
static TQStringList arcProtocols = TQStringList : : split ( " ; " , " tar;bzip;bzip2;gzip;krarc;zip " ) ;
static TQStringList arcProtocols = TQStringList : : split ( " ; " , " tar;bzip;bzip2;gzip;krarc;zip ;xz " ) ;
TDEWallet : : Wallet * KRarcHandler : : wallet = 0 ;
TDEWallet : : Wallet * KRarcHandler : : wallet = 0 ;
@ -69,6 +69,7 @@ TQStringList KRarcHandler::supportedPackers() {
if ( KrServices : : cmdExist ( " dpkg " ) ) packers . append ( " dpkg " ) ;
if ( KrServices : : cmdExist ( " dpkg " ) ) packers . append ( " dpkg " ) ;
if ( KrServices : : cmdExist ( " 7z " ) | | KrServices : : cmdExist ( " 7za " ) ) packers . append ( " 7z " ) ;
if ( KrServices : : cmdExist ( " 7z " ) | | KrServices : : cmdExist ( " 7za " ) ) packers . append ( " 7z " ) ;
if ( KrServices : : cmdExist ( " rpm " ) & & KrServices : : cmdExist ( " rpm2cpio " ) ) packers . append ( " rpm " ) ;
if ( KrServices : : cmdExist ( " rpm " ) & & KrServices : : cmdExist ( " rpm2cpio " ) ) packers . append ( " rpm " ) ;
if ( KrServices : : cmdExist ( " xz " ) ) packers . append ( " xz " ) ;
// kdDebug() << "Supported Packers:" << endl;
// kdDebug() << "Supported Packers:" << endl;
//TQStringList::Iterator it;
//TQStringList::Iterator it;
//for( it = packers.begin(); it != packers.end(); ++it )
//for( it = packers.begin(); it != packers.end(); ++it )
@ -90,6 +91,8 @@ bool KRarcHandler::arcSupported( TQString type ) {
return true ;
return true ;
else if ( type = = " -tgz " & & lst . contains ( " tar " ) )
else if ( type = = " -tgz " & & lst . contains ( " tar " ) )
return true ;
return true ;
else if ( type = = " -txz " & & lst . contains ( " tar " ) )
return true ;
else if ( type = = " tarz " & & lst . contains ( " tar " ) )
else if ( type = = " tarz " & & lst . contains ( " tar " ) )
return true ;
return true ;
else if ( type = = " gzip " & & lst . contains ( " gzip " ) )
else if ( type = = " gzip " & & lst . contains ( " gzip " ) )
@ -110,7 +113,9 @@ bool KRarcHandler::arcSupported( TQString type ) {
return true ;
return true ;
else if ( type = = " -deb " & & ( lst . contains ( " dpkg " ) & & lst . contains ( " tar " ) ) )
else if ( type = = " -deb " & & ( lst . contains ( " dpkg " ) & & lst . contains ( " tar " ) ) )
return true ;
return true ;
else if ( type = = " -7z " & & lst . contains ( " 7z " ) )
else if ( type = = " -7z " & & lst . contains ( " 7z " ) )
return true ;
else if ( type = = " -xz " & & lst . contains ( " xz " ) )
return true ;
return true ;
// not supported : (
// not supported : (
return false ;
return false ;
@ -123,19 +128,21 @@ bool KRarcHandler::arcHandled( TQString type ) {
krConfig - > setGroup ( " Archives " ) ;
krConfig - > setGroup ( " Archives " ) ;
if ( ( type = = " -tgz " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
if ( ( type = = " -tgz " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " tarz " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " tarz " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " -tar " & & krConfig - > readBoolEntry ( " Do Tar " , _DoTar ) ) | |
( type = = " -tar " & & krConfig - > readBoolEntry ( " Do Tar " , _DoTar ) ) | |
( type = = " -tbz " & & krConfig - > readBoolEntry ( " Do BZip2 " , _DoBZip2 ) ) | |
( type = = " -tbz " & & krConfig - > readBoolEntry ( " Do BZip2 " , _DoBZip2 ) ) | |
( type = = " -txz " & & krConfig - > readBoolEntry ( " Do Xz " , _DoXz ) ) | |
( type = = " gzip " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " gzip " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " zip2 " & & krConfig - > readBoolEntry ( " Do BZip2 " , _DoBZip2 ) ) | |
( type = = " zip2 " & & krConfig - > readBoolEntry ( " Do BZip2 " , _DoBZip2 ) ) | |
( type = = " -zip " & & krConfig - > readBoolEntry ( " Do UnZip " , _DoUnZip ) ) | |
( type = = " -zip " & & krConfig - > readBoolEntry ( " Do UnZip " , _DoUnZip ) ) | |
( type = = " -lha " & & krConfig - > readBoolEntry ( " Do Lha " , _DoUnZip ) ) | |
( type = = " -lha " & & krConfig - > readBoolEntry ( " Do Lha " , _DoUnZip ) ) | |
( type = = " -rar " & & krConfig - > readBoolEntry ( " Do UnRar " , _DoUnRar ) ) | |
( type = = " -rar " & & krConfig - > readBoolEntry ( " Do UnRar " , _DoUnRar ) ) | |
( type = = " -arj " & & krConfig - > readBoolEntry ( " Do UnArj " , _DoUnarj ) ) | |
( type = = " -arj " & & krConfig - > readBoolEntry ( " Do UnArj " , _DoUnarj ) ) | |
( type = = " -ace " & & krConfig - > readBoolEntry ( " Do UnAce " , _DoUnAce ) ) | |
( type = = " -ace " & & krConfig - > readBoolEntry ( " Do UnAce " , _DoUnAce ) ) | |
( type = = " cpio " & & krConfig - > readBoolEntry ( " Do RPM " , _DoRPM ) ) | |
( type = = " cpio " & & krConfig - > readBoolEntry ( " Do RPM " , _DoRPM ) ) | |
( type = = " -rpm " & & krConfig - > readBoolEntry ( " Do RPM " , _DoRPM ) ) | |
( type = = " -rpm " & & krConfig - > readBoolEntry ( " Do RPM " , _DoRPM ) ) | |
( type = = " -deb " & & krConfig - > readBoolEntry ( " Do DEB " , _DoDEB ) ) | |
( type = = " -deb " & & krConfig - > readBoolEntry ( " Do DEB " , _DoDEB ) ) | |
( type = = " -7z " & & krConfig - > readBoolEntry ( " Do 7z " , _Do7z ) ) )
( type = = " -7z " & & krConfig - > readBoolEntry ( " Do 7z " , _Do7z ) ) | |
( type = = " -xz " & & krConfig - > readBoolEntry ( " Do Xz " , _DoXz ) ) )
return true ;
return true ;
else
else
return false ;
return false ;
@ -148,8 +155,8 @@ long KRarcHandler::arcFileCount( TQString archive, TQString type, TQString passw
// first check if supported
// first check if supported
if ( ! arcSupported ( type ) ) return 0 ;
if ( ! arcSupported ( type ) ) return 0 ;
// bzip an gzip archive contains only one file
// bzip , gzip and xz archives contain only one file
if ( type = = " zip2 " | | type = = " gzip " ) return 1L ;
if ( type = = " zip2 " | | type = = " gzip " | | type = = " -xz " ) return 1L ;
// set the right lister to do the job
// set the right lister to do the job
TQString lister ;
TQString lister ;
@ -159,6 +166,7 @@ long KRarcHandler::arcFileCount( TQString archive, TQString type, TQString passw
else if ( type = = " -tgz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " -tgz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " tarz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " tarz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " -tbz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tjvf " ;
else if ( type = = " -tbz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tjvf " ;
else if ( type = = " -txz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tJvf " ;
else if ( type = = " -lha " ) lister = KrServices : : fullPathName ( " lha " ) + " l " ;
else if ( type = = " -lha " ) lister = KrServices : : fullPathName ( " lha " ) + " l " ;
else if ( type = = " -rar " ) lister = KrServices : : fullPathName ( KrServices : : cmdExist ( " rar " ) ? " rar " : " unrar " ) + " l -v " ;
else if ( type = = " -rar " ) lister = KrServices : : fullPathName ( KrServices : : cmdExist ( " rar " ) ? " rar " : " unrar " ) + " l -v " ;
else if ( type = = " -ace " ) lister = KrServices : : fullPathName ( " unace " ) + " l " ;
else if ( type = = " -ace " ) lister = KrServices : : fullPathName ( " unace " ) + " l " ;
@ -171,6 +179,7 @@ long KRarcHandler::arcFileCount( TQString archive, TQString type, TQString passw
else if ( type = = " -rpm " ) lister = KrServices : : fullPathName ( " rpm " ) + " --dump -lpq " ;
else if ( type = = " -rpm " ) lister = KrServices : : fullPathName ( " rpm " ) + " --dump -lpq " ;
else if ( type = = " -deb " ) lister = KrServices : : fullPathName ( " dpkg " ) + " -c " ;
else if ( type = = " -deb " ) lister = KrServices : : fullPathName ( " dpkg " ) + " -c " ;
else if ( type = = " -7z " ) lister = KrServices : : fullPathName ( " 7z " ) + " -y l " ;
else if ( type = = " -7z " ) lister = KrServices : : fullPathName ( " 7z " ) + " -y l " ;
else if ( type = = " -xz " ) lister = KrServices : : fullPathName ( " xz " ) + " -l " ;
else return 0L ;
else return 0L ;
if ( ! password . isNull ( ) ) {
if ( ! password . isNull ( ) ) {
@ -241,6 +250,7 @@ bool KRarcHandler::unpack( TQString archive, TQString type, TQString password, T
else if ( type = = " -tgz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xvzf " ;
else if ( type = = " -tgz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xvzf " ;
else if ( type = = " tarz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xvzf " ;
else if ( type = = " tarz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xvzf " ;
else if ( type = = " -tbz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xjvf " ;
else if ( type = = " -tbz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xjvf " ;
else if ( type = = " -txz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xJvf " ;
else if ( type = = " gzip " ) packer = KrServices : : fullPathName ( " gzip " ) + " -cd " ;
else if ( type = = " gzip " ) packer = KrServices : : fullPathName ( " gzip " ) + " -cd " ;
else if ( type = = " zip2 " ) packer = KrServices : : fullPathName ( " bzip2 " ) + " -cdk " ;
else if ( type = = " zip2 " ) packer = KrServices : : fullPathName ( " bzip2 " ) + " -cdk " ;
else if ( type = = " -lha " ) packer = KrServices : : fullPathName ( " lha " ) + " xf " ;
else if ( type = = " -lha " ) packer = KrServices : : fullPathName ( " lha " ) + " xf " ;
@ -250,6 +260,7 @@ bool KRarcHandler::unpack( TQString archive, TQString type, TQString password, T
KrServices : : fullPathName ( " arj " ) + " -y -v x " :
KrServices : : fullPathName ( " arj " ) + " -y -v x " :
KrServices : : fullPathName ( " unarj " ) + " x " ;
KrServices : : fullPathName ( " unarj " ) + " x " ;
else if ( type = = " -7z " ) packer = KrServices : : fullPathName ( " 7z " ) + " -y x " ;
else if ( type = = " -7z " ) packer = KrServices : : fullPathName ( " 7z " ) + " -y x " ;
else if ( type = = " -xz " ) packer = KrServices : : fullPathName ( " xz " ) + " -cdk " ;
else if ( type = = " -rpm " ) {
else if ( type = = " -rpm " ) {
TQString tempDir = locateLocal ( " tmp " , TQString ( ) ) ;
TQString tempDir = locateLocal ( " tmp " , TQString ( ) ) ;
@ -354,6 +365,7 @@ bool KRarcHandler::test( TQString archive, TQString type, TQString password, lon
else if ( type = = " -tgz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " -tgz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " tarz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " tarz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " -tbz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tjvf " ;
else if ( type = = " -tbz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tjvf " ;
else if ( type = = " -txz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tJvf " ;
else if ( type = = " gzip " ) packer = KrServices : : fullPathName ( " gzip " ) + " -tv " ;
else if ( type = = " gzip " ) packer = KrServices : : fullPathName ( " gzip " ) + " -tv " ;
else if ( type = = " zip2 " ) packer = KrServices : : fullPathName ( " bzip2 " ) + " -tv " ;
else if ( type = = " zip2 " ) packer = KrServices : : fullPathName ( " bzip2 " ) + " -tv " ;
else if ( type = = " -rar " ) packer = KrServices : : fullPathName ( KrServices : : cmdExist ( " rar " ) ? " rar " : " unrar " ) + " t " ;
else if ( type = = " -rar " ) packer = KrServices : : fullPathName ( KrServices : : cmdExist ( " rar " ) ? " rar " : " unrar " ) + " t " ;
@ -362,6 +374,7 @@ bool KRarcHandler::test( TQString archive, TQString type, TQString password, lon
else if ( type = = " -arj " ) packer = KrServices : : fullPathName ( KrServices : : cmdExist ( " arj " ) ? " arj " : " unarj " ) + " t " ;
else if ( type = = " -arj " ) packer = KrServices : : fullPathName ( KrServices : : cmdExist ( " arj " ) ? " arj " : " unarj " ) + " t " ;
else if ( type = = " cpio " ) packer = KrServices : : fullPathName ( " cpio " ) + " --only-verify-crc -tvF " ;
else if ( type = = " cpio " ) packer = KrServices : : fullPathName ( " cpio " ) + " --only-verify-crc -tvF " ;
else if ( type = = " -7z " ) packer = KrServices : : fullPathName ( " 7z " ) + " -y t " ;
else if ( type = = " -7z " ) packer = KrServices : : fullPathName ( " 7z " ) + " -y t " ;
else if ( type = = " -xz " ) packer = KrServices : : fullPathName ( " xz " ) + " -tv " ;
else return false ;
else return false ;
if ( ! password . isNull ( ) ) {
if ( ! password . isNull ( ) ) {
@ -411,10 +424,12 @@ bool KRarcHandler::pack( TQStringList fileNames, TQString type, TQString dest, l
else if ( type = = " tar " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvf " ; type = " -tar " ; }
else if ( type = = " tar " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvf " ; type = " -tar " ; }
else if ( type = = " tar.gz " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvzf " ; type = " -tgz " ; }
else if ( type = = " tar.gz " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvzf " ; type = " -tgz " ; }
else if ( type = = " tar.bz2 " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvjf " ; type = " -tbz " ; }
else if ( type = = " tar.bz2 " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvjf " ; type = " -tbz " ; }
else if ( type = = " tar.xz " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvJf " ; type = " -txz " ; }
else if ( type = = " rar " ) { packer = KrServices : : fullPathName ( " rar " ) + " -r a " ; type = " -rar " ; }
else if ( type = = " rar " ) { packer = KrServices : : fullPathName ( " rar " ) + " -r a " ; type = " -rar " ; }
else if ( type = = " lha " ) { packer = KrServices : : fullPathName ( " lha " ) + " a " ; type = " -lha " ; }
else if ( type = = " lha " ) { packer = KrServices : : fullPathName ( " lha " ) + " a " ; type = " -lha " ; }
else if ( type = = " arj " ) { packer = KrServices : : fullPathName ( " arj " ) + " -r -y a " ; type = " -arj " ; }
else if ( type = = " arj " ) { packer = KrServices : : fullPathName ( " arj " ) + " -r -y a " ; type = " -arj " ; }
else if ( type = = " 7z " ) { packer = KrServices : : fullPathName ( " 7z " ) + " -y a " ; type = " -7z " ; }
else if ( type = = " 7z " ) { packer = KrServices : : fullPathName ( " 7z " ) + " -y a " ; type = " -7z " ; }
else if ( type = = " xz " ) { packer = KrServices : : fullPathName ( " xz " ) + " -z " ; type = " -xz " ; }
else return false ;
else return false ;
TQString password = TQString ( ) ;
TQString password = TQString ( ) ;
@ -473,6 +488,10 @@ bool KRarcHandler::pack( TQStringList fileNames, TQString type, TQString dest, l
static const int sevenZipLevels [ ] = { 0 , 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 } ;
static const int sevenZipLevels [ ] = { 0 , 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 } ;
packer + = TQString ( " -mx%1 " ) . arg ( sevenZipLevels [ level ] ) ;
packer + = TQString ( " -mx%1 " ) . arg ( sevenZipLevels [ level ] ) ;
}
}
else if ( type = = " -xz " ) {
static const int xzLevels [ ] = { 0 , 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 } ;
packer + = TQString ( " -%1 " ) . arg ( xzLevels [ level ] ) ;
}
}
}
if ( extraProps . count ( " CommandLineSwitches " ) > 0 )
if ( extraProps . count ( " CommandLineSwitches " ) > 0 )
@ -590,8 +609,14 @@ TQString KRarcHandler::getType( bool &encrypted, TQString fileName, TQString mim
else
else
result = " - " + result ;
result = " - " + result ;
if ( result . endsWith ( " -7z " ) )
if ( result . endsWith ( " -7z " ) )
{
result = " -7z " ;
result = " -7z " ;
}
if ( result . endsWith ( " -xz " ) )
{
result = " -xz " ;
}
return result . right ( 4 ) ;
return result . right ( 4 ) ;
}
}
@ -602,9 +627,9 @@ bool KRarcHandler::checkStatus( TQString type, int exitCode ) {
return exitCode = = 0 | | exitCode = = 1 ;
return exitCode = = 0 | | exitCode = = 1 ;
else if ( type = = " -ace " | | type = = " zip2 " | | type = = " -lha " | | type = = " -rpm " | | type = = " cpio " | |
else if ( type = = " -ace " | | type = = " zip2 " | | type = = " -lha " | | type = = " -rpm " | | type = = " cpio " | |
type = = " -tar " | | type = = " tarz " | | type = = " -tbz " | | type = = " -tgz " | | type = = " -arj " | |
type = = " -tar " | | type = = " tarz " | | type = = " -tbz " | | type = = " -tgz " | | type = = " -arj " | |
type = = " -deb " )
type = = " -deb " | | type = = " -txz " | | type = = " -xz " )
return exitCode = = 0 ;
return exitCode = = 0 ;
else if ( type = = " gzip " )
else if ( type = = " gzip " | | type = = " -xz " )
return exitCode = = 0 | | exitCode = = 2 ;
return exitCode = = 0 | | exitCode = = 2 ;
else
else
return exitCode = = 0 ;
return exitCode = = 0 ;
@ -625,7 +650,8 @@ TQString KRarcHandler::detectArchive( bool &encrypted, TQString fileName, bool c
{ " bzip2 " , 0 , " \x42 \x5a \x68 \x39 \x31 " } ,
{ " bzip2 " , 0 , " \x42 \x5a \x68 \x39 \x31 " } ,
{ " gzip " , 0 , " \x1f \x8b " } ,
{ " gzip " , 0 , " \x1f \x8b " } ,
{ " deb " , 0 , " !<arch> \n debian-binary " } ,
{ " deb " , 0 , " !<arch> \n debian-binary " } ,
{ " 7z " , 0 , " 7z \xbc \xaf \x27 \x1c " } } ;
{ " 7z " , 0 , " 7z \xbc \xaf \x27 \x1c " } ,
{ " xz " , 0 , " \xfd7 zXZ \x00 " } } ;
static int autoDetectElems = sizeof ( autoDetectParams ) / sizeof ( AutoDetectParams ) ;
static int autoDetectElems = sizeof ( autoDetectParams ) / sizeof ( AutoDetectParams ) ;
encrypted = false ;
encrypted = false ;
@ -749,6 +775,16 @@ TQString KRarcHandler::detectArchive( bool &encrypted, TQString fileName, bool c
}
}
}
}
}
}
if ( fileName . endsWith ( " .tar.xz " ) )
{
return " txz " ;
}
else if ( fileName . endsWith ( " .xz " ) )
{
return " xz " ;
}
return TQString ( ) ;
return TQString ( ) ;
}
}