diff --git a/src/discord/UpdateChecker.cpp b/src/discord/UpdateChecker.cpp index b3b081c..1f0982f 100644 --- a/src/discord/UpdateChecker.cpp +++ b/src/discord/UpdateChecker.cpp @@ -12,11 +12,6 @@ void UpdateChecker::StartCheckingForUpdates() GetHTTPClient()->PerformRequest(true, NetRequest::GET, GetUpdateAPIURL(), 0, 0, "", "", "", OnRequestDone); } -void UpdateChecker::DownloadUpdate(const std::string& url) -{ - DbgPrintF("Downloading update: %s", url.c_str()); -} - #ifdef _MSC_VER #define IS_MINGW false #else diff --git a/src/discord/UpdateChecker.hpp b/src/discord/UpdateChecker.hpp index d2c427e..0aa2395 100644 --- a/src/discord/UpdateChecker.hpp +++ b/src/discord/UpdateChecker.hpp @@ -8,7 +8,6 @@ class UpdateChecker public: static std::string GetUpdateAPIURL(); static void StartCheckingForUpdates(); - static void DownloadUpdate(const std::string& url); private: static void OnRequestDone(NetRequest*); diff --git a/src/resource.h b/src/resource.h index c79ed73..7e431cb 100644 --- a/src/resource.h +++ b/src/resource.h @@ -203,6 +203,7 @@ #define IDS_NEW_VERSION_AVAILABLE 696 #define IDS_FAILED_UPDATE_CHECK 697 #define IDS_FAILED_TO_UPLOAD 698 +#define IDS_SAVED_UPDATE 699 #define IDC_OPTIONS_TABS 801 #define IDC_MY_ACCOUNT_BOX 802 #define IDC_MY_ACCOUNT_NAME 803 diff --git a/src/resource.rc b/src/resource.rc index 76c1858..21b9bb7 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -975,6 +975,7 @@ BEGIN "Discord Messenger has had a new update!\n\nYour version: %s\nLatest version: %s\n\nWould you like to download the new version?\n\nNote: No web browser window will be opened, the app itself will download the files into a location you choose.\nNote: You won't be bugged again for 3 days." IDS_FAILED_UPDATE_CHECK "Failed to check for updates! (error %d, message '%s').\n\nTrying again when the app restarts." IDS_FAILED_TO_UPLOAD "Error! Can't upload file %s, got error %d." + IDS_SAVED_UPDATE "Downloaded update successfully. Go extract it and enjoy!" END #endif // English (United States) resources diff --git a/src/windows/Frontend_Win32.cpp b/src/windows/Frontend_Win32.cpp index 18d9c5d..44adda7 100644 --- a/src/windows/Frontend_Win32.cpp +++ b/src/windows/Frontend_Win32.cpp @@ -134,7 +134,15 @@ void Frontend_Win32::OnUpdateAvailable(const std::string& url, const std::string free(tstr2); if (MessageBox(g_Hwnd, buff, TmGetTString(IDS_PROGRAM_NAME), MB_ICONINFORMATION | MB_YESNO) == IDYES) - UpdateChecker::DownloadUpdate(url); + { + size_t idx = 0, idxsave = 0; + for (; idx != url.size(); idx++) { + if (url[idx] == '/') + idxsave = idx + 1; + } + + DownloadFileDialog(g_Hwnd, url, url.substr(idxsave)); + } GetLocalSettings()->StopUpdateCheckTemporarily(); } diff --git a/src/windows/Main.cpp b/src/windows/Main.cpp index 1854f89..9ce12fc 100644 --- a/src/windows/Main.cpp +++ b/src/windows/Main.cpp @@ -1178,6 +1178,17 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) DismissProfilePopout(); break; } + case WM_IMAGESAVED: + { + // TODO: Probably should automatically extract and install it or something + MessageBox( + hWnd, + TmGetTString(IDS_SAVED_UPDATE), + TmGetTString(IDS_PROGRAM_NAME), + MB_ICONINFORMATION | MB_OK + ); + break; + } case WM_MOVE: DismissProfilePopout(); diff --git a/src/windows/NetworkerThread.cpp b/src/windows/NetworkerThread.cpp index 98ffaa7..71678d5 100644 --- a/src/windows/NetworkerThread.cpp +++ b/src/windows/NetworkerThread.cpp @@ -110,6 +110,9 @@ void NetworkerThread::FulfillRequest(NetRequest& req) // for now..... client.enable_server_certificate_verification(false); + // Follow redirects. Used by GitHub auto-update service + client.set_follow_location(true); + Headers headers; headers.insert(std::make_pair("User-Agent", GetFrontend()->GetUserAgent())); diff --git a/src/windows/WinUtils.cpp b/src/windows/WinUtils.cpp index a1aefc3..4328f49 100644 --- a/src/windows/WinUtils.cpp +++ b/src/windows/WinUtils.cpp @@ -626,6 +626,7 @@ LPCTSTR GetFilter(const std::string& fileName) EndsWith(fileName, ".jpeg")) return TEXT("JPG file\0*.jpg\0JPEG file\0*.jpeg\0\0"); if (EndsWith(fileName, ".gif")) return TEXT("GIF file\0*.webp\0\0"); if (EndsWith(fileName, ".webp")) return TEXT("WEBP file\0*.webp\0\0"); + if (EndsWith(fileName, ".zip")) return TEXT("ZIP file\0*.zip\0\0"); return TEXT("All files\0*.*\0\0"); } @@ -636,9 +637,10 @@ void DownloadFileDialog(HWND hWnd, const std::string& url, const std::string& fi LPTSTR fileTitle2 = ConvertCppStringToTString(fileName); LPTSTR buff = (LPTSTR) new TCHAR[MAX_FILE]; - _tcscpy(buff, fileTitle2); - free(fileTitle2); + buff[MAX_FILE - 1] = 0; buff[0] = 0; + _tcsncpy(buff, fileTitle2, MAX_FILE); + free(fileTitle2); OPENFILENAME ofn{}; ofn.lStructSize = sizeof(ofn); diff --git a/vs/DiscordMessenger.vcxproj b/vs/DiscordMessenger.vcxproj index 19ce624..2d01b3f 100644 --- a/vs/DiscordMessenger.vcxproj +++ b/vs/DiscordMessenger.vcxproj @@ -241,6 +241,7 @@ + diff --git a/vs/DiscordMessenger.vcxproj.filters b/vs/DiscordMessenger.vcxproj.filters index 604ea93..b819e35 100644 --- a/vs/DiscordMessenger.vcxproj.filters +++ b/vs/DiscordMessenger.vcxproj.filters @@ -40,6 +40,9 @@ {8baa4f98-a70c-4417-afbc-c45523d2fb51} + + {552415f8-f70b-4d64-9741-f2722deed194} + @@ -500,6 +503,9 @@ Header Files\Windows + + Source Files\Deps\Httplib +