mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-03 21:41:19 +12:00
fix Curl deprecation warnings
This commit is contained in:
parent
00ff5549d9
commit
32c3671c1a
6 changed files with 38 additions and 57 deletions
|
@ -1098,7 +1098,7 @@ size_t read_callback(char* buffer, size_t size, size_t nitems, void* instream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int progress_callback(void* clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
int progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||||
{
|
{
|
||||||
//peterBreak();
|
//peterBreak();
|
||||||
CURL_t* curl = (CURL_t*)clientp;
|
CURL_t* curl = (CURL_t*)clientp;
|
||||||
|
@ -1317,11 +1317,11 @@ void export_curl_easy_setopt(PPCInterpreter_t* hCPU)
|
||||||
curl->in_set = parameter;
|
curl->in_set = parameter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CURLOPT_PROGRESSFUNCTION:
|
case CURLOPT_XFERINFOFUNCTION:
|
||||||
{
|
{
|
||||||
curlDebug_logEasySetOptPtr(curl.GetPtr(), "CURLOPT_PROGRESSFUNCTION", parameter.GetMPTR());
|
curlDebug_logEasySetOptPtr(curl.GetPtr(), "CURLOPT_XFERINFOFUNCTION", parameter.GetMPTR());
|
||||||
curl->fprogress = parameter;
|
curl->fprogress = parameter;
|
||||||
result = ::curl_easy_setopt(curlObj, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
result = ::curl_easy_setopt(curlObj, CURLOPT_XFERINFOFUNCTION, progress_callback);
|
||||||
::curl_easy_setopt(curlObj, CURLOPT_PROGRESSDATA, curl.GetPtr());
|
::curl_easy_setopt(curlObj, CURLOPT_PROGRESSDATA, curl.GetPtr());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1380,11 +1380,11 @@ void export_curl_easy_getinfo(PPCInterpreter_t* hCPU)
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
switch (info)
|
switch (info)
|
||||||
{
|
{
|
||||||
case CURLINFO_SIZE_DOWNLOAD:
|
case CURLINFO_SIZE_DOWNLOAD_T:
|
||||||
case CURLINFO_SPEED_DOWNLOAD:
|
case CURLINFO_SPEED_DOWNLOAD_T:
|
||||||
case CURLINFO_SIZE_UPLOAD:
|
case CURLINFO_SIZE_UPLOAD_T:
|
||||||
case CURLINFO_SPEED_UPLOAD:
|
case CURLINFO_SPEED_UPLOAD_T:
|
||||||
case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
|
case CURLINFO_CONTENT_LENGTH_DOWNLOAD_T:
|
||||||
{
|
{
|
||||||
double tempDouble = 0.0;
|
double tempDouble = 0.0;
|
||||||
result = curl_easy_getinfo(curlObj, (CURLINFO)info, &tempDouble);
|
result = curl_easy_getinfo(curlObj, (CURLINFO)info, &tempDouble);
|
||||||
|
|
|
@ -266,17 +266,16 @@ namespace nn
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sint32 olv_curlformcode_to_error(CURLFORMcode code)
|
sint32 olv_curlformcode_to_error(CURLcode code)
|
||||||
{
|
{
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case CURL_FORMADD_OK:
|
case CURLE_OK:
|
||||||
return OLV_RESULT_SUCCESS;
|
return OLV_RESULT_SUCCESS;
|
||||||
|
|
||||||
case CURL_FORMADD_MEMORY:
|
case CURLE_OUT_OF_MEMORY:
|
||||||
return OLV_RESULT_FATAL(25);
|
return OLV_RESULT_FATAL(25);
|
||||||
|
|
||||||
case CURL_FORMADD_OPTION_TWICE:
|
|
||||||
default:
|
default:
|
||||||
return OLV_RESULT_LVL6(50);
|
return OLV_RESULT_LVL6(50);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ namespace nn
|
||||||
bool GetCommunityIdFromCode(uint32* pOutId, const char* pCode);
|
bool GetCommunityIdFromCode(uint32* pOutId, const char* pCode);
|
||||||
bool FormatCommunityCode(char* pOutCode, uint32* outLen, uint32 communityId);
|
bool FormatCommunityCode(char* pOutCode, uint32* outLen, uint32 communityId);
|
||||||
|
|
||||||
sint32 olv_curlformcode_to_error(CURLFORMcode code);
|
sint32 olv_curlformcode_to_error(CURLcode code);
|
||||||
|
|
||||||
// convert and copy utf8 string into UC2 big-endian array
|
// convert and copy utf8 string into UC2 big-endian array
|
||||||
template<size_t TLength>
|
template<size_t TLength>
|
||||||
|
|
|
@ -78,8 +78,8 @@ namespace nn
|
||||||
std::string encodedAppData;
|
std::string encodedAppData;
|
||||||
uint8* encodedIcon = nullptr;
|
uint8* encodedIcon = nullptr;
|
||||||
|
|
||||||
struct curl_httppost* post = nullptr;
|
curl_mime *mime = curl_mime_init(req.getCURL());
|
||||||
struct curl_httppost* last = nullptr;
|
curl_mimepart *part;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -96,13 +96,9 @@ namespace nn
|
||||||
}
|
}
|
||||||
|
|
||||||
base64icon = NCrypto::base64Encode(encodedIcon, iconEncodeRes);
|
base64icon = NCrypto::base64Encode(encodedIcon, iconEncodeRes);
|
||||||
res = olv_curlformcode_to_error(
|
part = curl_mime_addpart(mime);
|
||||||
curl_formadd(&post, &last,
|
curl_mime_name(part, "icon");
|
||||||
CURLFORM_COPYNAME, "icon",
|
res = olv_curlformcode_to_error(curl_mime_data(part, base64icon.data(), base64icon.size()));
|
||||||
CURLFORM_PTRCONTENTS, base64icon.data(),
|
|
||||||
CURLFORM_CONTENTSLENGTH, base64icon.size(),
|
|
||||||
CURLFORM_END)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
throw std::runtime_error("curl_formadd() error! - icon");
|
throw std::runtime_error("curl_formadd() error! - icon");
|
||||||
|
@ -112,13 +108,9 @@ namespace nn
|
||||||
if (pParam->titleText[0])
|
if (pParam->titleText[0])
|
||||||
{
|
{
|
||||||
form_name = StringHelpers::ToUtf8((const uint16be*)pParam->titleText, 127);
|
form_name = StringHelpers::ToUtf8((const uint16be*)pParam->titleText, 127);
|
||||||
res = olv_curlformcode_to_error(
|
part = curl_mime_addpart(mime);
|
||||||
curl_formadd(&post, &last,
|
curl_mime_name(part, "name");
|
||||||
CURLFORM_COPYNAME, "name",
|
res = olv_curlformcode_to_error(curl_mime_data(part, form_name.data(), form_name.size()));
|
||||||
CURLFORM_PTRCONTENTS, form_name.data(),
|
|
||||||
CURLFORM_CONTENTSLENGTH, form_name.size(),
|
|
||||||
CURLFORM_END)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
throw std::runtime_error("curl_formadd() error! - name");
|
throw std::runtime_error("curl_formadd() error! - name");
|
||||||
|
@ -127,13 +119,9 @@ namespace nn
|
||||||
if (pParam->description[0])
|
if (pParam->description[0])
|
||||||
{
|
{
|
||||||
form_desc = StringHelpers::ToUtf8((const uint16be*)pParam->description, 255);
|
form_desc = StringHelpers::ToUtf8((const uint16be*)pParam->description, 255);
|
||||||
res = olv_curlformcode_to_error(
|
part = curl_mime_addpart(mime);
|
||||||
curl_formadd(&post, &last,
|
curl_mime_name(part, "description");
|
||||||
CURLFORM_COPYNAME, "description",
|
res = olv_curlformcode_to_error(curl_mime_data(part, form_desc.data(), form_desc.size()));
|
||||||
CURLFORM_PTRCONTENTS, form_desc.data(),
|
|
||||||
CURLFORM_CONTENTSLENGTH, form_desc.size(),
|
|
||||||
CURLFORM_END)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
|
@ -145,13 +133,9 @@ namespace nn
|
||||||
if (pParam->searchKeys[i][0])
|
if (pParam->searchKeys[i][0])
|
||||||
{
|
{
|
||||||
form_searchKey[i] = StringHelpers::ToUtf8((const uint16be*)pParam->searchKeys[i], 151);
|
form_searchKey[i] = StringHelpers::ToUtf8((const uint16be*)pParam->searchKeys[i], 151);
|
||||||
res = olv_curlformcode_to_error(
|
part = curl_mime_addpart(mime);
|
||||||
curl_formadd(&post, &last,
|
curl_mime_name(part, "search_key");
|
||||||
CURLFORM_COPYNAME, "search_key",
|
res = olv_curlformcode_to_error(curl_mime_data(part, form_searchKey[i].data(), form_searchKey[i].size()));
|
||||||
CURLFORM_PTRCONTENTS, form_searchKey[i].data(),
|
|
||||||
CURLFORM_CONTENTSLENGTH, form_searchKey[i].size(),
|
|
||||||
CURLFORM_END)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
throw std::runtime_error("curl_formadd() error! - search_key");
|
throw std::runtime_error("curl_formadd() error! - search_key");
|
||||||
|
@ -165,13 +149,9 @@ namespace nn
|
||||||
res = OLV_RESULT_FATAL(101);
|
res = OLV_RESULT_FATAL(101);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = olv_curlformcode_to_error(
|
part = curl_mime_addpart(mime);
|
||||||
curl_formadd(&post, &last,
|
curl_mime_name(part, "app_data");
|
||||||
CURLFORM_COPYNAME, "app_data",
|
res = olv_curlformcode_to_error(curl_mime_data(part, encodedAppData.data(), encodedAppData.size()));
|
||||||
CURLFORM_PTRCONTENTS, encodedAppData.data(),
|
|
||||||
CURLFORM_CONTENTSLENGTH, encodedAppData.size(),
|
|
||||||
CURLFORM_END)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
throw std::runtime_error("curl_formadd() error! - app_data");
|
throw std::runtime_error("curl_formadd() error! - app_data");
|
||||||
|
@ -181,7 +161,7 @@ namespace nn
|
||||||
catch (const std::runtime_error& error)
|
catch (const std::runtime_error& error)
|
||||||
{
|
{
|
||||||
cemuLog_log(LogType::Force, "Error in multipart curl -> {}", error.what());
|
cemuLog_log(LogType::Force, "Error in multipart curl -> {}", error.what());
|
||||||
curl_formfree(post);
|
curl_mime_free(mime);
|
||||||
|
|
||||||
if (encodedIcon)
|
if (encodedIcon)
|
||||||
delete[] encodedIcon;
|
delete[] encodedIcon;
|
||||||
|
@ -189,7 +169,7 @@ namespace nn
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(req.getCURL(), CURLOPT_HTTPPOST, post);
|
curl_easy_setopt(req.getCURL(), CURLOPT_MIMEPOST, mime);
|
||||||
req.setUseMultipartFormData(true);
|
req.setUseMultipartFormData(true);
|
||||||
|
|
||||||
bool reqResult = req.submitRequest(true);
|
bool reqResult = req.submitRequest(true);
|
||||||
|
|
|
@ -28,7 +28,7 @@ size_t DownloadGraphicPacksWindow::curlDownloadFile_writeData(void *ptr, size_t
|
||||||
return writeSize;
|
return writeSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DownloadGraphicPacksWindow::progress_callback(curlDownloadFileState_t* downloadState, double dltotal, double dlnow, double ultotal, double ulnow)
|
int DownloadGraphicPacksWindow::progress_callback(curlDownloadFileState_t* downloadState, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||||
{
|
{
|
||||||
if (dltotal > 1.0)
|
if (dltotal > 1.0)
|
||||||
downloadState->progress = dlnow / dltotal;
|
downloadState->progress = dlnow / dltotal;
|
||||||
|
@ -47,7 +47,7 @@ bool DownloadGraphicPacksWindow::curlDownloadFile(const char *url, curlDownloadF
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlDownloadFile_writeData);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlDownloadFile_writeData);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, downloadState);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, downloadState);
|
||||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback);
|
||||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, downloadState);
|
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, downloadState);
|
||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <curl/system.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <wx/dialog.h>
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
#include <wx/gauge.h>
|
#include <wx/gauge.h>
|
||||||
|
|
||||||
|
@ -55,6 +57,6 @@ private:
|
||||||
std::unique_ptr<curlDownloadFileState_t> m_downloadState;
|
std::unique_ptr<curlDownloadFileState_t> m_downloadState;
|
||||||
|
|
||||||
static size_t curlDownloadFile_writeData(void* ptr, size_t size, size_t nmemb, curlDownloadFileState_t* downloadState);
|
static size_t curlDownloadFile_writeData(void* ptr, size_t size, size_t nmemb, curlDownloadFileState_t* downloadState);
|
||||||
static int progress_callback(curlDownloadFileState_t* downloadState, double dltotal, double dlnow, double ultotal, double ulnow);
|
static int progress_callback(curlDownloadFileState_t* downloadState, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
|
||||||
static bool curlDownloadFile(const char* url, curlDownloadFileState_t* downloadState);
|
static bool curlDownloadFile(const char* url, curlDownloadFileState_t* downloadState);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue