summaryrefslogtreecommitdiff
path: root/protocols/Weather/src/weather_http.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-01-22 21:19:44 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-01-22 21:19:44 +0300
commit4f5e18684ec9518657a035164d04e04e87fca5a0 (patch)
treefd1a424be59a0fdf70bccce0801e1d6191b06407 /protocols/Weather/src/weather_http.cpp
parentdd3b89ded0e7cbfdb6ce833895104ec4fda6448f (diff)
Weather: first version that compiles
Diffstat (limited to 'protocols/Weather/src/weather_http.cpp')
-rw-r--r--protocols/Weather/src/weather_http.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/protocols/Weather/src/weather_http.cpp b/protocols/Weather/src/weather_http.cpp
index bfbcadc589..91ae9b911c 100644
--- a/protocols/Weather/src/weather_http.cpp
+++ b/protocols/Weather/src/weather_http.cpp
@@ -25,15 +25,13 @@ from the web using netlib
#include "stdafx.h"
-HNETLIBUSER hNetlibUser;
-
-//============ DOWNLOAD NEW WEATHER ============
+/////////////////////////////////////////////////////////////////////////////////////////
// function to download webpage from the internet
// szUrl = URL of the webpage to be retrieved
// return value = 0 for success, 1 or HTTP error code for failure
// global var used: szData, szInfo = containing the retrieved data
-//
-int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **szData)
+
+int CWeatherProto::InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **szData)
{
if (userAgent == nullptr || userAgent[0] == 0)
userAgent = NETLIB_USER_AGENT;
@@ -50,7 +48,7 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
nlhr.AddHeader("Cookie", cookie);
// download the page
- NLHR_PTR nlhrReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (nlhrReply == nullptr) {
// if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
*szData = (wchar_t*)mir_alloc(512);
@@ -117,15 +115,3 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
// make a copy of the retrieved data, then free the memory of the http reply
return result;
}
-
-//============ NETLIB INITIALIZATION ============
-//
-// initialize netlib support for weather protocol
-void NetlibInit(void)
-{
- NETLIBUSER nlu = {};
- nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION;
- nlu.szSettingsModule = MODULENAME;
- nlu.szDescriptiveName.a = MODULENAME;
- hNetlibUser = Netlib_RegisterUser(&nlu);
-}