Reuse existing reserved session if present on card insertion

pull/2/head
Timothy Pearson 9 years ago
parent f05cf05bc1
commit cd13be0789

@ -56,6 +56,9 @@ void CardWatcher::cryptographicCardInserted(TDECryptographicCardDevice* cdevice)
DM dm; DM dm;
SessList sess; SessList sess;
bool user_active = false; bool user_active = false;
bool unused_session_available = false;
bool unused_session_active = false;
int unused_session_vt_number = -1;
if (dm.localSessions(sess)) { if (dm.localSessions(sess)) {
TQString user, loc; TQString user, loc;
for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) { for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
@ -63,18 +66,30 @@ void CardWatcher::cryptographicCardInserted(TDECryptographicCardDevice* cdevice)
if (user.startsWith(login_name + ": ")) { if (user.startsWith(login_name + ": ")) {
// Found active session // Found active session
user_active = true; user_active = true;
break;
} }
if (user == "Unused") { if (user == "Unused") {
// Found active unused session
unused_session_available = true;
unused_session_vt_number = (*it).vt;
if ((*it).vt == dm.activeVT()) { if ((*it).vt == dm.activeVT()) {
// Found active unused session unused_session_active = true;
user_active = true; break;
} }
} }
} }
} }
if (!user_active) { if (!user_active || unused_session_available) {
// Activate new VT if (unused_session_available) {
DM().startReserve(); if (!unused_session_active) {
// Switch to unused VT
DM().switchVT(unused_session_vt_number);
}
}
else {
// Activate new VT
DM().startReserve();
}
} }
} }
} }

Loading…
Cancel
Save