void DownLoadFun::httpFinished() { httpBuff.clear(); httpBuff = reply->readAll(); if (!httpBuff.isEmpty()) emit httpData(m_id, httpBuff); reply->deleteLater(); reply = NULL; }
void StyleGetter::sltHtmlCopied( KJob *job ) { kDebug(); if ( job->error() ) { KMessageBox::detailedError( mParent, i18n( "Cannot get html file."), job->errorString() ); sender()->deleteLater(); return; } Q_EMIT sigGetStyleProgress( 50 ); QByteArray httpData( qobject_cast<KIO::StoredTransferJob*>( job )->data() ); QString href( mTempPost->permaLink().url() ); int filenameOffset = href.lastIndexOf( "/" ); href = href.remove( filenameOffset + 1, 255 ); QString base( "<base href=\""+href+"\"/>" ); QRegExp rxBase( "(<base\\shref=[^>]+>)" ); if ( rxBase.indexIn( httpData ) != -1 ) { httpData.replace( rxBase.cap( 1 ).toLatin1(), base.toLatin1() ); } else { int headOffset = httpData.indexOf( "<head>" ); httpData.insert( headOffset + 6, base.toLatin1() ); } QFile file( mCachePath + "style.html" ); // Q_ASSERT( dest.isValid() ); if ( file.exists() ) { file.remove(); } file.open( QIODevice::WriteOnly ); if ( file.write( httpData ) == -1 ) { KMessageBox::error( mParent, i18n( "Cannot write data to file %1", file.fileName() ) ); file.close(); return; } file.close(); Q_EMIT sigGetStyleProgress( 70 ); // Q_EMIT sigStyleFetched(); //Remove temp post from the server. connect( b, SIGNAL( sigPostRemoved( int, const BilboPost &) ), this, SLOT( sltTempPostRemoved( int, const BilboPost & ) ) ); b->removePost( *mTempPost ); }
void AddEditBlog::gotHtml(KJob *job) { if (!job) { return; } if (job->error()) { qCDebug(BLOGILO_LOG) << "Auto configuration failed! Error: " << job->errorString(); hideWaitWidget(); KMessageBox::sorry(this, i18n("Auto configuration failed. You have to set Blog API on Advanced tab manually.")); return; } QString httpData(QString::fromUtf8(static_cast<KIO::StoredTransferJob *>(job)->data())); job->deleteLater(); QRegExp rxGData(QStringLiteral("content='blogger' name='generator'")); if (rxGData.indexIn(httpData) != -1) { qCDebug(BLOGILO_LOG) << "content='blogger' name='generator' matched"; d->mFetchAPITimer->deleteLater(); d->ui.comboApi->setCurrentIndex(4); QRegExp rxBlogId(QStringLiteral("BlogID=(\\d+)")); d->ui.txtId->setText(rxBlogId.cap(1)); hideWaitWidget(); return; } QRegExp rxLiveJournal(QStringLiteral("rel=\"openid.server\" href=\"http://www.livejournal.com/openid/server.bml\"")); if (rxLiveJournal.indexIn(httpData) != -1) { qCDebug(BLOGILO_LOG) << " rel=\"openid.server\" href=\"http://www.livejournal.com/openid/server.bml\" matched"; d->mFetchAPITimer->deleteLater(); d->ui.comboApi->setCurrentIndex(0); d->ui.txtUrl->setText(QStringLiteral("http://www.liverjournal.com/interface/blogger/")); d->ui.txtId->setText(d->ui.txtUser->text()); hideWaitWidget(); return; } QString textUrl; QRegExp rxWordpress(QStringLiteral("name=\"generator\" content=\"WordPress")); if (rxWordpress.indexIn(httpData) != -1) { qCDebug(BLOGILO_LOG) << "name=\"generator\" content=\"WordPress matched"; d->mFetchAPITimer->deleteLater(); d->ui.comboApi->setCurrentIndex(3); textUrl = d->ui.txtUrl->text(); while (textUrl.endsWith(QLatin1Char('/'))) { textUrl.remove(textUrl.length() - 1, 1); } d->ui.txtUrl->setText(textUrl + QLatin1String("/xmlrpc.php")); fetchBlogId(); return; } // add MT for WordpressBuggy -> URL/xmlrpc.php exists textUrl = d->ui.txtUrl->text(); while (textUrl.endsWith(QLatin1Char('/'))) { textUrl.remove(textUrl.length() - 1, 1); } KIO::StoredTransferJob *testXmlRpcJob = KIO::storedGet(QUrl(QStringLiteral("%1/xmlrpc.php").arg(textUrl)), KIO::NoReload, KIO::HideProgressInfo); connect(testXmlRpcJob, &KIO::StoredTransferJob::result, this, &AddEditBlog::gotXmlRpcTest); }