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); }
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); }
QImage ImageLoader::loadImage(const QUrl &url, bool *ok, bool selectPictureSize) { QImage image; if (url.isEmpty()) { return image; } (*ok) = false; if (url.isLocalFile()) { if (image.load(url.toLocalFile())) { (*ok) = true; } } else { QByteArray imageData; KIO::TransferJob *job = KIO::get(url, KIO::NoReload); QObject::connect(job, &KIO::TransferJob::data, [&imageData](KIO::Job *, const QByteArray & data) { imageData.append(data); }); if (job->exec()) { if (image.loadFromData(imageData)) { (*ok) = true; } } } if (!(*ok)) { // image does not exist (any more) KMessageBox::sorry(mParent, i18n("This contact's image cannot be found.")); return image; } if (selectPictureSize) { QPixmap pixmap = QPixmap::fromImage(image); image = KPixmapRegionSelectorDialog::getSelectedImage(pixmap, 1, 1, mParent); if (image.isNull()) { (*ok) = false; return image; } } if (image.height() > 720 || image.width() > 720) { if (image.height() > image.width()) { image = image.scaledToHeight(720); } else { image = image.scaledToWidth(720); } } (*ok) = true; return image; }
QString ManPageDocumentation::getManPageContent() { KIO::TransferJob * transferJob = KIO::get(m_url, KIO::NoReload, KIO::HideProgressInfo); connect( transferJob, SIGNAL(data(KIO::Job*,QByteArray)), this, SLOT(readDataFromManPage(KIO::Job*,QByteArray)) ); if (transferJob->exec()){ return m_manPageBuffer; } else { return i18n("Could not find any documentation for '%1'", m_name); } }