summaryrefslogtreecommitdiffstats
path: root/clients/tde/src
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde/src')
-rw-r--r--clients/tde/src/app/remotemdi.cpp2
-rw-r--r--clients/tde/src/part/Makefile.am2
-rw-r--r--clients/tde/src/part/adminconsole/Makefile.am11
-rw-r--r--clients/tde/src/part/adminconsole/hi16-action-libremotelab_adminconsole.pngbin0 -> 650 bytes
-rw-r--r--clients/tde/src/part/adminconsole/layout.ui341
-rw-r--r--clients/tde/src/part/adminconsole/part.cpp621
-rw-r--r--clients/tde/src/part/adminconsole/part.h105
-rw-r--r--clients/tde/src/part/adminconsole/terminatedlg.cpp95
-rw-r--r--clients/tde/src/part/adminconsole/terminatedlg.h53
-rw-r--r--clients/tde/src/part/adminconsole/terminatedlgbase.ui84
10 files changed, 1312 insertions, 2 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index 223996e..32043c2 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -281,7 +281,7 @@ void RemoteMDI::finishConnectingToServer() {
void RemoteMDI::masterPoll() {
// Query current termination timestamp
if (m_rsvSvrSocket) {
- if (m_rsvSvrSocket->state() == TQSocket::Connected) {
+ if ((m_rsvSvrSocket->state() == TQSocket::Connected) && (!connToServerConnecting)) {
TQDataStream ds(m_rsvSvrSocket);
ds.setPrintableData(true);
TQ_ULLONG terminationStamp;
diff --git a/clients/tde/src/part/Makefile.am b/clients/tde/src/part/Makefile.am
index 55afedd..7d3bcfe 100644
--- a/clients/tde/src/part/Makefile.am
+++ b/clients/tde/src/part/Makefile.am
@@ -1 +1 @@
-SUBDIRS = scope commanalyzer fpgaview fpgaprogram sensormonitor
+SUBDIRS = scope commanalyzer fpgaview fpgaprogram sensormonitor adminconsole
diff --git a/clients/tde/src/part/adminconsole/Makefile.am b/clients/tde/src/part/adminconsole/Makefile.am
new file mode 100644
index 0000000..9db32f5
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/Makefile.am
@@ -0,0 +1,11 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/src -I$(top_srcdir)/src/widgets $(KDE_INCLUDES)/tde
+KDE_CXXFLAGS = $(USE_EXCEPTIONS)
+METASOURCES = AUTO
+
+KDE_ICON = libremotelab_adminconsole
+
+# Part
+kde_module_LTLIBRARIES = libremotelab_adminconsole.la
+libremotelab_adminconsole_la_LIBADD = ../../widgets/libtracewidget.la ../../widgets/libfloatspinbox.la $(LIB_KFILE) $(LIB_KPARTS) $(LIB_TDEUI) $(LIB_QT) -ltdekrbsocket -ltqtrla
+libremotelab_adminconsole_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(LIB_TDECORE) $(LIB_TDEUI) -lkio -ltdefx
+libremotelab_adminconsole_la_SOURCES = part.cpp layout.ui terminatedlg.cpp terminatedlgbase.ui
diff --git a/clients/tde/src/part/adminconsole/hi16-action-libremotelab_adminconsole.png b/clients/tde/src/part/adminconsole/hi16-action-libremotelab_adminconsole.png
new file mode 100644
index 0000000..a8d720b
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/hi16-action-libremotelab_adminconsole.png
Binary files differ
diff --git a/clients/tde/src/part/adminconsole/layout.ui b/clients/tde/src/part/adminconsole/layout.ui
new file mode 100644
index 0000000..5a56809
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/layout.ui
@@ -0,0 +1,341 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+ <class>AdminConsoleBase</class>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>AdminConsoleBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>519</width>
+ <height>356</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed_grid</cstring>
+ </property>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupTerminalServices</cstring>
+ </property>
+ <property name="title">
+ <string>Terminal Services</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed_grid</cstring>
+ </property>
+ <widget class="TQSplitter" row="1" column="0" colspan="4">
+ <property name="name">
+ <cstring>splitter1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="KListView" row="1" column="0" colspan="4">
+ <column>
+ <property name="text">
+ <string>Session ID</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>User Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Server Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Control PID</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Window Manager PID</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>X11 Display Number</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Logon Date</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Last Session Management Activity</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>ts_list</cstring>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="0" colspan="4">
+ <property name="name">
+ <cstring>unnamed_layoutwidget1</cstring>
+ </property>
+ <grid>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>ts_controls</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed_grid3</cstring>
+ </property>
+ <widget class="TQPushButton" row="0" column="0" colspan="1">
+ <property name="name">
+ <cstring>ts_buttonKill</cstring>
+ </property>
+ <property name="text">
+ <string>Terminate Session</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="4" column="0">
+ <property name="name" stdset="0">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupWorkspaces</cstring>
+ </property>
+ <property name="title">
+ <string>Workspaces</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed_grid</cstring>
+ </property>
+ <widget class="TQSplitter" row="1" column="0" colspan="4">
+ <property name="name">
+ <cstring>splitter1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="KListView" row="1" column="0" colspan="4">
+ <column>
+ <property name="text">
+ <string>Session ID</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>User Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Realm Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Server ID</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Logon Date</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Forced Logoff Date</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>workspace_list</cstring>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="0" colspan="4">
+ <property name="name">
+ <cstring>unnamed_layoutwidget1</cstring>
+ </property>
+ <grid>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>workspace_controls</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed_grid3</cstring>
+ </property>
+ <widget class="TQPushButton" row="0" column="0" colspan="1">
+ <property name="name">
+ <cstring>workspace_buttonTerminate</cstring>
+ </property>
+ <property name="text">
+ <string>Terminate Workspace</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1" colspan="1">
+ <property name="name">
+ <cstring>workspace_buttonCancelTermination</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel Termination</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="4" column="0">
+ <property name="name" stdset="0">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <includes>
+ <include location="local" impldecl="in implementation">AdminConsoleBase.ui.h</include>
+ </includes>
+ <includes>
+ <include location="local" impldecl="in implementation">tracewidget.h</include>
+ <include location="local" impldecl="in implementation">floatspinbox.h</include>
+ <include location="local" impldecl="in implementation">part.h</include>
+ </includes>
+ <layoutdefaults spacing="3" margin="6"/>
+ <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+</UI>
diff --git a/clients/tde/src/part/adminconsole/part.cpp b/clients/tde/src/part/adminconsole/part.cpp
new file mode 100644
index 0000000..2b5a619
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/part.cpp
@@ -0,0 +1,621 @@
+/*
+ * Remote Laboratory Administration Console Part
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (c) 2012 Timothy Pearson
+ * Raptor Engineering
+ * http://www.raptorengineeringinc.com
+ */
+
+#include "define.h"
+#include "part.h"
+
+#include <kaboutdata.h> //::createAboutData()
+#include <kaction.h>
+#include <klocale.h>
+#include <ktextedit.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h> //::start()
+#include <kparts/genericfactory.h>
+#include <kstatusbar.h>
+#include <kstdaction.h>
+#include <knuminput.h>
+#include <kmdcodec.h>
+#include <kurlrequester.h>
+#include <tqfile.h> //encodeName()
+#include <tqtimer.h> //postInit() hack
+#include <tqvbox.h>
+#include <tqsocket.h>
+#include <tqmutex.h>
+#include <tqeventloop.h>
+#include <tqapplication.h>
+#include <tqgroupbox.h>
+#include <tqcheckbox.h>
+#include <tqpushbutton.h>
+#include <tqprogressbar.h>
+#include <tqlistview.h>
+#include <klistview.h>
+#include <unistd.h> //access()
+#include <stdint.h>
+
+#include <tqpainter.h>
+
+#include "tracewidget.h"
+#include "floatspinbox.h"
+#include "layout.h"
+#include "terminatedlg.h"
+
+#define NETWORK_COMM_TIMEOUT_MS 2500
+
+enum connectionModes {
+ ModeIdle = 0,
+ ModeTerminate = 1
+};
+
+enum connectionStates {
+ ModeIdle_None = 0,
+ ModeIdle_StateTerminalListRequest = 1,
+ ModeIdle_StateProcessTerminalList = 2,
+ ModeIdle_StateWorkspaceListRequest = 3,
+ ModeIdle_StateProcessWorkspaceList = 4,
+ ModeIdle_StateDelay = 5,
+ ModeTerminate_TerminalServices = 6,
+ ModeTerminate_LaboratoryWorkspace = 7,
+ ModeTerminate_CancelTerminationOfWorkspace = 8,
+ ModeTerminate_ProcessResponse = 9
+};
+
+namespace RemoteLab {
+
+typedef KParts::GenericFactory<RemoteLab::AdminConsolePart> Factory;
+#define CLIENT_LIBRARY "libremotelab_adminconsole"
+K_EXPORT_COMPONENT_FACTORY(libremotelab_adminconsole, RemoteLab::Factory)
+
+AdminConsolePart::AdminConsolePart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
+ : RemoteInstrumentPart( parent, name ), m_base(NULL), m_commHandlerState(0), m_connectionActiveAndValid(false), m_tickerState(0)
+{
+ // Initialize important base class variables
+ m_clientLibraryName = CLIENT_LIBRARY;
+
+ // Initialize mutex
+ m_connectionMutex = new TQMutex(false);
+
+ // Initialize kpart
+ setInstance(Factory::instance());
+ setWidget(new TQVBox(parentWidget, widgetName));
+
+ // Create timers
+ m_forcedUpdateTimer = new TQTimer(this);
+ connect(m_forcedUpdateTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
+ m_updateTimeoutTimer = new TQTimer(this);
+ connect(m_updateTimeoutTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
+ m_pingDelayTimer = new TQTimer(this);
+ connect(m_pingDelayTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
+
+ // Create widgets
+ m_base = new AdminConsoleBase(widget());
+
+ // Initialize widgets
+ connect(m_base->ts_buttonKill, SIGNAL(clicked()), this, SLOT(terminalServiceKillButtonClicked()));
+ connect(m_base->workspace_buttonTerminate, SIGNAL(clicked()), this, SLOT(workspaceTerminateButtonClicked()));
+ connect(m_base->workspace_buttonCancelTermination, SIGNAL(clicked()), this, SLOT(workspaceCancelTerminationButtonClicked()));
+
+ m_base->ts_list->setAllColumnsShowFocus(true);
+ connect(m_base->ts_list, SIGNAL(selectionChanged()), this, SLOT(terminalServiceListSelect()));
+ m_base->workspace_list->setAllColumnsShowFocus(true);
+ connect(m_base->workspace_list, SIGNAL(selectionChanged()), this, SLOT(workspaceListSelect()));
+
+ TQTimer::singleShot(0, this, TQT_SLOT(postInit()));
+}
+
+AdminConsolePart::~AdminConsolePart() {
+ if (m_connectionMutex->locked()) {
+ printf("[WARNING] Exiting when data transfer still in progress!\n\r"); fflush(stdout);
+ }
+
+ disconnectFromServer();
+ delete m_connectionMutex;
+}
+
+void AdminConsolePart::processLockouts() {
+ TQWidget* mainWidget = widget();
+ if (mainWidget) {
+ if ((m_socket) && (m_socket->state() == TQSocket::Connected) && (connToServerState > 0) && (connToServerConnecting == false) && (m_commHandlerNextMode == ModeIdle)) {
+ mainWidget->setEnabled(true);
+ }
+ else {
+ mainWidget->setEnabled(false);
+ }
+ }
+
+ if ((m_connectionActiveAndValid == true) && (m_base->ts_list->selectedItem())) {
+ m_base->ts_buttonKill->setEnabled(true);
+ }
+ else {
+ m_base->ts_buttonKill->setEnabled(false);
+ }
+
+ if ((m_connectionActiveAndValid == true) && (m_base->workspace_list->selectedItem())) {
+ m_base->workspace_buttonTerminate->setEnabled(true);
+ }
+ else {
+ m_base->workspace_buttonTerminate->setEnabled(false);
+ }
+
+ if ((m_connectionActiveAndValid == true) && (m_base->workspace_list->selectedItem())) {
+ m_base->workspace_buttonCancelTermination->setEnabled(true);
+ }
+ else {
+ m_base->workspace_buttonCancelTermination->setEnabled(false);
+ }
+}
+
+void AdminConsolePart::resizeToHint() {
+ resize(widget()->sizeHint());
+}
+
+void AdminConsolePart::connectionClosed() {
+ closeURL();
+}
+
+void AdminConsolePart::postInit() {
+ setUsingFixedSize(false);
+}
+
+bool AdminConsolePart::openURL(const KURL &url) {
+ int ret;
+ ret = connectToServer(url.url());
+ processLockouts();
+ return (ret != 0);
+}
+
+bool AdminConsolePart::closeURL() {
+ disconnectFromServer();
+ m_url = KURL();
+ return true;
+}
+
+void AdminConsolePart::disconnectFromServerCallback() {
+ m_forcedUpdateTimer->stop();
+ m_updateTimeoutTimer->stop();
+}
+
+void AdminConsolePart::connectionFinishedCallback() {
+ connect(m_socket, SIGNAL(readyRead()), m_socket, SLOT(processPendingData()));
+ m_socket->processPendingData();
+ connect(m_socket, SIGNAL(newDataReceived()), this, SLOT(mainEventLoop()));
+ m_tickerState = 0;
+ m_commHandlerState = ModeIdle_StateTerminalListRequest;
+ m_commHandlerMode = ModeIdle;
+ m_commHandlerNextState = ModeIdle_None;
+ m_commHandlerNextMode = ModeIdle;
+ m_socket->setDataTimeout(NETWORK_COMM_TIMEOUT_MS);
+ m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
+ processLockouts();
+ mainEventLoop();
+ return;
+}
+
+void AdminConsolePart::connectionStatusChangedCallback() {
+ processLockouts();
+}
+
+void AdminConsolePart::terminalServiceKillButtonClicked() {
+ TQListViewItem* item = m_base->ts_list->selectedItem();
+
+ TerminateDialog termdlg(0);
+ termdlg.setWarningLabelText(i18n("Configure termination of Terminal Services for user %1").arg(item->text(1)));
+ termdlg.enableDelayedTermination(false);
+ if (termdlg.exec() == TQDialog::Accepted) {
+ terminateSessionID = item->text(0);
+ terminateSessionDelayMinutes = termdlg.minutes();
+ m_commHandlerNextState = ModeTerminate_TerminalServices;
+ m_commHandlerNextMode = ModeTerminate;
+ }
+
+ processLockouts();
+}
+
+void AdminConsolePart::workspaceTerminateButtonClicked() {
+ TQListViewItem* item = m_base->workspace_list->selectedItem();
+
+ TerminateDialog termdlg(0);
+ termdlg.setWarningLabelText(i18n("Configure termination of Laboratory Workspace for user %1").arg(item->text(1)));
+ termdlg.enableDelayedTermination(true);
+ if (termdlg.exec() == TQDialog::Accepted) {
+ terminateSessionID = item->text(0);
+ terminateSessionDelayMinutes = termdlg.minutes();
+ m_commHandlerNextState = ModeTerminate_LaboratoryWorkspace;
+ m_commHandlerNextMode = ModeTerminate;
+ }
+
+ processLockouts();
+}
+
+void AdminConsolePart::workspaceCancelTerminationButtonClicked() {
+ TQListViewItem* item = m_base->workspace_list->selectedItem();
+
+ terminateSessionID = item->text(0);
+ m_commHandlerNextState = ModeTerminate_CancelTerminationOfWorkspace;
+ m_commHandlerNextMode = ModeTerminate;
+
+ processLockouts();
+}
+
+void AdminConsolePart::terminalServiceListSelect() {
+ // Highlight the matching user session in the workspace list,
+ // or deselect all workspace list items if no matching workspace session is found
+
+ TQListViewItem* item = m_base->ts_list->selectedItem();
+ if (item) {
+ TQString username = item->text(1);
+
+ TQListViewItemIterator it;
+ it = TQListViewItemIterator(m_base->workspace_list);
+ bool found = false;
+ TQListViewItem* item2 = NULL;
+ while (it.current()) {
+ item2 = *it;
+ if (item2->text(1) == username) {
+ found = true;
+ break;
+ }
+ ++it;
+ }
+ if (found) {
+ m_base->workspace_list->setCurrentItem(item2);
+ }
+ else {
+ m_base->workspace_list->clearSelection();
+ }
+ }
+ else {
+ m_base->workspace_list->clearSelection();
+ }
+
+ processLockouts();
+}
+
+void AdminConsolePart::workspaceListSelect() {
+ // Highlight the matching user session in the terminal services list,
+ // or deselect all workspace list items if no matching terminal services session is found
+
+ TQListViewItem* item = m_base->workspace_list->selectedItem();
+ if (item) {
+ TQString username = item->text(1);
+
+ TQListViewItemIterator it;
+ it = TQListViewItemIterator(m_base->ts_list);
+ bool found = false;
+ TQListViewItem* item2 = NULL;
+ while (it.current()) {
+ item2 = *it;
+ if (item2->text(1) == username) {
+ found = true;
+ break;
+ }
+ ++it;
+ }
+ if (found) {
+ m_base->ts_list->setCurrentItem(item2);
+ }
+ else {
+ m_base->ts_list->clearSelection();
+ }
+ }
+ else {
+ m_base->ts_list->clearSelection();
+ }
+
+ processLockouts();
+}
+
+#define UPDATEDISPLAY_TIMEOUT m_connectionActiveAndValid = false; \
+ m_tickerState = 0; \
+ m_commHandlerState = ModeIdle_StateTerminalListRequest; \
+ m_commHandlerMode = ModeIdle; \
+ m_commHandlerNextState = ModeIdle_None; \
+ m_commHandlerNextMode = ModeIdle; \
+ m_socket->clearIncomingData(); \
+ setStatusMessage(i18n("Server ping timeout. Please verify the status of your network connection.")); \
+ m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE); \
+ m_connectionMutex->unlock(); \
+ return;
+
+#define SET_WATCHDOG_TIMER if (!m_updateTimeoutTimer->isActive()) m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
+#define PAT_WATCHDOG_TIMER m_updateTimeoutTimer->stop(); m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE);
+
+#define SET_NEXT_STATE(x) m_commHandlerState = x;
+
+#define EXEC_NEXT_STATE_IMMEDIATELY m_forcedUpdateTimer->start(0, TRUE);
+
+void AdminConsolePart::setTickerMessage(TQString message) {
+ m_connectionActiveAndValid = true;
+ TQString tickerChar;
+ switch (m_tickerState) {
+ case 0:
+ tickerChar = "-";
+ break;
+ case 1:
+ tickerChar = "\\";
+ break;
+ case 2:
+ tickerChar = "|";
+ break;
+ case 3:
+ tickerChar = "/";
+ break;
+ }
+ setStatusMessage(message + TQString("... %1").arg(tickerChar));
+ m_tickerState++;
+ if (m_tickerState > 3) {
+ m_tickerState = 0;
+ }
+}
+
+void AdminConsolePart::mainEventLoop() {
+ TQDataStream ds(m_socket);
+ ds.setPrintableData(true);
+
+ if (!m_connectionMutex->tryLock()) {
+ EXEC_NEXT_STATE_IMMEDIATELY
+ return;
+ }
+
+ if (m_socket) {
+ if (m_commHandlerMode == ModeIdle) {
+ // Normal operation
+ switch (m_commHandlerState) {
+ case ModeIdle_StateTerminalListRequest:
+ // Get status of remote system
+ // Clear buffers to synchronize frames in case of data corruption
+ m_socket->clearIncomingData();
+ ds << TQString("USERS");
+ ds << TQString("TERMINALS");
+ m_socket->writeEndOfFrame();
+
+ SET_NEXT_STATE(ModeIdle_StateProcessTerminalList)
+ break;
+ case ModeIdle_StateProcessTerminalList:
+ // Get all data
+ if (m_socket->canReadFrame()) {
+ PAT_WATCHDOG_TIMER
+
+ TQString status;
+ TerminalServiceStatusList list;
+ ds >> status;
+ if (status == "OK") {
+ ds >> list;
+ m_socket->clearFrameTail();
+
+ TerminalServiceStatusList::iterator it;
+ TQListViewItemIterator it2;
+
+ for (it = list.begin(); it != list.end(); ++it) {
+ TerminalServiceStatusType info = *it;
+ it2 = TQListViewItemIterator(m_base->ts_list);
+ bool found = false;
+ while (it2.current()) {
+ TQListViewItem* item = *it2;
+ if (info.sessionID == item->text(0).toInt()) {
+ found = true;
+ }
+ ++it2;
+ }
+ if (!found) {
+ new TQListViewItem(m_base->ts_list, TQString("%1").arg(info.sessionID), info.username, info.serverName, TQString("%1").arg(info.serverPID), TQString("%1").arg(info.wmPID), TQString(":%1").arg(info.display), info.loginStamp.toString(), info.activityStamp.toString());
+ }
+ }
+ it2 = TQListViewItemIterator(m_base->ts_list);
+ while (it2.current()) {
+ TQListViewItem* item = *it2;
+ bool found = false;
+ for (it = list.begin(); it != list.end(); ++it) {
+ TerminalServiceStatusType info = *it;
+ if (info.sessionID == item->text(0).toInt()) {
+ found = true;
+ }
+ }
+ if (!found) {
+ delete item;
+ }
+ ++it2;
+ }
+
+ setTickerMessage(i18n("Connected"));
+ }
+
+ SET_NEXT_STATE(ModeIdle_StateWorkspaceListRequest);
+ EXEC_NEXT_STATE_IMMEDIATELY
+ }
+ else {
+ if (!m_updateTimeoutTimer->isActive()) {
+ UPDATEDISPLAY_TIMEOUT
+ }
+ }
+ break;
+ case ModeIdle_StateWorkspaceListRequest:
+ // Get status of remote system
+ // Clear buffers to synchronize frames in case of data corruption
+ m_socket->clearIncomingData();
+ ds << TQString("USERS");
+ ds << TQString("WORKSPACES");
+ m_socket->writeEndOfFrame();
+
+ SET_NEXT_STATE(ModeIdle_StateProcessWorkspaceList)
+ EXEC_NEXT_STATE_IMMEDIATELY
+ break;
+ case ModeIdle_StateProcessWorkspaceList:
+ // Get all data
+ if (m_socket->canReadFrame()) {
+ PAT_WATCHDOG_TIMER
+
+ TQString status;
+ WorkspaceServiceStatusList list;
+ ds >> status;
+ if (status == "OK") {
+ ds >> list;
+ m_socket->clearFrameTail();
+
+ WorkspaceServiceStatusList::iterator it;
+ TQListViewItemIterator it2;
+
+ for (it = list.begin(); it != list.end(); ++it) {
+ WorkspaceServiceStatusType info = *it;
+ if (info.serviceID != 0) {
+ continue;
+ }
+ it2 = TQListViewItemIterator(m_base->workspace_list);
+ bool found = false;
+ while (it2.current()) {
+ TQListViewItem* item = *it2;
+ if (info.sessionID == item->text(0).toInt()) {
+ found = true;
+ }
+ ++it2;
+ }
+ if (!found) {
+ new TQListViewItem(m_base->workspace_list, TQString("%1").arg(info.sessionID), info.username, info.realmname, TQString("%1").arg(info.stationName), info.loginStamp.toString(), (info.terminateStamp.toTime_t()==0)?i18n("Not Set"):info.terminateStamp.toString());
+ }
+ }
+ it2 = TQListViewItemIterator(m_base->workspace_list);
+ while (it2.current()) {
+ TQListViewItem* item = *it2;
+ bool found = false;
+ for (it = list.begin(); it != list.end(); ++it) {
+ WorkspaceServiceStatusType info = *it;
+ if (info.serviceID != 0) {
+ continue;
+ }
+ if (info.sessionID == item->text(0).toInt()) {
+ found = true;
+ }
+ }
+ if (!found) {
+ delete item;
+ }
+ ++it2;
+ }
+
+ setTickerMessage(i18n("Connected"));
+ }
+
+ if (m_commHandlerState == ModeIdle_StateProcessWorkspaceList) {
+ m_pingDelayTimer->start(250, TRUE);
+ SET_NEXT_STATE(ModeIdle_StateDelay);
+ }
+ }
+ else {
+ if (!m_updateTimeoutTimer->isActive()) {
+ UPDATEDISPLAY_TIMEOUT
+ }
+ }
+ break;
+ case ModeIdle_StateDelay:
+ if (m_commHandlerNextMode == ModeIdle) {
+ // Let the client and server rest for a bit to lower CPU/network overhead
+ if (!m_pingDelayTimer->isActive()) {
+ EXEC_NEXT_STATE_IMMEDIATELY
+ // Execute query on next event loop
+ SET_NEXT_STATE(ModeIdle_StateTerminalListRequest);
+ }
+ PAT_WATCHDOG_TIMER
+ }
+ else {
+ m_commHandlerMode = m_commHandlerNextMode;
+ SET_NEXT_STATE(m_commHandlerNextState);
+ EXEC_NEXT_STATE_IMMEDIATELY
+ m_commHandlerNextState = ModeIdle_None;
+ m_commHandlerNextMode = ModeIdle;
+ }
+ break;
+ }
+ }
+ else if (m_commHandlerMode == ModeTerminate) {
+ switch (m_commHandlerState) {
+ case ModeTerminate_TerminalServices:
+ ds << TQString("SESSION");
+ ds << TQString("KILL_TERMINAL");
+ ds << terminateSessionID;
+ m_socket->writeEndOfFrame();
+
+ SET_NEXT_STATE(ModeTerminate_ProcessResponse)
+ EXEC_NEXT_STATE_IMMEDIATELY
+ break;
+ case ModeTerminate_LaboratoryWorkspace:
+ ds << TQString("SESSION");
+ ds << TQString("KILL_WORKSPACE");
+ ds << terminateSessionID;
+ ds << terminateSessionDelayMinutes;
+ m_socket->writeEndOfFrame();
+
+ SET_NEXT_STATE(ModeTerminate_ProcessResponse)
+ EXEC_NEXT_STATE_IMMEDIATELY
+ break;
+ case ModeTerminate_CancelTerminationOfWorkspace:
+ ds << TQString("SESSION");
+ ds << TQString("CANCEL_KILL_WORKSPACE");
+ ds << terminateSessionID;
+ m_socket->writeEndOfFrame();
+
+ SET_NEXT_STATE(ModeTerminate_ProcessResponse)
+ EXEC_NEXT_STATE_IMMEDIATELY
+ break;
+ case ModeTerminate_ProcessResponse:
+ // Get all data
+ if (m_socket->canReadFrame()) {
+ PAT_WATCHDOG_TIMER
+
+ TQString status;
+ WorkspaceServiceStatusList list;
+ ds >> status;
+
+ if (status != "OK") {
+ // Command failed!
+ KMessageBox::error(0, i18n("Command Failure"), i18n("Unable to execute command!"));
+ }
+
+ m_commHandlerMode = ModeIdle;
+ SET_NEXT_STATE(ModeIdle_StateTerminalListRequest);
+ EXEC_NEXT_STATE_IMMEDIATELY
+ }
+ else {
+ if (!m_updateTimeoutTimer->isActive()) {
+ UPDATEDISPLAY_TIMEOUT
+ }
+ }
+ break;
+ }
+ }
+
+ processLockouts();
+ SET_WATCHDOG_TIMER
+ }
+ else {
+ SET_NEXT_STATE(ModeIdle_StateTerminalListRequest);
+ m_commHandlerMode = ModeIdle;
+ }
+
+ m_connectionMutex->unlock();
+}
+
+KAboutData* AdminConsolePart::createAboutData() {
+ return new KAboutData( APP_NAME, I18N_NOOP( APP_PRETTYNAME ), APP_VERSION );
+}
+
+} //namespace RemoteLab
+
+#include "part.moc"
diff --git a/clients/tde/src/part/adminconsole/part.h b/clients/tde/src/part/adminconsole/part.h
new file mode 100644
index 0000000..d8a9076
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/part.h
@@ -0,0 +1,105 @@
+/*
+ * Remote Laboratory Administration Console Part
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (c) 2012 Timothy Pearson
+ * Raptor Engineering
+ * http://www.raptorengineeringinc.com
+ */
+
+#ifndef REMOTELAB_ADMINCONSOLEPART_H
+#define REMOTELAB_ADMINCONSOLEPART_H
+
+#include <tdekrbclientsocket.h>
+
+#include <tqcstring.h>
+#include <tqframe.h>
+#include <tqimage.h>
+
+#include <kparts/browserextension.h>
+#include <kparts/statusbarextension.h>
+#include <kparts/part.h>
+#include <kurl.h>
+#include <kled.h>
+
+#include <tqtrla.h>
+
+class KAboutData;
+using KParts::StatusBarExtension;
+class TraceWidget;
+class TQSocket;
+class TQTimer;
+class TQMutex;
+class TQFile;
+class AdminConsoleBase;
+
+namespace RemoteLab
+{
+ class AdminConsolePart : public KParts::RemoteInstrumentPart
+ {
+ Q_OBJECT
+
+ public:
+ AdminConsolePart(TQWidget *, const char *, TQObject *, const char *, const TQStringList&);
+ ~AdminConsolePart();
+
+ virtual bool openFile() { return false; } // pure virtual in the base class
+ virtual bool closeURL();
+ static KAboutData *createAboutData();
+
+ public slots:
+ virtual bool openURL(const KURL &url);
+
+ private slots:
+ void postInit();
+ void resizeToHint();
+ void mainEventLoop();
+ void processLockouts();
+ void connectionClosed();
+ void connectionFinishedCallback();
+ void disconnectFromServerCallback();
+ void connectionStatusChangedCallback();
+ void setTickerMessage(TQString message);
+
+ void terminalServiceKillButtonClicked();
+ void workspaceTerminateButtonClicked();
+ void workspaceCancelTerminationButtonClicked();
+
+ void terminalServiceListSelect();
+ void workspaceListSelect();
+
+ private:
+ AdminConsoleBase* m_base;
+ TQMutex* m_connectionMutex;
+ TQTimer* m_pingDelayTimer;
+ TQTimer* m_forcedUpdateTimer;
+ TQTimer* m_updateTimeoutTimer;
+
+ int m_commHandlerState;
+ int m_commHandlerMode;
+ int m_commHandlerNextState;
+ int m_commHandlerNextMode;
+ TQString terminateSessionID;
+ TQ_INT32 terminateSessionDelayMinutes;
+ bool m_connectionActiveAndValid;
+ unsigned char m_tickerState;
+ TQByteArray m_programmingFileData;
+ TQ_ULONG m_programmingFileTotalSize;
+ TQ_ULONG m_programmingFileTransferredBytes;
+ };
+}
+
+#endif
diff --git a/clients/tde/src/part/adminconsole/terminatedlg.cpp b/clients/tde/src/part/adminconsole/terminatedlg.cpp
new file mode 100644
index 0000000..f87ae4b
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/terminatedlg.cpp
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * Copyright (C) 2012 by Timothy Pearson *
+ * kb9vqf@pearsoncomputing.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <klocale.h>
+#include <klineedit.h>
+#include <ktextedit.h>
+#include <knuminput.h>
+#include <kactionselector.h>
+#include <tqlistbox.h>
+#include <kpushbutton.h>
+#include <tqpixmap.h>
+#include <tqiconset.h>
+#include <tqlabel.h>
+#include <kconfig.h>
+#include <tqcheckbox.h>
+#include <tqradiobutton.h>
+
+#include "terminatedlgbase.h"
+#include "terminatedlg.h"
+
+TerminateDialog::TerminateDialog(TQWidget* parent, const char* name)
+ : KDialogBase(parent, name, true, i18n("Terminate Session"), Ok|Cancel, Ok, true)
+{
+ m_base = new TerminateDlgBase(this);
+
+ setMainWidget(m_base);
+
+ connect(m_base->m_btnImmediate, SIGNAL(clicked()), this, SLOT(processLockouts()));
+ connect(m_base->m_btnDelayed, SIGNAL(clicked()), this, SLOT(processLockouts()));
+
+ m_base->m_btnDelayed->setChecked(false);
+ m_base->m_btnImmediate->setChecked(true);
+ processLockouts();
+}
+
+void TerminateDialog::processLockouts() {
+ if (m_base->m_btnDelayed->isChecked()) {
+ m_base->terminateMinutes->setEnabled(true);
+ }
+ if (m_base->m_btnImmediate->isChecked()) {
+ m_base->terminateMinutes->setEnabled(false);
+ }
+}
+
+void TerminateDialog::setWarningLabelText(TQString text) {
+ m_base->m_warningLabel->setText(text);
+}
+
+void TerminateDialog::enableDelayedTermination(bool enabled) {
+ if (enabled) {
+ m_base->m_btnImmediate->setEnabled(true);
+ m_base->m_btnDelayed->setEnabled(true);
+ }
+ else {
+ m_base->m_btnImmediate->setChecked(true);
+ m_base->m_btnImmediate->setEnabled(true);
+ m_base->m_btnDelayed->setEnabled(false);
+ }
+}
+
+bool TerminateDialog::delayed() {
+ return m_base->m_btnDelayed->isChecked();
+}
+
+int TerminateDialog::minutes() {
+ if (m_base->m_btnDelayed->isChecked()) {
+ return m_base->terminateMinutes->value();
+ }
+ else {
+ return -1;
+ }
+}
+
+void TerminateDialog::slotOk() {
+ accept();
+}
+
+#include "terminatedlg.moc"
diff --git a/clients/tde/src/part/adminconsole/terminatedlg.h b/clients/tde/src/part/adminconsole/terminatedlg.h
new file mode 100644
index 0000000..eff6080
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/terminatedlg.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2012 by Timothy Pearson *
+ * kb9vqf@pearsoncomputing.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _TERMINATEDIALOG_H_
+#define _TERMINATEDIALOG_H_
+
+#include <kdialogbase.h>
+#include <kcombobox.h>
+
+class TerminateDlgBase;
+class TopLevel;
+
+class TerminateDialog : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ TerminateDialog(TQWidget* parent = 0, const char* name = 0);
+
+public slots:
+ void slotOk();
+
+public:
+ void enableDelayedTermination(bool enabled);
+ void setWarningLabelText(TQString text);
+ bool delayed();
+ int minutes();
+
+private slots:
+ void processLockouts();
+
+private:
+ TerminateDlgBase *m_base;
+};
+
+#endif
diff --git a/clients/tde/src/part/adminconsole/terminatedlgbase.ui b/clients/tde/src/part/adminconsole/terminatedlgbase.ui
new file mode 100644
index 0000000..385f0b6
--- /dev/null
+++ b/clients/tde/src/part/adminconsole/terminatedlgbase.ui
@@ -0,0 +1,84 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>TerminateDlgBase</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>TerminateDlgBase</cstring>
+ </property>
+ <grid>
+ <widget class="TQButtonGroup">
+ <property name="name">
+ <cstring>m_frameTerminate</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0" colspan="2">
+ <property name="name">
+ <cstring>m_warningLabel</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>m_btnImmediate</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Terminate Now</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>m_btnDelayed</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Terminate After</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="1">
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput" row="0" column="1">
+ <property name="name">
+ <cstring>terminateMinutes</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="2">
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="text">
+ <string>minutes</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="3" margin="6"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+</UI>