mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Added curlSetOpt() method to API for setting curl options
This commit is contained in:
parent
9f715aa2d1
commit
b3792554bf
@ -73,7 +73,7 @@ class API
|
|||||||
public:
|
public:
|
||||||
userDetails user;
|
userDetails user;
|
||||||
|
|
||||||
API(const std::string& token,const std::string& secret, const bool& verbose = false, const bool& bVerifyPeer = true, const long int& iTimeout = 10);
|
API(const std::string& token,const std::string& secret);
|
||||||
int init();
|
int init();
|
||||||
int login(const std::string& email, const std::string& password);
|
int login(const std::string& email, const std::string& password);
|
||||||
int getAPIConfig();
|
int getAPIConfig();
|
||||||
@ -91,6 +91,7 @@ class API
|
|||||||
std::string getErrorMessage() { return this->error_message; };
|
std::string getErrorMessage() { return this->error_message; };
|
||||||
std::string getToken() { return this->config.oauth_token; };
|
std::string getToken() { return this->config.oauth_token; };
|
||||||
std::string getSecret() { return this->config.oauth_secret; };
|
std::string getSecret() { return this->config.oauth_secret; };
|
||||||
|
template <typename T> CURLcode curlSetOpt(CURLoption option, T value) { return curl_easy_setopt(this->curlhandle, option, value); };
|
||||||
virtual ~API();
|
virtual ~API();
|
||||||
protected:
|
protected:
|
||||||
private:
|
private:
|
||||||
|
@ -33,16 +33,13 @@ gameFile::~gameFile()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
API::API(const std::string& token, const std::string& secret, const bool& verbose, const bool& bVerifyPeer, const long int& iTimeout)
|
API::API(const std::string& token, const std::string& secret)
|
||||||
{
|
{
|
||||||
curlhandle = curl_easy_init();
|
curlhandle = curl_easy_init();
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, verbose);
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, iTimeout);
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSDATA, this);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSDATA, this);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FAILONERROR, true);
|
curl_easy_setopt(curlhandle, CURLOPT_FAILONERROR, true);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, bVerifyPeer);
|
|
||||||
|
|
||||||
this->error = false;
|
this->error = false;
|
||||||
this->getAPIConfig();
|
this->getAPIConfig();
|
||||||
|
@ -64,7 +64,11 @@ int Downloader::init()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
||||||
|
|
||||||
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose, config.bVerifyPeer, config.iTimeout);
|
gogAPI = new API(config.sToken, config.sSecret);
|
||||||
|
gogAPI->curlSetOpt(CURLOPT_VERBOSE, config.bVerbose);
|
||||||
|
gogAPI->curlSetOpt(CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
||||||
|
gogAPI->curlSetOpt(CURLOPT_CONNECTTIMEOUT, config.iTimeout);
|
||||||
|
|
||||||
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
||||||
|
|
||||||
if (config.bLogin || !gogAPI->init())
|
if (config.bLogin || !gogAPI->init())
|
||||||
|
Loading…
Reference in New Issue
Block a user