summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-08-29 19:48:43 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-08-29 19:48:43 +0300
commit2fddf1d26f7fc33d12abe95015ec67d48b8e7131 (patch)
tree4aabc5a7937fd89661f984837a07efa0ab36e99d /plugins
parent0547bea1ba1c85d16b934fd795d46e32829d916d (diff)
fixes #1557 (Msg_Export: move some strings to debug log)
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/Msg_Export/src/FileViewer.cpp23
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp36
-rwxr-xr-xplugins/Msg_Export/src/utils.h4
3 files changed, 22 insertions, 41 deletions
diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp
index 4f36f9fbd3..6a50585603 100755
--- a/plugins/Msg_Export/src/FileViewer.cpp
+++ b/plugins/Msg_Export/src/FileViewer.cpp
@@ -395,18 +395,9 @@ bool bOpenExternaly(MCONTACT hContact)
sStartupInfo.lpTitle = (wchar_t*)sFileViewerPrg.c_str();
PROCESS_INFORMATION stProcesses = {};
- if (!CreateProcess(nullptr,
- (wchar_t*)sTmp.c_str(),
- nullptr,
- nullptr,
- FALSE,
- CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
- nullptr,
- nullptr,
- &sStartupInfo,
- &stProcesses)) {
- DisplayLastError(LPGENW("Failed to execute external file view"));
- }
+ if (!CreateProcess(nullptr, (wchar_t*)sTmp.c_str(), 0, 0, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, 0, 0, &sStartupInfo, &stProcesses))
+ LogLastError(L"Failed to execute external file view");
+
return true;
}
@@ -433,7 +424,7 @@ bool bUseInternalViewer(bool bNew)
if (g_bUseIntViewer && !hRichEditDll) {
hRichEditDll = LoadLibraryA("Msftedit.dll");
if (!hRichEditDll) {
- DisplayLastError(LPGENW("Failed to load Rich Edit (Msftedit.dll)"));
+ LogLastError(L"Failed to load Rich Edit (Msftedit.dll)");
return false;
}
}
@@ -939,7 +930,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam,
FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
- DisplayLastError(LPGENW("Failed to create file"));
+ LogLastError(L"Failed to create file");
return TRUE;
}
@@ -949,7 +940,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam,
eds.pfnCallback = RichEditStreamSaveFile;
LRESULT nWriteOk = SendMessage(hRichEdit, EM_STREAMOUT, (WPARAM)SF_RTF, (LPARAM)&eds);
if (nWriteOk <= 0 || eds.dwError != 0) {
- DisplayLastError(TranslateT("Failed to save file"));
+ LogLastError(L"Failed to save file");
CloseHandle(hFile);
return TRUE;
}
@@ -1034,7 +1025,7 @@ bool bShowFileViewer(MCONTACT hContact)
ShowWindow(pcl->hWnd, SW_SHOWNORMAL);
return true;
}
- DisplayLastError(LPGENW("Failed to create history dialog"));
+
delete pcl;
return false;
}
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index 815cb22ce5..76472650fa 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -143,7 +143,7 @@ static void ReplaceAll(wstring &sSrc, const wchar_t *pszReplace, const wchar_t *
// Parameters : dwError - ?
// Returns : string
-wstring sGetErrorString(DWORD dwError)
+CMStringW sGetErrorString(DWORD dwError)
{
LPVOID lpMsgBuf;
FormatMessage(
@@ -157,31 +157,32 @@ wstring sGetErrorString(DWORD dwError)
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
- wstring ret = (LPCTSTR)lpMsgBuf;
- ReplaceAll(ret, L"\r", L" ");
- ReplaceAll(ret, L"\n", L" ");
- ReplaceAll(ret, L" ", L" ");
+ CMStringW ret((LPCTSTR)lpMsgBuf);
+ ret.Replace(L"\r", L" ");
+ ret.Replace(L"\n", L" ");
+ ret.Replace(L" ", L" ");
// Free the buffer.
LocalFree(lpMsgBuf);
return ret;
}
-wstring sGetErrorString()
+CMStringW sGetErrorString()
{
return sGetErrorString(GetLastError());
}
-void DisplayLastError(const wchar_t *pszError)
+void LogLastError(const wchar_t *pszError)
{
- wstring sError = pszError;
DWORD error = GetLastError();
+ CMStringW sError = pszError;
+
wchar_t szTemp[50];
- mir_snwprintf(szTemp, L"\r\nErrorCode: %d\r\n", error);
+ mir_snwprintf(szTemp, L"MsgExport error\r\nErrorCode: %d\r\n", error);
sError += szTemp;
sError += sGetErrorString(error);
- MessageBox(nullptr, sError.c_str(), MSG_BOX_TITEL, MB_OK);
+ Netlib_LogW(nullptr, sError.c_str());
}
/////////////////////////////////////////////////////////////////////
@@ -354,14 +355,7 @@ wstring GetFilePathFromUser(MCONTACT hContact)
// we can not use FILE_SHARE_DELETE because this is not supported by
// win 98 / ME
- HANDLE hPrevFile = CreateFile(sPrevFileName.c_str(),
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- nullptr,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- nullptr);
-
+ HANDLE hPrevFile = CreateFile(sPrevFileName.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hPrevFile != INVALID_HANDLE_VALUE) {
CloseHandle(hPrevFile);
wchar_t szTemp[500];
@@ -378,9 +372,7 @@ wstring GetFilePathFromUser(MCONTACT hContact)
sFilePath.c_str());
bTryRename = MessageBox(nullptr, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES;
}
- else
- bTryRename = true;
-
+ else bTryRename = true;
if (bTryRename) {
if (!MoveFile(sPrevFileName.c_str(), sFilePath.c_str())) {
@@ -1245,7 +1237,7 @@ int nContactDeleted(WPARAM hContact, LPARAM)
TranslateT("Failed to delete the file"),
sFilePath.c_str());
- DisplayLastError(szTemp);
+ LogLastError(szTemp);
}
}
}
diff --git a/plugins/Msg_Export/src/utils.h b/plugins/Msg_Export/src/utils.h
index 32e242c4ff..b976e6f5ef 100755
--- a/plugins/Msg_Export/src/utils.h
+++ b/plugins/Msg_Export/src/utils.h
@@ -43,9 +43,7 @@ extern bool g_bUseLessAndGreaterInExport;
extern bool g_bReplaceHistory;
-wstring sGetErrorString(DWORD dwError);
-wstring sGetErrorString();
-void DisplayLastError(const wchar_t *pszError);
+void LogLastError(const wchar_t *pszError);
void DisplayErrorDialog(const wchar_t *pszError, wstring &sFilePath, DBEVENTINFO *dbei);
bool bIsExportEnabled(MCONTACT hContact);