]> git.vomp.tv Git - vompclient.git/blob - command.h
Extended recordings menu, including artwork from tvscraper
[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 "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
49 class Command : public MessageQueue
50 {
51   public:
52     Command();
53     ~Command();
54     static Command* getInstance();
55
56     int init(bool crashed = false, char* server = NULL);
57     int shutdown();
58     void run();
59     void stop();
60     void doReboot();
61     void postMessage(Message* m); // override of MessageQueue::postMessage
62     void postMessageNoLock(Message* m); // override of MessageQueue::postMessage
63     bool postMessageIfNotBusy(Message* m); // for timers, when masterMutex might be locked
64     void postMessageFromOuterSpace(Message* m); // err, read the cc comments.
65     void sig1();
66     void connectionLost();
67
68     void setAdvMenues(bool adv) {advmenues=adv;};
69     bool advMenues() { return advmenues;};
70
71   private:
72     void handleCommand(int);
73     void doStandby();
74     void doPowerOn();
75     void doPowerOff();
76     void doJustConnected(VConnect* vconnect);
77     void doWallpaper();
78     void doFromTheTop(bool which);  // true - show vinfo,wait. false - del vinfo,restart
79     void buildCrashedBox();
80
81     static Command* instance;
82 #ifndef WIN32
83     pid_t mainPid;
84     pthread_mutex_t masterLock;
85 #else
86     HANDLE masterLock;
87     HANDLE mainPid; //Window
88 #endif
89     UCHAR initted;
90     UCHAR irun;
91     UCHAR isStandby;
92     UCHAR firstBoot;
93
94     Log* logger;
95     BoxStack* boxstack;
96     Remote* remote;
97     Boxx* wallpaper;
98     VInfo* connLost;
99     bool crashed;
100     char* server;
101
102     bool  advmenues;
103         
104     UDP udp;
105
106     void processMessage(Message* m);
107 };
108
109 #endif