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.
125 lines
3.2 KiB
125 lines
3.2 KiB
15 years ago
|
/*
|
||
|
** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
|
||
|
**
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
** This program is free software; you can redistribute it and/or modify
|
||
|
** it under the terms of the GNU General Public License as published by
|
||
|
** the Free Software Foundation; either version 2 of the License, or
|
||
|
** (at your option) any later version.
|
||
|
**
|
||
|
** This program is distributed in the hope that it will be useful,
|
||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
** GNU General Public License for more details.
|
||
|
**
|
||
|
** You should have received a copy of the GNU General Public License
|
||
|
** along with this program in a file called COPYING; if not, write to
|
||
|
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
|
** MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
** Bug reports and questions can be sent to kde-devel@kde.org
|
||
|
*/
|
||
|
|
||
|
#include <kapplication.h>
|
||
|
#include <kdebug.h>
|
||
12 years ago
|
#include "tdeio.h"
|
||
15 years ago
|
|
||
|
Kio::Kio()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
bool Kio::download(const KURL & from, const TQString & to)
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEIO::Job *iojob = TDEIO::file_copy(from, to);
|
||
|
connect( iojob, TQT_SIGNAL( result(TDEIO::Job*) ),
|
||
|
TQT_SLOT( slotIOJobFinished( TDEIO::Job* )));
|
||
15 years ago
|
// missing modal widget hack here.
|
||
12 years ago
|
// I'd recommend using TDEIO::NetAccess instead (David).
|
||
15 years ago
|
kapp->enter_loop();
|
||
|
return worked;
|
||
|
}
|
||
|
|
||
12 years ago
|
void Kio::slotIOJobFinished( TDEIO::Job * job)
|
||
15 years ago
|
{
|
||
|
worked = (job->error() == 0);
|
||
|
kapp->exit_loop();
|
||
|
}
|
||
|
|
||
|
Kiod::Kiod()
|
||
|
{
|
||
|
file=0L;
|
||
|
fileT = 0L;
|
||
|
}
|
||
|
|
||
|
Kiod::~Kiod()
|
||
|
{
|
||
|
delete file;
|
||
|
delete fileT;
|
||
|
}
|
||
|
|
||
15 years ago
|
bool Kiod::listDir(const TQString &url, const TQString &fname, bool subdirs)
|
||
15 years ago
|
{
|
||
|
delete file;
|
||
15 years ago
|
file = new TQFile(fname);
|
||
15 years ago
|
if (file->open(IO_WriteOnly)) {
|
||
|
delete fileT;
|
||
15 years ago
|
fileT = new TQTextStream(file);
|
||
12 years ago
|
TDEIO::ListJob *job;
|
||
15 years ago
|
if (!subdirs)
|
||
12 years ago
|
job = TDEIO::listDir( url );
|
||
15 years ago
|
else
|
||
12 years ago
|
job = TDEIO::listRecursive( url, false);
|
||
15 years ago
|
|
||
|
kdDebug() << "started " << job << " " << subdirs << endl;
|
||
|
|
||
12 years ago
|
TQObject::connect( job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ),
|
||
|
TQT_SLOT( slotListEntries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) );
|
||
|
TQObject::connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ),
|
||
|
TQT_SLOT( slotFinished( TDEIO::Job* ) ) );
|
||
15 years ago
|
|
||
|
kapp->enter_loop();
|
||
|
|
||
|
file->close();
|
||
|
if (worked)
|
||
|
return TRUE;
|
||
|
else
|
||
|
return FALSE;
|
||
|
} else
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
12 years ago
|
void Kiod::slotListEntries( TDEIO::Job *, const TDEIO::UDSEntryList& entries )
|
||
15 years ago
|
{
|
||
|
long size = 0;
|
||
15 years ago
|
TQString text;
|
||
15 years ago
|
|
||
12 years ago
|
TDEIO::UDSEntryList::ConstIterator entryIt = entries.begin();
|
||
15 years ago
|
|
||
|
for (; entryIt != entries.end(); ++entryIt) {
|
||
12 years ago
|
//kdDebug() << "listDir " << dynamic_cast<TDEIO::ListJob*>(job)->url() << endl;
|
||
|
for (TDEIO::UDSEntry::ConstIterator it = (*entryIt).begin();
|
||
15 years ago
|
it != (*entryIt).end(); it++ )
|
||
|
{
|
||
12 years ago
|
if ( (*it).m_uds == TDEIO::UDS_SIZE )
|
||
15 years ago
|
size = (*it).m_long;
|
||
12 years ago
|
else if ( (*it).m_uds == TDEIO::UDS_NAME )
|
||
15 years ago
|
text = (*it).m_str;
|
||
|
}
|
||
|
*fileT << text << "\n" << size << "\n";
|
||
|
kdDebug() << text << " " << size << "\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void Kiod::slotFinished( TDEIO::Job *job )
|
||
15 years ago
|
{
|
||
12 years ago
|
//kdDebug() << "finished" << " " << job << " " << dynamic_cast<TDEIO::ListJob*>(job)->url() << endl;
|
||
15 years ago
|
worked = (job->error() == 0);
|
||
|
kapp->exit_loop();
|
||
|
}
|
||
|
|
||
12 years ago
|
#include "tdeio.moc"
|