diff --git a/src/salmon/compress.cpp b/src/salmon/compress.cpp index e0bf86362..f05ca7044 100644 --- a/src/salmon/compress.cpp +++ b/src/salmon/compress.cpp @@ -38,7 +38,7 @@ BOOL CompresBugReports(CCompressParams* compressParams) char archive[MAX_PATH]; strcpy(archive, BugReports[i].Name); strcat(archive, ".7Z"); - DeleteFile(archive); // aby neselhala nasledna komprese + DeleteFile(archive); // so the subsequent compression does not fail error[0] = 0; BOOL res = CompressFiles(archive, BugReportPath, mask, error, 10000); diff --git a/src/salmon/compress.h b/src/salmon/compress.h index a95e7e432..910e1ca4a 100644 --- a/src/salmon/compress.h +++ b/src/salmon/compress.h @@ -3,11 +3,11 @@ #pragma once -// struktura predavana do compress vlakna, slouzi pro presun vstupne/vystupnich parametru +// structure passed to the compression thread, used to transfer input/output parameters struct CCompressParams { - BOOL Result; // TRUE, pokud operace dobehla uspesne, jinak FALSE - char ErrorMessage[2 * MAX_PATH]; // pokud je Result FALSE, obsahuje popis chyby + BOOL Result; // TRUE if the operation completed successfully, otherwise FALSE + char ErrorMessage[2 * MAX_PATH]; // if Result is FALSE, contains the error description }; BOOL StartCompressThread(CCompressParams* params); diff --git a/src/salmon/config.cpp b/src/salmon/config.cpp index f97abee8e..02ebed30b 100644 --- a/src/salmon/config.cpp +++ b/src/salmon/config.cpp @@ -17,7 +17,7 @@ CConfiguration Config; BOOL CreateKey(HKEY hKey, const char* name, HKEY& createdKey) { - DWORD createType; // info jestli byl klic vytvoren nebo jen otevren + DWORD createType; // info whether the key was created or just opened LONG res = HANDLES(RegCreateKeyEx(hKey, name, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &createdKey, &createType)); diff --git a/src/salmon/config.h b/src/salmon/config.h index 83f67db8f..51e8f588b 100644 --- a/src/salmon/config.h +++ b/src/salmon/config.h @@ -16,7 +16,7 @@ class CConfiguration public: char Description[DESCRIPTION_SIZE]; char Email[EMAIL_SIZE]; - BOOL Restart; // neukladame + BOOL Restart; // not stored public: CConfiguration(); diff --git a/src/salmon/dialogs.cpp b/src/salmon/dialogs.cpp index 9d5edbafd..ddff87d87 100644 --- a/src/salmon/dialogs.cpp +++ b/src/salmon/dialogs.cpp @@ -10,7 +10,7 @@ HWND GetTopVisibleParent(HWND hParent) { - // hledame parenta, ktery uz neni child window (jde o POPUP/OVERLAPPED window) + // look for a parent that is no longer a child window (it is a POPUP/OVERLAPPED window) HWND hIterator = hParent; while ((GetWindowLongPtr(hIterator, GWL_STYLE) & WS_CHILD) && (hIterator = ::GetParent(hIterator)) != NULL && @@ -32,20 +32,20 @@ void MultiMonGetClipRectByRect(const RECT* rect, RECT* workClipRect, RECT* monit void MultiMonGetClipRectByWindow(HWND hByWnd, RECT* workClipRect, RECT* monitorClipRect) { - HMONITOR hMonitor; // na tento monitor okno umistime + HMONITOR hMonitor; // we will place the window on this monitor MONITORINFO mi; mi.cbSize = sizeof(mi); - if (hByWnd != NULL && IsWindowVisible(hByWnd) && !IsIconic(hByWnd)) // pozor, tato podminka je take v MultiMonCenterWindow + if (hByWnd != NULL && IsWindowVisible(hByWnd) && !IsIconic(hByWnd)) // note this condition is also in MultiMonCenterWindow { hMonitor = MonitorFromWindow(hByWnd, MONITOR_DEFAULTTONEAREST); - // vytahneme working area desktopu + // retrieve the desktop working area GetMonitorInfo(hMonitor, &mi); } else { - // pokud nalezneme foreground okno patrici nasi aplikaci, - // centrujeme okno na stejny desktop + // if we find a foreground window belonging to our application, + // center the window on the same desktop HWND hForegroundWnd = GetForegroundWindow(); DWORD processID; GetWindowThreadProcessId(hForegroundWnd, &processID); @@ -55,14 +55,14 @@ void MultiMonGetClipRectByWindow(HWND hByWnd, RECT* workClipRect, RECT* monitorC } else { - // jinak okno centrujeme k primarnimu desktopu + // otherwise center the window on the primary desktop POINT pt; - pt.x = 0; // primarni monitor + pt.x = 0; // primary monitor pt.y = 0; hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); } - // vytahneme working area desktopu + // retrieve the desktop working area GetMonitorInfo(hMonitor, &mi); } *workClipRect = mi.rcWork; @@ -74,14 +74,14 @@ void MultiMonCenterWindowByRect(HWND hWindow, const RECT& clipR, const RECT& byR { if (hWindow == NULL) { - // pri praci s NULL hwnd dochazi k nechtenemu blikani oken + // working with a NULL hwnd causes unwanted window flicker TRACE_E("MultiMonCenterWindowByRect: hWindow == NULL"); return; } if (IsZoomed(hWindow)) { - // s maximalizovany oknem nebudeme hybat + // do not move a maximized window return; } @@ -90,20 +90,20 @@ void MultiMonCenterWindowByRect(HWND hWindow, const RECT& clipR, const RECT& byR int wndWidth = wndRect.right - wndRect.left; int wndHeight = wndRect.bottom - wndRect.top; - // vycentrujeme + // center it wndRect.left = byR.left + (byR.right - byR.left - wndWidth) / 2; wndRect.top = byR.top + (byR.bottom - byR.top - wndHeight) / 2; wndRect.right = wndRect.left + wndWidth; wndRect.bottom = wndRect.top + wndHeight; - // ohlidame hranice - if (wndRect.left < clipR.left) // pokud je okno vetsi nez clipR, nechame zobrazit jeho levou cast + // keep the window within the clipping bounds + if (wndRect.left < clipR.left) // when the window is wider than clipR, leave its left edge visible { wndRect.left = clipR.left; wndRect.right = wndRect.left + wndWidth; } - if (wndRect.top < clipR.top) // pokud je okno vetsi nez clipR, nechame zobrazit jeho hotni cast + if (wndRect.top < clipR.top) // when the window is taller than clipR, leave its top edge visible { wndRect.top = clipR.top; wndRect.bottom = wndRect.top + wndHeight; @@ -111,7 +111,7 @@ void MultiMonCenterWindowByRect(HWND hWindow, const RECT& clipR, const RECT& byR if (wndWidth <= clipR.right - clipR.left) { - // pokud je okno mensi nez clipR, osetrime aby nelezlo vpravo za hranici clipR + // when the window fits inside clipR, prevent it from spilling past the right edge if (wndRect.right >= clipR.right) { wndRect.left = clipR.right - wndWidth; @@ -120,14 +120,14 @@ void MultiMonCenterWindowByRect(HWND hWindow, const RECT& clipR, const RECT& byR } else { - // pokud je okno vetsi nez clipR + // otherwise anchor the window to the left edge so the visible area is maximized if (wndRect.left > clipR.left) - wndRect.left = clipR.left; // vyuzijeme maximalne prostor + wndRect.left = clipR.left; // make maximum use of the space } if (wndHeight <= clipR.bottom - clipR.top) { - // pokud je okno mensi nez clipR, osetrime aby nelezlo dole za hranici clipR + // when the window fits inside clipR, keep it from extending past the bottom edge if (wndRect.bottom >= clipR.bottom) { wndRect.top = clipR.bottom - wndHeight; @@ -136,9 +136,9 @@ void MultiMonCenterWindowByRect(HWND hWindow, const RECT& clipR, const RECT& byR } else { - // pokud je okno vetsi nez clipR + // otherwise anchor the window to the top edge so the visible area is maximized if (wndRect.top > clipR.top) - wndRect.top = clipR.top; // vyuzijeme maximalne prostor + wndRect.top = clipR.top; // make maximum use of the space } SetWindowPos(hWindow, NULL, wndRect.left, wndRect.top, 0, 0, @@ -149,18 +149,18 @@ void MultiMonCenterWindow(HWND hWindow, HWND hByWnd, BOOL findTopWindow) { if (hWindow == NULL) { - // pri praci s NULL hwnd dochazi k nechtenemu blikani oken + // working with a NULL hwnd causes unwanted window flicker TRACE_E("MultiMonCenterWindow: hWindow == NULL"); return; } if (IsZoomed(hWindow)) { - // s maximalizovany oknem nebudeme hybat + // do not move a maximized window return; } - // mame dohledat top-level window + // we need to find the top-level window if (findTopWindow) { if (hByWnd != NULL) @@ -172,7 +172,7 @@ void MultiMonCenterWindow(HWND hWindow, HWND hByWnd, BOOL findTopWindow) RECT clipR; MultiMonGetClipRectByWindow(hByWnd, &clipR, NULL); RECT byR; - if (hByWnd != NULL && IsWindowVisible(hByWnd) && !IsIconic(hByWnd)) // pozor, tato podminka je take v MultiMonGetClipRectByWindow + if (hByWnd != NULL && IsWindowVisible(hByWnd) && !IsIconic(hByWnd)) // note this condition is also in MultiMonGetClipRectByWindow GetWindowRect(hByWnd, &byR); else byR = clipR; @@ -226,7 +226,7 @@ void CMainDialog::ShowChilds(CDialogTaskEnum task, BOOL show) ShowWindow(GetDlgItem(HWindow, ids[i]), show ? SW_SHOW : SW_HIDE); if (!show) { - // nastavim rozmer child okna podle obsahu + // set the size of the child window according to the content HWND hChild = GetDlgItem(HWindow, IDC_SALMON_UPLOADING); char buff[200]; int resID = 0; @@ -260,7 +260,7 @@ void CMainDialog::ShowChilds(CDialogTaskEnum task, BOOL show) SelectObject(hDC, hOldFont); HANDLES(ReleaseDC(HWindow, hDC)); SIZE sz = {tR.right - tR.left, tR.bottom - tR.top}; - sz.cx += 3; // pro jistotu + sz.cx += 3; // just to be sure sz.cy += 1; SetWindowPos(hChild, NULL, 0, 0, sz.cx, sz.cy, SWP_NOZORDER | SWP_NOMOVE); CenterControl(IDC_SALMON_UPLOADING); @@ -292,27 +292,27 @@ void StripWhiteSpaces(char* buff) *s = 0; } -BOOL ValidateEmail(const char* buff) // primitivni kontrola syntakticke validity emailu +BOOL ValidateEmail(const char* buff) // primitive check of the email's syntactic validity { - // predpoklada, ze jsou orezany white spacy na zacatku/konci + // assumes leading/trailing whitespace is trimmed const char* s = buff; - // string nesmi byt prazdny + // the string must not be empty if (*s == 0) return FALSE; - // nejaky znak jiny nez zavinac musi byt pred zacinacem + // some character other than the at sign must precede it if (*s == '@') return FALSE; - // hledame zacinac + // search for the at sign while (*s != '@' && *s != 0) s++; - // pokud jsme ho nenasli, neni email validni + // if we did not find it, the email is not valid if (*s != '@') return FALSE; s++; - // email nemuze koncit zavinacem + // the email cannot end with the at sign if (*s == 0) return FALSE; - // dalsi zavinac uz nesmi byt + // there must not be another at sign while (*s != '@' && *s != 0) s++; if (*s == '@') @@ -356,10 +356,12 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { case WM_INITDIALOG: { - // od monitorovaneho procesu mame pridelene povoleni pro zavolani SetForegroundWindow - // podstatne je, ze jiz bezi nase message loop, jinak to osklive zlobilo (dokud jsme SetForegroundWindow - // volali z OpenMainDialog) - pri spusteni monitorovaneho softu pres StartMenu a padu jsme zustavali dole, - // ProtMon okno nebylo aktivni, nedostalo focus, dokud monitorovany soft nezavrel sve okno + // the monitored process grants us permission to call SetForegroundWindow. + // The crucial detail is to invoke it only once our message loop is already running; + // otherwise Windows behaves poorly (until we call SetForegroundWindow from OpenMainDialog). + // When the monitored application was launched from the Start Menu and crashed, we stayed in the background, + // the ProtMon window remained inactive, and it did not receive focus until the monitored application + // closed its window. SetForegroundWindow(HWindow); MultiMonCenterWindow(HWindow, NULL, FALSE); @@ -388,7 +390,7 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) ShowChilds(dteMinidump, FALSE); } - // focus do pole s popisem padu + // focus the field with the crash description SetFocus(GetDlgItem(HWindow, IDC_SALMON_ACTION)); SendMessage(HWindow, DM_SETDEFID, IDC_SALMON_ACTION, 0); @@ -409,7 +411,7 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_TIMER: { - if (!AppIsBusy && wParam == 666) // chranime se pred stavem, kdy uz mame zobrazeny msgbox; nechceme dalsi + if (!AppIsBusy && wParam == 666) // skip updates while a message box is up; we do not want another one { if (Compressing || Uploading || Minidumping) { @@ -427,7 +429,7 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { Minidumping = FALSE; - // pokud selhalo generovani minidumpu, pouze vyhlasime chybu, ale pokracujeme dale (neco se mohlo povest ulozit) + // if minidump generation failed, just report the error but continue (some data may have been saved) if (!MinidumpParams.Result) { char msg[2 * MAX_PATH]; @@ -437,11 +439,11 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (GetBugReportNames() && GetUniqueBugReportCount() > 1) { - // reportu je vic, doptame se zda je mame poslat vsechny + // if multiple reports exist, ask whether to send them all int res = MessageBox(HWindow, LoadStr(IDS_SALMON_MORE_REPORTS, HLanguage), LoadStr(IDS_SALMON_TITLE, HLanguage), MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND); ReportOldBugs = (res == IDYES); } - // zobrazime hlavni dialog s dotazem + // bring back the main dialog along with the question prompt ShowChilds(dteDialog, TRUE); } @@ -451,7 +453,7 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (CompressParams.Result) { - // spustime upload vlakno + // start the upload thread UploadingIndex = 0; Uploading = StartUploadIndex(UploadingIndex); } @@ -474,14 +476,14 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (UploadingIndex + 1 < BugReports.Count && ReportOldBugs) { - // zacneme uploadit dalsi soubor + // start uploading the next file UploadingIndex++; Uploading = StartUploadIndex(UploadingIndex); } else { MessageBox(HWindow, LoadStr(IDS_SALMON_UPLOADSUCCESS, HLanguage), LoadStr(IDS_SALMON_TITLE, HLanguage), MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); - CleanBugReportsDirectory(FALSE); // napred promazneme, jinak bude Salam pri startu nadavat + CleanBugReportsDirectory(FALSE); // clean first so Salamander does not complain when it starts if (IsDlgButtonChecked(HWindow, IDC_SALMON_RESTART) == BST_CHECKED) RestartSalamander(HWindow); PostQuitMessage(0); @@ -492,7 +494,7 @@ CMainDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) char msg[2 * MAX_PATH]; sprintf(msg, LoadStr(IDS_SALMON_UPLOADFAILED, HLanguage), UploadParams.ErrorMessage); MessageBox(HWindow, msg, LoadStr(IDS_SALMON_TITLE, HLanguage), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND); - CleanBugReportsDirectory(TRUE); // promazeme reporty, nechame jen archivy + CleanBugReportsDirectory(TRUE); // delete the reports, keep only the archives OpenFolder(NULL, BugReportPath); PostQuitMessage(0); } diff --git a/src/salmon/dialogs.h b/src/salmon/dialogs.h index ae749ec77..0c1e4100f 100644 --- a/src/salmon/dialogs.h +++ b/src/salmon/dialogs.h @@ -18,12 +18,12 @@ class CMainDialog : public CDialog BOOL Compressing; BOOL Uploading; BOOL Minidumping; - int UploadingIndex; // index do pole BugReports, ktery prave uploadime + int UploadingIndex; // index into the BugReports array we are currently uploading CCompressParams CompressParams; CUploadParams UploadParams; CMinidumpParams MinidumpParams; char CurrentProgressText[200]; - BOOL MinidumpOnOpen; // ma se po otevreni okna zacit generovat minidump? + BOOL MinidumpOnOpen; // should minidump generation start after opening the window? public: CMainDialog(HINSTANCE modul, int resID, BOOL minidumpOnOpen); diff --git a/src/salmon/minidump.cpp b/src/salmon/minidump.cpp index 7dddafe44..ce19f009d 100644 --- a/src/salmon/minidump.cpp +++ b/src/salmon/minidump.cpp @@ -14,8 +14,8 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, *overSize = FALSE; char szPath[MAX_PATH]; ::GetModuleFileName(NULL, szPath, MAX_PATH); - *(strrchr(szPath, '\\')) = 0; // bezime z utils\salmon.exe - strcat_s(szPath, "\\dbghelp.dll"); // chceme novou verzi, nejmene 6.1 a ta na starsich W2K/XP neni + *(strrchr(szPath, '\\')) = 0; // we are running from utils\\salmon.exe + strcat_s(szPath, "\\dbghelp.dll"); // we want a newer version, at least 6.1, which older W2K/XP do not have static HMODULE hDbgHelp; hDbgHelp = LoadLibrary(szPath); if (hDbgHelp != NULL) @@ -30,15 +30,15 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, if (funcMiniDumpWriteDump != NULL && funcMakeSureDirectoryPathExists != NULL) { char szFileName[MAX_PATH]; - strcpy(szFileName, mem->BugPath); // cesta je zakoncena zpetnym lomitkem + strcpy(szFileName, mem->BugPath); // the path ends with a trailing backslash int bugPathLen = (int)strlen(mem->BugPath); if (bugPathLen > 0 && mem->BugPath[bugPathLen - 1] != '\\') strcat(szFileName, "\\"); strcat(szFileName, mem->BaseName); strcat(szFileName, ".DMP"); - // cesta jeste nemusi existovat - vytvorime ji - funcMakeSureDirectoryPathExists(szFileName); // nazev souboru je ignorovan + // the path may not exist yet - create it + funcMakeSureDirectoryPathExists(szFileName); // the file name is ignored HANDLE hDumpFile; hDumpFile = CreateFile(szFileName, GENERIC_READ | GENERIC_WRITE, @@ -53,9 +53,9 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, expParam.ExceptionPointers = &ePtrs; expParam.ClientPointers = FALSE; - // skvele vysvetleni flagu (lepsi nez na MSDN): http://www.debuginfo.com/articles/effminidumps.html#minidumptypes + // great explanation of the flags (better than on MSDN): http://www.debuginfo.com/articles/effminidumps.html#minidumptypes static MINIDUMP_TYPE dumpType; - // nektere z flagu vyzaduji dbghelp.dll 6.1 - proto mame u Salamandera vlastni + // some of the flags require dbghelp.dll 6.1 - that is why Salamander ships its own copy if (smallMinidump) { dumpType = (MINIDUMP_TYPE)(MiniDumpWithProcessThreadData | @@ -63,7 +63,7 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | - MiniDumpIgnoreInaccessibleMemory); // v zadnem pripade si neprejeme selhani funkce + MiniDumpIgnoreInaccessibleMemory); // under no circumstances do we want the function to fail } else { @@ -73,7 +73,7 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | - MiniDumpIgnoreInaccessibleMemory); // v zadnem pripade si neprejeme selhani funkce + MiniDumpIgnoreInaccessibleMemory); // under no circumstances do we want the function to fail } BOOL bMiniDumpSuccessful; @@ -87,15 +87,15 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, } else { - // generovani selhava pod W7 pri x64/Debug verzi spustene z MSVC; pokud ji spustim mimo MSVC, vse slape + // generation fails on W7 with the x64/Debug build launched from MSVC; if I run it outside MSVC, everything works fine DWORD err = GetLastError(); sprintf(minidumpParams->ErrorMessage, LoadStr(IDS_SALMON_MINIDUMP_CALL, HLanguage), err); } - // at uz vratilo generovani minidumpu TRUE nebo FALSE, omrknem velikost vyprodukovaneho dumpu + // regardless of whether minidump generation returned TRUE or FALSE, check the size of the produced dump DWORD sizeHigh = 0; DWORD sizeLow = GetFileSize(hDumpFile, &sizeHigh); if (sizeLow != INVALID_FILE_SIZE && (sizeHigh > 0 || sizeLow > 50 * 1000 * 1024)) - *overSize = TRUE; // pokud je vysledek vetsi nez 50MB, dame to vedet ven, aby se zkusila jeste mensi verze + *overSize = TRUE; // if the result exceeds 50 MB, report it so a smaller version can be tried CloseHandle(hDumpFile); } else @@ -119,8 +119,8 @@ BOOL GenerateMiniDump(CMinidumpParams* minidumpParams, CSalmonSharedMemory* mem, extern BOOL DirExists(const char* dirName); -// na zaklade aktualniho casu a kratke verze Salamandera nageneruje nazev (bez pripony) -// ze ktereho se nasledne odvodi nazev pro textovy bug reportu a pro minidump +// based on the current time and the short Salamander version, generate a name (without an extension) +// from which the names for the text bug report and for the minidump are derived void GetReportBaseName(char* name, int nameSize, const char* targetPath, const char* shortName, DWORD64 uid, SYSTEMTIME lt) { static char year[10]; @@ -134,15 +134,15 @@ void GetReportBaseName(char* name, int nameSize, const char* targetPath, const c sprintf_s(name, nameSize, "%I64X-%s-%s%02u%02u-%02u%02u%02u", uid, shortName, year, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond); - CharUpperBuff(name, nameSize); // x64/x86 je lowercase, chceme vse upcase + CharUpperBuff(name, nameSize); // x64/x86 is lowercase, we want everything uppercased - // pokud cilova cesta existuje, mohlo by dojit ke kolizi (nepravdepodobne diky casu v nazvu) + // if the target path exists, there could be a collision (unlikely thanks to the timestamp in the name) if (targetPath != NULL && DirExists(targetPath)) { static char findPath[MAX_PATH]; static char findMask[MAX_PATH]; int i; - for (i = 0; i < 100; i++) // resime 1 - 99, pak to vzdavame + for (i = 0; i < 100; i++) // cover 1 - 99, then give up { strcpy(findMask, name); if (i > 0) @@ -158,7 +158,7 @@ void GetReportBaseName(char* name, int nameSize, const char* targetPath, const c if (hFind != INVALID_HANDLE_VALUE) NOHANDLES(FindClose(hFind)); else - break; // konflikt nenalezen + break; // no conflict found } if (i > 0) sprintf(name + strlen(name), "-%d", i); @@ -172,12 +172,12 @@ DWORD WINAPI MinidumpThreadF(void* param) SYSTEMTIME lt; GetLocalTime(<); - //char baseName[MAX_PATH]; + // char baseName[MAX_PATH]; GetReportBaseName(SalmonSharedMemory->BaseName, sizeof(SalmonSharedMemory->BaseName), SalmonSharedMemory->BugPath, SalmonSharedMemory->BugName, SalmonSharedMemory->UID, lt); - // nagenerujeme minidump + // generate the minidump BOOL overSize; BOOL ret = GenerateMiniDump(minidumpParams, SalmonSharedMemory, FALSE, &overSize); @@ -187,15 +187,15 @@ DWORD WINAPI MinidumpThreadF(void* param) SalmonSharedMemory->BugPath, SalmonSharedMemory->BugName, SalmonSharedMemory->UID, lt); - // nagenerujeme minidump + // generate the minidump ret = GenerateMiniDump(minidumpParams, SalmonSharedMemory, TRUE, &overSize); } - // dame do Salamandera vedet, ze je minidump vytvoreny - // v tutu chvili se Salamander pokusi ulozit na disk textovy bug report a ukonci se + // let Salamander know that the minidump has been created + // at this moment Salamander attempts to write the text bug report to disk and then exits SetEvent(SalmonSharedMemory->Done); - // pockame az Salamander report ulozi nebo prestane existovat; muze byt ve spatnem stavu, takze cekame jen omezenou dobu + // wait until Salamander saves the report or terminates; it may be in a bad state, so wait only for a limited time DWORD res = WaitForSingleObject(SalmonSharedMemory->Process, 10000); minidumpParams->Result = ret; diff --git a/src/salmon/minidump.h b/src/salmon/minidump.h index 093f52d20..ddf4d0056 100644 --- a/src/salmon/minidump.h +++ b/src/salmon/minidump.h @@ -3,11 +3,11 @@ #pragma once -// struktura predavana do compress vlakna, slouzi pro presun vstupne/vystupnich parametru +// structure passed to the minidump thread, used to transfer input/output parameters struct CMinidumpParams { - BOOL Result; // TRUE, pokud operace dobehla uspesne, jinak FALSE - char ErrorMessage[2 * MAX_PATH]; // pokud je Result FALSE, obsahuje popis chyby + BOOL Result; // TRUE if the operation completed successfully, otherwise FALSE + char ErrorMessage[2 * MAX_PATH]; // if Result is FALSE, contains the error description }; BOOL StartMinidumpThread(CMinidumpParams* params); diff --git a/src/salmon/salmon.cpp b/src/salmon/salmon.cpp index d649e131d..290f158dd 100644 --- a/src/salmon/salmon.cpp +++ b/src/salmon/salmon.cpp @@ -12,8 +12,8 @@ CSalmonSharedMemory* SalmonSharedMemory = NULL; char BugReportPath[MAX_PATH] = {0}; extern TDirectArray BugReports(1, 10); -char LatestBugReport[MAX_PATH] = {0}; // jmeno casove posledniho bug reportu (pouze jmeno bez pripony) -BOOL ReportOldBugs = TRUE; // uzivatel povolil upload i starych reportu +char LatestBugReport[MAX_PATH] = {0}; // name of the most recent bug report (name only, without extension) +BOOL ReportOldBugs = TRUE; // the user allowed uploading old reports as well const char* APP_NAME = "Open Salamander Bug Reporter"; @@ -28,7 +28,7 @@ class C__StrCriticalSection ~C__StrCriticalSection() { HANDLES(DeleteCriticalSection(&cs)); } }; -// zajistime vcasnou konstrukci kriticke sekce +// ensure the critical section is constructed in time #pragma warning(disable : 4073) #pragma init_seg(lib) C__StrCriticalSection __StrCriticalSection; @@ -38,7 +38,7 @@ C__StrCriticalSection __StrCriticalSection2; char* LoadStr(int resID, HINSTANCE hInstance) { - static char buffer[10000]; // buffer pro mnoho stringu + static char buffer[10000]; // buffer for many strings static char* act = buffer; HANDLES(EnterCriticalSection(&__StrCriticalSection.cs)); @@ -49,23 +49,23 @@ char* LoadStr(int resID, HINSTANCE hInstance) if (hInstance == NULL) hInstance = HLanguage; #ifdef _DEBUG - // radeji si pojistime, aby nas nekdo nevolal pred inicializaci handlu s resourcy + // better ensure nobody calls us before the resource handle is initialized if (hInstance == NULL) TRACE_E("LoadStr: hInstance == NULL"); #endif // _DEBUG RELOAD: int size = LoadString(hInstance, resID, act, 10000 - (int)(act - buffer)); - // size obsahuje pocet nakopirovanych znaku bez terminatoru + // size contains the number of copied characters without the terminator // DWORD error = GetLastError(); char* ret; - if (size != 0) // error je NO_ERROR, i kdyz string neexistuje - nepouzitelne + if (size != 0) // error is NO_ERROR even when the string does not exist - unusable { if ((10000 - (act - buffer) == size + 1) && (act > buffer)) { - // pokud byl retezec presne na konci bufferu, mohlo - // jit o oriznuti retezce -- pokud muzeme posunout okno - // na zacatek bufferu, nacteme string jeste jednou + // if the string ended exactly at the end of the buffer, it might + // have been truncated -- if we can shift the window to the beginning + // of the buffer, load the string once more act = buffer; goto RELOAD; } @@ -91,12 +91,12 @@ char* LoadStr(int resID, HINSTANCE hInstance) // // GetErrorText // -// az do soubehu minimalne 10 vypisovanych chyb naraz by to melo jiste fungovat, -// vic threadu nez 10 najednou neocekavame ;-) +// this should reliably work for at least 10 errors being written at once, +// we do not expect more than 10 threads at the same time ;-) char* GetErrorText(DWORD error) { - static char buffer[10 * MAX_PATH]; // buffer pro mnoho stringu + static char buffer[10 * MAX_PATH]; // buffer for many strings static char* act = buffer; HANDLES(EnterCriticalSection(&__StrCriticalSection2.cs)); @@ -105,8 +105,8 @@ char* GetErrorText(DWORD error) act = buffer; char* ret = act; - // POZOR: sprintf_s v debug verzi vyplnuje cely buffer, tedy nelze mu podat cely buffer (jsou - // v nem i dalsi stringy), resit bud pres _CrtSetDebugFillThreshold nebo zadanim mensi velikosti) + // NOTE: sprintf_s in the debug build fills the entire buffer, so we cannot pass it the whole buffer (it + // also contains other strings); handle it via _CrtSetDebugFillThreshold or by specifying a smaller size int l = sprintf(act, ((int)error < 0 ? "(%08X) " : "(%d) "), error); int fl; if ((fl = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, @@ -180,7 +180,7 @@ void OpenFolder(HWND hWnd, const char* szDir) memset(&se, 0, sizeof(SHELLEXECUTEINFO)); se.cbSize = sizeof(SHELLEXECUTEINFO); se.fMask = SEE_MASK_IDLIST; - se.lpVerb = "explore"; // volba zda otevirat se stromeckem + se.lpVerb = "explore"; // option whether to open with the tree view se.hwnd = hWnd; se.nShow = SW_SHOWNORMAL; se.lpIDList = pidl; @@ -205,10 +205,10 @@ DWORD SalGetFileAttributes(const char* fileName) { int fileNameLen = (int)strlen(fileName); char fileNameCopy[3 * MAX_PATH]; - // pokud cesta konci mezerou/teckou, musime pripojit '\\', jinak GetFileAttributes - // mezery/tecky orizne a pracuje tak s jinou cestou + u souboru to sice nefunguje, - // ale porad lepsi nez ziskat atributy jineho souboru/adresare (pro "c:\\file.txt " - // pracuje se jmenem "c:\\file.txt") + // if the path ends with a space/dot, we must append '\\', otherwise GetFileAttributes trims + // the spaces/dots and works with a different path; for files it does not work anyway, + // but it is still better than getting attributes of another file/directory (for "c:\\file.txt " + // it works with the name "c:\\file.txt") if (fileNameLen > 0 && (fileName[fileNameLen - 1] <= ' ' || fileName[fileNameLen - 1] == '.') && fileNameLen + 1 < _countof(fileNameCopy)) { @@ -217,7 +217,7 @@ DWORD SalGetFileAttributes(const char* fileName) fileNameCopy[fileNameLen + 1] = 0; return GetFileAttributes(fileNameCopy); } - else // obycejna cesta, neni co resit, jen zavolame windowsovou GetFileAttributes + else // a plain path, nothing special to do, just call the Windows GetFileAttributes { return GetFileAttributes(fileName); } @@ -290,8 +290,8 @@ HINSTANCE LoadSLG(const char* slgName) HINSTANCE hSLG = LoadLibrary(path); if (hSLG == NULL) { - // pokud se SLG nepovedlo nacist, nemusi existovat nebo nam nepredali validni nazev - // pokusime se najit nejake vhodne jine, podle priority + // if loading the SLG failed, it might not exist or we were not given a valid name + // try to find another suitable one based on priority const char* masks[] = {"english.slg", "czech.slg", "german.slg", "spanish.slg", "*.slg", ""}; for (int i = 0; *masks[i] != 0 && (hSLG == NULL); i++) { @@ -395,8 +395,8 @@ BOOL CleanBugReportsDirectory(BOOL keep7ZipArchives) // GetBugReportNameIndexIgnoreExt() // -// prohleda pole BugReports (ktere obsahuje nazvy vcetne pripon) a vrati index 'name' -// ignoruje pripony +// search the BugReports array (which contains names including extensions) and return the index of 'name' +// ignores extensions int GetBugReportNameIndexIgnoreExt(const char* name) { char strippedName[MAX_PATH]; @@ -429,11 +429,11 @@ BOOL GetBugReportNames() if (BugReportPath[0] == 0) return FALSE; - // pokud adresar neexistuje, nemuze obsahovat reporty + // if the directory does not exist, it cannot contain reports if (!DirExists(BugReportPath)) return FALSE; - // hledame reporty podle pripon + // look for reports by extension char findPath[MAX_PATH]; const char* extensions[] = {"*.DMP", "*.TXT", NULL}; FILETIME latestFiletime; @@ -456,7 +456,7 @@ BOOL GetBugReportNames() BOOL skipFile = FALSE; if (_stricmp(ext + 1, "dmp") == 0) { - // minidumpy nad 200MB proste smazeme, protoze neverim, ze by po zapakovani prosly na server + // delete minidumps over 200 MB because I do not believe they would pass to the server even after packing if (find.nFileSizeHigh > 0 || find.nFileSizeLow > 200 * 1000 * 1024) { char deleteFileName[MAX_PATH]; @@ -469,14 +469,14 @@ BOOL GetBugReportNames() if (!skipFile) { - // ulozime nejnovejsi jmeno a cas + // store the newest name and timestamp if (latestFilename[0] == 0 || CompareFileTime(&latestFiletime, &find.ftLastWriteTime) == -1) { strcpy(latestFilename, item.Name); latestFiletime = find.ftLastWriteTime; } - // jmena co nemame v seznamu do nej pridame + // add names that are missing from the list if (GetBugReportNameIndexIgnoreExt(item.Name) == -1) BugReports.Add(item); } @@ -485,7 +485,7 @@ BOOL GetBugReportNames() } } - // nejnovejsi report vybublame na nultou pozici + // bubble the newest report to index zero if (BugReports.Count > 1) { int index = GetBugReportNameIndexIgnoreExt(latestFilename); @@ -497,13 +497,13 @@ BOOL GetBugReportNames() } } - // pokud jde o padacky z WERu, nemaji predponu s UID a verzi - prejmenujeme je + // if these are crash dumps from WER, they lack the UID/version prefix - rename them char uid[17]; sprintf(uid, "%I64X", SalmonSharedMemory->UID); for (int i = 0; i < BugReports.Count; i++) { CBugReport* item = &BugReports[i]; - // pokud soubor nezacina nasim UID, generoval ho nekdo jiny (WER) a polozku prejmenujeme + // if the file does not start with our UID, someone else (WER) generated it and we rename the item if (_strnicmp(item->Name, uid, strlen(uid)) != 0) { char fullOrgName[MAX_PATH]; @@ -514,7 +514,7 @@ BOOL GetBugReportNames() strcpy(fullOrgName, BugReportPath); strcat(fullOrgName, item->Name); - char* ext = strrchr(item->Name, '.'); // priponu dame az na konec + char* ext = strrchr(item->Name, '.'); // move the extension to the end if (ext != NULL) strcpy(extName, ext); else @@ -525,23 +525,23 @@ BOOL GetBugReportNames() strcpy(tmpName, item->Name); if (ext != NULL) - *strrchr(tmpName, '.') = 0; // uvnitr jmena ji vystrihnem + *strrchr(tmpName, '.') = 0; // cut it out inside the name strcat(tmpName, "-"); strcat(tmpName, SalmonSharedMemory->BugName); GetReportBaseName(newName, sizeof(newName), BugReportPath, tmpName, SalmonSharedMemory->UID, lt); strcat(newName, extName); - // nove jmeno v poli + // new name in the array strcpy(item->Name, newName); - // nove jmeno na disku + // new name on disk strcpy(fullNewName, BugReportPath); strcat(fullNewName, newName); MoveFile(fullOrgName, fullNewName); } } - // pripona nas nezajima, ustrihneme ji + // the extension is irrelevant, trim it off for (int i = 0; i < BugReports.Count; i++) { CBugReport* item = &BugReports[i]; @@ -553,7 +553,7 @@ BOOL GetBugReportNames() return BugReports.Count > 0; } -// ignoruje 'oversize' reporty, ktere konci -1 az -99 +// ignore 'oversize' reports that end with -1 to -99 int GetUniqueBugReportCount() { TDirectArray UniqueNames(1, 10); @@ -562,7 +562,7 @@ int GetUniqueBugReportCount() { CBugReport* item = &BugReports[i]; // MessageBox(NULL, item->Name, item->Name, MB_OK); - // z nazvu orizneme koncove -1 az -99 + // remove trailing -1 to -99 from the name strcpy(buff, item->Name); int len = (int)strlen(buff); if (len > 3) @@ -572,7 +572,7 @@ int GetUniqueBugReportCount() if (buff[len - 3] == '-') buff[len - 3] = 0; } - // pokud polozku nenajdeme v unikatnich nazvech, pridame ji tam + // if we do not find the item among unique names, add it there int j; for (j = 0; j < UniqueNames.Count; j++) { @@ -601,7 +601,7 @@ BOOL SaveDescriptionAndEmail() BOOL ret = FALSE; char name[MAX_PATH]; - sprintf(name, "%s%s.INF", BugReportPath, BugReports[0].Name); // budeme pracovat s nejnovejsim nazvem + sprintf(name, "%s%s.INF", BugReportPath, BugReports[0].Name); // work with the newest name HANDLE hFile = CreateFile(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { @@ -748,7 +748,7 @@ BOOL GetStringSid(LPTSTR* stringSid) return FALSE; } - // volajici musi uvolnit vracenou pamet pomoci LocalFree, viz MSDN + // the caller must release the returned memory with LocalFree, see MSDN ConvertSidToStringSid(pTokenUser->User.Sid, stringSid); free(pTokenUser); @@ -783,7 +783,7 @@ class CMainDialogMutex void Leave(); }; -CMainDialogMutex MainDialogMutex; // mutex zajistujici, abychom uzivatelum ukazovali pro jednoho uzivatele (i na serveru) jen jeden dialog +CMainDialogMutex MainDialogMutex; // mutex ensuring that we show only one dialog per user (even on the server) void CMainDialogMutex::Init() { @@ -794,7 +794,7 @@ void CMainDialogMutex::Init() char buff[1000]; if (sid == NULL) { - // chyba v ziskani SID -- pojedeme v nouzovem rezimu + // failed to obtain the SID -- fall back to a degraded mode _snprintf_s(buff, _TRUNCATE, "%s", SALMON_MAINDLG_MUTEX_NAME); } else @@ -834,7 +834,7 @@ BOOL CMainDialogMutex::Enter() if (ret == WAIT_FAILED) TRACE_E("CMainDialogMutex::Enter(): WaitForSingleObject() failed!"); if (ret == WAIT_TIMEOUT) - return FALSE; // je otevrene jine okno, nemuzeme se otevrit my + return FALSE; // another window is open, we cannot open ourselves } else TRACE_E("CMainDialogMutex::Enter(): the Mutex==NULL! Not initialized?"); @@ -927,16 +927,16 @@ void ChechForBugs(CSalmonSharedMemory* mem, const char* slgName) { if (GetBugReportNames()) { - // potrebujeme zobrazit GUI, musime nacist SLG + // we need to display the GUI, we must load the SLG if (LoadHLanguageVerbose(slgName)) { if (GetUniqueBugReportCount() > 1) { - // reportu je vic, doptame se zda je mame poslat vsechny + // if multiple reports exist, ask whether to send them all int res = MessageBox(NULL, LoadStr(IDS_SALMON_MORE_REPORTS, HLanguage), LoadStr(IDS_SALMON_TITLE, HLanguage), MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND); ReportOldBugs = (res == IDYES); } - // nyni muzeme otevrit dialog + // with that decision made we can open the dialog OpenMainDialog(FALSE); } } @@ -945,7 +945,7 @@ void ChechForBugs(CSalmonSharedMemory* mem, const char* slgName) } ResetEvent(mem->CheckBugs); - SetEvent(mem->Done); // dame do Salamandera vedet, ze jsme si nazev SLG prevzali + SetEvent(mem->Done); // let Salamander know we have taken over the SLG name } //------------------------------------------------------------------------------------------------ @@ -965,14 +965,14 @@ LPARAM PostponedMsgLParam = 0; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow) { - // v 99% kdy Salamander nespadne pobezi salmon.exe nepozorovane na pozadi a mel by mit jen co nejmensi pametove / cpu naroky; - // proto odlozime nacitani SLG az na okamzik, kdy bude potreba neco zobrazovat (pad Salamandera) + // in 99% of cases when Salamander does not crash, salmon.exe will run unnoticed in the background and should + // consume as little memory/CPU as possible; therefore delay loading the SLG until something needs to be shown (a Salamander crash) SetTraceProcessName("Salmon"); SetThreadNameInVCAndTrace("Main"); TRACE_I("Begin"); - // nechceme zadne kriticke chyby jako "no disk in drive A:" + // we do not want critical errors such as "no disk in drive A:" SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS); HInstance = hInstance; @@ -980,11 +980,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow Config.Load(); char fileMappingName[SALMON_FILEMAPPIN_NAME_SIZE]; - char slgName[MAX_PATH] = {0}; // nazev slg (napr "english.slg"), ktere se ma nacist do HLanguage; muze byt i prazdny retezec (potom se nacte nejaky default) + char slgName[MAX_PATH] = {0}; // name of the SLG (e.g. "english.slg") to load into HLanguage; can be empty (then a default is loaded) if (!ParseCommandLine(cmdLine, fileMappingName, slgName) || strlen(fileMappingName) == 0) { - HINSTANCE hLanguage = LoadSLG(slgName); // nactu default SLG, abychom mohli zobrazovat pripadne chyby + HINSTANCE hLanguage = LoadSLG(slgName); // load the default SLG so that we can display possible errors if (hLanguage != NULL) MessageBox(NULL, LoadStr(IDS_SALMON_WRONG_CMDLINE, hLanguage), LoadStr(IDS_SALMON_TITLE, hLanguage), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND); return SALMON_RET_ERROR; @@ -998,7 +998,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow { if (fm != NULL) CloseHandle(fm); - HINSTANCE hLanguage = LoadSLG(slgName); // nactu default SLG, abychom mohli zobrazovat pripadne chyby + HINSTANCE hLanguage = LoadSLG(slgName); // load the default SLG so that we can display possible errors if (hLanguage != NULL) MessageBox(NULL, LoadStr(IDS_SALMON_WRONG_CMDLINE, hLanguage), LoadStr(IDS_SALMON_TITLE, hLanguage), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND); return SALMON_RET_ERROR; @@ -1008,7 +1008,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow { UnmapViewOfFile(mem); CloseHandle(fm); - HINSTANCE hLanguage = LoadSLG(slgName); // nactu default SLG, abychom mohli zobrazovat pripadne chyby + HINSTANCE hLanguage = LoadSLG(slgName); // load the default SLG so that we can display possible errors if (hLanguage != NULL) MessageBox(NULL, LoadStr(IDS_SALMON_WRONG_CMDLINE, hLanguage), LoadStr(IDS_SALMON_TITLE, hLanguage), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND); return SALMON_RET_ERROR; @@ -1020,7 +1020,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow arr[2] = mem->SetSLG; arr[3] = mem->CheckBugs; - SalmonSharedMemory = mem; // nastavime globalku, at to nemusime pasirovat pres parametry + SalmonSharedMemory = mem; // set the global pointer so we do not have to thread it through parameters strcpy(BugReportPath, mem->BugPath); if (BugReportPath[0] != 0 && *(BugReportPath + strlen(BugReportPath) - 1) != '\\') strcat(BugReportPath, "\\"); @@ -1028,19 +1028,19 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow BOOL run = TRUE; while (run) { - // pockame na nektery z hlidanych eventu + // wait for one of the monitored events DWORD waitRet = MsgWaitForMultipleObjects(4, arr, FALSE, INFINITE, QS_ALLINPUT); switch (waitRet) { case WAIT_OBJECT_0 + 0: // sharedMemory->Process { - // parent proces prestal existovat, koncime take + // the parent process has terminated, so we exit as well - // pokud najdeme nejake dumpy, odbavime je - Salamander mohl padnou napriklad pri initu behem nacitani - // shell extensions a nestihl otevrit hlavni okno a zavolat nam ChechForBugs - // pripadne Salamander padnul jeste pred instalaci exception handleru a minidump zachytil WER, ktery - // mame nasmerovany do naseho bug report adresare (Vista+) - // dale mohl Salamander padnou tak, ze nezabral exception handler (typicky to delaji vadne shell extensions) + // if we find any dumps, process them - Salamander could have crashed during init while loading + // shell extensions and did not manage to open the main window and call CheckForBugs + // or Salamander crashed before the exception handler was installed and the minidump was captured by WER, + // which we have redirected to our bug report directory (Vista+) + // Salamander could also have crashed in a way that bypassed the exception handler (typically caused by faulty shell extensions) ChechForBugs(mem, slgName); run = FALSE; @@ -1049,11 +1049,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow case WAIT_OBJECT_0 + 1: // sharedMemory->Fire { - // parent proces po nas chce nagenerovani minidumpu - if (LoadHLanguageVerbose(slgName)) // potrebujeme zobrazit GUI, musime nacist SLG + // the parent process wants us to generate a minidump + if (LoadHLanguageVerbose(slgName)) // we need to display the GUI, we must load the SLG { - // pokud se nam podari mutex zabrat, pozdeji ho uvolnime; neprejeme si, aby - // behem naseho okna vyskakovala dalsi z nove spoustenych procesu + // if we manage to lock the mutex, release it later; we do not want + // additional processes started afterwards to pop up their windows during ours BOOL leave = MainDialogMutex.Enter(); OpenMainDialog(TRUE); if (leave) @@ -1065,29 +1065,29 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow case WAIT_OBJECT_0 + 2: // sharedMemory->SetSLG { - // Salamander nacetl "spravne" slg a dava nam vedet, at na nej take prejdeme - // ulozime si jeho nazev, aktivne zatim nema smysl ho cist + // Salamander loaded the “correct” SLG and lets us know we should switch to it + // store its name; actively reading it now makes no sense yet strcpy(slgName, mem->SLGName); ResetEvent(mem->SetSLG); - SetEvent(mem->Done); // dame do Salamandera vedet, ze jsme si nazev SLG prevzali + SetEvent(mem->Done); // let Salamander know we have taken over the SLG name break; } case WAIT_OBJECT_0 + 3: // sharedMemory->CheckBugs { - // Salamander nam dava vedet, ze ma otevrene hlavni okno a je cas provest kontrolu, zda - // v adresari s bug reporty nelezi nejake stare soubory, co bychom meli odeslat na server + // Salamander informs us that the main window is open and it is time to check whether + // there are old files in the bug report directory that we should send to the server ChechForBugs(mem, slgName); break; } - case WAIT_OBJECT_0 + 4: // dorazila zprava do message queue, vypumpujeme ji + case WAIT_OBJECT_0 + 4: // a message arrived in the message queue, pump it out { - // salmon.exe pouziva win32 subsystem u ktereho Windows ocekavaji message loop, kterou vsak nemame - // po spusteni salmon.exe se tak na 5s zobrazoval wait cursor, viz - // https://forum.altap.cz/viewtopic.php?f=16&t=5572 - // abychom se ho zbavili, mame dve moznosti: prejit na "console" subsystem - // nebo pumpovat message loop, coz jsem zvolil jako hezci reseni (pri spusteni uzivatelem neukaze shell okno, jen msgbox) + // salmon.exe uses the Win32 subsystem where Windows expects a message loop, which we do not have. + // After starting salmon.exe a wait cursor was shown for about 5 seconds, see + // https://forum.altap.cz/viewtopic.php?f=16&t=5572. + // To get rid of it we had two options: switch to the "console" subsystem + // or pump the message loop, which I chose as the cleaner solution (when launched by the user it shows no shell window, only a message box). MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { diff --git a/src/salmon/salmon.h b/src/salmon/salmon.h index 30b3bd791..8fe4bc54e 100644 --- a/src/salmon/salmon.h +++ b/src/salmon/salmon.h @@ -4,7 +4,7 @@ #pragma once extern HINSTANCE HLanguage; -extern char BugReportPath[MAX_PATH]; // cesta bude koncit zpetnym lomitkem +extern char BugReportPath[MAX_PATH]; // the path will end with a trailing backslash struct CBugReport { char Name[MAX_PATH]; @@ -24,8 +24,8 @@ BOOL RestartSalamander(HWND hParent); BOOL CleanBugReportsDirectory(BOOL keep7ZipArchives); -// vraci TRUE, pokud existuje bug report -// nastavuje globalku LatestBugReport na casove posledni nazev +// returns TRUE if a bug report exists +// sets the LatestBugReport global to the most recent name BOOL GetBugReportNames(); int GetUniqueBugReportCount(); @@ -38,4 +38,4 @@ BOOL CompresBugReports(); extern BOOL AppIsBusy; -//#define WM_USER_THREAD_EXIT WM_APP + 100 // upload thread dobehnul \ No newline at end of file +//#define WM_USER_THREAD_EXIT WM_APP + 100 // upload thread has finished diff --git a/src/salmon/upload.cpp b/src/salmon/upload.cpp index d696b953f..4e014edac 100644 --- a/src/salmon/upload.cpp +++ b/src/salmon/upload.cpp @@ -29,7 +29,7 @@ BOOL CreateHTTPOutput(CUploadParams* uploadParams, char** buffer, int* bufferSiz DWORD fileSize = GetFileSize(hFile, NULL); if (fileSize != INVALID_FILE_SIZE) { - int allocatedSize = (int)(fileSize + 2000); // rezerva pro HTTP stringy + int allocatedSize = (int)(fileSize + 2000); // reserve for HTTP strings char* header = (char*)malloc(allocatedSize); ZeroMemory(header, allocatedSize); if (header != NULL) @@ -44,7 +44,7 @@ BOOL CreateHTTPOutput(CUploadParams* uploadParams, char** buffer, int* bufferSiz sprintf(s, "Content-Type: multipart/form-data; boundary=---------------------------90721038027008\r\n"); s += strlen(s); sprintf(s, "Content-Length: %d\r\n", allocatedSize); - s += strlen(s); // snad nebude tato nepresnost zlobit, uvidime + s += strlen(s); // hopefully this imprecision will not cause trouble; we will see sprintf(s, "\r\n"); s += strlen(s); sprintf(s, "-----------------------------90721038027008\r\n"); @@ -85,7 +85,7 @@ BOOL CreateHTTPOutput(CUploadParams* uploadParams, char** buffer, int* bufferSiz return ret; } -// z PHP dle http://php.net/manual/en/features.file-upload.errors.php +// taken from PHP at http://php.net/manual/en/features.file-upload.errors.php #define UPLOAD_ERR_OK 0 #define UPLOAD_ERR_INI_SIZE 1 #define UPLOAD_ERR_FORM_SIZE 2 @@ -153,8 +153,8 @@ BOOL GetFilesError(int err, CUploadParams* uploadParams) BOOL AnalyzeResponse(const char* str, int strLen, CUploadParams* uploadParams) { - // vyhledame nasi odpoved z php skriptu, ve tvaru X, kde X je - // error z http://php.net/manual/en/features.file-upload.errors.php + // find our response from the PHP script in the form X, where X is + // an error from http://php.net/manual/en/features.file-upload.errors.php const char* TAG_OPEN = ""; const char* TAG_CLOSE = ""; const char* tagOpen = strstr(str, TAG_OPEN); diff --git a/src/salmon/upload.h b/src/salmon/upload.h index cedcde799..f37bdc214 100644 --- a/src/salmon/upload.h +++ b/src/salmon/upload.h @@ -3,12 +3,12 @@ #pragma once -// struktura predavana do upload vlakna, slouzi pro presun vstupne/vystupnich parametru +// structure passed to the upload thread, used to transfer input/output parameters struct CUploadParams { - BOOL Result; // TRUE, pokud operace dobehla uspesne, jinak FALSE - char ErrorMessage[2 * MAX_PATH]; // pokud je Result FALSE, obsahuje popis chyby - char FileName[MAX_PATH]; // plna cesta k souboru, ktery se ma uploadnout + BOOL Result; // TRUE if the operation completed successfully, otherwise FALSE + char ErrorMessage[2 * MAX_PATH]; // if Result is FALSE, contains the error description + char FileName[MAX_PATH]; // full path to the file that should be uploaded }; BOOL StartUploadThread(CUploadParams* params);