diff mbox series

[07/15] service: Add 'service_set_proxy_method' function.

Message ID 20241212052817.2021264-8-gerickson@nuovations.com (mailing list archive)
State New
Headers show
Series Improve PAC URL Mutation and PAC URL and WISPr Proxy Failure Logging | expand

Commit Message

Grant Erickson Dec. 12, 2024, 5:28 a.m. UTC
Allows for logging, setting, and dispatching property changed
notifications for the network service proxy method and associated URL,
if any, from a single place.
---
 src/service.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox series

Patch

diff --git a/src/service.c b/src/service.c
index 0713520d88a1..e58958635992 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5568,6 +5568,37 @@  const char * const *connman_service_get_timeservers(const struct connman_service
 	return (const char * const *)service->timeservers;
 }
 
+static void service_set_proxy_method(struct connman_service *service,
+			enum connman_service_proxy_method method,
+			bool donotifier,
+			bool (*handler)(struct connman_service *service,
+				enum connman_service_proxy_method method,
+				const void *context),
+			const void *context)
+{
+	DBG("service %p (%s) method %d (%s) donotifier %u "
+		"handler %p, context %p",
+		service, connman_service_get_identifier(service),
+		method, proxymethod2string(method),
+		donotifier,
+		handler,
+		context);
+
+	if (!service || service->hidden)
+		return;
+
+	service->proxy = method;
+
+	if (handler != NULL)
+		if (handler(service, method, context) != true)
+			return;
+
+	proxy_changed(service);
+
+	if (donotifier)
+		__connman_notifier_proxy_changed(service);
+}
+
 /**
  *  @brief
  *    Set the web proxy method of the specified service.