23#include <wx/filename.h>
24#include <wx/stdpaths.h>
26#include <wx/tokenzr.h>
48 wxString temp = aPath +
'\0';
50 SHFILEOPSTRUCT fileOp;
51 ::ZeroMemory( &fileOp,
sizeof( fileOp ) );
53 fileOp.hwnd =
nullptr;
54 fileOp.wFunc = FO_DELETE;
55 fileOp.pFrom = temp.c_str();
57 fileOp.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT;
59 int eVal = SHFileOperation( &fileOp );
63 aError = wxString::Format(
_(
"Error code: %d" ), eVal );
73 return ::PathIsNetworkPathW( aPath.wc_str() );
81 if( wxTheApp ==
nullptr )
84 return wxStandardPaths::Get().GetDocumentsDir();
87 return wxStandardPaths::Get().GetDocumentsDir();
95 if( wxTheApp ==
nullptr )
98 return wxStandardPaths::Get().GetUserConfigDir();
101 return wxStandardPaths::Get().GetUserConfigDir();
109 if( wxTheApp ==
nullptr )
112 return wxStandardPaths::Get().GetUserDataDir();
115 return wxStandardPaths::Get().GetUserDataDir();
123 if( wxTheApp ==
nullptr )
126 return wxStandardPaths::Get().GetUserLocalDataDir();
129 return wxStandardPaths::Get().GetUserLocalDataDir();
141 if( wxTheApp ==
nullptr )
144 wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
146 return wxStandardPaths::Get().GetUserLocalDataDir();
149 wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
151 return wxStandardPaths::Get().GetUserLocalDataDir();
159 bool autoProxyDetect =
false;
160 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxyConfig = { 0 };
161 WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions = { 0 };
162 WINHTTP_PROXY_INFO autoProxyInfo = { 0 };
163 HINTERNET proxyResolveSession = NULL;
164 bool success =
false;
166 if( WinHttpGetIEProxyConfigForCurrentUser( &ieProxyConfig ) )
170 if( ieProxyConfig.fAutoDetect )
172 autoProxyDetect =
true;
175 if( ieProxyConfig.lpszAutoConfigUrl != NULL )
177 autoProxyDetect =
true;
178 autoProxyOptions.lpszAutoConfigUrl = ieProxyConfig.lpszAutoConfigUrl;
181 else if( GetLastError() == ERROR_FILE_NOT_FOUND )
184 autoProxyDetect =
true;
187 if( autoProxyDetect )
189 proxyResolveSession =
190 WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME,
191 WINHTTP_NO_PROXY_BYPASS, WINHTTP_FLAG_ASYNC );
193 if( proxyResolveSession )
196 if( autoProxyOptions.lpszAutoConfigUrl != NULL )
198 autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
202 autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
203 autoProxyOptions.dwAutoDetectFlags =
204 WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
209 autoProxyOptions.fAutoLogonIfChallenged = FALSE;
211 autoProxyDetect = WinHttpGetProxyForUrl( proxyResolveSession, aURL.c_str(),
212 &autoProxyOptions, &autoProxyInfo );
214 if( !autoProxyDetect && GetLastError() == ERROR_WINHTTP_LOGIN_FAILURE )
216 autoProxyOptions.fAutoLogonIfChallenged = TRUE;
219 autoProxyDetect = WinHttpGetProxyForUrl( proxyResolveSession, aURL.c_str(),
220 &autoProxyOptions, &autoProxyInfo );
223 WinHttpCloseHandle( proxyResolveSession );
228 if( autoProxyDetect )
230 if( autoProxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY )
234 wxString proxyList = autoProxyInfo.lpszProxy;
235 wxStringTokenizer tokenizer( proxyList, wxT(
";" ) );
237 if( tokenizer.HasMoreTokens() )
239 aCfg.host = tokenizer.GetNextToken();
247 if( ieProxyConfig.lpszProxy != NULL )
251 aCfg.host = ieProxyConfig.lpszProxy;
253 if(aCfg.host !=
":" && aCfg.host !=
"::")
261 if( autoProxyInfo.lpszProxy )
263 GlobalFree( autoProxyInfo.lpszProxy );
264 autoProxyInfo.lpszProxy = NULL;
267 if( autoProxyInfo.lpszProxyBypass )
269 GlobalFree( autoProxyInfo.lpszProxyBypass );
270 autoProxyInfo.lpszProxyBypass = NULL;
273 if( ieProxyConfig.lpszAutoConfigUrl != NULL )
275 GlobalFree( ieProxyConfig.lpszAutoConfigUrl );
276 ieProxyConfig.lpszAutoConfigUrl = NULL;
279 if( ieProxyConfig.lpszProxy != NULL )
281 GlobalFree( ieProxyConfig.lpszProxy );
282 ieProxyConfig.lpszProxy = NULL;
285 if( ieProxyConfig.lpszProxyBypass != NULL )
287 GlobalFree( ieProxyConfig.lpszProxyBypass );
288 ieProxyConfig.lpszProxyBypass = NULL;
297 WINTRUST_FILE_INFO fileData;
298 memset( &fileData, 0,
sizeof( fileData ) );
299 fileData.cbStruct =
sizeof( WINTRUST_FILE_INFO );
300 fileData.pcwszFilePath = aPath.wc_str();
303 GUID policy = WINTRUST_ACTION_GENERIC_VERIFY_V2;
305 WINTRUST_DATA trustData;
306 memset( &trustData, 0,
sizeof( trustData ) );
308 trustData.cbStruct =
sizeof( trustData );
309 trustData.dwUIChoice = WTD_UI_NONE;
311 trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
312 trustData.dwUnionChoice = WTD_CHOICE_FILE;
313 trustData.dwStateAction = WTD_STATEACTION_VERIFY;
314 trustData.pFile = &fileData;
317 bool verified =
false;
318 LONG status = WinVerifyTrust( NULL, &policy, &trustData );
320 verified = ( status == ERROR_SUCCESS );
323 trustData.dwStateAction = WTD_STATEACTION_CLOSE;
324 WinVerifyTrust( NULL, &policy, &trustData );
std::vector< FAB_LAYER_COLOR > dummy