]> git.vomp.tv Git - vompserver.git/blob - vompserver.c
Active patch from pompase
[vompserver.git] / vompserver.c
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include <vdr/plugin.h>
22 #include <getopt.h>
23
24 #include "mvpserver.h"
25 #include "mvpclient.h"
26
27 static const char *VERSION        = "0.2.6";
28 static const char *DESCRIPTION    = "VDR on MVP plugin by Chris Tallon";
29
30 class cPluginVompserver : public cPlugin
31 {
32 public:
33   cPluginVompserver(void);
34   virtual ~cPluginVompserver();
35   virtual const char *Version(void) { return VERSION; }
36   virtual const char *Description(void) { return DESCRIPTION; }
37   virtual const char *CommandLineHelp(void);
38   virtual bool ProcessArgs(int argc, char *argv[]);
39   virtual bool Initialize(void);
40   virtual bool Start(void);
41   virtual bool SetupParse(const char *Name, const char *Value);
42   virtual cString Active(void);
43
44 private:
45
46   MVPServer mvpserver;
47   char* configDir;
48 };
49
50 cPluginVompserver::cPluginVompserver(void)
51 {
52   // Initialize any member variables here.
53   // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
54   // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
55
56   configDir = NULL;
57 }
58
59 bool cPluginVompserver::Start(void)
60 {
61   // Start any background activities the plugin shall perform.
62   int success = mvpserver.run(configDir);
63   if (success) return true;
64   else return false;
65 }
66
67 cPluginVompserver::~cPluginVompserver()
68 {
69   // Clean up after yourself!
70   mvpserver.stop();
71 }
72
73 const char *cPluginVompserver::CommandLineHelp(void)
74 {
75   // Return a string that describes all known command line options.
76
77   return "  -c dir    config path relative to VDR plugins config path\n";
78 }
79
80 bool cPluginVompserver::ProcessArgs(int argc, char *argv[])
81 {
82   // Implement command line argument processing here if applicable.
83
84   int c;
85   while ((c = getopt(argc, argv, "c:")) != -1)
86   {
87     if (c == 'c')
88     {
89       configDir = optarg;
90     }
91     else
92     {
93       return false;
94     }
95   }
96
97   return true;
98 }
99
100 bool cPluginVompserver::Initialize(void)
101 {
102   // Initialize any background activities the plugin shall perform.
103   return true;
104 }
105
106 bool cPluginVompserver::SetupParse(const char *Name, const char *Value)
107 {
108   // Parse your own setup parameters and store their values.
109   return false;
110 }
111
112 cString cPluginVompserver::Active(void)
113 {
114   if(MVPClient::getNrClients() != 0) return tr("VOMP client(s) connected");
115   return NULL;
116 }
117
118 VDRPLUGINCREATOR(cPluginVompserver); // Don't touch this!
119