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); }
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; }
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); }
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::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); }
/** * 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); }
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); }
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); }
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="******"&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); }
/** * 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); }
bool SmugTalker::addPhoto(const QString& imgPath, int albumID, const QString& caption) { if (m_job) { m_job->kill(); m_job = 0; } emit signalBusy(true); QString imgName = QFileInfo(imgPath).fileName(); // load temporary image to buffer QFile imgFile(imgPath); if (!imgFile.open(QIODevice::ReadOnly)) { emit signalBusy(false); return false; } long long imgSize = imgFile.size(); QByteArray imgData = imgFile.readAll(); imgFile.close(); KMD5 imgMD5(imgData); MPForm form; form.addPair("ByteCount", QString::number(imgSize)); form.addPair("MD5Sum", QString(imgMD5.hexDigest())); form.addPair("AlbumID", QString::number(albumID)); form.addPair("ResponseType", "REST"); if (!caption.isEmpty()) form.addPair("Caption", caption); if (!form.addFile(imgName, imgPath)) return false; form.finish(); QString customHdr; KUrl url("http://upload.smugmug.com/photos/xmladd.mg"); KIO::TransferJob *job = KIO::http_post(url, form.formData(), KIO::HideProgressInfo); job->addMetaData("content-type", form.contentType()); job->addMetaData("UserAgent", m_userAgent); customHdr += "X-Smug-SessionID: " + m_sessionID + "\r\n"; customHdr += "X-Smug-Version: " + m_apiVersion + "\r\n"; job->addMetaData("customHTTPHeader", customHdr); 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_ADDPHOTO; m_job = job; m_buffer.resize(0); return true; }
void GData::createComment( KBlog::BlogPost *post, KBlog::BlogComment *comment ) { kDebug(); if ( !comment ) { kError() << "comment is null pointer"; return; } if ( !post ) { kError() << "post is null pointer"; return; } Q_D( GData ); if ( !d->authenticate() ){ kError() << "Authentication failed."; emit errorComment( Atom, i18n( "Authentication failed." ), post, comment ); return; } QString atomMarkup = "<entry xmlns='http://www.w3.org/2005/Atom'>"; atomMarkup += "<title type=\"text\">" + comment->title() + "</title>"; atomMarkup += "<content type=\"html\">" + comment->content() + "</content>"; atomMarkup += "<author>"; atomMarkup += "<name>" + comment->name() + "</name>"; atomMarkup += "<email>" + comment->email() + "</email>"; atomMarkup += "</author></entry>"; QByteArray postData; kDebug() << postData; QDataStream stream( &postData, QIODevice::WriteOnly ); stream.writeRawData( atomMarkup.toUtf8(), atomMarkup.toUtf8().length() ); KIO::TransferJob *job = KIO::http_post( KUrl( "http://www.blogger.com/feeds/" + blogId() + "/" + post->postId() + "/comments/default" ), postData, KIO::HideProgressInfo ); d->mCreateCommentMap[ job ][post] = comment; if ( !job ) { kWarning() << "Unable to create KIO job for http://www.blogger.com/feeds/" << blogId() << "/" << post->postId() << "/comments/default"; } job->addMetaData( "content-type", "Content-Type: application/atom+xml; charset=utf-8" ); job->addMetaData( "ConnectTimeout", "50" ); job->addMetaData( "customHTTPHeader", "Authorization: GoogleLogin auth=" + d->mAuthenticationString ); job->addMetaData( "UserAgent", userAgent() ); connect( job, SIGNAL(data(KIO::Job*,const QByteArray&)), this, SLOT(slotCreateCommentData(KIO::Job*,const QByteArray&)) ); connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCreateComment(KJob*)) ); }
void KRun::slotStart() { // if ( !inherits( "KHTMLRun" ) ) // foundMimeType( "text/html" ); QString externalHandler = KProtocolManager::externalProtocolHandler( m_strURL.protocol() ); if ( !externalHandler.isEmpty() ) { if ( externalHandler.left( 1 ) == "@" ) { m_strURL = externalHandler.mid( 1 ) + m_strURL.url().mid( m_strURL.url().find( ':' ) + 1 ); } else { if ( externalHandler.left( 1 ) != "!" ) exec( externalHandler, m_strURL.url() ); emit error(); // stop the spinning wheel, err, the enabled stop button delete this; // pretend you don't see this :) return; } } KIO::TransferJob *job = 0; // eeeeek! if ( inherits( "KHTMLRun" ) ) { KHTMLRun *run = static_cast<KHTMLRun *>( this ); if ( run->urlArgs().postData.size() > 0 ) { job = KIO::http_post( m_strURL, run->urlArgs().postData, false ); job->addMetaData( "content-type", run->urlArgs().contentType() ); } else job = KIO::get( m_strURL, false, false ); job->addMetaData( run->urlArgs().metaData() ); } else job = KIO::get( m_strURL, false, true ); // ### connect( job, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotJobData( KIO::Job *, const QByteArray & ) ) ); connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotJobResult( KIO::Job * ) ) ); connect( job, SIGNAL( mimetype( KIO::Job *, const QString & ) ), this, SLOT( slotFoundMime( KIO::Job *, const QString & ) ) ); m_job = job; }
bool FbTalker::addPhoto(const QString& imgPath, const QString& albumID, const QString& caption) { kDebug() << "Adding photo " << imgPath << " to album with id " << albumID << " using caption '" << caption << "'"; if (m_job) { m_job->kill(); m_job = 0; } emit signalBusy(true); QMap<QString, QString> args; args["access_token"] = m_accessToken; args["name"] = KUrl(imgPath).fileName(); if (!albumID.isEmpty()) args["aid"] = albumID; if (!caption.isEmpty()) args["caption"] = caption; MPForm form; for (QMap<QString, QString>::const_iterator it = args.constBegin(); it != args.constEnd(); ++it) { form.addPair(it.key(), it.value()); } if (!form.addFile(args["name"], imgPath)) { emit signalBusy(false); return false; } form.finish(); kDebug() << "FORM: " << endl << form.formData(); KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"photos.upload"), form.formData(), KIO::HideProgressInfo); job->addMetaData("UserAgent", m_userAgent); job->addMetaData("content-type", form.contentType()); 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_ADDPHOTO; m_job = job; m_buffer.resize(0); return true; }
KIO::TransferJob *GroupDavGlobals::createDownloadJob( KPIM::GroupwareDataAdaptor *adaptor, const KURL &url, KPIM::FolderLister::ContentType /*ctype*/ ) { kdDebug()<<"GroupDavGlobals::createDownloadJob, url="<<url.url()<<endl; KIO::TransferJob *job = KIO::get( url, false, false ); if ( adaptor ) { QString mt = adaptor->mimeType(); job->addMetaData( "accept", mt ); } job->addMetaData( "PropagateHttpHeader", "true" ); return job; }
void KWebPage::downloadRequest(const QNetworkRequest& request) { KIO::TransferJob* job = KIO::get(request.url()); connect(job, SIGNAL(mimetype(KIO::Job*,QString)), this, SLOT(_k_receivedContentType(KIO::Job*,QString))); connect(job, SIGNAL(result(KJob*)), this, SLOT(_k_receivedContentTypeResult(KJob*))); job->setMetaData(request.attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap()); job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache. job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available. job->ui()->setWindow(d->windowWidget()); }
void SmugTalker::createAlbum(const SmugAlbum& album) { if (m_job) { m_job->kill(); m_job = 0; } emit signalBusy(true); KUrl url(m_apiURL); url.addQueryItem("method", "smugmug.albums.create"); url.addQueryItem("SessionID", m_sessionID); url.addQueryItem("Title", album.title); url.addQueryItem("CategoryID", QString::number(album.categoryID)); if (album.subCategoryID > 0) url.addQueryItem("SubCategoryID", QString::number(album.subCategoryID)); if (!album.description.isEmpty()) url.addQueryItem("Description", album.description); if (album.tmplID > 0) { // template will also define privacy settings url.addQueryItem("AlbumTemplateID", QString::number(album.tmplID)); } else { if (!album.password.isEmpty()) url.addQueryItem("Password", album.password); if (!album.passwordHint.isEmpty()) url.addQueryItem("PasswordHint", album.passwordHint); if (album.isPublic) url.addQueryItem("Public", "1"); else url.addQueryItem("Public", "0"); } 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_CREATEALBUM; m_job = job; m_buffer.resize(0); }
void FbTalker::createAlbum(const FbAlbum& album) { if (m_job) { m_job->kill(); m_job = 0; } emit signalBusy(true); QMap<QString, QString> args; args["access_token"] = m_accessToken; args["name"] = album.title; if (!album.location.isEmpty()) args["location"] = album.location; if (!album.description.isEmpty()) args["description"] = album.description; // TODO (Dirk): Wasn't that a requested feature in Bugzilla? switch (album.privacy) { case FB_FRIENDS: args["visible"] = "friends"; break; case FB_FRIENDS_OF_FRIENDS: args["visible"] = "friends-of-friends"; break; case FB_NETWORKS: args["visible"] = "networks"; break; case FB_EVERYONE: args["visible"] = "everyone"; break; } QByteArray tmp(getCallString(args).toUtf8()); KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"photos.createAlbum"), 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_CREATEALBUM; m_job = job; m_buffer.resize(0); }
KIO::TransferJob *GroupDavGlobals::createListItemsJob( const KURL &url ) { QDomDocument doc; QDomElement root = WebdavHandler::addDavElement( doc, doc, "propfind" ); QDomElement prop = WebdavHandler::addDavElement( doc, root, "prop" ); WebdavHandler::addDavElement( doc, prop, "getetag" ); // WebdavHandler::addDavElement( doc, prop, "getcontenttype" ); kdDebug(5800) << "props = "<< doc.toString() << endl; KIO::TransferJob *job = KIO::davPropFind( url, doc, "1", false ); if ( job ) { job->addMetaData( "accept", "text/xml" ); job->addMetaData( "customHTTPHeader", "accept-encoding: " ); } return job; }
void GData::removeComment( KBlog::BlogPost *post, KBlog::BlogComment *comment ) { kDebug(); Q_D( GData ); kDebug(); if ( !comment ) { kError() << "comment is null pointer"; return; } if ( !post ) { kError() << "post is null pointer"; return; } if ( !d->authenticate() ){ kError() << "Authentication failed."; emit errorComment( Atom, i18n( "Authentication failed." ), post, comment ); return; } QByteArray postData; KIO::TransferJob *job = KIO::http_post( KUrl( "http://www.blogger.com/feeds/" + blogId() + "/" + post->postId() + "/comments/default/" + comment->commentId() ), postData, KIO::HideProgressInfo ); d->mRemoveCommentMap[ job ][ post ] = comment; if ( !job ) { kWarning() << "Unable to create KIO job for http://www.blogger.com/feeds/" << blogId() << post->postId() << "/comments/default/" << comment->commentId(); } job->addMetaData( "ConnectTimeout", "50" ); job->addMetaData( "UserAgent", userAgent() ); job->addMetaData( "customHTTPHeader", "Authorization: GoogleLogin auth=" + d->mAuthenticationString + "\r\nX-HTTP-Method-Override: DELETE" ); connect( job, SIGNAL(data(KIO::Job*,const QByteArray&)), this, SLOT(slotRemoveCommentData(KIO::Job*,const QByteArray&)) ); connect( job, SIGNAL(result(KJob*)), this, SLOT(slotRemoveComment(KJob*)) ); }
void Resource::revokeAccess(const QString &id, const QString &name, const QString &password) { QUrl url = baseUrl; url.setPath(url.path() + "/authorizations/" + id); KIO::TransferJob *job = KIO::http_delete(url, KIO::HideProgressInfo); job->addMetaData("customHTTPHeader", "Authorization: Basic " + QString (name + ':' + password).toUtf8().toBase64()); /* And we don't care if it's successful ;) */ job->start(); }
KIO::TransferJob * Resource::getTransferJob(const QString &uri, const QString &token) const { QUrl url = baseUrl; url = url.adjusted(QUrl::StripTrailingSlash); url.setPath(url.path() + '/' + uri); KIO::TransferJob *job = KIO::get(url, KIO::Reload, KIO::HideProgressInfo); if (!token.isEmpty()) job->addMetaData("customHTTPHeader", "Authorization: token " + token); return job; }
void SmugTalker::login(const QString& email, const QString& password) { if (m_job) { m_job->kill(); m_job = 0; } emit signalBusy(true); emit signalLoginProgress(1, 4, i18n("Logging in to SmugMug service...")); KUrl url(m_apiURL); if (email.isEmpty()) { url.addQueryItem("method", "smugmug.login.anonymously"); url.addQueryItem("APIKey", m_apiKey); } else { url.addQueryItem("method", "smugmug.login.withPassword"); url.addQueryItem("APIKey", m_apiKey); url.addQueryItem("EmailAddress", email); url.addQueryItem("Password", password); } 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_LOGIN; m_job = job; m_buffer.resize(0); m_user.email = email; }
bool ImgurTalker::imageRemove(const QString& delete_hash) { // @TODO : make sure it works MPForm form; KUrl removeUrl = KUrl("http://api.imgur.com/2/delete/"); removeUrl.addPath(delete_hash + ".json"); form.finish(); KIO::TransferJob* job = KIO::http_post(removeUrl, form.formData(), KIO::HideProgressInfo); job->addMetaData("content-type", form.contentType()); job->addMetaData("UserAgent", m_userAgent); m_state = IE_REMOVEPHOTO; emit signalBusy(true); return true; }
KIO::Job* HTTPSubmit::createJob(const CDInfo& cdInfo) { KIO::TransferJob* job = KIO::http_post(url_, diskData_.utf8(), false); job->addMetaData("content-type", "Content-Type: text/plain"); QString header; header += "Content-Type: text/plain\n"; header += "Category: " + cdInfo.category + "\n"; header += "Discid: " + cdInfo.id + "\n"; header += "User-Email: " + from_ + "\n"; // Change to test for testing header += "Submit-Mode: submit\n"; header += "Charset: UTF-8"; job->addMetaData("customHTTPHeader", header); return job; }
void Transport::query( const QString &xml ) { mData.truncate( 0 ); QByteArray postData; QDataStream stream( &postData, QIODevice::WriteOnly ); stream.writeRawData( xml.toUtf8(), xml.toUtf8().length() ); KIO::TransferJob* job = KIO::http_post( KUrl( mUrl ), postData, KIO::HideProgressInfo ); if ( !job ) { kWarning() <<"Unable to create KIO job for" << mUrl; return; } job->addMetaData( "UserAgent", "KDE Kung" ); job->addMetaData( "content-type", "Content-Type: application/xml; charset=utf-8" ); connect( job, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) ); connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotResult( KJob* ) ) ); }
void FbTalker::getUserInfo(const QString& userIDs) { if (m_job) { m_job->kill(); m_job = 0; } if (userIDs.isEmpty()) { emit signalBusy(true); emit signalLoginProgress(6); } QMap<QString, QString> args; args["access_token"] = m_accessToken; if (userIDs.isEmpty()) args["uids"] = QString::number(m_user.id); else args["uids"] = userIDs; args["fields"] = "name,profile_url"; QByteArray tmp(getCallString(args).toUtf8()); KIO::TransferJob* job = KIO::http_post(KUrl(m_apiURL,"users.getInfo"), 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*))); if (userIDs.isEmpty()) m_state = FB_GETUSERINFO; else m_state = FB_GETUSERINFO_FRIENDS; m_job = job; m_buffer.resize(0); }
void KSVGLoader::postUrl(::KURL url, const QByteArray &data, const QString &mimeType, KJS::ExecState *exec, KJS::Object &callBackFunction, KJS::Object &status) { KIO::TransferJob *job = KIO::http_post(url, data, false); job->addMetaData("content-type", mimeType); m_postUrlData.job = job; m_postUrlData.exec = exec; m_postUrlData.status = &status; m_postUrlData.callBackFunction = &callBackFunction; connect(job, SIGNAL(result(KIO::Job *)), SLOT(slotResult(KIO::Job *))); }
void FlickrTalker::addPhotoToPhotoSet(const QString& photoId, const QString& photoSetId) { if (m_job) { m_job->kill(); m_job = 0; } kDebug() << "addPhotoToPhotoSet invoked"; KUrl url(m_apiUrl); /* If the photoset id starts with the special string "UNDEFINED_", it means * it doesn't exist yet on Flickr and needs to be created. Note that it's * not necessary to subsequently add the photo to the photo set, as this * is done in the set creation call to Flickr. */ if (photoSetId.startsWith(QLatin1String("UNDEFINED_"))) { createPhotoSet("", m_selectedPhotoSet.title, m_selectedPhotoSet.description, photoId); } else { url.addQueryItem("auth_token", m_token); url.addQueryItem("photoset_id", photoSetId); url.addQueryItem("api_key", m_apikey); url.addQueryItem("method", "flickr.photosets.addPhoto"); url.addQueryItem("photo_id", photoId); QString md5 = getApiSig(m_secret, url); url.addQueryItem("api_sig", md5); QByteArray tmp; kDebug() << "Add photo to Photo set url: " << url; KIO::TransferJob* job = KIO::http_post(url, tmp, KIO::HideProgressInfo); 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 = FE_ADDPHOTOTOPHOTOSET; m_job = job; m_buffer.resize(0); emit signalBusy(true); } }
void PicasaModel::query(const QString &username, const QString &request) { if (username.isEmpty()) { m_flag = false; return; } // if we require photos from an album, we have to split request to // obtain the albumid; ex: photo/32323232432 if (request.contains("/")) { ; m_albumid = request.split('/').last(); m_request = request.split('/').first(); } else { m_request = request; } QString searchString = username; QString url = "http://picasaweb.google.com/data/feed/api/user/" + username; if (m_request.contains("photo")) { url.append("/albumid/" + m_albumid); } //url.append("?kind=" + m_request); KUrl query(url); KIO::TransferJob *job = KIO::get(query, KIO::NoReload, KIO::HideProgressInfo); if (!m_token.isEmpty()) { m_flag = true; QString auth_string = "GoogleLogin auth=" + m_token; job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded"); job->addMetaData("customHTTPHeader", "Authorization: " + auth_string); } m_queries[job] = username; connect (job, SIGNAL(data(KIO::Job*,QByteArray)), this, SLOT(picasaDataReady(KIO::Job*,QByteArray))); connect (job, SIGNAL(result(KJob*)), this, SLOT(parseResults(KJob*))); }