Skip to content

Commit

Permalink
Device model name propagated from zeroconf to proto handlers, for quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpevzner committed Jun 1, 2024
1 parent 67a35b1 commit 690c25c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions airscan-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ device_new (zeroconf_devinfo *devinfo)
log_debug(dev->log, "device created");

dev->proto_ctx.log = dev->log;
dev->proto_ctx.devinfo = dev->devinfo;
dev->proto_ctx.devcaps = &dev->opt.caps;

devopt_init(&dev->opt);
Expand Down
5 changes: 5 additions & 0 deletions airscan-zeroconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,9 @@ zeroconf_parse_devinfo_from_ident(const char *ident)
devinfo = mem_new(zeroconf_devinfo, 1);
devinfo->ident = str_dup(ident);
devinfo->name = str_dup(name);
devinfo->model = str_dup("");
devinfo->endpoints = zeroconf_endpoint_new(proto, uri);

return devinfo;
}

Expand Down Expand Up @@ -1349,9 +1351,11 @@ zeroconf_devinfo_lookup (const char *ident)
if (dev_conf != NULL) {
http_uri *uri = http_uri_clone(dev_conf->uri);
devinfo->name = str_dup(dev_conf->name);
devinfo->model = str_dup("");
devinfo->endpoints = zeroconf_endpoint_new(dev_conf->proto, uri);
} else {
devinfo->name = str_dup(zeroconf_device_name(device));
devinfo->model = str_dup(device->model ? device->model : "");
devinfo->endpoints = zeroconf_device_endpoints(device, proto);
}

Expand All @@ -1365,6 +1369,7 @@ zeroconf_devinfo_free (zeroconf_devinfo *devinfo)
{
mem_free((char*) devinfo->ident);
mem_free((char*) devinfo->name);
mem_free((char*) devinfo->model);
zeroconf_endpoint_list_free(devinfo->endpoints);
mem_free(devinfo);
}
Expand Down
2 changes: 2 additions & 0 deletions airscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,7 @@ zeroconf_finding_done (ZEROCONF_METHOD method);
typedef struct {
const char *ident; /* Unique ident */
const char *name; /* Human-friendly name */
const char *model; /* Model name, for quirks. "" if unknown */
zeroconf_endpoint *endpoints; /* Device endpoints */
} zeroconf_devinfo;

Expand Down Expand Up @@ -3248,6 +3249,7 @@ typedef struct {
/* Common context */
log_ctx *log; /* Logging context */
struct proto_handler *proto; /* Link to proto_handler */
const zeroconf_devinfo *devinfo; /* Device info, from zeroconf */
const devcaps *devcaps; /* Device capabilities */
PROTO_OP op; /* Current operation */
http_client *http; /* HTTP client for sending requests */
Expand Down

0 comments on commit 690c25c

Please sign in to comment.