| OLD | NEW |
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include <ctime> | 3 #include <ctime> |
| 4 | 4 |
| 5 #include "PluginClass.h" | 5 #include "PluginClass.h" |
| 6 #include "PluginDictionary.h" | 6 #include "PluginDictionary.h" |
| 7 #include "PluginSettings.h" | 7 #include "PluginSettings.h" |
| 8 #include "PluginSystem.h" | 8 #include "PluginSystem.h" |
| 9 #include "PluginConfiguration.h" | 9 #include "PluginConfiguration.h" |
| 10 #ifdef SUPPORT_FILTER | 10 #ifdef SUPPORT_FILTER |
| 11 #include "PluginFilter.h" | 11 #include "PluginFilter.h" |
| 12 #endif | 12 #endif |
| 13 #ifdef SUPPORT_CONFIG | 13 #ifdef SUPPORT_CONFIG |
| 14 #include "PluginConfig.h" | 14 #include "PluginConfig.h" |
| 15 #endif | 15 #endif |
| 16 #include "PluginMimeFilterClient.h" | 16 #include "PluginMimeFilterClient.h" |
| 17 | 17 |
| 18 #include "PluginUpdateDialog.h" | |
| 19 #include "PluginDownloadDialog.h" | |
| 20 #include "PluginClient.h" | 18 #include "PluginClient.h" |
| 21 #include "PluginClientFactory.h" | 19 #include "PluginClientFactory.h" |
| 22 #include "PluginWbPassThrough.h" | 20 #include "PluginWbPassThrough.h" |
| 23 #include "PluginHttpRequest.h" | 21 #include "PluginHttpRequest.h" |
| 24 | 22 |
| 25 #include "ProtocolImpl.h" | 23 #include "ProtocolImpl.h" |
| 26 #include "ProtocolCF.h" | 24 #include "ProtocolCF.h" |
| 27 | 25 |
| 28 HANDLE CPluginClass::s_hMainThread = NULL; | 26 HANDLE CPluginClass::s_hMainThread = NULL; |
| 29 bool CPluginClass::s_isMainThreadDone = false; | 27 bool CPluginClass::s_isMainThreadDone = false; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 130 |
| 133 if (wInfoSettings == wInfo) | 131 if (wInfoSettings == wInfo) |
| 134 { | 132 { |
| 135 settings->Remove(SETTING_PLUGIN_INFO_PANEL); | 133 settings->Remove(SETTING_PLUGIN_INFO_PANEL); |
| 136 settings->Write(); | 134 settings->Write(); |
| 137 } | 135 } |
| 138 } | 136 } |
| 139 } | 137 } |
| 140 | 138 |
| 141 // -------------------------------------------------------------------- | 139 // -------------------------------------------------------------------- |
| 142 // Should update plugin ? | |
| 143 // -------------------------------------------------------------------- | |
| 144 | |
| 145 if (!IsMainThreadDone(hMainThread) && settings->IsPluginUpdateAvailable()) | |
| 146 { | |
| 147 DEBUG_THREAD(L"Thread::Should update plugin"); | |
| 148 | |
| 149 CString lastUpdateStr = settings->GetString(SETTING_PLUGIN_UPDATE_TIME); | |
| 150 | |
| 151 std::time_t today = std::time(NULL); | |
| 152 std::time_t lastUpdate = lastUpdateStr.IsEmpty() ? today : _wtoi(lastUpdateS
tr.GetBuffer()); | |
| 153 | |
| 154 if (today != (std::time_t)(-1) && lastUpdate != (std::time_t)(-1)) | |
| 155 { | |
| 156 if (today == lastUpdate || std::difftime(today, lastUpdate) / (60 * 60 * 2
4) >= 5.0) | |
| 157 { | |
| 158 CString updateVersion = settings->GetString(SETTING_PLUGIN_UPDATE_VERSIO
N); | |
| 159 | |
| 160 DEBUG_GENERAL(L"*** Displaying update plugin dialog for version " + upda
teVersion); | |
| 161 | |
| 162 // Show update dialog | |
| 163 CUpdateDialog uDlg; | |
| 164 | |
| 165 uDlg.SetVersions(updateVersion, IEPLUGIN_VERSION); | |
| 166 | |
| 167 if (uDlg.DoModal(::GetDesktopWindow()) == IDOK) | |
| 168 { | |
| 169 s_isPluginToBeUpdated = true; | |
| 170 } | |
| 171 | |
| 172 settings->SetValue(SETTING_PLUGIN_UPDATE_TIME, (int)today); | |
| 173 settings->Write(); | |
| 174 } | |
| 175 } | |
| 176 } | |
| 177 | |
| 178 // -------------------------------------------------------------------- | |
| 179 // Main loop | 140 // Main loop |
| 180 // -------------------------------------------------------------------- | 141 // -------------------------------------------------------------------- |
| 181 | 142 |
| 182 DWORD mainLoopIteration = 1; | 143 DWORD mainLoopIteration = 1; |
| 183 | 144 |
| 184 while (!IsMainThreadDone(hMainThread)) | 145 while (!IsMainThreadDone(hMainThread)) |
| 185 { | 146 { |
| 186 CString sMainLoopIteration; | 147 CString sMainLoopIteration; |
| 187 sMainLoopIteration.Format(L"%u", mainLoopIteration); | 148 sMainLoopIteration.Format(L"%u", mainLoopIteration); |
| 188 | 149 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 #ifdef SUPPORT_FILTER | 197 #ifdef SUPPORT_FILTER |
| 237 DEBUG_GENERAL("*** before isNewFilterVersion"); | 198 DEBUG_GENERAL("*** before isNewFilterVersion"); |
| 238 | 199 |
| 239 // Update filters, if needed (5 days * (random() * 0.4 + 0.8)) | 200 // Update filters, if needed (5 days * (random() * 0.4 + 0.8)) |
| 240 if (isNewFilterVersion) | 201 if (isNewFilterVersion) |
| 241 { | 202 { |
| 242 | 203 |
| 243 DEBUG_GENERAL("*** before CheckFilterAndDownload"); | 204 DEBUG_GENERAL("*** before CheckFilterAndDownload"); |
| 244 settings->RefreshFilterlist(); | 205 settings->RefreshFilterlist(); |
| 245 | 206 |
| 246 settings->MakeRequestForUpdate(); | |
| 247 | |
| 248 | 207 |
| 249 settings->Write(); | 208 settings->Write(); |
| 250 | 209 |
| 251 tab->OnUpdate(); | 210 tab->OnUpdate(); |
| 252 } | 211 } |
| 253 #endif // SUPPORT_FILTER | 212 #endif // SUPPORT_FILTER |
| 254 } | 213 } |
| 255 } | 214 } |
| 256 | 215 |
| 257 | 216 |
| 258 #ifndef ENTERPRISE | |
| 259 // -------------------------------------------------------------------- | |
| 260 // Update plugin | |
| 261 // -------------------------------------------------------------------- | |
| 262 | |
| 263 if (!IsMainThreadDone(hMainThread) && s_isPluginToBeUpdated) | |
| 264 { | |
| 265 DEBUG_GENERAL(L"*** Displaying download plugin dialog"); | |
| 266 | |
| 267 s_isPluginToBeUpdated = false; | |
| 268 | |
| 269 try | |
| 270 { | |
| 271 CString updateUrl = settings->GetString(SETTING_PLUGIN_UPDATE_URL); | |
| 272 CString updatePath = L""; | |
| 273 if (updateUrl.Find(L".exe") == updateUrl.GetLength() - 4) | |
| 274 { | |
| 275 updatePath = CPluginSettings::GetTempPath(INSTALL_EXE_FILE); | |
| 276 // Delete old installer | |
| 277 ::DeleteFile(CPluginSettings::GetTempPath(INSTALL_EXE_FILE)); | |
| 278 } | |
| 279 else | |
| 280 { | |
| 281 updatePath = CPluginSettings::GetTempPath(INSTALL_MSI_FILE); | |
| 282 // Delete old installer | |
| 283 ::DeleteFile(CPluginSettings::GetTempPath(INSTALL_MSI_FILE)); | |
| 284 } | |
| 285 | |
| 286 CPluginDownloadDialog dlDlg; | |
| 287 | |
| 288 dlDlg.SetUrlAndPath(updateUrl, updatePath); | |
| 289 if (dlDlg.DoModal(::GetDesktopWindow()) == IDC_INSTALLBTN) | |
| 290 { | |
| 291 LaunchUpdater(updatePath); | |
| 292 #ifdef AUTOMATIC_SHUTDOWN | |
| 293 settings->EraseTab(); | |
| 294 ::ExitProcess(0); | |
| 295 #endif // AUTOMATIC_SHUTDOWN | |
| 296 } | |
| 297 } | |
| 298 catch (std::runtime_error& er) | |
| 299 { | |
| 300 DEBUG_ERROR(er.what()); | |
| 301 } | |
| 302 } | |
| 303 #endif | |
| 304 // ---------------------------------------------------------------- | 217 // ---------------------------------------------------------------- |
| 305 // End loop | 218 // End loop |
| 306 // ---------------------------------------------------------------- | 219 // ---------------------------------------------------------------- |
| 307 | 220 |
| 308 if (!IsMainThreadDone(hMainThread)) | 221 if (!IsMainThreadDone(hMainThread)) |
| 309 { | 222 { |
| 310 bool isDone = false; | 223 bool isDone = false; |
| 311 DWORD sleepLoopIteration = 1; | 224 DWORD sleepLoopIteration = 1; |
| 312 | 225 |
| 313 // Sleep loop | 226 // Sleep loop |
| 314 while (!isDone && !IsMainThreadDone(hMainThread) && !s_isPluginToBeUpdat
ed) | 227 while (!isDone && !IsMainThreadDone(hMainThread)) |
| 315 { | 228 { |
| 316 // Non-hanging sleep | 229 // Non-hanging sleep |
| 317 Sleep(5000); | 230 Sleep(5000); |
| 318 | 231 |
| 319 if (sleepLoopIteration++ % (TIMER_THREAD_SLEEP_USER_REGISTRATION) == 0
) | 232 if (sleepLoopIteration++ % (TIMER_THREAD_SLEEP_USER_REGISTRATION) == 0
) |
| 320 { | 233 { |
| 321 isDone = true; | 234 isDone = true; |
| 322 } | 235 } |
| 323 } | 236 } |
| 324 } | 237 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 349 bool isDone = false; | 262 bool isDone = false; |
| 350 | 263 |
| 351 s_criticalSectionLocal.Lock(); | 264 s_criticalSectionLocal.Lock(); |
| 352 { | 265 { |
| 353 isDone = s_isMainThreadDone || mainThread != s_hMainThread; | 266 isDone = s_isMainThreadDone || mainThread != s_hMainThread; |
| 354 } | 267 } |
| 355 s_criticalSectionLocal.Unlock(); | 268 s_criticalSectionLocal.Unlock(); |
| 356 | 269 |
| 357 return isDone; | 270 return isDone; |
| 358 } | 271 } |
| OLD | NEW |