diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index 7751c9cd6b..d2d149348e 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -174,10 +174,10 @@ void CLauncherDlg::startProcess() { LauncherUtils::deleteDirectoriesOnThread(installDir, downloadDir, [&](int error) { LauncherUtils::DeleteDirError deleteError = (LauncherUtils::DeleteDirError)error; - if (error == LauncherUtils::DeleteDirError::NoErrorDeleting) { + switch(error) { + case LauncherUtils::DeleteDirError::NoErrorDeleting: theApp._manager.addToLog(_T("Install directory deleted.")); theApp._manager.addToLog(_T("Downloads directory deleted.")); - // CString interfaceExe = installPath += "\\interface.exe"; if (!theApp._manager.isLoggedIn()) { theApp._manager.addToLog(_T("Downloading Content")); theApp._manager.downloadContent(); @@ -185,14 +185,18 @@ void CLauncherDlg::startProcess() { theApp._manager.addToLog(_T("Downloading App")); theApp._manager.downloadApplication(); } - } - if (error == LauncherUtils::DeleteDirError::ErrorDeletingPath1 || - error == LauncherUtils::DeleteDirError::ErrorDeletingPaths) { - theApp._manager.addToLog(_T("Error deleting install directory.")); - } - if (error == LauncherUtils::DeleteDirError::ErrorDeletingPath2 || - error == LauncherUtils::DeleteDirError::ErrorDeletingPaths) { + break; + case LauncherUtils::DeleteDirError::ErrorDeletingBothDirs: + theApp._manager.addToLog(_T("Error deleting directories.")); + break; + case LauncherUtils::DeleteDirError::ErrorDeletingApplicationDir: + theApp._manager.addToLog(_T("Error deleting application directory.")); + break; + case LauncherUtils::DeleteDirError::ErrorDeletingDownloadsDir: theApp._manager.addToLog(_T("Error deleting downloads directory.")); + break; + default: + break; } }); } @@ -233,8 +237,8 @@ afx_msg void CLauncherDlg::OnNextClicked() { theApp._manager.addToLog(_T("Bad credentials. Try again")); setDrawDialog(DrawStep::DrawLoginErrorCred); } else { - theApp._manager.addToLog(_T("Error Reading or retreaving response.")); - MessageBox(L"Error Reading or retreaving response.", L"Network Error", MB_OK | MB_ICONERROR); + theApp._manager.addToLog(_T("Error Reading or retrieving response.")); + MessageBox(L"Error Reading or retrieving response.", L"Network Error", MB_OK | MB_ICONERROR); } } else { theApp._manager.addToLog(_T("Organization name does not exist.")); @@ -575,7 +579,7 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) { if (_showSplash) { if (_splashStep == 0){ if (theApp._manager.needsUninstall()) { - theApp._manager.addToLog(_T("Waiting to unistall")); + theApp._manager.addToLog(_T("Waiting to uninstall")); setDrawDialog(DrawStep::DrawProcessUninstall); } else { theApp._manager.addToLog(_T("Start splash screen")); diff --git a/launchers/win32/LauncherUtils.cpp b/launchers/win32/LauncherUtils.cpp index 8cf1d78ebf..22724ac499 100644 --- a/launchers/win32/LauncherUtils.cpp +++ b/launchers/win32/LauncherUtils.cpp @@ -395,11 +395,11 @@ DWORD WINAPI LauncherUtils::downloadThread(LPVOID lpParameter) DWORD WINAPI LauncherUtils::deleteDirectoriesThread(LPVOID lpParameter) { DeleteThreadData& data = *((DeleteThreadData*)lpParameter); DeleteDirError error = DeleteDirError::NoErrorDeleting; - if (!LauncherUtils::deleteFileOrDirectory(data._path1)) { - error = DeleteDirError::ErrorDeletingPath1; + if (!LauncherUtils::deleteFileOrDirectory(data._applicationDir)) { + error = DeleteDirError::ErrorDeletingApplicationDir; } - if (!LauncherUtils::deleteFileOrDirectory(data._path2)) { - error = error == NoError ? DeleteDirError::ErrorDeletingPath2 : DeleteDirError::ErrorDeletingPaths; + if (!LauncherUtils::deleteFileOrDirectory(data._downloadsDir)) { + error = error == NoError ? DeleteDirError::ErrorDeletingDownloadsDir : DeleteDirError::ErrorDeletingBothDirs; } data.callback(error); return 0; @@ -435,11 +435,13 @@ BOOL LauncherUtils::downloadFileOnThread(int type, const CString& url, const CSt return FALSE; } -BOOL LauncherUtils::deleteDirectoriesOnThread(const CString& dir1, const CString& dir2, std::function callback) { +BOOL LauncherUtils::deleteDirectoriesOnThread(const CString& applicationDir, + const CString& downloadsDir, + std::function callback) { DWORD myThreadID; DeleteThreadData* deleteThreadData = new DeleteThreadData(); - deleteThreadData->_path1 = dir1; - deleteThreadData->_path2 = dir2; + deleteThreadData->_applicationDir = applicationDir; + deleteThreadData->_downloadsDir = downloadsDir; deleteThreadData->setCallback(callback); HANDLE myHandle = CreateThread(0, 0, deleteDirectoriesThread, deleteThreadData, 0, &myThreadID); if (myHandle) { diff --git a/launchers/win32/LauncherUtils.h b/launchers/win32/LauncherUtils.h index 4add0fb931..47a8fc56c8 100644 --- a/launchers/win32/LauncherUtils.h +++ b/launchers/win32/LauncherUtils.h @@ -32,9 +32,9 @@ public: enum DeleteDirError { NoErrorDeleting = 0, - ErrorDeletingPath1, - ErrorDeletingPath2, - ErrorDeletingPaths + ErrorDeletingApplicationDir, + ErrorDeletingDownloadsDir, + ErrorDeletingBothDirs }; struct DownloadThreadData { @@ -60,8 +60,8 @@ public: }; struct DeleteThreadData { - CString _path1; - CString _path2; + CString _applicationDir; + CString _downloadsDir; std::function callback; void setCallback(std::function fn) { callback = std::bind(fn, std::placeholders::_1); } }; @@ -83,10 +83,12 @@ public: static BOOL deleteRegistryKey(const CString& registryPath); static BOOL unzipFileOnThread(int type, const std::string& zipFile, const std::string& path, std::function callback); static BOOL downloadFileOnThread(int type, const CString& url, const CString& file, std::function callback); - static BOOL deleteDirectoriesOnThread(const CString& dir1, const CString& dir2, std::function callback); + static BOOL deleteDirectoriesOnThread(const CString& applicationDir, + const CString& downloadsDir, + std::function callback); static CString urlEncodeString(const CString& url); - private: +private: // Threads static DWORD WINAPI unzipThread(LPVOID lpParameter); static DWORD WINAPI downloadThread(LPVOID lpParameter);