| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #include "ProtocolImpl.h" | 25 #include "ProtocolImpl.h" |
| 26 #include "ProtocolCF.h" | 26 #include "ProtocolCF.h" |
| 27 | 27 |
| 28 HANDLE CPluginClass::s_hMainThread = NULL; | 28 HANDLE CPluginClass::s_hMainThread = NULL; |
| 29 bool CPluginClass::s_isMainThreadDone = false; | 29 bool CPluginClass::s_isMainThreadDone = false; |
| 30 | 30 |
| 31 | 31 |
| 32 DWORD WINAPI CPluginClass::MainThreadProc(LPVOID pParam) | 32 DWORD WINAPI CPluginClass::MainThreadProc(LPVOID pParam) |
| 33 { | 33 { |
| 34 |
| 34 CPluginTab* tab = static_cast<CPluginTab*>(pParam); | 35 CPluginTab* tab = static_cast<CPluginTab*>(pParam); |
| 35 | 36 |
| 36 // Force loading/creation of settings | 37 // Force loading/creation of settings |
| 37 CPluginSettings* settings = CPluginSettings::GetInstance(); | 38 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 38 | 39 |
| 39 CPluginSystem* system = CPluginSystem::GetInstance(); | 40 CPluginSystem* system = CPluginSystem::GetInstance(); |
| 40 | 41 |
| 41 settings->SetMainThreadId(); | 42 settings->SetMainThreadId(); |
| 42 | 43 |
| 43 CString debugText; | 44 CString debugText; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 bool isNewFilterVersion = false; | 208 bool isNewFilterVersion = false; |
| 208 #endif | 209 #endif |
| 209 #ifdef SUPPORT_CONFIG | 210 #ifdef SUPPORT_CONFIG |
| 210 bool isNewConfig = false; | 211 bool isNewConfig = false; |
| 211 #endif | 212 #endif |
| 212 | 213 |
| 213 DEBUG_THREAD("Thread::Update settings (action)"); | 214 DEBUG_THREAD("Thread::Update settings (action)"); |
| 214 | 215 |
| 215 settings->ForceConfigurationUpdateOnStart(false); | 216 settings->ForceConfigurationUpdateOnStart(false); |
| 216 | 217 |
| 217 if (configuration->IsValidPluginUpdate() && configur
ation->GetPluginUpdateVersion() != IEPLUGIN_VERSION) | |
| 218 { | |
| 219 settings->SetString(SETTING_PLUGIN_UPDATE_URL, configuration
->GetPluginUpdateUrl()); | |
| 220 settings->SetString(SETTING_PLUGIN_UPDATE_VERSION, configura
tion->GetPluginUpdateVersion()); | |
| 221 } | |
| 222 else | |
| 223 { | |
| 224 settings->Remove(SETTING_PLUGIN_UPDATE_VERSION); | |
| 225 settings->Remove(SETTING_PLUGIN_UPDATE_URL); | |
| 226 } | |
| 227 | |
| 228 if (configuration->IsValidPluginInfoPanel()) | 218 if (configuration->IsValidPluginInfoPanel()) |
| 229 { | 219 { |
| 230 settings->SetValue(SETTING_PLUGIN_INFO_PANEL
, configuration->GetPluginInfoPanel()); | 220 settings->SetValue(SETTING_PLUGIN_INFO_PANEL
, configuration->GetPluginInfoPanel()); |
| 231 } | 221 } |
| 232 | 222 |
| 233 #ifdef SUPPORT_FILTER | 223 #ifdef SUPPORT_FILTER |
| 234 // Update filter URL list | 224 // Update filter URL list |
| 235 if (configuration->IsValidFilter()) | 225 if (configuration->IsValidFilter()) |
| 236 { | 226 { |
| 237 isNewFilterVersion = true; | 227 isNewFilterVersion = true; |
| 238 } | 228 } |
| 239 #endif // SUPPORT_FILTER | 229 #endif // SUPPORT_FILTER |
| 240 | 230 |
| 241 settings->Write(); | 231 settings->Write(); |
| 242 | 232 |
| 243 configuration->Invalidate(); | 233 configuration->Invalidate(); |
| 244 | 234 |
| 245 #ifdef SUPPORT_FILTER | 235 #ifdef SUPPORT_FILTER |
| 246 // Update filters, if needed (5 days * (random() * 0.4 + 0.8)) | 236 // Update filters, if needed (5 days * (random() * 0.4 + 0.8)) |
| 247 if (isNewFilterVersion) | 237 if (isNewFilterVersion) |
| 248 { | 238 { |
| 249 | 239 |
| 250 settings->CheckFilterAndDownload(); | 240 settings->CheckFilterAndDownload(); |
| 251 | 241 |
| 252 settings->MakeRequestForUpdate(); | 242 settings->MakeRequestForUpdate(); |
| 243 |
| 244 |
| 245 settings->Write(); |
| 246 |
| 253 tab->OnUpdate(); | 247 tab->OnUpdate(); |
| 254 } | 248 } |
| 255 #endif // SUPPORT_FILTER | 249 #endif // SUPPORT_FILTER |
| 256 } | 250 } |
| 257 } | 251 } |
| 258 | 252 |
| 259 // -----------------------------------------------------------------
--- | |
| 260 // Check filters | |
| 261 // -----------------------------------------------------------------
--- | |
| 262 #ifdef SUPPORT_FILTER | |
| 263 | |
| 264 DEBUG_THREAD(L"Thread::Check filters"); | |
| 265 | |
| 266 if (!IsMainThreadDone(hMainThread)) | |
| 267 { | |
| 268 if (client->DownloadFirstMissingFilter()) | |
| 269 { | |
| 270 tab->OnUpdate(); | |
| 271 } | |
| 272 } | |
| 273 | |
| 274 #endif // SUPPORT_FILTER | |
| 275 | 253 |
| 276 #ifndef ENTERPRISE | 254 #ifndef ENTERPRISE |
| 277 // -----------------------------------------------------------------
--- | 255 // -----------------------------------------------------------------
--- |
| 278 // Update plugin | 256 // Update plugin |
| 279 // -----------------------------------------------------------------
--- | 257 // -----------------------------------------------------------------
--- |
| 280 | 258 |
| 281 if (!IsMainThreadDone(hMainThread) && s_isPluginToBeUpdated) | 259 if (!IsMainThreadDone(hMainThread) && s_isPluginToBeUpdated) |
| 282 { | 260 { |
| 283 DEBUG_GENERAL(L"*** Displaying download plugin dialog"); | 261 DEBUG_GENERAL(L"*** Displaying download plugin dialog"); |
| 284 | 262 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 297 dlDlg.SetUrlAndPath(updateUrl, updatePath); | 275 dlDlg.SetUrlAndPath(updateUrl, updatePath); |
| 298 if (dlDlg.DoModal(::GetDesktopWindow()) == IDC_INSTALLBT
N) | 276 if (dlDlg.DoModal(::GetDesktopWindow()) == IDC_INSTALLBT
N) |
| 299 { | 277 { |
| 300 LaunchUpdater(updatePath); | 278 LaunchUpdater(updatePath); |
| 301 #ifdef AUTOMATIC_SHUTDOWN | 279 #ifdef AUTOMATIC_SHUTDOWN |
| 302 settings->EraseTab(); | 280 settings->EraseTab(); |
| 303 ::ExitProcess(0); | 281 ::ExitProcess(0); |
| 304 #endif // AUTOMATIC_SHUTDOWN | 282 #endif // AUTOMATIC_SHUTDOWN |
| 305 } | 283 } |
| 306 } | 284 } |
| 307 catch (std::runtime_error&) | 285 catch (std::runtime_error& er) |
| 308 { | 286 { |
| 287 DEBUG_ERROR(er.what()); |
| 309 } | 288 } |
| 310 } | 289 } |
| 311 #endif | 290 #endif |
| 312 // ---------------------------------------------------------------- | 291 // ---------------------------------------------------------------- |
| 313 // End loop | 292 // End loop |
| 314 // ---------------------------------------------------------------- | 293 // ---------------------------------------------------------------- |
| 315 | 294 |
| 316 if (!IsMainThreadDone(hMainThread)) | 295 if (!IsMainThreadDone(hMainThread)) |
| 317 { | 296 { |
| 318 bool isDone = false; | 297 bool isDone = false; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 bool isDone = false; | 336 bool isDone = false; |
| 358 | 337 |
| 359 s_criticalSectionLocal.Lock(); | 338 s_criticalSectionLocal.Lock(); |
| 360 { | 339 { |
| 361 isDone = s_isMainThreadDone || mainThread != s_hMainThread; | 340 isDone = s_isMainThreadDone || mainThread != s_hMainThread; |
| 362 } | 341 } |
| 363 s_criticalSectionLocal.Unlock(); | 342 s_criticalSectionLocal.Unlock(); |
| 364 | 343 |
| 365 return isDone; | 344 return isDone; |
| 366 } | 345 } |
| OLD | NEW |