summaryrefslogtreecommitdiffstats
path: root/tdm/cryptocardwatcher
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2015-09-24 21:27:20 -0500
committerTimothy Pearson <[email protected]>2015-09-24 21:27:20 -0500
commitcd13be0789411619698e3d5d8483b85ca1bad7c0 (patch)
treee5ecfc2b0337d35a736118e743bb6e1b3aa92741 /tdm/cryptocardwatcher
parentf05cf05bc1de0320fa95c999df3a00bacf05e0c9 (diff)
downloadtdebase-cd13be0789411619698e3d5d8483b85ca1bad7c0.tar.gz
tdebase-cd13be0789411619698e3d5d8483b85ca1bad7c0.zip
Reuse existing reserved session if present on card insertion
Diffstat (limited to 'tdm/cryptocardwatcher')
-rw-r--r--tdm/cryptocardwatcher/watcher.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/tdm/cryptocardwatcher/watcher.cc b/tdm/cryptocardwatcher/watcher.cc
index e25821183..021f59949 100644
--- a/tdm/cryptocardwatcher/watcher.cc
+++ b/tdm/cryptocardwatcher/watcher.cc
@@ -56,6 +56,9 @@ void CardWatcher::cryptographicCardInserted(TDECryptographicCardDevice* cdevice)
DM dm;
SessList sess;
bool user_active = false;
+ bool unused_session_available = false;
+ bool unused_session_active = false;
+ int unused_session_vt_number = -1;
if (dm.localSessions(sess)) {
TQString user, loc;
for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
@@ -63,18 +66,30 @@ void CardWatcher::cryptographicCardInserted(TDECryptographicCardDevice* cdevice)
if (user.startsWith(login_name + ": ")) {
// Found active session
user_active = true;
+ break;
}
if (user == "Unused") {
+ // Found active unused session
+ unused_session_available = true;
+ unused_session_vt_number = (*it).vt;
if ((*it).vt == dm.activeVT()) {
- // Found active unused session
- user_active = true;
+ unused_session_active = true;
+ break;
}
}
}
}
- if (!user_active) {
- // Activate new VT
- DM().startReserve();
+ if (!user_active || unused_session_available) {
+ if (unused_session_available) {
+ if (!unused_session_active) {
+ // Switch to unused VT
+ DM().switchVT(unused_session_vt_number);
+ }
+ }
+ else {
+ // Activate new VT
+ DM().startReserve();
+ }
}
}
}