mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 17:01:08 +02:00
driver/pictureviewer/pictureviewer.cpp: add support to get file from url, (c) martii <m4rtii@gmx.de>
Origin commit data
------------------
Commit: a876b074ed
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2013-09-03 (Tue, 03 Sep 2013)
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include <cs_api.h>
|
#include <cs_api.h>
|
||||||
|
|
||||||
@@ -101,7 +103,7 @@ CPictureViewer::CFormathandler * CPictureViewer::fh_getsize (const char *name, i
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPictureViewer::DecodeImage (const std::string & name, bool showBusySign, bool unscaled)
|
bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign, bool unscaled)
|
||||||
{
|
{
|
||||||
// dbout("DecodeImage {\n");
|
// dbout("DecodeImage {\n");
|
||||||
#if 0 // quick fix for issue #245. TODO more smart fix for this problem
|
#if 0 // quick fix for issue #245. TODO more smart fix for this problem
|
||||||
@@ -119,6 +121,30 @@ bool CPictureViewer::DecodeImage (const std::string & name, bool showBusySign, b
|
|||||||
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
CFormathandler *fh;
|
CFormathandler *fh;
|
||||||
if (unscaled)
|
if (unscaled)
|
||||||
fh = fh_getsize (name.c_str (), &x, &y, INT_MAX, INT_MAX);
|
fh = fh_getsize (name.c_str (), &x, &y, INT_MAX, INT_MAX);
|
||||||
@@ -201,6 +227,8 @@ bool CPictureViewer::DecodeImage (const std::string & name, bool showBusySign, b
|
|||||||
m_NextPic_YPan = 0;
|
m_NextPic_YPan = 0;
|
||||||
}
|
}
|
||||||
m_NextPic_Name = name;
|
m_NextPic_Name = name;
|
||||||
|
if (url)
|
||||||
|
unlink(name.c_str());
|
||||||
hideBusy ();
|
hideBusy ();
|
||||||
// dbout("DecodeImage }\n");
|
// dbout("DecodeImage }\n");
|
||||||
return (m_NextPic_Buffer != NULL);
|
return (m_NextPic_Buffer != NULL);
|
||||||
|
Reference in New Issue
Block a user