vlp-27 Added move OptionsDialog to the QtDesigner generated one.
[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
40 #include "comm.h"
41 #include "ui/main-window.h"
42
43 #define GPATH "loggr"
44 #define IPATH "logi"
45 #define NPATH "logn"
46 #define REMOTE_PATH "REMOTE"
47 #define MAXINTERP 20
48 #define MAXINSTANCES 256 
49
50
51 #define MESG_COL        0
52 #define WARN_COL        1
53 #define NORM_COL        2
54
55
56 /**
57  * Interpreter slot
58  */
59 class InterpEntry {
60 public:
61         /** Interpreter identifier */
62         int ID;
63         /** Defines if interpreter is remote or not */
64         bool remote;
65         /* Program name */
66         char fullname[255];
67         char shortname[255];
68         
69         /* Socket */
70         int sock;
71         QSocketNotifier *notify;
72         /* IDs of my remote INT modules */
73         int RInstances[MAXINSTANCES];
74         /* Parent interpreter info */
75         ctx_struct p_ctx;
76 };
77
78 /**
79  * Connection slot
80  */
81 class ConnectEntry {
82 public:
83         char addr[256];
84         
85         ConnectEntry(char *s) {
86                 strcpy(addr, s);
87         };
88 };
89
90
91 /**
92  * Kernel class
93  */
94 class QKernel : public QMainWindow, private Ui::MainWindow {
95         Q_OBJECT
96 public:
97         char progdir[256];
98         int NodeNumber;
99         /**
100          * Connection type (explicit = 1/registration = 2)
101          * @attention It looks that it is not used 
102          */
103         int ConType;
104
105         QKernel(QWidget *parent = 0);
106
107         void WriteMessage(char* msg);
108         void InitMessage();
109
110 public slots:
111         void n_impl();
112         void on_actionExecute_triggered();
113         void on_actionEditor_triggered();
114         void on_actionHelp_triggered();
115         void on_actionOptions_triggered();
116         void on_actionLock_Console_triggered();
117         void on_actionUnlock_console_triggered();
118         void on_actionMessage_triggered();
119         void QuitProc();
120         void NetMessage();
121         void IntMessage(int);
122         void on_actionKill_triggered();
123         void on_actionDisconnect_triggered();
124         void on_actionInfo_messages_triggered();
125         void on_actionConnect_triggered();
126         void on_actionInfo_triggered();
127
128 protected:
129         virtual void closeEvent (QCloseEvent * e);
130
131 private:
132         QList<InterpEntry*> Interpreters;
133         QList<ConnectEntry*> ConnectList;
134         
135         /**
136          * number of working interpreters
137          * @attention Currently not in use
138          */
139         int Tasks;
140         
141         /**
142          * number of connected VLPs
143          */
144         int ActiveConnections;
145         /**
146          * Indicates state of the Kernel Program. Is it locked or not.
147          */
148         bool LOCKED;
149         bool synchro;
150         bool wait_for_info;
151         char LockPasswd[25];
152         
153         int net_sock;
154         int freeINTid;
155         QSocketNotifier *Net_Notify;
156         char HomeDir[255];
157         bool info_messages;
158
159         void LoadConfig(char *);
160         void RunGraphModule(char*);
161         void RunNetModule();
162         InterpEntry *findINTbySocket(int);
163         InterpEntry *findINTbyID(int);
164         InterpEntry *RunIntModule(char *ss, int r);
165         void RemoteInstance(InterpEntry*, int);
166         void CloseInstances(InterpEntry*);
167
168         /**
169          * Sets QKernel menu entries to the given status
170          * @param locked status which will be set on the menu entries.
171          */
172         void setLocked(bool locked);
173 };
174
175 #endif /* VLP_KERNEL_H */