summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Borisov <borisov.alexandr@rambler.ru>2011-11-17 00:06:16 +0200
committerAlex Borisov <borisov.alexandr@rambler.ru>2011-11-17 00:06:16 +0200
commitb068f321dd9c6077c590473c4f108be87e7eb99d (patch)
treea24853f71981773b2a3051c2a32beea5c9c7dc59
parent5861309ceb8474cf0cdb4d29b2e3a0e76518a9aa (diff)
Return to server config w permanent connection. Update message
-rw-r--r--client/Dialog.cpp1
-rw-r--r--client/ProxyClientApp.cpp14
-rw-r--r--client/ProxyClientApp.h1
-rw-r--r--client/SslClient.cpp10
-rw-r--r--client/UpdatedConfig.cpp28
-rw-r--r--client/UpdatedConfig.h6
6 files changed, 38 insertions, 22 deletions
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index c8336f6..40f1a1c 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -12,7 +12,6 @@ using namespace std;
ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
{
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
- cfg->AcquireConfig();
/* generic proxy panel */
topLabel = new QLabel(QString::fromLocal8Bit(cfg->TopPanelText.c_str()));
diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp
index 653d201..e132d53 100644
--- a/client/ProxyClientApp.cpp
+++ b/client/ProxyClientApp.cpp
@@ -12,6 +12,8 @@ ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv
{
/* initiates UpdatedConfig singleton that start sending configuration requests */
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
+ connect(cfg, SIGNAL(updated()),
+ this, SLOT(configUpdated()));
if (!QSystemTrayIcon::isSystemTrayAvailable())
{
@@ -80,6 +82,18 @@ void ProxyClientApp::showProxyDialog()
dialog->show();
}
+void ProxyClientApp::configUpdated()
+{
+ UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
+ QString msg = QString::fromLocal8Bit(cfg->ConfigLoadedMsg.c_str());
+ QMessageBox updatedMsg;
+ updatedMsg.setText(msg);
+ updatedMsg.setWindowTitle("Information");
+ updatedMsg.setStandardButtons(QMessageBox::Ok);
+ updatedMsg.setIcon(QMessageBox::Information);
+ updatedMsg.exec();
+}
+
void ProxyClientApp::quitApp()
{
Logger::Info("Terminating\n");
diff --git a/client/ProxyClientApp.h b/client/ProxyClientApp.h
index c75b7b9..83c7c31 100644
--- a/client/ProxyClientApp.h
+++ b/client/ProxyClientApp.h
@@ -15,6 +15,7 @@ public:
private slots:
void trayActivated(QSystemTrayIcon::ActivationReason reason);
void showProxyDialog();
+ void configUpdated();
void quitApp();
private:
QSystemTrayIcon *trayIcon;
diff --git a/client/SslClient.cpp b/client/SslClient.cpp
index c04667b..25165d2 100644
--- a/client/SslClient.cpp
+++ b/client/SslClient.cpp
@@ -109,10 +109,6 @@ void SslClient::Connected()
void SslClient::Disconnected()
{
Logger::Info("Disconnected from server %s\n", server.toStdString().c_str());
-
-#ifdef DEBUG
- SendRequest(StaticProxyList);
-#endif
}
void SslClient::DataRecieved()
@@ -157,12 +153,6 @@ void SslClient::DataRecieved()
/* remove header and tail */
data.remove(0, 3);
data.remove(length-1, 3);
-
-#ifdef DEBUG
- Logger::Debug("Disconnecting from server\n");
- sslSocket.disconnectFromHost();
-#endif
-
emit ReplyRecieved(type, data);
}
diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp
index a08d417..1bae8a2 100644
--- a/client/UpdatedConfig.cpp
+++ b/client/UpdatedConfig.cpp
@@ -54,20 +54,19 @@ void UpdatedConfig::update()
retryFailed = false;
}
- /*if (! (updateStatus & SslClient::Config))
+ if (! (updateStatus & (1 << SslClient::Config)))
{
client->SendRequest(SslClient::Config);
}
- else*/
- if (! (updateStatus & SslClient::GenericProxyList))
+ if (! (updateStatus & (1 << SslClient::GenericProxyList)))
{
client->SendRequest(SslClient::GenericProxyList);
}
- else if (! (updateStatus & SslClient::StaticProxyList))
+ else if (! (updateStatus & (1 << SslClient::StaticProxyList)))
{
client->SendRequest(SslClient::StaticProxyList);
}
- else if (! (updateStatus & SslClient::FirewallList))
+ else if (! (updateStatus & (1 << SslClient::FirewallList)))
{
client->SendRequest(SslClient::FirewallList);
}
@@ -99,6 +98,8 @@ void UpdatedConfig::gotServerReply(SslClient::RequestType &type, QByteArray &con
goto end;
}
+ //Logger::Debug("data: %s\n", confdata.constData());
+
/* stop timer - working server found */
configUpdateTimer->stop();
@@ -106,19 +107,19 @@ void UpdatedConfig::gotServerReply(SslClient::RequestType &type, QByteArray &con
{
case SslClient::Config:
ParseConfig(confdata.constData());
- updateStatus |= type;
+ updateStatus |= (1 << type);
break;
case SslClient::GenericProxyList:
ParseGenericProxies(confdata.constData());
- updateStatus |= type;
+ updateStatus |= (1 << type);
break;
case SslClient::StaticProxyList:
ParseStaticPorxies(confdata.constData());
- updateStatus |= type;
+ updateStatus |= (1 << type);
break;
case SslClient::FirewallList:
ParseFirewalls(confdata.constData());
- updateStatus |= type;
+ updateStatus |= (1 << type);
break;
default:
Logger::Warn("Unknown reply type: %x\n", type);
@@ -126,9 +127,14 @@ void UpdatedConfig::gotServerReply(SslClient::RequestType &type, QByteArray &con
}
end:
- if ((updateStatus & 0x0F) != 0x0F)
+ if (updateStatus != 0x1E)
{
- Logger::Trace("Still need to update other config parts\n");
+ Logger::Trace("Still need to update other config parts. Update status: %x\n", updateStatus);
update();
}
+ else
+ {
+ Logger::Info("Config successfully updated!\n");
+ emit updated();
+ }
} \ No newline at end of file
diff --git a/client/UpdatedConfig.h b/client/UpdatedConfig.h
index 041fc45..bc58ca5 100644
--- a/client/UpdatedConfig.h
+++ b/client/UpdatedConfig.h
@@ -25,6 +25,12 @@ public:
* @return Pointer to singleton instance of Config class
*/
static UpdatedConfig *CurrentConfig();
+
+signals:
+ /**
+ * @brief Signal is emitted when client configuration is updated
+ */
+ void updated();
private:
/**
* @brief creates an instance and tries to connect to servers from config.cfg<br/>