625
|
1 |
/*
|
|
2 |
* Hedgewars, a worms-like game
|
|
3 |
* Copyright (c) 2007 Andrey Korotaev <unC0Rr@gmail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; version 2 of the License
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <QHttp>
|
|
20 |
#include <QListWidget>
|
|
21 |
#include <QMessageBox>
|
|
22 |
|
|
23 |
#include "netwwwwidget.h"
|
|
24 |
#include "hwconsts.h"
|
|
25 |
|
|
26 |
HWNetWwwWidget::HWNetWwwWidget(QWidget* parent) :
|
634
|
27 |
HWNetServersWidget(parent)
|
625
|
28 |
{
|
|
29 |
http = new QHttp(this);
|
|
30 |
http->setHost("www.hedgewars.org", 80);
|
|
31 |
connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(onClientRead(int, bool)));
|
|
32 |
}
|
635
|
33 |
|
625
|
34 |
void HWNetWwwWidget::updateList()
|
|
35 |
{
|
|
36 |
http->abort();
|
635
|
37 |
|
625
|
38 |
QString request = QString("protocol_version=%1")
|
|
39 |
.arg(*cProtoVer);
|
|
40 |
http->post("/games/list_games", request.toUtf8());
|
|
41 |
|
|
42 |
serversList->clear();
|
|
43 |
}
|
|
44 |
|
|
45 |
void HWNetWwwWidget::onClientRead(int id, bool error)
|
|
46 |
{
|
|
47 |
if (error)
|
|
48 |
{
|
|
49 |
QMessageBox::critical(this, tr("Error"), http->errorString());
|
|
50 |
return;
|
|
51 |
}
|
|
52 |
serversList->addItem(http->readAll());
|
|
53 |
}
|