This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

67
proto/source/Internet.hpp Normal file
View File

@@ -0,0 +1,67 @@
#ifndef _PROTO_INTERNET_HPP_
#define _PROTO_INTERNET_HPP_
#ifndef _COMMON_EXCEPTION_HPP_
#include <common/except.hpp>
#endif
#ifndef _COMMON_WININET_HPP_
#include <common/wininet.hpp>
#endif
class Internet
{
public:
typedef enum AccessType{OpenDirect=INTERNET_OPEN_TYPE_DIRECT,PreConfig=INTERNET_OPEN_TYPE_PRECONFIG,AutoProxy=
INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY,Proxy=INTERNET_OPEN_TYPE_PROXY};
typedef enum Flags{Async=INTERNET_FLAG_ASYNC,FromCache=INTERNET_FLAG_FROM_CACHE,
Offline=INTERNET_FLAG_OFFLINE,InvalidPort=INTERNET_INVALID_PORT_NUMBER,None=0};
Internet();
virtual ~Internet();
bool open(AccessType accessType=AutoProxy,const String &strProxy=String(),const String &proxyBypass=String(),Flags flags=None);
bool connect();
void close();
bool isOkay(void)const;
HINTERNET getHANDLE(void)const;
private:
HINTERNET mhInternet;
};
inline
Internet::Internet()
: mhInternet(0)
{
}
inline
Internet::~Internet()
{
close();
}
inline
bool Internet::open(AccessType accessType,const String &strProxy,const String &proxyByPass,Flags flags)
{
close();
mhInternet=::InternetOpen("Custom Agent",accessType,strProxy.str(),proxyByPass.str(),flags);
return isOkay();
}
inline
void Internet::close()
{
if(!isOkay())return;
::InternetCloseHandle(mhInternet);
mhInternet=0;
}
inline
HINTERNET Internet::getHANDLE(void)const
{
return mhInternet;
}
inline
bool Internet::isOkay()const
{
return mhInternet?true:false;
}
#endif