summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-09-11 04:40:44 +0000
committerRobert Pösel <robyer@seznam.cz>2016-09-11 04:40:44 +0000
commit0f4fb60ad8da3ce7d3d567cf8578b87bb59b9184 (patch)
tree734a05243d2c4ddd192b15ee56e6490043c3660f /plugins/New_GPG/src
parentbd9f1b83e15116ab6c695cb999257e29443dc7b3 (diff)
New_GPG: Fix unicode paths handling (fixes #349); versiom bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@17278 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG/src')
-rwxr-xr-xplugins/New_GPG/src/main.cpp88
-rwxr-xr-xplugins/New_GPG/src/options.cpp31
-rw-r--r--plugins/New_GPG/src/stdafx.h1
-rwxr-xr-xplugins/New_GPG/src/version.h2
4 files changed, 50 insertions, 72 deletions
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index a28f21294c..ac80248efa 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -787,25 +787,23 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- wchar_t *path = (wchar_t*)mir_alloc(sizeof(wchar_t) * MAX_PATH);
+ CMStringW path;
bool gpg_exists = false, lang_exists = false;
{
- ptrA mir_path((char*)mir_alloc(sizeof(char) * MAX_PATH));
- PathToAbsolute("\\", mir_path);
- SetCurrentDirectoryA(mir_path);
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ SetCurrentDirectoryW(mir_path);
- ptrW tmp(mir_a2u(mir_path));
+ CMStringW gpg_path(mir_path); gpg_path.Append(L"\\GnuPG\\gpg.exe");
+ CMStringW gpg_lang_path(mir_path); gpg_lang_path.Append(L"\\GnuPG\\gnupg.nls\\en@quot.mo");
- wstring gpg_path(tmp); gpg_path += L"\\GnuPG\\gpg.exe";
- wstring gpg_lang_path(tmp); gpg_lang_path += L"\\GnuPG\\gnupg.nls\\en@quot.mo";
-
- if (boost::filesystem::exists(gpg_path)) {
+ if (boost::filesystem::exists(gpg_path.c_str())) {
gpg_exists = true;
- mir_wstrcpy(path, L"GnuPG\\gpg.exe");
+ path = L"GnuPG\\gpg.exe";
}
- else mir_wstrcpy(path, gpg_path.c_str());
+ else path = gpg_path;
- if (boost::filesystem::exists(gpg_lang_path))
+ if (boost::filesystem::exists(gpg_lang_path.c_str()))
lang_exists = true;
if (gpg_exists && !lang_exists)
MessageBox(0, TranslateT("GPG binary found in Miranda folder, but English locale does not exist.\nIt's highly recommended that you place \\gnupg.nls\\en@quot.mo in GnuPG folder under Miranda root.\nWithout this file you may experience many problems with GPG output on non-English systems\nand plugin may completely not work.\nYou have been warned."), TranslateT("Warning"), MB_OK);
@@ -815,13 +813,12 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
{
ptrW tmp;
if (!gpg_exists) {
- tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", (SHGetValue(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, path, &len) == ERROR_SUCCESS) ? path : L"");
+ tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", (SHGetValueW(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, (void*)path.c_str(), &len) == ERROR_SUCCESS) ? path.c_str() : L"");
if (tmp[0])
if (!boost::filesystem::exists((wchar_t*)tmp))
MessageBox(0, TranslateT("Wrong GPG binary location found in system.\nPlease choose another location"), TranslateT("Warning"), MB_OK);
}
- else tmp = mir_wstrdup(path);
- mir_free(path);
+ else tmp = mir_wstrdup(path.c_str());
SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
if (gpg_exists/* && lang_exists*/) {
@@ -856,12 +853,11 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
{
ptrW tmp(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""));
if (!tmp[0]) {
- mir_free(tmp);
- char *mir_path = (char*)mir_alloc(sizeof(char) * MAX_PATH);
- PathToAbsolute("\\", mir_path);
- mir_strcat(mir_path, "\\gpg");
- if (_access(mir_path, 0) != -1) {
- tmp = mir_wstrdup(toUTF16(mir_path).c_str());
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ mir_wstrcat(mir_path, L"\\gpg");
+ if (_waccess(mir_path, 0) != -1) {
+ tmp = mir_wstrdup(mir_path);
MessageBox(0, TranslateT("\"GPG\" directory found in Miranda root.\nAssuming it's GPG home directory.\nGPG home directory set."), TranslateT("Info"), MB_OK);
}
else {
@@ -887,34 +883,27 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case IDC_SET_BIN_PATH:
{
GetFilePath(L"Choose gpg.exe", "szGpgBinPath", L"*.exe", L"EXE Executables");
- wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe");
+ CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe")));
SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
- char mir_path[MAX_PATH];
- char *atmp = mir_u2a(tmp);
- mir_free(tmp);
- PathToAbsolute("\\", mir_path);
- char* p_path = NULL;
- if (StriStr(atmp, mir_path)) {
- p_path = atmp + mir_strlen(mir_path);
- tmp = mir_a2u(p_path);
- SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ if (tmp.Find(mir_path, 0) == 0) {
+ CMStringW path = tmp.Mid(mir_wstrlen(mir_path));
+ SetDlgItemText(hwndDlg, IDC_BIN_PATH, path);
}
}
break;
case IDC_SET_HOME_DIR:
{
GetFolderPath(L"Set home directory", "szHomePath");
- wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"");
+ CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")));
SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp);
- char mir_path[MAX_PATH];
- char *atmp = mir_u2a(tmp);
- mir_free(tmp);
- PathToAbsolute("\\", mir_path);
- char* p_path = NULL;
- if (StriStr(atmp, mir_path)) {
- p_path = atmp + mir_strlen(mir_path);
- tmp = mir_a2u(p_path);
- SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp);
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ PathToAbsoluteW(L"\\", mir_path);
+ if (tmp.Find(mir_path, 0) == 0) {
+ CMStringW path = tmp.Mid(mir_wstrlen(mir_path));
+ SetDlgItemText(hwndDlg, IDC_HOME_DIR, path);
}
}
break;
@@ -923,10 +912,9 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
wchar_t tmp[512];
GetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp, _countof(tmp));
if (tmp[0]) {
- char *mir_path = new char[MAX_PATH];
- PathToAbsolute("\\", mir_path);
- SetCurrentDirectoryA(mir_path);
- delete[] mir_path;
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ SetCurrentDirectoryW(mir_path);
if (!boost::filesystem::exists(tmp)) {
MessageBox(0, TranslateT("GPG binary does not exist.\nPlease choose another location"), TranslateT("Warning"), MB_OK);
break;
@@ -994,10 +982,9 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
wchar_t tmp[512];
GetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp, _countof(tmp));
if (tmp[0]) {
- char *mir_path = new char[MAX_PATH];
- PathToAbsolute("\\", mir_path);
- SetCurrentDirectoryA(mir_path);
- delete[] mir_path;
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ SetCurrentDirectoryW(mir_path);
if (!boost::filesystem::exists(tmp)) {
MessageBox(0, TranslateT("GPG binary does not exist.\nPlease choose another location"), TranslateT("Warning"), MB_OK);
break;
@@ -1046,13 +1033,12 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
}
db_set_ws(NULL, szGPGModuleName, "szHomePath", tmp);
{
- wchar_t *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"");
+ ptrW path(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L""));
DWORD dwFileAttr = GetFileAttributes(path);
if (dwFileAttr != INVALID_FILE_ATTRIBUTES) {
dwFileAttr &= ~FILE_ATTRIBUTE_READONLY;
SetFileAttributes(path, dwFileAttr);
}
- mir_free(path);
}
}
{
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index 4baaa264b1..8cf20a395a 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -424,7 +424,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case IDC_SET_BIN_PATH:
{
GetFilePath(TranslateT("Choose gpg.exe"), "szGpgBinPath", L"*.exe", TranslateT("EXE Executables"));
- wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe");
+ CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L"gpg.exe")));
SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
bool gpg_exists = false;
{
@@ -463,34 +463,25 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
MessageBox(0, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), L"Warning", MB_OK); */
}
}
- char mir_path[MAX_PATH];
- char *atmp = mir_u2a(tmp);
- mir_free(tmp);
- PathToAbsolute("\\", mir_path);
- char* p_path = NULL;
- if (StriStr(atmp, mir_path)) {
- p_path = atmp + mir_strlen(mir_path);
- tmp = mir_a2u(p_path);
- SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ if (tmp.Find(mir_path, 0) == 0) {
+ CMStringW path = tmp.Mid(mir_wstrlen(mir_path));
+ SetDlgItemText(hwndDlg, IDC_BIN_PATH, path);
}
}
break;
case IDC_SET_HOME_DIR:
{
GetFolderPath(TranslateT("Set home directory"), "szHomePath");
- wchar_t *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"");
+ CMStringW tmp(ptrW(UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", L"")));
SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp);
- char mir_path[MAX_PATH];
- char *atmp = mir_u2a(tmp);
- mir_free(tmp);
- PathToAbsolute("\\", mir_path);
- char* p_path = NULL;
- if (StriStr(atmp, mir_path)) {
- p_path = atmp + mir_strlen(mir_path);
- tmp = mir_a2u(p_path);
+ wchar_t mir_path[MAX_PATH];
+ PathToAbsoluteW(L"\\", mir_path);
+ if (tmp.Find(mir_path, 0) == 0) {
+ CMStringW path = tmp.Mid(mir_wstrlen(mir_path));
SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp);
}
- mir_free(atmp);
}
break;
default:
diff --git a/plugins/New_GPG/src/stdafx.h b/plugins/New_GPG/src/stdafx.h
index d2adb3f422..f3bc474f9d 100644
--- a/plugins/New_GPG/src/stdafx.h
+++ b/plugins/New_GPG/src/stdafx.h
@@ -67,6 +67,7 @@ using std::fstream;
#include <m_cluiframes.h>
#include <m_icolib.h>
#include <m_extraicons.h>
+#include <m_string.h>
#include <win2k.h>
#include <m_metacontacts.h>
diff --git a/plugins/New_GPG/src/version.h b/plugins/New_GPG/src/version.h
index 4be838749d..5fb5a9f001 100755
--- a/plugins/New_GPG/src/version.h
+++ b/plugins/New_GPG/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 0
-#define __BUILD_NUM 13
+#define __BUILD_NUM 14
#include <stdver.h>