Index: src/engine/Updater.cpp |
=================================================================== |
--- a/src/engine/Updater.cpp |
+++ b/src/engine/Updater.cpp |
@@ -1,14 +1,15 @@ |
#include <functional> |
#include <memory> |
#include <sstream> |
#include <AdblockPlus/FileSystem.h> |
#include <AdblockPlus/WebRequest.h> |
+#include "../shared/Dictionary.h" |
#include "../shared/Utils.h" |
#include "Debug.h" |
#include "Resource.h" |
#include "Updater.h" |
namespace |
{ |
typedef std::function<void()> ThreadCallbackType; |
@@ -17,17 +18,22 @@ namespace |
const int DOWNLOAD_FAILED = 101; |
LRESULT CALLBACK UpdateDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
{ |
switch (msg) |
{ |
case WM_INITDIALOG: |
{ |
- // TODO: Localize dialog strings |
+ Dictionary* dict = Dictionary::GetInstance(); |
+ SetWindowTextW(hWnd, dict->Lookup("updater", "update-title").c_str()); |
+ SetDlgItemTextW(hWnd, IDC_UPDATETEXT, dict->Lookup("updater", "update-text").c_str()); |
+ SetDlgItemTextW(hWnd, IDC_DOYOU, dict->Lookup("updater", "update-question").c_str()); |
+ SetDlgItemTextW(hWnd, IDOK, dict->Lookup("general", "button-yes").c_str()); |
+ SetDlgItemTextW(hWnd, IDCANCEL, dict->Lookup("general", "button-no").c_str()); |
return TRUE; |
} |
case WM_COMMAND: |
{ |
if (wParam == IDOK || wParam == IDCANCEL) |
{ |
EndDialog(hWnd, wParam); |
return TRUE; |
@@ -42,17 +48,21 @@ namespace |
LRESULT CALLBACK DownloadDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
{ |
// TODO: Indicate progress |
switch (msg) |
{ |
case WM_INITDIALOG: |
{ |
- // TODO: Localize dialog strings |
+ Dictionary* dict = Dictionary::GetInstance(); |
+ SetWindowTextW(hWnd, dict->Lookup("updater", "download-title").c_str()); |
+ SetDlgItemTextW(hWnd, IDC_INSTALLMSG, dict->Lookup("updater", "download-progress-text").c_str()); |
+ SetDlgItemTextW(hWnd, IDCANCEL, dict->Lookup("general", "button-cancel").c_str()); |
+ |
std::auto_ptr<DialogCallbackType> callback(reinterpret_cast<DialogCallbackType*>(lParam)); |
(*callback)(hWnd); |
return TRUE; |
} |
case WM_COMMAND: |
{ |
if (wParam == IDCANCEL) |
{ |
@@ -89,32 +99,38 @@ void Updater::Update() |
DialogCallbackType* callback = new DialogCallbackType(std::bind(&Updater::StartDownload, |
this, std::placeholders::_1)); |
int result = DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DOWNLOADDIALOG), GetDesktopWindow(), |
reinterpret_cast<DLGPROC>(&DownloadDlgProc), |
reinterpret_cast<LPARAM>(callback)); |
if (result == DOWNLOAD_FAILED) |
{ |
- // TODO: Localize |
- MessageBoxW(NULL, L"Download failed", L"Downloading update", 0); |
+ Dictionary* dict = Dictionary::GetInstance(); |
+ MessageBoxW(NULL, |
+ dict->Lookup("updater", "download-error-neterror").c_str(), |
+ dict->Lookup("updater", "download-error-title").c_str(), |
+ 0); |
} |
if (result != IDOK) |
return; |
PROCESS_INFORMATION pi; |
STARTUPINFO si; |
::ZeroMemory(&si, sizeof(si)); |
si.cb = sizeof(si); |
si.wShowWindow = FALSE; |
if (!::CreateProcessW(tempFile.c_str(), NULL, NULL, NULL, FALSE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi)) |
{ |
- // TODO: Localize |
- MessageBoxW(NULL, L"Failed to run updater", L"Downloading update", 0); |
+ Dictionary* dict = Dictionary::GetInstance(); |
+ MessageBoxW(NULL, |
+ dict->Lookup("updater", "download-error-runerror").c_str(), |
+ dict->Lookup("updater", "download-error-title").c_str(), |
+ 0); |
DebugLastError("Creating updater process failed"); |
return; |
} |
::CloseHandle(pi.hProcess); |
::CloseHandle(pi.hThread); |
} |
} |