void LoadPage::gotResponse() { qDebug() << "LoadPage::gotResponse"; QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); if (reply->error() == QNetworkReply::NoError) { int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); qDebug() << "LoadPage::gotResponse: status:" << status; QString r_url; switch (status) { case 301: case 302: case 307: r_url = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl().toString(); qDebug() << "LoadPage::gotResponse: redirected:" << r_url; fetchPage(r_url); break; default: qDebug() << "LoadPage::gotResponse: emit pageLoaded"; emit pageLoaded(reply->readAll()); } } else { qDebug() << "LoadPage::gotResponse: error:" << reply->error() << ":" << reply->errorString(); emit errorOcurred((int)reply->error(), reply->errorString()); } reply->deleteLater(); }
void Browser::loadFinished(bool ok) { QUrl current_url(page->currentFrame()->baseUrl()); // events trottling if (current_url == this->last_url) { qDebug() << this << QString("%1, loadFinished trottled.").arg(QDateTime::currentDateTime().toTime_t()); return; } this->last_url = current_url; qDebug() << this << QString("%1, '%2', %3 ms.").arg(QDateTime::currentDateTime().toTime_t()).arg(current_url.toString()).arg(page_load_time.elapsed()); if (!ok) { emit(errorHappened(page_load_time.elapsed(), page->currentFrame()->baseUrl())); restartTest(QString("its not ok, something wrong happened! (possibly 500) URL: %1").arg(page->currentFrame()->baseUrl().toString())); return; } QWebElement document= page->currentFrame()->documentElement(); if (page->currentFrame()->baseUrl().host() != base_url.host()) { restartTest("We've got outside the test site. Restarting."); return; } QWebElementCollection collection = document.findAll("a[href]"); QWebElement link; QString link_href; if (collection.count() == 0) { restartTest("No links found on page. Restarting."); return; } // Ignoring javascript and empty links do { link = collection.at(qrand()%collection.count()); link_href = link.attribute("href"); } while ((link_href.count() == 0) || (link_href.at(0) == '#') || (link_href.contains("javascript:;"))); emit(pageLoaded(page_load_time.elapsed(), page->currentFrame()->baseUrl())); link.evaluateJavaScript("var evObj = document.createEvent('MouseEvents');evObj.initEvent( 'click', true, true );this.dispatchEvent(evObj);"); page_load_time.start(); timeout_countdown->start(); }
KonqSideBarWebModule::KonqSideBarWebModule(TDEInstance *instance, TQObject *parent, TQWidget *widgetParent, TQString &desktopName, const char* name) : KonqSidebarPlugin(instance, parent, widgetParent, desktopName, name) { _htmlPart = new TDEHTMLSideBar(universalMode()); connect(_htmlPart, TQT_SIGNAL(reload()), this, TQT_SLOT(reload())); connect(_htmlPart, TQT_SIGNAL(completed()), this, TQT_SLOT(pageLoaded())); connect(_htmlPart, TQT_SIGNAL(setWindowCaption(const TQString&)), this, TQT_SLOT(setTitle(const TQString&))); connect(_htmlPart, TQT_SIGNAL(openURLRequest(const TQString&, KParts::URLArgs)), this, TQT_SLOT(urlClicked(const TQString&, KParts::URLArgs))); connect(_htmlPart->browserExtension(), TQT_SIGNAL(openURLRequest(const KURL&, const KParts::URLArgs&)), this, TQT_SLOT(formClicked(const KURL&, const KParts::URLArgs&))); connect(_htmlPart, TQT_SIGNAL(setAutoReload()), this, TQT_SLOT( setAutoReload() )); connect(_htmlPart, TQT_SIGNAL(openURLNewWindow(const TQString&, KParts::URLArgs)), this, TQT_SLOT(urlNewWindow(const TQString&, KParts::URLArgs))); connect(_htmlPart, TQT_SIGNAL(submitFormRequest(const char*,const TQString&,const TQByteArray&,const TQString&,const TQString&,const TQString&)), this, TQT_SIGNAL(submitFormRequest(const char*,const TQString&,const TQByteArray&,const TQString&,const TQString&,const TQString&))); _desktopName = desktopName; KSimpleConfig ksc(_desktopName); ksc.setGroup("Desktop Entry"); reloadTimeout = ksc.readNumEntry("Reload", 0); _url = ksc.readPathEntry("URL"); _htmlPart->openURL(_url ); // Must load this delayed TQTimer::singleShot(0, this, TQT_SLOT(loadFavicon())); }
void CHelpWidget::loadPage(const QString &title, const QString &filePath) { dDebug() << "Loading: "+filePath; /* QFile file(filePath); QFileInfo finfo(file); if ( finfo.exists() && !finfo.isDir() && file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QTextStream ts(&file); QString document = ""; while( ! ts.atEnd() ) { document += ts.readLine(); } file.close(); if ( document != "" )*/ emit pageLoaded(title, filePath); // } }
KonqSideBarWebModule::KonqSideBarWebModule(const KComponentData &componentData, QWidget *parent, const KConfigGroup& configGroup) : KonqSidebarModule(componentData, parent, configGroup) { _htmlPart = new KHTMLSideBar(); _htmlPart->setAutoDeletePart(false); connect(_htmlPart, SIGNAL(reload()), this, SLOT(reload())); connect(_htmlPart, SIGNAL(completed()), this, SLOT(pageLoaded())); connect(_htmlPart, SIGNAL(setWindowCaption(QString)), this, SLOT(setTitle(QString))); connect(_htmlPart, SIGNAL(openUrlRequest(QString,KParts::OpenUrlArguments,KParts::BrowserArguments)), this, SLOT(urlClicked(QString,KParts::OpenUrlArguments,KParts::BrowserArguments))); connect(_htmlPart->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), this, SLOT(formClicked(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) ); connect(_htmlPart, SIGNAL(setAutoReload()), this, SLOT(setAutoReload())); connect(_htmlPart, SIGNAL(openUrlNewWindow(QString,KParts::OpenUrlArguments,KParts::BrowserArguments,KParts::WindowArgs)), this, SLOT(urlNewWindow(QString,KParts::OpenUrlArguments,KParts::BrowserArguments,KParts::WindowArgs))); connect(_htmlPart, SIGNAL(submitFormRequest(const char*,QString,QByteArray,QString,QString,QString)), this, SIGNAL(submitFormRequest(const char*,QString,QByteArray,QString,QString,QString))); reloadTimeout = configGroup.readEntry("Reload", 0); _url = configGroup.readPathEntry("URL", QString()); _htmlPart->openUrl(_url ); // Must load this delayed QTimer::singleShot(0, this, SLOT(loadFavicon())); }