summaryrefslogtreecommitdiffstats
path: root/lib/libtqtrla/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-02-27 00:59:35 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-02-27 00:59:35 -0600
commit1fbfe130665dc4bce56869ed9158531137406129 (patch)
tree384969dfeec5cd31d2e71e9cdf068b84d27eb8b7 /lib/libtqtrla/src
parent6ae28a47f75bc1096b056ba398a558bd9fcacf73 (diff)
downloadulab-1fbfe130665dc4bce56869ed9158531137406129.tar.gz
ulab-1fbfe130665dc4bce56869ed9158531137406129.zip
First pass of logic analyzer functionality (client and FPGA core)
Diffstat (limited to 'lib/libtqtrla/src')
-rw-r--r--lib/libtqtrla/src/tqtrla.cpp78
-rw-r--r--lib/libtqtrla/src/tqtrla.h4
2 files changed, 70 insertions, 12 deletions
diff --git a/lib/libtqtrla/src/tqtrla.cpp b/lib/libtqtrla/src/tqtrla.cpp
index 4bbae6f..cf6493d 100644
--- a/lib/libtqtrla/src/tqtrla.cpp
+++ b/lib/libtqtrla/src/tqtrla.cpp
@@ -20,16 +20,18 @@
#include "tqtrla.h"
+#include <pwd.h>
+
#include <tqwidget.h>
#include <tqbuffer.h>
+#include <kdialog.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
-// RAJA UNCOMMENT ME
-//#define SERVER_TIMEOUT_MS 10000
-// RAJA DEBUG ONLY
-#define SERVER_TIMEOUT_MS 100000
+#include <libtdeldap.h>
+
+#define SERVER_TIMEOUT_MS 10000
#define FPGA_DATA_PROCESSING_TIMEOUT_MS 2500
namespace KParts
@@ -106,6 +108,42 @@ namespace KParts
}
}
+ int RemoteInstrumentPart::getNewTicket() {
+ int ret = -1;
+
+ TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent());
+ if (!parentWidget) {
+ return ret;
+ }
+
+ LDAPCredentials credentials;
+ KerberosTicketInfoList ticketList = LDAPManager::getKerberosTicketList();
+ if (ticketList.count() > 0) {
+ TQStringList princParts = TQStringList::split("@", ticketList[0].cachePrincipal);
+ credentials.username = princParts[0];
+ credentials.realm = princParts[1];
+ }
+ else {
+ struct passwd* pwd = getpwuid(geteuid());
+ if (pwd) {
+ credentials.username = TQString(pwd->pw_name);
+ }
+ }
+ int result = LDAPManager::getKerberosPassword(credentials, i18n("Please provide Kerberos credentials"), false, parentWidget);
+ if (result == KDialog::Accepted) {
+ TQString errorstring;
+ TQString service;
+ if (LDAPManager::obtainKerberosTicket(credentials, service, &errorstring) != 0) {
+ KMessageBox::error(parentWidget, i18n("<qt>Failed to obtain ticket<p>%1</qt>").arg(errorstring), i18n("Failed to obtain Kerberos ticket"));
+ }
+ else {
+ ret = 0;
+ }
+ }
+
+ return ret;
+ }
+
void RemoteInstrumentPart::setStatusMessage(const TQString& message) {
emit(statusMessageSet(message));
}
@@ -147,9 +185,10 @@ namespace KParts
m_socket = new TDEKerberosClientSocket(this);
connect(m_socket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), this, TQT_SLOT(setStatusMessage(const TQString&) ));
}
+ m_hostName = server;
m_socket->setServiceName("ulab");
- m_socket->setServerFQDN(server);
- m_socket->connectToHost(server, 4004);
+ m_socket->setServerFQDN(m_hostName);
+ m_socket->connectToHost(m_hostName, 4004);
// Finish connecting when appropriate
connToServerState = 0;
@@ -221,12 +260,27 @@ namespace KParts
}
else {
if (m_socket->kerberosStatus() != TDEKerberosClientSocket::KerberosInUse) {
- connToServerState = -1;
- connToServerConnecting = false;
- disconnectFromServer();
- 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"));
- close();
- return;
+ // Try to get a valid ticket
+ if (getNewTicket() == 0) {
+ // Retry connection if no obvious errors were detected
+ m_connectionTimer->stop();
+ if (m_socket) {
+ m_socket->clearPendingData();
+ m_socket->close();
+ delete m_socket;
+ m_socket = NULL;
+ }
+ connectToServer(m_hostName);
+ return;
+ }
+ else {
+ connToServerState = -1;
+ connToServerConnecting = false;
+ disconnectFromServer();
+ 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"));
+ close();
+ return;
+ }
}
else {
connToServerState = 2;
diff --git a/lib/libtqtrla/src/tqtrla.h b/lib/libtqtrla/src/tqtrla.h
index 16501db..8351196 100644
--- a/lib/libtqtrla/src/tqtrla.h
+++ b/lib/libtqtrla/src/tqtrla.h
@@ -74,6 +74,9 @@ namespace KParts
void setMDIMainForm(KMdiMainFrm* form);
KMdiMainFrm* mdiMainForm();
+ private:
+ int getNewTicket();
+
private slots:
void finishConnectingToServer();
virtual void connectionFinishedCallback();
@@ -102,6 +105,7 @@ namespace KParts
TQTimer *connToServerTimeoutTimer;
bool m_fixedSize;
KMdiMainFrm* m_mdiMainForm;
+ TQString m_hostName;
private:
RemoteInstrumentPartPrivate *d;