summaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index 8e005b8..56340ac 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -238,6 +238,30 @@ extern "C" {
}
+ NK_C_API bool NK_get_device_model(enum NK_device_model *out) {
+ if (out == nullptr) {
+ return false;
+ }
+ auto m = NitrokeyManager::instance();
+ try {
+ auto model = m->get_connected_device_model();
+ switch (model) {
+ case DeviceModel::PRO:
+ *out = NK_PRO;
+ return true;
+ case DeviceModel::STORAGE:
+ *out = NK_STORAGE;
+ return true;
+ default:
+ /* unknown device -- should not happen */
+ return false;
+ }
+ } catch (const DeviceNotConnected& e) {
+ return false;
+ }
+ }
+
+
void clear_string(std::string &s) {
std::fill(s.begin(), s.end(), ' ');
}