summaryrefslogtreecommitdiff
path: root/client/Dialog.cpp
diff options
context:
space:
mode:
authorAlex Borisov <borisov.alexandr@rambler.ru>2011-12-12 03:57:23 +0200
committerAlex Borisov <borisov.alexandr@rambler.ru>2011-12-12 03:57:23 +0200
commitf77a7f9a1e282dba6e39f6b7f0685971cfac7747 (patch)
tree4053e95d95c3a34f6b0cdaa11c61b50de9bbf05f /client/Dialog.cpp
parent1ecb59ec27137a039a73289a3ded1f8dedcdab88 (diff)
Proxifier config parsing
Diffstat (limited to 'client/Dialog.cpp')
-rw-r--r--client/Dialog.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index 4ce48be..dfb280d 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -5,6 +5,7 @@
#include "client.h"
#include "UpdatedConfig.h"
#include "Dialog.h"
+#include "Proxifier.h"
#include "Proxy.h"
using namespace std;
@@ -12,7 +13,12 @@ using namespace std;
ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
{
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
-
+ Proxifier *proxifier = Proxifier::GetInstance();
+ if (!proxifier->IsValid())
+ {
+ Logger::Fatal("No valid proxifier configuration file found!\n");
+ }
+
/* generic proxy panel */
topLabel = new QLabel(QString::fromLocal8Bit(cfg->TopPanelText.c_str()));
topLabel->setObjectName("topLabel");
@@ -29,14 +35,14 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
countryBox->addItem(country);
}
countryBox->setCurrentIndex(-1);
-
+
connect(countryBox, SIGNAL(activated(int)),
this, SLOT(CountryActivated(int)));
connect(stateBox, SIGNAL(activated(int)),
this, SLOT(StateActivated(int)));
connect(cityBox, SIGNAL(activated(int)),
this, SLOT(CityActivated(int)));
-
+
topPanelLayout = new QGridLayout;
topPanelLayout->setSpacing(5);
topPanelLayout->addWidget(countryBox, 0, 0);
@@ -44,7 +50,7 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
topPanelLayout->addWidget(cityBox, 2, 0);
genericProxyGroup = new QButtonGroup;
staticProxyGroup = new QButtonGroup;
-
+
/* static proxy panel */
bottomLabel = new QLabel(QString::fromLocal8Bit(cfg->BottomPanelText.c_str()));
bottomLabel->setObjectName("bottomLabel");
@@ -89,7 +95,7 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
bottomPanelLayout->addWidget(btn, i, j);
}
}
-
+
/* setup layouting */
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(topLabel);
@@ -106,7 +112,7 @@ void ProxyDialog::StaticToggle(bool val)
void ProxyDialog::StaticClick()
{
- Logger::Debug("click\n");
+ Logger::Debug("click\n");
}
void ProxyDialog::CountryActivated(int index)
@@ -118,10 +124,10 @@ void ProxyDialog::CountryActivated(int index)
{
return;
}
-
+
string country(countryBox->currentText().toLocal8Bit().constData());
Logger::Info("Country %s was selected\n", country.c_str());
-
+
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
vector<string> states = cfg->GetStates(country);
if (states.empty())
@@ -160,11 +166,11 @@ void ProxyDialog::StateActivated(int index)
{
return;
}
-
+
string country(countryBox->currentText().toLocal8Bit().constData());
string state(stateBox->currentText().toLocal8Bit().constData());
Logger::Info("State %s was selected\n", state.c_str());
-
+
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
vector<string> cities = cfg->GetCities(country, state);
cityBox->clear();
@@ -185,9 +191,9 @@ void ProxyDialog::CityActivated(int index)
{
return;
}
-
+
vector<string> proxies;
- UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
+ UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
string country(countryBox->currentText().toLocal8Bit().constData());
string city(cityBox->currentText().toLocal8Bit().constData());
if (stateBox->isVisible())
@@ -199,7 +205,7 @@ void ProxyDialog::CityActivated(int index)
{
proxies = cfg->GetProxies(country, city);
}
-
+
/* delete existing buttons */
if (topPanelLayout->count() != 0)
{
@@ -210,7 +216,7 @@ void ProxyDialog::CityActivated(int index)
delete child->widget();
}
}
-
+
Logger::Trace("Adding new buttons\n");
for (unsigned i = 0; i < proxies.size(); i++)
{