aboutsummaryrefslogtreecommitdiff
path: root/src/dbus
diff options
context:
space:
mode:
authorZhanglong Xia <zhanglongxia@google.com>2021-10-21 06:10:28 +0800
committerGitHub <noreply@github.com>2021-10-20 15:10:28 -0700
commit92059387fc5bc253cda65a75293d511b58383b38 (patch)
treee80c3774b953655e65dfd7a90dbc096eda0f8de3 /src/dbus
parentae90b332891874df4200cfdf27f082d05a2cf7c7 (diff)
downloadot-br-posix-92059387fc5bc253cda65a75293d511b58383b38.tar.gz
[common] add mainloop manager (#1044)
This commit adds a mainloop manager to manage all mainloop processors. This commit also adds a class `br::vendor::VendorServer` to allow other users to implement their server in otbr-agent.
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/server/dbus_agent.cpp6
-rw-r--r--src/dbus/server/dbus_agent.hpp7
2 files changed, 6 insertions, 7 deletions
diff --git a/src/dbus/server/dbus_agent.cpp b/src/dbus/server/dbus_agent.cpp
index e07143f7..b0aaaee9 100644
--- a/src/dbus/server/dbus_agent.cpp
+++ b/src/dbus/server/dbus_agent.cpp
@@ -38,8 +38,8 @@ namespace DBus {
const struct timeval DBusAgent::kPollTimeout = {0, 0};
-DBusAgent::DBusAgent(const std::string &aInterfaceName, otbr::Ncp::ControllerOpenThread *aNcp)
- : mInterfaceName(aInterfaceName)
+DBusAgent::DBusAgent(otbr::Ncp::ControllerOpenThread &aNcp)
+ : mInterfaceName(aNcp.GetInterfaceName())
, mNcp(aNcp)
{
}
@@ -64,7 +64,7 @@ otbrError DBusAgent::Init(void)
error = OTBR_ERROR_DBUS);
VerifyOrExit(
dbus_connection_set_watch_functions(mConnection.get(), AddDBusWatch, RemoveDBusWatch, nullptr, this, nullptr));
- mThreadObject = std::unique_ptr<DBusThreadObject>(new DBusThreadObject(mConnection.get(), mInterfaceName, mNcp));
+ mThreadObject = std::unique_ptr<DBusThreadObject>(new DBusThreadObject(mConnection.get(), mInterfaceName, &mNcp));
error = mThreadObject->Init();
exit:
if (error != OTBR_ERROR_NONE)
diff --git a/src/dbus/server/dbus_agent.hpp b/src/dbus/server/dbus_agent.hpp
index 83283194..4e349d9a 100644
--- a/src/dbus/server/dbus_agent.hpp
+++ b/src/dbus/server/dbus_agent.hpp
@@ -56,11 +56,10 @@ public:
/**
* The constructor of dbus agent.
*
- * @param[in] aInterfaceName The interface name.
- * @param[in] aNcp The ncp controller.
+ * @param[in] aNcp A reference to the NCP controller.
*
*/
- DBusAgent(const std::string &aInterfaceName, otbr::Ncp::ControllerOpenThread *aNcp);
+ DBusAgent(otbr::Ncp::ControllerOpenThread &aNcp);
/**
* This method initializes the dbus agent.
@@ -96,7 +95,7 @@ private:
std::unique_ptr<DBusThreadObject> mThreadObject;
using UniqueDBusConnection = std::unique_ptr<DBusConnection, std::function<void(DBusConnection *)>>;
UniqueDBusConnection mConnection;
- otbr::Ncp::ControllerOpenThread *mNcp;
+ otbr::Ncp::ControllerOpenThread &mNcp;
/**
* This map is used to track DBusWatch-es.