Skip to content

Commit

Permalink
Remove ImageExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
hannemann committed Jan 31, 2015
1 parent b360669 commit e26b6f0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions channels.cpp
Expand Up @@ -126,13 +126,13 @@ void ChannelsResponder::replyImage(ostream& out, cxxtools::http::Request& reques
string absolute_path = imageFolder + imageName;

if (request.hasHeader("If-Modified-Since")) {
timediff = difftime(ImageExtension::get()->getModifiedTime(absolute_path), ImageExtension::get()->getModifiedSinceTime(request));
timediff = difftime(FileExtension::get()->getModifiedTime(absolute_path), FileExtension::get()->getModifiedSinceTime(request));
}

if (timediff > 0.0 || timediff < 0.0) {
string contenttype = (string)"image/" + imageName.substr( imageName.find_last_of('.') + 1 );
if ( se.writeBinary(absolute_path) ) {
ImageExtension::get()->addModifiedHeader(absolute_path, reply);
FileExtension::get()->addModifiedHeader(absolute_path, reply);
reply.addHeader("Content-Type", contenttype.c_str());
} else {
reply.httpReturn(502, "Binary Output failed");
Expand Down
4 changes: 2 additions & 2 deletions events.cpp
Expand Up @@ -162,13 +162,13 @@ void EventsResponder::replyImage(ostream& out, cxxtools::http::Request& request,
string path = Settings::get()->EpgImageDirectory() + (string)"/" + image;

if (request.hasHeader("If-Modified-Since")) {
timediff = difftime(ImageExtension::get()->getModifiedTime(path), ImageExtension::get()->getModifiedSinceTime(request));
timediff = difftime(FileExtension::get()->getModifiedTime(path), FileExtension::get()->getModifiedSinceTime(request));
}

if (timediff > 0.0 || timediff < 0.0) {
if ( se.writeBinary(path) ) {
reply.addHeader("Content-Type", contenttype.c_str());
ImageExtension::get()->addModifiedHeader(path, reply);
FileExtension::get()->addModifiedHeader(path, reply);
} else {
reply.httpReturn(404, "Could not find image!");
}
Expand Down
6 changes: 3 additions & 3 deletions scraper2vdr.cpp
Expand Up @@ -510,22 +510,22 @@ void ScraperImageResponder::reply(ostream& out, cxxtools::http::Request& request
string image = url.replace(0, base.length(), "");
string path = epgImagesPath + (string)"/" + image;

if (!ImageExtension::get()->exists(path)) {
if (!FileExtension::get()->exists(path)) {
isyslog("restfulapi Scraper: image does not exist");
reply.httpReturn(404, "File not found");
return;
}

if (request.hasHeader("If-Modified-Since")) {
timediff = difftime(ImageExtension::get()->getModifiedTime(path), ImageExtension::get()->getModifiedSinceTime(request));
timediff = difftime(FileExtension::get()->getModifiedTime(path), FileExtension::get()->getModifiedSinceTime(request));
}
if (timediff > 0.0 || timediff < 0.0) {
string type = image.substr(image.find_last_of(".")+1);
string contenttype = (string)"image/" + type;
StreamExtension se(&out);
if ( se.writeBinary(path) ) {
isyslog("restfulapi Scraper: successfully piped image");
ImageExtension::get()->addModifiedHeader(path, reply);
FileExtension::get()->addModifiedHeader(path, reply);
reply.addHeader("Content-Type", contenttype.c_str());
} else {
isyslog("restfulapi Scraper: error piping image");
Expand Down
4 changes: 0 additions & 4 deletions tools.cpp
Expand Up @@ -491,10 +491,6 @@ bool FileExtension::exists(string path) {
return false;
};



// --- ImageExtension -----------------------------------------------------------

// --- VdrExtension -----------------------------------------------------------

cChannel* VdrExtension::getChannel(int number)
Expand Down
2 changes: 0 additions & 2 deletions tools.h
Expand Up @@ -173,8 +173,6 @@ class FileExtension {
bool exists(std::string path);
};

class ImageExtension : public FileExtension {};

class VdrExtension
{
private:
Expand Down

0 comments on commit e26b6f0

Please sign in to comment.