summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/app/remotemdi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde/src/app/remotemdi.cpp')
-rw-r--r--clients/tde/src/app/remotemdi.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index 669350f..223996e 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -29,12 +29,17 @@ using namespace std;
#include "views/instrumentview.h"
#include "dialogs/selectserverdlg.h"
+#define STATUSBAR_TIMEOUT_ID 5
+
RemoteMDI::RemoteMDI()
: KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL)
{
setXMLFile("remotelabui.rc");
setIcon(SmallIcon("remote_laboratory_client"));
+ masterPollTimer = new TQTimer();
+ connect(masterPollTimer, SIGNAL(timeout()), this, SLOT(masterPoll()));
+
// Create some actions
KStdAction::close(this, SLOT(closeCurrent()), actionCollection());
KStdAction::quit(this, SLOT(close()), actionCollection());
@@ -67,6 +72,10 @@ RemoteMDI::RemoteMDI()
// Create the status bar
updateStatusBarMainMessage(i18n("No active instruments"));
+ KStatusBar* sb = statusBar();
+ if (sb) {
+ sb->insertItem(i18n("Unknown Time Remaining"), STATUSBAR_TIMEOUT_ID, 0, true);
+ }
processActions();
@@ -77,6 +86,11 @@ RemoteMDI::RemoteMDI()
RemoteMDI::~RemoteMDI()
{
+ if (masterPollTimer) {
+ masterPollTimer->stop();
+ delete masterPollTimer;
+ }
+
while (m_pCurrentWindow) {
closeCurrent();
}
@@ -255,6 +269,7 @@ void RemoteMDI::finishConnectingToServer() {
}
connToServerState = 3;
connToServerConnecting = false;
+ masterPollTimer->start(0, TRUE);
processLockouts();
break;
}
@@ -263,6 +278,67 @@ void RemoteMDI::finishConnectingToServer() {
}
}
+void RemoteMDI::masterPoll() {
+ // Query current termination timestamp
+ if (m_rsvSvrSocket) {
+ if (m_rsvSvrSocket->state() == TQSocket::Connected) {
+ TQDataStream ds(m_rsvSvrSocket);
+ ds.setPrintableData(true);
+ TQ_ULLONG terminationStamp;
+ long long currentStamp;
+ ds << TQString("TSTP");
+ m_rsvSvrSocket->writeEndOfFrame();
+ while (!m_rsvSvrSocket->canReadFrame()) {
+ tqApp->processEvents();
+ if (!m_rsvSvrSocket) {
+ masterPollTimer->start(1000, TRUE);
+ return;
+ }
+ }
+ ds >> terminationStamp;
+ m_rsvSvrSocket->clearFrameTail();
+ currentStamp = TQDateTime::currentDateTime().toTime_t();
+
+ KStatusBar* sb = statusBar();
+ if (sb) {
+ if (terminationStamp == 0) {
+ sb->changeItem(i18n("Unlimited Time Remaining"), STATUSBAR_TIMEOUT_ID);
+ }
+ else {
+ long long difference = terminationStamp - currentStamp;
+ int seconds = 0;
+ int minutes = 0;
+ int hours = 0;
+ int days = 0;
+ if (difference >= 0) {
+ days = (difference / 86400);
+ difference = difference - (days * 86400);
+ hours = (difference / 3600);
+ difference = difference - (hours * 3600);
+ minutes = (difference / 60);
+ difference = difference - (minutes * 60);
+ seconds = difference;
+ }
+ TQString differenceString;
+ if (days > 0) {
+ differenceString.append(i18n("%1 day(s), ").arg(days));
+ }
+ if ((days > 0) || (hours > 0)) {
+ differenceString.append(i18n("%1 hours(s), ").arg(hours));
+ }
+ if ((days > 0) || (hours > 0) || (minutes > 0)) {
+ differenceString.append(i18n("%1 minutes(s), ").arg(minutes));
+ }
+ differenceString.append(i18n("%1 seconds(s)").arg(seconds));
+ sb->changeItem(i18n("%1 Remaining").arg(differenceString), STATUSBAR_TIMEOUT_ID);
+ }
+ }
+ }
+ }
+
+ masterPollTimer->start(1000, TRUE);
+}
+
void RemoteMDI::connectToServer() {
if (m_rsvSvrSocket) {
if (m_rsvSvrSocket->state() != TQSocket::Idle) {
@@ -394,6 +470,13 @@ void RemoteMDI::processLockouts() {
for (TQPtrList<KAction>::Iterator it(m_instrumentActionList.begin()); it != m_instrumentActionList.end(); ++it) {
(*it)->setEnabled(connected);
}
+
+ if (!connected) {
+ KStatusBar* sb = statusBar();
+ if (sb) {
+ sb->changeItem(i18n("Unknown Time Remaining"), STATUSBAR_TIMEOUT_ID);
+ }
+ }
}
void RemoteMDI::configToolbars() {