63 #include "pageoptions.h" |
63 #include "pageoptions.h" |
64 #include "pageeditteam.h" |
64 #include "pageeditteam.h" |
65 #include "pagemultiplayer.h" |
65 #include "pagemultiplayer.h" |
66 #include "pagenet.h" |
66 #include "pagenet.h" |
67 #include "pagemain.h" |
67 #include "pagemain.h" |
|
68 #include "pagefeedback.h" |
68 #include "pagenetserver.h" |
69 #include "pagenetserver.h" |
69 #include "pagedrawmap.h" |
70 #include "pagedrawmap.h" |
70 #include "pagenettype.h" |
71 #include "pagenettype.h" |
71 #include "pagegamestats.h" |
72 #include "pagegamestats.h" |
72 #include "pageplayrecord.h" |
73 #include "pageplayrecord.h" |
168 connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
170 connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
169 pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER); |
171 pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER); |
170 |
172 |
171 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
173 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
172 pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); |
174 pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); |
|
175 |
|
176 connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
|
177 pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK); |
173 |
178 |
174 connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
179 connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
175 pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); |
180 pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); |
176 |
181 |
177 connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
182 connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
180 connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
185 connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
181 pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); |
186 pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); |
182 |
187 |
183 //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
188 //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
184 //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
189 //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
|
190 |
|
191 connect(ui.pageFeedback->BtnSend, SIGNAL(clicked()), this, SLOT(SendFeedback())); |
185 |
192 |
186 connect(ui.pageEditTeam, SIGNAL(teamEdited()), this, SLOT(AfterTeamEdit())); |
193 connect(ui.pageEditTeam, SIGNAL(teamEdited()), this, SLOT(AfterTeamEdit())); |
187 |
194 |
188 connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
195 connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
189 connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
196 connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
1552 } |
1559 } |
1553 } while(!fileName.isEmpty() && !ok); |
1560 } while(!fileName.isEmpty() && !ok); |
1554 } |
1561 } |
1555 } |
1562 } |
1556 |
1563 |
|
1564 void HWForm::SendFeedback() |
|
1565 { |
|
1566 //Create Xml representation of google code issue first |
|
1567 if (!CreateIssueXml()) |
|
1568 { |
|
1569 QMessageBox::warning(this, QMessageBox::tr("Fields required"), |
|
1570 QMessageBox::tr("Please fill out all fields")); |
|
1571 return; |
|
1572 } |
|
1573 |
|
1574 //Google login using fake account (feedback.hedgewars@gmail.com) |
|
1575 nam = new QNetworkAccessManager(this); |
|
1576 connect(nam, SIGNAL(finished(QNetworkReply*)), |
|
1577 this, SLOT(finishedSlot(QNetworkReply*))); |
|
1578 |
|
1579 QUrl url(string(string("https://www.google.com/accounts/ClientLogin?" |
|
1580 "accountType=GOOGLE&Email=feedback.hedgewars@gmail.com&Passwd=hwfeedback&service=code&source=HedgewarsFoundation-Hedgewars-") |
|
1581 + (cVersionString?(*cVersionString):QString("")).toStdString()).c_str()); |
|
1582 nam->get(QNetworkRequest(url)); |
|
1583 |
|
1584 } |
|
1585 |
|
1586 bool HWForm::CreateIssueXml() |
|
1587 { |
|
1588 QString summary = ui.pageFeedback->summary->text(); |
|
1589 QString description = ui.pageFeedback->description->toPlainText(); |
|
1590 |
|
1591 //Check if all necessary information is entered |
|
1592 if (summary.isEmpty() || description.isEmpty()) |
|
1593 return false; |
|
1594 |
|
1595 issueXml = |
|
1596 "<?xml version='1.0' encoding='UTF-8'?>" |
|
1597 "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:issues='http://code.google.com/p/hedgewars/issues/list'>" |
|
1598 "<title>"; |
|
1599 issueXml.append(summary); |
|
1600 issueXml.append("</title><content type='html'>"); |
|
1601 issueXml.append(description); |
|
1602 issueXml.append("</content><author><name>feedback.hedgewars</name></author></entry>"); |
|
1603 |
|
1604 return true; |
|
1605 } |
|
1606 |
|
1607 void HWForm::finishedSlot(QNetworkReply* reply) |
|
1608 { |
|
1609 if (reply && reply->error() == QNetworkReply::NoError) |
|
1610 { |
|
1611 QByteArray array = reply->readAll(); |
|
1612 QString str(array); |
|
1613 |
|
1614 if (authToken.length() != 0) |
|
1615 { |
|
1616 QMessageBox::information(this, QMessageBox::tr("Success"), |
|
1617 QMessageBox::tr("Successfully posted the issue on code.google.com!")); |
|
1618 ui.pageFeedback->summary->clear(); |
|
1619 ui.pageFeedback->description->clear(); |
|
1620 authToken = ""; |
|
1621 return; |
|
1622 } |
|
1623 |
|
1624 if(!getAuthToken(str)) |
|
1625 { |
|
1626 QMessageBox::warning(this, QMessageBox::tr("Network"), |
|
1627 QMessageBox::tr("Error during authentication with www.google.com")); |
|
1628 return; |
|
1629 } |
|
1630 |
|
1631 QByteArray body(issueXml.toStdString().c_str()); |
|
1632 QNetworkRequest header(QUrl("https://code.google.com/feeds/issues/p/hedgewars/issues/full")); |
|
1633 header.setRawHeader("Content-Length", QString::number(issueXml.length()).toAscii()); |
|
1634 header.setRawHeader("Content-Type", "application/atom+xml"); |
|
1635 header.setRawHeader("Authorization", string( |
|
1636 string("GoogleLogin auth=") + authToken.toStdString()).c_str()); |
|
1637 nam->post(header, body); |
|
1638 |
|
1639 } |
|
1640 else if (authToken.length() == 0) |
|
1641 QMessageBox::warning(this, QMessageBox::tr("Network"), |
|
1642 QMessageBox::tr("Error during authentication with www.google.com")); |
|
1643 else |
|
1644 { |
|
1645 QMessageBox::warning(this, QMessageBox::tr("Network"), |
|
1646 QMessageBox::tr("Error creating the issue")); |
|
1647 authToken = ""; |
|
1648 } |
|
1649 |
|
1650 } |
|
1651 |
|
1652 bool HWForm::getAuthToken(QString str) |
|
1653 { |
|
1654 QRegExp ex("Auth=(.+)"); |
|
1655 |
|
1656 if (-1 == ex.indexIn(str)) |
|
1657 return false; |
|
1658 |
|
1659 authToken = ex.cap(1); |
|
1660 authToken.remove(QChar('\n')); |
|
1661 |
|
1662 return true; |
|
1663 } |
|
1664 |
|
1665 |
|
1666 |