From 30aa1477719849e56abb3624adf2eb4c3d443718 Mon Sep 17 00:00:00 2001 From: Martin Schirrmacher Date: Sat, 27 Aug 2016 10:41:04 +0200 Subject: [add] svdrp command to remove logo from cache --- HISTORY | 3 +++ imagecache.c | 21 +++++++++++++++++++-- imagecache.h | 3 ++- imageloader.c | 4 ++-- imageloader.h | 4 ++-- skinflatplus.c | 26 +++++++++++++++++++++++++- 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/HISTORY b/HISTORY index b8a3cd5b..00beb06b 100644 --- a/HISTORY +++ b/HISTORY @@ -36,6 +36,9 @@ VDR Plugin 'skinflatplus' Revision History There is also a new menu option: MenuItemRecordingDefaultOldDays This is the default value if You don't want to use recordings_old.cfg. If MenuItemRecordingDefaultOldDays is -1, the default value is disabled. +- [add] svdrp command to remove logo from cache + Use svdrp command "RLFC" to remove a logo from cache. Specify logo filename with extension, but without path. + For example: svdrpsend PLUG skinflatplus RLFC "rtl ii.png" 2015-02-14: Version 0.5.1 - [fix] topbar number recordings diff --git a/imagecache.c b/imagecache.c index 61606476..639c3ec9 100644 --- a/imagecache.c +++ b/imagecache.c @@ -1,6 +1,6 @@ #include "imagecache.h" #include "config.h" - +#include #include "displaychannel.h" #include "displaymenu.h" @@ -15,7 +15,7 @@ cImageCache::cImageCache() { } cImageCache::~cImageCache() { - + } void cImageCache::Create(void) { @@ -38,6 +38,23 @@ void cImageCache::Clear(void) { InsertIndex = 0; } +bool cImageCache::RemoveFromCache( std::string Name ) { + bool found = false; + for(int index = 0; index < MAX_IMAGE_CACHE; index++ ) { + char *bname; + bname = basename( (char *)CacheName[index].c_str() ); + if( !strcmp(bname, Name.c_str()) ) { + found = true; + dsyslog("skinflatplus RemoveFromCache - %s", CacheName[index].c_str() ); + CacheImage[index] = NULL; + CacheName[index] = ""; + CacheWidth[index] = -1; + CacheHeight[index] = -1; + } + } + return found; +} + cImage* cImageCache::GetImage(std::string Name, int Width, int Height) { //dsyslog("imagecache search for image %s Width %d Height %d", Name.c_str(), Width, Height); for(int index = 0; index < MAX_IMAGE_CACHE; index++ ) { diff --git a/imagecache.h b/imagecache.h index 1cd03a58..ce1cff01 100644 --- a/imagecache.h +++ b/imagecache.h @@ -5,7 +5,7 @@ #define MAX_IMAGE_CACHE 999 #define LOGO_PRE_CACHE 200 -// note MAX_LOGO_PRE_CACHE is used twice +// note LOGO_PRE_CACHE is used twice // one for displaychannel and one for menu // you must double the value for the real amount of pre cached logos @@ -24,6 +24,7 @@ public: void Create(void); void Clear(void); + bool RemoveFromCache( std::string Name ); int getCacheCount(void) { if(Overflow) return MAX_IMAGE_CACHE; return InsertIndex+1; } diff --git a/imageloader.c b/imageloader.c index a5e3a91d..d8690d4b 100644 --- a/imageloader.c +++ b/imageloader.c @@ -72,7 +72,7 @@ cImage* cImageLoader::LoadLogo(const char *logo, int width, int height) { return img; } -cImage* cImageLoader::LoadIcon(const char *cIcon, int width, int height, bool preserveAspect) { +cImage* cImageLoader::LoadIcon(const char *cIcon, int width, int height) { if ((width == 0)||(height==0)) return NULL; @@ -156,7 +156,7 @@ cImage* cImageLoader::LoadIcon(const char *cIcon, int width, int height, bool pr return img; } -cImage* cImageLoader::LoadFile(const char *cFile, int width, int height, bool preserveAspect) { +cImage* cImageLoader::LoadFile(const char *cFile, int width, int height ) { if( (width == 0) || (height==0) ) return NULL; cString File = cFile; diff --git a/imageloader.h b/imageloader.h index b340f9a0..44d44743 100644 --- a/imageloader.h +++ b/imageloader.h @@ -17,8 +17,8 @@ public: ~cImageLoader(); cImage* LoadLogo(const char *logo, int width, int height); - cImage* LoadIcon(const char *cIcon, int width, int height, bool preserveAspect = true); - cImage* LoadFile(const char *cFile, int width, int height, bool preserveAspect = true); + cImage* LoadIcon(const char *cIcon, int width, int height); + cImage* LoadFile(const char *cFile, int width, int height); bool FileExits(const std::string& name); bool SearchRecordingPoster(cString recPath, cString &found); private: diff --git a/skinflatplus.c b/skinflatplus.c index 384dc5c4..9f9b4a6e 100644 --- a/skinflatplus.c +++ b/skinflatplus.c @@ -130,10 +130,34 @@ bool cPluginFlat::Service(const char *Id, void *Data) { } const char **cPluginFlat::SVDRPHelpPages(void) { - return NULL; + static const char *HelpPages[] = { + "RLFC\n" + " Remove Logo From Cache.\n" + " Specify logo filename with extension, but without path", + NULL + }; + return HelpPages; } cString cPluginFlat::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) { + if( !strcasecmp(Command, "RLFC")) { + if( Option == NULL ) { + ReplyCode = 500; + return "no logo given"; + } + if( !strcmp(Option, "") ) { + ReplyCode = 500; + return "no logo given"; + } + + if( imgCache.RemoveFromCache( Option ) ) { + ReplyCode = 900; + return "successfully remove logo from cache"; + } else { + ReplyCode = 501; + return "Failure - logo not found in cache"; + } + } return NULL; } -- cgit v1.2.3