]> git.vomp.tv Git - vompclient.git/blob - vconnect.h
Convert VConnect to std::thread
[vompclient.git] / vconnect.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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef VCONNECT_H
21 #define VCONNECT_H
22
23 #include <string.h>
24 #include <vector>
25 #include <mutex>
26 #include <thread>
27 #include <condition_variable>
28
29 #include "vinfo.h"
30 #include "vdr.h"
31
32 class Log;
33 class BoxStack;
34 class Message;
35
36 class VConnect : public VInfo
37 {
38   public:
39     VConnect(char* server);
40     ~VConnect();
41
42     int handleCommand(int command);
43     void processMessage(Message* m);
44     void draw();
45
46     void run();
47
48   private:
49
50     void clearServerIPs();
51
52     BoxStack* boxstack;
53     VDR* vdr;
54     Log* logger;
55     std::vector<VDRServer> servers;
56     int selectedServer;
57     char* server;
58
59     std::thread connectThread;
60     std::mutex threadMutex;
61     std::condition_variable threadCond;
62     bool threadReqQuit;
63     void threadMethod();
64     void stop();
65 };
66
67 #endif