Version 0.3
[aspt.git] / configtab.cc
index 841dd04..64ee685 100755 (executable)
@@ -6,9 +6,12 @@ http://creativecommons.org/licenses/by-nc-nd/2.5/legalcode
 
 #include "configtab.h"
 
+/**
+ * \brief Config Tab constructor.
+ */
 ConfigTab::ConfigTab(QWidget *parent): QWidget(parent) {
        file = 0;
-       http = new QHttp;
+       http = new QHttp("https://www.soccerproject.com/sptd.php", QHttp::ConnectionModeHttps, 443);
        QSettings settings("config/global.ini", QSettings::IniFormat);
        langToSave = settings.value("lang", 0).toInt();
        useProxy = settings.value("Network/proxyUsed", 0).toInt();
@@ -76,6 +79,9 @@ ConfigTab::ConfigTab(QWidget *parent): QWidget(parent) {
        setLayout(mainLayout);
 }
 
+/**
+ * \brief Config Tab destructor.
+ */
 ConfigTab::~ConfigTab() {
        if(file) delete file;
        delete http;
@@ -100,23 +106,35 @@ ConfigTab::~ConfigTab() {
        delete mainLayout;
 }
 
+/**
+ * \brief Slot assigned to language change action.
+ * \param langId language ID.
+ */
 void ConfigTab::changeLang(int langId) {
        langToSave = langId;
 }
 
+/**
+ * \brief Slot assigned to proxy settings opening action.
+ */
 void ConfigTab::openProxy() {
        proxyWin = new ProxySet();
 }
 
+/**
+ * \brief Slot assigned to save button click.
+ */
 void ConfigTab::saveSettings() {
-       const char* langs[5] = {"en", "cs", "ro", "pl", "lt"};
+       const char* langs[] = {"en", "cs", "ro", "pl", "lt"};
+       const unsigned langSize = sizeof(langs) / sizeof(char *);
        QSettings settings("config/global.ini", QSettings::IniFormat);
-       if(langs) {
-               settings.setValue("lang", langs[langToSave]);
-               settings.sync();
-       }
+       settings.setValue("lang", langs[langToSave % langSize]);
+       settings.sync();
 }
 
+/**
+ * \brief Slot assigned to download button click.
+ */
 void ConfigTab::downloadLatest() {
        QSettings settings("config/global.ini", QSettings::IniFormat);
        useProxy = settings.value("Network/proxyUsed", 0).toInt();
@@ -124,16 +142,19 @@ void ConfigTab::downloadLatest() {
        msgbox->setText("downloading...");
        file = new QFile("data/data_"+num+".xml");
        file->open(QIODevice::WriteOnly);
-       QUrl url("http://www.soccerproject.com/sptd.php");
-       int p_port = settings.value("Network/proxyPort", 80).toInt();
+       QUrl url("https://www.soccerproject.com/sptd.php");
+       int p_port = settings.value("Network/proxyPort", 443).toInt();
        if(useProxy) http->setProxy(settings.value("Network/proxyAddr", "").toString(), p_port, settings.value("Network/proxyName", "").toString(), settings.value("Network/proxyPass", "").toString());
-       http->setHost(url.host(), 80);
+       http->setHost(url.host(), QHttp::ConnectionModeHttps, 443);
        //QTextStream out(stdout); out << "log";
        httpId = http->get(url.path() + "?login=" + QUrl::toPercentEncoding(nick->text()) + "&pw=" + QUrl::toPercentEncoding(pass->text()) + "&sptdid=8&sptdpw=Cerm12", file);
        settings.setValue("username", nick->text());
        settings.sync();
 }
 
+/**
+ * \brief Slot assigned to download finished action.
+ */
 void ConfigTab::httpRequestFinished(int requestId, bool error) {
        if (requestId != httpId) return;
 
@@ -171,6 +192,10 @@ void ConfigTab::httpRequestFinished(int requestId, bool error) {
        file = 0;
 }
 
+/**
+ * \brief Slot assigned to QHttp response action.
+ * \param responseHeader QHttp response.
+ */
 void ConfigTab::readResponseHeader(const QHttpResponseHeader &responseHeader) {
        if (responseHeader.statusCode() != 200) {
                QMessageBox::information(this, tr("HTTP"), tr("Download failed: %1.").arg(responseHeader.reasonPhrase()));
@@ -179,6 +204,10 @@ void ConfigTab::readResponseHeader(const QHttpResponseHeader &responseHeader) {
        }
 }
 
+/**
+ * \brief Slot assigned to errMsgBox signal.
+ * \param text text to show.
+ */
 void ConfigTab::showMsgBox(const QString &text) {
        msgbox->clear();
        msgbox->setText(text);