void KJavaDownloader::slotResult( KJob* ) { kDebug(6100) << "slotResult(" << d->loaderID << ")"; KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); if( d->job->error()) { kDebug(6100) << "slave had an error = " << d->job->errorString(); int code = d->job->error(); if (!code) code = 404; QString codestr = QString::number(code); d->file.resize(codestr.length()); memcpy( d->file.data(), codestr.toAscii().constData(), codestr.length() ); kDebug(6100) << "slave had an error = " << code; server->sendURLData( d->loaderID, ERRORCODE, d->file ); d->file.resize( 0 ); } else { server->sendURLData( d->loaderID, FINISHED, d->file ); } d->job = 0L; // signal KIO::Job::result deletes itself server->removeDataJob( d->loaderID ); // will delete this KJavaAppletServer::freeJavaServer(); }
void KJavaUploader::start() { kDebug(6100) << "KJavaUploader::start(" << d->loaderID << ")"; KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); // create a suspended job d->job = KIO::put( *d->url, -1, KIO::HideProgressInfo ); d->job->suspend(); connect( d->job, SIGNAL(dataReq( KIO::Job*, QByteArray& )), this, SLOT(slotDataRequest( KIO::Job*, QByteArray& )) ); connect( d->job, SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*)) ); server->sendURLData( d->loaderID, CONNECTED, d->file ); KJavaAppletServer::freeJavaServer(); }
void KJavaDownloader::slotData( KIO::Job*, const QByteArray& qb ) { //kDebug(6100) << "slotData(" << d->loaderID << ")"; KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); if (d->isfirstdata) { QString headers = d->job->queryMetaData("HTTP-Headers"); if (!headers.isEmpty()) { d->file.resize( headers.length() ); memcpy( d->file.data(), headers.toAscii().constData(), headers.length() ); server->sendURLData( d->loaderID, HEADERS, d->file ); d->file.resize( 0 ); } d->isfirstdata = false; } if ( qb.size() ) server->sendURLData( d->loaderID, DATA, qb ); KJavaAppletServer::freeJavaServer(); }
void KJavaUploader::slotDataRequest( KIO::Job*, QByteArray& qb ) { // send our data and suspend kDebug(6100) << "slotDataRequest(" << d->loaderID << ") finished:" << d->finished; qb.resize( d->file.size() ); KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); if (d->file.size() == 0) { d->job = 0L; // eof, job deletes itself server->removeDataJob( d->loaderID ); // will delete this } else { memcpy( qb.data(), d->file.data(), d->file.size() ); d->file.resize( 0 ); if (!d->finished) { server->sendURLData( d->loaderID, REQUESTDATA, d->file ); d->job->suspend(); } } KJavaAppletServer::freeJavaServer(); }
void KJavaDownloader::jobCommand( int cmd ) { if (!d->job) return; switch (cmd) { case KJAS_STOP: { kDebug(6100) << "jobCommand(" << d->loaderID << ") stop"; d->job->kill(); d->job = 0L; // KIO::Job::kill deletes itself KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); server->removeDataJob( d->loaderID ); // will delete this KJavaAppletServer::freeJavaServer(); break; } case KJAS_HOLD: kDebug(6100) << "jobCommand(" << d->loaderID << ") hold"; d->job->suspend(); break; case KJAS_RESUME: kDebug(6100) << "jobCommand(" << d->loaderID << ") resume"; d->job->resume(); break; } }
void KJavaDownloader::slotResult( KIO::Job* ) { kdDebug(6100) << "slotResult for url = " << d->url->url() << endl; if( d->job->error() ) { kdDebug(6100) << "slave had an error = " << d->job->errorString() << endl; KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); d->file.resize(0); server->sendURLData( d->loaderID, d->url->url(), d->file ); KJavaAppletServer::freeJavaServer(); } else { kdDebug(6100) << "slave got all its data, sending to KJAS" << endl; kdDebug(6100) << "size of data = " << d->file.size() << endl; KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); server->sendURLData( d->loaderID, d->url->url(), d->file ); KJavaAppletServer::freeJavaServer(); } delete this; }
void KJavaUploader::slotResult( KJob* ) { kDebug(6100) << "slotResult(" << d->loaderID << ") job:" << d->job; if (!d->job) return; KJavaAppletServer* server = KJavaAppletServer::allocateJavaServer(); if (d->job->error()) { int code = d->job->error(); QString codestr = QString::number(code); d->file.resize(codestr.length()); memcpy( d->file.data(), codestr.toAscii().constData(), codestr.length() ); kDebug(6100) << "slave had an error " << code << ": " << d->job->errorString(); server->sendURLData( d->loaderID, ERRORCODE, d->file ); d->file.resize( 0 ); } else // shouldn't come here kError(6100) << "slotResult(" << d->loaderID << ") job:" << d->job << endl; d->job = 0L; // signal KIO::Job::result deletes itself server->removeDataJob( d->loaderID ); // will delete this KJavaAppletServer::freeJavaServer(); }