scmApi.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <boost/function.hpp>
6 #include <boost/system/error_code.hpp>
7 #include <boost/shared_ptr.hpp>
8 #include "scmTypes.h"
9 
10 class SCMClient;
11 
12 //To avoid redefinition in client and app
13 #ifndef SCM_TYPES
14 #define SCM_TYPES
15 
21 namespace dpySCM {
22 
27 typedef boost::function<void(const bool &available)> service_availability_handler;
28 
37 typedef boost::function<void(boost::system::error_code& ec, const dpySCM::Device& rDevice)> get_devices_handler_function;
38 typedef boost::function<void(boost::system::error_code& ec, const dpySCM::DeviceReaderList& rReader)> get_readers_handler_function;
39 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId, dpySCM::CardEvent cardEvent)> handler_cardEvent_function;
40 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceChargeResult deviceChargeResult)> handler_device_charge_result_function;
41 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId, dpySCM::Event deviceEvent)> handler_deviceListEvent_function;
42 typedef boost::function<void(boost::system::error_code& ec)> confirmation_handler_function;
43 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceKeys deviceKeys)> get_keys_handler_function;
44 typedef boost::function<void(boost::system::error_code& ec, dpySCM::TransactionDevice TransactionDevice)> card_operation_handler_function;
45 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePassThrough devicePassThrough)> pass_through_operation_handler_function;
46 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceVersion& deviceVersion)> device_version_handler_function;
47 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePaymentAppInfo& devicePaymentAppInfo)> device_payment_app_info_function;
48 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceMediaProfiles& deviceMediaProfiles)> device_media_profiles_function;
49 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceUpgradeStatus& deviceUpgradeStatus)> upgrade_status_events_function;
50 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId)> force_device_upgrade_function;
51 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePciRebootTime& devicePciRebootTime)> reboot_time_handler_function;
52 typedef boost::function<void(boost::system::error_code& ec, dpySCM::UltraLightCounter& ulCounter)> ultralight_counter_handler_function;
53 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceNetworkConfiguration& deviceNetworkConfiguration)> device_network_configuration_handler_function;
54 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePaymentAppConfiguration& devicePaymentAppConf)> device_payment_app_conf_function;
55 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceDateTime& dateTime)> device_date_time_handler_function;
56 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceNetworkStatus& deviceNetworkStatus)> network_status_handler_function;
57 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId, dpySCM::LoggingConfiguration& loggingConfiguration)> get_logging_configuration_handler_function;
58 
59 } //dpySCM
60 
61 #endif
62 
67 {
68 public:
75  virtual void newSmartCard(boost::system::error_code& ec, const std::string& deviceId, dpySCM::CardEvent cardEvent) = 0;
81  virtual void chargeResult(boost::system::error_code& ec, dpySCM::DeviceChargeResult deviceChargeResult) = 0;
85  virtual ~IsmartCardReaderObserver() = default;
86 };
87 
92 {
93 public:
94 
100  virtual void notifyPciReboot(boost::system::error_code& ec, dpySCM::DevicePciRebootTime& devicePciRebootTime) = 0;
101 
107  virtual void newUpgradeStatus(boost::system::error_code& ec, dpySCM::DeviceUpgradeStatus& deviceUpgradeStatus) = 0;
108 
112  virtual ~IsmartCardDeviceObserver() = default;
113 
114 };
115 
120 {
121 public:
128  virtual void deviceListEvent(boost::system::error_code& ec, const std::string& deviceId, dpySCM::Event deviceEvent) = 0;
132  virtual ~IsmartCardDeviceListObserver() = default;
133 };
134 
135 
141 class SCM
142 {
143 private:
144 
148  boost::shared_ptr<SCMClient> mClient;
149 
150  std::vector<IsmartCardDeviceListObserver*> observersDeviceListObserver;
151  std::vector<IsmartCardDeviceObserver*> observersDeviceObserver;
152  std::vector<IsmartCardReaderObserver*> observersReaderObserver;
153  boost::system::error_code operateData(dpySCM::OperationType opType, std::string deviceId, std::string uid, std::list<dpySCM::Data> &contents);
154  boost::system::error_code operateDataBlock(dpySCM::OperationType opType, std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
155 
156 public:
157 
158  explicit SCM(std::string ip = "127.0.0.1");
159  ~SCM();
160  bool isAlive();
161  void monitorServiceAvailability_S(dpySCM::service_availability_handler handler);
162  void monitorServiceAvailability_U();
163 
166  void asyncGetDevices(dpySCM::get_devices_handler_function handler);
168  boost::system::error_code getDevices(dpySCM::Device& rDevice);
169  void deviceListEvent_S(dpySCM::handler_deviceListEvent_function handler);
170  void deviceListEvent_U();
171  void asyncGetReaders(std::string deviceId,dpySCM::get_readers_handler_function handler);
172  void asyncGetVersion(std::string deviceId, dpySCM::device_version_handler_function handler);
173  void newCardEvent_S(dpySCM::handler_cardEvent_function handler);
174  void newCardEvent_U();
175  void asyncAddKeys(dpySCM::DeviceKeys keyGroup, dpySCM::confirmation_handler_function handler);
176  void asyncAddKeys(std::string deviceId, std::string json, dpySCM::confirmation_handler_function handler);
177  void asyncGetKeys(std::string deviceId, dpySCM::get_keys_handler_function handler);
178  void asyncRemoveKeys(std::string deviceId, dpySCM::confirmation_handler_function handler);
179  void upgradeStatus_S(dpySCM::upgrade_status_events_function handler);
180  void upgradeStatus_U();
181  void asyncForceDeviceUpgrade(std::string deviceId,dpySCM::force_device_upgrade_function handler);
183 
184  // Device list observer
185  boost::system::error_code subscribeDeviceListEvent(IsmartCardDeviceListObserver *observer);
186  boost::system::error_code unsubscribeDeviceListEvent(IsmartCardDeviceListObserver *observer);
187  // Device observer
188  boost::system::error_code subscribeDeviceEvent(IsmartCardDeviceObserver *observer);
189  boost::system::error_code unsubscribeDeviceEvent(IsmartCardDeviceObserver *observer);
190  // Reader observer
191  boost::system::error_code subscribeReaderEvent(IsmartCardReaderObserver *observer);
192  boost::system::error_code unsubscribeReaderEvent(IsmartCardReaderObserver *observer);
193 
197  void asyncCardOperation(dpySCM::TransactionDevice operationDevice, dpySCM::card_operation_handler_function handler);
199  void asyncPassThrough(dpySCM::DevicePassThrough devicePassThrough, dpySCM::pass_through_operation_handler_function handler);
200  void asyncGetULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter, dpySCM::ultralight_counter_handler_function handler);
201  void asyncIncrementULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter, dpySCM::confirmation_handler_function handler);
202  void asyncResetSamSlot(std::string deviceId, dpySCM::SamSlot slotNumber, dpySCM::confirmation_handler_function handler);
203 
205 
209  boost::system::error_code read(std::string deviceId, std::string uid, std::list<dpySCM::Data>& contents);
211  boost::system::error_code write(std::string deviceId, std::string uid, std::list<dpySCM::Data>& contents);
212  boost::system::error_code apduExchange(std::string deviceId, std::string uid, std::list<dpySCM::ApduTxData>& apduTx, std::list<dpySCM::ApduRxData>& apduRx);
213  boost::system::error_code passThrough(std::string deviceId, dpySCM::PassThrough& passThrough);
214  boost::system::error_code getULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter);
215  boost::system::error_code incrementULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter);
216  boost::system::error_code transferBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
217  boost::system::error_code restoreBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
218  boost::system::error_code incrementOnlyBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
219  boost::system::error_code decrementOnlyBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
220  boost::system::error_code incrementBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
221  boost::system::error_code decrementBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
223 
227  void chargeResultEMV_S(dpySCM::handler_device_charge_result_function handler);
229  void chargeResultEMV_U();
230  void asyncRequestChargeEMV(dpySCM::DeviceRequestCharge requestChargeDevice, dpySCM::confirmation_handler_function handler);
231  void asyncChargeConfirmationEMV(dpySCM::DeviceChargeConfirmation requestChargeConfirmation, dpySCM::confirmation_handler_function handler);
232  void asyncSetPaymentAppStatus(dpySCM::DevicePaymentAppStatus devicePaymentAppStatus, dpySCM::confirmation_handler_function handler);
233  void asyncGetPaymentAppInfo(std::string deviceId, dpySCM::device_payment_app_info_function handler);
234  void asyncGetPaymentAppConf(dpySCM::DevicePaymentAppConfiguration devicePaymentAppConf, dpySCM::device_payment_app_conf_function handler);
235  void asyncSetPaymentAppConf(dpySCM::DevicePaymentAppConfiguration devicePaymentAppConf, dpySCM::confirmation_handler_function handler);
236  void asyncForcePaymentAppComm(std::string deviceId, dpySCM::confirmation_handler_function handler);
238 
242 
244  void asyncPlayProfile(std::string deviceId, std::string profileId, dpySCM::confirmation_handler_function handler);
245  void asyncAddMediaProfiles(std::string deviceId,std::string json, dpySCM::confirmation_handler_function handler);
246  void asyncAddMediaProfiles(dpySCM::DeviceMediaProfiles deviceMediaProfiles, dpySCM::confirmation_handler_function handler);
247  void asyncGetMediaProfiles(std::string deviceId, dpySCM::device_media_profiles_function handler);
248  void asyncRemoveMediaProfiles(std::string deviceId, dpySCM::confirmation_handler_function handler);
250 
253  void pciRebootEvent_S(dpySCM::reboot_time_handler_function handler);
255  void pciRebootEvent_U();
256  void asyncGetPciRebootTime(std::string deviceId, dpySCM::reboot_time_handler_function handler);
257  void asyncSetPciRebootTime(dpySCM::DevicePciRebootTime deviceRebootTime, dpySCM::confirmation_handler_function handler);
258  boost::system::error_code getPciRebootTime(std::string deviceId, dpySCM::DevicePciRebootTime& rebootTime);
259  boost::system::error_code setPciRebootTime(dpySCM::DevicePciRebootTime deviceRebootTime);
261 
265  void asyncGetNetworkConfiguration(std::string deviceId, dpySCM::device_network_configuration_handler_function handler);
267  void asyncSetNetworkConfiguration(dpySCM::DeviceNetworkConfiguration deviceNetworkConfiguration, dpySCM::confirmation_handler_function handler);
269  void asyncGetDateTime(std::string deviceId, dpySCM::device_date_time_handler_function handler);
270  void asyncRebootDevice(std::string deviceId, dpySCM::RebootType rebootType, dpySCM::confirmation_handler_function handler);
271  void asyncTestNetworkConnectivity(dpySCM::DeviceNetworkConnectivity deviceNetworkConnectivity, dpySCM::network_status_handler_function handler);
272  void asyncSetLoggingConfiguration(std::string deviceId, dpySCM::LoggingConfiguration loggingConfiguration, dpySCM::confirmation_handler_function handler);
273  void asyncGetLoggingConfiguration(std::string deviceId, dpySCM::get_logging_configuration_handler_function handler);
274 
275 };
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceNetworkConfiguration &deviceNetworkConfiguration)> device_network_configuration_handler_function
Result of get network configuration.
Definition: scmApi.h:53
Structure for UltraLight counter requests.
Definition: scmTypes.h:640
boost::function< void(boost::system::error_code &ec, dpySCM::TransactionDevice TransactionDevice)> card_operation_handler_function
Result of card operation.
Definition: scmApi.h:44
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceKeys deviceKeys)> get_keys_handler_function
Result of getting keys information.
Definition: scmApi.h:43
All the date related to the device information.
Definition: scmTypes.h:172
The device network configuration.
Definition: scmTypes.h:258
Device payment terminal configuration.
Definition: scmTypes.h:371
Device request of charging.
Definition: scmTypes.h:395
Transaction operation device.
Definition: scmTypes.h:195
Definition: scmApi.h:66
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePaymentAppConfiguration &devicePaymentAppConf)> device_payment_app_conf_function
Result of get device payment application configuration.
Definition: scmApi.h:54
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceDateTime &dateTime)> device_date_time_handler_function
Result of get network configuration.
Definition: scmApi.h:55
boost::function< void(boost::system::error_code &ec, dpySCM::UltraLightCounter &ulCounter)> ultralight_counter_handler_function
Result of getting a ultralight counter value.
Definition: scmApi.h:52
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceChargeResult deviceChargeResult)> handler_device_charge_result_function
Result of device charge EMV result.
Definition: scmApi.h:40
boost::function< void(boost::system::error_code &ec)> confirmation_handler_function
Result of confirmation operation.
Definition: scmApi.h:42
SamSlot
Logging Level values indicating severity of the logs.
Definition: scmTypes.h:715
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePaymentAppInfo &devicePaymentAppInfo)> device_payment_app_info_function
Result of get device payment application info.
Definition: scmApi.h:47
Device pass through.
Definition: scmTypes.h:633
OperationType
Different types of operation.
Definition: scmTypes.h:86
The Logging Configuration to be applied or being applied.
Definition: scmTypes.h:705
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceVersion &deviceVersion)> device_version_handler_function
Result of get version.
Definition: scmApi.h:46
Device charge result.
Definition: scmTypes.h:468
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: scmApi.h:27
Device payment application information.
Definition: scmTypes.h:289
Add Keys.
Definition: scmTypes.h:210
Structure containing information needed to execute a pass through.
Definition: scmTypes.h:625
Device media profiles.
Definition: scmTypes.h:610
Contains the network address to be tested on that device.
Definition: scmTypes.h:667
boost::function< void(boost::system::error_code &ec, const dpySCM::Device &rDevice)> get_devices_handler_function
Handler for status function callback.
Definition: scmApi.h:37
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceUpgradeStatus &deviceUpgradeStatus)> upgrade_status_events_function
Result of every upgrade status event.
Definition: scmApi.h:49
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePciRebootTime &devicePciRebootTime)> reboot_time_handler_function
Result of getting PCI Data Security Standard reboot time.
Definition: scmApi.h:51
boost::function< void(boost::system::error_code &ec, const std::string &deviceId)> force_device_upgrade_function
Result of force device upgrade request.
Definition: scmApi.h:50
Deepsy SCM namespace that includes the different enums, structs or method signatures that should be u...
Definition: scmApi.h:119
Device confirmation charge.
Definition: scmTypes.h:488
RebootType
Reboot type, it defines different reboot types.
Definition: scmTypes.h:660
Event
The type of event related to the smart card.
Definition: scmTypes.h:140
boost::function< void(boost::system::error_code &ec, const std::string &deviceId, dpySCM::Event deviceEvent)> handler_deviceListEvent_function
Result of added/removed device event.
Definition: scmApi.h:41
The kind of event and the card information.
Definition: scmTypes.h:157
boost::function< void(boost::system::error_code &ec, const std::string &deviceId, dpySCM::LoggingConfiguration &loggingConfiguration)> get_logging_configuration_handler_function
Result of getting logging configuration.
Definition: scmApi.h:57
Device PCI Reboot Time.
Definition: scmTypes.h:509
Definition: scmApi.h:91
Allows to interact with a platform manager.
Definition: scmApi.h:141
Interacts with platform manager service.
Definition: scmClient.h:12
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePassThrough devicePassThrough)> pass_through_operation_handler_function
Result of pass through operation.
Definition: scmApi.h:45
boost::function< void(boost::system::error_code &ec, const dpySCM::DeviceReaderList &rReader)> get_readers_handler_function
Result of getting readers information.
Definition: scmApi.h:38
boost::function< void(boost::system::error_code &ec, const std::string &deviceId, dpySCM::CardEvent cardEvent)> handler_cardEvent_function
Result of new card event.
Definition: scmApi.h:39
Device upgrade status.
Definition: scmTypes.h:543
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceNetworkStatus &deviceNetworkStatus)> network_status_handler_function
Result of testing network connectivity.
Definition: scmApi.h:56
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceMediaProfiles &deviceMediaProfiles)> device_media_profiles_function
Result of get media profiles.
Definition: scmApi.h:48