⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jobclasses.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*  This file is part of the KDE project     This file is derived from kdelibs/kio/job.cpp.    Copyright (C) 2000 Stephan Kulow <coolo@kde.org>                       David Faure <faure@kde.org>                       Waldo Bastian <bastian@kde.org>		       Simon Hausmann <hausmann@kde.org>    Copyright (C) 2002-2003 Paul Chitescu <paulc-devel@null.ro>    Copyright (C) 2002-2003 Luciano Montanaro <mikelima@cirulla.net>    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library 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    Library General Public License for more details.    You should have received a copy of the GNU Library General Public License    along with this library; see the file COPYING.LIB.  If not, write to    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,    Boston, MA 02110-1301, USA.*/#include "job.h"#include "jobclasses.h"#include "slavebase.h"#include "scheduler.h"#include "mimehandler.h"#include <assert.h>#include <qtimer.h>#include <slave.h>#include <klocale.h>#include <kmessagebox.h>#include <kdebug.h>#include <global.h>using namespace KIO;Job::Job( bool showProgressInfo ) : m_reenter( 0 ), m_destruct( false ){    m_showProgressInfo = showProgressInfo;    m_error = 0;    m_task = -1;    m_percent = 0;    // ###}Job::~Job(){}bool Job::recurseExit(){    if ( --m_reenter > 0 || !m_destruct )	return false;    delete this;    return true;}void Job::kill(){    // ###    if ( m_reenter > 0 )	m_destruct = true;    else	delete this;}QString Job::errorString() const{    return KIO::buildErrorString(m_error, m_errorText);}void Job::emitPercent( unsigned long size, unsigned long total ){  unsigned long ipercent = m_percent;  if( total == 0 ) m_percent = 100;  else m_percent = 100 * size / total;  if( ( ipercent != m_percent ) || ( m_percent == 100 ) )    emit percent( this, m_percent );}void Job::showErrorDialog( QWidget *parent ){    kdDebug() << k_funcinfo << " called" << endl;    kdDebug() << errorString() << endl;    if ( m_error != ERR_USER_CANCELED )        KMessageBox::error( parent, errorString() );}SimpleJob::SimpleJob( const KURL &url, int command,                      const QByteArray &packedArgs,                      bool showProgressInfo )    : Job( showProgressInfo ){    m_url = url;    m_command = command;    m_packedArgs = packedArgs;    m_totalSize = 0;    m_slave = 0;    if ( !m_url.isValid() )    {        m_error = ERR_MALFORMED_URL;        m_errorText = m_url.url();        QTimer::singleShot( 0, this, SLOT( slaveFinished() ) );        return;    }    if ( !Scheduler::self()->doJob( this ) )    {        m_error = ERR_UNSUPPORTED_PROTOCOL;        m_errorText = m_url.protocol();        QTimer::singleShot( 0, this, SLOT( slaveFinished() ) );        return;    }}SimpleJob::~SimpleJob(){}void SimpleJob::start( Slave *slave ){    m_slave = slave;    assert( m_slave );    QObject::connect( m_slave, SIGNAL( dataReq() ),                      this, SLOT( dataReq() ) );    QObject::connect( m_slave, SIGNAL( redirection( const KURL & ) ),                      this, SLOT( slaveRedirection( const KURL & ) ) );    QObject::connect( m_slave, SIGNAL( finished() ),                      this, SLOT( slaveFinished() ) );    QObject::connect( m_slave, SIGNAL( data( const QByteArray & ) ),                      this, SLOT( receiveData( const QByteArray & ) ) );    QObject::connect( m_slave, SIGNAL( infoMessage( const QString & ) ),                      this, SLOT( slotInfoMessage( const QString & ) ) );    QObject::connect( m_slave, SIGNAL( error( int, const QString & ) ),                      this, SLOT( slotError( int, const QString & ) ) );    QObject::connect( m_slave, SIGNAL( processedSize( KIO::filesize_t ) ),		      this, SLOT( slotProcessedSize( KIO::filesize_t ) ) ) ;    QObject::connect( m_slave, SIGNAL( totalSize( KIO::filesize_t ) ),		      this, SLOT( slotTotalSize( KIO::filesize_t ) ) ) ;    QObject::connect( slave, SIGNAL(metaData( const KIO::MetaData& ) ),              this, SLOT( slotMetaData( const KIO::MetaData& ) ) );    KIO_ARGS << m_url.host() << (Q_INT32)m_url.port() << m_url.user() << m_url.pass();    m_slave->send( CMD_HOST, packedArgs );    m_slave->send( m_command, m_packedArgs );}void SimpleJob::kill(){    Scheduler::self()->releaseJob( this, true );    Job::kill();}void SimpleJob::receiveData( const QByteArray & ){}void SimpleJob::slaveFinished(){    Scheduler::self()->releaseJob( this );    recurseEnter();    emit result( this );    recurseExit();    Job::kill();}void SimpleJob::slaveRedirection( const KURL & ){}void SimpleJob::dataReq(){    // ###}void SimpleJob::slotInfoMessage( const QString &msg ){    emit infoMessage( this, msg );}void SimpleJob::slotError( int id, const QString &text ){    m_error = id;    m_errorText = text;    QTimer::singleShot( 0, this, SLOT( slaveFinished() ) );}void SimpleJob::slotTotalSize( KIO::filesize_t total_size ){  m_totalSize = total_size;  emit totalSize( this, m_totalSize );}void SimpleJob::slotProcessedSize( KIO::filesize_t size ){  recurseEnter();  emit processedSize( this, size );  if ( recurseExit() )    return;  if( size > m_totalSize ) slotTotalSize( size );  emitPercent( size, m_totalSize );}void SimpleJob::slotPercent( unsigned long p ){  emit percent( this, p );}QPtrList<TransferJob> *TransferJob::s_detachedJobs = 0;TransferJob::TransferJob( const KURL &url, int command,                          const QByteArray &packedArgs,                          const QByteArray &staticData,                          bool showProgressInfo )    : SimpleJob( url, command, packedArgs, showProgressInfo ){    m_staticData = staticData;    m_detached = false;    m_cachedDataEmitted = false;    m_finishAfterCacheEmit = false;    m_filter = 0;    m_firstdata = true;}TransferJob::~TransferJob(){    if ( s_detachedJobs )        s_detachedJobs->removeRef( this );    if ( m_filter )	delete m_filter;}void TransferJob::setMetaData( const KIO::MetaData &data ){    m_outgoingMetaData = data;}void TransferJob::addMetaData( const QString &key, const QString &value ){    m_outgoingMetaData.insert( key, value );}void TransferJob::addMetaData( const QMap<QString,QString> &values ){    QMap<QString,QString>::ConstIterator it = values.begin();    QMap<QString,QString>::ConstIterator end = values.end();    for (; it != end; ++it )        m_outgoingMetaData.insert( it.key(), it.data() );}void TransferJob::setIncomingMetaData( const MetaData &dat ){    m_incomingMetaData = dat;}MetaData TransferJob::metaData(){    return m_incomingMetaData;}MetaData TransferJob::outgoingMetaData(){    return m_outgoingMetaData;}QString TransferJob::queryMetaData( const QString &key ){    MetaData::ConstIterator it = m_incomingMetaData.find( key );    if ( it == m_incomingMetaData.end() )        return QString::null;    return it.data();}void TransferJob::slotMimetype( const QString& type ){    m_mimetype = type;    mimeRules( MimeHandler::Find( type ) );    if ( !m_mimetype.isEmpty() )	emit mimetype( this, m_mimetype );}void TransferJob::start( Slave *slave ){    m_slave = slave;    assert( m_slave );    QObject::connect( m_slave, SIGNAL( metaData( const KIO::MetaData & ) ),                      this, SLOT( setIncomingMetaData( const KIO::MetaData & ) ) );    QObject::connect( m_slave, SIGNAL( mimeType( const QString & ) ),                      this, SLOT( slotMimetype( const QString & ) ) );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -