equal
deleted
inserted
replaced
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 */ |
17 */ |
18 |
18 |
19 #include <QHttp> |
19 #include <QHttp> |
20 #include <QListWidget> |
20 #include <QListWidget> |
21 #include <QMessageBox> |
21 #include <QDebug> |
22 |
22 |
23 #include "netwwwwidget.h" |
23 #include "netwwwwidget.h" |
24 #include "hwconsts.h" |
24 #include "hwconsts.h" |
25 |
25 |
26 HWNetWwwWidget::HWNetWwwWidget(QWidget* parent) : |
26 HWNetWwwWidget::HWNetWwwWidget(QWidget* parent) : |
31 connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(onClientRead(int, bool))); |
31 connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(onClientRead(int, bool))); |
32 } |
32 } |
33 |
33 |
34 void HWNetWwwWidget::updateList() |
34 void HWNetWwwWidget::updateList() |
35 { |
35 { |
36 http->abort(); |
|
37 |
|
38 QString request = QString("protocol_version=%1") |
36 QString request = QString("protocol_version=%1") |
39 .arg(*cProtoVer); |
37 .arg(*cProtoVer); |
40 http->post("/games/list_games", request.toUtf8()); |
38 http->post("/games/list_games", request.toUtf8()); |
41 |
39 |
42 serversList->clear(); |
40 serversList->clear(); |
44 |
42 |
45 void HWNetWwwWidget::onClientRead(int id, bool error) |
43 void HWNetWwwWidget::onClientRead(int id, bool error) |
46 { |
44 { |
47 if (error) |
45 if (error) |
48 { |
46 { |
49 QMessageBox::critical(this, tr("Error"), http->errorString()); |
47 qDebug() << "Error" << http->errorString(); |
50 return; |
48 return; |
51 } |
49 } |
|
50 serversList->clear(); |
52 serversList->addItem(http->readAll()); |
51 serversList->addItem(http->readAll()); |
53 } |
52 } |