Skip to content

Commit ae66e1a

Browse files
committed
reverted changes (did not solve gui upgrade issues)
1 parent 8f42ef7 commit ae66e1a

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

httpclient/HTTPClient.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ size_t write_curl_data(void *contents, size_t size, size_t nmemb, void *userp) {
2121
return realsize;
2222
}
2323

24-
size_t write_curl_data_file(void *contents, size_t size, size_t nmemb, FILE *fp) {
25-
size_t written = fwrite(contents, size, nmemb, fp);
26-
return written;
24+
size_t write_curl_data_file(void *contents, size_t size, size_t nmemb, void *userp) {
25+
size_t realsize = size * nmemb;
26+
std::ofstream *outfile=(std::ofstream*)userp;
27+
outfile->write((const char*)contents,realsize);
28+
return realsize;
2729
}
2830

2931
bool HTTPClient::CheckIfGlobalInitDone()
@@ -57,7 +59,6 @@ void HTTPClient::SetGlobalOptions(void *curlobj)
5759
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
5860
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "domocookie.txt");
5961
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "domocookie.txt");
60-
curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
6162
}
6263

6364
//Configuration functions
@@ -130,8 +131,10 @@ bool HTTPClient::GETBinaryToFile(const std::string &url, const std::string &outp
130131
if (!CheckIfGlobalInitDone())
131132
return false;
132133

133-
FILE *fp = fopen(outputfile.c_str(), "wb+");
134-
if (!fp)
134+
//open the output file for writing
135+
std::ofstream outfile;
136+
outfile.open(outputfile.c_str(),std::ios::out|std::ios::binary|std::ios::trunc);
137+
if (!outfile.is_open())
135138
return false;
136139

137140
CURL *curl=curl_easy_init();
@@ -141,12 +144,12 @@ bool HTTPClient::GETBinaryToFile(const std::string &url, const std::string &outp
141144
CURLcode res;
142145
SetGlobalOptions(curl);
143146
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_curl_data_file);
144-
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)fp);
147+
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&outfile);
145148
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
146149
res = curl_easy_perform(curl);
147150
curl_easy_cleanup(curl);
148151

149-
fclose(fp);
152+
outfile.close();
150153

151154
return (res==CURLE_OK);
152155
}

main/mainworker.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,19 +1012,13 @@ bool MainWorker::StartDownloadUpdate()
10121012
std::string checksumURL;
10131013
if (!bIsBetaChannel)
10141014
{
1015-
downloadURL = "http://domoticz.sourceforge.net/domoticz_" + systemname + "_" + machine + ".tgz";
1016-
checksumURL = "http://domoticz.sourceforge.net/domoticz_" + systemname + "_" + machine + ".tgz.sha256sum";
1017-
1018-
//downloadURL = "http://www.domoticz.com/download.php?channel=stable&type=release&system=" + systemname + "&machine=" + machine;
1019-
//checksumURL = "http://www.domoticz.com/download.php?channel=stable&type=checksum&system=" + systemname + "&machine=" + machine;
1015+
downloadURL = "http://www.domoticz.com/download.php?channel=stable&type=release&system=" + systemname + "&machine=" + machine;
1016+
checksumURL = "http://www.domoticz.com/download.php?channel=stable&type=checksum&system=" + systemname + "&machine=" + machine;
10201017
}
10211018
else
10221019
{
1023-
downloadURL = "http://domoticz.sourceforge.net/beta/domoticz_" + systemname + "_" + machine + ".tgz";
1024-
checksumURL = "http://domoticz.sourceforge.net/beta/domoticz_" + systemname + "_" + machine + ".tgz.sha256sum";
1025-
1026-
//downloadURL = "http://www.domoticz.com/download.php?channel=beta&type=release&system=" + systemname + "&machine=" + machine;
1027-
//checksumURL = "http://www.domoticz.com/download.php?channel=beta&type=checksum&system=" + systemname + "&machine=" + machine;
1020+
downloadURL = "http://www.domoticz.com/download.php?channel=beta&type=release&system=" + systemname + "&machine=" + machine;
1021+
checksumURL = "http://www.domoticz.com/download.php?channel=beta&type=checksum&system=" + systemname + "&machine=" + machine;
10281022
}
10291023
m_szDomoticzUpdateURL = downloadURL;
10301024
m_szDomoticzUpdateChecksumURL = checksumURL;

0 commit comments

Comments
 (0)