summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <b0ris@b0ris-satellite.(none)>2012-03-05 00:35:20 +0200
committerunknown <b0ris@b0ris-satellite.(none)>2012-03-05 00:35:20 +0200
commit0b04a9542db946e9fb94780aee24869e463ceaa2 (patch)
tree476a9a6049474e354e1645b836dae4d8f4ed71a9 /client
parentd46b59919581ace366930f45390aeb20409ccebe (diff)
Reload proxifier config functionality. Remove message about config update
Diffstat (limited to 'client')
-rw-r--r--client/Dialog.cpp2
-rw-r--r--client/Proxifier.cpp114
-rw-r--r--client/Proxifier.h10
-rw-r--r--client/ProxyClientApp.cpp6
4 files changed, 58 insertions, 74 deletions
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index de421dd..87d61bd 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -135,7 +135,7 @@ void ProxyDialog::Closed(int i)
Logger::Error("No valid proxifier configuration file found!\n");
return; // do not restart if no config found
}
- if (!proxifier->Restart())
+ if (!proxifier->ReloadConfig())
{
Logger::Error("Unable to restart Proxifier process!\n");
}
diff --git a/client/Proxifier.cpp b/client/Proxifier.cpp
index 0d3005d..c80657f 100644
--- a/client/Proxifier.cpp
+++ b/client/Proxifier.cpp
@@ -118,76 +118,58 @@ Proxifier::Proxifier(): valid(false)
ReadConfig();
}
-bool Proxifier::Restart()
+bool Proxifier::ReloadConfig()
{
- Logger::Info("Restarting Proxifier process\n");
-
#ifdef WIN32
- char execName[] = "Proxifier.exe";
- HANDLE hProcessSnap;
- HANDLE hProcess;
- PROCESSENTRY32 pe32;
+ char execName[] = "Proxifier.exe";
+ QString program;
+ QStringList args;
- // Takes a snapshot of all the processes
- hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if (hProcessSnap == INVALID_HANDLE_VALUE)
- {
- return false;
- }
-
- // interate snapshot and find all process to be killed
- pe32.dwSize = sizeof(PROCESSENTRY32);
- if (!Process32First(hProcessSnap, &pe32))
- {
- CloseHandle(hProcessSnap);
- return false;
- }
- do
- {
- QString procName = QString::fromWCharArray(pe32.szExeFile);
- if (QString::compare(procName, QString::fromLocal8Bit(execName)) == 0)
- {
- Logger::Trace("Killing Proxifier process\n");
- hProcess = OpenProcess(PROCESS_TERMINATE, 0, pe32.th32ProcessID);
- TerminateProcess(hProcess, 0);
- CloseHandle(hProcess);
- }
- }
- while (Process32Next(hProcessSnap, &pe32));
-
- // find Proxifier's executable and start over again
- UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
- if (! cfg->ProxifierExeFile.empty())
- {
- QString program = QString::fromLocal8Bit(cfg->ProxifierExeFile.c_str());
- QFileInfo filePathInfo(program);
- if (filePathInfo.exists())
- {
- Logger::Trace("Starting process: %s\n", program.toStdString().c_str());
- return QProcess::startDetached(program);
- }
- }
-
- QString folderName = "Proxifier";
- QString pathSlash = "\\";
- TCHAR programFiles[MAX_PATH];
- if (SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, programFiles) != S_FALSE)
- {
- // check in %ProgramFiles(x86)%
- char *str = wstrdup(programFiles);
- QString program = str;
- program += pathSlash + folderName + pathSlash + execName;
- program.prepend("\"");
- program.append("\"");
- QFileInfo filePathInfo(program);
- if (filePathInfo.exists())
- {
- Logger::Trace("Starting process: %s\n", program.toStdString().c_str());
- return QProcess::startDetached(program);
- }
- }
+ UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
+ if (! cfg->ProxifierExeFile.empty())
+ {
+ program = QString::fromLocal8Bit(cfg->ProxifierExeFile.c_str());
+ QFileInfo filePathInfo(program);
+ if (! filePathInfo.exists())
+ {
+ return false;
+ }
+ }
+ else
+ {
+ //try to find Proxifier.exe on my own
+ QString folderName = "Proxifier";
+ QString pathSlash = "\\";
+ TCHAR programFiles[MAX_PATH];
+ if (SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, programFiles) == S_FALSE)
+ {
+ return false;
+ }
+
+ // check in %ProgramFiles(x86)%
+ char *str = wstrdup(programFiles);
+ program = str;
+ program += pathSlash + folderName + pathSlash + execName;
+ program.prepend("\"");
+ program.append("\"");
+ QFileInfo filePathInfo(program);
+ if (filePathInfo.exists())
+ {
+ return false;
+ }
+ }
+
+ if (filePath.isEmpty())
+ {
+ return false;
+ }
+
+ Logger::Trace("Starting process: %s\n", program.toStdString().c_str());
+ args << filePath << "silent-load";
+ return QProcess::startDetached(program, args);
+#else
+ return false;
#endif
- return false;
}
bool Proxifier::IsValid()
diff --git a/client/Proxifier.h b/client/Proxifier.h
index 9d5b316..712e79c 100644
--- a/client/Proxifier.h
+++ b/client/Proxifier.h
@@ -30,11 +30,11 @@ public:
* @return pointer to Proxifier singleton
*/
static Proxifier* GetInstance();
- /**
- * @brief restart Proxifier.exe process
- * @return true on success or false otherwise
- */
- bool Restart();
+ /**
+ * @brief Reload Proxifier's profile
+ * @return true on success or false otherwise
+ */
+ bool ReloadConfig();
/**
* @brief Chack if the current config is valid
* @return true if the config is valid or false otherwise
diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp
index 62de86f..5b890a5 100644
--- a/client/ProxyClientApp.cpp
+++ b/client/ProxyClientApp.cpp
@@ -98,9 +98,9 @@ void ProxyClientApp::configUpdated()
if (proxifier->IsValid())
{
proxifier->ApplyFirewallRules(cfg->GetFirewallList());
- if (!proxifier->Restart())
+ if (!proxifier->ReloadConfig())
{
- Logger::Error("Unable to restart Proxifier process!\n");
+ Logger::Error("Unable to reload Proxifier's configuration!\n");
}
}
else
@@ -109,6 +109,7 @@ void ProxyClientApp::configUpdated()
}
// show message when config updated
+ /*
QString msg = QString::fromLocal8Bit(cfg->ConfigLoadedMsg.c_str());
QMessageBox updatedMsg;
updatedMsg.setText(msg);
@@ -116,6 +117,7 @@ void ProxyClientApp::configUpdated()
updatedMsg.setStandardButtons(QMessageBox::Ok);
updatedMsg.setIcon(QMessageBox::Information);
updatedMsg.exec();
+ */
}
void ProxyClientApp::quitApp()