mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
added dbus bindings
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
|
||||
/*
|
||||
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
|
||||
*/
|
||||
|
||||
#ifndef __sdbuscpp___home_lasan_Dev_nearby_latest_sharing_linux_daemon_nearby_sharing_client_h__proxy__H__
|
||||
#define __sdbuscpp___home_lasan_Dev_nearby_latest_sharing_linux_daemon_nearby_sharing_client_h__proxy__H__
|
||||
|
||||
#include <sdbus-c++/sdbus-c++.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
namespace com {
|
||||
namespace google {
|
||||
namespace nearby {
|
||||
|
||||
class sharing_proxy {
|
||||
public:
|
||||
static constexpr const char* INTERFACE_NAME = "com.google.nearby.sharing";
|
||||
|
||||
protected:
|
||||
sharing_proxy(sdbus::IProxy& proxy) : m_proxy(proxy) {}
|
||||
|
||||
sharing_proxy(const sharing_proxy&) = delete;
|
||||
sharing_proxy& operator=(const sharing_proxy&) = delete;
|
||||
sharing_proxy(sharing_proxy&&) = delete;
|
||||
sharing_proxy& operator=(sharing_proxy&&) = delete;
|
||||
|
||||
~sharing_proxy() = default;
|
||||
|
||||
void registerProxy() {
|
||||
m_proxy.uponSignal("TargetDiscovered")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call(
|
||||
[this](const std::map<std::string, sdbus::Variant>& share_target) {
|
||||
this->onTargetDiscovered(share_target);
|
||||
});
|
||||
m_proxy.uponSignal("TargetUpdated")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call(
|
||||
[this](const std::map<std::string, sdbus::Variant>& share_target) {
|
||||
this->onTargetUpdated(share_target);
|
||||
});
|
||||
m_proxy.uponSignal("TargetLost")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call(
|
||||
[this](const std::map<std::string, sdbus::Variant>& share_target) {
|
||||
this->onTargetLost(share_target);
|
||||
});
|
||||
m_proxy.uponSignal("IncomingTransfer")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call([this](const std::string& direction,
|
||||
const std::map<std::string, sdbus::Variant>& share_target,
|
||||
const std::map<std::string, sdbus::Variant>& transfer) {
|
||||
this->onIncomingTransfer(direction, share_target, transfer);
|
||||
});
|
||||
m_proxy.uponSignal("TransferUpdate")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call([this](const std::string& direction,
|
||||
const std::map<std::string, sdbus::Variant>& share_target,
|
||||
const std::map<std::string, sdbus::Variant>& transfer) {
|
||||
this->onTransferUpdate(direction, share_target, transfer);
|
||||
});
|
||||
m_proxy.uponSignal("StatusChanged")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call([this](const std::map<std::string, sdbus::Variant>& status) {
|
||||
this->onStatusChanged(status);
|
||||
});
|
||||
}
|
||||
|
||||
virtual void onTargetDiscovered(
|
||||
const std::map<std::string, sdbus::Variant>& share_target) = 0;
|
||||
virtual void onTargetUpdated(
|
||||
const std::map<std::string, sdbus::Variant>& share_target) = 0;
|
||||
virtual void onTargetLost(
|
||||
const std::map<std::string, sdbus::Variant>& share_target) = 0;
|
||||
virtual void onIncomingTransfer(
|
||||
const std::string& direction,
|
||||
const std::map<std::string, sdbus::Variant>& share_target,
|
||||
const std::map<std::string, sdbus::Variant>& transfer) = 0;
|
||||
virtual void onTransferUpdate(
|
||||
const std::string& direction,
|
||||
const std::map<std::string, sdbus::Variant>& share_target,
|
||||
const std::map<std::string, sdbus::Variant>& transfer) = 0;
|
||||
virtual void onStatusChanged(
|
||||
const std::map<std::string, sdbus::Variant>& status) = 0;
|
||||
|
||||
public:
|
||||
std::tuple<bool, std::string> StartReceive() {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("StartReceive")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> StopReceive() {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("StopReceive")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> StartDiscovery() {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("StartDiscovery")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> StopDiscovery() {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("StopDiscovery")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> SendFile(const int64_t& share_target_id,
|
||||
const std::string& path) {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("SendFile")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target_id, path)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> Accept(const int64_t& share_target_id) {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("Accept")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target_id)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> Reject(const int64_t& share_target_id) {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("Reject")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target_id)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> Cancel(const int64_t& share_target_id) {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("Cancel")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target_id)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<bool, std::string> Shutdown() {
|
||||
std::tuple<bool, std::string> result;
|
||||
m_proxy.callMethod("Shutdown")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace google
|
||||
} // namespace com
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<node name="/com/google/nearby/sharing">
|
||||
<!--
|
||||
D-Bus contract for the Linux Nearby Sharing daemon.
|
||||
|
||||
The daemon internally exposes a socket-based JSON IPC model with:
|
||||
- commands: start_receive, stop_receive, start_discovery,
|
||||
stop_discovery, send_file, accept, reject, cancel, shutdown
|
||||
- events: target_discovered, target_updated, target_lost,
|
||||
incoming_transfer, transfer_update, status_changed
|
||||
|
||||
This interface preserves that surface with typed D-Bus methods and
|
||||
signals. Flexible payloads that were JSON objects are represented as
|
||||
a{sv} dictionaries so the daemon can expose the same field set without
|
||||
forcing a brittle fixed struct encoding for optional values.
|
||||
|
||||
Common dictionary payloads:
|
||||
- share_target a{sv}
|
||||
id x
|
||||
device_name s
|
||||
type i
|
||||
is_incoming b
|
||||
is_known b
|
||||
device_id s
|
||||
for_self_share b
|
||||
vendor_id i
|
||||
receive_disabled b
|
||||
- transfer a{sv}
|
||||
status s
|
||||
progress i
|
||||
transferred_bytes x
|
||||
total_bytes x
|
||||
transfer_speed x
|
||||
estimated_time_remaining x
|
||||
total_attachments_count i
|
||||
transferred_attachments_count i
|
||||
is_final_status b
|
||||
is_self_share b
|
||||
binding_id s
|
||||
token s (optional)
|
||||
in_progress_attachment_id x (optional)
|
||||
in_progress_attachment_transferred_bytes x (optional)
|
||||
in_progress_attachment_total_bytes x (optional)
|
||||
- status a{sv}
|
||||
receive_registered b
|
||||
discovery_registered b
|
||||
is_transferring b
|
||||
is_scanning b
|
||||
bluetooth_present b
|
||||
bluetooth_powered b
|
||||
lan_connected b
|
||||
targets aa{sv}
|
||||
-->
|
||||
<interface name="com.google.nearby.sharing">
|
||||
<method name="StartReceive">
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="StopReceive">
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="StartDiscovery">
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="StopDiscovery">
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="SendFile">
|
||||
<arg name="share_target_id" type="x" direction="in"/>
|
||||
<arg name="path" type="s" direction="in"/>
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="Accept">
|
||||
<arg name="share_target_id" type="x" direction="in"/>
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="Reject">
|
||||
<arg name="share_target_id" type="x" direction="in"/>
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="Cancel">
|
||||
<arg name="share_target_id" type="x" direction="in"/>
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="Shutdown">
|
||||
<arg name="ok" type="b" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<signal name="TargetDiscovered">
|
||||
<arg name="share_target" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
<signal name="TargetUpdated">
|
||||
<arg name="share_target" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
<signal name="TargetLost">
|
||||
<arg name="share_target" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
<signal name="IncomingTransfer">
|
||||
<arg name="direction" type="s"/>
|
||||
<arg name="share_target" type="a{sv}"/>
|
||||
<arg name="transfer" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
<signal name="TransferUpdate">
|
||||
<arg name="direction" type="s"/>
|
||||
<arg name="share_target" type="a{sv}"/>
|
||||
<arg name="transfer" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
<signal name="StatusChanged">
|
||||
<arg name="status" type="a{sv}"/>
|
||||
</signal>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -0,0 +1,168 @@
|
||||
|
||||
/*
|
||||
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
|
||||
*/
|
||||
|
||||
#ifndef __sdbuscpp___home_lasan_Dev_nearby_latest_sharing_linux_daemon_nearby_sharing_server_h__adaptor__H__
|
||||
#define __sdbuscpp___home_lasan_Dev_nearby_latest_sharing_linux_daemon_nearby_sharing_server_h__adaptor__H__
|
||||
|
||||
#include <sdbus-c++/sdbus-c++.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
namespace com {
|
||||
namespace google {
|
||||
namespace nearby {
|
||||
|
||||
class sharing_adaptor {
|
||||
public:
|
||||
static constexpr const char* INTERFACE_NAME = "com.google.nearby.sharing";
|
||||
|
||||
protected:
|
||||
sharing_adaptor(sdbus::IObject& object) : m_object(object) {}
|
||||
|
||||
sharing_adaptor(const sharing_adaptor&) = delete;
|
||||
sharing_adaptor& operator=(const sharing_adaptor&) = delete;
|
||||
sharing_adaptor(sharing_adaptor&&) = delete;
|
||||
sharing_adaptor& operator=(sharing_adaptor&&) = delete;
|
||||
|
||||
~sharing_adaptor() = default;
|
||||
|
||||
void registerAdaptor() {
|
||||
m_object
|
||||
.addVTable(
|
||||
sdbus::registerMethod("StartReceive")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this]() { return this->StartReceive(); }),
|
||||
sdbus::registerMethod("StopReceive")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this]() { return this->StopReceive(); }),
|
||||
sdbus::registerMethod("StartDiscovery")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this]() { return this->StartDiscovery(); }),
|
||||
sdbus::registerMethod("StopDiscovery")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this]() { return this->StopDiscovery(); }),
|
||||
sdbus::registerMethod("SendFile")
|
||||
.withInputParamNames("share_target_id", "path")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this](const int64_t& share_target_id,
|
||||
const std::string& path) {
|
||||
return this->SendFile(share_target_id, path);
|
||||
}),
|
||||
sdbus::registerMethod("Accept")
|
||||
.withInputParamNames("share_target_id")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this](const int64_t& share_target_id) {
|
||||
return this->Accept(share_target_id);
|
||||
}),
|
||||
sdbus::registerMethod("Reject")
|
||||
.withInputParamNames("share_target_id")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this](const int64_t& share_target_id) {
|
||||
return this->Reject(share_target_id);
|
||||
}),
|
||||
sdbus::registerMethod("Cancel")
|
||||
.withInputParamNames("share_target_id")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this](const int64_t& share_target_id) {
|
||||
return this->Cancel(share_target_id);
|
||||
}),
|
||||
sdbus::registerMethod("Shutdown")
|
||||
.withOutputParamNames("ok", "message")
|
||||
.implementedAs([this]() { return this->Shutdown(); }),
|
||||
sdbus::registerSignal("TargetDiscovered")
|
||||
.withParameters<std::map<std::string, sdbus::Variant>>(
|
||||
"share_target"),
|
||||
sdbus::registerSignal("TargetUpdated")
|
||||
.withParameters<std::map<std::string, sdbus::Variant>>(
|
||||
"share_target"),
|
||||
sdbus::registerSignal("TargetLost")
|
||||
.withParameters<std::map<std::string, sdbus::Variant>>(
|
||||
"share_target"),
|
||||
sdbus::registerSignal("IncomingTransfer")
|
||||
.withParameters<std::string,
|
||||
std::map<std::string, sdbus::Variant>,
|
||||
std::map<std::string, sdbus::Variant>>(
|
||||
"direction", "share_target", "transfer"),
|
||||
sdbus::registerSignal("TransferUpdate")
|
||||
.withParameters<std::string,
|
||||
std::map<std::string, sdbus::Variant>,
|
||||
std::map<std::string, sdbus::Variant>>(
|
||||
"direction", "share_target", "transfer"),
|
||||
sdbus::registerSignal("StatusChanged")
|
||||
.withParameters<std::map<std::string, sdbus::Variant>>(
|
||||
"status"))
|
||||
.forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void emitTargetDiscovered(
|
||||
const std::map<std::string, sdbus::Variant>& share_target) {
|
||||
m_object.emitSignal("TargetDiscovered")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target);
|
||||
}
|
||||
|
||||
void emitTargetUpdated(
|
||||
const std::map<std::string, sdbus::Variant>& share_target) {
|
||||
m_object.emitSignal("TargetUpdated")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target);
|
||||
}
|
||||
|
||||
void emitTargetLost(
|
||||
const std::map<std::string, sdbus::Variant>& share_target) {
|
||||
m_object.emitSignal("TargetLost")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(share_target);
|
||||
}
|
||||
|
||||
void emitIncomingTransfer(
|
||||
const std::string& direction,
|
||||
const std::map<std::string, sdbus::Variant>& share_target,
|
||||
const std::map<std::string, sdbus::Variant>& transfer) {
|
||||
m_object.emitSignal("IncomingTransfer")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(direction, share_target, transfer);
|
||||
}
|
||||
|
||||
void emitTransferUpdate(
|
||||
const std::string& direction,
|
||||
const std::map<std::string, sdbus::Variant>& share_target,
|
||||
const std::map<std::string, sdbus::Variant>& transfer) {
|
||||
m_object.emitSignal("TransferUpdate")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(direction, share_target, transfer);
|
||||
}
|
||||
|
||||
void emitStatusChanged(const std::map<std::string, sdbus::Variant>& status) {
|
||||
m_object.emitSignal("StatusChanged")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.withArguments(status);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual std::tuple<bool, std::string> StartReceive() = 0;
|
||||
virtual std::tuple<bool, std::string> StopReceive() = 0;
|
||||
virtual std::tuple<bool, std::string> StartDiscovery() = 0;
|
||||
virtual std::tuple<bool, std::string> StopDiscovery() = 0;
|
||||
virtual std::tuple<bool, std::string> SendFile(const int64_t& share_target_id,
|
||||
const std::string& path) = 0;
|
||||
virtual std::tuple<bool, std::string> Accept(
|
||||
const int64_t& share_target_id) = 0;
|
||||
virtual std::tuple<bool, std::string> Reject(
|
||||
const int64_t& share_target_id) = 0;
|
||||
virtual std::tuple<bool, std::string> Cancel(
|
||||
const int64_t& share_target_id) = 0;
|
||||
virtual std::tuple<bool, std::string> Shutdown() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace google
|
||||
} // namespace com
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user