]> git.vomp.tv Git - vompclient.git/blob - command.h
Rework master loop
[vompclient.git] / command.h
1 /*
2     Copyright 2004-2020 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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef COMMAND_H
21 #define COMMAND_H
22
23 #ifndef WIN32
24 #include <unistd.h> // for reboot
25 #include <linux/reboot.h>
26 #include <sys/reboot.h>
27 #endif
28
29 #include <time.h>
30 #ifndef WIN32
31 #include <pthread.h>
32 #endif
33
34 #include <string>
35 #include <vector>
36
37 #include "defines.h"
38 #include "messagequeue.h"
39 #include "udp.h"
40
41 class VConnect;
42 class Message;
43 class Remote;
44 class Boxx;
45 class BoxStack;
46 class Log;
47 class VInfo;
48 class WJpeg;
49
50 struct ASLPref
51 {
52   std::string langcode;
53   int audiopref;
54   int subtitlepref;
55 };
56
57 typedef std::vector<struct ASLPref> ASLPrefList;
58
59 class Command : public MessageQueue
60 {
61   public:
62     Command();
63     ~Command();
64     static Command* getInstance();
65
66     int init(bool crashed = false, char* server = NULL);
67     int shutdown();
68     void run();
69     void stop();
70     void doReboot();
71     void connectionLost();
72
73     void setAdvMenus(bool adv) { advMenus = adv; };
74     bool isAdvMenus() { return advMenus; };
75     int getLangPref(bool subtitle,const char* langcode);
76     void setSubDefault(int subon) { subdefault = subon; };
77     int getSubDefault() { return subdefault; };
78     ASLPrefList &getASLList() { return langcodes; };
79
80   private:
81     void handleCommand(int);
82     void doStandby();
83     void doPowerOn();
84     void doPowerOff();
85     void doJustConnected(VConnect* vconnect);
86     void doWallpaper();
87     void doFromTheTop(bool which);  // true - show vinfo,wait. false - del vinfo,restart
88     void buildCrashedBox();
89     void sig1();
90     void clearMQInputEvents();
91
92     static Command* instance;
93
94     Log* logger;
95     BoxStack* boxstack;
96     Remote* remote;
97
98     bool initted{};
99     bool irun{};
100     bool isStandby{};
101     bool firstBoot{true};
102     Boxx* wallpaper{};
103     WJpeg* wallpaper_pict{};
104     VInfo* connLost{};
105     bool crashed{};
106     char* server{};
107
108     bool advMenus{};
109     ASLPrefList langcodes;
110     int subdefault;
111         
112     UDP udp;
113
114     void processMessage(Message* m);
115 };
116
117 #endif