mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
feat: notification proxy (#70)
* init
* chore: clippy and fmt
* feat: ffi wrapper
* feat: multi-observe and timeout to notification proxy
* fix: nitpicks
1. proxy death its onw error in emun #69
2. make returned stream actual stream, copied from 54439b85dd/idevice/src/services/bt_packet_logger.rs (L126-L138)
This commit is contained in:
46
cpp/include/idevice++/notification_proxy.hpp
Normal file
46
cpp/include/idevice++/notification_proxy.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <idevice++/bindings.hpp>
|
||||
#include <idevice++/ffi.hpp>
|
||||
#include <idevice++/provider.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
using NotificationProxyPtr = std::unique_ptr<NotificationProxyClientHandle,
|
||||
FnDeleter<NotificationProxyClientHandle, notification_proxy_client_free>>;
|
||||
|
||||
class NotificationProxy {
|
||||
public:
|
||||
// Factory: connect via Provider
|
||||
static Result<NotificationProxy, FfiError> connect(Provider& provider);
|
||||
|
||||
// Factory: wrap an existing Idevice socket (consumes it on success)
|
||||
static Result<NotificationProxy, FfiError> from_socket(Idevice&& socket);
|
||||
|
||||
// Ops
|
||||
Result<void, FfiError> post_notification(const std::string& name);
|
||||
Result<void, FfiError> observe_notification(const std::string& name);
|
||||
Result<void, FfiError> observe_notifications(const std::vector<std::string>& names);
|
||||
Result<std::string, FfiError> receive_notification();
|
||||
Result<std::string, FfiError> receive_notification_with_timeout(u_int64_t interval);
|
||||
|
||||
// RAII / moves
|
||||
~NotificationProxy() noexcept = default;
|
||||
NotificationProxy(NotificationProxy&&) noexcept = default;
|
||||
NotificationProxy& operator=(NotificationProxy&&) noexcept = default;
|
||||
NotificationProxy(const NotificationProxy&) = delete;
|
||||
NotificationProxy& operator=(const NotificationProxy&) = delete;
|
||||
|
||||
NotificationProxyClientHandle* raw() const noexcept { return handle_.get(); }
|
||||
static NotificationProxy adopt(NotificationProxyClientHandle* h) noexcept {
|
||||
return NotificationProxy(h);
|
||||
}
|
||||
|
||||
private:
|
||||
explicit NotificationProxy(NotificationProxyClientHandle* h) noexcept : handle_(h) {}
|
||||
NotificationProxyPtr handle_{};
|
||||
};
|
||||
|
||||
} // namespace IdeviceFFI
|
||||
Reference in New Issue
Block a user