1 #include "ActiveSession.h"
2 #include "ActiveSession.moc"
7 ActiveSession::ActiveSession(Session
*session
, QWidget
*parent
) : QTabWidget(parent
), session(session
), status(INITIALIZING
) {
8 this->setTabPosition(West
);
9 overview
= new ActiveSessionOverview(session
);
10 this->addTab(overview
, tr("&Overview"));
12 memory
= new Platform::Memory();
13 status
= WAITING_FOR_CONNECTION
;
14 connect(this, SIGNAL(status_changed(QString
)), overview
, SLOT(update_status(QString
)));
15 emit
status_changed(get_status_as_string());
17 block_view
= new ActiveSessionBlockView(memory
);
18 this->addTab(block_view
, tr("&Block view"));
21 ActiveSession::~ActiveSession() {
25 void ActiveSession::execute() {
26 connect_to("localhost", session
->get_port());
29 void ActiveSession::connect_to(QString host
, int port
) {
30 socket
= new ActiveSessionSocket(host
, port
, memory
);
31 connect(socket
, SIGNAL(connected()), this, SLOT(socket_connection()));
32 connect(socket
, SIGNAL(disconnected()), this, SLOT(socket_disconnection()));
34 connect(socket
, SIGNAL(event_received(Platform::Event
*)), block_view
, SLOT(memory_changed(Platform::Event
*)));
37 void ActiveSession::socket_connection() {
38 set_status(CONNECTED
);
41 void ActiveSession::socket_disconnection() {
42 set_status(CONNECTION_CLOSED
);
45 QString
ActiveSession::get_status_as_string() const {
46 switch(get_status()) {
48 return tr("Initializing . . .");
49 case WAITING_FOR_CONNECTION
:
50 return tr("Establishing connection to monitor . . .");
52 return tr("Connection established to monitor.");
53 case CONNECTION_CLOSED
:
54 return tr("Connection to monitor closed.");
56 qDebug("Invalid ActiveSession status!");
57 return tr("Invalid ActiveSession status!");
61 } // namespace Aesalon