/* * Image plugin to VDR (C++) * * (C) 2003 Kai Tobias Burwieck * (C) 2004 "Interpohl" * (C) 2004 A. Brachold * (C) 2004 O. Kreuzinger * (C) 2004 A. Holzhammer for the massive script updates * * based on mp3/mplayer plguin by Stefan Hülswitt * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #include #include #include "setup-image.h" #include "data-image.h" #include "control-image.h" #include "menu-image.h" static const char *VERSION = "0.0.2"; static const char *DESCRIPTION = trNOOP("An Image Viewer plugin for OSD"); static const char *MAINMENUENTRY = trNOOP("Picselshow"); class cPluginImage : public cPlugin { private: #if APIVERSNUM >= 10330 bool ExternalPlay(const char *path, bool test); #endif public: virtual ~cPluginImage(); virtual const char *Version(void) { return VERSION; } virtual const char *Description(void) { return tr(DESCRIPTION); } virtual const char *CommandLineHelp(void); virtual bool ProcessArgs(int argc, char *argv[]); virtual bool Start(void); virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); } virtual cOsdObject *MainMenuAction(void); virtual cMenuSetupPage *SetupMenu(void); virtual bool SetupParse(const char *Name, const char *Value); #if APIVERSNUM >= 10330 virtual bool Service(const char *Id, void *Data); #if APIVERSNUM >= 10331 virtual const char **SVDRPHelpPages(void); virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode); #endif #endif }; bool cPluginImage::SetupParse(const char *szName, const char *szValue) { return ImageSetup.SetupParse(szName,szValue); } const char *g_szConfigDirectory = NULL; const char *cPluginImage::CommandLineHelp(void) { static char *help_str=0; free(help_str); // for easier orientation, this is column 80| asprintf(&help_str," -m CMD, --mount=CMD use CMD to mount/unmount/eject image sources\n" " (default: \"%s\")\n" " -C PATH, --config=PATH to specify directory of configuration data\n" " relative to VDR Plugin configuration directory\n" " (default: \"%s\")\n", g_szMountScript, g_szConfigDirectory?g_szConfigDirectory:"" ); return help_str; } bool cPluginImage::ProcessArgs(int argc, char *argv[]) { static struct option long_options[] = { { "mount", required_argument, NULL, 'm' }, { "config", required_argument, NULL, 'c' }, { NULL } }; int c, option_index = 0; while((c=getopt_long(argc,argv,"m:c:",long_options,&option_index))!=-1) { switch (c) { case 'm': g_szMountScript=optarg;break; case 'c': g_szConfigDirectory=optarg;break; default: return false; } } return true; } bool cPluginImage::Start(void) { ImageSources.Load(AddDirectory(ConfigDirectory(g_szConfigDirectory), "imagesources.conf")); if(ImageSources.Count()<1) { esyslog("picselshow: you must have defined at least one source in imagesources.conf"); return false; } return true; } cPluginImage::~cPluginImage() { } cOsdObject *cPluginImage::MainMenuAction(void) { return new cImageControl; } #if APIVERSNUM >= 10330 bool cPluginImage::ExternalPlay(const char *path, bool test) { cFileSource *src=ImageSources.FindSource(path); if(src) { // src->BaseDir(); cDirItem *item=new cDirItem(src, 0, "Screensaver", itDir); if(item) { cSlideShow *newss = new cSlideShow(item); if(newss->Load() && newss->Count()) { if(!test) cImageControl::SetSlideShow(newss); else delete newss; delete item; return true; } else { delete newss; } delete item; } } return false; } bool cPluginImage::Service(const char *Id, void *Data) { if(strcmp(Id,"Picselshow-Play-v1") == 0) { if(Data) { struct PicselshowServiceData *psd=(struct PicselshowServiceData *)Data; psd->result=ExternalPlay(psd->data.filename,false); } return true; } return false; } #if APIVERSNUM >= 10331 const char **cPluginImage::SVDRPHelpPages(void) { static const char *HelpPages[] = { "PLAYDIR \n" " Triggers playback of directory 'dirname'.", NULL }; return HelpPages; } cString cPluginImage::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) { if(!strcasecmp(Command,"PLAYDIR")) { if(*Option) { if(ExternalPlay(Option,false)) { cRemote::CallPlugin("picselshow"); return "Playback triggered"; } else { ReplyCode=550; return "Playback failed";} } else { ReplyCode=501; return "Missing dirname";} } return NULL; } #endif #endif cMenuSetupPage *cPluginImage::SetupMenu(void) { return new cMenuSetupImage; } VDRPLUGINCREATOR(cPluginImage); // Don't touch this!