All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 1/4] client: Extend client proxy object's API
Date: Thu, 05 Dec 2019 13:52:38 -0800	[thread overview]
Message-ID: <20191205215241.31283-1-tim.a.kourt@linux.intel.com> (raw)

[-- 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

             reply	other threads:[~2019-12-05 21:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 21:52 Tim Kourt [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191205215241.31283-1-tim.a.kourt@linux.intel.com \
    --to=tim.a.kourt@linux.intel.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.