summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmain.cpp367
-rwxr-xr-xmessages.cpp97
-rwxr-xr-xnew_gpg.vcxproj2
3 files changed, 107 insertions, 359 deletions
diff --git a/main.cpp b/main.cpp
index 3857f38..7fdf27c 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,4 +1,4 @@
-// Copyright © 2010-2012 sss
+// Copyright © 2010-2011 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -148,27 +148,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
}
}
}
- {
- SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)Translate("Default"));
- int count = 0;
- PROTOACCOUNT **accounts;
- ProtoEnumAccounts(&count, &accounts);
- for(int i = 0; i < count; i++)
- {
- if(StriStr(accounts[i]->szModuleName, "metacontacts"))
- continue;
- if(StriStr(accounts[i]->szModuleName, "weather"))
- continue;
- SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)accounts[i]->szModuleName);
- }
- SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_SELECTSTRING, 0, (LPARAM)Translate("Default"));
- string keyinfo = Translate("key id");
- keyinfo += ": ";
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
- mir_free(keyid);
- SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str());
- }
+
return TRUE;
}
@@ -222,29 +202,9 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
{
out.erase(s, 1);
}
- {
- char buf[64];
- GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
- if(!strcmp(buf, Translate("Default")))
- {
- DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str());
- DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyMainName", name);
- DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp);
- }
- else
- {
- char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str());
- strcpy(setting, buf);
- strcat(setting, "_KeyMainName");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, name);
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp);
- }
- }
+ DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str());
+ DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyMainName", name);
+ DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp);
TCHAR passwd[64];
GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, passwd, 64);
if(passwd[0])
@@ -257,8 +217,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
DBWriteContactSettingTString(NULL, szGPGModuleName, dbsetting.c_str(), passwd);
}
{
- wstring keyinfo = TranslateT("Default private key id");
- keyinfo += _T(": ");
+ wstring keyinfo = _T("Current private key id: ");
keyinfo += (fp[0])?fp:_T("not set");
extern HWND hwndCurKey_p;
SetWindowText(hwndCurKey_p, keyinfo.c_str());
@@ -266,8 +225,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
delete [] name;
}
bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange");
- gpg_valid = isGPGValid();
- gpg_keyexist = isGPGKeyExist();
+ gpg_configured = isGPGConfigured();
DestroyWindow(hwndDlg);
break;
case IDC_OTHER:
@@ -412,41 +370,12 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(result == pxNotFound)
break;
}
- {
- char buf[64];
- GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
- if(!strcmp(buf, Translate("Default")))
- {
- DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey");
- DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID");
- DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment");
- DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName");
- DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail");
- DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType");
- }
- else
- {
- char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyMainName");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyComment");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyMainEmail");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyType");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- }
- }
+ DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail");
+ DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType");
ListView_DeleteItem(hwndList, itemnum);
break;
case IDC_GENERATE_RANDOM:
@@ -460,12 +389,12 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
wfstream f(path.c_str(), std::ios::out);
if(!f.is_open())
{
- MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK);
+ MessageBox(0, _T("Failed to open file"), _T("Error"), MB_OK);
break;
}
f<<"Key-Type: RSA";
f<<"\n";
- f<<"Key-Length: 4096";
+ f<<"Key-Length: 2048";
f<<"\n";
f<<"Subkey-Type: RSA";
f<<"\n";
@@ -495,12 +424,6 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
params.out = &out;
params.code = &code;
params.result = &result;
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_GENERATING_KEY), Translate("Generating new random key, please wait"));
- EnableWindow(GetDlgItem(hwndDlg, IDC_GENERATE_KEY), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OTHER), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_KEY), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_LIST), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_GENERATE_RANDOM), 0);
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::minutes(10)))
{
@@ -549,59 +472,14 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
{
out.erase(s, 1);
}
- {
- char buf[64];
- GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
- if(!strcmp(buf, Translate("Default")))
- {
- DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str());
- DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp);
- }
- else
- {
- char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str());
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp);
- }
- }
+ DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str());
+ DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", path.c_str());
extern HWND hwndCurKey_p;
SetWindowText(hwndCurKey_p, path.c_str());
}
}
DestroyWindow(hwndDlg);
break;
- case IDC_ACCOUNT:
- {
- char buf[64];
- GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
- if(!strcmp(buf, Translate("Default")))
- {
- string keyinfo = Translate("key id");
- keyinfo += ": ";
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
- mir_free(keyid);
- SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str());
- }
- else
- {
- string keyinfo = Translate("key id");
- keyinfo += ": ";
- char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, "");
- keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
- mir_free(keyid);
- SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str());
- }
- }
- break;
-
}
break;
}
@@ -616,16 +494,12 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
itemnum = hdr->iItem;
}
}
-/* switch(LOWORD(wParam))
- {
- default:
- break;
- }; */
-/* switch (((LPNMHDR)lParam)->code)
- {
- default:
- break;
- } */
+// switch (((LPNMHDR)lParam)->code)
+ // {
+// default:
+// break;
+
+// }
}
break;
case WM_CLOSE:
@@ -678,7 +552,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if(_waccess(gpg_lang_path, 0) != -1)
lang_exists = true;
if(gpg_exists && !lang_exists) //TODO: check gpg version
- MessageBox(0, TranslateT("gpg binary found in miranda folder, but english locale does not exists.\nit's highly recommended to place \\gnupg.nls\\en@quot.mo in gnupg folder under miranda root.\nwithout this file you may expirense many problem with gpg output on non english systems.\nand plugin may completely do not work.\nyou have beed warned."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("gpg binary found in miranda folder, but english locale does not exists.\nit's highly recommended to place \\gnupg.nls\\en@quot.mo in gnupg folder under miranda root.\nwithout this file you may expirense many problem with gpg output on non english systems.\nand plugin may completely do not work.\nyou have beed warned."), _T("Warning"), MB_OK);
mir_free(gpg_path);
mir_free(gpg_lang_path);
}
@@ -695,7 +569,9 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if(_waccess(tmp, 0) == -1)
{
if(errno == ENOENT)
- MessageBox(0, TranslateT("wrong gpg binary location found in system.\nplease choose another location"), TranslateT("Warning"), MB_OK);
+ {
+ MessageBox(0, _T("wrong gpg binary location found in system.\nplease choose another location"), _T("Warning"), MB_OK);
+ }
}
}
}
@@ -717,7 +593,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.out = &out;
params.code = &code;
params.result = &result;
- gpg_valid = true;
+ gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
@@ -726,7 +602,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
}
- gpg_valid = false;
+ gpg_configured = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
string::size_type p1 = out.find("(GnuPG) ");
if(p1 != string::npos)
@@ -738,10 +614,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
else
{
bad_version = false;
- MessageBox(0, TranslateT("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
if(bad_version)
- MessageBox(0, TranslateT("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
mir_free(tmp);
if(!gpg_exists)
@@ -753,7 +629,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SetDlgItemText(hwndDlg, IDC_HOME_DIR, !gpg_exists?tmp:_T("gpg"));
mir_free(tmp);
if(gpg_exists && lang_exists && !bad_version)
- MessageBox(0, TranslateT("Your GPG version is supported. The language file was found.\nGPG plugin should work fine.\nPress OK to continue."), TranslateT("Info"), MB_OK);
+ MessageBox(0, _T("You have supported version of gpg binary, and gpg language file in place!\ngpg plugin should work fine on your installation!\njust press ok in wollowing diallog."), _T("Info"), MB_OK);
extern bool bIsMiranda09;
EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), bIsMiranda09);
return TRUE;
@@ -814,14 +690,14 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
if(errno == ENOENT)
{
- MessageBox(0, TranslateT("gpg binary does not exists.\nplease choose another location"), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("gpg binary does not exists.\nplease choose another location"), _T("Warning"), MB_OK);
break;
}
}
}
else
{
- MessageBox(0, TranslateT("please choose gpg binary location"), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("please choose gpg binary location"), _T("Warning"), MB_OK);
break;
}
{
@@ -837,7 +713,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.out = &out;
params.code = &code;
params.result = &result;
- gpg_valid = true;
+ gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
@@ -846,7 +722,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
gpg_thread.~thread();
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
}
- gpg_valid = false;
+ gpg_configured = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
string::size_type p1 = out.find("(GnuPG) ");
if(p1 != string::npos)
@@ -858,10 +734,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
else
{
bad_version = false;
- MessageBox(0, TranslateT("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
if(bad_version)
- MessageBox(0, TranslateT("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
DBWriteContactSettingTString(NULL, szGPGModuleName, "szGpgBinPath", tmp);
GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, 512);
@@ -869,7 +745,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
tmp[_tcslen(tmp)-1] = '\0';
if(!tmp[0])
{
- MessageBox(0, TranslateT("please set keyring's home directory"), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("please set keyring's home directory"), _T("Warning"), MB_OK);
break;
}
DBWriteContactSettingTString(NULL, szGPGModuleName, "szHomePath", tmp);
@@ -883,7 +759,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
mir_free(path);
}
- gpg_valid = true;
+ gpg_configured = true;
DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0);
DestroyWindow(hwndDlg);
ShowFirstRunDialog();
@@ -903,14 +779,14 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
if(errno == ENOENT)
{
- MessageBox(0, TranslateT("gpg binary does not exists.\nplease choose another location"), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("gpg binary does not exists.\nplease choose another location"), _T("Warning"), MB_OK);
break;
}
}
}
else
{
- MessageBox(0, TranslateT("please choose gpg binary location"), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("please choose gpg binary location"), _T("Warning"), MB_OK);
break;
}
{
@@ -926,7 +802,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.out = &out;
params.code = &code;
params.result = &result;
- gpg_valid = true;
+ gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
@@ -935,7 +811,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
gpg_thread.~thread();
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
}
- gpg_valid = false;
+ gpg_configured = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
string::size_type p1 = out.find("(GnuPG) ");
if(p1 != string::npos)
@@ -947,10 +823,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
else
{
bad_version = false;
- MessageBox(0, TranslateT("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
if(bad_version)
- MessageBox(0, TranslateT("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
DBWriteContactSettingTString(NULL, szGPGModuleName, "szGpgBinPath", tmp);
GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, 512);
@@ -958,7 +834,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
tmp[_tcslen(tmp)-1] = '\0';
if(!tmp[0])
{
- MessageBox(0, TranslateT("please set keyring's home directory"), TranslateT("Warning"), MB_OK);
+ MessageBox(0, _T("please set keyring's home directory"), _T("Warning"), MB_OK);
break;
}
DBWriteContactSettingTString(NULL, szGPGModuleName, "szHomePath", tmp);
@@ -983,7 +859,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
wfstream f(path.c_str(), std::ios::out);
if(!f.is_open())
{
- MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK);
+ MessageBox(0, _T("Failed to open file"), _T("Error"), MB_OK);
break;
}
f<<"Key-Type: RSA";
@@ -1018,7 +894,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.out = &out;
params.code = &code;
params.result = &result;
- gpg_valid = true;
+ gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::minutes(10)))
{
@@ -1026,10 +902,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted";
- gpg_valid = false;
+ gpg_configured = false;
break;
}
- gpg_valid = false;
+ gpg_configured = false;
if(result == pxNotFound)
break;
DeleteFile(path.c_str());
@@ -1052,7 +928,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.out = &out;
params.code = &code;
params.result = &result;
- gpg_valid = true;
+ gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
@@ -1060,10 +936,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
debuglog<<time_str()<<"GPG execution timed out, aborted\n";
- gpg_valid = false;
+ gpg_configured = false;
break;
}
- gpg_valid = false;
+ gpg_configured = false;
if(result == pxNotFound)
break;
string::size_type s = 0;
@@ -1078,7 +954,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
}
bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange");
- gpg_valid = true;
+ gpg_configured = true;
DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0);
DestroyWindow(hwndDlg);
break;
@@ -1113,24 +989,23 @@ static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
{
extern HANDLE new_key_hcnt;
extern boost::mutex new_key_hcnt_mutex;
- static HANDLE hContact = INVALID_HANDLE_VALUE;
+ HANDLE hContact = new_key_hcnt;
+ new_key_hcnt_mutex.unlock();
void ImportKey();
TCHAR *tmp = NULL;
switch (msg)
{
case WM_INITDIALOG:
{
- hContact = new_key_hcnt;
- new_key_hcnt_mutex.unlock();
SetWindowPos(hwndDlg, 0, new_key_rect.left, new_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
TranslateDialogDefault(hwndDlg);
TCHAR *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
- SetDlgItemText(hwndDlg, IDC_MESSAGE, tmp[0]?TranslateT("There is existing key for contact, would you like to replace with new key ?"):TranslateT("New public key was received, do you want to import it?"));
+ SetDlgItemText(hwndDlg, IDC_MESSAGE, (_tcslen(tmp) > 0)?_T("There is existing key for contact, would you like to replace with new key ?"):_T("New public key was received, do you want to import it?"));
EnableWindow(GetDlgItem(hwndDlg, IDC_IMPORT_AND_USE), DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0)?0:1);
- SetDlgItemText(hwndDlg, ID_IMPORT, tmp[0]?TranslateT("Replace"):TranslateT("Accept"));
+ SetDlgItemText(hwndDlg, ID_IMPORT, (_tcslen(tmp) > 0)?_T("Replace"):_T("Accept"));
mir_free(tmp);
tmp = new TCHAR [256];
- _tcscpy(tmp, TranslateT("Received key from "));
+ _tcscpy(tmp, _T("Received key from "));
_tcscat(tmp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, (LPARAM)GCDNF_TCHAR));
SetDlgItemText(hwndDlg, IDC_KEY_FROM, tmp);
delete [] tmp;
@@ -1197,12 +1072,12 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
{
SetWindowPos(hwndDlg, 0, key_gen_rect.left, key_gen_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
TranslateDialogDefault(hwndDlg);
- SetWindowText(hwndDlg, TranslateT("Key Generation dialog"));
+ SetWindowText(hwndDlg, TranslateW(_T("Key Generation dialog")));
ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEY_TYPE), _T("RSA"), 0);
ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEY_TYPE), _T("DSA"), 1);
SendDlgItemMessage(hwndDlg, IDC_KEY_TYPE, CB_SETCURSEL, (WPARAM)1, 0);
SetDlgItemInt(hwndDlg, IDC_KEY_EXPIRE_DATE, 0, 0);
- SetDlgItemInt(hwndDlg, IDC_KEY_LENGTH, 4096, 0);
+ SetDlgItemInt(hwndDlg, IDC_KEY_LENGTH, 2048, 0);
return TRUE;
}
@@ -1223,7 +1098,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
if(_tcslen(tmp) < 3)
{
mir_free(tmp);
- MessageBox(0, TranslateT("You must set encryption algorythm first"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("You must set encryption algorythm first")), TranslateW(_T("Error")), MB_OK);
break;
}
mir_free(tmp);
@@ -1233,14 +1108,14 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
mir_free(tmp);
if(length < 1024 || length > 4096)
{
- MessageBox(0, TranslateT("Key length must be of length from 1024 to 4096 bits"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("Key length must be of length from 1024 to 4096 bits")), TranslateW(_T("Error")), MB_OK);
break;
}
tmp = new TCHAR [12];
GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 12);
if(_tcslen(tmp) != 10 && tmp[0] != '0')
{
- MessageBox(0, TranslateT("Invalid date"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("Invalid date")), TranslateW(_T("Error")), MB_OK);
delete [] tmp;
break;
}
@@ -1249,13 +1124,13 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 128);
if(_tcslen(tmp) < 5)
{
- MessageBox(0, TranslateT("Name must contain at least 5 characters"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("Name must contain at least 5 characters")), TranslateW(_T("Error")), MB_OK);
delete [] tmp;
break;
}
else if (_tcschr(tmp, _T('(')) || _tcschr(tmp, _T(')')))
{
- MessageBox(0, TranslateT("Name cannot contain '(' or ')'"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("Name cannot contain '(' or ')'")), TranslateW(_T("Error")), MB_OK);
delete [] tmp;
break;
}
@@ -1264,7 +1139,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
GetDlgItemText(hwndDlg, IDC_KEY_EMAIL, tmp, 128);
if((_tcslen(tmp)) < 5 || (!_tcschr(tmp, _T('@'))) || (!_tcschr(tmp, _T('.'))))
{
- MessageBox(0, TranslateT("Invalid Email"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("Invalid Email")), TranslateW(_T("Error")), MB_OK);
delete [] tmp;
break;
}
@@ -1280,7 +1155,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
wfstream f(path.c_str(), std::ios::out);
if(!f.is_open())
{
- MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK);
+ MessageBox(0, TranslateW(_T("Failed to open file")), TranslateW(_T("Error")), MB_OK);
break;
}
f<<"Key-Type: ";
@@ -1372,16 +1247,6 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
params.out = &out;
params.code = &code;
params.result = &result;
- SetWindowTextA(GetDlgItem(hwndDlg, IDC_GENERATING_TEXT), Translate("Generating new key, please wait..."));
- EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_TYPE), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_LENGTH), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_PASSWD), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_REAL_NAME), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_EMAIL), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_COMMENT), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_EXPIRE_DATE), 0);
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::minutes(10)))
{
@@ -1702,25 +1567,10 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,
{
out.erase(s, 1);
}
- std::string::size_type p1 = 0, p2 = 0;
- p1 = out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----");
- if(p1 != std::string::npos)
- {
- p2 = out.find("-----END PGP PUBLIC KEY BLOCK-----", p1);
- if(p2 != std::string::npos)
- {
- p2 += strlen("-----END PGP PUBLIC KEY BLOCK-----");
- out = out.substr(p1, p2-p1);
- TCHAR *tmp = mir_a2t(out.c_str());
- SetWindowText(hPubKeyEdit, tmp);
- mir_free(tmp);
- }
- else
- MessageBox(NULL, TranslateT("Failed to export public key."), TranslateT("Error"), MB_OK);
- }
- else
- MessageBox(NULL, TranslateT("Failed to export public key."), TranslateT("Error"), MB_OK);
+ TCHAR *tmp = mir_a2t(out.c_str());
// SetDlgItemText(hPubKeyEdit, IDC_PUBLIC_KEY_EDIT, tmp);
+ SetWindowText(hPubKeyEdit, tmp);
+ mir_free(tmp);
}
DestroyWindow(hwndDlg);
break;
@@ -1772,13 +1622,12 @@ static BOOL CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara
{
extern HANDLE new_key_hcnt;
extern boost::mutex new_key_hcnt_mutex;
- HANDLE hContact = INVALID_HANDLE_VALUE;
+ HANDLE hContact = new_key_hcnt;
+ new_key_hcnt_mutex.unlock();
switch (msg)
{
case WM_INITDIALOG:
{
- hContact = new_key_hcnt;
- new_key_hcnt_mutex.unlock();
SetWindowPos(hwndDlg, 0 , import_key_rect.left, import_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
TranslateDialogDefault(hwndDlg);
ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("subkeys.pgp.net"), 0);
@@ -1920,49 +1769,9 @@ void FirstRun()
void InitCheck()
{
{//parse gpg output
- gpg_valid = isGPGValid();
- bool home_dir_access = false, temp_access = false;
- TCHAR *home_dir = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
- std::wstring test_path = home_dir;
- mir_free(home_dir);
- test_path += _T("/");
- test_path += toUTF16(get_random(13));
- wfstream test_file;
- test_file.open(test_path, std::ios::trunc | std::ios::out);
- if(test_file.is_open() && test_file.good())
- {
- test_file<<_T("access_test\n");
- if(test_file.good())
- home_dir_access = true;
- test_file.close();
- DeleteFile(test_path.c_str());
- }
- home_dir = _tgetenv(_T("TEMP"));
- test_path = home_dir;
- test_path += _T("/");
- test_path += toUTF16(get_random(13));
- test_file.open(test_path, std::ios::trunc | std::ios::out);
- if(test_file.is_open() && test_file.good())
- {
- test_file<<_T("access_test\n");
- if(test_file.good())
- temp_access = true;
- test_file.close();
- DeleteFile(test_path.c_str());
- }
- if(!home_dir_access || !temp_access || !gpg_valid)
- {
- char buf[4096];
- strcpy(buf, gpg_valid?Translate("GPG binary is set and valid (this is good).\n"):Translate("GPG binary unset or invalid (plugin will not work).\n"));
- strcat(buf, home_dir_access?Translate("Home dir write access granted (this is good).\n"):Translate("Home dir have not write access (plugin most probably will not work).\n"));
- strcat(buf, temp_access?Translate("Temp dir write access granted (this is good).\n"):Translate("Temp dir have not write access (plugin should work, but may have some problems, filetransfers will not work)."));
- if(!gpg_valid)
- strcat(buf, Translate("\nGPG will be disabled until you solve this problems"));
- MessageBoxA(0, buf, Translate("GPG plugin problems"), MB_OK);
- }
- if(!gpg_valid)
+ gpg_configured = isGPGConfigured();
+ if(!gpg_configured)
return;
- gpg_keyexist = isGPGKeyExist();
string out;
DWORD code;
pxResult result;
@@ -1987,30 +1796,20 @@ void InitCheck()
if(result == pxNotFound)
return;
}
- home_dir = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
+ TCHAR *home_dir = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
wstring tmp_dir = home_dir;
mir_free(home_dir);
tmp_dir += _T("\\tmp");
_wmkdir(tmp_dir.c_str());
- string question = Translate("Your secret key whith id: ");
+ string question = "Your secret key whith id: ";
char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
+ question += keyid;
+ mir_free(keyid);
+ question += " deleted from gpg secret keyring\nDo you want to set another key ?";
void ShowFirstRunDialog();
- if(!DBGetContactSettingByte(NULL, szGPGModuleName, "FirstRun", 1) && (!keyid[0] || !key[0]))
- {
- question = Translate("You have not set public key for gpg, it's recommended to do it.\nDo you want to do it now ?");
- if(MessageBoxA(0, question.c_str(), Translate("Own public key warning"), MB_YESNO) == IDYES)
- ShowFirstRunDialog();
- }
if(out.find(keyid) == string::npos)
- {
- question += keyid;
- question += Translate(" deleted from gpg secret keyring\nDo you want to set another key ?");
- if(MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES)
+ if(MessageBoxA(0, question.c_str(), "Own secret key warning", MB_YESNO) == IDYES)
ShowFirstRunDialog();
- }
- mir_free(keyid);
- mir_free(key);
}
{
TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
@@ -2043,7 +1842,7 @@ void ImportKey()
new_key_hcnt_mutex.unlock();
bool for_all_sub = false;
if(metaIsProtoMetaContacts(hContact))
- if(MessageBox(0, TranslateT("Do you want load key for all subcontacts ?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
+ if(MessageBox(0, _T("Do you want load key for all subcontacts ?"), _T("Metacontact detected"), MB_YESNO) == IDYES)
for_all_sub = true;
if(metaIsProtoMetaContacts(hContact))
{
diff --git a/messages.cpp b/messages.cpp
index 18b2378..4b4a686 100755
--- a/messages.cpp
+++ b/messages.cpp
@@ -1,4 +1,4 @@
-// Copyright © 2010-2012 sss
+// Copyright © 2010-2011 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -23,8 +23,6 @@ boost::mutex new_key_hcnt_mutex;
bool _terminate = false;
int returnNoError(HANDLE hContact);
-std::list<HANDLE> sent_msgs;
-
int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp)
{
DWORD dbflags = DBEF_UTF;
@@ -54,13 +52,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
}
else
{
- DBWriteContactSettingByte(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 1);
+ DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
if(isContactHaveKey(hContact))
{
- DBWriteContactSettingByte(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 1);
+ DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
@@ -99,30 +97,30 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
wstring cmd;
cmd += _T("--batch ");
{
- char *inkeyid = UniGetContactSettingUtf(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "InKeyID", "");
+ char *inkeyid = UniGetContactSettingUtf(metaGetMostOnline(hContact), szGPGModuleName, "InKeyID", "");
TCHAR *pass = NULL;
- if(inkeyid[0])
+ if(strlen(inkeyid) > 0)
{
string dbsetting = "szKey_";
dbsetting += inkeyid;
dbsetting += "_Password";
pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T(""));
- if(pass[0])
+ if(_tcslen(pass) > 0)
debuglog<<time_str()<<": info: found password in database for key id: "<<inkeyid<<", trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n";
}
else
{
pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T(""));
- if(pass[0])
+ if(_tcslen(pass) > 0)
debuglog<<time_str()<<": info: found password for all keys in database, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n";
}
- if(pass && pass[0])
+ if(_tcslen(pass) > 0)
{
cmd += _T("--passphrase \"");
cmd += pass;
cmd += _T("\" ");
}
- else if(password && password[0])
+ else if(password)
{
debuglog<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n";
cmd += _T("--passphrase \"");
@@ -164,11 +162,6 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(path.c_str());
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
- BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc);
return 0;
}
if(result == pxNotFound)
@@ -182,20 +175,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
{
debuglog<<time_str()<<": info: failed to decrypt messaage from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" password needed, trying to get one\n";
if(_terminate)
- {
- BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc);
break;
- }
{ //save inkey id
string::size_type s = out.find(" encrypted with ");
s = out.find(" ID ", s);
s += strlen(" ID ");
string::size_type s2 = out.find(",",s);
- DBWriteContactSettingString(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str());
+ DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str());
}
void ShowLoadKeyPasswordWindow();
new_key_hcnt_mutex.lock();
@@ -227,11 +213,6 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(path.c_str());
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
- BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc);
return 0;
}
if(result == pxNotFound)
@@ -251,11 +232,6 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(path.c_str());
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
- BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc);
return 0;
}
if(result == pxNotFound)
@@ -283,11 +259,6 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
char *tmp = new char [str.length()+1];
strcpy(tmp, str.c_str());
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
- BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc);
mir_free(tmp);
return 0;
}
@@ -320,11 +291,6 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
debuglog<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n";
char *tmp = mir_strdup(str.c_str());
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
- BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc);
mir_free(tmp);
return 0;
}
@@ -352,7 +318,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D
}
}
}
- if(DBGetContactSettingByte(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 0))
+ if(DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0))
{
if(metaIsSubcontact(hContact))
{
@@ -545,7 +511,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
HistoryLog(ccs->hContact, db_event(msg, 0, 0, dbflags));
return 0;
}
- if(bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && gpg_valid && gpg_keyexist)
+ if(bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && isGPGConfigured())
{
char *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
if(tmp[0])
@@ -557,7 +523,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1);
}
mir_free(tmp);
- if(!isContactHaveKey(ccs->hContact) && bAutoExchange && gpg_valid && gpg_keyexist)
+ if(!isContactHaveKey(ccs->hContact) && bAutoExchange && isGPGConfigured())
{
LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0);
@@ -627,20 +593,6 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
str.append(tmp);
mir_free(tmp);
}
- if(bStripTags && bAppendTags)
- {
- std::wstring::size_type p;
- for(p = str.find(inopentag); p != std::wstring::npos; p = str.find(inopentag))
- str.erase(p, _tcslen(inopentag));
- for(p = str.find(inclosetag); p != std::wstring::npos; p = str.find(inclosetag))
- str.erase(p, _tcslen(inclosetag));
- for(p = str.find(outopentag); p != std::wstring::npos; p = str.find(outopentag))
- str.erase(p, _tcslen(outopentag));
- for(p = str.find(outclosetag); p != std::wstring::npos; p = str.find(outclosetag))
- str.erase(p, _tcslen(outclosetag));
- }
-/* for(std::wstring::size_type i = str.find(_T("\r\n")); i != std::wstring::npos; i = str.find(_T("\r\n"), i+1))
- str.replace(i, 2, _T("\n")); */
string out;
DWORD code;
wstring cmd;
@@ -660,7 +612,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
cmd += _T("--comment \"\" --no-version ");
if(DBGetContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 0))
cmd += _T("--trust-model always ");
- cmd += _T("--batch --yes -e -a -t -r ");
+ cmd += _T("--batch --yes -e -a -r ");
TCHAR *tmp2 = mir_a2t(tmp);
mir_free(tmp);
cmd += tmp2;
@@ -794,7 +746,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT));
if(!(flags & PREF_UTF))
flags |= PREF_UTF;
- sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str()));
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str());
mir_free(msg);
return 0;
}
@@ -814,7 +766,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
return CallService(MS_PROTO_CHAINSEND, w, l);
if(!isContactHaveKey(ccs->hContact))
{
- if(bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && gpg_valid)
+ if(bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && isGPGConfigured())
{
void send_encrypted_msgs_thread(HANDLE hContact);
LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
@@ -875,7 +827,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
return CallService(MS_PROTO_CHAINSEND, w, l);
}
}
- if(!isContactSecured(ccs->hContact) || metaIsProtoMetaContacts(ccs->hContact))
+ if(metaIsProtoMetaContacts(ccs->hContact) || !isContactSecured(ccs->hContact))
{
mir_free(msg);
return CallService(MS_PROTO_CHAINSEND, w, l);
@@ -917,8 +869,6 @@ int HookSendMsg(WPARAM w, LPARAM l)
}
event_processing_mutex.unlock();
}
- if(metaIsProtoMetaContacts(hContact) && !isContactSecured(metaGetMostOnline(hContact)))
- return 0;
return 1;
}
if(!isContactSecured(hContact))
@@ -940,15 +890,14 @@ int HookSendMsg(WPARAM w, LPARAM l)
static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- char *inkeyid = NULL;
+ char *inkeyid = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "InKeyID", "");
+ new_key_hcnt_mutex.unlock();
+ TCHAR *tmp = NULL;
+
switch (msg)
{
case WM_INITDIALOG:
{
- inkeyid = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "InKeyID", "");
- new_key_hcnt_mutex.unlock();
- TCHAR *tmp = NULL;
-
SetWindowPos(hwndDlg, 0, key_password_rect.left, key_password_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
TranslateDialogDefault(hwndDlg);
string questionstr = "Please enter password for key with ID: ";
@@ -967,12 +916,12 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L
{
TCHAR tmp[64];
GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, tmp, 64);
- if(tmp[0])
+ if(_tcslen(tmp) > 0)
{
extern TCHAR *password;
if(IsDlgButtonChecked(hwndDlg, IDC_SAVE_PASSWORD))
{
- if(inkeyid && inkeyid[0] && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULT_PASSWORD))
+ if((strlen(inkeyid) > 0) && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULT_PASSWORD))
{
string dbsetting = "szKey_";
dbsetting += inkeyid;
diff --git a/new_gpg.vcxproj b/new_gpg.vcxproj
index 0dad1bc..69f5edd 100755
--- a/new_gpg.vcxproj
+++ b/new_gpg.vcxproj
@@ -659,7 +659,7 @@
<Link>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>x:\temp\windows\libs\boost\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Boost\lib-release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
<OptimizeReferences>true</OptimizeReferences>