Add new dynamic destination APIs #3924

Closed
michaelrsweet opened this Issue Aug 17, 2011 · 2 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Aug 17, 2011

Version: 1.6-feature
CUPS.org User: mike

Add new APIs to libcups for a dynamic destination interface, basically something that will start or stop a discovery/enumeration thread that calls a function (or block) when a destination is added or removed. The existing cupsGetDests API would be updated accordingly to use this with a shared cache of destinations.

The API should be extensible to support alternate protocols, but the initial focus should be on Bonjour discovery.

Collaborator

michaelrsweet commented Jan 13, 2012

CUPS.org User: mike

Doing development on the cups-api-1.6...

/* Flags for the destination functions/blocks */

#define CUPS_DEST_FLAGS_NONE 0
#define CUPS_DEST_FLAGS_UNCONNECTED 1
#define CUPS_DEST_FLAGS_MORE 2
#define CUPS_DEST_FLAGS_REMOVED 4

/* Callback and block signatures */

typedef int (*cups_dest_cb_t)(void *user_data, unsigned flags, cups_dest_t *dest);
typedef int (^cups_dest_block_t)(unsigned flags, cups_dest_t *dest);

/* Connect to the destination, returning a new http_t connection object and
optionally the resource path to use for the destination. These calls will
block until a connection is made, the timeout expires, the integer pointed
to by "cancel" is non-zero, or the callback function (or block) returns 0,
The caller is responsible for calling httpClose() on the returned object. */

http_t *cupsConnectDest(cups_dest_t *dest,
unsigned flags, int timeout, int *cancel,
char *resource, size_t resourcesize,
cups_dest_cb_t cb, void *user_data);
http_t *cupsConnectDestBlock(cups_dest_t *dest,
unsigned flags, int timeout, int *cancel,
char *resource, size_t resourcesize,
cups_dest_block_t block);

/* Make a copy of the destination to an array of destinations (or just a single
copy) - for use with the cupsEnumDests* functions. The caller is responsible
for calling cupsFreeDests() on the returned object(s). */

int cupsCopyDest(cups_dest_t _dest, int num_dests, cups_dest_t *_dests);

/* Enumerate local and network (Bonjour/LDAP/etc.) destinations, calling the
function or block for every destination that is added or removed. These calls
will block until the timeout expires, the integer pointed to by "cancel" is
non-zero, or the callback function (or block) returns 0, Destinations are
filtered using the 'type' and 'mask' arguments, e.g. to only enumerate color
printers with duplex printing capabilities. */
*/

int cupsEnumDests(unsigned flags, int timeout, int *cancel,
cups_printer_t type, cups_printer_t mask,
cups_dest_cb_t cb, void *user_data);
int cupsEnumDestsBlock(unsigned flags, int timeout, int *cancel,
cups_printer_t type, cups_printer_t mask,
cups_dest_block_t block);

Collaborator

michaelrsweet commented Jan 19, 2012

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment