|
|
|
@ -417,6 +417,7 @@ void AuthSocket::commandLoop() {
|
|
|
|
|
while (m_databaseStationsCursor->next()) {
|
|
|
|
|
bool authorized = false;
|
|
|
|
|
bool in_use = false;
|
|
|
|
|
bool multi_use = false;
|
|
|
|
|
|
|
|
|
|
int ngroups = 0;
|
|
|
|
|
gid_t *groups;
|
|
|
|
@ -462,7 +463,7 @@ void AuthSocket::commandLoop() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((authorized) && (!in_use)) {
|
|
|
|
|
if (authorized) {
|
|
|
|
|
StationType st;
|
|
|
|
|
st.id = m_databaseStationsCursor->value("pk").toInt();
|
|
|
|
|
st.name = m_databaseStationsCursor->value("name").toString();
|
|
|
|
@ -480,6 +481,7 @@ void AuthSocket::commandLoop() {
|
|
|
|
|
char tempchar;
|
|
|
|
|
tempchar = m_databaseServiceTypesCursor->value("single_instance").toInt();
|
|
|
|
|
svt.singleInstance = (tempchar != 0);
|
|
|
|
|
if (!svt.singleInstance) multi_use = true;
|
|
|
|
|
}
|
|
|
|
|
if (svt.name == "") {
|
|
|
|
|
svt.name = i18n("<unknown>");
|
|
|
|
@ -490,9 +492,11 @@ void AuthSocket::commandLoop() {
|
|
|
|
|
st.services.append(svt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((!in_use) || (multi_use)) {
|
|
|
|
|
m_slist.append(st);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ds << m_slist;
|
|
|
|
|
writeEndOfFrame();
|
|
|
|
@ -573,19 +577,48 @@ void AuthSocket::commandLoop() {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Find the service ID for the specified client library name
|
|
|
|
|
TQ_INT32 sid = -1;
|
|
|
|
|
TQInt32List sidList;
|
|
|
|
|
m_databaseServiceTypesCursor->select(TQString("client_library='%1'").arg(libname));
|
|
|
|
|
if (m_databaseServiceTypesCursor->next()) {
|
|
|
|
|
sid = m_databaseServiceTypesCursor->value("serviceid").toInt();
|
|
|
|
|
sidList.append(m_databaseServiceTypesCursor->value("serviceid").toInt());
|
|
|
|
|
}
|
|
|
|
|
if (sid < 0) {
|
|
|
|
|
if (sidList.empty()) {
|
|
|
|
|
ds << TQString("ERRNOSERV");
|
|
|
|
|
writeEndOfFrame();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Attempt to connect to the backend server
|
|
|
|
|
m_databaseServicesCursor->select(TQString("servicetype=%1 AND station=%2").arg(sid).arg(m_stationID));
|
|
|
|
|
TQ_INT32 sid = -1;
|
|
|
|
|
while (1) {
|
|
|
|
|
m_databaseServicesCursor->select(TQString("servicetype=%1 AND station=%2").arg(sidList[0]).arg(m_stationID));
|
|
|
|
|
if (m_databaseServicesCursor->next()) {
|
|
|
|
|
sid = sidList[0];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sidList.remove(sidList.at(0));
|
|
|
|
|
if (sidList.isEmpty()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sid != -1) {
|
|
|
|
|
// Enforce single instance flags
|
|
|
|
|
bool available = true;
|
|
|
|
|
m_databaseServiceTypesCursor->select(TQString("serviceid=%1").arg(sid));
|
|
|
|
|
if (m_databaseServiceTypesCursor->next()) {
|
|
|
|
|
char tempchar;
|
|
|
|
|
tempchar = m_databaseServiceTypesCursor->value("single_instance").toInt();
|
|
|
|
|
if (tempchar != 0) {
|
|
|
|
|
// Verify that service is not already in use
|
|
|
|
|
m_databaseActivityCursor->select(TQString("station=%1 AND serviceid=%2").arg(m_databaseStationsCursor->value("pk").toInt()).arg(sid));
|
|
|
|
|
while (m_databaseActivityCursor->next()) {
|
|
|
|
|
if (m_databaseActivityCursor->value("username").toString() != "") {
|
|
|
|
|
available = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (available) {
|
|
|
|
|
m_srvServiceHostName = m_databaseServicesCursor->value("hostname").toString();
|
|
|
|
|
m_srvServicePort = m_databaseServicesCursor->value("port").toInt();
|
|
|
|
|
|
|
|
|
@ -617,6 +650,11 @@ void AuthSocket::commandLoop() {
|
|
|
|
|
writeEndOfFrame();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ds << TQString("ERRNOSERV");
|
|
|
|
|
writeEndOfFrame();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|