Extract cloud browser file-list request helper
This commit is contained in:
@@ -59,6 +59,25 @@ NodeText* NodeDialogCloud::create_loading_status_text()
|
||||
return text;
|
||||
}
|
||||
|
||||
bool NodeDialogCloud::load_cloud_file_list(CURL* curl, std::string& response, NodeText& status_text)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://panopainter.com/cloud/cloud-list.php");
|
||||
if (pp::platform::default_disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
|
||||
const auto err = curl_easy_perform(curl);
|
||||
if (err != CURLE_OK)
|
||||
{
|
||||
LOG("connection error: %d", err);
|
||||
status_text.set_text("Could not connect to the server");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NodeDialogCloud::load_thumbs_thread()
|
||||
{
|
||||
#if WITH_CURL
|
||||
@@ -70,17 +89,8 @@ void NodeDialogCloud::load_thumbs_thread()
|
||||
auto* text = create_loading_status_text();
|
||||
auto* align = text->m_parent;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://panopainter.com/cloud/cloud-list.php");
|
||||
if (pp::platform::default_disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
auto err = curl_easy_perform(curl);
|
||||
|
||||
if (err != CURLE_OK)
|
||||
if (!load_cloud_file_list(curl, res, *text))
|
||||
{
|
||||
LOG("connection error: %d", err);
|
||||
text->set_text("Could not connect to the server");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,4 +46,5 @@ public:
|
||||
virtual void removed(Node* parent) override;
|
||||
void load_thumbs_thread();
|
||||
NodeText* create_loading_status_text();
|
||||
bool load_cloud_file_list(CURL* curl, std::string& response, NodeText& status_text);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user