mirror of https://github.com/OpenVPN/openvpn-gui
commit
c3e2584674
6
README
6
README
|
@ -228,4 +228,8 @@ Building OpenVPN GUI from source
|
||||||
|
|
||||||
* Start a bash shell by running msys.bat.
|
* Start a bash shell by running msys.bat.
|
||||||
|
|
||||||
* Run "make" from the OpenVPN GUI source directory.
|
* Run at the OpenVPN GUI source directory:
|
||||||
|
|
||||||
|
$ autoreconf -i
|
||||||
|
$ ./configure
|
||||||
|
$ make
|
||||||
|
|
67
main.c
67
main.c
|
@ -28,6 +28,7 @@
|
||||||
#include <wtsapi32.h>
|
#include <wtsapi32.h>
|
||||||
#include <prsht.h>
|
#include <prsht.h>
|
||||||
#include <pbt.h>
|
#include <pbt.h>
|
||||||
|
#include <commdlg.h>
|
||||||
|
|
||||||
#include "tray.h"
|
#include "tray.h"
|
||||||
#include "openvpn.h"
|
#include "openvpn.h"
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
||||||
static void ShowSettingsDialog();
|
static void ShowSettingsDialog();
|
||||||
void CloseApplication(HWND hwnd);
|
void CloseApplication(HWND hwnd);
|
||||||
|
void ImportConfigFile();
|
||||||
|
|
||||||
/* Class name and window title */
|
/* Class name and window title */
|
||||||
TCHAR szClassName[ ] = _T("OpenVPN-GUI");
|
TCHAR szClassName[ ] = _T("OpenVPN-GUI");
|
||||||
|
@ -352,6 +354,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
ShowChangePassphraseDialog(&o.conn[LOWORD(wParam) - IDM_PASSPHRASEMENU]);
|
ShowChangePassphraseDialog(&o.conn[LOWORD(wParam) - IDM_PASSPHRASEMENU]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (LOWORD(wParam) == IDM_IMPORT) {
|
||||||
|
ImportConfigFile();
|
||||||
|
}
|
||||||
if (LOWORD(wParam) == IDM_SETTINGS) {
|
if (LOWORD(wParam) == IDM_SETTINGS) {
|
||||||
ShowSettingsDialog();
|
ShowSettingsDialog();
|
||||||
}
|
}
|
||||||
|
@ -528,6 +533,68 @@ CloseApplication(HWND hwnd)
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ImportConfigFile()
|
||||||
|
{
|
||||||
|
|
||||||
|
TCHAR filter[37];
|
||||||
|
|
||||||
|
_sntprintf_0(filter, _T("*.%s%c*.%s%c"), o.ext_string, _T('\0'), o.ext_string, _T('\0'));
|
||||||
|
|
||||||
|
OPENFILENAME fn;
|
||||||
|
TCHAR source[MAX_PATH] = _T("");
|
||||||
|
|
||||||
|
fn.lStructSize = sizeof(OPENFILENAME);
|
||||||
|
fn.hwndOwner = NULL;
|
||||||
|
fn.lpstrFilter = filter;
|
||||||
|
fn.lpstrCustomFilter = NULL;
|
||||||
|
fn.nFilterIndex = 1;
|
||||||
|
fn.lpstrFile = source;
|
||||||
|
fn.nMaxFile = MAX_PATH;
|
||||||
|
fn.lpstrFileTitle = NULL;
|
||||||
|
fn.lpstrInitialDir = NULL;
|
||||||
|
fn.lpstrTitle = NULL;
|
||||||
|
fn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST;
|
||||||
|
fn.lpstrDefExt = NULL;
|
||||||
|
|
||||||
|
if (GetOpenFileName(&fn))
|
||||||
|
{
|
||||||
|
|
||||||
|
TCHAR destination[MAX_PATH];
|
||||||
|
PTCHAR fileName = source + fn.nFileOffset;
|
||||||
|
|
||||||
|
_sntprintf_0(destination, _T("%s\\%s"), o.config_dir, fileName);
|
||||||
|
|
||||||
|
destination[_tcslen(destination) - _tcslen(o.ext_string) - 1] = _T('\0');
|
||||||
|
|
||||||
|
if (EnsureDirExists(destination))
|
||||||
|
{
|
||||||
|
|
||||||
|
_sntprintf_0(destination, _T("%s\\%s"), destination, fileName);
|
||||||
|
|
||||||
|
if (!CopyFile(source, destination, TRUE))
|
||||||
|
{
|
||||||
|
if (GetLastError() == ERROR_FILE_EXISTS)
|
||||||
|
{
|
||||||
|
fileName[_tcslen(fileName) - _tcslen(o.ext_string) - 1] = _T('\0');
|
||||||
|
ShowLocalizedMsg(IDS_ERR_IMPORT_EXISTS, fileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowLocalizedMsg(IDS_NFO_IMPORT_SUCCESS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowLocalizedMsg(IDS_ERR_IMPORT_FAILED, destination);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void PrintDebugMsg(TCHAR *msg)
|
void PrintDebugMsg(TCHAR *msg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
#define IDS_MENU_SERVICEONLY_STOP 1020
|
#define IDS_MENU_SERVICEONLY_STOP 1020
|
||||||
#define IDS_MENU_SERVICEONLY_RESTART 1021
|
#define IDS_MENU_SERVICEONLY_RESTART 1021
|
||||||
#define IDS_MENU_ASK_STOP_SERVICE 1022
|
#define IDS_MENU_ASK_STOP_SERVICE 1022
|
||||||
|
#define IDS_MENU_IMPORT 1023
|
||||||
|
|
||||||
/* LogViewer Dialog */
|
/* LogViewer Dialog */
|
||||||
#define IDS_ERR_START_LOG_VIEWER 1101
|
#define IDS_ERR_START_LOG_VIEWER 1101
|
||||||
|
@ -247,4 +248,10 @@
|
||||||
#define IDS_ERR_WRITE_REGVALUE 1812
|
#define IDS_ERR_WRITE_REGVALUE 1812
|
||||||
#define IDS_ERR_GET_PROFILE_DIR 1813
|
#define IDS_ERR_GET_PROFILE_DIR 1813
|
||||||
|
|
||||||
|
/* Importation Related */
|
||||||
|
|
||||||
|
#define IDS_ERR_IMPORT_EXISTS 1901
|
||||||
|
#define IDS_ERR_IMPORT_FAILED 1902
|
||||||
|
#define IDS_NFO_IMPORT_SUCCESS 1903
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -160,6 +160,7 @@ BEGIN
|
||||||
IDS_TIP_CONNECTED_SINCE "\nConnected since: "
|
IDS_TIP_CONNECTED_SINCE "\nConnected since: "
|
||||||
IDS_TIP_ASSIGNED_IP "\nAssigned IP: %s"
|
IDS_TIP_ASSIGNED_IP "\nAssigned IP: %s"
|
||||||
IDS_MENU_SERVICE "OpenVPN Service"
|
IDS_MENU_SERVICE "OpenVPN Service"
|
||||||
|
IDS_MENU_IMPORT "Import file…"
|
||||||
IDS_MENU_SETTINGS "Settings…"
|
IDS_MENU_SETTINGS "Settings…"
|
||||||
IDS_MENU_CLOSE "Exit"
|
IDS_MENU_CLOSE "Exit"
|
||||||
IDS_MENU_CONNECT "Connect"
|
IDS_MENU_CONNECT "Connect"
|
||||||
|
@ -348,4 +349,10 @@ BEGIN
|
||||||
"once as Administrator to update the registry."
|
"once as Administrator to update the registry."
|
||||||
IDS_ERR_READ_SET_KEY "Error reading and setting registry key ""%s""."
|
IDS_ERR_READ_SET_KEY "Error reading and setting registry key ""%s""."
|
||||||
IDS_ERR_WRITE_REGVALUE "Error writing registry value ""HKEY_CURRENT_USER\\%s\\%s""."
|
IDS_ERR_WRITE_REGVALUE "Error writing registry value ""HKEY_CURRENT_USER\\%s\\%s""."
|
||||||
|
|
||||||
|
/* importation */
|
||||||
|
IDS_ERR_IMPORT_EXISTS "A config named ""%s"" already exists."
|
||||||
|
IDS_ERR_IMPORT_FAILED "Failed to import file. The following path could not be created.\n\n" \
|
||||||
|
"%s\n\nMake sure you have the right permissions."
|
||||||
|
IDS_NFO_IMPORT_SUCCESS "File imported successfully."
|
||||||
END
|
END
|
||||||
|
|
|
@ -147,6 +147,7 @@ BEGIN
|
||||||
IDS_TIP_CONNECTED_SINCE "\nConectado desde: "
|
IDS_TIP_CONNECTED_SINCE "\nConectado desde: "
|
||||||
IDS_TIP_ASSIGNED_IP "\nIP atribuído: %s"
|
IDS_TIP_ASSIGNED_IP "\nIP atribuído: %s"
|
||||||
IDS_MENU_SERVICE "Serviço OpenVPN"
|
IDS_MENU_SERVICE "Serviço OpenVPN"
|
||||||
|
IDS_MENU_IMPORT "Importar arquivo…"
|
||||||
IDS_MENU_SETTINGS "Configurações…"
|
IDS_MENU_SETTINGS "Configurações…"
|
||||||
IDS_MENU_CLOSE "Sair"
|
IDS_MENU_CLOSE "Sair"
|
||||||
IDS_MENU_CONNECT "Conectar"
|
IDS_MENU_CONNECT "Conectar"
|
||||||
|
@ -324,4 +325,10 @@ BEGIN
|
||||||
"uma vez como Administrador para alterar o registro."
|
"uma vez como Administrador para alterar o registro."
|
||||||
IDS_ERR_READ_SET_KEY "Erro ao ler e ajustar chave de registro ""%s""."
|
IDS_ERR_READ_SET_KEY "Erro ao ler e ajustar chave de registro ""%s""."
|
||||||
IDS_ERR_WRITE_REGVALUE "Erro ao gravar valor da chave de registro ""HKEY_CURRENT_USER\\%s\\%s""."
|
IDS_ERR_WRITE_REGVALUE "Erro ao gravar valor da chave de registro ""HKEY_CURRENT_USER\\%s\\%s""."
|
||||||
|
|
||||||
|
/* importation */
|
||||||
|
IDS_ERR_IMPORT_EXISTS "Já existe uma configuração com o nome ""%s""."
|
||||||
|
IDS_ERR_IMPORT_FAILED "Falha ao importar o arquivo. O seguinte caminho não pôde ser criado.\n\n" \
|
||||||
|
"%s\n\nCertifique-se de que você possui as permissões necessárias."
|
||||||
|
IDS_NFO_IMPORT_SUCCESS "Arquivo importado com sucesso."
|
||||||
END
|
END
|
||||||
|
|
2
tray.c
2
tray.c
|
@ -91,6 +91,7 @@ CreatePopupMenus()
|
||||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppendMenu(hMenu, MF_STRING, IDM_IMPORT, LoadLocalizedString(IDS_MENU_IMPORT));
|
||||||
AppendMenu(hMenu, MF_STRING ,IDM_SETTINGS, LoadLocalizedString(IDS_MENU_SETTINGS));
|
AppendMenu(hMenu, MF_STRING ,IDM_SETTINGS, LoadLocalizedString(IDS_MENU_SETTINGS));
|
||||||
AppendMenu(hMenu, MF_STRING ,IDM_CLOSE, LoadLocalizedString(IDS_MENU_CLOSE));
|
AppendMenu(hMenu, MF_STRING ,IDM_CLOSE, LoadLocalizedString(IDS_MENU_CLOSE));
|
||||||
|
|
||||||
|
@ -116,6 +117,7 @@ CreatePopupMenus()
|
||||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppendMenu(hMenu, MF_STRING, IDM_IMPORT, LoadLocalizedString(IDS_MENU_IMPORT));
|
||||||
AppendMenu(hMenu, MF_STRING, IDM_SETTINGS, LoadLocalizedString(IDS_MENU_SETTINGS));
|
AppendMenu(hMenu, MF_STRING, IDM_SETTINGS, LoadLocalizedString(IDS_MENU_SETTINGS));
|
||||||
AppendMenu(hMenu, MF_STRING, IDM_CLOSE, LoadLocalizedString(IDS_MENU_CLOSE));
|
AppendMenu(hMenu, MF_STRING, IDM_CLOSE, LoadLocalizedString(IDS_MENU_CLOSE));
|
||||||
|
|
||||||
|
|
1
tray.h
1
tray.h
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#define IDM_SETTINGS 221
|
#define IDM_SETTINGS 221
|
||||||
#define IDM_CLOSE 223
|
#define IDM_CLOSE 223
|
||||||
|
#define IDM_IMPORT 224
|
||||||
|
|
||||||
#define IDM_CONNECTMENU 300
|
#define IDM_CONNECTMENU 300
|
||||||
#define IDM_DISCONNECTMENU (MAX_CONFIGS + IDM_CONNECTMENU)
|
#define IDM_DISCONNECTMENU (MAX_CONFIGS + IDM_CONNECTMENU)
|
||||||
|
|
Loading…
Reference in New Issue