mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
CPictureViewer:: move download code to separate funktion DownloadImage
This commit is contained in:
@@ -102,6 +102,29 @@ CPictureViewer::CFormathandler * CPictureViewer::fh_getsize (const char *name, i
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
std::string CPictureViewer::DownloadImage(std::string url)
|
||||
{
|
||||
if (strstr(url.c_str(), "://")) {
|
||||
std::string tmpname = "/tmp/pictureviewer" + url.substr(url.find_last_of("."));
|
||||
FILE *tmpFile = fopen(tmpname.c_str(), "wb");
|
||||
if (tmpFile) {
|
||||
CURL *ch = curl_easy_init();
|
||||
curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L);
|
||||
curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
|
||||
curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, NULL);
|
||||
curl_easy_setopt(ch, CURLOPT_WRITEDATA, tmpFile);
|
||||
curl_easy_setopt(ch, CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(ch, CURLOPT_URL, url.c_str());
|
||||
curl_easy_perform(ch);
|
||||
curl_easy_cleanup(ch);
|
||||
fclose(tmpFile);
|
||||
url = true;
|
||||
}
|
||||
url = tmpname;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign, bool unscaled)
|
||||
{
|
||||
@@ -121,29 +144,9 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign,
|
||||
if (showBusySign)
|
||||
showBusy (m_startx + 3, m_starty + 3, 10, 0xff, 00, 00);
|
||||
|
||||
std::string name = _name;
|
||||
bool url = false;
|
||||
|
||||
if (strstr(name.c_str(), "://")) {
|
||||
std::string tmpname;
|
||||
tmpname = "/tmp/pictureviewer" + name.substr(name.find_last_of("."));
|
||||
FILE *tmpFile = fopen(tmpname.c_str(), "wb");
|
||||
if (tmpFile) {
|
||||
CURL *ch = curl_easy_init();
|
||||
curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L);
|
||||
curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
|
||||
curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, NULL);
|
||||
curl_easy_setopt(ch, CURLOPT_WRITEDATA, tmpFile);
|
||||
curl_easy_setopt(ch, CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(ch, CURLOPT_URL, name.c_str());
|
||||
curl_easy_perform(ch);
|
||||
curl_easy_cleanup(ch);
|
||||
fclose(tmpFile);
|
||||
url = true;
|
||||
}
|
||||
name = tmpname;
|
||||
}
|
||||
std::string name = DownloadImage(_name);
|
||||
|
||||
CFormathandler *fh;
|
||||
if (unscaled)
|
||||
|
Reference in New Issue
Block a user