summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp33
-rw-r--r--messages.cpp19
2 files changed, 24 insertions, 28 deletions
diff --git a/main.cpp b/main.cpp
index f4f4e00..b461349 100644
--- a/main.cpp
+++ b/main.cpp
@@ -413,8 +413,8 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
- TCHAR *path = new TCHAR [MAX_PATH];
DWORD len = MAX_PATH;
+ TCHAR *path = NULL;
tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", (SHGetValue(HKEY_CURRENT_USER, _T("Software\\GNU\\GnuPG\\gpgProgram"), 0, 0, path, &len) == ERROR_SUCCESS)?path:_T(""));
delete [] path;
SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
@@ -437,7 +437,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
case IDC_SET_BIN_PATH:
GetFilePath(_T("Choose gpg2.exe"), "szGpgBinPath", _T("*.exe"), _T("EXE Executables"));
- tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", _T("gpg2.exe"));
+ tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", _T("gpg.exe"));
SetDlgItemText(hwndDlg, IDC_BIN_PATH, tmp);
mir_free(tmp);
break;
@@ -1125,6 +1125,12 @@ void FirstRun()
void InitCheck()
{
{//parse gpg output
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ if(strlen(keyid) < 1)
+ {
+ mir_free(keyid);
+ return;
+ }
string out;
DWORD code;
pxResult result;
@@ -1149,21 +1155,14 @@ void InitCheck()
return;
}
}
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- if(strlen(keyid) > 0)
- {
- string question = "Your secret key whith id: ";
- question += keyid;
- mir_free(keyid);
- question += " deleted from gpg secret keyring\nDo you want to set another key ?";
- void ShowFirstRunDialog();
- if(out.find(keyid) == string::npos)
- if(MessageBoxA(0, question.c_str(), "Own secret key warning", MB_YESNO) == IDYES)
- ShowFirstRunDialog();
- return;
- }
- else
- mir_free(keyid);
+ string question = "Your secret key whith id: ";
+ question += keyid;
+ mir_free(keyid);
+ question += " deleted from gpg secret keyring\nDo you want to set another key ?";
+ void ShowFirstRunDialog();
+ if(out.find(keyid) == string::npos)
+ if(MessageBoxA(0, question.c_str(), "Own secret key warning", MB_YESNO) == IDYES)
+ ShowFirstRunDialog();
}
}
diff --git a/messages.cpp b/messages.cpp
index f4e9ad6..7cc59e2 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -35,7 +35,6 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
char *msg = pre->szMessage;
if (!msg)
return CallService(MS_PROTO_CHAINRECV, w, l);
- BOOL unicode = (BOOL)(pre->flags&PREF_UNICODE);
HANDLE hContact = ccs->hContact;
if(isProtoMetaContacts(hContact))
hContact = metaGetMostOnline(hContact);
@@ -317,8 +316,10 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
str.erase(str.find_last_of(_T("\n")), 1);
if(!str.length())
{
+ string str = pre->szMessage;
mir_free((void**)pre->szMessage);
- pre->szMessage = "Failed to decrypt GPG encrypted message";
+ str.insert(0, "Failed to decrypt GPG encrypted message:\n");
+ pre->szMessage = mir_strdup(str.c_str());
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
}
else
@@ -329,8 +330,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
str.insert(0, inopentag);
str.append(inclosetag);
}
- char *utf = mir_utf8encodeW(str.c_str());
- pre->szMessage = utf;
+ pre->szMessage = mir_utf8encodeW(str.c_str());
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
}
}
@@ -344,8 +344,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
mir_free(tmp);
mir_free((void**)pre->szMessage);
str.insert(0, _T("Received unencrypted message:\n"));
- char *utf = mir_utf8encodeW(str.c_str());
- pre->szMessage = utf;
+ pre->szMessage = mir_utf8encodeW(str.c_str());
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
}
return CallService(MS_PROTO_CHAINRECV, w, l);
@@ -360,7 +359,6 @@ int SendMsgSvc(WPARAM w, LPARAM l)
char *msg = (char*)(ccs->lParam);
if (!msg)
return CallService(MS_PROTO_CHAINSEND, w, l);
- BOOL unicode = (BOOL)(ccs->wParam&PREF_UNICODE);
HANDLE hContact = ccs->hContact;
if(isProtoMetaContacts(hContact))
hContact = metaGetMostOnline(hContact);
@@ -481,14 +479,13 @@ int SendMsgSvc(WPARAM w, LPARAM l)
HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT);
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
}
- mir_free((void**)ccs->lParam);
- char *utf = mir_u2a(str.c_str());
- ccs->lParam = (LPARAM)utf;
+// mir_free((void**)ccs->lParam);
+ ccs->lParam = (LPARAM)mir_utf8encodeW(str.c_str());
if(bAppendTags)
DBWriteContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(ccs->hContact, szGPGModuleName, "MsgsForTagging", 0) + 1);
}
}
- ccs->wParam&=~PREF_UNICODE;
+// ccs->wParam&=~PREF_UNICODE; //memory leak ?
return CallService(MS_PROTO_CHAINSEND, w, l);
}