7 #include "ActiveSession.h"
8 #include "ActiveSession.moc"
13 ActiveSession::ActiveSession(Session
*session
, QWidget
*parent
) : QTabWidget(parent
), session(session
), status(INITIALIZING
) {
14 this->setTabPosition(West
);
15 overview
= new ActiveSessionOverview(session
);
16 this->addTab(overview
, tr("&Overview"));
18 status
= WAITING_FOR_CONNECTION
;
19 connect(this, SIGNAL(status_changed(QString
)), overview
, SLOT(update_status(QString
)));
20 emit
status_changed(get_status_as_string());
22 QShortcut
*close_tab
= new QShortcut(Qt::Key_W
+ Qt::CTRL
, this);
23 connect(close_tab
, SIGNAL(activated()), this, SLOT(terminate_session()));
26 ActiveSession::~ActiveSession() {
29 void ActiveSession::execute() {
31 /* NOTE: reimplement this function */\
33 al
.add_argument(settings
.value("xterm-path").toString().toStdString());
34 al
.add_argument("-e");
35 al
.add_argument(settings
.value("aesalon-path").toString().toStdString());
36 al
.add_argument("--wait");
37 al
.add_argument("--use-port");
38 al
.add_argument(QString().setNum(session
->get_port()).toStdString());
39 al
.add_argument(session
->get_executable_path().toStdString());
40 /* TODO: handle arguments in here . . . */
44 execv(al
.get_argument(0).c_str(), al
.get_as_argv());
48 connect_to("localhost", session
->get_port());
51 void ActiveSession::connect_to(QString host
, int port
) {
52 socket
= new ActiveSessionSocket(host
, port
);
53 connect(socket
, SIGNAL(connected()), this, SLOT(socket_connection()));
54 connect(socket
, SIGNAL(disconnected()), this, SLOT(socket_disconnection()));
57 void ActiveSession::socket_connection() {
58 set_status(CONNECTED
);
61 void ActiveSession::socket_disconnection() {
62 set_status(CONNECTION_CLOSED
);
65 QString
ActiveSession::get_status_as_string() const {
66 switch(get_status()) {
68 return tr("Initializing . . .");
69 case WAITING_FOR_CONNECTION
:
70 return tr("Connecting . . .");
72 return tr("Running . . .");
73 case CONNECTION_CLOSED
:
74 return tr("Execution completed.");
76 qDebug("Invalid ActiveSession status!");
77 return tr("Invalid ActiveSession status!");
81 } // namespace Aesalon