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 "PluginSettings.h" | 6 #include "PluginSettings.h" |
7 #include "PluginSystem.h" | 7 #include "PluginSystem.h" |
8 #include "PluginConfiguration.h" | |
9 #ifdef SUPPORT_FILTER | 8 #ifdef SUPPORT_FILTER |
10 #include "PluginFilter.h" | 9 #include "PluginFilter.h" |
11 #endif | 10 #endif |
12 #ifdef SUPPORT_CONFIG | 11 #ifdef SUPPORT_CONFIG |
13 #include "PluginConfig.h" | 12 #include "PluginConfig.h" |
14 #endif | 13 #endif |
15 #include "PluginMimeFilterClient.h" | 14 #include "PluginMimeFilterClient.h" |
16 | 15 |
17 #include "PluginClient.h" | 16 #include "PluginClient.h" |
18 #include "PluginClientFactory.h" | 17 #include "PluginClientFactory.h" |
19 #include "PluginWbPassThrough.h" | 18 #include "PluginWbPassThrough.h" |
20 #include "PluginHttpRequest.h" | |
21 | 19 |
22 #include "ProtocolImpl.h" | 20 #include "ProtocolImpl.h" |
23 #include "ProtocolCF.h" | 21 #include "ProtocolCF.h" |
24 | 22 |
25 HANDLE CPluginClass::s_hMainThread = NULL; | 23 HANDLE CPluginClass::s_hMainThread = NULL; |
26 bool CPluginClass::s_isMainThreadDone = false; | 24 bool CPluginClass::s_isMainThreadDone = false; |
27 | 25 |
28 | 26 |
29 DWORD WINAPI CPluginClass::MainThreadProc(LPVOID pParam) | 27 DWORD WINAPI CPluginClass::MainThreadProc(LPVOID pParam) |
30 { | 28 { |
(...skipping 20 matching lines...) Expand all Loading... |
51 debugText += L"\nBrowser version: " + system->GetBrowserVersion(); | 49 debugText += L"\nBrowser version: " + system->GetBrowserVersion(); |
52 debugText += L"\nBrowser language: " + system->GetBrowserLanguage(); | 50 debugText += L"\nBrowser language: " + system->GetBrowserLanguage(); |
53 | 51 |
54 DWORD osVersion = ::GetVersion(); | 52 DWORD osVersion = ::GetVersion(); |
55 | 53 |
56 CString ver; | 54 CString ver; |
57 ver.Format(L"%d.%d", LOBYTE(LOWORD(osVersion)), HIBYTE(LOWORD(osVersion))); | 55 ver.Format(L"%d.%d", LOBYTE(LOWORD(osVersion)), HIBYTE(LOWORD(osVersion))); |
58 | 56 |
59 | 57 |
60 debugText += L"\nWindows version: " + ver; | 58 debugText += L"\nWindows version: " + ver; |
61 | |
62 CString proxyName; | |
63 CString proxyBypass; | |
64 | |
65 if (CPluginHttpRequest::GetProxySettings(proxyName, proxyBypass)) | |
66 { | |
67 if (!proxyName.IsEmpty()) | |
68 { | |
69 debugText += L"\nHTTP proxy name: " + proxyName; | |
70 } | |
71 if (!proxyBypass.IsEmpty()) | |
72 { | |
73 debugText += L"\nHTTP proxy bypass: " + proxyBypass; | |
74 } | |
75 } | |
76 | |
77 debugText += L"\n=============================================================
==================="; | 59 debugText += L"\n=============================================================
==================="; |
78 | 60 |
79 DEBUG_GENERAL(debugText) | 61 DEBUG_GENERAL(debugText) |
80 | 62 |
81 HANDLE hMainThread = GetMainThreadHandle(); | 63 HANDLE hMainThread = GetMainThreadHandle(); |
82 | |
83 CPluginClient* client = CPluginClient::GetInstance(); | |
84 client->SetLocalization(); | |
85 | 64 |
86 DWORD nNextUserTimerBase = GetTickCount() / TIMER_INTERVAL_USER_REGISTRATION +
1; | 65 DWORD nNextUserTimerBase = GetTickCount() / TIMER_INTERVAL_USER_REGISTRATION +
1; |
87 DWORD nUserTimerBaseStep = 1; | 66 DWORD nUserTimerBaseStep = 1; |
88 | 67 |
89 bool isConfigutationLoaded = false; | |
90 | |
91 std::auto_ptr<CPluginConfiguration> configuration = std::auto_ptr<CPluginConfi
guration>(new CPluginConfiguration); | |
92 | |
93 // -------------------------------------------------------------------- | 68 // -------------------------------------------------------------------- |
94 // Welcome / Info page | 69 // Welcome / Info page |
95 // -------------------------------------------------------------------- | 70 // -------------------------------------------------------------------- |
96 | 71 |
97 DEBUG_THREAD("Thread::Set welcome/info page"); | 72 DEBUG_THREAD("Thread::Set welcome/info page"); |
98 | 73 |
99 if (!IsMainThreadDone(hMainThread)) | 74 if (!IsMainThreadDone(hMainThread)) |
100 { | 75 { |
101 WORD wInfo = 0; | 76 WORD wInfo = 0; |
102 WORD wInfoSettings = 0; | 77 WORD wInfoSettings = 0; |
103 | 78 |
104 wInfo = wInfoSettings = settings->GetValue(SETTING_PLUGIN_INFO_PANEL, 0); | |
105 if (wInfo == 1) | |
106 { | |
107 DEBUG_GENERAL("*** Display welcome page") | |
108 } | |
109 else if (wInfo == 2) | |
110 { | |
111 DEBUG_GENERAL("*** Display update page") | |
112 } | |
113 else if (wInfo != 0) | |
114 { | |
115 DEBUG_GENERAL("*** Display info page") | |
116 } | |
117 | 79 |
| 80 // TODO: Add First run page logic here |
118 if (wInfo != 0) | 81 if (wInfo != 0) |
119 { | 82 { |
120 DEBUG_THREAD("Thread::Set info page (action)"); | 83 DEBUG_THREAD("Thread::Set info page (action)"); |
121 | 84 |
122 s_criticalSectionLocal.Lock(); | 85 s_criticalSectionLocal.Lock(); |
123 { | 86 { |
124 ::PostMessage(tab->m_plugin->m_hPaneWnd, WM_LAUNCH_INFO, wInfo, NULL); | 87 ::PostMessage(tab->m_plugin->m_hPaneWnd, WM_LAUNCH_INFO, wInfo, NULL); |
125 } | 88 } |
126 s_criticalSectionLocal.Unlock(); | 89 s_criticalSectionLocal.Unlock(); |
127 | |
128 if (wInfoSettings == wInfo) | |
129 { | |
130 settings->Remove(SETTING_PLUGIN_INFO_PANEL); | |
131 settings->Write(); | |
132 } | |
133 } | 90 } |
134 } | 91 } |
135 | 92 |
136 // -------------------------------------------------------------------- | 93 // -------------------------------------------------------------------- |
137 // Main loop | 94 // Main loop |
138 // -------------------------------------------------------------------- | 95 // -------------------------------------------------------------------- |
139 | 96 |
140 DWORD mainLoopIteration = 1; | 97 DWORD mainLoopIteration = 1; |
141 | 98 |
142 while (!IsMainThreadDone(hMainThread)) | 99 while (!IsMainThreadDone(hMainThread)) |
(...skipping 10 matching lines...) Expand all Loading... |
153 DEBUG_GENERAL(debugText) | 110 DEBUG_GENERAL(debugText) |
154 | 111 |
155 // -------------------------------------------------------------------- | 112 // -------------------------------------------------------------------- |
156 // Update settings | 113 // Update settings |
157 // -------------------------------------------------------------------- | 114 // -------------------------------------------------------------------- |
158 | 115 |
159 if (!IsMainThreadDone(hMainThread)) | 116 if (!IsMainThreadDone(hMainThread)) |
160 { | 117 { |
161 DEBUG_THREAD("Thread::Update settings"); | 118 DEBUG_THREAD("Thread::Update settings"); |
162 | 119 |
163 if (configuration->IsValid()) | 120 bool isNewDictionaryVersion = false; |
164 { | |
165 bool isNewDictionaryVersion = false; | |
166 #ifdef SUPPORT_FILTER | 121 #ifdef SUPPORT_FILTER |
167 bool isNewFilterVersion = false; | 122 bool isNewFilterVersion = false; |
168 #endif | 123 #endif |
169 #ifdef SUPPORT_CONFIG | 124 #ifdef SUPPORT_CONFIG |
170 bool isNewConfig = false; | 125 bool isNewConfig = false; |
171 #endif | 126 #endif |
172 | 127 |
173 DEBUG_THREAD("Thread::Update settings (action)"); | 128 DEBUG_THREAD("Thread::Update settings (action)"); |
174 | 129 |
175 settings->ForceConfigurationUpdateOnStart(false); | 130 // Update filters, if needed (5 days * (random() * 0.4 + 0.8)) |
176 | 131 settings->RefreshFilterlist(); |
177 if (configuration->IsValidPluginInfoPanel()) | 132 tab->OnUpdate(); |
178 { | |
179 settings->SetValue(SETTING_PLUGIN_INFO_PANEL, configuration->GetPlug
inInfoPanel()); | |
180 } | |
181 | |
182 #ifdef SUPPORT_FILTER | |
183 // Update filter URL list | |
184 if (configuration->IsValidFilter()) | |
185 { | |
186 isNewFilterVersion = true; | |
187 } | |
188 #endif // SUPPORT_FILTER | |
189 | |
190 settings->Write(); | |
191 | |
192 configuration->Invalidate(); | |
193 | |
194 #ifdef SUPPORT_FILTER | |
195 DEBUG_GENERAL("*** before isNewFilterVersion"); | |
196 | |
197 // Update filters, if needed (5 days * (random() * 0.4 + 0.8)) | |
198 if (isNewFilterVersion) | |
199 { | |
200 | |
201 DEBUG_GENERAL("*** before CheckFilterAndDownload"); | |
202 settings->RefreshFilterlist(); | |
203 | |
204 | |
205 settings->Write(); | |
206 | |
207 tab->OnUpdate(); | |
208 } | |
209 #endif // SUPPORT_FILTER | |
210 } | |
211 } | 133 } |
212 | 134 |
213 | 135 |
214 // ---------------------------------------------------------------- | 136 // ---------------------------------------------------------------- |
215 // End loop | 137 // End loop |
216 // ---------------------------------------------------------------- | 138 // ---------------------------------------------------------------- |
217 | 139 |
218 if (!IsMainThreadDone(hMainThread)) | 140 if (!IsMainThreadDone(hMainThread)) |
219 { | 141 { |
220 bool isDone = false; | 142 bool isDone = false; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 bool isDone = false; | 181 bool isDone = false; |
260 | 182 |
261 s_criticalSectionLocal.Lock(); | 183 s_criticalSectionLocal.Lock(); |
262 { | 184 { |
263 isDone = s_isMainThreadDone || mainThread != s_hMainThread; | 185 isDone = s_isMainThreadDone || mainThread != s_hMainThread; |
264 } | 186 } |
265 s_criticalSectionLocal.Unlock(); | 187 s_criticalSectionLocal.Unlock(); |
266 | 188 |
267 return isDone; | 189 return isDone; |
268 } | 190 } |
OLD | NEW |