You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
556 lines
16 KiB
556 lines
16 KiB
15 years ago
|
/*
|
||
|
This file is or will be part of KDE desktop environment
|
||
|
|
||
|
Copyright 1999 Matt Koss <koss@miesto.sk>
|
||
|
|
||
|
It is licensed under GPL version 2.
|
||
|
|
||
|
If it is part of KDE libraries than this file is licensed under
|
||
|
LGPL version 2.
|
||
|
*/
|
||
|
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqmessagebox.h>
|
||
|
#include <tqdir.h>
|
||
15 years ago
|
|
||
|
#include <kacl.h>
|
||
|
#include <kapplication.h>
|
||
|
#include <kcmdlineargs.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kurl.h>
|
||
|
#include <kstatusbar.h>
|
||
12 years ago
|
#include <tdeio/job.h>
|
||
|
#include <tdeio/scheduler.h>
|
||
15 years ago
|
#include <kprotocolinfo.h>
|
||
|
|
||
12 years ago
|
#include "tdeioslavetest.h"
|
||
15 years ago
|
|
||
12 years ago
|
using namespace TDEIO;
|
||
15 years ago
|
|
||
15 years ago
|
KioslaveTest::KioslaveTest( TQString src, TQString dest, uint op, uint pr )
|
||
15 years ago
|
: KMainWindow(0, "")
|
||
|
{
|
||
|
|
||
|
job = 0L;
|
||
|
|
||
15 years ago
|
main_widget = new TQWidget( this, "");
|
||
|
TQBoxLayout *topLayout = new TQVBoxLayout( main_widget, 10, 5 );
|
||
15 years ago
|
|
||
15 years ago
|
TQGridLayout *grid = new TQGridLayout( 2, 2, 10 );
|
||
15 years ago
|
topLayout->addLayout( grid );
|
||
|
|
||
|
grid->setRowStretch(0,1);
|
||
|
grid->setRowStretch(1,1);
|
||
|
|
||
|
grid->setColStretch(0,1);
|
||
|
grid->setColStretch(1,100);
|
||
|
|
||
15 years ago
|
lb_from = new TQLabel( "From:", main_widget );
|
||
15 years ago
|
grid->addWidget( lb_from, 0, 0 );
|
||
|
|
||
15 years ago
|
le_source = new TQLineEdit( main_widget );
|
||
15 years ago
|
grid->addWidget( le_source, 0, 1 );
|
||
|
le_source->setText( src );
|
||
|
|
||
15 years ago
|
lb_to = new TQLabel( "To:", main_widget );
|
||
15 years ago
|
grid->addWidget( lb_to, 1, 0 );
|
||
|
|
||
15 years ago
|
le_dest = new TQLineEdit( main_widget );
|
||
15 years ago
|
grid->addWidget( le_dest, 1, 1 );
|
||
|
le_dest->setText( dest );
|
||
|
|
||
|
// Operation groupbox & buttons
|
||
15 years ago
|
opButtons = new TQButtonGroup( "Operation", main_widget );
|
||
15 years ago
|
topLayout->addWidget( opButtons, 10 );
|
||
15 years ago
|
connect( opButtons, TQT_SIGNAL(clicked(int)), TQT_SLOT(changeOperation(int)) );
|
||
15 years ago
|
|
||
15 years ago
|
TQBoxLayout *hbLayout = new TQHBoxLayout( opButtons, 15 );
|
||
15 years ago
|
|
||
15 years ago
|
rbList = new TQRadioButton( "List", opButtons );
|
||
15 years ago
|
opButtons->insert( rbList, List );
|
||
|
hbLayout->addWidget( rbList, 5 );
|
||
|
|
||
15 years ago
|
rbListRecursive = new TQRadioButton( "ListRecursive", opButtons );
|
||
15 years ago
|
opButtons->insert( rbListRecursive, ListRecursive );
|
||
|
hbLayout->addWidget( rbListRecursive, 5 );
|
||
|
|
||
15 years ago
|
rbStat = new TQRadioButton( "Stat", opButtons );
|
||
15 years ago
|
opButtons->insert( rbStat, Stat );
|
||
|
hbLayout->addWidget( rbStat, 5 );
|
||
|
|
||
15 years ago
|
rbGet = new TQRadioButton( "Get", opButtons );
|
||
15 years ago
|
opButtons->insert( rbGet, Get );
|
||
|
hbLayout->addWidget( rbGet, 5 );
|
||
|
|
||
15 years ago
|
rbPut = new TQRadioButton( "Put", opButtons );
|
||
15 years ago
|
opButtons->insert( rbPut, Put );
|
||
|
hbLayout->addWidget( rbPut, 5 );
|
||
|
|
||
15 years ago
|
rbCopy = new TQRadioButton( "Copy", opButtons );
|
||
15 years ago
|
opButtons->insert( rbCopy, Copy );
|
||
|
hbLayout->addWidget( rbCopy, 5 );
|
||
|
|
||
15 years ago
|
rbMove = new TQRadioButton( "Move", opButtons );
|
||
15 years ago
|
opButtons->insert( rbMove, Move );
|
||
|
hbLayout->addWidget( rbMove, 5 );
|
||
|
|
||
15 years ago
|
rbDelete = new TQRadioButton( "Delete", opButtons );
|
||
15 years ago
|
opButtons->insert( rbDelete, Delete );
|
||
|
hbLayout->addWidget( rbDelete, 5 );
|
||
|
|
||
15 years ago
|
rbShred = new TQRadioButton( "Shred", opButtons );
|
||
15 years ago
|
opButtons->insert( rbShred, Shred );
|
||
|
hbLayout->addWidget( rbShred, 5 );
|
||
|
|
||
15 years ago
|
rbMkdir = new TQRadioButton( "Mkdir", opButtons );
|
||
15 years ago
|
opButtons->insert( rbMkdir, Mkdir );
|
||
|
hbLayout->addWidget( rbMkdir, 5 );
|
||
|
|
||
15 years ago
|
rbMimetype = new TQRadioButton( "Mimetype", opButtons );
|
||
15 years ago
|
opButtons->insert( rbMimetype, Mimetype );
|
||
|
hbLayout->addWidget( rbMimetype, 5 );
|
||
|
|
||
|
opButtons->setButton( op );
|
||
|
changeOperation( op );
|
||
|
|
||
|
// Progress groupbox & buttons
|
||
15 years ago
|
progressButtons = new TQButtonGroup( "Progress dialog mode", main_widget );
|
||
15 years ago
|
topLayout->addWidget( progressButtons, 10 );
|
||
15 years ago
|
connect( progressButtons, TQT_SIGNAL(clicked(int)), TQT_SLOT(changeProgressMode(int)) );
|
||
15 years ago
|
|
||
15 years ago
|
hbLayout = new TQHBoxLayout( progressButtons, 15 );
|
||
15 years ago
|
|
||
15 years ago
|
rbProgressNone = new TQRadioButton( "None", progressButtons );
|
||
15 years ago
|
progressButtons->insert( rbProgressNone, ProgressNone );
|
||
|
hbLayout->addWidget( rbProgressNone, 5 );
|
||
|
|
||
15 years ago
|
rbProgressDefault = new TQRadioButton( "Default", progressButtons );
|
||
15 years ago
|
progressButtons->insert( rbProgressDefault, ProgressDefault );
|
||
|
hbLayout->addWidget( rbProgressDefault, 5 );
|
||
|
|
||
14 years ago
|
rbProgressStatus = new TQRadioButton( "Status", progressButtons );
|
||
|
progressButtons->insert( rbProgressStatus, ProgressStatus );
|
||
|
hbLayout->addWidget( rbProgressStatus, 5 );
|
||
15 years ago
|
|
||
|
progressButtons->setButton( pr );
|
||
|
changeProgressMode( pr );
|
||
|
|
||
|
// statusbar progress widget
|
||
14 years ago
|
statusProgress = new StatusbarProgress( statusBar() );
|
||
15 years ago
|
statusBar()->addWidget( statusProgress, 0, true );
|
||
|
|
||
|
// run & stop butons
|
||
15 years ago
|
hbLayout = new TQHBoxLayout( topLayout, 15 );
|
||
15 years ago
|
|
||
15 years ago
|
pbStart = new TQPushButton( "&Start", main_widget );
|
||
13 years ago
|
pbStart->setFixedSize( pbStart->sizeHint() );
|
||
15 years ago
|
connect( pbStart, TQT_SIGNAL(clicked()), TQT_SLOT(startJob()) );
|
||
15 years ago
|
hbLayout->addWidget( pbStart, 5 );
|
||
|
|
||
15 years ago
|
pbStop = new TQPushButton( "Sto&p", main_widget );
|
||
13 years ago
|
pbStop->setFixedSize( pbStop->sizeHint() );
|
||
15 years ago
|
pbStop->setEnabled( false );
|
||
15 years ago
|
connect( pbStop, TQT_SIGNAL(clicked()), TQT_SLOT(stopJob()) );
|
||
15 years ago
|
hbLayout->addWidget( pbStop, 5 );
|
||
|
|
||
|
// close button
|
||
15 years ago
|
close = new TQPushButton( "&Close", main_widget );
|
||
13 years ago
|
close->setFixedSize( close->sizeHint() );
|
||
15 years ago
|
connect(close, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotQuit()));
|
||
15 years ago
|
|
||
|
topLayout->addWidget( close, 5 );
|
||
|
|
||
13 years ago
|
main_widget->setMinimumSize( main_widget->sizeHint() );
|
||
15 years ago
|
setCentralWidget( main_widget );
|
||
|
|
||
|
slave = 0;
|
||
12 years ago
|
// slave = TDEIO::Scheduler::getConnectedSlave(KURL("ftp://ftp.kde.org"));
|
||
|
TDEIO::Scheduler::connect(TQT_SIGNAL(slaveConnected(TDEIO::Slave*)),
|
||
15 years ago
|
this, TQT_SLOT(slotSlaveConnected()));
|
||
12 years ago
|
TDEIO::Scheduler::connect(TQT_SIGNAL(slaveError(TDEIO::Slave*,int,const TQString&)),
|
||
15 years ago
|
this, TQT_SLOT(slotSlaveError()));
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void KioslaveTest::closeEvent( TQCloseEvent * ){
|
||
15 years ago
|
slotQuit();
|
||
|
}
|
||
|
|
||
|
|
||
|
void KioslaveTest::slotQuit(){
|
||
|
if ( job ) {
|
||
|
job->kill( true ); // kill the job quietly
|
||
|
}
|
||
|
if (slave)
|
||
12 years ago
|
TDEIO::Scheduler::disconnectSlave(slave);
|
||
15 years ago
|
kapp->quit();
|
||
|
}
|
||
|
|
||
|
|
||
|
void KioslaveTest::changeOperation( int id ) {
|
||
|
// only two urls for copy and move
|
||
|
bool enab = rbCopy->isChecked() || rbMove->isChecked();
|
||
|
|
||
|
le_dest->setEnabled( enab );
|
||
|
|
||
|
selectedOperation = id;
|
||
|
}
|
||
|
|
||
|
|
||
|
void KioslaveTest::changeProgressMode( int id ) {
|
||
|
progressMode = id;
|
||
|
|
||
14 years ago
|
if ( progressMode == ProgressStatus ) {
|
||
15 years ago
|
statusBar()->show();
|
||
|
} else {
|
||
|
statusBar()->hide();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void KioslaveTest::startJob() {
|
||
15 years ago
|
TQString sCurrent = TQDir::currentDirPath()+"/";
|
||
15 years ago
|
KURL::encode_string(sCurrent);
|
||
15 years ago
|
TQString sSrc( le_source->text() );
|
||
15 years ago
|
KURL src( sCurrent, sSrc );
|
||
|
|
||
|
if ( !src.isValid() ) {
|
||
15 years ago
|
TQMessageBox::critical(this, "Kioslave Error Message", "Source URL is malformed" );
|
||
15 years ago
|
return;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString sDest( le_dest->text() );
|
||
15 years ago
|
KURL dest( sCurrent, sDest );
|
||
|
|
||
|
if ( !dest.isValid() &&
|
||
|
( selectedOperation == Copy || selectedOperation == Move ) ) {
|
||
15 years ago
|
TQMessageBox::critical(this, "Kioslave Error Message",
|
||
15 years ago
|
"Destination URL is malformed" );
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
pbStart->setEnabled( false );
|
||
|
|
||
|
bool observe = true;
|
||
|
if (progressMode != ProgressDefault) {
|
||
|
observe = false;
|
||
|
}
|
||
|
|
||
|
SimpleJob *myJob = 0;
|
||
|
|
||
|
switch ( selectedOperation ) {
|
||
|
case List:
|
||
12 years ago
|
myJob = TDEIO::listDir( src );
|
||
|
connect(myJob, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList&)),
|
||
|
TQT_SLOT( slotEntries( TDEIO::Job*, const TDEIO::UDSEntryList&)));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case ListRecursive:
|
||
12 years ago
|
myJob = TDEIO::listRecursive( src );
|
||
|
connect(myJob, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList&)),
|
||
|
TQT_SLOT( slotEntries( TDEIO::Job*, const TDEIO::UDSEntryList&)));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Stat:
|
||
12 years ago
|
myJob = TDEIO::stat( src, false, 2 );
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Get:
|
||
12 years ago
|
myJob = TDEIO::get( src, true );
|
||
|
connect(myJob, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray &)),
|
||
|
TQT_SLOT( slotData( TDEIO::Job*, const TQByteArray &)));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Put:
|
||
|
putBuffer = 0;
|
||
12 years ago
|
myJob = TDEIO::put( src, -1, true, false);
|
||
|
connect(myJob, TQT_SIGNAL( dataReq( TDEIO::Job*, TQByteArray &)),
|
||
|
TQT_SLOT( slotDataReq( TDEIO::Job*, TQByteArray &)));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Copy:
|
||
12 years ago
|
job = TDEIO::copy( src, dest, observe );
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Move:
|
||
12 years ago
|
job = TDEIO::move( src, dest, observe );
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Delete:
|
||
12 years ago
|
job = TDEIO::del( src, false, observe );
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Shred:
|
||
12 years ago
|
job = TDEIO::del(src, true, observe);
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Mkdir:
|
||
12 years ago
|
myJob = TDEIO::mkdir( src );
|
||
15 years ago
|
break;
|
||
|
|
||
|
case Mimetype:
|
||
12 years ago
|
myJob = TDEIO::mimetype( src );
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
if (myJob)
|
||
|
{
|
||
|
if (slave)
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave(slave, myJob);
|
||
15 years ago
|
job = myJob;
|
||
|
}
|
||
|
|
||
12 years ago
|
connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ),
|
||
|
TQT_SLOT( slotResult( TDEIO::Job * ) ) );
|
||
15 years ago
|
|
||
12 years ago
|
connect( job, TQT_SIGNAL( canceled( TDEIO::Job * ) ),
|
||
|
TQT_SLOT( slotResult( TDEIO::Job * ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
if (progressMode == ProgressStatus) {
|
||
15 years ago
|
statusProgress->setJob( job );
|
||
|
}
|
||
|
|
||
|
pbStop->setEnabled( true );
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KioslaveTest::slotResult( TDEIO::Job * _job )
|
||
15 years ago
|
{
|
||
|
if ( _job->error() )
|
||
|
{
|
||
|
_job->showErrorDialog();
|
||
|
}
|
||
|
else if ( selectedOperation == Stat )
|
||
|
{
|
||
12 years ago
|
UDSEntry entry = ((TDEIO::StatJob*)_job)->statResult();
|
||
15 years ago
|
printUDSEntry( entry );
|
||
|
}
|
||
|
else if ( selectedOperation == Mimetype )
|
||
|
{
|
||
12 years ago
|
kdDebug() << "mimetype is " << ((TDEIO::MimetypeJob*)_job)->mimetype() << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
if (job == _job)
|
||
|
job = 0L;
|
||
|
pbStart->setEnabled( true );
|
||
|
pbStop->setEnabled( false );
|
||
|
}
|
||
|
|
||
|
void KioslaveTest::slotSlaveConnected()
|
||
|
{
|
||
|
kdDebug() << "Slave connected." << endl;
|
||
|
}
|
||
|
|
||
|
void KioslaveTest::slotSlaveError()
|
||
|
{
|
||
|
kdDebug() << "Error connected." << endl;
|
||
|
slave = 0;
|
||
|
}
|
||
|
|
||
15 years ago
|
static void printACL( const TQString& acl )
|
||
15 years ago
|
{
|
||
|
KACL kacl( acl );
|
||
|
kdDebug() << "According to KACL: " << endl << kacl.asString() << endl;
|
||
|
kdDebug() << "Owner: " << kacl.ownerPermissions() << endl;
|
||
|
kdDebug() << "Owning group: " << kacl.owningGroupPermissions() << endl;
|
||
|
kdDebug() << "Others: " << kacl.othersPermissions() << endl;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KioslaveTest::printUDSEntry( const TDEIO::UDSEntry & entry )
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEIO::UDSEntry::ConstIterator it = entry.begin();
|
||
15 years ago
|
for( ; it != entry.end(); it++ ) {
|
||
|
switch ((*it).m_uds) {
|
||
12 years ago
|
case TDEIO::UDS_FILE_TYPE:
|
||
15 years ago
|
kdDebug() << "File Type : " << (mode_t)((*it).m_long) << endl;
|
||
|
if ( S_ISDIR( (mode_t)((*it).m_long) ) )
|
||
|
{
|
||
|
kdDebug() << "is a dir" << endl;
|
||
|
}
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_ACCESS:
|
||
15 years ago
|
kdDebug() << "Access permissions : " << (*it).m_long << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_EXTENDED_ACL:
|
||
15 years ago
|
if( (*it).m_long == 1 )
|
||
|
kdDebug() << "Has extended ACL information." << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_ACL_STRING:
|
||
15 years ago
|
kdDebug() << "ACL: " << ( (*it).m_str.ascii() ) << endl;
|
||
|
printACL( (*it).m_str );
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_DEFAULT_ACL_STRING:
|
||
15 years ago
|
kdDebug() << "Default ACL: " << ( (*it).m_str.ascii() ) << endl;
|
||
|
printACL( (*it).m_str );
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_USER:
|
||
15 years ago
|
kdDebug() << "User : " << ((*it).m_str.ascii() ) << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_GROUP:
|
||
15 years ago
|
kdDebug() << "Group : " << ((*it).m_str.ascii() ) << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_NAME:
|
||
15 years ago
|
kdDebug() << "Name : " << ((*it).m_str.ascii() ) << endl;
|
||
|
//m_strText = decodeFileName( (*it).m_str );
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_URL:
|
||
15 years ago
|
kdDebug() << "URL : " << ((*it).m_str.ascii() ) << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_MIME_TYPE:
|
||
15 years ago
|
kdDebug() << "MimeType : " << ((*it).m_str.ascii() ) << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_LINK_DEST:
|
||
15 years ago
|
kdDebug() << "LinkDest : " << ((*it).m_str.ascii() ) << endl;
|
||
|
break;
|
||
12 years ago
|
case TDEIO::UDS_SIZE:
|
||
|
kdDebug() << "Size: " << TDEIO::convertSize((*it).m_long) << endl;
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void KioslaveTest::slotEntries(TDEIO::Job* job, const TDEIO::UDSEntryList& list) {
|
||
15 years ago
|
|
||
12 years ago
|
KURL url = static_cast<TDEIO::ListJob*>( job )->url();
|
||
15 years ago
|
KProtocolInfo::ExtraFieldList extraFields = KProtocolInfo::extraFields(url);
|
||
|
UDSEntryListConstIterator it=list.begin();
|
||
|
for (; it != list.end(); ++it) {
|
||
|
// For each file...
|
||
|
KProtocolInfo::ExtraFieldList::Iterator extraFieldsIt = extraFields.begin();
|
||
|
UDSEntry::ConstIterator it2 = (*it).begin();
|
||
|
for( ; it2 != (*it).end(); it2++ ) {
|
||
|
if ((*it2).m_uds == UDS_NAME)
|
||
|
kdDebug() << "" << ( *it2 ).m_str << endl;
|
||
|
else if ( (*it2).m_uds == UDS_EXTRA) {
|
||
|
Q_ASSERT( extraFieldsIt != extraFields.end() );
|
||
15 years ago
|
TQString column = (*extraFieldsIt).name;
|
||
|
//TQString type = (*extraFieldsIt).type;
|
||
15 years ago
|
kdDebug() << " Extra data (" << column << ") :" << ( *it2 ).m_str << endl;
|
||
|
++extraFieldsIt;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void KioslaveTest::slotData(TDEIO::Job*, const TQByteArray &data)
|
||
15 years ago
|
{
|
||
|
if (data.size() == 0)
|
||
|
{
|
||
|
kdDebug(0) << "Data: <End>" << endl;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
kdDebug(0) << "Data: \"" << TQCString(data, data.size()+1) << "\"" << endl;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void KioslaveTest::slotDataReq(TDEIO::Job*, TQByteArray &data)
|
||
15 years ago
|
{
|
||
|
const char *fileDataArray[] =
|
||
|
{
|
||
|
"Hello world\n",
|
||
|
"This is a test file\n",
|
||
|
"You can safely delete it.\n",
|
||
|
"BIG\n",
|
||
|
0
|
||
|
};
|
||
|
const char *fileData = fileDataArray[putBuffer++];
|
||
|
|
||
|
if (!fileData)
|
||
|
{
|
||
|
kdDebug(0) << "DataReq: <End>" << endl;
|
||
|
return;
|
||
|
}
|
||
|
if (!strcmp(fileData, "BIG\n"))
|
||
|
data.fill(0, 29*1024*1024);
|
||
|
else
|
||
|
data.duplicate(fileData, strlen(fileData));
|
||
|
kdDebug(0) << "DataReq: \"" << fileData << "\"" << endl;
|
||
|
}
|
||
|
|
||
|
void KioslaveTest::stopJob() {
|
||
|
kdDebug() << "KioslaveTest::stopJob()" << endl;
|
||
|
job->kill();
|
||
|
job = 0L;
|
||
|
|
||
|
pbStop->setEnabled( false );
|
||
|
pbStart->setEnabled( true );
|
||
|
}
|
||
|
|
||
|
static const char version[] = "v0.0.0 0000"; // :-)
|
||
12 years ago
|
static const char description[] = "Test for tdeioslaves";
|
||
15 years ago
|
static KCmdLineOptions options[] =
|
||
|
{
|
||
|
{ "s", 0, 0 },
|
||
|
{ "src <src>", "Source URL", "" },
|
||
|
{ "d", 0, 0 },
|
||
|
{ "dest <dest>", "Destination URL", "" },
|
||
|
{ "o", 0, 0 },
|
||
|
{ "operation <operation>", "Operation (list,listrecursive,stat,get,put,copy,move,del,shred,mkdir)", "copy" },
|
||
|
{ "p", 0, 0 },
|
||
|
{ "progress <progress>", "Progress Type (none,default,status)", "default" },
|
||
|
KCmdLineLastOption
|
||
|
};
|
||
|
|
||
|
int main(int argc, char **argv) {
|
||
12 years ago
|
TDECmdLineArgs::init( argc, argv, "tdeioslavetest", description, version );
|
||
12 years ago
|
TDECmdLineArgs::addCmdLineOptions( options );
|
||
12 years ago
|
TDEApplication app;
|
||
15 years ago
|
|
||
12 years ago
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
||
15 years ago
|
|
||
15 years ago
|
TQString src = args->getOption("src");
|
||
|
TQString dest = args->getOption("dest");
|
||
15 years ago
|
|
||
|
uint op = 0;
|
||
|
uint pr = 0;
|
||
|
|
||
15 years ago
|
TQString tmps;
|
||
15 years ago
|
|
||
|
tmps = args->getOption("operation");
|
||
|
if ( tmps == "list") {
|
||
|
op = KioslaveTest::List;
|
||
|
} else if ( tmps == "listrecursive") {
|
||
|
op = KioslaveTest::ListRecursive;
|
||
|
} else if ( tmps == "stat") {
|
||
|
op = KioslaveTest::Stat;
|
||
|
} else if ( tmps == "get") {
|
||
|
op = KioslaveTest::Get;
|
||
|
} else if ( tmps == "put") {
|
||
|
op = KioslaveTest::Put;
|
||
|
} else if ( tmps == "copy") {
|
||
|
op = KioslaveTest::Copy;
|
||
|
} else if ( tmps == "move") {
|
||
|
op = KioslaveTest::Move;
|
||
|
} else if ( tmps == "del") {
|
||
|
op = KioslaveTest::Delete;
|
||
|
} else if ( tmps == "shred") {
|
||
|
op = KioslaveTest::Shred;
|
||
|
} else if ( tmps == "mkdir") {
|
||
|
op = KioslaveTest::Mkdir;
|
||
12 years ago
|
} else TDECmdLineArgs::usage("unknown operation");
|
||
15 years ago
|
|
||
|
tmps = args->getOption("progress");
|
||
|
if ( tmps == "none") {
|
||
|
pr = KioslaveTest::ProgressNone;
|
||
|
} else if ( tmps == "default") {
|
||
|
pr = KioslaveTest::ProgressDefault;
|
||
|
} else if ( tmps == "status") {
|
||
14 years ago
|
pr = KioslaveTest::ProgressStatus;
|
||
12 years ago
|
} else TDECmdLineArgs::usage("unknown progress mode");
|
||
15 years ago
|
|
||
|
args->clear(); // Free up memory
|
||
|
|
||
|
KioslaveTest test( src, dest, op, pr );
|
||
|
test.show();
|
||
14 years ago
|
// Bug in KTMW / Qt / layouts ?
|
||
13 years ago
|
test.resize( test.sizeHint() );
|
||
15 years ago
|
|
||
|
app.setMainWidget(&test);
|
||
|
app.exec();
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
#include "tdeioslavetest.moc"
|