diff options
| author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-01-31 18:12:31 +0100 | 
|---|---|---|
| committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-03-11 15:41:40 +0100 | 
| commit | 0503db5b47f247568b78504fa781e083e108eab9 (patch) | |
| tree | 6bd756eea3585c8754b0ccedb11c9aeb41e27af6 /include | |
| parent | cb6b2dd65e1f0132353159b83ae05c944d8e62f0 (diff) | |
| download | libnitrokey-0503db5b47f247568b78504fa781e083e108eab9.tar.gz libnitrokey-0503db5b47f247568b78504fa781e083e108eab9.tar.bz2  | |
Pass devices shared pointer to methods instead of ref
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/device_proto.h | 22 | 
1 files changed, 11 insertions, 11 deletions
diff --git a/include/device_proto.h b/include/device_proto.h index 2105f30..ba314f4 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -206,7 +206,7 @@ namespace nitrokey {                bzero(&st, sizeof(st));              } -            static ClearingProxy<ResponsePacket, response_payload> run(device::Device &dev, +            static ClearingProxy<ResponsePacket, response_payload> run(std::shared_ptr<device::Device> dev,                                                                         const command_payload &payload) {                using namespace ::nitrokey::device;                using namespace ::nitrokey::log; @@ -235,22 +235,22 @@ namespace nitrokey {                bool successful_communication = false;                int receiving_retry_counter = 0; -              int sending_retry_counter = dev.get_retry_sending_count(); +              int sending_retry_counter = dev->get_retry_sending_count();                while (sending_retry_counter-- > 0) { -                status = dev.send(&outp); +                status = dev->send(&outp);                  if (status <= 0) -                  throw std::runtime_error( +                  throw DeviceSendingFailure(                        std::string("Device error while sending command ") +                        std::to_string(status)); -                std::this_thread::sleep_for(dev.get_send_receive_delay()); +                std::this_thread::sleep_for(dev->get_send_receive_delay());                  // FIXME make checks done in device:recv here -                receiving_retry_counter = dev.get_retry_receiving_count(); +                receiving_retry_counter = dev->get_retry_receiving_count();                  while (receiving_retry_counter-- > 0) { -                  status = dev.recv(&resp); +                  status = dev->recv(&resp); -                  if (dev.get_device_model() == DeviceModel::STORAGE && +                  if (dev->get_device_model() == DeviceModel::STORAGE &&                        resp.command_id >= stick20::CMD_START_VALUE &&                        resp.command_id < stick20::CMD_END_VALUE ) {                      Log::instance()(std::string("Detected storage device cmd, status: ") + @@ -306,7 +306,7 @@ namespace nitrokey {                        Loglevel::DEBUG);                    Log::instance()("Invalid incoming HID packet:", Loglevel::DEBUG_L2);                    Log::instance()(static_cast<std::string>(resp), Loglevel::DEBUG_L2); -                  std::this_thread::sleep_for(dev.get_retry_timeout()); +                  std::this_thread::sleep_for(dev->get_retry_timeout());                    continue;                  }                  if (successful_communication) break; @@ -315,7 +315,7 @@ namespace nitrokey {                                  Loglevel::DEBUG);                } -              dev.set_last_command_status(resp.last_command_status); // FIXME should be handled on device.recv +              dev->set_last_command_status(resp.last_command_status); // FIXME should be handled on device.recv                clear_packet(outp); @@ -348,7 +348,7 @@ namespace nitrokey {                return resp;              } -            static ClearingProxy<ResponsePacket, response_payload> run(device::Device &dev) { +            static ClearingProxy<ResponsePacket, response_payload> run(std::shared_ptr<device::Device> dev) {                command_payload empty_payload;                return run(dev, empty_payload);              }  | 
