diff --git a/as.c b/as.c index cfa4d4d..4fb9d8b 100644 --- a/as.c +++ b/as.c @@ -682,7 +682,7 @@ ImportProfileFromURLDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa if (downloaded) { EndDialog(hwndDlg, LOWORD(wParam)); - ImportConfigFile(path); + ImportConfigFile(path, false); /* do not prompt user */ _wunlink(path); } return TRUE; diff --git a/main.c b/main.c index 6ca6702..510f309 100644 --- a/main.c +++ b/main.c @@ -471,7 +471,7 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data) } else if(copy_data->dwData == WM_OVPN_IMPORT && str) { - ImportConfigFile(str); + ImportConfigFile(str, true); /* prompt user */ } else if (copy_data->dwData == WM_OVPN_NOTIFY) { @@ -531,7 +531,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM /* if '--import' was specified, do it now */ if (o.action == WM_OVPN_IMPORT && o.action_arg) { - ImportConfigFile(o.action_arg); + ImportConfigFile(o.action_arg, true); /* prompt user */ } if (!AutoStartConnections()) { @@ -794,7 +794,7 @@ ImportConfigFileFromDisk() if (GetOpenFileName(&fn)) { - ImportConfigFile(source); + ImportConfigFile(source, false); /* do not prompt user */ } } diff --git a/misc.c b/misc.c index 6589b7c..861163f 100644 --- a/misc.c +++ b/misc.c @@ -646,7 +646,7 @@ open_url(const wchar_t *url) extern options_t o; void -ImportConfigFile(const TCHAR* source) +ImportConfigFile(const TCHAR* source, bool prompt_user) { TCHAR fileName[MAX_PATH] = _T(""); TCHAR ext[MAX_PATH] = _T(""); @@ -683,6 +683,12 @@ ImportConfigFile(const TCHAR* source) } else { + if (prompt_user + && ShowLocalizedMsgEx(MB_YESNO, NULL, TEXT(PACKAGE_NAME), + IDS_NFO_IMPORT_SOURCE, fileName) == IDNO) + { + return; + } WCHAR dest_dir[MAX_PATH+1]; swprintf(dest_dir, MAX_PATH, L"%ls\\%ls", o.config_dir, fileName); dest_dir[MAX_PATH] = L'\0'; diff --git a/misc.h b/misc.h index 625a9b1..79f3762 100644 --- a/misc.h +++ b/misc.h @@ -72,7 +72,7 @@ DWORD md_final(md_ctx *ctx, BYTE *md); /* Open specified http/https URL using ShellExecute. */ BOOL open_url(const wchar_t *url); -void ImportConfigFile(const TCHAR* path); +void ImportConfigFile(const TCHAR* path, bool prompt_user); /* * Helper function to convert UCS-2 text from a dialog item to UTF-8. diff --git a/openvpn-gui-res.h b/openvpn-gui-res.h index 6a47e63..8a64018 100644 --- a/openvpn-gui-res.h +++ b/openvpn-gui-res.h @@ -339,6 +339,7 @@ #define IDS_NFO_IMPORT_OVERWRITE 1904 #define IDS_ERR_IMPORT_SOURCE 1905 #define IDS_ERR_IMPORT_ACCESS 1906 +#define IDS_NFO_IMPORT_SOURCE 1907 /* Save password related messages */ #define IDS_NFO_DELETE_PASS 2001 diff --git a/res/openvpn-gui-res-en.rc b/res/openvpn-gui-res-en.rc index 06ca925..8aaf48b 100644 --- a/res/openvpn-gui-res-en.rc +++ b/res/openvpn-gui-res-en.rc @@ -521,6 +521,7 @@ once as Administrator to update the registry." %ls\n\nMake sure you have the right permissions." IDS_NFO_IMPORT_SUCCESS "File imported successfully." IDS_NFO_IMPORT_OVERWRITE "A config named ""%ls"" already exists. Do you want to replace it?" + IDS_NFO_IMPORT_SOURCE "Do you want to import the profile <%ls>?" IDS_ERR_IMPORT_SOURCE "Cannot import file <%ls> as it is already in the global or local config directory" IDS_ERR_IMPORT_ACCESS "Cannot import <%ls> as it is missing or not readable"