Keep a single QNetworkAccessManager in qtclient

The ServerBrowser uses QNetworkAccessManager for HTTP requests.
Applications should use a single QNetworkAccessManager instance so
cookies and other state are shared between requests.

This patch moves QNetworkAccessManager out of ServerBrowser and gives it
a member variable in MainWindow.

The ConnectDialog and ServerBrowser constructors need to take the
QNetworkAccessManager as an argument.  This keeps the classes decoupled
and makes them easy to test or reusable.

Note that the comment in ServerBrowser about deleting reply objects is
outdated - we already connect the finish() signal to
reply->deleteLater(). It is safe to drop the comment, the reply object
will be freed.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Supress unused parameter warning

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Overload loadServerList for QString

This change make the slot accessible from QtScript.
Plain QtScript does not support QUrl type, and
It is easy for script to take string parameter.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Remove member used for temporary variable

Parameter was set to member and passed to slot.
That make class have a state, when loadServerList was called twice
before start completeDownloadServerList, they may get unexpected "reply"
instance. This change ensure the sender is the "reply" instance who invoked
the slot. ServerBrowser class will get close to a reentrant.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Add some debug code for ServerBrowser class

 * Catch QNetworkReply::error() signal
 * Q_ASSERT for what QNetworkReply state was assumed on that method

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Separate parse server list and tree item update

If server returned huge list, UI update may block main thread.
This change make parseServerList() method a little scalable,
It is a basic task in async program, that split big task into small pieces.

But not perfectly yet,
parse too long stream(or too long line) may intrerupt main thread.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Remove useless comment

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Rename ServerBrowser class private slots

Follow Qt's naming convertions.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
no-blocking ServerBrowser::parseServerList

Aavoid blocking when server list return huge invalid stream.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Parse safe for too long line

This change expects avoid the parsing phase become busy state
by reading unexpected data.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Use forward declare in ServerBrowser.h

Some of headers did not need to be included in the header file.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>
Fix include guard coding style

Missing suffix in a guard name, and comment on endif line.

No explicit guide about this project's coding style,
however this change follows almost all other files does.

Signed-off-by: Ikkei Shimomura (tea) <Ikkei.Shimomura@gmail.com>