|
|
@ -61,14 +61,14 @@ using namespace TDEIO;
|
|
|
|
extern "C" {
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
int kdemain( int argc, char **argv ){
|
|
|
|
int kdemain( int argc, char **argv ){
|
|
|
|
TDEInstance instance( "kio_krarc" );
|
|
|
|
TDEInstance instance( "tdeio_krarc" );
|
|
|
|
|
|
|
|
|
|
|
|
if (argc != 4) {
|
|
|
|
if (argc != 4) {
|
|
|
|
kdWarning() << "Usage: kio_krarc protocol domain-socket1 domain-socket2" << endl;
|
|
|
|
kdWarning() << "Usage: tdeio_krarc protocol domain-socket1 domain-socket2" << endl;
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
kio_krarcProtocol slave(argv[2], argv[3]);
|
|
|
|
tdeio_krarcProtocol slave(argv[2], argv[3]);
|
|
|
|
slave.dispatchLoop();
|
|
|
|
slave.dispatchLoop();
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -76,8 +76,8 @@ int kdemain( int argc, char **argv ){
|
|
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
|
|
|
|
kio_krarcProtocol::kio_krarcProtocol(const TQCString &pool_socket, const TQCString &app_socket)
|
|
|
|
tdeio_krarcProtocol::tdeio_krarcProtocol(const TQCString &pool_socket, const TQCString &app_socket)
|
|
|
|
: SlaveBase("kio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(0L),extArcReady(false),
|
|
|
|
: SlaveBase("tdeio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(0L),extArcReady(false),
|
|
|
|
password(TQString()) {
|
|
|
|
password(TQString()) {
|
|
|
|
|
|
|
|
|
|
|
|
krConfig = new TDEConfig( "krusaderrc" );
|
|
|
|
krConfig = new TDEConfig( "krusaderrc" );
|
|
|
@ -93,7 +93,7 @@ kio_krarcProtocol::kio_krarcProtocol(const TQCString &pool_socket, const TQCStri
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------------- */
|
|
|
|
/* ---------------------------------------------------------------------------------- */
|
|
|
|
kio_krarcProtocol::~kio_krarcProtocol(){
|
|
|
|
tdeio_krarcProtocol::~tdeio_krarcProtocol(){
|
|
|
|
// delete the temp directory
|
|
|
|
// delete the temp directory
|
|
|
|
KrShellProcess proc;
|
|
|
|
KrShellProcess proc;
|
|
|
|
proc << "rm -rf "<< arcTempDir;
|
|
|
|
proc << "rm -rf "<< arcTempDir;
|
|
|
@ -101,7 +101,7 @@ kio_krarcProtocol::~kio_krarcProtocol(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------------- */
|
|
|
|
/* ---------------------------------------------------------------------------------- */
|
|
|
|
void kio_krarcProtocol::receivedData(TDEProcess*,char* buf,int len){
|
|
|
|
void tdeio_krarcProtocol::receivedData(TDEProcess*,char* buf,int len){
|
|
|
|
TQByteArray d(len);
|
|
|
|
TQByteArray d(len);
|
|
|
|
d.setRawData(buf,len);
|
|
|
|
d.setRawData(buf,len);
|
|
|
|
data(d);
|
|
|
|
data(d);
|
|
|
@ -110,7 +110,7 @@ void kio_krarcProtocol::receivedData(TDEProcess*,char* buf,int len){
|
|
|
|
decompressedLen += len;
|
|
|
|
decompressedLen += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::mkdir(const KURL& url,int permissions){
|
|
|
|
void tdeio_krarcProtocol::mkdir(const KURL& url,int permissions){
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
|
|
|
|
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
@ -171,7 +171,7 @@ void kio_krarcProtocol::mkdir(const KURL& url,int permissions){
|
|
|
|
finished();
|
|
|
|
finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::put(const KURL& url,int permissions,bool overwrite,bool resume){
|
|
|
|
void tdeio_krarcProtocol::put(const KURL& url,int permissions,bool overwrite,bool resume){
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
|
|
|
|
error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
|
|
|
@ -240,11 +240,11 @@ void kio_krarcProtocol::put(const KURL& url,int permissions,bool overwrite,bool
|
|
|
|
finished();
|
|
|
|
finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::get(const KURL& url ){
|
|
|
|
void tdeio_krarcProtocol::get(const KURL& url ){
|
|
|
|
get( url, TRIES_WITH_PASSWORDS );
|
|
|
|
get( url, TRIES_WITH_PASSWORDS );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::get(const KURL& url, int tries ){
|
|
|
|
void tdeio_krarcProtocol::get(const KURL& url, int tries ){
|
|
|
|
bool decompressToFile = false;
|
|
|
|
bool decompressToFile = false;
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
|
|
|
|
|
|
|
@ -425,7 +425,7 @@ void kio_krarcProtocol::get(const KURL& url, int tries ){
|
|
|
|
finished();
|
|
|
|
finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::del(KURL const & url, bool isFile){
|
|
|
|
void tdeio_krarcProtocol::del(KURL const & url, bool isFile){
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
|
|
|
|
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
@ -466,7 +466,7 @@ void kio_krarcProtocol::del(KURL const & url, bool isFile){
|
|
|
|
finished();
|
|
|
|
finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::stat( const KURL & url ){
|
|
|
|
void tdeio_krarcProtocol::stat( const KURL & url ){
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
|
|
|
|
error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
|
|
|
@ -506,7 +506,7 @@ void kio_krarcProtocol::stat( const KURL & url ){
|
|
|
|
} else error( TDEIO::ERR_DOES_NOT_EXIST, path );
|
|
|
|
} else error( TDEIO::ERR_DOES_NOT_EXIST, path );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::copy (const KURL &url, const KURL &dest, int, bool overwrite) {
|
|
|
|
void tdeio_krarcProtocol::copy (const KURL &url, const KURL &dest, int, bool overwrite) {
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
|
|
|
|
|
|
|
|
// KDE HACK: opening the password dlg in copy causes error for the COPY, and further problems
|
|
|
|
// KDE HACK: opening the password dlg in copy causes error for the COPY, and further problems
|
|
|
@ -571,7 +571,7 @@ void kio_krarcProtocol::copy (const KURL &url, const KURL &dest, int, bool overw
|
|
|
|
error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY));
|
|
|
|
error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::listDir(const KURL& url){
|
|
|
|
void tdeio_krarcProtocol::listDir(const KURL& url){
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
KRDEBUG(url.path());
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
if( !setArcFile( url ) ) {
|
|
|
|
error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
|
|
|
|
error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
|
|
|
@ -615,7 +615,7 @@ void kio_krarcProtocol::listDir(const KURL& url){
|
|
|
|
finished();
|
|
|
|
finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool kio_krarcProtocol::setArcFile(const KURL& url){
|
|
|
|
bool tdeio_krarcProtocol::setArcFile(const KURL& url){
|
|
|
|
TQString path = url.path();
|
|
|
|
TQString path = url.path();
|
|
|
|
time_t currTime = time( 0 );
|
|
|
|
time_t currTime = time( 0 );
|
|
|
|
archiveChanged = true;
|
|
|
|
archiveChanged = true;
|
|
|
@ -690,7 +690,7 @@ bool kio_krarcProtocol::setArcFile(const KURL& url){
|
|
|
|
return initArcParameters();
|
|
|
|
return initArcParameters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool kio_krarcProtocol::initDirDict(const KURL&url, bool forced){
|
|
|
|
bool tdeio_krarcProtocol::initDirDict(const KURL&url, bool forced){
|
|
|
|
// set the archive location
|
|
|
|
// set the archive location
|
|
|
|
//if( !setArcFile(url.path()) ) return false;
|
|
|
|
//if( !setArcFile(url.path()) ) return false;
|
|
|
|
// no need to rescan the archive if it's not changed
|
|
|
|
// no need to rescan the archive if it's not changed
|
|
|
@ -807,7 +807,7 @@ bool kio_krarcProtocol::initDirDict(const KURL&url, bool forced){
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::findArcDirectory(const KURL& url){
|
|
|
|
TQString tdeio_krarcProtocol::findArcDirectory(const KURL& url){
|
|
|
|
TQString path = url.path();
|
|
|
|
TQString path = url.path();
|
|
|
|
if( path.right(1) == "/" ) path.truncate(path.length()-1);
|
|
|
|
if( path.right(1) == "/" ) path.truncate(path.length()-1);
|
|
|
|
|
|
|
|
|
|
|
@ -821,7 +821,7 @@ TQString kio_krarcProtocol::findArcDirectory(const KURL& url){
|
|
|
|
return arcDir;
|
|
|
|
return arcDir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UDSEntry* kio_krarcProtocol::findFileEntry(const KURL& url){
|
|
|
|
UDSEntry* tdeio_krarcProtocol::findFileEntry(const KURL& url){
|
|
|
|
TQString arcDir = findArcDirectory(url);
|
|
|
|
TQString arcDir = findArcDirectory(url);
|
|
|
|
if( arcDir.isEmpty() ) return 0;
|
|
|
|
if( arcDir.isEmpty() ) return 0;
|
|
|
|
|
|
|
|
|
|
|
@ -851,7 +851,7 @@ UDSEntry* kio_krarcProtocol::findFileEntry(const KURL& url){
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::nextWord(TQString &s,char d) {
|
|
|
|
TQString tdeio_krarcProtocol::nextWord(TQString &s,char d) {
|
|
|
|
s=s.stripWhiteSpace();
|
|
|
|
s=s.stripWhiteSpace();
|
|
|
|
int j=s.find(d,0);
|
|
|
|
int j=s.find(d,0);
|
|
|
|
TQString temp=s.left(j); // find the leftmost word.
|
|
|
|
TQString temp=s.left(j); // find the leftmost word.
|
|
|
@ -859,7 +859,7 @@ TQString kio_krarcProtocol::nextWord(TQString &s,char d) {
|
|
|
|
return temp;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mode_t kio_krarcProtocol::parsePermString(TQString perm){
|
|
|
|
mode_t tdeio_krarcProtocol::parsePermString(TQString perm){
|
|
|
|
mode_t mode=0;
|
|
|
|
mode_t mode=0;
|
|
|
|
// file type
|
|
|
|
// file type
|
|
|
|
if(perm[0] == 'd') mode |= S_IFDIR;
|
|
|
|
if(perm[0] == 'd') mode |= S_IFDIR;
|
|
|
@ -881,7 +881,7 @@ mode_t kio_krarcProtocol::parsePermString(TQString perm){
|
|
|
|
return mode;
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UDSEntryList* kio_krarcProtocol::addNewDir(TQString path){
|
|
|
|
UDSEntryList* tdeio_krarcProtocol::addNewDir(TQString path){
|
|
|
|
UDSEntryList* dir;
|
|
|
|
UDSEntryList* dir;
|
|
|
|
|
|
|
|
|
|
|
|
// check if the current dir exists
|
|
|
|
// check if the current dir exists
|
|
|
@ -928,7 +928,7 @@ UDSEntryList* kio_krarcProtocol::addNewDir(TQString path){
|
|
|
|
return dir;
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::parseLine(int lineNo, TQString line, TQFile*) {
|
|
|
|
void tdeio_krarcProtocol::parseLine(int lineNo, TQString line, TQFile*) {
|
|
|
|
UDSEntryList* dir;
|
|
|
|
UDSEntryList* dir;
|
|
|
|
UDSEntry entry;
|
|
|
|
UDSEntry entry;
|
|
|
|
UDSAtom atom;
|
|
|
|
UDSAtom atom;
|
|
|
@ -1232,7 +1232,7 @@ void kio_krarcProtocol::parseLine(int lineNo, TQString line, TQFile*) {
|
|
|
|
dir->append(entry);
|
|
|
|
dir->append(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool kio_krarcProtocol::initArcParameters() {
|
|
|
|
bool tdeio_krarcProtocol::initArcParameters() {
|
|
|
|
KRDEBUG("arcType: "<<arcType);
|
|
|
|
KRDEBUG("arcType: "<<arcType);
|
|
|
|
|
|
|
|
|
|
|
|
if(arcType == "zip"){
|
|
|
|
if(arcType == "zip"){
|
|
|
@ -1376,7 +1376,7 @@ bool kio_krarcProtocol::initArcParameters() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool kio_krarcProtocol::checkStatus( int exitCode ) {
|
|
|
|
bool tdeio_krarcProtocol::checkStatus( int exitCode ) {
|
|
|
|
KRDEBUG( exitCode );
|
|
|
|
KRDEBUG( exitCode );
|
|
|
|
|
|
|
|
|
|
|
|
if( arcType == "zip" || arcType == "rar" || arcType == "7z" )
|
|
|
|
if( arcType == "zip" || arcType == "rar" || arcType == "7z" )
|
|
|
@ -1395,7 +1395,7 @@ struct AutoDetectParams {
|
|
|
|
TQString detectionString;
|
|
|
|
TQString detectionString;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::detectArchive( bool &encrypted, TQString fileName ) {
|
|
|
|
TQString tdeio_krarcProtocol::detectArchive( bool &encrypted, TQString fileName ) {
|
|
|
|
static AutoDetectParams autoDetectParams[] = {{"zip", 0, "PK\x03\x04"},
|
|
|
|
static AutoDetectParams autoDetectParams[] = {{"zip", 0, "PK\x03\x04"},
|
|
|
|
{"rar", 0, "Rar!\x1a" },
|
|
|
|
{"rar", 0, "Rar!\x1a" },
|
|
|
|
{"arj", 0, "\x60\xea" },
|
|
|
|
{"arj", 0, "\x60\xea" },
|
|
|
@ -1548,7 +1548,7 @@ TQString kio_krarcProtocol::detectArchive( bool &encrypted, TQString fileName )
|
|
|
|
return TQString();
|
|
|
|
return TQString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::checkOutputForPassword( TDEProcess *proc,char *buf,int len ) {
|
|
|
|
void tdeio_krarcProtocol::checkOutputForPassword( TDEProcess *proc,char *buf,int len ) {
|
|
|
|
TQByteArray d(len);
|
|
|
|
TQByteArray d(len);
|
|
|
|
d.setRawData(buf,len);
|
|
|
|
d.setRawData(buf,len);
|
|
|
|
TQString data = TQString( d );
|
|
|
|
TQString data = TQString( d );
|
|
|
@ -1574,7 +1574,7 @@ void kio_krarcProtocol::checkOutputForPassword( TDEProcess *proc,char *buf,int l
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void kio_krarcProtocol::invalidatePassword() {
|
|
|
|
void tdeio_krarcProtocol::invalidatePassword() {
|
|
|
|
KRDEBUG( arcFile->url().path(-1) + "/" );
|
|
|
|
KRDEBUG( arcFile->url().path(-1) + "/" );
|
|
|
|
|
|
|
|
|
|
|
|
if( !encrypted )
|
|
|
|
if( !encrypted )
|
|
|
@ -1596,7 +1596,7 @@ void kio_krarcProtocol::invalidatePassword() {
|
|
|
|
cacheAuthentication( authInfo );
|
|
|
|
cacheAuthentication( authInfo );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::getPassword() {
|
|
|
|
TQString tdeio_krarcProtocol::getPassword() {
|
|
|
|
KRDEBUG( encrypted );
|
|
|
|
KRDEBUG( encrypted );
|
|
|
|
|
|
|
|
|
|
|
|
if( !password.isNull() )
|
|
|
|
if( !password.isNull() )
|
|
|
@ -1631,20 +1631,20 @@ TQString kio_krarcProtocol::getPassword() {
|
|
|
|
return password;
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::fullPathName( TQString name ) {
|
|
|
|
TQString tdeio_krarcProtocol::fullPathName( TQString name ) {
|
|
|
|
TQString supposedName = krConfig->readEntry( name, name );
|
|
|
|
TQString supposedName = krConfig->readEntry( name, name );
|
|
|
|
if( supposedName.isEmpty() )
|
|
|
|
if( supposedName.isEmpty() )
|
|
|
|
supposedName = name;
|
|
|
|
supposedName = name;
|
|
|
|
return escape( supposedName );
|
|
|
|
return escape( supposedName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::convertFileName( TQString name ) {
|
|
|
|
TQString tdeio_krarcProtocol::convertFileName( TQString name ) {
|
|
|
|
if( arcType == "zip" )
|
|
|
|
if( arcType == "zip" )
|
|
|
|
name = name.replace( "[", "[[]" );
|
|
|
|
name = name.replace( "[", "[[]" );
|
|
|
|
return convertName( name );
|
|
|
|
return convertName( name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::convertName( TQString name ) {
|
|
|
|
TQString tdeio_krarcProtocol::convertName( TQString name ) {
|
|
|
|
if( !name.contains( '\'' ) )
|
|
|
|
if( !name.contains( '\'' ) )
|
|
|
|
return "'" + name + "'";
|
|
|
|
return "'" + name + "'";
|
|
|
|
if( !name.contains( '"' ) && !name.contains( '$' ) )
|
|
|
|
if( !name.contains( '"' ) && !name.contains( '$' ) )
|
|
|
@ -1652,7 +1652,7 @@ TQString kio_krarcProtocol::convertName( TQString name ) {
|
|
|
|
return escape( name );
|
|
|
|
return escape( name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString kio_krarcProtocol::escape( TQString name ) {
|
|
|
|
TQString tdeio_krarcProtocol::escape( TQString name ) {
|
|
|
|
const TQString evilstuff = "\\\"'`()[]{}!?;$&<>| "; // stuff that should get escaped
|
|
|
|
const TQString evilstuff = "\\\"'`()[]{}!?;$&<>| "; // stuff that should get escaped
|
|
|
|
|
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < evilstuff.length(); ++i )
|
|
|
|
for ( unsigned int i = 0; i < evilstuff.length(); ++i )
|
|
|
|