summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAlex <b0ris@b0ris-satellite.(none)>2011-11-01 02:49:07 +0200
committerAlex <b0ris@b0ris-satellite.(none)>2011-11-01 02:49:07 +0200
commit103a6a013b6e6df1d1dbbcd073fc9a931fa4cf0a (patch)
treec2e99d49e43fd6661e8568f8aac54b1445d7e9a8 /client
parenta6e060642537eadc3785a19f2b6daac0f63c5179 (diff)
Fix generic proxy parsing bug. New generic proxy button layouting. Static proxy button functionality
Diffstat (limited to 'client')
-rw-r--r--client/Config.cpp24
-rw-r--r--client/Config.h19
-rw-r--r--client/Dialog.cpp78
-rw-r--r--client/Dialog.h10
-rw-r--r--client/client.pro6
-rw-r--r--client/config/proxy_list.cfg9
-rw-r--r--client/config/static_proxy_list.cfg12
7 files changed, 117 insertions, 41 deletions
diff --git a/client/Config.cpp b/client/Config.cpp
index 614d95f..7fef568 100644
--- a/client/Config.cpp
+++ b/client/Config.cpp
@@ -114,6 +114,28 @@ vector<string> Config::GetProxies(string &country, string &state, string &city)
return proxies;
}
+vector<ProxyEntryStatic> Config::GetStaticProxyGuiLine(int line)
+{
+ vector<ProxyEntryStatic> staticProxyLine;
+ for (unsigned i = 0; i < staticProxy.size(); i++)
+ {
+ if (staticProxy[i].position == line)
+ staticProxyLine.push_back(staticProxy[i]);
+ }
+ return staticProxyLine;
+}
+
+unsigned Config::GetStaticProxyGuiLines()
+{
+ int maxLine = 0;
+ for (unsigned i = 0; i < staticProxy.size(); i++)
+ {
+ if (staticProxy[i].position > maxLine)
+ maxLine = staticProxy[i].position;
+ }
+ return maxLine;
+}
+
int Config::ReadGenericProxy()
{
Logger::Info("Parsing generic proxy list\n");
@@ -130,6 +152,7 @@ int Config::ReadGenericProxy()
while (!proxyFile.eof())
{
proxyFile.getline(str, str_size, ';');
+ proxyFile.ignore(2, '\n');
if (proxyFile.eof())
break;
string entry = str;
@@ -157,6 +180,7 @@ int Config::ReadStaticProxy()
while (!proxyFile.eof())
{
proxyFile.getline(str, str_size, ';');
+ proxyFile.ignore(2, '\n');
if (proxyFile.eof())
break;
string entry = str;
diff --git a/client/Config.h b/client/Config.h
index 9d9e9eb..868c859 100644
--- a/client/Config.h
+++ b/client/Config.h
@@ -68,22 +68,37 @@ public:
*/
std::vector<std::string> GetCities(std::string &country, std::string &state);
- /*
+ /**
* @brief Get list of proxy server addresses in particular country and city (without states)<br/>
* (generic proxy records only)
* @param country name of country to get list of proxies for
* @param city name of city to get list of proxies for
+ * @return Alphabetically sorted vector<string> with unique proxy names
*/
std::vector<std::string> GetProxies(std::string &country, std::string &city);
- /*
+ /**
* @brief Get list of proxy server addresses in particular country, state and city<br/>
* (generic proxy records only)
* @param country name of country to get list of proxies for
* @param state name of state to get list of proxies for
* @param city name of city to get list of proxies for
+ * @return Alphabetically sorted vector<string> with unique proxy names
*/
std::vector<std::string> GetProxies(std::string &country, std::string &state, std::string &city);
+
+ /**
+ * @brief Get list of static proxy entries
+ * @param line number of GUI line proxy list associated with
+ * @return List of static proxy entries in order as they appear in config file
+ */
+ std::vector<ProxyEntryStatic> GetStaticProxyGuiLine(int line);
+
+ /**
+ * @brief Get number of static proxy GUI lines
+ * @return number of static proxy GUI lines or 0 if none
+ */
+ unsigned GetStaticProxyGuiLines();
protected:
Config();
private:
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index 03b9db7..63a3c63 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -1,6 +1,7 @@
#include <QtGui>
#include <iostream>
+#include <typeinfo>
#include "client.h"
#include "Config.h"
#include "Dialog.h"
@@ -19,14 +20,14 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
Logger::Fatal("No valid configuration found! Can't proceed.");
return ;
}
-
- topLabel = new QLabel(tr("Top Panel"));
+
+ /* generic proxy panel */
+ topLabel = new QLabel("Top Panel");
countryBox = new QComboBox;
stateBox = new QComboBox;
stateBox->setVisible(false);
cityBox = new QComboBox;
cityBox->setVisible(false);
-
vector<string> countries = cfg->GetCountries();
for (unsigned i = 0; i < countries.size(); i++)
{
@@ -42,39 +43,43 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
connect(cityBox, SIGNAL(activated(int)),
this, SLOT(CityActivated(int)));
- /* proxy buttons */
- QPushButton *topProxy1 = new QPushButton("proxy 1");
- QPushButton *topProxy2 = new QPushButton("proxy 2");
-
- QPushButton *bottomProxy1 = new QPushButton("proxy 3");
- QPushButton *bottomProxy2 = new QPushButton("proxy 4");
+ topPanelLayout = new QGridLayout;
+ topPanelLayout->setSpacing(5);
+ topPanelLayout->addWidget(countryBox, 0, 0);
+ topPanelLayout->addWidget(stateBox, 1, 0);
+ topPanelLayout->addWidget(cityBox, 2, 0);
+ genericProxyGroup = new QButtonGroup;
+ /* static proxy panel */
bottomLabel = new QLabel(tr("Bottom Panel"));
+ QGridLayout *bottomPanelLayout = new QGridLayout;
+ unsigned nlines = cfg->GetStaticProxyGuiLines();
+ for (unsigned i = 0; i < nlines; i++)
+ {
+ vector<ProxyEntryStatic> staticProxyLine = cfg->GetStaticProxyGuiLine(i+1);
+ for (unsigned j = 0; j < staticProxyLine.size(); j++)
+ {
+ //char speed[8];
+ //sprintf(speed, "%d", staticProxyLine[j].speed);
+ //QLabel *speedLabel = new QLabel(speed);
+ QString btnStr = QString::fromUtf8(staticProxyLine[j]. name.c_str());
+ //QLabel *btnLabel = new QLabel(btnStr);
+ //QHBoxLayout *btnLayout = new QHBoxLayout;
+ //btnLayout->addWidget(speedLabel);
+ //btnLayout->addWidget(btnLabel);
+ QPushButton *btn = new QPushButton(btnStr);
+ //btn->setLayout(btnLayout);
+ btn->setCheckable(true);
+ bottomPanelLayout->addWidget(btn, i, j);
+ }
+ }
/* setup layouting */
- QVBoxLayout *comboBoxLayout = new QVBoxLayout;
- comboBoxLayout->addWidget(countryBox);
- comboBoxLayout->addWidget(stateBox);
- comboBoxLayout->addWidget(cityBox);
-
- QVBoxLayout *proxyButtonLayout = new QVBoxLayout;
- proxyButtonLayout->addWidget(topProxy1);
- proxyButtonLayout->addWidget(topProxy2);
-
- QHBoxLayout *topPanelLayout = new QHBoxLayout;
- topPanelLayout->addLayout(comboBoxLayout);
- topPanelLayout->addLayout(proxyButtonLayout);
-
- QHBoxLayout *bottomPanelLayout = new QHBoxLayout;
- bottomPanelLayout->addWidget(bottomProxy1);
- bottomPanelLayout->addWidget(bottomProxy2);
-
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(topLabel);
mainLayout->addLayout(topPanelLayout);
mainLayout->addWidget(bottomLabel);
mainLayout->addLayout(bottomPanelLayout);
-
setLayout(mainLayout);
}
@@ -169,5 +174,24 @@ void ProxyDialog::CityActivated(int index)
proxies = cfg->GetProxies(country, city);
}
+ /* delete existing buttons */
+ if (topPanelLayout->count() != 0)
+ {
+ Logger::Trace("Going to delete existing buttons\n");
+ QLayoutItem *child;
+ while ((child = topPanelLayout->takeAt(3)) != 0)
+ {
+ delete child->widget();
+ }
+ }
+ Logger::Trace("Adding new buttons\n");
+ for (unsigned i = 0; i < proxies.size(); i++)
+ {
+ QString btnStr = QString::fromUtf8(proxies[i].c_str());
+ QPushButton *btn = new QPushButton(btnStr);
+ btn->setCheckable(true);
+ genericProxyGroup->addButton(btn);
+ topPanelLayout->addWidget(btn, i / 3, i % 3 + 1);
+ }
}
diff --git a/client/Dialog.h b/client/Dialog.h
index 1b66b55..7155673 100644
--- a/client/Dialog.h
+++ b/client/Dialog.h
@@ -5,9 +5,10 @@
#include <QDialog>
#include <vector>
+class QButtonGroup;
class QComboBox;
+class QGridLayout;
class QLabel;
-class QVBoxLayout;
class ProxyEntryGeneric;
class ProxyEntryStatic;
@@ -24,11 +25,14 @@ private slots:
void CityActivated(int index);
private:
- QLabel *topLabel;
- QLabel *bottomLabel;
+ QButtonGroup *genericProxyGroup;
+ QButtonGroup *staticProxyGroup;
QComboBox *countryBox;
QComboBox *stateBox;
QComboBox *cityBox;
+ QGridLayout *topPanelLayout;
+ QLabel *topLabel;
+ QLabel *bottomLabel;
};
#endif \ No newline at end of file
diff --git a/client/client.pro b/client/client.pro
index 4a6bcdc..189f75d 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -2,7 +2,11 @@
# Automatically generated by qmake (2.01a) Wed Oct 19 03:05:59 2011
######################################################################
-QMAKE_CXXFLAGS= -DDEBUG -g -ggdb
+QMAKE_CXXFLAGS=-O0
+QMAKE_CXXFLAGS_DEBUG += -DDEBUG -g3 -ggdb -O0
+
+CONFIG -= release
+CONFIG += debug console
TEMPLATE = app
TARGET =
diff --git a/client/config/proxy_list.cfg b/client/config/proxy_list.cfg
index c4ec480..ded8164 100644
--- a/client/config/proxy_list.cfg
+++ b/client/config/proxy_list.cfg
@@ -7,9 +7,16 @@ user:password@server.com:123 "Украина" "Сумская обл." "Коно
user:password@server.com:123 "Украина" "Сумская обл." "Середина-Буда";
user:password@server.com:123 "Украина" "АР Крым" "Алушта";
user:password@server.com:123 "Украина" "АР Крым" "Симферополь";
+sss.chaoslab.ru:3412 "Украина" "АР Крым" "Симферополь";
+simferopol.ua:222 "Украина" "АР Крым" "Симферополь";
+b0ris.net:123 "Украина" "АР Крым" "Симферополь";
+home.b0ris.net:123 "Украина" "АР Крым" "Симферополь";
+b0ris.net:123 "Украина" "АР Крым" "Симферополь";
+b0ris.net:123 "Украина" "АР Крым" "Симферополь";
+b0ris.net:123 "Украина" "АР Крым" "Симферополь";
user:password@server.com:123 "Украина" "АР Крым" "Севастополь";
user:password@server.com:123 "Украина" "АР Крым" "Евпатория";
-server.com:123 "Украина" "АР Крым" "Керч";
+server.com:123 "Украина" "АР Крым" "Керчь";
user:password@server.com:123 "Украина" "АР Крым" "Ялта";
user:password@server.com:123 "Украина" "АР Крым" "Судак";
server.net:213 "Russia" "-" "Moscow";
diff --git a/client/config/static_proxy_list.cfg b/client/config/static_proxy_list.cfg
index 1cd2488..c618922 100644
--- a/client/config/static_proxy_list.cfg
+++ b/client/config/static_proxy_list.cfg
@@ -1,7 +1,5 @@
-asdsad:qweqwe@qweqwe.de:3204 "label" 1 17;
-sdfsdf:234 "asdd" 2 35;
-user:password@server.com:123 "Ukraine 1" 1 14;
-server.com:123 "Ukraine 2" 3 54;
-user:password@server.com:123 "Ukraine 3" 3 137;
-user:password@server.com:123 "Russia 1" 1 95;
-user:password@server.com:123 "Russia 2" 2 26; \ No newline at end of file
+192.168.222.1:10001 "Российский сервер No1" 1 34;
+192.168.222.1:10002 "Российский сервер No2" 1 132;
+192.168.222.1:10003 "Украинский сервер No1" 2 12;
+login:password@192.168.222.1:10004 "Украинский сервер No2" 2 45;
+