23#include <wx/filename.h>
24#include <wx/stdpaths.h>
26#include <wx/tokenzr.h>
49 wxString temp = aPath +
'\0';
51 SHFILEOPSTRUCT fileOp;
52 ::ZeroMemory( &fileOp,
sizeof( fileOp ) );
54 fileOp.hwnd =
nullptr;
55 fileOp.wFunc = FO_DELETE;
56 fileOp.pFrom = temp.c_str();
58 fileOp.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT;
60 int eVal = SHFileOperation( &fileOp );
64 aError = wxString::Format(
_(
"Error code: %d" ), eVal );
74 return ::PathIsNetworkPathW( aPath.wc_str() );
82 if( wxTheApp ==
nullptr )
85 return wxStandardPaths::Get().GetDocumentsDir();
88 return wxStandardPaths::Get().GetDocumentsDir();
96 if( wxTheApp ==
nullptr )
99 return wxStandardPaths::Get().GetUserConfigDir();
102 return wxStandardPaths::Get().GetUserConfigDir();
110 if( wxTheApp ==
nullptr )
113 return wxStandardPaths::Get().GetUserDataDir();
116 return wxStandardPaths::Get().GetUserDataDir();
124 if( wxTheApp ==
nullptr )
127 return wxStandardPaths::Get().GetUserLocalDataDir();
130 return wxStandardPaths::Get().GetUserLocalDataDir();
142 if( wxTheApp ==
nullptr )
145 wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
147 return wxStandardPaths::Get().GetUserLocalDataDir();
150 wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
152 return wxStandardPaths::Get().GetUserLocalDataDir();
160 bool autoProxyDetect =
false;
161 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxyConfig = { 0 };
162 WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions = { 0 };
163 WINHTTP_PROXY_INFO autoProxyInfo = { 0 };
164 HINTERNET proxyResolveSession = NULL;
165 bool success =
false;
169 LPWSTR proxyStr = NULL;
170 LPWSTR bypassProxyStr = NULL;
172 if( WinHttpGetIEProxyConfigForCurrentUser( &ieProxyConfig ) )
176 if( ieProxyConfig.fAutoDetect )
178 autoProxyDetect =
true;
181 if( ieProxyConfig.lpszAutoConfigUrl != NULL )
183 autoProxyDetect =
true;
184 autoProxyOptions.lpszAutoConfigUrl = ieProxyConfig.lpszAutoConfigUrl;
187 else if( GetLastError() == ERROR_FILE_NOT_FOUND )
190 autoProxyDetect =
true;
193 if( autoProxyDetect )
195 proxyResolveSession =
196 WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME,
197 WINHTTP_NO_PROXY_BYPASS, WINHTTP_FLAG_ASYNC );
199 if( proxyResolveSession )
202 if( autoProxyOptions.lpszAutoConfigUrl != NULL )
204 autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
208 autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
209 autoProxyOptions.dwAutoDetectFlags =
210 WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
215 autoProxyOptions.fAutoLogonIfChallenged = FALSE;
217 autoProxyDetect = WinHttpGetProxyForUrl( proxyResolveSession, aURL.c_str(),
218 &autoProxyOptions, &autoProxyInfo );
220 if( !autoProxyDetect && GetLastError() == ERROR_WINHTTP_LOGIN_FAILURE )
222 autoProxyOptions.fAutoLogonIfChallenged = TRUE;
225 autoProxyDetect = WinHttpGetProxyForUrl( proxyResolveSession, aURL.c_str(),
226 &autoProxyOptions, &autoProxyInfo );
229 if( autoProxyDetect )
231 if( autoProxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY )
233 proxyStr = autoProxyInfo.lpszProxy;
234 bypassProxyStr = autoProxyInfo.lpszProxyBypass;
238 WinHttpCloseHandle( proxyResolveSession );
242 if( !autoProxyDetect && ieProxyConfig.lpszProxy != NULL )
244 proxyStr = ieProxyConfig.lpszProxy;
245 bypassProxyStr = ieProxyConfig.lpszProxyBypass;
248 bool bypassed =
false;
249 if( bypassProxyStr != NULL )
251 wxStringTokenizer tokenizer( bypassProxyStr, wxT(
";" ) );
253 while( tokenizer.HasMoreTokens() )
255 wxString host = tokenizer.GetNextToken();
257 if( host == uri.GetServer() )
266 if( host ==
"<local>" )
268 if( !uri.GetServer().Contains(
"." ) )
278 if( !bypassed && proxyStr != NULL )
283 wxStringTokenizer tokenizer( proxyStr, wxT(
"; \t" ) );
285 while( tokenizer.HasMoreTokens() )
287 wxString entry = tokenizer.GetNextToken();
290 if( entry.Contains(
"=" ) )
292 wxString scheme = entry.BeforeFirst(
'=' ).Lower();
293 entry = entry.AfterFirst(
'=' );
296 if( scheme != uri.GetScheme().Lower() )
306 if( entry !=
"" && entry !=
":" && entry !=
"::" )
317 if( autoProxyInfo.lpszProxy )
319 GlobalFree( autoProxyInfo.lpszProxy );
320 autoProxyInfo.lpszProxy = NULL;
323 if( autoProxyInfo.lpszProxyBypass )
325 GlobalFree( autoProxyInfo.lpszProxyBypass );
326 autoProxyInfo.lpszProxyBypass = NULL;
329 if( ieProxyConfig.lpszAutoConfigUrl != NULL )
331 GlobalFree( ieProxyConfig.lpszAutoConfigUrl );
332 ieProxyConfig.lpszAutoConfigUrl = NULL;
335 if( ieProxyConfig.lpszProxy != NULL )
337 GlobalFree( ieProxyConfig.lpszProxy );
338 ieProxyConfig.lpszProxy = NULL;
341 if( ieProxyConfig.lpszProxyBypass != NULL )
343 GlobalFree( ieProxyConfig.lpszProxyBypass );
344 ieProxyConfig.lpszProxyBypass = NULL;
353 WINTRUST_FILE_INFO fileData;
354 memset( &fileData, 0,
sizeof( fileData ) );
355 fileData.cbStruct =
sizeof( WINTRUST_FILE_INFO );
356 fileData.pcwszFilePath = aPath.wc_str();
359 GUID policy = WINTRUST_ACTION_GENERIC_VERIFY_V2;
361 WINTRUST_DATA trustData;
362 memset( &trustData, 0,
sizeof( trustData ) );
364 trustData.cbStruct =
sizeof( trustData );
365 trustData.dwUIChoice = WTD_UI_NONE;
367 trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
368 trustData.dwUnionChoice = WTD_CHOICE_FILE;
369 trustData.dwStateAction = WTD_STATEACTION_VERIFY;
370 trustData.pFile = &fileData;
373 bool verified =
false;
374 LONG status = WinVerifyTrust( NULL, &policy, &trustData );
376 verified = ( status == ERROR_SUCCESS );
379 trustData.dwStateAction = WTD_STATEACTION_CLOSE;
380 WinVerifyTrust( NULL, &policy, &trustData );
std::vector< FAB_LAYER_COLOR > dummy