本文整理汇总了C++中kio::TransferJob类的典型用法代码示例。如果您正苦于以下问题:C++ TransferJob类的具体用法?C++ TransferJob怎么用?C++ TransferJob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TransferJob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listSubCategories
void SmugTalker::listSubCategories(int categoryID)
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
KUrl url(m_apiURL);
url.addQueryItem("method", "smugmug.subcategories.get");
url.addQueryItem("SessionID", m_sessionID);
url.addQueryItem("CategoryID", QString::number(categoryID));
QByteArray tmp;
KIO::TransferJob* job = KIO::http_post(url, tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = SMUG_LISTSUBCATEGORIES;
m_job = job;
m_buffer.resize(0);
}
示例2: QString
KJob *UPnPRouter::sendSoapQuery(const QString & query,const QString & soapact,const QString & controlurl)
{
// if port is not set, 0 will be returned
// thanks to Diego R. Brogna for spotting this bug
if (location.port()<=0)
location.setPort(80);
QUrl address;
address.setScheme(QString("http"));
address.setHost(location.host());
address.setPort(location.port());
address.setPath(controlurl);
KIO::TransferJob *req = KIO::http_post( address, query.toLatin1(), KIO::HideProgressInfo );
req->addMetaData("content-type", QString("text/xml"));
req->addMetaData("UserAgent", QString("Konversation UPnP"));
req->addMetaData("customHTTPHeader", QString("SOAPAction: ") + soapact);
soap_data_out[req] = QByteArray();
soap_data_in[req] = QByteArray();
connect(req, &KIO::TransferJob::data, this, &UPnPRouter::recvSoapData);
connect(req, &KIO::TransferJob::dataReq, this, &UPnPRouter::sendSoapData);
connect(req, &KIO::TransferJob::result, this, &UPnPRouter::onRequestFinished);
return req;
}
示例3: logout
void SmugTalker::logout()
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
KUrl url(m_apiURL);
url.addQueryItem("method", "smugmug.logout");
url.addQueryItem("SessionID", m_sessionID);
QByteArray tmp;
KIO::TransferJob* job = KIO::http_post(url, tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
m_state = SMUG_LOGOUT;
m_job = job;
m_buffer.resize(0);
// logout is synchronous call
job->exec();
slotResult(job);
}
示例4: getUploadPermission
/**
* Request upload permission using OAuth
*
* TODO (Dirk) maybe this can go or be merged with a re-authentication function.
*/
void FbTalker::getUploadPermission()
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
if (m_loginInProgress)
emit signalLoginProgress(8);
QMap<QString, QString> args;
args["access_token"] = m_accessToken;
args["ext_perm"] = "photo_upload";
QByteArray tmp(getCallString(args).toUtf8());
KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"users.hasAppPermission"), tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = FB_GETUPLOADPERM;
m_job = job;
m_buffer.resize(0);
}
示例5: listAlbums
void SmugTalker::listAlbums(const QString& nickName)
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
KUrl url(m_apiURL);
url.addQueryItem("method", "smugmug.albums.get");
url.addQueryItem("SessionID", m_sessionID);
url.addQueryItem("Heavy", "1");
if (!nickName.isEmpty())
url.addQueryItem("NickName", nickName);
QByteArray tmp;
KIO::TransferJob* job = KIO::http_post(url, tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = SMUG_LISTALBUMS;
m_job = job;
m_buffer.resize(0);
}
示例6: listFriends
void FbTalker::listFriends()
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
QMap<QString, QString> args;
args["access_token"] = m_accessToken;
QByteArray tmp(getCallString(args).toUtf8());
KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"friends.get"), tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = FB_LISTFRIENDS;
m_job = job;
m_buffer.resize(0);
}
示例7: logout
void FbTalker::logout()
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
QMap<QString, QString> args;
args["access_token"] = m_accessToken;
QByteArray tmp(getCallString(args).toUtf8());
KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"auth.expireSession"), tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
m_state = FB_LOGOUT;
m_job = job;
m_buffer.resize(0);
// logout is synchronous call
job->exec();
slotResult(job);
}
示例8: listPhotos
void FbTalker::listPhotos(long long userID, const QString &albumID)
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
QMap<QString, QString> args;
args["access_token"] = m_accessToken;
if (!albumID.isEmpty())
args["aid"] = albumID;
else if (userID != 0)
args["subj_id"] = QString::number(userID);
else
args["subj_id"] = QString::number(m_user.id);
QByteArray tmp(getCallString(args).toUtf8());
KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"photos.get"), tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = FB_LISTPHOTOS;
m_job = job;
m_buffer.resize(0);
}
示例9: slotLocalGotResult
void DccTransferRecv::slotLocalGotResult( KIO::Job* job )
{
kdDebug() << "DccTransferRecv::slotLocalGotResult() [BEGIN]" << endl;
KIO::TransferJob* transferJob = static_cast<KIO::TransferJob*>( job );
disconnect( transferJob, 0, 0, 0 );
switch ( transferJob->error() )
{
case 0: // no error
kdDebug() << "DccTransferRecv::slotLocalGotResult(): job->error() returned 0." << endl
<< "DccTransferRecv::slotLocalGotResult(): Why was I called in spite of no error?" << endl;
break;
case KIO::ERR_FILE_ALREADY_EXIST:
askAndPrepareLocalKio( i18n( "<b>The file already exists.</b><br>"
"%1<br>" )
.arg( m_fileURL.prettyURL() ),
DccResumeDialog::RA_Overwrite | DccResumeDialog::RA_Rename | DccResumeDialog::RA_Cancel,
DccResumeDialog::RA_Overwrite );
break;
default:
askAndPrepareLocalKio( i18n( "<b>Could not open the file.<br>"
"Error: %1</b><br>"
"%2<br>" )
.arg( transferJob->error() )
.arg( m_fileURL.prettyURL() ),
DccResumeDialog::RA_Rename | DccResumeDialog::RA_Cancel,
DccResumeDialog::RA_Rename );
}
kdDebug() << "DccTransferRecv::slotLocalGotResult() [END]" << endl;
}
示例10: putAndGet
void JobRemoteTest::putAndGet()
{
const QString filePath = remoteTmpDir() + "putAndGetFile";
KUrl u(filePath);
KIO::TransferJob* job = KIO::put( u, 0600, KIO::Overwrite | KIO::HideProgressInfo );
QDateTime mtime = QDateTime::currentDateTime().addSecs( -30 ); // 30 seconds ago
mtime.setTime_t(mtime.toTime_t()); // hack for losing the milliseconds
job->setModificationTime(mtime);
job->setUiDelegate( 0 );
connect( job, SIGNAL( result(KJob*) ),
this, SLOT( slotResult(KJob*) ) );
connect( job, SIGNAL(dataReq(KIO::Job*, QByteArray&)),
this, SLOT(slotDataReq(KIO::Job*, QByteArray&)) );
m_result = -1;
m_dataReqCount = 0;
enterLoop();
QVERIFY( m_result == 0 ); // no error
m_result = -1;
KIO::StoredTransferJob* getJob = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
getJob->setUiDelegate( 0 );
connect( getJob, SIGNAL( result( KJob* ) ),
this, SLOT( slotGetResult( KJob* ) ) );
enterLoop();
QCOMPARE( m_result, 0 ); // no error
QCOMPARE( m_data, QByteArray("This is a test for KIO::put()\n") );
//QCOMPARE( m_data.size(), 11 );
}
示例11: onFinishedReadingFile
void ShareProvider::onFinishedReadingFile(KIO::Job* job, const QByteArray& data)
{
job->disconnect(this);
qobject_cast<KIO::FileJob *>(job)->close();
if (data.length() == 0) {
Q_EMIT finishedError(this, i18n("It was not possible to read the selected file"));
return;
}
d->m_data.clear();
AbstractSharer *sharer = d->getSharer();
if (sharer) {
KUrl sharerUrl = sharer->url();
if (!sharerUrl.isValid()) {
Q_EMIT finishedError(this, i18n("Service Url is not valid"));
return;
}
KIO::TransferJob *tJob = KIO::http_post(sharer->url(), sharer->postBody(data), KIO::HideProgressInfo);
tJob->setMetaData(sharer->headers());
connect(tJob, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(onTransferJobDataReceived(KIO::Job*,QByteArray)));
connect(tJob, SIGNAL(result(KJob*)), this, SLOT(onTransferJobResultReceived(KJob*)));
}
}
示例12: onTransferJobResultReceived
void ShareProvider::onTransferJobResultReceived(KJob* job)
{
if (d->m_data.size() == 0) {
Q_EMIT finishedError(this, i18n("Service was not available"));
return;
}
KIO::TransferJob *tfJob = qobject_cast<KIO::TransferJob*>(job);
if (tfJob) {
QString mimeType = tfJob->mimetype();
AbstractSharer *sharer = d->getSharer();
if (sharer) {
sharer->parseResponse(d->m_data);
if (tfJob->isErrorPage() || sharer->hasError()) {
QString errorMessage = sharer->errorMessage();
if (!errorMessage.isEmpty()) {
Q_EMIT finishedError(this, errorMessage);
} else {
Q_EMIT finishedError(this, tfJob->errorString());
}
} else {
Q_EMIT finishedSuccess(this, sharer->imageUrl().url());
}
}
}
}
示例13: fetchFinished
void HttpContainer::fetchFinished(KJob *job)
{
if (!job->error()) {
// We now set the data on the source with the retrieved data and some
// additional stats. Note that we don't include the source name, as that
// is implied as this object *is* the DataContainer. setData is called
// with just key/value pairs.
setData("Contents", m_data);
setData("Size", job->processedAmount(KJob::Bytes));
// Since we only create TransferJobs, it's safe to just static_cast here.
// In many real-world situations, this isn't the safest thing to do and a
// qobject_cast with a test on the result is often safer and cleaner.
KIO::TransferJob *tjob = static_cast<KIO::TransferJob *>(job);
setData("Error Page", tjob->isErrorPage());
setData("Mimetype", tjob->mimetype());
// Let DataContainer know we have data that needs storing
setNeedsToBeStored(true);
// Notify DataContainer that now is a good time to check to see that
// data has been updated. This will cause visualizations to be updated.
checkForUpdate();
// Clean up behind ourselves so there isn't unecessary memory usage
m_data.clear();
}
}
示例14: exchangeSession
/**
* upgrade session key to OAuth
*
* This method (or step) can be removed after June 2012 (a year after its
* implementation), since it is only a convenience method for those people
* who just upgraded and have an active session using the old authentication.
*/
void FbTalker::exchangeSession(const QString& sessionKey)
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
emit signalLoginProgress(1, 9, i18n("Upgrading to OAuth..."));
QMap<QString, QString> args;
args["client_id"] = m_appID;
args["client_secret"] = m_secretKey;
args["sessions"] = sessionKey;
QByteArray tmp(getCallString(args).toUtf8());
KIO::TransferJob* job = KIO::http_post(KUrl("https://graph.facebook.com/oauth/exchange_sessions"), tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = FB_EXCHANGESESSION;
m_job = job;
m_buffer.resize(0);
}
示例15: checkRegistrationCode
void ImageshackTalker::checkRegistrationCode()
{
if (m_job)
{
m_job->kill();
m_job = 0;
}
emit signalBusy(true);
emit signalLoginInProgress(2, 4, i18n("Checking the web server"));
QString args = "login=";
args.append(m_imageshack->registrationCode());
args.append("&xml=yes");
QByteArray tmp = args.toUtf8();
KIO::TransferJob* job = KIO::http_post(KUrl(m_loginApiUrl), tmp, KIO::HideProgressInfo);
job->addMetaData("UserAgent", m_userAgent);
job->addMetaData("content-type",
"Content-Type: application/x-www-form-urlencoded");
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(data(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = IMGHCK_CHECKREGCODE;
m_job = job;
m_buffer.resize(0);
}