OLD | NEW |
1 #include <functional> | 1 #include <functional> |
2 #include <memory> | 2 #include <memory> |
3 #include <sstream> | 3 #include <sstream> |
4 | 4 |
5 #include <Windows.h> | 5 #include <Windows.h> |
6 | 6 |
7 #include <AdblockPlus/FileSystem.h> | 7 #include <AdblockPlus/FileSystem.h> |
8 #include <AdblockPlus/WebRequest.h> | 8 #include <AdblockPlus/WebRequest.h> |
9 | 9 |
10 #include "../shared/AutoHandle.h" | 10 #include "../shared/AutoHandle.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 HINSTANCE instance = ShellExecuteW(NULL, operation, msiexec.c_str(), params.
c_str(), NULL, SW_HIDE); | 69 HINSTANCE instance = ShellExecuteW(NULL, operation, msiexec.c_str(), params.
c_str(), NULL, SW_HIDE); |
70 if (reinterpret_cast<int>(instance) <= 32) | 70 if (reinterpret_cast<int>(instance) <= 32) |
71 return false; | 71 return false; |
72 | 72 |
73 // As far as we are concerned everything is fine - MSI service will handle | 73 // As far as we are concerned everything is fine - MSI service will handle |
74 // further errors. | 74 // further errors. |
75 return true; | 75 return true; |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 Updater::Updater(AdblockPlus::JsEnginePtr jsEngine, const std::string& url) | 79 Updater::Updater(AdblockPlus::JsEnginePtr jsEngine) |
80 : jsEngine(jsEngine), url(url), tempFile(GetAppDataPath() + L"\\update.msi") | 80 : jsEngine(jsEngine), tempFile(GetAppDataPath() + L"\\update.msi") |
81 { | 81 { |
82 } | 82 } |
83 | 83 |
| 84 void Updater::SetUrl(const std::string& url) |
| 85 { |
| 86 this->url = url; |
| 87 } |
| 88 |
84 void Updater::Update() | 89 void Updater::Update() |
85 { | 90 { |
86 Debug("Downloading update: " + url); | 91 Debug("Downloading update: " + url); |
87 ThreadCallbackType* callback = new ThreadCallbackType(std::bind(&Updater::Down
load, this)); | 92 ThreadCallbackType* callback = new ThreadCallbackType(std::bind(&Updater::Down
load, this)); |
88 ::CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(&RunThread),
callback, 0, NULL); | 93 ::CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(&RunThread),
callback, 0, NULL); |
89 } | 94 } |
90 | 95 |
91 void Updater::Download() | 96 void Updater::Download() |
92 { | 97 { |
93 AdblockPlus::ServerResponse response = jsEngine->GetWebRequest()->GET(url, Adb
lockPlus::HeaderList()); | 98 AdblockPlus::ServerResponse response = jsEngine->GetWebRequest()->GET(url, Adb
lockPlus::HeaderList()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 { | 141 { |
137 DebugLastError("Failed to install update"); | 142 DebugLastError("Failed to install update"); |
138 Dictionary* dictionary = Dictionary::GetInstance(); | 143 Dictionary* dictionary = Dictionary::GetInstance(); |
139 MessageBoxW( | 144 MessageBoxW( |
140 0, dictionary->Lookup("updater", "install-error-text").c_str(), | 145 0, dictionary->Lookup("updater", "install-error-text").c_str(), |
141 dictionary->Lookup("updater", "install-error-title").c_str(), | 146 dictionary->Lookup("updater", "install-error-title").c_str(), |
142 MB_OK | MB_ICONEXCLAMATION); | 147 MB_OK | MB_ICONEXCLAMATION); |
143 } | 148 } |
144 } | 149 } |
145 } | 150 } |
OLD | NEW |