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>
|
638
|
21 |
#include <QDebug>
|
625
|
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 |
QString request = QString("protocol_version=%1")
|
|
37 |
.arg(*cProtoVer);
|
|
38 |
http->post("/games/list_games", request.toUtf8());
|
|
39 |
|
|
40 |
serversList->clear();
|
|
41 |
}
|
|
42 |
|
|
43 |
void HWNetWwwWidget::onClientRead(int id, bool error)
|
|
44 |
{
|
|
45 |
if (error)
|
|
46 |
{
|
638
|
47 |
qDebug() << "Error" << http->errorString();
|
625
|
48 |
return;
|
|
49 |
}
|
638
|
50 |
serversList->clear();
|
625
|
51 |
serversList->addItem(http->readAll());
|
|
52 |
}
|