Receives responses from daemon on requests sent via EveusbController.

Pure abstract class.

 

Write an inheriting class with the implementation of methods and pass an instance of this class

to EveusbController::setEventHandler, after that, send requests to the daemon via

EveusbController.


Methods:


 void onError(const std::string &msg);
 long writeToDaemon(const std::string &buf);
 long readFromDaemon(std::vector<char> &buf);

 void onMessage(const std::string &msg, bool incoming);
 void onVersion(const std::string &version);
 void onCompress(const std::string &compress);

 void onLicense(const License &info);
 void onActivation(const Activation &info);
 void onOfflineRequest(const std::string &data);

 void onLoglevel(int level);
 void onShareLimitExceeded(Device &dev, int limit);
 void onLocalDeviceTreeEnumerated();

 void onSharedDevicesEnumerated();
 void onRemoteDevicesEnumerated();
 void onServerFound(const std::string &host);

 void onServerDeviceFound(Device &dev);
 void onServerDevicesEnumerated(const std::string &host);
 void onLocalDeviceInfo(const std::string &devname, const DeviceInfo &info);

 void onLocalAddedRemoved(const std::string &devname, int maxchild, const std::string &name, bool added);
 void onLocalSharedUnshared(Device &dev, bool shared);
 void onLocalAcquiredReleased(Device &dev, bool acquired);

 void onRemoteConnecting(Device &dev);
 void onRemoteConnected(Device &dev);
 void onRemoteReconnecting(Device &dev);

 void onRemoteDisconnecting(Device &dev);
 void onRemoteDisconnected(Device &dev);
 void onRemoteDeleted(Device &dev);


void onError(const std::string &msg);


Notifies about non-critical errors.

There are parse errors, unknown command, bad syntax, etc.

 

Parameters:

 

msg - text of error


long writeToDaemon(const std::string &buf);


Call this method to write buf to socket connection established with daemon.

Example of implementation: return write(fd, buf.data(), buf.size());

 

Parameters:

 

buf - data that needs to be written to socket

 

Return:

 

Return bytes actually transferred or -1 in case of error.

 

Note:

 

See readFromDaemon() to find out why const std::string &buf is used instead of traditional

(const void *buf, size_t len) arguments.


long readFromDaemon(std::vector<char> &buf);


Call this method to read no more than buf.size() bytes into buf from socket connection established with daemon.

 

Example of implementation: return read(fd, &buf[0], buf.size());

 

Parameters:

 

buf - buffer to which data from socket will be written

 

Return:

 

Returns bytes actually transferred or -1 in case of error.

 

Remarks:

 

SWIG forces to use std::vector<char> instead of traditional (void *buf, size_t len) arguments.

The reason is that SWIG automatically passes std::vector<char> to/from target language, you

do not need to write typemaps for every language that you will use.

 

The example of how to deal with (void *buf, size_t len) in Python can be found in SWIG

documentation, Multi-argument typemaps.


void onMessage(const std::string &msg, bool incoming);


Notifies about message received from or sent to the daemon.

Call this method for debug purposes, etc.

 

Parameters:

 

msg - message

incoming - true if message is incoming (from daemon), false if message is outgoing (to daemon)

 

Remarks:

 

You should not parse this message and can ignore it.


void onVersion(const std::string &version);


This method is called after invocation of EveusbController::getVersion

 

Parameters:

 

version - сomma-separated values

the first field - the daemon version in format MAJOR.MINOR.RELEASE.

the second field - version verbose description that includes new line character.


void onCompress(const std::string &compress);


This method is called after invocation of EveusbController::getCompression

 

Parameters:

 

compress - type of compression ("none", "best", "fast")


void onLicense(const License &info);


This method is called after invocation of EveusbController::getLicense

 

Parameters:

 

info - structure that contains information from the license

 

Note:

 

see EveusbController::getLicense()


void onActivation(const Activation &info);


This method is called after invocation of EveusbController::getLicense or

EveusbController::Activate

 

Parameters:

 

info - structure that contains information from the license

error - result of the activation request

online - true if EveusbController::Activate method was called, false in all other cases

 

Note:

 

see EveusbController::getLicense()


void onOfflineRequest(const std::string &data);


This method is called after the invocation of EveusbController::getOfflineRequest

 

Parameters:

 

data - data that should be sent to the activation server to request offline activation

 

Note:

 

see EveusbController::getOfflineRequest()


void onLoglevel(int level);


This method is called if loglevel changed or the current value was requested via getLoglevel.

 

Parameters:

 

level - constants from syslog: LOG_ERR, LOG_WARNING, …


void onShareLimitExceeded(Device &dev, int limit);


This method is called if there was an attempt to share a device that couldn’t be shared due to

license limitations. See EveusbController::localShare

 

Parameters:

 

dev - device you tried to share

limit - max number of devices you can share according to your license


void onLocalDeviceTreeEnumerated();


End of enumeration notifications (no more devices left).

See EveusbController::enumLocalDeviceTree


void onSharedDevicesEnumerated();


End of enumeration notifications (no more devices left).

See EveusbController::enumSharedDevices


void onRemoteDevicesEnumerated();


End of enumeration notifications (no more devices left).

See EveusbController::enumRemoteDevices


void onServerFound(const std::string &host);


Server or devices search notifications. See EveusbController::findServers

 

Parameters:

 

host - address of the detected host


void onServerDeviceFound(Device &dev);


Server or devices search notifications. See EveusbController::findServerDevices

 

Parameters:

 

dev - object corresponding to device found. This object can be used to perform actions on the

device (connect, disconnect, etc.)


void onServerDevicesEnumerated(const std::string &host);


Server or devices search notifications. End of enumeration notifications (no more devices left).

See EveusbController::findServerDevices

 

Parameters:

 

host - address of host for which devices were found


void onLocalDeviceInfo(const std::string &devname, const DeviceInfo &info);


Local device notifications. See EveusbController::enumLocalDeviceTree

 

Parameters:

 

devname - sys name of device (unique USB device identifier obtained from kernel:

hub-port[.port ...])

info - structure that contains information about device (see above)


void onLocalAddedRemoved(const std::string &devname, int maxchild, const std::string &name, bool added);


Local device notifications. This method is called if list of local devices changed (device was

plugged into a USB port/unplugged)

 

Parameters:

 

devname - sys name of device (unique USB device identifier obtained from kernel: hub-port[.port ...])

maxchild - number of hub ports (= 0 for USB devices, > 0 for hubs)

name - device name

added - true if device was connected to a USB port, false if device was disconnected


void onLocalSharedUnshared(Device &dev, bool shared);


Local device notifications. This method is called after invocation of

EveusbController::localShare, EveusbController::enumSharedDevices

 

Parameters:

 

dev - object corresponding to device which was shared or unshared. You can use it to perform actions on the device (share, unshare, etc.)

 

shared - true if the device was shared, false if it was unshared


void onLocalAcquiredReleased(Device &dev, bool acquired);


Local device notifications. This method is called if client connects to shared device. See

EveusbController::enumSharedDevices

 

Parameters:

 

dev - object corresponding to shared device. You can use it to perform actions on the device

(share, unshare, etc.)

 

acquired - true if client was connected to the device, false if it was disconnected


void onRemoteConnecting(Device &dev);


Remote device notifications. This method is called when you’re trying to connect to a remote device.

 

See EveusbController::remoteConnect, EveusbController::enumRemoteDevices

 

Parameters:

 

dev - object corresponding to device you’re trying to connect to. You can use it to perform actions on the device (connect, disconnect, etc.)


void onRemoteConnected(Device &dev);


Remote device notifications. This method is called after connecting to a remote device.

See EveusbController::remoteConnect, EveusbController::enumRemoteDevices

 

Parameters:

 

dev - object corresponding to device you connected to. You can use it to perform actions on the

device (connect, disconnect, etc.)


void onRemoteReconnecting(Device &dev);


Remote device notifications. This method is called when reconnecting to a remote device after failure.

 

See EveusbController::enumRemoteDevices

 

Parameters:

 

dev - object corresponding to device you’re trying to reconnect to. You can use it to perform operations on the device (cvoid onError(const std::string &msg);onnect, disconnect, etc.)


void onRemoteDisconnecting(Device &dev);


Remote device notifications. This method is called when disconnecting from a remote device.

See EveusbController::remoteDisconnect, EveusbController::enumRemoteDevices

 

Parameters:

 

dev - object corresponding to device which is going to be disconnected. You can use it to perform actions on the device (connect, disconnect, etc.)


void onRemoteDisconnected(Device &dev);


Remote device notifications. This method is called after disconnecting from a remote device.

 

See EveusbController::remoteDisconnect, EveusbController::enumRemoteDevices

 

Parameters:

 

dev - object corresponding to disconnected device. You can use it to perform actions on the device (connect, disconnect, etc.)


void onRemoteDeleted(Device &dev);


Remote device notifications. This method is called if the remote device is not on the list any more.

 

See EveusbController::remoteDelete

 

Parameters:

 

dev - object corresponding to remote device