mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 08:51:04 +02:00
CPictureViewer:: move download code to separate funktion DownloadImage
Origin commit data
------------------
Commit: 80d7cc186d
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2014-03-19 (Wed, 19 Mar 2014)
This commit is contained in:
@@ -102,6 +102,29 @@ CPictureViewer::CFormathandler * CPictureViewer::fh_getsize (const char *name, i
|
|||||||
}
|
}
|
||||||
return (NULL);
|
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)
|
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)
|
if (showBusySign)
|
||||||
showBusy (m_startx + 3, m_starty + 3, 10, 0xff, 00, 00);
|
showBusy (m_startx + 3, m_starty + 3, 10, 0xff, 00, 00);
|
||||||
|
|
||||||
std::string name = _name;
|
|
||||||
bool url = false;
|
bool url = false;
|
||||||
|
|
||||||
if (strstr(name.c_str(), "://")) {
|
std::string name = DownloadImage(_name);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFormathandler *fh;
|
CFormathandler *fh;
|
||||||
if (unscaled)
|
if (unscaled)
|
||||||
|
@@ -54,6 +54,7 @@ class CPictureViewer
|
|||||||
bool ShowImage(const std::string & filename, bool unscaled=false);
|
bool ShowImage(const std::string & filename, bool unscaled=false);
|
||||||
bool DecodeImage(const std::string & name, bool showBusySign=false, bool unscaled=false);
|
bool DecodeImage(const std::string & name, bool showBusySign=false, bool unscaled=false);
|
||||||
bool DisplayNextImage();
|
bool DisplayNextImage();
|
||||||
|
std::string DownloadImage(std::string url);
|
||||||
void SetScaling(ScalingMode s){m_scaling=s;}
|
void SetScaling(ScalingMode s){m_scaling=s;}
|
||||||
void SetAspectRatio(float aspect_ratio) {m_aspect=aspect_ratio;}
|
void SetAspectRatio(float aspect_ratio) {m_aspect=aspect_ratio;}
|
||||||
void showBusy(int sx, int sy, int width, char r, char g, char b);
|
void showBusy(int sx, int sy, int width, char r, char g, char b);
|
||||||
|
Reference in New Issue
Block a user