summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clients/tde/configure.in1
-rw-r--r--clients/tde/misc/remotelabui.rc8
-rw-r--r--clients/tde/src/app/remotemdi.cpp80
-rw-r--r--clients/tde/src/app/remotemdi.h3
-rw-r--r--clients/tde/src/app/views/instrumentview.cpp6
-rw-r--r--clients/tde/src/part/Makefile.am2
-rw-r--r--clients/tde/src/part/fpgaview/Makefile.am9
-rw-r--r--clients/tde/src/part/fpgaview/layout.ui77
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp155
-rw-r--r--clients/tde/src/part/fpgaview/part.h71
-rw-r--r--lib/libtdekrb/src/tdekrbclientsocket.cpp2
-rw-r--r--lib/libtdekrb/src/tdekrbserversocket.cpp2
-rw-r--r--servers/auth_server_lin/src/auth_conn.cpp127
-rw-r--r--servers/auth_server_lin/src/auth_conn.h5
-rw-r--r--servers/fpga_server_lin/src/fpga_conn.cpp25
15 files changed, 471 insertions, 102 deletions
diff --git a/clients/tde/configure.in b/clients/tde/configure.in
index 472817b..59b7401 100644
--- a/clients/tde/configure.in
+++ b/clients/tde/configure.in
@@ -87,6 +87,7 @@ AC_CONFIG_FILES([ src/app/views/Makefile ])
AC_CONFIG_FILES([ src/dialogs/Makefile ])
AC_CONFIG_FILES([ src/part/Makefile ])
AC_CONFIG_FILES([ src/part/commanalyzer/Makefile ])
+AC_CONFIG_FILES([ src/part/fpgaview/Makefile ])
AC_CONFIG_FILES([ src/widgets/Makefile ])
AC_OUTPUT
# Check if KDE_SET_PREFIX was called, and --prefix was passed to configure
diff --git a/clients/tde/misc/remotelabui.rc b/clients/tde/misc/remotelabui.rc
index 60fa401..bd409b9 100644
--- a/clients/tde/misc/remotelabui.rc
+++ b/clients/tde/misc/remotelabui.rc
@@ -6,6 +6,10 @@
<Action name="connect_server"/>
<Action name="disconnect_server"/>
</Menu>
+ <Menu name="fpgaMenu">
+ <text>Instrumentation</text>
+ <Action name="fpga_viewer"/>
+ </Menu>
<Menu name="instrumentMenu">
<text>Instrumentation</text>
<Action name="oscilloscope"/>
@@ -18,6 +22,10 @@
<Action name="connect_server"/>
<Action name="disconnect_server"/>
</ToolBar>
+ <ToolBar name="fpgaToolBar" fullWidth="true" noMerge="1">
+ <text>Instrumentation Toolbar</text>
+ <Action name="fpga_viewer"/>
+ </ToolBar>
<ToolBar name="instrumentToolBar" fullWidth="true" noMerge="1">
<text>Instrumentation Toolbar</text>
<Action name="oscilloscope"/>
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp
index 4d355e3..10d4fc8 100644
--- a/clients/tde/src/app/remotemdi.cpp
+++ b/clients/tde/src/app/remotemdi.cpp
@@ -1,7 +1,7 @@
//Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>, (C) 2012
//Copyright: See COPYING file that comes with this distribution
-// TDE MDI interface based on excellent tutorial by Andrea Bergia et al.
+// TDE MDI interface based on a (passable) tutorial by Andrea Bergia et al.
#include "remotemdi.h"
@@ -45,7 +45,8 @@ RemoteMDI::RemoteMDI()
KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(configKeys()), ac);
connect_action = new KAction(i18n("Connect to Server"), "connect_creating", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(connectToServer()), ac, "connect_server");
disconnect_action = new KAction(i18n("Disconnect from Server"), "connect_no", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(disconnectFromServer()), ac, "disconnect_server");
- inst_sa_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer");
+ inst_fpgaviewer_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer");
+ inst_sa_menu = new KAction(i18n("Launch FPGA Viewer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startFPGAViewer()), ac, "fpga_viewer");
// Add Window menu
if ( !isFakingSDIApplication() ) {
@@ -92,12 +93,13 @@ RemoteMDI::~RemoteMDI()
void RemoteMDI::connectToServer() {
if (m_rsvSvrSocket) {
if (m_rsvSvrSocket->state() != TQSocket::Idle) {
+ printf("[DEBUG] Not connecting because the socket is still in state %d\n\r", m_rsvSvrSocket->state()); fflush(stdout);
return;
}
}
connect_action->setEnabled(false);
- disconnect_action->setEnabled(false);
+ disconnect_action->setEnabled(true);
// Connect to the central reservation/control server
if (!m_rsvSvrSocket) {
@@ -196,7 +198,15 @@ void RemoteMDI::disconnectFromServer() {
connect_action->setEnabled(false);
disconnect_action->setEnabled(false);
+ for (TQValueList< KMdiChildView *>::iterator it = m_window.begin(); it != m_window.end(); ++it ) {
+ // Get the view
+ KMdiChildView *view = *it;
+ // Close it
+ closeSpecifiedWindow(view);
+ }
+
if (m_rsvSvrSocket) {
+ m_rsvSvrSocket->clearPendingData();
m_rsvSvrSocket->close();
while (m_rsvSvrSocket->state() == TQSocket::Closing) {
tqApp->processEvents();
@@ -222,6 +232,7 @@ printf("[RAJA DEBUG 600.0] connected: %d\n\r", connected); fflush(stdout);
connect_action->setEnabled(!connected);
disconnect_action->setEnabled(connected);
+ inst_fpgaviewer_menu->setEnabled(connected);
inst_sa_menu->setEnabled(connected);
}
@@ -250,8 +261,15 @@ void RemoteMDI::startSpectrumAnalyzer() {
}
}
-void RemoteMDI::openNewWindow(KMdiChildView *view)
-{
+void RemoteMDI::startFPGAViewer() {
+ RemoteLab::InstrumentView* fpgaview = new RemoteLab::InstrumentView("libremotelab_fpgaviewer", i18n("FPGA Viewer"), (mdiMode() == KMdi::ToplevelMode) ? 0 : this);
+ openNewWindow(fpgaview);
+ if (m_serverHost != "") {
+ fpgaview->connectServer(m_serverHost);
+ }
+}
+
+void RemoteMDI::openNewWindow(KMdiChildView *view) {
// Add a child view
m_children++;
@@ -288,8 +306,7 @@ void RemoteMDI::childWindowCloseRequest(KMdiChildView *pWnd) {
}
}
-void RemoteMDI::currentChanged(KMdiChildView *current)
-{
+void RemoteMDI::currentChanged(KMdiChildView *current) {
// Update status bar and list box
statusBar()->message(i18n( "%1 activated").arg(current->tabCaption()));
@@ -298,34 +315,38 @@ void RemoteMDI::currentChanged(KMdiChildView *current)
m_listBox->setCurrentItem(item);
}
-void RemoteMDI::closeCurrent()
-{
+void RemoteMDI::closeCurrent() {
// If there's a current view, close it
- if ( m_pCurrentWindow != 0 ) {
- // Notify the status bar of the removal of the window
- statusBar()->message(i18n("%1 removed").arg(m_pCurrentWindow->tabCaption()));
+ if (m_pCurrentWindow) {
+ closeSpecifiedWindow(m_pCurrentWindow);
+ }
+}
+void RemoteMDI::closeSpecifiedWindow(KMdiChildView *window) {
+ if (window) {
+ // Notify the status bar of the removal of the window
+ statusBar()->message(i18n("%1 removed").arg(window->tabCaption()));
+
// Remove from the window list
- m_window.remove(m_window.find(m_pCurrentWindow));
-
+ m_window.remove(m_window.find(window));
+
// Remove from the list box
- TQListBoxItem *item = m_listBox->findItem(m_pCurrentWindow->tabCaption());
- assert( item );
+ TQListBoxItem *item = m_listBox->findItem(window->tabCaption());
+ assert(item);
delete item;
-
+
// We could also call removeWindowFromMdi, but it doesn't delete the
// pointer. This way, we're sure that the view will get deleted.
- closeWindow(m_pCurrentWindow);
- }
-
- // Synchronize combo box
- if (m_pCurrentWindow) {
- currentChanged(m_pCurrentWindow);
+ closeWindow(window);
+
+ // Synchronize combo box
+ if (m_pCurrentWindow) {
+ currentChanged(m_pCurrentWindow);
+ }
}
}
-void RemoteMDI::listBoxExecuted(TQListBoxItem *item)
-{
+void RemoteMDI::listBoxExecuted(TQListBoxItem *item) {
// Get the current item's text
TQString text = item->text();
@@ -343,8 +364,7 @@ void RemoteMDI::listBoxExecuted(TQListBoxItem *item)
}
}
-void RemoteMDI::listBoxRightClicked(TQListBoxItem *item)
-{
+void RemoteMDI::listBoxRightClicked(TQListBoxItem *item) {
// Get the current item's text
TQString text = item->text();
@@ -363,8 +383,7 @@ void RemoteMDI::listBoxRightClicked(TQListBoxItem *item)
}
}
-void RemoteMDI::childClosed(KMdiChildView * w)
-{
+void RemoteMDI::childClosed(KMdiChildView * w) {
assert(w);
// Set as active
@@ -386,8 +405,7 @@ void RemoteMDI::childClosed(KMdiChildView * w)
removeWindowFromMdi(w);
}
-bool RemoteMDI::queryClose()
-{
+bool RemoteMDI::queryClose() {
// Close all open connections
for (TQValueList< KMdiChildView *>::iterator it = m_window.begin(); it != m_window.end(); ++it ) {
RemoteLab::InstrumentView* iview = dynamic_cast<RemoteLab::InstrumentView*>(*it);
diff --git a/clients/tde/src/app/remotemdi.h b/clients/tde/src/app/remotemdi.h
index 9270ee0..1be1b70 100644
--- a/clients/tde/src/app/remotemdi.h
+++ b/clients/tde/src/app/remotemdi.h
@@ -52,6 +52,7 @@ class RemoteMDI : public KMdiMainFrm
void openNewWindow(KMdiChildView *view=0);
void currentChanged(KMdiChildView *current);
void closeCurrent();
+ void closeSpecifiedWindow(KMdiChildView *window);
void listBoxExecuted(TQListBoxItem *);
void listBoxRightClicked(TQListBoxItem *);
void childClosed(KMdiChildView *w);
@@ -65,6 +66,7 @@ class RemoteMDI : public KMdiMainFrm
void connectionClosedHandler();
void processLockouts();
void startSpectrumAnalyzer();
+ void startFPGAViewer();
protected:
virtual bool queryClose();
@@ -81,6 +83,7 @@ class RemoteMDI : public KMdiMainFrm
KAction *connect_action;
KAction *disconnect_action;
KAction *inst_sa_menu;
+ KAction *inst_fpgaviewer_menu;
};
#endif // _REMOTEMDI_H_
diff --git a/clients/tde/src/app/views/instrumentview.cpp b/clients/tde/src/app/views/instrumentview.cpp
index ab6c141..0b434d4 100644
--- a/clients/tde/src/app/views/instrumentview.cpp
+++ b/clients/tde/src/app/views/instrumentview.cpp
@@ -33,9 +33,9 @@ InstrumentView::~InstrumentView() {
void InstrumentView::init() {
KLibFactory *factory = KLibLoader::self()->factory(m_libraryName.ascii());
-
+
if (!factory) {
- KMessageBox::error( this, i18n("TDE could not find the %1 Part, or the Remote Laboratory Communications Analyzer Part could not be started. Did you make install?").arg(m_libraryName) );
+ KMessageBox::error( this, i18n("TDE could not find the %1 part, or it could not be started. Did you 'make install'?").arg(m_libraryName) );
TQTimer::singleShot(0, this, SLOT(close()));
}
else {
@@ -72,4 +72,4 @@ void InstrumentView::saveProperties( KConfig *config ) {
void InstrumentView::readProperties( KConfig *config ) {
}
-} //namespace RemoteLab \ No newline at end of file
+} //namespace RemoteLab
diff --git a/clients/tde/src/part/Makefile.am b/clients/tde/src/part/Makefile.am
index 920b70c..900ddb1 100644
--- a/clients/tde/src/part/Makefile.am
+++ b/clients/tde/src/part/Makefile.am
@@ -1 +1 @@
-SUBDIRS = commanalyzer
+SUBDIRS = commanalyzer fpgaview
diff --git a/clients/tde/src/part/fpgaview/Makefile.am b/clients/tde/src/part/fpgaview/Makefile.am
new file mode 100644
index 0000000..60ec9ca
--- /dev/null
+++ b/clients/tde/src/part/fpgaview/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/src -I$(top_srcdir)/src/widgets $(KDE_INCLUDES)/tde
+KDE_CXXFLAGS = $(USE_EXCEPTIONS)
+METASOURCES = AUTO
+
+# Part
+kde_module_LTLIBRARIES = libremotelab_fpgaviewer.la
+libremotelab_fpgaviewer_la_LIBADD = ../../widgets/libtracewidget.la ../../widgets/libfloatspinbox.la $(LIB_KFILE) $(LIB_KPARTS) $(LIB_TDEUI) $(LIB_QT) -ltdekrbsocket
+libremotelab_fpgaviewer_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(LIB_TDECORE) $(LIB_TDEUI) -lkio -ltdefx
+libremotelab_fpgaviewer_la_SOURCES = part.cpp layout.ui
diff --git a/clients/tde/src/part/fpgaview/layout.ui b/clients/tde/src/part/fpgaview/layout.ui
new file mode 100644
index 0000000..ce29018
--- /dev/null
+++ b/clients/tde/src/part/fpgaview/layout.ui
@@ -0,0 +1,77 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+ <class>FPGAViewBase</class>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>FPGAViewBase</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</cstring>
+ </property>
+ <widget class="TQTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>TabWidget2</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>FPGA Viewer</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupFPGAView</cstring>
+ </property>
+ <property name="title">
+ <string>FPGA Viewer</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>group8Bit</cstring>
+ </property>
+ <property name="title">
+ <string>8-Bit Input Values</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ <includes>
+ <include location="local" impldecl="in implementation">FPGAViewBase.ui.h</include>
+ </includes>
+ <includes>
+ <include location="local" impldecl="in implementation">tracewidget.h</include>
+ <include location="local" impldecl="in implementation">floatspinbox.h</include>
+ </includes>
+ <layoutdefaults spacing="3" margin="6"/>
+ <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+</UI>
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
new file mode 100644
index 0000000..dab2742
--- /dev/null
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -0,0 +1,155 @@
+/*
+ * Remote Laboratory FPGA Viewer 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 <kmessagebox.h> //::start()
+#include <kparts/genericfactory.h>
+#include <kstatusbar.h>
+#include <kstdaction.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 <unistd.h> //access()
+#include <stdint.h>
+
+
+
+#include "tracewidget.h"
+#include "floatspinbox.h"
+#include "layout.h"
+
+/* exception handling */
+struct exit_exception {
+ int c;
+ exit_exception(int c):c(c) { }
+};
+
+namespace RemoteLab {
+
+typedef KParts::GenericFactory<RemoteLab::FPGAViewPart> Factory;
+K_EXPORT_COMPONENT_FACTORY( libremotelab_fpgaviewer, RemoteLab::Factory )
+
+
+FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
+ : ReadOnlyPart( parent, name ), m_socket(0), m_base(0)
+{
+ // Initialize mutex
+ m_instrumentMutex = new TQMutex(false);
+
+ // Initialize kpart
+ setInstance(Factory::instance());
+ setWidget(new TQVBox(parentWidget, widgetName));
+
+ // Create timers
+ m_updateTimer = new TQTimer(this);
+
+ // Create widgets
+ m_base = new FPGAViewBase(widget());
+
+ TQTimer::singleShot(0, this, TQT_SLOT(postInit()));
+}
+
+FPGAViewPart::~FPGAViewPart() {
+ if (m_socket) {
+ m_socket->close();
+ while (m_socket->state() == TQSocket::Closing) {
+ tqApp->processEvents();
+ }
+ delete m_socket;
+ }
+
+ delete m_instrumentMutex;
+}
+
+void FPGAViewPart::postInit() {
+ connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateDisplay()));
+}
+
+bool FPGAViewPart::openURL(const KURL &url) {
+ return connectToServer(url.url());
+}
+
+bool FPGAViewPart::closeURL() {
+ if (m_socket) {
+ m_socket->close();
+
+ while (m_socket->state() != TQSocket::Idle) {
+ tqApp->processEvents();
+ }
+ }
+
+ m_url = KURL();
+
+ if (m_instrumentMutex->locked()) {
+ throw exit_exception(-1);
+ }
+
+ return true;
+}
+
+int FPGAViewPart::connectToServer(TQString server) {
+ if (!m_socket) {
+ m_socket = new TDEKerberosClientSocket(this);
+ }
+ m_socket->setServiceName("remotefpga");
+ m_socket->setServerFQDN(server);
+ m_socket->connectToHost(server, 4004);
+ while ((m_socket->state() != TQSocket::Connected) && (m_socket->state() != TQSocket::Idle)) {
+ tqApp->eventLoop()->processEvents(TQEventLoop::AllEvents);
+ }
+ if (m_socket->state() != TQSocket::Connected) {
+ return -1;
+ }
+ if (m_socket->setUsingKerberos(true) != 0) {
+ m_socket->close();
+ KMessageBox::error(0, i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"), i18n("Connection Failed"));
+ return -1;
+ }
+ TQDataStream ds(m_socket);
+ // RAJA FIXME
+ // How do we know which service to request?
+// ds << TQString("SERV");
+// ds <<
+
+ return 0;
+}
+
+void FPGAViewPart::updateDisplay() {
+ // RAJA FIXME
+}
+
+KAboutData* FPGAViewPart::createAboutData() {
+ return new KAboutData( APP_NAME, I18N_NOOP( APP_PRETTYNAME ), APP_VERSION );
+}
+
+} //namespace RemoteLab
+
+#include "part.moc"
diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h
new file mode 100644
index 0000000..ff1a5da
--- /dev/null
+++ b/clients/tde/src/part/fpgaview/part.h
@@ -0,0 +1,71 @@
+/*
+ * Remote Laboratory FPGA Viewer 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_FPGAVIEWPART_H
+#define REMOTELAB_FPGAVIEWPART_H
+
+#include <tdekrbclientsocket.h>
+
+#include <kparts/browserextension.h>
+#include <kparts/statusbarextension.h>
+#include <kparts/part.h>
+#include <kurl.h>
+
+class KAboutData;
+using KParts::StatusBarExtension;
+class TraceWidget;
+class TQSocket;
+class TQTimer;
+class TQMutex;
+class FPGAViewBase;
+
+namespace RemoteLab
+{
+ class FPGAViewPart : public KParts::ReadOnlyPart
+ {
+ Q_OBJECT
+
+ public:
+ FPGAViewPart(TQWidget *, const char *, TQObject *, const char *, const TQStringList&);
+ ~FPGAViewPart();
+
+ virtual bool openFile() { return false; } // pure virtual in the base class
+ virtual bool closeURL();
+ static KAboutData *createAboutData();
+ int connectToServer(TQString server);
+
+ public slots:
+ virtual bool openURL(const KURL &url);
+
+ private slots:
+ void postInit();
+ void updateDisplay();
+
+ private:
+ TDEKerberosClientSocket* m_socket;
+ FPGAViewBase* m_base;
+ TQMutex* m_instrumentMutex;
+ TQTimer* m_updateTimer;
+ };
+}
+
+#endif
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp
index 96833a2..9ea30fa 100644
--- a/lib/libtdekrb/src/tdekrbclientsocket.cpp
+++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp
@@ -388,7 +388,7 @@ void TDEKerberosClientSocket::sendSASLDataToNetwork(const char *buffer, unsigned
int result;
alloclen = ((length / 3) + 1) * 4 + 1;
- buf = (char*)malloc(alloclen);
+ buf = (char*)malloc(alloclen+1);
if (!buf) {
printf("[ERROR] Unable to malloc()!\n\r");
return;
diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp
index d99ddaa..89cb05d 100644
--- a/lib/libtdekrb/src/tdekrbserversocket.cpp
+++ b/lib/libtdekrb/src/tdekrbserversocket.cpp
@@ -388,7 +388,7 @@ void TDEKerberosServerSocket::sendSASLDataToNetwork(const char *buffer, unsigned
int result;
alloclen = ((length / 3) + 1) * 4 + 1;
- buf = (char*)malloc(alloclen);
+ buf = (char*)malloc(alloclen+1);
if (!buf) {
printf("[ERROR] Unable to malloc()!\n\r");
return;
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp
index e531099..14c234f 100644
--- a/servers/auth_server_lin/src/auth_conn.cpp
+++ b/servers/auth_server_lin/src/auth_conn.cpp
@@ -26,6 +26,15 @@
#include "auth_conn.h"
+#define ABORT_SOCKET(s) s->close(); \
+ tqApp->processEvents(); \
+ while (s->state() == TQSocket::Closing) { \
+ tqApp->processEvents(); \
+ } \
+ s->disconnect(); \
+ delete s; \
+ s = NULL;
+
/* exception handling */
struct exit_exception {
int c;
@@ -38,7 +47,7 @@ struct exit_exception {
instance of this class.
*/
AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) :
- TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_config(static_cast<AuthServer*>(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL),
+ TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_config(static_cast<AuthServer*>(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL),
m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL)
{
@@ -69,11 +78,6 @@ AuthSocket::~AuthSocket() {
if (m_databaseActivityCursor) {
delete m_databaseActivityCursor;
}
-
- if (m_database) {
- m_database->close();
- delete m_database;
- }
}
void AuthSocket::close() {
@@ -86,11 +90,13 @@ void AuthSocket::close() {
void AuthSocket::connectionClosedHandler() {
printf("[DEBUG] Connection from %s closed\n\r", m_remoteHost.ascii());
- // Update database
- m_databaseActivityCursor->select(TQString("station='%1' AND username='%2' AND realmname='%3'").arg(m_stationID).arg(m_authenticatedUserName).arg(m_authenticatedRealmName));
- if (m_databaseActivityCursor->next()) {
- m_databaseActivityCursor->primeDelete();
- m_databaseActivityCursor->del(true);
+ if (m_bound) {
+ // Update database
+ m_databaseActivityCursor->select(TQString("station='%1' AND username='%2' AND realmname='%3'").arg(m_stationID).arg(m_authenticatedUserName).arg(m_authenticatedRealmName));
+ if (m_databaseActivityCursor->next()) {
+ m_databaseActivityCursor->primeDelete();
+ m_databaseActivityCursor->del(true);
+ }
}
if (m_criticalSection > 0) {
@@ -115,8 +121,6 @@ int AuthSocket::initiateKerberosHandshake() {
}
int AuthSocket::enterCommandLoop() {
- bool bound = false;
-
m_criticalSection++;
try {
TQString command;
@@ -196,7 +200,7 @@ int AuthSocket::enterCommandLoop() {
ds << TQString("ERRUNAVAL");
}
else {
- bound = true;
+ m_bound = true;
// Update database
TQSqlRecord *buffer = m_databaseActivityCursor->primeInsert();
@@ -219,7 +223,7 @@ int AuthSocket::enterCommandLoop() {
m_stationID = m_databaseActivityCursor->value("station").toInt();
}
- if (bound == true) {
+ if (m_bound == true) {
ds << TQString("ERRINVCMD");
}
@@ -284,6 +288,53 @@ int AuthSocket::connectToDatabase() {
return -2;
}
+ m_database = TQSqlDatabase::database();
+ if (!m_database) {
+ printf("[ERROR] Database was not constructed by the application\n\r"); fflush(stdout);
+ return -1;
+ }
+
+ m_databaseStationsCursor = new TQSqlCursor("stations", TRUE, m_database);
+ m_databaseServicesCursor = new TQSqlCursor("services", TRUE, m_database);
+ m_databaseServiceTypesCursor = new TQSqlCursor("servicetypes", TRUE, m_database);
+ m_databasePermissionsCursor = new TQSqlCursor("permissions", TRUE, m_database);
+ m_databaseActivityCursor = new TQSqlCursor("activity", TRUE, m_database);
+
+ return 0;
+}
+
+/*
+ The AuthServer class handles new connections to the server. For every
+ client that connects, it creates a new AuthSocket -- that instance is now
+ responsible for the communication with that client.
+*/
+AuthServer::AuthServer(TQObject* parent) :
+ TQServerSocket( 4004, 1, parent ), m_database(NULL) {
+
+ m_config = new KSimpleConfig("remotefpga_authserver.conf", false);
+
+ if (connectToDatabase() != 0) {
+ exit(1);
+ }
+
+ if ( !ok() ) {
+ printf("[ERROR] Failed to bind to port 4004\n\r");
+ exit(1);
+ }
+
+ printf("[INFO] Server started on port 4004\n\r"); fflush(stdout);
+}
+
+AuthServer::~AuthServer() {
+ if (m_database) {
+ TQSqlDatabase::removeDatabase(m_database);
+ m_database = NULL;
+ }
+
+ delete m_config;
+}
+
+int AuthServer::connectToDatabase() {
m_config->setGroup("Database");
m_database = TQSqlDatabase::addDatabase(m_config->readEntry("driver"));
@@ -294,7 +345,7 @@ int AuthSocket::connectToDatabase() {
if(!m_database->open()) {
printf("[ERROR] Failed to connect to control database on server '%s' [%s]\n\r", m_database->hostName().ascii(), m_database->lastError().text().ascii()); fflush(stdout);
- delete m_database;
+ TQSqlDatabase::removeDatabase(m_database);
m_database = NULL;
return -1;
}
@@ -302,7 +353,7 @@ int AuthSocket::connectToDatabase() {
if (!m_database->tables().contains("stations")) {
m_database->close();
printf("[ERROR] Control database '%s' on '%s' does not contain the required 'stations' table\n\r", m_database->databaseName().ascii(), m_database->hostName().ascii()); fflush(stdout);
- delete m_database;
+ TQSqlDatabase::removeDatabase(m_database);
m_database = NULL;
return -1;
}
@@ -310,7 +361,7 @@ int AuthSocket::connectToDatabase() {
if (!m_database->tables().contains("services")) {
m_database->close();
printf("[ERROR] Control database '%s' on '%s' does not contain the required 'services' table\n\r", m_database->databaseName().ascii(), m_database->hostName().ascii()); fflush(stdout);
- delete m_database;
+ TQSqlDatabase::removeDatabase(m_database);
m_database = NULL;
return -1;
}
@@ -318,7 +369,7 @@ int AuthSocket::connectToDatabase() {
if (!m_database->tables().contains("servicetypes")) {
m_database->close();
printf("[ERROR] Control database '%s' on '%s' does not contain the required 'servicetypes' table\n\r", m_database->databaseName().ascii(), m_database->hostName().ascii()); fflush(stdout);
- delete m_database;
+ TQSqlDatabase::removeDatabase(m_database);
m_database = NULL;
return -1;
}
@@ -326,7 +377,7 @@ int AuthSocket::connectToDatabase() {
if (!m_database->tables().contains("permissions")) {
m_database->close();
printf("[ERROR] Control database '%s' on '%s' does not contain the required 'permissions' table\n\r", m_database->databaseName().ascii(), m_database->hostName().ascii()); fflush(stdout);
- delete m_database;
+ TQSqlDatabase::removeDatabase(m_database);
m_database = NULL;
return -1;
}
@@ -334,51 +385,21 @@ int AuthSocket::connectToDatabase() {
if (!m_database->tables().contains("activity")) {
m_database->close();
printf("[ERROR] Control database '%s' on '%s' does not contain the required 'activity' table\n\r", m_database->databaseName().ascii(), m_database->hostName().ascii()); fflush(stdout);
- delete m_database;
+ TQSqlDatabase::removeDatabase(m_database);
m_database = NULL;
return -1;
}
- m_databaseStationsCursor = new TQSqlCursor("stations");
- m_databaseServicesCursor = new TQSqlCursor("services");
- m_databaseServiceTypesCursor = new TQSqlCursor("servicetypes");
- m_databasePermissionsCursor = new TQSqlCursor("permissions");
- m_databaseActivityCursor = new TQSqlCursor("activity");
-
return 0;
}
-/*
- The AuthServer class handles new connections to the server. For every
- client that connects, it creates a new AuthSocket -- that instance is now
- responsible for the communication with that client.
-*/
-AuthServer::AuthServer(TQObject* parent) :
- TQServerSocket( 4004, 1, parent ) {
-
- m_config = new KSimpleConfig("remotefpga_authserver.conf", false);
-
- if ( !ok() ) {
- printf("[ERROR] Failed to bind to port 4004\n\r");
- exit(1);
- }
-
- printf("[INFO] Server started on port 4004\n\r"); fflush(stdout);
-}
-
-AuthServer::~AuthServer() {
- delete m_config;
-}
-
void AuthServer::newConnection(int socket) {
AuthSocket *s = new AuthSocket(socket, this);
s->m_remoteHost = s->peerAddress().toString();
printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii());
if (s->initiateKerberosHandshake() != 0) {
- printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii());
- s->close();
- delete s;
- s = NULL;
+ printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii()); fflush(stdout);
+ ABORT_SOCKET(s)
return;
}
else {
diff --git a/servers/auth_server_lin/src/auth_conn.h b/servers/auth_server_lin/src/auth_conn.h
index aea8a48..55bb5de 100644
--- a/servers/auth_server_lin/src/auth_conn.h
+++ b/servers/auth_server_lin/src/auth_conn.h
@@ -63,6 +63,7 @@ class AuthSocket : public TDEKerberosServerSocket
int m_criticalSection;
TQString m_remoteHost;
int m_stationID;
+ bool m_bound;
KSimpleConfig* m_config;
TQSqlDatabase* m_database;
@@ -86,12 +87,16 @@ class AuthServer : public TQServerSocket
~AuthServer();
void newConnection(int socket);
+
+ private slots:
+ int connectToDatabase();
signals:
void newConnect(AuthSocket*);
private:
KSimpleConfig* m_config;
+ TQSqlDatabase* m_database;
friend class AuthSocket;
diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp
index 1335a5a..ddd430a 100644
--- a/servers/fpga_server_lin/src/fpga_conn.cpp
+++ b/servers/fpga_server_lin/src/fpga_conn.cpp
@@ -40,6 +40,15 @@
#include "fpga_conn.h"
+#define ABORT_SOCKET(s) s->close(); \
+ tqApp->processEvents(); \
+ while (s->state() == TQSocket::Closing) { \
+ tqApp->processEvents(); \
+ } \
+ s->disconnect(); \
+ delete s; \
+ s = NULL;
+
/* exception handling */
struct exit_exception {
int c;
@@ -202,16 +211,12 @@ void FPGAServer::newConnection(int socket) {
printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii());
if (m_numberOfConnections > 0) {
printf("[DEBUG] Connection from %s closed due to multiple access attempt\n\r", s->m_remoteHost.ascii());
- s->close();
- delete s;
- s = NULL;
+ ABORT_SOCKET(s)
return;
}
if (s->initiateKerberosHandshake() != 0) {
printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii());
- s->close();
- delete s;
- s = NULL;
+ ABORT_SOCKET(s)
return;
}
m_config->setGroup("Security");
@@ -222,16 +227,12 @@ void FPGAServer::newConnection(int socket) {
}
if ((s->m_authenticatedUserName != masterUser) || (s->m_authenticatedRealmName != masterRealm)) {
printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", s->m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii());
- s->close();
- delete s;
- s = NULL;
+ ABORT_SOCKET(s)
return;
}
if (s->setupSerial() != 0) {
printf("[DEBUG] Connection from %s closed due to serial port initialization failure\n\r", s->m_remoteHost.ascii());
- s->close();
- delete s;
- s = NULL;
+ ABORT_SOCKET(s)
return;
}
else {