aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 162ad93..f2518b1 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -171,10 +171,14 @@ using nitrokey::misc::strcpyT;
std::lock_guard<std::mutex> lock(mex_dev_com_manager);
auto position = connected_devices_byID.find(id);
- if (position == connected_devices_byID.end()) return false;
+ if (position == connected_devices_byID.end()) {
+ LOGD1(std::string("Could not find device ")+id);
+ return false;
+ }
auto d = connected_devices_byID[id];
device = d;
+ current_device_id = id;
//validate connection
try{
@@ -185,10 +189,13 @@ using nitrokey::misc::strcpyT;
}
catch (const DeviceCommunicationException &){
d->disconnect();
+ current_device_id = "";
connected_devices_byID[id] = nullptr;
connected_devices_byID.erase(position);
return false;
}
+ nitrokey::log::Log::setPrefix(id);
+ LOGD1("Device successfully changed");
return true;
}
@@ -221,6 +228,9 @@ using nitrokey::misc::strcpyT;
}
device = p; //previous device will be disconnected automatically
+ current_device_id = path;
+ nitrokey::log::Log::setPrefix(path);
+ LOGD1("Device successfully changed");
return true;
}
@@ -1105,5 +1115,9 @@ using nitrokey::misc::strcpyT;
return data.data().SD_Card_Size_u8;
}
+ const string NitrokeyManager::get_current_device_id() const {
+ return current_device_id;
+ }
+
}