From 1de40ac790d3218cc10d37f95f9f1a8c573dbe77 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 10 Aug 2010 23:51:58 +0300 Subject: modified: main.cpp modified: options.cpp modified: utilities.cpp modified: utilities.h --- main.cpp | 7 +++++++ options.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- utilities.cpp | 22 +++++++++++++++++++-- utilities.h | 2 ++ 4 files changed, 87 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 6ad5032..b3f01d5 100644 --- a/main.cpp +++ b/main.cpp @@ -24,9 +24,16 @@ void test() DWORD exitcode; string output; TCHAR *bin_path = UniGetContactSettingUtf(NULL, szModuleName, "szGpgBinPath", _T("")); + TCHAR *home_dir = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); TCHAR bin[512]; _tcscpy(bin, bin_path); + _tcscat(bin, _T(" --homedir ")); + _tcscat(bin, _T("\"")); + _tcscat(bin, home_dir); + _tcscat(bin, _T("\"")); _tcscat(bin, _T(" --help")); pxResult pxresult=pxExecute(bin,"",&output,&exitcode); + mir_free(bin_path); + mir_free(home_dir); MessageBoxA(0, output.c_str(), "", MB_OK); } \ No newline at end of file diff --git a/options.cpp b/options.cpp index 60cf2d9..b5c690d 100644 --- a/options.cpp +++ b/options.cpp @@ -138,7 +138,12 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA } wfstream f(tmp, std::ios::out); delete [] tmp; - wstring str = UniGetContactSettingUtf(user_data[item_num+1], szModuleName, "GPGPubKey", _T("")); + wstring str; + { + TCHAR *tmp = UniGetContactSettingUtf(user_data[item_num+1], szModuleName, "GPGPubKey", _T("")); + str.append(tmp); + mir_free(tmp); + } wstring::size_type s = 0; while((s = str.find(_T("\r"), s)) != wstring::npos) { @@ -191,8 +196,12 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); - SetDlgItemText(hwndDlg, IDC_BIN_PATH, UniGetContactSettingUtf(NULL, szModuleName, "szGpgBinPath", _T("gpg2.exe"))); - SetDlgItemText(hwndDlg, IDC_HOME_DIR, UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("gpg"))); + tmp = UniGetContactSettingUtf(NULL, szModuleName, "szGpgBinPath", _T("gpg2.exe")); + SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp); + mir_free(tmp); + tmp = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("gpg")); + SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp); + mir_free(tmp); return TRUE; } @@ -203,11 +212,15 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { case IDC_SET_BIN_PATH: GetFilePath(_T("Choose gpg2.exe"), "szGpgBinPath", _T("*.exe"), _T("EXE Executables")); - SetDlgItemText(hwndDlg, IDC_BIN_PATH, UniGetContactSettingUtf(NULL, szModuleName, "szGpgBinPath", _T("gpg2.exe"))); + tmp = UniGetContactSettingUtf(NULL, szModuleName, "szGpgBinPath", _T("gpg2.exe")); + SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp); + mir_free(tmp); break; case IDC_SET_HOME_DIR: GetFolderPath(_T("Set home diractory"), "szHomePath"); - SetDlgItemText(hwndDlg, IDC_HOME_DIR, UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T(""))); + tmp = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); + SetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp); + mir_free(tmp); break; default: break; @@ -282,6 +295,46 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP tmp = new TCHAR [key_buf.length()+1]; _tcscpy(tmp, key_buf.substr(ws1,ws2-ws1).c_str()); ListView_SetItemText(hwndList_p, item_num, 2, tmp); + { //gpg execute block + TCHAR cmd[40960] = {0}; + TCHAR tmp2[MAX_PATH] = {0}; + TCHAR *ptmp; + string output; + DWORD exitcode; + ptmp = UniGetContactSettingUtf(NULL, szModuleName, "szGpgBinPath", _T("")); + _tcscpy(cmd, ptmp); + mir_free(ptmp); + _tcscat(cmd, _T(" --homedir ")); + _tcscat(cmd, _T("\"")); + ptmp = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); + _tcscat(cmd, ptmp); + _tcscat(cmd, _T("\"")); + _tcscat(cmd, _T(" --import ")); + { + _tcscpy(tmp2, ptmp); + mir_free(ptmp); + _tcscat(tmp2, _T("\\")); + _tcscat(tmp2, _T("temporary_exported.asc")); + wfstream f(tmp2, std::ios::out); + ptmp = UniGetContactSettingUtf(user_data[item_num+1], szModuleName, "GPGPubKey", _T("")); + wstring str = ptmp; + mir_free(ptmp); + wstring::size_type s = 0; + while((s = str.find(_T("\r"), s)) != wstring::npos) + { + str.erase(s, 1); + } + f<append(readbuffer, 10); } while (available>0); } + +void cp866_to_cp1251(string *str) +{ + string::iterator p; + for(p = str->begin(); p != str->end(); p++) + { + if(*p > -129 && *p < -80) + *p += 64; + else if(*p > -33 && *p < -16) + *p += 16; + else if(*p == -16) + *p -= 72; + else if(*p == -17) + *p -= 57; + } +} diff --git a/utilities.h b/utilities.h index 73a451f..423f87c 100644 --- a/utilities.h +++ b/utilities.h @@ -23,4 +23,6 @@ void GetFolderPath(TCHAR *WindowTittle, char *szSetting); void storeOutput(HANDLE ahandle, string *output); +void cp866_to_cp1251(string *str); + #endif -- cgit v1.2.3