diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-17 15:54:24 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-17 15:54:24 -0500 |
commit | 0e11c4ce6d21acd0139345c19b6341971e679b23 (patch) | |
tree | 361adc3f2312984ba2fbf2e3189e41a55d292648 /clients/tde/src/app/remotemdi.cpp | |
parent | 2c6c71334b9a5a9ee9211e4b389a239273642313 (diff) | |
download | ulab-0e11c4ce6d21acd0139345c19b6341971e679b23.tar.gz ulab-0e11c4ce6d21acd0139345c19b6341971e679b23.zip |
Write initial SASL/GSSAPI Kerberos classes and server code
Diffstat (limited to 'clients/tde/src/app/remotemdi.cpp')
-rw-r--r-- | clients/tde/src/app/remotemdi.cpp | 137 |
1 files changed, 123 insertions, 14 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp index 3e7e26b..cb1d397 100644 --- a/clients/tde/src/app/remotemdi.cpp +++ b/clients/tde/src/app/remotemdi.cpp @@ -28,7 +28,7 @@ using namespace std; #include "views/instrumentview.h" RemoteMDI::RemoteMDI() - : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(0) + : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(NULL), m_rsvSvrSocket(NULL) { setXMLFile("remotelabui.rc"); @@ -36,32 +36,41 @@ RemoteMDI::RemoteMDI() KStdAction::close(this, SLOT(closeCurrent()), actionCollection()); KStdAction::quit(this, SLOT(close()), actionCollection()); - // Use a traditional MDI - switchToChildframeMode(); - - KToggleAction *inst_sa_menu = new KToggleAction(i18n("Spectrum Analyzer"), KShortcut(), this, SLOT(startSpectrumAnalyzer()), actionCollection(), "spectrum_analyzer"); - KActionCollection *const ac = actionCollection(); - setStandardToolBarMenuEnabled( true ); - KStdAction::quit( TQT_TQOBJECT(this), TQT_SLOT(close()), ac ); + setStandardToolBarMenuEnabled(true); + KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(close()), ac); KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(configToolbars()), ac); KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(configKeys()), ac); - new KAction(i18n("Launch Spectrum Analyzer"), "remote", CTRL+Key_Home, TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer" ); + connect_action = new KAction(i18n("Connect to Server"), "remote", NULL, TQT_TQOBJECT(this), TQT_SLOT(connectToServer()), ac, "connect_server"); + disconnect_action = new KAction(i18n("Disconnect from Server"), "remote", NULL, TQT_TQOBJECT(this), TQT_SLOT(disconnectFromServer()), ac, "disconnect_server"); + inst_sa_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", NULL, TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer"); + + // Add Window menu + if ( !isFakingSDIApplication() ) { + menuBar()->insertItem(i18n("&Window"), windowMenu()); + } createGUI( 0 ); // When we change view, change the status bar text connect(this, SIGNAL(viewActivated(KMdiChildView*)), this, SLOT(currentChanged(KMdiChildView*))); + ac->setHighlightingEnabled(true); + connect(ac, TQT_SIGNAL(actionStatusText(const TQString&)), statusBar(), TQT_SLOT(message(const TQString&) )); + connect(ac, TQT_SIGNAL(clearStatusText()), statusBar(), TQT_SLOT(clear())); + // Create the status bar - statusBar()->message( i18n( "No view!" ) ); + statusBar()->message(i18n("No view!")); // Create the list of the opened windows - m_listBox = new KListBox( this ); - m_listBox->setCaption( i18n( "Opened windows" ) ); - addToolWindow( m_listBox, KDockWidget::DockLeft, getMainDockWidget() ); + m_listBox = new KListBox(this); + m_listBox->setCaption(i18n("Opened windows")); + addToolWindow(m_listBox, KDockWidget::DockLeft, getMainDockWidget()); + + connect(m_listBox, SIGNAL(executed(TQListBoxItem *)), this, SLOT(listBoxExecuted(TQListBoxItem*))); + connect(m_listBox, SIGNAL(rightButtonClicked(TQListBoxItem*, const TQPoint&)), this, SLOT(listBoxRightClicked(TQListBoxItem*))); - connect(m_listBox, SIGNAL(executed(TQListBoxItem *)), this, SLOT(listBoxExecuted(TQListBoxItem* ))); + processLockouts(); } RemoteMDI::~RemoteMDI() @@ -69,6 +78,86 @@ RemoteMDI::~RemoteMDI() while (m_pCurrentWindow) { closeCurrent(); } + + if (m_rsvSvrSocket) { + m_rsvSvrSocket->close(); + while (m_rsvSvrSocket->state() == TQSocket::Closing) { + tqApp->processEvents(); + } + delete m_rsvSvrSocket; + } +} + +void RemoteMDI::connectToServer() { + if (m_rsvSvrSocket) { + return; + } + + connect_action->setEnabled(false); + disconnect_action->setEnabled(false); + + // Connect to the central reservation/control server + m_rsvSvrSocket = new TDEKerberosClientSocket(this); + connect(m_rsvSvrSocket, SIGNAL(connectionClosed()), this, SLOT(connectionClosedHandler())); + m_rsvSvrSocket->setServiceName("remotefpga"); + if (m_serverHost != "") { + m_rsvSvrSocket->setServerFQDN(m_serverHost); + m_rsvSvrSocket->connectToHost(m_serverHost, 4004); + while ((m_rsvSvrSocket->state() == TQSocket::Connecting) || (m_rsvSvrSocket->state() == TQSocket::HostLookup)) { + tqApp->processEvents(); + } + if (m_rsvSvrSocket->state() == TQSocket::Connected) { + printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout); + if (m_rsvSvrSocket->setUsingKerberos(true) != 0) { + disconnectFromServer(); + } + else { + // Connection established! + disconnect_action->setEnabled(true); + + // Read the next line from the server + TQString str = m_rsvSvrSocket->readLine(); + printf("[RAJA DEBUG 200.0] Got %s\n\r", str.ascii()); fflush(stdout); + } + } + else { + printf("[ERROR] Initial connection failed (state %d)\n\r", m_rsvSvrSocket->state()); fflush(stdout); + disconnectFromServer(); + } + } + + processLockouts(); +} + +void RemoteMDI::disconnectFromServer() { + connect_action->setEnabled(false); + disconnect_action->setEnabled(false); + + if (m_rsvSvrSocket) { + m_rsvSvrSocket->close(); + while (m_rsvSvrSocket->state() == TQSocket::Closing) { + tqApp->processEvents(); + } + delete m_rsvSvrSocket; + m_rsvSvrSocket = 0; + } + + connect_action->setEnabled(true); + processLockouts(); +} + +void RemoteMDI::connectionClosedHandler() { + disconnectFromServer(); +} + +void RemoteMDI::processLockouts() { + bool connected = false; + if (m_rsvSvrSocket) { + connected = (m_rsvSvrSocket->state() == TQSocket::Connected); + } + +printf("[RAJA DEBUG 600.0] connected: %d\n\r", connected); fflush(stdout); + inst_sa_menu->setEnabled(connected); } void RemoteMDI::configToolbars() { @@ -199,6 +288,26 @@ void RemoteMDI::listBoxExecuted(TQListBoxItem *item) } } +void RemoteMDI::listBoxRightClicked(TQListBoxItem *item) +{ + // Get the current item's text + TQString text = item->text(); + + // Bring up a menu for the corresponding window + // RAJA FIXME + for (TQValueList< KMdiChildView *>::iterator it = m_window.begin(); it != m_window.end(); ++it ) { + // Get the view + KMdiChildView *view = *it; + assert(view); + + // Is the view we need to show? + if (view->caption() == text) { + view->activate(); + break; + } + } +} + void RemoteMDI::childClosed(KMdiChildView * w) { assert(w); |