printf("[RAJA DEBUG 200.2] Got list of stations, count is %d\n\r",slist.count());fflush(stdout);
SelectServerDialogselect(this,0,slist);
constintret=select.exec();
if(ret==KDialog::Accepted){
TQStringresult;
ds<<TQString("BIND");
ds<<select.m_selectedStation;
ds>>result;
if(result=="OK"){
// Success, do nothing
}
elseif(result=="ERRUNAVAL"){
KMessageBox::error(this,i18n("<qt>No stations of the specified type are currently available<p>Please try again later</qt>"),i18n("Insufficient Laboratory Resources"));
disconnectFromServer();
}
else{
KMessageBox::error(this,i18n("<qt>Unknown server error<p>Please reconnect and try again</qt>"),i18n("Internal Error"));
@ -27,8 +27,8 @@ The client may terminate the connection at any time, or provide invalid data to
After initial negotiation, the server must enter command mode. In this mode the server expects to receive a command string. The following commands are currently supported:
LIST
BIND <TQ_UINT32 'Type ID'>
SERV <TQ_UINT32 'Service ID'>
BIND <StationType 'Type ID'>
SERV <ServiceType 'Service ID'>
QUIT
If an invalid command is specified, the server should respond with a string containing the case-sensitive text "ERRINVCMD".
@ -38,25 +38,23 @@ The expected actions and/or data transmission/reception on receipt of a valid co
LIST:
Returns a list of available laboratory stations
The server should return a TQValueList<StationType>, where StationType consists of the following types for each laboratory station:
TQ_UINT32 Type ID
TQValueList<TQ_UINT32> Service IDs
TQString Description
TQ_UINT32 Total station count of this type
TQ_UINT32 Number of stations of this type in use
<this is still in flux, see tqtrla.h for current data structure(s)>
Descriptions should be constructed from station service type flags as known to the master server, and multiple stations with identical resources should be consolidated to one type ID and description. Type IDs do not need to be universally unique, but must remain constant for a given connection after a LIST command. Subsequent commands may alter the Type ID mappings.
Descriptions should be constructed from station service type flags as known to the master server, and multiple stations with identical resources should be consolidated to one station type ID and description. Station type IDs do not need to be universally unique, but must not conflict with other station type IDs. Subsequent commands may alter the station type ID mappings.
BIND <TQ_UINT32 'Type ID'>:
BIND <StationType 'Type ID'>:
Connects to a specified laboratory station
If a station with the specified Type ID is available, the server must mark that station as in use by the authenticated user, must return the case-sensitive text "OK", and should block all commands other than QUIT. If a station with the specified Type ID is not available, the server must respond with a string containing the case-sensitive text "ERRUNAVAL" and must re-enter command mode.
If a station with the specified Service ID list is available, the server must mark that station as in use by the authenticated user, must return the case-sensitive text "OK", and should block all commands other than QUIT. If a station with the specified Service ID list is not available, the server must respond with a string containing the case-sensitive text "ERRUNAVAL" and must re-enter command mode.
Example: BIND 5
Example: BIND
StationType
SERV <TQ_UINT32 'Service ID'>
Requests a connection to the specified backend server on the laboratory station
If BIND was previously commanded on this connection, the server must respond with a string containing the case-sensitive text "ERRINVCMD". If no station has been reserved for this user via a call to BIND on an active connection, the server must respond with a string containing the case-sensitive text "ERRNOCONN". If the backend server is not available, i.e. a connection attempt or attempts have failed to establish a connection, the server should respond with the string "ERRNOTAVL" and must close the client connection. Otherwise, the server must return a string containing the case-sensitive text "OK" and then immediately enter binary pass-through mode between the backend server and the client.
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_criticalSection>0){
throwexit_exception(-1);
}
@ -85,15 +118,92 @@ int AuthSocket::enterCommandLoop() {
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);
deletem_database;
m_database=NULL;
return-1;
}
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);
deletem_database;
m_database=NULL;
return-1;
}
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);
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);
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);
deletem_database;
m_database=NULL;
return-1;
}
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);