Add support for querying the available built-in transports
Because the list of supported built-in transports depends on the availability of external libraries (libusb, hidapi) and the operating system, the application needs some mechanism to retrieve this information at runtime. Therefore, a new dc_context_get_transports() function is added, which returns a bitmask with all the available built-in transports.
This commit is contained in:
parent
eed993fd16
commit
aee59a33be
@ -53,6 +53,9 @@ dc_context_set_loglevel (dc_context_t *context, dc_loglevel_t loglevel);
|
|||||||
dc_status_t
|
dc_status_t
|
||||||
dc_context_set_logfunc (dc_context_t *context, dc_logfunc_t logfunc, void *userdata);
|
dc_context_set_logfunc (dc_context_t *context, dc_logfunc_t logfunc, void *userdata);
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
dc_context_get_transports (dc_context_t *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@ -19,6 +19,10 @@
|
|||||||
* MA 02110-1301 USA
|
* MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -313,3 +317,35 @@ dc_context_hexdump (dc_context_t *context, dc_loglevel_t loglevel, const char *f
|
|||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
dc_context_get_transports (dc_context_t *context)
|
||||||
|
{
|
||||||
|
UNUSED(context);
|
||||||
|
|
||||||
|
return DC_TRANSPORT_SERIAL
|
||||||
|
#if defined(HAVE_LIBUSB)
|
||||||
|
| DC_TRANSPORT_USB
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_HIDAPI)
|
||||||
|
| DC_TRANSPORT_USBHID
|
||||||
|
#elif defined(HAVE_LIBUSB) && !defined(__APPLE__)
|
||||||
|
| DC_TRANSPORT_USBHID
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef HAVE_AF_IRDA_H
|
||||||
|
| DC_TRANSPORT_IRDA
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WS2BTH_H
|
||||||
|
| DC_TRANSPORT_BLUETOOTH
|
||||||
|
#endif
|
||||||
|
#else /* _WIN32 */
|
||||||
|
#ifdef HAVE_LINUX_IRDA_H
|
||||||
|
| DC_TRANSPORT_IRDA
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_BLUEZ
|
||||||
|
| DC_TRANSPORT_BLUETOOTH
|
||||||
|
#endif
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ dc_context_new
|
|||||||
dc_context_free
|
dc_context_free
|
||||||
dc_context_set_loglevel
|
dc_context_set_loglevel
|
||||||
dc_context_set_logfunc
|
dc_context_set_logfunc
|
||||||
|
dc_context_get_transports
|
||||||
|
|
||||||
dc_iterator_next
|
dc_iterator_next
|
||||||
dc_iterator_free
|
dc_iterator_free
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user