diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2011-04-13 16:43:43 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2011-04-13 16:43:43 +0300 |
commit | 191c2e330ab91f4b35860e08c5424667ed1893c5 (patch) | |
tree | 986158bd87ca65c1a3a722f2593b9d32a1aede56 | |
parent | f1a201a3c3aeb1ec731d50568eb583a21ed1440c (diff) | |
parent | 3d4fe3639635d0496906fb56b8014b14b0fd1ec7 (diff) |
Merge branch 'new_gpg' into new_gpg_autoexchange
Conflicts:
messages.cpp
-rw-r--r-- | gpg_wrapper.cpp | 6 | ||||
-rw-r--r-- | gpg_wrapper.h | 1 | ||||
-rw-r--r-- | icons.cpp | 10 | ||||
-rw-r--r-- | main.cpp | 46 | ||||
-rw-r--r-- | messages.cpp | 75 | ||||
-rw-r--r-- | new_gpg.rc | 101 | ||||
-rw-r--r-- | new_gpg.vcxproj | 6 | ||||
-rw-r--r-- | options.cpp | 23 | ||||
-rw-r--r-- | srmm.cpp | 9 | ||||
-rw-r--r-- | utilities.cpp | 71 | ||||
-rw-r--r-- | utilities.h | 67 |
11 files changed, 280 insertions, 135 deletions
diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp index 3ed7f4a..0a50667 100644 --- a/gpg_wrapper.cpp +++ b/gpg_wrapper.cpp @@ -21,7 +21,7 @@ //boost::mutex gpg_mutex; -pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result, HANDLE hProcess) +pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result, HANDLE hProcess, PROCESS_INFORMATION *pr) { // gpg_mutex.lock(); if(!gpg_configured) @@ -122,6 +122,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD while (TRUE) { + if(!pri.hProcess) + break; success=GetExitCodeProcess(pri.hProcess,aexitcode); if (success && *aexitcode!=STILL_ACTIVE) break; @@ -157,5 +159,5 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD void pxEexcute_thread(void *param) { gpg_execution_params *params = (gpg_execution_params*)param; - pxResult result = pxExecute(params->cmd, params->useless, params->out, params->code, params->result, params->hProcess); + pxResult result = pxExecute(params->cmd, params->useless, params->out, params->code, params->result, params->hProcess, params->proc); } diff --git a/gpg_wrapper.h b/gpg_wrapper.h index f9d6670..77f84f8 100644 --- a/gpg_wrapper.h +++ b/gpg_wrapper.h @@ -25,6 +25,7 @@ struct gpg_execution_params LPDWORD code;
pxResult *result;
HANDLE hProcess;
+ PROCESS_INFORMATION *proc;
};
void pxEexcute_thread(void *param);
@@ -82,7 +82,9 @@ void setClistIcon(HANDLE hContact) bool enabled = isContactSecured(hContact);
extern HANDLE g_hCLIcon;
HANDLE hMC = hContact;
- if(metaIsProtoMetaContacts(hContact))
+ if(metaIsSubcontact(hContact))
+ hMC = metaGetContact(hContact);
+ else if(metaIsProtoMetaContacts(hContact))
hMC = metaGetContact(hContact);
if(g_hCLIcon && enabled)
{
@@ -107,10 +109,12 @@ void setSrmmIcon(HANDLE hContact) hContact = metaGetMostOnline(hContact);
bool enabled = isContactSecured(hContact);
HANDLE hMC = hContact;
- if(metaIsProtoMetaContacts(hContact))
+ if(metaIsSubcontact(hContact))
+ hMC = metaGetContact(hContact);
+ else if(metaIsProtoMetaContacts(hContact))
hMC = metaGetContact(hContact);
if(ServiceExists(MS_MSG_MODIFYICON))
- { // обновить иконки в srmm
+ {
StatusIconData sid = {0};
sid.cbSize = sizeof(sid);
sid.szModule = szGPGModuleName;
@@ -41,31 +41,32 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { SetWindowPos(hwndDlg, 0, firstrun_rect.left, firstrun_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); + SetWindowText(hwndDlg, TranslateW(_T("Set own key"))); col.pszText = _T("Key ID"); col.mask = LVCF_TEXT | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = 50; ListView_InsertColumn(hwndList, 0, &col); ZeroMemory(&col,sizeof(col)); - col.pszText = _T("Email"); + col.pszText = TranslateW(_T("Email")); col.mask = LVCF_TEXT | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = 30; ListView_InsertColumn(hwndList, 1, &col); ZeroMemory(&col,sizeof(col)); - col.pszText = _T("Name"); + col.pszText = TranslateW(_T("Name")); col.mask = LVCF_TEXT | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = 250; ListView_InsertColumn(hwndList, 2, &col); ZeroMemory(&col,sizeof(col)); - col.pszText = _T("Creation date"); + col.pszText = TranslateW(_T("Creation date")); col.mask = LVCF_TEXT | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = 30; ListView_InsertColumn(hwndList, 3, &col); ZeroMemory(&col,sizeof(col)); - col.pszText = _T("Key length"); + col.pszText = TranslateW(_T("Key length")); col.mask = LVCF_TEXT | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = 30; @@ -95,6 +96,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -189,6 +191,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -258,6 +261,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -330,6 +334,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -358,6 +363,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -423,6 +429,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted"; break; } @@ -454,6 +461,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<"GPG execution timed out, aborted\n"; break; } @@ -591,6 +599,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } gpg_configured = false; @@ -710,6 +719,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; gpg_thread.~thread(); debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } @@ -798,6 +808,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; gpg_thread.~thread(); debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } @@ -890,6 +901,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted"; gpg_configured = false; break; @@ -923,6 +935,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<"GPG execution timed out, aborted\n"; gpg_configured = false; break; @@ -1060,6 +1073,7 @@ 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, 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); @@ -1085,7 +1099,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, if(_tcslen(tmp) < 3) { mir_free(tmp); - MessageBox(0, _T("You must set encryption algorythm first"), _T("Error"), MB_OK); + MessageBox(0, TranslateW(_T("You must set encryption algorythm first")), TranslateW(_T("Error")), MB_OK); break; } mir_free(tmp); @@ -1095,14 +1109,14 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, mir_free(tmp); if(length < 1024 || length > 4096) { - MessageBox(0, _T("Key length must be of length from 1024 to 4096 bits"), _T("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, _T("Invalid date"), _T("Error"), MB_OK); + MessageBox(0, TranslateW(_T("Invalid date")), TranslateW(_T("Error")), MB_OK); delete [] tmp; break; } @@ -1111,13 +1125,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, _T("Name must contain at least 5 characters"), _T("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, _T("Name cannot contain '(' or ')'"), _T("Error"), MB_OK); + MessageBox(0, TranslateW(_T("Name cannot contain '(' or ')'")), TranslateW(_T("Error")), MB_OK); delete [] tmp; break; } @@ -1126,7 +1140,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, _T("Invalid Email"), _T("Error"), MB_OK); + MessageBox(0, TranslateW(_T("Invalid Email")), TranslateW(_T("Error")), MB_OK); delete [] tmp; break; } @@ -1142,7 +1156,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, _T("Failed to open file"), _T("Error"), MB_OK); + MessageBox(0, TranslateW(_T("Failed to open file")), TranslateW(_T("Error")), MB_OK); break; } f<<"Key-Type: "; @@ -1239,7 +1253,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -1272,6 +1286,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -1433,6 +1448,7 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam, { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -1541,6 +1557,7 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam, { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; break; } @@ -1651,6 +1668,7 @@ static BOOL CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; } MessageBoxA(0, out.c_str(), "GPG output", MB_OK); @@ -1772,6 +1790,7 @@ void InitCheck() { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; return; } @@ -1884,6 +1903,7 @@ void ImportKey() { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; return; } @@ -1977,7 +1997,7 @@ void ImportKey() tmp = new char [output.substr(s,s2-s-1).length()+1]; strcpy(tmp, output.substr(s,s2-s-1).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(metaGetContact(hContact), szGPGModuleName, "KeyMainName", tmp); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); if((s = output.find(")", s2)) == string::npos) s = output.find(">", s2); diff --git a/messages.cpp b/messages.cpp index 924c0de..8b339ab 100644 --- a/messages.cpp +++ b/messages.cpp @@ -23,7 +23,7 @@ boost::mutex new_key_hcnt_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); -int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) +int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp) { DWORD dbflags = DBEF_UTF; { //check for gpg related data @@ -36,9 +36,9 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) void setSrmmIcon(HANDLE); void setClistIcon(HANDLE); bool isContactHaveKey(HANDLE hContact); - if(!DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0)) + if(!isContactSecured(hContact)) { - debuglog<<time_str()<<": info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" whith tyrned off encryption\n"; + debuglog<<time_str()<<": info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with turned off encryption\n"; if(bAutoExchange) { if(!isContactHaveKey(hContact)) @@ -89,7 +89,8 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } else if(MessageBox(0, _T("Do you want try to decrypt encrypted message ?"), _T("Warning"), MB_YESNO) == IDNO) { - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } } @@ -181,15 +182,16 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } if(result == pxNotFound) { DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } _terminate = false; @@ -231,15 +233,16 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } if(result == pxNotFound) { DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } } @@ -249,15 +252,16 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } if(result == pxNotFound) { DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); } { wstring tmp = tmp2; @@ -278,7 +282,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) debuglog<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n"; char *tmp = new char [str.length()+1]; strcpy(tmp, str.c_str()); - HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); mir_free(tmp); return 0; } @@ -310,7 +314,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) str.insert(0, "Failed to decrypt GPG encrypted message.\nMessage body for manual decryption:\n"); debuglog<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n"; char *tmp = mir_strdup(str.c_str()); - HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); mir_free(tmp); return 0; } @@ -324,12 +328,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) if(metaIsSubcontact(hContact)) { char *msg = mir_strdup(toUTF8(str).c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags|DBEF_READ); - HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, dbflags); - return 1; + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); + HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); + mir_free(msg); + return 0; } char *tmp = mir_strdup(toUTF8(str).c_str()); - HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(tmp, timestamp, 0, dbflags)); mir_free(tmp); return 0; } @@ -341,14 +346,14 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) { if(metaIsSubcontact(hContact)) { - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags| DBEF_READ); - HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); + HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); return 0; } - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags|DBEF_READ); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); return 0; } - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } @@ -413,6 +418,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; return 1; } @@ -478,9 +484,9 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { setSrmmIcon(metaGetContact(ccs->hContact)); setClistIcon(metaGetContact(ccs->hContact)); - HistoryLog(metaGetContact(ccs->hContact), "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); + HistoryLog(metaGetContact(ccs->hContact), "PGP Encryption turned on by key autoexchange feature"); } - HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); + HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature"); } } return 1; @@ -498,9 +504,9 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } if((s2 != wstring::npos) && (s1 != wstring::npos)) { //this is public key - if(metaIsSubcontact(ccs->hContact)) + if(metaIsProtoMetaContacts(ccs->hContact)) { - HistoryLog(ccs->hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(ccs->hContact, db_event(msg, 0, 0, dbflags)); return 0; } debuglog<<time_str()<<": info: "<<"received key from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<"\n"; @@ -526,7 +532,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) new_key_hcnt_mutex.lock(); new_key_hcnt = ccs->hContact; ShowNewKeyDialog(); - HistoryLog(ccs->hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(ccs->hContact, db_event(msg, 0, 0, dbflags)); return 0; } if(bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && isGPGConfigured()) @@ -587,7 +593,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } if(!(strstr(msg, "-----BEGIN PGP MESSAGE-----") && strstr(msg, "-----END PGP MESSAGE-----"))) return CallService(MS_PROTO_CHAINRECV, w, l); - boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam)); + boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam, pre->timestamp)); return returnNoError(ccs->hContact); } @@ -621,7 +627,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(!tmp[0]) { mir_free(tmp); - HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT); + HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0,0, DBEF_SENT)); hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); mir_free(msg); return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); @@ -667,6 +673,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; mir_free(msg); return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); @@ -721,6 +728,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; mir_free(msg); return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); @@ -764,7 +772,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) } if(str.empty()) { - HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT); + HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0,0, DBEF_SENT)); hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); debuglog<<time_str()<<": info: Failed to encrypt message with GPG\n"; mir_free(msg); @@ -779,10 +787,13 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(metaIsSubcontact(hContact)) { hcontact_data[metaGetContact(hContact)].msgs_to_pass.push_back(str_event); - HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT|dbflags); + debuglog<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"is subcontact of"<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)metaGetContact(hContact), GCDNF_TCHAR)<<"\n"; + debuglog<<time_str()<<": adding event to metacontact: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)metaGetContact(hContact), GCDNF_TCHAR)<<" on send message.\n"; + HistoryLog(metaGetContact(hContact), db_event((char*)str_event.c_str(), 0,0, DBEF_SENT|dbflags)); } hcontact_data[hContact].msgs_to_pass.push_back(str_event); - HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, dbflags|DBEF_SENT); + debuglog<<time_str()<<": adding event to contact: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" on send message.\n"; + HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT)); if(!(flags & PREF_UTF)) flags |= PREF_UTF; CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str()); @@ -901,6 +912,7 @@ int HookSendMsg(WPARAM w, LPARAM l) if(!strcmp((*i).c_str(), (char*)dbei->pBlob)) { hcontact_data[hContact].msgs_to_pass.erase(i); + debuglog<<time_str()<<": event message: \""<<(char*)dbei->pBlob<<"\" passed event filter, contact "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<", message is in allowed list\n"; event_processing_mutex.unlock(); return 0; } @@ -910,7 +922,10 @@ int HookSendMsg(WPARAM w, LPARAM l) return 1; } if(!isContactSecured(hContact)) + { + debuglog<<time_str()<<": event message: \""<<(char*)dbei->pBlob<<"\" passed event filter, contact "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" is unsecured\n"; return 0; + } if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w)) { char tmp[29]; @@ -13,7 +13,7 @@ #undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// Russian (Russia) resources
+// Русский (Россия) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
@@ -56,11 +56,11 @@ CAPTION "Load Public GPG key" FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "ОК",ID_OK,7,169,50,14
- PUSHBUTTON "Load from file",ID_LOAD_FROM_FILE,277,169,54,14
+ PUSHBUTTON "Load from file",ID_LOAD_FROM_FILE,273,169,58,14
EDITTEXT IDC_PUBLIC_KEY_EDIT,7,7,324,134,ES_MULTILINE | WS_VSCROLL,WS_EX_STATICEDGE
- PUSHBUTTON "Select existing",IDC_SELECT_EXISTING,146,169,50,14
+ PUSHBUTTON "Select existing",IDC_SELECT_EXISTING,113,169,97,14
CONTROL "Turn on encryption",IDC_ENABLE_ENCRYPTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,143,196,10
- PUSHBUTTON "Import key from keyserver",IDC_IMPORT,231,152,97,14,WS_DISABLED
+ PUSHBUTTON "Import key from keyserver",IDC_IMPORT,140,152,188,14,WS_DISABLED
END
IDD_FIRST_RUN DIALOGEX 0, 0, 291, 205
@@ -70,12 +70,12 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN
DEFPUSHBUTTON "ОК",ID_OK,12,184,50,14,WS_DISABLED
CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,23,277,105
- PUSHBUTTON "Generate key",IDC_GENERATE_KEY,11,131,58,14
+ PUSHBUTTON "Generate key",IDC_GENERATE_KEY,8,131,74,14
LTEXT "Select key for use",IDC_STATIC,16,12,186,8
EDITTEXT IDC_KEY_PASSWORD,94,147,77,14,ES_PASSWORD | ES_AUTOHSCROLL
RTEXT "Key password:",IDC_STATIC,12,149,76,8
- PUSHBUTTON "Load other",IDC_OTHER,73,131,56,14
- PUSHBUTTON "Delete key",IDC_DELETE_KEY,132,131,56,14
+ PUSHBUTTON "Load other",IDC_OTHER,83,131,64,14
+ PUSHBUTTON "Delete key",IDC_DELETE_KEY,149,131,70,14
PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,99,163,118,14
END
@@ -87,12 +87,12 @@ BEGIN DEFPUSHBUTTON "ОК",ID_OK,7,87,50,14
LTEXT "Home directory:",IDC_STATIC,9,34,325,8
LTEXT "GnuPG binary:",IDC_STATIC,10,7,147,8
- PUSHBUTTON "Browse",IDC_SET_BIN_PATH,293,18,38,14
- PUSHBUTTON "Browse",IDC_SET_HOME_DIR,293,44,38,14
+ PUSHBUTTON "Browse",IDC_SET_BIN_PATH,293,18,54,14
+ PUSHBUTTON "Browse",IDC_SET_HOME_DIR,293,44,54,14
EDITTEXT IDC_HOME_DIR,7,44,277,14,ES_AUTOHSCROLL
EDITTEXT IDC_BIN_PATH,7,17,277,14,ES_AUTOHSCROLL
PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,7,66,118,14
- CONTROL "Turn on key autoexchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,133,68,113,10
+ CONTROL "Turn on key autoexchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,133,68,191,10
END
IDD_NEW_KEY DIALOGEX 0, 0, 427, 68
@@ -107,31 +107,31 @@ BEGIN CTEXT "Статический",IDC_KEY_FROM,16,12,395,8
END
-IDD_KEY_GEN DIALOGEX 0, 0, 209, 166
+IDD_KEY_GEN DIALOGEX 0, 0, 284, 169
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Key Generation dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "ОК",IDOK,7,145,50,14
- PUSHBUTTON "Отмена",IDCANCEL,152,145,50,14
- COMBOBOX IDC_KEY_TYPE,65,14,48,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
- LTEXT "Key type:",IDC_STATIC,8,16,32,8
- LTEXT "Key length:",IDC_STATIC,7,32,38,8
- LTEXT "Key password:",IDC_STATIC,7,49,53,8
- EDITTEXT IDC_KEY_PASSWD,65,46,55,14,ES_AUTOHSCROLL | WS_GROUP
- LTEXT "Real name:",IDC_STATIC,7,63,54,8
- LTEXT "Email:",IDC_STATIC,7,79,47,8
- LTEXT "Comment:",IDC_STATIC,7,92,53,8
- LTEXT "Expire date:",IDC_STATIC,7,109,40,8
- EDITTEXT IDC_KEY_EMAIL,65,76,55,14,ES_AUTOHSCROLL | WS_GROUP
- EDITTEXT IDC_KEY_REAL_NAME,65,61,55,14,ES_AUTOHSCROLL | WS_GROUP
- EDITTEXT IDC_KEY_COMMENT,65,91,55,14,ES_AUTOHSCROLL | WS_GROUP
- EDITTEXT IDC_KEY_EXPIRE_DATE,65,106,55,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
- LTEXT "ex.: 2010-08-15",IDC_STATIC,127,108,54,8
- EDITTEXT IDC_KEY_LENGTH,65,30,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
- LTEXT "From 1024 to 4096",IDC_STATIC,113,33,62,8
- LTEXT "It can take a long time, be patient",IDC_STATIC,15,132,164,8
- LTEXT "0 - does not expire",IDC_STATIC,67,122,62,8
+ DEFPUSHBUTTON "OK",IDOK,7,148,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,227,148,50,14
+ COMBOBOX IDC_KEY_TYPE,120,14,48,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
+ LTEXT "Key type:",IDC_STATIC,8,16,96,8
+ LTEXT "Key length:",IDC_STATIC,7,32,106,8
+ LTEXT "Key password:",IDC_STATIC,7,49,105,8
+ EDITTEXT IDC_KEY_PASSWD,120,46,55,14,ES_AUTOHSCROLL | WS_GROUP
+ LTEXT "Real name:",IDC_STATIC,7,63,105,8
+ LTEXT "Email:",IDC_STATIC,7,79,108,8
+ LTEXT "Comment:",IDC_STATIC,7,92,107,8
+ LTEXT "Expire date:",IDC_STATIC,7,109,111,8
+ EDITTEXT IDC_KEY_EMAIL,120,76,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_REAL_NAME,120,61,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_COMMENT,120,91,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_EXPIRE_DATE,120,106,55,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
+ LTEXT "ex.: 2010-08-15",IDC_STATIC,182,108,75,8
+ EDITTEXT IDC_KEY_LENGTH,120,30,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
+ LTEXT "From 1024 to 4096",IDC_STATIC,168,33,89,8
+ LTEXT "It can take a long time, be patient",IDC_STATIC,15,132,246,8
+ LTEXT "0 - does not expire",IDC_STATIC,122,122,141,8
END
IDD_LOAD_EXISTING_KEY DIALOGEX 0, 0, 370, 257
@@ -213,9 +213,9 @@ BEGIN IDD_KEY_GEN, DIALOG
BEGIN
LEFTMARGIN, 7
- RIGHTMARGIN, 202
+ RIGHTMARGIN, 277
TOPMARGIN, 7
- BOTTOMMARGIN, 159
+ BOTTOMMARGIN, 162
END
IDD_LOAD_EXISTING_KEY, DIALOG
@@ -292,12 +292,12 @@ BEGIN END
END
-#endif // Russian (Russia) resources
+#endif // Русский (Россия) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
+// Английский (США) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@@ -314,8 +314,8 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN
CONTROL "",IDC_USERLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,17,272,112
CTEXT "Userlist:",IDC_STATIC,25,7,201,8
- PUSHBUTTON "Export PubKey",IDC_SAVE_KEY_BUTTON,8,135,66,14
- PUSHBUTTON "Delete key",IDC_DELETE_KEY_BUTTON,78,135,70,14
+ PUSHBUTTON "Export PubKey",IDC_SAVE_KEY_BUTTON,8,135,75,14
+ PUSHBUTTON "Delete key",IDC_DELETE_KEY_BUTTON,90,135,70,14
PUSHBUTTON "Select own key",IDC_SELECT_KEY,170,193,109,14
CONTROL "Turn on debug log",IDC_DEBUG_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,159,89,10
EDITTEXT IDC_LOG_FILE_EDIT,11,157,98,14,ES_AUTOHSCROLL
@@ -324,15 +324,15 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,175,251,10
LTEXT "Current key",IDC_CURRENT_KEY,48,196,116,8
CONTROL "Encrypt file transfers",IDC_FILE_TRANSFERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,185,137,10
- CONTROL "Automatic key exchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,137,117,10
+ CONTROL "Automatic key exchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,137,111,10
END
IDD_OPT_GPG_BIN DIALOGEX 0, 0, 282, 214
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
- PUSHBUTTON "Browse",IDC_SET_BIN_PATH,216,17,38,14
- PUSHBUTTON "Browse",IDC_SET_HOME_DIR,217,44,38,14
+ PUSHBUTTON "Browse",IDC_SET_BIN_PATH,216,17,60,14
+ PUSHBUTTON "Browse",IDC_SET_HOME_DIR,217,44,57,14
EDITTEXT IDC_BIN_PATH,7,17,195,14,ES_AUTOHSCROLL
EDITTEXT IDC_HOME_DIR,7,44,195,14,ES_AUTOHSCROLL
LTEXT "GnuPG binary:",IDC_STATIC,10,7,147,8
@@ -357,7 +357,26 @@ BEGIN RTEXT "Close:",IDC_STATIC,127,49,23,8
END
-#endif // English (United States) resources
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT_GPG, DIALOG
+ BEGIN
+ END
+
+ IDD_OPT_GPG_BIN, DIALOG
+ BEGIN
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Английский (США) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/new_gpg.vcxproj b/new_gpg.vcxproj index a325fb9..19274a0 100644 --- a/new_gpg.vcxproj +++ b/new_gpg.vcxproj @@ -499,7 +499,7 @@ <Culture>0x0809</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies) libboost_thread-vc100-mt-sgd-1_46_1.lib</AdditionalDependencies>
+ <AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies) libboost_thread-vc100-mt-sgd-1_47.lib</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>e:\temp\windows\libs\Boost\lib-debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -527,7 +527,7 @@ </Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>x:\temp\windows\libs\utf8cpp\include;X:\temp\windows\libs\Boost\include\boost-1_46;x:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>e:\temp\windows\libs\utf8cpp\include;e:\temp\windows\libs\Boost\include\boost-1_46;e:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTPLUG_EXPORTS;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@@ -551,7 +551,7 @@ <Link>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>X:\temp\windows\libs\Boost\lib-debug-x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>e:\temp\windows\libs\Boost\lib-debug-x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<GenerateMapFile>false</GenerateMapFile>
diff --git a/options.cpp b/options.cpp index 04cb56b..7eafe97 100644 --- a/options.cpp +++ b/options.cpp @@ -100,31 +100,31 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
- col.pszText = _T("Contact");
+ col.pszText = TranslateW(_T("Contact"));
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.fmt = LVCFMT_LEFT;
col.cx = 60;
ListView_InsertColumn(hwndList, 0, &col);
ZeroMemory(&col,sizeof(col));
- col.pszText = _T("Key ID");
+ col.pszText = TranslateW(_T("Key ID"));
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.fmt = LVCFMT_LEFT;
col.cx = 50;
ListView_InsertColumn(hwndList, 1, &col);
ZeroMemory(&col,sizeof(col));
- col.pszText = _T("Name");
+ col.pszText = TranslateW(_T("Name"));
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.fmt = LVCFMT_LEFT;
col.cx = 50;
ListView_InsertColumn(hwndList, 2, &col);
ZeroMemory(&col,sizeof(col));
- col.pszText = _T("Email");
+ col.pszText = TranslateW(_T("Email"));
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.fmt = LVCFMT_LEFT;
col.cx = 50;
ListView_InsertColumn(hwndList, 3, &col);
ZeroMemory(&col,sizeof(col));
- col.pszText = _T("Protocol");
+ col.pszText = TranslateW(_T("Protocol"));
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.fmt = LVCFMT_LEFT;
col.cx = 60;
@@ -180,7 +180,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_JABBER_API), bIsMiranda09);
EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), (bIsMiranda09 && bJabberAPI));
{
- string keyinfo = "Current private key id: ";
+ string keyinfo = Translate("Current private key id: ");
char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
keyinfo += (strlen(keyid) > 0)?keyid:"not set";
mir_free(keyid);
@@ -257,6 +257,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
+ params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
mir_free(tmp);
break;
@@ -466,6 +467,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP {
gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
+ params.hProcess = NULL;
}
DBWriteContactSettingTString(NULL, szGPGModuleName, "szGpgBinPath", tmp_path);
mir_free(tmp_path);
@@ -649,7 +651,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP hcnt = metaGetMostOnline(hcnt);
TranslateDialogDefault(hwndDlg);
{
- string msg = "Load Public GPG Key for ";
+ string msg = Translate("Load Public GPG Key for ");
msg += (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hcnt, 0);
SetWindowTextA(hwndDlg, msg.c_str());
}
@@ -660,10 +662,10 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_ENCRYPTION), 0);
}
if(isContactSecured(hcnt))
- SetDlgItemText(hwndDlg, IDC_ENABLE_ENCRYPTION, _T("Turn off encryption"));
+ SetDlgItemText(hwndDlg, IDC_ENABLE_ENCRYPTION, TranslateW(_T("Turn off encryption")));
else
{
- SetDlgItemText(hwndDlg, IDC_ENABLE_ENCRYPTION, _T("Turn on encryption"));
+ SetDlgItemText(hwndDlg, IDC_ENABLE_ENCRYPTION, TranslateW(_T("Turn on encryption")));
CheckDlgButton(hwndDlg, IDC_ENABLE_ENCRYPTION, 1);
}
if(hcnt)
@@ -712,6 +714,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP {
gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
+ params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
}
if((out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") != string::npos) && (out.find("-----END PGP PUBLIC KEY BLOCK-----") != string::npos))
@@ -864,6 +867,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP {
gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
+ params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -1100,6 +1104,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP {
gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
+ params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -34,11 +34,13 @@ int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) { int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam;
+ HANDLE hMeta = hContact;
if(metaIsProtoMetaContacts(hContact))
hContact = metaGetMostOnline(hContact); // возьмем тот, через который пойдет сообщение
-
+ else if(metaIsSubcontact(hContact))
+ hMeta = metaGetContact(hContact);
StatusIconClickData *sicd = (StatusIconClickData *)lParam;
- if(strcmp(sicd->szModule, szGPGModuleName) != 0)
+ if(strcmp(sicd->szModule, szGPGModuleName))
return 0; // not our event
void setSrmmIcon(HANDLE);
@@ -48,6 +50,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { if(enc)
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
+ DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 0);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
@@ -65,6 +68,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { else
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1);
+ DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
return 0;
@@ -72,6 +76,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { if(isContactHaveKey(hContact))
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1);
+ DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
diff --git a/utilities.cpp b/utilities.cpp index d368c56..dbf8786 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -201,7 +201,7 @@ int SendKey(WPARAM w, LPARAM l) BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)szMessage); - HistoryLog(hContact, "Public key sent", EVENTTYPE_MESSAGE, DBEF_SENT); + HistoryLog(hContact, db_event("Public key sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); } mir_free(szMessage); @@ -218,25 +218,23 @@ int ToggleEncryption(WPARAM w, LPARAM l) enc = DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0); else enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); + if(metaIsProtoMetaContacts(hContact)) { - if(metaIsProtoMetaContacts(hContact)) + HANDLE hcnt = NULL; + if(MessageBox(0, _T("Do you want to toggle encryption for all subcontacts ?"), _T("Metacontact detected"), MB_YESNO) == IDYES) { - HANDLE hcnt = NULL; - if(MessageBox(0, _T("Do you want to toggle encryption for all subcontacts ?"), _T("Metacontact detected"), MB_YESNO) == IDYES) + int count = metaGetContactsNum(hContact); + for(int i = 0; i < count; i++) { - int count = metaGetContactsNum(hContact); - for(int i = 0; i < count; i++) - { - hcnt = metaGetSubcontact(hContact, i); - if(hcnt) - DBWriteContactSettingByte(hcnt, szGPGModuleName, "GPGEncryption", enc?0:1); - } - DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc?0:1); + hcnt = metaGetSubcontact(hContact, i); + if(hcnt) + DBWriteContactSettingByte(hcnt, szGPGModuleName, "GPGEncryption", enc?0:1); } + DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc?0:1); } - else - DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", enc?0:1); } + else + DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", enc?0:1); void setSrmmIcon(HANDLE hContact); void setClistIcon(HANDLE hContact); setSrmmIcon(hContact); @@ -380,6 +378,7 @@ int onProtoAck(WPARAM w, LPARAM l) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; return 0; } @@ -424,6 +423,7 @@ int onProtoAck(WPARAM w, LPARAM l) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(filename); return 0; @@ -490,6 +490,7 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; return 0; } @@ -505,6 +506,7 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) { delete gpg_thread; TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; return 0; } @@ -582,16 +584,19 @@ void storeOutput(HANDLE ahandle, string *output) } while (available>0); } -void HistoryLog(HANDLE hContact, char *data, int event_type, int flags) +void HistoryLog(HANDLE hContact, db_event evt) { DBEVENTINFO Event = {0}; Event.cbSize = sizeof(Event); Event.szModule = szGPGModuleName; - Event.eventType = event_type; - Event.flags = flags; - Event.timestamp = (DWORD)time(NULL); - Event.cbBlob = strlen(data)+1; - Event.pBlob = (PBYTE)_strdup(data); + Event.eventType = evt.eventType; + Event.flags = evt.flags; + if(!evt.timestamp) + Event.timestamp = (DWORD)time(NULL); + else + Event.timestamp = evt.timestamp; + Event.cbBlob = strlen((char*)evt.pBlob)+1; + Event.pBlob = (PBYTE)_strdup((char*)evt.pBlob); CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)hContact,(LPARAM)&Event); } @@ -771,6 +776,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<"GPG execution timed out, aborted\n"; } DeleteFile(path_out.c_str()); @@ -899,17 +905,15 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi { gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; -// sign_file_mutex.unlock(); return FALSE; } if(result == pxNotFound) { -// sign_file_mutex.unlock(); return FALSE; } DeleteFile(path_out.c_str()); -// sign_file_mutex.unlock(); if(out.find("key ID ") != string::npos) { //need to get hcontact here, i can get jid from hxml, and get handle from jid, maybe exists better way ? @@ -975,18 +979,24 @@ void AddHandlers() bool isContactSecured(HANDLE hContact) { - if(metaIsProtoMetaContacts(hContact)) - hContact = metaGetContact(hContact); BYTE gpg_enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); if(!gpg_enc) + { + debuglog<<time_str()<<": encryption is turned off for "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; return false; - TCHAR *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); - if(!key[0]) + } + if(!metaIsProtoMetaContacts(hContact)) { + TCHAR *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); + if(!key[0]) + { + mir_free(key); + debuglog<<time_str()<<": encryption is turned off for "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; + return false; + } mir_free(key); - return false; } - mir_free(key); + debuglog<<time_str()<<": encryption is turned on for "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; return true; } @@ -1147,7 +1157,8 @@ void send_encrypted_msgs_thread(HANDLE hContact) for(list<string>::iterator p = hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p) { CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)p->c_str()); - HistoryLog(hContact, (char*)p->c_str(), EVENTTYPE_MESSAGE, DBEF_SENT); + + HistoryLog(hContact, db_event((char*)p->c_str(),0,0, DBEF_SENT)); boost::this_thread::sleep(boost::posix_time::seconds(1)); } return; diff --git a/utilities.h b/utilities.h index bb4b459..5922311 100644 --- a/utilities.h +++ b/utilities.h @@ -24,8 +24,6 @@ void GetFolderPath(TCHAR *WindowTittle, char *szSetting); void storeOutput(HANDLE ahandle, string *output);
-
-void HistoryLog(HANDLE hContact, char *data, int event_type, int flags);
int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data);
bool isContactSecured(HANDLE hContact);
bool isContactHaveKey(HANDLE hContact);
@@ -36,4 +34,69 @@ wstring toUTF16(string str); string get_random(int length);
string time_str();
+struct db_event : public DBEVENTINFO
+{
+public:
+ db_event(char* msg)
+ {
+ eventType = EVENTTYPE_MESSAGE;
+ flags = 0;
+ timestamp = 0;
+ szModule = 0;
+ cbSize = 0;
+ cbBlob = strlen(msg)+1;
+ pBlob = (PBYTE)msg;
+ }
+ db_event(char* msg, DWORD time)
+ {
+ cbBlob = strlen(msg)+1;
+ pBlob = (PBYTE)msg;
+ eventType = EVENTTYPE_MESSAGE;
+ flags = 0;
+ timestamp = time;
+ szModule = 0;
+ cbSize = 0;
+ }
+ db_event(char* msg, DWORD time, int type)
+ {
+ cbBlob = strlen(msg)+1;
+ pBlob = (PBYTE)msg;
+ if(type)
+ eventType = type;
+ else
+ eventType = EVENTTYPE_MESSAGE;
+ flags = 0;
+ timestamp = time;
+ szModule = 0;
+ cbSize = 0;
+ }
+ db_event(char* msg, int type)
+ {
+ cbBlob = strlen(msg)+1;
+ pBlob = (PBYTE)msg;
+ flags = 0;
+ if(type)
+ eventType = type;
+ else
+ eventType = EVENTTYPE_MESSAGE;
+ timestamp = 0;
+ szModule = 0;
+ cbSize = 0;
+ }
+ db_event(char* msg, DWORD time, int type, DWORD _flags)
+ {
+ cbBlob = strlen(msg)+1;
+ pBlob = (PBYTE)msg;
+ if(type)
+ eventType = type;
+ else
+ eventType = EVENTTYPE_MESSAGE;
+ flags = _flags;
+ timestamp = time;
+ szModule = 0;
+ cbSize = 0;
+ }
+};
+void HistoryLog(HANDLE, db_event);
+
#endif
|