2 * Copyright 2004-2013 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.4.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;
79 const char *cPluginVompserver::CommandLineHelp(void)
81 // Return a string that describes all known command line options.
82 return " -c dir config path relative to VDR plugins config path\n";
85 bool cPluginVompserver::ProcessArgs(int argc, char *argv[])
87 // Implement command line argument processing here if applicable.
90 while ((c = getopt(argc, argv, "c:")) != -1)
94 const char* vdrdeveldevelret = cPlugin::ConfigDirectory(optarg);
95 if (!vdrdeveldevelret)
97 dsyslog("VOMP: Could not get config dir from VDR");
101 configDir = new char[strlen(vdrdeveldevelret)+1];
102 strcpy(configDir, vdrdeveldevelret);
113 bool cPluginVompserver::Initialize(void)
115 // Initialize any background activities the plugin shall perform.
119 bool cPluginVompserver::Start(void)
121 // Start any background activities the plugin shall perform.
125 const char* vdrdeveldevelret = cPlugin::ConfigDirectory("vompserver");
126 if (!vdrdeveldevelret)
128 dsyslog("VOMP: Could not get config dir from VDR");
131 configDir = new char[strlen(vdrdeveldevelret)+1];
132 strcpy(configDir, vdrdeveldevelret);
135 int success = mvpserver.run(configDir);
136 if (success) return true;
140 void cPluginVompserver::Stop(void)
142 // Stop any background activities the plugin is performing.
145 void cPluginVompserver::Housekeeping(void)
147 // Perform any cleanup or other regular tasks.
150 void cPluginVompserver::MainThreadHook(void)
152 // Perform actions in the context of the main program thread.
153 // WARNING: Use with great care - see PLUGINS.html!
156 cString cPluginVompserver::Active(void)
158 // Return a message string if shutdown should be postponed
159 if(VompClient::getNrClients() != 0) return tr("VOMP client(s) connected");
163 time_t cPluginVompserver::WakeupTime(void)
165 // Return custom wakeup time for shutdown script
169 cOsdObject *cPluginVompserver::MainMenuAction(void)
171 // Perform the action when selected from the main VDR menu.
175 cMenuSetupPage *cPluginVompserver::SetupMenu(void)
177 // Return a setup menu in case the plugin supports one.
181 bool cPluginVompserver::SetupParse(const char *Name, const char *Value)
183 // Parse your own setup parameters and store their values.
187 bool cPluginVompserver::Service(const char *Id, void *Data)
189 // Handle custom service requests from other plugins
193 const char **cPluginVompserver::SVDRPHelpPages(void)
195 // Return help text for SVDRP commands this plugin implements
199 cString cPluginVompserver::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
201 // Process SVDRP commands this plugin implements
205 VDRPLUGINCREATOR(cPluginVompserver); // Don't touch this!
208 #else //VOMPSTANDALONE
210 int main(int argc, char **argv) {
215 std::cout << "Vompserver starting Version " << VERSION << " " << DESCRIPTION << std::endl;
217 if ( server.run(cdir) != 1) {
218 std::cerr << "unable to start vompserver" << std::endl;
225 #endif //VOMPSTANDALONE