All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] client: Extend client proxy object's API
@ 2019-12-05 21:52 Tim Kourt
  2019-12-05 21:52 ` [PATCH 2/4] client: Add start/stop ops to agent manager proxy Tim Kourt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tim Kourt @ 2019-12-05 21:52 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

Add Start/Stop operations to the client proxy objects. The framework
invokes these operations right after the proxy objects are created
or just before the are destroyed, so proxy objects can perform the
needed actions like start/stop a service, etc. if they choose to
implement these ops.
---
 client/dbus-proxy.c | 16 ++++++++++++++++
 client/dbus-proxy.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c
index badd36a3..70b63686 100644
--- a/client/dbus-proxy.c
+++ b/client/dbus-proxy.c
@@ -555,6 +555,19 @@ static void proxy_interface_create(const char *path,
 		}
 
 		l_queue_push_tail(proxy_interfaces, proxy);
+
+		if (!interface_type->ops || !interface_type->ops->start)
+			continue;
+
+		if (interface_type->ops->start(proxy))
+			continue;
+
+		if (!command_is_interactive_mode())
+			command_set_exit_status(EXIT_FAILURE);
+
+		l_main_quit();
+
+		return;
 	}
 }
 
@@ -562,6 +575,9 @@ static void proxy_interface_destroy(void *data)
 {
 	struct proxy_interface *proxy = data;
 
+	if (proxy->type->ops && proxy->type->ops->stop)
+		proxy->type->ops->stop(proxy);
+
 	l_free(proxy->path);
 
 	if (proxy->type->ops && proxy->type->ops->destroy)
diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
index a3304848..e6b6f8c0 100644
--- a/client/dbus-proxy.h
+++ b/client/dbus-proxy.h
@@ -50,6 +50,8 @@ struct proxy_interface_property {
 struct proxy_interface_type_ops {
 	void *(*create)(void);
 	void (*destroy)(void *data);
+	bool (*start)(const struct proxy_interface *proxy);
+	void (*stop)(const struct proxy_interface *proxy);
 	const char *(*identity)(void *data);
 	void (*display)(const char *margin, const void *data);
 };
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-05 21:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-05 21:52 [PATCH 1/4] client: Extend client proxy object's API Tim Kourt
2019-12-05 21:52 ` [PATCH 2/4] client: Add start/stop ops to agent manager proxy Tim Kourt
2019-12-05 21:52 ` [PATCH 3/4] client: Remove explicit agent registartion from framework Tim Kourt
2019-12-05 21:52 ` [PATCH 4/4] client: Use full include path for local includes Tim Kourt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.