diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-07-28 12:24:45 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-01 13:54:57 +0200 |
commit | 08fa8c559b42fb07bdadd62369802c348b896607 (patch) | |
tree | 7a94fe1810d7468ccc5b4d82ecbc549dd0b6c933 /NitrokeyManager.cc | |
parent | bdb25a0c1feb5709d718f408d6c839dbc9b55738 (diff) | |
download | libnitrokey-08fa8c559b42fb07bdadd62369802c348b896607.tar.gz libnitrokey-08fa8c559b42fb07bdadd62369802c348b896607.tar.bz2 |
Choose device model during connection
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index caf9724..3697369 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -36,8 +36,17 @@ namespace nitrokey{ } NitrokeyManager::~NitrokeyManager() {delete _instance; delete device;} - bool NitrokeyManager::connect() { - device = new Stick10(); + bool NitrokeyManager::connect(const char *device_model) { + switch (device_model[0]){ + case 'P': + device = new Stick10(); + break; + case 'S': + device = new Stick20(); + break; + default: + throw std::runtime_error("Unknown model"); + } return device->connect(); } |