|
@@ -72,6 +72,7 @@ void MyNetworkAccessManager::allow(QString path) {
|
|
|
}
|
|
|
|
|
|
QNetworkReply * MyNetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData) {
|
|
|
+ emit debug(QString("Creating request: ") + req.url().toString());
|
|
|
|
|
|
if (disposed)
|
|
|
{
|
|
@@ -156,16 +157,16 @@ QList<QNetworkProxy> MyNetworkProxyFactory::queryProxy (const QNetworkProxyQuery
|
|
|
MyQWebPage::MyQWebPage(ResourceObject & res): resource(res) {}
|
|
|
|
|
|
void MyQWebPage::javaScriptAlert(QWebFrame *, const QString & msg) {
|
|
|
- resource.warning(QString("Javascript alert: %1").arg(msg));
|
|
|
+ resource.info(QString("Javascript alert: %1").arg(msg));
|
|
|
}
|
|
|
|
|
|
bool MyQWebPage::javaScriptConfirm(QWebFrame *, const QString & msg) {
|
|
|
- resource.warning(QString("Javascript confirm: %1 (answered yes)").arg(msg));
|
|
|
+ resource.info(QString("Javascript confirm: %1 (answered yes)").arg(msg));
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool MyQWebPage::javaScriptPrompt(QWebFrame *, const QString & msg, const QString & defaultValue, QString * result) {
|
|
|
- resource.warning(QString("Javascript prompt: %1 (answered %2)").arg(msg,defaultValue));
|
|
|
+ resource.info(QString("Javascript prompt: %1 (answered %2)").arg(msg,defaultValue));
|
|
|
result = (QString*)&defaultValue;
|
|
|
Q_UNUSED(result);
|
|
|
return true;
|
|
@@ -173,7 +174,7 @@ bool MyQWebPage::javaScriptPrompt(QWebFrame *, const QString & msg, const QStrin
|
|
|
|
|
|
void MyQWebPage::javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID) {
|
|
|
if (resource.settings.debugJavascript)
|
|
|
- resource.warning(QString("%1:%2 %3").arg(sourceID).arg(lineNumber).arg(message));
|
|
|
+ resource.info(QString("%1:%2 %3").arg(sourceID).arg(lineNumber).arg(message));
|
|
|
}
|
|
|
|
|
|
bool MyQWebPage::shouldInterruptJavaScript() {
|
|
@@ -181,6 +182,7 @@ bool MyQWebPage::shouldInterruptJavaScript() {
|
|
|
resource.warning("A slow script was stopped");
|
|
|
return true;
|
|
|
}
|
|
|
+ resource.debug("A slow script has been detected, but was not stopped");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -194,6 +196,7 @@ ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, con
|
|
|
url(u),
|
|
|
loginTry(0),
|
|
|
progress(0),
|
|
|
+ windowStatusCounter(0),
|
|
|
finished(false),
|
|
|
signalPrint(false),
|
|
|
multiPageLoader(mpl),
|
|
@@ -221,6 +224,12 @@ ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, con
|
|
|
connect(&networkAccessManager, SIGNAL(finished (QNetworkReply *)),
|
|
|
this, SLOT(amfinished (QNetworkReply *) ) );
|
|
|
|
|
|
+ connect(&networkAccessManager, SIGNAL(debug(const QString &)),
|
|
|
+ this, SLOT(debug(const QString &)));
|
|
|
+
|
|
|
+ connect(&networkAccessManager, SIGNAL(info(const QString &)),
|
|
|
+ this, SLOT(info(const QString &)));
|
|
|
+
|
|
|
connect(&networkAccessManager, SIGNAL(warning(const QString &)),
|
|
|
this, SLOT(warning(const QString &)));
|
|
|
|
|
@@ -265,6 +274,7 @@ ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, con
|
|
|
* Once loading starting, this is called
|
|
|
*/
|
|
|
void ResourceObject::loadStarted() {
|
|
|
+ debug("QWebPage load started.");
|
|
|
if (finished == true) {
|
|
|
++multiPageLoader.loading;
|
|
|
finished = false;
|
|
@@ -296,6 +306,8 @@ void ResourceObject::loadProgress(int p) {
|
|
|
|
|
|
|
|
|
void ResourceObject::loadFinished(bool ok) {
|
|
|
+ debug("QWebPage load finished.");
|
|
|
+
|
|
|
// If we are finished, this might be a potential bug.
|
|
|
if (finished || multiPageLoader.resources.size() <= 0) {
|
|
|
warning("A finished ResourceObject received a loading finished signal. "
|
|
@@ -330,10 +342,16 @@ void ResourceObject::loadFinished(bool ok) {
|
|
|
|
|
|
void ResourceObject::waitWindowStatus() {
|
|
|
QString windowStatus = webPage.mainFrame()->evaluateJavaScript("window.status").toString();
|
|
|
- //warning(QString("window.status:" + windowStatus + " settings.windowStatus:" + settings.windowStatus));
|
|
|
if (windowStatus != settings.windowStatus) {
|
|
|
+ // This is once a second
|
|
|
+ if ((++windowStatusCounter % 20) == 0) {
|
|
|
+ windowStatusCounter = 0;
|
|
|
+ debug(QString("Waiting for window.status; Found: \"" + windowStatus + "\", but expecting: \"" + settings.windowStatus + "\"."));
|
|
|
+ }
|
|
|
+
|
|
|
QTimer::singleShot(50, this, SLOT(waitWindowStatus()));
|
|
|
} else {
|
|
|
+ debug("Window status \"" + settings.windowStatus + "\" found.");
|
|
|
QTimer::singleShot(settings.jsdelay, this, SLOT(loadDone()));
|
|
|
}
|
|
|
}
|
|
@@ -347,6 +365,8 @@ void ResourceObject::loadDone() {
|
|
|
if (finished) return;
|
|
|
finished=true;
|
|
|
|
|
|
+ debug("Loading done; Stopping QWebPage and any possible page refreshes.");
|
|
|
+
|
|
|
// Ensure no more loading goes..
|
|
|
webPage.triggerAction(QWebPage::Stop);
|
|
|
webPage.triggerAction(QWebPage::StopScheduledPageRefresh);
|
|
@@ -384,6 +404,14 @@ void ResourceObject::handleAuthenticationRequired(QNetworkReply *reply, QAuthent
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ResourceObject::debug(const QString & str) {
|
|
|
+ emit multiPageLoader.outer.debug(str);
|
|
|
+}
|
|
|
+
|
|
|
+void ResourceObject::info(const QString & str) {
|
|
|
+ emit multiPageLoader.outer.info(str);
|
|
|
+}
|
|
|
+
|
|
|
void ResourceObject::warning(const QString & str) {
|
|
|
emit multiPageLoader.outer.warning(str);
|
|
|
}
|
|
@@ -397,6 +425,8 @@ void ResourceObject::error(const QString & str) {
|
|
|
* \param reply The networkreply that has finished
|
|
|
*/
|
|
|
void ResourceObject::amfinished(QNetworkReply * reply) {
|
|
|
+ debug(QString("Finished request: ") + reply->url().toString());
|
|
|
+
|
|
|
int networkStatus = reply->error();
|
|
|
int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
|
|
if ((networkStatus != 0 && networkStatus != 5) || (httpStatus > 399 && httpErrorCode == 0))
|
|
@@ -797,9 +827,21 @@ void MultiPageLoader::cancel() {
|
|
|
\brief Signal emitted when loading has started
|
|
|
*/
|
|
|
|
|
|
+/*!
|
|
|
+ \fn void MultiPageLoader::debug(QString text)
|
|
|
+ \brief Signal emitted when a debug message was generated
|
|
|
+ \param text The debug message
|
|
|
+*/
|
|
|
+
|
|
|
+/*!
|
|
|
+ \fn void MultiPageLoader::info(QString text)
|
|
|
+ \brief Signal emitted when an info message was generated
|
|
|
+ \param text The info message
|
|
|
+*/
|
|
|
+
|
|
|
/*!
|
|
|
\fn void MultiPageLoader::warning(QString text)
|
|
|
- \brief Signal emitted when a none fatal warning has occurred
|
|
|
+ \brief Signal emitted when a non fatal warning has occurred
|
|
|
\param text A string describing the warning
|
|
|
*/
|
|
|
|