PDA

View Full Version : QWebview fails to load page css on windows xp



marwyn
16th August 2011, 17:11
Hi.
I am currently trying to create a twitter sharing window in my application.
So I use the twitter api to get an url with an authentication token from twitter and load it in my QWebview.

The url looks like this: https://api.twitter.com/oauth/authorize?oauth_token=lBnVmsAjkxhRmqKcloK21ot74A5V cGYylSipkWiFkc&lang=fr

There is no problem at all in windows 7, but in windows XP, the webview does not seem to load the web page's css...

So the result is very ugly (see attached images...)

Any idea to make this work ? Or any hint on why this does not work ?

marwyn
17th August 2011, 14:31
bump.......

marwyn
23rd August 2011, 16:54
Still no one ?
Any idea ?

budda
24th August 2011, 06:09
Never had problems running css through a QWebview on Windows XP after compiling it on a windows 7 platform. I've look through some older programs and the one I am certain ran fine on windows xp didn't have the below code for enabling plugins. Flash embeds are nice with QWebview. But maybe adding this would help? I do believe the the JavaEnabled setting is currently still not supported, but I keep it with this block in the hope that it will be.

Your problem might be how you are running the application on the XP computer. Is Qt installed on both machines, or just the Windows 7? If it isn't on the XP computer, and you have all the seemingly required .dll files, you might not have the imageformat/ directory with the .dll's for images... (qgif4.dll, qjpeg4.dll, ...... ) they are not considered crucial to running the program, but no pictures will work in a QWebView, QGraphicsView, or what not.... they are located in your Qt program installation in the bin folder, then in the imageformats folder. And the folder has to be in the directory you are running the application from.



QWebSettings *defaultSettings = QWebSettings::globalSettings();
defaultSettings->setAttribute(QWebSettings::JavaEnabled, true);
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);


Hope this helps

marwyn
24th August 2011, 09:19
I did some more testing.
If I use a facebook login page on the same computer and in the same way, it loads without any problem, with all the graphics.

I also wiresharked what is exactly going on the network. It seems that the QWebview does not try to get any external ressources for this page (don't download images, css files, etc). It seems to only get the html content of the page and voila... tries to load it.

I seriously don't understand what is going on with this page... :confused:

budda
24th August 2011, 15:36
do you have the QtWebKit4.dll and QtXmlPatterns.dll? if it's not getting the external resources maybe that is the problem. Or when you created the project did you put the webkit in?

wysota
24th August 2011, 17:01
I did some more testing.
If I use a facebook login page on the same computer and in the same way, it loads without any problem, with all the graphics.

I also wiresharked what is exactly going on the network. It seems that the QWebview does not try to get any external ressources for this page (don't download images, css files, etc). It seems to only get the html content of the page and voila... tries to load it.

I seriously don't understand what is going on with this page... :confused:

Is the response sent by the server identical in both cases -- when it works and when it doesn't?

marwyn
24th August 2011, 17:39
When trying to load the twitter login page in the webview on windows seven, I see a lot of connections going through the network, reaching the page's ressources.
When i do the same thing on windows XP, i get only a few tcp connections, typically retrieving the page content without anything else...

One more test : when loading the Facebook login page in teh webView on windows XP, the network traffic is OK : loading images, css, etc

It seems there is no request sent at all when it fails... It just does not try to get the ressources...

wysota
24th August 2011, 18:04
I'm asking whether the response from the server that contains the main webpage is identical, forget the resources for now.

marwyn
25th August 2011, 09:14
The response from the server containing the main page looks similar. SLL handshake, blabla, several client / server HELLOs, getting the main page data. It's encrypted so i can't say if the content it gets is actually the same in both cases.

Then it gets the IP address of si0.twimg.com (containing the images, css etc according to the source code of the page). handshakes, blabla, HELLOs... And then, it gets data from this server for the one working, and not for the other.

That's as far as I got for now...

wysota
25th August 2011, 10:59
Similar and identical are two different things. I'm asking whether it is byte-by-byte equal. Without knowing that you can only guess what is wrong.

marwyn
25th August 2011, 12:54
it is not byte to byte equal.
But as it is encrypted, i don't think this is really relevant... a different salt on the same content will produce different encrypted data...

wysota
25th August 2011, 23:00
it is not byte to byte equal.
But as it is encrypted, i don't think this is really relevant... a different salt on the same content will produce different encrypted data...

I mean the decrypted data, obviously.

marwyn
26th August 2011, 09:35
I obviously can't access it...
I can't sniff it, i can't BP in it because i'm not in debug mode, and I can't put logs into QWebview to see what is going on...

Have to guess what is wrong I'm afraid

wysota
26th August 2011, 09:37
Why can't you access it? Decrypt it before it reacher the browser, I'm sure there are proxies available that do this kind of man-in-the-middle attack. Besides, you have access to QWebView's network access manager, and you'll have the data already decrypted there.

marwyn
26th August 2011, 10:12
Trying to access data from the QNetworkAccessManager. I'll keep you informed when I have results

marwyn
26th August 2011, 14:24
OK PROBLEM SOLVED ! :)

This was a problem of ssl connection.
My guess : facebook gets its ressources from an address in facebook.com domain where twitter gets it from twimg.com domain. And there must be some problems in certificates specific to windows XP with this domain (authority not trusted i think).

Workaround:



void
MyQWebview::load( const QUrl & url )
{
connect( this->page()->networkAccessManager(), SIGNAL( sslErrors( QNetworkReply*, const QList<QSslError> & ) ), this, SLOT( sslErrorHandler( QNetworkReply*, const QList<QSslError> & ) ) );
this->QWebView::load( url );
}

void
MyQWebView::sslErrorHandler( QNetworkReply *reply, const QList<QSslError> &errors )
{
reply->ignoreSslErrors( errors );
}


This allows the webview to load the page even if there is some ssl handshake errors

Thanks Wysota for ur help ;)

Regards,
Márwyn