From 690c25c2914c9824b815d1c6f4189685b3ceea4c Mon Sep 17 00:00:00 2001 From: Alexander Pevzner Date: Sat, 1 Jun 2024 12:02:58 +0300 Subject: [PATCH] Device model name propagated from zeroconf to proto handlers, for quirks --- airscan-device.c | 1 + airscan-zeroconf.c | 5 +++++ airscan.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/airscan-device.c b/airscan-device.c index 60d0be1..04919bc 100644 --- a/airscan-device.c +++ b/airscan-device.c @@ -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); diff --git a/airscan-zeroconf.c b/airscan-zeroconf.c index 2095021..a77a19c 100644 --- a/airscan-zeroconf.c +++ b/airscan-zeroconf.c @@ -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; } @@ -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); } @@ -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); } diff --git a/airscan.h b/airscan.h index 173e6f5..9c2fe66 100644 --- a/airscan.h +++ b/airscan.h @@ -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; @@ -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 */