本文整理汇总了C++中kio::TransferJob::detach方法的典型用法代码示例。如果您正苦于以下问题:C++ TransferJob::detach方法的具体用法?C++ TransferJob::detach怎么用?C++ TransferJob::detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kio::TransferJob
的用法示例。
在下文中一共展示了TransferJob::detach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotJobData
void KRun::slotJobData( KIO::Job *job, const QByteArray &data )
{
// Are we pumping data for an external program?
if ( m_fhandle != -1 )
{
// This should *REALLY* be implemented in another thread or process
if ( data.isEmpty() )
{
emit error();
delete this;
}
else
for ( uint d = 0; d < data.count(); )
{
int n = data.count() - d;
if ( n > 1024 )
n = 1024;
n = ::write( m_fhandle, data.data() + d, n );
if ( n >= 0 )
d += n;
else
{
if ( errno == EAGAIN )
usleep(5000);
else
{
delete this;
break;
}
}
}
return;
}
assert( job->inherits( "KIO::TransferJob" ) );
assert( job == m_job );
KIO::TransferJob *transferJob = static_cast<KIO::TransferJob *>( job );
QString referrer;
{
if ( transferJob->outgoingMetaData().contains( "referrer" ) )
referrer = transferJob->outgoingMetaData()["referrer"];
}
QString mtype = transferJob->mimetype();
// if no MIME type is available attempt to guess it
if ( mtype.isEmpty() )
{
const KIO::MimeHandler* guess = KIO::MimeHandler::Find( m_strURL );
if ( !guess )
guess = KIO::MimeHandler::Find( data );
if ( guess )
mtype = guess->Preferred();
else
mtype = QString::fromLatin1( "text/html" );
}
// If app wants us to pump it data don't detach from job
const KIO::MimeHandler* mime = KIO::MimeHandler::Find( mtype );
if ( mime && mime->isExtApp() && mime->isExtApp()->wantsData() )
{
m_fhandle = exec( ( static_cast<const KIO::MimeExtApp *>( mime ) )->getExtApp(), m_strURL.url(), referrer, true );
if ( m_fhandle >= 0 )
{
// Since we already got some data call itself once
slotJobData( job, data );
return;
}
}
transferJob->detach( data );
job->disconnect( this, 0 );
KURL url = transferJob->url();
m_strURL = url;
if ( mime && mime->isExtApp() )
{
job->kill();
exec( mime->isExtApp()->getExtApp(), m_strURL.url(), referrer );
emit error();
}
else if ( mime && mime->isUnknown() )
{
job->kill();
emit error();
}
else
foundMimeType( mtype );
QTimer::singleShot( 0, this, SLOT( slotSuicide() ) );
}