From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 2/5] client: Add start/stop ops to agent manager proxy
Date: Fri, 08 Nov 2019 11:32:20 -0800 [thread overview]
Message-ID: <20191108193223.1950-2-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20191108193223.1950-1-tim.a.kourt@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2265 bytes --]
This guarantees that the agent gets registered only when the agent
manager interface is available on dbus.
---
client/agent-manager.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/client/agent-manager.c b/client/agent-manager.c
index b7d4271b..fb371ea2 100644
--- a/client/agent-manager.c
+++ b/client/agent-manager.c
@@ -30,6 +30,7 @@
#include "agent.h"
#include "dbus-proxy.h"
#include "agent-manager.h"
+#include "command.h"
#define IWD_AGENT_MANAGER_PATH "/net/connman/iwd"
@@ -39,6 +40,46 @@ static void check_errors_method_callback(struct l_dbus_message *message,
dbus_message_has_error(message);
}
+static bool agent_manager_start(const struct proxy_interface *proxy)
+{
+ const char *path;
+
+ if (command_needs_no_agent())
+ return true;
+
+ path = proxy_interface_get_data(proxy);
+ if (!path)
+ return false;
+
+ if (!agent_init(path))
+ return false;
+
+ proxy_interface_method_call(proxy, "RegisterAgent", "o",
+ check_errors_method_callback, path);
+
+ return true;
+}
+
+static void agent_manager_stop(const struct proxy_interface *proxy)
+{
+ const char *path;
+
+ if (command_needs_no_agent())
+ return;
+
+ if (!proxy)
+ return;
+
+ path = proxy_interface_get_data(proxy);
+ if (!path)
+ return;
+
+ proxy_interface_method_call(proxy, "UnregisterAgent", "o",
+ check_errors_method_callback, path);
+
+ agent_exit(path);
+}
+
bool agent_manager_register_agent(void)
{
const char *path;
@@ -81,25 +122,21 @@ bool agent_manager_unregister_agent(void)
static void *agent_manager_create(void)
{
- char *path = l_strdup_printf("/agent/%i", getpid());
-
- agent_init(path);
-
- return path;
+ return l_strdup_printf("/agent/%i", getpid());
}
static void agent_manager_destroy(void *data)
{
char *path = data;
- agent_exit(path);
-
l_free(path);
}
static const struct proxy_interface_type_ops agent_manager_ops = {
.create = agent_manager_create,
.destroy = agent_manager_destroy,
+ .start = agent_manager_start,
+ .stop = agent_manager_stop,
};
static struct proxy_interface_type agent_manager_interface_type = {
--
2.13.6
next prev parent reply other threads:[~2019-11-08 19:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 19:32 [PATCH 1/5] client: Extend client proxy object's API Tim Kourt
2019-11-08 19:32 ` Tim Kourt [this message]
2019-11-09 3:21 ` [PATCH 2/5] client: Add start/stop ops to agent manager proxy Denis Kenzior
2019-11-08 19:32 ` [PATCH 3/5] client: Remove explicit agent registartion from framework Tim Kourt
2019-11-08 19:32 ` [PATCH 4/5] client: Use full include path for local includes Tim Kourt
2019-11-08 19:32 ` [PATCH 5/5] client: Fail in non-interactive mode if iwd service isn’t running Tim Kourt
2019-11-09 3:22 ` Denis Kenzior
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=20191108193223.1950-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox