aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-03-01 11:29:57 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-03-01 11:35:00 +0100
commitf5da7b4cbd508faef38fcdfff659fab5c4649838 (patch)
tree3d5a3bd22235468cde6a28cc9346691b2b52323c
parente6fc0cce3937b458179bed8648825f9f047a68d8 (diff)
downloadlibnitrokey-f5da7b4cbd508faef38fcdfff659fab5c4649838.tar.gz
libnitrokey-f5da7b4cbd508faef38fcdfff659fab5c4649838.tar.bz2
Minor cleanup
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--NitrokeyManager.cc12
-rw-r--r--include/NitrokeyManager.h7
2 files changed, 11 insertions, 8 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index fa69ac6..e5f10df 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -142,7 +142,8 @@ using nitrokey::misc::strcpyT;
const auto status = get_status_storage();
const auto sc_id = toHex(status.ActiveSmartCardID_u32);
const auto sd_id = toHex(status.ActiveSD_CardID_u32);
- id = sc_id + ":" + sd_id + "_p_" + p;
+ id += sc_id + ":" + sd_id;
+ id += "_p_" + p;
}
catch (const LongOperationInProgressException &e) {
LOGD1(std::string("Long operation in progress, setting ID to: ") + p);
@@ -162,18 +163,13 @@ using nitrokey::misc::strcpyT;
}
return res;
}
-/**
- * Connect to the device using unique smartcard:datacard id.
- * Needs list_device_by_cpuID run first
- * @param id
- * @return
- */
+
bool NitrokeyManager::connect_with_ID(const std::string id) {
std::lock_guard<std::mutex> lock(mex_dev_com_manager);
auto position = connected_devices_byID.find(id);
if (position == connected_devices_byID.end()) {
- LOGD1(std::string("Could not find device ")+id);
+ LOGD1(std::string("Could not find device ")+id + ". Refresh devices list with list_devices_by_cpuID().");
return false;
}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 5a76616..ca58d24 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -70,6 +70,13 @@ char * strndup(const char* str, size_t maxlen);
bool erase_hotp_slot(uint8_t slot_number, const char *temporary_password);
std::vector<std::string> list_devices();
std::vector<std::string> list_devices_by_cpuID();
+
+ /**
+ * Connect to the device using unique smartcard:datacard id.
+ * Needs list_device_by_cpuID() run first
+ * @param id Current ID of the target device
+ * @return true on success, false on failure
+ */
bool connect_with_ID(const std::string id);
bool connect_with_path (std::string path);
bool connect(const char *device_model);