]> git.vomp.tv Git - vompclient.git/blob - command.h
Fix resuming recording directly after stopping it
[vompclient.git] / command.h
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef COMMAND_H
22 #define COMMAND_H
23
24 #ifndef WIN32
25 #include <unistd.h> // for reboot
26 #include <linux/reboot.h>
27 #include <sys/reboot.h>
28 #endif
29
30 #include <time.h>
31 #ifndef WIN32
32 #include <pthread.h>
33 #endif
34
35 #include <signal.h>
36
37 #include <string>
38 #include <vector>
39
40 #include "defines.h"
41 #include "messagequeue.h"
42 #include "udp.h"
43
44 class VConnect;
45 class Message;
46 class Remote;
47 class Boxx;
48 class BoxStack;
49 class Log;
50 class VInfo;
51 class WJpeg;
52
53 struct ASLPref {
54         std::string langcode;
55         int audiopref;
56         int subtitlepref;
57 };
58
59 typedef vector<struct ASLPref> ASLPrefList;
60
61 #define SIG_INT 1
62 #define SIG_TERM 2
63 #define SIG_USR1 4
64 #define SIG_USR2 8
65 #define SIG_URG 16
66
67 class Command : public MessageQueue
68 {
69   public:
70     Command();
71     ~Command();
72     static Command* getInstance();
73
74     int init(bool crashed = false, char* server = NULL);
75     int shutdown();
76     void run();
77     void stop();
78     void doReboot();
79     void postMessage(Message* m); // override of MessageQueue::postMessage
80     void postMessageNoLock(Message* m); // override of MessageQueue::postMessage
81     bool postMessageIfNotBusy(Message* m); // for timers, when masterMutex might be locked
82     void postMessageFromOuterSpace(Message* m); // err, read the cc comments.
83     void setSignal(int signalReceived);
84     void connectionLost();
85
86     void setAdvMenues(bool adv) {advmenues=adv;};
87     bool advMenues() { return advmenues;};
88     int getLangPref(bool subtitle,const char* langcode);
89     void setSubDefault(int subon) {subdefault=subon;};
90     int getSubDefault() { return subdefault;};
91     ASLPrefList &getASLList(){return langcodes;};
92
93   private:
94     void handleCommand(int);
95     void processSignals();
96     void doStandby();
97     void doPowerOn();
98     void doPowerOff();
99     void doJustConnected(VConnect* vconnect);
100     void doWallpaper();
101     void doFromTheTop(bool which);  // true - show vinfo,wait. false - del vinfo,restart
102     void buildCrashedBox();
103     void sig1();
104
105     static Command* instance;
106 #ifndef WIN32
107     pid_t mainPid;
108     pthread_mutex_t masterLock;
109 #else
110     HANDLE masterLock;
111     HANDLE mainPid; //Window
112 #endif
113     UCHAR initted;
114     UCHAR irun;
115     UCHAR isStandby;
116     UCHAR firstBoot;
117     ULONG signals;
118
119     Log* logger;
120     BoxStack* boxstack;
121     Remote* remote;
122     Boxx* wallpaper;
123     WJpeg* wallpaper_pict;
124     VInfo* connLost;
125     bool crashed;
126     char* server;
127
128     bool  advmenues;
129     ASLPrefList langcodes;
130     int subdefault;
131         
132     UDP udp;
133
134     void processMessage(Message* m);
135 };
136
137 #endif