Move ui code into separate directory
[vlp.git] / src / kernel / kernel.h
1 /**************************************************************
2
3   Copyright (C) 1997  Oskar Swida
4
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either version 2
8  of the License, or (at your option) any later version.
9
10  This program is distributed in the hope that it will be useful, 
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19
20
21
22  NOTE: This software is using the free software license of 
23        the QT library v.1.30 from Troll Tech AS.
24        See the file LICENSE.QT.
25
26  
27   To contact the author, write:
28      e-mail: swida@aragorn.pb.bialystok.pl
29
30 ************************************************************/
31
32 #ifndef VLP_KERNEL_H
33 #define VLP_KERNEL_H
34
35 #include <QtGui/QMainWindow>
36 #include <QtGui/QListWidget>
37 #include <QtGui/QTextEdit>
38 #include <QtCore/QSocketNotifier>
39 #include <QtCore/QDir>
40
41 #include "comm.h"
42
43 #include "ui/kernelwindow.h"
44
45 #define GPATH "loggr"
46 #define IPATH "logi"
47 #define NPATH "logn"
48 #define REMOTE_PATH "REMOTE"
49 #define MAXINTERP 20
50 #define MAXINSTANCES 256 
51
52
53 #define MESG_COL        0
54 #define WARN_COL        1
55 #define NORM_COL        2
56
57
58 /**
59  * Interpreter slot
60  */
61 class InterpEntry {
62 public:
63         /** Interpreter identifier */
64         int ID;
65         /** Defines if interpreter is remote or not */
66         bool remote;
67         /* Program name */
68         char fullname[255];
69         char shortname[255];
70         
71         /* Socket */
72         int sock;
73         QSocketNotifier *notify;
74         /* IDs of my remote INT modules */
75         int RInstances[MAXINSTANCES];
76         /* Parent interpreter info */
77         ctx_struct p_ctx;
78 };
79
80 /**
81  * Connection slot
82  */
83 class ConnectEntry {
84 public:
85         char addr[256];
86         
87         ConnectEntry(char *s) {
88                 strcpy(addr, s);
89         };
90 };
91
92
93 /**
94  * Kernel class
95  */
96 class QKernel : public QMainWindow, private Ui::KernelWindow {
97         Q_OBJECT
98 public:
99         QMenu *toolsMenu;
100         char progdir[256];
101         int NodeNumber;
102         int ConType;
103
104         QKernel(int argc, char **argv);
105
106         void WriteMessage(char* msg);
107         void InitMessage();
108
109 public slots:
110         void NetMessage();
111         void IntMessage(int);
112
113 protected:
114         virtual void closeEvent (QCloseEvent * e);
115
116 private:
117         QList<InterpEntry*> Interpreters;
118         QList<ConnectEntry*> ConnectList;
119         
120         /**
121          * number of working interpreters
122          * @attention Currently not in use
123          */
124         int Tasks;
125         
126         /**
127          * number of connected VLPs
128          */
129         int ActiveConnections;
130         /**
131          * Indicates state of the Kernel Program. Is it locked or not.
132          */
133         bool LOCKED;
134         bool synchro;
135         bool wait_for_info;
136         char LockPasswd[25];
137         
138         int net_sock;
139         int freeINTid;
140         QSocketNotifier *Net_Notify;
141         QDir homeDir;
142         char myargs[5][255];
143         bool info_messages;
144
145         void loadConfig(const QString &fname);
146         void loadConfig(const char *);
147
148         void RunGraphModule(char*);
149         void RunNetModule();
150         InterpEntry *findINTbySocket(int);
151         InterpEntry *findINTbyID(int);
152         InterpEntry *RunIntModule(char *ss, int r);
153         void RemoteInstance(InterpEntry*, int);
154         void CloseInstances(InterpEntry*);
155
156         /**
157          * Sets QKernel menu entries to the given status
158          * @param locked status which will be set on the menu entries.
159          */
160         void setLocked(bool locked);
161
162         QString getConfigFilePath();
163         const char * getHomeDir();
164         const char * getRemoteDir();
165
166         const char * getNetModuleSocket();
167         const char * getGraphModuleSocket();
168
169 private slots:
170         void on_actionExecute_triggered();
171         void on_actionKill_triggered();
172         void on_actionQuit_triggered();
173         
174         void on_actionMessage_triggered();
175         void on_actionConnect_triggered();
176         void on_actionDisconnect_triggered();
177         void on_actionInfo_triggered();
178
179         void on_actionEditor_triggered();
180         void on_actionHelp_triggered();
181         void on_actionOptions_triggered();
182         void on_actionInfo_messages_triggered();
183         void on_actionLock_console_triggered();
184         void on_actionUnlock_console_triggered();
185 };
186
187 #endif /* VLP_KERNEL_H */