diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-18 10:06:27 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-18 10:06:27 -0500 |
commit | 9178fa8161fa97247a4b660e0eaa5c1a763969d6 (patch) | |
tree | d649d7ddd0abae8f7c54eb7282dc2b0a0c202a62 /servers/admin_sys_ctl_server_lin/src | |
parent | b140795f1f54f64dc704f9e3055b00d4aee20c3c (diff) | |
download | ulab-9178fa8161fa97247a4b660e0eaa5c1a763969d6.tar.gz ulab-9178fa8161fa97247a4b660e0eaa5c1a763969d6.zip |
Add logout timer to remote server and client
Diffstat (limited to 'servers/admin_sys_ctl_server_lin/src')
-rw-r--r-- | servers/admin_sys_ctl_server_lin/src/admin_sys_ctl.cpp | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/servers/admin_sys_ctl_server_lin/src/admin_sys_ctl.cpp b/servers/admin_sys_ctl_server_lin/src/admin_sys_ctl.cpp index 3cce4b5..f0cf958 100644 --- a/servers/admin_sys_ctl_server_lin/src/admin_sys_ctl.cpp +++ b/servers/admin_sys_ctl_server_lin/src/admin_sys_ctl.cpp @@ -181,6 +181,8 @@ void SysCtlSocket::commandLoop() { ds >> subCommand; if (subCommand == "TERMINALS") { clearFrameTail(); + ds << TQString("OK"); + writeEndOfFrame(); TQSqlCursor databaseActivityCursor("sessions", TRUE, m_terminals_database); databaseActivityCursor.select(); while (databaseActivityCursor.next()) { @@ -205,6 +207,8 @@ void SysCtlSocket::commandLoop() { } else if (subCommand == "WORKSPACES") { clearFrameTail(); + ds << TQString("OK"); + writeEndOfFrame(); TQSqlCursor databaseActivityCursor("activity", TRUE, m_workspaces_database); databaseActivityCursor.select(); while (databaseActivityCursor.next()) { @@ -224,6 +228,8 @@ void SysCtlSocket::commandLoop() { } else { clearFrameTail(); + ds << TQString("ERRINVCMD"); + writeEndOfFrame(); } } else if (command == "SESSION") { @@ -235,22 +241,69 @@ void SysCtlSocket::commandLoop() { TQ_UINT32 delay; ds >> delay; clearFrameTail(); - // FIXME + // FIXME UNIMPLEMENTED + ds << TQString("ERRINVCMD"); + writeEndOfFrame(); } else if (subCommand == "CANCEL_LOGOFF_TERMINAL") { clearFrameTail(); - // FIXME + // FIXME UNIMPLEMENTED + ds << TQString("ERRINVCMD"); + writeEndOfFrame(); } else if (subCommand == "KILL_TERMINAL") { clearFrameTail(); - // FIXME + TQSqlCursor databaseActivityCursor("sessions", TRUE, m_terminals_database); + databaseActivityCursor.select(TQString("pk=%1").arg(sessionID)); + if (databaseActivityCursor.next()) { + // Gather server information + TQString server_name = databaseActivityCursor.value("servername").toString(); + int server_pid = databaseActivityCursor.value("server_pid").toInt(); + // Kill server process + TQString command = TQString("ssh root@%1 'kill -9 %2'").arg(server_name).arg(server_pid); + if (system(command.ascii()) == 0) { + // Remove database entry + databaseActivityCursor.select(TQString("pk=%1").arg(sessionID)); + if (databaseActivityCursor.next()) { + databaseActivityCursor.primeDelete(); + databaseActivityCursor.del(true); + } + ds << TQString("OK"); + } + else { + ds << TQString("ERRFAILED"); + } + writeEndOfFrame(); + } + else { + ds << TQString("ERRINVCMD"); + } + writeEndOfFrame(); } else if (subCommand == "KILL_WORKSPACE") { clearFrameTail(); - // FIXME + TQSqlCursor databaseActivityCursor("activity", TRUE, m_workspaces_database); + databaseActivityCursor.select(TQString("pk=%1").arg(sessionID)); + if (databaseActivityCursor.next()) { + databaseActivityCursor.select(TQString("pk=%1").arg(sessionID)); + if (databaseActivityCursor.next()) { + TQSqlRecord *buffer = databaseActivityCursor.primeUpdate(); + buffer->setValue("terminate", true); + databaseActivityCursor.update(); + } + + ds << TQString("OK"); + writeEndOfFrame(); + } + else { + ds << TQString("ERRINVCMD"); + } + writeEndOfFrame(); } else { clearFrameTail(); + ds << TQString("ERRINVCMD"); + writeEndOfFrame(); } } else { |