2 * Copyright 2004-2019 Chris Tallon
4 * This file is part of VOMP.
6 * VOMP is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * VOMP is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with VOMP; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef VOMPSTANDALONE
22 #include <vdr/plugin.h>
27 #include "mvpserver.h"
28 //#include "vompclient.h"
30 static const char *VERSION = "0.5.1";
31 static const char *DESCRIPTION = "Vompserver plugin by Chris Tallon";
32 static const char *MAINMENUENTRY = "Vompserver";
34 #ifndef VOMPSTANDALONE
36 class cPluginVompserver : public cPlugin {
41 cPluginVompserver(void);
42 virtual ~cPluginVompserver();
43 virtual const char *Version(void) { return VERSION; }
44 virtual const char *Description(void) { return DESCRIPTION; }
45 virtual const char *CommandLineHelp(void);
46 virtual bool ProcessArgs(int argc, char *argv[]);
47 virtual bool Initialize(void);
48 virtual bool Start(void);
49 virtual void Stop(void);
50 virtual void Housekeeping(void);
51 virtual void MainThreadHook(void);
52 virtual cString Active(void);
53 virtual time_t WakeupTime(void);
54 virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; }
55 virtual cOsdObject *MainMenuAction(void);
56 virtual cMenuSetupPage *SetupMenu(void);
57 virtual bool SetupParse(const char *Name, const char *Value);
58 virtual bool Service(const char *Id, void *Data = NULL);
59 virtual const char **SVDRPHelpPages(void);
60 virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
63 cPluginVompserver::cPluginVompserver(void)
65 // Initialize any member variables here.
66 // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
67 // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
72 cPluginVompserver::~cPluginVompserver()
74 // Clean up after yourself!
76 if (configDir) delete[] configDir;
80 const char *cPluginVompserver::CommandLineHelp(void)
82 // Return a string that describes all known command line options.
83 return " -c dir config path relative to VDR plugins config path\n";
86 bool cPluginVompserver::ProcessArgs(int argc, char *argv[])
88 // Implement command line argument processing here if applicable.
91 while ((c = getopt(argc, argv, "c:")) != -1)
95 const char* vdrret = cPlugin::ConfigDirectory(optarg);
98 dsyslog("VOMP: Could not get config dir from VDR");
102 configDir = new char[strlen(vdrret)+1];
103 strcpy(configDir, vdrret);
114 bool cPluginVompserver::Initialize(void)
116 // Initialize any background activities the plugin shall perform.
120 bool cPluginVompserver::Start(void)
122 // Start any background activities the plugin shall perform.
126 const char* vdrret = cPlugin::ConfigDirectory("vompserver");
129 dsyslog("VOMP: Could not get config dir from VDR");
132 configDir = new char[strlen(vdrret)+1];
133 strcpy(configDir, vdrret);
136 int success = mvpserver.run(configDir);
137 if (success) return true;
141 void cPluginVompserver::Stop(void)
143 // Stop any background activities the plugin is performing.
146 void cPluginVompserver::Housekeeping(void)
148 // Perform any cleanup or other regular tasks.
151 void cPluginVompserver::MainThreadHook(void)
153 // Perform actions in the context of the main program thread.
154 // WARNING: Use with great care - see PLUGINS.html!
157 cString cPluginVompserver::Active(void)
159 // Return a message string if shutdown should be postponed
160 if(VompClient::getNrClients() != 0) return tr("VOMP client(s) connected");
164 time_t cPluginVompserver::WakeupTime(void)
166 // Return custom wakeup time for shutdown script
170 cOsdObject *cPluginVompserver::MainMenuAction(void)
172 // Perform the action when selected from the main VDR menu.
176 cMenuSetupPage *cPluginVompserver::SetupMenu(void)
178 // Return a setup menu in case the plugin supports one.
182 bool cPluginVompserver::SetupParse(const char *Name, const char *Value)
184 // Parse your own setup parameters and store their values.
188 bool cPluginVompserver::Service(const char *Id, void *Data)
190 // Handle custom service requests from other plugins
194 const char **cPluginVompserver::SVDRPHelpPages(void)
196 // Return help text for SVDRP commands this plugin implements
200 cString cPluginVompserver::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
202 // Process SVDRP commands this plugin implements
206 VDRPLUGINCREATOR(cPluginVompserver); // Don't touch this!
209 #else //VOMPSTANDALONE
211 int main(int argc, char **argv) {
216 std::cout << "Vompserver starting Version " << VERSION << " " << DESCRIPTION << std::endl;
218 if ( server.run(cdir) != 1) {
219 std::cerr << "unable to start vompserver" << std::endl;
226 #endif //VOMPSTANDALONE