mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-02 13:01:18 +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();
|
||||
CURL_t* curl = (CURL_t*)clientp;
|
||||
|
@ -1317,11 +1317,11 @@ void export_curl_easy_setopt(PPCInterpreter_t* hCPU)
|
|||
curl->in_set = parameter;
|
||||
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;
|
||||
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());
|
||||
break;
|
||||
}
|
||||
|
@ -1380,11 +1380,11 @@ void export_curl_easy_getinfo(PPCInterpreter_t* hCPU)
|
|||
CURLcode result = CURLE_OK;
|
||||
switch (info)
|
||||
{
|
||||
case CURLINFO_SIZE_DOWNLOAD:
|
||||
case CURLINFO_SPEED_DOWNLOAD:
|
||||
case CURLINFO_SIZE_UPLOAD:
|
||||
case CURLINFO_SPEED_UPLOAD:
|
||||
case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
|
||||
case CURLINFO_SIZE_DOWNLOAD_T:
|
||||
case CURLINFO_SPEED_DOWNLOAD_T:
|
||||
case CURLINFO_SIZE_UPLOAD_T:
|
||||
case CURLINFO_SPEED_UPLOAD_T:
|
||||
case CURLINFO_CONTENT_LENGTH_DOWNLOAD_T:
|
||||
{
|
||||
double tempDouble = 0.0;
|
||||
result = curl_easy_getinfo(curlObj, (CURLINFO)info, &tempDouble);
|
||||
|
@ -1538,4 +1538,4 @@ void load()
|
|||
osLib_addFunction("nlibcurl", "curl_easy_cleanup", export_curl_easy_cleanup);
|
||||
osLib_addFunction("nlibcurl", "curl_easy_pause", export_curl_easy_pause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,17 +266,16 @@ namespace nn
|
|||
return true;
|
||||
}
|
||||
|
||||
sint32 olv_curlformcode_to_error(CURLFORMcode code)
|
||||
sint32 olv_curlformcode_to_error(CURLcode code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case CURL_FORMADD_OK:
|
||||
case CURLE_OK:
|
||||
return OLV_RESULT_SUCCESS;
|
||||
|
||||
case CURL_FORMADD_MEMORY:
|
||||
case CURLE_OUT_OF_MEMORY:
|
||||
return OLV_RESULT_FATAL(25);
|
||||
|
||||
case CURL_FORMADD_OPTION_TWICE:
|
||||
default:
|
||||
return OLV_RESULT_LVL6(50);
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace nn
|
|||
bool GetCommunityIdFromCode(uint32* pOutId, const char* pCode);
|
||||
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
|
||||
template<size_t TLength>
|
||||
|
|
|
@ -78,8 +78,8 @@ namespace nn
|
|||
std::string encodedAppData;
|
||||
uint8* encodedIcon = nullptr;
|
||||
|
||||
struct curl_httppost* post = nullptr;
|
||||
struct curl_httppost* last = nullptr;
|
||||
curl_mime *mime = curl_mime_init(req.getCURL());
|
||||
curl_mimepart *part;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -96,13 +96,9 @@ namespace nn
|
|||
}
|
||||
|
||||
base64icon = NCrypto::base64Encode(encodedIcon, iconEncodeRes);
|
||||
res = olv_curlformcode_to_error(
|
||||
curl_formadd(&post, &last,
|
||||
CURLFORM_COPYNAME, "icon",
|
||||
CURLFORM_PTRCONTENTS, base64icon.data(),
|
||||
CURLFORM_CONTENTSLENGTH, base64icon.size(),
|
||||
CURLFORM_END)
|
||||
);
|
||||
part = curl_mime_addpart(mime);
|
||||
curl_mime_name(part, "icon");
|
||||
res = olv_curlformcode_to_error(curl_mime_data(part, base64icon.data(), base64icon.size()));
|
||||
|
||||
if (res < 0)
|
||||
throw std::runtime_error("curl_formadd() error! - icon");
|
||||
|
@ -112,13 +108,9 @@ namespace nn
|
|||
if (pParam->titleText[0])
|
||||
{
|
||||
form_name = StringHelpers::ToUtf8((const uint16be*)pParam->titleText, 127);
|
||||
res = olv_curlformcode_to_error(
|
||||
curl_formadd(&post, &last,
|
||||
CURLFORM_COPYNAME, "name",
|
||||
CURLFORM_PTRCONTENTS, form_name.data(),
|
||||
CURLFORM_CONTENTSLENGTH, form_name.size(),
|
||||
CURLFORM_END)
|
||||
);
|
||||
part = curl_mime_addpart(mime);
|
||||
curl_mime_name(part, "name");
|
||||
res = olv_curlformcode_to_error(curl_mime_data(part, form_name.data(), form_name.size()));
|
||||
|
||||
if (res < 0)
|
||||
throw std::runtime_error("curl_formadd() error! - name");
|
||||
|
@ -127,13 +119,9 @@ namespace nn
|
|||
if (pParam->description[0])
|
||||
{
|
||||
form_desc = StringHelpers::ToUtf8((const uint16be*)pParam->description, 255);
|
||||
res = olv_curlformcode_to_error(
|
||||
curl_formadd(&post, &last,
|
||||
CURLFORM_COPYNAME, "description",
|
||||
CURLFORM_PTRCONTENTS, form_desc.data(),
|
||||
CURLFORM_CONTENTSLENGTH, form_desc.size(),
|
||||
CURLFORM_END)
|
||||
);
|
||||
part = curl_mime_addpart(mime);
|
||||
curl_mime_name(part, "description");
|
||||
res = olv_curlformcode_to_error(curl_mime_data(part, form_desc.data(), form_desc.size()));
|
||||
|
||||
|
||||
if (res < 0)
|
||||
|
@ -145,13 +133,9 @@ namespace nn
|
|||
if (pParam->searchKeys[i][0])
|
||||
{
|
||||
form_searchKey[i] = StringHelpers::ToUtf8((const uint16be*)pParam->searchKeys[i], 151);
|
||||
res = olv_curlformcode_to_error(
|
||||
curl_formadd(&post, &last,
|
||||
CURLFORM_COPYNAME, "search_key",
|
||||
CURLFORM_PTRCONTENTS, form_searchKey[i].data(),
|
||||
CURLFORM_CONTENTSLENGTH, form_searchKey[i].size(),
|
||||
CURLFORM_END)
|
||||
);
|
||||
part = curl_mime_addpart(mime);
|
||||
curl_mime_name(part, "search_key");
|
||||
res = olv_curlformcode_to_error(curl_mime_data(part, form_searchKey[i].data(), form_searchKey[i].size()));
|
||||
|
||||
if (res < 0)
|
||||
throw std::runtime_error("curl_formadd() error! - search_key");
|
||||
|
@ -165,13 +149,9 @@ namespace nn
|
|||
res = OLV_RESULT_FATAL(101);
|
||||
else
|
||||
{
|
||||
res = olv_curlformcode_to_error(
|
||||
curl_formadd(&post, &last,
|
||||
CURLFORM_COPYNAME, "app_data",
|
||||
CURLFORM_PTRCONTENTS, encodedAppData.data(),
|
||||
CURLFORM_CONTENTSLENGTH, encodedAppData.size(),
|
||||
CURLFORM_END)
|
||||
);
|
||||
part = curl_mime_addpart(mime);
|
||||
curl_mime_name(part, "app_data");
|
||||
res = olv_curlformcode_to_error(curl_mime_data(part, encodedAppData.data(), encodedAppData.size()));
|
||||
|
||||
if (res < 0)
|
||||
throw std::runtime_error("curl_formadd() error! - app_data");
|
||||
|
@ -181,7 +161,7 @@ namespace nn
|
|||
catch (const std::runtime_error& error)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Error in multipart curl -> {}", error.what());
|
||||
curl_formfree(post);
|
||||
curl_mime_free(mime);
|
||||
|
||||
if (encodedIcon)
|
||||
delete[] encodedIcon;
|
||||
|
@ -189,7 +169,7 @@ namespace nn
|
|||
return res;
|
||||
}
|
||||
|
||||
curl_easy_setopt(req.getCURL(), CURLOPT_HTTPPOST, post);
|
||||
curl_easy_setopt(req.getCURL(), CURLOPT_MIMEPOST, mime);
|
||||
req.setUseMultipartFormData(true);
|
||||
|
||||
bool reqResult = req.submitRequest(true);
|
||||
|
|
|
@ -28,7 +28,7 @@ size_t DownloadGraphicPacksWindow::curlDownloadFile_writeData(void *ptr, size_t
|
|||
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)
|
||||
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_WRITEFUNCTION, curlDownloadFile_writeData);
|
||||
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_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <curl/system.h>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/timer.h>
|
||||
#include <wx/gauge.h>
|
||||
|
||||
|
@ -55,6 +57,6 @@ private:
|
|||
std::unique_ptr<curlDownloadFileState_t> m_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);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue